@codingame/monaco-vscode-npm-default-extension 1.85.1 → 1.85.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.
- package/index.js +9 -5
- package/package.json +2 -2
- package/resources/README.md +42 -0
- package/resources/code.svg +3 -0
- package/resources/npmBrowserMain.js +2 -0
- package/resources/npmBrowserMain.js.map +1 -0
- package/resources/npm_icon.png +0 -0
- package/resources/package.json +1 -0
- package/resources/package.nls.json +1 -0
- package/npmBrowserMain.js +0 -3345
- package/npmBrowserMain.js.map +0 -1
- package/package.nls.json +0 -33
package/npmBrowserMain.js
DELETED
|
@@ -1,3345 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ var __webpack_modules__ = ([
|
|
3
|
-
/* 0 */,
|
|
4
|
-
/* 1 */
|
|
5
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
6
|
-
|
|
7
|
-
(()=>{"use strict";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.getErrorStatusDescription=r.xhr=r.configure=void 0,r.configure=(e,r)=>{},r.xhr=async e=>{const r=new Headers;if(e.headers)for(const t in e.headers){const o=e.headers[t];Array.isArray(o)?o.forEach((e=>r.set(t,e))):r.set(t,o)}e.user&&e.password&&r.set("Authorization","Basic "+btoa(e.user+":"+e.password));const t={method:e.type,redirect:e.followRedirects>0?"follow":"manual",mode:"cors",headers:r};if(e.data&&(t.body=e.data),e.token){const r=new AbortController;e.token.isCancellationRequested&&r.abort(),e.token.onCancellationRequested((()=>{r.abort()})),t.signal=r.signal}const o=new Request(e.url,t),s=await fetch(o),a={};s.headers.forEach(((e,r)=>{a[r]=e}));const n=await s.arrayBuffer();return new class{constructor(){this.status=s.status,this.headers=a}get responseText(){return(new TextDecoder).decode(n)}get body(){return new Uint8Array(n)}}},r.getErrorStatusDescription=function(e){return String(e)}})();var r=exports;for(var t in e)r[t]=e[t];e.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
8
|
-
|
|
9
|
-
/***/ }),
|
|
10
|
-
/* 2 */
|
|
11
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
12
|
-
|
|
13
|
-
"use strict";
|
|
14
|
-
|
|
15
|
-
/*---------------------------------------------------------------------------------------------
|
|
16
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
17
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
18
|
-
*--------------------------------------------------------------------------------------------*/
|
|
19
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20
|
-
exports.xhrDisabled = exports.JSONCompletionItemProvider = exports.JSONHoverProvider = exports.addJSONProviders = void 0;
|
|
21
|
-
const jsonc_parser_1 = __webpack_require__(3);
|
|
22
|
-
const bowerJSONContribution_1 = __webpack_require__(8);
|
|
23
|
-
const packageJSONContribution_1 = __webpack_require__(10);
|
|
24
|
-
const vscode_1 = __webpack_require__(9);
|
|
25
|
-
function addJSONProviders(xhr, npmCommandPath) {
|
|
26
|
-
const contributions = [new packageJSONContribution_1.PackageJSONContribution(xhr, npmCommandPath), new bowerJSONContribution_1.BowerJSONContribution(xhr)];
|
|
27
|
-
const subscriptions = [];
|
|
28
|
-
contributions.forEach(contribution => {
|
|
29
|
-
const selector = contribution.getDocumentSelector();
|
|
30
|
-
subscriptions.push(vscode_1.languages.registerCompletionItemProvider(selector, new JSONCompletionItemProvider(contribution), '"', ':'));
|
|
31
|
-
subscriptions.push(vscode_1.languages.registerHoverProvider(selector, new JSONHoverProvider(contribution)));
|
|
32
|
-
});
|
|
33
|
-
return vscode_1.Disposable.from(...subscriptions);
|
|
34
|
-
}
|
|
35
|
-
exports.addJSONProviders = addJSONProviders;
|
|
36
|
-
class JSONHoverProvider {
|
|
37
|
-
constructor(jsonContribution) {
|
|
38
|
-
this.jsonContribution = jsonContribution;
|
|
39
|
-
}
|
|
40
|
-
provideHover(document, position, _token) {
|
|
41
|
-
const offset = document.offsetAt(position);
|
|
42
|
-
const location = (0, jsonc_parser_1.getLocation)(document.getText(), offset);
|
|
43
|
-
if (!location.previousNode) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const node = location.previousNode;
|
|
47
|
-
if (node && node.offset <= offset && offset <= node.offset + node.length) {
|
|
48
|
-
const promise = this.jsonContribution.getInfoContribution(document.uri, location);
|
|
49
|
-
if (promise) {
|
|
50
|
-
return promise.then(htmlContent => {
|
|
51
|
-
const range = new vscode_1.Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
52
|
-
const result = {
|
|
53
|
-
contents: htmlContent || [],
|
|
54
|
-
range: range
|
|
55
|
-
};
|
|
56
|
-
return result;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.JSONHoverProvider = JSONHoverProvider;
|
|
64
|
-
class JSONCompletionItemProvider {
|
|
65
|
-
constructor(jsonContribution) {
|
|
66
|
-
this.jsonContribution = jsonContribution;
|
|
67
|
-
}
|
|
68
|
-
resolveCompletionItem(item, _token) {
|
|
69
|
-
if (this.jsonContribution.resolveSuggestion) {
|
|
70
|
-
const resolver = this.jsonContribution.resolveSuggestion(this.lastResource, item);
|
|
71
|
-
if (resolver) {
|
|
72
|
-
return resolver;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return Promise.resolve(item);
|
|
76
|
-
}
|
|
77
|
-
provideCompletionItems(document, position, _token) {
|
|
78
|
-
this.lastResource = document.uri;
|
|
79
|
-
const currentWord = this.getCurrentWord(document, position);
|
|
80
|
-
let overwriteRange;
|
|
81
|
-
const items = [];
|
|
82
|
-
let isIncomplete = false;
|
|
83
|
-
const offset = document.offsetAt(position);
|
|
84
|
-
const location = (0, jsonc_parser_1.getLocation)(document.getText(), offset);
|
|
85
|
-
const node = location.previousNode;
|
|
86
|
-
if (node && node.offset <= offset && offset <= node.offset + node.length && (node.type === 'property' || node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
|
|
87
|
-
overwriteRange = new vscode_1.Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
overwriteRange = new vscode_1.Range(document.positionAt(offset - currentWord.length), position);
|
|
91
|
-
}
|
|
92
|
-
const proposed = {};
|
|
93
|
-
const collector = {
|
|
94
|
-
add: (suggestion) => {
|
|
95
|
-
const key = typeof suggestion.label === 'string'
|
|
96
|
-
? suggestion.label
|
|
97
|
-
: suggestion.label.label;
|
|
98
|
-
if (!proposed[key]) {
|
|
99
|
-
proposed[key] = true;
|
|
100
|
-
suggestion.range = { replacing: overwriteRange, inserting: new vscode_1.Range(overwriteRange.start, overwriteRange.start) };
|
|
101
|
-
items.push(suggestion);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
setAsIncomplete: () => isIncomplete = true,
|
|
105
|
-
error: (message) => console.error(message),
|
|
106
|
-
log: (message) => console.log(message)
|
|
107
|
-
};
|
|
108
|
-
let collectPromise = null;
|
|
109
|
-
if (location.isAtPropertyKey) {
|
|
110
|
-
const scanner = (0, jsonc_parser_1.createScanner)(document.getText(), true);
|
|
111
|
-
const addValue = !location.previousNode || !this.hasColonAfter(scanner, location.previousNode.offset + location.previousNode.length);
|
|
112
|
-
const isLast = this.isLast(scanner, document.offsetAt(position));
|
|
113
|
-
collectPromise = this.jsonContribution.collectPropertySuggestions(document.uri, location, currentWord, addValue, isLast, collector);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
if (location.path.length === 0) {
|
|
117
|
-
collectPromise = this.jsonContribution.collectDefaultSuggestions(document.uri, collector);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
collectPromise = this.jsonContribution.collectValueSuggestions(document.uri, location, collector);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (collectPromise) {
|
|
124
|
-
return collectPromise.then(() => {
|
|
125
|
-
if (items.length > 0 || isIncomplete) {
|
|
126
|
-
return new vscode_1.CompletionList(items, isIncomplete);
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
getCurrentWord(document, position) {
|
|
134
|
-
let i = position.character - 1;
|
|
135
|
-
const text = document.lineAt(position.line).text;
|
|
136
|
-
while (i >= 0 && ' \t\n\r\v":{[,'.indexOf(text.charAt(i)) === -1) {
|
|
137
|
-
i--;
|
|
138
|
-
}
|
|
139
|
-
return text.substring(i + 1, position.character);
|
|
140
|
-
}
|
|
141
|
-
isLast(scanner, offset) {
|
|
142
|
-
scanner.setPosition(offset);
|
|
143
|
-
let nextToken = scanner.scan();
|
|
144
|
-
if (nextToken === 10 /* SyntaxKind.StringLiteral */ && scanner.getTokenError() === 2 /* ScanError.UnexpectedEndOfString */) {
|
|
145
|
-
nextToken = scanner.scan();
|
|
146
|
-
}
|
|
147
|
-
return nextToken === 2 /* SyntaxKind.CloseBraceToken */ || nextToken === 17 /* SyntaxKind.EOF */;
|
|
148
|
-
}
|
|
149
|
-
hasColonAfter(scanner, offset) {
|
|
150
|
-
scanner.setPosition(offset);
|
|
151
|
-
return scanner.scan() === 6 /* SyntaxKind.ColonToken */;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.JSONCompletionItemProvider = JSONCompletionItemProvider;
|
|
155
|
-
const xhrDisabled = () => Promise.reject({ responseText: 'Use of online resources is disabled.' });
|
|
156
|
-
exports.xhrDisabled = xhrDisabled;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
/***/ }),
|
|
160
|
-
/* 3 */
|
|
161
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
162
|
-
|
|
163
|
-
"use strict";
|
|
164
|
-
__webpack_require__.r(__webpack_exports__);
|
|
165
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
166
|
-
/* harmony export */ "ParseErrorCode": () => (/* binding */ ParseErrorCode),
|
|
167
|
-
/* harmony export */ "ScanError": () => (/* binding */ ScanError),
|
|
168
|
-
/* harmony export */ "SyntaxKind": () => (/* binding */ SyntaxKind),
|
|
169
|
-
/* harmony export */ "applyEdits": () => (/* binding */ applyEdits),
|
|
170
|
-
/* harmony export */ "createScanner": () => (/* binding */ createScanner),
|
|
171
|
-
/* harmony export */ "findNodeAtLocation": () => (/* binding */ findNodeAtLocation),
|
|
172
|
-
/* harmony export */ "findNodeAtOffset": () => (/* binding */ findNodeAtOffset),
|
|
173
|
-
/* harmony export */ "format": () => (/* binding */ format),
|
|
174
|
-
/* harmony export */ "getLocation": () => (/* binding */ getLocation),
|
|
175
|
-
/* harmony export */ "getNodePath": () => (/* binding */ getNodePath),
|
|
176
|
-
/* harmony export */ "getNodeValue": () => (/* binding */ getNodeValue),
|
|
177
|
-
/* harmony export */ "modify": () => (/* binding */ modify),
|
|
178
|
-
/* harmony export */ "parse": () => (/* binding */ parse),
|
|
179
|
-
/* harmony export */ "parseTree": () => (/* binding */ parseTree),
|
|
180
|
-
/* harmony export */ "printParseErrorCode": () => (/* binding */ printParseErrorCode),
|
|
181
|
-
/* harmony export */ "stripComments": () => (/* binding */ stripComments),
|
|
182
|
-
/* harmony export */ "visit": () => (/* binding */ visit)
|
|
183
|
-
/* harmony export */ });
|
|
184
|
-
/* harmony import */ var _impl_format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
185
|
-
/* harmony import */ var _impl_edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
|
|
186
|
-
/* harmony import */ var _impl_scanner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
|
|
187
|
-
/* harmony import */ var _impl_parser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7);
|
|
188
|
-
/*---------------------------------------------------------------------------------------------
|
|
189
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
190
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
191
|
-
*--------------------------------------------------------------------------------------------*/
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Creates a JSON scanner on the given text.
|
|
199
|
-
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
|
200
|
-
*/
|
|
201
|
-
const createScanner = _impl_scanner__WEBPACK_IMPORTED_MODULE_2__.createScanner;
|
|
202
|
-
var ScanError;
|
|
203
|
-
(function (ScanError) {
|
|
204
|
-
ScanError[ScanError["None"] = 0] = "None";
|
|
205
|
-
ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
206
|
-
ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
207
|
-
ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
208
|
-
ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
209
|
-
ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
210
|
-
ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
211
|
-
})(ScanError || (ScanError = {}));
|
|
212
|
-
var SyntaxKind;
|
|
213
|
-
(function (SyntaxKind) {
|
|
214
|
-
SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
215
|
-
SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
216
|
-
SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
217
|
-
SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
218
|
-
SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
|
|
219
|
-
SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
|
|
220
|
-
SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
|
|
221
|
-
SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
|
|
222
|
-
SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
|
|
223
|
-
SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
|
|
224
|
-
SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
|
|
225
|
-
SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
226
|
-
SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
227
|
-
SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
228
|
-
SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
|
|
229
|
-
SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
|
|
230
|
-
SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
|
|
231
|
-
})(SyntaxKind || (SyntaxKind = {}));
|
|
232
|
-
/**
|
|
233
|
-
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
|
234
|
-
*/
|
|
235
|
-
const getLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getLocation;
|
|
236
|
-
/**
|
|
237
|
-
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
238
|
-
* Therefore, always check the errors list to find out if the input was valid.
|
|
239
|
-
*/
|
|
240
|
-
const parse = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parse;
|
|
241
|
-
/**
|
|
242
|
-
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
243
|
-
*/
|
|
244
|
-
const parseTree = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parseTree;
|
|
245
|
-
/**
|
|
246
|
-
* Finds the node at the given path in a JSON DOM.
|
|
247
|
-
*/
|
|
248
|
-
const findNodeAtLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtLocation;
|
|
249
|
-
/**
|
|
250
|
-
* Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
|
251
|
-
*/
|
|
252
|
-
const findNodeAtOffset = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtOffset;
|
|
253
|
-
/**
|
|
254
|
-
* Gets the JSON path of the given JSON DOM node
|
|
255
|
-
*/
|
|
256
|
-
const getNodePath = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodePath;
|
|
257
|
-
/**
|
|
258
|
-
* Evaluates the JavaScript object of the given JSON DOM node
|
|
259
|
-
*/
|
|
260
|
-
const getNodeValue = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodeValue;
|
|
261
|
-
/**
|
|
262
|
-
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
263
|
-
*/
|
|
264
|
-
const visit = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.visit;
|
|
265
|
-
/**
|
|
266
|
-
* Takes JSON with JavaScript-style comments and remove
|
|
267
|
-
* them. Optionally replaces every none-newline character
|
|
268
|
-
* of comments with a replaceCharacter
|
|
269
|
-
*/
|
|
270
|
-
const stripComments = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.stripComments;
|
|
271
|
-
var ParseErrorCode;
|
|
272
|
-
(function (ParseErrorCode) {
|
|
273
|
-
ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
274
|
-
ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
275
|
-
ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
276
|
-
ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
|
|
277
|
-
ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
|
|
278
|
-
ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
|
|
279
|
-
ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
280
|
-
ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
281
|
-
ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
282
|
-
ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
283
|
-
ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
284
|
-
ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
285
|
-
ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
286
|
-
ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
287
|
-
ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
288
|
-
ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
289
|
-
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
290
|
-
function printParseErrorCode(code) {
|
|
291
|
-
switch (code) {
|
|
292
|
-
case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';
|
|
293
|
-
case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';
|
|
294
|
-
case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';
|
|
295
|
-
case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';
|
|
296
|
-
case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';
|
|
297
|
-
case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';
|
|
298
|
-
case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';
|
|
299
|
-
case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';
|
|
300
|
-
case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';
|
|
301
|
-
case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';
|
|
302
|
-
case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
|
|
303
|
-
case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';
|
|
304
|
-
case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
|
|
305
|
-
case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';
|
|
306
|
-
case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
|
|
307
|
-
case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';
|
|
308
|
-
}
|
|
309
|
-
return '<unknown ParseErrorCode>';
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Computes the edit operations needed to format a JSON document.
|
|
313
|
-
*
|
|
314
|
-
* @param documentText The input text
|
|
315
|
-
* @param range The range to format or `undefined` to format the full content
|
|
316
|
-
* @param options The formatting options
|
|
317
|
-
* @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
|
|
318
|
-
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
|
319
|
-
*/
|
|
320
|
-
function format(documentText, range, options) {
|
|
321
|
-
return _impl_format__WEBPACK_IMPORTED_MODULE_0__.format(documentText, range, options);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Computes the edit operations needed to modify a value in the JSON document.
|
|
325
|
-
*
|
|
326
|
-
* @param documentText The input text
|
|
327
|
-
* @param path The path of the value to change. The path represents either to the document root, a property or an array item.
|
|
328
|
-
* If the path points to an non-existing property or item, it will be created.
|
|
329
|
-
* @param value The new value for the specified property or item. If the value is undefined,
|
|
330
|
-
* the property or item will be removed.
|
|
331
|
-
* @param options Options
|
|
332
|
-
* @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
|
|
333
|
-
* To apply the edit operations to the input, use {@linkcode applyEdits}.
|
|
334
|
-
*/
|
|
335
|
-
function modify(text, path, value, options) {
|
|
336
|
-
return _impl_edit__WEBPACK_IMPORTED_MODULE_1__.setProperty(text, path, value, options);
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Applies edits to an input string.
|
|
340
|
-
* @param text The input text
|
|
341
|
-
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
|
342
|
-
* @returns The text with the applied edits.
|
|
343
|
-
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
|
344
|
-
*/
|
|
345
|
-
function applyEdits(text, edits) {
|
|
346
|
-
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
347
|
-
const diff = a.offset - b.offset;
|
|
348
|
-
if (diff === 0) {
|
|
349
|
-
return a.length - b.length;
|
|
350
|
-
}
|
|
351
|
-
return diff;
|
|
352
|
-
});
|
|
353
|
-
let lastModifiedOffset = text.length;
|
|
354
|
-
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
355
|
-
let e = sortedEdits[i];
|
|
356
|
-
if (e.offset + e.length <= lastModifiedOffset) {
|
|
357
|
-
text = _impl_edit__WEBPACK_IMPORTED_MODULE_1__.applyEdit(text, e);
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
throw new Error('Overlapping edit');
|
|
361
|
-
}
|
|
362
|
-
lastModifiedOffset = e.offset;
|
|
363
|
-
}
|
|
364
|
-
return text;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
/***/ }),
|
|
369
|
-
/* 4 */
|
|
370
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
371
|
-
|
|
372
|
-
"use strict";
|
|
373
|
-
__webpack_require__.r(__webpack_exports__);
|
|
374
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
375
|
-
/* harmony export */ "format": () => (/* binding */ format),
|
|
376
|
-
/* harmony export */ "isEOL": () => (/* binding */ isEOL)
|
|
377
|
-
/* harmony export */ });
|
|
378
|
-
/* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
379
|
-
/*---------------------------------------------------------------------------------------------
|
|
380
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
381
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
382
|
-
*--------------------------------------------------------------------------------------------*/
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
function format(documentText, range, options) {
|
|
386
|
-
let initialIndentLevel;
|
|
387
|
-
let formatText;
|
|
388
|
-
let formatTextStart;
|
|
389
|
-
let rangeStart;
|
|
390
|
-
let rangeEnd;
|
|
391
|
-
if (range) {
|
|
392
|
-
rangeStart = range.offset;
|
|
393
|
-
rangeEnd = rangeStart + range.length;
|
|
394
|
-
formatTextStart = rangeStart;
|
|
395
|
-
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
396
|
-
formatTextStart--;
|
|
397
|
-
}
|
|
398
|
-
let endOffset = rangeEnd;
|
|
399
|
-
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
400
|
-
endOffset++;
|
|
401
|
-
}
|
|
402
|
-
formatText = documentText.substring(formatTextStart, endOffset);
|
|
403
|
-
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
formatText = documentText;
|
|
407
|
-
initialIndentLevel = 0;
|
|
408
|
-
formatTextStart = 0;
|
|
409
|
-
rangeStart = 0;
|
|
410
|
-
rangeEnd = documentText.length;
|
|
411
|
-
}
|
|
412
|
-
const eol = getEOL(options, documentText);
|
|
413
|
-
let numberLineBreaks = 0;
|
|
414
|
-
let indentLevel = 0;
|
|
415
|
-
let indentValue;
|
|
416
|
-
if (options.insertSpaces) {
|
|
417
|
-
indentValue = repeat(' ', options.tabSize || 4);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
indentValue = '\t';
|
|
421
|
-
}
|
|
422
|
-
let scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(formatText, false);
|
|
423
|
-
let hasError = false;
|
|
424
|
-
function newLinesAndIndent() {
|
|
425
|
-
if (numberLineBreaks > 1) {
|
|
426
|
-
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
function scanNext() {
|
|
433
|
-
let token = scanner.scan();
|
|
434
|
-
numberLineBreaks = 0;
|
|
435
|
-
while (token === 15 /* SyntaxKind.Trivia */ || token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
|
436
|
-
if (token === 14 /* SyntaxKind.LineBreakTrivia */ && options.keepLines) {
|
|
437
|
-
numberLineBreaks += 1;
|
|
438
|
-
}
|
|
439
|
-
else if (token === 14 /* SyntaxKind.LineBreakTrivia */) {
|
|
440
|
-
numberLineBreaks = 1;
|
|
441
|
-
}
|
|
442
|
-
token = scanner.scan();
|
|
443
|
-
}
|
|
444
|
-
hasError = token === 16 /* SyntaxKind.Unknown */ || scanner.getTokenError() !== 0 /* ScanError.None */;
|
|
445
|
-
return token;
|
|
446
|
-
}
|
|
447
|
-
const editOperations = [];
|
|
448
|
-
function addEdit(text, startOffset, endOffset) {
|
|
449
|
-
if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) {
|
|
450
|
-
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
let firstToken = scanNext();
|
|
454
|
-
if (options.keepLines && numberLineBreaks > 0) {
|
|
455
|
-
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
|
456
|
-
}
|
|
457
|
-
if (firstToken !== 17 /* SyntaxKind.EOF */) {
|
|
458
|
-
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
459
|
-
let initialIndent = repeat(indentValue, initialIndentLevel);
|
|
460
|
-
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
461
|
-
}
|
|
462
|
-
while (firstToken !== 17 /* SyntaxKind.EOF */) {
|
|
463
|
-
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
464
|
-
let secondToken = scanNext();
|
|
465
|
-
let replaceContent = '';
|
|
466
|
-
let needsLineBreak = false;
|
|
467
|
-
while (numberLineBreaks === 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
|
468
|
-
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
469
|
-
addEdit(' ', firstTokenEnd, commentTokenStart);
|
|
470
|
-
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
471
|
-
needsLineBreak = secondToken === 12 /* SyntaxKind.LineCommentTrivia */;
|
|
472
|
-
replaceContent = needsLineBreak ? newLinesAndIndent() : '';
|
|
473
|
-
secondToken = scanNext();
|
|
474
|
-
}
|
|
475
|
-
if (secondToken === 2 /* SyntaxKind.CloseBraceToken */) {
|
|
476
|
-
if (firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
|
477
|
-
indentLevel--;
|
|
478
|
-
}
|
|
479
|
-
;
|
|
480
|
-
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
|
|
481
|
-
replaceContent = newLinesAndIndent();
|
|
482
|
-
}
|
|
483
|
-
else if (options.keepLines) {
|
|
484
|
-
replaceContent = ' ';
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
else if (secondToken === 4 /* SyntaxKind.CloseBracketToken */) {
|
|
488
|
-
if (firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
|
489
|
-
indentLevel--;
|
|
490
|
-
}
|
|
491
|
-
;
|
|
492
|
-
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
|
|
493
|
-
replaceContent = newLinesAndIndent();
|
|
494
|
-
}
|
|
495
|
-
else if (options.keepLines) {
|
|
496
|
-
replaceContent = ' ';
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
switch (firstToken) {
|
|
501
|
-
case 3 /* SyntaxKind.OpenBracketToken */:
|
|
502
|
-
case 1 /* SyntaxKind.OpenBraceToken */:
|
|
503
|
-
indentLevel++;
|
|
504
|
-
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
505
|
-
replaceContent = newLinesAndIndent();
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
replaceContent = ' ';
|
|
509
|
-
}
|
|
510
|
-
break;
|
|
511
|
-
case 5 /* SyntaxKind.CommaToken */:
|
|
512
|
-
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
513
|
-
replaceContent = newLinesAndIndent();
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
replaceContent = ' ';
|
|
517
|
-
}
|
|
518
|
-
break;
|
|
519
|
-
case 12 /* SyntaxKind.LineCommentTrivia */:
|
|
520
|
-
replaceContent = newLinesAndIndent();
|
|
521
|
-
break;
|
|
522
|
-
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
|
523
|
-
if (numberLineBreaks > 0) {
|
|
524
|
-
replaceContent = newLinesAndIndent();
|
|
525
|
-
}
|
|
526
|
-
else if (!needsLineBreak) {
|
|
527
|
-
replaceContent = ' ';
|
|
528
|
-
}
|
|
529
|
-
break;
|
|
530
|
-
case 6 /* SyntaxKind.ColonToken */:
|
|
531
|
-
if (options.keepLines && numberLineBreaks > 0) {
|
|
532
|
-
replaceContent = newLinesAndIndent();
|
|
533
|
-
}
|
|
534
|
-
else if (!needsLineBreak) {
|
|
535
|
-
replaceContent = ' ';
|
|
536
|
-
}
|
|
537
|
-
break;
|
|
538
|
-
case 10 /* SyntaxKind.StringLiteral */:
|
|
539
|
-
if (options.keepLines && numberLineBreaks > 0) {
|
|
540
|
-
replaceContent = newLinesAndIndent();
|
|
541
|
-
}
|
|
542
|
-
else if (secondToken === 6 /* SyntaxKind.ColonToken */ && !needsLineBreak) {
|
|
543
|
-
replaceContent = '';
|
|
544
|
-
}
|
|
545
|
-
break;
|
|
546
|
-
case 7 /* SyntaxKind.NullKeyword */:
|
|
547
|
-
case 8 /* SyntaxKind.TrueKeyword */:
|
|
548
|
-
case 9 /* SyntaxKind.FalseKeyword */:
|
|
549
|
-
case 11 /* SyntaxKind.NumericLiteral */:
|
|
550
|
-
case 2 /* SyntaxKind.CloseBraceToken */:
|
|
551
|
-
case 4 /* SyntaxKind.CloseBracketToken */:
|
|
552
|
-
if (options.keepLines && numberLineBreaks > 0) {
|
|
553
|
-
replaceContent = newLinesAndIndent();
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
if ((secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */) && !needsLineBreak) {
|
|
557
|
-
replaceContent = ' ';
|
|
558
|
-
}
|
|
559
|
-
else if (secondToken !== 5 /* SyntaxKind.CommaToken */ && secondToken !== 17 /* SyntaxKind.EOF */) {
|
|
560
|
-
hasError = true;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
break;
|
|
564
|
-
case 16 /* SyntaxKind.Unknown */:
|
|
565
|
-
hasError = true;
|
|
566
|
-
break;
|
|
567
|
-
}
|
|
568
|
-
if (numberLineBreaks > 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
|
|
569
|
-
replaceContent = newLinesAndIndent();
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
if (secondToken === 17 /* SyntaxKind.EOF */) {
|
|
573
|
-
if (options.keepLines && numberLineBreaks > 0) {
|
|
574
|
-
replaceContent = newLinesAndIndent();
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
replaceContent = options.insertFinalNewline ? eol : '';
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
581
|
-
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
582
|
-
firstToken = secondToken;
|
|
583
|
-
}
|
|
584
|
-
return editOperations;
|
|
585
|
-
}
|
|
586
|
-
function repeat(s, count) {
|
|
587
|
-
let result = '';
|
|
588
|
-
for (let i = 0; i < count; i++) {
|
|
589
|
-
result += s;
|
|
590
|
-
}
|
|
591
|
-
return result;
|
|
592
|
-
}
|
|
593
|
-
function computeIndentLevel(content, options) {
|
|
594
|
-
let i = 0;
|
|
595
|
-
let nChars = 0;
|
|
596
|
-
const tabSize = options.tabSize || 4;
|
|
597
|
-
while (i < content.length) {
|
|
598
|
-
let ch = content.charAt(i);
|
|
599
|
-
if (ch === ' ') {
|
|
600
|
-
nChars++;
|
|
601
|
-
}
|
|
602
|
-
else if (ch === '\t') {
|
|
603
|
-
nChars += tabSize;
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
i++;
|
|
609
|
-
}
|
|
610
|
-
return Math.floor(nChars / tabSize);
|
|
611
|
-
}
|
|
612
|
-
function getEOL(options, text) {
|
|
613
|
-
for (let i = 0; i < text.length; i++) {
|
|
614
|
-
const ch = text.charAt(i);
|
|
615
|
-
if (ch === '\r') {
|
|
616
|
-
if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
|
|
617
|
-
return '\r\n';
|
|
618
|
-
}
|
|
619
|
-
return '\r';
|
|
620
|
-
}
|
|
621
|
-
else if (ch === '\n') {
|
|
622
|
-
return '\n';
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
return (options && options.eol) || '\n';
|
|
626
|
-
}
|
|
627
|
-
function isEOL(text, offset) {
|
|
628
|
-
return '\r\n'.indexOf(text.charAt(offset)) !== -1;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
/***/ }),
|
|
633
|
-
/* 5 */
|
|
634
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
635
|
-
|
|
636
|
-
"use strict";
|
|
637
|
-
__webpack_require__.r(__webpack_exports__);
|
|
638
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
639
|
-
/* harmony export */ "createScanner": () => (/* binding */ createScanner)
|
|
640
|
-
/* harmony export */ });
|
|
641
|
-
/*---------------------------------------------------------------------------------------------
|
|
642
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
643
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
644
|
-
*--------------------------------------------------------------------------------------------*/
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* Creates a JSON scanner on the given text.
|
|
648
|
-
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
|
649
|
-
*/
|
|
650
|
-
function createScanner(text, ignoreTrivia = false) {
|
|
651
|
-
const len = text.length;
|
|
652
|
-
let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;
|
|
653
|
-
function scanHexDigits(count, exact) {
|
|
654
|
-
let digits = 0;
|
|
655
|
-
let value = 0;
|
|
656
|
-
while (digits < count || !exact) {
|
|
657
|
-
let ch = text.charCodeAt(pos);
|
|
658
|
-
if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
|
|
659
|
-
value = value * 16 + ch - 48 /* CharacterCodes._0 */;
|
|
660
|
-
}
|
|
661
|
-
else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
|
|
662
|
-
value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;
|
|
663
|
-
}
|
|
664
|
-
else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
|
|
665
|
-
value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
pos++;
|
|
671
|
-
digits++;
|
|
672
|
-
}
|
|
673
|
-
if (digits < count) {
|
|
674
|
-
value = -1;
|
|
675
|
-
}
|
|
676
|
-
return value;
|
|
677
|
-
}
|
|
678
|
-
function setPosition(newPosition) {
|
|
679
|
-
pos = newPosition;
|
|
680
|
-
value = '';
|
|
681
|
-
tokenOffset = 0;
|
|
682
|
-
token = 16 /* SyntaxKind.Unknown */;
|
|
683
|
-
scanError = 0 /* ScanError.None */;
|
|
684
|
-
}
|
|
685
|
-
function scanNumber() {
|
|
686
|
-
let start = pos;
|
|
687
|
-
if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
|
|
688
|
-
pos++;
|
|
689
|
-
}
|
|
690
|
-
else {
|
|
691
|
-
pos++;
|
|
692
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
693
|
-
pos++;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
|
|
697
|
-
pos++;
|
|
698
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
699
|
-
pos++;
|
|
700
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
701
|
-
pos++;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
else {
|
|
705
|
-
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
|
706
|
-
return text.substring(start, pos);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
let end = pos;
|
|
710
|
-
if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
|
|
711
|
-
pos++;
|
|
712
|
-
if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
|
|
713
|
-
pos++;
|
|
714
|
-
}
|
|
715
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
716
|
-
pos++;
|
|
717
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
718
|
-
pos++;
|
|
719
|
-
}
|
|
720
|
-
end = pos;
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
return text.substring(start, end);
|
|
727
|
-
}
|
|
728
|
-
function scanString() {
|
|
729
|
-
let result = '', start = pos;
|
|
730
|
-
while (true) {
|
|
731
|
-
if (pos >= len) {
|
|
732
|
-
result += text.substring(start, pos);
|
|
733
|
-
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
734
|
-
break;
|
|
735
|
-
}
|
|
736
|
-
const ch = text.charCodeAt(pos);
|
|
737
|
-
if (ch === 34 /* CharacterCodes.doubleQuote */) {
|
|
738
|
-
result += text.substring(start, pos);
|
|
739
|
-
pos++;
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
if (ch === 92 /* CharacterCodes.backslash */) {
|
|
743
|
-
result += text.substring(start, pos);
|
|
744
|
-
pos++;
|
|
745
|
-
if (pos >= len) {
|
|
746
|
-
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
747
|
-
break;
|
|
748
|
-
}
|
|
749
|
-
const ch2 = text.charCodeAt(pos++);
|
|
750
|
-
switch (ch2) {
|
|
751
|
-
case 34 /* CharacterCodes.doubleQuote */:
|
|
752
|
-
result += '\"';
|
|
753
|
-
break;
|
|
754
|
-
case 92 /* CharacterCodes.backslash */:
|
|
755
|
-
result += '\\';
|
|
756
|
-
break;
|
|
757
|
-
case 47 /* CharacterCodes.slash */:
|
|
758
|
-
result += '/';
|
|
759
|
-
break;
|
|
760
|
-
case 98 /* CharacterCodes.b */:
|
|
761
|
-
result += '\b';
|
|
762
|
-
break;
|
|
763
|
-
case 102 /* CharacterCodes.f */:
|
|
764
|
-
result += '\f';
|
|
765
|
-
break;
|
|
766
|
-
case 110 /* CharacterCodes.n */:
|
|
767
|
-
result += '\n';
|
|
768
|
-
break;
|
|
769
|
-
case 114 /* CharacterCodes.r */:
|
|
770
|
-
result += '\r';
|
|
771
|
-
break;
|
|
772
|
-
case 116 /* CharacterCodes.t */:
|
|
773
|
-
result += '\t';
|
|
774
|
-
break;
|
|
775
|
-
case 117 /* CharacterCodes.u */:
|
|
776
|
-
const ch3 = scanHexDigits(4, true);
|
|
777
|
-
if (ch3 >= 0) {
|
|
778
|
-
result += String.fromCharCode(ch3);
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
scanError = 4 /* ScanError.InvalidUnicode */;
|
|
782
|
-
}
|
|
783
|
-
break;
|
|
784
|
-
default:
|
|
785
|
-
scanError = 5 /* ScanError.InvalidEscapeCharacter */;
|
|
786
|
-
}
|
|
787
|
-
start = pos;
|
|
788
|
-
continue;
|
|
789
|
-
}
|
|
790
|
-
if (ch >= 0 && ch <= 0x1f) {
|
|
791
|
-
if (isLineBreak(ch)) {
|
|
792
|
-
result += text.substring(start, pos);
|
|
793
|
-
scanError = 2 /* ScanError.UnexpectedEndOfString */;
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
scanError = 6 /* ScanError.InvalidCharacter */;
|
|
798
|
-
// mark as error but continue with string
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
pos++;
|
|
802
|
-
}
|
|
803
|
-
return result;
|
|
804
|
-
}
|
|
805
|
-
function scanNext() {
|
|
806
|
-
value = '';
|
|
807
|
-
scanError = 0 /* ScanError.None */;
|
|
808
|
-
tokenOffset = pos;
|
|
809
|
-
lineStartOffset = lineNumber;
|
|
810
|
-
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
811
|
-
if (pos >= len) {
|
|
812
|
-
// at the end
|
|
813
|
-
tokenOffset = len;
|
|
814
|
-
return token = 17 /* SyntaxKind.EOF */;
|
|
815
|
-
}
|
|
816
|
-
let code = text.charCodeAt(pos);
|
|
817
|
-
// trivia: whitespace
|
|
818
|
-
if (isWhiteSpace(code)) {
|
|
819
|
-
do {
|
|
820
|
-
pos++;
|
|
821
|
-
value += String.fromCharCode(code);
|
|
822
|
-
code = text.charCodeAt(pos);
|
|
823
|
-
} while (isWhiteSpace(code));
|
|
824
|
-
return token = 15 /* SyntaxKind.Trivia */;
|
|
825
|
-
}
|
|
826
|
-
// trivia: newlines
|
|
827
|
-
if (isLineBreak(code)) {
|
|
828
|
-
pos++;
|
|
829
|
-
value += String.fromCharCode(code);
|
|
830
|
-
if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
|
831
|
-
pos++;
|
|
832
|
-
value += '\n';
|
|
833
|
-
}
|
|
834
|
-
lineNumber++;
|
|
835
|
-
tokenLineStartOffset = pos;
|
|
836
|
-
return token = 14 /* SyntaxKind.LineBreakTrivia */;
|
|
837
|
-
}
|
|
838
|
-
switch (code) {
|
|
839
|
-
// tokens: []{}:,
|
|
840
|
-
case 123 /* CharacterCodes.openBrace */:
|
|
841
|
-
pos++;
|
|
842
|
-
return token = 1 /* SyntaxKind.OpenBraceToken */;
|
|
843
|
-
case 125 /* CharacterCodes.closeBrace */:
|
|
844
|
-
pos++;
|
|
845
|
-
return token = 2 /* SyntaxKind.CloseBraceToken */;
|
|
846
|
-
case 91 /* CharacterCodes.openBracket */:
|
|
847
|
-
pos++;
|
|
848
|
-
return token = 3 /* SyntaxKind.OpenBracketToken */;
|
|
849
|
-
case 93 /* CharacterCodes.closeBracket */:
|
|
850
|
-
pos++;
|
|
851
|
-
return token = 4 /* SyntaxKind.CloseBracketToken */;
|
|
852
|
-
case 58 /* CharacterCodes.colon */:
|
|
853
|
-
pos++;
|
|
854
|
-
return token = 6 /* SyntaxKind.ColonToken */;
|
|
855
|
-
case 44 /* CharacterCodes.comma */:
|
|
856
|
-
pos++;
|
|
857
|
-
return token = 5 /* SyntaxKind.CommaToken */;
|
|
858
|
-
// strings
|
|
859
|
-
case 34 /* CharacterCodes.doubleQuote */:
|
|
860
|
-
pos++;
|
|
861
|
-
value = scanString();
|
|
862
|
-
return token = 10 /* SyntaxKind.StringLiteral */;
|
|
863
|
-
// comments
|
|
864
|
-
case 47 /* CharacterCodes.slash */:
|
|
865
|
-
const start = pos - 1;
|
|
866
|
-
// Single-line comment
|
|
867
|
-
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
868
|
-
pos += 2;
|
|
869
|
-
while (pos < len) {
|
|
870
|
-
if (isLineBreak(text.charCodeAt(pos))) {
|
|
871
|
-
break;
|
|
872
|
-
}
|
|
873
|
-
pos++;
|
|
874
|
-
}
|
|
875
|
-
value = text.substring(start, pos);
|
|
876
|
-
return token = 12 /* SyntaxKind.LineCommentTrivia */;
|
|
877
|
-
}
|
|
878
|
-
// Multi-line comment
|
|
879
|
-
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
|
880
|
-
pos += 2;
|
|
881
|
-
const safeLength = len - 1; // For lookahead.
|
|
882
|
-
let commentClosed = false;
|
|
883
|
-
while (pos < safeLength) {
|
|
884
|
-
const ch = text.charCodeAt(pos);
|
|
885
|
-
if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
886
|
-
pos += 2;
|
|
887
|
-
commentClosed = true;
|
|
888
|
-
break;
|
|
889
|
-
}
|
|
890
|
-
pos++;
|
|
891
|
-
if (isLineBreak(ch)) {
|
|
892
|
-
if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
|
|
893
|
-
pos++;
|
|
894
|
-
}
|
|
895
|
-
lineNumber++;
|
|
896
|
-
tokenLineStartOffset = pos;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
if (!commentClosed) {
|
|
900
|
-
pos++;
|
|
901
|
-
scanError = 1 /* ScanError.UnexpectedEndOfComment */;
|
|
902
|
-
}
|
|
903
|
-
value = text.substring(start, pos);
|
|
904
|
-
return token = 13 /* SyntaxKind.BlockCommentTrivia */;
|
|
905
|
-
}
|
|
906
|
-
// just a single slash
|
|
907
|
-
value += String.fromCharCode(code);
|
|
908
|
-
pos++;
|
|
909
|
-
return token = 16 /* SyntaxKind.Unknown */;
|
|
910
|
-
// numbers
|
|
911
|
-
case 45 /* CharacterCodes.minus */:
|
|
912
|
-
value += String.fromCharCode(code);
|
|
913
|
-
pos++;
|
|
914
|
-
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
915
|
-
return token = 16 /* SyntaxKind.Unknown */;
|
|
916
|
-
}
|
|
917
|
-
// found a minus, followed by a number so
|
|
918
|
-
// we fall through to proceed with scanning
|
|
919
|
-
// numbers
|
|
920
|
-
case 48 /* CharacterCodes._0 */:
|
|
921
|
-
case 49 /* CharacterCodes._1 */:
|
|
922
|
-
case 50 /* CharacterCodes._2 */:
|
|
923
|
-
case 51 /* CharacterCodes._3 */:
|
|
924
|
-
case 52 /* CharacterCodes._4 */:
|
|
925
|
-
case 53 /* CharacterCodes._5 */:
|
|
926
|
-
case 54 /* CharacterCodes._6 */:
|
|
927
|
-
case 55 /* CharacterCodes._7 */:
|
|
928
|
-
case 56 /* CharacterCodes._8 */:
|
|
929
|
-
case 57 /* CharacterCodes._9 */:
|
|
930
|
-
value += scanNumber();
|
|
931
|
-
return token = 11 /* SyntaxKind.NumericLiteral */;
|
|
932
|
-
// literals and unknown symbols
|
|
933
|
-
default:
|
|
934
|
-
// is a literal? Read the full word.
|
|
935
|
-
while (pos < len && isUnknownContentCharacter(code)) {
|
|
936
|
-
pos++;
|
|
937
|
-
code = text.charCodeAt(pos);
|
|
938
|
-
}
|
|
939
|
-
if (tokenOffset !== pos) {
|
|
940
|
-
value = text.substring(tokenOffset, pos);
|
|
941
|
-
// keywords: true, false, null
|
|
942
|
-
switch (value) {
|
|
943
|
-
case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
|
|
944
|
-
case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
|
|
945
|
-
case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
|
|
946
|
-
}
|
|
947
|
-
return token = 16 /* SyntaxKind.Unknown */;
|
|
948
|
-
}
|
|
949
|
-
// some
|
|
950
|
-
value += String.fromCharCode(code);
|
|
951
|
-
pos++;
|
|
952
|
-
return token = 16 /* SyntaxKind.Unknown */;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
function isUnknownContentCharacter(code) {
|
|
956
|
-
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
957
|
-
return false;
|
|
958
|
-
}
|
|
959
|
-
switch (code) {
|
|
960
|
-
case 125 /* CharacterCodes.closeBrace */:
|
|
961
|
-
case 93 /* CharacterCodes.closeBracket */:
|
|
962
|
-
case 123 /* CharacterCodes.openBrace */:
|
|
963
|
-
case 91 /* CharacterCodes.openBracket */:
|
|
964
|
-
case 34 /* CharacterCodes.doubleQuote */:
|
|
965
|
-
case 58 /* CharacterCodes.colon */:
|
|
966
|
-
case 44 /* CharacterCodes.comma */:
|
|
967
|
-
case 47 /* CharacterCodes.slash */:
|
|
968
|
-
return false;
|
|
969
|
-
}
|
|
970
|
-
return true;
|
|
971
|
-
}
|
|
972
|
-
function scanNextNonTrivia() {
|
|
973
|
-
let result;
|
|
974
|
-
do {
|
|
975
|
-
result = scanNext();
|
|
976
|
-
} while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
|
|
977
|
-
return result;
|
|
978
|
-
}
|
|
979
|
-
return {
|
|
980
|
-
setPosition: setPosition,
|
|
981
|
-
getPosition: () => pos,
|
|
982
|
-
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
983
|
-
getToken: () => token,
|
|
984
|
-
getTokenValue: () => value,
|
|
985
|
-
getTokenOffset: () => tokenOffset,
|
|
986
|
-
getTokenLength: () => pos - tokenOffset,
|
|
987
|
-
getTokenStartLine: () => lineStartOffset,
|
|
988
|
-
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
989
|
-
getTokenError: () => scanError,
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
function isWhiteSpace(ch) {
|
|
993
|
-
return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;
|
|
994
|
-
}
|
|
995
|
-
function isLineBreak(ch) {
|
|
996
|
-
return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;
|
|
997
|
-
}
|
|
998
|
-
function isDigit(ch) {
|
|
999
|
-
return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
|
|
1000
|
-
}
|
|
1001
|
-
var CharacterCodes;
|
|
1002
|
-
(function (CharacterCodes) {
|
|
1003
|
-
CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
|
|
1004
|
-
CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
|
|
1005
|
-
CharacterCodes[CharacterCodes["space"] = 32] = "space";
|
|
1006
|
-
CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
|
|
1007
|
-
CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
|
|
1008
|
-
CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
|
|
1009
|
-
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
|
1010
|
-
CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
|
|
1011
|
-
CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
|
|
1012
|
-
CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
|
|
1013
|
-
CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
|
|
1014
|
-
CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
|
|
1015
|
-
CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
|
|
1016
|
-
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
|
1017
|
-
CharacterCodes[CharacterCodes["b"] = 98] = "b";
|
|
1018
|
-
CharacterCodes[CharacterCodes["c"] = 99] = "c";
|
|
1019
|
-
CharacterCodes[CharacterCodes["d"] = 100] = "d";
|
|
1020
|
-
CharacterCodes[CharacterCodes["e"] = 101] = "e";
|
|
1021
|
-
CharacterCodes[CharacterCodes["f"] = 102] = "f";
|
|
1022
|
-
CharacterCodes[CharacterCodes["g"] = 103] = "g";
|
|
1023
|
-
CharacterCodes[CharacterCodes["h"] = 104] = "h";
|
|
1024
|
-
CharacterCodes[CharacterCodes["i"] = 105] = "i";
|
|
1025
|
-
CharacterCodes[CharacterCodes["j"] = 106] = "j";
|
|
1026
|
-
CharacterCodes[CharacterCodes["k"] = 107] = "k";
|
|
1027
|
-
CharacterCodes[CharacterCodes["l"] = 108] = "l";
|
|
1028
|
-
CharacterCodes[CharacterCodes["m"] = 109] = "m";
|
|
1029
|
-
CharacterCodes[CharacterCodes["n"] = 110] = "n";
|
|
1030
|
-
CharacterCodes[CharacterCodes["o"] = 111] = "o";
|
|
1031
|
-
CharacterCodes[CharacterCodes["p"] = 112] = "p";
|
|
1032
|
-
CharacterCodes[CharacterCodes["q"] = 113] = "q";
|
|
1033
|
-
CharacterCodes[CharacterCodes["r"] = 114] = "r";
|
|
1034
|
-
CharacterCodes[CharacterCodes["s"] = 115] = "s";
|
|
1035
|
-
CharacterCodes[CharacterCodes["t"] = 116] = "t";
|
|
1036
|
-
CharacterCodes[CharacterCodes["u"] = 117] = "u";
|
|
1037
|
-
CharacterCodes[CharacterCodes["v"] = 118] = "v";
|
|
1038
|
-
CharacterCodes[CharacterCodes["w"] = 119] = "w";
|
|
1039
|
-
CharacterCodes[CharacterCodes["x"] = 120] = "x";
|
|
1040
|
-
CharacterCodes[CharacterCodes["y"] = 121] = "y";
|
|
1041
|
-
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
|
1042
|
-
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
|
1043
|
-
CharacterCodes[CharacterCodes["B"] = 66] = "B";
|
|
1044
|
-
CharacterCodes[CharacterCodes["C"] = 67] = "C";
|
|
1045
|
-
CharacterCodes[CharacterCodes["D"] = 68] = "D";
|
|
1046
|
-
CharacterCodes[CharacterCodes["E"] = 69] = "E";
|
|
1047
|
-
CharacterCodes[CharacterCodes["F"] = 70] = "F";
|
|
1048
|
-
CharacterCodes[CharacterCodes["G"] = 71] = "G";
|
|
1049
|
-
CharacterCodes[CharacterCodes["H"] = 72] = "H";
|
|
1050
|
-
CharacterCodes[CharacterCodes["I"] = 73] = "I";
|
|
1051
|
-
CharacterCodes[CharacterCodes["J"] = 74] = "J";
|
|
1052
|
-
CharacterCodes[CharacterCodes["K"] = 75] = "K";
|
|
1053
|
-
CharacterCodes[CharacterCodes["L"] = 76] = "L";
|
|
1054
|
-
CharacterCodes[CharacterCodes["M"] = 77] = "M";
|
|
1055
|
-
CharacterCodes[CharacterCodes["N"] = 78] = "N";
|
|
1056
|
-
CharacterCodes[CharacterCodes["O"] = 79] = "O";
|
|
1057
|
-
CharacterCodes[CharacterCodes["P"] = 80] = "P";
|
|
1058
|
-
CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
|
|
1059
|
-
CharacterCodes[CharacterCodes["R"] = 82] = "R";
|
|
1060
|
-
CharacterCodes[CharacterCodes["S"] = 83] = "S";
|
|
1061
|
-
CharacterCodes[CharacterCodes["T"] = 84] = "T";
|
|
1062
|
-
CharacterCodes[CharacterCodes["U"] = 85] = "U";
|
|
1063
|
-
CharacterCodes[CharacterCodes["V"] = 86] = "V";
|
|
1064
|
-
CharacterCodes[CharacterCodes["W"] = 87] = "W";
|
|
1065
|
-
CharacterCodes[CharacterCodes["X"] = 88] = "X";
|
|
1066
|
-
CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
|
|
1067
|
-
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
|
1068
|
-
CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
|
|
1069
|
-
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
|
1070
|
-
CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
|
|
1071
|
-
CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
|
|
1072
|
-
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
|
1073
|
-
CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
|
|
1074
|
-
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
|
1075
|
-
CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
|
|
1076
|
-
CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
|
|
1077
|
-
CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
|
|
1078
|
-
CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
|
|
1079
|
-
CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
|
|
1080
|
-
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
|
1081
|
-
CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
|
|
1082
|
-
CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
|
|
1083
|
-
})(CharacterCodes || (CharacterCodes = {}));
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
/***/ }),
|
|
1087
|
-
/* 6 */
|
|
1088
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1089
|
-
|
|
1090
|
-
"use strict";
|
|
1091
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1092
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1093
|
-
/* harmony export */ "applyEdit": () => (/* binding */ applyEdit),
|
|
1094
|
-
/* harmony export */ "isWS": () => (/* binding */ isWS),
|
|
1095
|
-
/* harmony export */ "removeProperty": () => (/* binding */ removeProperty),
|
|
1096
|
-
/* harmony export */ "setProperty": () => (/* binding */ setProperty)
|
|
1097
|
-
/* harmony export */ });
|
|
1098
|
-
/* harmony import */ var _format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
1099
|
-
/* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
|
1100
|
-
/*---------------------------------------------------------------------------------------------
|
|
1101
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1102
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1103
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
function removeProperty(text, path, options) {
|
|
1108
|
-
return setProperty(text, path, void 0, options);
|
|
1109
|
-
}
|
|
1110
|
-
function setProperty(text, originalPath, value, options) {
|
|
1111
|
-
const path = originalPath.slice();
|
|
1112
|
-
const errors = [];
|
|
1113
|
-
const root = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.parseTree)(text, errors);
|
|
1114
|
-
let parent = void 0;
|
|
1115
|
-
let lastSegment = void 0;
|
|
1116
|
-
while (path.length > 0) {
|
|
1117
|
-
lastSegment = path.pop();
|
|
1118
|
-
parent = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(root, path);
|
|
1119
|
-
if (parent === void 0 && value !== void 0) {
|
|
1120
|
-
if (typeof lastSegment === 'string') {
|
|
1121
|
-
value = { [lastSegment]: value };
|
|
1122
|
-
}
|
|
1123
|
-
else {
|
|
1124
|
-
value = [value];
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
else {
|
|
1128
|
-
break;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
if (!parent) {
|
|
1132
|
-
// empty document
|
|
1133
|
-
if (value === void 0) { // delete
|
|
1134
|
-
throw new Error('Can not delete in empty document');
|
|
1135
|
-
}
|
|
1136
|
-
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
|
1137
|
-
}
|
|
1138
|
-
else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
|
|
1139
|
-
const existing = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(parent, [lastSegment]);
|
|
1140
|
-
if (existing !== void 0) {
|
|
1141
|
-
if (value === void 0) { // delete
|
|
1142
|
-
if (!existing.parent) {
|
|
1143
|
-
throw new Error('Malformed AST');
|
|
1144
|
-
}
|
|
1145
|
-
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
1146
|
-
let removeBegin;
|
|
1147
|
-
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
1148
|
-
if (propertyIndex > 0) {
|
|
1149
|
-
// remove the comma of the previous node
|
|
1150
|
-
let previous = parent.children[propertyIndex - 1];
|
|
1151
|
-
removeBegin = previous.offset + previous.length;
|
|
1152
|
-
}
|
|
1153
|
-
else {
|
|
1154
|
-
removeBegin = parent.offset + 1;
|
|
1155
|
-
if (parent.children.length > 1) {
|
|
1156
|
-
// remove the comma of the next node
|
|
1157
|
-
let next = parent.children[1];
|
|
1158
|
-
removeEnd = next.offset;
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options);
|
|
1162
|
-
}
|
|
1163
|
-
else {
|
|
1164
|
-
// set value of existing property
|
|
1165
|
-
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
else {
|
|
1169
|
-
if (value === void 0) { // delete
|
|
1170
|
-
return []; // property does not exist, nothing to do
|
|
1171
|
-
}
|
|
1172
|
-
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
1173
|
-
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
|
|
1174
|
-
let edit;
|
|
1175
|
-
if (index > 0) {
|
|
1176
|
-
let previous = parent.children[index - 1];
|
|
1177
|
-
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
|
1178
|
-
}
|
|
1179
|
-
else if (parent.children.length === 0) {
|
|
1180
|
-
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1181
|
-
}
|
|
1182
|
-
else {
|
|
1183
|
-
edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
|
|
1184
|
-
}
|
|
1185
|
-
return withFormatting(text, edit, options);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
|
|
1189
|
-
const insertIndex = lastSegment;
|
|
1190
|
-
if (insertIndex === -1) {
|
|
1191
|
-
// Insert
|
|
1192
|
-
const newProperty = `${JSON.stringify(value)}`;
|
|
1193
|
-
let edit;
|
|
1194
|
-
if (parent.children.length === 0) {
|
|
1195
|
-
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1196
|
-
}
|
|
1197
|
-
else {
|
|
1198
|
-
const previous = parent.children[parent.children.length - 1];
|
|
1199
|
-
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
|
1200
|
-
}
|
|
1201
|
-
return withFormatting(text, edit, options);
|
|
1202
|
-
}
|
|
1203
|
-
else if (value === void 0 && parent.children.length >= 0) {
|
|
1204
|
-
// Removal
|
|
1205
|
-
const removalIndex = lastSegment;
|
|
1206
|
-
const toRemove = parent.children[removalIndex];
|
|
1207
|
-
let edit;
|
|
1208
|
-
if (parent.children.length === 1) {
|
|
1209
|
-
// only item
|
|
1210
|
-
edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
|
|
1211
|
-
}
|
|
1212
|
-
else if (parent.children.length - 1 === removalIndex) {
|
|
1213
|
-
// last item
|
|
1214
|
-
let previous = parent.children[removalIndex - 1];
|
|
1215
|
-
let offset = previous.offset + previous.length;
|
|
1216
|
-
let parentEndOffset = parent.offset + parent.length;
|
|
1217
|
-
edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
|
|
1218
|
-
}
|
|
1219
|
-
else {
|
|
1220
|
-
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
|
|
1221
|
-
}
|
|
1222
|
-
return withFormatting(text, edit, options);
|
|
1223
|
-
}
|
|
1224
|
-
else if (value !== void 0) {
|
|
1225
|
-
let edit;
|
|
1226
|
-
const newProperty = `${JSON.stringify(value)}`;
|
|
1227
|
-
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
|
1228
|
-
const toModify = parent.children[lastSegment];
|
|
1229
|
-
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
|
1230
|
-
}
|
|
1231
|
-
else if (parent.children.length === 0 || lastSegment === 0) {
|
|
1232
|
-
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
|
|
1233
|
-
}
|
|
1234
|
-
else {
|
|
1235
|
-
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
1236
|
-
const previous = parent.children[index - 1];
|
|
1237
|
-
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
|
1238
|
-
}
|
|
1239
|
-
return withFormatting(text, edit, options);
|
|
1240
|
-
}
|
|
1241
|
-
else {
|
|
1242
|
-
throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`);
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
else {
|
|
1246
|
-
throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
function withFormatting(text, edit, options) {
|
|
1250
|
-
if (!options.formattingOptions) {
|
|
1251
|
-
return [edit];
|
|
1252
|
-
}
|
|
1253
|
-
// apply the edit
|
|
1254
|
-
let newText = applyEdit(text, edit);
|
|
1255
|
-
// format the new text
|
|
1256
|
-
let begin = edit.offset;
|
|
1257
|
-
let end = edit.offset + edit.content.length;
|
|
1258
|
-
if (edit.length === 0 || edit.content.length === 0) { // insert or remove
|
|
1259
|
-
while (begin > 0 && !(0,_format__WEBPACK_IMPORTED_MODULE_0__.isEOL)(newText, begin - 1)) {
|
|
1260
|
-
begin--;
|
|
1261
|
-
}
|
|
1262
|
-
while (end < newText.length && !(0,_format__WEBPACK_IMPORTED_MODULE_0__.isEOL)(newText, end)) {
|
|
1263
|
-
end++;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
const edits = (0,_format__WEBPACK_IMPORTED_MODULE_0__.format)(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
|
1267
|
-
// apply the formatting edits and track the begin and end offsets of the changes
|
|
1268
|
-
for (let i = edits.length - 1; i >= 0; i--) {
|
|
1269
|
-
const edit = edits[i];
|
|
1270
|
-
newText = applyEdit(newText, edit);
|
|
1271
|
-
begin = Math.min(begin, edit.offset);
|
|
1272
|
-
end = Math.max(end, edit.offset + edit.length);
|
|
1273
|
-
end += edit.content.length - edit.length;
|
|
1274
|
-
}
|
|
1275
|
-
// create a single edit with all changes
|
|
1276
|
-
const editLength = text.length - (newText.length - end) - begin;
|
|
1277
|
-
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
|
1278
|
-
}
|
|
1279
|
-
function applyEdit(text, edit) {
|
|
1280
|
-
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
|
1281
|
-
}
|
|
1282
|
-
function isWS(text, offset) {
|
|
1283
|
-
return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
/***/ }),
|
|
1288
|
-
/* 7 */
|
|
1289
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1290
|
-
|
|
1291
|
-
"use strict";
|
|
1292
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1293
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1294
|
-
/* harmony export */ "contains": () => (/* binding */ contains),
|
|
1295
|
-
/* harmony export */ "findNodeAtLocation": () => (/* binding */ findNodeAtLocation),
|
|
1296
|
-
/* harmony export */ "findNodeAtOffset": () => (/* binding */ findNodeAtOffset),
|
|
1297
|
-
/* harmony export */ "getLocation": () => (/* binding */ getLocation),
|
|
1298
|
-
/* harmony export */ "getNodePath": () => (/* binding */ getNodePath),
|
|
1299
|
-
/* harmony export */ "getNodeType": () => (/* binding */ getNodeType),
|
|
1300
|
-
/* harmony export */ "getNodeValue": () => (/* binding */ getNodeValue),
|
|
1301
|
-
/* harmony export */ "parse": () => (/* binding */ parse),
|
|
1302
|
-
/* harmony export */ "parseTree": () => (/* binding */ parseTree),
|
|
1303
|
-
/* harmony export */ "stripComments": () => (/* binding */ stripComments),
|
|
1304
|
-
/* harmony export */ "visit": () => (/* binding */ visit)
|
|
1305
|
-
/* harmony export */ });
|
|
1306
|
-
/* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
|
|
1307
|
-
/*---------------------------------------------------------------------------------------------
|
|
1308
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1309
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1310
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
var ParseOptions;
|
|
1314
|
-
(function (ParseOptions) {
|
|
1315
|
-
ParseOptions.DEFAULT = {
|
|
1316
|
-
allowTrailingComma: false
|
|
1317
|
-
};
|
|
1318
|
-
})(ParseOptions || (ParseOptions = {}));
|
|
1319
|
-
/**
|
|
1320
|
-
* For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
|
|
1321
|
-
*/
|
|
1322
|
-
function getLocation(text, position) {
|
|
1323
|
-
const segments = []; // strings or numbers
|
|
1324
|
-
const earlyReturnException = new Object();
|
|
1325
|
-
let previousNode = undefined;
|
|
1326
|
-
const previousNodeInst = {
|
|
1327
|
-
value: {},
|
|
1328
|
-
offset: 0,
|
|
1329
|
-
length: 0,
|
|
1330
|
-
type: 'object',
|
|
1331
|
-
parent: undefined
|
|
1332
|
-
};
|
|
1333
|
-
let isAtPropertyKey = false;
|
|
1334
|
-
function setPreviousNode(value, offset, length, type) {
|
|
1335
|
-
previousNodeInst.value = value;
|
|
1336
|
-
previousNodeInst.offset = offset;
|
|
1337
|
-
previousNodeInst.length = length;
|
|
1338
|
-
previousNodeInst.type = type;
|
|
1339
|
-
previousNodeInst.colonOffset = undefined;
|
|
1340
|
-
previousNode = previousNodeInst;
|
|
1341
|
-
}
|
|
1342
|
-
try {
|
|
1343
|
-
visit(text, {
|
|
1344
|
-
onObjectBegin: (offset, length) => {
|
|
1345
|
-
if (position <= offset) {
|
|
1346
|
-
throw earlyReturnException;
|
|
1347
|
-
}
|
|
1348
|
-
previousNode = undefined;
|
|
1349
|
-
isAtPropertyKey = position > offset;
|
|
1350
|
-
segments.push(''); // push a placeholder (will be replaced)
|
|
1351
|
-
},
|
|
1352
|
-
onObjectProperty: (name, offset, length) => {
|
|
1353
|
-
if (position < offset) {
|
|
1354
|
-
throw earlyReturnException;
|
|
1355
|
-
}
|
|
1356
|
-
setPreviousNode(name, offset, length, 'property');
|
|
1357
|
-
segments[segments.length - 1] = name;
|
|
1358
|
-
if (position <= offset + length) {
|
|
1359
|
-
throw earlyReturnException;
|
|
1360
|
-
}
|
|
1361
|
-
},
|
|
1362
|
-
onObjectEnd: (offset, length) => {
|
|
1363
|
-
if (position <= offset) {
|
|
1364
|
-
throw earlyReturnException;
|
|
1365
|
-
}
|
|
1366
|
-
previousNode = undefined;
|
|
1367
|
-
segments.pop();
|
|
1368
|
-
},
|
|
1369
|
-
onArrayBegin: (offset, length) => {
|
|
1370
|
-
if (position <= offset) {
|
|
1371
|
-
throw earlyReturnException;
|
|
1372
|
-
}
|
|
1373
|
-
previousNode = undefined;
|
|
1374
|
-
segments.push(0);
|
|
1375
|
-
},
|
|
1376
|
-
onArrayEnd: (offset, length) => {
|
|
1377
|
-
if (position <= offset) {
|
|
1378
|
-
throw earlyReturnException;
|
|
1379
|
-
}
|
|
1380
|
-
previousNode = undefined;
|
|
1381
|
-
segments.pop();
|
|
1382
|
-
},
|
|
1383
|
-
onLiteralValue: (value, offset, length) => {
|
|
1384
|
-
if (position < offset) {
|
|
1385
|
-
throw earlyReturnException;
|
|
1386
|
-
}
|
|
1387
|
-
setPreviousNode(value, offset, length, getNodeType(value));
|
|
1388
|
-
if (position <= offset + length) {
|
|
1389
|
-
throw earlyReturnException;
|
|
1390
|
-
}
|
|
1391
|
-
},
|
|
1392
|
-
onSeparator: (sep, offset, length) => {
|
|
1393
|
-
if (position <= offset) {
|
|
1394
|
-
throw earlyReturnException;
|
|
1395
|
-
}
|
|
1396
|
-
if (sep === ':' && previousNode && previousNode.type === 'property') {
|
|
1397
|
-
previousNode.colonOffset = offset;
|
|
1398
|
-
isAtPropertyKey = false;
|
|
1399
|
-
previousNode = undefined;
|
|
1400
|
-
}
|
|
1401
|
-
else if (sep === ',') {
|
|
1402
|
-
const last = segments[segments.length - 1];
|
|
1403
|
-
if (typeof last === 'number') {
|
|
1404
|
-
segments[segments.length - 1] = last + 1;
|
|
1405
|
-
}
|
|
1406
|
-
else {
|
|
1407
|
-
isAtPropertyKey = true;
|
|
1408
|
-
segments[segments.length - 1] = '';
|
|
1409
|
-
}
|
|
1410
|
-
previousNode = undefined;
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
});
|
|
1414
|
-
}
|
|
1415
|
-
catch (e) {
|
|
1416
|
-
if (e !== earlyReturnException) {
|
|
1417
|
-
throw e;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
return {
|
|
1421
|
-
path: segments,
|
|
1422
|
-
previousNode,
|
|
1423
|
-
isAtPropertyKey,
|
|
1424
|
-
matches: (pattern) => {
|
|
1425
|
-
let k = 0;
|
|
1426
|
-
for (let i = 0; k < pattern.length && i < segments.length; i++) {
|
|
1427
|
-
if (pattern[k] === segments[i] || pattern[k] === '*') {
|
|
1428
|
-
k++;
|
|
1429
|
-
}
|
|
1430
|
-
else if (pattern[k] !== '**') {
|
|
1431
|
-
return false;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
return k === pattern.length;
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
}
|
|
1438
|
-
/**
|
|
1439
|
-
* Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
1440
|
-
* Therefore always check the errors list to find out if the input was valid.
|
|
1441
|
-
*/
|
|
1442
|
-
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1443
|
-
let currentProperty = null;
|
|
1444
|
-
let currentParent = [];
|
|
1445
|
-
const previousParents = [];
|
|
1446
|
-
function onValue(value) {
|
|
1447
|
-
if (Array.isArray(currentParent)) {
|
|
1448
|
-
currentParent.push(value);
|
|
1449
|
-
}
|
|
1450
|
-
else if (currentProperty !== null) {
|
|
1451
|
-
currentParent[currentProperty] = value;
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
const visitor = {
|
|
1455
|
-
onObjectBegin: () => {
|
|
1456
|
-
const object = {};
|
|
1457
|
-
onValue(object);
|
|
1458
|
-
previousParents.push(currentParent);
|
|
1459
|
-
currentParent = object;
|
|
1460
|
-
currentProperty = null;
|
|
1461
|
-
},
|
|
1462
|
-
onObjectProperty: (name) => {
|
|
1463
|
-
currentProperty = name;
|
|
1464
|
-
},
|
|
1465
|
-
onObjectEnd: () => {
|
|
1466
|
-
currentParent = previousParents.pop();
|
|
1467
|
-
},
|
|
1468
|
-
onArrayBegin: () => {
|
|
1469
|
-
const array = [];
|
|
1470
|
-
onValue(array);
|
|
1471
|
-
previousParents.push(currentParent);
|
|
1472
|
-
currentParent = array;
|
|
1473
|
-
currentProperty = null;
|
|
1474
|
-
},
|
|
1475
|
-
onArrayEnd: () => {
|
|
1476
|
-
currentParent = previousParents.pop();
|
|
1477
|
-
},
|
|
1478
|
-
onLiteralValue: onValue,
|
|
1479
|
-
onError: (error, offset, length) => {
|
|
1480
|
-
errors.push({ error, offset, length });
|
|
1481
|
-
}
|
|
1482
|
-
};
|
|
1483
|
-
visit(text, visitor, options);
|
|
1484
|
-
return currentParent[0];
|
|
1485
|
-
}
|
|
1486
|
-
/**
|
|
1487
|
-
* Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
|
|
1488
|
-
*/
|
|
1489
|
-
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1490
|
-
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
|
|
1491
|
-
function ensurePropertyComplete(endOffset) {
|
|
1492
|
-
if (currentParent.type === 'property') {
|
|
1493
|
-
currentParent.length = endOffset - currentParent.offset;
|
|
1494
|
-
currentParent = currentParent.parent;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
function onValue(valueNode) {
|
|
1498
|
-
currentParent.children.push(valueNode);
|
|
1499
|
-
return valueNode;
|
|
1500
|
-
}
|
|
1501
|
-
const visitor = {
|
|
1502
|
-
onObjectBegin: (offset) => {
|
|
1503
|
-
currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
|
|
1504
|
-
},
|
|
1505
|
-
onObjectProperty: (name, offset, length) => {
|
|
1506
|
-
currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
|
|
1507
|
-
currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
|
|
1508
|
-
},
|
|
1509
|
-
onObjectEnd: (offset, length) => {
|
|
1510
|
-
ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete
|
|
1511
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
1512
|
-
currentParent = currentParent.parent;
|
|
1513
|
-
ensurePropertyComplete(offset + length);
|
|
1514
|
-
},
|
|
1515
|
-
onArrayBegin: (offset, length) => {
|
|
1516
|
-
currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
|
|
1517
|
-
},
|
|
1518
|
-
onArrayEnd: (offset, length) => {
|
|
1519
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
1520
|
-
currentParent = currentParent.parent;
|
|
1521
|
-
ensurePropertyComplete(offset + length);
|
|
1522
|
-
},
|
|
1523
|
-
onLiteralValue: (value, offset, length) => {
|
|
1524
|
-
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
1525
|
-
ensurePropertyComplete(offset + length);
|
|
1526
|
-
},
|
|
1527
|
-
onSeparator: (sep, offset, length) => {
|
|
1528
|
-
if (currentParent.type === 'property') {
|
|
1529
|
-
if (sep === ':') {
|
|
1530
|
-
currentParent.colonOffset = offset;
|
|
1531
|
-
}
|
|
1532
|
-
else if (sep === ',') {
|
|
1533
|
-
ensurePropertyComplete(offset);
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
},
|
|
1537
|
-
onError: (error, offset, length) => {
|
|
1538
|
-
errors.push({ error, offset, length });
|
|
1539
|
-
}
|
|
1540
|
-
};
|
|
1541
|
-
visit(text, visitor, options);
|
|
1542
|
-
const result = currentParent.children[0];
|
|
1543
|
-
if (result) {
|
|
1544
|
-
delete result.parent;
|
|
1545
|
-
}
|
|
1546
|
-
return result;
|
|
1547
|
-
}
|
|
1548
|
-
/**
|
|
1549
|
-
* Finds the node at the given path in a JSON DOM.
|
|
1550
|
-
*/
|
|
1551
|
-
function findNodeAtLocation(root, path) {
|
|
1552
|
-
if (!root) {
|
|
1553
|
-
return undefined;
|
|
1554
|
-
}
|
|
1555
|
-
let node = root;
|
|
1556
|
-
for (let segment of path) {
|
|
1557
|
-
if (typeof segment === 'string') {
|
|
1558
|
-
if (node.type !== 'object' || !Array.isArray(node.children)) {
|
|
1559
|
-
return undefined;
|
|
1560
|
-
}
|
|
1561
|
-
let found = false;
|
|
1562
|
-
for (const propertyNode of node.children) {
|
|
1563
|
-
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
1564
|
-
node = propertyNode.children[1];
|
|
1565
|
-
found = true;
|
|
1566
|
-
break;
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
if (!found) {
|
|
1570
|
-
return undefined;
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
else {
|
|
1574
|
-
const index = segment;
|
|
1575
|
-
if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
|
1576
|
-
return undefined;
|
|
1577
|
-
}
|
|
1578
|
-
node = node.children[index];
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
return node;
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* Gets the JSON path of the given JSON DOM node
|
|
1585
|
-
*/
|
|
1586
|
-
function getNodePath(node) {
|
|
1587
|
-
if (!node.parent || !node.parent.children) {
|
|
1588
|
-
return [];
|
|
1589
|
-
}
|
|
1590
|
-
const path = getNodePath(node.parent);
|
|
1591
|
-
if (node.parent.type === 'property') {
|
|
1592
|
-
const key = node.parent.children[0].value;
|
|
1593
|
-
path.push(key);
|
|
1594
|
-
}
|
|
1595
|
-
else if (node.parent.type === 'array') {
|
|
1596
|
-
const index = node.parent.children.indexOf(node);
|
|
1597
|
-
if (index !== -1) {
|
|
1598
|
-
path.push(index);
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
return path;
|
|
1602
|
-
}
|
|
1603
|
-
/**
|
|
1604
|
-
* Evaluates the JavaScript object of the given JSON DOM node
|
|
1605
|
-
*/
|
|
1606
|
-
function getNodeValue(node) {
|
|
1607
|
-
switch (node.type) {
|
|
1608
|
-
case 'array':
|
|
1609
|
-
return node.children.map(getNodeValue);
|
|
1610
|
-
case 'object':
|
|
1611
|
-
const obj = Object.create(null);
|
|
1612
|
-
for (let prop of node.children) {
|
|
1613
|
-
const valueNode = prop.children[1];
|
|
1614
|
-
if (valueNode) {
|
|
1615
|
-
obj[prop.children[0].value] = getNodeValue(valueNode);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
return obj;
|
|
1619
|
-
case 'null':
|
|
1620
|
-
case 'string':
|
|
1621
|
-
case 'number':
|
|
1622
|
-
case 'boolean':
|
|
1623
|
-
return node.value;
|
|
1624
|
-
default:
|
|
1625
|
-
return undefined;
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
function contains(node, offset, includeRightBound = false) {
|
|
1629
|
-
return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
|
|
1630
|
-
}
|
|
1631
|
-
/**
|
|
1632
|
-
* Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
|
|
1633
|
-
*/
|
|
1634
|
-
function findNodeAtOffset(node, offset, includeRightBound = false) {
|
|
1635
|
-
if (contains(node, offset, includeRightBound)) {
|
|
1636
|
-
const children = node.children;
|
|
1637
|
-
if (Array.isArray(children)) {
|
|
1638
|
-
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
|
1639
|
-
const item = findNodeAtOffset(children[i], offset, includeRightBound);
|
|
1640
|
-
if (item) {
|
|
1641
|
-
return item;
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
return node;
|
|
1646
|
-
}
|
|
1647
|
-
return undefined;
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
1651
|
-
*/
|
|
1652
|
-
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
1653
|
-
const _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text, false);
|
|
1654
|
-
// Important: Only pass copies of this to visitor functions to prevent accidental modification, and
|
|
1655
|
-
// to not affect visitor functions which stored a reference to a previous JSONPath
|
|
1656
|
-
const _jsonPath = [];
|
|
1657
|
-
function toNoArgVisit(visitFunction) {
|
|
1658
|
-
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
1659
|
-
}
|
|
1660
|
-
function toNoArgVisitWithPath(visitFunction) {
|
|
1661
|
-
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
1662
|
-
}
|
|
1663
|
-
function toOneArgVisit(visitFunction) {
|
|
1664
|
-
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
1665
|
-
}
|
|
1666
|
-
function toOneArgVisitWithPath(visitFunction) {
|
|
1667
|
-
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
1668
|
-
}
|
|
1669
|
-
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
1670
|
-
const disallowComments = options && options.disallowComments;
|
|
1671
|
-
const allowTrailingComma = options && options.allowTrailingComma;
|
|
1672
|
-
function scanNext() {
|
|
1673
|
-
while (true) {
|
|
1674
|
-
const token = _scanner.scan();
|
|
1675
|
-
switch (_scanner.getTokenError()) {
|
|
1676
|
-
case 4 /* ScanError.InvalidUnicode */:
|
|
1677
|
-
handleError(14 /* ParseErrorCode.InvalidUnicode */);
|
|
1678
|
-
break;
|
|
1679
|
-
case 5 /* ScanError.InvalidEscapeCharacter */:
|
|
1680
|
-
handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
|
|
1681
|
-
break;
|
|
1682
|
-
case 3 /* ScanError.UnexpectedEndOfNumber */:
|
|
1683
|
-
handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
|
|
1684
|
-
break;
|
|
1685
|
-
case 1 /* ScanError.UnexpectedEndOfComment */:
|
|
1686
|
-
if (!disallowComments) {
|
|
1687
|
-
handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
|
|
1688
|
-
}
|
|
1689
|
-
break;
|
|
1690
|
-
case 2 /* ScanError.UnexpectedEndOfString */:
|
|
1691
|
-
handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
|
|
1692
|
-
break;
|
|
1693
|
-
case 6 /* ScanError.InvalidCharacter */:
|
|
1694
|
-
handleError(16 /* ParseErrorCode.InvalidCharacter */);
|
|
1695
|
-
break;
|
|
1696
|
-
}
|
|
1697
|
-
switch (token) {
|
|
1698
|
-
case 12 /* SyntaxKind.LineCommentTrivia */:
|
|
1699
|
-
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
|
1700
|
-
if (disallowComments) {
|
|
1701
|
-
handleError(10 /* ParseErrorCode.InvalidCommentToken */);
|
|
1702
|
-
}
|
|
1703
|
-
else {
|
|
1704
|
-
onComment();
|
|
1705
|
-
}
|
|
1706
|
-
break;
|
|
1707
|
-
case 16 /* SyntaxKind.Unknown */:
|
|
1708
|
-
handleError(1 /* ParseErrorCode.InvalidSymbol */);
|
|
1709
|
-
break;
|
|
1710
|
-
case 15 /* SyntaxKind.Trivia */:
|
|
1711
|
-
case 14 /* SyntaxKind.LineBreakTrivia */:
|
|
1712
|
-
break;
|
|
1713
|
-
default:
|
|
1714
|
-
return token;
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
1719
|
-
onError(error);
|
|
1720
|
-
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
1721
|
-
let token = _scanner.getToken();
|
|
1722
|
-
while (token !== 17 /* SyntaxKind.EOF */) {
|
|
1723
|
-
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
1724
|
-
scanNext();
|
|
1725
|
-
break;
|
|
1726
|
-
}
|
|
1727
|
-
else if (skipUntil.indexOf(token) !== -1) {
|
|
1728
|
-
break;
|
|
1729
|
-
}
|
|
1730
|
-
token = scanNext();
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
function parseString(isValue) {
|
|
1735
|
-
const value = _scanner.getTokenValue();
|
|
1736
|
-
if (isValue) {
|
|
1737
|
-
onLiteralValue(value);
|
|
1738
|
-
}
|
|
1739
|
-
else {
|
|
1740
|
-
onObjectProperty(value);
|
|
1741
|
-
// add property name afterwards
|
|
1742
|
-
_jsonPath.push(value);
|
|
1743
|
-
}
|
|
1744
|
-
scanNext();
|
|
1745
|
-
return true;
|
|
1746
|
-
}
|
|
1747
|
-
function parseLiteral() {
|
|
1748
|
-
switch (_scanner.getToken()) {
|
|
1749
|
-
case 11 /* SyntaxKind.NumericLiteral */:
|
|
1750
|
-
const tokenValue = _scanner.getTokenValue();
|
|
1751
|
-
let value = Number(tokenValue);
|
|
1752
|
-
if (isNaN(value)) {
|
|
1753
|
-
handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
|
|
1754
|
-
value = 0;
|
|
1755
|
-
}
|
|
1756
|
-
onLiteralValue(value);
|
|
1757
|
-
break;
|
|
1758
|
-
case 7 /* SyntaxKind.NullKeyword */:
|
|
1759
|
-
onLiteralValue(null);
|
|
1760
|
-
break;
|
|
1761
|
-
case 8 /* SyntaxKind.TrueKeyword */:
|
|
1762
|
-
onLiteralValue(true);
|
|
1763
|
-
break;
|
|
1764
|
-
case 9 /* SyntaxKind.FalseKeyword */:
|
|
1765
|
-
onLiteralValue(false);
|
|
1766
|
-
break;
|
|
1767
|
-
default:
|
|
1768
|
-
return false;
|
|
1769
|
-
}
|
|
1770
|
-
scanNext();
|
|
1771
|
-
return true;
|
|
1772
|
-
}
|
|
1773
|
-
function parseProperty() {
|
|
1774
|
-
if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
|
|
1775
|
-
handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
1776
|
-
return false;
|
|
1777
|
-
}
|
|
1778
|
-
parseString(false);
|
|
1779
|
-
if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
|
|
1780
|
-
onSeparator(':');
|
|
1781
|
-
scanNext(); // consume colon
|
|
1782
|
-
if (!parseValue()) {
|
|
1783
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
else {
|
|
1787
|
-
handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
1788
|
-
}
|
|
1789
|
-
_jsonPath.pop(); // remove processed property name
|
|
1790
|
-
return true;
|
|
1791
|
-
}
|
|
1792
|
-
function parseObject() {
|
|
1793
|
-
onObjectBegin();
|
|
1794
|
-
scanNext(); // consume open brace
|
|
1795
|
-
let needsComma = false;
|
|
1796
|
-
while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
1797
|
-
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
|
1798
|
-
if (!needsComma) {
|
|
1799
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
1800
|
-
}
|
|
1801
|
-
onSeparator(',');
|
|
1802
|
-
scanNext(); // consume comma
|
|
1803
|
-
if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
|
|
1804
|
-
break;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
else if (needsComma) {
|
|
1808
|
-
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
|
1809
|
-
}
|
|
1810
|
-
if (!parseProperty()) {
|
|
1811
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
1812
|
-
}
|
|
1813
|
-
needsComma = true;
|
|
1814
|
-
}
|
|
1815
|
-
onObjectEnd();
|
|
1816
|
-
if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
|
|
1817
|
-
handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
|
|
1818
|
-
}
|
|
1819
|
-
else {
|
|
1820
|
-
scanNext(); // consume close brace
|
|
1821
|
-
}
|
|
1822
|
-
return true;
|
|
1823
|
-
}
|
|
1824
|
-
function parseArray() {
|
|
1825
|
-
onArrayBegin();
|
|
1826
|
-
scanNext(); // consume open bracket
|
|
1827
|
-
let isFirstElement = true;
|
|
1828
|
-
let needsComma = false;
|
|
1829
|
-
while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
1830
|
-
if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
|
|
1831
|
-
if (!needsComma) {
|
|
1832
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
1833
|
-
}
|
|
1834
|
-
onSeparator(',');
|
|
1835
|
-
scanNext(); // consume comma
|
|
1836
|
-
if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
|
|
1837
|
-
break;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
else if (needsComma) {
|
|
1841
|
-
handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
|
|
1842
|
-
}
|
|
1843
|
-
if (isFirstElement) {
|
|
1844
|
-
_jsonPath.push(0);
|
|
1845
|
-
isFirstElement = false;
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
_jsonPath[_jsonPath.length - 1]++;
|
|
1849
|
-
}
|
|
1850
|
-
if (!parseValue()) {
|
|
1851
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
|
|
1852
|
-
}
|
|
1853
|
-
needsComma = true;
|
|
1854
|
-
}
|
|
1855
|
-
onArrayEnd();
|
|
1856
|
-
if (!isFirstElement) {
|
|
1857
|
-
_jsonPath.pop(); // remove array index
|
|
1858
|
-
}
|
|
1859
|
-
if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
|
|
1860
|
-
handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
|
|
1861
|
-
}
|
|
1862
|
-
else {
|
|
1863
|
-
scanNext(); // consume close bracket
|
|
1864
|
-
}
|
|
1865
|
-
return true;
|
|
1866
|
-
}
|
|
1867
|
-
function parseValue() {
|
|
1868
|
-
switch (_scanner.getToken()) {
|
|
1869
|
-
case 3 /* SyntaxKind.OpenBracketToken */:
|
|
1870
|
-
return parseArray();
|
|
1871
|
-
case 1 /* SyntaxKind.OpenBraceToken */:
|
|
1872
|
-
return parseObject();
|
|
1873
|
-
case 10 /* SyntaxKind.StringLiteral */:
|
|
1874
|
-
return parseString(true);
|
|
1875
|
-
default:
|
|
1876
|
-
return parseLiteral();
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
scanNext();
|
|
1880
|
-
if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
|
|
1881
|
-
if (options.allowEmptyContent) {
|
|
1882
|
-
return true;
|
|
1883
|
-
}
|
|
1884
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
1885
|
-
return false;
|
|
1886
|
-
}
|
|
1887
|
-
if (!parseValue()) {
|
|
1888
|
-
handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
|
|
1889
|
-
return false;
|
|
1890
|
-
}
|
|
1891
|
-
if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
|
|
1892
|
-
handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
|
|
1893
|
-
}
|
|
1894
|
-
return true;
|
|
1895
|
-
}
|
|
1896
|
-
/**
|
|
1897
|
-
* Takes JSON with JavaScript-style comments and remove
|
|
1898
|
-
* them. Optionally replaces every none-newline character
|
|
1899
|
-
* of comments with a replaceCharacter
|
|
1900
|
-
*/
|
|
1901
|
-
function stripComments(text, replaceCh) {
|
|
1902
|
-
let _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text), parts = [], kind, offset = 0, pos;
|
|
1903
|
-
do {
|
|
1904
|
-
pos = _scanner.getPosition();
|
|
1905
|
-
kind = _scanner.scan();
|
|
1906
|
-
switch (kind) {
|
|
1907
|
-
case 12 /* SyntaxKind.LineCommentTrivia */:
|
|
1908
|
-
case 13 /* SyntaxKind.BlockCommentTrivia */:
|
|
1909
|
-
case 17 /* SyntaxKind.EOF */:
|
|
1910
|
-
if (offset !== pos) {
|
|
1911
|
-
parts.push(text.substring(offset, pos));
|
|
1912
|
-
}
|
|
1913
|
-
if (replaceCh !== undefined) {
|
|
1914
|
-
parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
|
|
1915
|
-
}
|
|
1916
|
-
offset = _scanner.getPosition();
|
|
1917
|
-
break;
|
|
1918
|
-
}
|
|
1919
|
-
} while (kind !== 17 /* SyntaxKind.EOF */);
|
|
1920
|
-
return parts.join('');
|
|
1921
|
-
}
|
|
1922
|
-
function getNodeType(value) {
|
|
1923
|
-
switch (typeof value) {
|
|
1924
|
-
case 'boolean': return 'boolean';
|
|
1925
|
-
case 'number': return 'number';
|
|
1926
|
-
case 'string': return 'string';
|
|
1927
|
-
case 'object': {
|
|
1928
|
-
if (!value) {
|
|
1929
|
-
return 'null';
|
|
1930
|
-
}
|
|
1931
|
-
else if (Array.isArray(value)) {
|
|
1932
|
-
return 'array';
|
|
1933
|
-
}
|
|
1934
|
-
return 'object';
|
|
1935
|
-
}
|
|
1936
|
-
default: return 'null';
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
/***/ }),
|
|
1942
|
-
/* 8 */
|
|
1943
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1944
|
-
|
|
1945
|
-
"use strict";
|
|
1946
|
-
|
|
1947
|
-
/*---------------------------------------------------------------------------------------------
|
|
1948
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1949
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1950
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1951
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1952
|
-
exports.BowerJSONContribution = void 0;
|
|
1953
|
-
const vscode_1 = __webpack_require__(9);
|
|
1954
|
-
const USER_AGENT = 'Visual Studio Code';
|
|
1955
|
-
class BowerJSONContribution {
|
|
1956
|
-
constructor(xhr) {
|
|
1957
|
-
this.topRanked = ['twitter', 'bootstrap', 'angular-1.1.6', 'angular-latest', 'angulerjs', 'd3', 'myjquery', 'jq', 'abcdef1234567890', 'jQuery', 'jquery-1.11.1', 'jquery',
|
|
1958
|
-
'sushi-vanilla-x-data', 'font-awsome', 'Font-Awesome', 'font-awesome', 'fontawesome', 'html5-boilerplate', 'impress.js', 'homebrew',
|
|
1959
|
-
'backbone', 'moment1', 'momentjs', 'moment', 'linux', 'animate.css', 'animate-css', 'reveal.js', 'jquery-file-upload', 'blueimp-file-upload', 'threejs', 'express', 'chosen',
|
|
1960
|
-
'normalize-css', 'normalize.css', 'semantic', 'semantic-ui', 'Semantic-UI', 'modernizr', 'underscore', 'underscore1',
|
|
1961
|
-
'material-design-icons', 'ionic', 'chartjs', 'Chart.js', 'nnnick-chartjs', 'select2-ng', 'select2-dist', 'phantom', 'skrollr', 'scrollr', 'less.js', 'leancss', 'parser-lib',
|
|
1962
|
-
'hui', 'bootstrap-languages', 'async', 'gulp', 'jquery-pjax', 'coffeescript', 'hammer.js', 'ace', 'leaflet', 'jquery-mobile', 'sweetalert', 'typeahead.js', 'soup', 'typehead.js',
|
|
1963
|
-
'sails', 'codeigniter2'];
|
|
1964
|
-
this.xhr = xhr;
|
|
1965
|
-
}
|
|
1966
|
-
getDocumentSelector() {
|
|
1967
|
-
return [{ language: 'json', scheme: '*', pattern: '**/bower.json' }, { language: 'json', scheme: '*', pattern: '**/.bower.json' }];
|
|
1968
|
-
}
|
|
1969
|
-
isEnabled() {
|
|
1970
|
-
return !!vscode_1.workspace.getConfiguration('npm').get('fetchOnlinePackageInfo');
|
|
1971
|
-
}
|
|
1972
|
-
collectDefaultSuggestions(_resource, collector) {
|
|
1973
|
-
const defaultValue = {
|
|
1974
|
-
'name': '${1:name}',
|
|
1975
|
-
'description': '${2:description}',
|
|
1976
|
-
'authors': ['${3:author}'],
|
|
1977
|
-
'version': '${4:1.0.0}',
|
|
1978
|
-
'main': '${5:pathToMain}',
|
|
1979
|
-
'dependencies': {}
|
|
1980
|
-
};
|
|
1981
|
-
const proposal = new vscode_1.CompletionItem(vscode_1.l10n.t("Default bower.json"));
|
|
1982
|
-
proposal.kind = vscode_1.CompletionItemKind.Class;
|
|
1983
|
-
proposal.insertText = new vscode_1.SnippetString(JSON.stringify(defaultValue, null, '\t'));
|
|
1984
|
-
collector.add(proposal);
|
|
1985
|
-
return Promise.resolve(null);
|
|
1986
|
-
}
|
|
1987
|
-
collectPropertySuggestions(_resource, location, currentWord, addValue, isLast, collector) {
|
|
1988
|
-
if (!this.isEnabled()) {
|
|
1989
|
-
return null;
|
|
1990
|
-
}
|
|
1991
|
-
if ((location.matches(['dependencies']) || location.matches(['devDependencies']))) {
|
|
1992
|
-
if (currentWord.length > 0) {
|
|
1993
|
-
const queryUrl = 'https://registry.bower.io/packages/search/' + encodeURIComponent(currentWord);
|
|
1994
|
-
return this.xhr({
|
|
1995
|
-
url: queryUrl,
|
|
1996
|
-
headers: { agent: USER_AGENT }
|
|
1997
|
-
}).then((success) => {
|
|
1998
|
-
if (success.status === 200) {
|
|
1999
|
-
try {
|
|
2000
|
-
const obj = JSON.parse(success.responseText);
|
|
2001
|
-
if (Array.isArray(obj)) {
|
|
2002
|
-
const results = obj;
|
|
2003
|
-
for (const result of results) {
|
|
2004
|
-
const name = result.name;
|
|
2005
|
-
const description = result.description || '';
|
|
2006
|
-
const insertText = new vscode_1.SnippetString().appendText(JSON.stringify(name));
|
|
2007
|
-
if (addValue) {
|
|
2008
|
-
insertText.appendText(': ').appendPlaceholder('latest');
|
|
2009
|
-
if (!isLast) {
|
|
2010
|
-
insertText.appendText(',');
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
const proposal = new vscode_1.CompletionItem(name);
|
|
2014
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2015
|
-
proposal.insertText = insertText;
|
|
2016
|
-
proposal.filterText = JSON.stringify(name);
|
|
2017
|
-
proposal.documentation = description;
|
|
2018
|
-
collector.add(proposal);
|
|
2019
|
-
}
|
|
2020
|
-
collector.setAsIncomplete();
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
catch (e) {
|
|
2024
|
-
// ignore
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
else {
|
|
2028
|
-
collector.error(vscode_1.l10n.t("Request to the bower repository failed: {0}", success.responseText));
|
|
2029
|
-
return 0;
|
|
2030
|
-
}
|
|
2031
|
-
return undefined;
|
|
2032
|
-
}, (error) => {
|
|
2033
|
-
collector.error(vscode_1.l10n.t("Request to the bower repository failed: {0}", error.responseText));
|
|
2034
|
-
return 0;
|
|
2035
|
-
});
|
|
2036
|
-
}
|
|
2037
|
-
else {
|
|
2038
|
-
this.topRanked.forEach((name) => {
|
|
2039
|
-
const insertText = new vscode_1.SnippetString().appendText(JSON.stringify(name));
|
|
2040
|
-
if (addValue) {
|
|
2041
|
-
insertText.appendText(': ').appendPlaceholder('latest');
|
|
2042
|
-
if (!isLast) {
|
|
2043
|
-
insertText.appendText(',');
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
const proposal = new vscode_1.CompletionItem(name);
|
|
2047
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2048
|
-
proposal.insertText = insertText;
|
|
2049
|
-
proposal.filterText = JSON.stringify(name);
|
|
2050
|
-
proposal.documentation = '';
|
|
2051
|
-
collector.add(proposal);
|
|
2052
|
-
});
|
|
2053
|
-
collector.setAsIncomplete();
|
|
2054
|
-
return Promise.resolve(null);
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
return null;
|
|
2058
|
-
}
|
|
2059
|
-
collectValueSuggestions(_resource, location, collector) {
|
|
2060
|
-
if (!this.isEnabled()) {
|
|
2061
|
-
return null;
|
|
2062
|
-
}
|
|
2063
|
-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
|
|
2064
|
-
// not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26
|
|
2065
|
-
const proposal = new vscode_1.CompletionItem(vscode_1.l10n.t("latest"));
|
|
2066
|
-
proposal.insertText = new vscode_1.SnippetString('"${1:latest}"');
|
|
2067
|
-
proposal.filterText = '""';
|
|
2068
|
-
proposal.kind = vscode_1.CompletionItemKind.Value;
|
|
2069
|
-
proposal.documentation = 'The latest version of the package';
|
|
2070
|
-
collector.add(proposal);
|
|
2071
|
-
}
|
|
2072
|
-
return null;
|
|
2073
|
-
}
|
|
2074
|
-
resolveSuggestion(_resource, item) {
|
|
2075
|
-
if (item.kind === vscode_1.CompletionItemKind.Property && item.documentation === '') {
|
|
2076
|
-
let label = item.label;
|
|
2077
|
-
if (typeof label !== 'string') {
|
|
2078
|
-
label = label.label;
|
|
2079
|
-
}
|
|
2080
|
-
return this.getInfo(label).then(documentation => {
|
|
2081
|
-
if (documentation) {
|
|
2082
|
-
item.documentation = documentation;
|
|
2083
|
-
return item;
|
|
2084
|
-
}
|
|
2085
|
-
return null;
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
|
-
return null;
|
|
2089
|
-
}
|
|
2090
|
-
getInfo(pack) {
|
|
2091
|
-
const queryUrl = 'https://registry.bower.io/packages/' + encodeURIComponent(pack);
|
|
2092
|
-
return this.xhr({
|
|
2093
|
-
url: queryUrl,
|
|
2094
|
-
headers: { agent: USER_AGENT }
|
|
2095
|
-
}).then((success) => {
|
|
2096
|
-
try {
|
|
2097
|
-
const obj = JSON.parse(success.responseText);
|
|
2098
|
-
if (obj && obj.url) {
|
|
2099
|
-
let url = obj.url;
|
|
2100
|
-
if (url.indexOf('git://') === 0) {
|
|
2101
|
-
url = url.substring(6);
|
|
2102
|
-
}
|
|
2103
|
-
if (url.length >= 4 && url.substr(url.length - 4) === '.git') {
|
|
2104
|
-
url = url.substring(0, url.length - 4);
|
|
2105
|
-
}
|
|
2106
|
-
return url;
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
catch (e) {
|
|
2110
|
-
// ignore
|
|
2111
|
-
}
|
|
2112
|
-
return undefined;
|
|
2113
|
-
}, () => {
|
|
2114
|
-
return undefined;
|
|
2115
|
-
});
|
|
2116
|
-
}
|
|
2117
|
-
getInfoContribution(_resource, location) {
|
|
2118
|
-
if (!this.isEnabled()) {
|
|
2119
|
-
return null;
|
|
2120
|
-
}
|
|
2121
|
-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) {
|
|
2122
|
-
const pack = location.path[location.path.length - 1];
|
|
2123
|
-
if (typeof pack === 'string') {
|
|
2124
|
-
return this.getInfo(pack).then(documentation => {
|
|
2125
|
-
if (documentation) {
|
|
2126
|
-
const str = new vscode_1.MarkdownString();
|
|
2127
|
-
str.appendText(documentation);
|
|
2128
|
-
return [str];
|
|
2129
|
-
}
|
|
2130
|
-
return null;
|
|
2131
|
-
});
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
return null;
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
exports.BowerJSONContribution = BowerJSONContribution;
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
/***/ }),
|
|
2141
|
-
/* 9 */
|
|
2142
|
-
/***/ ((module) => {
|
|
2143
|
-
|
|
2144
|
-
"use strict";
|
|
2145
|
-
module.exports = require("vscode");
|
|
2146
|
-
|
|
2147
|
-
/***/ }),
|
|
2148
|
-
/* 10 */
|
|
2149
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2150
|
-
|
|
2151
|
-
"use strict";
|
|
2152
|
-
|
|
2153
|
-
/*---------------------------------------------------------------------------------------------
|
|
2154
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2155
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
2156
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2157
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2158
|
-
exports.PackageJSONContribution = void 0;
|
|
2159
|
-
const vscode_1 = __webpack_require__(9);
|
|
2160
|
-
const cp = __webpack_require__(11);
|
|
2161
|
-
const path_1 = __webpack_require__(12);
|
|
2162
|
-
const date_1 = __webpack_require__(13);
|
|
2163
|
-
const LIMIT = 40;
|
|
2164
|
-
const USER_AGENT = 'Visual Studio Code';
|
|
2165
|
-
class PackageJSONContribution {
|
|
2166
|
-
getDocumentSelector() {
|
|
2167
|
-
return [{ language: 'json', scheme: '*', pattern: '**/package.json' }];
|
|
2168
|
-
}
|
|
2169
|
-
constructor(xhr, npmCommandPath) {
|
|
2170
|
-
this.xhr = xhr;
|
|
2171
|
-
this.npmCommandPath = npmCommandPath;
|
|
2172
|
-
this.mostDependedOn = ['lodash', 'async', 'underscore', 'request', 'commander', 'express', 'debug', 'chalk', 'colors', 'q', 'coffee-script',
|
|
2173
|
-
'mkdirp', 'optimist', 'through2', 'yeoman-generator', 'moment', 'bluebird', 'glob', 'gulp-util', 'minimist', 'cheerio', 'pug', 'redis', 'node-uuid',
|
|
2174
|
-
'socket', 'io', 'uglify-js', 'winston', 'through', 'fs-extra', 'handlebars', 'body-parser', 'rimraf', 'mime', 'semver', 'mongodb', 'jquery',
|
|
2175
|
-
'grunt', 'connect', 'yosay', 'underscore', 'string', 'xml2js', 'ejs', 'mongoose', 'marked', 'extend', 'mocha', 'superagent', 'js-yaml', 'xtend',
|
|
2176
|
-
'shelljs', 'gulp', 'yargs', 'browserify', 'minimatch', 'react', 'less', 'prompt', 'inquirer', 'ws', 'event-stream', 'inherits', 'mysql', 'esprima',
|
|
2177
|
-
'jsdom', 'stylus', 'when', 'readable-stream', 'aws-sdk', 'concat-stream', 'chai', 'Thenable', 'wrench'];
|
|
2178
|
-
this.knownScopes = ['@types', '@angular', '@babel', '@nuxtjs', '@vue', '@bazel'];
|
|
2179
|
-
}
|
|
2180
|
-
collectDefaultSuggestions(_resource, result) {
|
|
2181
|
-
const defaultValue = {
|
|
2182
|
-
'name': '${1:name}',
|
|
2183
|
-
'description': '${2:description}',
|
|
2184
|
-
'authors': '${3:author}',
|
|
2185
|
-
'version': '${4:1.0.0}',
|
|
2186
|
-
'main': '${5:pathToMain}',
|
|
2187
|
-
'dependencies': {}
|
|
2188
|
-
};
|
|
2189
|
-
const proposal = new vscode_1.CompletionItem(vscode_1.l10n.t("Default package.json"));
|
|
2190
|
-
proposal.kind = vscode_1.CompletionItemKind.Module;
|
|
2191
|
-
proposal.insertText = new vscode_1.SnippetString(JSON.stringify(defaultValue, null, '\t'));
|
|
2192
|
-
result.add(proposal);
|
|
2193
|
-
return Promise.resolve(null);
|
|
2194
|
-
}
|
|
2195
|
-
isEnabled() {
|
|
2196
|
-
return this.npmCommandPath || this.onlineEnabled();
|
|
2197
|
-
}
|
|
2198
|
-
onlineEnabled() {
|
|
2199
|
-
return !!vscode_1.workspace.getConfiguration('npm').get('fetchOnlinePackageInfo');
|
|
2200
|
-
}
|
|
2201
|
-
collectPropertySuggestions(_resource, location, currentWord, addValue, isLast, collector) {
|
|
2202
|
-
if (!this.isEnabled()) {
|
|
2203
|
-
return null;
|
|
2204
|
-
}
|
|
2205
|
-
if ((location.matches(['dependencies']) || location.matches(['devDependencies']) || location.matches(['optionalDependencies']) || location.matches(['peerDependencies']))) {
|
|
2206
|
-
let queryUrl;
|
|
2207
|
-
if (currentWord.length > 0) {
|
|
2208
|
-
if (currentWord[0] === '@') {
|
|
2209
|
-
if (currentWord.indexOf('/') !== -1) {
|
|
2210
|
-
return this.collectScopedPackages(currentWord, addValue, isLast, collector);
|
|
2211
|
-
}
|
|
2212
|
-
for (const scope of this.knownScopes) {
|
|
2213
|
-
const proposal = new vscode_1.CompletionItem(scope);
|
|
2214
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2215
|
-
proposal.insertText = new vscode_1.SnippetString().appendText(`"${scope}/`).appendTabstop().appendText('"');
|
|
2216
|
-
proposal.filterText = JSON.stringify(scope);
|
|
2217
|
-
proposal.documentation = '';
|
|
2218
|
-
proposal.command = {
|
|
2219
|
-
title: '',
|
|
2220
|
-
command: 'editor.action.triggerSuggest'
|
|
2221
|
-
};
|
|
2222
|
-
collector.add(proposal);
|
|
2223
|
-
}
|
|
2224
|
-
collector.setAsIncomplete();
|
|
2225
|
-
}
|
|
2226
|
-
queryUrl = `https://registry.npmjs.org/-/v1/search?size=${LIMIT}&text=${encodeURIComponent(currentWord)}`;
|
|
2227
|
-
return this.xhr({
|
|
2228
|
-
url: queryUrl,
|
|
2229
|
-
headers: { agent: USER_AGENT }
|
|
2230
|
-
}).then((success) => {
|
|
2231
|
-
if (success.status === 200) {
|
|
2232
|
-
try {
|
|
2233
|
-
const obj = JSON.parse(success.responseText);
|
|
2234
|
-
if (obj && obj.objects && Array.isArray(obj.objects)) {
|
|
2235
|
-
const results = obj.objects;
|
|
2236
|
-
for (const result of results) {
|
|
2237
|
-
this.processPackage(result.package, addValue, isLast, collector);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
catch (e) {
|
|
2242
|
-
// ignore
|
|
2243
|
-
}
|
|
2244
|
-
collector.setAsIncomplete();
|
|
2245
|
-
}
|
|
2246
|
-
else {
|
|
2247
|
-
collector.error(vscode_1.l10n.t("Request to the NPM repository failed: {0}", success.responseText));
|
|
2248
|
-
return 0;
|
|
2249
|
-
}
|
|
2250
|
-
return undefined;
|
|
2251
|
-
}, (error) => {
|
|
2252
|
-
collector.error(vscode_1.l10n.t("Request to the NPM repository failed: {0}", error.responseText));
|
|
2253
|
-
return 0;
|
|
2254
|
-
});
|
|
2255
|
-
}
|
|
2256
|
-
else {
|
|
2257
|
-
this.mostDependedOn.forEach((name) => {
|
|
2258
|
-
const insertText = new vscode_1.SnippetString().appendText(JSON.stringify(name));
|
|
2259
|
-
if (addValue) {
|
|
2260
|
-
insertText.appendText(': "').appendTabstop().appendText('"');
|
|
2261
|
-
if (!isLast) {
|
|
2262
|
-
insertText.appendText(',');
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
const proposal = new vscode_1.CompletionItem(name);
|
|
2266
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2267
|
-
proposal.insertText = insertText;
|
|
2268
|
-
proposal.filterText = JSON.stringify(name);
|
|
2269
|
-
proposal.documentation = '';
|
|
2270
|
-
collector.add(proposal);
|
|
2271
|
-
});
|
|
2272
|
-
this.collectScopedPackages(currentWord, addValue, isLast, collector);
|
|
2273
|
-
collector.setAsIncomplete();
|
|
2274
|
-
return Promise.resolve(null);
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
return null;
|
|
2278
|
-
}
|
|
2279
|
-
collectScopedPackages(currentWord, addValue, isLast, collector) {
|
|
2280
|
-
const segments = currentWord.split('/');
|
|
2281
|
-
if (segments.length === 2 && segments[0].length > 1) {
|
|
2282
|
-
const scope = segments[0].substr(1);
|
|
2283
|
-
let name = segments[1];
|
|
2284
|
-
if (name.length < 4) {
|
|
2285
|
-
name = '';
|
|
2286
|
-
}
|
|
2287
|
-
const queryUrl = `https://registry.npmjs.com/-/v1/search?text=scope:${scope}%20${name}&size=250`;
|
|
2288
|
-
return this.xhr({
|
|
2289
|
-
url: queryUrl,
|
|
2290
|
-
headers: { agent: USER_AGENT }
|
|
2291
|
-
}).then((success) => {
|
|
2292
|
-
if (success.status === 200) {
|
|
2293
|
-
try {
|
|
2294
|
-
const obj = JSON.parse(success.responseText);
|
|
2295
|
-
if (obj && Array.isArray(obj.objects)) {
|
|
2296
|
-
const objects = obj.objects;
|
|
2297
|
-
for (const object of objects) {
|
|
2298
|
-
this.processPackage(object.package, addValue, isLast, collector);
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
catch (e) {
|
|
2303
|
-
// ignore
|
|
2304
|
-
}
|
|
2305
|
-
collector.setAsIncomplete();
|
|
2306
|
-
}
|
|
2307
|
-
else {
|
|
2308
|
-
collector.error(vscode_1.l10n.t("Request to the NPM repository failed: {0}", success.responseText));
|
|
2309
|
-
}
|
|
2310
|
-
return null;
|
|
2311
|
-
});
|
|
2312
|
-
}
|
|
2313
|
-
return Promise.resolve(null);
|
|
2314
|
-
}
|
|
2315
|
-
async collectValueSuggestions(resource, location, result) {
|
|
2316
|
-
if (!this.isEnabled()) {
|
|
2317
|
-
return null;
|
|
2318
|
-
}
|
|
2319
|
-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
|
|
2320
|
-
const currentKey = location.path[location.path.length - 1];
|
|
2321
|
-
if (typeof currentKey === 'string') {
|
|
2322
|
-
const info = await this.fetchPackageInfo(currentKey, resource);
|
|
2323
|
-
if (info && info.version) {
|
|
2324
|
-
let name = JSON.stringify(info.version);
|
|
2325
|
-
let proposal = new vscode_1.CompletionItem(name);
|
|
2326
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2327
|
-
proposal.insertText = name;
|
|
2328
|
-
proposal.documentation = vscode_1.l10n.t("The currently latest version of the package");
|
|
2329
|
-
result.add(proposal);
|
|
2330
|
-
name = JSON.stringify('^' + info.version);
|
|
2331
|
-
proposal = new vscode_1.CompletionItem(name);
|
|
2332
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2333
|
-
proposal.insertText = name;
|
|
2334
|
-
proposal.documentation = vscode_1.l10n.t("Matches the most recent major version (1.x.x)");
|
|
2335
|
-
result.add(proposal);
|
|
2336
|
-
name = JSON.stringify('~' + info.version);
|
|
2337
|
-
proposal = new vscode_1.CompletionItem(name);
|
|
2338
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2339
|
-
proposal.insertText = name;
|
|
2340
|
-
proposal.documentation = vscode_1.l10n.t("Matches the most recent minor version (1.2.x)");
|
|
2341
|
-
result.add(proposal);
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
return null;
|
|
2346
|
-
}
|
|
2347
|
-
getDocumentation(description, version, time, homepage) {
|
|
2348
|
-
const str = new vscode_1.MarkdownString();
|
|
2349
|
-
if (description) {
|
|
2350
|
-
str.appendText(description);
|
|
2351
|
-
}
|
|
2352
|
-
if (version) {
|
|
2353
|
-
str.appendText('\n\n');
|
|
2354
|
-
str.appendText(time ? vscode_1.l10n.t("Latest version: {0} published {1}", version, (0, date_1.fromNow)(Date.parse(time), true, true)) : vscode_1.l10n.t("Latest version: {0}", version));
|
|
2355
|
-
}
|
|
2356
|
-
if (homepage) {
|
|
2357
|
-
str.appendText('\n\n');
|
|
2358
|
-
str.appendText(homepage);
|
|
2359
|
-
}
|
|
2360
|
-
return str;
|
|
2361
|
-
}
|
|
2362
|
-
resolveSuggestion(resource, item) {
|
|
2363
|
-
if (item.kind === vscode_1.CompletionItemKind.Property && !item.documentation) {
|
|
2364
|
-
let name = item.label;
|
|
2365
|
-
if (typeof name !== 'string') {
|
|
2366
|
-
name = name.label;
|
|
2367
|
-
}
|
|
2368
|
-
return this.fetchPackageInfo(name, resource).then(info => {
|
|
2369
|
-
if (info) {
|
|
2370
|
-
item.documentation = this.getDocumentation(info.description, info.version, info.time, info.homepage);
|
|
2371
|
-
return item;
|
|
2372
|
-
}
|
|
2373
|
-
return null;
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
return null;
|
|
2377
|
-
}
|
|
2378
|
-
isValidNPMName(name) {
|
|
2379
|
-
// following rules from https://github.com/npm/validate-npm-package-name,
|
|
2380
|
-
// leading slash added as additional security measure
|
|
2381
|
-
if (!name || name.length > 214 || name.match(/^[-_.\s]/)) {
|
|
2382
|
-
return false;
|
|
2383
|
-
}
|
|
2384
|
-
const match = name.match(/^(?:@([^/~\s)('!*]+?)[/])?([^/~)('!*\s]+?)$/);
|
|
2385
|
-
if (match) {
|
|
2386
|
-
const scope = match[1];
|
|
2387
|
-
if (scope && encodeURIComponent(scope) !== scope) {
|
|
2388
|
-
return false;
|
|
2389
|
-
}
|
|
2390
|
-
const name = match[2];
|
|
2391
|
-
return encodeURIComponent(name) === name;
|
|
2392
|
-
}
|
|
2393
|
-
return false;
|
|
2394
|
-
}
|
|
2395
|
-
async fetchPackageInfo(pack, resource) {
|
|
2396
|
-
if (!this.isValidNPMName(pack)) {
|
|
2397
|
-
return undefined; // avoid unnecessary lookups
|
|
2398
|
-
}
|
|
2399
|
-
let info;
|
|
2400
|
-
if (this.npmCommandPath) {
|
|
2401
|
-
info = await this.npmView(this.npmCommandPath, pack, resource);
|
|
2402
|
-
}
|
|
2403
|
-
if (!info && this.onlineEnabled()) {
|
|
2404
|
-
info = await this.npmjsView(pack);
|
|
2405
|
-
}
|
|
2406
|
-
return info;
|
|
2407
|
-
}
|
|
2408
|
-
npmView(npmCommandPath, pack, resource) {
|
|
2409
|
-
return new Promise((resolve, _reject) => {
|
|
2410
|
-
const args = ['view', '--json', '--', pack, 'description', 'dist-tags.latest', 'homepage', 'version', 'time'];
|
|
2411
|
-
const cwd = resource && resource.scheme === 'file' ? (0, path_1.dirname)(resource.fsPath) : undefined;
|
|
2412
|
-
cp.execFile(npmCommandPath, args, { cwd }, (error, stdout) => {
|
|
2413
|
-
if (!error) {
|
|
2414
|
-
try {
|
|
2415
|
-
const content = JSON.parse(stdout);
|
|
2416
|
-
const version = content['dist-tags.latest'] || content['version'];
|
|
2417
|
-
resolve({
|
|
2418
|
-
description: content['description'],
|
|
2419
|
-
version,
|
|
2420
|
-
time: content.time?.[version],
|
|
2421
|
-
homepage: content['homepage']
|
|
2422
|
-
});
|
|
2423
|
-
return;
|
|
2424
|
-
}
|
|
2425
|
-
catch (e) {
|
|
2426
|
-
// ignore
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
resolve(undefined);
|
|
2430
|
-
});
|
|
2431
|
-
});
|
|
2432
|
-
}
|
|
2433
|
-
async npmjsView(pack) {
|
|
2434
|
-
const queryUrl = 'https://registry.npmjs.org/' + encodeURIComponent(pack);
|
|
2435
|
-
try {
|
|
2436
|
-
const success = await this.xhr({
|
|
2437
|
-
url: queryUrl,
|
|
2438
|
-
headers: { agent: USER_AGENT }
|
|
2439
|
-
});
|
|
2440
|
-
const obj = JSON.parse(success.responseText);
|
|
2441
|
-
const version = obj['dist-tags']?.latest || Object.keys(obj.versions).pop() || '';
|
|
2442
|
-
return {
|
|
2443
|
-
description: obj.description || '',
|
|
2444
|
-
version,
|
|
2445
|
-
time: obj.time?.[version],
|
|
2446
|
-
homepage: obj.homepage || ''
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
catch (e) {
|
|
2450
|
-
//ignore
|
|
2451
|
-
}
|
|
2452
|
-
return undefined;
|
|
2453
|
-
}
|
|
2454
|
-
getInfoContribution(resource, location) {
|
|
2455
|
-
if (!this.isEnabled()) {
|
|
2456
|
-
return null;
|
|
2457
|
-
}
|
|
2458
|
-
if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) {
|
|
2459
|
-
const pack = location.path[location.path.length - 1];
|
|
2460
|
-
if (typeof pack === 'string') {
|
|
2461
|
-
return this.fetchPackageInfo(pack, resource).then(info => {
|
|
2462
|
-
if (info) {
|
|
2463
|
-
return [this.getDocumentation(info.description, info.version, info.time, info.homepage)];
|
|
2464
|
-
}
|
|
2465
|
-
return null;
|
|
2466
|
-
});
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
return null;
|
|
2470
|
-
}
|
|
2471
|
-
processPackage(pack, addValue, isLast, collector) {
|
|
2472
|
-
if (pack && pack.name) {
|
|
2473
|
-
const name = pack.name;
|
|
2474
|
-
const insertText = new vscode_1.SnippetString().appendText(JSON.stringify(name));
|
|
2475
|
-
if (addValue) {
|
|
2476
|
-
insertText.appendText(': "');
|
|
2477
|
-
if (pack.version) {
|
|
2478
|
-
insertText.appendVariable('version', pack.version);
|
|
2479
|
-
}
|
|
2480
|
-
else {
|
|
2481
|
-
insertText.appendTabstop();
|
|
2482
|
-
}
|
|
2483
|
-
insertText.appendText('"');
|
|
2484
|
-
if (!isLast) {
|
|
2485
|
-
insertText.appendText(',');
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
const proposal = new vscode_1.CompletionItem(name);
|
|
2489
|
-
proposal.kind = vscode_1.CompletionItemKind.Property;
|
|
2490
|
-
proposal.insertText = insertText;
|
|
2491
|
-
proposal.filterText = JSON.stringify(name);
|
|
2492
|
-
proposal.documentation = this.getDocumentation(pack.description, pack.version, undefined, pack?.links?.homepage);
|
|
2493
|
-
collector.add(proposal);
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
exports.PackageJSONContribution = PackageJSONContribution;
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
/***/ }),
|
|
2501
|
-
/* 11 */
|
|
2502
|
-
/***/ (() => {
|
|
2503
|
-
|
|
2504
|
-
/* (ignored) */
|
|
2505
|
-
|
|
2506
|
-
/***/ }),
|
|
2507
|
-
/* 12 */
|
|
2508
|
-
/***/ ((module) => {
|
|
2509
|
-
|
|
2510
|
-
"use strict";
|
|
2511
|
-
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
|
2512
|
-
// transplited with Babel
|
|
2513
|
-
|
|
2514
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
2515
|
-
//
|
|
2516
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2517
|
-
// copy of this software and associated documentation files (the
|
|
2518
|
-
// "Software"), to deal in the Software without restriction, including
|
|
2519
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2520
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2521
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
2522
|
-
// following conditions:
|
|
2523
|
-
//
|
|
2524
|
-
// The above copyright notice and this permission notice shall be included
|
|
2525
|
-
// in all copies or substantial portions of the Software.
|
|
2526
|
-
//
|
|
2527
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2528
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2529
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2530
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2531
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2532
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2533
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
function assertPath(path) {
|
|
2538
|
-
if (typeof path !== 'string') {
|
|
2539
|
-
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
// Resolves . and .. elements in a path with directory names
|
|
2544
|
-
function normalizeStringPosix(path, allowAboveRoot) {
|
|
2545
|
-
var res = '';
|
|
2546
|
-
var lastSegmentLength = 0;
|
|
2547
|
-
var lastSlash = -1;
|
|
2548
|
-
var dots = 0;
|
|
2549
|
-
var code;
|
|
2550
|
-
for (var i = 0; i <= path.length; ++i) {
|
|
2551
|
-
if (i < path.length)
|
|
2552
|
-
code = path.charCodeAt(i);
|
|
2553
|
-
else if (code === 47 /*/*/)
|
|
2554
|
-
break;
|
|
2555
|
-
else
|
|
2556
|
-
code = 47 /*/*/;
|
|
2557
|
-
if (code === 47 /*/*/) {
|
|
2558
|
-
if (lastSlash === i - 1 || dots === 1) {
|
|
2559
|
-
// NOOP
|
|
2560
|
-
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
2561
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
|
|
2562
|
-
if (res.length > 2) {
|
|
2563
|
-
var lastSlashIndex = res.lastIndexOf('/');
|
|
2564
|
-
if (lastSlashIndex !== res.length - 1) {
|
|
2565
|
-
if (lastSlashIndex === -1) {
|
|
2566
|
-
res = '';
|
|
2567
|
-
lastSegmentLength = 0;
|
|
2568
|
-
} else {
|
|
2569
|
-
res = res.slice(0, lastSlashIndex);
|
|
2570
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
2571
|
-
}
|
|
2572
|
-
lastSlash = i;
|
|
2573
|
-
dots = 0;
|
|
2574
|
-
continue;
|
|
2575
|
-
}
|
|
2576
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
2577
|
-
res = '';
|
|
2578
|
-
lastSegmentLength = 0;
|
|
2579
|
-
lastSlash = i;
|
|
2580
|
-
dots = 0;
|
|
2581
|
-
continue;
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
if (allowAboveRoot) {
|
|
2585
|
-
if (res.length > 0)
|
|
2586
|
-
res += '/..';
|
|
2587
|
-
else
|
|
2588
|
-
res = '..';
|
|
2589
|
-
lastSegmentLength = 2;
|
|
2590
|
-
}
|
|
2591
|
-
} else {
|
|
2592
|
-
if (res.length > 0)
|
|
2593
|
-
res += '/' + path.slice(lastSlash + 1, i);
|
|
2594
|
-
else
|
|
2595
|
-
res = path.slice(lastSlash + 1, i);
|
|
2596
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
2597
|
-
}
|
|
2598
|
-
lastSlash = i;
|
|
2599
|
-
dots = 0;
|
|
2600
|
-
} else if (code === 46 /*.*/ && dots !== -1) {
|
|
2601
|
-
++dots;
|
|
2602
|
-
} else {
|
|
2603
|
-
dots = -1;
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
return res;
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
function _format(sep, pathObject) {
|
|
2610
|
-
var dir = pathObject.dir || pathObject.root;
|
|
2611
|
-
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
|
|
2612
|
-
if (!dir) {
|
|
2613
|
-
return base;
|
|
2614
|
-
}
|
|
2615
|
-
if (dir === pathObject.root) {
|
|
2616
|
-
return dir + base;
|
|
2617
|
-
}
|
|
2618
|
-
return dir + sep + base;
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
var posix = {
|
|
2622
|
-
// path.resolve([from ...], to)
|
|
2623
|
-
resolve: function resolve() {
|
|
2624
|
-
var resolvedPath = '';
|
|
2625
|
-
var resolvedAbsolute = false;
|
|
2626
|
-
var cwd;
|
|
2627
|
-
|
|
2628
|
-
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
2629
|
-
var path;
|
|
2630
|
-
if (i >= 0)
|
|
2631
|
-
path = arguments[i];
|
|
2632
|
-
else {
|
|
2633
|
-
if (cwd === undefined)
|
|
2634
|
-
cwd = process.cwd();
|
|
2635
|
-
path = cwd;
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2638
|
-
assertPath(path);
|
|
2639
|
-
|
|
2640
|
-
// Skip empty entries
|
|
2641
|
-
if (path.length === 0) {
|
|
2642
|
-
continue;
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
|
-
resolvedPath = path + '/' + resolvedPath;
|
|
2646
|
-
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
2647
|
-
}
|
|
2648
|
-
|
|
2649
|
-
// At this point the path should be resolved to a full absolute path, but
|
|
2650
|
-
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
2651
|
-
|
|
2652
|
-
// Normalize the path
|
|
2653
|
-
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
2654
|
-
|
|
2655
|
-
if (resolvedAbsolute) {
|
|
2656
|
-
if (resolvedPath.length > 0)
|
|
2657
|
-
return '/' + resolvedPath;
|
|
2658
|
-
else
|
|
2659
|
-
return '/';
|
|
2660
|
-
} else if (resolvedPath.length > 0) {
|
|
2661
|
-
return resolvedPath;
|
|
2662
|
-
} else {
|
|
2663
|
-
return '.';
|
|
2664
|
-
}
|
|
2665
|
-
},
|
|
2666
|
-
|
|
2667
|
-
normalize: function normalize(path) {
|
|
2668
|
-
assertPath(path);
|
|
2669
|
-
|
|
2670
|
-
if (path.length === 0) return '.';
|
|
2671
|
-
|
|
2672
|
-
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
2673
|
-
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
|
|
2674
|
-
|
|
2675
|
-
// Normalize the path
|
|
2676
|
-
path = normalizeStringPosix(path, !isAbsolute);
|
|
2677
|
-
|
|
2678
|
-
if (path.length === 0 && !isAbsolute) path = '.';
|
|
2679
|
-
if (path.length > 0 && trailingSeparator) path += '/';
|
|
2680
|
-
|
|
2681
|
-
if (isAbsolute) return '/' + path;
|
|
2682
|
-
return path;
|
|
2683
|
-
},
|
|
2684
|
-
|
|
2685
|
-
isAbsolute: function isAbsolute(path) {
|
|
2686
|
-
assertPath(path);
|
|
2687
|
-
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
|
|
2688
|
-
},
|
|
2689
|
-
|
|
2690
|
-
join: function join() {
|
|
2691
|
-
if (arguments.length === 0)
|
|
2692
|
-
return '.';
|
|
2693
|
-
var joined;
|
|
2694
|
-
for (var i = 0; i < arguments.length; ++i) {
|
|
2695
|
-
var arg = arguments[i];
|
|
2696
|
-
assertPath(arg);
|
|
2697
|
-
if (arg.length > 0) {
|
|
2698
|
-
if (joined === undefined)
|
|
2699
|
-
joined = arg;
|
|
2700
|
-
else
|
|
2701
|
-
joined += '/' + arg;
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
if (joined === undefined)
|
|
2705
|
-
return '.';
|
|
2706
|
-
return posix.normalize(joined);
|
|
2707
|
-
},
|
|
2708
|
-
|
|
2709
|
-
relative: function relative(from, to) {
|
|
2710
|
-
assertPath(from);
|
|
2711
|
-
assertPath(to);
|
|
2712
|
-
|
|
2713
|
-
if (from === to) return '';
|
|
2714
|
-
|
|
2715
|
-
from = posix.resolve(from);
|
|
2716
|
-
to = posix.resolve(to);
|
|
2717
|
-
|
|
2718
|
-
if (from === to) return '';
|
|
2719
|
-
|
|
2720
|
-
// Trim any leading backslashes
|
|
2721
|
-
var fromStart = 1;
|
|
2722
|
-
for (; fromStart < from.length; ++fromStart) {
|
|
2723
|
-
if (from.charCodeAt(fromStart) !== 47 /*/*/)
|
|
2724
|
-
break;
|
|
2725
|
-
}
|
|
2726
|
-
var fromEnd = from.length;
|
|
2727
|
-
var fromLen = fromEnd - fromStart;
|
|
2728
|
-
|
|
2729
|
-
// Trim any leading backslashes
|
|
2730
|
-
var toStart = 1;
|
|
2731
|
-
for (; toStart < to.length; ++toStart) {
|
|
2732
|
-
if (to.charCodeAt(toStart) !== 47 /*/*/)
|
|
2733
|
-
break;
|
|
2734
|
-
}
|
|
2735
|
-
var toEnd = to.length;
|
|
2736
|
-
var toLen = toEnd - toStart;
|
|
2737
|
-
|
|
2738
|
-
// Compare paths to find the longest common path from root
|
|
2739
|
-
var length = fromLen < toLen ? fromLen : toLen;
|
|
2740
|
-
var lastCommonSep = -1;
|
|
2741
|
-
var i = 0;
|
|
2742
|
-
for (; i <= length; ++i) {
|
|
2743
|
-
if (i === length) {
|
|
2744
|
-
if (toLen > length) {
|
|
2745
|
-
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
|
|
2746
|
-
// We get here if `from` is the exact base path for `to`.
|
|
2747
|
-
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
2748
|
-
return to.slice(toStart + i + 1);
|
|
2749
|
-
} else if (i === 0) {
|
|
2750
|
-
// We get here if `from` is the root
|
|
2751
|
-
// For example: from='/'; to='/foo'
|
|
2752
|
-
return to.slice(toStart + i);
|
|
2753
|
-
}
|
|
2754
|
-
} else if (fromLen > length) {
|
|
2755
|
-
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
|
|
2756
|
-
// We get here if `to` is the exact base path for `from`.
|
|
2757
|
-
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
2758
|
-
lastCommonSep = i;
|
|
2759
|
-
} else if (i === 0) {
|
|
2760
|
-
// We get here if `to` is the root.
|
|
2761
|
-
// For example: from='/foo'; to='/'
|
|
2762
|
-
lastCommonSep = 0;
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
break;
|
|
2766
|
-
}
|
|
2767
|
-
var fromCode = from.charCodeAt(fromStart + i);
|
|
2768
|
-
var toCode = to.charCodeAt(toStart + i);
|
|
2769
|
-
if (fromCode !== toCode)
|
|
2770
|
-
break;
|
|
2771
|
-
else if (fromCode === 47 /*/*/)
|
|
2772
|
-
lastCommonSep = i;
|
|
2773
|
-
}
|
|
2774
|
-
|
|
2775
|
-
var out = '';
|
|
2776
|
-
// Generate the relative path based on the path difference between `to`
|
|
2777
|
-
// and `from`
|
|
2778
|
-
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
2779
|
-
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
|
|
2780
|
-
if (out.length === 0)
|
|
2781
|
-
out += '..';
|
|
2782
|
-
else
|
|
2783
|
-
out += '/..';
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
|
|
2787
|
-
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
2788
|
-
// the common path parts
|
|
2789
|
-
if (out.length > 0)
|
|
2790
|
-
return out + to.slice(toStart + lastCommonSep);
|
|
2791
|
-
else {
|
|
2792
|
-
toStart += lastCommonSep;
|
|
2793
|
-
if (to.charCodeAt(toStart) === 47 /*/*/)
|
|
2794
|
-
++toStart;
|
|
2795
|
-
return to.slice(toStart);
|
|
2796
|
-
}
|
|
2797
|
-
},
|
|
2798
|
-
|
|
2799
|
-
_makeLong: function _makeLong(path) {
|
|
2800
|
-
return path;
|
|
2801
|
-
},
|
|
2802
|
-
|
|
2803
|
-
dirname: function dirname(path) {
|
|
2804
|
-
assertPath(path);
|
|
2805
|
-
if (path.length === 0) return '.';
|
|
2806
|
-
var code = path.charCodeAt(0);
|
|
2807
|
-
var hasRoot = code === 47 /*/*/;
|
|
2808
|
-
var end = -1;
|
|
2809
|
-
var matchedSlash = true;
|
|
2810
|
-
for (var i = path.length - 1; i >= 1; --i) {
|
|
2811
|
-
code = path.charCodeAt(i);
|
|
2812
|
-
if (code === 47 /*/*/) {
|
|
2813
|
-
if (!matchedSlash) {
|
|
2814
|
-
end = i;
|
|
2815
|
-
break;
|
|
2816
|
-
}
|
|
2817
|
-
} else {
|
|
2818
|
-
// We saw the first non-path separator
|
|
2819
|
-
matchedSlash = false;
|
|
2820
|
-
}
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
if (end === -1) return hasRoot ? '/' : '.';
|
|
2824
|
-
if (hasRoot && end === 1) return '//';
|
|
2825
|
-
return path.slice(0, end);
|
|
2826
|
-
},
|
|
2827
|
-
|
|
2828
|
-
basename: function basename(path, ext) {
|
|
2829
|
-
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
|
|
2830
|
-
assertPath(path);
|
|
2831
|
-
|
|
2832
|
-
var start = 0;
|
|
2833
|
-
var end = -1;
|
|
2834
|
-
var matchedSlash = true;
|
|
2835
|
-
var i;
|
|
2836
|
-
|
|
2837
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
2838
|
-
if (ext.length === path.length && ext === path) return '';
|
|
2839
|
-
var extIdx = ext.length - 1;
|
|
2840
|
-
var firstNonSlashEnd = -1;
|
|
2841
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
2842
|
-
var code = path.charCodeAt(i);
|
|
2843
|
-
if (code === 47 /*/*/) {
|
|
2844
|
-
// If we reached a path separator that was not part of a set of path
|
|
2845
|
-
// separators at the end of the string, stop now
|
|
2846
|
-
if (!matchedSlash) {
|
|
2847
|
-
start = i + 1;
|
|
2848
|
-
break;
|
|
2849
|
-
}
|
|
2850
|
-
} else {
|
|
2851
|
-
if (firstNonSlashEnd === -1) {
|
|
2852
|
-
// We saw the first non-path separator, remember this index in case
|
|
2853
|
-
// we need it if the extension ends up not matching
|
|
2854
|
-
matchedSlash = false;
|
|
2855
|
-
firstNonSlashEnd = i + 1;
|
|
2856
|
-
}
|
|
2857
|
-
if (extIdx >= 0) {
|
|
2858
|
-
// Try to match the explicit extension
|
|
2859
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
2860
|
-
if (--extIdx === -1) {
|
|
2861
|
-
// We matched the extension, so mark this as the end of our path
|
|
2862
|
-
// component
|
|
2863
|
-
end = i;
|
|
2864
|
-
}
|
|
2865
|
-
} else {
|
|
2866
|
-
// Extension does not match, so our result is the entire path
|
|
2867
|
-
// component
|
|
2868
|
-
extIdx = -1;
|
|
2869
|
-
end = firstNonSlashEnd;
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
|
-
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
|
|
2876
|
-
return path.slice(start, end);
|
|
2877
|
-
} else {
|
|
2878
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
2879
|
-
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
2880
|
-
// If we reached a path separator that was not part of a set of path
|
|
2881
|
-
// separators at the end of the string, stop now
|
|
2882
|
-
if (!matchedSlash) {
|
|
2883
|
-
start = i + 1;
|
|
2884
|
-
break;
|
|
2885
|
-
}
|
|
2886
|
-
} else if (end === -1) {
|
|
2887
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
2888
|
-
// path component
|
|
2889
|
-
matchedSlash = false;
|
|
2890
|
-
end = i + 1;
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
|
|
2894
|
-
if (end === -1) return '';
|
|
2895
|
-
return path.slice(start, end);
|
|
2896
|
-
}
|
|
2897
|
-
},
|
|
2898
|
-
|
|
2899
|
-
extname: function extname(path) {
|
|
2900
|
-
assertPath(path);
|
|
2901
|
-
var startDot = -1;
|
|
2902
|
-
var startPart = 0;
|
|
2903
|
-
var end = -1;
|
|
2904
|
-
var matchedSlash = true;
|
|
2905
|
-
// Track the state of characters (if any) we see before our first dot and
|
|
2906
|
-
// after any path separator we find
|
|
2907
|
-
var preDotState = 0;
|
|
2908
|
-
for (var i = path.length - 1; i >= 0; --i) {
|
|
2909
|
-
var code = path.charCodeAt(i);
|
|
2910
|
-
if (code === 47 /*/*/) {
|
|
2911
|
-
// If we reached a path separator that was not part of a set of path
|
|
2912
|
-
// separators at the end of the string, stop now
|
|
2913
|
-
if (!matchedSlash) {
|
|
2914
|
-
startPart = i + 1;
|
|
2915
|
-
break;
|
|
2916
|
-
}
|
|
2917
|
-
continue;
|
|
2918
|
-
}
|
|
2919
|
-
if (end === -1) {
|
|
2920
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
2921
|
-
// extension
|
|
2922
|
-
matchedSlash = false;
|
|
2923
|
-
end = i + 1;
|
|
2924
|
-
}
|
|
2925
|
-
if (code === 46 /*.*/) {
|
|
2926
|
-
// If this is our first dot, mark it as the start of our extension
|
|
2927
|
-
if (startDot === -1)
|
|
2928
|
-
startDot = i;
|
|
2929
|
-
else if (preDotState !== 1)
|
|
2930
|
-
preDotState = 1;
|
|
2931
|
-
} else if (startDot !== -1) {
|
|
2932
|
-
// We saw a non-dot and non-path separator before our dot, so we should
|
|
2933
|
-
// have a good chance at having a non-empty extension
|
|
2934
|
-
preDotState = -1;
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
|
-
if (startDot === -1 || end === -1 ||
|
|
2939
|
-
// We saw a non-dot character immediately before the dot
|
|
2940
|
-
preDotState === 0 ||
|
|
2941
|
-
// The (right-most) trimmed path component is exactly '..'
|
|
2942
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2943
|
-
return '';
|
|
2944
|
-
}
|
|
2945
|
-
return path.slice(startDot, end);
|
|
2946
|
-
},
|
|
2947
|
-
|
|
2948
|
-
format: function format(pathObject) {
|
|
2949
|
-
if (pathObject === null || typeof pathObject !== 'object') {
|
|
2950
|
-
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
2951
|
-
}
|
|
2952
|
-
return _format('/', pathObject);
|
|
2953
|
-
},
|
|
2954
|
-
|
|
2955
|
-
parse: function parse(path) {
|
|
2956
|
-
assertPath(path);
|
|
2957
|
-
|
|
2958
|
-
var ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
|
2959
|
-
if (path.length === 0) return ret;
|
|
2960
|
-
var code = path.charCodeAt(0);
|
|
2961
|
-
var isAbsolute = code === 47 /*/*/;
|
|
2962
|
-
var start;
|
|
2963
|
-
if (isAbsolute) {
|
|
2964
|
-
ret.root = '/';
|
|
2965
|
-
start = 1;
|
|
2966
|
-
} else {
|
|
2967
|
-
start = 0;
|
|
2968
|
-
}
|
|
2969
|
-
var startDot = -1;
|
|
2970
|
-
var startPart = 0;
|
|
2971
|
-
var end = -1;
|
|
2972
|
-
var matchedSlash = true;
|
|
2973
|
-
var i = path.length - 1;
|
|
2974
|
-
|
|
2975
|
-
// Track the state of characters (if any) we see before our first dot and
|
|
2976
|
-
// after any path separator we find
|
|
2977
|
-
var preDotState = 0;
|
|
2978
|
-
|
|
2979
|
-
// Get non-dir info
|
|
2980
|
-
for (; i >= start; --i) {
|
|
2981
|
-
code = path.charCodeAt(i);
|
|
2982
|
-
if (code === 47 /*/*/) {
|
|
2983
|
-
// If we reached a path separator that was not part of a set of path
|
|
2984
|
-
// separators at the end of the string, stop now
|
|
2985
|
-
if (!matchedSlash) {
|
|
2986
|
-
startPart = i + 1;
|
|
2987
|
-
break;
|
|
2988
|
-
}
|
|
2989
|
-
continue;
|
|
2990
|
-
}
|
|
2991
|
-
if (end === -1) {
|
|
2992
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
2993
|
-
// extension
|
|
2994
|
-
matchedSlash = false;
|
|
2995
|
-
end = i + 1;
|
|
2996
|
-
}
|
|
2997
|
-
if (code === 46 /*.*/) {
|
|
2998
|
-
// If this is our first dot, mark it as the start of our extension
|
|
2999
|
-
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
|
|
3000
|
-
} else if (startDot !== -1) {
|
|
3001
|
-
// We saw a non-dot and non-path separator before our dot, so we should
|
|
3002
|
-
// have a good chance at having a non-empty extension
|
|
3003
|
-
preDotState = -1;
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
|
-
if (startDot === -1 || end === -1 ||
|
|
3008
|
-
// We saw a non-dot character immediately before the dot
|
|
3009
|
-
preDotState === 0 ||
|
|
3010
|
-
// The (right-most) trimmed path component is exactly '..'
|
|
3011
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
3012
|
-
if (end !== -1) {
|
|
3013
|
-
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
|
|
3014
|
-
}
|
|
3015
|
-
} else {
|
|
3016
|
-
if (startPart === 0 && isAbsolute) {
|
|
3017
|
-
ret.name = path.slice(1, startDot);
|
|
3018
|
-
ret.base = path.slice(1, end);
|
|
3019
|
-
} else {
|
|
3020
|
-
ret.name = path.slice(startPart, startDot);
|
|
3021
|
-
ret.base = path.slice(startPart, end);
|
|
3022
|
-
}
|
|
3023
|
-
ret.ext = path.slice(startDot, end);
|
|
3024
|
-
}
|
|
3025
|
-
|
|
3026
|
-
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
|
|
3027
|
-
|
|
3028
|
-
return ret;
|
|
3029
|
-
},
|
|
3030
|
-
|
|
3031
|
-
sep: '/',
|
|
3032
|
-
delimiter: ':',
|
|
3033
|
-
win32: null,
|
|
3034
|
-
posix: null
|
|
3035
|
-
};
|
|
3036
|
-
|
|
3037
|
-
posix.posix = posix;
|
|
3038
|
-
|
|
3039
|
-
module.exports = posix;
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
/***/ }),
|
|
3043
|
-
/* 13 */
|
|
3044
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3045
|
-
|
|
3046
|
-
"use strict";
|
|
3047
|
-
|
|
3048
|
-
/*---------------------------------------------------------------------------------------------
|
|
3049
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3050
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3051
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3052
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3053
|
-
exports.fromNow = void 0;
|
|
3054
|
-
const vscode_1 = __webpack_require__(9);
|
|
3055
|
-
const minute = 60;
|
|
3056
|
-
const hour = minute * 60;
|
|
3057
|
-
const day = hour * 24;
|
|
3058
|
-
const week = day * 7;
|
|
3059
|
-
const month = day * 30;
|
|
3060
|
-
const year = day * 365;
|
|
3061
|
-
/**
|
|
3062
|
-
* Create a localized of the time between now and the specified date.
|
|
3063
|
-
* @param date The date to generate the difference from.
|
|
3064
|
-
* @param appendAgoLabel Whether to append the " ago" to the end.
|
|
3065
|
-
* @param useFullTimeWords Whether to use full words (eg. seconds) instead of
|
|
3066
|
-
* shortened (eg. secs).
|
|
3067
|
-
* @param disallowNow Whether to disallow the string "now" when the difference
|
|
3068
|
-
* is less than 30 seconds.
|
|
3069
|
-
*/
|
|
3070
|
-
function fromNow(date, appendAgoLabel, useFullTimeWords, disallowNow) {
|
|
3071
|
-
if (typeof date !== 'number') {
|
|
3072
|
-
date = date.getTime();
|
|
3073
|
-
}
|
|
3074
|
-
const seconds = Math.round((new Date().getTime() - date) / 1000);
|
|
3075
|
-
if (seconds < -30) {
|
|
3076
|
-
return vscode_1.l10n.t('in {0}', fromNow(new Date().getTime() + seconds * 1000, false));
|
|
3077
|
-
}
|
|
3078
|
-
if (!disallowNow && seconds < 30) {
|
|
3079
|
-
return vscode_1.l10n.t('now');
|
|
3080
|
-
}
|
|
3081
|
-
let value;
|
|
3082
|
-
if (seconds < minute) {
|
|
3083
|
-
value = seconds;
|
|
3084
|
-
if (appendAgoLabel) {
|
|
3085
|
-
if (value === 1) {
|
|
3086
|
-
return useFullTimeWords
|
|
3087
|
-
? vscode_1.l10n.t('{0} second ago', value)
|
|
3088
|
-
: vscode_1.l10n.t('{0} sec ago', value);
|
|
3089
|
-
}
|
|
3090
|
-
else {
|
|
3091
|
-
return useFullTimeWords
|
|
3092
|
-
? vscode_1.l10n.t('{0} seconds ago', value)
|
|
3093
|
-
: vscode_1.l10n.t('{0} secs ago', value);
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
else {
|
|
3097
|
-
if (value === 1) {
|
|
3098
|
-
return useFullTimeWords
|
|
3099
|
-
? vscode_1.l10n.t('{0} second', value)
|
|
3100
|
-
: vscode_1.l10n.t('{0} sec', value);
|
|
3101
|
-
}
|
|
3102
|
-
else {
|
|
3103
|
-
return useFullTimeWords
|
|
3104
|
-
? vscode_1.l10n.t('{0} seconds', value)
|
|
3105
|
-
: vscode_1.l10n.t('{0} secs', value);
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
}
|
|
3109
|
-
if (seconds < hour) {
|
|
3110
|
-
value = Math.floor(seconds / minute);
|
|
3111
|
-
if (appendAgoLabel) {
|
|
3112
|
-
if (value === 1) {
|
|
3113
|
-
return useFullTimeWords
|
|
3114
|
-
? vscode_1.l10n.t('{0} minute ago', value)
|
|
3115
|
-
: vscode_1.l10n.t('{0} min ago', value);
|
|
3116
|
-
}
|
|
3117
|
-
else {
|
|
3118
|
-
return useFullTimeWords
|
|
3119
|
-
? vscode_1.l10n.t('{0} minutes ago', value)
|
|
3120
|
-
: vscode_1.l10n.t('{0} mins ago', value);
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
else {
|
|
3124
|
-
if (value === 1) {
|
|
3125
|
-
return useFullTimeWords
|
|
3126
|
-
? vscode_1.l10n.t('{0} minute', value)
|
|
3127
|
-
: vscode_1.l10n.t('{0} min', value);
|
|
3128
|
-
}
|
|
3129
|
-
else {
|
|
3130
|
-
return useFullTimeWords
|
|
3131
|
-
? vscode_1.l10n.t('{0} minutes', value)
|
|
3132
|
-
: vscode_1.l10n.t('{0} mins', value);
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
}
|
|
3136
|
-
if (seconds < day) {
|
|
3137
|
-
value = Math.floor(seconds / hour);
|
|
3138
|
-
if (appendAgoLabel) {
|
|
3139
|
-
if (value === 1) {
|
|
3140
|
-
return useFullTimeWords
|
|
3141
|
-
? vscode_1.l10n.t('{0} hour ago', value)
|
|
3142
|
-
: vscode_1.l10n.t('{0} hr ago', value);
|
|
3143
|
-
}
|
|
3144
|
-
else {
|
|
3145
|
-
return useFullTimeWords
|
|
3146
|
-
? vscode_1.l10n.t('{0} hours ago', value)
|
|
3147
|
-
: vscode_1.l10n.t('{0} hrs ago', value);
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
else {
|
|
3151
|
-
if (value === 1) {
|
|
3152
|
-
return useFullTimeWords
|
|
3153
|
-
? vscode_1.l10n.t('{0} hour', value)
|
|
3154
|
-
: vscode_1.l10n.t('{0} hr', value);
|
|
3155
|
-
}
|
|
3156
|
-
else {
|
|
3157
|
-
return useFullTimeWords
|
|
3158
|
-
? vscode_1.l10n.t('{0} hours', value)
|
|
3159
|
-
: vscode_1.l10n.t('{0} hrs', value);
|
|
3160
|
-
}
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
if (seconds < week) {
|
|
3164
|
-
value = Math.floor(seconds / day);
|
|
3165
|
-
if (appendAgoLabel) {
|
|
3166
|
-
return value === 1
|
|
3167
|
-
? vscode_1.l10n.t('{0} day ago', value)
|
|
3168
|
-
: vscode_1.l10n.t('{0} days ago', value);
|
|
3169
|
-
}
|
|
3170
|
-
else {
|
|
3171
|
-
return value === 1
|
|
3172
|
-
? vscode_1.l10n.t('{0} day', value)
|
|
3173
|
-
: vscode_1.l10n.t('{0} days', value);
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
if (seconds < month) {
|
|
3177
|
-
value = Math.floor(seconds / week);
|
|
3178
|
-
if (appendAgoLabel) {
|
|
3179
|
-
if (value === 1) {
|
|
3180
|
-
return useFullTimeWords
|
|
3181
|
-
? vscode_1.l10n.t('{0} week ago', value)
|
|
3182
|
-
: vscode_1.l10n.t('{0} wk ago', value);
|
|
3183
|
-
}
|
|
3184
|
-
else {
|
|
3185
|
-
return useFullTimeWords
|
|
3186
|
-
? vscode_1.l10n.t('{0} weeks ago', value)
|
|
3187
|
-
: vscode_1.l10n.t('{0} wks ago', value);
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
else {
|
|
3191
|
-
if (value === 1) {
|
|
3192
|
-
return useFullTimeWords
|
|
3193
|
-
? vscode_1.l10n.t('{0} week', value)
|
|
3194
|
-
: vscode_1.l10n.t('{0} wk', value);
|
|
3195
|
-
}
|
|
3196
|
-
else {
|
|
3197
|
-
return useFullTimeWords
|
|
3198
|
-
? vscode_1.l10n.t('{0} weeks', value)
|
|
3199
|
-
: vscode_1.l10n.t('{0} wks', value);
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
}
|
|
3203
|
-
if (seconds < year) {
|
|
3204
|
-
value = Math.floor(seconds / month);
|
|
3205
|
-
if (appendAgoLabel) {
|
|
3206
|
-
if (value === 1) {
|
|
3207
|
-
return useFullTimeWords
|
|
3208
|
-
? vscode_1.l10n.t('{0} month ago', value)
|
|
3209
|
-
: vscode_1.l10n.t('{0} mo ago', value);
|
|
3210
|
-
}
|
|
3211
|
-
else {
|
|
3212
|
-
return useFullTimeWords
|
|
3213
|
-
? vscode_1.l10n.t('{0} months ago', value)
|
|
3214
|
-
: vscode_1.l10n.t('{0} mos ago', value);
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
else {
|
|
3218
|
-
if (value === 1) {
|
|
3219
|
-
return useFullTimeWords
|
|
3220
|
-
? vscode_1.l10n.t('{0} month', value)
|
|
3221
|
-
: vscode_1.l10n.t('{0} mo', value);
|
|
3222
|
-
}
|
|
3223
|
-
else {
|
|
3224
|
-
return useFullTimeWords
|
|
3225
|
-
? vscode_1.l10n.t('{0} months', value)
|
|
3226
|
-
: vscode_1.l10n.t('{0} mos', value);
|
|
3227
|
-
}
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
value = Math.floor(seconds / year);
|
|
3231
|
-
if (appendAgoLabel) {
|
|
3232
|
-
if (value === 1) {
|
|
3233
|
-
return useFullTimeWords
|
|
3234
|
-
? vscode_1.l10n.t('{0} year ago', value)
|
|
3235
|
-
: vscode_1.l10n.t('{0} yr ago', value);
|
|
3236
|
-
}
|
|
3237
|
-
else {
|
|
3238
|
-
return useFullTimeWords
|
|
3239
|
-
? vscode_1.l10n.t('{0} years ago', value)
|
|
3240
|
-
: vscode_1.l10n.t('{0} yrs ago', value);
|
|
3241
|
-
}
|
|
3242
|
-
}
|
|
3243
|
-
else {
|
|
3244
|
-
if (value === 1) {
|
|
3245
|
-
return useFullTimeWords
|
|
3246
|
-
? vscode_1.l10n.t('{0} year', value)
|
|
3247
|
-
: vscode_1.l10n.t('{0} yr', value);
|
|
3248
|
-
}
|
|
3249
|
-
else {
|
|
3250
|
-
return useFullTimeWords
|
|
3251
|
-
? vscode_1.l10n.t('{0} years', value)
|
|
3252
|
-
: vscode_1.l10n.t('{0} yrs', value);
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
exports.fromNow = fromNow;
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
/***/ })
|
|
3260
|
-
/******/ ]);
|
|
3261
|
-
/************************************************************************/
|
|
3262
|
-
/******/ // The module cache
|
|
3263
|
-
/******/ var __webpack_module_cache__ = {};
|
|
3264
|
-
/******/
|
|
3265
|
-
/******/ // The require function
|
|
3266
|
-
/******/ function __webpack_require__(moduleId) {
|
|
3267
|
-
/******/ // Check if module is in cache
|
|
3268
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
3269
|
-
/******/ if (cachedModule !== undefined) {
|
|
3270
|
-
/******/ return cachedModule.exports;
|
|
3271
|
-
/******/ }
|
|
3272
|
-
/******/ // Create a new module (and put it into the cache)
|
|
3273
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
3274
|
-
/******/ // no module.id needed
|
|
3275
|
-
/******/ // no module.loaded needed
|
|
3276
|
-
/******/ exports: {}
|
|
3277
|
-
/******/ };
|
|
3278
|
-
/******/
|
|
3279
|
-
/******/ // Execute the module function
|
|
3280
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
3281
|
-
/******/
|
|
3282
|
-
/******/ // Return the exports of the module
|
|
3283
|
-
/******/ return module.exports;
|
|
3284
|
-
/******/ }
|
|
3285
|
-
/******/
|
|
3286
|
-
/************************************************************************/
|
|
3287
|
-
/******/ /* webpack/runtime/define property getters */
|
|
3288
|
-
/******/ (() => {
|
|
3289
|
-
/******/ // define getter functions for harmony exports
|
|
3290
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
3291
|
-
/******/ for(var key in definition) {
|
|
3292
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
3293
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
3294
|
-
/******/ }
|
|
3295
|
-
/******/ }
|
|
3296
|
-
/******/ };
|
|
3297
|
-
/******/ })();
|
|
3298
|
-
/******/
|
|
3299
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3300
|
-
/******/ (() => {
|
|
3301
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
3302
|
-
/******/ })();
|
|
3303
|
-
/******/
|
|
3304
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
3305
|
-
/******/ (() => {
|
|
3306
|
-
/******/ // define __esModule on exports
|
|
3307
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
3308
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
3309
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3310
|
-
/******/ }
|
|
3311
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3312
|
-
/******/ };
|
|
3313
|
-
/******/ })();
|
|
3314
|
-
/******/
|
|
3315
|
-
/************************************************************************/
|
|
3316
|
-
var __webpack_exports__ = {};
|
|
3317
|
-
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
|
3318
|
-
(() => {
|
|
3319
|
-
"use strict";
|
|
3320
|
-
var exports = __webpack_exports__;
|
|
3321
|
-
|
|
3322
|
-
/*---------------------------------------------------------------------------------------------
|
|
3323
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3324
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3325
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3326
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3327
|
-
exports.deactivate = exports.activate = void 0;
|
|
3328
|
-
const httpRequest = __webpack_require__(1);
|
|
3329
|
-
const jsonContributions_1 = __webpack_require__(2);
|
|
3330
|
-
async function activate(context) {
|
|
3331
|
-
context.subscriptions.push((0, jsonContributions_1.addJSONProviders)(httpRequest.xhr, undefined));
|
|
3332
|
-
}
|
|
3333
|
-
exports.activate = activate;
|
|
3334
|
-
function deactivate() {
|
|
3335
|
-
}
|
|
3336
|
-
exports.deactivate = deactivate;
|
|
3337
|
-
|
|
3338
|
-
})();
|
|
3339
|
-
|
|
3340
|
-
var __webpack_export_target__ = exports;
|
|
3341
|
-
for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
|
|
3342
|
-
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
3343
|
-
/******/ })()
|
|
3344
|
-
;
|
|
3345
|
-
//# sourceMappingURL=npmBrowserMain.js.map
|