qauMaWeb/node_modules/.cache/babel-loader/e00fb9aedacb7f67d112d9eb722...

1 line
31 KiB
JSON
Raw Normal View History

2024-10-13 18:02:27 +08:00
{"ast":null,"code":"import \"core-js/modules/es.array.fill.js\";\nimport { brush, setClipPath, setGradient, setPattern } from './graphic.js';\nimport { createElement, createVNode, vNodeToString, getCssString, createBrushScope, createSVGVNode } from './core.js';\nimport { normalizeColor, encodeBase64, isGradient, isPattern } from './helper.js';\nimport { extend, keys, logError, map, noop, retrieve2 } from '../core/util.js';\nimport patch, { updateAttrs } from './patch.js';\nimport { getSize } from '../canvas/helper.js';\nvar svgId = 0;\n\nvar SVGPainter = function () {\n function SVGPainter(root, storage, opts) {\n this.type = 'svg';\n this.refreshHover = createMethodNotSupport('refreshHover');\n this.configLayer = createMethodNotSupport('configLayer');\n this.storage = storage;\n this._opts = opts = extend({}, opts);\n this.root = root;\n this._id = 'zr' + svgId++;\n this._oldVNode = createSVGVNode(opts.width, opts.height);\n\n if (root && !opts.ssr) {\n var viewport = this._viewport = document.createElement('div');\n viewport.style.cssText = 'position:relative;overflow:hidden';\n var svgDom = this._svgDom = this._oldVNode.elm = createElement('svg');\n updateAttrs(null, this._oldVNode);\n viewport.appendChild(svgDom);\n root.appendChild(viewport);\n }\n\n this.resize(opts.width, opts.height);\n }\n\n SVGPainter.prototype.getType = function () {\n return this.type;\n };\n\n SVGPainter.prototype.getViewportRoot = function () {\n return this._viewport;\n };\n\n SVGPainter.prototype.getViewportRootOffset = function () {\n var viewportRoot = this.getViewportRoot();\n\n if (viewportRoot) {\n return {\n offsetLeft: viewportRoot.offsetLeft || 0,\n offsetTop: viewportRoot.offsetTop || 0\n };\n }\n };\n\n SVGPainter.prototype.getSvgDom = function () {\n return this._svgDom;\n };\n\n SVGPainter.prototype.refresh = function () {\n if (this.root) {\n var vnode = this.renderToVNode({\n willUpdate: true\n });\n vnode.attrs.style = 'position:absolute;left:0;top:0;user-select:none';\n patch(this._oldVNode, vnode);\n this._oldVNode = vnode;\n }\n };\n\n SVGPainter.prototype.renderOneToVNode = function (el) {\n return brush(el, createBrushScope(this._id));\n };\n\n SVGPainter.prototype.renderToVNode = function (opts) {\n opts = opts || {};\n var list = this.storage.getDisplayList(true);\n var width = this._width;\n var height = this._height;\n var scope = createBrushScope(this._id);\n scope.animation = opts.animation;\n scope.willUpdate = opts.willUpdate;\n scope.compress = opts.compress;\n var children = [];\n var bgVNode = this._bgVNode = createBackgroundVNode(width, height, this._backgroundColor, scope);\n bgVNode && children.push(bgVNode);\n var mainVNode = !opts.compress ? this._mainVNode = createVNode('g', 'main', {}, []) : null;\n\n this._paintList(list, scope, mainVNode ? mainVNode.children : children);\n\n mainVNode && children.push(mainVNode);\n var defs = map(keys(scope.defs), function (id) {\n return scope.defs[id];\n });\n\n if (defs.length) {\n children.push(createVNode('defs', 'defs', {}, defs));\n }\n\n if (opts.animation) {\n var animationCssStr = getCssString(scope.cssNodes, scope.cssAnims, {\n newline: true\n });\n\n if (animationCssStr) {\n var styleNode = createVNode('style', 'stl', {}, [], animationCssStr);\n children.push(styleNode);\n }\n }\n\n return createSVGVNode(width, height, children, opts.useViewBox);\n };\n\n SVGPainter.prototype.renderToString = function (opts) {\n opts = opts || {};\n return vNodeToString(this.renderToVNode({\n animation: retrieve2(opts.cssAnimation, true),\n willUpdate: false,\n compress: true,\n useViewBox: retrieve2(opts.useViewBox, true)\n }), {\n newline: true\n });\n };\n\n SVGPainter.prototype.setBackgroundColor = function (backgroundColor) {\n this._backgroundColor =