@antv/g-svg 1.1.0 → 1.1.3-alpha.0
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/{es → dist}/ContextRegisterPlugin.d.ts +8 -7
- package/dist/ContextRegisterPlugin.d.ts.map +1 -0
- package/{lib → dist}/SVGContextService.d.ts +16 -15
- package/dist/SVGContextService.d.ts.map +1 -0
- package/{lib → dist}/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +156 -0
- package/dist/index.js +181 -0
- package/dist/index.umd.js +3909 -0
- package/dist/index.umd.min.js +7 -16
- package/package.json +26 -32
- package/es/ContextRegisterPlugin.js +0 -28
- package/es/SVGContextService.d.ts +0 -15
- package/es/SVGContextService.js +0 -80
- package/es/index.d.ts +0 -9
- package/es/index.js +0 -31
- package/es/utils/format.d.ts +0 -6
- package/es/utils/format.js +0 -33
- package/lib/ContextRegisterPlugin.d.ts +0 -7
- package/lib/ContextRegisterPlugin.js +0 -37
- package/lib/SVGContextService.js +0 -89
- package/lib/index.js +0 -54
- package/lib/utils/format.d.ts +0 -6
- package/lib/utils/format.js +0 -40
|
@@ -0,0 +1,3909 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g'), require('mana-syringe')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@antv/g', 'mana-syringe'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.SVG = {}), global.window.G, global.window.G.ManaSyringe));
|
|
5
|
+
}(this, (function (exports, g, manaSyringe) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _inheritsLoose(subClass, superClass) {
|
|
8
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
9
|
+
subClass.prototype.constructor = subClass;
|
|
10
|
+
|
|
11
|
+
_setPrototypeOf(subClass, superClass);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _setPrototypeOf(o, p) {
|
|
15
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
16
|
+
o.__proto__ = p;
|
|
17
|
+
return o;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return _setPrototypeOf(o, p);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/******************************************************************************
|
|
24
|
+
Copyright (c) Microsoft Corporation.
|
|
25
|
+
|
|
26
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
27
|
+
purpose with or without fee is hereby granted.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
30
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
31
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
32
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
33
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
34
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
35
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
36
|
+
***************************************************************************** */
|
|
37
|
+
|
|
38
|
+
function __decorate(decorators, target, key, desc) {
|
|
39
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
40
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
41
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
42
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function __metadata(metadataKey, metadataValue) {
|
|
46
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function _regeneratorRuntime() {
|
|
50
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
51
|
+
_regeneratorRuntime = function _regeneratorRuntime() {
|
|
52
|
+
return exports;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var exports = {},
|
|
56
|
+
Op = Object.prototype,
|
|
57
|
+
hasOwn = Op.hasOwnProperty,
|
|
58
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
59
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
60
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
61
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
62
|
+
|
|
63
|
+
function define(obj, key, value) {
|
|
64
|
+
return Object.defineProperty(obj, key, {
|
|
65
|
+
value: value,
|
|
66
|
+
enumerable: !0,
|
|
67
|
+
configurable: !0,
|
|
68
|
+
writable: !0
|
|
69
|
+
}), obj[key];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
define({}, "");
|
|
74
|
+
} catch (err) {
|
|
75
|
+
define = function define(obj, key, value) {
|
|
76
|
+
return obj[key] = value;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
81
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
82
|
+
generator = Object.create(protoGenerator.prototype),
|
|
83
|
+
context = new Context(tryLocsList || []);
|
|
84
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
85
|
+
var state = "suspendedStart";
|
|
86
|
+
return function (method, arg) {
|
|
87
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
88
|
+
|
|
89
|
+
if ("completed" === state) {
|
|
90
|
+
if ("throw" === method) throw arg;
|
|
91
|
+
return doneResult();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (context.method = method, context.arg = arg;;) {
|
|
95
|
+
var delegate = context.delegate;
|
|
96
|
+
|
|
97
|
+
if (delegate) {
|
|
98
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
99
|
+
|
|
100
|
+
if (delegateResult) {
|
|
101
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
102
|
+
return delegateResult;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
107
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
108
|
+
context.dispatchException(context.arg);
|
|
109
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
110
|
+
state = "executing";
|
|
111
|
+
var record = tryCatch(innerFn, self, context);
|
|
112
|
+
|
|
113
|
+
if ("normal" === record.type) {
|
|
114
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
115
|
+
return {
|
|
116
|
+
value: record.arg,
|
|
117
|
+
done: context.done
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}(innerFn, self, context), generator;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function tryCatch(fn, obj, arg) {
|
|
128
|
+
try {
|
|
129
|
+
return {
|
|
130
|
+
type: "normal",
|
|
131
|
+
arg: fn.call(obj, arg)
|
|
132
|
+
};
|
|
133
|
+
} catch (err) {
|
|
134
|
+
return {
|
|
135
|
+
type: "throw",
|
|
136
|
+
arg: err
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
exports.wrap = wrap;
|
|
142
|
+
var ContinueSentinel = {};
|
|
143
|
+
|
|
144
|
+
function Generator() {}
|
|
145
|
+
|
|
146
|
+
function GeneratorFunction() {}
|
|
147
|
+
|
|
148
|
+
function GeneratorFunctionPrototype() {}
|
|
149
|
+
|
|
150
|
+
var IteratorPrototype = {};
|
|
151
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
152
|
+
return this;
|
|
153
|
+
});
|
|
154
|
+
var getProto = Object.getPrototypeOf,
|
|
155
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
156
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
157
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
158
|
+
|
|
159
|
+
function defineIteratorMethods(prototype) {
|
|
160
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
161
|
+
define(prototype, method, function (arg) {
|
|
162
|
+
return this._invoke(method, arg);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
168
|
+
function invoke(method, arg, resolve, reject) {
|
|
169
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
170
|
+
|
|
171
|
+
if ("throw" !== record.type) {
|
|
172
|
+
var result = record.arg,
|
|
173
|
+
value = result.value;
|
|
174
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
175
|
+
invoke("next", value, resolve, reject);
|
|
176
|
+
}, function (err) {
|
|
177
|
+
invoke("throw", err, resolve, reject);
|
|
178
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
179
|
+
result.value = unwrapped, resolve(result);
|
|
180
|
+
}, function (error) {
|
|
181
|
+
return invoke("throw", error, resolve, reject);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
reject(record.arg);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var previousPromise;
|
|
189
|
+
|
|
190
|
+
this._invoke = function (method, arg) {
|
|
191
|
+
function callInvokeWithMethodAndArg() {
|
|
192
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
193
|
+
invoke(method, arg, resolve, reject);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
202
|
+
var method = delegate.iterator[context.method];
|
|
203
|
+
|
|
204
|
+
if (undefined === method) {
|
|
205
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
206
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
207
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return ContinueSentinel;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
214
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
215
|
+
var info = record.arg;
|
|
216
|
+
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);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function pushTryEntry(locs) {
|
|
220
|
+
var entry = {
|
|
221
|
+
tryLoc: locs[0]
|
|
222
|
+
};
|
|
223
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function resetTryEntry(entry) {
|
|
227
|
+
var record = entry.completion || {};
|
|
228
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function Context(tryLocsList) {
|
|
232
|
+
this.tryEntries = [{
|
|
233
|
+
tryLoc: "root"
|
|
234
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function values(iterable) {
|
|
238
|
+
if (iterable) {
|
|
239
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
240
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
241
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
242
|
+
|
|
243
|
+
if (!isNaN(iterable.length)) {
|
|
244
|
+
var i = -1,
|
|
245
|
+
next = function next() {
|
|
246
|
+
for (; ++i < iterable.length;) {
|
|
247
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return next.value = undefined, next.done = !0, next;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return next.next = next;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
next: doneResult
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function doneResult() {
|
|
263
|
+
return {
|
|
264
|
+
value: undefined,
|
|
265
|
+
done: !0
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
270
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
271
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
272
|
+
}, exports.mark = function (genFun) {
|
|
273
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
274
|
+
}, exports.awrap = function (arg) {
|
|
275
|
+
return {
|
|
276
|
+
__await: arg
|
|
277
|
+
};
|
|
278
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
279
|
+
return this;
|
|
280
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
281
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
282
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
283
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
284
|
+
return result.done ? result.value : iter.next();
|
|
285
|
+
});
|
|
286
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
287
|
+
return this;
|
|
288
|
+
}), define(Gp, "toString", function () {
|
|
289
|
+
return "[object Generator]";
|
|
290
|
+
}), exports.keys = function (object) {
|
|
291
|
+
var keys = [];
|
|
292
|
+
|
|
293
|
+
for (var key in object) {
|
|
294
|
+
keys.push(key);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return keys.reverse(), function next() {
|
|
298
|
+
for (; keys.length;) {
|
|
299
|
+
var key = keys.pop();
|
|
300
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return next.done = !0, next;
|
|
304
|
+
};
|
|
305
|
+
}, exports.values = values, Context.prototype = {
|
|
306
|
+
constructor: Context,
|
|
307
|
+
reset: function reset(skipTempReset) {
|
|
308
|
+
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) {
|
|
309
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
stop: function stop() {
|
|
313
|
+
this.done = !0;
|
|
314
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
315
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
316
|
+
return this.rval;
|
|
317
|
+
},
|
|
318
|
+
dispatchException: function dispatchException(exception) {
|
|
319
|
+
if (this.done) throw exception;
|
|
320
|
+
var context = this;
|
|
321
|
+
|
|
322
|
+
function handle(loc, caught) {
|
|
323
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
327
|
+
var entry = this.tryEntries[i],
|
|
328
|
+
record = entry.completion;
|
|
329
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
330
|
+
|
|
331
|
+
if (entry.tryLoc <= this.prev) {
|
|
332
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
333
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
334
|
+
|
|
335
|
+
if (hasCatch && hasFinally) {
|
|
336
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
337
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
338
|
+
} else if (hasCatch) {
|
|
339
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
340
|
+
} else {
|
|
341
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
342
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
abrupt: function abrupt(type, arg) {
|
|
348
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
349
|
+
var entry = this.tryEntries[i];
|
|
350
|
+
|
|
351
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
352
|
+
var finallyEntry = entry;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
358
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
359
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
360
|
+
},
|
|
361
|
+
complete: function complete(record, afterLoc) {
|
|
362
|
+
if ("throw" === record.type) throw record.arg;
|
|
363
|
+
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;
|
|
364
|
+
},
|
|
365
|
+
finish: function finish(finallyLoc) {
|
|
366
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
367
|
+
var entry = this.tryEntries[i];
|
|
368
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
catch: function _catch(tryLoc) {
|
|
372
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
373
|
+
var entry = this.tryEntries[i];
|
|
374
|
+
|
|
375
|
+
if (entry.tryLoc === tryLoc) {
|
|
376
|
+
var record = entry.completion;
|
|
377
|
+
|
|
378
|
+
if ("throw" === record.type) {
|
|
379
|
+
var thrown = record.arg;
|
|
380
|
+
resetTryEntry(entry);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return thrown;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
throw new Error("illegal catch attempt");
|
|
388
|
+
},
|
|
389
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
390
|
+
return this.delegate = {
|
|
391
|
+
iterator: values(iterable),
|
|
392
|
+
resultName: resultName,
|
|
393
|
+
nextLoc: nextLoc
|
|
394
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
395
|
+
}
|
|
396
|
+
}, exports;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
400
|
+
try {
|
|
401
|
+
var info = gen[key](arg);
|
|
402
|
+
var value = info.value;
|
|
403
|
+
} catch (error) {
|
|
404
|
+
reject(error);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (info.done) {
|
|
409
|
+
resolve(value);
|
|
410
|
+
} else {
|
|
411
|
+
Promise.resolve(value).then(_next, _throw);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function _asyncToGenerator(fn) {
|
|
416
|
+
return function () {
|
|
417
|
+
var self = this,
|
|
418
|
+
args = arguments;
|
|
419
|
+
return new Promise(function (resolve, reject) {
|
|
420
|
+
var gen = fn.apply(self, args);
|
|
421
|
+
|
|
422
|
+
function _next(value) {
|
|
423
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function _throw(err) {
|
|
427
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
_next(undefined);
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
var _class;
|
|
436
|
+
|
|
437
|
+
var DOMInteractionPlugin_1;
|
|
438
|
+
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
439
|
+
/**
|
|
440
|
+
* listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
var DOMInteractionPlugin = DOMInteractionPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
444
|
+
function DOMInteractionPlugin() {
|
|
445
|
+
this.contextService = void 0;
|
|
446
|
+
this.renderingContext = void 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
var _proto = DOMInteractionPlugin.prototype;
|
|
450
|
+
|
|
451
|
+
_proto.apply = function apply(renderingService) {
|
|
452
|
+
var _this = this;
|
|
453
|
+
|
|
454
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView;
|
|
455
|
+
var SUPPORT_ONLY_TOUCH = canvas.supportTouchEvent && MOBILE_REGEX.test(navigator.userAgent);
|
|
456
|
+
|
|
457
|
+
var onPointerMove = function onPointerMove(ev) {
|
|
458
|
+
renderingService.hooks.pointerMove.call(ev);
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
var onPointerUp = function onPointerUp(ev) {
|
|
462
|
+
renderingService.hooks.pointerUp.call(ev);
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
var onPointerDown = function onPointerDown(ev) {
|
|
466
|
+
renderingService.hooks.pointerDown.call(ev);
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
var onPointerOver = function onPointerOver(ev) {
|
|
470
|
+
renderingService.hooks.pointerOver.call(ev);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
var onPointerOut = function onPointerOut(ev) {
|
|
474
|
+
renderingService.hooks.pointerOut.call(ev);
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
var onPointerCancel = function onPointerCancel(ev) {
|
|
478
|
+
renderingService.hooks.pointerCancel.call(ev);
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
var onPointerWheel = function onPointerWheel(ev) {
|
|
482
|
+
renderingService.hooks.pointerWheel.call(ev);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
var addPointerEventListener = function addPointerEventListener($el) {
|
|
486
|
+
globalThis.document.addEventListener('pointermove', onPointerMove, true);
|
|
487
|
+
$el.addEventListener('pointerdown', onPointerDown, true);
|
|
488
|
+
$el.addEventListener('pointerleave', onPointerOut, true);
|
|
489
|
+
$el.addEventListener('pointerover', onPointerOver, true);
|
|
490
|
+
globalThis.addEventListener('pointerup', onPointerUp, true);
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
var addTouchEventListener = function addTouchEventListener($el) {
|
|
494
|
+
$el.addEventListener('touchstart', onPointerDown, true);
|
|
495
|
+
$el.addEventListener('touchend', onPointerUp, true);
|
|
496
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
497
|
+
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
var addMouseEventListener = function addMouseEventListener($el) {
|
|
501
|
+
globalThis.document.addEventListener('mousemove', onPointerMove, true);
|
|
502
|
+
$el.addEventListener('mousedown', onPointerDown, true);
|
|
503
|
+
$el.addEventListener('mouseout', onPointerOut, true);
|
|
504
|
+
$el.addEventListener('mouseover', onPointerOver, true);
|
|
505
|
+
globalThis.addEventListener('mouseup', onPointerUp, true);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
var removePointerEventListener = function removePointerEventListener($el) {
|
|
509
|
+
globalThis.document.removeEventListener('pointermove', onPointerMove, true);
|
|
510
|
+
$el.removeEventListener('pointerdown', onPointerDown, true);
|
|
511
|
+
$el.removeEventListener('pointerleave', onPointerOut, true);
|
|
512
|
+
$el.removeEventListener('pointerover', onPointerOver, true);
|
|
513
|
+
globalThis.removeEventListener('pointerup', onPointerUp, true);
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
517
|
+
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
518
|
+
$el.removeEventListener('touchend', onPointerUp, true);
|
|
519
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
523
|
+
globalThis.document.removeEventListener('mousemove', onPointerMove, true);
|
|
524
|
+
$el.removeEventListener('mousedown', onPointerDown, true);
|
|
525
|
+
$el.removeEventListener('mouseout', onPointerOut, true);
|
|
526
|
+
$el.removeEventListener('mouseover', onPointerOver, true);
|
|
527
|
+
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
531
|
+
var $el;
|
|
532
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
533
|
+
while (1) {
|
|
534
|
+
switch (_context.prev = _context.next) {
|
|
535
|
+
case 0:
|
|
536
|
+
$el = _this.contextService.getDomElement();
|
|
537
|
+
|
|
538
|
+
if (canvas.supportPointerEvent) {
|
|
539
|
+
addPointerEventListener($el);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (SUPPORT_ONLY_TOUCH) {
|
|
543
|
+
addTouchEventListener($el);
|
|
544
|
+
} else if (!canvas.supportTouchEvent) {
|
|
545
|
+
if (!canvas.supportPointerEvent) {
|
|
546
|
+
addMouseEventListener($el);
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
addTouchEventListener($el);
|
|
550
|
+
|
|
551
|
+
if (!canvas.supportPointerEvent) {
|
|
552
|
+
addMouseEventListener($el);
|
|
553
|
+
}
|
|
554
|
+
} // use passive event listeners
|
|
555
|
+
// @see https://zhuanlan.zhihu.com/p/24555031
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
$el.addEventListener('wheel', onPointerWheel, {
|
|
559
|
+
passive: true,
|
|
560
|
+
capture: true
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
case 4:
|
|
564
|
+
case "end":
|
|
565
|
+
return _context.stop();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}, _callee);
|
|
569
|
+
})));
|
|
570
|
+
renderingService.hooks.destroy.tap(DOMInteractionPlugin_1.tag, function () {
|
|
571
|
+
var $el = _this.contextService.getDomElement();
|
|
572
|
+
|
|
573
|
+
if (canvas.supportPointerEvent) {
|
|
574
|
+
removePointerEventListener($el);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (SUPPORT_ONLY_TOUCH) {
|
|
578
|
+
removeTouchEventListener($el);
|
|
579
|
+
} else if (!canvas.supportTouchEvent) {
|
|
580
|
+
if (!canvas.supportPointerEvent) {
|
|
581
|
+
removeMouseEventListener($el);
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
removeTouchEventListener($el);
|
|
585
|
+
|
|
586
|
+
if (!canvas.supportPointerEvent) {
|
|
587
|
+
removeMouseEventListener($el);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
$el.removeEventListener('wheel', onPointerWheel, true);
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
return DOMInteractionPlugin;
|
|
596
|
+
}(), _class.tag = 'DOMInteraction', _class);
|
|
597
|
+
|
|
598
|
+
__decorate([manaSyringe.inject(g.ContextService), __metadata("design:type", Object)], DOMInteractionPlugin.prototype, "contextService", void 0);
|
|
599
|
+
|
|
600
|
+
__decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], DOMInteractionPlugin.prototype, "renderingContext", void 0);
|
|
601
|
+
|
|
602
|
+
DOMInteractionPlugin = DOMInteractionPlugin_1 = __decorate([manaSyringe.singleton({
|
|
603
|
+
contrib: g.RenderingPluginContribution
|
|
604
|
+
})], DOMInteractionPlugin);
|
|
605
|
+
var containerModule = manaSyringe.Module(function (register) {
|
|
606
|
+
register(DOMInteractionPlugin);
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
var Plugin = /*#__PURE__*/function () {
|
|
610
|
+
function Plugin() {
|
|
611
|
+
this.name = 'dom-interaction';
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
var _proto = Plugin.prototype;
|
|
615
|
+
|
|
616
|
+
_proto.init = function init(container) {
|
|
617
|
+
container.load(containerModule, true);
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
_proto.destroy = function destroy(container) {
|
|
621
|
+
container.unload(containerModule);
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
return Plugin;
|
|
625
|
+
}();
|
|
626
|
+
|
|
627
|
+
var index_esm = /*#__PURE__*/Object.freeze({
|
|
628
|
+
__proto__: null,
|
|
629
|
+
Plugin: Plugin
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
633
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
634
|
+
if (ar || !(i in from)) {
|
|
635
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
636
|
+
ar[i] = from[i];
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
640
|
+
};
|
|
641
|
+
var BrowserInfo = /** @class */ (function () {
|
|
642
|
+
function BrowserInfo(name, version, os) {
|
|
643
|
+
this.name = name;
|
|
644
|
+
this.version = version;
|
|
645
|
+
this.os = os;
|
|
646
|
+
this.type = 'browser';
|
|
647
|
+
}
|
|
648
|
+
return BrowserInfo;
|
|
649
|
+
}());
|
|
650
|
+
var NodeInfo = /** @class */ (function () {
|
|
651
|
+
function NodeInfo(version) {
|
|
652
|
+
this.version = version;
|
|
653
|
+
this.type = 'node';
|
|
654
|
+
this.name = 'node';
|
|
655
|
+
this.os = process.platform;
|
|
656
|
+
}
|
|
657
|
+
return NodeInfo;
|
|
658
|
+
}());
|
|
659
|
+
var SearchBotDeviceInfo = /** @class */ (function () {
|
|
660
|
+
function SearchBotDeviceInfo(name, version, os, bot) {
|
|
661
|
+
this.name = name;
|
|
662
|
+
this.version = version;
|
|
663
|
+
this.os = os;
|
|
664
|
+
this.bot = bot;
|
|
665
|
+
this.type = 'bot-device';
|
|
666
|
+
}
|
|
667
|
+
return SearchBotDeviceInfo;
|
|
668
|
+
}());
|
|
669
|
+
var BotInfo = /** @class */ (function () {
|
|
670
|
+
function BotInfo() {
|
|
671
|
+
this.type = 'bot';
|
|
672
|
+
this.bot = true; // NOTE: deprecated test name instead
|
|
673
|
+
this.name = 'bot';
|
|
674
|
+
this.version = null;
|
|
675
|
+
this.os = null;
|
|
676
|
+
}
|
|
677
|
+
return BotInfo;
|
|
678
|
+
}());
|
|
679
|
+
var ReactNativeInfo = /** @class */ (function () {
|
|
680
|
+
function ReactNativeInfo() {
|
|
681
|
+
this.type = 'react-native';
|
|
682
|
+
this.name = 'react-native';
|
|
683
|
+
this.version = null;
|
|
684
|
+
this.os = null;
|
|
685
|
+
}
|
|
686
|
+
return ReactNativeInfo;
|
|
687
|
+
}());
|
|
688
|
+
// tslint:disable-next-line:max-line-length
|
|
689
|
+
var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;
|
|
690
|
+
var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/;
|
|
691
|
+
var REQUIRED_VERSION_PARTS = 3;
|
|
692
|
+
var userAgentRules = [
|
|
693
|
+
['aol', /AOLShield\/([0-9\._]+)/],
|
|
694
|
+
['edge', /Edge\/([0-9\._]+)/],
|
|
695
|
+
['edge-ios', /EdgiOS\/([0-9\._]+)/],
|
|
696
|
+
['yandexbrowser', /YaBrowser\/([0-9\._]+)/],
|
|
697
|
+
['kakaotalk', /KAKAOTALK\s([0-9\.]+)/],
|
|
698
|
+
['samsung', /SamsungBrowser\/([0-9\.]+)/],
|
|
699
|
+
['silk', /\bSilk\/([0-9._-]+)\b/],
|
|
700
|
+
['miui', /MiuiBrowser\/([0-9\.]+)$/],
|
|
701
|
+
['beaker', /BeakerBrowser\/([0-9\.]+)/],
|
|
702
|
+
['edge-chromium', /EdgA?\/([0-9\.]+)/],
|
|
703
|
+
[
|
|
704
|
+
'chromium-webview',
|
|
705
|
+
/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/,
|
|
706
|
+
],
|
|
707
|
+
['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
|
|
708
|
+
['phantomjs', /PhantomJS\/([0-9\.]+)(:?\s|$)/],
|
|
709
|
+
['crios', /CriOS\/([0-9\.]+)(:?\s|$)/],
|
|
710
|
+
['firefox', /Firefox\/([0-9\.]+)(?:\s|$)/],
|
|
711
|
+
['fxios', /FxiOS\/([0-9\.]+)/],
|
|
712
|
+
['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
|
|
713
|
+
['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
|
|
714
|
+
['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
|
|
715
|
+
['pie', /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
|
|
716
|
+
['pie', /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
|
|
717
|
+
['netfront', /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
|
|
718
|
+
['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
|
|
719
|
+
['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
|
|
720
|
+
['ie', /MSIE\s(7\.0)/],
|
|
721
|
+
['bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/],
|
|
722
|
+
['android', /Android\s([0-9\.]+)/],
|
|
723
|
+
['ios', /Version\/([0-9\._]+).*Mobile.*Safari.*/],
|
|
724
|
+
['safari', /Version\/([0-9\._]+).*Safari/],
|
|
725
|
+
['facebook', /FB[AS]V\/([0-9\.]+)/],
|
|
726
|
+
['instagram', /Instagram\s([0-9\.]+)/],
|
|
727
|
+
['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/],
|
|
728
|
+
['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
|
|
729
|
+
['curl', /^curl\/([0-9\.]+)$/],
|
|
730
|
+
['searchbot', SEARCHBOX_UA_REGEX],
|
|
731
|
+
];
|
|
732
|
+
var operatingSystemRules = [
|
|
733
|
+
['iOS', /iP(hone|od|ad)/],
|
|
734
|
+
['Android OS', /Android/],
|
|
735
|
+
['BlackBerry OS', /BlackBerry|BB10/],
|
|
736
|
+
['Windows Mobile', /IEMobile/],
|
|
737
|
+
['Amazon OS', /Kindle/],
|
|
738
|
+
['Windows 3.11', /Win16/],
|
|
739
|
+
['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],
|
|
740
|
+
['Windows 98', /(Windows 98)|(Win98)/],
|
|
741
|
+
['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],
|
|
742
|
+
['Windows XP', /(Windows NT 5.1)|(Windows XP)/],
|
|
743
|
+
['Windows Server 2003', /(Windows NT 5.2)/],
|
|
744
|
+
['Windows Vista', /(Windows NT 6.0)/],
|
|
745
|
+
['Windows 7', /(Windows NT 6.1)/],
|
|
746
|
+
['Windows 8', /(Windows NT 6.2)/],
|
|
747
|
+
['Windows 8.1', /(Windows NT 6.3)/],
|
|
748
|
+
['Windows 10', /(Windows NT 10.0)/],
|
|
749
|
+
['Windows ME', /Windows ME/],
|
|
750
|
+
['Windows CE', /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
|
|
751
|
+
['Open BSD', /OpenBSD/],
|
|
752
|
+
['Sun OS', /SunOS/],
|
|
753
|
+
['Chrome OS', /CrOS/],
|
|
754
|
+
['Linux', /(Linux)|(X11)/],
|
|
755
|
+
['Mac OS', /(Mac_PowerPC)|(Macintosh)/],
|
|
756
|
+
['QNX', /QNX/],
|
|
757
|
+
['BeOS', /BeOS/],
|
|
758
|
+
['OS/2', /OS\/2/],
|
|
759
|
+
];
|
|
760
|
+
function detect(userAgent) {
|
|
761
|
+
if (!!userAgent) {
|
|
762
|
+
return parseUserAgent(userAgent);
|
|
763
|
+
}
|
|
764
|
+
if (typeof document === 'undefined' &&
|
|
765
|
+
typeof navigator !== 'undefined' &&
|
|
766
|
+
navigator.product === 'ReactNative') {
|
|
767
|
+
return new ReactNativeInfo();
|
|
768
|
+
}
|
|
769
|
+
if (typeof navigator !== 'undefined') {
|
|
770
|
+
return parseUserAgent(navigator.userAgent);
|
|
771
|
+
}
|
|
772
|
+
return getNodeVersion();
|
|
773
|
+
}
|
|
774
|
+
function matchUserAgent(ua) {
|
|
775
|
+
// opted for using reduce here rather than Array#first with a regex.test call
|
|
776
|
+
// this is primarily because using the reduce we only perform the regex
|
|
777
|
+
// execution once rather than once for the test and for the exec again below
|
|
778
|
+
// probably something that needs to be benchmarked though
|
|
779
|
+
return (ua !== '' &&
|
|
780
|
+
userAgentRules.reduce(function (matched, _a) {
|
|
781
|
+
var browser = _a[0], regex = _a[1];
|
|
782
|
+
if (matched) {
|
|
783
|
+
return matched;
|
|
784
|
+
}
|
|
785
|
+
var uaMatch = regex.exec(ua);
|
|
786
|
+
return !!uaMatch && [browser, uaMatch];
|
|
787
|
+
}, false));
|
|
788
|
+
}
|
|
789
|
+
function parseUserAgent(ua) {
|
|
790
|
+
var matchedRule = matchUserAgent(ua);
|
|
791
|
+
if (!matchedRule) {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
var name = matchedRule[0], match = matchedRule[1];
|
|
795
|
+
if (name === 'searchbot') {
|
|
796
|
+
return new BotInfo();
|
|
797
|
+
}
|
|
798
|
+
// Do not use RegExp for split operation as some browser do not support it (See: http://blog.stevenlevithan.com/archives/cross-browser-split)
|
|
799
|
+
var versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3);
|
|
800
|
+
if (versionParts) {
|
|
801
|
+
if (versionParts.length < REQUIRED_VERSION_PARTS) {
|
|
802
|
+
versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
versionParts = [];
|
|
807
|
+
}
|
|
808
|
+
var version = versionParts.join('.');
|
|
809
|
+
var os = detectOS(ua);
|
|
810
|
+
var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua);
|
|
811
|
+
if (searchBotMatch && searchBotMatch[1]) {
|
|
812
|
+
return new SearchBotDeviceInfo(name, version, os, searchBotMatch[1]);
|
|
813
|
+
}
|
|
814
|
+
return new BrowserInfo(name, version, os);
|
|
815
|
+
}
|
|
816
|
+
function detectOS(ua) {
|
|
817
|
+
for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {
|
|
818
|
+
var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];
|
|
819
|
+
var match = regex.exec(ua);
|
|
820
|
+
if (match) {
|
|
821
|
+
return os;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
function getNodeVersion() {
|
|
827
|
+
var isNode = typeof process !== 'undefined' && process.version;
|
|
828
|
+
return isNode ? new NodeInfo(process.version.slice(1)) : null;
|
|
829
|
+
}
|
|
830
|
+
function createVersionParts(count) {
|
|
831
|
+
var output = [];
|
|
832
|
+
for (var ii = 0; ii < count; ii++) {
|
|
833
|
+
output.push('0');
|
|
834
|
+
}
|
|
835
|
+
return output;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
var ElementSVG = function ElementSVG() {
|
|
839
|
+
this.$el = void 0;
|
|
840
|
+
this.$groupEl = void 0;
|
|
841
|
+
this.$hitTestingEl = void 0;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
ElementSVG.tag = 'c-svg-element';
|
|
845
|
+
|
|
846
|
+
var RectRenderer = /*#__PURE__*/function () {
|
|
847
|
+
function RectRenderer() {
|
|
848
|
+
this.dependencies = ['radius', 'width', 'height'];
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
var _proto = RectRenderer.prototype;
|
|
852
|
+
|
|
853
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
854
|
+
var radius = parsedStyle.radius,
|
|
855
|
+
width = parsedStyle.width,
|
|
856
|
+
height = parsedStyle.height;
|
|
857
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
858
|
+
return r.value !== 0;
|
|
859
|
+
});
|
|
860
|
+
var d = '';
|
|
861
|
+
|
|
862
|
+
if (!hasRadius) {
|
|
863
|
+
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
864
|
+
} else {
|
|
865
|
+
var _radius$map = radius.map(function (r) {
|
|
866
|
+
return r.value;
|
|
867
|
+
}),
|
|
868
|
+
tlr = _radius$map[0],
|
|
869
|
+
trr = _radius$map[1],
|
|
870
|
+
brr = _radius$map[2],
|
|
871
|
+
blr = _radius$map[3];
|
|
872
|
+
|
|
873
|
+
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(' ');
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
$el.setAttribute('d', d);
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
return RectRenderer;
|
|
880
|
+
}();
|
|
881
|
+
|
|
882
|
+
RectRenderer = __decorate([manaSyringe.singleton()], RectRenderer);
|
|
883
|
+
|
|
884
|
+
var ImageRenderer = /*#__PURE__*/function () {
|
|
885
|
+
function ImageRenderer() {
|
|
886
|
+
this.dependencies = ['img', 'width', 'height'];
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
var _proto = ImageRenderer.prototype;
|
|
890
|
+
|
|
891
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
892
|
+
var _parsedStyle$img = parsedStyle.img,
|
|
893
|
+
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
894
|
+
width = parsedStyle.width,
|
|
895
|
+
height = parsedStyle.height;
|
|
896
|
+
$el.setAttribute('x', '0');
|
|
897
|
+
$el.setAttribute('y', '0');
|
|
898
|
+
|
|
899
|
+
if (g.isString(img)) {
|
|
900
|
+
$el.setAttribute('href', img);
|
|
901
|
+
} else if (img instanceof Image) {
|
|
902
|
+
if (!width) {
|
|
903
|
+
$el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
|
|
904
|
+
// this.attr('width', img.width);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
if (!height) {
|
|
908
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
$el.setAttribute('href', img.src);
|
|
912
|
+
} else if ( // @ts-ignore
|
|
913
|
+
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
914
|
+
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
915
|
+
} else if (img instanceof ImageData) {
|
|
916
|
+
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
917
|
+
|
|
918
|
+
canvas.setAttribute('width', "" + img.width); // @ts-ignore
|
|
919
|
+
|
|
920
|
+
canvas.setAttribute('height', "" + img.height);
|
|
921
|
+
var context = canvas.getContext('2d');
|
|
922
|
+
|
|
923
|
+
if (context) {
|
|
924
|
+
context.putImageData(img, 0, 0);
|
|
925
|
+
|
|
926
|
+
if (!width) {
|
|
927
|
+
// @ts-ignore
|
|
928
|
+
$el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if (!height) {
|
|
932
|
+
// @ts-ignore
|
|
933
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
$el.setAttribute('href', canvas.toDataURL());
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
return ImageRenderer;
|
|
942
|
+
}();
|
|
943
|
+
|
|
944
|
+
ImageRenderer = __decorate([manaSyringe.singleton()], ImageRenderer);
|
|
945
|
+
|
|
946
|
+
var LineRenderer = /*#__PURE__*/function () {
|
|
947
|
+
function LineRenderer() {
|
|
948
|
+
this.dependencies = ['x1', 'y1', 'x2', 'y2'];
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
var _proto = LineRenderer.prototype;
|
|
952
|
+
|
|
953
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
954
|
+
var x1 = parsedStyle.x1,
|
|
955
|
+
y1 = parsedStyle.y1,
|
|
956
|
+
x2 = parsedStyle.x2,
|
|
957
|
+
y2 = parsedStyle.y2,
|
|
958
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
959
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
960
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
961
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY,
|
|
962
|
+
stroke = parsedStyle.stroke;
|
|
963
|
+
$el.setAttribute('x1', "" + (x1.value - x));
|
|
964
|
+
$el.setAttribute('y1', "" + (y1.value - y));
|
|
965
|
+
$el.setAttribute('x2', "" + (x2.value - x)); // fix horizontal line stroke url bug in Chrome
|
|
966
|
+
// @see https://stackoverflow.com/questions/14680240/did-chrome-break-svg-stroke-url
|
|
967
|
+
|
|
968
|
+
if (y1.value === y2.value && stroke && !(stroke instanceof g.CSSRGB)) {
|
|
969
|
+
$el.setAttribute('y2', "" + (y2.value - y + 0.00001));
|
|
970
|
+
} else {
|
|
971
|
+
$el.setAttribute('y2', "" + (y2.value - y));
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
return LineRenderer;
|
|
976
|
+
}();
|
|
977
|
+
|
|
978
|
+
LineRenderer = __decorate([manaSyringe.singleton()], LineRenderer);
|
|
979
|
+
|
|
980
|
+
var PolylineRenderer = /*#__PURE__*/function () {
|
|
981
|
+
function PolylineRenderer() {
|
|
982
|
+
this.dependencies = ['points'];
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
var _proto = PolylineRenderer.prototype;
|
|
986
|
+
|
|
987
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
988
|
+
var points = parsedStyle.points,
|
|
989
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
990
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
991
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
992
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
993
|
+
|
|
994
|
+
if (points && points.points && points.points.length >= 2) {
|
|
995
|
+
$el.setAttribute('points', points.points.map(function (point) {
|
|
996
|
+
return point[0] - x + "," + (point[1] - y);
|
|
997
|
+
}).join(' '));
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
return PolylineRenderer;
|
|
1002
|
+
}();
|
|
1003
|
+
|
|
1004
|
+
PolylineRenderer = __decorate([manaSyringe.singleton()], PolylineRenderer);
|
|
1005
|
+
|
|
1006
|
+
function numberToLongString(x) {
|
|
1007
|
+
return x.toFixed(6).replace('.000000', '');
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
function convertHTML(str) {
|
|
1011
|
+
var regex = /[&|<|>|"|']/g;
|
|
1012
|
+
return str.replace(regex, function (match) {
|
|
1013
|
+
if (match === '&') {
|
|
1014
|
+
return '&';
|
|
1015
|
+
} else if (match === '<') {
|
|
1016
|
+
return '<';
|
|
1017
|
+
} else if (match === '>') {
|
|
1018
|
+
return '>';
|
|
1019
|
+
} else if (match === '"') {
|
|
1020
|
+
return '"';
|
|
1021
|
+
} else {
|
|
1022
|
+
return ''';
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
var BASELINE_MAP = {
|
|
1028
|
+
top: 'before-edge',
|
|
1029
|
+
middle: 'central',
|
|
1030
|
+
bottom: 'after-edge',
|
|
1031
|
+
alphabetic: 'alphabetic',
|
|
1032
|
+
ideographic: 'ideographic',
|
|
1033
|
+
hanging: 'hanging'
|
|
1034
|
+
}; // for FireFox
|
|
1035
|
+
// @see https://github.com/plouc/nivo/issues/164
|
|
1036
|
+
|
|
1037
|
+
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1038
|
+
top: 'text-before-edge',
|
|
1039
|
+
middle: 'central',
|
|
1040
|
+
bottom: 'text-after-edge',
|
|
1041
|
+
alphabetic: 'alphabetic',
|
|
1042
|
+
ideographic: 'ideographic',
|
|
1043
|
+
hanging: 'hanging'
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
var TextRenderer = /*#__PURE__*/function () {
|
|
1047
|
+
function TextRenderer() {
|
|
1048
|
+
this.dependencies = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'];
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
var _proto = TextRenderer.prototype;
|
|
1052
|
+
|
|
1053
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
1054
|
+
var textBaseline = parsedStyle.textBaseline,
|
|
1055
|
+
lineWidth = parsedStyle.lineWidth,
|
|
1056
|
+
metrics = parsedStyle.metrics,
|
|
1057
|
+
dx = parsedStyle.dx,
|
|
1058
|
+
dy = parsedStyle.dy;
|
|
1059
|
+
var browser = detect();
|
|
1060
|
+
|
|
1061
|
+
if (browser && browser.name === 'firefox') {
|
|
1062
|
+
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1063
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1064
|
+
} else {
|
|
1065
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1066
|
+
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
$el.setAttribute('paint-order', 'stroke');
|
|
1070
|
+
var lines = metrics.lines,
|
|
1071
|
+
lineHeight = metrics.lineHeight,
|
|
1072
|
+
height = metrics.height;
|
|
1073
|
+
var lineNum = lines.length;
|
|
1074
|
+
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1075
|
+
|
|
1076
|
+
if (lineNum === 1) {
|
|
1077
|
+
$el.innerHTML = convertHTML(lines[0]);
|
|
1078
|
+
$el.setAttribute('dx', "" + lineWidth.value / 2);
|
|
1079
|
+
} else {
|
|
1080
|
+
$el.innerHTML = lines.map(function (line, i) {
|
|
1081
|
+
var dx = lineWidth.value / 2;
|
|
1082
|
+
var dy = 0;
|
|
1083
|
+
|
|
1084
|
+
if (i === 0) {
|
|
1085
|
+
// TODO: handle other textBaseline values
|
|
1086
|
+
if (textBaseline.value === 'middle') {
|
|
1087
|
+
dy = lineHeight / 2 - height / 2;
|
|
1088
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1089
|
+
dy = 0;
|
|
1090
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1091
|
+
dy = -lineHeight * (lineNum - 1);
|
|
1092
|
+
}
|
|
1093
|
+
} else {
|
|
1094
|
+
dy = lineHeight;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
1098
|
+
}).join('');
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
return TextRenderer;
|
|
1103
|
+
}();
|
|
1104
|
+
|
|
1105
|
+
TextRenderer = __decorate([manaSyringe.singleton()], TextRenderer);
|
|
1106
|
+
|
|
1107
|
+
var PathRenderer = /*#__PURE__*/function () {
|
|
1108
|
+
function PathRenderer() {
|
|
1109
|
+
this.dependencies = ['path'];
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
var _proto = PathRenderer.prototype;
|
|
1113
|
+
|
|
1114
|
+
_proto.apply = function apply($el, parsedStyle) {
|
|
1115
|
+
var path = parsedStyle.path,
|
|
1116
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1117
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1118
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1119
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1120
|
+
$el.setAttribute('d', this.formatPath(path.absolutePath, x, y));
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
_proto.formatPath = function formatPath(value, x, y) {
|
|
1124
|
+
var newValue = value.map(function (params) {
|
|
1125
|
+
var command = params[0];
|
|
1126
|
+
|
|
1127
|
+
switch (command) {
|
|
1128
|
+
case 'M':
|
|
1129
|
+
return "M " + (params[1] - x) + "," + (params[2] - y);
|
|
1130
|
+
|
|
1131
|
+
case 'L':
|
|
1132
|
+
return "L " + (params[1] - x) + "," + (params[2] - y);
|
|
1133
|
+
|
|
1134
|
+
case 'Q':
|
|
1135
|
+
return "Q " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y);
|
|
1136
|
+
|
|
1137
|
+
case 'C':
|
|
1138
|
+
return "C " + (params[1] - x) + " " + (params[2] - y) + "," + (params[3] - x) + " " + (params[4] - y) + "," + (params[5] - x) + " " + (params[6] - y);
|
|
1139
|
+
|
|
1140
|
+
case 'A':
|
|
1141
|
+
return "A " + params[1] + " " + params[2] + " " + params[3] + " " + params[4] + " " + params[5] + " " + (params[6] - x) + " " + (params[7] - y);
|
|
1142
|
+
|
|
1143
|
+
case 'Z':
|
|
1144
|
+
return 'Z';
|
|
1145
|
+
}
|
|
1146
|
+
}).join(' ');
|
|
1147
|
+
|
|
1148
|
+
if (~newValue.indexOf('NaN')) {
|
|
1149
|
+
return '';
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
return newValue;
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
return PathRenderer;
|
|
1156
|
+
}();
|
|
1157
|
+
|
|
1158
|
+
PathRenderer = __decorate([manaSyringe.singleton()], PathRenderer);
|
|
1159
|
+
var ElementRendererFactory = manaSyringe.Syringe.defineToken('ElementRendererFactory');
|
|
1160
|
+
var ElementRenderer = manaSyringe.Syringe.defineToken('ElementRenderer');
|
|
1161
|
+
|
|
1162
|
+
function _regeneratorRuntime$1() {
|
|
1163
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
1164
|
+
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
1165
|
+
return exports;
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
var exports = {},
|
|
1169
|
+
Op = Object.prototype,
|
|
1170
|
+
hasOwn = Op.hasOwnProperty,
|
|
1171
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1172
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1173
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1174
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1175
|
+
|
|
1176
|
+
function define(obj, key, value) {
|
|
1177
|
+
return Object.defineProperty(obj, key, {
|
|
1178
|
+
value: value,
|
|
1179
|
+
enumerable: !0,
|
|
1180
|
+
configurable: !0,
|
|
1181
|
+
writable: !0
|
|
1182
|
+
}), obj[key];
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
try {
|
|
1186
|
+
define({}, "");
|
|
1187
|
+
} catch (err) {
|
|
1188
|
+
define = function define(obj, key, value) {
|
|
1189
|
+
return obj[key] = value;
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1194
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
1195
|
+
generator = Object.create(protoGenerator.prototype),
|
|
1196
|
+
context = new Context(tryLocsList || []);
|
|
1197
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
1198
|
+
var state = "suspendedStart";
|
|
1199
|
+
return function (method, arg) {
|
|
1200
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
1201
|
+
|
|
1202
|
+
if ("completed" === state) {
|
|
1203
|
+
if ("throw" === method) throw arg;
|
|
1204
|
+
return doneResult();
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
for (context.method = method, context.arg = arg;;) {
|
|
1208
|
+
var delegate = context.delegate;
|
|
1209
|
+
|
|
1210
|
+
if (delegate) {
|
|
1211
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1212
|
+
|
|
1213
|
+
if (delegateResult) {
|
|
1214
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1215
|
+
return delegateResult;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
1220
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
1221
|
+
context.dispatchException(context.arg);
|
|
1222
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1223
|
+
state = "executing";
|
|
1224
|
+
var record = tryCatch(innerFn, self, context);
|
|
1225
|
+
|
|
1226
|
+
if ("normal" === record.type) {
|
|
1227
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
1228
|
+
return {
|
|
1229
|
+
value: record.arg,
|
|
1230
|
+
done: context.done
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
}(innerFn, self, context), generator;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
function tryCatch(fn, obj, arg) {
|
|
1241
|
+
try {
|
|
1242
|
+
return {
|
|
1243
|
+
type: "normal",
|
|
1244
|
+
arg: fn.call(obj, arg)
|
|
1245
|
+
};
|
|
1246
|
+
} catch (err) {
|
|
1247
|
+
return {
|
|
1248
|
+
type: "throw",
|
|
1249
|
+
arg: err
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
exports.wrap = wrap;
|
|
1255
|
+
var ContinueSentinel = {};
|
|
1256
|
+
|
|
1257
|
+
function Generator() {}
|
|
1258
|
+
|
|
1259
|
+
function GeneratorFunction() {}
|
|
1260
|
+
|
|
1261
|
+
function GeneratorFunctionPrototype() {}
|
|
1262
|
+
|
|
1263
|
+
var IteratorPrototype = {};
|
|
1264
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1265
|
+
return this;
|
|
1266
|
+
});
|
|
1267
|
+
var getProto = Object.getPrototypeOf,
|
|
1268
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1269
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1270
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1271
|
+
|
|
1272
|
+
function defineIteratorMethods(prototype) {
|
|
1273
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1274
|
+
define(prototype, method, function (arg) {
|
|
1275
|
+
return this._invoke(method, arg);
|
|
1276
|
+
});
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1281
|
+
function invoke(method, arg, resolve, reject) {
|
|
1282
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1283
|
+
|
|
1284
|
+
if ("throw" !== record.type) {
|
|
1285
|
+
var result = record.arg,
|
|
1286
|
+
value = result.value;
|
|
1287
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1288
|
+
invoke("next", value, resolve, reject);
|
|
1289
|
+
}, function (err) {
|
|
1290
|
+
invoke("throw", err, resolve, reject);
|
|
1291
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1292
|
+
result.value = unwrapped, resolve(result);
|
|
1293
|
+
}, function (error) {
|
|
1294
|
+
return invoke("throw", error, resolve, reject);
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
reject(record.arg);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
var previousPromise;
|
|
1302
|
+
|
|
1303
|
+
this._invoke = function (method, arg) {
|
|
1304
|
+
function callInvokeWithMethodAndArg() {
|
|
1305
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1306
|
+
invoke(method, arg, resolve, reject);
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1315
|
+
var method = delegate.iterator[context.method];
|
|
1316
|
+
|
|
1317
|
+
if (undefined === method) {
|
|
1318
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
1319
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1320
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
return ContinueSentinel;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1327
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1328
|
+
var info = record.arg;
|
|
1329
|
+
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);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function pushTryEntry(locs) {
|
|
1333
|
+
var entry = {
|
|
1334
|
+
tryLoc: locs[0]
|
|
1335
|
+
};
|
|
1336
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function resetTryEntry(entry) {
|
|
1340
|
+
var record = entry.completion || {};
|
|
1341
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
function Context(tryLocsList) {
|
|
1345
|
+
this.tryEntries = [{
|
|
1346
|
+
tryLoc: "root"
|
|
1347
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function values(iterable) {
|
|
1351
|
+
if (iterable) {
|
|
1352
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1353
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
1354
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
1355
|
+
|
|
1356
|
+
if (!isNaN(iterable.length)) {
|
|
1357
|
+
var i = -1,
|
|
1358
|
+
next = function next() {
|
|
1359
|
+
for (; ++i < iterable.length;) {
|
|
1360
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
return next.value = undefined, next.done = !0, next;
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
return next.next = next;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
return {
|
|
1371
|
+
next: doneResult
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
function doneResult() {
|
|
1376
|
+
return {
|
|
1377
|
+
value: undefined,
|
|
1378
|
+
done: !0
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
1383
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
1384
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
1385
|
+
}, exports.mark = function (genFun) {
|
|
1386
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1387
|
+
}, exports.awrap = function (arg) {
|
|
1388
|
+
return {
|
|
1389
|
+
__await: arg
|
|
1390
|
+
};
|
|
1391
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1392
|
+
return this;
|
|
1393
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1394
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1395
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1396
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1397
|
+
return result.done ? result.value : iter.next();
|
|
1398
|
+
});
|
|
1399
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1400
|
+
return this;
|
|
1401
|
+
}), define(Gp, "toString", function () {
|
|
1402
|
+
return "[object Generator]";
|
|
1403
|
+
}), exports.keys = function (object) {
|
|
1404
|
+
var keys = [];
|
|
1405
|
+
|
|
1406
|
+
for (var key in object) {
|
|
1407
|
+
keys.push(key);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
return keys.reverse(), function next() {
|
|
1411
|
+
for (; keys.length;) {
|
|
1412
|
+
var key = keys.pop();
|
|
1413
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
return next.done = !0, next;
|
|
1417
|
+
};
|
|
1418
|
+
}, exports.values = values, Context.prototype = {
|
|
1419
|
+
constructor: Context,
|
|
1420
|
+
reset: function reset(skipTempReset) {
|
|
1421
|
+
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) {
|
|
1422
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
stop: function stop() {
|
|
1426
|
+
this.done = !0;
|
|
1427
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
1428
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1429
|
+
return this.rval;
|
|
1430
|
+
},
|
|
1431
|
+
dispatchException: function dispatchException(exception) {
|
|
1432
|
+
if (this.done) throw exception;
|
|
1433
|
+
var context = this;
|
|
1434
|
+
|
|
1435
|
+
function handle(loc, caught) {
|
|
1436
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1440
|
+
var entry = this.tryEntries[i],
|
|
1441
|
+
record = entry.completion;
|
|
1442
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
1443
|
+
|
|
1444
|
+
if (entry.tryLoc <= this.prev) {
|
|
1445
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
1446
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1447
|
+
|
|
1448
|
+
if (hasCatch && hasFinally) {
|
|
1449
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1450
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1451
|
+
} else if (hasCatch) {
|
|
1452
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1453
|
+
} else {
|
|
1454
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1455
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
},
|
|
1460
|
+
abrupt: function abrupt(type, arg) {
|
|
1461
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1462
|
+
var entry = this.tryEntries[i];
|
|
1463
|
+
|
|
1464
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1465
|
+
var finallyEntry = entry;
|
|
1466
|
+
break;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
1471
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1472
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
1473
|
+
},
|
|
1474
|
+
complete: function complete(record, afterLoc) {
|
|
1475
|
+
if ("throw" === record.type) throw record.arg;
|
|
1476
|
+
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;
|
|
1477
|
+
},
|
|
1478
|
+
finish: function finish(finallyLoc) {
|
|
1479
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1480
|
+
var entry = this.tryEntries[i];
|
|
1481
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
catch: function _catch(tryLoc) {
|
|
1485
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1486
|
+
var entry = this.tryEntries[i];
|
|
1487
|
+
|
|
1488
|
+
if (entry.tryLoc === tryLoc) {
|
|
1489
|
+
var record = entry.completion;
|
|
1490
|
+
|
|
1491
|
+
if ("throw" === record.type) {
|
|
1492
|
+
var thrown = record.arg;
|
|
1493
|
+
resetTryEntry(entry);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
return thrown;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
throw new Error("illegal catch attempt");
|
|
1501
|
+
},
|
|
1502
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1503
|
+
return this.delegate = {
|
|
1504
|
+
iterator: values(iterable),
|
|
1505
|
+
resultName: resultName,
|
|
1506
|
+
nextLoc: nextLoc
|
|
1507
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1508
|
+
}
|
|
1509
|
+
}, exports;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1513
|
+
try {
|
|
1514
|
+
var info = gen[key](arg);
|
|
1515
|
+
var value = info.value;
|
|
1516
|
+
} catch (error) {
|
|
1517
|
+
reject(error);
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
if (info.done) {
|
|
1522
|
+
resolve(value);
|
|
1523
|
+
} else {
|
|
1524
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
function _asyncToGenerator$1(fn) {
|
|
1529
|
+
return function () {
|
|
1530
|
+
var self = this,
|
|
1531
|
+
args = arguments;
|
|
1532
|
+
return new Promise(function (resolve, reject) {
|
|
1533
|
+
var gen = fn.apply(self, args);
|
|
1534
|
+
|
|
1535
|
+
function _next(value) {
|
|
1536
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function _throw(err) {
|
|
1540
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
_next(undefined);
|
|
1544
|
+
});
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Common utilities
|
|
1549
|
+
* @module glMatrix
|
|
1550
|
+
*/
|
|
1551
|
+
// Configuration Constants
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
var EPSILON = 0.000001;
|
|
1555
|
+
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
1556
|
+
if (!Math.hypot) Math.hypot = function () {
|
|
1557
|
+
var y = 0,
|
|
1558
|
+
i = arguments.length;
|
|
1559
|
+
|
|
1560
|
+
while (i--) {
|
|
1561
|
+
y += arguments[i] * arguments[i];
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
return Math.sqrt(y);
|
|
1565
|
+
};
|
|
1566
|
+
/**
|
|
1567
|
+
* 3x3 Matrix
|
|
1568
|
+
* @module mat3
|
|
1569
|
+
*/
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* Creates a new identity mat3
|
|
1573
|
+
*
|
|
1574
|
+
* @returns {mat3} a new 3x3 matrix
|
|
1575
|
+
*/
|
|
1576
|
+
|
|
1577
|
+
function create() {
|
|
1578
|
+
var out = new ARRAY_TYPE(9);
|
|
1579
|
+
|
|
1580
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1581
|
+
out[1] = 0;
|
|
1582
|
+
out[2] = 0;
|
|
1583
|
+
out[3] = 0;
|
|
1584
|
+
out[5] = 0;
|
|
1585
|
+
out[6] = 0;
|
|
1586
|
+
out[7] = 0;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
out[0] = 1;
|
|
1590
|
+
out[4] = 1;
|
|
1591
|
+
out[8] = 1;
|
|
1592
|
+
return out;
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Returns the translation vector component of a transformation
|
|
1596
|
+
* matrix. If a matrix is built with fromRotationTranslation,
|
|
1597
|
+
* the returned vector will be the same as the translation vector
|
|
1598
|
+
* originally supplied.
|
|
1599
|
+
* @param {vec3} out Vector to receive translation component
|
|
1600
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1601
|
+
* @return {vec3} out
|
|
1602
|
+
*/
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
function getTranslation(out, mat) {
|
|
1606
|
+
out[0] = mat[12];
|
|
1607
|
+
out[1] = mat[13];
|
|
1608
|
+
out[2] = mat[14];
|
|
1609
|
+
return out;
|
|
1610
|
+
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Returns the scaling factor component of a transformation
|
|
1613
|
+
* matrix. If a matrix is built with fromRotationTranslationScale
|
|
1614
|
+
* with a normalized Quaternion paramter, the returned vector will be
|
|
1615
|
+
* the same as the scaling vector
|
|
1616
|
+
* originally supplied.
|
|
1617
|
+
* @param {vec3} out Vector to receive scaling factor component
|
|
1618
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1619
|
+
* @return {vec3} out
|
|
1620
|
+
*/
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
function getScaling(out, mat) {
|
|
1624
|
+
var m11 = mat[0];
|
|
1625
|
+
var m12 = mat[1];
|
|
1626
|
+
var m13 = mat[2];
|
|
1627
|
+
var m21 = mat[4];
|
|
1628
|
+
var m22 = mat[5];
|
|
1629
|
+
var m23 = mat[6];
|
|
1630
|
+
var m31 = mat[8];
|
|
1631
|
+
var m32 = mat[9];
|
|
1632
|
+
var m33 = mat[10];
|
|
1633
|
+
out[0] = Math.hypot(m11, m12, m13);
|
|
1634
|
+
out[1] = Math.hypot(m21, m22, m23);
|
|
1635
|
+
out[2] = Math.hypot(m31, m32, m33);
|
|
1636
|
+
return out;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Returns a quaternion representing the rotational component
|
|
1640
|
+
* of a transformation matrix. If a matrix is built with
|
|
1641
|
+
* fromRotationTranslation, the returned quaternion will be the
|
|
1642
|
+
* same as the quaternion originally supplied.
|
|
1643
|
+
* @param {quat} out Quaternion to receive the rotation component
|
|
1644
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1645
|
+
* @return {quat} out
|
|
1646
|
+
*/
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
function getRotation(out, mat) {
|
|
1650
|
+
var scaling = new ARRAY_TYPE(3);
|
|
1651
|
+
getScaling(scaling, mat);
|
|
1652
|
+
var is1 = 1 / scaling[0];
|
|
1653
|
+
var is2 = 1 / scaling[1];
|
|
1654
|
+
var is3 = 1 / scaling[2];
|
|
1655
|
+
var sm11 = mat[0] * is1;
|
|
1656
|
+
var sm12 = mat[1] * is2;
|
|
1657
|
+
var sm13 = mat[2] * is3;
|
|
1658
|
+
var sm21 = mat[4] * is1;
|
|
1659
|
+
var sm22 = mat[5] * is2;
|
|
1660
|
+
var sm23 = mat[6] * is3;
|
|
1661
|
+
var sm31 = mat[8] * is1;
|
|
1662
|
+
var sm32 = mat[9] * is2;
|
|
1663
|
+
var sm33 = mat[10] * is3;
|
|
1664
|
+
var trace = sm11 + sm22 + sm33;
|
|
1665
|
+
var S = 0;
|
|
1666
|
+
|
|
1667
|
+
if (trace > 0) {
|
|
1668
|
+
S = Math.sqrt(trace + 1.0) * 2;
|
|
1669
|
+
out[3] = 0.25 * S;
|
|
1670
|
+
out[0] = (sm23 - sm32) / S;
|
|
1671
|
+
out[1] = (sm31 - sm13) / S;
|
|
1672
|
+
out[2] = (sm12 - sm21) / S;
|
|
1673
|
+
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
1674
|
+
S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
|
|
1675
|
+
out[3] = (sm23 - sm32) / S;
|
|
1676
|
+
out[0] = 0.25 * S;
|
|
1677
|
+
out[1] = (sm12 + sm21) / S;
|
|
1678
|
+
out[2] = (sm31 + sm13) / S;
|
|
1679
|
+
} else if (sm22 > sm33) {
|
|
1680
|
+
S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
|
|
1681
|
+
out[3] = (sm31 - sm13) / S;
|
|
1682
|
+
out[0] = (sm12 + sm21) / S;
|
|
1683
|
+
out[1] = 0.25 * S;
|
|
1684
|
+
out[2] = (sm23 + sm32) / S;
|
|
1685
|
+
} else {
|
|
1686
|
+
S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
|
|
1687
|
+
out[3] = (sm12 - sm21) / S;
|
|
1688
|
+
out[0] = (sm31 + sm13) / S;
|
|
1689
|
+
out[1] = (sm23 + sm32) / S;
|
|
1690
|
+
out[2] = 0.25 * S;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
return out;
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* 3 Dimensional Vector
|
|
1697
|
+
* @module vec3
|
|
1698
|
+
*/
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Creates a new, empty vec3
|
|
1702
|
+
*
|
|
1703
|
+
* @returns {vec3} a new 3D vector
|
|
1704
|
+
*/
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
function create$1() {
|
|
1708
|
+
var out = new ARRAY_TYPE(3);
|
|
1709
|
+
|
|
1710
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1711
|
+
out[0] = 0;
|
|
1712
|
+
out[1] = 0;
|
|
1713
|
+
out[2] = 0;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
return out;
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Calculates the length of a vec3
|
|
1720
|
+
*
|
|
1721
|
+
* @param {ReadonlyVec3} a vector to calculate length of
|
|
1722
|
+
* @returns {Number} length of a
|
|
1723
|
+
*/
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
function length(a) {
|
|
1727
|
+
var x = a[0];
|
|
1728
|
+
var y = a[1];
|
|
1729
|
+
var z = a[2];
|
|
1730
|
+
return Math.hypot(x, y, z);
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Creates a new vec3 initialized with the given values
|
|
1734
|
+
*
|
|
1735
|
+
* @param {Number} x X component
|
|
1736
|
+
* @param {Number} y Y component
|
|
1737
|
+
* @param {Number} z Z component
|
|
1738
|
+
* @returns {vec3} a new 3D vector
|
|
1739
|
+
*/
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
function fromValues(x, y, z) {
|
|
1743
|
+
var out = new ARRAY_TYPE(3);
|
|
1744
|
+
out[0] = x;
|
|
1745
|
+
out[1] = y;
|
|
1746
|
+
out[2] = z;
|
|
1747
|
+
return out;
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Normalize a vec3
|
|
1751
|
+
*
|
|
1752
|
+
* @param {vec3} out the receiving vector
|
|
1753
|
+
* @param {ReadonlyVec3} a vector to normalize
|
|
1754
|
+
* @returns {vec3} out
|
|
1755
|
+
*/
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
function normalize(out, a) {
|
|
1759
|
+
var x = a[0];
|
|
1760
|
+
var y = a[1];
|
|
1761
|
+
var z = a[2];
|
|
1762
|
+
var len = x * x + y * y + z * z;
|
|
1763
|
+
|
|
1764
|
+
if (len > 0) {
|
|
1765
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
1766
|
+
len = 1 / Math.sqrt(len);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
out[0] = a[0] * len;
|
|
1770
|
+
out[1] = a[1] * len;
|
|
1771
|
+
out[2] = a[2] * len;
|
|
1772
|
+
return out;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Calculates the dot product of two vec3's
|
|
1776
|
+
*
|
|
1777
|
+
* @param {ReadonlyVec3} a the first operand
|
|
1778
|
+
* @param {ReadonlyVec3} b the second operand
|
|
1779
|
+
* @returns {Number} dot product of a and b
|
|
1780
|
+
*/
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
function dot(a, b) {
|
|
1784
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Computes the cross product of two vec3's
|
|
1788
|
+
*
|
|
1789
|
+
* @param {vec3} out the receiving vector
|
|
1790
|
+
* @param {ReadonlyVec3} a the first operand
|
|
1791
|
+
* @param {ReadonlyVec3} b the second operand
|
|
1792
|
+
* @returns {vec3} out
|
|
1793
|
+
*/
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
function cross(out, a, b) {
|
|
1797
|
+
var ax = a[0],
|
|
1798
|
+
ay = a[1],
|
|
1799
|
+
az = a[2];
|
|
1800
|
+
var bx = b[0],
|
|
1801
|
+
by = b[1],
|
|
1802
|
+
bz = b[2];
|
|
1803
|
+
out[0] = ay * bz - az * by;
|
|
1804
|
+
out[1] = az * bx - ax * bz;
|
|
1805
|
+
out[2] = ax * by - ay * bx;
|
|
1806
|
+
return out;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Alias for {@link vec3.length}
|
|
1810
|
+
* @function
|
|
1811
|
+
*/
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
var len = length;
|
|
1815
|
+
/**
|
|
1816
|
+
* Perform some operation over an array of vec3s.
|
|
1817
|
+
*
|
|
1818
|
+
* @param {Array} a the array of vectors to iterate over
|
|
1819
|
+
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
|
|
1820
|
+
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
1821
|
+
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
|
|
1822
|
+
* @param {Function} fn Function to call for each vector in the array
|
|
1823
|
+
* @param {Object} [arg] additional argument to pass to fn
|
|
1824
|
+
* @returns {Array} a
|
|
1825
|
+
* @function
|
|
1826
|
+
*/
|
|
1827
|
+
|
|
1828
|
+
var forEach = function () {
|
|
1829
|
+
var vec = create$1();
|
|
1830
|
+
return function (a, stride, offset, count, fn, arg) {
|
|
1831
|
+
var i, l;
|
|
1832
|
+
|
|
1833
|
+
if (!stride) {
|
|
1834
|
+
stride = 3;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
if (!offset) {
|
|
1838
|
+
offset = 0;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
if (count) {
|
|
1842
|
+
l = Math.min(count * stride + offset, a.length);
|
|
1843
|
+
} else {
|
|
1844
|
+
l = a.length;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
for (i = offset; i < l; i += stride) {
|
|
1848
|
+
vec[0] = a[i];
|
|
1849
|
+
vec[1] = a[i + 1];
|
|
1850
|
+
vec[2] = a[i + 2];
|
|
1851
|
+
fn(vec, vec, arg);
|
|
1852
|
+
a[i] = vec[0];
|
|
1853
|
+
a[i + 1] = vec[1];
|
|
1854
|
+
a[i + 2] = vec[2];
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
return a;
|
|
1858
|
+
};
|
|
1859
|
+
}();
|
|
1860
|
+
/**
|
|
1861
|
+
* 4 Dimensional Vector
|
|
1862
|
+
* @module vec4
|
|
1863
|
+
*/
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Creates a new, empty vec4
|
|
1867
|
+
*
|
|
1868
|
+
* @returns {vec4} a new 4D vector
|
|
1869
|
+
*/
|
|
1870
|
+
|
|
1871
|
+
|
|
1872
|
+
function create$2() {
|
|
1873
|
+
var out = new ARRAY_TYPE(4);
|
|
1874
|
+
|
|
1875
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1876
|
+
out[0] = 0;
|
|
1877
|
+
out[1] = 0;
|
|
1878
|
+
out[2] = 0;
|
|
1879
|
+
out[3] = 0;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
return out;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Normalize a vec4
|
|
1886
|
+
*
|
|
1887
|
+
* @param {vec4} out the receiving vector
|
|
1888
|
+
* @param {ReadonlyVec4} a vector to normalize
|
|
1889
|
+
* @returns {vec4} out
|
|
1890
|
+
*/
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
function normalize$1(out, a) {
|
|
1894
|
+
var x = a[0];
|
|
1895
|
+
var y = a[1];
|
|
1896
|
+
var z = a[2];
|
|
1897
|
+
var w = a[3];
|
|
1898
|
+
var len = x * x + y * y + z * z + w * w;
|
|
1899
|
+
|
|
1900
|
+
if (len > 0) {
|
|
1901
|
+
len = 1 / Math.sqrt(len);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
out[0] = x * len;
|
|
1905
|
+
out[1] = y * len;
|
|
1906
|
+
out[2] = z * len;
|
|
1907
|
+
out[3] = w * len;
|
|
1908
|
+
return out;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Perform some operation over an array of vec4s.
|
|
1912
|
+
*
|
|
1913
|
+
* @param {Array} a the array of vectors to iterate over
|
|
1914
|
+
* @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
|
|
1915
|
+
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
1916
|
+
* @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
|
|
1917
|
+
* @param {Function} fn Function to call for each vector in the array
|
|
1918
|
+
* @param {Object} [arg] additional argument to pass to fn
|
|
1919
|
+
* @returns {Array} a
|
|
1920
|
+
* @function
|
|
1921
|
+
*/
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
var forEach$1 = function () {
|
|
1925
|
+
var vec = create$2();
|
|
1926
|
+
return function (a, stride, offset, count, fn, arg) {
|
|
1927
|
+
var i, l;
|
|
1928
|
+
|
|
1929
|
+
if (!stride) {
|
|
1930
|
+
stride = 4;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
if (!offset) {
|
|
1934
|
+
offset = 0;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
if (count) {
|
|
1938
|
+
l = Math.min(count * stride + offset, a.length);
|
|
1939
|
+
} else {
|
|
1940
|
+
l = a.length;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
for (i = offset; i < l; i += stride) {
|
|
1944
|
+
vec[0] = a[i];
|
|
1945
|
+
vec[1] = a[i + 1];
|
|
1946
|
+
vec[2] = a[i + 2];
|
|
1947
|
+
vec[3] = a[i + 3];
|
|
1948
|
+
fn(vec, vec, arg);
|
|
1949
|
+
a[i] = vec[0];
|
|
1950
|
+
a[i + 1] = vec[1];
|
|
1951
|
+
a[i + 2] = vec[2];
|
|
1952
|
+
a[i + 3] = vec[3];
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
return a;
|
|
1956
|
+
};
|
|
1957
|
+
}();
|
|
1958
|
+
/**
|
|
1959
|
+
* Quaternion
|
|
1960
|
+
* @module quat
|
|
1961
|
+
*/
|
|
1962
|
+
|
|
1963
|
+
/**
|
|
1964
|
+
* Creates a new identity quat
|
|
1965
|
+
*
|
|
1966
|
+
* @returns {quat} a new quaternion
|
|
1967
|
+
*/
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
function create$3() {
|
|
1971
|
+
var out = new ARRAY_TYPE(4);
|
|
1972
|
+
|
|
1973
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1974
|
+
out[0] = 0;
|
|
1975
|
+
out[1] = 0;
|
|
1976
|
+
out[2] = 0;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
out[3] = 1;
|
|
1980
|
+
return out;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Sets a quat from the given angle and rotation axis,
|
|
1984
|
+
* then returns it.
|
|
1985
|
+
*
|
|
1986
|
+
* @param {quat} out the receiving quaternion
|
|
1987
|
+
* @param {ReadonlyVec3} axis the axis around which to rotate
|
|
1988
|
+
* @param {Number} rad the angle in radians
|
|
1989
|
+
* @returns {quat} out
|
|
1990
|
+
**/
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
function setAxisAngle(out, axis, rad) {
|
|
1994
|
+
rad = rad * 0.5;
|
|
1995
|
+
var s = Math.sin(rad);
|
|
1996
|
+
out[0] = s * axis[0];
|
|
1997
|
+
out[1] = s * axis[1];
|
|
1998
|
+
out[2] = s * axis[2];
|
|
1999
|
+
out[3] = Math.cos(rad);
|
|
2000
|
+
return out;
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Performs a spherical linear interpolation between two quat
|
|
2004
|
+
*
|
|
2005
|
+
* @param {quat} out the receiving quaternion
|
|
2006
|
+
* @param {ReadonlyQuat} a the first operand
|
|
2007
|
+
* @param {ReadonlyQuat} b the second operand
|
|
2008
|
+
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2009
|
+
* @returns {quat} out
|
|
2010
|
+
*/
|
|
2011
|
+
|
|
2012
|
+
|
|
2013
|
+
function slerp(out, a, b, t) {
|
|
2014
|
+
// benchmarks:
|
|
2015
|
+
// http://jsperf.com/quaternion-slerp-implementations
|
|
2016
|
+
var ax = a[0],
|
|
2017
|
+
ay = a[1],
|
|
2018
|
+
az = a[2],
|
|
2019
|
+
aw = a[3];
|
|
2020
|
+
var bx = b[0],
|
|
2021
|
+
by = b[1],
|
|
2022
|
+
bz = b[2],
|
|
2023
|
+
bw = b[3];
|
|
2024
|
+
var omega, cosom, sinom, scale0, scale1; // calc cosine
|
|
2025
|
+
|
|
2026
|
+
cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
|
|
2027
|
+
|
|
2028
|
+
if (cosom < 0.0) {
|
|
2029
|
+
cosom = -cosom;
|
|
2030
|
+
bx = -bx;
|
|
2031
|
+
by = -by;
|
|
2032
|
+
bz = -bz;
|
|
2033
|
+
bw = -bw;
|
|
2034
|
+
} // calculate coefficients
|
|
2035
|
+
|
|
2036
|
+
|
|
2037
|
+
if (1.0 - cosom > EPSILON) {
|
|
2038
|
+
// standard case (slerp)
|
|
2039
|
+
omega = Math.acos(cosom);
|
|
2040
|
+
sinom = Math.sin(omega);
|
|
2041
|
+
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
2042
|
+
scale1 = Math.sin(t * omega) / sinom;
|
|
2043
|
+
} else {
|
|
2044
|
+
// "from" and "to" quaternions are very close
|
|
2045
|
+
// ... so we can do a linear interpolation
|
|
2046
|
+
scale0 = 1.0 - t;
|
|
2047
|
+
scale1 = t;
|
|
2048
|
+
} // calculate final values
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
out[0] = scale0 * ax + scale1 * bx;
|
|
2052
|
+
out[1] = scale0 * ay + scale1 * by;
|
|
2053
|
+
out[2] = scale0 * az + scale1 * bz;
|
|
2054
|
+
out[3] = scale0 * aw + scale1 * bw;
|
|
2055
|
+
return out;
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
2059
|
+
*
|
|
2060
|
+
* NOTE: The resultant quaternion is not normalized, so you should be sure
|
|
2061
|
+
* to renormalize the quaternion yourself where necessary.
|
|
2062
|
+
*
|
|
2063
|
+
* @param {quat} out the receiving quaternion
|
|
2064
|
+
* @param {ReadonlyMat3} m rotation matrix
|
|
2065
|
+
* @returns {quat} out
|
|
2066
|
+
* @function
|
|
2067
|
+
*/
|
|
2068
|
+
|
|
2069
|
+
|
|
2070
|
+
function fromMat3(out, m) {
|
|
2071
|
+
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
|
|
2072
|
+
// article "Quaternion Calculus and Fast Animation".
|
|
2073
|
+
var fTrace = m[0] + m[4] + m[8];
|
|
2074
|
+
var fRoot;
|
|
2075
|
+
|
|
2076
|
+
if (fTrace > 0.0) {
|
|
2077
|
+
// |w| > 1/2, may as well choose w > 1/2
|
|
2078
|
+
fRoot = Math.sqrt(fTrace + 1.0); // 2w
|
|
2079
|
+
|
|
2080
|
+
out[3] = 0.5 * fRoot;
|
|
2081
|
+
fRoot = 0.5 / fRoot; // 1/(4w)
|
|
2082
|
+
|
|
2083
|
+
out[0] = (m[5] - m[7]) * fRoot;
|
|
2084
|
+
out[1] = (m[6] - m[2]) * fRoot;
|
|
2085
|
+
out[2] = (m[1] - m[3]) * fRoot;
|
|
2086
|
+
} else {
|
|
2087
|
+
// |w| <= 1/2
|
|
2088
|
+
var i = 0;
|
|
2089
|
+
if (m[4] > m[0]) i = 1;
|
|
2090
|
+
if (m[8] > m[i * 3 + i]) i = 2;
|
|
2091
|
+
var j = (i + 1) % 3;
|
|
2092
|
+
var k = (i + 2) % 3;
|
|
2093
|
+
fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
|
|
2094
|
+
out[i] = 0.5 * fRoot;
|
|
2095
|
+
fRoot = 0.5 / fRoot;
|
|
2096
|
+
out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
|
|
2097
|
+
out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
|
|
2098
|
+
out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
return out;
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* Normalize a quat
|
|
2105
|
+
*
|
|
2106
|
+
* @param {quat} out the receiving quaternion
|
|
2107
|
+
* @param {ReadonlyQuat} a quaternion to normalize
|
|
2108
|
+
* @returns {quat} out
|
|
2109
|
+
* @function
|
|
2110
|
+
*/
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
var normalize$2 = normalize$1;
|
|
2114
|
+
/**
|
|
2115
|
+
* Sets a quaternion to represent the shortest rotation from one
|
|
2116
|
+
* vector to another.
|
|
2117
|
+
*
|
|
2118
|
+
* Both vectors are assumed to be unit length.
|
|
2119
|
+
*
|
|
2120
|
+
* @param {quat} out the receiving quaternion.
|
|
2121
|
+
* @param {ReadonlyVec3} a the initial vector
|
|
2122
|
+
* @param {ReadonlyVec3} b the destination vector
|
|
2123
|
+
* @returns {quat} out
|
|
2124
|
+
*/
|
|
2125
|
+
|
|
2126
|
+
var rotationTo = function () {
|
|
2127
|
+
var tmpvec3 = create$1();
|
|
2128
|
+
var xUnitVec3 = fromValues(1, 0, 0);
|
|
2129
|
+
var yUnitVec3 = fromValues(0, 1, 0);
|
|
2130
|
+
return function (out, a, b) {
|
|
2131
|
+
var dot$1 = dot(a, b);
|
|
2132
|
+
|
|
2133
|
+
if (dot$1 < -0.999999) {
|
|
2134
|
+
cross(tmpvec3, xUnitVec3, a);
|
|
2135
|
+
if (len(tmpvec3) < 0.000001) cross(tmpvec3, yUnitVec3, a);
|
|
2136
|
+
normalize(tmpvec3, tmpvec3);
|
|
2137
|
+
setAxisAngle(out, tmpvec3, Math.PI);
|
|
2138
|
+
return out;
|
|
2139
|
+
} else if (dot$1 > 0.999999) {
|
|
2140
|
+
out[0] = 0;
|
|
2141
|
+
out[1] = 0;
|
|
2142
|
+
out[2] = 0;
|
|
2143
|
+
out[3] = 1;
|
|
2144
|
+
return out;
|
|
2145
|
+
} else {
|
|
2146
|
+
cross(tmpvec3, a, b);
|
|
2147
|
+
out[0] = tmpvec3[0];
|
|
2148
|
+
out[1] = tmpvec3[1];
|
|
2149
|
+
out[2] = tmpvec3[2];
|
|
2150
|
+
out[3] = 1 + dot$1;
|
|
2151
|
+
return normalize$2(out, out);
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
}();
|
|
2155
|
+
/**
|
|
2156
|
+
* Performs a spherical linear interpolation with two control points
|
|
2157
|
+
*
|
|
2158
|
+
* @param {quat} out the receiving quaternion
|
|
2159
|
+
* @param {ReadonlyQuat} a the first operand
|
|
2160
|
+
* @param {ReadonlyQuat} b the second operand
|
|
2161
|
+
* @param {ReadonlyQuat} c the third operand
|
|
2162
|
+
* @param {ReadonlyQuat} d the fourth operand
|
|
2163
|
+
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2164
|
+
* @returns {quat} out
|
|
2165
|
+
*/
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
var sqlerp = function () {
|
|
2169
|
+
var temp1 = create$3();
|
|
2170
|
+
var temp2 = create$3();
|
|
2171
|
+
return function (out, a, b, c, d, t) {
|
|
2172
|
+
slerp(temp1, a, d, t);
|
|
2173
|
+
slerp(temp2, b, c, t);
|
|
2174
|
+
slerp(out, temp1, temp2, 2 * t * (1 - t));
|
|
2175
|
+
return out;
|
|
2176
|
+
};
|
|
2177
|
+
}();
|
|
2178
|
+
/**
|
|
2179
|
+
* Sets the specified quaternion with values corresponding to the given
|
|
2180
|
+
* axes. Each axis is a vec3 and is expected to be unit length and
|
|
2181
|
+
* perpendicular to all other specified axes.
|
|
2182
|
+
*
|
|
2183
|
+
* @param {ReadonlyVec3} view the vector representing the viewing direction
|
|
2184
|
+
* @param {ReadonlyVec3} right the vector representing the local "right" direction
|
|
2185
|
+
* @param {ReadonlyVec3} up the vector representing the local "up" direction
|
|
2186
|
+
* @returns {quat} out
|
|
2187
|
+
*/
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
var setAxes = function () {
|
|
2191
|
+
var matr = create();
|
|
2192
|
+
return function (out, view, right, up) {
|
|
2193
|
+
matr[0] = right[0];
|
|
2194
|
+
matr[3] = right[1];
|
|
2195
|
+
matr[6] = right[2];
|
|
2196
|
+
matr[1] = up[0];
|
|
2197
|
+
matr[4] = up[1];
|
|
2198
|
+
matr[7] = up[2];
|
|
2199
|
+
matr[2] = -view[0];
|
|
2200
|
+
matr[5] = -view[1];
|
|
2201
|
+
matr[8] = -view[2];
|
|
2202
|
+
return normalize$2(out, fromMat3(out, matr));
|
|
2203
|
+
};
|
|
2204
|
+
}();
|
|
2205
|
+
|
|
2206
|
+
function createSVGElement(type) {
|
|
2207
|
+
return document.createElementNS('http://www.w3.org/2000/svg', type);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
var FILTER_PREFIX = 'g-filter-';
|
|
2211
|
+
/**
|
|
2212
|
+
* use SVG filters, eg. blur, brightness, contrast...
|
|
2213
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2214
|
+
*/
|
|
2215
|
+
|
|
2216
|
+
function createOrUpdateFilter($def, object, $el, filters) {
|
|
2217
|
+
// eg. filter="url(#f1) url(#f2)"
|
|
2218
|
+
var filterName = FILTER_PREFIX + object.entity;
|
|
2219
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
2220
|
+
|
|
2221
|
+
if ($existedFilters.length) {
|
|
2222
|
+
$existedFilters.forEach(function ($filter) {
|
|
2223
|
+
$def.removeChild($filter);
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
if (filters.length === 0) {
|
|
2228
|
+
// 'none'
|
|
2229
|
+
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
2230
|
+
} else {
|
|
2231
|
+
var filterIds = filters.map(function (_ref, i) {
|
|
2232
|
+
var name = _ref.name,
|
|
2233
|
+
params = _ref.params;
|
|
2234
|
+
var $filter = createSVGElement('filter');
|
|
2235
|
+
|
|
2236
|
+
if (name === 'blur') {
|
|
2237
|
+
createBlur($filter, params);
|
|
2238
|
+
} else if (name === 'brightness') {
|
|
2239
|
+
createBrightness($filter, params);
|
|
2240
|
+
} else if (name === 'drop-shadow') {
|
|
2241
|
+
createDropShadow($filter, params);
|
|
2242
|
+
} else if (name === 'contrast') {
|
|
2243
|
+
createContrast($filter, params);
|
|
2244
|
+
} else if (name === 'grayscale') {
|
|
2245
|
+
createGrayscale($filter, params);
|
|
2246
|
+
} else if (name === 'sepia') {
|
|
2247
|
+
createSepia($filter, params);
|
|
2248
|
+
} else if (name === 'saturate') {
|
|
2249
|
+
createSaturate($filter, params);
|
|
2250
|
+
} else if (name === 'hue-rotate') {
|
|
2251
|
+
createHueRotate($filter, params);
|
|
2252
|
+
} else if (name === 'invert') {
|
|
2253
|
+
createInvert($filter, params);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
$filter.id = filterName + "-" + i;
|
|
2257
|
+
$filter.setAttribute('name', filterName);
|
|
2258
|
+
$def.appendChild($filter);
|
|
2259
|
+
return $filter.id;
|
|
2260
|
+
});
|
|
2261
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
2262
|
+
return "url(#" + filterId + ")";
|
|
2263
|
+
}).join(' '));
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
function convertToAbsoluteValue(param) {
|
|
2268
|
+
return param.unit === g.UnitType.kPercentage ? param.value / 100 : param.value;
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* @see https://drafts.fxtf.org/filter-effects/#blurEquivalent
|
|
2272
|
+
*/
|
|
2273
|
+
|
|
2274
|
+
|
|
2275
|
+
function createBlur($filter, params) {
|
|
2276
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2277
|
+
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2278
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
2279
|
+
$filter.appendChild($feGaussianBlur);
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
function createFeComponentTransfer($filter, _ref2) {
|
|
2283
|
+
var type = _ref2.type,
|
|
2284
|
+
slope = _ref2.slope,
|
|
2285
|
+
intercept = _ref2.intercept,
|
|
2286
|
+
tableValues = _ref2.tableValues;
|
|
2287
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer');
|
|
2288
|
+
[createSVGElement('feFuncR'), createSVGElement('feFuncG'), createSVGElement('feFuncB')].forEach(function ($feFunc) {
|
|
2289
|
+
$feFunc.setAttribute('type', type);
|
|
2290
|
+
|
|
2291
|
+
if (type === 'table') {
|
|
2292
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
2293
|
+
} else {
|
|
2294
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2295
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
$feComponentTransfer.appendChild($feFunc);
|
|
2299
|
+
});
|
|
2300
|
+
$filter.appendChild($feComponentTransfer);
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
function createContrast($filter, params) {
|
|
2304
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
2305
|
+
createFeComponentTransfer($filter, {
|
|
2306
|
+
type: 'linear',
|
|
2307
|
+
slope: slope,
|
|
2308
|
+
intercept: -(0.5 * slope) + 0.5
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
function createInvert($filter, params) {
|
|
2313
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2314
|
+
createFeComponentTransfer($filter, {
|
|
2315
|
+
type: 'table',
|
|
2316
|
+
tableValues: amount + " " + (1 - amount)
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
function createBrightness($filter, params) {
|
|
2321
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
2322
|
+
createFeComponentTransfer($filter, {
|
|
2323
|
+
type: 'linear',
|
|
2324
|
+
slope: slope,
|
|
2325
|
+
intercept: 0
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function createSaturate($filter, params) {
|
|
2330
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2331
|
+
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2332
|
+
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2333
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
2334
|
+
$filter.appendChild($feColorMatrix);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
function createHueRotate($filter, params) {
|
|
2338
|
+
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2339
|
+
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
2340
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
|
|
2341
|
+
$filter.appendChild($feColorMatrix);
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
function createDropShadow($filter, params) {
|
|
2345
|
+
var shadowOffsetX = params[0].value;
|
|
2346
|
+
var shadowOffsetY = params[1].value;
|
|
2347
|
+
var shadowBlur = params[2].value; // @ts-ignore
|
|
2348
|
+
|
|
2349
|
+
var shadowColor = params[3].formatted;
|
|
2350
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur');
|
|
2351
|
+
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2352
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
2353
|
+
$filter.appendChild($feGaussianBlur);
|
|
2354
|
+
var $feOffset = createSVGElement('feOffset');
|
|
2355
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2356
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
2357
|
+
$feOffset.setAttribute('result', 'offsetblur');
|
|
2358
|
+
$filter.appendChild($feOffset);
|
|
2359
|
+
var $feFlood = createSVGElement('feFlood');
|
|
2360
|
+
$feFlood.setAttribute('flood-color', shadowColor);
|
|
2361
|
+
$filter.appendChild($feFlood);
|
|
2362
|
+
var $feComposite = createSVGElement('feComposite');
|
|
2363
|
+
$feComposite.setAttribute('in2', 'offsetblur');
|
|
2364
|
+
$feComposite.setAttribute('operator', 'in');
|
|
2365
|
+
$filter.appendChild($feComposite);
|
|
2366
|
+
var $feMerge = createSVGElement('feMerge');
|
|
2367
|
+
$filter.appendChild($feMerge);
|
|
2368
|
+
var $feMergeNode1 = createSVGElement('feMergeNode');
|
|
2369
|
+
var $feMergeNode2 = createSVGElement('feMergeNode');
|
|
2370
|
+
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
2371
|
+
$feMerge.appendChild($feMergeNode1);
|
|
2372
|
+
$feMerge.appendChild($feMergeNode2);
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
function createFeColorMatrix($filter, matrix) {
|
|
2376
|
+
var $feColorMatrix = createSVGElement('feColorMatrix');
|
|
2377
|
+
$feColorMatrix.setAttribute('type', 'matrix');
|
|
2378
|
+
$feColorMatrix.setAttribute('values', matrix.join(' '));
|
|
2379
|
+
$filter.appendChild($feColorMatrix);
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* @see https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
|
|
2383
|
+
*/
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
function createGrayscale($filter, params) {
|
|
2387
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2388
|
+
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]);
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
2392
|
+
*/
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
function createSepia($filter, params) {
|
|
2396
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2397
|
+
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]);
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
var cacheKey2IDMap = {};
|
|
2401
|
+
var counter = 0;
|
|
2402
|
+
|
|
2403
|
+
function createOrUpdateGradientAndPattern($def, object, $el, parsedColor, name) {
|
|
2404
|
+
// eg. clipPath don't have fill/stroke
|
|
2405
|
+
if (!parsedColor) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
var gradientId = generateCacheKey(parsedColor);
|
|
2410
|
+
var existed = $def.querySelector("#" + gradientId);
|
|
2411
|
+
|
|
2412
|
+
if (parsedColor instanceof g.CSSRGB) {
|
|
2413
|
+
// keep using currentColor @see https://github.com/d3/d3-axis/issues/49
|
|
2414
|
+
if (object.style[name] === 'currentColor') {
|
|
2415
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, 'currentColor');
|
|
2416
|
+
} else {
|
|
2417
|
+
// constant value, eg. '#fff'
|
|
2418
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, parsedColor.isNone ? 'none' : parsedColor.toString());
|
|
2419
|
+
}
|
|
2420
|
+
} else {
|
|
2421
|
+
if (parsedColor.type === g.GradientPatternType.Pattern) {
|
|
2422
|
+
if (!existed) {
|
|
2423
|
+
createPattern($def, parsedColor, gradientId);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2427
|
+
} else {
|
|
2428
|
+
if (!existed) {
|
|
2429
|
+
createGradient($def, parsedColor, gradientId);
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
function generateCacheKey(params) {
|
|
2438
|
+
var cacheKey = '';
|
|
2439
|
+
|
|
2440
|
+
if (params instanceof g.CSSGradientValue) {
|
|
2441
|
+
var type = params.type;
|
|
2442
|
+
|
|
2443
|
+
if (type === g.GradientPatternType.Pattern) {
|
|
2444
|
+
var src = params.value.src;
|
|
2445
|
+
cacheKey = src;
|
|
2446
|
+
} else if (type === g.GradientPatternType.LinearGradient || type === g.GradientPatternType.RadialGradient) {
|
|
2447
|
+
// @ts-ignore
|
|
2448
|
+
var _params$value = params.value,
|
|
2449
|
+
x0 = _params$value.x0,
|
|
2450
|
+
y0 = _params$value.y0,
|
|
2451
|
+
x1 = _params$value.x1,
|
|
2452
|
+
y1 = _params$value.y1,
|
|
2453
|
+
r1 = _params$value.r1,
|
|
2454
|
+
steps = _params$value.steps;
|
|
2455
|
+
cacheKey = "" + type + x0 + y0 + x1 + y1 + (r1 || 0) + steps.map(function (step) {
|
|
2456
|
+
return step.join('');
|
|
2457
|
+
}).join('');
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
if (cacheKey) {
|
|
2461
|
+
if (!cacheKey2IDMap[cacheKey]) {
|
|
2462
|
+
cacheKey2IDMap[cacheKey] = "_pattern_" + type + "_" + counter++;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
return cacheKey2IDMap[cacheKey];
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
function createPattern($def, parsedColor, patternId) {
|
|
2471
|
+
var src = parsedColor.value.src; // @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
2472
|
+
|
|
2473
|
+
var $pattern = createSVGElement('pattern');
|
|
2474
|
+
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
2475
|
+
var $image = createSVGElement('image');
|
|
2476
|
+
$pattern.appendChild($image);
|
|
2477
|
+
$pattern.id = patternId;
|
|
2478
|
+
$def.appendChild($pattern);
|
|
2479
|
+
$image.setAttribute('href', src);
|
|
2480
|
+
var img = new window.Image();
|
|
2481
|
+
|
|
2482
|
+
if (!src.match(/^data:/i)) {
|
|
2483
|
+
img.crossOrigin = 'Anonymous';
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
img.src = src;
|
|
2487
|
+
|
|
2488
|
+
function onload() {
|
|
2489
|
+
$pattern.setAttribute('width', "" + img.width);
|
|
2490
|
+
$pattern.setAttribute('height', "" + img.height);
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
if (img.complete) {
|
|
2494
|
+
onload();
|
|
2495
|
+
} else {
|
|
2496
|
+
img.onload = onload; // Fix onload() bug in IE9
|
|
2497
|
+
|
|
2498
|
+
img.src = img.src;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
function createGradient($def, parsedColor, gradientId) {
|
|
2503
|
+
// <linearGradient> <radialGradient>
|
|
2504
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
2505
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2506
|
+
var $gradient = createSVGElement(parsedColor.type === g.GradientPatternType.LinearGradient ? 'linearGradient' : 'radialGradient');
|
|
2507
|
+
|
|
2508
|
+
if (parsedColor.type === g.GradientPatternType.LinearGradient) {
|
|
2509
|
+
var _parsedColor$value = parsedColor.value,
|
|
2510
|
+
x0 = _parsedColor$value.x0,
|
|
2511
|
+
y0 = _parsedColor$value.y0,
|
|
2512
|
+
x1 = _parsedColor$value.x1,
|
|
2513
|
+
y1 = _parsedColor$value.y1;
|
|
2514
|
+
$gradient.setAttribute('x1', "" + x0);
|
|
2515
|
+
$gradient.setAttribute('y1', "" + y0);
|
|
2516
|
+
$gradient.setAttribute('x2', "" + x1);
|
|
2517
|
+
$gradient.setAttribute('y2', "" + y1);
|
|
2518
|
+
} else {
|
|
2519
|
+
var _parsedColor$value2 = parsedColor.value,
|
|
2520
|
+
_x = _parsedColor$value2.x0,
|
|
2521
|
+
_y = _parsedColor$value2.y0,
|
|
2522
|
+
r1 = _parsedColor$value2.r1;
|
|
2523
|
+
$gradient.setAttribute('cx', "" + _x);
|
|
2524
|
+
$gradient.setAttribute('cy', "" + _y);
|
|
2525
|
+
$gradient.setAttribute('r', "" + r1 / 2);
|
|
2526
|
+
} // add stops
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
var innerHTML = '';
|
|
2530
|
+
parsedColor.value.steps.forEach(function (_ref) {
|
|
2531
|
+
var offset = _ref[0],
|
|
2532
|
+
color = _ref[1];
|
|
2533
|
+
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
2534
|
+
});
|
|
2535
|
+
$gradient.innerHTML = innerHTML;
|
|
2536
|
+
$gradient.id = gradientId;
|
|
2537
|
+
$def.appendChild($gradient);
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
var FILTER_DROPSHADOW_PREFIX = 'filter-dropshadow-';
|
|
2541
|
+
/**
|
|
2542
|
+
* use SVG filters
|
|
2543
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2544
|
+
*/
|
|
2545
|
+
|
|
2546
|
+
function createOrUpdateShadow($def, object, $el, name) {
|
|
2547
|
+
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2548
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2549
|
+
|
|
2550
|
+
if (!$existedFilter) {
|
|
2551
|
+
$existedFilter = createSVGElement('filter');
|
|
2552
|
+
|
|
2553
|
+
var _$feDropShadow = createSVGElement('feDropShadow');
|
|
2554
|
+
|
|
2555
|
+
_$feDropShadow.setAttribute('dx', '0');
|
|
2556
|
+
|
|
2557
|
+
_$feDropShadow.setAttribute('dy', '0');
|
|
2558
|
+
|
|
2559
|
+
$existedFilter.appendChild(_$feDropShadow);
|
|
2560
|
+
$existedFilter.id = shadowId;
|
|
2561
|
+
$def.appendChild($existedFilter);
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
var $feDropShadow = $existedFilter.children[0];
|
|
2565
|
+
|
|
2566
|
+
if (name === 'shadowColor') {
|
|
2567
|
+
var parsedColor = object.parsedStyle[name];
|
|
2568
|
+
$feDropShadow.setAttribute('flood-color', parsedColor.toString());
|
|
2569
|
+
} else if (name === 'shadowBlur') {
|
|
2570
|
+
var shadowBlur = object.parsedStyle[name]; // half the blur radius
|
|
2571
|
+
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2572
|
+
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2573
|
+
|
|
2574
|
+
$feDropShadow.setAttribute('stdDeviation', "" + (shadowBlur && shadowBlur.value || 0) / 2);
|
|
2575
|
+
} else if (name === 'shadowOffsetX') {
|
|
2576
|
+
var shadowOffsetX = object.parsedStyle[name];
|
|
2577
|
+
$feDropShadow.setAttribute('dx', "" + (shadowOffsetX && shadowOffsetX.value || 0) / 2);
|
|
2578
|
+
} else if (name === 'shadowOffsetY') {
|
|
2579
|
+
var shadowOffsetY = object.parsedStyle[name];
|
|
2580
|
+
$feDropShadow.setAttribute('dy', "" + (shadowOffsetY && shadowOffsetY.value || 0) / 2);
|
|
2581
|
+
} // use filter <feDropShadow>
|
|
2582
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
var _SHAPE2TAGS, _class$1;
|
|
2589
|
+
|
|
2590
|
+
var SVGRendererPlugin_1;
|
|
2591
|
+
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);
|
|
2592
|
+
var SVG_ATTR_MAP = {
|
|
2593
|
+
opacity: 'opacity',
|
|
2594
|
+
fillStyle: 'fill',
|
|
2595
|
+
fill: 'fill',
|
|
2596
|
+
fillOpacity: 'fill-opacity',
|
|
2597
|
+
strokeStyle: 'stroke',
|
|
2598
|
+
strokeOpacity: 'stroke-opacity',
|
|
2599
|
+
stroke: 'stroke',
|
|
2600
|
+
clipPath: 'clip-path',
|
|
2601
|
+
r: 'r',
|
|
2602
|
+
rx: 'rx',
|
|
2603
|
+
ry: 'ry',
|
|
2604
|
+
width: 'width',
|
|
2605
|
+
height: 'height',
|
|
2606
|
+
lineCap: 'stroke-linecap',
|
|
2607
|
+
lineJoin: 'stroke-linejoin',
|
|
2608
|
+
lineWidth: 'stroke-width',
|
|
2609
|
+
lineDash: 'stroke-dasharray',
|
|
2610
|
+
lineDashOffset: 'stroke-dashoffset',
|
|
2611
|
+
miterLimit: 'stroke-miterlimit',
|
|
2612
|
+
font: 'font',
|
|
2613
|
+
fontSize: 'font-size',
|
|
2614
|
+
fontStyle: 'font-style',
|
|
2615
|
+
fontVariant: 'font-variant',
|
|
2616
|
+
fontWeight: 'font-weight',
|
|
2617
|
+
fontFamily: 'font-family',
|
|
2618
|
+
letterSpacing: 'letter-spacing',
|
|
2619
|
+
startArrow: 'marker-start',
|
|
2620
|
+
endArrow: 'marker-end',
|
|
2621
|
+
class: 'class',
|
|
2622
|
+
id: 'id',
|
|
2623
|
+
style: 'style',
|
|
2624
|
+
preserveAspectRatio: 'preserveAspectRatio',
|
|
2625
|
+
visibility: 'visibility',
|
|
2626
|
+
anchor: 'anchor',
|
|
2627
|
+
shadowColor: 'flood-color',
|
|
2628
|
+
shadowBlur: 'stdDeviation',
|
|
2629
|
+
shadowOffsetX: 'dx',
|
|
2630
|
+
shadowOffsetY: 'dy',
|
|
2631
|
+
filter: 'filter',
|
|
2632
|
+
innerHTML: 'innerHTML',
|
|
2633
|
+
textAlign: 'text-anchor'
|
|
2634
|
+
};
|
|
2635
|
+
var FORMAT_VALUE_MAP = {
|
|
2636
|
+
textAlign: {
|
|
2637
|
+
inherit: 'inherit',
|
|
2638
|
+
left: 'left',
|
|
2639
|
+
start: 'left',
|
|
2640
|
+
center: 'middle',
|
|
2641
|
+
right: 'end',
|
|
2642
|
+
end: 'end'
|
|
2643
|
+
}
|
|
2644
|
+
};
|
|
2645
|
+
var DEFAULT_VALUE_MAP = {
|
|
2646
|
+
textAlign: 'inherit',
|
|
2647
|
+
// textBaseline: 'alphabetic',
|
|
2648
|
+
// @see https://www.w3.org/TR/SVG/painting.html#LineCaps
|
|
2649
|
+
lineCap: 'butt',
|
|
2650
|
+
// @see https://www.w3.org/TR/SVG/painting.html#LineJoin
|
|
2651
|
+
lineJoin: 'miter',
|
|
2652
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/stroke-width
|
|
2653
|
+
lineWidth: '1px',
|
|
2654
|
+
opacity: '1',
|
|
2655
|
+
fillOpacity: '1',
|
|
2656
|
+
strokeOpacity: '1',
|
|
2657
|
+
strokeWidth: '0',
|
|
2658
|
+
strokeMiterLimit: '4',
|
|
2659
|
+
letterSpacing: '0',
|
|
2660
|
+
fontSize: 'inherit',
|
|
2661
|
+
fontFamily: 'inherit'
|
|
2662
|
+
};
|
|
2663
|
+
/**
|
|
2664
|
+
* G_SVG_PREFIX + nodeName + entity
|
|
2665
|
+
*
|
|
2666
|
+
* eg. g_svg_circle_345
|
|
2667
|
+
*/
|
|
2668
|
+
|
|
2669
|
+
var G_SVG_PREFIX = 'g_svg';
|
|
2670
|
+
var CLIP_PATH_PREFIX = 'clip-path-';
|
|
2671
|
+
var SVGRendererPlugin = SVGRendererPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
2672
|
+
function SVGRendererPlugin() {
|
|
2673
|
+
this.canvasConfig = void 0;
|
|
2674
|
+
this.camera = void 0;
|
|
2675
|
+
this.contextService = void 0;
|
|
2676
|
+
this.renderingContext = void 0;
|
|
2677
|
+
this.elementRendererFactory = void 0;
|
|
2678
|
+
this.$def = void 0;
|
|
2679
|
+
this.$camera = void 0;
|
|
2680
|
+
this.renderQueue = [];
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
var _proto = SVGRendererPlugin.prototype;
|
|
2684
|
+
|
|
2685
|
+
_proto.apply = function apply(renderingService) {
|
|
2686
|
+
var _this = this;
|
|
2687
|
+
|
|
2688
|
+
var handleMounted = function handleMounted(e) {
|
|
2689
|
+
var object = e.target; // create SVG DOM Node
|
|
2690
|
+
|
|
2691
|
+
_this.createSVGDom(object, _this.$camera);
|
|
2692
|
+
};
|
|
2693
|
+
|
|
2694
|
+
var handleUnmounted = function handleUnmounted(e) {
|
|
2695
|
+
var object = e.target;
|
|
2696
|
+
|
|
2697
|
+
_this.removeSVGDom(object);
|
|
2698
|
+
};
|
|
2699
|
+
|
|
2700
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
2701
|
+
var object = e.target; // @see https://github.com/antvis/g/issues/994
|
|
2702
|
+
// @ts-ignore
|
|
2703
|
+
|
|
2704
|
+
if (!object.elementSVG) {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
var attrName = e.attrName;
|
|
2709
|
+
|
|
2710
|
+
if (attrName === 'zIndex') {
|
|
2711
|
+
var _object$parentNode, _object$parentNode$el;
|
|
2712
|
+
|
|
2713
|
+
var parent = object.parentNode; // @ts-ignore
|
|
2714
|
+
|
|
2715
|
+
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;
|
|
2716
|
+
var children = ((parent === null || parent === void 0 ? void 0 : parent.children) || []).slice();
|
|
2717
|
+
|
|
2718
|
+
if ($groupEl) {
|
|
2719
|
+
_this.reorderChildren($groupEl, children);
|
|
2720
|
+
}
|
|
2721
|
+
} else if (attrName === 'increasedLineWidthForHitTesting') {
|
|
2722
|
+
// @ts-ignore
|
|
2723
|
+
var svgElement = object.elementSVG;
|
|
2724
|
+
|
|
2725
|
+
_this.createOrUpdateHitArea(object, svgElement.$el, svgElement.$groupEl);
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
_this.updateAttribute(object, [attrName]);
|
|
2729
|
+
};
|
|
2730
|
+
|
|
2731
|
+
renderingService.hooks.init.tapPromise(SVGRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
2732
|
+
var $svg, background;
|
|
2733
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
2734
|
+
while (1) {
|
|
2735
|
+
switch (_context.prev = _context.next) {
|
|
2736
|
+
case 0:
|
|
2737
|
+
_this.$def = createSVGElement('defs');
|
|
2738
|
+
$svg = _this.contextService.getContext();
|
|
2739
|
+
background = _this.canvasConfig.background;
|
|
2740
|
+
|
|
2741
|
+
if (background) {
|
|
2742
|
+
$svg.style.background = background;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
$svg.appendChild(_this.$def); // @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/color-interpolation-filters
|
|
2746
|
+
|
|
2747
|
+
$svg.setAttribute('color-interpolation-filters', 'sRGB');
|
|
2748
|
+
_this.$camera = createSVGElement('g');
|
|
2749
|
+
_this.$camera.id = G_SVG_PREFIX + "_camera";
|
|
2750
|
+
|
|
2751
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
2752
|
+
|
|
2753
|
+
$svg.appendChild(_this.$camera);
|
|
2754
|
+
|
|
2755
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2756
|
+
|
|
2757
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2758
|
+
|
|
2759
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2760
|
+
|
|
2761
|
+
case 13:
|
|
2762
|
+
case "end":
|
|
2763
|
+
return _context.stop();
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}, _callee);
|
|
2767
|
+
})));
|
|
2768
|
+
renderingService.hooks.destroy.tap(SVGRendererPlugin_1.tag, function () {
|
|
2769
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2770
|
+
|
|
2771
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
2772
|
+
|
|
2773
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2774
|
+
});
|
|
2775
|
+
renderingService.hooks.render.tap(SVGRendererPlugin_1.tag, function (object) {
|
|
2776
|
+
// if (!object.isCulled()) {
|
|
2777
|
+
_this.renderQueue.push(object); // }
|
|
2778
|
+
|
|
2779
|
+
});
|
|
2780
|
+
renderingService.hooks.endFrame.tap(SVGRendererPlugin_1.tag, function () {
|
|
2781
|
+
if (_this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED)) {
|
|
2782
|
+
_this.applyTransform(_this.$camera, _this.camera.getOrthoMatrix());
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
_this.renderQueue.forEach(function (object) {
|
|
2786
|
+
var _object$elementSVG, _object$elementSVG2; // @ts-ignore
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
var $el = (_object$elementSVG = object.elementSVG) === null || _object$elementSVG === void 0 ? void 0 : _object$elementSVG.$el; // @ts-ignore
|
|
2790
|
+
|
|
2791
|
+
var $groupEl = (_object$elementSVG2 = object.elementSVG) === null || _object$elementSVG2 === void 0 ? void 0 : _object$elementSVG2.$groupEl;
|
|
2792
|
+
|
|
2793
|
+
if ($el && $groupEl) {
|
|
2794
|
+
// apply local RTS transformation to <group> wrapper
|
|
2795
|
+
// account for anchor
|
|
2796
|
+
_this.applyTransform($groupEl, object.getLocalTransform());
|
|
2797
|
+
|
|
2798
|
+
var children = ((object === null || object === void 0 ? void 0 : object.children) || []).slice();
|
|
2799
|
+
|
|
2800
|
+
_this.reorderChildren($groupEl, children || []); // finish rendering, clear dirty flag
|
|
2801
|
+
|
|
2802
|
+
|
|
2803
|
+
object.renderable.dirty = false;
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
|
|
2807
|
+
_this.renderQueue = [];
|
|
2808
|
+
});
|
|
2809
|
+
};
|
|
2810
|
+
|
|
2811
|
+
_proto.reorderChildren = function reorderChildren($groupEl, children) {
|
|
2812
|
+
// need to reorder parent's children
|
|
2813
|
+
children.sort(function (a, b) {
|
|
2814
|
+
return a.sortable.renderOrder - b.sortable.renderOrder;
|
|
2815
|
+
});
|
|
2816
|
+
|
|
2817
|
+
if (children.length) {
|
|
2818
|
+
// create empty fragment
|
|
2819
|
+
var fragment = document.createDocumentFragment();
|
|
2820
|
+
children.forEach(function (child) {
|
|
2821
|
+
// @ts-ignore
|
|
2822
|
+
var $el = child.elementSVG.$groupEl;
|
|
2823
|
+
|
|
2824
|
+
if ($el) {
|
|
2825
|
+
fragment.appendChild($el);
|
|
2826
|
+
}
|
|
2827
|
+
});
|
|
2828
|
+
$groupEl.appendChild(fragment);
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
|
|
2832
|
+
_proto.applyTransform = function applyTransform($el, transform) {
|
|
2833
|
+
var translation = getTranslation(create$1(), transform);
|
|
2834
|
+
var scaling = getScaling(create$1(), transform);
|
|
2835
|
+
var rotation = getRotation(create$3(), transform);
|
|
2836
|
+
var x = translation[0],
|
|
2837
|
+
y = translation[1];
|
|
2838
|
+
var scaleX = scaling[0],
|
|
2839
|
+
scaleY = scaling[1]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2840
|
+
|
|
2841
|
+
var _getEuler = g.getEuler(create$1(), rotation),
|
|
2842
|
+
ex = _getEuler[0],
|
|
2843
|
+
ey = _getEuler[1],
|
|
2844
|
+
ez = _getEuler[2]; // gimbal lock at 90 degrees
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
var rts = g.fromRotationTranslationScale(ex || ez, x, y, scaleX, scaleY); // use proper precision avoiding too long string in `transform`
|
|
2848
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
2849
|
+
|
|
2850
|
+
$el.setAttribute('transform', "matrix(" + numberToLongString(rts[0]) + "," + numberToLongString(rts[1]) + "," + numberToLongString(rts[3]) + "," + numberToLongString(rts[4]) + "," + numberToLongString(rts[6]) + "," + numberToLongString(rts[7]) + ")");
|
|
2851
|
+
};
|
|
2852
|
+
|
|
2853
|
+
_proto.applyAttributes = function applyAttributes(object) {
|
|
2854
|
+
// @ts-ignore
|
|
2855
|
+
var elementSVG = object.elementSVG;
|
|
2856
|
+
var $el = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$el;
|
|
2857
|
+
var $groupEl = elementSVG === null || elementSVG === void 0 ? void 0 : elementSVG.$groupEl;
|
|
2858
|
+
|
|
2859
|
+
if ($el && $groupEl) {
|
|
2860
|
+
var nodeName = object.nodeName,
|
|
2861
|
+
attributes = object.attributes;
|
|
2862
|
+
$el.setAttribute('fill', 'none');
|
|
2863
|
+
|
|
2864
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
2865
|
+
$el.setAttribute('preserveAspectRatio', 'none');
|
|
2866
|
+
} // apply attributes
|
|
2867
|
+
|
|
2868
|
+
|
|
2869
|
+
this.updateAttribute(object, Object.keys(attributes));
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
_proto.updateAttribute = function updateAttribute(object, attributes) {
|
|
2874
|
+
var _this2 = this;
|
|
2875
|
+
|
|
2876
|
+
var needGeneratePath = false; // @ts-ignore
|
|
2877
|
+
|
|
2878
|
+
var _object$elementSVG3 = object.elementSVG,
|
|
2879
|
+
$el = _object$elementSVG3.$el,
|
|
2880
|
+
$groupEl = _object$elementSVG3.$groupEl,
|
|
2881
|
+
$hitTestingEl = _object$elementSVG3.$hitTestingEl;
|
|
2882
|
+
var parsedStyle = object.parsedStyle,
|
|
2883
|
+
computedStyle = object.computedStyle;
|
|
2884
|
+
var elementRenderer = this.elementRendererFactory(object.nodeName);
|
|
2885
|
+
attributes.forEach(function (name) {
|
|
2886
|
+
var usedName = SVG_ATTR_MAP[name];
|
|
2887
|
+
var computedValue = computedStyle[name];
|
|
2888
|
+
var usedValue = parsedStyle[name]; // generate path only once
|
|
2889
|
+
|
|
2890
|
+
if (!needGeneratePath && elementRenderer && elementRenderer.dependencies.indexOf(name) > -1) {
|
|
2891
|
+
needGeneratePath = true;
|
|
2892
|
+
} // <foreignObject>
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
2896
|
+
if (name === 'fill') {
|
|
2897
|
+
$el.style.background = usedValue.toString();
|
|
2898
|
+
} else if (name === 'stroke') {
|
|
2899
|
+
$el.style['border-color'] = usedValue.toString();
|
|
2900
|
+
$el.style['border-style'] = 'solid';
|
|
2901
|
+
} else if (name === 'lineWidth') {
|
|
2902
|
+
$el.style['border-width'] = (usedValue.value || 0) + "px";
|
|
2903
|
+
} else if (name === 'lineDash') {
|
|
2904
|
+
$el.style['border-style'] = 'dashed';
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
if (name === 'fill' || name === 'stroke') {
|
|
2909
|
+
createOrUpdateGradientAndPattern(_this2.$def, object, $el, usedValue, usedName);
|
|
2910
|
+
} else if (name === 'visibility') {
|
|
2911
|
+
// use computed value
|
|
2912
|
+
// update `visibility` on <group>
|
|
2913
|
+
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
|
|
2914
|
+
} else if (name === 'clipPath') {
|
|
2915
|
+
_this2.createOrUpdateClipPath(usedValue, $groupEl);
|
|
2916
|
+
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2917
|
+
createOrUpdateShadow(_this2.$def, object, $el, name);
|
|
2918
|
+
} else if (name === 'filter') {
|
|
2919
|
+
createOrUpdateFilter(_this2.$def, object, $el, usedValue);
|
|
2920
|
+
} else if (name === 'innerHTML') {
|
|
2921
|
+
_this2.createOrUpdateInnerHTML($el, usedValue);
|
|
2922
|
+
} else {
|
|
2923
|
+
if ( // (!object.style.clipPathTargets) &&
|
|
2924
|
+
object.nodeName !== g.Shape.TEXT && // text' anchor is controlled by `textAnchor` property
|
|
2925
|
+
['width', 'height', 'r', 'rx', 'ry', 'anchor'].indexOf(name) > -1) {
|
|
2926
|
+
_this2.updateAnchorWithTransform(object);
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2929
|
+
if (name !== 'anchor' && computedValue) {
|
|
2930
|
+
// use computed value so that we can use cascaded effect in SVG
|
|
2931
|
+
var valueStr = computedValue.toString(); // ignore 'unset' and default value
|
|
2932
|
+
|
|
2933
|
+
if (valueStr !== 'unset' && valueStr !== DEFAULT_VALUE_MAP[name]) {
|
|
2934
|
+
var _FORMAT_VALUE_MAP$nam;
|
|
2935
|
+
|
|
2936
|
+
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;
|
|
2937
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2938
|
+
if ($el && usedName) {
|
|
2939
|
+
$el.setAttribute(usedName, formattedValueStr);
|
|
2940
|
+
}
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
}); // need re-generate path
|
|
2946
|
+
|
|
2947
|
+
if (needGeneratePath && $el) {
|
|
2948
|
+
[$el, $hitTestingEl].forEach(function ($el) {
|
|
2949
|
+
if ($el) {
|
|
2950
|
+
elementRenderer.apply($el, object.parsedStyle);
|
|
2951
|
+
}
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2956
|
+
_proto.createSVGDom = function createSVGDom(object, root, noWrapWithGroup) {
|
|
2957
|
+
if (noWrapWithGroup === void 0) {
|
|
2958
|
+
noWrapWithGroup = false;
|
|
2959
|
+
} // create svg element
|
|
2960
|
+
// @ts-ignore
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
object.elementSVG = new ElementSVG(); // @ts-ignore
|
|
2964
|
+
|
|
2965
|
+
var svgElement = object.elementSVG; // use <group> as default, eg. CustomElement
|
|
2966
|
+
|
|
2967
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
2968
|
+
|
|
2969
|
+
if (type) {
|
|
2970
|
+
var _object$parentNode$el2;
|
|
2971
|
+
|
|
2972
|
+
var $groupEl;
|
|
2973
|
+
var $el = createSVGElement(type); // save $el on parsedStyle, which will be returned in getDomElement()
|
|
2974
|
+
|
|
2975
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
2976
|
+
object.parsedStyle.$el = $el;
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
$el.id = G_SVG_PREFIX + "_" + object.nodeName + "_" + object.entity;
|
|
2980
|
+
|
|
2981
|
+
if (type !== 'g' && !noWrapWithGroup) {
|
|
2982
|
+
$groupEl = createSVGElement('g');
|
|
2983
|
+
$groupEl.appendChild($el);
|
|
2984
|
+
} else {
|
|
2985
|
+
$groupEl = $el;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
svgElement.$el = $el;
|
|
2989
|
+
svgElement.$groupEl = $groupEl;
|
|
2990
|
+
var $parentGroupEl = // @ts-ignore
|
|
2991
|
+
object.parentNode && ((_object$parentNode$el2 = object.parentNode.elementSVG) === null || _object$parentNode$el2 === void 0 ? void 0 : _object$parentNode$el2.$groupEl) || root;
|
|
2992
|
+
|
|
2993
|
+
if ($parentGroupEl) {
|
|
2994
|
+
$parentGroupEl.appendChild($groupEl);
|
|
2995
|
+
} // apply attributes at first time
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
this.applyAttributes(object); // create hitArea if necessary
|
|
2999
|
+
|
|
3000
|
+
this.createOrUpdateHitArea(object, $el, $groupEl);
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
|
|
3004
|
+
_proto.removeSVGDom = function removeSVGDom(object) {
|
|
3005
|
+
var _object$elementSVG4; // @ts-ignore
|
|
3006
|
+
|
|
3007
|
+
|
|
3008
|
+
var $groupEl = (_object$elementSVG4 = object.elementSVG) === null || _object$elementSVG4 === void 0 ? void 0 : _object$elementSVG4.$groupEl;
|
|
3009
|
+
|
|
3010
|
+
if ($groupEl && $groupEl.parentNode) {
|
|
3011
|
+
$groupEl.parentNode.removeChild($groupEl); // object.entity.removeComponent(ElementSVG, true);
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
|
|
3015
|
+
_proto.createOrUpdateHitArea = function createOrUpdateHitArea(object, $el, $groupEl) {
|
|
3016
|
+
var _object$parsedStyle$i; // @ts-ignore
|
|
3017
|
+
|
|
3018
|
+
|
|
3019
|
+
var svgElement = object.elementSVG;
|
|
3020
|
+
var $hitTestingEl = svgElement.$hitTestingEl;
|
|
3021
|
+
var increasedLineWidthForHitTesting = (_object$parsedStyle$i = object.parsedStyle.increasedLineWidthForHitTesting) === null || _object$parsedStyle$i === void 0 ? void 0 : _object$parsedStyle$i.value; // account for hitArea
|
|
3022
|
+
|
|
3023
|
+
if (increasedLineWidthForHitTesting) {
|
|
3024
|
+
var _object$parsedStyle$l;
|
|
3025
|
+
|
|
3026
|
+
if (!$hitTestingEl) {
|
|
3027
|
+
$hitTestingEl = $el.cloneNode(); // use the entity suffix, so that `g-plugin-svg-picker` can extract
|
|
3028
|
+
|
|
3029
|
+
$hitTestingEl.id = G_SVG_PREFIX + "_" + object.nodeName + "_hittesting_" + object.entity; // clear attributes like `filter` `font-size`
|
|
3030
|
+
|
|
3031
|
+
['filter'].forEach(function (attribute) {
|
|
3032
|
+
$hitTestingEl.removeAttribute(attribute);
|
|
3033
|
+
}); // hitArea should be 'transparent' but not 'none'
|
|
3034
|
+
|
|
3035
|
+
var hasFill = $el.getAttribute('fill') !== 'none';
|
|
3036
|
+
$hitTestingEl.setAttribute('fill', hasFill ? 'transparent' : 'none');
|
|
3037
|
+
$hitTestingEl.setAttribute('stroke', 'transparent');
|
|
3038
|
+
$groupEl.appendChild($hitTestingEl);
|
|
3039
|
+
svgElement.$hitTestingEl = $hitTestingEl;
|
|
3040
|
+
} // increase interactive line width
|
|
3041
|
+
|
|
3042
|
+
|
|
3043
|
+
$hitTestingEl.setAttribute('stroke-width', "" + (increasedLineWidthForHitTesting + ((_object$parsedStyle$l = object.parsedStyle.lineWidth) === null || _object$parsedStyle$l === void 0 ? void 0 : _object$parsedStyle$l.value)));
|
|
3044
|
+
} else {
|
|
3045
|
+
if ($hitTestingEl) {
|
|
3046
|
+
$groupEl.removeChild($hitTestingEl);
|
|
3047
|
+
svgElement.$hitTestingEl = null;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
_proto.createOrUpdateInnerHTML = function createOrUpdateInnerHTML($el, usedValue) {
|
|
3053
|
+
var $div = document.createElement('div');
|
|
3054
|
+
|
|
3055
|
+
if (typeof usedValue === 'string') {
|
|
3056
|
+
$div.innerHTML = usedValue;
|
|
3057
|
+
} else {
|
|
3058
|
+
$div.appendChild(usedValue);
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
$el.innerHTML = '';
|
|
3062
|
+
$el.appendChild($div);
|
|
3063
|
+
};
|
|
3064
|
+
|
|
3065
|
+
_proto.createOrUpdateClipPath = function createOrUpdateClipPath(clipPath, $groupEl) {
|
|
3066
|
+
if (clipPath) {
|
|
3067
|
+
var _clipPath$elementSVG;
|
|
3068
|
+
|
|
3069
|
+
var clipPathId = CLIP_PATH_PREFIX + clipPath.entity;
|
|
3070
|
+
var existed = this.$def.querySelector("#" + clipPathId);
|
|
3071
|
+
|
|
3072
|
+
if (!existed) {
|
|
3073
|
+
// create <clipPath> dom node, append it to <defs>
|
|
3074
|
+
var $clipPath = createSVGElement('clipPath');
|
|
3075
|
+
$clipPath.id = clipPathId;
|
|
3076
|
+
this.$def.appendChild($clipPath); // <clipPath><circle /></clipPath>
|
|
3077
|
+
|
|
3078
|
+
this.createSVGDom(clipPath, $clipPath, true); // @ts-ignore
|
|
3079
|
+
|
|
3080
|
+
clipPath.elementSVG.$groupEl = $clipPath;
|
|
3081
|
+
} // @ts-ignore
|
|
3082
|
+
|
|
3083
|
+
|
|
3084
|
+
var $clipPathGroupEl = (_clipPath$elementSVG = clipPath.elementSVG) === null || _clipPath$elementSVG === void 0 ? void 0 : _clipPath$elementSVG.$groupEl;
|
|
3085
|
+
|
|
3086
|
+
if ($clipPathGroupEl) {
|
|
3087
|
+
// apply local RTS transformation to <group> wrapper
|
|
3088
|
+
this.applyTransform($clipPathGroupEl, clipPath.getLocalTransform());
|
|
3089
|
+
} // apply attributes
|
|
3090
|
+
|
|
3091
|
+
|
|
3092
|
+
this.applyAttributes(clipPath); // apply clipPath to $group
|
|
3093
|
+
// @see https://github.com/antvis/g/issues/961
|
|
3094
|
+
|
|
3095
|
+
$groupEl.setAttribute('clip-path', "url(#" + clipPathId + ")");
|
|
3096
|
+
} else {
|
|
3097
|
+
// remove clip path
|
|
3098
|
+
$groupEl.removeAttribute('clip-path');
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
/**
|
|
3102
|
+
* the origin is bounding box's top left corner
|
|
3103
|
+
*/
|
|
3104
|
+
;
|
|
3105
|
+
|
|
3106
|
+
_proto.updateAnchorWithTransform = function updateAnchorWithTransform(object) {
|
|
3107
|
+
var _object$elementSVG5, _object$elementSVG6;
|
|
3108
|
+
|
|
3109
|
+
var bounds = object.getGeometryBounds();
|
|
3110
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
3111
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
3112
|
+
|
|
3113
|
+
var _ref2 = object.parsedStyle || {},
|
|
3114
|
+
anchor = _ref2.anchor; // @ts-ignore
|
|
3115
|
+
|
|
3116
|
+
|
|
3117
|
+
[(_object$elementSVG5 = object.elementSVG) === null || _object$elementSVG5 === void 0 ? void 0 : _object$elementSVG5.$el, (_object$elementSVG6 = object.elementSVG) === null || _object$elementSVG6 === void 0 ? void 0 : _object$elementSVG6.$hitTestingEl].forEach(function ($el) {
|
|
3118
|
+
if ($el) {
|
|
3119
|
+
// apply anchor to element's `transform` property
|
|
3120
|
+
$el.setAttribute('transform', // can't use percent unit like translate(-50%, -50%)
|
|
3121
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/transform#translate
|
|
3122
|
+
"translate(-" + anchor[0].value * width + ",-" + anchor[1].value * height + ")");
|
|
3123
|
+
|
|
3124
|
+
if (object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE) {
|
|
3125
|
+
$el.setAttribute('cx', "" + width / 2);
|
|
3126
|
+
$el.setAttribute('cy', "" + height / 2);
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
3130
|
+
};
|
|
3131
|
+
|
|
3132
|
+
return SVGRendererPlugin;
|
|
3133
|
+
}(), _class$1.tag = 'SVGRenderer', _class$1);
|
|
3134
|
+
|
|
3135
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "canvasConfig", void 0);
|
|
3136
|
+
|
|
3137
|
+
__decorate([manaSyringe.inject(g.DefaultCamera), __metadata("design:type", g.Camera)], SVGRendererPlugin.prototype, "camera", void 0);
|
|
3138
|
+
|
|
3139
|
+
__decorate([manaSyringe.inject(g.ContextService), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "contextService", void 0);
|
|
3140
|
+
|
|
3141
|
+
__decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], SVGRendererPlugin.prototype, "renderingContext", void 0);
|
|
3142
|
+
|
|
3143
|
+
__decorate([manaSyringe.inject(ElementRendererFactory), __metadata("design:type", Function)], SVGRendererPlugin.prototype, "elementRendererFactory", void 0);
|
|
3144
|
+
|
|
3145
|
+
SVGRendererPlugin = SVGRendererPlugin_1 = __decorate([manaSyringe.singleton({
|
|
3146
|
+
contrib: g.RenderingPluginContribution
|
|
3147
|
+
})], SVGRendererPlugin);
|
|
3148
|
+
var containerModule$1 = manaSyringe.Module(function (register) {
|
|
3149
|
+
/**
|
|
3150
|
+
* register shape renderers
|
|
3151
|
+
*/
|
|
3152
|
+
register(RectRenderer);
|
|
3153
|
+
register(ImageRenderer);
|
|
3154
|
+
register(LineRenderer);
|
|
3155
|
+
register(PolylineRenderer);
|
|
3156
|
+
register(TextRenderer);
|
|
3157
|
+
register(PathRenderer);
|
|
3158
|
+
register({
|
|
3159
|
+
token: ElementRendererFactory,
|
|
3160
|
+
useFactory: function useFactory(ctx) {
|
|
3161
|
+
return function (tagName) {
|
|
3162
|
+
if (tagName === g.Shape.RECT) {
|
|
3163
|
+
return ctx.container.get(RectRenderer);
|
|
3164
|
+
} else if (tagName === g.Shape.IMAGE) {
|
|
3165
|
+
return ctx.container.get(ImageRenderer);
|
|
3166
|
+
} else if (tagName === g.Shape.LINE) {
|
|
3167
|
+
return ctx.container.get(LineRenderer);
|
|
3168
|
+
} else if (tagName === g.Shape.POLYLINE || tagName === g.Shape.POLYGON) {
|
|
3169
|
+
return ctx.container.get(PolylineRenderer);
|
|
3170
|
+
} else if (tagName === g.Shape.TEXT) {
|
|
3171
|
+
return ctx.container.get(TextRenderer);
|
|
3172
|
+
} else if (tagName === g.Shape.PATH) {
|
|
3173
|
+
return ctx.container.get(PathRenderer);
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
return null;
|
|
3177
|
+
};
|
|
3178
|
+
}
|
|
3179
|
+
});
|
|
3180
|
+
register(SVGRendererPlugin);
|
|
3181
|
+
});
|
|
3182
|
+
|
|
3183
|
+
var Plugin$1 = /*#__PURE__*/function () {
|
|
3184
|
+
function Plugin() {
|
|
3185
|
+
this.name = 'svg-renderer';
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
var _proto = Plugin.prototype;
|
|
3189
|
+
|
|
3190
|
+
_proto.init = function init(container) {
|
|
3191
|
+
container.load(containerModule$1, true);
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3194
|
+
_proto.destroy = function destroy(container) {
|
|
3195
|
+
container.unload(containerModule$1);
|
|
3196
|
+
};
|
|
3197
|
+
|
|
3198
|
+
return Plugin;
|
|
3199
|
+
}();
|
|
3200
|
+
|
|
3201
|
+
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
3202
|
+
__proto__: null,
|
|
3203
|
+
DEFAULT_VALUE_MAP: DEFAULT_VALUE_MAP,
|
|
3204
|
+
ElementSVG: ElementSVG,
|
|
3205
|
+
G_SVG_PREFIX: G_SVG_PREFIX,
|
|
3206
|
+
Plugin: Plugin$1,
|
|
3207
|
+
SHAPE2TAGS: SHAPE2TAGS,
|
|
3208
|
+
get SVGRendererPlugin () { return SVGRendererPlugin; },
|
|
3209
|
+
SVG_ATTR_MAP: SVG_ATTR_MAP,
|
|
3210
|
+
containerModule: containerModule$1,
|
|
3211
|
+
createSVGElement: createSVGElement
|
|
3212
|
+
});
|
|
3213
|
+
|
|
3214
|
+
function _regeneratorRuntime$2() {
|
|
3215
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3216
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
3217
|
+
return exports;
|
|
3218
|
+
};
|
|
3219
|
+
|
|
3220
|
+
var exports = {},
|
|
3221
|
+
Op = Object.prototype,
|
|
3222
|
+
hasOwn = Op.hasOwnProperty,
|
|
3223
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
3224
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
3225
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
3226
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
3227
|
+
|
|
3228
|
+
function define(obj, key, value) {
|
|
3229
|
+
return Object.defineProperty(obj, key, {
|
|
3230
|
+
value: value,
|
|
3231
|
+
enumerable: !0,
|
|
3232
|
+
configurable: !0,
|
|
3233
|
+
writable: !0
|
|
3234
|
+
}), obj[key];
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
try {
|
|
3238
|
+
define({}, "");
|
|
3239
|
+
} catch (err) {
|
|
3240
|
+
define = function define(obj, key, value) {
|
|
3241
|
+
return obj[key] = value;
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
3246
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
3247
|
+
generator = Object.create(protoGenerator.prototype),
|
|
3248
|
+
context = new Context(tryLocsList || []);
|
|
3249
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
3250
|
+
var state = "suspendedStart";
|
|
3251
|
+
return function (method, arg) {
|
|
3252
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
3253
|
+
|
|
3254
|
+
if ("completed" === state) {
|
|
3255
|
+
if ("throw" === method) throw arg;
|
|
3256
|
+
return doneResult();
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
for (context.method = method, context.arg = arg;;) {
|
|
3260
|
+
var delegate = context.delegate;
|
|
3261
|
+
|
|
3262
|
+
if (delegate) {
|
|
3263
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
3264
|
+
|
|
3265
|
+
if (delegateResult) {
|
|
3266
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
3267
|
+
return delegateResult;
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
3272
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
3273
|
+
context.dispatchException(context.arg);
|
|
3274
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
3275
|
+
state = "executing";
|
|
3276
|
+
var record = tryCatch(innerFn, self, context);
|
|
3277
|
+
|
|
3278
|
+
if ("normal" === record.type) {
|
|
3279
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
3280
|
+
return {
|
|
3281
|
+
value: record.arg,
|
|
3282
|
+
done: context.done
|
|
3283
|
+
};
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
3287
|
+
}
|
|
3288
|
+
};
|
|
3289
|
+
}(innerFn, self, context), generator;
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
function tryCatch(fn, obj, arg) {
|
|
3293
|
+
try {
|
|
3294
|
+
return {
|
|
3295
|
+
type: "normal",
|
|
3296
|
+
arg: fn.call(obj, arg)
|
|
3297
|
+
};
|
|
3298
|
+
} catch (err) {
|
|
3299
|
+
return {
|
|
3300
|
+
type: "throw",
|
|
3301
|
+
arg: err
|
|
3302
|
+
};
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
exports.wrap = wrap;
|
|
3307
|
+
var ContinueSentinel = {};
|
|
3308
|
+
|
|
3309
|
+
function Generator() {}
|
|
3310
|
+
|
|
3311
|
+
function GeneratorFunction() {}
|
|
3312
|
+
|
|
3313
|
+
function GeneratorFunctionPrototype() {}
|
|
3314
|
+
|
|
3315
|
+
var IteratorPrototype = {};
|
|
3316
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
3317
|
+
return this;
|
|
3318
|
+
});
|
|
3319
|
+
var getProto = Object.getPrototypeOf,
|
|
3320
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
3321
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
3322
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
3323
|
+
|
|
3324
|
+
function defineIteratorMethods(prototype) {
|
|
3325
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
3326
|
+
define(prototype, method, function (arg) {
|
|
3327
|
+
return this._invoke(method, arg);
|
|
3328
|
+
});
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
3333
|
+
function invoke(method, arg, resolve, reject) {
|
|
3334
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
3335
|
+
|
|
3336
|
+
if ("throw" !== record.type) {
|
|
3337
|
+
var result = record.arg,
|
|
3338
|
+
value = result.value;
|
|
3339
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
3340
|
+
invoke("next", value, resolve, reject);
|
|
3341
|
+
}, function (err) {
|
|
3342
|
+
invoke("throw", err, resolve, reject);
|
|
3343
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
3344
|
+
result.value = unwrapped, resolve(result);
|
|
3345
|
+
}, function (error) {
|
|
3346
|
+
return invoke("throw", error, resolve, reject);
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
reject(record.arg);
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
var previousPromise;
|
|
3354
|
+
|
|
3355
|
+
this._invoke = function (method, arg) {
|
|
3356
|
+
function callInvokeWithMethodAndArg() {
|
|
3357
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
3358
|
+
invoke(method, arg, resolve, reject);
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
3367
|
+
var method = delegate.iterator[context.method];
|
|
3368
|
+
|
|
3369
|
+
if (undefined === method) {
|
|
3370
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
3371
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
3372
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3375
|
+
return ContinueSentinel;
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
3379
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
3380
|
+
var info = record.arg;
|
|
3381
|
+
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);
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
function pushTryEntry(locs) {
|
|
3385
|
+
var entry = {
|
|
3386
|
+
tryLoc: locs[0]
|
|
3387
|
+
};
|
|
3388
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
function resetTryEntry(entry) {
|
|
3392
|
+
var record = entry.completion || {};
|
|
3393
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
function Context(tryLocsList) {
|
|
3397
|
+
this.tryEntries = [{
|
|
3398
|
+
tryLoc: "root"
|
|
3399
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
function values(iterable) {
|
|
3403
|
+
if (iterable) {
|
|
3404
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
3405
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
3406
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
3407
|
+
|
|
3408
|
+
if (!isNaN(iterable.length)) {
|
|
3409
|
+
var i = -1,
|
|
3410
|
+
next = function next() {
|
|
3411
|
+
for (; ++i < iterable.length;) {
|
|
3412
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
return next.value = undefined, next.done = !0, next;
|
|
3416
|
+
};
|
|
3417
|
+
|
|
3418
|
+
return next.next = next;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
return {
|
|
3423
|
+
next: doneResult
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
function doneResult() {
|
|
3428
|
+
return {
|
|
3429
|
+
value: undefined,
|
|
3430
|
+
done: !0
|
|
3431
|
+
};
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
3435
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
3436
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
3437
|
+
}, exports.mark = function (genFun) {
|
|
3438
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
3439
|
+
}, exports.awrap = function (arg) {
|
|
3440
|
+
return {
|
|
3441
|
+
__await: arg
|
|
3442
|
+
};
|
|
3443
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
3444
|
+
return this;
|
|
3445
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
3446
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
3447
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
3448
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
3449
|
+
return result.done ? result.value : iter.next();
|
|
3450
|
+
});
|
|
3451
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
3452
|
+
return this;
|
|
3453
|
+
}), define(Gp, "toString", function () {
|
|
3454
|
+
return "[object Generator]";
|
|
3455
|
+
}), exports.keys = function (object) {
|
|
3456
|
+
var keys = [];
|
|
3457
|
+
|
|
3458
|
+
for (var key in object) {
|
|
3459
|
+
keys.push(key);
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
return keys.reverse(), function next() {
|
|
3463
|
+
for (; keys.length;) {
|
|
3464
|
+
var key = keys.pop();
|
|
3465
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
return next.done = !0, next;
|
|
3469
|
+
};
|
|
3470
|
+
}, exports.values = values, Context.prototype = {
|
|
3471
|
+
constructor: Context,
|
|
3472
|
+
reset: function reset(skipTempReset) {
|
|
3473
|
+
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) {
|
|
3474
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
3475
|
+
}
|
|
3476
|
+
},
|
|
3477
|
+
stop: function stop() {
|
|
3478
|
+
this.done = !0;
|
|
3479
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
3480
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
3481
|
+
return this.rval;
|
|
3482
|
+
},
|
|
3483
|
+
dispatchException: function dispatchException(exception) {
|
|
3484
|
+
if (this.done) throw exception;
|
|
3485
|
+
var context = this;
|
|
3486
|
+
|
|
3487
|
+
function handle(loc, caught) {
|
|
3488
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3492
|
+
var entry = this.tryEntries[i],
|
|
3493
|
+
record = entry.completion;
|
|
3494
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
3495
|
+
|
|
3496
|
+
if (entry.tryLoc <= this.prev) {
|
|
3497
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
3498
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
3499
|
+
|
|
3500
|
+
if (hasCatch && hasFinally) {
|
|
3501
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
3502
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
3503
|
+
} else if (hasCatch) {
|
|
3504
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
3505
|
+
} else {
|
|
3506
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
3507
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
},
|
|
3512
|
+
abrupt: function abrupt(type, arg) {
|
|
3513
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3514
|
+
var entry = this.tryEntries[i];
|
|
3515
|
+
|
|
3516
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
3517
|
+
var finallyEntry = entry;
|
|
3518
|
+
break;
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
3523
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
3524
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
3525
|
+
},
|
|
3526
|
+
complete: function complete(record, afterLoc) {
|
|
3527
|
+
if ("throw" === record.type) throw record.arg;
|
|
3528
|
+
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;
|
|
3529
|
+
},
|
|
3530
|
+
finish: function finish(finallyLoc) {
|
|
3531
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3532
|
+
var entry = this.tryEntries[i];
|
|
3533
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
3534
|
+
}
|
|
3535
|
+
},
|
|
3536
|
+
catch: function _catch(tryLoc) {
|
|
3537
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
3538
|
+
var entry = this.tryEntries[i];
|
|
3539
|
+
|
|
3540
|
+
if (entry.tryLoc === tryLoc) {
|
|
3541
|
+
var record = entry.completion;
|
|
3542
|
+
|
|
3543
|
+
if ("throw" === record.type) {
|
|
3544
|
+
var thrown = record.arg;
|
|
3545
|
+
resetTryEntry(entry);
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
return thrown;
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3552
|
+
throw new Error("illegal catch attempt");
|
|
3553
|
+
},
|
|
3554
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
3555
|
+
return this.delegate = {
|
|
3556
|
+
iterator: values(iterable),
|
|
3557
|
+
resultName: resultName,
|
|
3558
|
+
nextLoc: nextLoc
|
|
3559
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
3560
|
+
}
|
|
3561
|
+
}, exports;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3565
|
+
try {
|
|
3566
|
+
var info = gen[key](arg);
|
|
3567
|
+
var value = info.value;
|
|
3568
|
+
} catch (error) {
|
|
3569
|
+
reject(error);
|
|
3570
|
+
return;
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
if (info.done) {
|
|
3574
|
+
resolve(value);
|
|
3575
|
+
} else {
|
|
3576
|
+
Promise.resolve(value).then(_next, _throw);
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
function _asyncToGenerator$2(fn) {
|
|
3581
|
+
return function () {
|
|
3582
|
+
var self = this,
|
|
3583
|
+
args = arguments;
|
|
3584
|
+
return new Promise(function (resolve, reject) {
|
|
3585
|
+
var gen = fn.apply(self, args);
|
|
3586
|
+
|
|
3587
|
+
function _next(value) {
|
|
3588
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
function _throw(err) {
|
|
3592
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
_next(undefined);
|
|
3596
|
+
});
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
3601
|
+
if (!o) return;
|
|
3602
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
3603
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3604
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3605
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
3606
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
function _arrayLikeToArray(arr, len) {
|
|
3610
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3611
|
+
|
|
3612
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3613
|
+
arr2[i] = arr[i];
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
return arr2;
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
3620
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3621
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3622
|
+
|
|
3623
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3624
|
+
if (it) o = it;
|
|
3625
|
+
var i = 0;
|
|
3626
|
+
return function () {
|
|
3627
|
+
if (i >= o.length) return {
|
|
3628
|
+
done: true
|
|
3629
|
+
};
|
|
3630
|
+
return {
|
|
3631
|
+
done: false,
|
|
3632
|
+
value: o[i++]
|
|
3633
|
+
};
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
var _class$2;
|
|
3641
|
+
|
|
3642
|
+
var SVGPickerPlugin_1;
|
|
3643
|
+
/**
|
|
3644
|
+
* pick shape(s) with Mouse/Touch event
|
|
3645
|
+
*
|
|
3646
|
+
* 1. find AABB with r-tree
|
|
3647
|
+
* 2. use elementFromPoint
|
|
3648
|
+
*/
|
|
3649
|
+
|
|
3650
|
+
var SVGPickerPlugin = SVGPickerPlugin_1 = (_class$2 = /*#__PURE__*/function () {
|
|
3651
|
+
function SVGPickerPlugin() {
|
|
3652
|
+
this.sceneGraphService = void 0;
|
|
3653
|
+
this.displayObjectPool = void 0;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
var _proto = SVGPickerPlugin.prototype;
|
|
3657
|
+
|
|
3658
|
+
_proto.apply = function apply(renderingService) {
|
|
3659
|
+
var _this = this;
|
|
3660
|
+
|
|
3661
|
+
renderingService.hooks.pick.tapPromise(SVGPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
3662
|
+
var _ref = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee(result) {
|
|
3663
|
+
var topmost, _result$position, clientX, clientY, targets, _iterator, _step, element, id, index, target;
|
|
3664
|
+
|
|
3665
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
3666
|
+
while (1) {
|
|
3667
|
+
switch (_context.prev = _context.next) {
|
|
3668
|
+
case 0:
|
|
3669
|
+
topmost = result.topmost, _result$position = result.position, clientX = _result$position.clientX, clientY = _result$position.clientY;
|
|
3670
|
+
_context.prev = 1;
|
|
3671
|
+
targets = []; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/elementsFromPoint
|
|
3672
|
+
|
|
3673
|
+
_iterator = _createForOfIteratorHelperLoose(document.elementsFromPoint(clientX, clientY));
|
|
3674
|
+
|
|
3675
|
+
case 4:
|
|
3676
|
+
if ((_step = _iterator()).done) {
|
|
3677
|
+
_context.next = 17;
|
|
3678
|
+
break;
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
element = _step.value; // eg. g_svg_circle_345
|
|
3682
|
+
|
|
3683
|
+
id = element && element.getAttribute('id');
|
|
3684
|
+
|
|
3685
|
+
if (!(id && id.startsWith(G_SVG_PREFIX))) {
|
|
3686
|
+
_context.next = 15;
|
|
3687
|
+
break;
|
|
3688
|
+
}
|
|
3689
|
+
|
|
3690
|
+
index = id.lastIndexOf('_');
|
|
3691
|
+
target = _this.displayObjectPool.getByEntity(Number(id.substring(index + 1))); // don't need to account for `visibility` since DOM API already does
|
|
3692
|
+
|
|
3693
|
+
if (!(target && target.isInteractive())) {
|
|
3694
|
+
_context.next = 15;
|
|
3695
|
+
break;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
targets.push(target);
|
|
3699
|
+
|
|
3700
|
+
if (!topmost) {
|
|
3701
|
+
_context.next = 15;
|
|
3702
|
+
break;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
result.picked = targets;
|
|
3706
|
+
return _context.abrupt("return", result);
|
|
3707
|
+
|
|
3708
|
+
case 15:
|
|
3709
|
+
_context.next = 4;
|
|
3710
|
+
break;
|
|
3711
|
+
|
|
3712
|
+
case 17:
|
|
3713
|
+
result.picked = targets;
|
|
3714
|
+
_context.next = 23;
|
|
3715
|
+
break;
|
|
3716
|
+
|
|
3717
|
+
case 20:
|
|
3718
|
+
_context.prev = 20;
|
|
3719
|
+
_context.t0 = _context["catch"](1);
|
|
3720
|
+
result.picked = [];
|
|
3721
|
+
|
|
3722
|
+
case 23:
|
|
3723
|
+
return _context.abrupt("return", result);
|
|
3724
|
+
|
|
3725
|
+
case 24:
|
|
3726
|
+
case "end":
|
|
3727
|
+
return _context.stop();
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
}, _callee, null, [[1, 20]]);
|
|
3731
|
+
}));
|
|
3732
|
+
|
|
3733
|
+
return function (_x) {
|
|
3734
|
+
return _ref.apply(this, arguments);
|
|
3735
|
+
};
|
|
3736
|
+
}());
|
|
3737
|
+
};
|
|
3738
|
+
|
|
3739
|
+
return SVGPickerPlugin;
|
|
3740
|
+
}(), _class$2.tag = 'SVGPicker', _class$2);
|
|
3741
|
+
|
|
3742
|
+
__decorate([manaSyringe.inject(g.SceneGraphService), __metadata("design:type", Object)], SVGPickerPlugin.prototype, "sceneGraphService", void 0);
|
|
3743
|
+
|
|
3744
|
+
__decorate([manaSyringe.inject(g.DisplayObjectPool), __metadata("design:type", g.DisplayObjectPool)], SVGPickerPlugin.prototype, "displayObjectPool", void 0);
|
|
3745
|
+
|
|
3746
|
+
SVGPickerPlugin = SVGPickerPlugin_1 = __decorate([manaSyringe.singleton({
|
|
3747
|
+
contrib: g.RenderingPluginContribution
|
|
3748
|
+
})], SVGPickerPlugin);
|
|
3749
|
+
var containerModule$2 = manaSyringe.Module(function (register) {
|
|
3750
|
+
register(SVGPickerPlugin);
|
|
3751
|
+
});
|
|
3752
|
+
|
|
3753
|
+
var Plugin$2 = /*#__PURE__*/function () {
|
|
3754
|
+
function Plugin() {
|
|
3755
|
+
this.name = 'svg-picker';
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
var _proto = Plugin.prototype;
|
|
3759
|
+
|
|
3760
|
+
_proto.init = function init(container) {
|
|
3761
|
+
container.load(containerModule$2, true);
|
|
3762
|
+
};
|
|
3763
|
+
|
|
3764
|
+
_proto.destroy = function destroy(container) {
|
|
3765
|
+
container.unload(containerModule$2);
|
|
3766
|
+
};
|
|
3767
|
+
|
|
3768
|
+
return Plugin;
|
|
3769
|
+
}();
|
|
3770
|
+
|
|
3771
|
+
var index_esm$2 = /*#__PURE__*/Object.freeze({
|
|
3772
|
+
__proto__: null,
|
|
3773
|
+
Plugin: Plugin$2
|
|
3774
|
+
});
|
|
3775
|
+
|
|
3776
|
+
var SVGContextService = /*#__PURE__*/function () {
|
|
3777
|
+
function SVGContextService() {
|
|
3778
|
+
this.$container = void 0;
|
|
3779
|
+
this.$namespace = void 0;
|
|
3780
|
+
this.dpr = void 0;
|
|
3781
|
+
this.canvasConfig = void 0;
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
var _proto = SVGContextService.prototype;
|
|
3785
|
+
|
|
3786
|
+
_proto.init = function init() {
|
|
3787
|
+
var container = this.canvasConfig.container; // create container
|
|
3788
|
+
|
|
3789
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
3790
|
+
|
|
3791
|
+
if (this.$container) {
|
|
3792
|
+
if (!this.$container.style.position) {
|
|
3793
|
+
this.$container.style.position = 'relative';
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
var $namespace = createSVGElement('svg');
|
|
3797
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
3798
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
3799
|
+
this.$container.appendChild($namespace);
|
|
3800
|
+
this.$namespace = $namespace;
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
var dpr = window.devicePixelRatio || 1;
|
|
3804
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
3805
|
+
this.dpr = dpr;
|
|
3806
|
+
} // @ts-ignore
|
|
3807
|
+
;
|
|
3808
|
+
|
|
3809
|
+
_proto.getDomElement = function getDomElement() {
|
|
3810
|
+
return this.$namespace;
|
|
3811
|
+
};
|
|
3812
|
+
|
|
3813
|
+
_proto.getContext = function getContext() {
|
|
3814
|
+
return this.$namespace;
|
|
3815
|
+
};
|
|
3816
|
+
|
|
3817
|
+
_proto.getDPR = function getDPR() {
|
|
3818
|
+
return this.dpr;
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3821
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
3822
|
+
var _this$$namespace;
|
|
3823
|
+
|
|
3824
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
3825
|
+
};
|
|
3826
|
+
|
|
3827
|
+
_proto.destroy = function destroy() {
|
|
3828
|
+
// destroy context
|
|
3829
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
3830
|
+
this.$container.removeChild(this.$namespace);
|
|
3831
|
+
}
|
|
3832
|
+
};
|
|
3833
|
+
|
|
3834
|
+
_proto.resize = function resize(width, height) {
|
|
3835
|
+
if (this.$namespace) {
|
|
3836
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
3837
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
3838
|
+
}
|
|
3839
|
+
};
|
|
3840
|
+
|
|
3841
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
3842
|
+
if (this.$container) {
|
|
3843
|
+
this.$container.style.cursor = cursor;
|
|
3844
|
+
}
|
|
3845
|
+
};
|
|
3846
|
+
|
|
3847
|
+
return SVGContextService;
|
|
3848
|
+
}();
|
|
3849
|
+
|
|
3850
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
|
|
3851
|
+
|
|
3852
|
+
SVGContextService = __decorate([manaSyringe.singleton({
|
|
3853
|
+
token: g.ContextService
|
|
3854
|
+
})], SVGContextService);
|
|
3855
|
+
|
|
3856
|
+
var containerModule$3 = manaSyringe.Module(function (register) {
|
|
3857
|
+
/**
|
|
3858
|
+
* implements ContextService
|
|
3859
|
+
*/
|
|
3860
|
+
register(SVGContextService);
|
|
3861
|
+
});
|
|
3862
|
+
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
3863
|
+
function ContextRegisterPlugin() {
|
|
3864
|
+
this.name = 'svg-context-register';
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
3868
|
+
|
|
3869
|
+
_proto.init = function init(container) {
|
|
3870
|
+
container.load(containerModule$3, true);
|
|
3871
|
+
};
|
|
3872
|
+
|
|
3873
|
+
_proto.destroy = function destroy(container) {
|
|
3874
|
+
container.unload(containerModule$3);
|
|
3875
|
+
};
|
|
3876
|
+
|
|
3877
|
+
return ContextRegisterPlugin;
|
|
3878
|
+
}();
|
|
3879
|
+
|
|
3880
|
+
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
3881
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
3882
|
+
|
|
3883
|
+
function Renderer(config) {
|
|
3884
|
+
var _this;
|
|
3885
|
+
|
|
3886
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
3887
|
+
|
|
3888
|
+
_this.registerPlugin(new ContextRegisterPlugin());
|
|
3889
|
+
|
|
3890
|
+
_this.registerPlugin(new Plugin$1());
|
|
3891
|
+
|
|
3892
|
+
_this.registerPlugin(new Plugin());
|
|
3893
|
+
|
|
3894
|
+
_this.registerPlugin(new Plugin$2());
|
|
3895
|
+
|
|
3896
|
+
return _this;
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
return Renderer;
|
|
3900
|
+
}(g.AbstractRenderer);
|
|
3901
|
+
|
|
3902
|
+
exports.DomInteraction = index_esm;
|
|
3903
|
+
exports.Renderer = Renderer;
|
|
3904
|
+
exports.SVGPicker = index_esm$2;
|
|
3905
|
+
exports.SVGRenderer = index_esm$1;
|
|
3906
|
+
|
|
3907
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3908
|
+
|
|
3909
|
+
})));
|