@idraw/util 0.2.0-alpha.2 → 0.2.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -71,7 +71,7 @@ function createUUID() {
71
71
 
72
72
  function deepClone(target) {
73
73
  function _clone(t) {
74
- var type = is(t);
74
+ var type = is$1(t);
75
75
  if (['Null', 'Number', 'String', 'Boolean', 'Undefined'].indexOf(type) >= 0) {
76
76
  return t;
77
77
  }
@@ -93,7 +93,7 @@ function deepClone(target) {
93
93
  }
94
94
  return _clone(target);
95
95
  }
96
- function is(data) {
96
+ function is$1(data) {
97
97
  return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, '').split(' ')[1];
98
98
  }
99
99
 
@@ -134,61 +134,82 @@ var istype = {
134
134
  promise: function (data) {
135
135
  return parsePrototype(data) === 'Promise';
136
136
  },
137
- nodeList: function (data) {
138
- return parsePrototype(data) === 'NodeList';
139
- },
140
- imageData: function (data) {
141
- return parsePrototype(data) === 'ImageData';
142
- }
143
137
  };
144
138
 
145
- var Image = window.Image, Blob = window.Blob, FileReader = window.FileReader;
146
- function loadImage(src) {
147
- return new Promise(function (resolve, reject) {
148
- var img = new Image;
149
- img.onload = function () {
150
- resolve(img);
151
- };
152
- img.onabort = reject;
153
- img.onerror = reject;
154
- img.src = src;
155
- });
156
- }
157
- function loadSVG(svg) {
139
+ var __assign = function() {
140
+ __assign = Object.assign || function __assign(t) {
141
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
142
+ s = arguments[i];
143
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
144
+ }
145
+ return t;
146
+ };
147
+ return __assign.apply(this, arguments);
148
+ };
149
+ function __awaiter(thisArg, _arguments, P, generator) {
150
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
151
+ return new (P || (P = Promise))(function (resolve, reject) {
152
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
153
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
154
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
155
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
156
+ });
157
+ }
158
+ function __generator(thisArg, body) {
159
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
160
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
161
+ function verb(n) { return function (v) { return step([n, v]); }; }
162
+ function step(op) {
163
+ if (f) throw new TypeError("Generator is already executing.");
164
+ while (_) try {
165
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
166
+ if (y = 0, t) op = [op[0] & 2, t.value];
167
+ switch (op[0]) {
168
+ case 0: case 1: t = op; break;
169
+ case 4: _.label++; return { value: op[1], done: false };
170
+ case 5: _.label++; y = op[1]; op = [0]; continue;
171
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
172
+ default:
173
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
174
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
175
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
176
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
177
+ if (t[2]) _.ops.pop();
178
+ _.trys.pop(); continue;
179
+ }
180
+ op = body.call(thisArg, _);
181
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
182
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
183
+ }
184
+ }
185
+
186
+ function parseHTMLToDataURL(html, opts) {
187
+ var width = opts.width, height = opts.height;
158
188
  return new Promise(function (resolve, reject) {
159
- var _svg = svg;
160
- var image = new Image();
189
+ var _svg = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + (width || '') + "\" height = \"" + (height || '') + "\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n " + html + "\n </div>\n </foreignObject>\n </svg>\n ";
161
190
  var blob = new Blob([_svg], { type: 'image/svg+xml;charset=utf-8' });
162
191
  var reader = new FileReader();
163
192
  reader.readAsDataURL(blob);
164
193
  reader.onload = function (event) {
165
194
  var _a;
166
195
  var base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.result;
167
- image.onload = function () {
168
- resolve(image);
169
- };
170
- image.src = base64;
196
+ resolve(base64);
171
197
  };
172
198
  reader.onerror = function (err) {
173
199
  reject(err);
174
200
  };
175
201
  });
176
202
  }
177
- function loadHTML(html, opts) {
178
- var width = opts.width, height = opts.height;
203
+ function parseSVGToDataURL(svg) {
179
204
  return new Promise(function (resolve, reject) {
180
- var _svg = "\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + (width || '') + "\" height = \"" + (height || '') + "\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n " + html + "\n </div>\n </foreignObject>\n </svg>\n ";
181
- var image = new Image();
205
+ var _svg = svg;
182
206
  var blob = new Blob([_svg], { type: 'image/svg+xml;charset=utf-8' });
183
207
  var reader = new FileReader();
184
208
  reader.readAsDataURL(blob);
185
209
  reader.onload = function (event) {
186
210
  var _a;
187
211
  var base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.result;
188
- image.onload = function () {
189
- resolve(image);
190
- };
191
- image.src = base64;
212
+ resolve(base64);
192
213
  };
193
214
  reader.onerror = function (err) {
194
215
  reject(err);
@@ -196,7 +217,465 @@ function loadHTML(html, opts) {
196
217
  });
197
218
  }
198
219
 
220
+ var Image = window.Image;
221
+ function loadImage(src) {
222
+ return new Promise(function (resolve, reject) {
223
+ var img = new Image;
224
+ img.onload = function () {
225
+ resolve(img);
226
+ };
227
+ img.onabort = reject;
228
+ img.onerror = reject;
229
+ img.src = src;
230
+ });
231
+ }
232
+ function loadSVG(svg) {
233
+ return __awaiter(this, void 0, void 0, function () {
234
+ var dataURL, image;
235
+ return __generator(this, function (_a) {
236
+ switch (_a.label) {
237
+ case 0: return [4, parseSVGToDataURL(svg)];
238
+ case 1:
239
+ dataURL = _a.sent();
240
+ return [4, loadImage(dataURL)];
241
+ case 2:
242
+ image = _a.sent();
243
+ return [2, image];
244
+ }
245
+ });
246
+ });
247
+ }
248
+ function loadHTML(html, opts) {
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ var dataURL, image;
251
+ return __generator(this, function (_a) {
252
+ switch (_a.label) {
253
+ case 0: return [4, parseHTMLToDataURL(html, opts)];
254
+ case 1:
255
+ dataURL = _a.sent();
256
+ return [4, loadImage(dataURL)];
257
+ case 2:
258
+ image = _a.sent();
259
+ return [2, image];
260
+ }
261
+ });
262
+ });
263
+ }
264
+
265
+ var Context = (function () {
266
+ function Context(ctx, opts) {
267
+ this._opts = opts;
268
+ this._ctx = ctx;
269
+ this._transform = {
270
+ scale: 1,
271
+ scrollX: 0,
272
+ scrollY: 0,
273
+ };
274
+ }
275
+ Context.prototype.getContext = function () {
276
+ return this._ctx;
277
+ };
278
+ Context.prototype.resetSize = function (opts) {
279
+ this._opts = __assign(__assign({}, this._opts), opts);
280
+ };
281
+ Context.prototype.calcDeviceNum = function (num) {
282
+ return num * this._opts.devicePixelRatio;
283
+ };
284
+ Context.prototype.calcScreenNum = function (num) {
285
+ return num / this._opts.devicePixelRatio;
286
+ };
287
+ Context.prototype.getSize = function () {
288
+ return {
289
+ width: this._opts.width,
290
+ height: this._opts.height,
291
+ contextWidth: this._opts.contextWidth,
292
+ contextHeight: this._opts.contextHeight,
293
+ devicePixelRatio: this._opts.devicePixelRatio,
294
+ };
295
+ };
296
+ Context.prototype.setTransform = function (config) {
297
+ this._transform = __assign(__assign({}, this._transform), config);
298
+ };
299
+ Context.prototype.getTransform = function () {
300
+ return {
301
+ scale: this._transform.scale,
302
+ scrollX: this._transform.scrollX,
303
+ scrollY: this._transform.scrollY,
304
+ };
305
+ };
306
+ Context.prototype.setFillStyle = function (color) {
307
+ this._ctx.fillStyle = color;
308
+ };
309
+ Context.prototype.fill = function (fillRule) {
310
+ return this._ctx.fill(fillRule || 'nonzero');
311
+ };
312
+ Context.prototype.arc = function (x, y, radius, startAngle, endAngle, anticlockwise) {
313
+ return this._ctx.arc(this._doSize(x), this._doSize(y), this._doSize(radius), startAngle, endAngle, anticlockwise);
314
+ };
315
+ Context.prototype.rect = function (x, y, w, h) {
316
+ return this._ctx.rect(this._doSize(x), this._doSize(y), this._doSize(w), this._doSize(h));
317
+ };
318
+ Context.prototype.fillRect = function (x, y, w, h) {
319
+ return this._ctx.fillRect(this._doSize(x), this._doSize(y), this._doSize(w), this._doSize(h));
320
+ };
321
+ Context.prototype.clearRect = function (x, y, w, h) {
322
+ return this._ctx.clearRect(this._doSize(x), this._doSize(y), this._doSize(w), this._doSize(h));
323
+ };
324
+ Context.prototype.beginPath = function () {
325
+ return this._ctx.beginPath();
326
+ };
327
+ Context.prototype.closePath = function () {
328
+ return this._ctx.closePath();
329
+ };
330
+ Context.prototype.lineTo = function (x, y) {
331
+ return this._ctx.lineTo(this._doSize(x), this._doSize(y));
332
+ };
333
+ Context.prototype.moveTo = function (x, y) {
334
+ return this._ctx.moveTo(this._doSize(x), this._doSize(y));
335
+ };
336
+ Context.prototype.arcTo = function (x1, y1, x2, y2, radius) {
337
+ return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
338
+ };
339
+ Context.prototype.setLineWidth = function (w) {
340
+ return this._ctx.lineWidth = this._doSize(w);
341
+ };
342
+ Context.prototype.setLineDash = function (nums) {
343
+ var _this = this;
344
+ return this._ctx.setLineDash(nums.map(function (n) { return _this._doSize(n); }));
345
+ };
346
+ Context.prototype.isPointInPath = function (x, y) {
347
+ return this._ctx.isPointInPath(this._doX(x), this._doY(y));
348
+ };
349
+ Context.prototype.isPointInPathWithoutScroll = function (x, y) {
350
+ return this._ctx.isPointInPath(this._doSize(x), this._doSize(y));
351
+ };
352
+ Context.prototype.setStrokeStyle = function (color) {
353
+ this._ctx.strokeStyle = color;
354
+ };
355
+ Context.prototype.stroke = function () {
356
+ return this._ctx.stroke();
357
+ };
358
+ Context.prototype.translate = function (x, y) {
359
+ return this._ctx.translate(this._doSize(x), this._doSize(y));
360
+ };
361
+ Context.prototype.rotate = function (angle) {
362
+ return this._ctx.rotate(angle);
363
+ };
364
+ Context.prototype.drawImage = function () {
365
+ var args = [];
366
+ for (var _i = 0; _i < arguments.length; _i++) {
367
+ args[_i] = arguments[_i];
368
+ }
369
+ var image = args[0];
370
+ var sx = args[1];
371
+ var sy = args[2];
372
+ var sw = args[3];
373
+ var sh = args[4];
374
+ var dx = args[args.length - 4];
375
+ var dy = args[args.length - 3];
376
+ var dw = args[args.length - 2];
377
+ var dh = args[args.length - 1];
378
+ if (args.length === 9) {
379
+ return this._ctx.drawImage(image, this._doSize(sx), this._doSize(sy), this._doSize(sw), this._doSize(sh), this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
380
+ }
381
+ else {
382
+ return this._ctx.drawImage(image, this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
383
+ }
384
+ };
385
+ Context.prototype.createPattern = function (image, repetition) {
386
+ return this._ctx.createPattern(image, repetition);
387
+ };
388
+ Context.prototype.measureText = function (text) {
389
+ return this._ctx.measureText(text);
390
+ };
391
+ Context.prototype.setTextAlign = function (align) {
392
+ this._ctx.textAlign = align;
393
+ };
394
+ Context.prototype.fillText = function (text, x, y, maxWidth) {
395
+ if (maxWidth !== undefined) {
396
+ return this._ctx.fillText(text, this._doSize(x), this._doSize(y), this._doSize(maxWidth));
397
+ }
398
+ else {
399
+ return this._ctx.fillText(text, this._doSize(x), this._doSize(y));
400
+ }
401
+ };
402
+ Context.prototype.strokeText = function (text, x, y, maxWidth) {
403
+ if (maxWidth !== undefined) {
404
+ return this._ctx.strokeText(text, this._doSize(x), this._doSize(y), this._doSize(maxWidth));
405
+ }
406
+ else {
407
+ return this._ctx.strokeText(text, this._doSize(x), this._doSize(y));
408
+ }
409
+ };
410
+ Context.prototype.setFont = function (opts) {
411
+ var strList = [];
412
+ if (opts.fontWeight === 'bold') {
413
+ strList.push("" + opts.fontWeight);
414
+ }
415
+ strList.push(this._doSize(opts.fontSize || 12) + "px");
416
+ strList.push("" + (opts.fontFamily || 'sans-serif'));
417
+ this._ctx.font = "" + strList.join(' ');
418
+ };
419
+ Context.prototype.setTextBaseline = function (baseline) {
420
+ this._ctx.textBaseline = baseline;
421
+ };
422
+ Context.prototype.setGlobalAlpha = function (alpha) {
423
+ this._ctx.globalAlpha = alpha;
424
+ };
425
+ Context.prototype.save = function () {
426
+ this._ctx.save();
427
+ };
428
+ Context.prototype.restore = function () {
429
+ this._ctx.restore();
430
+ };
431
+ Context.prototype.scale = function (ratioX, ratioY) {
432
+ this._ctx.scale(ratioX, ratioY);
433
+ };
434
+ Context.prototype.setShadowColor = function (color) {
435
+ this._ctx.shadowColor = color;
436
+ };
437
+ Context.prototype.setShadowOffsetX = function (offsetX) {
438
+ this._ctx.shadowOffsetX = this._doSize(offsetX);
439
+ };
440
+ Context.prototype.setShadowOffsetY = function (offsetY) {
441
+ this._ctx.shadowOffsetY = this._doSize(offsetY);
442
+ };
443
+ Context.prototype.setShadowBlur = function (blur) {
444
+ this._ctx.shadowBlur = this._doSize(blur);
445
+ };
446
+ Context.prototype.ellipse = function (x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
447
+ this._ctx.ellipse(this._doSize(x), this._doSize(y), this._doSize(radiusX), this._doSize(radiusY), rotation, startAngle, endAngle, counterclockwise);
448
+ };
449
+ Context.prototype._doSize = function (num) {
450
+ return this._opts.devicePixelRatio * num;
451
+ };
452
+ Context.prototype._doX = function (x) {
453
+ var _a = this._transform, scale = _a.scale, scrollX = _a.scrollX;
454
+ var _x = (x - scrollX) / scale;
455
+ return this._doSize(_x);
456
+ };
457
+ Context.prototype._doY = function (y) {
458
+ var _a = this._transform, scale = _a.scale, scrollY = _a.scrollY;
459
+ var _y = (y - scrollY) / scale;
460
+ return this._doSize(_y);
461
+ };
462
+ return Context;
463
+ }());
464
+
465
+ function number(value) {
466
+ return (typeof value === 'number' && (value > 0 || value <= 0));
467
+ }
468
+ function x(value) {
469
+ return number(value);
470
+ }
471
+ function y(value) {
472
+ return number(value);
473
+ }
474
+ function w(value) {
475
+ return (typeof value === 'number' && value >= 0);
476
+ }
477
+ function h(value) {
478
+ return (typeof value === 'number' && value >= 0);
479
+ }
480
+ function angle(value) {
481
+ return (typeof value === 'number' && value >= -360 && value <= 360);
482
+ }
483
+ function borderWidth(value) {
484
+ return w(value);
485
+ }
486
+ function borderRadius(value) {
487
+ return number(value) && value >= 0;
488
+ }
489
+ function color(value) {
490
+ return isColorStr(value);
491
+ }
492
+ function imageURL(value) {
493
+ return (typeof value === 'string' && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("" + value));
494
+ }
495
+ function imageBase64(value) {
496
+ return (typeof value === 'string' && /^(data:image\/)/.test("" + value));
497
+ }
498
+ function imageSrc(value) {
499
+ return (imageBase64(value) || imageURL(value));
500
+ }
501
+ function svg(value) {
502
+ return (typeof value === 'string' && /^(<svg[\s]{1,}|<svg>)/i.test(("" + value).trim()) && /<\/[\s]{0,}svg>$/i.test(("" + value).trim()));
503
+ }
504
+ function html(value) {
505
+ var result = false;
506
+ if (typeof value === 'string') {
507
+ var div = document.createElement('div');
508
+ div.innerHTML = value;
509
+ if (div.children.length > 0) {
510
+ result = true;
511
+ }
512
+ div = null;
513
+ }
514
+ return result;
515
+ }
516
+ function text(value) {
517
+ return typeof value === 'string';
518
+ }
519
+ function fontSize(value) {
520
+ return number(value) && value > 0;
521
+ }
522
+ function lineHeight(value) {
523
+ return number(value) && value > 0;
524
+ }
525
+ function strokeWidth(value) {
526
+ return number(value) && value > 0;
527
+ }
528
+ function textAlign(value) {
529
+ return ['center', 'left', 'right'].includes(value);
530
+ }
531
+ function fontFamily(value) {
532
+ return typeof value === 'string' && value.length > 0;
533
+ }
534
+ function fontWeight(value) {
535
+ return ['bold'].includes(value);
536
+ }
537
+ var is = {
538
+ x: x,
539
+ y: y,
540
+ w: w,
541
+ h: h,
542
+ angle: angle,
543
+ number: number,
544
+ borderWidth: borderWidth,
545
+ borderRadius: borderRadius,
546
+ color: color,
547
+ imageSrc: imageSrc,
548
+ imageURL: imageURL,
549
+ imageBase64: imageBase64,
550
+ svg: svg,
551
+ html: html,
552
+ text: text,
553
+ fontSize: fontSize,
554
+ lineHeight: lineHeight,
555
+ textAlign: textAlign,
556
+ fontFamily: fontFamily,
557
+ fontWeight: fontWeight,
558
+ strokeWidth: strokeWidth,
559
+ };
560
+
561
+ function attrs(attrs) {
562
+ var x = attrs.x, y = attrs.y, w = attrs.w, h = attrs.h, angle = attrs.angle;
563
+ if (!(is.x(x) && is.y(y) && is.w(w) && is.h(h) && is.angle(angle))) {
564
+ return false;
565
+ }
566
+ if (!(angle >= -360 && angle <= 360)) {
567
+ return false;
568
+ }
569
+ return true;
570
+ }
571
+ function box(desc) {
572
+ if (desc === void 0) { desc = {}; }
573
+ var borderColor = desc.borderColor, borderRadius = desc.borderRadius, borderWidth = desc.borderWidth;
574
+ if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
575
+ return false;
576
+ }
577
+ if (desc.hasOwnProperty('borderRadius') && !is.number(borderRadius)) {
578
+ return false;
579
+ }
580
+ if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
581
+ return false;
582
+ }
583
+ return true;
584
+ }
585
+ function rectDesc(desc) {
586
+ var bgColor = desc.bgColor;
587
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
588
+ return false;
589
+ }
590
+ if (!box(desc)) {
591
+ return false;
592
+ }
593
+ return true;
594
+ }
595
+ function circleDesc(desc) {
596
+ var bgColor = desc.bgColor, borderColor = desc.borderColor, borderWidth = desc.borderWidth;
597
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
598
+ return false;
599
+ }
600
+ if (desc.hasOwnProperty('borderColor') && !is.color(borderColor)) {
601
+ return false;
602
+ }
603
+ if (desc.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
604
+ return false;
605
+ }
606
+ return true;
607
+ }
608
+ function imageDesc(desc) {
609
+ var src = desc.src;
610
+ if (!is.imageSrc(src)) {
611
+ return false;
612
+ }
613
+ return true;
614
+ }
615
+ function svgDesc(desc) {
616
+ var svg = desc.svg;
617
+ if (!is.svg(svg)) {
618
+ return false;
619
+ }
620
+ return true;
621
+ }
622
+ function htmlDesc(desc) {
623
+ var html = desc.html;
624
+ if (!is.html(html)) {
625
+ return false;
626
+ }
627
+ return true;
628
+ }
629
+ function textDesc(desc) {
630
+ var text = desc.text, color = desc.color, fontSize = desc.fontSize, lineHeight = desc.lineHeight, fontFamily = desc.fontFamily, textAlign = desc.textAlign, fontWeight = desc.fontWeight, bgColor = desc.bgColor, strokeWidth = desc.strokeWidth, strokeColor = desc.strokeColor;
631
+ if (!is.text(text)) {
632
+ return false;
633
+ }
634
+ if (!is.color(color)) {
635
+ return false;
636
+ }
637
+ if (!is.fontSize(fontSize)) {
638
+ return false;
639
+ }
640
+ if (desc.hasOwnProperty('bgColor') && !is.color(bgColor)) {
641
+ return false;
642
+ }
643
+ if (desc.hasOwnProperty('fontWeight') && !is.fontWeight(fontWeight)) {
644
+ return false;
645
+ }
646
+ if (desc.hasOwnProperty('lineHeight') && !is.lineHeight(lineHeight)) {
647
+ return false;
648
+ }
649
+ if (desc.hasOwnProperty('fontFamily') && !is.fontFamily(fontFamily)) {
650
+ return false;
651
+ }
652
+ if (desc.hasOwnProperty('textAlign') && !is.textAlign(textAlign)) {
653
+ return false;
654
+ }
655
+ if (desc.hasOwnProperty('strokeWidth') && !is.strokeWidth(strokeWidth)) {
656
+ return false;
657
+ }
658
+ if (desc.hasOwnProperty('strokeColor') && !is.color(strokeColor)) {
659
+ return false;
660
+ }
661
+ if (!box(desc)) {
662
+ return false;
663
+ }
664
+ return true;
665
+ }
666
+ var check = {
667
+ attrs: attrs,
668
+ textDesc: textDesc,
669
+ rectDesc: rectDesc,
670
+ circleDesc: circleDesc,
671
+ imageDesc: imageDesc,
672
+ svgDesc: svgDesc,
673
+ htmlDesc: htmlDesc,
674
+ };
675
+
199
676
  var index = {
677
+ is: is,
678
+ check: check,
200
679
  time: {
201
680
  delay: delay,
202
681
  compose: compose,
@@ -221,7 +700,8 @@ var index = {
221
700
  istype: istype,
222
701
  data: {
223
702
  deepClone: deepClone,
224
- }
703
+ },
704
+ Context: Context,
225
705
  };
226
706
 
227
707
  export { index as default };