UNPKG

vite-plugin-inspect

Version:

Inspect the intermediate state of Vite plugins

1,678 lines (1,649 loc) 1.32 MB
import { _ as _sfc_main$3, a as __unplugin_components_3, c as _sfc_main$4, b as _sfc_main$5, d as _sfc_main$6, e as _sfc_main$7 } from './QuerySelector.vue_vue_type_script_setup_true_lang-DZag_XE-.js'; import { u as useOptionsStore, _ as _sfc_main$8 } from './options-CljnBO7w.js'; import { d as defineComponent, A as h, B as shallowRef, C as inject, D as toRefs, e as computed, E as getCurrentInstance, w as watch, G as watchEffect, f as onMounted, H as onBeforeUnmount, I as nextTick, J as isRef, h as unref, m as usePayloadStore, b as ref, L as withAsyncContext, M as rpc, N as isDark, c as createElementBlock, o as openBlock, a as createBaseVNode, g as createCommentVNode, x as createBlock, n as normalizeStyle$1, i as createVNode, q as withCtx, t as toDisplayString, O as onModuleUpdated, F as Fragment, s as resolveComponent, r as renderList, P as isStaticMode } from './index-BHfFAmtB.js'; import { u as useSearchResults } from './search-DNdE-oe3.js'; import { g as getHot } from './hot-CPekYFok.js'; import './_plugin-vue_export-helper-DgDhiqFL.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. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[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 __()); } /* Injected with object hook! */ 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 = {}; if (typeof JSON === 'undefined') { return map; } for (var i = 0; i < mapStr.length; i++) { var char = String.fromCharCode(i + 32); var size = (mapStr.charCodeAt(i) - OFFSET) / SCALE; map[char] = size; } return map; } 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: width }; } }; })(), loadImage: function (src, onload, onerror) { var image = new Image(); image.onload = onload; image.onerror = onerror; image.src = src; return image; } }; /* Injected with object hook! */ 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 = 0x0907; 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 = source.length; i < len; 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 = source.length; i < len; 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 = keysArr.length; i < len; i++) { var key = keysArr[i]; if ((target[key] == null)) { target[key] = source[key]; } } return target; } function indexOf(array, value) { if (array) { if (array.indexOf) { return array.indexOf(value); } for (var i = 0, len = array.length; i < len; 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 ((target[key] == null)) { target[key] = source[key]; } } } } else { defaults(target, source); } } 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 = arr.length; i < len; 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 = arr.length; i < len; 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 = arr.length; i < len; 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 = arr.length; i < len; 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 = args.length; i < len; 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 = val.length; if (len === 2) { return [val[0], val[1], val[0], val[1]]; } else if (len === 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() { this.data = {}; } MapPolyfill.prototype["delete"] = function (key) { var existed = this.has(key); if (existed) { delete this.data[key]; } return existed; }; MapPolyfill.prototype.has = function (key) { return this.data.hasOwnProperty(key); }; MapPolyfill.prototype.get = function (key) { return this.data[key]; }; MapPolyfill.prototype.set = function (key, value) { this.data[key] = value; return this; }; MapPolyfill.prototype.keys = function () { return keys(this.data); }; MapPolyfill.prototype.forEach = function (callback) { var data = this.data; for (var key in data) { if (data.hasOwnProperty(key)) { callback(data[key], key); } } }; return MapPolyfill; }()); var isNativeMapSupported = typeof Map === 'function'; function maybeNativeMap() { return (isNativeMapSupported ? new Map() : new MapPolyfill()); } var HashMap = (function () { function HashMap(obj) { var isArr = isArray(obj); this.data = maybeNativeMap(); var thisMap = this; (obj instanceof HashMap) ? obj.each(visit) : (obj && each$4(obj, visit)); function visit(value, key) { isArr ? thisMap.set(value, key) : thisMap.set(key, value); } } HashMap.prototype.hasKey = function (key) { return this.data.has(key); }; HashMap.prototype.get = function (key) { return this.data.get(key); }; HashMap.prototype.set = function (key, value) { this.data.set(key, value); return value; }; HashMap.prototype.each = function (cb, context) { this.data.forEach(function (value, key) { cb.call(context, value, key); }); }; HashMap.prototype.keys = function () { var keys = this.data.keys(); return isNativeMapSupported ? Array.from(keys) : keys; }; HashMap.prototype.removeKey = function (key) { this.data["delete"](key); }; return HashMap; }()); 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, properties) { var obj; if (Object.create) { obj = Object.create(proto); } else { var StyleCtor = function () { }; StyleCtor.prototype = proto; 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; /* Injected with object hook! */ var Browser = (function () { function Browser() { this.firefox = false; this.ie = false; this.edge = false; this.newEdge = false; this.weChat = false; } return Browser; }()); var Env = (function () { function Env() { 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; }()); 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) { var browser = env.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.svgSupported = typeof SVGRect !== 'undefined'; env.touchEventsSupported = 'ontouchstart' in window && !browser.ie && !browser.edge; env.pointerEventsSupported = 'onpointerdown' in window && (browser.edge || (browser.ie && +browser.version >= 11)); env.domSupported = typeof document !== 'undefined'; var style = document.documentElement.style; env.transform3dSupported = ((browser.ie && 'transition' in style) || browser.edge || (('WebKitCSSMatrix' in window) && ('m11' in new WebKitCSSMatrix())) || 'MozPerspective' in style) && !('OTransition' in style); env.transformSupported = env.transform3dSupported || (browser.ie && +browser.version >= 9); } /* Injected with object hook! */ 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; } 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) { var superClass = this; var ExtendedClass; if (isESClass(superClass)) { ExtendedClass = /** @class */ function(_super) { __extends(class_1, _super); function class_1() { return _super.apply(this, arguments) || this; } return class_1; }(superClass); } else { ExtendedClass = function() { (proto.$constructor || superClass).apply(this, arguments); }; inherits(ExtendedClass, this); } extend(ExtendedClass.prototype, proto); 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) { 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]; }; target.getAllClassMainTypes = function() { var types = []; each$4(storage, function(obj, type) { types.push(type); }); return 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; } } /* Injected with object hook! */ function makeStyleMapper(properties, ignoreParent) { // Normalize 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 = 0; i < properties.length; i++) { var propName = properties[i][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][0]] = val; } } // TODO Text or image? return style; }; } /* Injected with object hook! */ var AREA_STYLE_KEY_MAP = [['fill', 'color'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['opacity'], ['shadowColor'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`. // So do not transfer decal directly. ]; var getAreaStyle = makeStyleMapper(AREA_STYLE_KEY_MAP); var AreaStyleMixin = /** @class */function () { function AreaStyleMixin() {} AreaStyleMixin.prototype.getAreaStyle = function (excludes, includes) { return getAreaStyle(this, excludes, includes); }; return AreaStyleMixin; }(); /* Injected with object hook! */ var Entry = (function () { function Entry(val) { this.value = val; } return Entry; }()); var LinkedList = (function () { function LinkedList() { this._len = 0; } LinkedList.prototype.insert = function (val) { var entry = new Entry(val); this.insertEntry(entry); return entry; }; LinkedList.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.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.prototype.len = function () { return this._len; }; LinkedList.prototype.clear = function () { this.head = this.tail = null; this._len = 0; }; return LinkedList; }()); var LRU = (function () { function LRU(maxSize) { this._list = new LinkedList(); this._maxSize = 10; this._map = {}; this._maxSize = maxSize; } LRU.prototype.put = function (key, value) { var list = this._list; var map = this._map; var removed = null; if (map[key] == null) { var len = list.len(); var entry = this._lastRemovedEntry; if (len >= this._maxSize && len > 0) { var leastUsedEntry = list.head; list.remove(leastUsedEntry); delete map[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[key] = entry; } return removed; }; LRU.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.prototype.clear = function () { this._list.clear(); this._map = {}; }; LRU.prototype.len = function () { return this._list.len(); }; return LRU; }()); /* Injected with object hook! */ var globalImageCache = new LRU(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: hostEl, cb: onload, cbPayload: 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: 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; } /* Injected with object hook! */ function create$1() { return [1, 0, 0, 1, 0, 0]; } function identity(out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 1; out[4] = 0; out[5] = 0; return out; } function copy(out, m) { out[0] = m[0]; out[1] = m[1]; out[2] = m[2]; out[3] = m[3]; out[4] = m[4]; out[5] = m[5]; return out; } function mul(out, 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[0] = out0; out[1] = out1; out[2] = out2; out[3] = out3; out[4] = out4; out[5] = out5; return out; } function translate(out, a, v) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4] + v[0]; out[5] = a[5] + v[1]; return out; } function rotate(out, 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[0] = aa * ct + ab * st; out[1] = -aa * st + ab * ct; out[2] = ac * ct + ad * st; out[3] = -ac * st + ct * ad; out[4] = ct * (atx - pivot[0]) + st * (aty - pivot[1]) + pivot[0]; out[5] = ct * (aty - pivot[1]) - st * (atx - pivot[0]) + pivot[1]; return out; } function scale$2(out, a, v) { var vx = v[0]; var vy = v[1]; out[0] = a[0] * vx; out[1] = a[1] * vy; out[2] = a[2] * vx; out[3] = a[3] * vy; out[4] = a[4] * vx; out[5] = a[5] * vy; return out; } function invert(out, 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.0 / det; out[0] = ad * det; out[1] = -ab * det; out[2] = -ac * det; out[3] = aa * det; out[4] = (ac * aty - ad * atx) * det; out[5] = (ab * atx - aa * aty) * det; return out; } /* Injected with object hook! */ var Point = (function () { function Point(x, y) { this.x = x || 0; this.y = y || 0; } Point.prototype.copy = function (other) { this.x = other.x; this.y = other.y; return this; }; Point.prototype.clone = function () { return new Point(this.x, this.y); }; Point.prototype.set = function (x, y) { this.x = x; this.y = y; return this; }; Point.prototype.equal = function (other) { return other.x === this.x && other.y === this.y; }; Point.prototype.add = function (other) { this.x += other.x; this.y += other.y; return this; }; Point.prototype.scale = function (scalar) { this.x *= scalar; this.y *= scalar; }; Point.prototype.scaleAndAdd = function (other, scalar) { this.x += other.x * scalar; this.y += other.y * scalar; }; Point.prototype.sub = function (other) { this.x -= other.x; this.y -= other.y; return this; }; Point.prototype.dot = function (other) { return this.x * other.x + this.y * other.y; }; Point.prototype.len = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; Point.prototype.lenSquare = function () { return this.x * this.x + this.y * this.y; }; Point.prototype.normalize = function () { var len = this.len(); this.x /= len; this.y /= len; return this; }; Point.prototype.distance = function (other) { var dx = this.x - other.x; var dy = this.y - other.y; return Math.sqrt(dx * dx + dy * dy); }; Point.prototype.distanceSquare = function (other) { var dx = this.x - other.x; var dy = this.y - other.y; return dx * dx + dy * dy; }; Point.prototype.negate = function () { this.x = -this.x; this.y = -this.y; return this; }; Point.prototype.transform = function (m) { if (!m) { return; } var x = this.x; var y = this.y; this.x = m[0] * x + m[2] * y + m[4]; this.y = m[1] * x + m[3] * y + m[5]; return this; }; Point.prototype.toArray = function (out) { out[0] = this.x; out[1] = this.y; return out; }; Point.prototype.fromArray = function (input) { this.x = input[0]; this.y = input[1]; }; Point.set = function (p, x, y) { p.x = x; p.y = y; }; Point.copy = function (p, p2) { p.x = p2.x; p.y = p2.y; }; Point.len = function (p) { return Math.sqrt(p.x * p.x + p.y * p.y); }; Point.lenSquare = function (p) { return p.x * p.x + p.y * p.y; }; Point.dot = function (p0, p1) { return p0.x * p1.x + p0.y * p1.y; }; Point.add = function (out, p0, p1) { out.x = p0.x + p1.x; out.y = p0.y + p1.y; }; Point.sub = function (out, p0, p1) { out.x = p0.x - p1.x; out.y = p0.y - p1.y; }; Point.scale = function (out, p0, scalar) { out.x = p0.x * scalar; out.y = p0.y * scalar; }; Point.scaleAndAdd = function (out, p0, p1, scalar) { out.x = p0.x + p1.x * scalar; out.y = p0.y + p1.y * scalar; }; Point.lerp = function (out, p0, p1, t) { var onet = 1 - t; out.x = onet * p0.x + t * p1.x; out.y = onet * p0.y + t * p1.y; }; return Point; }()); /* Injected with object hook! */ var mathMin$5 = Math.min; var mathMax$5 = Math.max; var lt = new Point(); var rb = new Point(); var lb = new Point(); var rt = new Point(); var minTv$1 = new Point(); var maxTv$1 = new Point(); var BoundingRect = (function () { function BoundingRect(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.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.prototype.applyTransform = function (m) { BoundingRect.applyTransform(this, this, m); }; BoundingRect.prototype.calculateTransform = function (b) { var a = this; var sx = b.width / a.width; var sy = b.height / a.height; var m = create$1(); translate(m, m, [-a.x, -a.y]); scale$2(m, m, [sx, sy]); translate(m, m, [b.x, b.y]); return m; }; BoundingRect.prototype.intersect = function (b, mtv) { if (!b) { return false; } if (!(b instanceof BoundingRect)) { b = BoundingRect.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.set(maxTv$1, -d0, 0); } else { Point.set(maxTv$1, d1, 0); } } } else { if (dx < dMin) { dMin = dx; if (d0 < d1) { Point.set(minTv$1, d0, 0); } else { Point.set(minTv$1, -d1, 0); } } } if (ay1 < by0 || by1 < ay0) { if (dy > dMax) { dMax = dy; if (d2 < d3) { Point.set(maxTv$1, 0, -d2); } else { Point.set(maxTv$1, 0, d3); } } } else { if (dx < dMin) { dMin = dx; if (d2 < d3) { Point.set(minTv$1, 0, d2); } else { Point.set(minTv$1, 0, -d3); } } } } if (mtv) { Point.copy(mtv, overlap ? minTv$1 : maxTv$1); } return overlap; }; BoundingRect.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.prototype.clone = function () { return new BoundingRect(this.x, this.y, this.width, this.height); }; BoundingRect.prototype.copy = function (other) { BoundingRect.copy(this, other); }; BoundingRect.prototype.plain = function () { return { x: this.x, y: this.y, width: this.width, height: this.height }; }; BoundingRect.prototype.isFinite = function () { return isFinite(this.x) && isFinite(this.y) && isFinite(this.width) && isFinite(this.height); }; BoundingRect.prototype.isZero = function () { return this.width === 0 || this.height === 0; }; BoundingRect.create = function (rect) { return new BoundingRect(rect.x, rect.y, rect.width, rect.height); }; BoundingRect.copy = function (target, source) { target.x = source.x; target.y = source.y; target.width = source.width; target.height = source.height; }; BoundingRect.applyTransform = function (target, source, m) { if (!m) { if (target !== source) { BoundingRect.copy(target, source); } return; } if (m[1] < 1e-5 && m[1] > -1e-5 && m[2] < 1e-5 && m[2] > -1e-5) { var sx = m[0]; var sy = m[3]; var tx = m[4]; var ty = m[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); rt.transform(m); rb.transform(m); lb.transform(m); 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; }()); /* Injected with object hook! */ var textWidthCache = {}; function getWidth(text, font) { font = font || DEFAULT_FONT; var cacheOfFont = textWidthCache[font]; if (!cacheOfFont) { cacheOfFont = textWidthCache[font] = new LRU(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(x, y, width, height); return rect; } function getBoundingRect(text, font, textAlign, textBaseline) { var textLines = ((text || '') + '').split('\n'); var len = textLines.length; if (len === 1) { return innerGetBoundingRect(textLines[0], font, textAlign, textBaseline); } else { var uniondRect = new BoundingRect(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, opts, rect) { var textPosition = opts.position || 'inside'; var distance = 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; y += halfHeight; textAlign = 'right'; textVerticalAlign = 'middle'; break; case 'right': x += distance + width; y += halfHeight; textVerticalAlign = 'middle'; break; case 'top': x += width / 2; y -= distance; textAlign = 'center'; textVerticalAlign = 'bottom'; break; case 'bottom': x += width / 2; y += height + distance; textAlign = 'center'; break; case 'inside': x += width / 2; y += halfHeight; textAlign = 'center'; textVerticalAlign = 'middle'; break; case 'insideLeft': x += distance; y += halfHeight; textVerticalAlign = 'middle'; break; case 'insideRight': x += width - distance; y += halfHeight; textAlign = 'right'; textVerticalAlign = 'middle'; break; case 'insideTop': x += width / 2; y += distance; textAlign = 'center'; break; case 'insideBottom': x += width / 2; y += height - distance; textAlign = 'center'; textVerticalAlign = 'bottom'; break; case 'insideTopLeft': x += distance; y += distance; break; case 'insideTopRight': x += width - distance; y += distance; textAlign = 'right'; break; case 'insideBottomLeft': x += distance; y += height - distance; textVerticalAlign = 'bottom'; break; case 'insideBottomRight': x += width - distance; y += height - distance; textAlign = 'right'; textVerticalAlign = 'bottom'; break; } } out = out || {}; out.x = x; out.y = y; out.align = textAlign; out.verticalAlign = textVerticalAlign; return out; } /* Injected with object hook! */ var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g; function truncateText2(out, text, containerWidth, font, ellipsis, options) { if (!containerWidth) { out.text = ''; out.isTruncated = false; return; } var textLines = (text + '').split('\n'); options = prepareTruncateOptions(containerWidth, font, ellipsis, options); var isTruncated = false; var truncateOut