@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 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.74.0](https://github.com/swagger-api/apidom/compare/v0.73.0...v0.74.0) (2023-07-24)
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 we originally created
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
- * @file **unraw - errors.ts** | Error messages used by `unraw`.
11008
- * @author Ian Sanders
11009
- * @copyright 2019 Ian Sanders
11010
- * @license MIT
11011
- */
11012
- Object.defineProperty(exports, "__esModule", ({ value: true }));
11013
- // NOTE: don't construct errors here or they'll have the wrong stack trace.
11014
- // NOTE: don't make custom error class; the JS engines use `SyntaxError`
11015
- /**
11016
- * Keys for possible error messages used by `unraw`.
11017
- * Note: These do _not_ map to actual error object types. All errors thrown
11018
- * are `SyntaxError`.
11019
- */
11020
- // Don't use const enum or JS users won't be able to access the enum values
11021
- var ErrorType;
11022
- (function (ErrorType) {
11023
- /**
11024
- * Thrown when a badly formed Unicode escape sequence is found. Possible
11025
- * reasons include the code being too short (`"\u25"`) or having invalid
11026
- * characters (`"\u2$A5"`).
11027
- */
11028
- ErrorType["MalformedUnicode"] = "MALFORMED_UNICODE";
11029
- /**
11030
- * Thrown when a badly formed hexadecimal escape sequence is found. Possible
11031
- * reasons include the code being too short (`"\x2"`) or having invalid
11032
- * characters (`"\x2$"`).
11033
- */
11034
- ErrorType["MalformedHexadecimal"] = "MALFORMED_HEXADECIMAL";
11035
- /**
11036
- * Thrown when a Unicode code point escape sequence has too high of a code
11037
- * point. The maximum code point allowed is `\u{10FFFF}`, so `\u{110000}` and
11038
- * higher will throw this error.
11039
- */
11040
- ErrorType["CodePointLimit"] = "CODE_POINT_LIMIT";
11041
- /**
11042
- * Thrown when an octal escape sequences is encountered and `allowOctals` is
11043
- * `false`. For example, `unraw("\234", false)`.
11044
- */
11045
- ErrorType["OctalDeprecation"] = "OCTAL_DEPRECATION";
11046
- /**
11047
- * Thrown only when a single backslash is found at the end of a string. For
11048
- * example, `"\\"` or `"test\\x24\\"`.
11049
- */
11050
- ErrorType["EndOfString"] = "END_OF_STRING";
11051
- })(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
11052
- /** Map of error message names to the full text of the message. */
11053
- exports.errorMessages = new Map([
11054
- [ErrorType.MalformedUnicode, "malformed Unicode character escape sequence"],
11055
- [
11056
- ErrorType.MalformedHexadecimal,
11057
- "malformed hexadecimal character escape sequence"
11058
- ],
11059
- [
11060
- ErrorType.CodePointLimit,
11061
- "Unicode codepoint must not be greater than 0x10FFFF in escape sequence"
11062
- ],
11063
- [
11064
- ErrorType.OctalDeprecation,
11065
- '"0"-prefixed octal literals and octal escape sequences are deprecated; ' +
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
- * @file **unraw** | Convert raw escape sequences to their respective characters
11081
- * (undo `String.raw`).
11082
- * @author Ian Sanders
11083
- * @copyright 2019 Ian Sanders
11084
- * @license MIT
11085
- */
11086
- Object.defineProperty(exports, "__esModule", ({ value: true }));
11087
- const errors_1 = __webpack_require__(42396);
11088
- exports.ErrorType = errors_1.ErrorType;
11089
- exports.errorMessages = errors_1.errorMessages;
11090
- /**
11091
- * Parse a string as a base-16 number. This is more strict than `parseInt` as it
11092
- * will not allow any other characters, including (for example) "+", "-", and
11093
- * ".".
11094
- * @param hex A string containing a hexadecimal number.
11095
- * @returns The parsed integer, or `NaN` if the string is not a valid hex
11096
- * number.
11097
- */
11098
- function parseHexToInt(hex) {
11099
- const isOnlyHexChars = !hex.match(/[^a-f0-9]/i);
11100
- return isOnlyHexChars ? parseInt(hex, 16) : NaN;
11101
- }
11102
- /**
11103
- * Check the validity and length of a hexadecimal code and optionally enforces
11104
- * a specific number of hex digits.
11105
- * @param hex The string to validate and parse.
11106
- * @param errorName The name of the error message to throw a `SyntaxError` with
11107
- * if `hex` is invalid. This is used to index `errorMessages`.
11108
- * @param enforcedLength If provided, will throw an error if `hex` is not
11109
- * exactly this many characters.
11110
- * @returns The parsed hex number as a normal number.
11111
- * @throws {SyntaxError} If the code is not valid.
11112
- */
11113
- function validateAndParseHex(hex, errorName, enforcedLength) {
11114
- const parsedHex = parseHexToInt(hex);
11115
- if (Number.isNaN(parsedHex) ||
11116
- (enforcedLength !== undefined && enforcedLength !== hex.length)) {
11117
- throw new SyntaxError(errors_1.errorMessages.get(errorName));
11118
- }
11119
- return parsedHex;
11120
- }
11121
- /**
11122
- * Parse a two-digit hexadecimal character escape code.
11123
- * @param code The two-digit hexadecimal number that represents the character to
11124
- * output.
11125
- * @returns The single character represented by the code.
11126
- * @throws {SyntaxError} If the code is not valid hex or is not the right
11127
- * length.
11128
- */
11129
- function parseHexadecimalCode(code) {
11130
- const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedHexadecimal, 2);
11131
- return String.fromCharCode(parsedCode);
11132
- }
11133
- /**
11134
- * Parse a four-digit Unicode character escape code.
11135
- * @param code The four-digit unicode number that represents the character to
11136
- * output.
11137
- * @param surrogateCode Optional four-digit unicode surrogate that represents
11138
- * the other half of the character to output.
11139
- * @returns The single character represented by the code.
11140
- * @throws {SyntaxError} If the codes are not valid hex or are not the right
11141
- * length.
11142
- */
11143
- function parseUnicodeCode(code, surrogateCode) {
11144
- const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedUnicode, 4);
11145
- if (surrogateCode !== undefined) {
11146
- const parsedSurrogateCode = validateAndParseHex(surrogateCode, errors_1.ErrorType.MalformedUnicode, 4);
11147
- return String.fromCharCode(parsedCode, parsedSurrogateCode);
11148
- }
11149
- return String.fromCharCode(parsedCode);
11150
- }
11151
- /**
11152
- * Test if the text is surrounded by curly braces (`{}`).
11153
- * @param text Text to check.
11154
- * @returns `true` if the text is in the form `{*}`.
11155
- */
11156
- function isCurlyBraced(text) {
11157
- return text.charAt(0) === "{" && text.charAt(text.length - 1) === "}";
11158
- }
11159
- /**
11160
- * Parse a Unicode code point character escape code.
11161
- * @param codePoint A unicode escape code point, including the surrounding curly
11162
- * braces.
11163
- * @returns The single character represented by the code.
11164
- * @throws {SyntaxError} If the code is not valid hex or does not have the
11165
- * surrounding curly braces.
11166
- */
11167
- function parseUnicodeCodePointCode(codePoint) {
11168
- if (!isCurlyBraced(codePoint)) {
11169
- throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.MalformedUnicode));
11170
- }
11171
- const withoutBraces = codePoint.slice(1, -1);
11172
- const parsedCode = validateAndParseHex(withoutBraces, errors_1.ErrorType.MalformedUnicode);
11173
- try {
11174
- return String.fromCodePoint(parsedCode);
11175
- }
11176
- catch (err) {
11177
- throw err instanceof RangeError
11178
- ? new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.CodePointLimit))
11179
- : err;
11180
- }
11181
- }
11182
- // Have to give overload that takes boolean for when compiler doesn't know if
11183
- // true or false
11184
- function parseOctalCode(code, error = false) {
11185
- if (error) {
11186
- throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.OctalDeprecation));
11187
- }
11188
- // The original regex only allows digits so we don't need to have a strict
11189
- // octal parser like hexToInt. Length is not enforced for octals.
11190
- const parsedCode = parseInt(code, 8);
11191
- return String.fromCharCode(parsedCode);
11192
- }
11193
- /**
11194
- * Map of unescaped letters to their corresponding special JS escape characters.
11195
- * Intentionally does not include characters that map to themselves like "\'".
11196
- */
11197
- const singleCharacterEscapes = new Map([
11198
- ["b", "\b"],
11199
- ["f", "\f"],
11200
- ["n", "\n"],
11201
- ["r", "\r"],
11202
- ["t", "\t"],
11203
- ["v", "\v"],
11204
- ["0", "\0"]
11205
- ]);
11206
- /**
11207
- * Parse a single character escape sequence and return the matching character.
11208
- * If none is matched, defaults to `code`.
11209
- * @param code A single character code.
11210
- */
11211
- function parseSingleCharacterCode(code) {
11212
- return singleCharacterEscapes.get(code) || code;
11213
- }
11214
- /**
11215
- * Matches every escape sequence possible, including invalid ones.
11216
- *
11217
- * All capture groups (described below) are unique (only one will match), except
11218
- * for 4, which can only potentially match if 3 does.
11219
- *
11220
- * **Capture Groups:**
11221
- * 0. A single backslash
11222
- * 1. Hexadecimal code
11223
- * 2. Unicode code point code with surrounding curly braces
11224
- * 3. Unicode escape code with surrogate
11225
- * 4. Surrogate code
11226
- * 5. Unicode escape code without surrogate
11227
- * 6. Octal code _NOTE: includes "0"._
11228
- * 7. A single character (will never be \, x, u, or 0-3)
11229
- */
11230
- 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;
11231
- /**
11232
- * Replace raw escape character strings with their escape characters.
11233
- * @param raw A string where escape characters are represented as raw string
11234
- * values like `\'` rather than `'`.
11235
- * @param allowOctals If `true`, will process the now-deprecated octal escape
11236
- * sequences (ie, `\111`).
11237
- * @returns The processed string, with escape characters replaced by their
11238
- * respective actual Unicode characters.
11239
- */
11240
- function unraw(raw, allowOctals = false) {
11241
- return raw.replace(escapeMatch, function (_, backslash, hex, codePoint, unicodeWithSurrogate, surrogate, unicode, octal, singleCharacter) {
11242
- // Compare groups to undefined because empty strings mean different errors
11243
- // Otherwise, `\u` would fail the same as `\` which is wrong.
11244
- if (backslash !== undefined) {
11245
- return "\\";
11246
- }
11247
- if (hex !== undefined) {
11248
- return parseHexadecimalCode(hex);
11249
- }
11250
- if (codePoint !== undefined) {
11251
- return parseUnicodeCodePointCode(codePoint);
11252
- }
11253
- if (unicodeWithSurrogate !== undefined) {
11254
- return parseUnicodeCode(unicodeWithSurrogate, surrogate);
11255
- }
11256
- if (unicode !== undefined) {
11257
- return parseUnicodeCode(unicode);
11258
- }
11259
- if (octal === "0") {
11260
- return "\0";
11261
- }
11262
- if (octal !== undefined) {
11263
- return parseOctalCode(octal, !allowOctals);
11264
- }
11265
- if (singleCharacter !== undefined) {
11266
- return parseSingleCharacterCode(singleCharacter);
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