commit
This commit is contained in:
parent
be4fd23bcf
commit
0bd53741af
728 changed files with 86573 additions and 0 deletions
49
node_modules/unraw/changelog.md
generated
vendored
Normal file
49
node_modules/unraw/changelog.md
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Change Log
|
||||
|
||||
All notable outward-facing changes will be documented in this file.
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Update dependencies to fix security vulnerabilities
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- Change to CommonJS module form
|
||||
|
||||
## 1.2.5
|
||||
|
||||
- Fix minor inconsistencies
|
||||
- Improve JSDoc and type hints
|
||||
- Update dependencies
|
||||
|
||||
## 1.2.4
|
||||
- Add security policy
|
||||
- Add badges and code block to readme
|
||||
- Update dependencies
|
||||
- Clean up some type annotations for inferred types
|
||||
|
||||
## 1.2.3
|
||||
- Improve UMD documentation
|
||||
- Export `unraw`, `ErrorType`, and `errorMessages` from main module along with
|
||||
default export
|
||||
|
||||
## 1.2.2
|
||||
- Update readme
|
||||
- Publish types for `errors.ts`
|
||||
|
||||
## 1.2.1
|
||||
- Publish error messages in `errors.ts`
|
||||
- Refactor `index.ts` methods
|
||||
|
||||
## 1.1.1
|
||||
- Refactor tests and add more tests
|
||||
- Fix: properly handle code point escapes that directly follow unicode escapes
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Switch to UMD for broader compatibility
|
||||
- Remove circular dependency with `compress-tag`
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Initial release
|
44
node_modules/unraw/dist/errors.d.ts
generated
vendored
Normal file
44
node_modules/unraw/dist/errors.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* @file **unraw - errors.ts** | Error messages used by `unraw`.
|
||||
* @author Ian Sanders
|
||||
* @copyright 2019 Ian Sanders
|
||||
* @license MIT
|
||||
*/
|
||||
/**
|
||||
* Keys for possible error messages used by `unraw`.
|
||||
* Note: These do _not_ map to actual error object types. All errors thrown
|
||||
* are `SyntaxError`.
|
||||
*/
|
||||
export declare enum ErrorType {
|
||||
/**
|
||||
* Thrown when a badly formed Unicode escape sequence is found. Possible
|
||||
* reasons include the code being too short (`"\u25"`) or having invalid
|
||||
* characters (`"\u2$A5"`).
|
||||
*/
|
||||
MalformedUnicode = "MALFORMED_UNICODE",
|
||||
/**
|
||||
* Thrown when a badly formed hexadecimal escape sequence is found. Possible
|
||||
* reasons include the code being too short (`"\x2"`) or having invalid
|
||||
* characters (`"\x2$"`).
|
||||
*/
|
||||
MalformedHexadecimal = "MALFORMED_HEXADECIMAL",
|
||||
/**
|
||||
* Thrown when a Unicode code point escape sequence has too high of a code
|
||||
* point. The maximum code point allowed is `\u{10FFFF}`, so `\u{110000}` and
|
||||
* higher will throw this error.
|
||||
*/
|
||||
CodePointLimit = "CODE_POINT_LIMIT",
|
||||
/**
|
||||
* Thrown when an octal escape sequences is encountered and `allowOctals` is
|
||||
* `false`. For example, `unraw("\234", false)`.
|
||||
*/
|
||||
OctalDeprecation = "OCTAL_DEPRECATION",
|
||||
/**
|
||||
* Thrown only when a single backslash is found at the end of a string. For
|
||||
* example, `"\\"` or `"test\\x24\\"`.
|
||||
*/
|
||||
EndOfString = "END_OF_STRING"
|
||||
}
|
||||
/** Map of error message names to the full text of the message. */
|
||||
export declare const errorMessages: Readonly<Map<ErrorType, string>>;
|
||||
//# sourceMappingURL=errors.d.ts.map
|
1
node_modules/unraw/dist/errors.d.ts.map
generated
vendored
Normal file
1
node_modules/unraw/dist/errors.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;GAIG;AAEH,oBAAY,SAAS;IACnB;;;;OAIG;IACH,gBAAgB,sBAAsB;IACtC;;;;OAIG;IACH,oBAAoB,0BAA0B;IAC9C;;;;OAIG;IACH,cAAc,qBAAqB;IACnC;;;OAGG;IACH,gBAAgB,sBAAsB;IACtC;;;OAGG;IACH,WAAW,kBAAkB;CAC9B;AAED,kEAAkE;AAClE,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAgBzD,CAAC"}
|
66
node_modules/unraw/dist/errors.js
generated
vendored
Normal file
66
node_modules/unraw/dist/errors.js
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
"use strict";
|
||||
/**
|
||||
* @file **unraw - errors.ts** | Error messages used by `unraw`.
|
||||
* @author Ian Sanders
|
||||
* @copyright 2019 Ian Sanders
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// NOTE: don't construct errors here or they'll have the wrong stack trace.
|
||||
// NOTE: don't make custom error class; the JS engines use `SyntaxError`
|
||||
/**
|
||||
* Keys for possible error messages used by `unraw`.
|
||||
* Note: These do _not_ map to actual error object types. All errors thrown
|
||||
* are `SyntaxError`.
|
||||
*/
|
||||
// Don't use const enum or JS users won't be able to access the enum values
|
||||
var ErrorType;
|
||||
(function (ErrorType) {
|
||||
/**
|
||||
* Thrown when a badly formed Unicode escape sequence is found. Possible
|
||||
* reasons include the code being too short (`"\u25"`) or having invalid
|
||||
* characters (`"\u2$A5"`).
|
||||
*/
|
||||
ErrorType["MalformedUnicode"] = "MALFORMED_UNICODE";
|
||||
/**
|
||||
* Thrown when a badly formed hexadecimal escape sequence is found. Possible
|
||||
* reasons include the code being too short (`"\x2"`) or having invalid
|
||||
* characters (`"\x2$"`).
|
||||
*/
|
||||
ErrorType["MalformedHexadecimal"] = "MALFORMED_HEXADECIMAL";
|
||||
/**
|
||||
* Thrown when a Unicode code point escape sequence has too high of a code
|
||||
* point. The maximum code point allowed is `\u{10FFFF}`, so `\u{110000}` and
|
||||
* higher will throw this error.
|
||||
*/
|
||||
ErrorType["CodePointLimit"] = "CODE_POINT_LIMIT";
|
||||
/**
|
||||
* Thrown when an octal escape sequences is encountered and `allowOctals` is
|
||||
* `false`. For example, `unraw("\234", false)`.
|
||||
*/
|
||||
ErrorType["OctalDeprecation"] = "OCTAL_DEPRECATION";
|
||||
/**
|
||||
* Thrown only when a single backslash is found at the end of a string. For
|
||||
* example, `"\\"` or `"test\\x24\\"`.
|
||||
*/
|
||||
ErrorType["EndOfString"] = "END_OF_STRING";
|
||||
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
||||
/** Map of error message names to the full text of the message. */
|
||||
exports.errorMessages = new Map([
|
||||
[ErrorType.MalformedUnicode, "malformed Unicode character escape sequence"],
|
||||
[
|
||||
ErrorType.MalformedHexadecimal,
|
||||
"malformed hexadecimal character escape sequence"
|
||||
],
|
||||
[
|
||||
ErrorType.CodePointLimit,
|
||||
"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"
|
||||
],
|
||||
[
|
||||
ErrorType.OctalDeprecation,
|
||||
'"0"-prefixed octal literals and octal escape sequences are deprecated; ' +
|
||||
'for octal literals use the "0o" prefix instead'
|
||||
],
|
||||
[ErrorType.EndOfString, "malformed escape sequence at end of string"]
|
||||
]);
|
||||
//# sourceMappingURL=errors.js.map
|
1
node_modules/unraw/dist/errors.js.map
generated
vendored
Normal file
1
node_modules/unraw/dist/errors.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,2EAA2E;AAC3E,wEAAwE;AAExE;;;;GAIG;AACH,2EAA2E;AAC3E,IAAY,SA6BX;AA7BD,WAAY,SAAS;IACnB;;;;OAIG;IACH,mDAAsC,CAAA;IACtC;;;;OAIG;IACH,2DAA8C,CAAA;IAC9C;;;;OAIG;IACH,gDAAmC,CAAA;IACnC;;;OAGG;IACH,mDAAsC,CAAA;IACtC;;;OAGG;IACH,0CAA6B,CAAA;AAC/B,CAAC,EA7BW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QA6BpB;AAED,kEAAkE;AACrD,QAAA,aAAa,GAAqC,IAAI,GAAG,CAAC;IACrE,CAAC,SAAS,CAAC,gBAAgB,EAAE,6CAA6C,CAAC;IAC3E;QACE,SAAS,CAAC,oBAAoB;QAC9B,iDAAiD;KAClD;IACD;QACE,SAAS,CAAC,cAAc;QACxB,wEAAwE;KACzE;IACD;QACE,SAAS,CAAC,gBAAgB;QAC1B,yEAAyE;YACvE,gDAAgD;KACnD;IACD,CAAC,SAAS,CAAC,WAAW,EAAE,4CAA4C,CAAC;CACtE,CAAC,CAAC"}
|
1
node_modules/unraw/dist/errors.min.js
generated
vendored
Normal file
1
node_modules/unraw/dist/errors.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
"use strict";var ErrorType;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.MalformedUnicode="MALFORMED_UNICODE",e.MalformedHexadecimal="MALFORMED_HEXADECIMAL",e.CodePointLimit="CODE_POINT_LIMIT",e.OctalDeprecation="OCTAL_DEPRECATION",e.EndOfString="END_OF_STRING"}(ErrorType=exports.ErrorType||(exports.ErrorType={})),exports.errorMessages=new Map([[ErrorType.MalformedUnicode,"malformed Unicode character escape sequence"],[ErrorType.MalformedHexadecimal,"malformed hexadecimal character escape sequence"],[ErrorType.CodePointLimit,"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"],[ErrorType.OctalDeprecation,'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'],[ErrorType.EndOfString,"malformed escape sequence at end of string"]]);
|
21
node_modules/unraw/dist/index.d.ts
generated
vendored
Normal file
21
node_modules/unraw/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* @file **unraw** | Convert raw escape sequences to their respective characters
|
||||
* (undo `String.raw`).
|
||||
* @author Ian Sanders
|
||||
* @copyright 2019 Ian Sanders
|
||||
* @license MIT
|
||||
*/
|
||||
import { ErrorType, errorMessages } from "./errors";
|
||||
export { ErrorType, errorMessages };
|
||||
/**
|
||||
* Replace raw escape character strings with their escape characters.
|
||||
* @param raw A string where escape characters are represented as raw string
|
||||
* values like `\'` rather than `'`.
|
||||
* @param allowOctals If `true`, will process the now-deprecated octal escape
|
||||
* sequences (ie, `\111`).
|
||||
* @returns The processed string, with escape characters replaced by their
|
||||
* respective actual Unicode characters.
|
||||
*/
|
||||
export declare function unraw(raw: string, allowOctals?: boolean): string;
|
||||
export default unraw;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/unraw/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/unraw/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAClD,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;AAwLlC;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,MAAM,CAwC9D;AACD,eAAe,KAAK,CAAC"}
|
196
node_modules/unraw/dist/index.js
generated
vendored
Normal file
196
node_modules/unraw/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,196 @@
|
|||
"use strict";
|
||||
/**
|
||||
* @file **unraw** | Convert raw escape sequences to their respective characters
|
||||
* (undo `String.raw`).
|
||||
* @author Ian Sanders
|
||||
* @copyright 2019 Ian Sanders
|
||||
* @license MIT
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const errors_1 = require("./errors");
|
||||
exports.ErrorType = errors_1.ErrorType;
|
||||
exports.errorMessages = errors_1.errorMessages;
|
||||
/**
|
||||
* Parse a string as a base-16 number. This is more strict than `parseInt` as it
|
||||
* will not allow any other characters, including (for example) "+", "-", and
|
||||
* ".".
|
||||
* @param hex A string containing a hexadecimal number.
|
||||
* @returns The parsed integer, or `NaN` if the string is not a valid hex
|
||||
* number.
|
||||
*/
|
||||
function parseHexToInt(hex) {
|
||||
const isOnlyHexChars = !hex.match(/[^a-f0-9]/i);
|
||||
return isOnlyHexChars ? parseInt(hex, 16) : NaN;
|
||||
}
|
||||
/**
|
||||
* Check the validity and length of a hexadecimal code and optionally enforces
|
||||
* a specific number of hex digits.
|
||||
* @param hex The string to validate and parse.
|
||||
* @param errorName The name of the error message to throw a `SyntaxError` with
|
||||
* if `hex` is invalid. This is used to index `errorMessages`.
|
||||
* @param enforcedLength If provided, will throw an error if `hex` is not
|
||||
* exactly this many characters.
|
||||
* @returns The parsed hex number as a normal number.
|
||||
* @throws {SyntaxError} If the code is not valid.
|
||||
*/
|
||||
function validateAndParseHex(hex, errorName, enforcedLength) {
|
||||
const parsedHex = parseHexToInt(hex);
|
||||
if (Number.isNaN(parsedHex) ||
|
||||
(enforcedLength !== undefined && enforcedLength !== hex.length)) {
|
||||
throw new SyntaxError(errors_1.errorMessages.get(errorName));
|
||||
}
|
||||
return parsedHex;
|
||||
}
|
||||
/**
|
||||
* Parse a two-digit hexadecimal character escape code.
|
||||
* @param code The two-digit hexadecimal number that represents the character to
|
||||
* output.
|
||||
* @returns The single character represented by the code.
|
||||
* @throws {SyntaxError} If the code is not valid hex or is not the right
|
||||
* length.
|
||||
*/
|
||||
function parseHexadecimalCode(code) {
|
||||
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedHexadecimal, 2);
|
||||
return String.fromCharCode(parsedCode);
|
||||
}
|
||||
/**
|
||||
* Parse a four-digit Unicode character escape code.
|
||||
* @param code The four-digit unicode number that represents the character to
|
||||
* output.
|
||||
* @param surrogateCode Optional four-digit unicode surrogate that represents
|
||||
* the other half of the character to output.
|
||||
* @returns The single character represented by the code.
|
||||
* @throws {SyntaxError} If the codes are not valid hex or are not the right
|
||||
* length.
|
||||
*/
|
||||
function parseUnicodeCode(code, surrogateCode) {
|
||||
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedUnicode, 4);
|
||||
if (surrogateCode !== undefined) {
|
||||
const parsedSurrogateCode = validateAndParseHex(surrogateCode, errors_1.ErrorType.MalformedUnicode, 4);
|
||||
return String.fromCharCode(parsedCode, parsedSurrogateCode);
|
||||
}
|
||||
return String.fromCharCode(parsedCode);
|
||||
}
|
||||
/**
|
||||
* Test if the text is surrounded by curly braces (`{}`).
|
||||
* @param text Text to check.
|
||||
* @returns `true` if the text is in the form `{*}`.
|
||||
*/
|
||||
function isCurlyBraced(text) {
|
||||
return text.charAt(0) === "{" && text.charAt(text.length - 1) === "}";
|
||||
}
|
||||
/**
|
||||
* Parse a Unicode code point character escape code.
|
||||
* @param codePoint A unicode escape code point, including the surrounding curly
|
||||
* braces.
|
||||
* @returns The single character represented by the code.
|
||||
* @throws {SyntaxError} If the code is not valid hex or does not have the
|
||||
* surrounding curly braces.
|
||||
*/
|
||||
function parseUnicodeCodePointCode(codePoint) {
|
||||
if (!isCurlyBraced(codePoint)) {
|
||||
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.MalformedUnicode));
|
||||
}
|
||||
const withoutBraces = codePoint.slice(1, -1);
|
||||
const parsedCode = validateAndParseHex(withoutBraces, errors_1.ErrorType.MalformedUnicode);
|
||||
try {
|
||||
return String.fromCodePoint(parsedCode);
|
||||
}
|
||||
catch (err) {
|
||||
throw err instanceof RangeError
|
||||
? new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.CodePointLimit))
|
||||
: err;
|
||||
}
|
||||
}
|
||||
// Have to give overload that takes boolean for when compiler doesn't know if
|
||||
// true or false
|
||||
function parseOctalCode(code, error = false) {
|
||||
if (error) {
|
||||
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.OctalDeprecation));
|
||||
}
|
||||
// The original regex only allows digits so we don't need to have a strict
|
||||
// octal parser like hexToInt. Length is not enforced for octals.
|
||||
const parsedCode = parseInt(code, 8);
|
||||
return String.fromCharCode(parsedCode);
|
||||
}
|
||||
/**
|
||||
* Map of unescaped letters to their corresponding special JS escape characters.
|
||||
* Intentionally does not include characters that map to themselves like "\'".
|
||||
*/
|
||||
const singleCharacterEscapes = new Map([
|
||||
["b", "\b"],
|
||||
["f", "\f"],
|
||||
["n", "\n"],
|
||||
["r", "\r"],
|
||||
["t", "\t"],
|
||||
["v", "\v"],
|
||||
["0", "\0"]
|
||||
]);
|
||||
/**
|
||||
* Parse a single character escape sequence and return the matching character.
|
||||
* If none is matched, defaults to `code`.
|
||||
* @param code A single character code.
|
||||
*/
|
||||
function parseSingleCharacterCode(code) {
|
||||
return singleCharacterEscapes.get(code) || code;
|
||||
}
|
||||
/**
|
||||
* Matches every escape sequence possible, including invalid ones.
|
||||
*
|
||||
* All capture groups (described below) are unique (only one will match), except
|
||||
* for 4, which can only potentially match if 3 does.
|
||||
*
|
||||
* **Capture Groups:**
|
||||
* 0. A single backslash
|
||||
* 1. Hexadecimal code
|
||||
* 2. Unicode code point code with surrounding curly braces
|
||||
* 3. Unicode escape code with surrogate
|
||||
* 4. Surrogate code
|
||||
* 5. Unicode escape code without surrogate
|
||||
* 6. Octal code _NOTE: includes "0"._
|
||||
* 7. A single character (will never be \, x, u, or 0-3)
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* Replace raw escape character strings with their escape characters.
|
||||
* @param raw A string where escape characters are represented as raw string
|
||||
* values like `\'` rather than `'`.
|
||||
* @param allowOctals If `true`, will process the now-deprecated octal escape
|
||||
* sequences (ie, `\111`).
|
||||
* @returns The processed string, with escape characters replaced by their
|
||||
* respective actual Unicode characters.
|
||||
*/
|
||||
function unraw(raw, allowOctals = false) {
|
||||
return raw.replace(escapeMatch, function (_, backslash, hex, codePoint, unicodeWithSurrogate, surrogate, unicode, octal, singleCharacter) {
|
||||
// Compare groups to undefined because empty strings mean different errors
|
||||
// Otherwise, `\u` would fail the same as `\` which is wrong.
|
||||
if (backslash !== undefined) {
|
||||
return "\\";
|
||||
}
|
||||
if (hex !== undefined) {
|
||||
return parseHexadecimalCode(hex);
|
||||
}
|
||||
if (codePoint !== undefined) {
|
||||
return parseUnicodeCodePointCode(codePoint);
|
||||
}
|
||||
if (unicodeWithSurrogate !== undefined) {
|
||||
return parseUnicodeCode(unicodeWithSurrogate, surrogate);
|
||||
}
|
||||
if (unicode !== undefined) {
|
||||
return parseUnicodeCode(unicode);
|
||||
}
|
||||
if (octal === "0") {
|
||||
return "\0";
|
||||
}
|
||||
if (octal !== undefined) {
|
||||
return parseOctalCode(octal, !allowOctals);
|
||||
}
|
||||
if (singleCharacter !== undefined) {
|
||||
return parseSingleCharacterCode(singleCharacter);
|
||||
}
|
||||
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.EndOfString));
|
||||
});
|
||||
}
|
||||
exports.unraw = unraw;
|
||||
exports.default = unraw;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/unraw/dist/index.js.map
generated
vendored
Normal file
1
node_modules/unraw/dist/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,qCAAkD;AAC1C,oBADA,kBAAS,CACA;AAAE,wBADA,sBAAa,CACA;AAEhC;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAChD,OAAO,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAClD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,mBAAmB,CAC1B,GAAW,EACX,SAAoB,EACpB,cAAuB;IAEvB,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAA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AAC;AAxCD,sBAwCC;AACD,kBAAe,KAAK,CAAC"}
|
1
node_modules/unraw/dist/index.min.js
generated
vendored
Normal file
1
node_modules/unraw/dist/index.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("./errors");function parseHexToInt(r){return!r.match(/[^a-f0-9]/i)?parseInt(r,16):NaN}function validateAndParseHex(r,e,o){const n=parseHexToInt(r);if(Number.isNaN(n)||void 0!==o&&o!==r.length)throw new SyntaxError(errors_1.errorMessages.get(e));return n}function parseHexadecimalCode(r){const e=validateAndParseHex(r,errors_1.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(e)}function parseUnicodeCode(r,e){const o=validateAndParseHex(r,errors_1.ErrorType.MalformedUnicode,4);if(void 0!==e){const r=validateAndParseHex(e,errors_1.ErrorType.MalformedUnicode,4);return String.fromCharCode(o,r)}return String.fromCharCode(o)}function isCurlyBraced(r){return"{"===r.charAt(0)&&"}"===r.charAt(r.length-1)}function parseUnicodeCodePointCode(r){if(!isCurlyBraced(r))throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.MalformedUnicode));const e=validateAndParseHex(r.slice(1,-1),errors_1.ErrorType.MalformedUnicode);try{return String.fromCodePoint(e)}catch(r){throw r instanceof RangeError?new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.CodePointLimit)):r}}function parseOctalCode(r,e=!1){if(e)throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.OctalDeprecation));const o=parseInt(r,8);return String.fromCharCode(o)}exports.ErrorType=errors_1.ErrorType,exports.errorMessages=errors_1.errorMessages;const singleCharacterEscapes=new Map([["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t","\t"],["v","\v"],["0","\0"]]);function parseSingleCharacterCode(r){return singleCharacterEscapes.get(r)||r}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;function unraw(r,e=!1){return r.replace(escapeMatch,function(r,o,n,t,a,s,i,d,c){if(void 0!==o)return"\\";if(void 0!==n)return parseHexadecimalCode(n);if(void 0!==t)return parseUnicodeCodePointCode(t);if(void 0!==a)return parseUnicodeCode(a,s);if(void 0!==i)return parseUnicodeCode(i);if("0"===d)return"\0";if(void 0!==d)return parseOctalCode(d,!e);if(void 0!==c)return parseSingleCharacterCode(c);throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.EndOfString))})}exports.unraw=unraw,exports.default=unraw;
|
21
node_modules/unraw/license.md
generated
vendored
Normal file
21
node_modules/unraw/license.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ian Sanders
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
87
node_modules/unraw/package.json
generated
vendored
Normal file
87
node_modules/unraw/package.json
generated
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"name": "unraw",
|
||||
"version": "2.0.1",
|
||||
"description": "Convert raw escape sequences to their respective characters (undo String.raw).",
|
||||
"main": "dist/index.js",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"repository": "https://github.com/iansan5653/unraw",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"minify": "node-minify --compressor uglify-es --input dist/index.js --output dist/index.min.js & node-minify --compressor uglify-es --input dist/errors.js --output dist/errors.min.js",
|
||||
"test": "ts-mocha src/**/*.test.ts",
|
||||
"testWithCoverage": "npm run build && nyc --reporter=text mocha src/**/*.test.ts --require ts-node/register --require source-map-support/register",
|
||||
"testForCheck": "nyc --reporter=text-summary mocha src/index.test.ts --reporter=progress",
|
||||
"testForCI": "nyc --reporter=cobertura --reporter=html mocha src/index.test.ts --reporter=mocha-junit-reporter --reporter-options mochaFile=test-results.xml",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"check": "npm run build && npm run testForCheck && npm run lint",
|
||||
"ensureCleanTree": "echo 'Checking to ensure all changes are committed...' && git diff --quiet --exit-code & git diff --quiet --cached --exit-code",
|
||||
"prepublishOnly": "npm run ensureCleanTree && npm run check && npm run minify",
|
||||
"postpublish": "cross-var git tag -a $npm_package_version -m \"See changelog.md for release notes.\" && git push --tags && cross-var git tag -d $npm_package_version",
|
||||
"format": "prettier src/**/*.test.ts --write"
|
||||
},
|
||||
"author": {
|
||||
"name": "Ian Sanders",
|
||||
"url": "https://github.com/iansan5653"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@node-minify/core": "^5.3.0",
|
||||
"@node-minify/cli": "^5.3.0",
|
||||
"@node-minify/uglify-es": "^5.3.0",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^13.9.5",
|
||||
"@typescript-eslint/eslint-plugin": "^2.25.0",
|
||||
"@typescript-eslint/parser": "^2.25.0",
|
||||
"cross-var": "^1.1.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-plugin-jsdoc": "^22.1.0",
|
||||
"eslint-plugin-mocha": "^6.3.0",
|
||||
"mocha": "^7.1.1",
|
||||
"mocha-junit-reporter": "^1.23.3",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^2.0.2",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-mocha": "^7.0.0",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {},
|
||||
"nyc": {
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"extension": [
|
||||
".ts",
|
||||
".tsx"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"instrument": true
|
||||
},
|
||||
"files": [
|
||||
"dist/index.d.ts",
|
||||
"dist/index.d.ts.map",
|
||||
"dist/index.js",
|
||||
"dist/index.js.map",
|
||||
"dist/index.min.js",
|
||||
"dist/errors.d.ts",
|
||||
"dist/errors.d.ts.map",
|
||||
"dist/errors.js",
|
||||
"dist/errors.js.map",
|
||||
"dist/errors.min.js"
|
||||
],
|
||||
"keywords": [
|
||||
"strings",
|
||||
"escapes",
|
||||
"raw strings",
|
||||
"cooked strings",
|
||||
"template literal",
|
||||
"unescape",
|
||||
"unicode",
|
||||
"decode"
|
||||
]
|
||||
}
|
176
node_modules/unraw/readme.md
generated
vendored
Normal file
176
node_modules/unraw/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
# `unraw`
|
||||
|
||||
[](https://dev.azure.com/iansan5653/unraw/_build/latest?definitionId=3&branchName=master)
|
||||
[](https://dev.azure.com/iansan5653/unraw/_build/latest?definitionId=3&branchName=master)
|
||||
[](https://dev.azure.com/iansan5653/unraw/_build/latest?definitionId=3&branchName=master)
|
||||
[](https://www.npmjs.com/package/unraw)
|
||||
[](https://david-dm.org/iansan5653/unraw)
|
||||
[](https://david-dm.org/iansan5653/unraw?type=dev)
|
||||
|
||||
|
||||
```ts
|
||||
unraw("\\'\\t\\u{1f601}\\'"); // -> "' 😁'"
|
||||
```
|
||||
|
||||
`unraw` is a small module that converts raw strings to parsed strings in the same
|
||||
manner as the standard JavaScript escaping engine. In essence, it is the exact
|
||||
opposite of
|
||||
[`String.raw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw).
|
||||
|
||||
## Use Case
|
||||
|
||||
Most of the time, you probably don't need this library unless you're working
|
||||
directly with raw strings and you need a way to get them back to normal strings.
|
||||
Maybe the most signicant use case is when building
|
||||
[template literal tags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates);
|
||||
you can use the `.raw` property of the passed string array to access the raw
|
||||
strings, but then you may want to still return normal strings after processing.
|
||||
|
||||
The module is also useful for parsing text files written with escape sequences,
|
||||
although keep in mind that the JavaScript flavor of escape sequences may differ
|
||||
from the flavor used in an input file.
|
||||
|
||||
## Getting Started
|
||||
|
||||
`unraw` is a UMD module, so it can be used in Node or on the web. Typings are
|
||||
included for TypeScript as well.
|
||||
|
||||
### Usage in Node.JS
|
||||
|
||||
`unraw` is hosted on [npm](https://www.npmjs.com/unraw), so you can install
|
||||
with:
|
||||
|
||||
```bash
|
||||
npm i unraw
|
||||
```
|
||||
|
||||
To use in code:
|
||||
|
||||
```js
|
||||
import unraw from "unraw";
|
||||
|
||||
unraw("\\n");
|
||||
```
|
||||
|
||||
If you want to access error messages:
|
||||
|
||||
```js
|
||||
import {unraw, errorMessages, ErrorType} from "unraw";
|
||||
|
||||
unraw("\\n");
|
||||
errorMessages.get(ErrorType.MalformedUnicode);
|
||||
```
|
||||
|
||||
### Usage in the Browser
|
||||
|
||||
You can embed it (minified) on a webpage with
|
||||
[RequireJS](https://requirejs.org/). The module is available on
|
||||
[UNPKG](https://unpkg.com) at https://unpkg.com/unraw:
|
||||
|
||||
```html
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
|
||||
<script>
|
||||
require(["https://unpkg.com/unraw^1.2.3/dist/index.min.js"], function(unraw) {
|
||||
unraw.unraw("\\n");
|
||||
unraw.errorMessages.get(unraw.ErrorType.MalformedUnicode);
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
_Note_: Importing via the 'bare' url (`https://unpkg.com/unraw`) is not
|
||||
supported as it breaks references to other required files.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage is simple - the library exports a default function, `unraw`. The first
|
||||
argument to `unraw` is the string to parse, and the second is an optional flag
|
||||
to allow or disallow octal escapes, which are deprecated (defaults to
|
||||
`false`, so the default behavior is to throw an error when octal sequences
|
||||
are encountered).
|
||||
|
||||
```js
|
||||
unraw("\\t\\tThis is indented.");
|
||||
// => " This is indented."
|
||||
```
|
||||
|
||||
The library attempts to mimic the behaviour of standard JavaScript strings as
|
||||
closely as possible. This means that invalid escape sequences will throw
|
||||
`SyntaxError`s and that every escape sequence that is valid in a normal string
|
||||
should be valid when passed to `unraw`.
|
||||
|
||||
In some ways this is similar to the behavior of `JSON.parse`.
|
||||
|
||||
You can always expect the outcome of calling `unraw` on a raw string to be
|
||||
exactly the same as if that string were not raw in the first place:
|
||||
|
||||
```js
|
||||
`Invalid: \u23` // Throws a SyntaxError
|
||||
unraw(String.raw`Invalid: \u23`) // Throws a SyntaxError
|
||||
|
||||
`Valid: \u0041` // => `Valid: A`
|
||||
unraw(String.raw`Valid: \u0041`) // => `Valid: A`
|
||||
|
||||
`Valid: \A` // => `Valid: A`
|
||||
unraw(String.raw`Valid: \A`) // => `Valid: A`
|
||||
|
||||
`Valid: \\` // => `Valid: \`
|
||||
unraw(String.raw`Valid: \\`) // => `Valid: \`
|
||||
|
||||
`Valid: \x42` // => `Valid: B`
|
||||
unraw(String.raw`Valid: \x42`) // => `Valid: B`
|
||||
|
||||
`Octal: \102` // => Throws a SyntaxError
|
||||
unraw(String.raw`Octal: \102`) // => Throws a SyntaxError
|
||||
unraw(String.raw`Octal: \102`, true) // => Octal: B
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
If desired, you can access the possible error messages to help identify errors:
|
||||
|
||||
```ts
|
||||
import {unraw, ErrorType, errorMessages} from "unraw";
|
||||
|
||||
try {
|
||||
unraw("\\u25");
|
||||
} catch (err) {
|
||||
if (err.message === errorMessages.get(ErrorType.MalformedUnicode)) {
|
||||
console.error("String had an invalid Unicode escape sequence.");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The full list of error message names available through the `ErrorType` enum
|
||||
(exposed as a normal object in JavaScript).
|
||||
|
||||
## Contributing
|
||||
|
||||
Found a bug? Please,
|
||||
[submit it here.](https://github.com/iansan5653/unraw/issues)
|
||||
|
||||
Pull requests are always welcome, although to increase your chances of your
|
||||
contribution being accepted, opening an issue and linking to it is always a
|
||||
good idea.
|
||||
|
||||
Pull requests will not be merged unless the Azure Pipelines build succeeds.
|
||||
This means that all checks must pass and code must be free of lint errors. To
|
||||
quickly confirm that it will, just run:
|
||||
|
||||
```bash
|
||||
npm run check
|
||||
```
|
||||
|
||||
This checks your formatting, tests, and for TypeScript compiler errors. If the
|
||||
task doesn't fail, you should be good to go.
|
||||
|
||||
### Other Tasks
|
||||
|
||||
For your convenience, some other tasks are also provided in the `package.json`:
|
||||
|
||||
- `npm run build` - Compiles TypeScript code to JavaScript
|
||||
- `npm run minify` - Generate minified JavaScript files from compiled files
|
||||
- `npm run test` - Quickly run tests using TypeScript code without compiling
|
||||
- `npm run testWithCoverage` - Run tests and generate coverage report
|
||||
- `npm run lint` - Check code for linting errors
|
||||
- `npm run check` - Check to ensure code will pass Pipelines checks (see above)
|
||||
- `npm run format` - Format code using Prettier
|
Loading…
Add table
Add a link
Reference in a new issue