modern-canvas 0.9.3 → 0.9.4

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
@@ -4476,7 +4476,7 @@ class VertexAttribute extends Resource {
4476
4476
  }
4477
4477
  }
4478
4478
  __decorateClass$W([
4479
- modernIdoc.property({ protected: true })
4479
+ modernIdoc.property({ internal: true })
4480
4480
  ], VertexAttribute.prototype, "buffer");
4481
4481
  __decorateClass$W([
4482
4482
  modernIdoc.property({ fallback: 0 })
@@ -4870,7 +4870,7 @@ class Texture2D extends Resource {
4870
4870
  }
4871
4871
  }
4872
4872
  __decorateClass$V([
4873
- modernIdoc.property({ protected: true })
4873
+ modernIdoc.property({ internal: true })
4874
4874
  ], Texture2D.prototype, "source");
4875
4875
  __decorateClass$V([
4876
4876
  modernIdoc.property({ fallback: 0 })
@@ -6204,7 +6204,7 @@ __decorateClass$S([
6204
6204
  modernIdoc.property({ internal: true, fallback: "default" })
6205
6205
  ], exports.Node.prototype, "internalMode", 2);
6206
6206
  __decorateClass$S([
6207
- modernIdoc.property({ protected: true })
6207
+ modernIdoc.property({ internal: true })
6208
6208
  ], exports.Node.prototype, "mask", 2);
6209
6209
  exports.Node = __decorateClass$S([
6210
6210
  customNode("Node")
@@ -6888,7 +6888,7 @@ exports.Effect = class Effect extends exports.TimelineNode {
6888
6888
  }
6889
6889
  };
6890
6890
  __decorateClass$O([
6891
- modernIdoc.property({ protected: true })
6891
+ modernIdoc.property({ internal: true })
6892
6892
  ], exports.Effect.prototype, "material", 2);
6893
6893
  __decorateClass$O([
6894
6894
  modernIdoc.property()
@@ -7022,6 +7022,7 @@ var __decorateClass$L = (decorators, target, key, kind) => {
7022
7022
  return result;
7023
7023
  };
7024
7024
  class SceneTree extends MainLoop {
7025
+ fonts;
7025
7026
  input = new Input();
7026
7027
  renderStack = new RenderStack();
7027
7028
  root = new exports.Window(true).setTree(this);
@@ -8905,7 +8906,7 @@ void main(void) {
8905
8906
  }`
8906
8907
  }));
8907
8908
  __decorateClass$w([
8908
- modernIdoc.property({ protected: true })
8909
+ modernIdoc.property({ internal: true })
8909
8910
  ], exports.MaskEffect.prototype, "texture", 2);
8910
8911
  __decorateClass$w([
8911
8912
  modernIdoc.property({ fallback: "" })
@@ -9707,9 +9708,9 @@ class BaseElement2DText extends CoreObject {
9707
9708
  constructor(parent) {
9708
9709
  super();
9709
9710
  this.parent = parent;
9710
- this.base.setPropertyAccessor(this);
9711
+ this.base = new modernText.Text().setPropertyAccessor(this);
9711
9712
  }
9712
- base = new modernText.Text();
9713
+ base;
9713
9714
  measureResult;
9714
9715
  _textureMap = /* @__PURE__ */ new Map();
9715
9716
  setProperties(properties) {
@@ -9733,8 +9734,12 @@ class BaseElement2DText extends CoreObject {
9733
9734
  break;
9734
9735
  }
9735
9736
  }
9736
- _updateTextureMap() {
9737
+ _updateBase() {
9738
+ this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
9737
9739
  this.base.update();
9740
+ }
9741
+ _updateTextureMap() {
9742
+ this._updateBase();
9738
9743
  this._textureMap.clear();
9739
9744
  const pGlyphBoxs = [];
9740
9745
  this.base.paragraphs.forEach((p, pIndex) => {
@@ -9790,6 +9795,7 @@ class BaseElement2DText extends CoreObject {
9790
9795
  this.content = modernIdoc.normalizeTextContent(content);
9791
9796
  }
9792
9797
  measure() {
9798
+ this._updateBase();
9793
9799
  return this.base.measure();
9794
9800
  }
9795
9801
  updateMeasure() {
@@ -9812,7 +9818,7 @@ class BaseElement2DText extends CoreObject {
9812
9818
  }
9813
9819
  draw() {
9814
9820
  const ctx = this.parent.context;
9815
- this.base.update();
9821
+ this._updateBase();
9816
9822
  this.base.pathSets.forEach((pathSet) => {
9817
9823
  pathSet.paths.forEach((path) => {
9818
9824
  const meta = path.getMeta();
@@ -10935,7 +10941,7 @@ exports.Image2D = class Image2D extends exports.Element2D {
10935
10941
  }
10936
10942
  };
10937
10943
  __decorateClass$i([
10938
- modernIdoc.property({ protected: true })
10944
+ modernIdoc.property({ internal: true })
10939
10945
  ], exports.Image2D.prototype, "texture", 2);
10940
10946
  __decorateClass$i([
10941
10947
  modernIdoc.property({ fallback: "" })
@@ -14174,6 +14180,7 @@ class Engine extends SceneTree {
14174
14180
  height,
14175
14181
  pixelRatio = DEVICE_PIXEL_RATIO,
14176
14182
  backgroundColor = 0,
14183
+ fonts,
14177
14184
  autoResize,
14178
14185
  autoStart,
14179
14186
  timeline,
@@ -14188,6 +14195,7 @@ class Engine extends SceneTree {
14188
14195
  this._setupInput();
14189
14196
  this.pixelRatio = pixelRatio;
14190
14197
  this.backgroundColor = backgroundColor;
14198
+ this.fonts = fonts;
14191
14199
  if (autoResize) {
14192
14200
  if (!view && this.renderer.view) {
14193
14201
  this.renderer.view.style.width = "100%";
@@ -14338,13 +14346,14 @@ async function start(sleep = 100) {
14338
14346
  starting = false;
14339
14347
  }
14340
14348
  async function task(options) {
14341
- const { data, width, height, debug = false, time = 0 } = options;
14349
+ const { debug = false, fonts, width, height, time = 0, data } = options;
14342
14350
  engine ??= new Engine({
14343
14351
  width: 1,
14344
14352
  height: 1,
14345
14353
  preserveDrawingBuffer: true
14346
14354
  });
14347
14355
  engine.debug = debug;
14356
+ engine.fonts = fonts;
14348
14357
  engine.root.removeChildren();
14349
14358
  engine.timeline.currentTime = time;
14350
14359
  engine.resize(width, height, true);
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Font } from 'modern-font';
1
+ import { Font, Fonts } from 'modern-font';
2
2
  import { ObservableEvents, Observable, ReactivableEvents, Reactivable, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
@@ -1599,6 +1599,7 @@ declare class SceneTree extends MainLoop {
1599
1599
  processPaused: boolean;
1600
1600
  backgroundColor: Color$1 | undefined;
1601
1601
  debug: boolean;
1602
+ fonts?: Fonts;
1602
1603
  readonly input: Input;
1603
1604
  readonly renderStack: RenderStack;
1604
1605
  readonly root: Window;
@@ -2080,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
2080
2081
  constructor(parent: BaseElement2D);
2081
2082
  setProperties(properties?: Text$1): this;
2082
2083
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2084
+ protected _updateBase(): void;
2083
2085
  protected _updateTextureMap(): void;
2084
2086
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2085
2087
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
@@ -3301,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
3301
3303
  height?: number;
3302
3304
  pixelRatio?: number;
3303
3305
  backgroundColor?: Color$1;
3306
+ fonts?: Fonts;
3304
3307
  autoResize?: boolean;
3305
3308
  autoStart?: boolean;
3306
3309
  timeline?: Timeline;
@@ -3362,6 +3365,7 @@ interface RenderOptions {
3362
3365
  height: number;
3363
3366
  debug?: boolean;
3364
3367
  time?: number;
3368
+ fonts?: Fonts;
3365
3369
  onBeforeRender?: (engine: Engine) => void | Promise<void>;
3366
3370
  }
3367
3371
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Font } from 'modern-font';
1
+ import { Font, Fonts } from 'modern-font';
2
2
  import { ObservableEvents, Observable, ReactivableEvents, Reactivable, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
@@ -1599,6 +1599,7 @@ declare class SceneTree extends MainLoop {
1599
1599
  processPaused: boolean;
1600
1600
  backgroundColor: Color$1 | undefined;
1601
1601
  debug: boolean;
1602
+ fonts?: Fonts;
1602
1603
  readonly input: Input;
1603
1604
  readonly renderStack: RenderStack;
1604
1605
  readonly root: Window;
@@ -2080,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
2080
2081
  constructor(parent: BaseElement2D);
2081
2082
  setProperties(properties?: Text$1): this;
2082
2083
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2084
+ protected _updateBase(): void;
2083
2085
  protected _updateTextureMap(): void;
2084
2086
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2085
2087
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
@@ -3301,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
3301
3303
  height?: number;
3302
3304
  pixelRatio?: number;
3303
3305
  backgroundColor?: Color$1;
3306
+ fonts?: Fonts;
3304
3307
  autoResize?: boolean;
3305
3308
  autoStart?: boolean;
3306
3309
  timeline?: Timeline;
@@ -3362,6 +3365,7 @@ interface RenderOptions {
3362
3365
  height: number;
3363
3366
  debug?: boolean;
3364
3367
  time?: number;
3368
+ fonts?: Fonts;
3365
3369
  onBeforeRender?: (engine: Engine) => void | Promise<void>;
3366
3370
  }
3367
3371
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Font } from 'modern-font';
1
+ import { Font, Fonts } from 'modern-font';
2
2
  import { ObservableEvents, Observable, ReactivableEvents, Reactivable, Color as Color$1, RawWeakMap as RawWeakMap$1, LinearGradient, RadialGradient, NormalizedFill, Fill, NormalizedBackground, Background, NormalizedForeground, Foreground, NormalizedOutline, Outline, NormalizedShadow, Shadow, NormalizedShape, Shape, FullStyle, Text as Text$1, TextContent, Style, ImageFillCropRect } from 'modern-idoc';
3
3
  export { Color as ColorValue } from 'modern-idoc';
4
4
  import { AnimationItem } from 'lottie-web';
@@ -1599,6 +1599,7 @@ declare class SceneTree extends MainLoop {
1599
1599
  processPaused: boolean;
1600
1600
  backgroundColor: Color$1 | undefined;
1601
1601
  debug: boolean;
1602
+ fonts?: Fonts;
1602
1603
  readonly input: Input;
1603
1604
  readonly renderStack: RenderStack;
1604
1605
  readonly root: Window;
@@ -2080,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
2080
2081
  constructor(parent: BaseElement2D);
2081
2082
  setProperties(properties?: Text$1): this;
2082
2083
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2084
+ protected _updateBase(): void;
2083
2085
  protected _updateTextureMap(): void;
2084
2086
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2085
2087
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
@@ -3301,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
3301
3303
  height?: number;
3302
3304
  pixelRatio?: number;
3303
3305
  backgroundColor?: Color$1;
3306
+ fonts?: Fonts;
3304
3307
  autoResize?: boolean;
3305
3308
  autoStart?: boolean;
3306
3309
  timeline?: Timeline;
@@ -3362,6 +3365,7 @@ interface RenderOptions {
3362
3365
  height: number;
3363
3366
  debug?: boolean;
3364
3367
  time?: number;
3368
+ fonts?: Fonts;
3365
3369
  onBeforeRender?: (engine: Engine) => void | Promise<void>;
3366
3370
  }
3367
3371
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;