@opensumi/ide-components 3.1.5-next-1719988985.0 → 3.1.5-next-1720065119.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/dist/index.js +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6357,7 +6357,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
6357
6357
|
/***/ ((__unused_webpack_module, exports) => {
|
|
6358
6358
|
|
|
6359
6359
|
"use strict";
|
|
6360
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.IAIReporter = exports.MergeConflictEditorMode = exports.AISerivceType = exports.AI_REPORTER_NAME = void 0;\nexports.AI_REPORTER_NAME = 'AI';\nvar AISerivceType;\n(function (AISerivceType) {\n AISerivceType[\"Chat\"] = \"chat\";\n AISerivceType[\"InlineChat\"] = \"inlineChat\";\n AISerivceType[\"InlineChatInput\"] = \"inlineChatInput\";\n AISerivceType[\"CustomReplay\"] = \"customReplay\";\n AISerivceType[\"Completion\"] = \"completion\";\n AISerivceType[\"Agent\"] = \"agent\";\n AISerivceType[\"MergeConflict\"] = \"mergeConflict\";\n AISerivceType[\"Rename\"] = \"rename\";\n})(AISerivceType = exports.AISerivceType || (exports.AISerivceType = {}));\nvar MergeConflictEditorMode;\n(function (MergeConflictEditorMode) {\n MergeConflictEditorMode[\"3way\"] = \"3way\";\n MergeConflictEditorMode[\"traditional\"] = \"traditional\";\n})(MergeConflictEditorMode = exports.MergeConflictEditorMode || (exports.MergeConflictEditorMode = {}));\nexports.IAIReporter = Symbol('IAIReporter');\n//# sourceMappingURL=reporter.js.map\n\n//# sourceURL=webpack://@opensumi/ide-components/../core-common/lib/types/ai-native/reporter.js?");
|
|
6360
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.IAIReporter = exports.MergeConflictEditorMode = exports.AISerivceType = exports.AI_REPORTER_NAME = void 0;\nexports.AI_REPORTER_NAME = 'AI';\nvar AISerivceType;\n(function (AISerivceType) {\n AISerivceType[\"Chat\"] = \"chat\";\n AISerivceType[\"InlineChat\"] = \"inlineChat\";\n AISerivceType[\"InlineChatInput\"] = \"inlineChatInput\";\n AISerivceType[\"CustomReplay\"] = \"customReplay\";\n AISerivceType[\"Completion\"] = \"completion\";\n AISerivceType[\"Agent\"] = \"agent\";\n AISerivceType[\"MergeConflict\"] = \"mergeConflict\";\n AISerivceType[\"Rename\"] = \"rename\";\n AISerivceType[\"TerminalAICommand\"] = \"terminalAICommand\";\n})(AISerivceType = exports.AISerivceType || (exports.AISerivceType = {}));\nvar MergeConflictEditorMode;\n(function (MergeConflictEditorMode) {\n MergeConflictEditorMode[\"3way\"] = \"3way\";\n MergeConflictEditorMode[\"traditional\"] = \"traditional\";\n})(MergeConflictEditorMode = exports.MergeConflictEditorMode || (exports.MergeConflictEditorMode = {}));\nexports.IAIReporter = Symbol('IAIReporter');\n//# sourceMappingURL=reporter.js.map\n\n//# sourceURL=webpack://@opensumi/ide-components/../core-common/lib/types/ai-native/reporter.js?");
|
|
6361
6361
|
|
|
6362
6362
|
/***/ }),
|
|
6363
6363
|
|
|
@@ -6973,7 +6973,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexpo
|
|
|
6973
6973
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6974
6974
|
|
|
6975
6975
|
"use strict";
|
|
6976
|
-
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.containsUppercaseCharacter = exports.fuzzyContains = exports.repeat = exports.safeBtoa = exports.stripUTF8BOM = exports.startsWithUTF8BOM = exports.UTF8_BOM_CHARACTER = exports.removeAccents = exports.removeAnsiEscapeCodes = exports.lcut = exports.isFullWidthCharacter = exports.containsFullWidthCharacter = exports.isBasicASCII = exports.containsEmoji = exports.containsRTL = exports.isLowSurrogate = exports.isHighSurrogate = exports.overlap = exports.commonSuffixLength = exports.commonPrefixLength = exports.startsWithIgnoreCase = exports.equalsIgnoreCase = exports.isUpperAsciiLetter = exports.isLowerAsciiLetter = exports.compareIgnoreCase = exports.compare = exports.lastNonWhitespaceIndex = exports.getLeadingWhitespace = exports.firstNonWhitespaceIndex = exports.regExpFlags = exports.regExpContainsBackreference = exports.regExpLeadsToEndlessLoop = exports.createRegExp = exports.endsWith = exports.startsWith = exports.stripWildcards = exports.convertSimple2RegExpPattern = exports.rtrim = exports.multiRightTrim = exports.ltrim = exports.trim = exports.count = exports.escapeRegExpCharacters = exports.escape = exports.mnemonicButtonLabel = exports.format = exports.pad = exports.isFalsyOrWhitespace = exports.stringUtils = exports.empty = void 0;\nexports.getChunks = exports.format2 = exports.template = exports.decodeUTF8 = exports.encodeUTF8 = exports.getNextCodePoint = exports.computeCodePoint = exports.getNLines = exports.uppercaseFirstLetter = void 0;\nconst platform_1 = __webpack_require__(/*! ./platform */ \"../utils/lib/platform.js\");\n/**\n * The empty string.\n */\nexports.empty = '';\nconst hasTextEncoder = typeof TextEncoder !== 'undefined';\nconst hasTextDecoder = typeof TextDecoder !== 'undefined';\n/**\n * 浏览器全局可以直接使用 TextEncoder/TextDecoder\n * Node.js 11+ 才可以全局使用,以下需要 require('util')\n */\nvar stringUtils;\n(function (stringUtils) {\n stringUtils.StringTextEncoder = hasTextEncoder ? TextEncoder : (__webpack_require__(/*! util */ \"../../node_modules/util/util.js\").TextEncoder);\n stringUtils.StringTextDecoder = hasTextDecoder ? TextDecoder : (__webpack_require__(/*! util */ \"../../node_modules/util/util.js\").TextDecoder);\n})(stringUtils = exports.stringUtils || (exports.stringUtils = {}));\nfunction isFalsyOrWhitespace(str) {\n if (!str || typeof str !== 'string') {\n return true;\n }\n return str.trim().length === 0;\n}\nexports.isFalsyOrWhitespace = isFalsyOrWhitespace;\n/**\n * @returns the provided number with the given number of preceding zeros.\n */\nfunction pad(n, l, char = '0') {\n const str = '' + n;\n const r = [str];\n for (let i = str.length; i < l; i++) {\n r.push(char);\n }\n return r.reverse().join('');\n}\nexports.pad = pad;\nconst _formatRegexp = /{(\\d+)}/g;\n/**\n * Helper to produce a string with a variable number of arguments. Insert variable segments\n * into the string using the {n} notation where N is the index of the argument following the string.\n * @param value string to which formatting is applied\n * @param args replacements for {n}-entries\n */\nfunction format(value, ...args) {\n if (args.length === 0) {\n return value;\n }\n return value.replace(_formatRegexp, function (match, group) {\n const idx = parseInt(group, 10);\n return isNaN(idx) || idx < 0 || idx >= args.length ? match : args[idx];\n });\n}\nexports.format = format;\n/**\n * Handles mnemonics for buttons. Depending on OS:\n * - Windows: Supported via & character (replace && with & and & with && for escaping)\n * - Linux: Supported via _ character (replace && with _)\n * - macOS: Unsupported (replace && with empty string)\n */\nfunction mnemonicButtonLabel(label, forceDisableMnemonics) {\n if (platform_1.isMacintosh || forceDisableMnemonics) {\n return label.replace(/\\(&&\\w\\)|&&/g, '');\n }\n if (platform_1.isWindows) {\n return label.replace(/&&|&/g, (m) => (m === '&' ? '&&' : '&'));\n }\n return label.replace(/&&/g, '_');\n}\nexports.mnemonicButtonLabel = mnemonicButtonLabel;\n/**\n * Converts HTML characters inside the string to use entities instead. Makes the string safe from\n * being used e.g. in HTMLElement.innerHTML.\n */\nfunction escape(html) {\n return html.replace(/[<>&]/g, function (match) {\n switch (match) {\n case '<':\n return '<';\n case '>':\n return '>';\n case '&':\n return '&';\n default:\n return match;\n }\n });\n}\nexports.escape = escape;\n/**\n * Escapes regular expression characters in a given string\n */\nfunction escapeRegExpCharacters(value) {\n return value.replace(/[\\\\\\{\\}\\*\\+\\?\\|\\^\\$\\.\\[\\]\\(\\)]/g, '\\\\$&');\n}\nexports.escapeRegExpCharacters = escapeRegExpCharacters;\n/**\n * Counts how often `character` occurs inside `value`.\n */\nfunction count(value, character) {\n let result = 0;\n const ch = character.charCodeAt(0);\n for (let i = value.length - 1; i >= 0; i--) {\n if (value.charCodeAt(i) === ch) {\n result++;\n }\n }\n return result;\n}\nexports.count = count;\n/**\n * Removes all occurrences of needle from the beginning and end of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim (default is a blank)\n */\nfunction trim(haystack, needle = ' ') {\n const trimmed = ltrim(haystack, needle);\n return rtrim(trimmed, needle);\n}\nexports.trim = trim;\n/**\n * Removes all occurrences of needle from the beginning of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim\n */\nfunction ltrim(haystack, needle) {\n if (!haystack || !needle) {\n return haystack;\n }\n const needleLen = needle.length;\n if (needleLen === 0 || haystack.length === 0) {\n return haystack;\n }\n let offset = 0;\n while (haystack.indexOf(needle, offset) === offset) {\n offset = offset + needleLen;\n }\n return haystack.substring(offset);\n}\nexports.ltrim = ltrim;\n/**\n * Removes all occurrences of needles from the end of haystack.\n * @param source\n * @param needles\n * @example\n * ```ts\n * let source = '/path/to/file.ts,;';\n * const res = multiRightTrim(source, [`,`, ';']);\n * // res === '/path/to/file.ts';\n * ```\n */\nfunction multiRightTrim(source, needles) {\n let result = decodeURIComponent(source);\n for (const needle of needles) {\n result = rtrim(result, needle);\n }\n return result;\n}\nexports.multiRightTrim = multiRightTrim;\n/**\n * Removes all occurrences of needle from the end of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim\n */\nfunction rtrim(haystack, needle) {\n if (!haystack || !needle) {\n return haystack;\n }\n const needleLen = needle.length;\n const haystackLen = haystack.length;\n if (needleLen === 0 || haystackLen === 0) {\n return haystack;\n }\n let offset = haystackLen;\n let idx = -1;\n while (true) {\n idx = haystack.lastIndexOf(needle, offset - 1);\n if (idx === -1 || idx + needleLen !== offset) {\n break;\n }\n if (idx === 0) {\n return '';\n }\n offset = idx;\n }\n return haystack.substring(0, offset);\n}\nexports.rtrim = rtrim;\nfunction convertSimple2RegExpPattern(pattern) {\n return pattern.replace(/[\\-\\\\\\{\\}\\+\\?\\|\\^\\$\\.\\,\\[\\]\\(\\)\\#\\s]/g, '\\\\$&').replace(/[\\*]/g, '.*');\n}\nexports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;\nfunction stripWildcards(pattern) {\n return pattern.replace(/\\*/g, '');\n}\nexports.stripWildcards = stripWildcards;\n/**\n * Determines if haystack starts with needle.\n */\nfunction startsWith(haystack, needle) {\n if (haystack.length < needle.length) {\n return false;\n }\n if (haystack === needle) {\n return true;\n }\n for (let i = 0; i < needle.length; i++) {\n if (haystack[i] !== needle[i]) {\n return false;\n }\n }\n return true;\n}\nexports.startsWith = startsWith;\n/**\n * Determines if haystack ends with needle.\n */\nfunction endsWith(haystack, needle) {\n const diff = haystack.length - needle.length;\n if (diff > 0) {\n return haystack.indexOf(needle, diff) === diff;\n }\n else if (diff === 0) {\n return haystack === needle;\n }\n else {\n return false;\n }\n}\nexports.endsWith = endsWith;\nfunction createRegExp(searchString, isRegex, options = {}) {\n if (!searchString) {\n throw new Error('Cannot create regex from empty string');\n }\n if (!isRegex) {\n searchString = escapeRegExpCharacters(searchString);\n }\n if (options.wholeWord) {\n if (!/\\B/.test(searchString.charAt(0))) {\n searchString = '\\\\b' + searchString;\n }\n if (!/\\B/.test(searchString.charAt(searchString.length - 1))) {\n searchString = searchString + '\\\\b';\n }\n }\n let modifiers = '';\n if (options.global) {\n modifiers += 'g';\n }\n if (!options.matchCase) {\n modifiers += 'i';\n }\n if (options.multiline) {\n modifiers += 'm';\n }\n if (options.unicode) {\n modifiers += 'u';\n }\n return new RegExp(searchString, modifiers);\n}\nexports.createRegExp = createRegExp;\nfunction regExpLeadsToEndlessLoop(regexp) {\n // Exit early if it's one of these special cases which are meant to match\n // against an empty string\n if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\\\s*$') {\n return false;\n }\n // We check against an empty string. If the regular expression doesn't advance\n // (e.g. ends in an endless loop) it will match an empty string.\n const match = regexp.exec('');\n return !!(match && regexp.lastIndex === 0);\n}\nexports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;\nfunction regExpContainsBackreference(regexpValue) {\n return !!regexpValue.match(/([^\\\\]|^)(\\\\\\\\)*\\\\\\d+/);\n}\nexports.regExpContainsBackreference = regExpContainsBackreference;\nfunction regExpFlags(regexp) {\n return ((regexp.global ? 'g' : '') +\n (regexp.ignoreCase ? 'i' : '') +\n (regexp.multiline ? 'm' : '') +\n (regexp.unicode ? 'u' : ''));\n}\nexports.regExpFlags = regExpFlags;\n/**\n * Returns first index of the string that is not whitespace.\n * If string is empty or contains only whitespaces, returns -1\n */\nfunction firstNonWhitespaceIndex(str) {\n for (let i = 0, len = str.length; i < len; i++) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return i;\n }\n }\n return -1;\n}\nexports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;\n/**\n * Returns the leading whitespace of the string.\n * If the string contains only whitespaces, returns entire string\n */\nfunction getLeadingWhitespace(str, start = 0, end = str.length) {\n for (let i = start; i < end; i++) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return str.substring(start, i);\n }\n }\n return str.substring(start, end);\n}\nexports.getLeadingWhitespace = getLeadingWhitespace;\n/**\n * Returns last index of the string that is not whitespace.\n * If string is empty or contains only whitespaces, returns -1\n */\nfunction lastNonWhitespaceIndex(str, startIndex = str.length - 1) {\n for (let i = startIndex; i >= 0; i--) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return i;\n }\n }\n return -1;\n}\nexports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;\nfunction compare(a, b) {\n if (a < b) {\n return -1;\n }\n else if (a > b) {\n return 1;\n }\n else {\n return 0;\n }\n}\nexports.compare = compare;\nfunction compareIgnoreCase(a, b) {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n let codeA = a.charCodeAt(i);\n let codeB = b.charCodeAt(i);\n if (codeA === codeB) {\n // equal\n continue;\n }\n if (isUpperAsciiLetter(codeA)) {\n codeA += 32;\n }\n if (isUpperAsciiLetter(codeB)) {\n codeB += 32;\n }\n const diff = codeA - codeB;\n if (diff === 0) {\n // equal -> ignoreCase\n continue;\n }\n else if (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {\n //\n return diff;\n }\n else {\n return compare(a.toLowerCase(), b.toLowerCase());\n }\n }\n if (a.length < b.length) {\n return -1;\n }\n else if (a.length > b.length) {\n return 1;\n }\n else {\n return 0;\n }\n}\nexports.compareIgnoreCase = compareIgnoreCase;\nfunction isLowerAsciiLetter(code) {\n return code >= 97 /* CharCode.a */ && code <= 122 /* CharCode.z */;\n}\nexports.isLowerAsciiLetter = isLowerAsciiLetter;\nfunction isUpperAsciiLetter(code) {\n return code >= 65 /* CharCode.A */ && code <= 90 /* CharCode.Z */;\n}\nexports.isUpperAsciiLetter = isUpperAsciiLetter;\nfunction isAsciiLetter(code) {\n return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);\n}\nfunction equalsIgnoreCase(a, b) {\n const len1 = a ? a.length : 0;\n const len2 = b ? b.length : 0;\n if (len1 !== len2) {\n return false;\n }\n return doEqualsIgnoreCase(a, b);\n}\nexports.equalsIgnoreCase = equalsIgnoreCase;\nfunction doEqualsIgnoreCase(a, b, stopAt = a.length) {\n if (typeof a !== 'string' || typeof b !== 'string') {\n return false;\n }\n for (let i = 0; i < stopAt; i++) {\n const codeA = a.charCodeAt(i);\n const codeB = b.charCodeAt(i);\n if (codeA === codeB) {\n continue;\n }\n // a-z A-Z\n if (isAsciiLetter(codeA) && isAsciiLetter(codeB)) {\n const diff = Math.abs(codeA - codeB);\n if (diff !== 0 && diff !== 32) {\n return false;\n }\n }\n else {\n // Any other charcode\n if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {\n return false;\n }\n }\n }\n return true;\n}\nfunction startsWithIgnoreCase(str, candidate) {\n const candidateLength = candidate.length;\n if (candidate.length > str.length) {\n return false;\n }\n return doEqualsIgnoreCase(str, candidate, candidateLength);\n}\nexports.startsWithIgnoreCase = startsWithIgnoreCase;\n/**\n * @returns the length of the common prefix of the two strings.\n */\nfunction commonPrefixLength(a, b) {\n let i;\n const len = Math.min(a.length, b.length);\n for (i = 0; i < len; i++) {\n if (a.charCodeAt(i) !== b.charCodeAt(i)) {\n return i;\n }\n }\n return len;\n}\nexports.commonPrefixLength = commonPrefixLength;\n/**\n * @returns the length of the common suffix of the two strings.\n */\nfunction commonSuffixLength(a, b) {\n let i;\n const len = Math.min(a.length, b.length);\n const aLastIndex = a.length - 1;\n const bLastIndex = b.length - 1;\n for (i = 0; i < len; i++) {\n if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {\n return i;\n }\n }\n return len;\n}\nexports.commonSuffixLength = commonSuffixLength;\nfunction substrEquals(a, aStart, aEnd, b, bStart, bEnd) {\n while (aStart < aEnd && bStart < bEnd) {\n if (a[aStart] !== b[bStart]) {\n return false;\n }\n aStart += 1;\n bStart += 1;\n }\n return true;\n}\n/**\n * Return the overlap between the suffix of `a` and the prefix of `b`.\n * For instance `overlap(\"foobar\", \"arr, I'm a pirate\") === 2`.\n */\nfunction overlap(a, b) {\n const aEnd = a.length;\n let bEnd = b.length;\n let aStart = aEnd - bEnd;\n if (aStart === 0) {\n return a === b ? aEnd : 0;\n }\n else if (aStart < 0) {\n bEnd += aStart;\n aStart = 0;\n }\n while (aStart < aEnd && bEnd > 0) {\n if (substrEquals(a, aStart, aEnd, b, 0, bEnd)) {\n return bEnd;\n }\n bEnd -= 1;\n aStart += 1;\n }\n return 0;\n}\nexports.overlap = overlap;\n// --- unicode\n// http://en.wikipedia.org/wiki/Surrogate_pair\n// Returns the code point starting at a specified index in a string\n// Code points U+0000 to U+D7FF and U+E000 to U+FFFF are represented on a single character\n// Code points U+10000 to U+10FFFF are represented on two consecutive characters\n// export function getUnicodePoint(str:string, index:number, len:number):number {\n//\tconst chrCode = str.charCodeAt(index);\n//\tif (0xD800 <= chrCode && chrCode <= 0xDBFF && index + 1 < len) {\n//\t\tconst nextChrCode = str.charCodeAt(index + 1);\n//\t\tif (0xDC00 <= nextChrCode && nextChrCode <= 0xDFFF) {\n//\t\t\treturn (chrCode - 0xD800) << 10 + (nextChrCode - 0xDC00) + 0x10000;\n//\t\t}\n//\t}\n//\treturn chrCode;\n// }\nfunction isHighSurrogate(charCode) {\n return 0xd800 <= charCode && charCode <= 0xdbff;\n}\nexports.isHighSurrogate = isHighSurrogate;\nfunction isLowSurrogate(charCode) {\n return 0xdc00 <= charCode && charCode <= 0xdfff;\n}\nexports.isLowSurrogate = isLowSurrogate;\n/**\n * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-rtl-test.js\n */\nconst CONTAINS_RTL = /(?:[\\u05BE\\u05C0\\u05C3\\u05C6\\u05D0-\\u05F4\\u0608\\u060B\\u060D\\u061B-\\u064A\\u066D-\\u066F\\u0671-\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1-\\u07EA\\u07F4\\u07F5\\u07FA-\\u0815\\u081A\\u0824\\u0828\\u0830-\\u0858\\u085E-\\u08BD\\u200F\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFD3D\\uFD50-\\uFDFC\\uFE70-\\uFEFC]|\\uD802[\\uDC00-\\uDD1B\\uDD20-\\uDE00\\uDE10-\\uDE33\\uDE40-\\uDEE4\\uDEEB-\\uDF35\\uDF40-\\uDFFF]|\\uD803[\\uDC00-\\uDCFF]|\\uD83A[\\uDC00-\\uDCCF\\uDD00-\\uDD43\\uDD50-\\uDFFF]|\\uD83B[\\uDC00-\\uDEBB])/;\n/**\n * Returns true if `str` contains any Unicode character that is classified as \"R\" or \"AL\".\n */\nfunction containsRTL(str) {\n return CONTAINS_RTL.test(str);\n}\nexports.containsRTL = containsRTL;\n/**\n * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js\n */\nconst CONTAINS_EMOJI = /(?:[\\u231A\\u231B\\u23F0\\u23F3\\u2600-\\u27BF\\u2B50\\u2B55]|\\uD83C[\\uDDE6-\\uDDFF\\uDF00-\\uDFFF]|\\uD83D[\\uDC00-\\uDE4F\\uDE80-\\uDEF8]|\\uD83E[\\uDD00-\\uDDE6])/;\nfunction containsEmoji(str) {\n return CONTAINS_EMOJI.test(str);\n}\nexports.containsEmoji = containsEmoji;\nconst IS_BASIC_ASCII = /^[\\t\\n\\r\\x20-\\x7E]*$/;\n/**\n * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \\n, \\r, \\t\n */\nfunction isBasicASCII(str) {\n return IS_BASIC_ASCII.test(str);\n}\nexports.isBasicASCII = isBasicASCII;\nfunction containsFullWidthCharacter(str) {\n for (let i = 0, len = str.length; i < len; i++) {\n if (isFullWidthCharacter(str.charCodeAt(i))) {\n return true;\n }\n }\n return false;\n}\nexports.containsFullWidthCharacter = containsFullWidthCharacter;\nfunction isFullWidthCharacter(charCode) {\n // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns\n // http://jrgraphix.net/research/unicode_blocks.php\n // 2E80 — 2EFF CJK Radicals Supplement\n // 2F00 — 2FDF Kangxi Radicals\n // 2FF0 — 2FFF Ideographic Description Characters\n // 3000 — 303F CJK Symbols and Punctuation\n // 3040 — 309F Hiragana\n // 30A0 — 30FF Katakana\n // 3100 — 312F Bopomofo\n // 3130 — 318F Hangul Compatibility Jamo\n // 3190 — 319F Kanbun\n // 31A0 — 31BF Bopomofo Extended\n // 31F0 — 31FF Katakana Phonetic Extensions\n // 3200 — 32FF Enclosed CJK Letters and Months\n // 3300 — 33FF CJK Compatibility\n // 3400 — 4DBF CJK Unified Ideographs Extension A\n // 4DC0 — 4DFF Yijing Hexagram Symbols\n // 4E00 — 9FFF CJK Unified Ideographs\n // A000 — A48F Yi Syllables\n // A490 — A4CF Yi Radicals\n // AC00 — D7AF Hangul Syllables\n // [IGNORE] D800 — DB7F High Surrogates\n // [IGNORE] DB80 — DBFF High Private Use Surrogates\n // [IGNORE] DC00 — DFFF Low Surrogates\n // [IGNORE] E000 — F8FF Private Use Area\n // F900 — FAFF CJK Compatibility Ideographs\n // [IGNORE] FB00 — FB4F Alphabetic Presentation Forms\n // [IGNORE] FB50 — FDFF Arabic Presentation Forms-A\n // [IGNORE] FE00 — FE0F Variation Selectors\n // [IGNORE] FE20 — FE2F Combining Half Marks\n // [IGNORE] FE30 — FE4F CJK Compatibility Forms\n // [IGNORE] FE50 — FE6F Small Form Variants\n // [IGNORE] FE70 — FEFF Arabic Presentation Forms-B\n // FF00 — FFEF Halfwidth and Fullwidth Forms\n // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]\n // of which FF01 - FF5E fullwidth ASCII of 21 to 7E\n // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul\n // [IGNORE] FFF0 — FFFF Specials\n charCode = +charCode; // @perf\n return ((charCode >= 0x2e80 && charCode <= 0xd7af) ||\n (charCode >= 0xf900 && charCode <= 0xfaff) ||\n (charCode >= 0xff01 && charCode <= 0xff5e));\n}\nexports.isFullWidthCharacter = isFullWidthCharacter;\n/**\n * Given a string and a max length returns a shorted version. Shorting\n * happens at favorable positions - such as whitespace or punctuation characters.\n */\nfunction lcut(text, n) {\n if (text.length < n) {\n return text;\n }\n const re = /\\b/g;\n let i = 0;\n while (re.test(text)) {\n if (text.length - re.lastIndex < n) {\n break;\n }\n i = re.lastIndex;\n re.lastIndex += 1;\n }\n return text.substring(i).replace(/^\\s/, exports.empty);\n}\nexports.lcut = lcut;\n// Escape codes\n// http://en.wikipedia.org/wiki/ANSI_escape_code\nconst EL = /\\x1B\\x5B[12]?K/g; // Erase in line\nconst COLOR_START = /\\x1b\\[\\d+m/g; // Color\nconst COLOR_END = /\\x1b\\[0?m/g; // Color\nfunction removeAnsiEscapeCodes(str) {\n if (str) {\n str = str.replace(EL, '');\n str = str.replace(COLOR_START, '');\n str = str.replace(COLOR_END, '');\n }\n return str;\n}\nexports.removeAnsiEscapeCodes = removeAnsiEscapeCodes;\nexports.removeAccents = (function () {\n if (typeof String.prototype.normalize !== 'function') {\n // ☹️ no ES6 features...\n return function (str) {\n return str;\n };\n }\n else {\n // transform into NFD form and remove accents\n // see: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463\n const regex = /[\\u0300-\\u036f]/g;\n return function (str) {\n return str.normalize('NFD').replace(regex, exports.empty);\n };\n }\n})();\n// -- UTF-8 BOM\nexports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* CharCode.UTF8_BOM */);\nfunction startsWithUTF8BOM(str) {\n return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* CharCode.UTF8_BOM */);\n}\nexports.startsWithUTF8BOM = startsWithUTF8BOM;\nfunction stripUTF8BOM(str) {\n return startsWithUTF8BOM(str) ? str.substr(1) : str;\n}\nexports.stripUTF8BOM = stripUTF8BOM;\nfunction safeBtoa(str) {\n return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values\n}\nexports.safeBtoa = safeBtoa;\nfunction repeat(s, count) {\n let result = '';\n for (let i = 0; i < count; i++) {\n result += s;\n }\n return result;\n}\nexports.repeat = repeat;\n/**\n * Checks if the characters of the provided query string are included in the\n * target string. The characters do not have to be contiguous within the string.\n */\nfunction fuzzyContains(target, query) {\n if (!target || !query) {\n return false; // return early if target or query are undefined\n }\n if (target.length < query.length) {\n return false; // impossible for query to be contained in target\n }\n const queryLen = query.length;\n const targetLower = target.toLowerCase();\n let index = 0;\n let lastIndexOf = -1;\n while (index < queryLen) {\n const indexOf = targetLower.indexOf(query[index], lastIndexOf + 1);\n if (indexOf < 0) {\n return false;\n }\n lastIndexOf = indexOf;\n index++;\n }\n return true;\n}\nexports.fuzzyContains = fuzzyContains;\nfunction containsUppercaseCharacter(target, ignoreEscapedChars = false) {\n if (!target) {\n return false;\n }\n if (ignoreEscapedChars) {\n target = target.replace(/\\\\./g, '');\n }\n return target.toLowerCase() !== target;\n}\nexports.containsUppercaseCharacter = containsUppercaseCharacter;\nfunction uppercaseFirstLetter(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\nexports.uppercaseFirstLetter = uppercaseFirstLetter;\nfunction getNLines(str, n = 1) {\n if (n === 0) {\n return '';\n }\n let idx = -1;\n do {\n idx = str.indexOf('\\n', idx + 1);\n n--;\n } while (n > 0 && idx >= 0);\n return idx >= 0 ? str.substr(0, idx) : str;\n}\nexports.getNLines = getNLines;\n/**\n * See http://en.wikipedia.org/wiki/Surrogate_pair\n */\nfunction computeCodePoint(highSurrogate, lowSurrogate) {\n return ((highSurrogate - 0xd800) << 10) + (lowSurrogate - 0xdc00) + 0x10000;\n}\nexports.computeCodePoint = computeCodePoint;\n/**\n * get the code point that begins at offset `offset`\n */\nfunction getNextCodePoint(str, len, offset) {\n const charCode = str.charCodeAt(offset);\n if (isHighSurrogate(charCode) && offset + 1 < len) {\n const nextCharCode = str.charCodeAt(offset + 1);\n if (isLowSurrogate(nextCharCode)) {\n return computeCodePoint(charCode, nextCharCode);\n }\n }\n return charCode;\n}\nexports.getNextCodePoint = getNextCodePoint;\n/**\n * A manual encoding of `str` to UTF8.\n * Use only in environments which do not offer native conversion methods!\n */\nfunction encodeUTF8(str) {\n const strLen = str.length;\n // See https://en.wikipedia.org/wiki/UTF-8\n // first loop to establish needed buffer size\n let neededSize = 0;\n let strOffset = 0;\n while (strOffset < strLen) {\n const codePoint = getNextCodePoint(str, strLen, strOffset);\n strOffset += codePoint >= 65536 /* Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;\n if (codePoint < 0x0080) {\n neededSize += 1;\n }\n else if (codePoint < 0x0800) {\n neededSize += 2;\n }\n else if (codePoint < 0x10000) {\n neededSize += 3;\n }\n else {\n neededSize += 4;\n }\n }\n // second loop to actually encode\n const arr = new Uint8Array(neededSize);\n strOffset = 0;\n let arrOffset = 0;\n while (strOffset < strLen) {\n const codePoint = getNextCodePoint(str, strLen, strOffset);\n strOffset += codePoint >= 65536 /* Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;\n if (codePoint < 0x0080) {\n arr[arrOffset++] = codePoint;\n }\n else if (codePoint < 0x0800) {\n arr[arrOffset++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n else if (codePoint < 0x10000) {\n arr[arrOffset++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n else {\n arr[arrOffset++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n }\n return arr;\n}\nexports.encodeUTF8 = encodeUTF8;\n/**\n * A manual decoding of a UTF8 string.\n * Use only in environments which do not offer native conversion methods!\n */\nfunction decodeUTF8(buffer) {\n // https://en.wikipedia.org/wiki/UTF-8\n const len = buffer.byteLength;\n const result = [];\n let offset = 0;\n while (offset < len) {\n const v0 = buffer[offset];\n let codePoint;\n if (v0 >= 0b11110000 && offset + 3 < len) {\n // 4 bytes\n codePoint =\n (((buffer[offset++] & 0b00000111) << 18) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 12) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 6) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else if (v0 >= 0b11100000 && offset + 2 < len) {\n // 3 bytes\n codePoint =\n (((buffer[offset++] & 0b00001111) << 12) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 6) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else if (v0 >= 0b11000000 && offset + 1 < len) {\n // 2 bytes\n codePoint = (((buffer[offset++] & 0b00011111) << 6) >>> 0) | (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else {\n // 1 byte\n codePoint = buffer[offset++];\n }\n if ((codePoint >= 0 && codePoint <= 0xd7ff) || (codePoint >= 0xe000 && codePoint <= 0xffff)) {\n // Basic Multilingual Plane\n result.push(String.fromCharCode(codePoint));\n }\n else if (codePoint >= 0x010000 && codePoint <= 0x10ffff) {\n // Supplementary Planes\n const uPrime = codePoint - 0x10000;\n const w1 = 0xd800 + ((uPrime & 0b11111111110000000000) >>> 10);\n const w2 = 0xdc00 + ((uPrime & 0b00000000001111111111) >>> 0);\n result.push(String.fromCharCode(w1));\n result.push(String.fromCharCode(w2));\n }\n else {\n // illegal code point\n result.push(String.fromCharCode(0xfffd));\n }\n }\n return result.join('');\n}\nexports.decodeUTF8 = decodeUTF8;\n/**\n * 插值表达式的标记使用的是 ${}\n * 该函数会对 options 中的 separator 会有特殊处理,\n */\nfunction template(tpl, variables, options) {\n const result = [];\n let placeHolderStack = [];\n for (let idx = 0; idx < tpl.length; idx++) {\n const char = tpl[idx];\n const nextChar = tpl[idx + 1];\n // 往后多看一位\n if (char === '$' && nextChar === '{') {\n // 往后的可能是占位符了,注入进栈标志位(即 $)\n // 如果 placeHolder 栈已经有值了,现在不支持嵌套 ${},直接吐出所有值放到 result 中即可\n if (placeHolderStack.length > 0) {\n result.push(...placeHolderStack);\n placeHolderStack = [];\n }\n placeHolderStack.push(char);\n placeHolderStack.push(nextChar);\n idx++;\n continue;\n }\n // 如果当前 placeHolder 栈有字符,一直将字符入栈,直到匹配到 }\n if (placeHolderStack.length > 0) {\n if (char === '}') {\n // 占位符匹配结束\n // 拿出占位符进行值替换\n const placeholder = placeHolderStack.slice(2).join('');\n let v;\n if (placeholder === 'separator') {\n if (result[result.length - 1] === options.separator) {\n // 不需要重复 separator\n placeHolderStack = [];\n continue;\n }\n // 分隔符有单独的优化\n v = options.separator;\n }\n else {\n v = variables[placeholder];\n }\n const toPush = v !== null && v !== void 0 ? v : options.defaultValue;\n if (toPush) {\n result.push(toPush);\n }\n placeHolderStack = [];\n }\n else {\n placeHolderStack.push(char);\n }\n continue;\n }\n result.push(tpl[idx]);\n }\n // 去除前面和后面的 sep\n // 这些 sep 也是不需要的\n while (result[result.length - 1] === options.separator) {\n result.pop();\n }\n while (result[0] === options.separator) {\n result.shift();\n }\n return result.join('');\n}\nexports.template = template;\nconst _format2Regexp = /{([^}]+)}/g;\n/**\n * Helper to create a string from a template and a string record.\n * Similar to `format` but with objects instead of positional arguments.\n */\nfunction format2(template, values) {\n return template.replace(_format2Regexp, (match, group) => { var _a; return ((_a = values[group]) !== null && _a !== void 0 ? _a : match); });\n}\nexports.format2 = format2;\nfunction getChunks(str, size) {\n const strLength = str.length;\n const numChunks = Math.ceil(strLength / size);\n const chunks = new Array(numChunks);\n let i = 0;\n let o = 0;\n for (; i < numChunks; ++i, o += size) {\n chunks[i] = str.substr(o, size);\n }\n return chunks;\n}\nexports.getChunks = getChunks;\n//# sourceMappingURL=strings.js.map\n\n//# sourceURL=webpack://@opensumi/ide-components/../utils/lib/strings.js?");
|
|
6976
|
+
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.fuzzyContains = exports.repeat = exports.safeBtoa = exports.stripUTF8BOM = exports.startsWithUTF8BOM = exports.UTF8_BOM_CHARACTER = exports.removeAccents = exports.removeAnsiEscapeCodes = exports.lcut = exports.isFullWidthCharacter = exports.containsFullWidthCharacter = exports.isBasicASCII = exports.containsEmoji = exports.containsRTL = exports.isLowSurrogate = exports.isHighSurrogate = exports.overlap = exports.commonSuffixLength = exports.commonPrefixLength = exports.startsWithIgnoreCase = exports.equalsIgnoreCase = exports.isUpperAsciiLetter = exports.isLowerAsciiLetter = exports.compareIgnoreCase = exports.compare = exports.lastNonWhitespaceIndex = exports.getLeadingWhitespace = exports.firstNonWhitespaceIndex = exports.regExpFlags = exports.regExpContainsBackreference = exports.regExpLeadsToEndlessLoop = exports.createRegExp = exports.endsWith = exports.startsWith = exports.stripWildcards = exports.convertSimple2RegExpPattern = exports.rtrim = exports.multiRightTrim = exports.ltrim = exports.trim = exports.count = exports.escapeRegExpCharacters = exports.escape = exports.mnemonicButtonLabel = exports.format = exports.pad = exports.isFalsyOrWhitespace = exports.stringUtils = exports.space = exports.empty = void 0;\nexports.getChunks = exports.format2 = exports.template = exports.decodeUTF8 = exports.encodeUTF8 = exports.getNextCodePoint = exports.computeCodePoint = exports.getNLines = exports.uppercaseFirstLetter = exports.containsUppercaseCharacter = void 0;\nconst platform_1 = __webpack_require__(/*! ./platform */ \"../utils/lib/platform.js\");\n/**\n * The empty string.\n */\nexports.empty = '';\nexports.space = ' ';\nconst hasTextEncoder = typeof TextEncoder !== 'undefined';\nconst hasTextDecoder = typeof TextDecoder !== 'undefined';\n/**\n * 浏览器全局可以直接使用 TextEncoder/TextDecoder\n * Node.js 11+ 才可以全局使用,以下需要 require('util')\n */\nvar stringUtils;\n(function (stringUtils) {\n stringUtils.StringTextEncoder = hasTextEncoder ? TextEncoder : (__webpack_require__(/*! util */ \"../../node_modules/util/util.js\").TextEncoder);\n stringUtils.StringTextDecoder = hasTextDecoder ? TextDecoder : (__webpack_require__(/*! util */ \"../../node_modules/util/util.js\").TextDecoder);\n})(stringUtils = exports.stringUtils || (exports.stringUtils = {}));\nfunction isFalsyOrWhitespace(str) {\n if (!str || typeof str !== 'string') {\n return true;\n }\n return str.trim().length === 0;\n}\nexports.isFalsyOrWhitespace = isFalsyOrWhitespace;\n/**\n * @returns the provided number with the given number of preceding zeros.\n */\nfunction pad(n, l, char = '0') {\n const str = '' + n;\n const r = [str];\n for (let i = str.length; i < l; i++) {\n r.push(char);\n }\n return r.reverse().join('');\n}\nexports.pad = pad;\nconst _formatRegexp = /{(\\d+)}/g;\n/**\n * Helper to produce a string with a variable number of arguments. Insert variable segments\n * into the string using the {n} notation where N is the index of the argument following the string.\n * @param value string to which formatting is applied\n * @param args replacements for {n}-entries\n */\nfunction format(value, ...args) {\n if (args.length === 0) {\n return value;\n }\n return value.replace(_formatRegexp, function (match, group) {\n const idx = parseInt(group, 10);\n return isNaN(idx) || idx < 0 || idx >= args.length ? match : args[idx];\n });\n}\nexports.format = format;\n/**\n * Handles mnemonics for buttons. Depending on OS:\n * - Windows: Supported via & character (replace && with & and & with && for escaping)\n * - Linux: Supported via _ character (replace && with _)\n * - macOS: Unsupported (replace && with empty string)\n */\nfunction mnemonicButtonLabel(label, forceDisableMnemonics) {\n if (platform_1.isMacintosh || forceDisableMnemonics) {\n return label.replace(/\\(&&\\w\\)|&&/g, '');\n }\n if (platform_1.isWindows) {\n return label.replace(/&&|&/g, (m) => (m === '&' ? '&&' : '&'));\n }\n return label.replace(/&&/g, '_');\n}\nexports.mnemonicButtonLabel = mnemonicButtonLabel;\n/**\n * Converts HTML characters inside the string to use entities instead. Makes the string safe from\n * being used e.g. in HTMLElement.innerHTML.\n */\nfunction escape(html) {\n return html.replace(/[<>&]/g, function (match) {\n switch (match) {\n case '<':\n return '<';\n case '>':\n return '>';\n case '&':\n return '&';\n default:\n return match;\n }\n });\n}\nexports.escape = escape;\n/**\n * Escapes regular expression characters in a given string\n */\nfunction escapeRegExpCharacters(value) {\n return value.replace(/[\\\\\\{\\}\\*\\+\\?\\|\\^\\$\\.\\[\\]\\(\\)]/g, '\\\\$&');\n}\nexports.escapeRegExpCharacters = escapeRegExpCharacters;\n/**\n * Counts how often `character` occurs inside `value`.\n */\nfunction count(value, character) {\n let result = 0;\n const ch = character.charCodeAt(0);\n for (let i = value.length - 1; i >= 0; i--) {\n if (value.charCodeAt(i) === ch) {\n result++;\n }\n }\n return result;\n}\nexports.count = count;\n/**\n * Removes all occurrences of needle from the beginning and end of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim (default is a blank)\n */\nfunction trim(haystack, needle = ' ') {\n const trimmed = ltrim(haystack, needle);\n return rtrim(trimmed, needle);\n}\nexports.trim = trim;\n/**\n * Removes all occurrences of needle from the beginning of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim\n */\nfunction ltrim(haystack, needle) {\n if (!haystack || !needle) {\n return haystack;\n }\n const needleLen = needle.length;\n if (needleLen === 0 || haystack.length === 0) {\n return haystack;\n }\n let offset = 0;\n while (haystack.indexOf(needle, offset) === offset) {\n offset = offset + needleLen;\n }\n return haystack.substring(offset);\n}\nexports.ltrim = ltrim;\n/**\n * Removes all occurrences of needles from the end of haystack.\n * @param source\n * @param needles\n * @example\n * ```ts\n * let source = '/path/to/file.ts,;';\n * const res = multiRightTrim(source, [`,`, ';']);\n * // res === '/path/to/file.ts';\n * ```\n */\nfunction multiRightTrim(source, needles) {\n let result = decodeURIComponent(source);\n for (const needle of needles) {\n result = rtrim(result, needle);\n }\n return result;\n}\nexports.multiRightTrim = multiRightTrim;\n/**\n * Removes all occurrences of needle from the end of haystack.\n * @param haystack string to trim\n * @param needle the thing to trim\n */\nfunction rtrim(haystack, needle) {\n if (!haystack || !needle) {\n return haystack;\n }\n const needleLen = needle.length;\n const haystackLen = haystack.length;\n if (needleLen === 0 || haystackLen === 0) {\n return haystack;\n }\n let offset = haystackLen;\n let idx = -1;\n while (true) {\n idx = haystack.lastIndexOf(needle, offset - 1);\n if (idx === -1 || idx + needleLen !== offset) {\n break;\n }\n if (idx === 0) {\n return '';\n }\n offset = idx;\n }\n return haystack.substring(0, offset);\n}\nexports.rtrim = rtrim;\nfunction convertSimple2RegExpPattern(pattern) {\n return pattern.replace(/[\\-\\\\\\{\\}\\+\\?\\|\\^\\$\\.\\,\\[\\]\\(\\)\\#\\s]/g, '\\\\$&').replace(/[\\*]/g, '.*');\n}\nexports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;\nfunction stripWildcards(pattern) {\n return pattern.replace(/\\*/g, '');\n}\nexports.stripWildcards = stripWildcards;\n/**\n * Determines if haystack starts with needle.\n */\nfunction startsWith(haystack, needle) {\n if (haystack.length < needle.length) {\n return false;\n }\n if (haystack === needle) {\n return true;\n }\n for (let i = 0; i < needle.length; i++) {\n if (haystack[i] !== needle[i]) {\n return false;\n }\n }\n return true;\n}\nexports.startsWith = startsWith;\n/**\n * Determines if haystack ends with needle.\n */\nfunction endsWith(haystack, needle) {\n const diff = haystack.length - needle.length;\n if (diff > 0) {\n return haystack.indexOf(needle, diff) === diff;\n }\n else if (diff === 0) {\n return haystack === needle;\n }\n else {\n return false;\n }\n}\nexports.endsWith = endsWith;\nfunction createRegExp(searchString, isRegex, options = {}) {\n if (!searchString) {\n throw new Error('Cannot create regex from empty string');\n }\n if (!isRegex) {\n searchString = escapeRegExpCharacters(searchString);\n }\n if (options.wholeWord) {\n if (!/\\B/.test(searchString.charAt(0))) {\n searchString = '\\\\b' + searchString;\n }\n if (!/\\B/.test(searchString.charAt(searchString.length - 1))) {\n searchString = searchString + '\\\\b';\n }\n }\n let modifiers = '';\n if (options.global) {\n modifiers += 'g';\n }\n if (!options.matchCase) {\n modifiers += 'i';\n }\n if (options.multiline) {\n modifiers += 'm';\n }\n if (options.unicode) {\n modifiers += 'u';\n }\n return new RegExp(searchString, modifiers);\n}\nexports.createRegExp = createRegExp;\nfunction regExpLeadsToEndlessLoop(regexp) {\n // Exit early if it's one of these special cases which are meant to match\n // against an empty string\n if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\\\s*$') {\n return false;\n }\n // We check against an empty string. If the regular expression doesn't advance\n // (e.g. ends in an endless loop) it will match an empty string.\n const match = regexp.exec('');\n return !!(match && regexp.lastIndex === 0);\n}\nexports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;\nfunction regExpContainsBackreference(regexpValue) {\n return !!regexpValue.match(/([^\\\\]|^)(\\\\\\\\)*\\\\\\d+/);\n}\nexports.regExpContainsBackreference = regExpContainsBackreference;\nfunction regExpFlags(regexp) {\n return ((regexp.global ? 'g' : '') +\n (regexp.ignoreCase ? 'i' : '') +\n (regexp.multiline ? 'm' : '') +\n (regexp.unicode ? 'u' : ''));\n}\nexports.regExpFlags = regExpFlags;\n/**\n * Returns first index of the string that is not whitespace.\n * If string is empty or contains only whitespaces, returns -1\n */\nfunction firstNonWhitespaceIndex(str) {\n for (let i = 0, len = str.length; i < len; i++) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return i;\n }\n }\n return -1;\n}\nexports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;\n/**\n * Returns the leading whitespace of the string.\n * If the string contains only whitespaces, returns entire string\n */\nfunction getLeadingWhitespace(str, start = 0, end = str.length) {\n for (let i = start; i < end; i++) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return str.substring(start, i);\n }\n }\n return str.substring(start, end);\n}\nexports.getLeadingWhitespace = getLeadingWhitespace;\n/**\n * Returns last index of the string that is not whitespace.\n * If string is empty or contains only whitespaces, returns -1\n */\nfunction lastNonWhitespaceIndex(str, startIndex = str.length - 1) {\n for (let i = startIndex; i >= 0; i--) {\n const chCode = str.charCodeAt(i);\n if (chCode !== 32 /* CharCode.Space */ && chCode !== 9 /* CharCode.Tab */) {\n return i;\n }\n }\n return -1;\n}\nexports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;\nfunction compare(a, b) {\n if (a < b) {\n return -1;\n }\n else if (a > b) {\n return 1;\n }\n else {\n return 0;\n }\n}\nexports.compare = compare;\nfunction compareIgnoreCase(a, b) {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n let codeA = a.charCodeAt(i);\n let codeB = b.charCodeAt(i);\n if (codeA === codeB) {\n // equal\n continue;\n }\n if (isUpperAsciiLetter(codeA)) {\n codeA += 32;\n }\n if (isUpperAsciiLetter(codeB)) {\n codeB += 32;\n }\n const diff = codeA - codeB;\n if (diff === 0) {\n // equal -> ignoreCase\n continue;\n }\n else if (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {\n //\n return diff;\n }\n else {\n return compare(a.toLowerCase(), b.toLowerCase());\n }\n }\n if (a.length < b.length) {\n return -1;\n }\n else if (a.length > b.length) {\n return 1;\n }\n else {\n return 0;\n }\n}\nexports.compareIgnoreCase = compareIgnoreCase;\nfunction isLowerAsciiLetter(code) {\n return code >= 97 /* CharCode.a */ && code <= 122 /* CharCode.z */;\n}\nexports.isLowerAsciiLetter = isLowerAsciiLetter;\nfunction isUpperAsciiLetter(code) {\n return code >= 65 /* CharCode.A */ && code <= 90 /* CharCode.Z */;\n}\nexports.isUpperAsciiLetter = isUpperAsciiLetter;\nfunction isAsciiLetter(code) {\n return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);\n}\nfunction equalsIgnoreCase(a, b) {\n const len1 = a ? a.length : 0;\n const len2 = b ? b.length : 0;\n if (len1 !== len2) {\n return false;\n }\n return doEqualsIgnoreCase(a, b);\n}\nexports.equalsIgnoreCase = equalsIgnoreCase;\nfunction doEqualsIgnoreCase(a, b, stopAt = a.length) {\n if (typeof a !== 'string' || typeof b !== 'string') {\n return false;\n }\n for (let i = 0; i < stopAt; i++) {\n const codeA = a.charCodeAt(i);\n const codeB = b.charCodeAt(i);\n if (codeA === codeB) {\n continue;\n }\n // a-z A-Z\n if (isAsciiLetter(codeA) && isAsciiLetter(codeB)) {\n const diff = Math.abs(codeA - codeB);\n if (diff !== 0 && diff !== 32) {\n return false;\n }\n }\n else {\n // Any other charcode\n if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {\n return false;\n }\n }\n }\n return true;\n}\nfunction startsWithIgnoreCase(str, candidate) {\n const candidateLength = candidate.length;\n if (candidate.length > str.length) {\n return false;\n }\n return doEqualsIgnoreCase(str, candidate, candidateLength);\n}\nexports.startsWithIgnoreCase = startsWithIgnoreCase;\n/**\n * @returns the length of the common prefix of the two strings.\n */\nfunction commonPrefixLength(a, b) {\n let i;\n const len = Math.min(a.length, b.length);\n for (i = 0; i < len; i++) {\n if (a.charCodeAt(i) !== b.charCodeAt(i)) {\n return i;\n }\n }\n return len;\n}\nexports.commonPrefixLength = commonPrefixLength;\n/**\n * @returns the length of the common suffix of the two strings.\n */\nfunction commonSuffixLength(a, b) {\n let i;\n const len = Math.min(a.length, b.length);\n const aLastIndex = a.length - 1;\n const bLastIndex = b.length - 1;\n for (i = 0; i < len; i++) {\n if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {\n return i;\n }\n }\n return len;\n}\nexports.commonSuffixLength = commonSuffixLength;\nfunction substrEquals(a, aStart, aEnd, b, bStart, bEnd) {\n while (aStart < aEnd && bStart < bEnd) {\n if (a[aStart] !== b[bStart]) {\n return false;\n }\n aStart += 1;\n bStart += 1;\n }\n return true;\n}\n/**\n * Return the overlap between the suffix of `a` and the prefix of `b`.\n * For instance `overlap(\"foobar\", \"arr, I'm a pirate\") === 2`.\n */\nfunction overlap(a, b) {\n const aEnd = a.length;\n let bEnd = b.length;\n let aStart = aEnd - bEnd;\n if (aStart === 0) {\n return a === b ? aEnd : 0;\n }\n else if (aStart < 0) {\n bEnd += aStart;\n aStart = 0;\n }\n while (aStart < aEnd && bEnd > 0) {\n if (substrEquals(a, aStart, aEnd, b, 0, bEnd)) {\n return bEnd;\n }\n bEnd -= 1;\n aStart += 1;\n }\n return 0;\n}\nexports.overlap = overlap;\n// --- unicode\n// http://en.wikipedia.org/wiki/Surrogate_pair\n// Returns the code point starting at a specified index in a string\n// Code points U+0000 to U+D7FF and U+E000 to U+FFFF are represented on a single character\n// Code points U+10000 to U+10FFFF are represented on two consecutive characters\n// export function getUnicodePoint(str:string, index:number, len:number):number {\n//\tconst chrCode = str.charCodeAt(index);\n//\tif (0xD800 <= chrCode && chrCode <= 0xDBFF && index + 1 < len) {\n//\t\tconst nextChrCode = str.charCodeAt(index + 1);\n//\t\tif (0xDC00 <= nextChrCode && nextChrCode <= 0xDFFF) {\n//\t\t\treturn (chrCode - 0xD800) << 10 + (nextChrCode - 0xDC00) + 0x10000;\n//\t\t}\n//\t}\n//\treturn chrCode;\n// }\nfunction isHighSurrogate(charCode) {\n return 0xd800 <= charCode && charCode <= 0xdbff;\n}\nexports.isHighSurrogate = isHighSurrogate;\nfunction isLowSurrogate(charCode) {\n return 0xdc00 <= charCode && charCode <= 0xdfff;\n}\nexports.isLowSurrogate = isLowSurrogate;\n/**\n * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-rtl-test.js\n */\nconst CONTAINS_RTL = /(?:[\\u05BE\\u05C0\\u05C3\\u05C6\\u05D0-\\u05F4\\u0608\\u060B\\u060D\\u061B-\\u064A\\u066D-\\u066F\\u0671-\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1-\\u07EA\\u07F4\\u07F5\\u07FA-\\u0815\\u081A\\u0824\\u0828\\u0830-\\u0858\\u085E-\\u08BD\\u200F\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFD3D\\uFD50-\\uFDFC\\uFE70-\\uFEFC]|\\uD802[\\uDC00-\\uDD1B\\uDD20-\\uDE00\\uDE10-\\uDE33\\uDE40-\\uDEE4\\uDEEB-\\uDF35\\uDF40-\\uDFFF]|\\uD803[\\uDC00-\\uDCFF]|\\uD83A[\\uDC00-\\uDCCF\\uDD00-\\uDD43\\uDD50-\\uDFFF]|\\uD83B[\\uDC00-\\uDEBB])/;\n/**\n * Returns true if `str` contains any Unicode character that is classified as \"R\" or \"AL\".\n */\nfunction containsRTL(str) {\n return CONTAINS_RTL.test(str);\n}\nexports.containsRTL = containsRTL;\n/**\n * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js\n */\nconst CONTAINS_EMOJI = /(?:[\\u231A\\u231B\\u23F0\\u23F3\\u2600-\\u27BF\\u2B50\\u2B55]|\\uD83C[\\uDDE6-\\uDDFF\\uDF00-\\uDFFF]|\\uD83D[\\uDC00-\\uDE4F\\uDE80-\\uDEF8]|\\uD83E[\\uDD00-\\uDDE6])/;\nfunction containsEmoji(str) {\n return CONTAINS_EMOJI.test(str);\n}\nexports.containsEmoji = containsEmoji;\nconst IS_BASIC_ASCII = /^[\\t\\n\\r\\x20-\\x7E]*$/;\n/**\n * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \\n, \\r, \\t\n */\nfunction isBasicASCII(str) {\n return IS_BASIC_ASCII.test(str);\n}\nexports.isBasicASCII = isBasicASCII;\nfunction containsFullWidthCharacter(str) {\n for (let i = 0, len = str.length; i < len; i++) {\n if (isFullWidthCharacter(str.charCodeAt(i))) {\n return true;\n }\n }\n return false;\n}\nexports.containsFullWidthCharacter = containsFullWidthCharacter;\nfunction isFullWidthCharacter(charCode) {\n // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns\n // http://jrgraphix.net/research/unicode_blocks.php\n // 2E80 — 2EFF CJK Radicals Supplement\n // 2F00 — 2FDF Kangxi Radicals\n // 2FF0 — 2FFF Ideographic Description Characters\n // 3000 — 303F CJK Symbols and Punctuation\n // 3040 — 309F Hiragana\n // 30A0 — 30FF Katakana\n // 3100 — 312F Bopomofo\n // 3130 — 318F Hangul Compatibility Jamo\n // 3190 — 319F Kanbun\n // 31A0 — 31BF Bopomofo Extended\n // 31F0 — 31FF Katakana Phonetic Extensions\n // 3200 — 32FF Enclosed CJK Letters and Months\n // 3300 — 33FF CJK Compatibility\n // 3400 — 4DBF CJK Unified Ideographs Extension A\n // 4DC0 — 4DFF Yijing Hexagram Symbols\n // 4E00 — 9FFF CJK Unified Ideographs\n // A000 — A48F Yi Syllables\n // A490 — A4CF Yi Radicals\n // AC00 — D7AF Hangul Syllables\n // [IGNORE] D800 — DB7F High Surrogates\n // [IGNORE] DB80 — DBFF High Private Use Surrogates\n // [IGNORE] DC00 — DFFF Low Surrogates\n // [IGNORE] E000 — F8FF Private Use Area\n // F900 — FAFF CJK Compatibility Ideographs\n // [IGNORE] FB00 — FB4F Alphabetic Presentation Forms\n // [IGNORE] FB50 — FDFF Arabic Presentation Forms-A\n // [IGNORE] FE00 — FE0F Variation Selectors\n // [IGNORE] FE20 — FE2F Combining Half Marks\n // [IGNORE] FE30 — FE4F CJK Compatibility Forms\n // [IGNORE] FE50 — FE6F Small Form Variants\n // [IGNORE] FE70 — FEFF Arabic Presentation Forms-B\n // FF00 — FFEF Halfwidth and Fullwidth Forms\n // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]\n // of which FF01 - FF5E fullwidth ASCII of 21 to 7E\n // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul\n // [IGNORE] FFF0 — FFFF Specials\n charCode = +charCode; // @perf\n return ((charCode >= 0x2e80 && charCode <= 0xd7af) ||\n (charCode >= 0xf900 && charCode <= 0xfaff) ||\n (charCode >= 0xff01 && charCode <= 0xff5e));\n}\nexports.isFullWidthCharacter = isFullWidthCharacter;\n/**\n * Given a string and a max length returns a shorted version. Shorting\n * happens at favorable positions - such as whitespace or punctuation characters.\n */\nfunction lcut(text, n) {\n if (text.length < n) {\n return text;\n }\n const re = /\\b/g;\n let i = 0;\n while (re.test(text)) {\n if (text.length - re.lastIndex < n) {\n break;\n }\n i = re.lastIndex;\n re.lastIndex += 1;\n }\n return text.substring(i).replace(/^\\s/, exports.empty);\n}\nexports.lcut = lcut;\n// Escape codes\n// http://en.wikipedia.org/wiki/ANSI_escape_code\nconst EL = /\\x1B\\x5B[12]?K/g; // Erase in line\nconst COLOR_START = /\\x1b\\[\\d+m/g; // Color\nconst COLOR_END = /\\x1b\\[0?m/g; // Color\nfunction removeAnsiEscapeCodes(str) {\n if (str) {\n str = str.replace(EL, '');\n str = str.replace(COLOR_START, '');\n str = str.replace(COLOR_END, '');\n }\n return str;\n}\nexports.removeAnsiEscapeCodes = removeAnsiEscapeCodes;\nexports.removeAccents = (function () {\n if (typeof String.prototype.normalize !== 'function') {\n // ☹️ no ES6 features...\n return function (str) {\n return str;\n };\n }\n else {\n // transform into NFD form and remove accents\n // see: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463\n const regex = /[\\u0300-\\u036f]/g;\n return function (str) {\n return str.normalize('NFD').replace(regex, exports.empty);\n };\n }\n})();\n// -- UTF-8 BOM\nexports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* CharCode.UTF8_BOM */);\nfunction startsWithUTF8BOM(str) {\n return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* CharCode.UTF8_BOM */);\n}\nexports.startsWithUTF8BOM = startsWithUTF8BOM;\nfunction stripUTF8BOM(str) {\n return startsWithUTF8BOM(str) ? str.substr(1) : str;\n}\nexports.stripUTF8BOM = stripUTF8BOM;\nfunction safeBtoa(str) {\n return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values\n}\nexports.safeBtoa = safeBtoa;\nfunction repeat(s, count) {\n let result = '';\n for (let i = 0; i < count; i++) {\n result += s;\n }\n return result;\n}\nexports.repeat = repeat;\n/**\n * Checks if the characters of the provided query string are included in the\n * target string. The characters do not have to be contiguous within the string.\n */\nfunction fuzzyContains(target, query) {\n if (!target || !query) {\n return false; // return early if target or query are undefined\n }\n if (target.length < query.length) {\n return false; // impossible for query to be contained in target\n }\n const queryLen = query.length;\n const targetLower = target.toLowerCase();\n let index = 0;\n let lastIndexOf = -1;\n while (index < queryLen) {\n const indexOf = targetLower.indexOf(query[index], lastIndexOf + 1);\n if (indexOf < 0) {\n return false;\n }\n lastIndexOf = indexOf;\n index++;\n }\n return true;\n}\nexports.fuzzyContains = fuzzyContains;\nfunction containsUppercaseCharacter(target, ignoreEscapedChars = false) {\n if (!target) {\n return false;\n }\n if (ignoreEscapedChars) {\n target = target.replace(/\\\\./g, '');\n }\n return target.toLowerCase() !== target;\n}\nexports.containsUppercaseCharacter = containsUppercaseCharacter;\nfunction uppercaseFirstLetter(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\nexports.uppercaseFirstLetter = uppercaseFirstLetter;\nfunction getNLines(str, n = 1) {\n if (n === 0) {\n return '';\n }\n let idx = -1;\n do {\n idx = str.indexOf('\\n', idx + 1);\n n--;\n } while (n > 0 && idx >= 0);\n return idx >= 0 ? str.substr(0, idx) : str;\n}\nexports.getNLines = getNLines;\n/**\n * See http://en.wikipedia.org/wiki/Surrogate_pair\n */\nfunction computeCodePoint(highSurrogate, lowSurrogate) {\n return ((highSurrogate - 0xd800) << 10) + (lowSurrogate - 0xdc00) + 0x10000;\n}\nexports.computeCodePoint = computeCodePoint;\n/**\n * get the code point that begins at offset `offset`\n */\nfunction getNextCodePoint(str, len, offset) {\n const charCode = str.charCodeAt(offset);\n if (isHighSurrogate(charCode) && offset + 1 < len) {\n const nextCharCode = str.charCodeAt(offset + 1);\n if (isLowSurrogate(nextCharCode)) {\n return computeCodePoint(charCode, nextCharCode);\n }\n }\n return charCode;\n}\nexports.getNextCodePoint = getNextCodePoint;\n/**\n * A manual encoding of `str` to UTF8.\n * Use only in environments which do not offer native conversion methods!\n */\nfunction encodeUTF8(str) {\n const strLen = str.length;\n // See https://en.wikipedia.org/wiki/UTF-8\n // first loop to establish needed buffer size\n let neededSize = 0;\n let strOffset = 0;\n while (strOffset < strLen) {\n const codePoint = getNextCodePoint(str, strLen, strOffset);\n strOffset += codePoint >= 65536 /* Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;\n if (codePoint < 0x0080) {\n neededSize += 1;\n }\n else if (codePoint < 0x0800) {\n neededSize += 2;\n }\n else if (codePoint < 0x10000) {\n neededSize += 3;\n }\n else {\n neededSize += 4;\n }\n }\n // second loop to actually encode\n const arr = new Uint8Array(neededSize);\n strOffset = 0;\n let arrOffset = 0;\n while (strOffset < strLen) {\n const codePoint = getNextCodePoint(str, strLen, strOffset);\n strOffset += codePoint >= 65536 /* Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;\n if (codePoint < 0x0080) {\n arr[arrOffset++] = codePoint;\n }\n else if (codePoint < 0x0800) {\n arr[arrOffset++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n else if (codePoint < 0x10000) {\n arr[arrOffset++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n else {\n arr[arrOffset++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n }\n }\n return arr;\n}\nexports.encodeUTF8 = encodeUTF8;\n/**\n * A manual decoding of a UTF8 string.\n * Use only in environments which do not offer native conversion methods!\n */\nfunction decodeUTF8(buffer) {\n // https://en.wikipedia.org/wiki/UTF-8\n const len = buffer.byteLength;\n const result = [];\n let offset = 0;\n while (offset < len) {\n const v0 = buffer[offset];\n let codePoint;\n if (v0 >= 0b11110000 && offset + 3 < len) {\n // 4 bytes\n codePoint =\n (((buffer[offset++] & 0b00000111) << 18) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 12) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 6) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else if (v0 >= 0b11100000 && offset + 2 < len) {\n // 3 bytes\n codePoint =\n (((buffer[offset++] & 0b00001111) << 12) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 6) >>> 0) |\n (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else if (v0 >= 0b11000000 && offset + 1 < len) {\n // 2 bytes\n codePoint = (((buffer[offset++] & 0b00011111) << 6) >>> 0) | (((buffer[offset++] & 0b00111111) << 0) >>> 0);\n }\n else {\n // 1 byte\n codePoint = buffer[offset++];\n }\n if ((codePoint >= 0 && codePoint <= 0xd7ff) || (codePoint >= 0xe000 && codePoint <= 0xffff)) {\n // Basic Multilingual Plane\n result.push(String.fromCharCode(codePoint));\n }\n else if (codePoint >= 0x010000 && codePoint <= 0x10ffff) {\n // Supplementary Planes\n const uPrime = codePoint - 0x10000;\n const w1 = 0xd800 + ((uPrime & 0b11111111110000000000) >>> 10);\n const w2 = 0xdc00 + ((uPrime & 0b00000000001111111111) >>> 0);\n result.push(String.fromCharCode(w1));\n result.push(String.fromCharCode(w2));\n }\n else {\n // illegal code point\n result.push(String.fromCharCode(0xfffd));\n }\n }\n return result.join('');\n}\nexports.decodeUTF8 = decodeUTF8;\n/**\n * 插值表达式的标记使用的是 ${}\n * 该函数会对 options 中的 separator 会有特殊处理,\n */\nfunction template(tpl, variables, options) {\n const result = [];\n let placeHolderStack = [];\n for (let idx = 0; idx < tpl.length; idx++) {\n const char = tpl[idx];\n const nextChar = tpl[idx + 1];\n // 往后多看一位\n if (char === '$' && nextChar === '{') {\n // 往后的可能是占位符了,注入进栈标志位(即 $)\n // 如果 placeHolder 栈已经有值了,现在不支持嵌套 ${},直接吐出所有值放到 result 中即可\n if (placeHolderStack.length > 0) {\n result.push(...placeHolderStack);\n placeHolderStack = [];\n }\n placeHolderStack.push(char);\n placeHolderStack.push(nextChar);\n idx++;\n continue;\n }\n // 如果当前 placeHolder 栈有字符,一直将字符入栈,直到匹配到 }\n if (placeHolderStack.length > 0) {\n if (char === '}') {\n // 占位符匹配结束\n // 拿出占位符进行值替换\n const placeholder = placeHolderStack.slice(2).join('');\n let v;\n if (placeholder === 'separator') {\n if (result[result.length - 1] === options.separator) {\n // 不需要重复 separator\n placeHolderStack = [];\n continue;\n }\n // 分隔符有单独的优化\n v = options.separator;\n }\n else {\n v = variables[placeholder];\n }\n const toPush = v !== null && v !== void 0 ? v : options.defaultValue;\n if (toPush) {\n result.push(toPush);\n }\n placeHolderStack = [];\n }\n else {\n placeHolderStack.push(char);\n }\n continue;\n }\n result.push(tpl[idx]);\n }\n // 去除前面和后面的 sep\n // 这些 sep 也是不需要的\n while (result[result.length - 1] === options.separator) {\n result.pop();\n }\n while (result[0] === options.separator) {\n result.shift();\n }\n return result.join('');\n}\nexports.template = template;\nconst _format2Regexp = /{([^}]+)}/g;\n/**\n * Helper to create a string from a template and a string record.\n * Similar to `format` but with objects instead of positional arguments.\n */\nfunction format2(template, values) {\n return template.replace(_format2Regexp, (match, group) => { var _a; return ((_a = values[group]) !== null && _a !== void 0 ? _a : match); });\n}\nexports.format2 = format2;\nfunction getChunks(str, size) {\n const strLength = str.length;\n const numChunks = Math.ceil(strLength / size);\n const chunks = new Array(numChunks);\n let i = 0;\n let o = 0;\n for (; i < numChunks; ++i, o += size) {\n chunks[i] = str.substr(o, size);\n }\n return chunks;\n}\nexports.getChunks = getChunks;\n//# sourceMappingURL=strings.js.map\n\n//# sourceURL=webpack://@opensumi/ide-components/../utils/lib/strings.js?");
|
|
6977
6977
|
|
|
6978
6978
|
/***/ }),
|
|
6979
6979
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-components",
|
|
3
|
-
"version": "3.1.5-next-
|
|
3
|
+
"version": "3.1.5-next-1720065119.0",
|
|
4
4
|
"description": "@opensumi/ide-components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@ant-design/icons": "^4.6.4",
|
|
19
|
-
"@opensumi/ide-utils": "3.1.5-next-
|
|
19
|
+
"@opensumi/ide-utils": "3.1.5-next-1720065119.0",
|
|
20
20
|
"fuzzy": "^0.1.3",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"marked": "4.0.10",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"react-window": "^1.8.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@opensumi/ide-dev-tool": "3.1.5-next-
|
|
39
|
+
"@opensumi/ide-dev-tool": "3.1.5-next-1720065119.0",
|
|
40
40
|
"@types/marked": "^4.0.7",
|
|
41
41
|
"@types/react-window": "^1.8.5",
|
|
42
42
|
"prop-types": "^15.8.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "cfae93307e43780bc51caefe3570bf37ead0dd97"
|
|
45
45
|
}
|