modern-canvas 0.4.52 → 0.4.53
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 +391 -463
- package/dist/index.d.cts +18 -27
- package/dist/index.d.mts +18 -27
- package/dist/index.d.ts +18 -27
- package/dist/index.js +45 -44
- package/dist/index.mjs +242 -311
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,274 +1,10 @@
|
|
|
1
|
+
import { defineProperty, property, getDeclarations, parseColor, RawWeakMap as RawWeakMap$1, isGradient, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText } from 'modern-idoc';
|
|
1
2
|
import { extend } from 'colord';
|
|
2
3
|
import namesPlugin from 'colord/plugins/names';
|
|
3
|
-
import { parseColor, isGradient, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText } from 'modern-idoc';
|
|
4
4
|
import { Path2D, Path2DSet, svgToDOM, svgToPath2DSet, Matrix3 as Matrix3$1 } from 'modern-path2d';
|
|
5
5
|
import { Text, textDefaultStyle } from 'modern-text';
|
|
6
6
|
import { loadYoga, BoxSizing, PositionType, Edge, Overflow, Gutter, Justify, Wrap, FlexDirection, Display, Direction, Align } from 'yoga-layout/load';
|
|
7
7
|
|
|
8
|
-
const PI = Math.PI;
|
|
9
|
-
const PI_2 = PI * 2;
|
|
10
|
-
let UID$1 = 0;
|
|
11
|
-
function uid(object) {
|
|
12
|
-
return object?.__SPECTOR_Object_TAG?.id ?? ++UID$1;
|
|
13
|
-
}
|
|
14
|
-
function isPow2(v) {
|
|
15
|
-
return !(v & v - 1) && !!v;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const FUNCTIONS_RE = /([\w-]+)\((.+?)\)/g;
|
|
19
|
-
const ARGS_RE = /[^,]+/g;
|
|
20
|
-
const ARG_RE = /([-e.\d]+)(.*)/;
|
|
21
|
-
function getDefaultCssPropertyValue(value) {
|
|
22
|
-
if (Array.isArray(value)) {
|
|
23
|
-
return value.map((func) => {
|
|
24
|
-
return {
|
|
25
|
-
name: func.name,
|
|
26
|
-
args: func.args.map((arg) => {
|
|
27
|
-
return {
|
|
28
|
-
...arg,
|
|
29
|
-
normalizedIntValue: arg.normalizedDefaultIntValue
|
|
30
|
-
};
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
return {
|
|
36
|
-
...value,
|
|
37
|
-
normalizedIntValue: value.normalizedDefaultIntValue
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function parseCssProperty(name, propertyValue, context = {}) {
|
|
42
|
-
const functions = parseCssFunctions(propertyValue, context);
|
|
43
|
-
return functions.length ? functions : parseArgument(name, propertyValue, context);
|
|
44
|
-
}
|
|
45
|
-
function parseCssFunctions(propertyValue, context = {}) {
|
|
46
|
-
const functions = [];
|
|
47
|
-
let match;
|
|
48
|
-
while ((match = FUNCTIONS_RE.exec(propertyValue)) !== null) {
|
|
49
|
-
const [, name, value] = match;
|
|
50
|
-
if (name) {
|
|
51
|
-
functions.push({
|
|
52
|
-
name,
|
|
53
|
-
args: parseArguments(name, value, context)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return functions;
|
|
58
|
-
}
|
|
59
|
-
function parseArguments(name, value, context = {}) {
|
|
60
|
-
const values = [];
|
|
61
|
-
let match;
|
|
62
|
-
let i = 0;
|
|
63
|
-
while ((match = ARGS_RE.exec(value)) !== null) {
|
|
64
|
-
values.push(
|
|
65
|
-
parseArgument(name, match[0], {
|
|
66
|
-
...context,
|
|
67
|
-
index: i++
|
|
68
|
-
})
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
return values;
|
|
72
|
-
}
|
|
73
|
-
function parseArgument(name, value, context = {}) {
|
|
74
|
-
const { width = 1, height = 1, index = 0 } = context;
|
|
75
|
-
const matched = value.match(ARG_RE);
|
|
76
|
-
const result = {
|
|
77
|
-
unit: matched?.[2] ?? null,
|
|
78
|
-
value,
|
|
79
|
-
intValue: Number(matched?.[1]),
|
|
80
|
-
normalizedIntValue: 0,
|
|
81
|
-
normalizedDefaultIntValue: 0
|
|
82
|
-
};
|
|
83
|
-
switch (name) {
|
|
84
|
-
case "scale":
|
|
85
|
-
case "scaleX":
|
|
86
|
-
case "scaleY":
|
|
87
|
-
case "scale3d":
|
|
88
|
-
result.normalizedDefaultIntValue = 1;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
switch (result.unit) {
|
|
92
|
-
case "%":
|
|
93
|
-
result.normalizedIntValue = result.intValue / 100;
|
|
94
|
-
break;
|
|
95
|
-
case "rad":
|
|
96
|
-
result.normalizedIntValue = result.intValue / PI_2;
|
|
97
|
-
break;
|
|
98
|
-
case "deg":
|
|
99
|
-
result.normalizedIntValue = result.intValue / 360;
|
|
100
|
-
break;
|
|
101
|
-
case "px":
|
|
102
|
-
switch (index) {
|
|
103
|
-
case 0:
|
|
104
|
-
result.normalizedIntValue = result.intValue / width;
|
|
105
|
-
break;
|
|
106
|
-
case 1:
|
|
107
|
-
result.normalizedIntValue = result.intValue / height;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
case "turn":
|
|
112
|
-
case "em":
|
|
113
|
-
// div fontSize
|
|
114
|
-
case "rem":
|
|
115
|
-
// div fontSize
|
|
116
|
-
default:
|
|
117
|
-
result.normalizedIntValue = result.intValue;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const SUPPORTS_WEBGL2 = "WebGL2RenderingContext" in globalThis;
|
|
124
|
-
const SUPPORTS_IMAGE_BITMAP = "ImageBitmap" in globalThis;
|
|
125
|
-
const SUPPORTS_RESIZE_OBSERVER = "ResizeObserver" in globalThis;
|
|
126
|
-
const SUPPORTS_POINTER_EVENTS = "PointerEvent" in globalThis;
|
|
127
|
-
const SUPPORTS_WHEEL_EVENTS = "WheelEvent" in globalThis;
|
|
128
|
-
const SUPPORTS_MOUSE_EVENTS = "MouseEvent" in globalThis;
|
|
129
|
-
const SUPPORTS_TOUCH_EVENTS = "ontouchstart" in globalThis;
|
|
130
|
-
const SUPPORTS_CLICK_EVENTS = "onclick" in globalThis;
|
|
131
|
-
const SUPPORTS_CREATE_IMAGE_BITMAP = "createImageBitmap" in globalThis;
|
|
132
|
-
const SUPPORTS_AUDIO_CONTEXT = "AudioContext" in globalThis;
|
|
133
|
-
const SUPPORTS_WEBKIT_AUDIO_CONTEXT = "webkitAudioContext" in globalThis;
|
|
134
|
-
const SUPPORTS_OFFLINE_AUDIO_CONTEXT = "OfflineAudioContext" in globalThis;
|
|
135
|
-
const SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT = "webkitOfflineAudioContext" in globalThis;
|
|
136
|
-
const SUPPORTS_WEB_AUDIO = SUPPORTS_AUDIO_CONTEXT || SUPPORTS_WEBKIT_AUDIO_CONTEXT;
|
|
137
|
-
const IN_BROWSER = typeof window !== "undefined";
|
|
138
|
-
const DEVICE_PIXEL_RATIO = globalThis.devicePixelRatio || 1;
|
|
139
|
-
const isElementNode = (node) => node !== null && typeof node === "object" && node.nodeType === 1;
|
|
140
|
-
const isVideoElement = (node) => isElementNode(node) && node.tagName === "VIDEO";
|
|
141
|
-
const isImageElement = (node) => isElementNode(node) && node.tagName === "IMG";
|
|
142
|
-
function isCanvasElement(node) {
|
|
143
|
-
return typeof node === "object" && node !== null && node.nodeType === 1 && node.tagName === "CANVAS";
|
|
144
|
-
}
|
|
145
|
-
function isWebgl2(gl) {
|
|
146
|
-
return SUPPORTS_WEBGL2 && gl instanceof globalThis.WebGL2RenderingContext;
|
|
147
|
-
}
|
|
148
|
-
function createHTMLCanvas() {
|
|
149
|
-
if (IN_BROWSER) {
|
|
150
|
-
return globalThis.document.createElement("canvas");
|
|
151
|
-
}
|
|
152
|
-
return void 0;
|
|
153
|
-
}
|
|
154
|
-
function determineCrossOrigin(url, loc = globalThis.location) {
|
|
155
|
-
if (url.startsWith("data:")) {
|
|
156
|
-
return "";
|
|
157
|
-
}
|
|
158
|
-
loc = loc || globalThis.location;
|
|
159
|
-
const parsedUrl = new URL(url, document.baseURI);
|
|
160
|
-
if (parsedUrl.hostname !== loc.hostname || parsedUrl.port !== loc.port || parsedUrl.protocol !== loc.protocol) {
|
|
161
|
-
return "anonymous";
|
|
162
|
-
}
|
|
163
|
-
return "";
|
|
164
|
-
}
|
|
165
|
-
function crossOrigin(element, url, crossorigin) {
|
|
166
|
-
if (crossorigin === null && !url.startsWith("data:")) {
|
|
167
|
-
element.crossOrigin = determineCrossOrigin(url);
|
|
168
|
-
} else if (crossorigin !== false) {
|
|
169
|
-
element.crossOrigin = typeof crossorigin === "string" ? crossorigin : "anonymous";
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
class RawWeakMap {
|
|
174
|
-
_map = /* @__PURE__ */ new WeakMap();
|
|
175
|
-
// fix: vue reactive object
|
|
176
|
-
_toRaw(value) {
|
|
177
|
-
if (value && typeof value === "object") {
|
|
178
|
-
const raw = value.__v_raw;
|
|
179
|
-
if (raw) {
|
|
180
|
-
value = this._toRaw(raw);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return value;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Removes the specified element from the WeakMap.
|
|
187
|
-
* @returns true if the element was successfully removed, or false if it was not present.
|
|
188
|
-
*/
|
|
189
|
-
delete(key) {
|
|
190
|
-
return this._map.delete(this._toRaw(key));
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* @returns a specified element.
|
|
194
|
-
*/
|
|
195
|
-
get(key) {
|
|
196
|
-
return this._map.get(this._toRaw(key));
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
200
|
-
*/
|
|
201
|
-
has(key) {
|
|
202
|
-
return this._map.has(this._toRaw(key));
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Adds a new element with a specified key and value.
|
|
206
|
-
* @param key Must be an object or symbol.
|
|
207
|
-
*/
|
|
208
|
-
set(key, value) {
|
|
209
|
-
this._map.set(this._toRaw(key), this._toRaw(value));
|
|
210
|
-
return this;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const declarationMap = new RawWeakMap();
|
|
215
|
-
function getDeclarations(constructor) {
|
|
216
|
-
let declarations = declarationMap.get(constructor);
|
|
217
|
-
if (!declarations) {
|
|
218
|
-
const superConstructor = Object.getPrototypeOf(constructor);
|
|
219
|
-
declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
|
|
220
|
-
declarationMap.set(constructor, declarations);
|
|
221
|
-
}
|
|
222
|
-
return declarations;
|
|
223
|
-
}
|
|
224
|
-
function defineProperty(constructor, name, declaration = {}) {
|
|
225
|
-
getDeclarations(constructor).set(name, declaration);
|
|
226
|
-
const {
|
|
227
|
-
default: defaultValue,
|
|
228
|
-
alias
|
|
229
|
-
} = declaration;
|
|
230
|
-
let descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
|
|
231
|
-
if (!descriptor) {
|
|
232
|
-
const key = alias ?? Symbol.for(String(name));
|
|
233
|
-
descriptor = {
|
|
234
|
-
get() {
|
|
235
|
-
return this[key];
|
|
236
|
-
},
|
|
237
|
-
set(v) {
|
|
238
|
-
this[key] = v;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
243
|
-
Object.defineProperty(constructor.prototype, name, {
|
|
244
|
-
get() {
|
|
245
|
-
let value = descriptor.get?.call(this);
|
|
246
|
-
if (value === void 0) {
|
|
247
|
-
value = getDefaultValue();
|
|
248
|
-
if (value !== void 0) {
|
|
249
|
-
descriptor.set?.call(this, value);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return value;
|
|
253
|
-
},
|
|
254
|
-
set(value) {
|
|
255
|
-
let oldValue = descriptor.get?.call(this);
|
|
256
|
-
if (oldValue === void 0) {
|
|
257
|
-
oldValue = getDefaultValue();
|
|
258
|
-
}
|
|
259
|
-
descriptor.set?.call(this, value);
|
|
260
|
-
this.requestUpdate?.(name, oldValue, declaration);
|
|
261
|
-
},
|
|
262
|
-
configurable: true,
|
|
263
|
-
enumerable: true
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
function property(options) {
|
|
267
|
-
return function(proto, name) {
|
|
268
|
-
defineProperty(proto.constructor, name, options);
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
8
|
const customNodes = /* @__PURE__ */ new Map();
|
|
273
9
|
function customNode(tag, defaultProperties) {
|
|
274
10
|
return function(constructor) {
|
|
@@ -468,9 +204,9 @@ class EventEmitter {
|
|
|
468
204
|
}
|
|
469
205
|
}
|
|
470
206
|
|
|
471
|
-
let UID = 0;
|
|
207
|
+
let UID$1 = 0;
|
|
472
208
|
class CoreObject extends EventEmitter {
|
|
473
|
-
instanceId = ++UID;
|
|
209
|
+
instanceId = ++UID$1;
|
|
474
210
|
_defaultProperties;
|
|
475
211
|
_updatedProperties = /* @__PURE__ */ new Map();
|
|
476
212
|
_changedProperties = /* @__PURE__ */ new Set();
|
|
@@ -554,9 +290,8 @@ class CoreObject extends EventEmitter {
|
|
|
554
290
|
}
|
|
555
291
|
return this;
|
|
556
292
|
}
|
|
557
|
-
requestUpdate(key, oldValue, declaration) {
|
|
293
|
+
requestUpdate(key, newValue, oldValue, declaration) {
|
|
558
294
|
if (key !== void 0) {
|
|
559
|
-
const newValue = this[key];
|
|
560
295
|
if (!Object.is(newValue, oldValue)) {
|
|
561
296
|
this._updatedProperties.set(key, oldValue);
|
|
562
297
|
this._changedProperties.add(key);
|
|
@@ -600,6 +335,212 @@ class RefCounted extends CoreObject {
|
|
|
600
335
|
//
|
|
601
336
|
}
|
|
602
337
|
|
|
338
|
+
const PI = Math.PI;
|
|
339
|
+
const PI_2 = PI * 2;
|
|
340
|
+
let UID = 0;
|
|
341
|
+
function uid(object) {
|
|
342
|
+
return object?.__SPECTOR_Object_TAG?.id ?? ++UID;
|
|
343
|
+
}
|
|
344
|
+
function isPow2(v) {
|
|
345
|
+
return !(v & v - 1) && !!v;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const FUNCTIONS_RE = /([\w-]+)\((.+?)\)/g;
|
|
349
|
+
const ARGS_RE = /[^,]+/g;
|
|
350
|
+
const ARG_RE = /([-e.\d]+)(.*)/;
|
|
351
|
+
function getDefaultCssPropertyValue(value) {
|
|
352
|
+
if (Array.isArray(value)) {
|
|
353
|
+
return value.map((func) => {
|
|
354
|
+
return {
|
|
355
|
+
name: func.name,
|
|
356
|
+
args: func.args.map((arg) => {
|
|
357
|
+
return {
|
|
358
|
+
...arg,
|
|
359
|
+
normalizedIntValue: arg.normalizedDefaultIntValue
|
|
360
|
+
};
|
|
361
|
+
})
|
|
362
|
+
};
|
|
363
|
+
});
|
|
364
|
+
} else {
|
|
365
|
+
return {
|
|
366
|
+
...value,
|
|
367
|
+
normalizedIntValue: value.normalizedDefaultIntValue
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function parseCssProperty(name, propertyValue, context = {}) {
|
|
372
|
+
const functions = parseCssFunctions(propertyValue, context);
|
|
373
|
+
return functions.length ? functions : parseArgument(name, propertyValue, context);
|
|
374
|
+
}
|
|
375
|
+
function parseCssFunctions(propertyValue, context = {}) {
|
|
376
|
+
const functions = [];
|
|
377
|
+
let match;
|
|
378
|
+
while ((match = FUNCTIONS_RE.exec(propertyValue)) !== null) {
|
|
379
|
+
const [, name, value] = match;
|
|
380
|
+
if (name) {
|
|
381
|
+
functions.push({
|
|
382
|
+
name,
|
|
383
|
+
args: parseArguments(name, value, context)
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return functions;
|
|
388
|
+
}
|
|
389
|
+
function parseArguments(name, value, context = {}) {
|
|
390
|
+
const values = [];
|
|
391
|
+
let match;
|
|
392
|
+
let i = 0;
|
|
393
|
+
while ((match = ARGS_RE.exec(value)) !== null) {
|
|
394
|
+
values.push(
|
|
395
|
+
parseArgument(name, match[0], {
|
|
396
|
+
...context,
|
|
397
|
+
index: i++
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
return values;
|
|
402
|
+
}
|
|
403
|
+
function parseArgument(name, value, context = {}) {
|
|
404
|
+
const { width = 1, height = 1, index = 0 } = context;
|
|
405
|
+
const matched = value.match(ARG_RE);
|
|
406
|
+
const result = {
|
|
407
|
+
unit: matched?.[2] ?? null,
|
|
408
|
+
value,
|
|
409
|
+
intValue: Number(matched?.[1]),
|
|
410
|
+
normalizedIntValue: 0,
|
|
411
|
+
normalizedDefaultIntValue: 0
|
|
412
|
+
};
|
|
413
|
+
switch (name) {
|
|
414
|
+
case "scale":
|
|
415
|
+
case "scaleX":
|
|
416
|
+
case "scaleY":
|
|
417
|
+
case "scale3d":
|
|
418
|
+
result.normalizedDefaultIntValue = 1;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
switch (result.unit) {
|
|
422
|
+
case "%":
|
|
423
|
+
result.normalizedIntValue = result.intValue / 100;
|
|
424
|
+
break;
|
|
425
|
+
case "rad":
|
|
426
|
+
result.normalizedIntValue = result.intValue / PI_2;
|
|
427
|
+
break;
|
|
428
|
+
case "deg":
|
|
429
|
+
result.normalizedIntValue = result.intValue / 360;
|
|
430
|
+
break;
|
|
431
|
+
case "px":
|
|
432
|
+
switch (index) {
|
|
433
|
+
case 0:
|
|
434
|
+
result.normalizedIntValue = result.intValue / width;
|
|
435
|
+
break;
|
|
436
|
+
case 1:
|
|
437
|
+
result.normalizedIntValue = result.intValue / height;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
break;
|
|
441
|
+
case "turn":
|
|
442
|
+
case "em":
|
|
443
|
+
// div fontSize
|
|
444
|
+
case "rem":
|
|
445
|
+
// div fontSize
|
|
446
|
+
default:
|
|
447
|
+
result.normalizedIntValue = result.intValue;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
return result;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const SUPPORTS_WEBGL2 = "WebGL2RenderingContext" in globalThis;
|
|
454
|
+
const SUPPORTS_IMAGE_BITMAP = "ImageBitmap" in globalThis;
|
|
455
|
+
const SUPPORTS_RESIZE_OBSERVER = "ResizeObserver" in globalThis;
|
|
456
|
+
const SUPPORTS_POINTER_EVENTS = "PointerEvent" in globalThis;
|
|
457
|
+
const SUPPORTS_WHEEL_EVENTS = "WheelEvent" in globalThis;
|
|
458
|
+
const SUPPORTS_MOUSE_EVENTS = "MouseEvent" in globalThis;
|
|
459
|
+
const SUPPORTS_TOUCH_EVENTS = "ontouchstart" in globalThis;
|
|
460
|
+
const SUPPORTS_CLICK_EVENTS = "onclick" in globalThis;
|
|
461
|
+
const SUPPORTS_CREATE_IMAGE_BITMAP = "createImageBitmap" in globalThis;
|
|
462
|
+
const SUPPORTS_AUDIO_CONTEXT = "AudioContext" in globalThis;
|
|
463
|
+
const SUPPORTS_WEBKIT_AUDIO_CONTEXT = "webkitAudioContext" in globalThis;
|
|
464
|
+
const SUPPORTS_OFFLINE_AUDIO_CONTEXT = "OfflineAudioContext" in globalThis;
|
|
465
|
+
const SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT = "webkitOfflineAudioContext" in globalThis;
|
|
466
|
+
const SUPPORTS_WEB_AUDIO = SUPPORTS_AUDIO_CONTEXT || SUPPORTS_WEBKIT_AUDIO_CONTEXT;
|
|
467
|
+
const IN_BROWSER = typeof window !== "undefined";
|
|
468
|
+
const DEVICE_PIXEL_RATIO = globalThis.devicePixelRatio || 1;
|
|
469
|
+
const isElementNode = (node) => node !== null && typeof node === "object" && node.nodeType === 1;
|
|
470
|
+
const isVideoElement = (node) => isElementNode(node) && node.tagName === "VIDEO";
|
|
471
|
+
const isImageElement = (node) => isElementNode(node) && node.tagName === "IMG";
|
|
472
|
+
function isCanvasElement(node) {
|
|
473
|
+
return typeof node === "object" && node !== null && node.nodeType === 1 && node.tagName === "CANVAS";
|
|
474
|
+
}
|
|
475
|
+
function isWebgl2(gl) {
|
|
476
|
+
return SUPPORTS_WEBGL2 && gl instanceof globalThis.WebGL2RenderingContext;
|
|
477
|
+
}
|
|
478
|
+
function createHTMLCanvas() {
|
|
479
|
+
if (IN_BROWSER) {
|
|
480
|
+
return globalThis.document.createElement("canvas");
|
|
481
|
+
}
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
function determineCrossOrigin(url, loc = globalThis.location) {
|
|
485
|
+
if (url.startsWith("data:")) {
|
|
486
|
+
return "";
|
|
487
|
+
}
|
|
488
|
+
loc = loc || globalThis.location;
|
|
489
|
+
const parsedUrl = new URL(url, document.baseURI);
|
|
490
|
+
if (parsedUrl.hostname !== loc.hostname || parsedUrl.port !== loc.port || parsedUrl.protocol !== loc.protocol) {
|
|
491
|
+
return "anonymous";
|
|
492
|
+
}
|
|
493
|
+
return "";
|
|
494
|
+
}
|
|
495
|
+
function crossOrigin(element, url, crossorigin) {
|
|
496
|
+
if (crossorigin === null && !url.startsWith("data:")) {
|
|
497
|
+
element.crossOrigin = determineCrossOrigin(url);
|
|
498
|
+
} else if (crossorigin !== false) {
|
|
499
|
+
element.crossOrigin = typeof crossorigin === "string" ? crossorigin : "anonymous";
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
class RawWeakMap {
|
|
504
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
505
|
+
// fix: vue reactive object
|
|
506
|
+
_toRaw(value) {
|
|
507
|
+
if (value && typeof value === "object") {
|
|
508
|
+
const raw = value.__v_raw;
|
|
509
|
+
if (raw) {
|
|
510
|
+
value = this._toRaw(raw);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return value;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Removes the specified element from the WeakMap.
|
|
517
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
518
|
+
*/
|
|
519
|
+
delete(key) {
|
|
520
|
+
return this._map.delete(this._toRaw(key));
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* @returns a specified element.
|
|
524
|
+
*/
|
|
525
|
+
get(key) {
|
|
526
|
+
return this._map.get(this._toRaw(key));
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
530
|
+
*/
|
|
531
|
+
has(key) {
|
|
532
|
+
return this._map.has(this._toRaw(key));
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Adds a new element with a specified key and value.
|
|
536
|
+
* @param key Must be an object or symbol.
|
|
537
|
+
*/
|
|
538
|
+
set(key, value) {
|
|
539
|
+
this._map.set(this._toRaw(key), this._toRaw(value));
|
|
540
|
+
return this;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
603
544
|
class InputEvent {
|
|
604
545
|
bubbles = true;
|
|
605
546
|
cancelable = false;
|
|
@@ -1496,18 +1437,18 @@ class ColorMatrix extends Matrix {
|
|
|
1496
1437
|
const lumG = 0.715;
|
|
1497
1438
|
const lumB = 0.072;
|
|
1498
1439
|
return this.multiply([
|
|
1499
|
-
lumR + cos * (1 - lumR) + sin * -
|
|
1500
|
-
lumG + cos * -
|
|
1501
|
-
lumB + cos * -
|
|
1440
|
+
lumR + cos * (1 - lumR) + sin * -lumR,
|
|
1441
|
+
lumG + cos * -lumG + sin * -lumG,
|
|
1442
|
+
lumB + cos * -lumB + sin * (1 - lumB),
|
|
1502
1443
|
0,
|
|
1503
1444
|
0,
|
|
1504
|
-
lumR + cos * -
|
|
1445
|
+
lumR + cos * -lumR + sin * 0.143,
|
|
1505
1446
|
lumG + cos * (1 - lumG) + sin * 0.14,
|
|
1506
|
-
lumB + cos * -
|
|
1447
|
+
lumB + cos * -lumB + sin * -0.283,
|
|
1507
1448
|
0,
|
|
1508
1449
|
0,
|
|
1509
|
-
lumR + cos * -
|
|
1510
|
-
lumG + cos * -
|
|
1450
|
+
lumR + cos * -lumR + sin * -0.787,
|
|
1451
|
+
lumG + cos * -lumG + sin * lumG,
|
|
1511
1452
|
lumB + cos * (1 - lumB) + sin * lumB,
|
|
1512
1453
|
0,
|
|
1513
1454
|
0,
|
|
@@ -3318,7 +3259,7 @@ class WebGLProgramModule extends WebGLModule {
|
|
|
3318
3259
|
return {
|
|
3319
3260
|
attributes: /* @__PURE__ */ new Map(),
|
|
3320
3261
|
uniforms: /* @__PURE__ */ new Map(),
|
|
3321
|
-
boundUniforms: new RawWeakMap()
|
|
3262
|
+
boundUniforms: new RawWeakMap$1()
|
|
3322
3263
|
};
|
|
3323
3264
|
});
|
|
3324
3265
|
}
|
|
@@ -7416,7 +7357,8 @@ let CanvasItem = class extends TimelineNode {
|
|
|
7416
7357
|
this.requestUpdate();
|
|
7417
7358
|
}
|
|
7418
7359
|
}
|
|
7419
|
-
_update() {
|
|
7360
|
+
_update(changed) {
|
|
7361
|
+
super._update(changed);
|
|
7420
7362
|
const parent = this.getParent();
|
|
7421
7363
|
if (this._parentGlobalVisible !== parent?.globalVisible) {
|
|
7422
7364
|
this._updateGlobalVisible();
|
|
@@ -9343,11 +9285,8 @@ class BaseElement2DText extends CoreObject {
|
|
|
9343
9285
|
super();
|
|
9344
9286
|
this.parent = parent;
|
|
9345
9287
|
}
|
|
9346
|
-
|
|
9347
|
-
measureDom;
|
|
9348
|
-
fonts;
|
|
9288
|
+
base = new Text();
|
|
9349
9289
|
texture = new CanvasTexture();
|
|
9350
|
-
baseText = new Text();
|
|
9351
9290
|
measureResult;
|
|
9352
9291
|
setProperties(properties) {
|
|
9353
9292
|
return super.setProperties(
|
|
@@ -9359,7 +9298,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9359
9298
|
switch (key) {
|
|
9360
9299
|
case "content":
|
|
9361
9300
|
case "effects":
|
|
9362
|
-
case "
|
|
9301
|
+
case "measureDOM":
|
|
9363
9302
|
case "fonts":
|
|
9364
9303
|
case "split":
|
|
9365
9304
|
this.parent.requestRedraw();
|
|
@@ -9367,21 +9306,17 @@ class BaseElement2DText extends CoreObject {
|
|
|
9367
9306
|
}
|
|
9368
9307
|
}
|
|
9369
9308
|
_updateText() {
|
|
9370
|
-
this.
|
|
9309
|
+
this.base.style = {
|
|
9371
9310
|
justifyContent: "center",
|
|
9372
9311
|
alignItems: "center",
|
|
9373
9312
|
textAlign: "center",
|
|
9374
9313
|
...this.parent.style.toJSON()
|
|
9375
9314
|
};
|
|
9376
|
-
this.
|
|
9377
|
-
this.baseText.effects = this.effects;
|
|
9378
|
-
this.baseText.fonts = this.fonts;
|
|
9379
|
-
this.baseText.measureDom = this.measureDom;
|
|
9380
|
-
this.baseText.requestUpdate();
|
|
9315
|
+
this.base.requestUpdate();
|
|
9381
9316
|
}
|
|
9382
9317
|
measure() {
|
|
9383
9318
|
this._updateText();
|
|
9384
|
-
return this.
|
|
9319
|
+
return this.base.measure();
|
|
9385
9320
|
}
|
|
9386
9321
|
updateMeasure() {
|
|
9387
9322
|
this.measureResult = this.measure();
|
|
@@ -9389,11 +9324,11 @@ class BaseElement2DText extends CoreObject {
|
|
|
9389
9324
|
}
|
|
9390
9325
|
canDraw() {
|
|
9391
9326
|
return Boolean(
|
|
9392
|
-
this.
|
|
9327
|
+
!/^\s*$/.test(this.base.toString()) && this.texture?.valid
|
|
9393
9328
|
);
|
|
9394
9329
|
}
|
|
9395
9330
|
draw() {
|
|
9396
|
-
this.
|
|
9331
|
+
this.base.render({
|
|
9397
9332
|
pixelRatio: this.texture.pixelRatio,
|
|
9398
9333
|
view: this.texture.source
|
|
9399
9334
|
});
|
|
@@ -9415,16 +9350,16 @@ class BaseElement2DText extends CoreObject {
|
|
|
9415
9350
|
}
|
|
9416
9351
|
}
|
|
9417
9352
|
__decorateClass$o([
|
|
9418
|
-
property({
|
|
9353
|
+
property({ alias: "base.content" })
|
|
9419
9354
|
], BaseElement2DText.prototype, "content");
|
|
9420
9355
|
__decorateClass$o([
|
|
9421
|
-
property()
|
|
9356
|
+
property({ alias: "base.effects" })
|
|
9422
9357
|
], BaseElement2DText.prototype, "effects");
|
|
9423
9358
|
__decorateClass$o([
|
|
9424
|
-
protectedProperty()
|
|
9425
|
-
], BaseElement2DText.prototype, "
|
|
9359
|
+
protectedProperty({ alias: "base.measureDOM" })
|
|
9360
|
+
], BaseElement2DText.prototype, "measureDOM");
|
|
9426
9361
|
__decorateClass$o([
|
|
9427
|
-
protectedProperty()
|
|
9362
|
+
protectedProperty({ alias: "base.fonts" })
|
|
9428
9363
|
], BaseElement2DText.prototype, "fonts");
|
|
9429
9364
|
|
|
9430
9365
|
var __getOwnPropDesc$m = Object.getOwnPropertyDescriptor;
|
|
@@ -10663,7 +10598,7 @@ let Text2D = class extends TextureRect2D {
|
|
|
10663
10598
|
switch (key) {
|
|
10664
10599
|
case "content":
|
|
10665
10600
|
case "effects":
|
|
10666
|
-
case "
|
|
10601
|
+
case "measureDOM":
|
|
10667
10602
|
case "fonts":
|
|
10668
10603
|
case "split":
|
|
10669
10604
|
this._updateSplit();
|
|
@@ -10678,10 +10613,6 @@ let Text2D = class extends TextureRect2D {
|
|
|
10678
10613
|
}
|
|
10679
10614
|
_updateBase() {
|
|
10680
10615
|
this.base.style = this.style.toJSON();
|
|
10681
|
-
this.base.content = this.content ?? "";
|
|
10682
|
-
this.base.effects = this.effects;
|
|
10683
|
-
this.base.fonts = this.fonts;
|
|
10684
|
-
this.base.measureDom = this.measureDom;
|
|
10685
10616
|
this.emit("updateBase", this.base);
|
|
10686
10617
|
this.base.requestUpdate();
|
|
10687
10618
|
}
|
|
@@ -10797,16 +10728,16 @@ __decorateClass$g([
|
|
|
10797
10728
|
property({ default: false })
|
|
10798
10729
|
], Text2D.prototype, "split", 2);
|
|
10799
10730
|
__decorateClass$g([
|
|
10800
|
-
property({
|
|
10731
|
+
property({ alias: "base.content" })
|
|
10801
10732
|
], Text2D.prototype, "content", 2);
|
|
10802
10733
|
__decorateClass$g([
|
|
10803
|
-
property()
|
|
10734
|
+
property({ alias: "base.effects" })
|
|
10804
10735
|
], Text2D.prototype, "effects", 2);
|
|
10805
10736
|
__decorateClass$g([
|
|
10806
|
-
protectedProperty()
|
|
10807
|
-
], Text2D.prototype, "
|
|
10737
|
+
protectedProperty({ alias: "base.measureDOM" })
|
|
10738
|
+
], Text2D.prototype, "measureDOM", 2);
|
|
10808
10739
|
__decorateClass$g([
|
|
10809
|
-
protectedProperty()
|
|
10740
|
+
protectedProperty({ alias: "base.fonts" })
|
|
10810
10741
|
], Text2D.prototype, "fonts", 2);
|
|
10811
10742
|
Text2D = __decorateClass$g([
|
|
10812
10743
|
customNode("Text2D")
|
|
@@ -11006,7 +10937,7 @@ let Animation = class extends TimelineNode {
|
|
|
11006
10937
|
easing;
|
|
11007
10938
|
_keyframes = [];
|
|
11008
10939
|
_isFirstUpdatePosition = false;
|
|
11009
|
-
_cachedProps = new RawWeakMap();
|
|
10940
|
+
_cachedProps = new RawWeakMap$1();
|
|
11010
10941
|
_stoped = false;
|
|
11011
10942
|
constructor(properties, children = []) {
|
|
11012
10943
|
super();
|
|
@@ -13682,7 +13613,7 @@ class CanvasItemEditor extends Control {
|
|
|
13682
13613
|
style: {
|
|
13683
13614
|
visibility: "hidden",
|
|
13684
13615
|
outlineStyle: "solid",
|
|
13685
|
-
outlineColor:
|
|
13616
|
+
outlineColor: "#00FF00FF",
|
|
13686
13617
|
outlineWidth: 2,
|
|
13687
13618
|
pointerEvents: "none"
|
|
13688
13619
|
}
|
|
@@ -13719,7 +13650,7 @@ class CanvasItemEditor extends Control {
|
|
|
13719
13650
|
style: {
|
|
13720
13651
|
width: 500,
|
|
13721
13652
|
height: 500,
|
|
13722
|
-
backgroundColor:
|
|
13653
|
+
backgroundColor: "#FFFFFFFF",
|
|
13723
13654
|
overflow: "hidden",
|
|
13724
13655
|
pointerEvents: "none",
|
|
13725
13656
|
boxShadow: "2px 2px 2px 1px rgba(0, 0, 0, 0.2)"
|
|
@@ -14095,4 +14026,4 @@ async function render(options) {
|
|
|
14095
14026
|
});
|
|
14096
14027
|
}
|
|
14097
14028
|
|
|
14098
|
-
export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DOutline, BaseElement2DShadow, BaseElement2DShape, BaseElement2DStyle, BaseElement2DText, CanvasContext, CanvasItem, CanvasItemEditor, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, Control, CoreObject, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, Effect, EffectMaterial, Element2D, Element2DStyle, EmbossEffect, Engine, EventEmitter, FlexElement2D, FlexElement2DStyle, FlexLayout, FontLoader, GIFLoader, GaussianBlurEffect, Geometry, GlitchEffect, GodrayEffect, GradientTexture, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, ImageTexture, IndexBuffer, Input, InputEvent, JSONLoader, KawaseBlurEffect, KawaseTransition, LeftEraseTransition, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, OutlineEffect, PI, PI_2, PixelateEffect, PixelsTexture, PointerInputEvent, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, RawWeakMap, Rect2, RefCounted, Renderer, Resource, Ruler, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, SceneTree, ScrollBar, Text2D, TextLoader, Texture2D, TextureLoader, TextureRect2D, Ticker, TiltShiftTransition, Timeline, TimelineNode, Transform2D, TransformRect2D, Transition, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, XScrollBar, YScrollBar, ZoomBlurEffect, assets, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions,
|
|
14029
|
+
export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DOutline, BaseElement2DShadow, BaseElement2DShape, BaseElement2DStyle, BaseElement2DText, CanvasContext, CanvasItem, CanvasItemEditor, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, Control, CoreObject, DEG_TO_RAD, DEVICE_PIXEL_RATIO, DropShadowEffect, Effect, EffectMaterial, Element2D, Element2DStyle, EmbossEffect, Engine, EventEmitter, FlexElement2D, FlexElement2DStyle, FlexLayout, FontLoader, GIFLoader, GaussianBlurEffect, Geometry, GlitchEffect, GodrayEffect, GradientTexture, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, IN_BROWSER, Image2D, ImageTexture, IndexBuffer, Input, InputEvent, JSONLoader, KawaseBlurEffect, KawaseTransition, LeftEraseTransition, Loader, Lottie2D, LottieLoader, MainLoop, MaskEffect, Material, Matrix, Matrix2, Matrix3, Matrix4, MouseInputEvent, Node, Node2D, OutlineEffect, PI, PI_2, PixelateEffect, PixelsTexture, PointerInputEvent, Projection2D, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Range, RawWeakMap, Rect2, RefCounted, Renderer, Resource, Ruler, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, SceneTree, ScrollBar, Text2D, TextLoader, Texture2D, TextureLoader, TextureRect2D, Ticker, TiltShiftTransition, Timeline, TimelineNode, Transform2D, TransformRect2D, Transition, TwistTransition, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, VertexAttribute, VertexBuffer, Video2D, VideoLoader, VideoTexture, Viewport, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, WebGLBufferModule, WebGLFramebufferModule, WebGLMaskModule, WebGLModule, WebGLProgramModule, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, WebGLTextureModule, WebGLVertexArrayModule, WebGLViewportModule, WebSound, WheelInputEvent, XScrollBar, YScrollBar, ZoomBlurEffect, assets, clamp, clampFrag, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag$1 as frag, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, protectedProperty, render, timingFunctions, uid };
|