82 lines
3.4 KiB
JavaScript
82 lines
3.4 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$textTokenization = function(global, require, module, exports) {
|
|
function isNewline(char) {
|
|
return "string" !== typeof char ? !1 : NEWLINES_SET.has(char.charCodeAt(0));
|
|
}
|
|
function isBreakingSpace(char, _nextChar) {
|
|
return "string" !== typeof char ? !1 : BREAKING_SPACES_SET.has(char.charCodeAt(0));
|
|
}
|
|
function isBreakAfterChar(char) {
|
|
return "string" !== typeof char ? !1 : BREAK_AFTER_CHARS_SET.has(char.charCodeAt(0));
|
|
}
|
|
global = [10, 13];
|
|
const NEWLINES_SET = new Set(global);
|
|
require = [9, 32, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8200, 8201, 8202, 8287, 12288];
|
|
const BREAKING_SPACES_SET = new Set(require);
|
|
module = [9, 32];
|
|
const COLLAPSIBLE_SPACES_SET = new Set(module), BREAK_AFTER_CHARS = [45, 8208, 8211, 8212, 173], BREAK_AFTER_CHARS_SET = new Set(BREAK_AFTER_CHARS);
|
|
exports.BREAKING_SPACES = require;
|
|
exports.BREAKING_SPACES_SET = BREAKING_SPACES_SET;
|
|
exports.BREAK_AFTER_CHARS = BREAK_AFTER_CHARS;
|
|
exports.BREAK_AFTER_CHARS_SET = BREAK_AFTER_CHARS_SET;
|
|
exports.COLLAPSIBLE_SPACES = module;
|
|
exports.COLLAPSIBLE_SPACES_SET = COLLAPSIBLE_SPACES_SET;
|
|
exports.NEWLINES = global;
|
|
exports.NEWLINES_SET = NEWLINES_SET;
|
|
exports.NEWLINE_MATCH_REGEX = /(?:\r\n|\r|\n)/;
|
|
exports.NEWLINE_SPLIT_REGEX = /(\r\n|\r|\n)/;
|
|
exports.collapseNewlines = function(whiteSpace) {
|
|
return "normal" === whiteSpace;
|
|
};
|
|
exports.collapseSpaces = function(whiteSpace) {
|
|
return "normal" === whiteSpace || "pre-line" === whiteSpace;
|
|
};
|
|
exports.getCharacterGroups = function(token, breakWords, splitFn, canBreakCharsFn) {
|
|
splitFn = splitFn(token);
|
|
const groups = [];
|
|
for (let j = 0; j < splitFn.length; j++) {
|
|
let char = splitFn[j], lastChar = char, k = 1;
|
|
for (; splitFn[j + k];) {
|
|
const nextChar = splitFn[j + k];
|
|
if (canBreakCharsFn(lastChar, nextChar, token, j, breakWords)) {
|
|
break;
|
|
} else {
|
|
char += nextChar, lastChar = nextChar, k++;
|
|
}
|
|
}
|
|
j += k - 1;
|
|
groups.push(char);
|
|
}
|
|
return groups;
|
|
};
|
|
exports.isBreakAfterChar = isBreakAfterChar;
|
|
exports.isBreakingSpace = isBreakingSpace;
|
|
exports.isCollapsibleSpace = function(char) {
|
|
return "string" !== typeof char ? !1 : COLLAPSIBLE_SPACES_SET.has(char.charCodeAt(0));
|
|
};
|
|
exports.isNewline = isNewline;
|
|
exports.tokenize = function(text) {
|
|
const tokens = [], tokenChars = [];
|
|
if ("string" !== typeof text) {
|
|
return tokens;
|
|
}
|
|
for (let i = 0; i < text.length; i++) {
|
|
const char = text[i], nextChar = text[i + 1];
|
|
isBreakingSpace(char, nextChar) || isNewline(char) ? (0 < tokenChars.length && (tokens.push(tokenChars.join("")), tokenChars.length = 0), "\r" === char && "\n" === nextChar ? (tokens.push("\r\n"), i++) : tokens.push(char)) : (tokenChars.push(char), isBreakAfterChar(char) && nextChar && !isBreakingSpace(nextChar) && !isNewline(nextChar) && (tokens.push(tokenChars.join("")), tokenChars.length = 0));
|
|
}
|
|
0 < tokenChars.length && tokens.push(tokenChars.join(""));
|
|
return tokens;
|
|
};
|
|
exports.trimRight = function(text) {
|
|
if ("string" !== typeof text) {
|
|
return "";
|
|
}
|
|
let i = text.length - 1;
|
|
for (; 0 <= i && isBreakingSpace(text[i]);) {
|
|
i--;
|
|
}
|
|
return i < text.length - 1 ? text.slice(0, i + 1) : text;
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$textTokenization.js.map
|