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