modern-canvas 0.4.32 → 0.4.34

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 CHANGED
@@ -561,7 +561,17 @@ class CoreObject extends EventEmitter {
561
561
  }
562
562
  }
563
563
  toJSON() {
564
- return this.getProperties(Array.from(this._changedProperties));
564
+ const json = {};
565
+ const properties = this.getProperties(Array.from(this._changedProperties));
566
+ for (const key in properties) {
567
+ const value = properties[key];
568
+ if (value && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
569
+ json[key] = value.toJSON();
570
+ } else {
571
+ json[key] = value;
572
+ }
573
+ }
574
+ return json;
565
575
  }
566
576
  clone() {
567
577
  return new this.constructor(this.toJSON());
@@ -1064,27 +1074,7 @@ class Color {
1064
1074
  return this._value;
1065
1075
  }
1066
1076
  set value(value) {
1067
- if (value === void 0 || this._value === value)
1068
- return;
1069
- this._value = value;
1070
- let input;
1071
- if (typeof value === "number") {
1072
- input = {
1073
- r: value >> 24 & 255,
1074
- g: value >> 16 & 255,
1075
- b: value >> 8 & 255,
1076
- a: (value & 255) / 255
1077
- };
1078
- } else {
1079
- input = value;
1080
- }
1081
- const parsed = colord.colord(input);
1082
- if (parsed.isValid()) {
1083
- this._colord = parsed;
1084
- } else {
1085
- this._colord = colord.colord("#000000");
1086
- console.warn(`Unable to convert color ${value}`);
1087
- }
1077
+ this._colord = modernIdoc.parseColor(value ?? "none");
1088
1078
  }
1089
1079
  get r8() {
1090
1080
  return this._colord.rgba.r;
@@ -9214,12 +9204,6 @@ __decorateClass$q([
9214
9204
  __decorateClass$q([
9215
9205
  property({ default: "solid" })
9216
9206
  ], BaseElement2DOutline.prototype, "style");
9217
- __decorateClass$q([
9218
- property()
9219
- ], BaseElement2DOutline.prototype, "src");
9220
- __decorateClass$q([
9221
- property({ default: 1 })
9222
- ], BaseElement2DOutline.prototype, "opacity");
9223
9207
 
9224
9208
  var __defProp$i = Object.defineProperty;
9225
9209
  var __decorateClass$p = (decorators, target, key, kind) => {
@@ -9808,13 +9792,15 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9808
9792
  return {
9809
9793
  ...json,
9810
9794
  props: {
9795
+ ...json.props,
9811
9796
  style: this.style.toJSON(),
9812
- text: this.text.toJSON(),
9797
+ background: this.background.toJSON(),
9813
9798
  geometry: this.geometry.toJSON(),
9814
9799
  fill: this.fill.toJSON(),
9815
9800
  outline: this.outline.toJSON(),
9816
- shadow: this.shadow.toJSON(),
9817
- ...json.props
9801
+ text: this.text.toJSON(),
9802
+ foreground: this.foreground.toJSON(),
9803
+ shadow: this.shadow.toJSON()
9818
9804
  }
9819
9805
  };
9820
9806
  }
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Font } from 'modern-font';
2
2
  import { AnimationItem } from 'lottie-web';
3
- import { AnyColor, Colord } from 'colord';
4
- import { FillDeclaration, FillProperty, BackgroundDeclaration, BackgroundProperty, ForegroundDeclaration, ForegroundProperty, GeometryPathDeclaration, GeometryProperty, OutlineDeclaration, OutlineProperty, ShadowDeclaration, ShadowProperty, StyleDeclaration, TextProperty, StyleProperty, TextureFillSourceRect } from 'modern-idoc';
3
+ import { Colord } from 'colord';
4
+ import { Color as Color$1, FillDeclaration, FillProperty, BackgroundDeclaration, BackgroundProperty, ForegroundDeclaration, ForegroundProperty, GeometryPathDeclaration, GeometryProperty, OutlineDeclaration, OutlineProperty, ShadowDeclaration, ShadowProperty, StyleDeclaration, TextProperty, StyleProperty, TextureFillSourceRect } from 'modern-idoc';
5
+ export { Color as ColorValue } from 'modern-idoc';
5
6
  import { Path2D, LineCap, LineJoin, LineStyle, Path2DSet } from 'modern-path2d';
6
7
  import { TextOptions, Text, MeasureResult } from 'modern-text';
7
8
  import { Node as Node$1, Direction } from 'yoga-layout/load';
@@ -300,12 +301,11 @@ interface Resource {
300
301
  declare class Resource extends RefCounted {
301
302
  }
302
303
 
303
- type ColorValue = number | AnyColor;
304
304
  declare class Color {
305
305
  protected _colord: Colord;
306
- protected _value: ColorValue;
307
- get value(): ColorValue;
308
- set value(value: ColorValue | undefined);
306
+ protected _value: Color$1;
307
+ get value(): Color$1;
308
+ set value(value: Color$1 | undefined);
309
309
  get r8(): number;
310
310
  get g8(): number;
311
311
  get b8(): number;
@@ -317,7 +317,7 @@ declare class Color {
317
317
  get rgb(): number;
318
318
  get bgr(): number;
319
319
  get abgr(): number;
320
- constructor(value?: ColorValue);
320
+ constructor(value?: Color$1);
321
321
  toArgb(alpha?: number, applyToRGB?: boolean): number;
322
322
  toHex(): string;
323
323
  toArray(): [number, number, number, number];
@@ -1331,7 +1331,7 @@ declare class CanvasTexture extends Texture2D<HTMLCanvasElement> {
1331
1331
  }
1332
1332
 
1333
1333
  declare class ColorTexture extends Texture2D {
1334
- constructor(value: ColorValue);
1334
+ constructor(value: Color$1);
1335
1335
  }
1336
1336
 
1337
1337
  interface ImageTextureOptions {
@@ -1426,8 +1426,8 @@ interface FillDraw extends Partial<CanvasBatchable> {
1426
1426
  }
1427
1427
  declare class CanvasContext extends Path2D {
1428
1428
  textureTransform?: Transform2D;
1429
- fillStyle?: ColorValue | Texture2D;
1430
- strokeStyle?: ColorValue | Texture2D;
1429
+ fillStyle?: Color$1 | Texture2D;
1430
+ strokeStyle?: Color$1 | Texture2D;
1431
1431
  lineCap?: LineCap;
1432
1432
  lineJoin?: LineJoin;
1433
1433
  lineWidth?: number;
@@ -1555,7 +1555,7 @@ interface SceneTree {
1555
1555
  }
1556
1556
  declare class SceneTree extends MainLoop {
1557
1557
  processPaused: boolean;
1558
- backgroundColor?: ColorValue;
1558
+ backgroundColor?: Color$1;
1559
1559
  debug: boolean;
1560
1560
  readonly input: Input;
1561
1561
  readonly renderStack: RenderStack;
@@ -1743,7 +1743,7 @@ declare class TimelineNode extends Node {
1743
1743
  }
1744
1744
 
1745
1745
  interface CanvasItemProperties extends TimelineNodeProperties {
1746
- modulate: ColorValue;
1746
+ modulate: Color$1;
1747
1747
  blendMode: WebGLBlendMode;
1748
1748
  }
1749
1749
  interface CanvasItemEventMap extends TimelineNodeEventMap {
@@ -1756,7 +1756,7 @@ interface CanvasItem {
1756
1756
  emit: (<K extends keyof CanvasItemEventMap>(type: K, ...args: Parameters<CanvasItemEventMap[K]>) => boolean) & ((type: string, ...args: any[]) => boolean);
1757
1757
  }
1758
1758
  declare class CanvasItem extends TimelineNode {
1759
- modulate?: ColorValue;
1759
+ modulate?: Color$1;
1760
1760
  blendMode?: WebGLBlendMode;
1761
1761
  visible: boolean;
1762
1762
  opacity: number;
@@ -1938,8 +1938,6 @@ declare class BaseElement2DOutline extends CoreObject {
1938
1938
  color: OutlineDeclaration['color'];
1939
1939
  width: OutlineDeclaration['width'];
1940
1940
  style: OutlineDeclaration['style'];
1941
- src?: OutlineDeclaration['src'];
1942
- opacity: OutlineDeclaration['opacity'];
1943
1941
  constructor(parent: BaseElement2D);
1944
1942
  setProperties(properties?: OutlineProperty): this;
1945
1943
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
@@ -1994,7 +1992,7 @@ interface BaseElement2DEventMap extends CanvasItemEventMap {
1994
1992
  updateStyleProperty: (key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration) => void;
1995
1993
  }
1996
1994
  interface BaseElement2DProperties extends Node2DProperties {
1997
- modulate: ColorValue;
1995
+ modulate: Color$1;
1998
1996
  blendMode: WebGLBlendMode;
1999
1997
  style: StyleProperty;
2000
1998
  background: BackgroundProperty;
@@ -2154,8 +2152,8 @@ declare class Graphics2D extends Node2D {
2154
2152
  protected _resetContext: boolean;
2155
2153
  lineCap?: LineCap;
2156
2154
  lineJoin?: LineJoin;
2157
- fillStyle?: ColorValue | Texture2D;
2158
- strokeStyle?: ColorValue | Texture2D;
2155
+ fillStyle?: Color$1 | Texture2D;
2156
+ strokeStyle?: Color$1 | Texture2D;
2159
2157
  lineWidth?: number;
2160
2158
  miterLimit?: number;
2161
2159
  rect: (x: number, y: number, width: number, height: number) => this;
@@ -2708,12 +2706,12 @@ declare class ColorFilterEffect extends Effect {
2708
2706
  }
2709
2707
 
2710
2708
  interface ColorOverlayEffectProperties extends EffectProperties {
2711
- colors: ColorValue[];
2709
+ colors: Color$1[];
2712
2710
  alpha: number;
2713
2711
  }
2714
2712
  declare class ColorOverlayEffect extends Effect {
2715
2713
  static material: Material;
2716
- colors: ColorValue[];
2714
+ colors: Color$1[];
2717
2715
  alpha: number;
2718
2716
  protected _color: Color;
2719
2717
  constructor(properties?: Partial<ColorOverlayEffectProperties>, children?: Node[]);
@@ -2721,12 +2719,12 @@ declare class ColorOverlayEffect extends Effect {
2721
2719
  }
2722
2720
 
2723
2721
  interface ColorRemoveEffectProperties extends EffectProperties {
2724
- colors: ColorValue[];
2722
+ colors: Color$1[];
2725
2723
  epsilon: number;
2726
2724
  }
2727
2725
  declare class ColorRemoveEffect extends Effect {
2728
2726
  static material: Material;
2729
- colors: ColorValue[];
2727
+ colors: Color$1[];
2730
2728
  epsilon: number;
2731
2729
  protected _color: Color;
2732
2730
  constructor(properties?: Partial<ColorRemoveEffectProperties>, children?: Node[]);
@@ -2734,12 +2732,12 @@ declare class ColorRemoveEffect extends Effect {
2734
2732
  }
2735
2733
 
2736
2734
  interface ColorReplaceEffectProperties extends EffectProperties {
2737
- colors: ColorValue[];
2735
+ colors: Color$1[];
2738
2736
  epsilon: number;
2739
2737
  }
2740
2738
  declare class ColorReplaceEffect extends Effect {
2741
2739
  static material: Material;
2742
- colors: ColorValue[][];
2740
+ colors: Color$1[][];
2743
2741
  epsilon: number;
2744
2742
  protected _color: Color;
2745
2743
  constructor(properties?: Partial<ColorReplaceEffectProperties>, children?: Node[]);
@@ -2760,7 +2758,7 @@ declare class GaussianBlurEffect extends Effect {
2760
2758
  }
2761
2759
 
2762
2760
  interface DropShadowEffectProperties extends EffectProperties {
2763
- color: ColorValue;
2761
+ color: Color$1;
2764
2762
  blur: number;
2765
2763
  offsetX: number;
2766
2764
  offsetY: number;
@@ -2768,7 +2766,7 @@ interface DropShadowEffectProperties extends EffectProperties {
2768
2766
  }
2769
2767
  declare class DropShadowEffect extends Effect {
2770
2768
  static material: Material;
2771
- color: ColorValue;
2769
+ color: Color$1;
2772
2770
  blur: number;
2773
2771
  offsetX: number;
2774
2772
  offsetY: number;
@@ -2879,7 +2877,7 @@ declare class MaskEffect extends Effect {
2879
2877
  }
2880
2878
 
2881
2879
  interface OutlineEffectProperties extends EffectProperties {
2882
- color: ColorValue;
2880
+ color: Color$1;
2883
2881
  width: number;
2884
2882
  style: 'dashed' | 'solid' | string;
2885
2883
  image?: string;
@@ -2892,7 +2890,7 @@ declare class OutlineEffect extends Effect {
2892
2890
  static MIN_SAMPLES: number;
2893
2891
  static MAX_SAMPLES: number;
2894
2892
  static getAngleStep(quality: number): number;
2895
- color: ColorValue;
2893
+ color: Color$1;
2896
2894
  width: number;
2897
2895
  style: 'dashed' | 'solid' | string;
2898
2896
  image?: string;
@@ -3190,7 +3188,7 @@ interface EngineOptions extends WebGLContextAttributes {
3190
3188
  width?: number;
3191
3189
  height?: number;
3192
3190
  pixelRatio?: number;
3193
- backgroundColor?: ColorValue;
3191
+ backgroundColor?: Color$1;
3194
3192
  autoResize?: boolean;
3195
3193
  autoStart?: boolean;
3196
3194
  timeline?: Timeline;
@@ -3257,4 +3255,4 @@ interface RenderOptions {
3257
3255
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3258
3256
 
3259
3257
  export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DGeometry, BaseElement2DOutline, BaseElement2DShadow, 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, 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, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
3260
- export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ColorValue, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, EventListener, EventListenerOptions, EventListenerValue, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, PropertyDeclaration, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Text2DEventMap, Text2DProperties, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, Transform2DObject, TransformRect2DProperties, TransitionProperties, VectorLike, VectorOperateOutput, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };
3258
+ export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, EventListener, EventListenerOptions, EventListenerValue, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, PropertyDeclaration, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Text2DEventMap, Text2DProperties, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, Transform2DObject, TransformRect2DProperties, TransitionProperties, VectorLike, VectorOperateOutput, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Font } from 'modern-font';
2
2
  import { AnimationItem } from 'lottie-web';
3
- import { AnyColor, Colord } from 'colord';
4
- import { FillDeclaration, FillProperty, BackgroundDeclaration, BackgroundProperty, ForegroundDeclaration, ForegroundProperty, GeometryPathDeclaration, GeometryProperty, OutlineDeclaration, OutlineProperty, ShadowDeclaration, ShadowProperty, StyleDeclaration, TextProperty, StyleProperty, TextureFillSourceRect } from 'modern-idoc';
3
+ import { Colord } from 'colord';
4
+ import { Color as Color$1, FillDeclaration, FillProperty, BackgroundDeclaration, BackgroundProperty, ForegroundDeclaration, ForegroundProperty, GeometryPathDeclaration, GeometryProperty, OutlineDeclaration, OutlineProperty, ShadowDeclaration, ShadowProperty, StyleDeclaration, TextProperty, StyleProperty, TextureFillSourceRect } from 'modern-idoc';
5
+ export { Color as ColorValue } from 'modern-idoc';
5
6
  import { Path2D, LineCap, LineJoin, LineStyle, Path2DSet } from 'modern-path2d';
6
7
  import { TextOptions, Text, MeasureResult } from 'modern-text';
7
8
  import { Node as Node$1, Direction } from 'yoga-layout/load';
@@ -300,12 +301,11 @@ interface Resource {
300
301
  declare class Resource extends RefCounted {
301
302
  }
302
303
 
303
- type ColorValue = number | AnyColor;
304
304
  declare class Color {
305
305
  protected _colord: Colord;
306
- protected _value: ColorValue;
307
- get value(): ColorValue;
308
- set value(value: ColorValue | undefined);
306
+ protected _value: Color$1;
307
+ get value(): Color$1;
308
+ set value(value: Color$1 | undefined);
309
309
  get r8(): number;
310
310
  get g8(): number;
311
311
  get b8(): number;
@@ -317,7 +317,7 @@ declare class Color {
317
317
  get rgb(): number;
318
318
  get bgr(): number;
319
319
  get abgr(): number;
320
- constructor(value?: ColorValue);
320
+ constructor(value?: Color$1);
321
321
  toArgb(alpha?: number, applyToRGB?: boolean): number;
322
322
  toHex(): string;
323
323
  toArray(): [number, number, number, number];
@@ -1331,7 +1331,7 @@ declare class CanvasTexture extends Texture2D<HTMLCanvasElement> {
1331
1331
  }
1332
1332
 
1333
1333
  declare class ColorTexture extends Texture2D {
1334
- constructor(value: ColorValue);
1334
+ constructor(value: Color$1);
1335
1335
  }
1336
1336
 
1337
1337
  interface ImageTextureOptions {
@@ -1426,8 +1426,8 @@ interface FillDraw extends Partial<CanvasBatchable> {
1426
1426
  }
1427
1427
  declare class CanvasContext extends Path2D {
1428
1428
  textureTransform?: Transform2D;
1429
- fillStyle?: ColorValue | Texture2D;
1430
- strokeStyle?: ColorValue | Texture2D;
1429
+ fillStyle?: Color$1 | Texture2D;
1430
+ strokeStyle?: Color$1 | Texture2D;
1431
1431
  lineCap?: LineCap;
1432
1432
  lineJoin?: LineJoin;
1433
1433
  lineWidth?: number;
@@ -1555,7 +1555,7 @@ interface SceneTree {
1555
1555
  }
1556
1556
  declare class SceneTree extends MainLoop {
1557
1557
  processPaused: boolean;
1558
- backgroundColor?: ColorValue;
1558
+ backgroundColor?: Color$1;
1559
1559
  debug: boolean;
1560
1560
  readonly input: Input;
1561
1561
  readonly renderStack: RenderStack;
@@ -1743,7 +1743,7 @@ declare class TimelineNode extends Node {
1743
1743
  }
1744
1744
 
1745
1745
  interface CanvasItemProperties extends TimelineNodeProperties {
1746
- modulate: ColorValue;
1746
+ modulate: Color$1;
1747
1747
  blendMode: WebGLBlendMode;
1748
1748
  }
1749
1749
  interface CanvasItemEventMap extends TimelineNodeEventMap {
@@ -1756,7 +1756,7 @@ interface CanvasItem {
1756
1756
  emit: (<K extends keyof CanvasItemEventMap>(type: K, ...args: Parameters<CanvasItemEventMap[K]>) => boolean) & ((type: string, ...args: any[]) => boolean);
1757
1757
  }
1758
1758
  declare class CanvasItem extends TimelineNode {
1759
- modulate?: ColorValue;
1759
+ modulate?: Color$1;
1760
1760
  blendMode?: WebGLBlendMode;
1761
1761
  visible: boolean;
1762
1762
  opacity: number;
@@ -1938,8 +1938,6 @@ declare class BaseElement2DOutline extends CoreObject {
1938
1938
  color: OutlineDeclaration['color'];
1939
1939
  width: OutlineDeclaration['width'];
1940
1940
  style: OutlineDeclaration['style'];
1941
- src?: OutlineDeclaration['src'];
1942
- opacity: OutlineDeclaration['opacity'];
1943
1941
  constructor(parent: BaseElement2D);
1944
1942
  setProperties(properties?: OutlineProperty): this;
1945
1943
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
@@ -1994,7 +1992,7 @@ interface BaseElement2DEventMap extends CanvasItemEventMap {
1994
1992
  updateStyleProperty: (key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration) => void;
1995
1993
  }
1996
1994
  interface BaseElement2DProperties extends Node2DProperties {
1997
- modulate: ColorValue;
1995
+ modulate: Color$1;
1998
1996
  blendMode: WebGLBlendMode;
1999
1997
  style: StyleProperty;
2000
1998
  background: BackgroundProperty;
@@ -2154,8 +2152,8 @@ declare class Graphics2D extends Node2D {
2154
2152
  protected _resetContext: boolean;
2155
2153
  lineCap?: LineCap;
2156
2154
  lineJoin?: LineJoin;
2157
- fillStyle?: ColorValue | Texture2D;
2158
- strokeStyle?: ColorValue | Texture2D;
2155
+ fillStyle?: Color$1 | Texture2D;
2156
+ strokeStyle?: Color$1 | Texture2D;
2159
2157
  lineWidth?: number;
2160
2158
  miterLimit?: number;
2161
2159
  rect: (x: number, y: number, width: number, height: number) => this;
@@ -2708,12 +2706,12 @@ declare class ColorFilterEffect extends Effect {
2708
2706
  }
2709
2707
 
2710
2708
  interface ColorOverlayEffectProperties extends EffectProperties {
2711
- colors: ColorValue[];
2709
+ colors: Color$1[];
2712
2710
  alpha: number;
2713
2711
  }
2714
2712
  declare class ColorOverlayEffect extends Effect {
2715
2713
  static material: Material;
2716
- colors: ColorValue[];
2714
+ colors: Color$1[];
2717
2715
  alpha: number;
2718
2716
  protected _color: Color;
2719
2717
  constructor(properties?: Partial<ColorOverlayEffectProperties>, children?: Node[]);
@@ -2721,12 +2719,12 @@ declare class ColorOverlayEffect extends Effect {
2721
2719
  }
2722
2720
 
2723
2721
  interface ColorRemoveEffectProperties extends EffectProperties {
2724
- colors: ColorValue[];
2722
+ colors: Color$1[];
2725
2723
  epsilon: number;
2726
2724
  }
2727
2725
  declare class ColorRemoveEffect extends Effect {
2728
2726
  static material: Material;
2729
- colors: ColorValue[];
2727
+ colors: Color$1[];
2730
2728
  epsilon: number;
2731
2729
  protected _color: Color;
2732
2730
  constructor(properties?: Partial<ColorRemoveEffectProperties>, children?: Node[]);
@@ -2734,12 +2732,12 @@ declare class ColorRemoveEffect extends Effect {
2734
2732
  }
2735
2733
 
2736
2734
  interface ColorReplaceEffectProperties extends EffectProperties {
2737
- colors: ColorValue[];
2735
+ colors: Color$1[];
2738
2736
  epsilon: number;
2739
2737
  }
2740
2738
  declare class ColorReplaceEffect extends Effect {
2741
2739
  static material: Material;
2742
- colors: ColorValue[][];
2740
+ colors: Color$1[][];
2743
2741
  epsilon: number;
2744
2742
  protected _color: Color;
2745
2743
  constructor(properties?: Partial<ColorReplaceEffectProperties>, children?: Node[]);
@@ -2760,7 +2758,7 @@ declare class GaussianBlurEffect extends Effect {
2760
2758
  }
2761
2759
 
2762
2760
  interface DropShadowEffectProperties extends EffectProperties {
2763
- color: ColorValue;
2761
+ color: Color$1;
2764
2762
  blur: number;
2765
2763
  offsetX: number;
2766
2764
  offsetY: number;
@@ -2768,7 +2766,7 @@ interface DropShadowEffectProperties extends EffectProperties {
2768
2766
  }
2769
2767
  declare class DropShadowEffect extends Effect {
2770
2768
  static material: Material;
2771
- color: ColorValue;
2769
+ color: Color$1;
2772
2770
  blur: number;
2773
2771
  offsetX: number;
2774
2772
  offsetY: number;
@@ -2879,7 +2877,7 @@ declare class MaskEffect extends Effect {
2879
2877
  }
2880
2878
 
2881
2879
  interface OutlineEffectProperties extends EffectProperties {
2882
- color: ColorValue;
2880
+ color: Color$1;
2883
2881
  width: number;
2884
2882
  style: 'dashed' | 'solid' | string;
2885
2883
  image?: string;
@@ -2892,7 +2890,7 @@ declare class OutlineEffect extends Effect {
2892
2890
  static MIN_SAMPLES: number;
2893
2891
  static MAX_SAMPLES: number;
2894
2892
  static getAngleStep(quality: number): number;
2895
- color: ColorValue;
2893
+ color: Color$1;
2896
2894
  width: number;
2897
2895
  style: 'dashed' | 'solid' | string;
2898
2896
  image?: string;
@@ -3190,7 +3188,7 @@ interface EngineOptions extends WebGLContextAttributes {
3190
3188
  width?: number;
3191
3189
  height?: number;
3192
3190
  pixelRatio?: number;
3193
- backgroundColor?: ColorValue;
3191
+ backgroundColor?: Color$1;
3194
3192
  autoResize?: boolean;
3195
3193
  autoStart?: boolean;
3196
3194
  timeline?: Timeline;
@@ -3257,4 +3255,4 @@ interface RenderOptions {
3257
3255
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3258
3256
 
3259
3257
  export { AnimatedTexture, Animation, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, BaseElement2D, BaseElement2DBackground, BaseElement2DFill, BaseElement2DForeground, BaseElement2DGeometry, BaseElement2DOutline, BaseElement2DShadow, 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, 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, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, frag, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCSSFilter, parseCSSTransform, parseCSSTransformOrigin, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
3260
- export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ColorValue, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, EventListener, EventListenerOptions, EventListenerValue, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, PropertyDeclaration, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Text2DEventMap, Text2DProperties, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, Transform2DObject, TransformRect2DProperties, TransitionProperties, VectorLike, VectorOperateOutput, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };
3258
+ export type { AnimationEffectMode, AnimationProperties, AssetHandler, AudioWaveformProperties, BaseElement2DEventMap, BaseElement2DProperties, BaseElement2DStyleProperties, Batchable2D, CSSFilterKey, CSSFilters, CanvasBatchable, CanvasItemEventMap, CanvasItemProperties, ColorAdjustEffectProperties, ColorFilterEffectProperties, ColorOverlayEffectProperties, ColorRemoveEffectProperties, ColorReplaceEffectProperties, ComputedLayout, ControlEventMap, ControlProperties, CoreObjectEventMap, CssFunction, CssFunctionArg, Cursor, DropShadowEffectProperties, Easing, EffectContext, EffectMode, EffectProperties, Element2DEventMap, Element2DProperties, Element2DStyleProperties, EmbossEffectProperties, EngineOptions, EventListener, EventListenerOptions, EventListenerValue, FillDraw, FlexBaseElement2DEventMap, FlexElement2DProperties, FlexElement2DStyleProperties, GaussianBlurEffectProperties, GeometryOptions, GlitchEffectProperties, GodrayEffectProperties, IAudioContext, IAudioNode, IPlayOptions, Image2DProperties, ImageFrame, ImageTextureOptions, IndexBufferOptions, InputEventKey, InputEventMap, InternalMode, KawaseBlurEffectProperties, Keyframe, Lottie2DProperties, MainLoopEventMap, MaskColor, MaskData, MaskEffectProperties, MaskObject, MaskRect, Maskable, MaterialOptions, MatrixLike, MatrixOperateOutput, Node2DProperties, NodeEventMap, NodeProperties, NormalizedKeyframe, OutlineEffectProperties, PixelateEffectProperties, PlatformAudio, PlatformSound, ProcessMode, ProcessSortMode, PropertyDeclaration, RangeProperties, Rectangulable, RectangulableEventMap, RefCountedEventMap, RenderMode, RenderOptions, Renderable, ResourceEventMap, RulerProperties, ScalerEventMap, ScalerProperties, SceneTreeEventMap, ScrollBarProperties, StrokeDraw, Text2DEventMap, Text2DProperties, Texture2DFilterMode, Texture2DPixelsSource, Texture2DSource, Texture2DWrapMode, TextureRect2DProperties, TimelineEventMap, TimelineNodeEventMap, TimelineNodeProperties, TimelineProperties, TimingFunctions, Transform2DObject, TransformRect2DProperties, TransitionProperties, VectorLike, VectorOperateOutput, VertexAttributeOptions, VertexBufferOptions, Video2DProperties, VideoTextureOptions, VideoTextureSource, ViewportEventMap, ViewportFramebuffer, WebGLBufferMeta, WebGLBufferOptions, WebGLBufferTarget, WebGLBufferUsage, WebGLDrawMode, WebGLDrawOptions, WebGLExtensions, WebGLFramebufferMeta, WebGLFramebufferOptions, WebGLProgramMeta, WebGLProgramOptions, WebGLTarget, WebGLTextureFilterMode, WebGLTextureLocation, WebGLTextureMeta, WebGLTextureOptions, WebGLTextureSource, WebGLTextureTarget, WebGLTextureWrapMode, WebGLVertexArrayObjectMeta, WebGLVertexArrayObjectOptions, WebGLVertexAttrib, WebGLVertexAttribType, WebGLViewport, XScrollBarProperties, YScrollBarProperties, ZoomBlurEffectProperties };