@antv/g-svg 1.8.60 → 1.9.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ContextRegisterPlugin.d.ts +6 -7
- package/dist/SVGContextService.d.ts +19 -20
- package/dist/index.d.ts +15 -16
- package/dist/index.esm.js +176 -595
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +191 -613
- package/dist/index.js.map +1 -0
- package/dist/index.umd.min.js +2 -1
- package/dist/index.umd.min.js.map +1 -0
- package/package.json +17 -13
- package/dist/ContextRegisterPlugin.d.ts.map +0 -1
- package/dist/SVGContextService.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -3271
package/dist/index.js
CHANGED
|
@@ -1,648 +1,226 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var tslib = require('tslib');
|
|
5
4
|
var gLite = require('@antv/g-lite');
|
|
6
5
|
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
7
6
|
var SVGPicker = require('@antv/g-plugin-svg-picker');
|
|
8
7
|
var SVGRenderer = require('@antv/g-plugin-svg-renderer');
|
|
9
8
|
var util = require('@antv/util');
|
|
10
9
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
10
|
+
function _interopNamespaceDefault(e) {
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
23
21
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
n['default'] = e;
|
|
28
|
-
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
var DomInteraction__namespace = /*#__PURE__*/
|
|
32
|
-
var SVGPicker__namespace = /*#__PURE__*/
|
|
33
|
-
var SVGRenderer__namespace = /*#__PURE__*/
|
|
27
|
+
var DomInteraction__namespace = /*#__PURE__*/_interopNamespaceDefault(DomInteraction);
|
|
28
|
+
var SVGPicker__namespace = /*#__PURE__*/_interopNamespaceDefault(SVGPicker);
|
|
29
|
+
var SVGRenderer__namespace = /*#__PURE__*/_interopNamespaceDefault(SVGRenderer);
|
|
34
30
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var exports = {},
|
|
40
|
-
Op = Object.prototype,
|
|
41
|
-
hasOwn = Op.hasOwnProperty,
|
|
42
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
43
|
-
obj[key] = desc.value;
|
|
44
|
-
},
|
|
45
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
46
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
47
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
48
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
49
|
-
function define(obj, key, value) {
|
|
50
|
-
return Object.defineProperty(obj, key, {
|
|
51
|
-
value: value,
|
|
52
|
-
enumerable: !0,
|
|
53
|
-
configurable: !0,
|
|
54
|
-
writable: !0
|
|
55
|
-
}), obj[key];
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
define({}, "");
|
|
59
|
-
} catch (err) {
|
|
60
|
-
define = function (obj, key, value) {
|
|
61
|
-
return obj[key] = value;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
65
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
66
|
-
generator = Object.create(protoGenerator.prototype),
|
|
67
|
-
context = new Context(tryLocsList || []);
|
|
68
|
-
return defineProperty(generator, "_invoke", {
|
|
69
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
70
|
-
}), generator;
|
|
71
|
-
}
|
|
72
|
-
function tryCatch(fn, obj, arg) {
|
|
73
|
-
try {
|
|
74
|
-
return {
|
|
75
|
-
type: "normal",
|
|
76
|
-
arg: fn.call(obj, arg)
|
|
77
|
-
};
|
|
78
|
-
} catch (err) {
|
|
79
|
-
return {
|
|
80
|
-
type: "throw",
|
|
81
|
-
arg: err
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.wrap = wrap;
|
|
86
|
-
var ContinueSentinel = {};
|
|
87
|
-
function Generator() {}
|
|
88
|
-
function GeneratorFunction() {}
|
|
89
|
-
function GeneratorFunctionPrototype() {}
|
|
90
|
-
var IteratorPrototype = {};
|
|
91
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
92
|
-
return this;
|
|
93
|
-
});
|
|
94
|
-
var getProto = Object.getPrototypeOf,
|
|
95
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
96
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
97
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
98
|
-
function defineIteratorMethods(prototype) {
|
|
99
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
100
|
-
define(prototype, method, function (arg) {
|
|
101
|
-
return this._invoke(method, arg);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
106
|
-
function invoke(method, arg, resolve, reject) {
|
|
107
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
108
|
-
if ("throw" !== record.type) {
|
|
109
|
-
var result = record.arg,
|
|
110
|
-
value = result.value;
|
|
111
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
112
|
-
invoke("next", value, resolve, reject);
|
|
113
|
-
}, function (err) {
|
|
114
|
-
invoke("throw", err, resolve, reject);
|
|
115
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
116
|
-
result.value = unwrapped, resolve(result);
|
|
117
|
-
}, function (error) {
|
|
118
|
-
return invoke("throw", error, resolve, reject);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
reject(record.arg);
|
|
31
|
+
var SVGContextService = /** @class */ (function () {
|
|
32
|
+
function SVGContextService(context) {
|
|
33
|
+
this.context = context;
|
|
34
|
+
this.canvasConfig = context.config;
|
|
122
35
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
139
|
-
if ("completed" === state) {
|
|
140
|
-
if ("throw" === method) throw arg;
|
|
141
|
-
return doneResult();
|
|
142
|
-
}
|
|
143
|
-
for (context.method = method, context.arg = arg;;) {
|
|
144
|
-
var delegate = context.delegate;
|
|
145
|
-
if (delegate) {
|
|
146
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
147
|
-
if (delegateResult) {
|
|
148
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
149
|
-
return delegateResult;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
153
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
154
|
-
context.dispatchException(context.arg);
|
|
155
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
156
|
-
state = "executing";
|
|
157
|
-
var record = tryCatch(innerFn, self, context);
|
|
158
|
-
if ("normal" === record.type) {
|
|
159
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
160
|
-
return {
|
|
161
|
-
value: record.arg,
|
|
162
|
-
done: context.done
|
|
163
|
-
};
|
|
36
|
+
SVGContextService.prototype.init = function () {
|
|
37
|
+
var _a = this.canvasConfig, container = _a.container, doc = _a.document, devicePixelRatio = _a.devicePixelRatio;
|
|
38
|
+
// create container
|
|
39
|
+
this.$container = util.isString(container)
|
|
40
|
+
? (doc || document).getElementById(container)
|
|
41
|
+
: container;
|
|
42
|
+
if (this.$container) {
|
|
43
|
+
if (!this.$container.style.position) {
|
|
44
|
+
this.$container.style.position = 'relative';
|
|
45
|
+
}
|
|
46
|
+
var $namespace = SVGRenderer.createSVGElement('svg', doc);
|
|
47
|
+
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
48
|
+
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
49
|
+
this.$container.appendChild($namespace);
|
|
50
|
+
this.$namespace = $namespace;
|
|
164
51
|
}
|
|
165
|
-
|
|
166
|
-
|
|
52
|
+
// use user-defined dpr first
|
|
53
|
+
var dpr = devicePixelRatio || (gLite.isBrowser && window.devicePixelRatio) || 1;
|
|
54
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
55
|
+
this.dpr = dpr;
|
|
167
56
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
method = delegate.iterator[methodName];
|
|
172
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
173
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
174
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
175
|
-
var info = record.arg;
|
|
176
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
177
|
-
}
|
|
178
|
-
function pushTryEntry(locs) {
|
|
179
|
-
var entry = {
|
|
180
|
-
tryLoc: locs[0]
|
|
181
|
-
};
|
|
182
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
183
|
-
}
|
|
184
|
-
function resetTryEntry(entry) {
|
|
185
|
-
var record = entry.completion || {};
|
|
186
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
187
|
-
}
|
|
188
|
-
function Context(tryLocsList) {
|
|
189
|
-
this.tryEntries = [{
|
|
190
|
-
tryLoc: "root"
|
|
191
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
192
|
-
}
|
|
193
|
-
function values(iterable) {
|
|
194
|
-
if (iterable) {
|
|
195
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
196
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
197
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
198
|
-
if (!isNaN(iterable.length)) {
|
|
199
|
-
var i = -1,
|
|
200
|
-
next = function next() {
|
|
201
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
202
|
-
return next.value = undefined, next.done = !0, next;
|
|
203
|
-
};
|
|
204
|
-
return next.next = next;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return {
|
|
208
|
-
next: doneResult
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
SVGContextService.prototype.getDomElement = function () {
|
|
59
|
+
return this.$namespace;
|
|
209
60
|
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return {
|
|
213
|
-
value: undefined,
|
|
214
|
-
done: !0
|
|
61
|
+
SVGContextService.prototype.getContext = function () {
|
|
62
|
+
return this.$namespace;
|
|
215
63
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
value: GeneratorFunctionPrototype,
|
|
219
|
-
configurable: !0
|
|
220
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
221
|
-
value: GeneratorFunction,
|
|
222
|
-
configurable: !0
|
|
223
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
224
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
225
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
226
|
-
}, exports.mark = function (genFun) {
|
|
227
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
228
|
-
}, exports.awrap = function (arg) {
|
|
229
|
-
return {
|
|
230
|
-
__await: arg
|
|
64
|
+
SVGContextService.prototype.getDPR = function () {
|
|
65
|
+
return this.dpr;
|
|
231
66
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
236
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
237
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
238
|
-
return result.done ? result.value : iter.next();
|
|
239
|
-
});
|
|
240
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
241
|
-
return this;
|
|
242
|
-
}), define(Gp, "toString", function () {
|
|
243
|
-
return "[object Generator]";
|
|
244
|
-
}), exports.keys = function (val) {
|
|
245
|
-
var object = Object(val),
|
|
246
|
-
keys = [];
|
|
247
|
-
for (var key in object) keys.push(key);
|
|
248
|
-
return keys.reverse(), function next() {
|
|
249
|
-
for (; keys.length;) {
|
|
250
|
-
var key = keys.pop();
|
|
251
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
252
|
-
}
|
|
253
|
-
return next.done = !0, next;
|
|
67
|
+
SVGContextService.prototype.getBoundingClientRect = function () {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
254
70
|
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
stop: function () {
|
|
261
|
-
this.done = !0;
|
|
262
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
263
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
264
|
-
return this.rval;
|
|
265
|
-
},
|
|
266
|
-
dispatchException: function (exception) {
|
|
267
|
-
if (this.done) throw exception;
|
|
268
|
-
var context = this;
|
|
269
|
-
function handle(loc, caught) {
|
|
270
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
271
|
-
}
|
|
272
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
273
|
-
var entry = this.tryEntries[i],
|
|
274
|
-
record = entry.completion;
|
|
275
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
276
|
-
if (entry.tryLoc <= this.prev) {
|
|
277
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
278
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
279
|
-
if (hasCatch && hasFinally) {
|
|
280
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
281
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
282
|
-
} else if (hasCatch) {
|
|
283
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
284
|
-
} else {
|
|
285
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
286
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
287
|
-
}
|
|
71
|
+
SVGContextService.prototype.destroy = function () {
|
|
72
|
+
// destroy context
|
|
73
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
74
|
+
this.$container.removeChild(this.$namespace);
|
|
288
75
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var finallyEntry = entry;
|
|
296
|
-
break;
|
|
76
|
+
};
|
|
77
|
+
SVGContextService.prototype.resize = function (width, height) {
|
|
78
|
+
// SVG should ignore DPR
|
|
79
|
+
if (this.$namespace) {
|
|
80
|
+
this.$namespace.setAttribute('width', "".concat(width));
|
|
81
|
+
this.$namespace.setAttribute('height', "".concat(height));
|
|
297
82
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
},
|
|
303
|
-
complete: function (record, afterLoc) {
|
|
304
|
-
if ("throw" === record.type) throw record.arg;
|
|
305
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
306
|
-
},
|
|
307
|
-
finish: function (finallyLoc) {
|
|
308
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
309
|
-
var entry = this.tryEntries[i];
|
|
310
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
catch: function (tryLoc) {
|
|
314
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
315
|
-
var entry = this.tryEntries[i];
|
|
316
|
-
if (entry.tryLoc === tryLoc) {
|
|
317
|
-
var record = entry.completion;
|
|
318
|
-
if ("throw" === record.type) {
|
|
319
|
-
var thrown = record.arg;
|
|
320
|
-
resetTryEntry(entry);
|
|
321
|
-
}
|
|
322
|
-
return thrown;
|
|
83
|
+
};
|
|
84
|
+
SVGContextService.prototype.applyCursorStyle = function (cursor) {
|
|
85
|
+
if (this.$container) {
|
|
86
|
+
this.$container.style.cursor = cursor;
|
|
323
87
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
// create container
|
|
412
|
-
this.$container = util.isString(container) ? (doc || document).getElementById(container) : container;
|
|
413
|
-
if (this.$container) {
|
|
414
|
-
if (!this.$container.style.position) {
|
|
415
|
-
this.$container.style.position = 'relative';
|
|
416
|
-
}
|
|
417
|
-
var $namespace = SVGRenderer.createSVGElement('svg', doc);
|
|
418
|
-
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
419
|
-
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
420
|
-
this.$container.appendChild($namespace);
|
|
421
|
-
this.$namespace = $namespace;
|
|
422
|
-
}
|
|
423
|
-
// use user-defined dpr first
|
|
424
|
-
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
425
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
426
|
-
this.dpr = dpr;
|
|
427
|
-
}
|
|
428
|
-
// @ts-ignore
|
|
429
|
-
;
|
|
430
|
-
_proto.getDomElement = function getDomElement() {
|
|
431
|
-
return this.$namespace;
|
|
432
|
-
};
|
|
433
|
-
_proto.getContext = function getContext() {
|
|
434
|
-
return this.$namespace;
|
|
435
|
-
};
|
|
436
|
-
_proto.getDPR = function getDPR() {
|
|
437
|
-
return this.dpr;
|
|
438
|
-
};
|
|
439
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
440
|
-
var _this$$namespace;
|
|
441
|
-
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
442
|
-
};
|
|
443
|
-
_proto.destroy = function destroy() {
|
|
444
|
-
// destroy context
|
|
445
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
446
|
-
this.$container.removeChild(this.$namespace);
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
_proto.resize = function resize(width, height) {
|
|
450
|
-
// SVG should ignore DPR
|
|
451
|
-
if (this.$namespace) {
|
|
452
|
-
this.$namespace.setAttribute('width', "" + width);
|
|
453
|
-
this.$namespace.setAttribute('height', "" + height);
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
457
|
-
if (this.$container) {
|
|
458
|
-
this.$container.style.cursor = cursor;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
_proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
|
|
462
|
-
if (prefixes === void 0) {
|
|
463
|
-
prefixes = {};
|
|
464
|
-
}
|
|
465
|
-
var duration = timing.duration,
|
|
466
|
-
easing = timing.easing,
|
|
467
|
-
delay = timing.delay,
|
|
468
|
-
direction = timing.direction,
|
|
469
|
-
iterations = timing.iterations,
|
|
470
|
-
fill = timing.fill;
|
|
471
|
-
return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
|
|
472
|
-
var offset = keyframe.offset,
|
|
473
|
-
composite = keyframe.composite,
|
|
474
|
-
computedOffset = keyframe.computedOffset,
|
|
475
|
-
easing = keyframe.easing,
|
|
476
|
-
rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
|
|
477
|
-
var rules = Object.keys(rest).map(function (attributeName) {
|
|
478
|
-
return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
|
|
479
|
-
}).join('');
|
|
480
|
-
return computedOffset * 100 + "%{" + rules + "}";
|
|
481
|
-
}).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
|
|
482
|
-
};
|
|
483
|
-
_proto.toDataURL = /*#__PURE__*/function () {
|
|
484
|
-
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
485
|
-
var _this = this;
|
|
486
|
-
var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
|
|
487
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
488
|
-
while (1) switch (_context.prev = _context.next) {
|
|
489
|
-
case 0:
|
|
490
|
-
cloneNode = this.$namespace.cloneNode(true);
|
|
491
|
-
doc = this.canvasConfig.document;
|
|
492
|
-
animationCounter = 0;
|
|
493
|
-
$style = null;
|
|
494
|
-
this.context.renderingContext.root.forEach(function (object) {
|
|
495
|
-
var animations = object.getAnimations();
|
|
496
|
-
if (animations.length) {
|
|
497
|
-
if (!$style) {
|
|
498
|
-
// export animations to <style>, using CSS Transformation
|
|
499
|
-
$style = (doc || document).createElement('style');
|
|
500
|
-
cloneNode.appendChild($style);
|
|
501
|
-
}
|
|
502
|
-
// @ts-ignore
|
|
503
|
-
var svgElement = object.elementSVG;
|
|
504
|
-
var selfSelector = "#" + svgElement.$el.id;
|
|
505
|
-
var groupSelector = "#" + svgElement.$groupEl.id;
|
|
506
|
-
var selfCssText = '';
|
|
507
|
-
var groupCssText = '';
|
|
508
|
-
animations.forEach(function (animation) {
|
|
509
|
-
var keyframes = animation.effect.getKeyframes();
|
|
510
|
-
// split attributes into self and group
|
|
511
|
-
if (keyframes.length) {
|
|
512
|
-
var selfAttributes = [];
|
|
513
|
-
var groupAttributes = [];
|
|
514
|
-
var _keyframes$ = keyframes[0],
|
|
515
|
-
offset = _keyframes$.offset,
|
|
516
|
-
composite = _keyframes$.composite,
|
|
517
|
-
computedOffset = _keyframes$.computedOffset,
|
|
518
|
-
easing = _keyframes$.easing,
|
|
519
|
-
transformOrigin = _keyframes$.transformOrigin,
|
|
520
|
-
rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
|
|
521
|
-
Object.keys(rest).forEach(function (attributeName) {
|
|
522
|
-
var _propertyMetadataCach;
|
|
523
|
-
if (attributeName === 'transform') {
|
|
524
|
-
groupAttributes.push(attributeName);
|
|
525
|
-
}
|
|
526
|
-
var inherited = !!((_propertyMetadataCach = gLite.propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
527
|
-
if (inherited) {
|
|
528
|
-
groupAttributes.push(attributeName);
|
|
529
|
-
} else if (attributeName !== 'transform') {
|
|
530
|
-
selfAttributes.push(attributeName);
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
if (groupAttributes.length) {
|
|
534
|
-
var keyframesWithGroup = keyframes.map(function (keyframe) {
|
|
535
|
-
var offset = keyframe.offset,
|
|
536
|
-
composite = keyframe.composite,
|
|
537
|
-
computedOffset = keyframe.computedOffset,
|
|
538
|
-
easing = keyframe.easing,
|
|
539
|
-
transformOrigin = keyframe.transformOrigin,
|
|
540
|
-
rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
|
|
541
|
-
var ret = {
|
|
542
|
-
offset: offset,
|
|
543
|
-
composite: composite,
|
|
544
|
-
computedOffset: computedOffset,
|
|
545
|
-
easing: easing
|
|
546
|
-
};
|
|
547
|
-
Object.keys(rest).forEach(function (attributeName) {
|
|
548
|
-
if (groupAttributes.includes(attributeName)) {
|
|
549
|
-
ret[attributeName] = keyframe[attributeName];
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
return ret;
|
|
553
|
-
});
|
|
554
|
-
groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
|
|
555
|
-
transform: svgElement.$groupEl.getAttribute('transform')
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
if (selfAttributes.length) {
|
|
559
|
-
var keyframesWithSelf = keyframes.map(function (keyframe) {
|
|
560
|
-
var offset = keyframe.offset,
|
|
561
|
-
composite = keyframe.composite,
|
|
562
|
-
computedOffset = keyframe.computedOffset,
|
|
563
|
-
easing = keyframe.easing,
|
|
564
|
-
transformOrigin = keyframe.transformOrigin,
|
|
565
|
-
rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
|
|
566
|
-
var ret = {
|
|
567
|
-
offset: offset,
|
|
568
|
-
composite: composite,
|
|
569
|
-
computedOffset: computedOffset,
|
|
570
|
-
easing: easing
|
|
571
|
-
};
|
|
572
|
-
Object.keys(rest).forEach(function (attributeName) {
|
|
573
|
-
if (selfAttributes.includes(attributeName)) {
|
|
574
|
-
ret[attributeName] = keyframe[attributeName];
|
|
575
|
-
}
|
|
88
|
+
};
|
|
89
|
+
SVGContextService.prototype.generateCSSText = function (animationName, selector, keyframes, timing, prefixes) {
|
|
90
|
+
if (prefixes === void 0) { prefixes = {}; }
|
|
91
|
+
var duration = timing.duration, easing = timing.easing, delay = timing.delay, direction = timing.direction, iterations = timing.iterations, fill = timing.fill;
|
|
92
|
+
return ("@keyframes ".concat(animationName, "{").concat(keyframes
|
|
93
|
+
.map(function (keyframe) {
|
|
94
|
+
keyframe.offset; keyframe.composite; var computedOffset = keyframe.computedOffset; keyframe.easing; var rest = tslib.__rest(keyframe, ["offset", "composite", "computedOffset", "easing"]);
|
|
95
|
+
var rules = Object.keys(rest)
|
|
96
|
+
.map(function (attributeName) {
|
|
97
|
+
return "".concat(attributeName, ":").concat(prefixes[attributeName] || '').concat(rest[attributeName], ";");
|
|
98
|
+
})
|
|
99
|
+
.join('');
|
|
100
|
+
return "".concat(computedOffset * 100, "%{").concat(rules, "}");
|
|
101
|
+
})
|
|
102
|
+
.join(''), "}") +
|
|
103
|
+
"".concat(selector, " {animation: ").concat(animationName, " ").concat(duration, "ms ").concat(easing, " ").concat(delay, "ms ").concat(iterations === Infinity ? 'infinite' : iterations, " ").concat(direction, " ").concat(fill, ";}"));
|
|
104
|
+
};
|
|
105
|
+
SVGContextService.prototype.toDataURL = function (options) {
|
|
106
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
|
|
108
|
+
var _this = this;
|
|
109
|
+
return tslib.__generator(this, function (_a) {
|
|
110
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
111
|
+
doc = this.canvasConfig.document;
|
|
112
|
+
animationCounter = 0;
|
|
113
|
+
$style = null;
|
|
114
|
+
this.context.renderingContext.root.forEach(function (object) {
|
|
115
|
+
var animations = object.getAnimations();
|
|
116
|
+
if (animations.length) {
|
|
117
|
+
if (!$style) {
|
|
118
|
+
// export animations to <style>, using CSS Transformation
|
|
119
|
+
$style = (doc || document).createElement('style');
|
|
120
|
+
cloneNode.appendChild($style);
|
|
121
|
+
}
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
var svgElement_1 = object.elementSVG;
|
|
124
|
+
var selfSelector_1 = "#".concat(svgElement_1.$el.id);
|
|
125
|
+
var groupSelector_1 = "#".concat(svgElement_1.$groupEl.id);
|
|
126
|
+
var selfCssText_1 = '';
|
|
127
|
+
var groupCssText_1 = '';
|
|
128
|
+
animations.forEach(function (animation) {
|
|
129
|
+
var keyframes = animation.effect.getKeyframes();
|
|
130
|
+
// split attributes into self and group
|
|
131
|
+
if (keyframes.length) {
|
|
132
|
+
var selfAttributes_1 = [];
|
|
133
|
+
var groupAttributes_1 = [];
|
|
134
|
+
var _a = keyframes[0]; _a.offset; _a.composite; _a.computedOffset; _a.easing; _a.transformOrigin; var rest = tslib.__rest(_a, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
|
|
135
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
136
|
+
var _a;
|
|
137
|
+
if (attributeName === 'transform') {
|
|
138
|
+
groupAttributes_1.push(attributeName);
|
|
139
|
+
}
|
|
140
|
+
var inherited = !!((_a = gLite.propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.inh);
|
|
141
|
+
if (inherited) {
|
|
142
|
+
groupAttributes_1.push(attributeName);
|
|
143
|
+
}
|
|
144
|
+
else if (attributeName !== 'transform') {
|
|
145
|
+
selfAttributes_1.push(attributeName);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
if (groupAttributes_1.length) {
|
|
149
|
+
var keyframesWithGroup = keyframes.map(function (keyframe) {
|
|
150
|
+
var offset = keyframe.offset, composite = keyframe.composite, computedOffset = keyframe.computedOffset, easing = keyframe.easing; keyframe.transformOrigin; var rest = tslib.__rest(keyframe, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
|
|
151
|
+
var ret = { offset: offset, composite: composite, computedOffset: computedOffset, easing: easing };
|
|
152
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
153
|
+
if (groupAttributes_1.includes(attributeName)) {
|
|
154
|
+
ret[attributeName] = keyframe[attributeName];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return ret;
|
|
158
|
+
});
|
|
159
|
+
groupCssText_1 += _this.generateCSSText("a".concat(animationCounter++), groupSelector_1, keyframesWithGroup, animation.effect.getComputedTiming(), { transform: svgElement_1.$groupEl.getAttribute('transform') });
|
|
160
|
+
}
|
|
161
|
+
if (selfAttributes_1.length) {
|
|
162
|
+
var keyframesWithSelf = keyframes.map(function (keyframe) {
|
|
163
|
+
var offset = keyframe.offset, composite = keyframe.composite, computedOffset = keyframe.computedOffset, easing = keyframe.easing; keyframe.transformOrigin; var rest = tslib.__rest(keyframe, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
|
|
164
|
+
var ret = { offset: offset, composite: composite, computedOffset: computedOffset, easing: easing };
|
|
165
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
166
|
+
if (selfAttributes_1.includes(attributeName)) {
|
|
167
|
+
ret[attributeName] = keyframe[attributeName];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return ret;
|
|
171
|
+
});
|
|
172
|
+
selfCssText_1 += _this.generateCSSText("a".concat(animationCounter++), selfSelector_1, keyframesWithSelf, animation.effect.getComputedTiming());
|
|
173
|
+
}
|
|
174
|
+
}
|
|
576
175
|
});
|
|
577
|
-
|
|
578
|
-
});
|
|
579
|
-
selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
|
|
176
|
+
$style.textContent += selfCssText_1 + groupCssText_1;
|
|
580
177
|
}
|
|
581
|
-
}
|
|
582
178
|
});
|
|
583
|
-
|
|
584
|
-
|
|
179
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
180
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
181
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
182
|
+
return [2 /*return*/, "data:image/svg+xml;charset=utf8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)))];
|
|
585
183
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
case 10:
|
|
591
|
-
case "end":
|
|
592
|
-
return _context.stop();
|
|
593
|
-
}
|
|
594
|
-
}, _callee, this);
|
|
595
|
-
}));
|
|
596
|
-
function toDataURL(_x) {
|
|
597
|
-
return _toDataURL.apply(this, arguments);
|
|
598
|
-
}
|
|
599
|
-
return toDataURL;
|
|
600
|
-
}();
|
|
601
|
-
return SVGContextService;
|
|
602
|
-
}();
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
return SVGContextService;
|
|
187
|
+
}());
|
|
603
188
|
|
|
604
|
-
var ContextRegisterPlugin =
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
189
|
+
var ContextRegisterPlugin = /** @class */ (function (_super) {
|
|
190
|
+
tslib.__extends(ContextRegisterPlugin, _super);
|
|
191
|
+
function ContextRegisterPlugin() {
|
|
192
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
193
|
+
_this.name = 'svg-context-register';
|
|
194
|
+
return _this;
|
|
610
195
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
_proto.destroy = function destroy() {
|
|
621
|
-
delete this.context.ContextService;
|
|
622
|
-
};
|
|
623
|
-
return ContextRegisterPlugin;
|
|
624
|
-
}(gLite.AbstractRendererPlugin);
|
|
196
|
+
ContextRegisterPlugin.prototype.init = function () {
|
|
197
|
+
// @ts-ignore
|
|
198
|
+
this.context.ContextService = SVGContextService;
|
|
199
|
+
};
|
|
200
|
+
ContextRegisterPlugin.prototype.destroy = function () {
|
|
201
|
+
delete this.context.ContextService;
|
|
202
|
+
};
|
|
203
|
+
return ContextRegisterPlugin;
|
|
204
|
+
}(gLite.AbstractRendererPlugin));
|
|
625
205
|
|
|
626
|
-
var Renderer =
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
206
|
+
var Renderer = /** @class */ (function (_super) {
|
|
207
|
+
tslib.__extends(Renderer, _super);
|
|
208
|
+
function Renderer(config) {
|
|
209
|
+
if (config === void 0) { config = {}; }
|
|
210
|
+
var _this = _super.call(this, config) || this;
|
|
211
|
+
_this.registerPlugin(new ContextRegisterPlugin());
|
|
212
|
+
_this.registerPlugin(new SVGRenderer__namespace.Plugin({
|
|
213
|
+
outputSVGElementId: config.outputSVGElementId,
|
|
214
|
+
}));
|
|
215
|
+
_this.registerPlugin(new DomInteraction__namespace.Plugin());
|
|
216
|
+
_this.registerPlugin(new SVGPicker__namespace.Plugin());
|
|
217
|
+
return _this;
|
|
632
218
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
_this.registerPlugin(new SVGRenderer.Plugin({
|
|
636
|
-
outputSVGElementId: config.outputSVGElementId
|
|
637
|
-
}));
|
|
638
|
-
_this.registerPlugin(new DomInteraction.Plugin());
|
|
639
|
-
_this.registerPlugin(new SVGPicker.Plugin());
|
|
640
|
-
return _this;
|
|
641
|
-
}
|
|
642
|
-
return Renderer;
|
|
643
|
-
}(gLite.AbstractRenderer);
|
|
219
|
+
return Renderer;
|
|
220
|
+
}(gLite.AbstractRenderer));
|
|
644
221
|
|
|
645
222
|
exports.DomInteraction = DomInteraction__namespace;
|
|
646
223
|
exports.SVGPicker = SVGPicker__namespace;
|
|
647
224
|
exports.SVGRenderer = SVGRenderer__namespace;
|
|
648
225
|
exports.Renderer = Renderer;
|
|
226
|
+
//# sourceMappingURL=index.js.map
|