vite-plugin-inspect
Version:
Inspect the intermediate state of Vite plugins
1,642 lines (1,615 loc) • 1.09 MB
JavaScript
import { __export, getHot } from "./hot-D67q3Up2.js";
import { Fragment, computed, createBaseVNode, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, getCurrentInstance, h, inject, isRef, nextTick, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, resolveComponent, shallowRef, toDisplayString, toRefs, unref, watch, watchEffect, withAsyncContext, withCtx } from "./runtime-core.esm-bundler-Cyv4obHQ.js";
import { isDark, isStaticMode, onModuleUpdated, rpc, usePayloadStore } from "./payload-BX9lTMvN.js";
import "./_plugin-vue_export-helper-DfavQbjy.js";
import { Badge_default, Container_default, NavBar_default, PluginName_default, QuerySelector_default, SegmentControl_default } from "./QuerySelector-iLRAQoow.js";
import { DurationDisplay_default, useOptionsStore } from "./options-D_MMddT_.js";
import { useSearchResults } from "./search-Bklj8tNk.js";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d$1, b$1) {
d$1.__proto__ = b$1;
} || function(d$1, b$1) {
for (var p in b$1) if (Object.prototype.hasOwnProperty.call(b$1, p)) d$1[p] = b$1[p];
};
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var DEFAULT_FONT_SIZE = 12;
var DEFAULT_FONT_FAMILY = "sans-serif";
var DEFAULT_FONT = DEFAULT_FONT_SIZE + "px " + DEFAULT_FONT_FAMILY;
var OFFSET = 20;
var SCALE = 100;
var defaultWidthMapStr = "007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";
function getTextWidthMap(mapStr) {
var map$2 = {};
if (typeof JSON === "undefined") return map$2;
for (var i = 0; i < mapStr.length; i++) {
var char = String.fromCharCode(i + 32);
var size = (mapStr.charCodeAt(i) - OFFSET) / SCALE;
map$2[char] = size;
}
return map$2;
}
var DEFAULT_TEXT_WIDTH_MAP = getTextWidthMap(defaultWidthMapStr);
var platformApi = {
createCanvas: function() {
return typeof document !== "undefined" && document.createElement("canvas");
},
measureText: function() {
var _ctx;
var _cachedFont;
return function(text, font) {
if (!_ctx) {
var canvas = platformApi.createCanvas();
_ctx = canvas && canvas.getContext("2d");
}
if (_ctx) {
if (_cachedFont !== font) _cachedFont = _ctx.font = font || DEFAULT_FONT;
return _ctx.measureText(text);
} else {
text = text || "";
font = font || DEFAULT_FONT;
var res = /((?:\d+)?\.?\d*)px/.exec(font);
var fontSize = res && +res[1] || DEFAULT_FONT_SIZE;
var width = 0;
if (font.indexOf("mono") >= 0) width = fontSize * text.length;
else for (var i = 0; i < text.length; i++) {
var preCalcWidth = DEFAULT_TEXT_WIDTH_MAP[text[i]];
width += preCalcWidth == null ? fontSize : preCalcWidth * fontSize;
}
return { width };
}
};
}(),
loadImage: function(src, onload, onerror) {
var image = new Image();
image.onload = onload;
image.onerror = onerror;
image.src = src;
return image;
}
};
var BUILTIN_OBJECT = reduce([
"Function",
"RegExp",
"Date",
"Error",
"CanvasGradient",
"CanvasPattern",
"Image",
"Canvas"
], function(obj, val) {
obj["[object " + val + "]"] = true;
return obj;
}, {});
var TYPED_ARRAY = reduce([
"Int8",
"Uint8",
"Uint8Clamped",
"Int16",
"Uint16",
"Int32",
"Uint32",
"Float32",
"Float64"
], function(obj, val) {
obj["[object " + val + "Array]"] = true;
return obj;
}, {});
var objToString = Object.prototype.toString;
var arrayProto = Array.prototype;
var nativeForEach = arrayProto.forEach;
var nativeFilter = arrayProto.filter;
var nativeSlice = arrayProto.slice;
var nativeMap = arrayProto.map;
var ctorFunction = function() {}.constructor;
var protoFunction = ctorFunction ? ctorFunction.prototype : null;
var protoKey = "__proto__";
var idStart = 2311;
function guid() {
return idStart++;
}
function logError() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
if (typeof console !== "undefined") console.error.apply(console, args);
}
function clone$2(source) {
if (source == null || typeof source !== "object") return source;
var result = source;
var typeStr = objToString.call(source);
if (typeStr === "[object Array]") {
if (!isPrimitive(source)) {
result = [];
for (var i = 0, len$1 = source.length; i < len$1; i++) result[i] = clone$2(source[i]);
}
} else if (TYPED_ARRAY[typeStr]) {
if (!isPrimitive(source)) {
var Ctor = source.constructor;
if (Ctor.from) result = Ctor.from(source);
else {
result = new Ctor(source.length);
for (var i = 0, len$1 = source.length; i < len$1; i++) result[i] = source[i];
}
}
} else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
result = {};
for (var key in source) if (source.hasOwnProperty(key) && key !== protoKey) result[key] = clone$2(source[key]);
}
return result;
}
function merge(target, source, overwrite) {
if (!isObject$2(source) || !isObject$2(target)) return overwrite ? clone$2(source) : target;
for (var key in source) if (source.hasOwnProperty(key) && key !== protoKey) {
var targetProp = target[key];
var sourceProp = source[key];
if (isObject$2(sourceProp) && isObject$2(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) merge(targetProp, sourceProp, overwrite);
else if (overwrite || !(key in target)) target[key] = clone$2(source[key]);
}
return target;
}
function extend(target, source) {
if (Object.assign) Object.assign(target, source);
else for (var key in source) if (source.hasOwnProperty(key) && key !== protoKey) target[key] = source[key];
return target;
}
function defaults(target, source, overlay) {
var keysArr = keys(source);
for (var i = 0, len$1 = keysArr.length; i < len$1; i++) {
var key = keysArr[i];
if (overlay ? source[key] != null : target[key] == null) target[key] = source[key];
}
return target;
}
var createCanvas = platformApi.createCanvas;
function indexOf(array, value) {
if (array) {
if (array.indexOf) return array.indexOf(value);
for (var i = 0, len$1 = array.length; i < len$1; i++) if (array[i] === value) return i;
}
return -1;
}
function inherits(clazz, baseClazz) {
var clazzPrototype = clazz.prototype;
function F() {}
F.prototype = baseClazz.prototype;
clazz.prototype = new F();
for (var prop in clazzPrototype) if (clazzPrototype.hasOwnProperty(prop)) clazz.prototype[prop] = clazzPrototype[prop];
clazz.prototype.constructor = clazz;
clazz.superClass = baseClazz;
}
function mixin(target, source, override) {
target = "prototype" in target ? target.prototype : target;
source = "prototype" in source ? source.prototype : source;
if (Object.getOwnPropertyNames) {
var keyList = Object.getOwnPropertyNames(source);
for (var i = 0; i < keyList.length; i++) {
var key = keyList[i];
if (key !== "constructor") {
if (override ? source[key] != null : target[key] == null) target[key] = source[key];
}
}
} else defaults(target, source, override);
}
function isArrayLike(data) {
if (!data) return false;
if (typeof data === "string") return false;
return typeof data.length === "number";
}
function each$4(arr, cb, context) {
if (!(arr && cb)) return;
if (arr.forEach && arr.forEach === nativeForEach) arr.forEach(cb, context);
else if (arr.length === +arr.length) for (var i = 0, len$1 = arr.length; i < len$1; i++) cb.call(context, arr[i], i, arr);
else for (var key in arr) if (arr.hasOwnProperty(key)) cb.call(context, arr[key], key, arr);
}
function map$1(arr, cb, context) {
if (!arr) return [];
if (!cb) return slice(arr);
if (arr.map && arr.map === nativeMap) return arr.map(cb, context);
else {
var result = [];
for (var i = 0, len$1 = arr.length; i < len$1; i++) result.push(cb.call(context, arr[i], i, arr));
return result;
}
}
function reduce(arr, cb, memo, context) {
if (!(arr && cb)) return;
for (var i = 0, len$1 = arr.length; i < len$1; i++) memo = cb.call(context, memo, arr[i], i, arr);
return memo;
}
function filter(arr, cb, context) {
if (!arr) return [];
if (!cb) return slice(arr);
if (arr.filter && arr.filter === nativeFilter) return arr.filter(cb, context);
else {
var result = [];
for (var i = 0, len$1 = arr.length; i < len$1; i++) if (cb.call(context, arr[i], i, arr)) result.push(arr[i]);
return result;
}
}
function keys(obj) {
if (!obj) return [];
if (Object.keys) return Object.keys(obj);
var keyList = [];
for (var key in obj) if (obj.hasOwnProperty(key)) keyList.push(key);
return keyList;
}
function bindPolyfill(func, context) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) args[_i - 2] = arguments[_i];
return function() {
return func.apply(context, args.concat(nativeSlice.call(arguments)));
};
}
var bind$1 = protoFunction && isFunction(protoFunction.bind) ? protoFunction.call.bind(protoFunction.bind) : bindPolyfill;
function curry$1(func) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i];
return function() {
return func.apply(this, args.concat(nativeSlice.call(arguments)));
};
}
function isArray(value) {
if (Array.isArray) return Array.isArray(value);
return objToString.call(value) === "[object Array]";
}
function isFunction(value) {
return typeof value === "function";
}
function isString(value) {
return typeof value === "string";
}
function isStringSafe(value) {
return objToString.call(value) === "[object String]";
}
function isNumber(value) {
return typeof value === "number";
}
function isObject$2(value) {
var type = typeof value;
return type === "function" || !!value && type === "object";
}
function isBuiltInObject(value) {
return !!BUILTIN_OBJECT[objToString.call(value)];
}
function isTypedArray(value) {
return !!TYPED_ARRAY[objToString.call(value)];
}
function isDom(value) {
return typeof value === "object" && typeof value.nodeType === "number" && typeof value.ownerDocument === "object";
}
function isGradientObject(value) {
return value.colorStops != null;
}
function isImagePatternObject(value) {
return value.image != null;
}
function eqNaN(value) {
return value !== value;
}
function retrieve() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
for (var i = 0, len$1 = args.length; i < len$1; i++) if (args[i] != null) return args[i];
}
function retrieve2(value0, value1) {
return value0 != null ? value0 : value1;
}
function retrieve3(value0, value1, value2) {
return value0 != null ? value0 : value1 != null ? value1 : value2;
}
function slice(arr) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) args[_i - 1] = arguments[_i];
return nativeSlice.apply(arr, args);
}
function normalizeCssArray$1(val) {
if (typeof val === "number") return [
val,
val,
val,
val
];
var len$1 = val.length;
if (len$1 === 2) return [
val[0],
val[1],
val[0],
val[1]
];
else if (len$1 === 3) return [
val[0],
val[1],
val[2],
val[1]
];
return val;
}
function assert(condition, message) {
if (!condition) throw new Error(message);
}
function trim(str) {
if (str == null) return null;
else if (typeof str.trim === "function") return str.trim();
else return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
}
var primitiveKey = "__ec_primitive__";
function setAsPrimitive(obj) {
obj[primitiveKey] = true;
}
function isPrimitive(obj) {
return obj[primitiveKey];
}
var MapPolyfill = function() {
function MapPolyfill$1() {
this.data = {};
}
MapPolyfill$1.prototype["delete"] = function(key) {
var existed = this.has(key);
if (existed) delete this.data[key];
return existed;
};
MapPolyfill$1.prototype.has = function(key) {
return this.data.hasOwnProperty(key);
};
MapPolyfill$1.prototype.get = function(key) {
return this.data[key];
};
MapPolyfill$1.prototype.set = function(key, value) {
this.data[key] = value;
return this;
};
MapPolyfill$1.prototype.keys = function() {
return keys(this.data);
};
MapPolyfill$1.prototype.forEach = function(callback) {
var data = this.data;
for (var key in data) if (data.hasOwnProperty(key)) callback(data[key], key);
};
return MapPolyfill$1;
}();
var isNativeMapSupported = typeof Map === "function";
function maybeNativeMap() {
return isNativeMapSupported ? new Map() : new MapPolyfill();
}
var HashMap = function() {
function HashMap$1(obj) {
var isArr = isArray(obj);
this.data = maybeNativeMap();
var thisMap = this;
obj instanceof HashMap$1 ? obj.each(visit) : obj && each$4(obj, visit);
function visit(value, key) {
isArr ? thisMap.set(value, key) : thisMap.set(key, value);
}
}
HashMap$1.prototype.hasKey = function(key) {
return this.data.has(key);
};
HashMap$1.prototype.get = function(key) {
return this.data.get(key);
};
HashMap$1.prototype.set = function(key, value) {
this.data.set(key, value);
return value;
};
HashMap$1.prototype.each = function(cb, context) {
this.data.forEach(function(value, key) {
cb.call(context, value, key);
});
};
HashMap$1.prototype.keys = function() {
var keys$1 = this.data.keys();
return isNativeMapSupported ? Array.from(keys$1) : keys$1;
};
HashMap$1.prototype.removeKey = function(key) {
this.data["delete"](key);
};
return HashMap$1;
}();
function createHashMap(obj) {
return new HashMap(obj);
}
function concatArray(a, b) {
var newArray = new a.constructor(a.length + b.length);
for (var i = 0; i < a.length; i++) newArray[i] = a[i];
var offset = a.length;
for (var i = 0; i < b.length; i++) newArray[i + offset] = b[i];
return newArray;
}
function createObject(proto$1, properties) {
var obj;
if (Object.create) obj = Object.create(proto$1);
else {
var StyleCtor = function() {};
StyleCtor.prototype = proto$1;
obj = new StyleCtor();
}
if (properties) extend(obj, properties);
return obj;
}
function disableUserSelect(dom) {
var domStyle = dom.style;
domStyle.webkitUserSelect = "none";
domStyle.userSelect = "none";
domStyle.webkitTapHighlightColor = "rgba(0,0,0,0)";
domStyle["-webkit-touch-callout"] = "none";
}
function hasOwn(own, prop) {
return own.hasOwnProperty(prop);
}
function noop() {}
var RADIAN_TO_DEGREE = 180 / Math.PI;
var Browser = function() {
function Browser$1() {
this.firefox = false;
this.ie = false;
this.edge = false;
this.newEdge = false;
this.weChat = false;
}
return Browser$1;
}();
var Env = function() {
function Env$1() {
this.browser = new Browser();
this.node = false;
this.wxa = false;
this.worker = false;
this.svgSupported = false;
this.touchEventsSupported = false;
this.pointerEventsSupported = false;
this.domSupported = false;
this.transformSupported = false;
this.transform3dSupported = false;
this.hasGlobalWindow = typeof window !== "undefined";
}
return Env$1;
}();
var env = new Env();
if (typeof wx === "object" && typeof wx.getSystemInfoSync === "function") {
env.wxa = true;
env.touchEventsSupported = true;
} else if (typeof document === "undefined" && typeof self !== "undefined") env.worker = true;
else if (!env.hasGlobalWindow || "Deno" in window) {
env.node = true;
env.svgSupported = true;
} else detect(navigator.userAgent, env);
function detect(ua, env$1) {
var browser = env$1.browser;
var firefox = ua.match(/Firefox\/([\d.]+)/);
var ie = ua.match(/MSIE\s([\d.]+)/) || ua.match(/Trident\/.+?rv:(([\d.]+))/);
var edge = ua.match(/Edge?\/([\d.]+)/);
var weChat = /micromessenger/i.test(ua);
if (firefox) {
browser.firefox = true;
browser.version = firefox[1];
}
if (ie) {
browser.ie = true;
browser.version = ie[1];
}
if (edge) {
browser.edge = true;
browser.version = edge[1];
browser.newEdge = +edge[1].split(".")[0] > 18;
}
if (weChat) browser.weChat = true;
env$1.svgSupported = typeof SVGRect !== "undefined";
env$1.touchEventsSupported = "ontouchstart" in window && !browser.ie && !browser.edge;
env$1.pointerEventsSupported = "onpointerdown" in window && (browser.edge || browser.ie && +browser.version >= 11);
env$1.domSupported = typeof document !== "undefined";
var style = document.documentElement.style;
env$1.transform3dSupported = (browser.ie && "transition" in style || browser.edge || "WebKitCSSMatrix" in window && "m11" in new WebKitCSSMatrix() || "MozPerspective" in style) && !("OTransition" in style);
env$1.transformSupported = env$1.transform3dSupported || browser.ie && +browser.version >= 9;
}
var env_default = env;
var TYPE_DELIMITER = ".";
var IS_CONTAINER = "___EC__COMPONENT__CONTAINER___";
var IS_EXTENDED_CLASS = "___EC__EXTENDED_CLASS___";
function parseClassType(componentType) {
var ret = {
main: "",
sub: ""
};
if (componentType) {
var typeArr = componentType.split(TYPE_DELIMITER);
ret.main = typeArr[0] || "";
ret.sub = typeArr[1] || "";
}
return ret;
}
/**
* @public
*/
function checkClassType(componentType) {
assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType), "componentType \"" + componentType + "\" illegal");
}
function isExtendedClass(clz) {
return !!(clz && clz[IS_EXTENDED_CLASS]);
}
function enableClassExtend(rootClz, mandatoryMethods) {
rootClz.$constructor = rootClz;
rootClz.extend = function(proto$1) {
var superClass = this;
var ExtendedClass;
if (isESClass(superClass)) ExtendedClass = function(_super) {
__extends(class_1, _super);
function class_1() {
return _super.apply(this, arguments) || this;
}
return class_1;
}(superClass);
else {
ExtendedClass = function() {
(proto$1.$constructor || superClass).apply(this, arguments);
};
inherits(ExtendedClass, this);
}
extend(ExtendedClass.prototype, proto$1);
ExtendedClass[IS_EXTENDED_CLASS] = true;
ExtendedClass.extend = this.extend;
ExtendedClass.superCall = superCall;
ExtendedClass.superApply = superApply;
ExtendedClass.superClass = superClass;
return ExtendedClass;
};
}
function isESClass(fn) {
return isFunction(fn) && /^class\s/.test(Function.prototype.toString.call(fn));
}
function mountExtend(SubClz, SupperClz) {
SubClz.extend = SupperClz.extend;
}
var classBase = Math.round(Math.random() * 10);
function enableClassCheck(target) {
var classAttr = ["__\0is_clz", classBase++].join("_");
target.prototype[classAttr] = true;
target.isInstance = function(obj) {
return !!(obj && obj[classAttr]);
};
}
function superCall(context, methodName) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) args[_i - 2] = arguments[_i];
return this.superClass.prototype[methodName].apply(context, args);
}
function superApply(context, methodName, args) {
return this.superClass.prototype[methodName].apply(context, args);
}
function enableClassManagement(target) {
/**
* Component model classes
* key: componentType,
* value:
* componentClass, when componentType is 'a'
* or Object.<subKey, componentClass>, when componentType is 'a.b'
*/
var storage = {};
target.registerClass = function(clz) {
var componentFullType = clz.type || clz.prototype.type;
if (componentFullType) {
checkClassType(componentFullType);
clz.prototype.type = componentFullType;
var componentTypeInfo = parseClassType(componentFullType);
if (!componentTypeInfo.sub) storage[componentTypeInfo.main] = clz;
else if (componentTypeInfo.sub !== IS_CONTAINER) {
var container = makeContainer(componentTypeInfo);
container[componentTypeInfo.sub] = clz;
}
}
return clz;
};
target.getClass = function(mainType, subType, throwWhenNotFound) {
var clz = storage[mainType];
if (clz && clz[IS_CONTAINER]) clz = subType ? clz[subType] : null;
if (throwWhenNotFound && !clz) throw new Error(!subType ? mainType + ".type should be specified." : "Component " + mainType + "." + (subType || "") + " is used but not imported.");
return clz;
};
target.getClassesByMainType = function(componentType) {
var componentTypeInfo = parseClassType(componentType);
var result = [];
var obj = storage[componentTypeInfo.main];
if (obj && obj[IS_CONTAINER]) each$4(obj, function(o, type) {
type !== IS_CONTAINER && result.push(o);
});
else result.push(obj);
return result;
};
target.hasClass = function(componentType) {
var componentTypeInfo = parseClassType(componentType);
return !!storage[componentTypeInfo.main];
};
/**
* @return Like ['aa', 'bb'], but can not be ['aa.xx']
*/
target.getAllClassMainTypes = function() {
var types = [];
each$4(storage, function(obj, type) {
types.push(type);
});
return types;
};
/**
* If a main type is container and has sub types
*/
target.hasSubTypes = function(componentType) {
var componentTypeInfo = parseClassType(componentType);
var obj = storage[componentTypeInfo.main];
return obj && obj[IS_CONTAINER];
};
function makeContainer(componentTypeInfo) {
var container = storage[componentTypeInfo.main];
if (!container || !container[IS_CONTAINER]) {
container = storage[componentTypeInfo.main] = {};
container[IS_CONTAINER] = true;
}
return container;
}
}
function makeStyleMapper(properties, ignoreParent) {
for (var i = 0; i < properties.length; i++) if (!properties[i][1]) properties[i][1] = properties[i][0];
ignoreParent = ignoreParent || false;
return function(model, excludes, includes) {
var style = {};
for (var i$1 = 0; i$1 < properties.length; i$1++) {
var propName = properties[i$1][1];
if (excludes && indexOf(excludes, propName) >= 0 || includes && indexOf(includes, propName) < 0) continue;
var val = model.getShallow(propName, ignoreParent);
if (val != null) style[properties[i$1][0]] = val;
}
return style;
};
}
var AREA_STYLE_KEY_MAP = [
["fill", "color"],
["shadowBlur"],
["shadowOffsetX"],
["shadowOffsetY"],
["opacity"],
["shadowColor"]
];
var getAreaStyle = makeStyleMapper(AREA_STYLE_KEY_MAP);
var AreaStyleMixin = function() {
function AreaStyleMixin$1() {}
AreaStyleMixin$1.prototype.getAreaStyle = function(excludes, includes) {
return getAreaStyle(this, excludes, includes);
};
return AreaStyleMixin$1;
}();
var Entry = function() {
function Entry$1(val) {
this.value = val;
}
return Entry$1;
}();
var LinkedList = function() {
function LinkedList$1() {
this._len = 0;
}
LinkedList$1.prototype.insert = function(val) {
var entry = new Entry(val);
this.insertEntry(entry);
return entry;
};
LinkedList$1.prototype.insertEntry = function(entry) {
if (!this.head) this.head = this.tail = entry;
else {
this.tail.next = entry;
entry.prev = this.tail;
entry.next = null;
this.tail = entry;
}
this._len++;
};
LinkedList$1.prototype.remove = function(entry) {
var prev = entry.prev;
var next = entry.next;
if (prev) prev.next = next;
else this.head = next;
if (next) next.prev = prev;
else this.tail = prev;
entry.next = entry.prev = null;
this._len--;
};
LinkedList$1.prototype.len = function() {
return this._len;
};
LinkedList$1.prototype.clear = function() {
this.head = this.tail = null;
this._len = 0;
};
return LinkedList$1;
}();
var LRU = function() {
function LRU$1(maxSize) {
this._list = new LinkedList();
this._maxSize = 10;
this._map = {};
this._maxSize = maxSize;
}
LRU$1.prototype.put = function(key, value) {
var list = this._list;
var map$2 = this._map;
var removed = null;
if (map$2[key] == null) {
var len$1 = list.len();
var entry = this._lastRemovedEntry;
if (len$1 >= this._maxSize && len$1 > 0) {
var leastUsedEntry = list.head;
list.remove(leastUsedEntry);
delete map$2[leastUsedEntry.key];
removed = leastUsedEntry.value;
this._lastRemovedEntry = leastUsedEntry;
}
if (entry) entry.value = value;
else entry = new Entry(value);
entry.key = key;
list.insertEntry(entry);
map$2[key] = entry;
}
return removed;
};
LRU$1.prototype.get = function(key) {
var entry = this._map[key];
var list = this._list;
if (entry != null) {
if (entry !== list.tail) {
list.remove(entry);
list.insertEntry(entry);
}
return entry.value;
}
};
LRU$1.prototype.clear = function() {
this._list.clear();
this._map = {};
};
LRU$1.prototype.len = function() {
return this._list.len();
};
return LRU$1;
}();
var LRU_default = LRU;
var globalImageCache = new LRU_default(50);
function findExistImage(newImageOrSrc) {
if (typeof newImageOrSrc === "string") {
var cachedImgObj = globalImageCache.get(newImageOrSrc);
return cachedImgObj && cachedImgObj.image;
} else return newImageOrSrc;
}
function createOrUpdateImage(newImageOrSrc, image, hostEl, onload, cbPayload) {
if (!newImageOrSrc) return image;
else if (typeof newImageOrSrc === "string") {
if (image && image.__zrImageSrc === newImageOrSrc || !hostEl) return image;
var cachedImgObj = globalImageCache.get(newImageOrSrc);
var pendingWrap = {
hostEl,
cb: onload,
cbPayload
};
if (cachedImgObj) {
image = cachedImgObj.image;
!isImageReady(image) && cachedImgObj.pending.push(pendingWrap);
} else {
image = platformApi.loadImage(newImageOrSrc, imageOnLoad, imageOnLoad);
image.__zrImageSrc = newImageOrSrc;
globalImageCache.put(newImageOrSrc, image.__cachedImgObj = {
image,
pending: [pendingWrap]
});
}
return image;
} else return newImageOrSrc;
}
function imageOnLoad() {
var cachedImgObj = this.__cachedImgObj;
this.onload = this.onerror = this.__cachedImgObj = null;
for (var i = 0; i < cachedImgObj.pending.length; i++) {
var pendingWrap = cachedImgObj.pending[i];
var cb = pendingWrap.cb;
cb && cb(this, pendingWrap.cbPayload);
pendingWrap.hostEl.dirty();
}
cachedImgObj.pending.length = 0;
}
function isImageReady(image) {
return image && image.width && image.height;
}
function create$1() {
return [
1,
0,
0,
1,
0,
0
];
}
function identity(out$1) {
out$1[0] = 1;
out$1[1] = 0;
out$1[2] = 0;
out$1[3] = 1;
out$1[4] = 0;
out$1[5] = 0;
return out$1;
}
function copy(out$1, m$1) {
out$1[0] = m$1[0];
out$1[1] = m$1[1];
out$1[2] = m$1[2];
out$1[3] = m$1[3];
out$1[4] = m$1[4];
out$1[5] = m$1[5];
return out$1;
}
function mul(out$1, m1, m2) {
var out0 = m1[0] * m2[0] + m1[2] * m2[1];
var out1 = m1[1] * m2[0] + m1[3] * m2[1];
var out2 = m1[0] * m2[2] + m1[2] * m2[3];
var out3 = m1[1] * m2[2] + m1[3] * m2[3];
var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
out$1[0] = out0;
out$1[1] = out1;
out$1[2] = out2;
out$1[3] = out3;
out$1[4] = out4;
out$1[5] = out5;
return out$1;
}
function translate(out$1, a, v) {
out$1[0] = a[0];
out$1[1] = a[1];
out$1[2] = a[2];
out$1[3] = a[3];
out$1[4] = a[4] + v[0];
out$1[5] = a[5] + v[1];
return out$1;
}
function rotate(out$1, a, rad, pivot) {
if (pivot === void 0) pivot = [0, 0];
var aa = a[0];
var ac = a[2];
var atx = a[4];
var ab = a[1];
var ad = a[3];
var aty = a[5];
var st = Math.sin(rad);
var ct = Math.cos(rad);
out$1[0] = aa * ct + ab * st;
out$1[1] = -aa * st + ab * ct;
out$1[2] = ac * ct + ad * st;
out$1[3] = -ac * st + ct * ad;
out$1[4] = ct * (atx - pivot[0]) + st * (aty - pivot[1]) + pivot[0];
out$1[5] = ct * (aty - pivot[1]) - st * (atx - pivot[0]) + pivot[1];
return out$1;
}
function scale$2(out$1, a, v) {
var vx = v[0];
var vy = v[1];
out$1[0] = a[0] * vx;
out$1[1] = a[1] * vy;
out$1[2] = a[2] * vx;
out$1[3] = a[3] * vy;
out$1[4] = a[4] * vx;
out$1[5] = a[5] * vy;
return out$1;
}
function invert(out$1, a) {
var aa = a[0];
var ac = a[2];
var atx = a[4];
var ab = a[1];
var ad = a[3];
var aty = a[5];
var det = aa * ad - ab * ac;
if (!det) return null;
det = 1 / det;
out$1[0] = ad * det;
out$1[1] = -ab * det;
out$1[2] = -ac * det;
out$1[3] = aa * det;
out$1[4] = (ac * aty - ad * atx) * det;
out$1[5] = (ab * atx - aa * aty) * det;
return out$1;
}
var Point = function() {
function Point$1(x, y) {
this.x = x || 0;
this.y = y || 0;
}
Point$1.prototype.copy = function(other) {
this.x = other.x;
this.y = other.y;
return this;
};
Point$1.prototype.clone = function() {
return new Point$1(this.x, this.y);
};
Point$1.prototype.set = function(x, y) {
this.x = x;
this.y = y;
return this;
};
Point$1.prototype.equal = function(other) {
return other.x === this.x && other.y === this.y;
};
Point$1.prototype.add = function(other) {
this.x += other.x;
this.y += other.y;
return this;
};
Point$1.prototype.scale = function(scalar) {
this.x *= scalar;
this.y *= scalar;
};
Point$1.prototype.scaleAndAdd = function(other, scalar) {
this.x += other.x * scalar;
this.y += other.y * scalar;
};
Point$1.prototype.sub = function(other) {
this.x -= other.x;
this.y -= other.y;
return this;
};
Point$1.prototype.dot = function(other) {
return this.x * other.x + this.y * other.y;
};
Point$1.prototype.len = function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
Point$1.prototype.lenSquare = function() {
return this.x * this.x + this.y * this.y;
};
Point$1.prototype.normalize = function() {
var len$1 = this.len();
this.x /= len$1;
this.y /= len$1;
return this;
};
Point$1.prototype.distance = function(other) {
var dx = this.x - other.x;
var dy = this.y - other.y;
return Math.sqrt(dx * dx + dy * dy);
};
Point$1.prototype.distanceSquare = function(other) {
var dx = this.x - other.x;
var dy = this.y - other.y;
return dx * dx + dy * dy;
};
Point$1.prototype.negate = function() {
this.x = -this.x;
this.y = -this.y;
return this;
};
Point$1.prototype.transform = function(m$1) {
if (!m$1) return;
var x = this.x;
var y = this.y;
this.x = m$1[0] * x + m$1[2] * y + m$1[4];
this.y = m$1[1] * x + m$1[3] * y + m$1[5];
return this;
};
Point$1.prototype.toArray = function(out$1) {
out$1[0] = this.x;
out$1[1] = this.y;
return out$1;
};
Point$1.prototype.fromArray = function(input) {
this.x = input[0];
this.y = input[1];
};
Point$1.set = function(p, x, y) {
p.x = x;
p.y = y;
};
Point$1.copy = function(p, p2) {
p.x = p2.x;
p.y = p2.y;
};
Point$1.len = function(p) {
return Math.sqrt(p.x * p.x + p.y * p.y);
};
Point$1.lenSquare = function(p) {
return p.x * p.x + p.y * p.y;
};
Point$1.dot = function(p0, p1) {
return p0.x * p1.x + p0.y * p1.y;
};
Point$1.add = function(out$1, p0, p1) {
out$1.x = p0.x + p1.x;
out$1.y = p0.y + p1.y;
};
Point$1.sub = function(out$1, p0, p1) {
out$1.x = p0.x - p1.x;
out$1.y = p0.y - p1.y;
};
Point$1.scale = function(out$1, p0, scalar) {
out$1.x = p0.x * scalar;
out$1.y = p0.y * scalar;
};
Point$1.scaleAndAdd = function(out$1, p0, p1, scalar) {
out$1.x = p0.x + p1.x * scalar;
out$1.y = p0.y + p1.y * scalar;
};
Point$1.lerp = function(out$1, p0, p1, t) {
var onet = 1 - t;
out$1.x = onet * p0.x + t * p1.x;
out$1.y = onet * p0.y + t * p1.y;
};
return Point$1;
}();
var Point_default = Point;
var mathMin$5 = Math.min;
var mathMax$5 = Math.max;
var lt = new Point_default();
var rb = new Point_default();
var lb = new Point_default();
var rt = new Point_default();
var minTv$1 = new Point_default();
var maxTv$1 = new Point_default();
var BoundingRect = function() {
function BoundingRect$1(x, y, width, height) {
if (width < 0) {
x = x + width;
width = -width;
}
if (height < 0) {
y = y + height;
height = -height;
}
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
BoundingRect$1.prototype.union = function(other) {
var x = mathMin$5(other.x, this.x);
var y = mathMin$5(other.y, this.y);
if (isFinite(this.x) && isFinite(this.width)) this.width = mathMax$5(other.x + other.width, this.x + this.width) - x;
else this.width = other.width;
if (isFinite(this.y) && isFinite(this.height)) this.height = mathMax$5(other.y + other.height, this.y + this.height) - y;
else this.height = other.height;
this.x = x;
this.y = y;
};
BoundingRect$1.prototype.applyTransform = function(m$1) {
BoundingRect$1.applyTransform(this, this, m$1);
};
BoundingRect$1.prototype.calculateTransform = function(b) {
var a = this;
var sx = b.width / a.width;
var sy = b.height / a.height;
var m$1 = create$1();
translate(m$1, m$1, [-a.x, -a.y]);
scale$2(m$1, m$1, [sx, sy]);
translate(m$1, m$1, [b.x, b.y]);
return m$1;
};
BoundingRect$1.prototype.intersect = function(b, mtv) {
if (!b) return false;
if (!(b instanceof BoundingRect$1)) b = BoundingRect$1.create(b);
var a = this;
var ax0 = a.x;
var ax1 = a.x + a.width;
var ay0 = a.y;
var ay1 = a.y + a.height;
var bx0 = b.x;
var bx1 = b.x + b.width;
var by0 = b.y;
var by1 = b.y + b.height;
var overlap = !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
if (mtv) {
var dMin = Infinity;
var dMax = 0;
var d0 = Math.abs(ax1 - bx0);
var d1 = Math.abs(bx1 - ax0);
var d2 = Math.abs(ay1 - by0);
var d3 = Math.abs(by1 - ay0);
var dx = Math.min(d0, d1);
var dy = Math.min(d2, d3);
if (ax1 < bx0 || bx1 < ax0) {
if (dx > dMax) {
dMax = dx;
if (d0 < d1) Point_default.set(maxTv$1, -d0, 0);
else Point_default.set(maxTv$1, d1, 0);
}
} else if (dx < dMin) {
dMin = dx;
if (d0 < d1) Point_default.set(minTv$1, d0, 0);
else Point_default.set(minTv$1, -d1, 0);
}
if (ay1 < by0 || by1 < ay0) {
if (dy > dMax) {
dMax = dy;
if (d2 < d3) Point_default.set(maxTv$1, 0, -d2);
else Point_default.set(maxTv$1, 0, d3);
}
} else if (dx < dMin) {
dMin = dx;
if (d2 < d3) Point_default.set(minTv$1, 0, d2);
else Point_default.set(minTv$1, 0, -d3);
}
}
if (mtv) Point_default.copy(mtv, overlap ? minTv$1 : maxTv$1);
return overlap;
};
BoundingRect$1.prototype.contain = function(x, y) {
var rect = this;
return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
};
BoundingRect$1.prototype.clone = function() {
return new BoundingRect$1(this.x, this.y, this.width, this.height);
};
BoundingRect$1.prototype.copy = function(other) {
BoundingRect$1.copy(this, other);
};
BoundingRect$1.prototype.plain = function() {
return {
x: this.x,
y: this.y,
width: this.width,
height: this.height
};
};
BoundingRect$1.prototype.isFinite = function() {
return isFinite(this.x) && isFinite(this.y) && isFinite(this.width) && isFinite(this.height);
};
BoundingRect$1.prototype.isZero = function() {
return this.width === 0 || this.height === 0;
};
BoundingRect$1.create = function(rect) {
return new BoundingRect$1(rect.x, rect.y, rect.width, rect.height);
};
BoundingRect$1.copy = function(target, source) {
target.x = source.x;
target.y = source.y;
target.width = source.width;
target.height = source.height;
};
BoundingRect$1.applyTransform = function(target, source, m$1) {
if (!m$1) {
if (target !== source) BoundingRect$1.copy(target, source);
return;
}
if (m$1[1] < 1e-5 && m$1[1] > -1e-5 && m$1[2] < 1e-5 && m$1[2] > -1e-5) {
var sx = m$1[0];
var sy = m$1[3];
var tx = m$1[4];
var ty = m$1[5];
target.x = source.x * sx + tx;
target.y = source.y * sy + ty;
target.width = source.width * sx;
target.height = source.height * sy;
if (target.width < 0) {
target.x += target.width;
target.width = -target.width;
}
if (target.height < 0) {
target.y += target.height;
target.height = -target.height;
}
return;
}
lt.x = lb.x = source.x;
lt.y = rt.y = source.y;
rb.x = rt.x = source.x + source.width;
rb.y = lb.y = source.y + source.height;
lt.transform(m$1);
rt.transform(m$1);
rb.transform(m$1);
lb.transform(m$1);
target.x = mathMin$5(lt.x, rb.x, lb.x, rt.x);
target.y = mathMin$5(lt.y, rb.y, lb.y, rt.y);
var maxX = mathMax$5(lt.x, rb.x, lb.x, rt.x);
var maxY = mathMax$5(lt.y, rb.y, lb.y, rt.y);
target.width = maxX - target.x;
target.height = maxY - target.y;
};
return BoundingRect$1;
}();
var BoundingRect_default = BoundingRect;
var textWidthCache = {};
function getWidth(text, font) {
font = font || DEFAULT_FONT;
var cacheOfFont = textWidthCache[font];
if (!cacheOfFont) cacheOfFont = textWidthCache[font] = new LRU_default(500);
var width = cacheOfFont.get(text);
if (width == null) {
width = platformApi.measureText(text, font).width;
cacheOfFont.put(text, width);
}
return width;
}
function innerGetBoundingRect(text, font, textAlign, textBaseline) {
var width = getWidth(text, font);
var height = getLineHeight(font);
var x = adjustTextX(0, width, textAlign);
var y = adjustTextY(0, height, textBaseline);
var rect = new BoundingRect_default(x, y, width, height);
return rect;
}
function getBoundingRect(text, font, textAlign, textBaseline) {
var textLines = ((text || "") + "").split("\n");
var len$1 = textLines.length;
if (len$1 === 1) return innerGetBoundingRect(textLines[0], font, textAlign, textBaseline);
else {
var uniondRect = new BoundingRect_default(0, 0, 0, 0);
for (var i = 0; i < textLines.length; i++) {
var rect = innerGetBoundingRect(textLines[i], font, textAlign, textBaseline);
i === 0 ? uniondRect.copy(rect) : uniondRect.union(rect);
}
return uniondRect;
}
}
function adjustTextX(x, width, textAlign) {
if (textAlign === "right") x -= width;
else if (textAlign === "center") x -= width / 2;
return x;
}
function adjustTextY(y, height, verticalAlign) {
if (verticalAlign === "middle") y -= height / 2;
else if (verticalAlign === "bottom") y -= height;
return y;
}
function getLineHeight(font) {
return getWidth("国", font);
}
function parsePercent$1(value, maxValue) {
if (typeof value === "string") {
if (value.lastIndexOf("%") >= 0) return parseFloat(value) / 100 * maxValue;
return parseFloat(value);
}
return value;
}
function calculateTextPosition(out$1, opts, rect) {
var textPosition = opts.position || "inside";
var distance$1 = opts.distance != null ? opts.distance : 5;
var height = rect.height;
var width = rect.width;
var halfHeight = height / 2;
var x = rect.x;
var y = rect.y;
var textAlign = "left";
var textVerticalAlign = "top";
if (textPosition instanceof Array) {
x += parsePercent$1(textPosition[0], rect.width);
y += parsePercent$1(textPosition[1], rect.height);
textAlign = null;
textVerticalAlign = null;
} else switch (textPosition) {
case "left":
x -= distance$1;
y += halfHeight;
textAlign = "right";
textVerticalAlign = "middle";
break;
case "right":
x += distance$1 + width;
y += halfHeight;
textVerticalAlign = "middle";
break;
case "top":
x += width / 2;
y -= distance$1;
textAlign = "center";
textVerticalAlign = "bottom";
break;
case "bottom":
x += width / 2;
y += height + distance$1;
textAlign = "center";
break;
case "inside":
x += width / 2;
y += halfHeight;
textAlign = "center";
textVerticalAlign = "middle";
break;
case "insideLeft":
x += distance$1;
y += halfHeight;
textVerticalAlign = "middle";
break;
case "insideRight":
x += width - distance$1;
y += halfHeight;
textAlign = "right";
textVerticalAlign = "middle";
break;
case "insideTop":
x += width / 2;
y += distance$1;
textAlign = "center";
break;
case "insideBottom":
x += width / 2;
y += height - distance$1;
textAlign = "center";
textVerticalAlign = "bottom";
break;
case "insideTopLeft":
x += distance$1;
y += distance$1;
break;
case "insideTopRight":
x += width - distance$1;
y += distance$1;
textAlign = "right";
break;
case "insideBottomLeft":
x += distance$1;
y += height - distance$1;
textVerticalAlign = "bottom";
break;
case "insideBottomRight":
x += width - distance$1;
y += height - distance$1;
textAlign = "right";
textVerticalAlign = "bottom";
break;
}
out$1 = out$1 || {};
out$1.x = x;
out$1.y = y;
out$1.align = textAlign;
out$1.verticalAlign = textVerticalAlign;
return out$1;
}
var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
function truncateText2(out$1, text, containerWidth, font, ellipsis, options) {
if (!containerWidth) {
out$1.text = "";
out$1.isTruncated = false;
return;
}
var textLines = (text + "").split("\n");
options = prepareTruncateOptions(containerWidth, font, ellipsis, options);
var isTruncated = false;
var truncateOut = {};
for (var i = 0, len$1 = textLines.length; i < len$1; i++) {
truncateSingleLine(truncateOut, textLines[i], options);
textLines[i] = truncateOut.textLine;
isTruncated = isTruncated || truncateOut.isTruncated;
}
out$1.text = textLines.join("\n");
out$1.isTruncated = isTruncated;
}
function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
options = options || {};
var preparedOpts = extend({}, options);
preparedOpts.font = font;
ellipsis = retrieve2(ellipsis, "...");
preparedOpts.maxIterations = retrieve2(options.maxIterations, 2);
var minChar = preparedOpts.minChar = retrieve2(options.minChar, 0);
preparedOpts.cnCharWidth = getWidth("国", font);
var ascCharWidth = preparedOpts.ascCharWidth = getWidth("a", font);
preparedOpts.placeholder = retrieve2(options.placeholder, "");
var contentWidth = containerWidth = Math.max(0, containerWidth - 1);
for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) contentWidth -= ascCharWidth;
var ellipsisWidth = getWidth(ellipsis, font);
if (ellipsisWidth > contentWidth) {
ellipsis = "";
ellipsisWidth = 0;
}
contentWidth = containerWidth - ellipsisWidth;
preparedOpts.ellipsis = ellipsis;
preparedOpts.ellipsisWidth = ellipsisWidth;
preparedOpts.contentWidth = contentWidth;
preparedOpts.containerWidth = containerWidth;
return preparedOpts;
}
function truncateSingleLine(out$1, textLine, options) {
var containerWidth = options.containerWidth;
var font = options.font;
var contentWidth = options.contentWidth;
if (!containerWidth) {
out$1.textLine = "";
out$1.isTruncated = false;
return;
}
var lineWidth = getWidth(textLine, font);
if (lineWidth <= containerWidth) {
out$1.textLine = textLine;
out$1.isTruncated = false;
return;
}
for (var j = 0;; j++) {
if (lineWidth <= contentWidth || j >= options.maxIterations) {
textLine += options.ellipsis;
break;
}
var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;
textLine = textLine.substr(0, subLength);
lineWidth = getWidth(textLine, font);
}
if (textLine === "") textLine = options.placeholder;
out$1.textLine = textLine;
out$1.isTruncated = true;
}
function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
var width = 0;
var i = 0;
for (var len$1 = text.length; i < len$1 && width < contentWidth; i++) {
var charCode = text.charCodeAt(i);
width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;
}
return i;
}
function parsePlainText(text, style) {
text != null && (text += "");
var overflow = style.overflow;
var padding = style.padding;
var font = style.font;
var truncate = overflow === "truncate";
var calculatedLineHeight = getLineHeight(font);
var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
var bgColorDrawn = !!style.backgroundColor;
var truncateLineOverflow = style.lineOverflow === "truncate";
var isTruncated = false;
var width = style.width;
var lines;
if (width != null && (overflow === "break" || overflow === "breakAll")) lines = text ? wrapText(text, style.font, width, overflow === "breakAll", 0).lines : [];
else lines = text ? text.split("\n") : [];
var contentHeight = lines.length * lineHeight;
var height = retrieve2(style.height, contentHeight);
if (contentHeight > height && truncateLineOverflow) {
var lineCount = Math.floor(height / lineHeight);
isTruncated = isTruncated || lines.length > lineCount;
lines = lines.slice(0, lineCount);
}
if (text && truncate && width != null) {
var options = prepareTruncateOptions(width, font, style.ellipsis, {
minChar: style.truncateMinChar,
placeholder: style.placeholder
});
var singleOut = {};
for (var i = 0; i < lines.length; i++) {
truncateSingleLine(singleOut, lines[i], options);
lines[i] = singleOut.textLine;
isTruncated = isTruncated || singleOut.isTruncated;
}
}
var outerHeight = height;
var contentWidth = 0;
for (var i = 0; i < lines.length; i++) contentWidth = Math.max(getWidth(lines[i], font), contentWidth);
if (width == null) width = contentWidth;
var outerWidth = contentWidth;
if (padding) {
outerHeight += padding[0] + padding[2];
outerWidth += padding[1] + padding[3];
width += padding[1] + padding[3];
}
if (bgColorDrawn) outerWidth = width;
return {
lines,
height,
outerWidth,
outerHeight,
lineHeight,
calculatedLineHeight,
contentWidth,
contentHeight,
width,
isTruncated
};
}
var RichTextToken = function() {
function RichTextToken$1() {}
return RichTextToken$1;
}();
var RichTextLine = function() {
function RichTextLine$1(tokens) {
this.tokens = [];
if (tokens) this.tokens = tokens;
}
return RichTextLine$1;
}();
var RichTextContentBlock = function() {
function RichTextContentBlock$1() {
this.width = 0;
this.height = 0;
this.contentWidth = 0;
this.contentHeight = 0;
this.outerWidth = 0;
this.outerHeight = 0;
this.lines = [];
this.isTruncated = false;
}
return RichTextContentBlock$1;
}();
function parseRichText(text, style) {
var contentBlock = new RichTextContentBlock();
text != null && (text += "");
if (!text) return contentBlock;
var topWidth = style.width;
var topHeight = style.height;
var overflow = style.overflow;
var wrapInfo = (overflow === "break" || overflow === "breakAll") && topWidth != null ? {
width: topWidth,
accumWidth: 0,
breakAll: overflow === "breakAll"
} : null;
var lastIndex = STYLE_REG.lastIndex = 0;
var result;
while ((result = STYLE_REG.exec(text)) != null) {
var matchedIndex = result.index;
if (matchedIndex > lastIndex) pushTokens(contentBlock, text.substring(lastIndex, matchedIndex), style, wrapInfo);
pushTokens(contentBlock, result[2], style, wrapInfo, result[1]);
lastIndex = STYLE_REG.lastIndex;
}
if (lastIndex < text.length) pushTokens(contentBlock, text.substring(lastIndex, text.length), style, wrapInfo);
var pendingList = [];
var calculatedHeight = 0;
var calculatedWidth = 0;
var stlPadding = style.padding;
var truncate = overflow === "truncate";
var truncateLine = style.lineOverflow === "truncate";
var tmpTruncateOut = {};
function finishLine(line$1, lineWidth$1, lineHeight$1) {
line$1.width = lineWidth$1;
line$1.lineHeight = lineHeight$1;
calculatedHeight += lineHeight$1;
calculatedWidth = Math.max(calculatedWidth, lineWidth$1);
}
outer: for (var i = 0; i < contentBlock.lines.length; i++) {
var line = contentBlock.lines[i];
var lineHeight = 0;
var lineWidth = 0;
for (var j = 0; j < line.tokens.length; j++) {
var token = line.tokens[j];
var tokenStyle = token.styleName && style.rich[token.styleName] || {};
var textPadding = token.textPadding = tokenStyle.padding;
var paddingH = textPadding ? textPadding[1] + textPadding[3] : 0;
var font = token.font = tokenStyle.font || style.font;
token.contentHeight = getLineHeight(font);
var tokenHeight = retrieve2(tokenStyle.height, token.contentHeight);
token.innerHeight = tokenHeight;
textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
token.height = tokenHeight;
token.lineHeight = retrieve3(tokenStyle.lineHeight, style.lineHeight, tokenHeight);
token.align = tokenStyle && tokenStyle.align || style.align;
token.verticalAlign = tokenStyle && tokenStyle.verticalAlign || "middle";
if (truncateLine && topHeight != null && calculatedHeight + token.lineHeight > topHeight) {
var originalLength = contentBlock.lines.length;
if (j > 0) {
line.tokens = line.tokens.slice(0, j);
finishLine(line, lineWidth, lineHeight);
contentBlock.lines = contentBlock.lines.slice(0, i + 1);
} else contentBlock.lines = contentBlock.lines.slice(0, i);
contentBlock.isTruncated = contentBlock.isTruncated || contentBlock.lines.length < originalLength;
break outer;
}
var styleTokenWidth = tokenStyle.width;
var tokenWidthNotSpecified = styleTokenWidth == null || styleTokenWidth === "auto";
if (typeof styleTokenWidth === "string" && styleTokenWidth.charAt(styleTokenWidth.length - 1) === "%") {
token.percentWidth = styleTokenWidth;
pendingList.push(token);
token.contentWidth = getWidth(token.text, font);
} else {
if (tokenWidthNotSpecified) {
var textBackgroundColor = tokenStyle.backgroundColor;
var bgImg = textBackgroundColor && textBackgroundColor.image;
if (bgImg) {
bgImg = findExistImage(bgImg);
if (isImageReady(bgImg)) token.width = Math.max(toke