@swagger-api/apidom-parser-adapter-api-design-systems-yaml 0.74.0 → 0.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -13
- package/NOTICE +1 -1
- package/dist/apidom-parser-adapter-api-design-systems-yaml.browser.js +251 -262
- package/dist/apidom-parser-adapter-api-design-systems-yaml.browser.min.js +1 -2
- package/package.json +5 -5
- package/dist/apidom-parser-adapter-api-design-systems-yaml.browser.min.js.LICENSE.txt +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,38 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [0.
|
|
6
|
+
# [0.75.0](https://github.com/swagger-api/apidom/compare/v0.74.1...v0.75.0) (2023-08-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
9
9
|
|
|
10
|
+
## [0.74.1](https://github.com/swagger-api/apidom/compare/v0.74.0...v0.74.1) (2023-07-28)
|
|
10
11
|
|
|
12
|
+
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
11
13
|
|
|
14
|
+
# [0.74.0](https://github.com/swagger-api/apidom/compare/v0.73.0...v0.74.0) (2023-07-24)
|
|
12
15
|
|
|
16
|
+
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
13
17
|
|
|
14
18
|
# [0.73.0](https://github.com/swagger-api/apidom/compare/v0.72.0...v0.73.0) (2023-07-18)
|
|
15
19
|
|
|
16
20
|
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
22
|
# [0.72.0](https://github.com/swagger-api/apidom/compare/v0.71.1...v0.72.0) (2023-07-17)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
26
|
# [0.71.0](https://github.com/swagger-api/apidom/compare/v0.70.4...v0.71.0) (2023-07-13)
|
|
31
27
|
|
|
32
28
|
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
30
|
## [0.70.3](https://github.com/swagger-api/apidom/compare/v0.70.2...v0.70.3) (2023-06-27)
|
|
39
31
|
|
|
40
32
|
**Note:** Version bump only for package @swagger-api/apidom-parser-adapter-api-design-systems-yaml
|
package/NOTICE
CHANGED
|
@@ -38,7 +38,7 @@ Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
|
38
38
|
- File packages/apidom-core/src/deepmerge.ts contains algorithms that we originally created
|
|
39
39
|
in https://github.com/TehShrike/deepmerge/blob/master/index.js to handle deep merging of JavaScript Objects and Arrays.
|
|
40
40
|
These algorithms have been reverse engineered and adapted to support deep merging of ApiDOM structures.
|
|
41
|
-
- File packages/apidom-core/test/deepmerge.ts contains tests and fixtures that
|
|
41
|
+
- File packages/apidom-core/test/deepmerge.ts contains tests and fixtures that were originally created
|
|
42
42
|
in https://github.com/TehShrike/deepmerge/blob/master/test/merge.js to test deep merging of JavaScript Objects and Arrays.
|
|
43
43
|
These tests have been adapted to support testing deep merging of ApiDOM structures.
|
|
44
44
|
- File packages/apidom-core/README.md contains text fragments that were originally created
|
|
@@ -11002,72 +11002,67 @@ var trimStart = (0,_isFunction__WEBPACK_IMPORTED_MODULE_2__["default"])(String.p
|
|
|
11002
11002
|
/***/ ((__unused_webpack_module, exports) => {
|
|
11003
11003
|
|
|
11004
11004
|
"use strict";
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
*
|
|
11026
|
-
*
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
*
|
|
11032
|
-
*
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
*
|
|
11038
|
-
*
|
|
11039
|
-
*/
|
|
11040
|
-
ErrorType["
|
|
11041
|
-
/**
|
|
11042
|
-
* Thrown when
|
|
11043
|
-
*
|
|
11044
|
-
*/
|
|
11045
|
-
ErrorType["
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
[
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
],
|
|
11063
|
-
[
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
'for octal literals use the "0o" prefix instead'
|
|
11067
|
-
],
|
|
11068
|
-
[ErrorType.EndOfString, "malformed escape sequence at end of string"]
|
|
11069
|
-
]);
|
|
11070
|
-
//# sourceMappingURL=errors.js.map
|
|
11005
|
+
|
|
11006
|
+
// NOTE: don't construct errors here or they'll have the wrong stack trace.
|
|
11007
|
+
// NOTE: don't make custom error class; the JS engines use `SyntaxError`
|
|
11008
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11009
|
+
exports.errorMessages = exports.ErrorType = void 0;
|
|
11010
|
+
/**
|
|
11011
|
+
* Keys for possible error messages used by `unraw`.
|
|
11012
|
+
* Note: These do _not_ map to actual error object types. All errors thrown
|
|
11013
|
+
* are `SyntaxError`.
|
|
11014
|
+
*/
|
|
11015
|
+
// Don't use const enum or JS users won't be able to access the enum values
|
|
11016
|
+
var ErrorType;
|
|
11017
|
+
(function (ErrorType) {
|
|
11018
|
+
/**
|
|
11019
|
+
* Thrown when a badly formed Unicode escape sequence is found. Possible
|
|
11020
|
+
* reasons include the code being too short (`"\u25"`) or having invalid
|
|
11021
|
+
* characters (`"\u2$A5"`).
|
|
11022
|
+
*/
|
|
11023
|
+
ErrorType["MalformedUnicode"] = "MALFORMED_UNICODE";
|
|
11024
|
+
/**
|
|
11025
|
+
* Thrown when a badly formed hexadecimal escape sequence is found. Possible
|
|
11026
|
+
* reasons include the code being too short (`"\x2"`) or having invalid
|
|
11027
|
+
* characters (`"\x2$"`).
|
|
11028
|
+
*/
|
|
11029
|
+
ErrorType["MalformedHexadecimal"] = "MALFORMED_HEXADECIMAL";
|
|
11030
|
+
/**
|
|
11031
|
+
* Thrown when a Unicode code point escape sequence has too high of a code
|
|
11032
|
+
* point. The maximum code point allowed is `\u{10FFFF}`, so `\u{110000}` and
|
|
11033
|
+
* higher will throw this error.
|
|
11034
|
+
*/
|
|
11035
|
+
ErrorType["CodePointLimit"] = "CODE_POINT_LIMIT";
|
|
11036
|
+
/**
|
|
11037
|
+
* Thrown when an octal escape sequences is encountered and `allowOctals` is
|
|
11038
|
+
* `false`. For example, `unraw("\234", false)`.
|
|
11039
|
+
*/
|
|
11040
|
+
ErrorType["OctalDeprecation"] = "OCTAL_DEPRECATION";
|
|
11041
|
+
/**
|
|
11042
|
+
* Thrown only when a single backslash is found at the end of a string. For
|
|
11043
|
+
* example, `"\\"` or `"test\\x24\\"`.
|
|
11044
|
+
*/
|
|
11045
|
+
ErrorType["EndOfString"] = "END_OF_STRING";
|
|
11046
|
+
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
11047
|
+
/** Map of error message names to the full text of the message. */
|
|
11048
|
+
exports.errorMessages = new Map([
|
|
11049
|
+
[ErrorType.MalformedUnicode, "malformed Unicode character escape sequence"],
|
|
11050
|
+
[
|
|
11051
|
+
ErrorType.MalformedHexadecimal,
|
|
11052
|
+
"malformed hexadecimal character escape sequence"
|
|
11053
|
+
],
|
|
11054
|
+
[
|
|
11055
|
+
ErrorType.CodePointLimit,
|
|
11056
|
+
"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"
|
|
11057
|
+
],
|
|
11058
|
+
[
|
|
11059
|
+
ErrorType.OctalDeprecation,
|
|
11060
|
+
'"0"-prefixed octal literals and octal escape sequences are deprecated; ' +
|
|
11061
|
+
'for octal literals use the "0o" prefix instead'
|
|
11062
|
+
],
|
|
11063
|
+
[ErrorType.EndOfString, "malformed escape sequence at end of string"]
|
|
11064
|
+
]);
|
|
11065
|
+
|
|
11071
11066
|
|
|
11072
11067
|
/***/ }),
|
|
11073
11068
|
|
|
@@ -11075,202 +11070,196 @@ exports.errorMessages = new Map([
|
|
|
11075
11070
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
11076
11071
|
|
|
11077
11072
|
"use strict";
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
*
|
|
11104
|
-
*
|
|
11105
|
-
* @
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
}
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
*
|
|
11135
|
-
*
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
*
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
}
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
}
|
|
11182
|
-
//
|
|
11183
|
-
//
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
["
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
*
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
*
|
|
11216
|
-
*
|
|
11217
|
-
*
|
|
11218
|
-
*
|
|
11219
|
-
*
|
|
11220
|
-
*
|
|
11221
|
-
*
|
|
11222
|
-
*
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
*
|
|
11227
|
-
*
|
|
11228
|
-
*
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
*
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
if (
|
|
11245
|
-
return
|
|
11246
|
-
}
|
|
11247
|
-
if (
|
|
11248
|
-
return
|
|
11249
|
-
}
|
|
11250
|
-
if (
|
|
11251
|
-
return
|
|
11252
|
-
}
|
|
11253
|
-
if (
|
|
11254
|
-
return
|
|
11255
|
-
}
|
|
11256
|
-
if (
|
|
11257
|
-
return
|
|
11258
|
-
}
|
|
11259
|
-
if (
|
|
11260
|
-
return
|
|
11261
|
-
}
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.EndOfString));
|
|
11269
|
-
});
|
|
11270
|
-
}
|
|
11271
|
-
exports.unraw = unraw;
|
|
11272
|
-
exports["default"] = unraw;
|
|
11273
|
-
//# sourceMappingURL=index.js.map
|
|
11073
|
+
|
|
11074
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11075
|
+
exports.unraw = exports.errorMessages = exports.ErrorType = void 0;
|
|
11076
|
+
const errors_1 = __webpack_require__(42396);
|
|
11077
|
+
Object.defineProperty(exports, "ErrorType", ({ enumerable: true, get: function () { return errors_1.ErrorType; } }));
|
|
11078
|
+
Object.defineProperty(exports, "errorMessages", ({ enumerable: true, get: function () { return errors_1.errorMessages; } }));
|
|
11079
|
+
/**
|
|
11080
|
+
* Parse a string as a base-16 number. This is more strict than `parseInt` as it
|
|
11081
|
+
* will not allow any other characters, including (for example) "+", "-", and
|
|
11082
|
+
* ".".
|
|
11083
|
+
* @param hex A string containing a hexadecimal number.
|
|
11084
|
+
* @returns The parsed integer, or `NaN` if the string is not a valid hex
|
|
11085
|
+
* number.
|
|
11086
|
+
*/
|
|
11087
|
+
function parseHexToInt(hex) {
|
|
11088
|
+
const isOnlyHexChars = !hex.match(/[^a-f0-9]/i);
|
|
11089
|
+
return isOnlyHexChars ? parseInt(hex, 16) : NaN;
|
|
11090
|
+
}
|
|
11091
|
+
/**
|
|
11092
|
+
* Check the validity and length of a hexadecimal code and optionally enforces
|
|
11093
|
+
* a specific number of hex digits.
|
|
11094
|
+
* @param hex The string to validate and parse.
|
|
11095
|
+
* @param errorName The name of the error message to throw a `SyntaxError` with
|
|
11096
|
+
* if `hex` is invalid. This is used to index `errorMessages`.
|
|
11097
|
+
* @param enforcedLength If provided, will throw an error if `hex` is not
|
|
11098
|
+
* exactly this many characters.
|
|
11099
|
+
* @returns The parsed hex number as a normal number.
|
|
11100
|
+
* @throws {SyntaxError} If the code is not valid.
|
|
11101
|
+
*/
|
|
11102
|
+
function validateAndParseHex(hex, errorName, enforcedLength) {
|
|
11103
|
+
const parsedHex = parseHexToInt(hex);
|
|
11104
|
+
if (Number.isNaN(parsedHex) ||
|
|
11105
|
+
(enforcedLength !== undefined && enforcedLength !== hex.length)) {
|
|
11106
|
+
throw new SyntaxError(errors_1.errorMessages.get(errorName));
|
|
11107
|
+
}
|
|
11108
|
+
return parsedHex;
|
|
11109
|
+
}
|
|
11110
|
+
/**
|
|
11111
|
+
* Parse a two-digit hexadecimal character escape code.
|
|
11112
|
+
* @param code The two-digit hexadecimal number that represents the character to
|
|
11113
|
+
* output.
|
|
11114
|
+
* @returns The single character represented by the code.
|
|
11115
|
+
* @throws {SyntaxError} If the code is not valid hex or is not the right
|
|
11116
|
+
* length.
|
|
11117
|
+
*/
|
|
11118
|
+
function parseHexadecimalCode(code) {
|
|
11119
|
+
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedHexadecimal, 2);
|
|
11120
|
+
return String.fromCharCode(parsedCode);
|
|
11121
|
+
}
|
|
11122
|
+
/**
|
|
11123
|
+
* Parse a four-digit Unicode character escape code.
|
|
11124
|
+
* @param code The four-digit unicode number that represents the character to
|
|
11125
|
+
* output.
|
|
11126
|
+
* @param surrogateCode Optional four-digit unicode surrogate that represents
|
|
11127
|
+
* the other half of the character to output.
|
|
11128
|
+
* @returns The single character represented by the code.
|
|
11129
|
+
* @throws {SyntaxError} If the codes are not valid hex or are not the right
|
|
11130
|
+
* length.
|
|
11131
|
+
*/
|
|
11132
|
+
function parseUnicodeCode(code, surrogateCode) {
|
|
11133
|
+
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedUnicode, 4);
|
|
11134
|
+
if (surrogateCode !== undefined) {
|
|
11135
|
+
const parsedSurrogateCode = validateAndParseHex(surrogateCode, errors_1.ErrorType.MalformedUnicode, 4);
|
|
11136
|
+
return String.fromCharCode(parsedCode, parsedSurrogateCode);
|
|
11137
|
+
}
|
|
11138
|
+
return String.fromCharCode(parsedCode);
|
|
11139
|
+
}
|
|
11140
|
+
/**
|
|
11141
|
+
* Test if the text is surrounded by curly braces (`{}`).
|
|
11142
|
+
* @param text Text to check.
|
|
11143
|
+
* @returns `true` if the text is in the form `{*}`.
|
|
11144
|
+
*/
|
|
11145
|
+
function isCurlyBraced(text) {
|
|
11146
|
+
return text.charAt(0) === "{" && text.charAt(text.length - 1) === "}";
|
|
11147
|
+
}
|
|
11148
|
+
/**
|
|
11149
|
+
* Parse a Unicode code point character escape code.
|
|
11150
|
+
* @param codePoint A unicode escape code point, including the surrounding curly
|
|
11151
|
+
* braces.
|
|
11152
|
+
* @returns The single character represented by the code.
|
|
11153
|
+
* @throws {SyntaxError} If the code is not valid hex or does not have the
|
|
11154
|
+
* surrounding curly braces.
|
|
11155
|
+
*/
|
|
11156
|
+
function parseUnicodeCodePointCode(codePoint) {
|
|
11157
|
+
if (!isCurlyBraced(codePoint)) {
|
|
11158
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.MalformedUnicode));
|
|
11159
|
+
}
|
|
11160
|
+
const withoutBraces = codePoint.slice(1, -1);
|
|
11161
|
+
const parsedCode = validateAndParseHex(withoutBraces, errors_1.ErrorType.MalformedUnicode);
|
|
11162
|
+
try {
|
|
11163
|
+
return String.fromCodePoint(parsedCode);
|
|
11164
|
+
}
|
|
11165
|
+
catch (err) {
|
|
11166
|
+
throw err instanceof RangeError
|
|
11167
|
+
? new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.CodePointLimit))
|
|
11168
|
+
: err;
|
|
11169
|
+
}
|
|
11170
|
+
}
|
|
11171
|
+
// Have to give overload that takes boolean for when compiler doesn't know if
|
|
11172
|
+
// true or false
|
|
11173
|
+
function parseOctalCode(code, error = false) {
|
|
11174
|
+
if (error) {
|
|
11175
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.OctalDeprecation));
|
|
11176
|
+
}
|
|
11177
|
+
// The original regex only allows digits so we don't need to have a strict
|
|
11178
|
+
// octal parser like hexToInt. Length is not enforced for octals.
|
|
11179
|
+
const parsedCode = parseInt(code, 8);
|
|
11180
|
+
return String.fromCharCode(parsedCode);
|
|
11181
|
+
}
|
|
11182
|
+
/**
|
|
11183
|
+
* Map of unescaped letters to their corresponding special JS escape characters.
|
|
11184
|
+
* Intentionally does not include characters that map to themselves like "\'".
|
|
11185
|
+
*/
|
|
11186
|
+
const singleCharacterEscapes = new Map([
|
|
11187
|
+
["b", "\b"],
|
|
11188
|
+
["f", "\f"],
|
|
11189
|
+
["n", "\n"],
|
|
11190
|
+
["r", "\r"],
|
|
11191
|
+
["t", "\t"],
|
|
11192
|
+
["v", "\v"],
|
|
11193
|
+
["0", "\0"]
|
|
11194
|
+
]);
|
|
11195
|
+
/**
|
|
11196
|
+
* Parse a single character escape sequence and return the matching character.
|
|
11197
|
+
* If none is matched, defaults to `code`.
|
|
11198
|
+
* @param code A single character code.
|
|
11199
|
+
*/
|
|
11200
|
+
function parseSingleCharacterCode(code) {
|
|
11201
|
+
return singleCharacterEscapes.get(code) || code;
|
|
11202
|
+
}
|
|
11203
|
+
/**
|
|
11204
|
+
* Matches every escape sequence possible, including invalid ones.
|
|
11205
|
+
*
|
|
11206
|
+
* All capture groups (described below) are unique (only one will match), except
|
|
11207
|
+
* for 4, which can only potentially match if 3 does.
|
|
11208
|
+
*
|
|
11209
|
+
* **Capture Groups:**
|
|
11210
|
+
* 0. A single backslash
|
|
11211
|
+
* 1. Hexadecimal code
|
|
11212
|
+
* 2. Unicode code point code with surrounding curly braces
|
|
11213
|
+
* 3. Unicode escape code with surrogate
|
|
11214
|
+
* 4. Surrogate code
|
|
11215
|
+
* 5. Unicode escape code without surrogate
|
|
11216
|
+
* 6. Octal code _NOTE: includes "0"._
|
|
11217
|
+
* 7. A single character (will never be \, x, u, or 0-3)
|
|
11218
|
+
*/
|
|
11219
|
+
const escapeMatch = /\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;
|
|
11220
|
+
/**
|
|
11221
|
+
* Replace raw escape character strings with their escape characters.
|
|
11222
|
+
* @param raw A string where escape characters are represented as raw string
|
|
11223
|
+
* values like `\'` rather than `'`.
|
|
11224
|
+
* @param allowOctals If `true`, will process the now-deprecated octal escape
|
|
11225
|
+
* sequences (ie, `\111`).
|
|
11226
|
+
* @returns The processed string, with escape characters replaced by their
|
|
11227
|
+
* respective actual Unicode characters.
|
|
11228
|
+
*/
|
|
11229
|
+
function unraw(raw, allowOctals = false) {
|
|
11230
|
+
return raw.replace(escapeMatch, function (_, backslash, hex, codePoint, unicodeWithSurrogate, surrogate, unicode, octal, singleCharacter) {
|
|
11231
|
+
// Compare groups to undefined because empty strings mean different errors
|
|
11232
|
+
// Otherwise, `\u` would fail the same as `\` which is wrong.
|
|
11233
|
+
if (backslash !== undefined) {
|
|
11234
|
+
return "\\";
|
|
11235
|
+
}
|
|
11236
|
+
if (hex !== undefined) {
|
|
11237
|
+
return parseHexadecimalCode(hex);
|
|
11238
|
+
}
|
|
11239
|
+
if (codePoint !== undefined) {
|
|
11240
|
+
return parseUnicodeCodePointCode(codePoint);
|
|
11241
|
+
}
|
|
11242
|
+
if (unicodeWithSurrogate !== undefined) {
|
|
11243
|
+
return parseUnicodeCode(unicodeWithSurrogate, surrogate);
|
|
11244
|
+
}
|
|
11245
|
+
if (unicode !== undefined) {
|
|
11246
|
+
return parseUnicodeCode(unicode);
|
|
11247
|
+
}
|
|
11248
|
+
if (octal === "0") {
|
|
11249
|
+
return "\0";
|
|
11250
|
+
}
|
|
11251
|
+
if (octal !== undefined) {
|
|
11252
|
+
return parseOctalCode(octal, !allowOctals);
|
|
11253
|
+
}
|
|
11254
|
+
if (singleCharacter !== undefined) {
|
|
11255
|
+
return parseSingleCharacterCode(singleCharacter);
|
|
11256
|
+
}
|
|
11257
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.EndOfString));
|
|
11258
|
+
});
|
|
11259
|
+
}
|
|
11260
|
+
exports.unraw = unraw;
|
|
11261
|
+
exports["default"] = unraw;
|
|
11262
|
+
|
|
11274
11263
|
|
|
11275
11264
|
/***/ }),
|
|
11276
11265
|
|