modern-canvas 0.1.4 → 0.1.6
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 +79 -29
- package/dist/index.d.cts +36 -12
- package/dist/index.d.mts +36 -12
- package/dist/index.d.ts +36 -12
- package/dist/index.js +35 -35
- package/dist/index.mjs +80 -31
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -252,6 +252,45 @@ class EventEmitter {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
class RawWeakMap {
|
|
256
|
+
_map = /* @__PURE__ */ new WeakMap();
|
|
257
|
+
_toRaw(value) {
|
|
258
|
+
if (value && typeof value === "object") {
|
|
259
|
+
if ("__v_raw" in value) {
|
|
260
|
+
value = value.__v_raw;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return value;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Removes the specified element from the WeakMap.
|
|
267
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
268
|
+
*/
|
|
269
|
+
delete(key) {
|
|
270
|
+
return this._map.delete(this._toRaw(key));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @returns a specified element.
|
|
274
|
+
*/
|
|
275
|
+
get(key) {
|
|
276
|
+
return this._map.get(this._toRaw(key));
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
280
|
+
*/
|
|
281
|
+
has(key) {
|
|
282
|
+
return this._map.has(this._toRaw(key));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Adds a new element with a specified key and value.
|
|
286
|
+
* @param key Must be an object or symbol.
|
|
287
|
+
*/
|
|
288
|
+
set(key, value) {
|
|
289
|
+
this._map.set(this._toRaw(key), this._toRaw(value));
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
255
294
|
const customNodes = /* @__PURE__ */ new Map();
|
|
256
295
|
function customNode(options) {
|
|
257
296
|
let tag;
|
|
@@ -278,7 +317,7 @@ function customNode(options) {
|
|
|
278
317
|
};
|
|
279
318
|
}
|
|
280
319
|
|
|
281
|
-
const declarationMap =
|
|
320
|
+
const declarationMap = new RawWeakMap();
|
|
282
321
|
function getDeclarations(constructor) {
|
|
283
322
|
let declarations = declarationMap.get(constructor);
|
|
284
323
|
if (!declarations) {
|
|
@@ -543,7 +582,7 @@ class Geometry extends Resource {
|
|
|
543
582
|
indexBuffer;
|
|
544
583
|
instanceCount;
|
|
545
584
|
mode;
|
|
546
|
-
_materialWeakMap =
|
|
585
|
+
_materialWeakMap = new RawWeakMap();
|
|
547
586
|
constructor(options = {}) {
|
|
548
587
|
super();
|
|
549
588
|
this.vertexAttributes = new Map(Object.entries(options?.vertexAttributes ?? {}));
|
|
@@ -3392,8 +3431,8 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3392
3431
|
lineWidth;
|
|
3393
3432
|
miterLimit;
|
|
3394
3433
|
_defaultStyle = Texture.EMPTY;
|
|
3395
|
-
|
|
3396
|
-
|
|
3434
|
+
_stroke = [];
|
|
3435
|
+
_fille = [];
|
|
3397
3436
|
stroke() {
|
|
3398
3437
|
let texture = this._defaultStyle;
|
|
3399
3438
|
if (this.strokeStyle) {
|
|
@@ -3404,8 +3443,8 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3404
3443
|
}
|
|
3405
3444
|
}
|
|
3406
3445
|
if (this.curves.length) {
|
|
3407
|
-
this.
|
|
3408
|
-
|
|
3446
|
+
this._stroke.push({
|
|
3447
|
+
path: new modernPath2d.Path2D(this),
|
|
3409
3448
|
texture,
|
|
3410
3449
|
textureTransform: this.textureTransform,
|
|
3411
3450
|
style: {
|
|
@@ -3416,6 +3455,7 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3416
3455
|
miterLimit: this.miterLimit ?? 10
|
|
3417
3456
|
}
|
|
3418
3457
|
});
|
|
3458
|
+
this.currentCurve = new modernPath2d.CurvePath();
|
|
3419
3459
|
this.curves = [this.currentCurve];
|
|
3420
3460
|
}
|
|
3421
3461
|
}
|
|
@@ -3434,14 +3474,29 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3434
3474
|
texture = new ColorTexture(this.fillStyle);
|
|
3435
3475
|
}
|
|
3436
3476
|
}
|
|
3437
|
-
this.
|
|
3438
|
-
|
|
3477
|
+
this._fille.push({
|
|
3478
|
+
path: new modernPath2d.Path2D(this),
|
|
3439
3479
|
texture,
|
|
3440
3480
|
textureTransform: this.textureTransform
|
|
3441
3481
|
});
|
|
3482
|
+
this.currentCurve = new modernPath2d.CurvePath();
|
|
3442
3483
|
this.curves = [this.currentCurve];
|
|
3443
3484
|
}
|
|
3485
|
+
copy(source) {
|
|
3486
|
+
super.copy(source);
|
|
3487
|
+
this.strokeStyle = source.strokeStyle;
|
|
3488
|
+
this.fillStyle = source.fillStyle;
|
|
3489
|
+
this.textureTransform = source.textureTransform;
|
|
3490
|
+
this.lineCap = source.lineCap;
|
|
3491
|
+
this.lineJoin = source.lineJoin;
|
|
3492
|
+
this.lineWidth = source.lineWidth;
|
|
3493
|
+
this.miterLimit = source.miterLimit;
|
|
3494
|
+
this._stroke = source._stroke.slice();
|
|
3495
|
+
this._fille = source._fille.slice();
|
|
3496
|
+
return this;
|
|
3497
|
+
}
|
|
3444
3498
|
reset() {
|
|
3499
|
+
super.reset();
|
|
3445
3500
|
this.strokeStyle = void 0;
|
|
3446
3501
|
this.fillStyle = void 0;
|
|
3447
3502
|
this.textureTransform = void 0;
|
|
@@ -3449,9 +3504,9 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3449
3504
|
this.lineJoin = void 0;
|
|
3450
3505
|
this.lineWidth = void 0;
|
|
3451
3506
|
this.miterLimit = void 0;
|
|
3452
|
-
this.
|
|
3453
|
-
this.
|
|
3454
|
-
this
|
|
3507
|
+
this._stroke.length = 0;
|
|
3508
|
+
this._fille.length = 0;
|
|
3509
|
+
return this;
|
|
3455
3510
|
}
|
|
3456
3511
|
buildUvs(start, vertices, uvs, texture, textureTransform) {
|
|
3457
3512
|
if (texture) {
|
|
@@ -3489,15 +3544,11 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3489
3544
|
uvs = [];
|
|
3490
3545
|
texture = void 0;
|
|
3491
3546
|
};
|
|
3492
|
-
for (let len = this.
|
|
3547
|
+
for (let len = this._stroke.length, i = 0; i < len; i++) {
|
|
3493
3548
|
startUv = vertices.length;
|
|
3494
|
-
const graphics = this.
|
|
3549
|
+
const graphics = this._stroke[i];
|
|
3495
3550
|
texture ??= graphics.texture;
|
|
3496
|
-
|
|
3497
|
-
for (let len2 = graphics.shapes.length, i2 = 0; i2 < len2; i2++) {
|
|
3498
|
-
graphics.shapes[i2].getAdaptivePointArray(points);
|
|
3499
|
-
}
|
|
3500
|
-
modernPath2d.strokeTriangulate(points, {
|
|
3551
|
+
graphics.path.strokeTriangulate({
|
|
3501
3552
|
vertices,
|
|
3502
3553
|
indices,
|
|
3503
3554
|
lineStyle: graphics.style,
|
|
@@ -3507,19 +3558,17 @@ class CanvasContext extends modernPath2d.Path2D {
|
|
|
3507
3558
|
this.buildUvs(startUv, vertices, uvs, graphics.texture, graphics.textureTransform);
|
|
3508
3559
|
push("stroke");
|
|
3509
3560
|
}
|
|
3510
|
-
for (let len = this.
|
|
3511
|
-
const graphics = this.
|
|
3561
|
+
for (let len = this._fille.length, i = 0; i < len; i++) {
|
|
3562
|
+
const graphics = this._fille[i];
|
|
3512
3563
|
texture ??= graphics.texture;
|
|
3513
3564
|
if (texture !== graphics.texture) {
|
|
3514
3565
|
push("fill");
|
|
3515
3566
|
}
|
|
3516
3567
|
startUv = vertices.length;
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
});
|
|
3522
|
-
}
|
|
3568
|
+
graphics.path.fillTriangulate({
|
|
3569
|
+
vertices,
|
|
3570
|
+
indices
|
|
3571
|
+
});
|
|
3523
3572
|
this.buildUvs(startUv, vertices, uvs, graphics.texture, graphics.textureTransform);
|
|
3524
3573
|
}
|
|
3525
3574
|
if (vertices.length) {
|
|
@@ -4454,7 +4503,7 @@ exports.Animation2D = class Animation2D extends exports.Node {
|
|
|
4454
4503
|
easing;
|
|
4455
4504
|
_keyframes = [];
|
|
4456
4505
|
_starting = false;
|
|
4457
|
-
_startProps =
|
|
4506
|
+
_startProps = new RawWeakMap();
|
|
4458
4507
|
constructor(options) {
|
|
4459
4508
|
super();
|
|
4460
4509
|
this._onUpdateTime = this._onUpdateTime.bind(this);
|
|
@@ -9305,7 +9354,7 @@ class Renderer {
|
|
|
9305
9354
|
view;
|
|
9306
9355
|
pixelRatio = DEVICE_PIXEL_RATIO;
|
|
9307
9356
|
screen = { x: 0, y: 0, width: 0, height: 0 };
|
|
9308
|
-
related =
|
|
9357
|
+
related = new RawWeakMap();
|
|
9309
9358
|
getRelated(source, createFn) {
|
|
9310
9359
|
let related = this.related.get(source);
|
|
9311
9360
|
if (related)
|
|
@@ -10377,7 +10426,7 @@ class WebGLProgramModule extends WebGLModule {
|
|
|
10377
10426
|
return {
|
|
10378
10427
|
attributes: /* @__PURE__ */ new Map(),
|
|
10379
10428
|
uniforms: /* @__PURE__ */ new Map(),
|
|
10380
|
-
boundUniforms:
|
|
10429
|
+
boundUniforms: new RawWeakMap()
|
|
10381
10430
|
};
|
|
10382
10431
|
});
|
|
10383
10432
|
}
|
|
@@ -11578,6 +11627,7 @@ exports.Projection2D = Projection2D;
|
|
|
11578
11627
|
exports.QuadGeometry = QuadGeometry;
|
|
11579
11628
|
exports.QuadUvGeometry = QuadUvGeometry;
|
|
11580
11629
|
exports.RAD_TO_DEG = RAD_TO_DEG;
|
|
11630
|
+
exports.RawWeakMap = RawWeakMap;
|
|
11581
11631
|
exports.Reference = Reference;
|
|
11582
11632
|
exports.RenderStack = RenderStack;
|
|
11583
11633
|
exports.Renderer = Renderer;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -67,6 +67,29 @@ declare class EventEmitter {
|
|
|
67
67
|
emit(type: string, ...args: any[]): boolean;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
71
|
+
protected _map: WeakMap<K, V>;
|
|
72
|
+
protected _toRaw(value: any): any;
|
|
73
|
+
/**
|
|
74
|
+
* Removes the specified element from the WeakMap.
|
|
75
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
76
|
+
*/
|
|
77
|
+
delete(key: K): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @returns a specified element.
|
|
80
|
+
*/
|
|
81
|
+
get(key: K): V | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
84
|
+
*/
|
|
85
|
+
has(key: K): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a new element with a specified key and value.
|
|
88
|
+
* @param key Must be an object or symbol.
|
|
89
|
+
*/
|
|
90
|
+
set(key: K, value: V): this;
|
|
91
|
+
}
|
|
92
|
+
|
|
70
93
|
declare const PI: number;
|
|
71
94
|
declare const PI_2: number;
|
|
72
95
|
declare function uid(object?: Record<string, any>): number;
|
|
@@ -141,7 +164,7 @@ declare abstract class Renderer {
|
|
|
141
164
|
width: number;
|
|
142
165
|
height: number;
|
|
143
166
|
};
|
|
144
|
-
readonly related:
|
|
167
|
+
readonly related: RawWeakMap<object, any>;
|
|
145
168
|
getRelated<T>(source: object, createFn?: () => T): T;
|
|
146
169
|
resize(width: number, height: number, updateStyle?: boolean): void;
|
|
147
170
|
}
|
|
@@ -221,7 +244,7 @@ interface WebGLProgramMeta {
|
|
|
221
244
|
name: string;
|
|
222
245
|
location: WebGLUniformLocation | null;
|
|
223
246
|
}>;
|
|
224
|
-
boundUniforms:
|
|
247
|
+
boundUniforms: RawWeakMap<object, any>;
|
|
225
248
|
}
|
|
226
249
|
interface WebGLProgramOptions {
|
|
227
250
|
vert: string;
|
|
@@ -739,7 +762,7 @@ declare class Geometry extends Resource {
|
|
|
739
762
|
indexBuffer?: IndexBuffer;
|
|
740
763
|
instanceCount?: number;
|
|
741
764
|
mode: WebGLDrawMode;
|
|
742
|
-
protected _materialWeakMap:
|
|
765
|
+
protected _materialWeakMap: RawWeakMap<Material, Record<string, any>>;
|
|
743
766
|
constructor(options?: GeometryOptions);
|
|
744
767
|
/** @internal */
|
|
745
768
|
_glVertexArray(renderer: WebGLRenderer): WebGLVertexArrayObjectOptions;
|
|
@@ -1417,7 +1440,7 @@ declare class Animation2D extends Node {
|
|
|
1417
1440
|
duration: number;
|
|
1418
1441
|
protected _keyframes: NormalizedKeyframe[];
|
|
1419
1442
|
protected _starting: boolean;
|
|
1420
|
-
protected _startProps:
|
|
1443
|
+
protected _startProps: RawWeakMap<any, Map<string, any>>;
|
|
1421
1444
|
constructor(options?: AnimationOptions);
|
|
1422
1445
|
protected _enterTree(): void;
|
|
1423
1446
|
protected _exitTree(): void;
|
|
@@ -1488,13 +1511,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1511
|
texture?: Texture;
|
|
1489
1512
|
}
|
|
1490
1513
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1514
|
+
path: Path2D;
|
|
1492
1515
|
texture?: Texture;
|
|
1493
1516
|
textureTransform?: Transform2D;
|
|
1494
1517
|
style: LineStyle;
|
|
1495
1518
|
}
|
|
1496
1519
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1520
|
+
path: Path2D;
|
|
1498
1521
|
texture?: Texture;
|
|
1499
1522
|
textureTransform?: Transform2D;
|
|
1500
1523
|
}
|
|
@@ -1506,14 +1529,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1529
|
lineJoin?: LineJoin;
|
|
1507
1530
|
lineWidth?: number;
|
|
1508
1531
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1532
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1533
|
+
_stroke: StrokedGraphics[];
|
|
1534
|
+
_fille: FilledGraphics[];
|
|
1512
1535
|
stroke(): void;
|
|
1513
1536
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1537
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1538
|
fill(): void;
|
|
1516
|
-
|
|
1539
|
+
copy(source: CanvasContext): this;
|
|
1540
|
+
reset(): this;
|
|
1517
1541
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1542
|
toBatchables(): CanvasBatchable[];
|
|
1519
1543
|
}
|
|
@@ -2740,4 +2764,4 @@ interface RenderOptions {
|
|
|
2740
2764
|
}
|
|
2741
2765
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
2742
2766
|
|
|
2743
|
-
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
|
2767
|
+
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, RawWeakMap, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -67,6 +67,29 @@ declare class EventEmitter {
|
|
|
67
67
|
emit(type: string, ...args: any[]): boolean;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
71
|
+
protected _map: WeakMap<K, V>;
|
|
72
|
+
protected _toRaw(value: any): any;
|
|
73
|
+
/**
|
|
74
|
+
* Removes the specified element from the WeakMap.
|
|
75
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
76
|
+
*/
|
|
77
|
+
delete(key: K): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @returns a specified element.
|
|
80
|
+
*/
|
|
81
|
+
get(key: K): V | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
84
|
+
*/
|
|
85
|
+
has(key: K): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a new element with a specified key and value.
|
|
88
|
+
* @param key Must be an object or symbol.
|
|
89
|
+
*/
|
|
90
|
+
set(key: K, value: V): this;
|
|
91
|
+
}
|
|
92
|
+
|
|
70
93
|
declare const PI: number;
|
|
71
94
|
declare const PI_2: number;
|
|
72
95
|
declare function uid(object?: Record<string, any>): number;
|
|
@@ -141,7 +164,7 @@ declare abstract class Renderer {
|
|
|
141
164
|
width: number;
|
|
142
165
|
height: number;
|
|
143
166
|
};
|
|
144
|
-
readonly related:
|
|
167
|
+
readonly related: RawWeakMap<object, any>;
|
|
145
168
|
getRelated<T>(source: object, createFn?: () => T): T;
|
|
146
169
|
resize(width: number, height: number, updateStyle?: boolean): void;
|
|
147
170
|
}
|
|
@@ -221,7 +244,7 @@ interface WebGLProgramMeta {
|
|
|
221
244
|
name: string;
|
|
222
245
|
location: WebGLUniformLocation | null;
|
|
223
246
|
}>;
|
|
224
|
-
boundUniforms:
|
|
247
|
+
boundUniforms: RawWeakMap<object, any>;
|
|
225
248
|
}
|
|
226
249
|
interface WebGLProgramOptions {
|
|
227
250
|
vert: string;
|
|
@@ -739,7 +762,7 @@ declare class Geometry extends Resource {
|
|
|
739
762
|
indexBuffer?: IndexBuffer;
|
|
740
763
|
instanceCount?: number;
|
|
741
764
|
mode: WebGLDrawMode;
|
|
742
|
-
protected _materialWeakMap:
|
|
765
|
+
protected _materialWeakMap: RawWeakMap<Material, Record<string, any>>;
|
|
743
766
|
constructor(options?: GeometryOptions);
|
|
744
767
|
/** @internal */
|
|
745
768
|
_glVertexArray(renderer: WebGLRenderer): WebGLVertexArrayObjectOptions;
|
|
@@ -1417,7 +1440,7 @@ declare class Animation2D extends Node {
|
|
|
1417
1440
|
duration: number;
|
|
1418
1441
|
protected _keyframes: NormalizedKeyframe[];
|
|
1419
1442
|
protected _starting: boolean;
|
|
1420
|
-
protected _startProps:
|
|
1443
|
+
protected _startProps: RawWeakMap<any, Map<string, any>>;
|
|
1421
1444
|
constructor(options?: AnimationOptions);
|
|
1422
1445
|
protected _enterTree(): void;
|
|
1423
1446
|
protected _exitTree(): void;
|
|
@@ -1488,13 +1511,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1511
|
texture?: Texture;
|
|
1489
1512
|
}
|
|
1490
1513
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1514
|
+
path: Path2D;
|
|
1492
1515
|
texture?: Texture;
|
|
1493
1516
|
textureTransform?: Transform2D;
|
|
1494
1517
|
style: LineStyle;
|
|
1495
1518
|
}
|
|
1496
1519
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1520
|
+
path: Path2D;
|
|
1498
1521
|
texture?: Texture;
|
|
1499
1522
|
textureTransform?: Transform2D;
|
|
1500
1523
|
}
|
|
@@ -1506,14 +1529,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1529
|
lineJoin?: LineJoin;
|
|
1507
1530
|
lineWidth?: number;
|
|
1508
1531
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1532
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1533
|
+
_stroke: StrokedGraphics[];
|
|
1534
|
+
_fille: FilledGraphics[];
|
|
1512
1535
|
stroke(): void;
|
|
1513
1536
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1537
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1538
|
fill(): void;
|
|
1516
|
-
|
|
1539
|
+
copy(source: CanvasContext): this;
|
|
1540
|
+
reset(): this;
|
|
1517
1541
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1542
|
toBatchables(): CanvasBatchable[];
|
|
1519
1543
|
}
|
|
@@ -2740,4 +2764,4 @@ interface RenderOptions {
|
|
|
2740
2764
|
}
|
|
2741
2765
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
2742
2766
|
|
|
2743
|
-
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
|
2767
|
+
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, RawWeakMap, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Visibility, Overflow, IDOCTextStyleDeclaration, IDOCTransformStyleDeclaration } from 'modern-idoc';
|
|
2
|
-
import {
|
|
2
|
+
import { Path2D, LineStyle, LineCap, LineJoin, BoundingBox } from 'modern-path2d';
|
|
3
3
|
import { AnyColor, Colord } from 'colord';
|
|
4
4
|
import { AnimationItem } from 'lottie-web';
|
|
5
5
|
import { TextOptions, Text, MeasureResult } from 'modern-text';
|
|
@@ -67,6 +67,29 @@ declare class EventEmitter {
|
|
|
67
67
|
emit(type: string, ...args: any[]): boolean;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
|
|
71
|
+
protected _map: WeakMap<K, V>;
|
|
72
|
+
protected _toRaw(value: any): any;
|
|
73
|
+
/**
|
|
74
|
+
* Removes the specified element from the WeakMap.
|
|
75
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
76
|
+
*/
|
|
77
|
+
delete(key: K): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* @returns a specified element.
|
|
80
|
+
*/
|
|
81
|
+
get(key: K): V | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @returns a boolean indicating whether an element with the specified key exists or not.
|
|
84
|
+
*/
|
|
85
|
+
has(key: K): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Adds a new element with a specified key and value.
|
|
88
|
+
* @param key Must be an object or symbol.
|
|
89
|
+
*/
|
|
90
|
+
set(key: K, value: V): this;
|
|
91
|
+
}
|
|
92
|
+
|
|
70
93
|
declare const PI: number;
|
|
71
94
|
declare const PI_2: number;
|
|
72
95
|
declare function uid(object?: Record<string, any>): number;
|
|
@@ -141,7 +164,7 @@ declare abstract class Renderer {
|
|
|
141
164
|
width: number;
|
|
142
165
|
height: number;
|
|
143
166
|
};
|
|
144
|
-
readonly related:
|
|
167
|
+
readonly related: RawWeakMap<object, any>;
|
|
145
168
|
getRelated<T>(source: object, createFn?: () => T): T;
|
|
146
169
|
resize(width: number, height: number, updateStyle?: boolean): void;
|
|
147
170
|
}
|
|
@@ -221,7 +244,7 @@ interface WebGLProgramMeta {
|
|
|
221
244
|
name: string;
|
|
222
245
|
location: WebGLUniformLocation | null;
|
|
223
246
|
}>;
|
|
224
|
-
boundUniforms:
|
|
247
|
+
boundUniforms: RawWeakMap<object, any>;
|
|
225
248
|
}
|
|
226
249
|
interface WebGLProgramOptions {
|
|
227
250
|
vert: string;
|
|
@@ -739,7 +762,7 @@ declare class Geometry extends Resource {
|
|
|
739
762
|
indexBuffer?: IndexBuffer;
|
|
740
763
|
instanceCount?: number;
|
|
741
764
|
mode: WebGLDrawMode;
|
|
742
|
-
protected _materialWeakMap:
|
|
765
|
+
protected _materialWeakMap: RawWeakMap<Material, Record<string, any>>;
|
|
743
766
|
constructor(options?: GeometryOptions);
|
|
744
767
|
/** @internal */
|
|
745
768
|
_glVertexArray(renderer: WebGLRenderer): WebGLVertexArrayObjectOptions;
|
|
@@ -1417,7 +1440,7 @@ declare class Animation2D extends Node {
|
|
|
1417
1440
|
duration: number;
|
|
1418
1441
|
protected _keyframes: NormalizedKeyframe[];
|
|
1419
1442
|
protected _starting: boolean;
|
|
1420
|
-
protected _startProps:
|
|
1443
|
+
protected _startProps: RawWeakMap<any, Map<string, any>>;
|
|
1421
1444
|
constructor(options?: AnimationOptions);
|
|
1422
1445
|
protected _enterTree(): void;
|
|
1423
1446
|
protected _exitTree(): void;
|
|
@@ -1488,13 +1511,13 @@ interface CanvasBatchable extends Batchable2D {
|
|
|
1488
1511
|
texture?: Texture;
|
|
1489
1512
|
}
|
|
1490
1513
|
interface StrokedGraphics {
|
|
1491
|
-
|
|
1514
|
+
path: Path2D;
|
|
1492
1515
|
texture?: Texture;
|
|
1493
1516
|
textureTransform?: Transform2D;
|
|
1494
1517
|
style: LineStyle;
|
|
1495
1518
|
}
|
|
1496
1519
|
interface FilledGraphics {
|
|
1497
|
-
|
|
1520
|
+
path: Path2D;
|
|
1498
1521
|
texture?: Texture;
|
|
1499
1522
|
textureTransform?: Transform2D;
|
|
1500
1523
|
}
|
|
@@ -1506,14 +1529,15 @@ declare class CanvasContext extends Path2D {
|
|
|
1506
1529
|
lineJoin?: LineJoin;
|
|
1507
1530
|
lineWidth?: number;
|
|
1508
1531
|
miterLimit?: number;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1532
|
+
_defaultStyle: Texture<TextureSource>;
|
|
1533
|
+
_stroke: StrokedGraphics[];
|
|
1534
|
+
_fille: FilledGraphics[];
|
|
1512
1535
|
stroke(): void;
|
|
1513
1536
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
1514
1537
|
strokeRect(x: number, y: number, width: number, height: number): void;
|
|
1515
1538
|
fill(): void;
|
|
1516
|
-
|
|
1539
|
+
copy(source: CanvasContext): this;
|
|
1540
|
+
reset(): this;
|
|
1517
1541
|
buildUvs(start: number, vertices: number[], uvs: number[], texture?: Texture, textureTransform?: Transform2D): void;
|
|
1518
1542
|
toBatchables(): CanvasBatchable[];
|
|
1519
1543
|
}
|
|
@@ -2740,4 +2764,4 @@ interface RenderOptions {
|
|
|
2740
2764
|
}
|
|
2741
2765
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|
|
2742
2766
|
|
|
2743
|
-
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|
|
2767
|
+
export { Animation2D, type AnimationOptions, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformOptions, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasItem, type CanvasItemOptions, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectOptions, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, type CssFunction, type CssFunctionArg, type Cursor, type CustomNodeOptions, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DOptions, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, LottieLoader, type LottieOptions, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DOptions, type NodeEventMap, type NodeOptions, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, PointerInputEvent, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, RawWeakMap, Reference, type ReferenceEventMap, type RenderCall, type RenderOptions, RenderStack, type Renderable, Renderer, Resource, type ResourceEventMap, 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, SceneTree, type SceneTreeEventMap, type StrokedGraphics, Style2D, type Style2DBackgroundExtend, Style2DBackgroundModule, type Style2DBackgroundProperties, type Style2DFilter, type Style2DFilterExtend, type Style2DFilterKey, Style2DFilterModule, type Style2DFilterProperties, Style2DModule, type Style2DOptions, type Style2DTextExtend, Style2DTextModule, type Style2DTextProperties, type Style2DTransformExtend, Style2DTransformModule, type Style2DTransformProperties, Text2D, type Text2DOptions, TextLoader, Texture, type TextureFilterMode, TextureLoader, type TexturePixelsSource, type TextureSource, type TextureWrapMode, Ticker, TiltShiftEffect, Timer, type TimerEventMap, type TimerOptions, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UIInputEvent, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DOptions, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, _Object, type _ObjectEventMap, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
|