vscode-json-languageservice 5.0.0 → 5.1.1
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/CHANGELOG.md +10 -2
- package/lib/esm/jsonContributions.d.ts +17 -17
- package/lib/esm/jsonContributions.js +1 -1
- package/lib/esm/jsonLanguageService.d.ts +29 -29
- package/lib/esm/jsonLanguageService.js +66 -66
- package/lib/esm/jsonLanguageTypes.d.ts +292 -279
- package/lib/esm/jsonLanguageTypes.js +55 -46
- package/lib/esm/jsonSchema.d.ts +89 -89
- package/lib/esm/jsonSchema.js +1 -1
- package/lib/esm/parser/jsonParser.js +1236 -1214
- package/lib/esm/services/configuration.js +528 -528
- package/lib/esm/services/jsonCompletion.js +924 -918
- package/lib/esm/services/jsonDocumentSymbols.js +267 -267
- package/lib/esm/services/jsonFolding.js +120 -120
- package/lib/esm/services/jsonHover.js +109 -109
- package/lib/esm/services/jsonLinks.js +72 -72
- package/lib/esm/services/jsonSchemaService.js +593 -586
- package/lib/esm/services/jsonSelectionRanges.js +61 -61
- package/lib/esm/services/jsonValidation.js +151 -151
- package/lib/esm/utils/colors.js +68 -68
- package/lib/esm/utils/glob.js +124 -124
- package/lib/esm/utils/json.js +42 -42
- package/lib/esm/utils/objects.js +68 -68
- package/lib/esm/utils/strings.js +79 -64
- package/lib/umd/jsonContributions.d.ts +17 -17
- package/lib/umd/jsonContributions.js +12 -12
- package/lib/umd/jsonLanguageService.d.ts +29 -29
- package/lib/umd/jsonLanguageService.js +94 -90
- package/lib/umd/jsonLanguageTypes.d.ts +292 -279
- package/lib/umd/jsonLanguageTypes.js +103 -93
- package/lib/umd/jsonSchema.d.ts +89 -89
- package/lib/umd/jsonSchema.js +12 -12
- package/lib/umd/parser/jsonParser.js +1265 -1243
- package/lib/umd/services/configuration.js +541 -541
- package/lib/umd/services/jsonCompletion.js +938 -932
- package/lib/umd/services/jsonDocumentSymbols.js +281 -281
- package/lib/umd/services/jsonFolding.js +134 -134
- package/lib/umd/services/jsonHover.js +123 -123
- package/lib/umd/services/jsonLinks.js +86 -86
- package/lib/umd/services/jsonSchemaService.js +609 -602
- package/lib/umd/services/jsonSelectionRanges.js +75 -75
- package/lib/umd/services/jsonValidation.js +165 -165
- package/lib/umd/utils/colors.js +84 -84
- package/lib/umd/utils/glob.js +138 -138
- package/lib/umd/utils/json.js +56 -56
- package/lib/umd/utils/objects.js +87 -87
- package/lib/umd/utils/strings.js +98 -82
- package/package.json +11 -10
package/lib/umd/utils/colors.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
(function (factory) {
|
|
6
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
-
var v = factory(require, exports);
|
|
8
|
-
if (v !== undefined) module.exports = v;
|
|
9
|
-
}
|
|
10
|
-
else if (typeof define === "function" && define.amd) {
|
|
11
|
-
define(["require", "exports"], factory);
|
|
12
|
-
}
|
|
13
|
-
})(function (require, exports) {
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = void 0;
|
|
17
|
-
const Digit0 = 48;
|
|
18
|
-
const Digit9 = 57;
|
|
19
|
-
const A = 65;
|
|
20
|
-
const a = 97;
|
|
21
|
-
const f = 102;
|
|
22
|
-
function hexDigit(charCode) {
|
|
23
|
-
if (charCode < Digit0) {
|
|
24
|
-
return 0;
|
|
25
|
-
}
|
|
26
|
-
if (charCode <= Digit9) {
|
|
27
|
-
return charCode - Digit0;
|
|
28
|
-
}
|
|
29
|
-
if (charCode < a) {
|
|
30
|
-
charCode += (a - A);
|
|
31
|
-
}
|
|
32
|
-
if (charCode >= a && charCode <= f) {
|
|
33
|
-
return charCode - a + 10;
|
|
34
|
-
}
|
|
35
|
-
return 0;
|
|
36
|
-
}
|
|
37
|
-
exports.hexDigit = hexDigit;
|
|
38
|
-
function colorFromHex(text) {
|
|
39
|
-
if (text[0] !== '#') {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
switch (text.length) {
|
|
43
|
-
case 4:
|
|
44
|
-
return {
|
|
45
|
-
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
|
46
|
-
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
|
47
|
-
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
|
48
|
-
alpha: 1
|
|
49
|
-
};
|
|
50
|
-
case 5:
|
|
51
|
-
return {
|
|
52
|
-
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
|
53
|
-
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
|
54
|
-
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
|
55
|
-
alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0,
|
|
56
|
-
};
|
|
57
|
-
case 7:
|
|
58
|
-
return {
|
|
59
|
-
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
|
60
|
-
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
|
61
|
-
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
|
62
|
-
alpha: 1
|
|
63
|
-
};
|
|
64
|
-
case 9:
|
|
65
|
-
return {
|
|
66
|
-
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
|
67
|
-
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
|
68
|
-
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
|
69
|
-
alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
exports.colorFromHex = colorFromHex;
|
|
75
|
-
function colorFrom256RGB(red, green, blue, alpha = 1.0) {
|
|
76
|
-
return {
|
|
77
|
-
red: red / 255.0,
|
|
78
|
-
green: green / 255.0,
|
|
79
|
-
blue: blue / 255.0,
|
|
80
|
-
alpha
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.colorFrom256RGB = colorFrom256RGB;
|
|
84
|
-
});
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
(function (factory) {
|
|
6
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
+
var v = factory(require, exports);
|
|
8
|
+
if (v !== undefined) module.exports = v;
|
|
9
|
+
}
|
|
10
|
+
else if (typeof define === "function" && define.amd) {
|
|
11
|
+
define(["require", "exports"], factory);
|
|
12
|
+
}
|
|
13
|
+
})(function (require, exports) {
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = void 0;
|
|
17
|
+
const Digit0 = 48;
|
|
18
|
+
const Digit9 = 57;
|
|
19
|
+
const A = 65;
|
|
20
|
+
const a = 97;
|
|
21
|
+
const f = 102;
|
|
22
|
+
function hexDigit(charCode) {
|
|
23
|
+
if (charCode < Digit0) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
if (charCode <= Digit9) {
|
|
27
|
+
return charCode - Digit0;
|
|
28
|
+
}
|
|
29
|
+
if (charCode < a) {
|
|
30
|
+
charCode += (a - A);
|
|
31
|
+
}
|
|
32
|
+
if (charCode >= a && charCode <= f) {
|
|
33
|
+
return charCode - a + 10;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
exports.hexDigit = hexDigit;
|
|
38
|
+
function colorFromHex(text) {
|
|
39
|
+
if (text[0] !== '#') {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
switch (text.length) {
|
|
43
|
+
case 4:
|
|
44
|
+
return {
|
|
45
|
+
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
|
46
|
+
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
|
47
|
+
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
|
48
|
+
alpha: 1
|
|
49
|
+
};
|
|
50
|
+
case 5:
|
|
51
|
+
return {
|
|
52
|
+
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
|
53
|
+
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
|
54
|
+
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
|
55
|
+
alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0,
|
|
56
|
+
};
|
|
57
|
+
case 7:
|
|
58
|
+
return {
|
|
59
|
+
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
|
60
|
+
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
|
61
|
+
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
|
62
|
+
alpha: 1
|
|
63
|
+
};
|
|
64
|
+
case 9:
|
|
65
|
+
return {
|
|
66
|
+
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
|
67
|
+
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
|
68
|
+
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
|
69
|
+
alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
exports.colorFromHex = colorFromHex;
|
|
75
|
+
function colorFrom256RGB(red, green, blue, alpha = 1.0) {
|
|
76
|
+
return {
|
|
77
|
+
red: red / 255.0,
|
|
78
|
+
green: green / 255.0,
|
|
79
|
+
blue: blue / 255.0,
|
|
80
|
+
alpha
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.colorFrom256RGB = colorFrom256RGB;
|
|
84
|
+
});
|
package/lib/umd/utils/glob.js
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createRegex = void 0;
|
|
13
|
-
/*---------------------------------------------------------------------------------------------
|
|
14
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
-
* Copyright (c) 2013, Nick Fitzgerald
|
|
16
|
-
* Licensed under the MIT License. See LICENCE.md in the project root for license information.
|
|
17
|
-
*--------------------------------------------------------------------------------------------*/
|
|
18
|
-
function createRegex(glob, opts) {
|
|
19
|
-
if (typeof glob !== 'string') {
|
|
20
|
-
throw new TypeError('Expected a string');
|
|
21
|
-
}
|
|
22
|
-
const str = String(glob);
|
|
23
|
-
// The regexp we are building, as a string.
|
|
24
|
-
let reStr = "";
|
|
25
|
-
// Whether we are matching so called "extended" globs (like bash) and should
|
|
26
|
-
// support single character matching, matching ranges of characters, group
|
|
27
|
-
// matching, etc.
|
|
28
|
-
const extended = opts ? !!opts.extended : false;
|
|
29
|
-
// When globstar is _false_ (default), '/foo/*' is translated a regexp like
|
|
30
|
-
// '^\/foo\/.*$' which will match any string beginning with '/foo/'
|
|
31
|
-
// When globstar is _true_, '/foo/*' is translated to regexp like
|
|
32
|
-
// '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
|
|
33
|
-
// which does not have a '/' to the right of it.
|
|
34
|
-
// E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
|
|
35
|
-
// these will not '/foo/bar/baz', '/foo/bar/baz.txt'
|
|
36
|
-
// Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
|
|
37
|
-
// globstar is _false_
|
|
38
|
-
const globstar = opts ? !!opts.globstar : false;
|
|
39
|
-
// If we are doing extended matching, this boolean is true when we are inside
|
|
40
|
-
// a group (eg {*.html,*.js}), and false otherwise.
|
|
41
|
-
let inGroup = false;
|
|
42
|
-
// RegExp flags (eg "i" ) to pass in to RegExp constructor.
|
|
43
|
-
const flags = opts && typeof (opts.flags) === "string" ? opts.flags : "";
|
|
44
|
-
let c;
|
|
45
|
-
for (let i = 0, len = str.length; i < len; i++) {
|
|
46
|
-
c = str[i];
|
|
47
|
-
switch (c) {
|
|
48
|
-
case "/":
|
|
49
|
-
case "$":
|
|
50
|
-
case "^":
|
|
51
|
-
case "+":
|
|
52
|
-
case ".":
|
|
53
|
-
case "(":
|
|
54
|
-
case ")":
|
|
55
|
-
case "=":
|
|
56
|
-
case "!":
|
|
57
|
-
case "|":
|
|
58
|
-
reStr += "\\" + c;
|
|
59
|
-
break;
|
|
60
|
-
case "?":
|
|
61
|
-
if (extended) {
|
|
62
|
-
reStr += ".";
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
case "[":
|
|
66
|
-
case "]":
|
|
67
|
-
if (extended) {
|
|
68
|
-
reStr += c;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "{":
|
|
72
|
-
if (extended) {
|
|
73
|
-
inGroup = true;
|
|
74
|
-
reStr += "(";
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
case "}":
|
|
78
|
-
if (extended) {
|
|
79
|
-
inGroup = false;
|
|
80
|
-
reStr += ")";
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case ",":
|
|
84
|
-
if (inGroup) {
|
|
85
|
-
reStr += "|";
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
reStr += "\\" + c;
|
|
89
|
-
break;
|
|
90
|
-
case "*":
|
|
91
|
-
// Move over all consecutive "*"'s.
|
|
92
|
-
// Also store the previous and next characters
|
|
93
|
-
const prevChar = str[i - 1];
|
|
94
|
-
let starCount = 1;
|
|
95
|
-
while (str[i + 1] === "*") {
|
|
96
|
-
starCount++;
|
|
97
|
-
i++;
|
|
98
|
-
}
|
|
99
|
-
const nextChar = str[i + 1];
|
|
100
|
-
if (!globstar) {
|
|
101
|
-
// globstar is disabled, so treat any number of "*" as one
|
|
102
|
-
reStr += ".*";
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
// globstar is enabled, so determine if this is a globstar segment
|
|
106
|
-
const isGlobstar = starCount > 1 // multiple "*"'s
|
|
107
|
-
&& (prevChar === "/" || prevChar === undefined || prevChar === '{' || prevChar === ',') // from the start of the segment
|
|
108
|
-
&& (nextChar === "/" || nextChar === undefined || nextChar === ',' || nextChar === '}'); // to the end of the segment
|
|
109
|
-
if (isGlobstar) {
|
|
110
|
-
if (nextChar === "/") {
|
|
111
|
-
i++; // move over the "/"
|
|
112
|
-
}
|
|
113
|
-
else if (prevChar === '/' && reStr.endsWith('\\/')) {
|
|
114
|
-
reStr = reStr.substr(0, reStr.length - 2);
|
|
115
|
-
}
|
|
116
|
-
// it's a globstar, so match zero or more path segments
|
|
117
|
-
reStr += "((?:[^/]*(?:\/|$))*)";
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
// it's not a globstar, so only match one path segment
|
|
121
|
-
reStr += "([^/]*)";
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
reStr += c;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// When regexp 'g' flag is specified don't
|
|
130
|
-
// constrain the regular expression with ^ & $
|
|
131
|
-
if (!flags || !~flags.indexOf('g')) {
|
|
132
|
-
reStr = "^" + reStr + "$";
|
|
133
|
-
}
|
|
134
|
-
return new RegExp(reStr, flags);
|
|
135
|
-
}
|
|
136
|
-
exports.createRegex = createRegex;
|
|
137
|
-
;
|
|
138
|
-
});
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createRegex = void 0;
|
|
13
|
+
/*---------------------------------------------------------------------------------------------
|
|
14
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
+
* Copyright (c) 2013, Nick Fitzgerald
|
|
16
|
+
* Licensed under the MIT License. See LICENCE.md in the project root for license information.
|
|
17
|
+
*--------------------------------------------------------------------------------------------*/
|
|
18
|
+
function createRegex(glob, opts) {
|
|
19
|
+
if (typeof glob !== 'string') {
|
|
20
|
+
throw new TypeError('Expected a string');
|
|
21
|
+
}
|
|
22
|
+
const str = String(glob);
|
|
23
|
+
// The regexp we are building, as a string.
|
|
24
|
+
let reStr = "";
|
|
25
|
+
// Whether we are matching so called "extended" globs (like bash) and should
|
|
26
|
+
// support single character matching, matching ranges of characters, group
|
|
27
|
+
// matching, etc.
|
|
28
|
+
const extended = opts ? !!opts.extended : false;
|
|
29
|
+
// When globstar is _false_ (default), '/foo/*' is translated a regexp like
|
|
30
|
+
// '^\/foo\/.*$' which will match any string beginning with '/foo/'
|
|
31
|
+
// When globstar is _true_, '/foo/*' is translated to regexp like
|
|
32
|
+
// '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
|
|
33
|
+
// which does not have a '/' to the right of it.
|
|
34
|
+
// E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
|
|
35
|
+
// these will not '/foo/bar/baz', '/foo/bar/baz.txt'
|
|
36
|
+
// Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
|
|
37
|
+
// globstar is _false_
|
|
38
|
+
const globstar = opts ? !!opts.globstar : false;
|
|
39
|
+
// If we are doing extended matching, this boolean is true when we are inside
|
|
40
|
+
// a group (eg {*.html,*.js}), and false otherwise.
|
|
41
|
+
let inGroup = false;
|
|
42
|
+
// RegExp flags (eg "i" ) to pass in to RegExp constructor.
|
|
43
|
+
const flags = opts && typeof (opts.flags) === "string" ? opts.flags : "";
|
|
44
|
+
let c;
|
|
45
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
46
|
+
c = str[i];
|
|
47
|
+
switch (c) {
|
|
48
|
+
case "/":
|
|
49
|
+
case "$":
|
|
50
|
+
case "^":
|
|
51
|
+
case "+":
|
|
52
|
+
case ".":
|
|
53
|
+
case "(":
|
|
54
|
+
case ")":
|
|
55
|
+
case "=":
|
|
56
|
+
case "!":
|
|
57
|
+
case "|":
|
|
58
|
+
reStr += "\\" + c;
|
|
59
|
+
break;
|
|
60
|
+
case "?":
|
|
61
|
+
if (extended) {
|
|
62
|
+
reStr += ".";
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "[":
|
|
66
|
+
case "]":
|
|
67
|
+
if (extended) {
|
|
68
|
+
reStr += c;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "{":
|
|
72
|
+
if (extended) {
|
|
73
|
+
inGroup = true;
|
|
74
|
+
reStr += "(";
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "}":
|
|
78
|
+
if (extended) {
|
|
79
|
+
inGroup = false;
|
|
80
|
+
reStr += ")";
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case ",":
|
|
84
|
+
if (inGroup) {
|
|
85
|
+
reStr += "|";
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
reStr += "\\" + c;
|
|
89
|
+
break;
|
|
90
|
+
case "*":
|
|
91
|
+
// Move over all consecutive "*"'s.
|
|
92
|
+
// Also store the previous and next characters
|
|
93
|
+
const prevChar = str[i - 1];
|
|
94
|
+
let starCount = 1;
|
|
95
|
+
while (str[i + 1] === "*") {
|
|
96
|
+
starCount++;
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
99
|
+
const nextChar = str[i + 1];
|
|
100
|
+
if (!globstar) {
|
|
101
|
+
// globstar is disabled, so treat any number of "*" as one
|
|
102
|
+
reStr += ".*";
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// globstar is enabled, so determine if this is a globstar segment
|
|
106
|
+
const isGlobstar = starCount > 1 // multiple "*"'s
|
|
107
|
+
&& (prevChar === "/" || prevChar === undefined || prevChar === '{' || prevChar === ',') // from the start of the segment
|
|
108
|
+
&& (nextChar === "/" || nextChar === undefined || nextChar === ',' || nextChar === '}'); // to the end of the segment
|
|
109
|
+
if (isGlobstar) {
|
|
110
|
+
if (nextChar === "/") {
|
|
111
|
+
i++; // move over the "/"
|
|
112
|
+
}
|
|
113
|
+
else if (prevChar === '/' && reStr.endsWith('\\/')) {
|
|
114
|
+
reStr = reStr.substr(0, reStr.length - 2);
|
|
115
|
+
}
|
|
116
|
+
// it's a globstar, so match zero or more path segments
|
|
117
|
+
reStr += "((?:[^/]*(?:\/|$))*)";
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// it's not a globstar, so only match one path segment
|
|
121
|
+
reStr += "([^/]*)";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
reStr += c;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// When regexp 'g' flag is specified don't
|
|
130
|
+
// constrain the regular expression with ^ & $
|
|
131
|
+
if (!flags || !~flags.indexOf('g')) {
|
|
132
|
+
reStr = "^" + reStr + "$";
|
|
133
|
+
}
|
|
134
|
+
return new RegExp(reStr, flags);
|
|
135
|
+
}
|
|
136
|
+
exports.createRegex = createRegex;
|
|
137
|
+
;
|
|
138
|
+
});
|
package/lib/umd/utils/json.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
(function (factory) {
|
|
6
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
-
var v = factory(require, exports);
|
|
8
|
-
if (v !== undefined) module.exports = v;
|
|
9
|
-
}
|
|
10
|
-
else if (typeof define === "function" && define.amd) {
|
|
11
|
-
define(["require", "exports"], factory);
|
|
12
|
-
}
|
|
13
|
-
})(function (require, exports) {
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.stringifyObject = void 0;
|
|
17
|
-
function stringifyObject(obj, indent, stringifyLiteral) {
|
|
18
|
-
if (obj !== null && typeof obj === 'object') {
|
|
19
|
-
const newIndent = indent + '\t';
|
|
20
|
-
if (Array.isArray(obj)) {
|
|
21
|
-
if (obj.length === 0) {
|
|
22
|
-
return '[]';
|
|
23
|
-
}
|
|
24
|
-
let result = '[\n';
|
|
25
|
-
for (let i = 0; i < obj.length; i++) {
|
|
26
|
-
result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
|
|
27
|
-
if (i < obj.length - 1) {
|
|
28
|
-
result += ',';
|
|
29
|
-
}
|
|
30
|
-
result += '\n';
|
|
31
|
-
}
|
|
32
|
-
result += indent + ']';
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const keys = Object.keys(obj);
|
|
37
|
-
if (keys.length === 0) {
|
|
38
|
-
return '{}';
|
|
39
|
-
}
|
|
40
|
-
let result = '{\n';
|
|
41
|
-
for (let i = 0; i < keys.length; i++) {
|
|
42
|
-
const key = keys[i];
|
|
43
|
-
result += newIndent + JSON.stringify(key) + ': ' + stringifyObject(obj[key], newIndent, stringifyLiteral);
|
|
44
|
-
if (i < keys.length - 1) {
|
|
45
|
-
result += ',';
|
|
46
|
-
}
|
|
47
|
-
result += '\n';
|
|
48
|
-
}
|
|
49
|
-
result += indent + '}';
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return stringifyLiteral(obj);
|
|
54
|
-
}
|
|
55
|
-
exports.stringifyObject = stringifyObject;
|
|
56
|
-
});
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
(function (factory) {
|
|
6
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
+
var v = factory(require, exports);
|
|
8
|
+
if (v !== undefined) module.exports = v;
|
|
9
|
+
}
|
|
10
|
+
else if (typeof define === "function" && define.amd) {
|
|
11
|
+
define(["require", "exports"], factory);
|
|
12
|
+
}
|
|
13
|
+
})(function (require, exports) {
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.stringifyObject = void 0;
|
|
17
|
+
function stringifyObject(obj, indent, stringifyLiteral) {
|
|
18
|
+
if (obj !== null && typeof obj === 'object') {
|
|
19
|
+
const newIndent = indent + '\t';
|
|
20
|
+
if (Array.isArray(obj)) {
|
|
21
|
+
if (obj.length === 0) {
|
|
22
|
+
return '[]';
|
|
23
|
+
}
|
|
24
|
+
let result = '[\n';
|
|
25
|
+
for (let i = 0; i < obj.length; i++) {
|
|
26
|
+
result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
|
|
27
|
+
if (i < obj.length - 1) {
|
|
28
|
+
result += ',';
|
|
29
|
+
}
|
|
30
|
+
result += '\n';
|
|
31
|
+
}
|
|
32
|
+
result += indent + ']';
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const keys = Object.keys(obj);
|
|
37
|
+
if (keys.length === 0) {
|
|
38
|
+
return '{}';
|
|
39
|
+
}
|
|
40
|
+
let result = '{\n';
|
|
41
|
+
for (let i = 0; i < keys.length; i++) {
|
|
42
|
+
const key = keys[i];
|
|
43
|
+
result += newIndent + JSON.stringify(key) + ': ' + stringifyObject(obj[key], newIndent, stringifyLiteral);
|
|
44
|
+
if (i < keys.length - 1) {
|
|
45
|
+
result += ',';
|
|
46
|
+
}
|
|
47
|
+
result += '\n';
|
|
48
|
+
}
|
|
49
|
+
result += indent + '}';
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return stringifyLiteral(obj);
|
|
54
|
+
}
|
|
55
|
+
exports.stringifyObject = stringifyObject;
|
|
56
|
+
});
|