@antv/g-svg 1.1.6 → 1.1.8-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/SVGContextService.d.ts +1 -1
- package/dist/SVGContextService.d.ts.map +1 -1
- package/dist/index.esm.js +451 -160
- package/dist/index.js +451 -160
- package/dist/index.umd.js +1566 -1536
- package/dist/index.umd.min.js +6 -4
- package/package.json +6 -5
package/dist/index.umd.js
CHANGED
|
@@ -4,64 +4,392 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.SVG = {}), global.window.G, global.window.G.ManaSyringe));
|
|
5
5
|
}(this, (function (exports, g, manaSyringe) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
14
|
-
}, _typeof(obj);
|
|
15
|
-
}
|
|
7
|
+
function _regeneratorRuntime() {
|
|
8
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
9
|
+
|
|
10
|
+
_regeneratorRuntime = function () {
|
|
11
|
+
return exports;
|
|
12
|
+
};
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
var exports = {},
|
|
15
|
+
Op = Object.prototype,
|
|
16
|
+
hasOwn = Op.hasOwnProperty,
|
|
17
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
18
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
19
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
20
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
21
|
+
|
|
22
|
+
function define(obj, key, value) {
|
|
23
|
+
return Object.defineProperty(obj, key, {
|
|
24
|
+
value: value,
|
|
25
|
+
enumerable: !0,
|
|
26
|
+
configurable: !0,
|
|
27
|
+
writable: !0
|
|
28
|
+
}), obj[key];
|
|
20
29
|
}
|
|
21
|
-
}
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
try {
|
|
32
|
+
define({}, "");
|
|
33
|
+
} catch (err) {
|
|
34
|
+
define = function (obj, key, value) {
|
|
35
|
+
return obj[key] = value;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
40
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
41
|
+
generator = Object.create(protoGenerator.prototype),
|
|
42
|
+
context = new Context(tryLocsList || []);
|
|
43
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
44
|
+
var state = "suspendedStart";
|
|
45
|
+
return function (method, arg) {
|
|
46
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
47
|
+
|
|
48
|
+
if ("completed" === state) {
|
|
49
|
+
if ("throw" === method) throw arg;
|
|
50
|
+
return doneResult();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (context.method = method, context.arg = arg;;) {
|
|
54
|
+
var delegate = context.delegate;
|
|
55
|
+
|
|
56
|
+
if (delegate) {
|
|
57
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
58
|
+
|
|
59
|
+
if (delegateResult) {
|
|
60
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
61
|
+
return delegateResult;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
66
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
67
|
+
context.dispatchException(context.arg);
|
|
68
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
69
|
+
state = "executing";
|
|
70
|
+
var record = tryCatch(innerFn, self, context);
|
|
71
|
+
|
|
72
|
+
if ("normal" === record.type) {
|
|
73
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
74
|
+
return {
|
|
75
|
+
value: record.arg,
|
|
76
|
+
done: context.done
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}(innerFn, self, context), generator;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function tryCatch(fn, obj, arg) {
|
|
87
|
+
try {
|
|
88
|
+
return {
|
|
89
|
+
type: "normal",
|
|
90
|
+
arg: fn.call(obj, arg)
|
|
91
|
+
};
|
|
92
|
+
} catch (err) {
|
|
93
|
+
return {
|
|
94
|
+
type: "throw",
|
|
95
|
+
arg: err
|
|
96
|
+
};
|
|
97
|
+
}
|
|
30
98
|
}
|
|
31
|
-
}
|
|
32
99
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
100
|
+
exports.wrap = wrap;
|
|
101
|
+
var ContinueSentinel = {};
|
|
102
|
+
|
|
103
|
+
function Generator() {}
|
|
104
|
+
|
|
105
|
+
function GeneratorFunction() {}
|
|
106
|
+
|
|
107
|
+
function GeneratorFunctionPrototype() {}
|
|
108
|
+
|
|
109
|
+
var IteratorPrototype = {};
|
|
110
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
111
|
+
return this;
|
|
38
112
|
});
|
|
39
|
-
|
|
113
|
+
var getProto = Object.getPrototypeOf,
|
|
114
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
115
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
116
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
117
|
+
|
|
118
|
+
function defineIteratorMethods(prototype) {
|
|
119
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
120
|
+
define(prototype, method, function (arg) {
|
|
121
|
+
return this._invoke(method, arg);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
127
|
+
function invoke(method, arg, resolve, reject) {
|
|
128
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
129
|
+
|
|
130
|
+
if ("throw" !== record.type) {
|
|
131
|
+
var result = record.arg,
|
|
132
|
+
value = result.value;
|
|
133
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
134
|
+
invoke("next", value, resolve, reject);
|
|
135
|
+
}, function (err) {
|
|
136
|
+
invoke("throw", err, resolve, reject);
|
|
137
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
138
|
+
result.value = unwrapped, resolve(result);
|
|
139
|
+
}, function (error) {
|
|
140
|
+
return invoke("throw", error, resolve, reject);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
reject(record.arg);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var previousPromise;
|
|
148
|
+
|
|
149
|
+
this._invoke = function (method, arg) {
|
|
150
|
+
function callInvokeWithMethodAndArg() {
|
|
151
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
152
|
+
invoke(method, arg, resolve, reject);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
161
|
+
var method = delegate.iterator[context.method];
|
|
162
|
+
|
|
163
|
+
if (undefined === method) {
|
|
164
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
165
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
166
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return ContinueSentinel;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
173
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
174
|
+
var info = record.arg;
|
|
175
|
+
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);
|
|
176
|
+
}
|
|
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
|
+
|
|
185
|
+
function resetTryEntry(entry) {
|
|
186
|
+
var record = entry.completion || {};
|
|
187
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function Context(tryLocsList) {
|
|
191
|
+
this.tryEntries = [{
|
|
192
|
+
tryLoc: "root"
|
|
193
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function values(iterable) {
|
|
197
|
+
if (iterable) {
|
|
198
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
199
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
200
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
201
|
+
|
|
202
|
+
if (!isNaN(iterable.length)) {
|
|
203
|
+
var i = -1,
|
|
204
|
+
next = function next() {
|
|
205
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
206
|
+
|
|
207
|
+
return next.value = undefined, next.done = !0, next;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
return next.next = next;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
next: doneResult
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function doneResult() {
|
|
220
|
+
return {
|
|
221
|
+
value: undefined,
|
|
222
|
+
done: !0
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
227
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
228
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
229
|
+
}, exports.mark = function (genFun) {
|
|
230
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
231
|
+
}, exports.awrap = function (arg) {
|
|
232
|
+
return {
|
|
233
|
+
__await: arg
|
|
234
|
+
};
|
|
235
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
236
|
+
return this;
|
|
237
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
238
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
239
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
240
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
241
|
+
return result.done ? result.value : iter.next();
|
|
242
|
+
});
|
|
243
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
244
|
+
return this;
|
|
245
|
+
}), define(Gp, "toString", function () {
|
|
246
|
+
return "[object Generator]";
|
|
247
|
+
}), exports.keys = function (object) {
|
|
248
|
+
var keys = [];
|
|
249
|
+
|
|
250
|
+
for (var key in object) keys.push(key);
|
|
251
|
+
|
|
252
|
+
return keys.reverse(), function next() {
|
|
253
|
+
for (; keys.length;) {
|
|
254
|
+
var key = keys.pop();
|
|
255
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return next.done = !0, next;
|
|
259
|
+
};
|
|
260
|
+
}, exports.values = values, Context.prototype = {
|
|
261
|
+
constructor: Context,
|
|
262
|
+
reset: function (skipTempReset) {
|
|
263
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
264
|
+
},
|
|
265
|
+
stop: function () {
|
|
266
|
+
this.done = !0;
|
|
267
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
268
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
269
|
+
return this.rval;
|
|
270
|
+
},
|
|
271
|
+
dispatchException: function (exception) {
|
|
272
|
+
if (this.done) throw exception;
|
|
273
|
+
var context = this;
|
|
274
|
+
|
|
275
|
+
function handle(loc, caught) {
|
|
276
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
280
|
+
var entry = this.tryEntries[i],
|
|
281
|
+
record = entry.completion;
|
|
282
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
283
|
+
|
|
284
|
+
if (entry.tryLoc <= this.prev) {
|
|
285
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
286
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
287
|
+
|
|
288
|
+
if (hasCatch && hasFinally) {
|
|
289
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
290
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
291
|
+
} else if (hasCatch) {
|
|
292
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
293
|
+
} else {
|
|
294
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
295
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
abrupt: function (type, arg) {
|
|
301
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
302
|
+
var entry = this.tryEntries[i];
|
|
303
|
+
|
|
304
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
305
|
+
var finallyEntry = entry;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
311
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
312
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
313
|
+
},
|
|
314
|
+
complete: function (record, afterLoc) {
|
|
315
|
+
if ("throw" === record.type) throw record.arg;
|
|
316
|
+
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;
|
|
317
|
+
},
|
|
318
|
+
finish: function (finallyLoc) {
|
|
319
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
320
|
+
var entry = this.tryEntries[i];
|
|
321
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
catch: function (tryLoc) {
|
|
325
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
326
|
+
var entry = this.tryEntries[i];
|
|
327
|
+
|
|
328
|
+
if (entry.tryLoc === tryLoc) {
|
|
329
|
+
var record = entry.completion;
|
|
330
|
+
|
|
331
|
+
if ("throw" === record.type) {
|
|
332
|
+
var thrown = record.arg;
|
|
333
|
+
resetTryEntry(entry);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return thrown;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
throw new Error("illegal catch attempt");
|
|
341
|
+
},
|
|
342
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
343
|
+
return this.delegate = {
|
|
344
|
+
iterator: values(iterable),
|
|
345
|
+
resultName: resultName,
|
|
346
|
+
nextLoc: nextLoc
|
|
347
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
348
|
+
}
|
|
349
|
+
}, exports;
|
|
40
350
|
}
|
|
41
351
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
352
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
353
|
+
try {
|
|
354
|
+
var info = gen[key](arg);
|
|
355
|
+
var value = info.value;
|
|
356
|
+
} catch (error) {
|
|
357
|
+
reject(error);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (info.done) {
|
|
362
|
+
resolve(value);
|
|
363
|
+
} else {
|
|
364
|
+
Promise.resolve(value).then(_next, _throw);
|
|
45
365
|
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function _asyncToGenerator(fn) {
|
|
369
|
+
return function () {
|
|
370
|
+
var self = this,
|
|
371
|
+
args = arguments;
|
|
372
|
+
return new Promise(function (resolve, reject) {
|
|
373
|
+
var gen = fn.apply(self, args);
|
|
374
|
+
|
|
375
|
+
function _next(value) {
|
|
376
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function _throw(err) {
|
|
380
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
381
|
+
}
|
|
46
382
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
writable: true,
|
|
51
|
-
configurable: true
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(subClass, "prototype", {
|
|
55
|
-
writable: false
|
|
56
|
-
});
|
|
57
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
383
|
+
_next(undefined);
|
|
384
|
+
});
|
|
385
|
+
};
|
|
58
386
|
}
|
|
59
387
|
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
388
|
+
function _inheritsLoose(subClass, superClass) {
|
|
389
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
390
|
+
subClass.prototype.constructor = subClass;
|
|
391
|
+
|
|
392
|
+
_setPrototypeOf(subClass, superClass);
|
|
65
393
|
}
|
|
66
394
|
|
|
67
395
|
function _setPrototypeOf(o, p) {
|
|
@@ -73,56 +401,6 @@
|
|
|
73
401
|
return _setPrototypeOf(o, p);
|
|
74
402
|
}
|
|
75
403
|
|
|
76
|
-
function _isNativeReflectConstruct() {
|
|
77
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
78
|
-
if (Reflect.construct.sham) return false;
|
|
79
|
-
if (typeof Proxy === "function") return true;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
83
|
-
return true;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _assertThisInitialized(self) {
|
|
90
|
-
if (self === void 0) {
|
|
91
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return self;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function _possibleConstructorReturn(self, call) {
|
|
98
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
99
|
-
return call;
|
|
100
|
-
} else if (call !== void 0) {
|
|
101
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return _assertThisInitialized(self);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function _createSuper(Derived) {
|
|
108
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
109
|
-
|
|
110
|
-
return function _createSuperInternal() {
|
|
111
|
-
var Super = _getPrototypeOf(Derived),
|
|
112
|
-
result;
|
|
113
|
-
|
|
114
|
-
if (hasNativeReflectConstruct) {
|
|
115
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
116
|
-
|
|
117
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
118
|
-
} else {
|
|
119
|
-
result = Super.apply(this, arguments);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return _possibleConstructorReturn(this, result);
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
404
|
/******************************************************************************
|
|
127
405
|
Copyright (c) Microsoft Corporation.
|
|
128
406
|
|
|
@@ -149,9 +427,9 @@
|
|
|
149
427
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
150
428
|
}
|
|
151
429
|
|
|
152
|
-
function _regeneratorRuntime() {
|
|
430
|
+
function _regeneratorRuntime$1() {
|
|
153
431
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
154
|
-
_regeneratorRuntime = function _regeneratorRuntime() {
|
|
432
|
+
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
155
433
|
return exports;
|
|
156
434
|
};
|
|
157
435
|
|
|
@@ -274,7 +552,7 @@
|
|
|
274
552
|
if ("throw" !== record.type) {
|
|
275
553
|
var result = record.arg,
|
|
276
554
|
value = result.value;
|
|
277
|
-
return value && "object" ==
|
|
555
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
278
556
|
invoke("next", value, resolve, reject);
|
|
279
557
|
}, function (err) {
|
|
280
558
|
invoke("throw", err, resolve, reject);
|
|
@@ -499,7 +777,7 @@
|
|
|
499
777
|
}, exports;
|
|
500
778
|
}
|
|
501
779
|
|
|
502
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
780
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
503
781
|
try {
|
|
504
782
|
var info = gen[key](arg);
|
|
505
783
|
var value = info.value;
|
|
@@ -515,7 +793,7 @@
|
|
|
515
793
|
}
|
|
516
794
|
}
|
|
517
795
|
|
|
518
|
-
function _asyncToGenerator(fn) {
|
|
796
|
+
function _asyncToGenerator$1(fn) {
|
|
519
797
|
return function () {
|
|
520
798
|
var self = this,
|
|
521
799
|
args = arguments;
|
|
@@ -523,11 +801,11 @@
|
|
|
523
801
|
var gen = fn.apply(self, args);
|
|
524
802
|
|
|
525
803
|
function _next(value) {
|
|
526
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
804
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
527
805
|
}
|
|
528
806
|
|
|
529
807
|
function _throw(err) {
|
|
530
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
808
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
531
809
|
}
|
|
532
810
|
|
|
533
811
|
_next(undefined);
|
|
@@ -535,31 +813,6 @@
|
|
|
535
813
|
};
|
|
536
814
|
}
|
|
537
815
|
|
|
538
|
-
function _classCallCheck$1(instance, Constructor) {
|
|
539
|
-
if (!(instance instanceof Constructor)) {
|
|
540
|
-
throw new TypeError("Cannot call a class as a function");
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
function _defineProperties$1(target, props) {
|
|
545
|
-
for (var i = 0; i < props.length; i++) {
|
|
546
|
-
var descriptor = props[i];
|
|
547
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
548
|
-
descriptor.configurable = true;
|
|
549
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
550
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
555
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
556
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
557
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
558
|
-
writable: false
|
|
559
|
-
});
|
|
560
|
-
return Constructor;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
816
|
var _class;
|
|
564
817
|
|
|
565
818
|
var DOMInteractionPlugin_1;
|
|
@@ -569,150 +822,147 @@
|
|
|
569
822
|
|
|
570
823
|
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
571
824
|
function DOMInteractionPlugin() {
|
|
572
|
-
_classCallCheck$1(this, DOMInteractionPlugin);
|
|
573
|
-
|
|
574
825
|
this.contextService = void 0;
|
|
575
826
|
this.renderingContext = void 0;
|
|
576
827
|
}
|
|
577
828
|
|
|
578
|
-
|
|
579
|
-
key: "apply",
|
|
580
|
-
value: function apply(renderingService) {
|
|
581
|
-
var _this = this;
|
|
582
|
-
|
|
583
|
-
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
829
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
584
830
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
};
|
|
831
|
+
_proto.apply = function apply(renderingService) {
|
|
832
|
+
var _this = this;
|
|
588
833
|
|
|
589
|
-
|
|
590
|
-
renderingService.hooks.pointerUp.call(ev);
|
|
591
|
-
};
|
|
834
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
592
835
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
836
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
837
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
838
|
+
};
|
|
596
839
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
840
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
841
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
842
|
+
};
|
|
600
843
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
844
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
845
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
846
|
+
};
|
|
604
847
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
848
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
849
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
850
|
+
};
|
|
608
851
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
852
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
853
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
854
|
+
};
|
|
612
855
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
617
|
-
$el.addEventListener('pointerover', onPointerOver, true);
|
|
618
|
-
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
619
|
-
};
|
|
856
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
857
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
858
|
+
};
|
|
620
859
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
$el.addEventListener('touchmove', onPointerMove, true);
|
|
625
|
-
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
626
|
-
};
|
|
860
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
861
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
862
|
+
};
|
|
627
863
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
864
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
865
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
866
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
867
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
868
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
869
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
870
|
+
};
|
|
635
871
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
};
|
|
872
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
873
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
874
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
875
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
876
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
877
|
+
};
|
|
643
878
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
879
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
880
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
881
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
882
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
883
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
884
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
885
|
+
};
|
|
649
886
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
887
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
888
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
889
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
890
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
891
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
892
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
893
|
+
};
|
|
657
894
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
case 0:
|
|
664
|
-
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
895
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
896
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
897
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
898
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
899
|
+
};
|
|
665
900
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
901
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
902
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
903
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
904
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
905
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
906
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
907
|
+
};
|
|
669
908
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
909
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
910
|
+
var $el;
|
|
911
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
912
|
+
while (1) {
|
|
913
|
+
switch (_context.prev = _context.next) {
|
|
914
|
+
case 0:
|
|
915
|
+
$el = _this.contextService.getDomElement(); // @ts-ignore
|
|
916
|
+
|
|
917
|
+
if (globalThis.navigator.msPointerEnabled) {
|
|
918
|
+
// @ts-ignore
|
|
919
|
+
$el.style.msContentZooming = 'none'; // @ts-ignore
|
|
920
|
+
|
|
921
|
+
$el.style.msTouchAction = 'none';
|
|
922
|
+
} else if (canvas.supportsPointerEvents) {
|
|
923
|
+
$el.style.touchAction = 'none';
|
|
924
|
+
}
|
|
674
925
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
926
|
+
if (canvas.supportsPointerEvents) {
|
|
927
|
+
addPointerEventListener($el);
|
|
928
|
+
} else {
|
|
929
|
+
addMouseEventListener($el);
|
|
930
|
+
}
|
|
680
931
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
932
|
+
if (canvas.supportsTouchEvents) {
|
|
933
|
+
addTouchEventListener($el);
|
|
934
|
+
} // use passive event listeners
|
|
935
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
685
936
|
|
|
686
937
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
938
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
939
|
+
passive: true,
|
|
940
|
+
capture: true
|
|
941
|
+
});
|
|
691
942
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
943
|
+
case 5:
|
|
944
|
+
case "end":
|
|
945
|
+
return _context.stop();
|
|
696
946
|
}
|
|
697
|
-
}, _callee);
|
|
698
|
-
})));
|
|
699
|
-
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
700
|
-
var $el = _this.contextService.getDomElement();
|
|
701
|
-
|
|
702
|
-
if (canvas.supportsPointerEvents) {
|
|
703
|
-
removePointerEventListener($el);
|
|
704
|
-
} else {
|
|
705
|
-
removeMouseEventListener($el);
|
|
706
947
|
}
|
|
948
|
+
}, _callee);
|
|
949
|
+
})));
|
|
950
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
951
|
+
var $el = _this.contextService.getDomElement();
|
|
707
952
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
953
|
+
if (canvas.supportsPointerEvents) {
|
|
954
|
+
removePointerEventListener($el);
|
|
955
|
+
} else {
|
|
956
|
+
removeMouseEventListener($el);
|
|
957
|
+
}
|
|
711
958
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
959
|
+
if (canvas.supportsTouchEvents) {
|
|
960
|
+
removeTouchEventListener($el);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
964
|
+
});
|
|
965
|
+
};
|
|
716
966
|
|
|
717
967
|
return DOMInteractionPlugin;
|
|
718
968
|
}(), _class.tag = 'DOMInteraction', _class);
|
|
@@ -730,22 +980,18 @@
|
|
|
730
980
|
|
|
731
981
|
var Plugin = /*#__PURE__*/function () {
|
|
732
982
|
function Plugin() {
|
|
733
|
-
_classCallCheck$1(this, Plugin);
|
|
734
|
-
|
|
735
983
|
this.name = 'dom-interaction';
|
|
736
984
|
}
|
|
737
985
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
}]);
|
|
986
|
+
var _proto = Plugin.prototype;
|
|
987
|
+
|
|
988
|
+
_proto.init = function init(container) {
|
|
989
|
+
container.load(containerModule, true);
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
_proto.destroy = function destroy(container) {
|
|
993
|
+
container.unload(containerModule);
|
|
994
|
+
};
|
|
749
995
|
|
|
750
996
|
return Plugin;
|
|
751
997
|
}();
|
|
@@ -961,9 +1207,336 @@
|
|
|
961
1207
|
return output;
|
|
962
1208
|
}
|
|
963
1209
|
|
|
964
|
-
function
|
|
1210
|
+
var ElementSVG = function ElementSVG() {
|
|
1211
|
+
this.$el = void 0;
|
|
1212
|
+
this.$groupEl = void 0;
|
|
1213
|
+
this.$hitTestingEl = void 0;
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
ElementSVG.tag = 'c-svg-element';
|
|
1217
|
+
|
|
1218
|
+
function updateImageElementAttribute($el, parsedStyle) {
|
|
1219
|
+
var _parsedStyle$img = parsedStyle.img,
|
|
1220
|
+
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1221
|
+
width = parsedStyle.width,
|
|
1222
|
+
height = parsedStyle.height;
|
|
1223
|
+
$el.setAttribute('x', '0');
|
|
1224
|
+
$el.setAttribute('y', '0');
|
|
1225
|
+
|
|
1226
|
+
if (g.isString(img)) {
|
|
1227
|
+
$el.setAttribute('href', img);
|
|
1228
|
+
} else if (img instanceof Image) {
|
|
1229
|
+
if (!width) {
|
|
1230
|
+
$el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
|
|
1231
|
+
// this.attr('width', img.width);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
if (!height) {
|
|
1235
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
$el.setAttribute('href', img.src);
|
|
1239
|
+
} else if ( // @ts-ignore
|
|
1240
|
+
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
1241
|
+
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
1242
|
+
} else if (img instanceof ImageData) {
|
|
1243
|
+
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1244
|
+
|
|
1245
|
+
canvas.setAttribute('width', "" + img.width); // @ts-ignore
|
|
1246
|
+
|
|
1247
|
+
canvas.setAttribute('height', "" + img.height);
|
|
1248
|
+
var context = canvas.getContext('2d');
|
|
1249
|
+
|
|
1250
|
+
if (context) {
|
|
1251
|
+
context.putImageData(img, 0, 0);
|
|
1252
|
+
|
|
1253
|
+
if (!width) {
|
|
1254
|
+
// @ts-ignore
|
|
1255
|
+
$el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
if (!height) {
|
|
1259
|
+
// @ts-ignore
|
|
1260
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
$el.setAttribute('href', canvas.toDataURL());
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
function updateLineElementAttribute($el, parsedStyle) {
|
|
1269
|
+
var x1 = parsedStyle.x1,
|
|
1270
|
+
y1 = parsedStyle.y1,
|
|
1271
|
+
x2 = parsedStyle.x2,
|
|
1272
|
+
y2 = parsedStyle.y2,
|
|
1273
|
+
defX = parsedStyle.defX,
|
|
1274
|
+
defY = parsedStyle.defY;
|
|
1275
|
+
$el.setAttribute('x1', "" + (x1.value - defX));
|
|
1276
|
+
$el.setAttribute('y1', "" + (y1.value - defY));
|
|
1277
|
+
$el.setAttribute('x2', "" + (x2.value - defX));
|
|
1278
|
+
$el.setAttribute('y2', "" + (y2.value - defY));
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
function updatePathElementAttribute($el, parsedStyle) {
|
|
1282
|
+
var path = parsedStyle.path,
|
|
1283
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1284
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1285
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1286
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1287
|
+
$el.setAttribute('d', formatPath(path.absolutePath, x, y));
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function formatPath(value, x, y) {
|
|
1291
|
+
var newValue = value.map(function (params) {
|
|
1292
|
+
var command = params[0];
|
|
1293
|
+
|
|
1294
|
+
switch (command) {
|
|
1295
|
+
case 'M':
|
|
1296
|
+
return "M " + (params[1] - x) + "," + (params[2] - y);
|
|
1297
|
+
|
|
1298
|
+
case 'L':
|
|
1299
|
+
return "L " + (params[1] - x) + "," + (params[2] - y);
|
|
1300
|
+
|
|
1301
|
+
case 'Q':
|
|
1302
|
+
return "Q " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y);
|
|
1303
|
+
|
|
1304
|
+
case 'C':
|
|
1305
|
+
return "C " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y) + "," + (params[5] - x) + " " + (params[6] - y);
|
|
1306
|
+
|
|
1307
|
+
case 'A':
|
|
1308
|
+
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - x) + " " + (params[7] - y);
|
|
1309
|
+
|
|
1310
|
+
case 'Z':
|
|
1311
|
+
return 'Z';
|
|
1312
|
+
}
|
|
1313
|
+
}).join(' ');
|
|
1314
|
+
|
|
1315
|
+
if (~newValue.indexOf('NaN')) {
|
|
1316
|
+
return '';
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
return newValue;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function updatePolylineElementAttribute($el, parsedStyle) {
|
|
1323
|
+
var points = parsedStyle.points,
|
|
1324
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1325
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1326
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1327
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1328
|
+
|
|
1329
|
+
if (points && points.points && points.points.length >= 2) {
|
|
1330
|
+
$el.setAttribute('points', points.points.map(function (point) {
|
|
1331
|
+
return point[0] - x + "," + (point[1] - y);
|
|
1332
|
+
}).join(' '));
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function updateRectElementAttribute($el, parsedStyle) {
|
|
1337
|
+
var radius = parsedStyle.radius,
|
|
1338
|
+
width = parsedStyle.width,
|
|
1339
|
+
height = parsedStyle.height;
|
|
1340
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
1341
|
+
return r.value !== 0;
|
|
1342
|
+
});
|
|
1343
|
+
var d = '';
|
|
1344
|
+
|
|
1345
|
+
if (!hasRadius) {
|
|
1346
|
+
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
1347
|
+
} else {
|
|
1348
|
+
var _radius$map = radius.map(function (r) {
|
|
1349
|
+
return r.value;
|
|
1350
|
+
}),
|
|
1351
|
+
tlr = _radius$map[0],
|
|
1352
|
+
trr = _radius$map[1],
|
|
1353
|
+
brr = _radius$map[2],
|
|
1354
|
+
blr = _radius$map[3];
|
|
1355
|
+
|
|
1356
|
+
d = [["M " + tlr + ",0"], ["l " + (width.value - tlr - trr) + ",0"], ["a " + trr + "," + trr + ",0,0,1," + trr + "," + trr], ["l 0," + (height.value - trr - brr)], ["a " + brr + "," + brr + ",0,0,1," + -brr + "," + brr], ["l " + (brr + blr - width.value) + ",0"], ["a " + blr + "," + blr + ",0,0,1," + -blr + "," + -blr], ["l 0," + (blr + tlr - height.value)], ["a " + tlr + "," + tlr + ",0,0,1," + tlr + "," + -tlr], ['z']].join(' ');
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
$el.setAttribute('d', d);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
function numberToLongString(x) {
|
|
1363
|
+
return x.toFixed(6).replace('.000000', '');
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function convertHTML(str) {
|
|
1367
|
+
var regex = /[&|<|>|"|']/g;
|
|
1368
|
+
return str.replace(regex, function (match) {
|
|
1369
|
+
if (match === '&') {
|
|
1370
|
+
return '&';
|
|
1371
|
+
} else if (match === '<') {
|
|
1372
|
+
return '<';
|
|
1373
|
+
} else if (match === '>') {
|
|
1374
|
+
return '>';
|
|
1375
|
+
} else if (match === '"') {
|
|
1376
|
+
return '"';
|
|
1377
|
+
} else {
|
|
1378
|
+
return ''';
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
var BASELINE_MAP = {
|
|
1384
|
+
top: 'before-edge',
|
|
1385
|
+
middle: 'central',
|
|
1386
|
+
bottom: 'after-edge',
|
|
1387
|
+
alphabetic: 'alphabetic',
|
|
1388
|
+
ideographic: 'ideographic',
|
|
1389
|
+
hanging: 'hanging'
|
|
1390
|
+
}; // for FireFox
|
|
1391
|
+
// @see https://github.com/plouc/nivo/issues/164
|
|
1392
|
+
|
|
1393
|
+
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1394
|
+
top: 'text-before-edge',
|
|
1395
|
+
middle: 'central',
|
|
1396
|
+
bottom: 'text-after-edge',
|
|
1397
|
+
alphabetic: 'alphabetic',
|
|
1398
|
+
ideographic: 'ideographic',
|
|
1399
|
+
hanging: 'hanging'
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
function updateTextElementAttribute($el, parsedStyle) {
|
|
1403
|
+
var textBaseline = parsedStyle.textBaseline,
|
|
1404
|
+
lineWidth = parsedStyle.lineWidth,
|
|
1405
|
+
metrics = parsedStyle.metrics,
|
|
1406
|
+
dx = parsedStyle.dx,
|
|
1407
|
+
dy = parsedStyle.dy;
|
|
1408
|
+
var browser = detect();
|
|
1409
|
+
|
|
1410
|
+
if (browser && browser.name === 'firefox') {
|
|
1411
|
+
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1412
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1413
|
+
} else {
|
|
1414
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1415
|
+
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
$el.setAttribute('paint-order', 'stroke');
|
|
1419
|
+
var lines = metrics.lines,
|
|
1420
|
+
lineHeight = metrics.lineHeight,
|
|
1421
|
+
height = metrics.height;
|
|
1422
|
+
var lineNum = lines.length;
|
|
1423
|
+
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1424
|
+
|
|
1425
|
+
if (lineNum === 1) {
|
|
1426
|
+
$el.innerHTML = convertHTML(lines[0]);
|
|
1427
|
+
$el.setAttribute('dx', "" + lineWidth.value / 2);
|
|
1428
|
+
} else {
|
|
1429
|
+
$el.innerHTML = lines.map(function (line, i) {
|
|
1430
|
+
var dx = lineWidth.value / 2;
|
|
1431
|
+
var dy = 0;
|
|
1432
|
+
|
|
1433
|
+
if (i === 0) {
|
|
1434
|
+
// TODO: handle other textBaseline values
|
|
1435
|
+
if (textBaseline.value === 'middle') {
|
|
1436
|
+
dy = lineHeight / 2 - height / 2;
|
|
1437
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1438
|
+
dy = 0;
|
|
1439
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1440
|
+
dy = -lineHeight * (lineNum - 1);
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
dy = lineHeight;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
1447
|
+
}).join('');
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
var CreateElementContribution = manaSyringe.Syringe.defineToken('CreateElementContribution', {
|
|
1452
|
+
multiple: false
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
function createSVGElement(type, doc) {
|
|
1456
|
+
return (doc || document).createElementNS('http://www.w3.org/2000/svg', type);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
1460
|
+
|
|
1461
|
+
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[g.Shape.RECT] = 'path', _SHAPE2TAGS[g.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[g.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[g.Shape.IMAGE] = 'image', _SHAPE2TAGS[g.Shape.GROUP] = 'g', _SHAPE2TAGS[g.Shape.LINE] = 'line', _SHAPE2TAGS[g.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[g.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[g.Shape.TEXT] = 'text', _SHAPE2TAGS[g.Shape.PATH] = 'path', _SHAPE2TAGS[g.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
|
|
1462
|
+
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS[g.Shape.CIRCLE] = ['r'], _SHAPE_UPDATE_DEPS[g.Shape.ELLIPSE] = ['rx', 'ry'], _SHAPE_UPDATE_DEPS[g.Shape.RECT] = ['width', 'height', 'radius'], _SHAPE_UPDATE_DEPS[g.Shape.IMAGE] = ['img', 'width', 'height'], _SHAPE_UPDATE_DEPS[g.Shape.LINE] = ['x1', 'y1', 'x2', 'y2'], _SHAPE_UPDATE_DEPS[g.Shape.POLYLINE] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.POLYGON] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.PATH] = ['path'], _SHAPE_UPDATE_DEPS[g.Shape.TEXT] = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
1463
|
+
|
|
1464
|
+
var DefaultCreateElementContribution = /*#__PURE__*/function () {
|
|
1465
|
+
function DefaultCreateElementContribution() {
|
|
1466
|
+
this.canvasConfig = void 0;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
var _proto = DefaultCreateElementContribution.prototype;
|
|
1470
|
+
|
|
1471
|
+
_proto.createElement = function createElement(object) {
|
|
1472
|
+
var doc = this.canvasConfig.document;
|
|
1473
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
1474
|
+
return createSVGElement(type, doc || document);
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
1478
|
+
var nodeName = object.nodeName;
|
|
1479
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
1483
|
+
// @ts-ignore
|
|
1484
|
+
var $el = object.elementSVG.$el;
|
|
1485
|
+
var nodeName = object.nodeName,
|
|
1486
|
+
parsedStyle = object.parsedStyle;
|
|
1487
|
+
|
|
1488
|
+
switch (nodeName) {
|
|
1489
|
+
case g.Shape.IMAGE:
|
|
1490
|
+
{
|
|
1491
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
case g.Shape.RECT:
|
|
1496
|
+
{
|
|
1497
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
case g.Shape.LINE:
|
|
1502
|
+
{
|
|
1503
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
case g.Shape.POLYGON:
|
|
1508
|
+
case g.Shape.POLYLINE:
|
|
1509
|
+
{
|
|
1510
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
case g.Shape.PATH:
|
|
1515
|
+
{
|
|
1516
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
case g.Shape.TEXT:
|
|
1521
|
+
{
|
|
1522
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
|
|
1528
|
+
return DefaultCreateElementContribution;
|
|
1529
|
+
}();
|
|
1530
|
+
|
|
1531
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], DefaultCreateElementContribution.prototype, "canvasConfig", void 0);
|
|
1532
|
+
|
|
1533
|
+
DefaultCreateElementContribution = __decorate([manaSyringe.singleton({
|
|
1534
|
+
token: CreateElementContribution
|
|
1535
|
+
})], DefaultCreateElementContribution);
|
|
1536
|
+
|
|
1537
|
+
function _regeneratorRuntime$2() {
|
|
965
1538
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
966
|
-
_regeneratorRuntime$
|
|
1539
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
967
1540
|
return exports;
|
|
968
1541
|
};
|
|
969
1542
|
|
|
@@ -1086,7 +1659,7 @@
|
|
|
1086
1659
|
if ("throw" !== record.type) {
|
|
1087
1660
|
var result = record.arg,
|
|
1088
1661
|
value = result.value;
|
|
1089
|
-
return value && "object" ==
|
|
1662
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1090
1663
|
invoke("next", value, resolve, reject);
|
|
1091
1664
|
}, function (err) {
|
|
1092
1665
|
invoke("throw", err, resolve, reject);
|
|
@@ -1311,7 +1884,7 @@
|
|
|
1311
1884
|
}, exports;
|
|
1312
1885
|
}
|
|
1313
1886
|
|
|
1314
|
-
function asyncGeneratorStep$
|
|
1887
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1315
1888
|
try {
|
|
1316
1889
|
var info = gen[key](arg);
|
|
1317
1890
|
var value = info.value;
|
|
@@ -1327,7 +1900,7 @@
|
|
|
1327
1900
|
}
|
|
1328
1901
|
}
|
|
1329
1902
|
|
|
1330
|
-
function _asyncToGenerator$
|
|
1903
|
+
function _asyncToGenerator$2(fn) {
|
|
1331
1904
|
return function () {
|
|
1332
1905
|
var self = this,
|
|
1333
1906
|
args = arguments;
|
|
@@ -1335,470 +1908,24 @@
|
|
|
1335
1908
|
var gen = fn.apply(self, args);
|
|
1336
1909
|
|
|
1337
1910
|
function _next(value) {
|
|
1338
|
-
asyncGeneratorStep$
|
|
1911
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1339
1912
|
}
|
|
1340
1913
|
|
|
1341
1914
|
function _throw(err) {
|
|
1342
|
-
asyncGeneratorStep$
|
|
1915
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1343
1916
|
}
|
|
1344
1917
|
|
|
1345
1918
|
_next(undefined);
|
|
1346
1919
|
});
|
|
1347
1920
|
};
|
|
1348
1921
|
}
|
|
1349
|
-
|
|
1350
|
-
function _classCallCheck$2(instance, Constructor) {
|
|
1351
|
-
if (!(instance instanceof Constructor)) {
|
|
1352
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
function _defineProperties$2(target, props) {
|
|
1357
|
-
for (var i = 0; i < props.length; i++) {
|
|
1358
|
-
var descriptor = props[i];
|
|
1359
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1360
|
-
descriptor.configurable = true;
|
|
1361
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1362
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
function _createClass$2(Constructor, protoProps, staticProps) {
|
|
1367
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
1368
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
1369
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
1370
|
-
writable: false
|
|
1371
|
-
});
|
|
1372
|
-
return Constructor;
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
function _defineProperty(obj, key, value) {
|
|
1376
|
-
if (key in obj) {
|
|
1377
|
-
Object.defineProperty(obj, key, {
|
|
1378
|
-
value: value,
|
|
1379
|
-
enumerable: true,
|
|
1380
|
-
configurable: true,
|
|
1381
|
-
writable: true
|
|
1382
|
-
});
|
|
1383
|
-
} else {
|
|
1384
|
-
obj[key] = value;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return obj;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
function _slicedToArray(arr, i) {
|
|
1391
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
function _arrayWithHoles(arr) {
|
|
1395
|
-
if (Array.isArray(arr)) return arr;
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
function _iterableToArrayLimit(arr, i) {
|
|
1399
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1400
|
-
|
|
1401
|
-
if (_i == null) return;
|
|
1402
|
-
var _arr = [];
|
|
1403
|
-
var _n = true;
|
|
1404
|
-
var _d = false;
|
|
1405
|
-
|
|
1406
|
-
var _s, _e;
|
|
1407
|
-
|
|
1408
|
-
try {
|
|
1409
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
1410
|
-
_arr.push(_s.value);
|
|
1411
|
-
|
|
1412
|
-
if (i && _arr.length === i) break;
|
|
1413
|
-
}
|
|
1414
|
-
} catch (err) {
|
|
1415
|
-
_d = true;
|
|
1416
|
-
_e = err;
|
|
1417
|
-
} finally {
|
|
1418
|
-
try {
|
|
1419
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1420
|
-
} finally {
|
|
1421
|
-
if (_d) throw _e;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
return _arr;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
1429
|
-
if (!o) return;
|
|
1430
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1431
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1432
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1433
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1434
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
function _arrayLikeToArray(arr, len) {
|
|
1438
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1439
|
-
|
|
1440
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
1441
|
-
arr2[i] = arr[i];
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
return arr2;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
function _nonIterableRest() {
|
|
1448
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
var ElementSVG = /*#__PURE__*/_createClass$2(function ElementSVG() {
|
|
1452
|
-
_classCallCheck$2(this, ElementSVG);
|
|
1453
|
-
|
|
1454
|
-
this.$el = void 0;
|
|
1455
|
-
this.$groupEl = void 0;
|
|
1456
|
-
this.$hitTestingEl = void 0;
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
ElementSVG.tag = 'c-svg-element';
|
|
1460
|
-
|
|
1461
|
-
var RectRenderer = /*#__PURE__*/function () {
|
|
1462
|
-
function RectRenderer() {
|
|
1463
|
-
_classCallCheck$2(this, RectRenderer);
|
|
1464
|
-
|
|
1465
|
-
this.dependencies = ['radius', 'width', 'height'];
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
_createClass$2(RectRenderer, [{
|
|
1469
|
-
key: "apply",
|
|
1470
|
-
value: function apply($el, parsedStyle) {
|
|
1471
|
-
var radius = parsedStyle.radius,
|
|
1472
|
-
width = parsedStyle.width,
|
|
1473
|
-
height = parsedStyle.height;
|
|
1474
|
-
var hasRadius = radius && radius.some(function (r) {
|
|
1475
|
-
return r.value !== 0;
|
|
1476
|
-
});
|
|
1477
|
-
var d = '';
|
|
1478
|
-
|
|
1479
|
-
if (!hasRadius) {
|
|
1480
|
-
d = "M 0,0 l ".concat(width.value, ",0 l 0,").concat(height.value, " l").concat(-width.value, " 0 z");
|
|
1481
|
-
} else {
|
|
1482
|
-
var _radius$map = radius.map(function (r) {
|
|
1483
|
-
return r.value;
|
|
1484
|
-
}),
|
|
1485
|
-
_radius$map2 = _slicedToArray(_radius$map, 4),
|
|
1486
|
-
tlr = _radius$map2[0],
|
|
1487
|
-
trr = _radius$map2[1],
|
|
1488
|
-
brr = _radius$map2[2],
|
|
1489
|
-
blr = _radius$map2[3];
|
|
1490
|
-
|
|
1491
|
-
d = [["M ".concat(tlr, ",0")], ["l ".concat(width.value - tlr - trr, ",0")], ["a ".concat(trr, ",").concat(trr, ",0,0,1,").concat(trr, ",").concat(trr)], ["l 0,".concat(height.value - trr - brr)], ["a ".concat(brr, ",").concat(brr, ",0,0,1,").concat(-brr, ",").concat(brr)], ["l ".concat(brr + blr - width.value, ",0")], ["a ".concat(blr, ",").concat(blr, ",0,0,1,").concat(-blr, ",").concat(-blr)], ["l 0,".concat(blr + tlr - height.value)], ["a ".concat(tlr, ",").concat(tlr, ",0,0,1,").concat(tlr, ",").concat(-tlr)], ['z']].join(' ');
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
$el.setAttribute('d', d);
|
|
1495
|
-
}
|
|
1496
|
-
}]);
|
|
1497
|
-
|
|
1498
|
-
return RectRenderer;
|
|
1499
|
-
}();
|
|
1500
|
-
|
|
1501
|
-
RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
|
|
1502
|
-
|
|
1503
|
-
var ImageRenderer = /*#__PURE__*/function () {
|
|
1504
|
-
function ImageRenderer() {
|
|
1505
|
-
_classCallCheck$2(this, ImageRenderer);
|
|
1506
|
-
|
|
1507
|
-
this.dependencies = ['img', 'width', 'height'];
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
_createClass$2(ImageRenderer, [{
|
|
1511
|
-
key: "apply",
|
|
1512
|
-
value: function apply($el, parsedStyle) {
|
|
1513
|
-
var _parsedStyle$img = parsedStyle.img,
|
|
1514
|
-
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1515
|
-
width = parsedStyle.width,
|
|
1516
|
-
height = parsedStyle.height;
|
|
1517
|
-
$el.setAttribute('x', '0');
|
|
1518
|
-
$el.setAttribute('y', '0');
|
|
1519
|
-
|
|
1520
|
-
if (g.isString(img)) {
|
|
1521
|
-
$el.setAttribute('href', img);
|
|
1522
|
-
} else if (img instanceof Image) {
|
|
1523
|
-
if (!width) {
|
|
1524
|
-
$el.setAttribute('width', "".concat(img.width)); // TODO: set renderable.boundsDirty
|
|
1525
|
-
// this.attr('width', img.width);
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
if (!height) {
|
|
1529
|
-
$el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
$el.setAttribute('href', img.src);
|
|
1533
|
-
} else if ( // @ts-ignore
|
|
1534
|
-
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
1535
|
-
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
1536
|
-
} else if (img instanceof ImageData) {
|
|
1537
|
-
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1538
|
-
|
|
1539
|
-
canvas.setAttribute('width', "".concat(img.width)); // @ts-ignore
|
|
1540
|
-
|
|
1541
|
-
canvas.setAttribute('height', "".concat(img.height));
|
|
1542
|
-
var context = canvas.getContext('2d');
|
|
1543
|
-
|
|
1544
|
-
if (context) {
|
|
1545
|
-
context.putImageData(img, 0, 0);
|
|
1546
|
-
|
|
1547
|
-
if (!width) {
|
|
1548
|
-
// @ts-ignore
|
|
1549
|
-
$el.setAttribute('width', "".concat(img.width)); // this.attr('width', img.width);
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
if (!height) {
|
|
1553
|
-
// @ts-ignore
|
|
1554
|
-
$el.setAttribute('height', "".concat(img.height)); // this.attr('height', img.height);
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
$el.setAttribute('href', canvas.toDataURL());
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
}]);
|
|
1562
|
-
|
|
1563
|
-
return ImageRenderer;
|
|
1564
|
-
}();
|
|
1565
|
-
|
|
1566
|
-
ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
|
|
1567
|
-
|
|
1568
|
-
var LineRenderer = /*#__PURE__*/function () {
|
|
1569
|
-
function LineRenderer() {
|
|
1570
|
-
_classCallCheck$2(this, LineRenderer);
|
|
1571
|
-
|
|
1572
|
-
this.dependencies = ['x1', 'y1', 'x2', 'y2'];
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
_createClass$2(LineRenderer, [{
|
|
1576
|
-
key: "apply",
|
|
1577
|
-
value: function apply($el, parsedStyle) {
|
|
1578
|
-
var x1 = parsedStyle.x1,
|
|
1579
|
-
y1 = parsedStyle.y1,
|
|
1580
|
-
x2 = parsedStyle.x2,
|
|
1581
|
-
y2 = parsedStyle.y2,
|
|
1582
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1583
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1584
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1585
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
|
|
1586
|
-
stroke = parsedStyle.stroke;
|
|
1587
|
-
$el.setAttribute('x1', "".concat(x1.value - x));
|
|
1588
|
-
$el.setAttribute('y1', "".concat(y1.value - y));
|
|
1589
|
-
$el.setAttribute('x2', "".concat(x2.value - x)); // fix horizontal line stroke url bug in Chrome
|
|
1590
|
-
// @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
|
|
1591
|
-
|
|
1592
|
-
if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
|
|
1593
|
-
$el.setAttribute('y2', "".concat(y2.value - y + 0.00001));
|
|
1594
|
-
} else {
|
|
1595
|
-
$el.setAttribute('y2', "".concat(y2.value - y));
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
}]);
|
|
1599
|
-
|
|
1600
|
-
return LineRenderer;
|
|
1601
|
-
}();
|
|
1602
|
-
|
|
1603
|
-
LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
|
|
1604
|
-
|
|
1605
|
-
var PolylineRenderer = /*#__PURE__*/function () {
|
|
1606
|
-
function PolylineRenderer() {
|
|
1607
|
-
_classCallCheck$2(this, PolylineRenderer);
|
|
1608
|
-
|
|
1609
|
-
this.dependencies = ['points'];
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
_createClass$2(PolylineRenderer, [{
|
|
1613
|
-
key: "apply",
|
|
1614
|
-
value: function apply($el, parsedStyle) {
|
|
1615
|
-
var points = parsedStyle.points,
|
|
1616
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1617
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1618
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1619
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1620
|
-
|
|
1621
|
-
if (points && points.points && points.points.length >= 2) {
|
|
1622
|
-
$el.setAttribute('points', points.points.map(function (point) {
|
|
1623
|
-
return "".concat(point[0] - x, ",").concat(point[1] - y);
|
|
1624
|
-
}).join(' '));
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
}]);
|
|
1628
|
-
|
|
1629
|
-
return PolylineRenderer;
|
|
1630
|
-
}();
|
|
1631
|
-
|
|
1632
|
-
PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
|
|
1633
|
-
|
|
1634
|
-
function numberToLongString(x) {
|
|
1635
|
-
return x.toFixed(6).replace('.000000', '');
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
function convertHTML(str) {
|
|
1639
|
-
var regex = /[&|<|>|"|']/g;
|
|
1640
|
-
return str.replace(regex, function (match) {
|
|
1641
|
-
if (match === '&') {
|
|
1642
|
-
return '&';
|
|
1643
|
-
} else if (match === '<') {
|
|
1644
|
-
return '<';
|
|
1645
|
-
} else if (match === '>') {
|
|
1646
|
-
return '>';
|
|
1647
|
-
} else if (match === '"') {
|
|
1648
|
-
return '"';
|
|
1649
|
-
} else {
|
|
1650
|
-
return ''';
|
|
1651
|
-
}
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
var BASELINE_MAP = {
|
|
1656
|
-
top: 'before-edge',
|
|
1657
|
-
middle: 'central',
|
|
1658
|
-
bottom: 'after-edge',
|
|
1659
|
-
alphabetic: 'alphabetic',
|
|
1660
|
-
ideographic: 'ideographic',
|
|
1661
|
-
hanging: 'hanging'
|
|
1662
|
-
}; // for FireFox
|
|
1663
|
-
// @see https://github.com/plouc/nivo/issues/164
|
|
1664
|
-
|
|
1665
|
-
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1666
|
-
top: 'text-before-edge',
|
|
1667
|
-
middle: 'central',
|
|
1668
|
-
bottom: 'text-after-edge',
|
|
1669
|
-
alphabetic: 'alphabetic',
|
|
1670
|
-
ideographic: 'ideographic',
|
|
1671
|
-
hanging: 'hanging'
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
var TextRenderer = /*#__PURE__*/function () {
|
|
1675
|
-
function TextRenderer() {
|
|
1676
|
-
_classCallCheck$2(this, TextRenderer);
|
|
1677
|
-
|
|
1678
|
-
this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
_createClass$2(TextRenderer, [{
|
|
1682
|
-
key: "apply",
|
|
1683
|
-
value: function apply($el, parsedStyle) {
|
|
1684
|
-
var textBaseline = parsedStyle.textBaseline,
|
|
1685
|
-
lineWidth = parsedStyle.lineWidth,
|
|
1686
|
-
metrics = parsedStyle.metrics,
|
|
1687
|
-
dx = parsedStyle.dx,
|
|
1688
|
-
dy = parsedStyle.dy;
|
|
1689
|
-
var browser = detect();
|
|
1690
|
-
|
|
1691
|
-
if (browser && browser.name === 'firefox') {
|
|
1692
|
-
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1693
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1694
|
-
} else {
|
|
1695
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1696
|
-
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
$el.setAttribute('paint-order', 'stroke');
|
|
1700
|
-
var lines = metrics.lines,
|
|
1701
|
-
lineHeight = metrics.lineHeight,
|
|
1702
|
-
height = metrics.height;
|
|
1703
|
-
var lineNum = lines.length;
|
|
1704
|
-
$el.setAttribute('style', "transform:translate(".concat(dx.toString(), ", ").concat(dy.toString(), ");"));
|
|
1705
|
-
|
|
1706
|
-
if (lineNum === 1) {
|
|
1707
|
-
$el.innerHTML = convertHTML(lines[0]);
|
|
1708
|
-
$el.setAttribute('dx', "".concat(lineWidth.value / 2));
|
|
1709
|
-
} else {
|
|
1710
|
-
$el.innerHTML = lines.map(function (line, i) {
|
|
1711
|
-
var dx = lineWidth.value / 2;
|
|
1712
|
-
var dy = 0;
|
|
1713
|
-
|
|
1714
|
-
if (i === 0) {
|
|
1715
|
-
// TODO: handle other textBaseline values
|
|
1716
|
-
if (textBaseline.value === 'middle') {
|
|
1717
|
-
dy = lineHeight / 2 - height / 2;
|
|
1718
|
-
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1719
|
-
dy = 0;
|
|
1720
|
-
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1721
|
-
dy = -lineHeight * (lineNum - 1);
|
|
1722
|
-
}
|
|
1723
|
-
} else {
|
|
1724
|
-
dy = lineHeight;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
return "<tspan x=\"0\" dx=\"".concat(dx, "\" dy=\"").concat(dy, "\">").concat(convertHTML(line), "</tspan>");
|
|
1728
|
-
}).join('');
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
}]);
|
|
1732
|
-
|
|
1733
|
-
return TextRenderer;
|
|
1734
|
-
}();
|
|
1735
|
-
|
|
1736
|
-
TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
|
|
1737
|
-
|
|
1738
|
-
var PathRenderer = /*#__PURE__*/function () {
|
|
1739
|
-
function PathRenderer() {
|
|
1740
|
-
_classCallCheck$2(this, PathRenderer);
|
|
1741
|
-
|
|
1742
|
-
this.dependencies = ['path'];
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
_createClass$2(PathRenderer, [{
|
|
1746
|
-
key: "apply",
|
|
1747
|
-
value: function apply($el, parsedStyle) {
|
|
1748
|
-
var path = parsedStyle.path,
|
|
1749
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1750
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1751
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1752
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1753
|
-
$el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
|
|
1754
|
-
}
|
|
1755
|
-
}, {
|
|
1756
|
-
key: "formatPath",
|
|
1757
|
-
value: function formatPath(value, x, y) {
|
|
1758
|
-
var newValue = value.map(function (params) {
|
|
1759
|
-
var command = params[0];
|
|
1760
|
-
|
|
1761
|
-
switch (command) {
|
|
1762
|
-
case 'M':
|
|
1763
|
-
return "M ".concat(params[1] - x, ",").concat(params[2] - y);
|
|
1764
|
-
|
|
1765
|
-
case 'L':
|
|
1766
|
-
return "L ".concat(params[1] - x, ",").concat(params[2] - y);
|
|
1767
|
-
|
|
1768
|
-
case 'Q':
|
|
1769
|
-
return "Q ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y);
|
|
1770
|
-
|
|
1771
|
-
case 'C':
|
|
1772
|
-
return "C ".concat(params[1] - x, " ").concat(params[2] - y, ",").concat(params[3] - x, " ").concat(params[4] - y, ",").concat(params[5] - x, " ").concat(params[6] - y);
|
|
1773
|
-
|
|
1774
|
-
case 'A':
|
|
1775
|
-
return "A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6] - x, " ").concat(params[7] - y);
|
|
1776
|
-
|
|
1777
|
-
case 'Z':
|
|
1778
|
-
return 'Z';
|
|
1779
|
-
}
|
|
1780
|
-
}).join(' ');
|
|
1781
|
-
|
|
1782
|
-
if (~newValue.indexOf('NaN')) {
|
|
1783
|
-
return '';
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
return newValue;
|
|
1787
|
-
}
|
|
1788
|
-
}]);
|
|
1789
|
-
|
|
1790
|
-
return PathRenderer;
|
|
1791
|
-
}();
|
|
1792
|
-
|
|
1793
|
-
PathRenderer = __decorate([manaSyringe.singleton()], PathRenderer);
|
|
1794
|
-
var ElementRendererFactory = manaSyringe.Syringe.defineToken('ElementRendererFactory');
|
|
1795
|
-
var ElementRenderer = manaSyringe.Syringe.defineToken('ElementRenderer');
|
|
1796
1922
|
/**
|
|
1797
1923
|
* Common utilities
|
|
1798
1924
|
* @module glMatrix
|
|
1799
1925
|
*/
|
|
1800
1926
|
// Configuration Constants
|
|
1801
1927
|
|
|
1928
|
+
|
|
1802
1929
|
var EPSILON = 0.000001;
|
|
1803
1930
|
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
1804
1931
|
if (!Math.hypot) Math.hypot = function () {
|
|
@@ -2451,20 +2578,16 @@
|
|
|
2451
2578
|
};
|
|
2452
2579
|
}();
|
|
2453
2580
|
|
|
2454
|
-
function createSVGElement(type) {
|
|
2455
|
-
return document.createElementNS('http://www.w3.org/2000/svg', type);
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
2581
|
var FILTER_PREFIX = 'g-filter-';
|
|
2459
2582
|
/**
|
|
2460
2583
|
* use SVG filters, eg. blur, brightness, contrast...
|
|
2461
2584
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2462
2585
|
*/
|
|
2463
2586
|
|
|
2464
|
-
function createOrUpdateFilter($def, object, $el, filters) {
|
|
2587
|
+
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
2465
2588
|
// eg. filter="url(#f1) url(#f2)"
|
|
2466
2589
|
var filterName = FILTER_PREFIX + object.entity;
|
|
2467
|
-
var $existedFilters = $def.querySelectorAll("[name="
|
|
2590
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
2468
2591
|
|
|
2469
2592
|
if ($existedFilters.length) {
|
|
2470
2593
|
$existedFilters.forEach(function ($filter) {
|
|
@@ -2479,35 +2602,37 @@
|
|
|
2479
2602
|
var filterIds = filters.map(function (_ref, i) {
|
|
2480
2603
|
var name = _ref.name,
|
|
2481
2604
|
params = _ref.params;
|
|
2482
|
-
var $filter = createSVGElement('filter');
|
|
2605
|
+
var $filter = createSVGElement('filter', document); // @see https://github.com/antvis/g/issues/1025
|
|
2606
|
+
|
|
2607
|
+
$filter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
2483
2608
|
|
|
2484
2609
|
if (name === 'blur') {
|
|
2485
|
-
createBlur($filter, params);
|
|
2610
|
+
createBlur(document, $filter, params);
|
|
2486
2611
|
} else if (name === 'brightness') {
|
|
2487
|
-
createBrightness($filter, params);
|
|
2612
|
+
createBrightness(document, $filter, params);
|
|
2488
2613
|
} else if (name === 'drop-shadow') {
|
|
2489
|
-
createDropShadow($filter, params);
|
|
2614
|
+
createDropShadow(document, $filter, params);
|
|
2490
2615
|
} else if (name === 'contrast') {
|
|
2491
|
-
createContrast($filter, params);
|
|
2616
|
+
createContrast(document, $filter, params);
|
|
2492
2617
|
} else if (name === 'grayscale') {
|
|
2493
|
-
createGrayscale($filter, params);
|
|
2618
|
+
createGrayscale(document, $filter, params);
|
|
2494
2619
|
} else if (name === 'sepia') {
|
|
2495
|
-
createSepia($filter, params);
|
|
2620
|
+
createSepia(document, $filter, params);
|
|
2496
2621
|
} else if (name === 'saturate') {
|
|
2497
|
-
createSaturate($filter, params);
|
|
2622
|
+
createSaturate(document, $filter, params);
|
|
2498
2623
|
} else if (name === 'hue-rotate') {
|
|
2499
|
-
createHueRotate($filter, params);
|
|
2624
|
+
createHueRotate(document, $filter, params);
|
|
2500
2625
|
} else if (name === 'invert') {
|
|
2501
|
-
createInvert($filter, params);
|
|
2626
|
+
createInvert(document, $filter, params);
|
|
2502
2627
|
}
|
|
2503
2628
|
|
|
2504
|
-
$filter.id =
|
|
2629
|
+
$filter.id = filterName + "-" + i;
|
|
2505
2630
|
$filter.setAttribute('name', filterName);
|
|
2506
2631
|
$def.appendChild($filter);
|
|
2507
2632
|
return $filter.id;
|
|
2508
2633
|
});
|
|
2509
2634
|
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
2510
|
-
return "url(#"
|
|
2635
|
+
return "url(#" + filterId + ")";
|
|
2511
2636
|
}).join(' '));
|
|
2512
2637
|
}
|
|
2513
2638
|
}
|
|
@@ -2520,27 +2645,27 @@
|
|
|
2520
2645
|
*/
|
|
2521
2646
|
|
|
2522
2647
|
|
|
2523
|
-
function createBlur($filter, params) {
|
|
2524
|
-
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2648
|
+
function createBlur(document, $filter, params) {
|
|
2649
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2525
2650
|
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2526
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2651
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
2527
2652
|
$filter.appendChild($feGaussianBlur);
|
|
2528
2653
|
}
|
|
2529
2654
|
|
|
2530
|
-
function createFeComponentTransfer($filter, _ref2) {
|
|
2655
|
+
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
2531
2656
|
var type = _ref2.type,
|
|
2532
2657
|
slope = _ref2.slope,
|
|
2533
2658
|
intercept = _ref2.intercept,
|
|
2534
2659
|
tableValues = _ref2.tableValues;
|
|
2535
|
-
var $feComponentTransfer = createSVGElement('feComponentTransfer');
|
|
2536
|
-
[createSVGElement('feFuncR'), createSVGElement('feFuncG'), createSVGElement('feFuncB')].forEach(function ($feFunc) {
|
|
2660
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
2661
|
+
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
2537
2662
|
$feFunc.setAttribute('type', type);
|
|
2538
2663
|
|
|
2539
2664
|
if (type === 'table') {
|
|
2540
|
-
$feFunc.setAttribute('tableValues', ""
|
|
2665
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
2541
2666
|
} else {
|
|
2542
|
-
$feFunc.setAttribute('slope', ""
|
|
2543
|
-
$feFunc.setAttribute('intercept', ""
|
|
2667
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2668
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
2544
2669
|
}
|
|
2545
2670
|
|
|
2546
2671
|
$feComponentTransfer.appendChild($feFunc);
|
|
@@ -2548,80 +2673,80 @@
|
|
|
2548
2673
|
$filter.appendChild($feComponentTransfer);
|
|
2549
2674
|
}
|
|
2550
2675
|
|
|
2551
|
-
function createContrast($filter, params) {
|
|
2676
|
+
function createContrast(document, $filter, params) {
|
|
2552
2677
|
var slope = convertToAbsoluteValue(params[0]);
|
|
2553
|
-
createFeComponentTransfer($filter, {
|
|
2678
|
+
createFeComponentTransfer(document, $filter, {
|
|
2554
2679
|
type: 'linear',
|
|
2555
2680
|
slope: slope,
|
|
2556
2681
|
intercept: -(0.5 * slope) + 0.5
|
|
2557
2682
|
});
|
|
2558
2683
|
}
|
|
2559
2684
|
|
|
2560
|
-
function createInvert($filter, params) {
|
|
2685
|
+
function createInvert(document, $filter, params) {
|
|
2561
2686
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2562
|
-
createFeComponentTransfer($filter, {
|
|
2687
|
+
createFeComponentTransfer(document, $filter, {
|
|
2563
2688
|
type: 'table',
|
|
2564
|
-
tableValues:
|
|
2689
|
+
tableValues: amount + " " + (1 - amount)
|
|
2565
2690
|
});
|
|
2566
2691
|
}
|
|
2567
2692
|
|
|
2568
|
-
function createBrightness($filter, params) {
|
|
2693
|
+
function createBrightness(document, $filter, params) {
|
|
2569
2694
|
var slope = convertToAbsoluteValue(params[0]);
|
|
2570
|
-
createFeComponentTransfer($filter, {
|
|
2695
|
+
createFeComponentTransfer(document, $filter, {
|
|
2571
2696
|
type: 'linear',
|
|
2572
2697
|
slope: slope,
|
|
2573
2698
|
intercept: 0
|
|
2574
2699
|
});
|
|
2575
2700
|
}
|
|
2576
2701
|
|
|
2577
|
-
function createSaturate($filter, params) {
|
|
2702
|
+
function createSaturate(document, $filter, params) {
|
|
2578
2703
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2579
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2704
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2580
2705
|
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2581
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2706
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
2582
2707
|
$filter.appendChild($feColorMatrix);
|
|
2583
2708
|
}
|
|
2584
2709
|
|
|
2585
|
-
function createHueRotate($filter, params) {
|
|
2586
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2710
|
+
function createHueRotate(document, $filter, params) {
|
|
2711
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2587
2712
|
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
2588
|
-
$feColorMatrix.setAttribute('values', ""
|
|
2713
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
|
|
2589
2714
|
$filter.appendChild($feColorMatrix);
|
|
2590
2715
|
}
|
|
2591
2716
|
|
|
2592
|
-
function createDropShadow($filter, params) {
|
|
2717
|
+
function createDropShadow(document, $filter, params) {
|
|
2593
2718
|
var shadowOffsetX = params[0].value;
|
|
2594
2719
|
var shadowOffsetY = params[1].value;
|
|
2595
2720
|
var shadowBlur = params[2].value; // @ts-ignore
|
|
2596
2721
|
|
|
2597
2722
|
var shadowColor = params[3].formatted;
|
|
2598
|
-
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2723
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2599
2724
|
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2600
|
-
$feGaussianBlur.setAttribute('stdDeviation', ""
|
|
2725
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
2601
2726
|
$filter.appendChild($feGaussianBlur);
|
|
2602
|
-
var $feOffset = createSVGElement('feOffset');
|
|
2603
|
-
$feOffset.setAttribute('dx', ""
|
|
2604
|
-
$feOffset.setAttribute('dy', ""
|
|
2727
|
+
var $feOffset = createSVGElement('feOffset', document);
|
|
2728
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2729
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
2605
2730
|
$feOffset.setAttribute('result', 'offsetblur');
|
|
2606
2731
|
$filter.appendChild($feOffset);
|
|
2607
|
-
var $feFlood = createSVGElement('feFlood');
|
|
2732
|
+
var $feFlood = createSVGElement('feFlood', document);
|
|
2608
2733
|
$feFlood.setAttribute('flood-color', shadowColor);
|
|
2609
2734
|
$filter.appendChild($feFlood);
|
|
2610
|
-
var $feComposite = createSVGElement('feComposite');
|
|
2735
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
2611
2736
|
$feComposite.setAttribute('in2', 'offsetblur');
|
|
2612
2737
|
$feComposite.setAttribute('operator', 'in');
|
|
2613
2738
|
$filter.appendChild($feComposite);
|
|
2614
|
-
var $feMerge = createSVGElement('feMerge');
|
|
2739
|
+
var $feMerge = createSVGElement('feMerge', document);
|
|
2615
2740
|
$filter.appendChild($feMerge);
|
|
2616
|
-
var $feMergeNode1 = createSVGElement('feMergeNode');
|
|
2617
|
-
var $feMergeNode2 = createSVGElement('feMergeNode');
|
|
2741
|
+
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
2742
|
+
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
2618
2743
|
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
2619
2744
|
$feMerge.appendChild($feMergeNode1);
|
|
2620
2745
|
$feMerge.appendChild($feMergeNode2);
|
|
2621
2746
|
}
|
|
2622
2747
|
|
|
2623
|
-
function createFeColorMatrix($filter, matrix) {
|
|
2624
|
-
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2748
|
+
function createFeColorMatrix(document, $filter, matrix) {
|
|
2749
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2625
2750
|
$feColorMatrix.setAttribute('type', 'matrix');
|
|
2626
2751
|
$feColorMatrix.setAttribute('values', matrix.join(' '));
|
|
2627
2752
|
$filter.appendChild($feColorMatrix);
|
|
@@ -2631,32 +2756,29 @@
|
|
|
2631
2756
|
*/
|
|
2632
2757
|
|
|
2633
2758
|
|
|
2634
|
-
function createGrayscale($filter, params) {
|
|
2759
|
+
function createGrayscale(document, $filter, params) {
|
|
2635
2760
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2636
|
-
createFeColorMatrix($filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2761
|
+
createFeColorMatrix(document, $filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2637
2762
|
}
|
|
2638
2763
|
/**
|
|
2639
2764
|
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
2640
2765
|
*/
|
|
2641
2766
|
|
|
2642
2767
|
|
|
2643
|
-
function createSepia($filter, params) {
|
|
2768
|
+
function createSepia(document, $filter, params) {
|
|
2644
2769
|
var amount = convertToAbsoluteValue(params[0]);
|
|
2645
|
-
createFeColorMatrix($filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2770
|
+
createFeColorMatrix(document, $filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2646
2771
|
}
|
|
2647
2772
|
|
|
2648
2773
|
var cacheKey2IDMap = {};
|
|
2649
2774
|
var counter = 0;
|
|
2650
2775
|
|
|
2651
|
-
function createOrUpdateGradientAndPattern($def, object, $el, parsedColor, name) {
|
|
2776
|
+
function createOrUpdateGradientAndPattern(document, $def, object, $el, parsedColor, name) {
|
|
2652
2777
|
// eg. clipPath don't have fill/stroke
|
|
2653
2778
|
if (!parsedColor) {
|
|
2654
2779
|
return;
|
|
2655
2780
|
}
|
|
2656
2781
|
|
|
2657
|
-
var gradientId = generateCacheKey(parsedColor);
|
|
2658
|
-
var existed = $def.querySelector("#".concat(gradientId));
|
|
2659
|
-
|
|
2660
2782
|
if (parsedColor instanceof g.CSSRGB) {
|
|
2661
2783
|
// keep using currentColor @see https://github.com/d3/d3-axis/issues/49
|
|
2662
2784
|
if (object.style[name] === 'currentColor') {
|
|
@@ -2667,17 +2789,9 @@
|
|
|
2667
2789
|
}
|
|
2668
2790
|
} else {
|
|
2669
2791
|
if (parsedColor.type === g.GradientPatternType.Pattern) {
|
|
2670
|
-
|
|
2671
|
-
createPattern($def, parsedColor, gradientId);
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
|
|
2792
|
+
createOrUpdatePattern(document, $def, $el, name, parsedColor);
|
|
2675
2793
|
} else {
|
|
2676
|
-
|
|
2677
|
-
createGradient($def, parsedColor, gradientId);
|
|
2678
|
-
}
|
|
2679
|
-
|
|
2680
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#".concat(gradientId, ")"));
|
|
2794
|
+
createOrUpdateGradient(document, object, $def, $el, name, parsedColor);
|
|
2681
2795
|
}
|
|
2682
2796
|
}
|
|
2683
2797
|
}
|
|
@@ -2700,14 +2814,14 @@
|
|
|
2700
2814
|
y1 = _params$value.y1,
|
|
2701
2815
|
r1 = _params$value.r1,
|
|
2702
2816
|
steps = _params$value.steps;
|
|
2703
|
-
cacheKey = ""
|
|
2817
|
+
cacheKey = "" + type + x0 + y0 + x1 + y1 + (r1 || 0) + steps.map(function (step) {
|
|
2704
2818
|
return step.join('');
|
|
2705
|
-
}).join('')
|
|
2819
|
+
}).join('');
|
|
2706
2820
|
}
|
|
2707
2821
|
|
|
2708
2822
|
if (cacheKey) {
|
|
2709
2823
|
if (!cacheKey2IDMap[cacheKey]) {
|
|
2710
|
-
cacheKey2IDMap[cacheKey] = "_pattern_"
|
|
2824
|
+
cacheKey2IDMap[cacheKey] = "_pattern_" + type + "_" + counter++;
|
|
2711
2825
|
}
|
|
2712
2826
|
}
|
|
2713
2827
|
}
|
|
@@ -2715,43 +2829,71 @@
|
|
|
2715
2829
|
return cacheKey2IDMap[cacheKey];
|
|
2716
2830
|
}
|
|
2717
2831
|
|
|
2718
|
-
function
|
|
2719
|
-
var
|
|
2832
|
+
function createOrUpdatePattern(document, $def, $el, name, parsedColor) {
|
|
2833
|
+
var patternId = generateCacheKey(parsedColor);
|
|
2834
|
+
var $existed = $def.querySelector("#" + patternId);
|
|
2835
|
+
|
|
2836
|
+
if (!$existed) {
|
|
2837
|
+
var src = parsedColor.value.src; // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
2838
|
+
|
|
2839
|
+
var $pattern = createSVGElement('pattern', document);
|
|
2840
|
+
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
2841
|
+
var $image = createSVGElement('image', document);
|
|
2842
|
+
$pattern.appendChild($image);
|
|
2843
|
+
$pattern.id = patternId;
|
|
2844
|
+
$def.appendChild($pattern);
|
|
2845
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + patternId + ")");
|
|
2846
|
+
$image.setAttribute('href', src);
|
|
2847
|
+
var img = new window.Image();
|
|
2848
|
+
|
|
2849
|
+
if (!src.match(/^data:/i)) {
|
|
2850
|
+
img.crossOrigin = 'Anonymous';
|
|
2851
|
+
}
|
|
2720
2852
|
|
|
2721
|
-
|
|
2722
|
-
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
2723
|
-
var $image = createSVGElement('image');
|
|
2724
|
-
$pattern.appendChild($image);
|
|
2725
|
-
$pattern.id = patternId;
|
|
2726
|
-
$def.appendChild($pattern);
|
|
2727
|
-
$image.setAttribute('href', src);
|
|
2728
|
-
var img = new window.Image();
|
|
2853
|
+
img.src = src;
|
|
2729
2854
|
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2855
|
+
var onload = function onload() {
|
|
2856
|
+
$pattern.setAttribute('width', "" + img.width);
|
|
2857
|
+
$pattern.setAttribute('height', "" + img.height);
|
|
2858
|
+
};
|
|
2733
2859
|
|
|
2734
|
-
|
|
2860
|
+
if (img.complete) {
|
|
2861
|
+
onload();
|
|
2862
|
+
} else {
|
|
2863
|
+
img.onload = onload; // Fix onload() bug in IE9
|
|
2735
2864
|
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
$pattern.setAttribute('height', "".concat(img.height));
|
|
2865
|
+
img.src = img.src;
|
|
2866
|
+
}
|
|
2739
2867
|
}
|
|
2868
|
+
}
|
|
2740
2869
|
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
img.onload = onload; // Fix onload() bug in IE9
|
|
2870
|
+
function createOrUpdateGradient(document, object, $def, $el, name, parsedColor) {
|
|
2871
|
+
var gradientId = generateCacheKey(parsedColor);
|
|
2872
|
+
var $existed = $def.querySelector("#" + gradientId);
|
|
2745
2873
|
|
|
2746
|
-
|
|
2874
|
+
if (!$existed) {
|
|
2875
|
+
// <linearGradient> <radialGradient>
|
|
2876
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
2877
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2878
|
+
$existed = createSVGElement(parsedColor.type === g.GradientPatternType.LinearGradient ? 'linearGradient' : 'radialGradient', document); // @see https://github.com/antvis/g/issues/1025
|
|
2879
|
+
|
|
2880
|
+
$existed.setAttribute('gradientUnits', 'userSpaceOnUse'); // add stops
|
|
2881
|
+
|
|
2882
|
+
var innerHTML = '';
|
|
2883
|
+
parsedColor.value.steps.forEach(function (_ref) {
|
|
2884
|
+
var offset = _ref[0],
|
|
2885
|
+
color = _ref[1];
|
|
2886
|
+
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
2887
|
+
});
|
|
2888
|
+
$existed.innerHTML = innerHTML;
|
|
2889
|
+
$existed.id = gradientId;
|
|
2890
|
+
$def.appendChild($existed);
|
|
2891
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2747
2892
|
}
|
|
2748
|
-
}
|
|
2749
2893
|
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2754
|
-
var $gradient = createSVGElement(parsedColor.type === g.GradientPatternType.LinearGradient ? 'linearGradient' : 'radialGradient');
|
|
2894
|
+
var bounds = object.getGeometryBounds();
|
|
2895
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2896
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2755
2897
|
|
|
2756
2898
|
if (parsedColor.type === g.GradientPatternType.LinearGradient) {
|
|
2757
2899
|
var _parsedColor$value = parsedColor.value,
|
|
@@ -2759,32 +2901,20 @@
|
|
|
2759
2901
|
y0 = _parsedColor$value.y0,
|
|
2760
2902
|
x1 = _parsedColor$value.x1,
|
|
2761
2903
|
y1 = _parsedColor$value.y1;
|
|
2762
|
-
$
|
|
2763
|
-
$
|
|
2764
|
-
$
|
|
2765
|
-
$
|
|
2904
|
+
$existed.setAttribute('x1', "" + x0 * width);
|
|
2905
|
+
$existed.setAttribute('y1', "" + y0 * height);
|
|
2906
|
+
$existed.setAttribute('x2', "" + x1 * width);
|
|
2907
|
+
$existed.setAttribute('y2', "" + y1 * height);
|
|
2766
2908
|
} else {
|
|
2909
|
+
var r = Math.sqrt(width * width + height * height) / 2;
|
|
2767
2910
|
var _parsedColor$value2 = parsedColor.value,
|
|
2768
2911
|
_x = _parsedColor$value2.x0,
|
|
2769
2912
|
_y = _parsedColor$value2.y0,
|
|
2770
2913
|
r1 = _parsedColor$value2.r1;
|
|
2771
|
-
$
|
|
2772
|
-
$
|
|
2773
|
-
$
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
var innerHTML = '';
|
|
2778
|
-
parsedColor.value.steps.forEach(function (_ref) {
|
|
2779
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
2780
|
-
offset = _ref2[0],
|
|
2781
|
-
color = _ref2[1];
|
|
2782
|
-
|
|
2783
|
-
innerHTML += "<stop offset=\"".concat(offset, "\" stop-color=\"").concat(color, "\"></stop>");
|
|
2784
|
-
});
|
|
2785
|
-
$gradient.innerHTML = innerHTML;
|
|
2786
|
-
$gradient.id = gradientId;
|
|
2787
|
-
$def.appendChild($gradient);
|
|
2914
|
+
$existed.setAttribute('cx', "" + _x * width);
|
|
2915
|
+
$existed.setAttribute('cy', "" + _y * height);
|
|
2916
|
+
$existed.setAttribute('r', "" + r1 * r);
|
|
2917
|
+
}
|
|
2788
2918
|
}
|
|
2789
2919
|
|
|
2790
2920
|
var FILTER_DROPSHADOW_PREFIX = 'filter-dropshadow-';
|
|
@@ -2793,21 +2923,23 @@
|
|
|
2793
2923
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2794
2924
|
*/
|
|
2795
2925
|
|
|
2796
|
-
function createOrUpdateShadow($def, object, $el, name) {
|
|
2926
|
+
function createOrUpdateShadow(document, $def, object, $el, name) {
|
|
2797
2927
|
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2798
|
-
var $existedFilter = $def.querySelector("#"
|
|
2928
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2799
2929
|
|
|
2800
2930
|
if (!$existedFilter) {
|
|
2801
|
-
$existedFilter = createSVGElement('filter');
|
|
2931
|
+
$existedFilter = createSVGElement('filter', document);
|
|
2802
2932
|
|
|
2803
|
-
var _$feDropShadow = createSVGElement('feDropShadow');
|
|
2933
|
+
var _$feDropShadow = createSVGElement('feDropShadow', document);
|
|
2804
2934
|
|
|
2805
2935
|
_$feDropShadow.setAttribute('dx', '0');
|
|
2806
2936
|
|
|
2807
2937
|
_$feDropShadow.setAttribute('dy', '0');
|
|
2808
2938
|
|
|
2809
2939
|
$existedFilter.appendChild(_$feDropShadow);
|
|
2810
|
-
$existedFilter.id = shadowId;
|
|
2940
|
+
$existedFilter.id = shadowId; // @see https://github.com/antvis/g/issues/1025
|
|
2941
|
+
|
|
2942
|
+
$existedFilter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
2811
2943
|
$def.appendChild($existedFilter);
|
|
2812
2944
|
}
|
|
2813
2945
|
|
|
@@ -2821,52 +2953,28 @@
|
|
|
2821
2953
|
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2822
2954
|
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2823
2955
|
|
|
2824
|
-
$feDropShadow.setAttribute('stdDeviation', ""
|
|
2956
|
+
$feDropShadow.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2825
2957
|
} else if (name === 'shadowOffsetX') {
|
|
2826
2958
|
var shadowOffsetX = object.parsedStyle[name];
|
|
2827
|
-
$feDropShadow.setAttribute('dx', ""
|
|
2959
|
+
$feDropShadow.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2828
2960
|
} else if (name === 'shadowOffsetY') {
|
|
2829
2961
|
var shadowOffsetY = object.parsedStyle[name];
|
|
2830
|
-
$feDropShadow.setAttribute('dy', ""
|
|
2962
|
+
$feDropShadow.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2831
2963
|
} // only apply shadow when blur > 0
|
|
2832
2964
|
|
|
2833
2965
|
|
|
2834
|
-
if (
|
|
2966
|
+
if (!g.isNil(object.parsedStyle.shadowColor)) {
|
|
2835
2967
|
// use filter <feDropShadow>
|
|
2836
2968
|
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2837
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#"
|
|
2969
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2838
2970
|
} else {
|
|
2839
2971
|
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
2840
2972
|
}
|
|
2841
2973
|
}
|
|
2842
2974
|
|
|
2843
|
-
var
|
|
2844
|
-
multiple: false
|
|
2845
|
-
});
|
|
2846
|
-
|
|
2847
|
-
var DefaultElementContribution = /*#__PURE__*/function () {
|
|
2848
|
-
function DefaultElementContribution() {
|
|
2849
|
-
_classCallCheck$2(this, DefaultElementContribution);
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
_createClass$2(DefaultElementContribution, [{
|
|
2853
|
-
key: "createElement",
|
|
2854
|
-
value: function createElement(object) {
|
|
2855
|
-
return createSVGElement(object.nodeName);
|
|
2856
|
-
}
|
|
2857
|
-
}]);
|
|
2858
|
-
|
|
2859
|
-
return DefaultElementContribution;
|
|
2860
|
-
}();
|
|
2861
|
-
|
|
2862
|
-
DefaultElementContribution = __decorate([manaSyringe.singleton({
|
|
2863
|
-
token: CreateElementContribution
|
|
2864
|
-
})], DefaultElementContribution);
|
|
2865
|
-
|
|
2866
|
-
var _SHAPE2TAGS, _class$1;
|
|
2975
|
+
var _class$1;
|
|
2867
2976
|
|
|
2868
2977
|
var SVGRendererPlugin_1;
|
|
2869
|
-
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _defineProperty(_SHAPE2TAGS, g.Shape.RECT, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.CIRCLE, 'circle'), _defineProperty(_SHAPE2TAGS, g.Shape.ELLIPSE, 'ellipse'), _defineProperty(_SHAPE2TAGS, g.Shape.IMAGE, 'image'), _defineProperty(_SHAPE2TAGS, g.Shape.GROUP, 'g'), _defineProperty(_SHAPE2TAGS, g.Shape.LINE, 'line'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYLINE, 'polyline'), _defineProperty(_SHAPE2TAGS, g.Shape.POLYGON, 'polygon'), _defineProperty(_SHAPE2TAGS, g.Shape.TEXT, 'text'), _defineProperty(_SHAPE2TAGS, g.Shape.PATH, 'path'), _defineProperty(_SHAPE2TAGS, g.Shape.HTML, 'foreignObject'), _SHAPE2TAGS);
|
|
2870
2978
|
var SVG_ATTR_MAP = {
|
|
2871
2979
|
opacity: 'opacity',
|
|
2872
2980
|
fillStyle: 'fill',
|
|
@@ -2948,485 +3056,519 @@
|
|
|
2948
3056
|
var CLIP_PATH_PREFIX = 'clip-path-';
|
|
2949
3057
|
var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
2950
3058
|
function SVGRendererPlugin() {
|
|
2951
|
-
_classCallCheck$2(this, SVGRendererPlugin);
|
|
2952
|
-
|
|
2953
3059
|
this.canvasConfig = void 0;
|
|
2954
3060
|
this.camera = void 0;
|
|
2955
3061
|
this.contextService = void 0;
|
|
2956
3062
|
this.renderingContext = void 0;
|
|
2957
3063
|
this.createElementContribution = void 0;
|
|
2958
|
-
this.elementRendererFactory = void 0;
|
|
2959
3064
|
this.$def = void 0;
|
|
2960
3065
|
this.$camera = void 0;
|
|
2961
3066
|
this.renderQueue = [];
|
|
3067
|
+
this.pendingReorderQueue = new Set();
|
|
2962
3068
|
}
|
|
2963
3069
|
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
3070
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
3071
|
+
|
|
3072
|
+
_proto.apply = function apply(renderingService) {
|
|
3073
|
+
var _this = this;
|
|
3074
|
+
|
|
3075
|
+
var document = this.canvasConfig.document;
|
|
3076
|
+
|
|
3077
|
+
var handleMounted = function handleMounted(e) {
|
|
3078
|
+
var object = e.target; // create SVG DOM Node
|
|
3079
|
+
|
|
3080
|
+
_this.createSVGDom(document, object, _this.$camera);
|
|
3081
|
+
};
|
|
3082
|
+
|
|
3083
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
3084
|
+
var object = e.target;
|
|
3085
|
+
|
|
3086
|
+
_this.removeSVGDom(object);
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
3090
|
+
var object = e.target; // @see https://github.com/antvis/g/issues/994
|
|
3091
|
+
// @ts-ignore
|
|
2968
3092
|
|
|
2969
|
-
|
|
2970
|
-
|
|
3093
|
+
if (!object.elementSVG) {
|
|
3094
|
+
return;
|
|
3095
|
+
}
|
|
2971
3096
|
|
|
2972
|
-
|
|
2973
|
-
};
|
|
3097
|
+
var attrName = e.attrName;
|
|
2974
3098
|
|
|
2975
|
-
|
|
2976
|
-
var
|
|
3099
|
+
if (attrName === 'zIndex') {
|
|
3100
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2977
3101
|
|
|
2978
|
-
|
|
2979
|
-
};
|
|
3102
|
+
var parent = object.parentNode; // @ts-ignore
|
|
2980
3103
|
|
|
2981
|
-
|
|
2982
|
-
var
|
|
2983
|
-
// @ts-ignore
|
|
3104
|
+
var $groupEl = (_object$parentNode = object.parentNode) === null || _object$parentNode === void 0 ? void 0 : (_object$parentNode$el = _object$parentNode.elementSVG) === null || _object$parentNode$el === void 0 ? void 0 : _object$parentNode$el.$groupEl;
|
|
3105
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2984
3106
|
|
|
2985
|
-
if (
|
|
2986
|
-
|
|
3107
|
+
if ($groupEl) {
|
|
3108
|
+
_this.reorderChildren(document, $groupEl, children);
|
|
2987
3109
|
}
|
|
3110
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
3111
|
+
// @ts-ignore
|
|
3112
|
+
var svgElement = object.elementSVG;
|
|
2988
3113
|
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
if (attrName === 'zIndex') {
|
|
2992
|
-
var _object$parentNode, _object$parentNode$el;
|
|
3114
|
+
_this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
|
|
3115
|
+
}
|
|
2993
3116
|
|
|
2994
|
-
|
|
3117
|
+
_this.updateAttribute(object, [attrName]);
|
|
3118
|
+
};
|
|
2995
3119
|
|
|
2996
|
-
|
|
2997
|
-
|
|
3120
|
+
var handleGeometryBoundsChanged = function handleGeometryBoundsChanged(e) {
|
|
3121
|
+
var _object$elementSVG;
|
|
2998
3122
|
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
}
|
|
3002
|
-
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
3003
|
-
// @ts-ignore
|
|
3004
|
-
var svgElement = object.elementSVG;
|
|
3123
|
+
var doc = _this.canvasConfig.document;
|
|
3124
|
+
var object = e.target; // @ts-ignore
|
|
3005
3125
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3126
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el;
|
|
3127
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
3128
|
+
fill = _object$parsedStyle.fill,
|
|
3129
|
+
stroke = _object$parsedStyle.stroke;
|
|
3008
3130
|
|
|
3009
|
-
|
|
3010
|
-
|
|
3131
|
+
if (fill && !(fill instanceof g.CSSRGB)) {
|
|
3132
|
+
createOrUpdateGradientAndPattern(doc || document, _this.$def, object, $el, fill, 'fill');
|
|
3133
|
+
}
|
|
3011
3134
|
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
switch (_context.prev = _context.next) {
|
|
3017
|
-
case 0:
|
|
3018
|
-
_this.$def = createSVGElement('defs');
|
|
3019
|
-
$svg = _this.contextService.getContext();
|
|
3020
|
-
background = _this.canvasConfig.background;
|
|
3135
|
+
if (stroke && !(stroke instanceof g.CSSRGB)) {
|
|
3136
|
+
createOrUpdateGradientAndPattern(doc || document, _this.$def, object, $el, stroke, 'stroke');
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3021
3139
|
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
}
|
|
3140
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
3141
|
+
var _this$canvasConfig, background, document, $svg;
|
|
3025
3142
|
|
|
3026
|
-
|
|
3143
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3144
|
+
while (1) {
|
|
3145
|
+
switch (_context.prev = _context.next) {
|
|
3146
|
+
case 0:
|
|
3147
|
+
_this$canvasConfig = _this.canvasConfig, background = _this$canvasConfig.background, document = _this$canvasConfig.document;
|
|
3148
|
+
_this.$def = createSVGElement('defs', document);
|
|
3149
|
+
$svg = _this.contextService.getContext();
|
|
3027
3150
|
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3151
|
+
if (background) {
|
|
3152
|
+
$svg.style.background = background;
|
|
3153
|
+
}
|
|
3031
3154
|
|
|
3032
|
-
|
|
3155
|
+
$svg.appendChild(_this.$def); // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
3033
3156
|
|
|
3034
|
-
|
|
3157
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
3158
|
+
_this.$camera = createSVGElement('g', document);
|
|
3159
|
+
_this.$camera.id = G_SVG_PREFIX + "_camera";
|
|
3035
3160
|
|
|
3036
|
-
|
|
3161
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3037
3162
|
|
|
3038
|
-
|
|
3163
|
+
$svg.appendChild(_this.$camera);
|
|
3039
3164
|
|
|
3040
|
-
|
|
3165
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3041
3166
|
|
|
3042
|
-
|
|
3043
|
-
case "end":
|
|
3044
|
-
return _context.stop();
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
}, _callee);
|
|
3048
|
-
})));
|
|
3049
|
-
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
3050
|
-
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3167
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3051
3168
|
|
|
3052
|
-
|
|
3169
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3053
3170
|
|
|
3054
|
-
|
|
3055
|
-
});
|
|
3056
|
-
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
3057
|
-
// if (!object.isCulled()) {
|
|
3058
|
-
_this.renderQueue.push(object); // }
|
|
3171
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.GEOMETRY_BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
3059
3172
|
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3173
|
+
case 14:
|
|
3174
|
+
case "end":
|
|
3175
|
+
return _context.stop();
|
|
3176
|
+
}
|
|
3064
3177
|
}
|
|
3178
|
+
}, _callee);
|
|
3179
|
+
})));
|
|
3180
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
3181
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
3065
3182
|
|
|
3066
|
-
|
|
3067
|
-
var _object$elementSVG, _object$elementSVG2; // @ts-ignore
|
|
3183
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
3068
3184
|
|
|
3185
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
3069
3186
|
|
|
3070
|
-
|
|
3187
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.GEOMETRY_BOUNDS_CHANGED, handleGeometryBoundsChanged);
|
|
3188
|
+
});
|
|
3189
|
+
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
3190
|
+
// if (!object.isCulled()) {
|
|
3191
|
+
_this.renderQueue.push(object); // }
|
|
3071
3192
|
|
|
3072
|
-
|
|
3193
|
+
});
|
|
3194
|
+
renderingService.hooks.beginFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3195
|
+
var doc = _this.canvasConfig.document;
|
|
3073
3196
|
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
_this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
|
|
3197
|
+
if (_this.pendingReorderQueue.size) {
|
|
3198
|
+
_this.pendingReorderQueue.forEach(function (object) {
|
|
3199
|
+
var _object$elementSVG2;
|
|
3078
3200
|
|
|
3201
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
3202
|
+
var $parentGroupEl = // @ts-ignore
|
|
3203
|
+
object === null || object === void 0 ? void 0 : (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
3079
3204
|
|
|
3080
|
-
|
|
3205
|
+
if ($parentGroupEl) {
|
|
3206
|
+
_this.reorderChildren(doc || document, $parentGroupEl, children || []);
|
|
3081
3207
|
}
|
|
3082
3208
|
});
|
|
3083
3209
|
|
|
3084
|
-
_this.
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3210
|
+
_this.pendingReorderQueue.clear();
|
|
3211
|
+
}
|
|
3212
|
+
});
|
|
3213
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
3214
|
+
if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
|
|
3215
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
_this.renderQueue.forEach(function (object) {
|
|
3219
|
+
var _object$elementSVG3, _object$elementSVG4; // @ts-ignore
|
|
3220
|
+
|
|
3221
|
+
|
|
3222
|
+
var $el = (_object$elementSVG3 = object.elementSVG) === null || _object$elementSVG3 === void 0 ? void 0 : _object$elementSVG3.$el; // @ts-ignore
|
|
3223
|
+
|
|
3224
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3225
|
+
|
|
3226
|
+
if ($el && $groupEl) {
|
|
3227
|
+
// apply local RTS transformation to <group> wrapper
|
|
3228
|
+
// account for anchor
|
|
3229
|
+
_this.applyTransform($groupEl, object.getLocalTransform()); // finish rendering, clear dirty flag
|
|
3230
|
+
|
|
3231
|
+
|
|
3232
|
+
object.renderable.dirty = false;
|
|
3233
|
+
}
|
|
3093
3234
|
});
|
|
3094
3235
|
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
children.forEach(function (child) {
|
|
3099
|
-
if (child.isConnected) {
|
|
3100
|
-
// @ts-ignore
|
|
3101
|
-
var $el = child.elementSVG.$groupEl;
|
|
3236
|
+
_this.renderQueue = [];
|
|
3237
|
+
});
|
|
3238
|
+
};
|
|
3102
3239
|
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3240
|
+
_proto.reorderChildren = function reorderChildren(doc, $groupEl, children) {
|
|
3241
|
+
// need to reorder parent's children
|
|
3242
|
+
children.sort(function (a, b) {
|
|
3243
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
3244
|
+
});
|
|
3245
|
+
|
|
3246
|
+
if (children.length) {
|
|
3247
|
+
// create empty fragment
|
|
3248
|
+
var fragment = (doc || document).createDocumentFragment();
|
|
3249
|
+
children.forEach(function (child) {
|
|
3250
|
+
if (child.isConnected) {
|
|
3251
|
+
// @ts-ignore
|
|
3252
|
+
var $el = child.elementSVG.$groupEl;
|
|
3253
|
+
|
|
3254
|
+
if ($el) {
|
|
3255
|
+
fragment.appendChild($el);
|
|
3106
3256
|
}
|
|
3107
|
-
}
|
|
3108
|
-
|
|
3109
|
-
|
|
3257
|
+
}
|
|
3258
|
+
});
|
|
3259
|
+
$groupEl.appendChild(fragment);
|
|
3110
3260
|
}
|
|
3111
|
-
}
|
|
3112
|
-
key: "applyTransform",
|
|
3113
|
-
value: function applyTransform($el, transform) {
|
|
3114
|
-
var translation = getTranslation(create$1(), transform);
|
|
3115
|
-
var scaling = getScaling(create$1(), transform);
|
|
3116
|
-
var rotation = getRotation(create$3(), transform);
|
|
3117
|
-
|
|
3118
|
-
var _translation = _slicedToArray(translation, 2),
|
|
3119
|
-
x = _translation[0],
|
|
3120
|
-
y = _translation[1];
|
|
3261
|
+
};
|
|
3121
3262
|
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3263
|
+
_proto.applyTransform = function applyTransform($el, transform) {
|
|
3264
|
+
var translation = getTranslation(create$1(), transform);
|
|
3265
|
+
var scaling = getScaling(create$1(), transform);
|
|
3266
|
+
var rotation = getRotation(create$3(), transform);
|
|
3267
|
+
var x = translation[0],
|
|
3268
|
+
y = translation[1];
|
|
3269
|
+
var scaleX = scaling[0],
|
|
3270
|
+
scaleY = scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3125
3271
|
|
|
3272
|
+
var _getEuler = g.getEuler(create$1(), rotation),
|
|
3273
|
+
ex = _getEuler[0],
|
|
3274
|
+
ey = _getEuler[1],
|
|
3275
|
+
ez = _getEuler[2]; // gimbal lock at 90 degrees
|
|
3126
3276
|
|
|
3127
|
-
var _getEuler = g.getEuler(create$1(), rotation),
|
|
3128
|
-
_getEuler2 = _slicedToArray(_getEuler, 3),
|
|
3129
|
-
ex = _getEuler2[0],
|
|
3130
|
-
ey = _getEuler2[1],
|
|
3131
|
-
ez = _getEuler2[2]; // gimbal lock at 90 degrees
|
|
3132
3277
|
|
|
3278
|
+
var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
|
|
3279
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
3133
3280
|
|
|
3134
|
-
|
|
3135
|
-
|
|
3281
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
|
|
3282
|
+
};
|
|
3136
3283
|
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
// @ts-ignore
|
|
3143
|
-
var elementSVG = object.elementSVG;
|
|
3144
|
-
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
3145
|
-
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
3284
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
3285
|
+
// @ts-ignore
|
|
3286
|
+
var elementSVG = object.elementSVG;
|
|
3287
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
3288
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
3146
3289
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3290
|
+
if ($el && $groupEl) {
|
|
3291
|
+
var nodeName = object.nodeName,
|
|
3292
|
+
attributes = object.attributes;
|
|
3293
|
+
$el.setAttribute('fill', 'none');
|
|
3151
3294
|
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3295
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
3296
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
3297
|
+
} // apply attributes
|
|
3155
3298
|
|
|
3156
3299
|
|
|
3157
|
-
|
|
3158
|
-
}
|
|
3300
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
3159
3301
|
}
|
|
3160
|
-
}
|
|
3161
|
-
key: "updateAttribute",
|
|
3162
|
-
value: function updateAttribute(object, attributes) {
|
|
3163
|
-
var _this2 = this;
|
|
3164
|
-
|
|
3165
|
-
var needGeneratePath = false; // @ts-ignore
|
|
3166
|
-
|
|
3167
|
-
var _object$elementSVG3 = object.elementSVG,
|
|
3168
|
-
$el = _object$elementSVG3.$el,
|
|
3169
|
-
$groupEl = _object$elementSVG3.$groupEl,
|
|
3170
|
-
$hitTestingEl = _object$elementSVG3.$hitTestingEl;
|
|
3171
|
-
var parsedStyle = object.parsedStyle,
|
|
3172
|
-
computedStyle = object.computedStyle;
|
|
3173
|
-
var elementRenderer = this.elementRendererFactory(object.nodeName);
|
|
3174
|
-
attributes.forEach(function (name) {
|
|
3175
|
-
var usedName = SVG_ATTR_MAP[name];
|
|
3176
|
-
var computedValue = computedStyle[name];
|
|
3177
|
-
var usedValue = parsedStyle[name]; // generate path only once
|
|
3178
|
-
|
|
3179
|
-
if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
|
|
3180
|
-
needGeneratePath = true;
|
|
3181
|
-
} // <foreignObject>
|
|
3302
|
+
};
|
|
3182
3303
|
|
|
3304
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
3305
|
+
var _this2 = this;
|
|
3183
3306
|
|
|
3184
|
-
|
|
3185
|
-
if (name === 'fill') {
|
|
3186
|
-
$el.style.background = usedValue.toString();
|
|
3187
|
-
} else if (name === 'stroke') {
|
|
3188
|
-
$el.style['border-color'] = usedValue.toString();
|
|
3189
|
-
$el.style['border-style'] = 'solid';
|
|
3190
|
-
} else if (name === 'lineWidth') {
|
|
3191
|
-
$el.style['border-width'] = "".concat(usedValue.value || 0, "px");
|
|
3192
|
-
} else if (name === 'lineDash') {
|
|
3193
|
-
$el.style['border-style'] = 'dashed';
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3307
|
+
var document = this.canvasConfig.document; // @ts-ignore
|
|
3196
3308
|
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
_this2.
|
|
3211
|
-
|
|
3212
|
-
if (
|
|
3213
|
-
object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
|
|
3214
|
-
['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
|
|
3309
|
+
var _object$elementSVG5 = object.elementSVG,
|
|
3310
|
+
$el = _object$elementSVG5.$el,
|
|
3311
|
+
$groupEl = _object$elementSVG5.$groupEl,
|
|
3312
|
+
$hitTestingEl = _object$elementSVG5.$hitTestingEl;
|
|
3313
|
+
var parsedStyle = object.parsedStyle,
|
|
3314
|
+
computedStyle = object.computedStyle;
|
|
3315
|
+
var shouldUpdateElementAttribute = attributes.some(function (name) {
|
|
3316
|
+
return _this2.createElementContribution.shouldUpdateElementAttribute(object, name);
|
|
3317
|
+
}); // need re-generate path
|
|
3318
|
+
|
|
3319
|
+
if (shouldUpdateElementAttribute && $el) {
|
|
3320
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
3321
|
+
if ($el) {
|
|
3322
|
+
_this2.createElementContribution.updateElementAttribute(object, $el);
|
|
3323
|
+
|
|
3324
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
3215
3325
|
_this2.updateAnchorWithTransform(object);
|
|
3216
3326
|
}
|
|
3327
|
+
}
|
|
3328
|
+
});
|
|
3329
|
+
} // update common attributes
|
|
3217
3330
|
|
|
3218
|
-
if (name !== 'anchor' && computedValue) {
|
|
3219
|
-
// use computed value so that we can use cascaded effect in SVG
|
|
3220
|
-
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
3221
3331
|
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3332
|
+
attributes.forEach(function (name) {
|
|
3333
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
3334
|
+
var computedValue = computedStyle[name];
|
|
3335
|
+
var usedValue = parsedStyle[name]; // <foreignObject>
|
|
3226
3336
|
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
}
|
|
3233
|
-
});
|
|
3234
|
-
}
|
|
3337
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3338
|
+
if (name === 'lineWidth') {
|
|
3339
|
+
$el.style['border-width'] = (usedValue.value || 0) + "px";
|
|
3340
|
+
} else if (name === 'lineDash') {
|
|
3341
|
+
$el.style['border-style'] = 'dashed';
|
|
3235
3342
|
}
|
|
3236
|
-
}
|
|
3343
|
+
}
|
|
3237
3344
|
|
|
3238
|
-
if (
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
}
|
|
3345
|
+
if (name === 'fill') {
|
|
3346
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3347
|
+
$el.style.background = usedValue.toString();
|
|
3348
|
+
} else {
|
|
3349
|
+
createOrUpdateGradientAndPattern(document, _this2.$def, object, $el, usedValue, usedName);
|
|
3350
|
+
}
|
|
3351
|
+
} else if (name === 'stroke') {
|
|
3352
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3353
|
+
$el.style['border-color'] = usedValue.toString();
|
|
3354
|
+
$el.style['border-style'] = 'solid';
|
|
3355
|
+
} else {
|
|
3356
|
+
createOrUpdateGradientAndPattern(document, _this2.$def, object, $el, usedValue, usedName);
|
|
3357
|
+
}
|
|
3358
|
+
} else if (name === 'visibility' && computedValue.value !== 'unset') {
|
|
3359
|
+
// use computed value
|
|
3360
|
+
// update `visibility` on <group>
|
|
3361
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
|
|
3362
|
+
} else if (name === 'clipPath') {
|
|
3363
|
+
_this2.createOrUpdateClipPath(document, usedValue, $groupEl);
|
|
3364
|
+
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
3365
|
+
createOrUpdateShadow(document, _this2.$def, object, $el, name);
|
|
3366
|
+
} else if (name === 'filter') {
|
|
3367
|
+
createOrUpdateFilter(document, _this2.$def, object, $el, usedValue);
|
|
3368
|
+
} else if (name === 'innerHTML') {
|
|
3369
|
+
_this2.createOrUpdateInnerHTML(document, $el, usedValue);
|
|
3370
|
+
} else if (name === 'anchor') {
|
|
3371
|
+
// text' anchor is controlled by `textAnchor` property
|
|
3372
|
+
if (object.nodeName !== g.Shape.TEXT) {
|
|
3373
|
+
_this2.updateAnchorWithTransform(object);
|
|
3374
|
+
}
|
|
3375
|
+
} else {
|
|
3376
|
+
if (computedValue) {
|
|
3377
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
3378
|
+
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
3379
|
+
|
|
3380
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
3381
|
+
if ($el && usedName) {
|
|
3382
|
+
if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
3383
|
+
var _FORMAT_VALUE_MAP$nam;
|
|
3384
|
+
|
|
3385
|
+
var formattedValueStr = ((_FORMAT_VALUE_MAP$nam = FORMAT_VALUE_MAP[name]) === null || _FORMAT_VALUE_MAP$nam === void 0 ? void 0 : _FORMAT_VALUE_MAP$nam[valueStr]) || valueStr;
|
|
3386
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
3387
|
+
} else {
|
|
3388
|
+
$el.removeAttribute(usedName);
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3244
3393
|
}
|
|
3245
|
-
}
|
|
3246
|
-
}
|
|
3247
|
-
key: "createSVGDom",
|
|
3248
|
-
value: function createSVGDom(object, root) {
|
|
3249
|
-
var noWrapWithGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; // create svg element
|
|
3250
|
-
// @ts-ignore
|
|
3394
|
+
});
|
|
3395
|
+
};
|
|
3251
3396
|
|
|
3252
|
-
|
|
3397
|
+
_proto.createSVGDom = function createSVGDom(document, object, root, noWrapWithGroup) {
|
|
3398
|
+
if (noWrapWithGroup === void 0) {
|
|
3399
|
+
noWrapWithGroup = false;
|
|
3400
|
+
} // create svg element
|
|
3401
|
+
// @ts-ignore
|
|
3253
3402
|
|
|
3254
|
-
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3255
3403
|
|
|
3256
|
-
|
|
3404
|
+
object.elementSVG = new ElementSVG(); // @ts-ignore
|
|
3257
3405
|
|
|
3258
|
-
|
|
3259
|
-
var _object$parentNode$el2;
|
|
3406
|
+
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
3260
3407
|
|
|
3261
|
-
|
|
3262
|
-
var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
|
|
3408
|
+
var $el = this.createElementContribution.createElement(object);
|
|
3263
3409
|
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
}
|
|
3410
|
+
if ($el) {
|
|
3411
|
+
var _object$parentNode$el2;
|
|
3267
3412
|
|
|
3268
|
-
|
|
3413
|
+
var $groupEl; // save $el on parsedStyle, which will be returned in getDomElement()
|
|
3269
3414
|
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
}
|
|
3415
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
3416
|
+
object.parsedStyle.$el = $el;
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
$el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
|
|
3276
3420
|
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3421
|
+
if (($el.hasAttribute('data-wrapgroup') || $el.nodeName !== 'g') && !noWrapWithGroup) {
|
|
3422
|
+
$groupEl = createSVGElement('g', document);
|
|
3423
|
+
$groupEl.appendChild($el);
|
|
3424
|
+
} else {
|
|
3425
|
+
$groupEl = $el;
|
|
3426
|
+
}
|
|
3281
3427
|
|
|
3282
|
-
|
|
3283
|
-
|
|
3428
|
+
svgElement.$el = $el;
|
|
3429
|
+
svgElement.$groupEl = $groupEl; // apply attributes at first time
|
|
3284
3430
|
|
|
3285
|
-
|
|
3286
|
-
var children = (((_object$parentNode2 = object.parentNode) === null || _object$parentNode2 === void 0 ? void 0 : _object$parentNode2.children) || []).slice();
|
|
3287
|
-
this.reorderChildren($parentGroupEl, children || []);
|
|
3288
|
-
} // apply attributes at first time
|
|
3431
|
+
this.applyAttributes(object); // create hitArea if necessary
|
|
3289
3432
|
|
|
3433
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
3434
|
+
var $parentGroupEl = // @ts-ignore
|
|
3435
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
3290
3436
|
|
|
3291
|
-
|
|
3437
|
+
if ($parentGroupEl) {
|
|
3438
|
+
$parentGroupEl.appendChild($groupEl); // need reorder children later
|
|
3292
3439
|
|
|
3293
|
-
this.
|
|
3440
|
+
this.pendingReorderQueue.add(object.parentNode);
|
|
3294
3441
|
}
|
|
3295
3442
|
}
|
|
3296
|
-
}
|
|
3297
|
-
key: "removeSVGDom",
|
|
3298
|
-
value: function removeSVGDom(object) {
|
|
3299
|
-
var _object$elementSVG4; // @ts-ignore
|
|
3443
|
+
};
|
|
3300
3444
|
|
|
3445
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
3446
|
+
var _object$elementSVG6; // @ts-ignore
|
|
3301
3447
|
|
|
3302
|
-
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3303
3448
|
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3449
|
+
var $groupEl = (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$groupEl;
|
|
3450
|
+
|
|
3451
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
3452
|
+
$groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
|
|
3307
3453
|
}
|
|
3308
|
-
}
|
|
3309
|
-
key: "createOrUpdateHitArea",
|
|
3310
|
-
value: function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3311
|
-
var _object$parsedStyle$i; // @ts-ignore
|
|
3454
|
+
};
|
|
3312
3455
|
|
|
3456
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3457
|
+
var _object$parsedStyle$i; // @ts-ignore
|
|
3313
3458
|
|
|
3314
|
-
var svgElement = object.elementSVG;
|
|
3315
|
-
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3316
|
-
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3317
3459
|
|
|
3318
|
-
|
|
3319
|
-
|
|
3460
|
+
var svgElement = object.elementSVG;
|
|
3461
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3462
|
+
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3320
3463
|
|
|
3321
|
-
|
|
3322
|
-
|
|
3464
|
+
if (increasedLineWidthForHitTesting) {
|
|
3465
|
+
var _object$parsedStyle$l;
|
|
3323
3466
|
|
|
3324
|
-
|
|
3467
|
+
if (!$hitTestingEl) {
|
|
3468
|
+
$hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
3325
3469
|
|
|
3326
|
-
|
|
3327
|
-
$hitTestingEl.removeAttribute(attribute);
|
|
3328
|
-
}); // hitArea should be 'transparent' but not 'none'
|
|
3470
|
+
$hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
|
|
3329
3471
|
|
|
3330
|
-
|
|
3331
|
-
$hitTestingEl.
|
|
3332
|
-
|
|
3333
|
-
$groupEl.appendChild($hitTestingEl);
|
|
3334
|
-
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3335
|
-
} // increase interactive line width
|
|
3472
|
+
['filter'].forEach(function (attribute) {
|
|
3473
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
3474
|
+
}); // hitArea should be 'transparent' but not 'none'
|
|
3336
3475
|
|
|
3476
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
3477
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
3478
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
3479
|
+
$groupEl.appendChild($hitTestingEl);
|
|
3480
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3481
|
+
} // increase interactive line width
|
|
3337
3482
|
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3483
|
+
|
|
3484
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
|
|
3485
|
+
} else {
|
|
3486
|
+
if ($hitTestingEl) {
|
|
3487
|
+
$groupEl.removeChild($hitTestingEl);
|
|
3488
|
+
svgElement.$hitTestingEl = null;
|
|
3344
3489
|
}
|
|
3345
3490
|
}
|
|
3346
|
-
}
|
|
3347
|
-
key: "createOrUpdateInnerHTML",
|
|
3348
|
-
value: function createOrUpdateInnerHTML($el, usedValue) {
|
|
3349
|
-
var $div = document.createElement('div');
|
|
3491
|
+
};
|
|
3350
3492
|
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
} else {
|
|
3354
|
-
$div.appendChild(usedValue);
|
|
3355
|
-
}
|
|
3493
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML(doc, $el, usedValue) {
|
|
3494
|
+
var $div = (doc || document).createElement('div');
|
|
3356
3495
|
|
|
3357
|
-
|
|
3358
|
-
$
|
|
3496
|
+
if (typeof usedValue === 'string') {
|
|
3497
|
+
$div.innerHTML = usedValue;
|
|
3498
|
+
} else {
|
|
3499
|
+
$div.appendChild(usedValue);
|
|
3359
3500
|
}
|
|
3360
|
-
}, {
|
|
3361
|
-
key: "createOrUpdateClipPath",
|
|
3362
|
-
value: function createOrUpdateClipPath(clipPath, $groupEl) {
|
|
3363
|
-
if (clipPath) {
|
|
3364
|
-
var _clipPath$elementSVG;
|
|
3365
3501
|
|
|
3366
|
-
|
|
3367
|
-
|
|
3502
|
+
$el.innerHTML = '';
|
|
3503
|
+
$el.appendChild($div);
|
|
3504
|
+
};
|
|
3505
|
+
|
|
3506
|
+
_proto.createOrUpdateClipPath = function createOrUpdateClipPath(document, clipPath, $groupEl) {
|
|
3507
|
+
if (clipPath) {
|
|
3508
|
+
var _clipPath$elementSVG;
|
|
3368
3509
|
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
var $clipPath = createSVGElement('clipPath');
|
|
3372
|
-
$clipPath.id = clipPathId;
|
|
3373
|
-
this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3510
|
+
var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
|
|
3511
|
+
var existed = this.$def.querySelector("#" + clipPathId);
|
|
3374
3512
|
|
|
3375
|
-
|
|
3513
|
+
if (!existed) {
|
|
3514
|
+
// create <clipPath> dom node, append it to <defs>
|
|
3515
|
+
var $clipPath = createSVGElement('clipPath', document);
|
|
3516
|
+
$clipPath.id = clipPathId;
|
|
3517
|
+
this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3376
3518
|
|
|
3377
|
-
|
|
3378
|
-
} // @ts-ignore
|
|
3519
|
+
this.createSVGDom(document, clipPath, $clipPath, true); // @ts-ignore
|
|
3379
3520
|
|
|
3521
|
+
clipPath.elementSVG.$groupEl = $clipPath;
|
|
3522
|
+
} // @ts-ignore
|
|
3380
3523
|
|
|
3381
|
-
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
3382
3524
|
|
|
3383
|
-
|
|
3384
|
-
// apply local RTS transformation to <group> wrapper
|
|
3385
|
-
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3386
|
-
} // apply attributes
|
|
3525
|
+
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
3387
3526
|
|
|
3527
|
+
if ($clipPathGroupEl) {
|
|
3528
|
+
// apply local RTS transformation to <group> wrapper
|
|
3529
|
+
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3530
|
+
} // apply attributes
|
|
3388
3531
|
|
|
3389
|
-
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3390
|
-
// @see https://github.com/antvis/g/issues/961
|
|
3391
3532
|
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3533
|
+
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3534
|
+
// @see https://github.com/antvis/g/issues/961
|
|
3535
|
+
|
|
3536
|
+
$groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
|
|
3537
|
+
} else {
|
|
3538
|
+
// remove clip path
|
|
3539
|
+
$groupEl.removeAttribute('clip-path');
|
|
3397
3540
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3541
|
+
}
|
|
3542
|
+
/**
|
|
3543
|
+
* the origin is bounding box's top left corner
|
|
3544
|
+
*/
|
|
3545
|
+
;
|
|
3401
3546
|
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
value: function updateAnchorWithTransform(object) {
|
|
3405
|
-
var _object$elementSVG5, _object$elementSVG6;
|
|
3547
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
3548
|
+
var _object$elementSVG7, _object$elementSVG8;
|
|
3406
3549
|
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3550
|
+
var bounds = object.getGeometryBounds();
|
|
3551
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
3552
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
3410
3553
|
|
|
3411
|
-
|
|
3412
|
-
|
|
3554
|
+
var _ref2 = object.parsedStyle || {},
|
|
3555
|
+
anchor = _ref2.anchor; // @ts-ignore
|
|
3413
3556
|
|
|
3414
3557
|
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
}
|
|
3558
|
+
[(_object$elementSVG7 = object.elementSVG) === null || _object$elementSVG7 === void 0 ? void 0 : _object$elementSVG7.$el, (_object$elementSVG8 = object.elementSVG) === null || _object$elementSVG8 === void 0 ? void 0 : _object$elementSVG8.$hitTestingEl].forEach(function ($el) {
|
|
3559
|
+
if ($el) {
|
|
3560
|
+
// apply anchor to element's `transform` property
|
|
3561
|
+
$el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
|
|
3562
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
3563
|
+
"translate(-" + anchor[0].value * width + ",-" + anchor[1].value * height + ")");
|
|
3564
|
+
|
|
3565
|
+
if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
|
|
3566
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
3567
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
3426
3568
|
}
|
|
3427
|
-
}
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3569
|
+
}
|
|
3570
|
+
});
|
|
3571
|
+
};
|
|
3430
3572
|
|
|
3431
3573
|
return SVGRendererPlugin;
|
|
3432
3574
|
}(), _class$1.tag = 'SVGRenderer', _class$1);
|
|
@@ -3441,85 +3583,57 @@
|
|
|
3441
3583
|
|
|
3442
3584
|
__decorate([manaSyringe.inject(CreateElementContribution), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "createElementContribution", void 0);
|
|
3443
3585
|
|
|
3444
|
-
__decorate([manaSyringe.inject(ElementRendererFactory), __metadata("design:type", Function)], SVGRendererPlugin.prototype, "elementRendererFactory", void 0);
|
|
3445
|
-
|
|
3446
3586
|
SVGRendererPlugin = SVGRendererPlugin_1 = __decorate([manaSyringe.singleton({
|
|
3447
3587
|
contrib: g.RenderingPluginContribution
|
|
3448
3588
|
})], SVGRendererPlugin);
|
|
3449
3589
|
var containerModule$1 = manaSyringe.Module(function (register) {
|
|
3450
|
-
|
|
3451
|
-
* register shape renderers
|
|
3452
|
-
*/
|
|
3453
|
-
register(RectRenderer);
|
|
3454
|
-
register(ImageRenderer);
|
|
3455
|
-
register(LineRenderer);
|
|
3456
|
-
register(PolylineRenderer);
|
|
3457
|
-
register(TextRenderer);
|
|
3458
|
-
register(PathRenderer);
|
|
3459
|
-
register({
|
|
3460
|
-
token: ElementRendererFactory,
|
|
3461
|
-
useFactory: function useFactory(ctx) {
|
|
3462
|
-
return function (tagName) {
|
|
3463
|
-
if (tagName === g.Shape.RECT) {
|
|
3464
|
-
return ctx.container.get(RectRenderer);
|
|
3465
|
-
} else if (tagName === g.Shape.IMAGE) {
|
|
3466
|
-
return ctx.container.get(ImageRenderer);
|
|
3467
|
-
} else if (tagName === g.Shape.LINE) {
|
|
3468
|
-
return ctx.container.get(LineRenderer);
|
|
3469
|
-
} else if (tagName === g.Shape.POLYLINE || tagName === g.Shape.POLYGON) {
|
|
3470
|
-
return ctx.container.get(PolylineRenderer);
|
|
3471
|
-
} else if (tagName === g.Shape.TEXT) {
|
|
3472
|
-
return ctx.container.get(TextRenderer);
|
|
3473
|
-
} else if (tagName === g.Shape.PATH) {
|
|
3474
|
-
return ctx.container.get(PathRenderer);
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3477
|
-
return null;
|
|
3478
|
-
};
|
|
3479
|
-
}
|
|
3480
|
-
});
|
|
3481
|
-
register(DefaultElementContribution);
|
|
3590
|
+
register(DefaultCreateElementContribution);
|
|
3482
3591
|
register(SVGRendererPlugin);
|
|
3483
3592
|
});
|
|
3484
3593
|
|
|
3485
3594
|
var Plugin$1 = /*#__PURE__*/function () {
|
|
3486
3595
|
function Plugin() {
|
|
3487
|
-
_classCallCheck$2(this, Plugin);
|
|
3488
|
-
|
|
3489
3596
|
this.name = 'svg-renderer';
|
|
3490
3597
|
}
|
|
3491
3598
|
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
}
|
|
3502
|
-
}]);
|
|
3599
|
+
var _proto = Plugin.prototype;
|
|
3600
|
+
|
|
3601
|
+
_proto.init = function init(container) {
|
|
3602
|
+
container.load(containerModule$1, true);
|
|
3603
|
+
};
|
|
3604
|
+
|
|
3605
|
+
_proto.destroy = function destroy(container) {
|
|
3606
|
+
container.unload(containerModule$1);
|
|
3607
|
+
};
|
|
3503
3608
|
|
|
3504
3609
|
return Plugin;
|
|
3505
3610
|
}();
|
|
3506
3611
|
|
|
3507
3612
|
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
3508
3613
|
__proto__: null,
|
|
3614
|
+
CreateElementContribution: CreateElementContribution,
|
|
3509
3615
|
DEFAULT_VALUE_MAP: DEFAULT_VALUE_MAP,
|
|
3616
|
+
get DefaultCreateElementContribution () { return DefaultCreateElementContribution; },
|
|
3510
3617
|
ElementSVG: ElementSVG,
|
|
3511
3618
|
G_SVG_PREFIX: G_SVG_PREFIX,
|
|
3512
3619
|
Plugin: Plugin$1,
|
|
3513
3620
|
SHAPE2TAGS: SHAPE2TAGS,
|
|
3621
|
+
SHAPE_UPDATE_DEPS: SHAPE_UPDATE_DEPS,
|
|
3514
3622
|
get SVGRendererPlugin () { return SVGRendererPlugin; },
|
|
3515
3623
|
SVG_ATTR_MAP: SVG_ATTR_MAP,
|
|
3516
3624
|
containerModule: containerModule$1,
|
|
3517
|
-
createSVGElement: createSVGElement
|
|
3625
|
+
createSVGElement: createSVGElement,
|
|
3626
|
+
updateImageElementAttribute: updateImageElementAttribute,
|
|
3627
|
+
updateLineElementAttribute: updateLineElementAttribute,
|
|
3628
|
+
updatePathElementAttribute: updatePathElementAttribute,
|
|
3629
|
+
updatePolylineElementAttribute: updatePolylineElementAttribute,
|
|
3630
|
+
updateRectElementAttribute: updateRectElementAttribute,
|
|
3631
|
+
updateTextElementAttribute: updateTextElementAttribute
|
|
3518
3632
|
});
|
|
3519
3633
|
|
|
3520
|
-
function _regeneratorRuntime$
|
|
3634
|
+
function _regeneratorRuntime$3() {
|
|
3521
3635
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3522
|
-
_regeneratorRuntime$
|
|
3636
|
+
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
3523
3637
|
return exports;
|
|
3524
3638
|
};
|
|
3525
3639
|
|
|
@@ -3642,7 +3756,7 @@
|
|
|
3642
3756
|
if ("throw" !== record.type) {
|
|
3643
3757
|
var result = record.arg,
|
|
3644
3758
|
value = result.value;
|
|
3645
|
-
return value && "object" ==
|
|
3759
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3646
3760
|
invoke("next", value, resolve, reject);
|
|
3647
3761
|
}, function (err) {
|
|
3648
3762
|
invoke("throw", err, resolve, reject);
|
|
@@ -3867,7 +3981,7 @@
|
|
|
3867
3981
|
}, exports;
|
|
3868
3982
|
}
|
|
3869
3983
|
|
|
3870
|
-
function asyncGeneratorStep$
|
|
3984
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3871
3985
|
try {
|
|
3872
3986
|
var info = gen[key](arg);
|
|
3873
3987
|
var value = info.value;
|
|
@@ -3883,7 +3997,7 @@
|
|
|
3883
3997
|
}
|
|
3884
3998
|
}
|
|
3885
3999
|
|
|
3886
|
-
function _asyncToGenerator$
|
|
4000
|
+
function _asyncToGenerator$3(fn) {
|
|
3887
4001
|
return function () {
|
|
3888
4002
|
var self = this,
|
|
3889
4003
|
args = arguments;
|
|
@@ -3891,11 +4005,11 @@
|
|
|
3891
4005
|
var gen = fn.apply(self, args);
|
|
3892
4006
|
|
|
3893
4007
|
function _next(value) {
|
|
3894
|
-
asyncGeneratorStep$
|
|
4008
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
3895
4009
|
}
|
|
3896
4010
|
|
|
3897
4011
|
function _throw(err) {
|
|
3898
|
-
asyncGeneratorStep$
|
|
4012
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3899
4013
|
}
|
|
3900
4014
|
|
|
3901
4015
|
_next(undefined);
|
|
@@ -3903,41 +4017,16 @@
|
|
|
3903
4017
|
};
|
|
3904
4018
|
}
|
|
3905
4019
|
|
|
3906
|
-
function
|
|
3907
|
-
if (!(instance instanceof Constructor)) {
|
|
3908
|
-
throw new TypeError("Cannot call a class as a function");
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
|
|
3912
|
-
function _defineProperties$3(target, props) {
|
|
3913
|
-
for (var i = 0; i < props.length; i++) {
|
|
3914
|
-
var descriptor = props[i];
|
|
3915
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
3916
|
-
descriptor.configurable = true;
|
|
3917
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
3918
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3919
|
-
}
|
|
3920
|
-
}
|
|
3921
|
-
|
|
3922
|
-
function _createClass$3(Constructor, protoProps, staticProps) {
|
|
3923
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
3924
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
3925
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
3926
|
-
writable: false
|
|
3927
|
-
});
|
|
3928
|
-
return Constructor;
|
|
3929
|
-
}
|
|
3930
|
-
|
|
3931
|
-
function _unsupportedIterableToArray$1(o, minLen) {
|
|
4020
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
3932
4021
|
if (!o) return;
|
|
3933
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
4022
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
3934
4023
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3935
4024
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3936
4025
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3937
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray
|
|
4026
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
3938
4027
|
}
|
|
3939
4028
|
|
|
3940
|
-
function _arrayLikeToArray
|
|
4029
|
+
function _arrayLikeToArray(arr, len) {
|
|
3941
4030
|
if (len == null || len > arr.length) len = arr.length;
|
|
3942
4031
|
|
|
3943
4032
|
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
@@ -3947,61 +4036,25 @@
|
|
|
3947
4036
|
return arr2;
|
|
3948
4037
|
}
|
|
3949
4038
|
|
|
3950
|
-
function
|
|
4039
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
3951
4040
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4041
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3952
4042
|
|
|
3953
|
-
if (
|
|
3954
|
-
if (
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4043
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
4044
|
+
if (it) o = it;
|
|
4045
|
+
var i = 0;
|
|
4046
|
+
return function () {
|
|
4047
|
+
if (i >= o.length) return {
|
|
4048
|
+
done: true
|
|
4049
|
+
};
|
|
3960
4050
|
return {
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
if (i >= o.length) return {
|
|
3964
|
-
done: true
|
|
3965
|
-
};
|
|
3966
|
-
return {
|
|
3967
|
-
done: false,
|
|
3968
|
-
value: o[i++]
|
|
3969
|
-
};
|
|
3970
|
-
},
|
|
3971
|
-
e: function e(_e) {
|
|
3972
|
-
throw _e;
|
|
3973
|
-
},
|
|
3974
|
-
f: F
|
|
4051
|
+
done: false,
|
|
4052
|
+
value: o[i++]
|
|
3975
4053
|
};
|
|
3976
|
-
}
|
|
3977
|
-
|
|
3978
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4054
|
+
};
|
|
3979
4055
|
}
|
|
3980
4056
|
|
|
3981
|
-
|
|
3982
|
-
didErr = false,
|
|
3983
|
-
err;
|
|
3984
|
-
return {
|
|
3985
|
-
s: function s() {
|
|
3986
|
-
it = it.call(o);
|
|
3987
|
-
},
|
|
3988
|
-
n: function n() {
|
|
3989
|
-
var step = it.next();
|
|
3990
|
-
normalCompletion = step.done;
|
|
3991
|
-
return step;
|
|
3992
|
-
},
|
|
3993
|
-
e: function e(_e2) {
|
|
3994
|
-
didErr = true;
|
|
3995
|
-
err = _e2;
|
|
3996
|
-
},
|
|
3997
|
-
f: function f() {
|
|
3998
|
-
try {
|
|
3999
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
4000
|
-
} finally {
|
|
4001
|
-
if (didErr) throw err;
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
};
|
|
4057
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4005
4058
|
}
|
|
4006
4059
|
|
|
4007
4060
|
var _class$2;
|
|
@@ -4016,120 +4069,98 @@
|
|
|
4016
4069
|
|
|
4017
4070
|
var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
4018
4071
|
function SVGPickerPlugin() {
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
this.sceneGraphService = void 0;
|
|
4072
|
+
this.canvasConfig = void 0;
|
|
4022
4073
|
this.displayObjectPool = void 0;
|
|
4023
4074
|
}
|
|
4024
4075
|
|
|
4025
|
-
|
|
4026
|
-
key: "apply",
|
|
4027
|
-
value: function apply(renderingService) {
|
|
4028
|
-
var _this = this;
|
|
4029
|
-
|
|
4030
|
-
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
4031
|
-
var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
|
|
4032
|
-
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4076
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
4033
4077
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
switch (_context.prev = _context.next) {
|
|
4037
|
-
case 0:
|
|
4038
|
-
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
4039
|
-
_context.prev = 1;
|
|
4040
|
-
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4078
|
+
_proto.apply = function apply(renderingService) {
|
|
4079
|
+
var _this = this;
|
|
4041
4080
|
|
|
4042
|
-
|
|
4043
|
-
|
|
4081
|
+
var doc = this.canvasConfig.document;
|
|
4082
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
4083
|
+
var _ref = _asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee(result) {
|
|
4084
|
+
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
4044
4085
|
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
element = _step.value; // eg. g_svg_circle_345
|
|
4054
|
-
|
|
4055
|
-
id = element && element.getAttribute('id');
|
|
4056
|
-
|
|
4057
|
-
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
4058
|
-
_context.next = 17;
|
|
4059
|
-
break;
|
|
4060
|
-
}
|
|
4061
|
-
|
|
4062
|
-
index = id.lastIndexOf('_');
|
|
4063
|
-
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
4086
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
4087
|
+
while (1) {
|
|
4088
|
+
switch (_context.prev = _context.next) {
|
|
4089
|
+
case 0:
|
|
4090
|
+
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
4091
|
+
_context.prev = 1;
|
|
4092
|
+
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
4064
4093
|
|
|
4065
|
-
|
|
4066
|
-
_context.next = 17;
|
|
4067
|
-
break;
|
|
4068
|
-
}
|
|
4094
|
+
_iterator = _createForOfIteratorHelperLoose((doc || document).elementsFromPoint(clientX, clientY));
|
|
4069
4095
|
|
|
4070
|
-
|
|
4096
|
+
case 4:
|
|
4097
|
+
if ((_step = _iterator()).done) {
|
|
4098
|
+
_context.next = 17;
|
|
4099
|
+
break;
|
|
4100
|
+
}
|
|
4071
4101
|
|
|
4072
|
-
|
|
4073
|
-
_context.next = 17;
|
|
4074
|
-
break;
|
|
4075
|
-
}
|
|
4102
|
+
element = _step.value; // eg. g_svg_circle_345
|
|
4076
4103
|
|
|
4077
|
-
|
|
4078
|
-
return _context.abrupt("return", result);
|
|
4104
|
+
id = element && element.getAttribute('id');
|
|
4079
4105
|
|
|
4080
|
-
|
|
4081
|
-
_context.next =
|
|
4106
|
+
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
4107
|
+
_context.next = 15;
|
|
4082
4108
|
break;
|
|
4109
|
+
}
|
|
4083
4110
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
break;
|
|
4111
|
+
index = id.lastIndexOf('_');
|
|
4112
|
+
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
4087
4113
|
|
|
4088
|
-
|
|
4089
|
-
_context.
|
|
4090
|
-
|
|
4114
|
+
if (!(target && target.isInteractive())) {
|
|
4115
|
+
_context.next = 15;
|
|
4116
|
+
break;
|
|
4117
|
+
}
|
|
4091
4118
|
|
|
4092
|
-
|
|
4119
|
+
targets.push(target);
|
|
4093
4120
|
|
|
4094
|
-
|
|
4095
|
-
_context.
|
|
4121
|
+
if (!topmost) {
|
|
4122
|
+
_context.next = 15;
|
|
4123
|
+
break;
|
|
4124
|
+
}
|
|
4096
4125
|
|
|
4097
|
-
|
|
4126
|
+
result.picked = targets;
|
|
4127
|
+
return _context.abrupt("return", result);
|
|
4098
4128
|
|
|
4099
|
-
|
|
4129
|
+
case 15:
|
|
4130
|
+
_context.next = 4;
|
|
4131
|
+
break;
|
|
4100
4132
|
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4133
|
+
case 17:
|
|
4134
|
+
result.picked = targets;
|
|
4135
|
+
_context.next = 23;
|
|
4136
|
+
break;
|
|
4105
4137
|
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4138
|
+
case 20:
|
|
4139
|
+
_context.prev = 20;
|
|
4140
|
+
_context.t0 = _context["catch"](1);
|
|
4141
|
+
result.picked = [];
|
|
4110
4142
|
|
|
4111
|
-
|
|
4112
|
-
|
|
4143
|
+
case 23:
|
|
4144
|
+
return _context.abrupt("return", result);
|
|
4113
4145
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
}
|
|
4146
|
+
case 24:
|
|
4147
|
+
case "end":
|
|
4148
|
+
return _context.stop();
|
|
4118
4149
|
}
|
|
4119
|
-
}
|
|
4120
|
-
})
|
|
4150
|
+
}
|
|
4151
|
+
}, _callee, null, [[1, 20]]);
|
|
4152
|
+
}));
|
|
4121
4153
|
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
}]);
|
|
4154
|
+
return function (_x) {
|
|
4155
|
+
return _ref.apply(this, arguments);
|
|
4156
|
+
};
|
|
4157
|
+
}());
|
|
4158
|
+
};
|
|
4128
4159
|
|
|
4129
4160
|
return SVGPickerPlugin;
|
|
4130
4161
|
}(), _class$2.tag = 'SVGPicker', _class$2);
|
|
4131
4162
|
|
|
4132
|
-
__decorate([manaSyringe.inject(g.
|
|
4163
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], SVGPickerPlugin.prototype, "canvasConfig", void 0);
|
|
4133
4164
|
|
|
4134
4165
|
__decorate([manaSyringe.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], SVGPickerPlugin.prototype, "displayObjectPool", void 0);
|
|
4135
4166
|
|
|
@@ -4142,22 +4173,18 @@
|
|
|
4142
4173
|
|
|
4143
4174
|
var Plugin$2 = /*#__PURE__*/function () {
|
|
4144
4175
|
function Plugin() {
|
|
4145
|
-
_classCallCheck$3(this, Plugin);
|
|
4146
|
-
|
|
4147
4176
|
this.name = 'svg-picker';
|
|
4148
4177
|
}
|
|
4149
4178
|
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
}
|
|
4160
|
-
}]);
|
|
4179
|
+
var _proto = Plugin.prototype;
|
|
4180
|
+
|
|
4181
|
+
_proto.init = function init(container) {
|
|
4182
|
+
container.load(containerModule$2, true);
|
|
4183
|
+
};
|
|
4184
|
+
|
|
4185
|
+
_proto.destroy = function destroy(container) {
|
|
4186
|
+
container.unload(containerModule$2);
|
|
4187
|
+
};
|
|
4161
4188
|
|
|
4162
4189
|
return Plugin;
|
|
4163
4190
|
}();
|
|
@@ -4169,84 +4196,95 @@
|
|
|
4169
4196
|
|
|
4170
4197
|
var SVGContextService = /*#__PURE__*/function () {
|
|
4171
4198
|
function SVGContextService() {
|
|
4172
|
-
_classCallCheck(this, SVGContextService);
|
|
4173
|
-
|
|
4174
4199
|
this.$container = void 0;
|
|
4175
4200
|
this.$namespace = void 0;
|
|
4176
4201
|
this.dpr = void 0;
|
|
4177
4202
|
this.canvasConfig = void 0;
|
|
4178
4203
|
}
|
|
4179
4204
|
|
|
4180
|
-
|
|
4181
|
-
key: "init",
|
|
4182
|
-
value: function init() {
|
|
4183
|
-
var container = this.canvasConfig.container; // create container
|
|
4205
|
+
var _proto = SVGContextService.prototype;
|
|
4184
4206
|
|
|
4185
|
-
|
|
4207
|
+
_proto.init = /*#__PURE__*/function () {
|
|
4208
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4209
|
+
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
4186
4210
|
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4211
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4212
|
+
while (1) {
|
|
4213
|
+
switch (_context.prev = _context.next) {
|
|
4214
|
+
case 0:
|
|
4215
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
4191
4216
|
|
|
4192
|
-
|
|
4193
|
-
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
4194
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
4195
|
-
this.$container.appendChild($namespace);
|
|
4196
|
-
this.$namespace = $namespace;
|
|
4197
|
-
}
|
|
4217
|
+
this.$container = g.isString(container) ? (doc || document).getElementById(container) : container;
|
|
4198
4218
|
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4219
|
+
if (this.$container) {
|
|
4220
|
+
if (!this.$container.style.position) {
|
|
4221
|
+
this.$container.style.position = 'relative';
|
|
4222
|
+
}
|
|
4203
4223
|
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
key: "getContext",
|
|
4211
|
-
value: function getContext() {
|
|
4212
|
-
return this.$namespace;
|
|
4213
|
-
}
|
|
4214
|
-
}, {
|
|
4215
|
-
key: "getDPR",
|
|
4216
|
-
value: function getDPR() {
|
|
4217
|
-
return this.dpr;
|
|
4218
|
-
}
|
|
4219
|
-
}, {
|
|
4220
|
-
key: "getBoundingClientRect",
|
|
4221
|
-
value: function getBoundingClientRect() {
|
|
4222
|
-
var _this$$namespace;
|
|
4224
|
+
$namespace = createSVGElement('svg', doc);
|
|
4225
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
4226
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
4227
|
+
this.$container.appendChild($namespace);
|
|
4228
|
+
this.$namespace = $namespace;
|
|
4229
|
+
}
|
|
4223
4230
|
|
|
4224
|
-
|
|
4231
|
+
dpr = window.devicePixelRatio || 1;
|
|
4232
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
4233
|
+
this.dpr = dpr;
|
|
4234
|
+
|
|
4235
|
+
case 6:
|
|
4236
|
+
case "end":
|
|
4237
|
+
return _context.stop();
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
}, _callee, this);
|
|
4241
|
+
}));
|
|
4242
|
+
|
|
4243
|
+
function init() {
|
|
4244
|
+
return _init.apply(this, arguments);
|
|
4225
4245
|
}
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4246
|
+
|
|
4247
|
+
return init;
|
|
4248
|
+
}() // @ts-ignore
|
|
4249
|
+
;
|
|
4250
|
+
|
|
4251
|
+
_proto.getDomElement = function getDomElement() {
|
|
4252
|
+
return this.$namespace;
|
|
4253
|
+
};
|
|
4254
|
+
|
|
4255
|
+
_proto.getContext = function getContext() {
|
|
4256
|
+
return this.$namespace;
|
|
4257
|
+
};
|
|
4258
|
+
|
|
4259
|
+
_proto.getDPR = function getDPR() {
|
|
4260
|
+
return this.dpr;
|
|
4261
|
+
};
|
|
4262
|
+
|
|
4263
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
4264
|
+
var _this$$namespace;
|
|
4265
|
+
|
|
4266
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
4267
|
+
};
|
|
4268
|
+
|
|
4269
|
+
_proto.destroy = function destroy() {
|
|
4270
|
+
// destroy context
|
|
4271
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
4272
|
+
this.$container.removeChild(this.$namespace);
|
|
4233
4273
|
}
|
|
4234
|
-
}
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
}
|
|
4274
|
+
};
|
|
4275
|
+
|
|
4276
|
+
_proto.resize = function resize(width, height) {
|
|
4277
|
+
if (this.$namespace) {
|
|
4278
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
4279
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
4241
4280
|
}
|
|
4242
|
-
}
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
}
|
|
4281
|
+
};
|
|
4282
|
+
|
|
4283
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
4284
|
+
if (this.$container) {
|
|
4285
|
+
this.$container.style.cursor = cursor;
|
|
4248
4286
|
}
|
|
4249
|
-
}
|
|
4287
|
+
};
|
|
4250
4288
|
|
|
4251
4289
|
return SVGContextService;
|
|
4252
4290
|
}();
|
|
@@ -4265,37 +4303,29 @@
|
|
|
4265
4303
|
});
|
|
4266
4304
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
4267
4305
|
function ContextRegisterPlugin() {
|
|
4268
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
4269
|
-
|
|
4270
4306
|
this.name = 'svg-context-register';
|
|
4271
4307
|
}
|
|
4272
4308
|
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
}
|
|
4283
|
-
}]);
|
|
4309
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
4310
|
+
|
|
4311
|
+
_proto.init = function init(container) {
|
|
4312
|
+
container.load(containerModule$3, true);
|
|
4313
|
+
};
|
|
4314
|
+
|
|
4315
|
+
_proto.destroy = function destroy(container) {
|
|
4316
|
+
container.unload(containerModule$3);
|
|
4317
|
+
};
|
|
4284
4318
|
|
|
4285
4319
|
return ContextRegisterPlugin;
|
|
4286
4320
|
}();
|
|
4287
4321
|
|
|
4288
4322
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
var _super = _createSuper(Renderer);
|
|
4323
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
4292
4324
|
|
|
4293
4325
|
function Renderer(config) {
|
|
4294
4326
|
var _this;
|
|
4295
4327
|
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
_this = _super.call(this, config);
|
|
4328
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
4299
4329
|
|
|
4300
4330
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
4301
4331
|
|
|
@@ -4308,7 +4338,7 @@
|
|
|
4308
4338
|
return _this;
|
|
4309
4339
|
}
|
|
4310
4340
|
|
|
4311
|
-
return
|
|
4341
|
+
return Renderer;
|
|
4312
4342
|
}(g.AbstractRenderer);
|
|
4313
4343
|
|
|
4314
4344
|
exports.DomInteraction = index_esm;
|