@antv/x6-plugin-export
Advanced tools
+22
-22
| { | ||
| "name": "@antv/x6-plugin-export", | ||
| "version": "2.0.2", | ||
| "version": "3.0.0", | ||
| "description": "export plugin for X6.", | ||
@@ -21,7 +21,24 @@ "main": "lib/index.js", | ||
| ], | ||
| "scripts": { | ||
| "clean:build": "rss", | ||
| "clean:coverage": "rss", | ||
| "clean": "rss", | ||
| "build:esm": "rss", | ||
| "build:cjs": "rss", | ||
| "build:umd": "rss", | ||
| "build:dev": "rss", | ||
| "build:watch": "rss", | ||
| "build:watch:esm": "rss", | ||
| "build:watch:cjs": "rss", | ||
| "build": "rss", | ||
| "prebuild": "rss", | ||
| "test": "rss", | ||
| "coveralls": "rss", | ||
| "pretest": "rss" | ||
| }, | ||
| "peerDependencies": { | ||
| "@antv/x6": "^2.x" | ||
| "@antv/x6": "^3.x" | ||
| }, | ||
| "devDependencies": { | ||
| "@antv/x6": "^2.x" | ||
| "@antv/x6": "^3.x" | ||
| }, | ||
@@ -33,3 +50,3 @@ "author": { | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/antvis/x6", | ||
| "homepage": "https://x6.antv.antgroup.com/tutorial/plugins/export", | ||
| "bugs": { | ||
@@ -46,20 +63,3 @@ "url": "https://github.com/antvis/x6/issues" | ||
| "registry": "https://registry.npmjs.org" | ||
| }, | ||
| "scripts": { | ||
| "clean:build": "rss", | ||
| "clean:coverage": "rss", | ||
| "clean": "rss", | ||
| "build:esm": "rss", | ||
| "build:cjs": "rss", | ||
| "build:umd": "rss", | ||
| "build:dev": "rss", | ||
| "build:watch": "rss", | ||
| "build:watch:esm": "rss", | ||
| "build:watch:cjs": "rss", | ||
| "build": "rss", | ||
| "prebuild": "rss", | ||
| "test": "rss", | ||
| "coveralls": "rss", | ||
| "pretest": "rss" | ||
| } | ||
| } | ||
| } |
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/x6")):"function"==typeof define&&define.amd?define(["exports","@antv/x6"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).X6PluginExport={},t.X6)}(this,(function(t,e){"use strict";var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},o(t,e)};var r=function(){return r=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};e.Graph.prototype.exportPNG=function(t,e){var o=this.getPlugin("export");o&&o.exportPNG(t,e)},e.Graph.prototype.exportJPEG=function(t,e){var o=this.getPlugin("export");o&&o.exportJPEG(t,e)},e.Graph.prototype.exportSVG=function(t,e){var o=this.getPlugin("export");o&&o.exportSVG(t,e)};var i=function(t){function i(){var e=t.call(this)||this;return e.name="export",e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(i,t),i.prototype.init=function(t){this.graph=t},Object.defineProperty(i.prototype,"view",{get:function(){return this.graph.view},enumerable:!1,configurable:!0}),i.prototype.exportPNG=function(t,o){void 0===t&&(t="chart"),void 0===o&&(o={}),this.toPNG((function(o){e.DataUri.downloadDataUri(o,t)}),o)},i.prototype.exportJPEG=function(t,o){void 0===t&&(t="chart"),void 0===o&&(o={}),this.toPNG((function(o){e.DataUri.downloadDataUri(o,t)}),o)},i.prototype.exportSVG=function(t,o){void 0===t&&(t="chart"),void 0===o&&(o={}),this.toSVG((function(o){e.DataUri.downloadDataUri(e.DataUri.svgToDataUrl(o),t)}),o)},i.prototype.toSVG=function(t,o){var r=this;void 0===o&&(o={}),this.notify("before:export",o);var i=this.view.svg,n=e.Vector.create(i).clone(),a=n.node,h=n.findOne(".".concat(this.view.prefixClassName("graph-svg-stage"))),p=o.viewBox||this.graph.graphToLocal(this.graph.getContentBBox()),c=o.preserveDimensions;if(c){var l="boolean"==typeof c?p:c;n.attr({width:l.width,height:l.height})}if(n.removeAttribute("style").attr("viewBox",[p.x,p.y,p.width,p.height].join(" ")),h.removeAttribute("transform"),!1!==o.copyStyles){for(var f=i.ownerDocument,s=Array.from(i.querySelectorAll("*")),u=Array.from(a.querySelectorAll("*")),g=f.styleSheets.length,d=[],v=g-1;v>=0;v-=1)d[v]=f.styleSheets[v],f.styleSheets[v].disabled=!0;var y={};s.forEach((function(t,e){var o=window.getComputedStyle(t,null),r={};Object.keys(o).forEach((function(t){r[t]=o.getPropertyValue(t)})),y[e]=r})),g!==f.styleSheets.length&&d.forEach((function(t,e){f.styleSheets[e]=t}));for(var m=0;m<g;m+=1)f.styleSheets[m].disabled=!1;var w={};s.forEach((function(t,o){var r=window.getComputedStyle(t,null),i=y[o],n={};Object.keys(r).forEach((function(t){e.NumberExt.isNumber(t)||r.getPropertyValue(t)===i[t]||(n[t]=r.getPropertyValue(t))})),w[o]=n})),u.forEach((function(t,o){e.Dom.css(t,w[o])}))}var x=o.stylesheet;if("string"==typeof x){var b=i.ownerDocument.implementation.createDocument(null,"xml",null).createCDATASection(x);n.prepend(e.Vector.create("style",{type:"text/css"},[b]))}var S=function(){var i=o.beforeSerialize;if("function"==typeof i){var n=e.FunctionExt.call(i,r.graph,a);n instanceof SVGSVGElement&&(a=n)}var h=(new XMLSerializer).serializeToString(a).replace(/ /g," ");r.notify("after:export",o),t(h)};if(o.serializeImages){var P=n.find("image").map((function(t){return new Promise((function(o){var r=t.attr("xlink:href")||t.attr("href");e.DataUri.imageToDataUri(r,(function(e,r){!e&&r&&t.attr("xlink:href",r),o()}))}))}));Promise.all(P).then(S)}else S()},i.prototype.toDataURL=function(t,o){var i=o.viewBox||this.graph.getContentBBox(),n=e.NumberExt.normalizeSides(o.padding);o.width&&o.height&&(n.left+n.right>=o.width&&(n.left=n.right=0),n.top+n.bottom>=o.height&&(n.top=n.bottom=0));var a=new e.Rectangle(-n.left,-n.top,n.left+n.right,n.top+n.bottom);if(o.width&&o.height){var h=i.width+n.left+n.right,p=i.height+n.top+n.bottom;a.scale(h/o.width,p/o.height)}i=e.Rectangle.create(i).moveAndExpand(a);var c="number"==typeof o.width&&"number"==typeof o.height?{width:o.width,height:o.height}:i,l=o.ratio?parseFloat(o.ratio):1;Number.isFinite(l)&&0!==l||(l=1);var f={width:Math.max(Math.round(c.width*l),1),height:Math.max(Math.round(c.height*l),1)},s=document.createElement("canvas"),u=s.getContext("2d");s.width=f.width,s.height=f.height;var g=f.width-1,d=f.height-1;u.fillStyle="rgb(1,1,1)",u.fillRect(g,d,1,1);var v=u.getImageData(g,d,1,1).data;if(1!==v[0]||1!==v[1]||1!==v[2])throw new Error("size exceeded");var y=new Image;y.onload=function(){var e=document.createElement("canvas");e.width=f.width,e.height=f.height;var r=e.getContext("2d");r.fillStyle=o.backgroundColor||"white",r.fillRect(0,0,f.width,f.height);try{r.drawImage(y,0,0,f.width,f.height);var i=e.toDataURL(o.type,o.quality);t(i)}catch(t){}},this.toSVG((function(t){y.src="data:image/svg+xml,".concat(encodeURIComponent(t))}),r(r({},o),{viewBox:i,serializeImages:!0,preserveDimensions:r({},f)}))},i.prototype.toPNG=function(t,e){void 0===e&&(e={}),this.toDataURL(t,r(r({},e),{type:"image/png"}))},i.prototype.toJPEG=function(t,e){void 0===e&&(e={}),this.toDataURL(t,r(r({},e),{type:"image/jpeg"}))},i.prototype.notify=function(t,e){this.trigger(t,e),this.graph.trigger(t,e)},i}(e.Basecoat);t.Export=i})); | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/@rollup+plugin-typescript@8.5.0_skqhbvp355vci76ty3pdffvjrq/node_modules/tslib/tslib.es6.js","../src/api.ts","../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n",null,null],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","__assign","assign","t","s","i","n","arguments","length","apply","this","x6","Graph","exportPNG","fileName","options","instance","getPlugin","exportJPEG","exportSVG","Export","_super","_this","name","TypeError","String","__","constructor","create","__extends","init","graph","defineProperty","get","view","toPNG","dataUri","DataUri","downloadDataUri","toSVG","svg","svgToDataUrl","callback","notify","rawSVG","vSVG","Vector","clone","clonedSVG","node","vStage","findOne","concat","prefixClassName","viewBox","graphToLocal","getContentBBox","dimension","preserveDimensions","size","attr","width","height","removeAttribute","x","y","join","copyStyles","document_1","ownerDocument","raws","from","querySelectorAll","clones","styleSheetCount","styleSheets","styleSheetsCopy","k","disabled","defaultComputedStyles_1","forEach","elem","index","computedStyle","window","getComputedStyle","defaultComputedStyle","keys","property","getPropertyValue","copy","customStyles_1","customStyle","NumberExt","isNumber","Dom","css","stylesheet","cDATASection","implementation","createDocument","createCDATASection","prepend","type","format","beforeSerialize","ret","FunctionExt","SVGSVGElement","XMLSerializer","serializeToString","replace","serializeImages","deferrals","find","map","vImage","Promise","resolve","url","imageToDataUri","err","all","then","toDataURL","padding","normalizeSides","left","right","top","bottom","expanding","Rectangle","scale","moveAndExpand","rawSize","ratio","parseFloat","Number","isFinite","Math","max","round","imgDataCanvas","document","createElement","context2D","getContext","fillStyle","fillRect","data","getImageData","Error","img","Image","onload","canvas","context","backgroundColor","drawImage","quality","error","src","encodeURIComponent","toJPEG","args","trigger","Basecoat"],"mappings":"4RAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,CAAE,GACzE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOC,OAAOK,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,KACzFP,EAAcC,EAAGC,EAC5B,EAUO,IAAIS,EAAW,WAQlB,OAPAA,EAAWR,OAAOS,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIR,KADTO,EAAIG,UAAUF,GACOZ,OAAOK,UAAUC,eAAeC,KAAKI,EAAGP,KAAIM,EAAEN,GAAKO,EAAEP,IAE9E,OAAOM,CACV,EACMF,EAASQ,MAAMC,KAAMH,UAChC,EC7BKI,EAAAC,MAACd,UAAUe,UAAY,SAC1BC,EACAC,GAEA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EAAKG,QAC9C,IAAM1B,EAAUwH,EAAOhC,UAAU7G,EAAQwF,KAAMxF,EAAQiJ,SACvDtH,EAASN,EAGV,CAFC,MAAO6H,GAER,CACH,EAEAvJ,KAAK6B,OACH,SAACH,GACCqH,EAAIS,IAAM,sBAAA9G,OAAsB+G,mBAAmB/H,GACrD,GAEKnC,EAAAA,EAAA,CAAA,EAAAc,GACH,CAAAuC,UACA0D,iBAAiB,EACjBtD,mBACKzD,EAAA,CAAA,EAAA0D,OAMXvC,EAAAtB,UAAAqC,MAAA,SAAMO,EAAgC3B,QAAA,IAAAA,IAAAA,EAAmC,CAAA,GACvEL,KAAKkH,UAAUlF,EAAQzC,EAAAA,EAAA,CAAA,EAClBc,GAAO,CACVwF,KAAM,gBAIVnF,EAAAtB,UAAAsK,OAAA,SAAO1H,EAAgC3B,QAAA,IAAAA,IAAAA,EAAmC,CAAA,GACxEL,KAAKkH,UAAUlF,EAAQzC,EAAAA,EAAA,CAAA,EAClBc,GAAO,CACVwF,KAAM,iBAIAnF,EAAAtB,UAAA6C,OAAV,SACEpB,EACA8I,GAEA3J,KAAK4J,QAAQ/I,EAAM8I,GACnB3J,KAAKqB,MAAMuI,QAAQ/I,EAAM8I,IAE5BjJ,CAAD,CA5TA,CAA4BmJ"} |
| import { Export } from './index'; | ||
| declare module '@antv/x6/lib/graph/graph' { | ||
| interface Graph { | ||
| exportPNG: (fileName?: string, options?: Export.ToImageOptions) => void; | ||
| exportJPEG: (fileName?: string, options?: Export.ToImageOptions) => void; | ||
| exportSVG: (fileName?: string, options?: Export.ToSVGOptions) => void; | ||
| } | ||
| } |
-20
| import { Graph } from '@antv/x6'; | ||
| Graph.prototype.exportPNG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportPNG(fileName, options); | ||
| } | ||
| }; | ||
| Graph.prototype.exportJPEG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportJPEG(fileName, options); | ||
| } | ||
| }; | ||
| Graph.prototype.exportSVG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportSVG(fileName, options); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAWhC,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,UAC1B,QAAiB,EACjB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACtC;AACH,CAAC,CAAA;AAED,KAAK,CAAC,SAAS,CAAC,UAAU,GAAG,UAC3B,QAAiB,EACjB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACvC;AACH,CAAC,CAAA;AAED,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,UAC1B,QAAiB,EACjB,OAA6B;IAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACtC;AACH,CAAC,CAAA"} |
| import { NumberExt, Rectangle, Size, Basecoat, Graph } from '@antv/x6'; | ||
| import './api'; | ||
| export declare class Export extends Basecoat<Export.EventArgs> { | ||
| private graph; | ||
| name: string; | ||
| constructor(); | ||
| init(graph: Graph): void; | ||
| get view(): Graph.View; | ||
| exportPNG(fileName?: string, options?: Export.ToImageOptions): void; | ||
| exportJPEG(fileName?: string, options?: Export.ToImageOptions): void; | ||
| exportSVG(fileName?: string, options?: Export.ToSVGOptions): void; | ||
| toSVG(callback: Export.ToSVGCallback, options?: Export.ToSVGOptions): void; | ||
| toDataURL(callback: Export.ToSVGCallback, options: Export.ToDataURLOptions): void; | ||
| toPNG(callback: Export.ToSVGCallback, options?: Export.ToImageOptions): void; | ||
| toJPEG(callback: Export.ToSVGCallback, options?: Export.ToImageOptions): void; | ||
| protected notify<K extends keyof Export.EventArgs>(name: K, args: Export.EventArgs[K]): void; | ||
| } | ||
| export declare namespace Export { | ||
| interface EventArgs { | ||
| 'before:export': Export.ToSVGOptions; | ||
| 'after:export': Export.ToSVGOptions; | ||
| } | ||
| type ToSVGCallback = (dataUri: string) => any; | ||
| interface ToSVGOptions { | ||
| /** | ||
| * By default, the resulting SVG has set width and height to `100%`. | ||
| * If you'd like to have the dimensions to be set to the actual content | ||
| * width and height, set `preserveDimensions` to `true`. An object with | ||
| * `width` and `height` properties can be also used here if you need to | ||
| * define the export size explicitely. | ||
| */ | ||
| preserveDimensions?: boolean | Size; | ||
| viewBox?: Rectangle.RectangleLike; | ||
| /** | ||
| * When set to `true` all the styles from external stylesheets are copied | ||
| * to the resulting SVG export. Note this requires a lot of computations | ||
| * and it might significantly affect the export time. | ||
| */ | ||
| copyStyles?: boolean; | ||
| stylesheet?: string; | ||
| /** | ||
| * Converts all contained images into Data URI format. | ||
| */ | ||
| serializeImages?: boolean; | ||
| /** | ||
| * A function called before the XML serialization. It may be used to | ||
| * modify the exported SVG before it is converted to a string. The | ||
| * function can also return a new SVGDocument. | ||
| */ | ||
| beforeSerialize?: (this: Graph, svg: SVGSVGElement) => any; | ||
| } | ||
| interface ToImageOptions extends ToSVGOptions { | ||
| /** | ||
| * The width of the image in pixels. | ||
| */ | ||
| width?: number; | ||
| /** | ||
| * The height of the image in pixels. | ||
| */ | ||
| height?: number; | ||
| ratio?: string; | ||
| backgroundColor?: string; | ||
| padding?: NumberExt.SideOptions; | ||
| quality?: number; | ||
| } | ||
| interface ToDataURLOptions extends ToImageOptions { | ||
| type: 'image/png' | 'image/jpeg'; | ||
| } | ||
| } |
-234
| import { DataUri, NumberExt, FunctionExt, Vector, Rectangle, Basecoat, Dom, } from '@antv/x6'; | ||
| import './api'; | ||
| export class Export extends Basecoat { | ||
| constructor() { | ||
| super(); | ||
| this.name = 'export'; | ||
| } | ||
| init(graph) { | ||
| this.graph = graph; | ||
| } | ||
| get view() { | ||
| return this.graph.view; | ||
| } | ||
| exportPNG(fileName = 'chart', options = {}) { | ||
| this.toPNG((dataUri) => { | ||
| DataUri.downloadDataUri(dataUri, fileName); | ||
| }, options); | ||
| } | ||
| exportJPEG(fileName = 'chart', options = {}) { | ||
| this.toPNG((dataUri) => { | ||
| DataUri.downloadDataUri(dataUri, fileName); | ||
| }, options); | ||
| } | ||
| exportSVG(fileName = 'chart', options = {}) { | ||
| this.toSVG((svg) => { | ||
| DataUri.downloadDataUri(DataUri.svgToDataUrl(svg), fileName); | ||
| }, options); | ||
| } | ||
| toSVG(callback, options = {}) { | ||
| this.notify('before:export', options); | ||
| const rawSVG = this.view.svg; | ||
| const vSVG = Vector.create(rawSVG).clone(); | ||
| let clonedSVG = vSVG.node; | ||
| const vStage = vSVG.findOne(`.${this.view.prefixClassName('graph-svg-stage')}`); | ||
| const viewBox = options.viewBox || this.graph.graphToLocal(this.graph.getContentBBox()); | ||
| const dimension = options.preserveDimensions; | ||
| if (dimension) { | ||
| const size = typeof dimension === 'boolean' ? viewBox : dimension; | ||
| vSVG.attr({ | ||
| width: size.width, | ||
| height: size.height, | ||
| }); | ||
| } | ||
| vSVG | ||
| .removeAttribute('style') | ||
| .attr('viewBox', [viewBox.x, viewBox.y, viewBox.width, viewBox.height].join(' ')); | ||
| vStage.removeAttribute('transform'); | ||
| // Stores all the CSS declarations from external stylesheets to the | ||
| // `style` attribute of the SVG document nodes. | ||
| // This is achieved in three steps. | ||
| // ----------------------------------- | ||
| // 1. Disabling all the stylesheets in the page and therefore collecting | ||
| // only default style values. This, together with the step 2, makes it | ||
| // possible to discard default CSS property values and store only those | ||
| // that differ. | ||
| // | ||
| // 2. Enabling back all the stylesheets in the page and collecting styles | ||
| // that differ from the default values. | ||
| // | ||
| // 3. Applying the difference between default values and the ones set by | ||
| // custom stylesheets onto the `style` attribute of each of the nodes | ||
| // in SVG. | ||
| if (options.copyStyles !== false) { | ||
| const document = rawSVG.ownerDocument; | ||
| const raws = Array.from(rawSVG.querySelectorAll('*')); | ||
| const clones = Array.from(clonedSVG.querySelectorAll('*')); | ||
| const styleSheetCount = document.styleSheets.length; | ||
| const styleSheetsCopy = []; | ||
| for (let k = styleSheetCount - 1; k >= 0; k -= 1) { | ||
| // There is a bug (bugSS) in Chrome 14 and Safari. When you set | ||
| // `stylesheet.disable = true` it will also remove it from | ||
| // `document.styleSheets`. So we need to store all stylesheets before | ||
| // we disable them. Later on we put them back to `document.styleSheets` | ||
| // if needed. | ||
| // See the bug `https://code.google.com/p/chromium/issues/detail?id=88310`. | ||
| styleSheetsCopy[k] = document.styleSheets[k]; | ||
| document.styleSheets[k].disabled = true; | ||
| } | ||
| const defaultComputedStyles = {}; | ||
| raws.forEach((elem, index) => { | ||
| const computedStyle = window.getComputedStyle(elem, null); | ||
| // We're making a deep copy of the `computedStyle` so that it's not affected | ||
| // by that next step when all the stylesheets are re-enabled again. | ||
| const defaultComputedStyle = {}; | ||
| Object.keys(computedStyle).forEach((property) => { | ||
| defaultComputedStyle[property] = | ||
| computedStyle.getPropertyValue(property); | ||
| }); | ||
| defaultComputedStyles[index] = defaultComputedStyle; | ||
| }); | ||
| // Copy all stylesheets back | ||
| if (styleSheetCount !== document.styleSheets.length) { | ||
| styleSheetsCopy.forEach((copy, index) => { | ||
| document.styleSheets[index] = copy; | ||
| }); | ||
| } | ||
| for (let i = 0; i < styleSheetCount; i += 1) { | ||
| document.styleSheets[i].disabled = false; | ||
| } | ||
| const customStyles = {}; | ||
| raws.forEach((elem, index) => { | ||
| const computedStyle = window.getComputedStyle(elem, null); | ||
| const defaultComputedStyle = defaultComputedStyles[index]; | ||
| const customStyle = {}; | ||
| Object.keys(computedStyle).forEach((property) => { | ||
| if (!NumberExt.isNumber(property) && | ||
| computedStyle.getPropertyValue(property) !== | ||
| defaultComputedStyle[property]) { | ||
| customStyle[property] = computedStyle.getPropertyValue(property); | ||
| } | ||
| }); | ||
| customStyles[index] = customStyle; | ||
| }); | ||
| clones.forEach((elem, index) => { | ||
| Dom.css(elem, customStyles[index]); | ||
| }); | ||
| } | ||
| const stylesheet = options.stylesheet; | ||
| if (typeof stylesheet === 'string') { | ||
| const cDATASection = rawSVG | ||
| .ownerDocument.implementation.createDocument(null, 'xml', null) | ||
| .createCDATASection(stylesheet); | ||
| vSVG.prepend(Vector.create('style', { | ||
| type: 'text/css', | ||
| }, [cDATASection])); | ||
| } | ||
| const format = () => { | ||
| const beforeSerialize = options.beforeSerialize; | ||
| if (typeof beforeSerialize === 'function') { | ||
| const ret = FunctionExt.call(beforeSerialize, this.graph, clonedSVG); | ||
| if (ret instanceof SVGSVGElement) { | ||
| clonedSVG = ret; | ||
| } | ||
| } | ||
| const dataUri = new XMLSerializer() | ||
| .serializeToString(clonedSVG) | ||
| .replace(/ /g, '\u00a0'); | ||
| this.notify('after:export', options); | ||
| callback(dataUri); | ||
| }; | ||
| if (options.serializeImages) { | ||
| const deferrals = vSVG.find('image').map((vImage) => { | ||
| return new Promise((resolve) => { | ||
| const url = vImage.attr('xlink:href') || vImage.attr('href'); | ||
| DataUri.imageToDataUri(url, (err, dataUri) => { | ||
| if (!err && dataUri) { | ||
| vImage.attr('xlink:href', dataUri); | ||
| } | ||
| resolve(); | ||
| }); | ||
| }); | ||
| }); | ||
| Promise.all(deferrals).then(format); | ||
| } | ||
| else { | ||
| format(); | ||
| } | ||
| } | ||
| toDataURL(callback, options) { | ||
| let viewBox = options.viewBox || this.graph.getContentBBox(); | ||
| const padding = NumberExt.normalizeSides(options.padding); | ||
| if (options.width && options.height) { | ||
| if (padding.left + padding.right >= options.width) { | ||
| padding.left = padding.right = 0; | ||
| } | ||
| if (padding.top + padding.bottom >= options.height) { | ||
| padding.top = padding.bottom = 0; | ||
| } | ||
| } | ||
| const expanding = new Rectangle(-padding.left, -padding.top, padding.left + padding.right, padding.top + padding.bottom); | ||
| if (options.width && options.height) { | ||
| const width = viewBox.width + padding.left + padding.right; | ||
| const height = viewBox.height + padding.top + padding.bottom; | ||
| expanding.scale(width / options.width, height / options.height); | ||
| } | ||
| viewBox = Rectangle.create(viewBox).moveAndExpand(expanding); | ||
| const rawSize = typeof options.width === 'number' && typeof options.height === 'number' | ||
| ? { width: options.width, height: options.height } | ||
| : viewBox; | ||
| let scale = options.ratio ? parseFloat(options.ratio) : 1; | ||
| if (!Number.isFinite(scale) || scale === 0) { | ||
| scale = 1; | ||
| } | ||
| const size = { | ||
| width: Math.max(Math.round(rawSize.width * scale), 1), | ||
| height: Math.max(Math.round(rawSize.height * scale), 1), | ||
| }; | ||
| { | ||
| const imgDataCanvas = document.createElement('canvas'); | ||
| const context2D = imgDataCanvas.getContext('2d'); | ||
| imgDataCanvas.width = size.width; | ||
| imgDataCanvas.height = size.height; | ||
| const x = size.width - 1; | ||
| const y = size.height - 1; | ||
| context2D.fillStyle = 'rgb(1,1,1)'; | ||
| context2D.fillRect(x, y, 1, 1); | ||
| const data = context2D.getImageData(x, y, 1, 1).data; | ||
| if (data[0] !== 1 || data[1] !== 1 || data[2] !== 1) { | ||
| throw new Error('size exceeded'); | ||
| } | ||
| } | ||
| const img = new Image(); | ||
| img.onload = () => { | ||
| const canvas = document.createElement('canvas'); | ||
| canvas.width = size.width; | ||
| canvas.height = size.height; | ||
| const context = canvas.getContext('2d'); | ||
| context.fillStyle = options.backgroundColor || 'white'; | ||
| context.fillRect(0, 0, size.width, size.height); | ||
| try { | ||
| context.drawImage(img, 0, 0, size.width, size.height); | ||
| const dataUri = canvas.toDataURL(options.type, options.quality); | ||
| callback(dataUri); | ||
| } | ||
| catch (error) { | ||
| // pass | ||
| } | ||
| }; | ||
| this.toSVG((dataUri) => { | ||
| img.src = `data:image/svg+xml,${encodeURIComponent(dataUri)}`; | ||
| }, Object.assign(Object.assign({}, options), { viewBox, serializeImages: true, preserveDimensions: Object.assign({}, size) })); | ||
| } | ||
| toPNG(callback, options = {}) { | ||
| this.toDataURL(callback, Object.assign(Object.assign({}, options), { type: 'image/png' })); | ||
| } | ||
| toJPEG(callback, options = {}) { | ||
| this.toDataURL(callback, Object.assign(Object.assign({}, options), { type: 'image/jpeg' })); | ||
| } | ||
| notify(name, args) { | ||
| this.trigger(name, args); | ||
| this.graph.trigger(name, args); | ||
| } | ||
| } | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,SAAS,EACT,WAAW,EACX,MAAM,EACN,SAAS,EAGT,QAAQ,EACR,GAAG,GAEJ,MAAM,UAAU,CAAA;AACjB,OAAO,OAAO,CAAA;AAEd,MAAM,OAAO,MAAO,SAAQ,QAA0B;IAIpD;QACE,KAAK,EAAE,CAAA;QAHF,SAAI,GAAG,QAAQ,CAAA;IAItB,CAAC;IAED,IAAI,CAAC,KAAY;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,EAAE,UAAiC,EAAE;QAC/D,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YACrB,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC;IAED,UAAU,CAAC,QAAQ,GAAG,OAAO,EAAE,UAAiC,EAAE;QAChE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YACrB,OAAO,C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iC,EAAE;QACvE,IAAI,CAAC,SAAS,CAAC,QAAQ,kCAClB,OAAO,KACV,IAAI,EAAE,WAAW,IACjB,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,QAA8B,EAAE,UAAiC,EAAE;QACxE,IAAI,CAAC,SAAS,CAAC,QAAQ,kCAClB,OAAO,KACV,IAAI,EAAE,YAAY,IAClB,CAAA;IACJ,CAAC;IAES,MAAM,CACd,IAAO,EACP,IAAyB;QAEzB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAChC,CAAC;CACF"} |
| import { Export } from './index'; | ||
| declare module '@antv/x6/lib/graph/graph' { | ||
| interface Graph { | ||
| exportPNG: (fileName?: string, options?: Export.ToImageOptions) => void; | ||
| exportJPEG: (fileName?: string, options?: Export.ToImageOptions) => void; | ||
| exportSVG: (fileName?: string, options?: Export.ToSVGOptions) => void; | ||
| } | ||
| } |
-22
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const x6_1 = require("@antv/x6"); | ||
| x6_1.Graph.prototype.exportPNG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportPNG(fileName, options); | ||
| } | ||
| }; | ||
| x6_1.Graph.prototype.exportJPEG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportJPEG(fileName, options); | ||
| } | ||
| }; | ||
| x6_1.Graph.prototype.exportSVG = function (fileName, options) { | ||
| const instance = this.getPlugin('export'); | ||
| if (instance) { | ||
| instance.exportSVG(fileName, options); | ||
| } | ||
| }; | ||
| //# sourceMappingURL=api.js.map |
| {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAWhC,UAAK,CAAC,SAAS,CAAC,SAAS,GAAG,UAC1B,QAAiB,EACjB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACtC;AACH,CAAC,CAAA;AAED,UAAK,CAAC,SAAS,CAAC,UAAU,GAAG,UAC3B,QAAiB,EACjB,OAA+B;IAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACvC;AACH,CAAC,CAAA;AAED,UAAK,CAAC,SAAS,CAAC,SAAS,GAAG,UAC1B,QAAiB,EACjB,OAA6B;IAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAW,CAAA;IACnD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACtC;AACH,CAAC,CAAA"} |
| import { NumberExt, Rectangle, Size, Basecoat, Graph } from '@antv/x6'; | ||
| import './api'; | ||
| export declare class Export extends Basecoat<Export.EventArgs> { | ||
| private graph; | ||
| name: string; | ||
| constructor(); | ||
| init(graph: Graph): void; | ||
| get view(): Graph.View; | ||
| exportPNG(fileName?: string, options?: Export.ToImageOptions): void; | ||
| exportJPEG(fileName?: string, options?: Export.ToImageOptions): void; | ||
| exportSVG(fileName?: string, options?: Export.ToSVGOptions): void; | ||
| toSVG(callback: Export.ToSVGCallback, options?: Export.ToSVGOptions): void; | ||
| toDataURL(callback: Export.ToSVGCallback, options: Export.ToDataURLOptions): void; | ||
| toPNG(callback: Export.ToSVGCallback, options?: Export.ToImageOptions): void; | ||
| toJPEG(callback: Export.ToSVGCallback, options?: Export.ToImageOptions): void; | ||
| protected notify<K extends keyof Export.EventArgs>(name: K, args: Export.EventArgs[K]): void; | ||
| } | ||
| export declare namespace Export { | ||
| interface EventArgs { | ||
| 'before:export': Export.ToSVGOptions; | ||
| 'after:export': Export.ToSVGOptions; | ||
| } | ||
| type ToSVGCallback = (dataUri: string) => any; | ||
| interface ToSVGOptions { | ||
| /** | ||
| * By default, the resulting SVG has set width and height to `100%`. | ||
| * If you'd like to have the dimensions to be set to the actual content | ||
| * width and height, set `preserveDimensions` to `true`. An object with | ||
| * `width` and `height` properties can be also used here if you need to | ||
| * define the export size explicitely. | ||
| */ | ||
| preserveDimensions?: boolean | Size; | ||
| viewBox?: Rectangle.RectangleLike; | ||
| /** | ||
| * When set to `true` all the styles from external stylesheets are copied | ||
| * to the resulting SVG export. Note this requires a lot of computations | ||
| * and it might significantly affect the export time. | ||
| */ | ||
| copyStyles?: boolean; | ||
| stylesheet?: string; | ||
| /** | ||
| * Converts all contained images into Data URI format. | ||
| */ | ||
| serializeImages?: boolean; | ||
| /** | ||
| * A function called before the XML serialization. It may be used to | ||
| * modify the exported SVG before it is converted to a string. The | ||
| * function can also return a new SVGDocument. | ||
| */ | ||
| beforeSerialize?: (this: Graph, svg: SVGSVGElement) => any; | ||
| } | ||
| interface ToImageOptions extends ToSVGOptions { | ||
| /** | ||
| * The width of the image in pixels. | ||
| */ | ||
| width?: number; | ||
| /** | ||
| * The height of the image in pixels. | ||
| */ | ||
| height?: number; | ||
| ratio?: string; | ||
| backgroundColor?: string; | ||
| padding?: NumberExt.SideOptions; | ||
| quality?: number; | ||
| } | ||
| interface ToDataURLOptions extends ToImageOptions { | ||
| type: 'image/png' | 'image/jpeg'; | ||
| } | ||
| } |
-238
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Export = void 0; | ||
| const x6_1 = require("@antv/x6"); | ||
| require("./api"); | ||
| class Export extends x6_1.Basecoat { | ||
| constructor() { | ||
| super(); | ||
| this.name = 'export'; | ||
| } | ||
| init(graph) { | ||
| this.graph = graph; | ||
| } | ||
| get view() { | ||
| return this.graph.view; | ||
| } | ||
| exportPNG(fileName = 'chart', options = {}) { | ||
| this.toPNG((dataUri) => { | ||
| x6_1.DataUri.downloadDataUri(dataUri, fileName); | ||
| }, options); | ||
| } | ||
| exportJPEG(fileName = 'chart', options = {}) { | ||
| this.toPNG((dataUri) => { | ||
| x6_1.DataUri.downloadDataUri(dataUri, fileName); | ||
| }, options); | ||
| } | ||
| exportSVG(fileName = 'chart', options = {}) { | ||
| this.toSVG((svg) => { | ||
| x6_1.DataUri.downloadDataUri(x6_1.DataUri.svgToDataUrl(svg), fileName); | ||
| }, options); | ||
| } | ||
| toSVG(callback, options = {}) { | ||
| this.notify('before:export', options); | ||
| const rawSVG = this.view.svg; | ||
| const vSVG = x6_1.Vector.create(rawSVG).clone(); | ||
| let clonedSVG = vSVG.node; | ||
| const vStage = vSVG.findOne(`.${this.view.prefixClassName('graph-svg-stage')}`); | ||
| const viewBox = options.viewBox || this.graph.graphToLocal(this.graph.getContentBBox()); | ||
| const dimension = options.preserveDimensions; | ||
| if (dimension) { | ||
| const size = typeof dimension === 'boolean' ? viewBox : dimension; | ||
| vSVG.attr({ | ||
| width: size.width, | ||
| height: size.height, | ||
| }); | ||
| } | ||
| vSVG | ||
| .removeAttribute('style') | ||
| .attr('viewBox', [viewBox.x, viewBox.y, viewBox.width, viewBox.height].join(' ')); | ||
| vStage.removeAttribute('transform'); | ||
| // Stores all the CSS declarations from external stylesheets to the | ||
| // `style` attribute of the SVG document nodes. | ||
| // This is achieved in three steps. | ||
| // ----------------------------------- | ||
| // 1. Disabling all the stylesheets in the page and therefore collecting | ||
| // only default style values. This, together with the step 2, makes it | ||
| // possible to discard default CSS property values and store only those | ||
| // that differ. | ||
| // | ||
| // 2. Enabling back all the stylesheets in the page and collecting styles | ||
| // that differ from the default values. | ||
| // | ||
| // 3. Applying the difference between default values and the ones set by | ||
| // custom stylesheets onto the `style` attribute of each of the nodes | ||
| // in SVG. | ||
| if (options.copyStyles !== false) { | ||
| const document = rawSVG.ownerDocument; | ||
| const raws = Array.from(rawSVG.querySelectorAll('*')); | ||
| const clones = Array.from(clonedSVG.querySelectorAll('*')); | ||
| const styleSheetCount = document.styleSheets.length; | ||
| const styleSheetsCopy = []; | ||
| for (let k = styleSheetCount - 1; k >= 0; k -= 1) { | ||
| // There is a bug (bugSS) in Chrome 14 and Safari. When you set | ||
| // `stylesheet.disable = true` it will also remove it from | ||
| // `document.styleSheets`. So we need to store all stylesheets before | ||
| // we disable them. Later on we put them back to `document.styleSheets` | ||
| // if needed. | ||
| // See the bug `https://code.google.com/p/chromium/issues/detail?id=88310`. | ||
| styleSheetsCopy[k] = document.styleSheets[k]; | ||
| document.styleSheets[k].disabled = true; | ||
| } | ||
| const defaultComputedStyles = {}; | ||
| raws.forEach((elem, index) => { | ||
| const computedStyle = window.getComputedStyle(elem, null); | ||
| // We're making a deep copy of the `computedStyle` so that it's not affected | ||
| // by that next step when all the stylesheets are re-enabled again. | ||
| const defaultComputedStyle = {}; | ||
| Object.keys(computedStyle).forEach((property) => { | ||
| defaultComputedStyle[property] = | ||
| computedStyle.getPropertyValue(property); | ||
| }); | ||
| defaultComputedStyles[index] = defaultComputedStyle; | ||
| }); | ||
| // Copy all stylesheets back | ||
| if (styleSheetCount !== document.styleSheets.length) { | ||
| styleSheetsCopy.forEach((copy, index) => { | ||
| document.styleSheets[index] = copy; | ||
| }); | ||
| } | ||
| for (let i = 0; i < styleSheetCount; i += 1) { | ||
| document.styleSheets[i].disabled = false; | ||
| } | ||
| const customStyles = {}; | ||
| raws.forEach((elem, index) => { | ||
| const computedStyle = window.getComputedStyle(elem, null); | ||
| const defaultComputedStyle = defaultComputedStyles[index]; | ||
| const customStyle = {}; | ||
| Object.keys(computedStyle).forEach((property) => { | ||
| if (!x6_1.NumberExt.isNumber(property) && | ||
| computedStyle.getPropertyValue(property) !== | ||
| defaultComputedStyle[property]) { | ||
| customStyle[property] = computedStyle.getPropertyValue(property); | ||
| } | ||
| }); | ||
| customStyles[index] = customStyle; | ||
| }); | ||
| clones.forEach((elem, index) => { | ||
| x6_1.Dom.css(elem, customStyles[index]); | ||
| }); | ||
| } | ||
| const stylesheet = options.stylesheet; | ||
| if (typeof stylesheet === 'string') { | ||
| const cDATASection = rawSVG | ||
| .ownerDocument.implementation.createDocument(null, 'xml', null) | ||
| .createCDATASection(stylesheet); | ||
| vSVG.prepend(x6_1.Vector.create('style', { | ||
| type: 'text/css', | ||
| }, [cDATASection])); | ||
| } | ||
| const format = () => { | ||
| const beforeSerialize = options.beforeSerialize; | ||
| if (typeof beforeSerialize === 'function') { | ||
| const ret = x6_1.FunctionExt.call(beforeSerialize, this.graph, clonedSVG); | ||
| if (ret instanceof SVGSVGElement) { | ||
| clonedSVG = ret; | ||
| } | ||
| } | ||
| const dataUri = new XMLSerializer() | ||
| .serializeToString(clonedSVG) | ||
| .replace(/ /g, '\u00a0'); | ||
| this.notify('after:export', options); | ||
| callback(dataUri); | ||
| }; | ||
| if (options.serializeImages) { | ||
| const deferrals = vSVG.find('image').map((vImage) => { | ||
| return new Promise((resolve) => { | ||
| const url = vImage.attr('xlink:href') || vImage.attr('href'); | ||
| x6_1.DataUri.imageToDataUri(url, (err, dataUri) => { | ||
| if (!err && dataUri) { | ||
| vImage.attr('xlink:href', dataUri); | ||
| } | ||
| resolve(); | ||
| }); | ||
| }); | ||
| }); | ||
| Promise.all(deferrals).then(format); | ||
| } | ||
| else { | ||
| format(); | ||
| } | ||
| } | ||
| toDataURL(callback, options) { | ||
| let viewBox = options.viewBox || this.graph.getContentBBox(); | ||
| const padding = x6_1.NumberExt.normalizeSides(options.padding); | ||
| if (options.width && options.height) { | ||
| if (padding.left + padding.right >= options.width) { | ||
| padding.left = padding.right = 0; | ||
| } | ||
| if (padding.top + padding.bottom >= options.height) { | ||
| padding.top = padding.bottom = 0; | ||
| } | ||
| } | ||
| const expanding = new x6_1.Rectangle(-padding.left, -padding.top, padding.left + padding.right, padding.top + padding.bottom); | ||
| if (options.width && options.height) { | ||
| const width = viewBox.width + padding.left + padding.right; | ||
| const height = viewBox.height + padding.top + padding.bottom; | ||
| expanding.scale(width / options.width, height / options.height); | ||
| } | ||
| viewBox = x6_1.Rectangle.create(viewBox).moveAndExpand(expanding); | ||
| const rawSize = typeof options.width === 'number' && typeof options.height === 'number' | ||
| ? { width: options.width, height: options.height } | ||
| : viewBox; | ||
| let scale = options.ratio ? parseFloat(options.ratio) : 1; | ||
| if (!Number.isFinite(scale) || scale === 0) { | ||
| scale = 1; | ||
| } | ||
| const size = { | ||
| width: Math.max(Math.round(rawSize.width * scale), 1), | ||
| height: Math.max(Math.round(rawSize.height * scale), 1), | ||
| }; | ||
| { | ||
| const imgDataCanvas = document.createElement('canvas'); | ||
| const context2D = imgDataCanvas.getContext('2d'); | ||
| imgDataCanvas.width = size.width; | ||
| imgDataCanvas.height = size.height; | ||
| const x = size.width - 1; | ||
| const y = size.height - 1; | ||
| context2D.fillStyle = 'rgb(1,1,1)'; | ||
| context2D.fillRect(x, y, 1, 1); | ||
| const data = context2D.getImageData(x, y, 1, 1).data; | ||
| if (data[0] !== 1 || data[1] !== 1 || data[2] !== 1) { | ||
| throw new Error('size exceeded'); | ||
| } | ||
| } | ||
| const img = new Image(); | ||
| img.onload = () => { | ||
| const canvas = document.createElement('canvas'); | ||
| canvas.width = size.width; | ||
| canvas.height = size.height; | ||
| const context = canvas.getContext('2d'); | ||
| context.fillStyle = options.backgroundColor || 'white'; | ||
| context.fillRect(0, 0, size.width, size.height); | ||
| try { | ||
| context.drawImage(img, 0, 0, size.width, size.height); | ||
| const dataUri = canvas.toDataURL(options.type, options.quality); | ||
| callback(dataUri); | ||
| } | ||
| catch (error) { | ||
| // pass | ||
| } | ||
| }; | ||
| this.toSVG((dataUri) => { | ||
| img.src = `data:image/svg+xml,${encodeURIComponent(dataUri)}`; | ||
| }, Object.assign(Object.assign({}, options), { viewBox, serializeImages: true, preserveDimensions: Object.assign({}, size) })); | ||
| } | ||
| toPNG(callback, options = {}) { | ||
| this.toDataURL(callback, Object.assign(Object.assign({}, options), { type: 'image/png' })); | ||
| } | ||
| toJPEG(callback, options = {}) { | ||
| this.toDataURL(callback, Object.assign(Object.assign({}, options), { type: 'image/jpeg' })); | ||
| } | ||
| notify(name, args) { | ||
| this.trigger(name, args); | ||
| this.graph.trigger(name, args); | ||
| } | ||
| } | ||
| exports.Export = Export; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAWiB;AACjB,iBAAc;AAEd,MAAa,MAAO,SAAQ,aAA0B;IAIpD;QACE,KAAK,EAAE,CAAA;QAHF,SAAI,GAAG,QAAQ,CAAA;IAItB,CAAC;IAED,IAAI,CAAC,KAAY;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,EAAE,UAAiC,EAAE;QAC/D,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YACrB,YAAO,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC;IAED,UAAU,CAAC,QAAQ,GAAG,OAAO,EAAE,UAAiC,EAAE;QAChE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YACrB,YAAO,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5C,CAAC,EAAE,OAAO,CAAC,CAAA;IACb,CAAC;IAED,SAAS,CAAC,QAAQ,GAAG,OAAO,EAAE,UAA+B,EAAE;QAC7D,IAAI,CAAC,KAAK,CAAC,CAAC,GAAW,EAAE,EAAE;YACzB,YAAO,CAAC,eAAe,CAAC,YAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;QAC9D,CAAC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AC,IAAI,EAAE,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAChC,CAAC;CACF;AA5TD,wBA4TC"} |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
-100%2437
-96.9%3
-82.35%0
-100%1
Infinity%3
Infinity%