modern-canvas 0.9.2 → 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 +23 -11
- package/dist/index.d.cts +6 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +12 -12
- package/dist/index.mjs +23 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -879,6 +879,9 @@ class CoreObject extends modernIdoc.Reactivable {
|
|
|
879
879
|
get json() {
|
|
880
880
|
return this.toJSON();
|
|
881
881
|
}
|
|
882
|
+
set json(val) {
|
|
883
|
+
this.setProperties(val);
|
|
884
|
+
}
|
|
882
885
|
_nextTick() {
|
|
883
886
|
return nextTick();
|
|
884
887
|
}
|
|
@@ -4473,7 +4476,7 @@ class VertexAttribute extends Resource {
|
|
|
4473
4476
|
}
|
|
4474
4477
|
}
|
|
4475
4478
|
__decorateClass$W([
|
|
4476
|
-
modernIdoc.property({
|
|
4479
|
+
modernIdoc.property({ internal: true })
|
|
4477
4480
|
], VertexAttribute.prototype, "buffer");
|
|
4478
4481
|
__decorateClass$W([
|
|
4479
4482
|
modernIdoc.property({ fallback: 0 })
|
|
@@ -4867,7 +4870,7 @@ class Texture2D extends Resource {
|
|
|
4867
4870
|
}
|
|
4868
4871
|
}
|
|
4869
4872
|
__decorateClass$V([
|
|
4870
|
-
modernIdoc.property({
|
|
4873
|
+
modernIdoc.property({ internal: true })
|
|
4871
4874
|
], Texture2D.prototype, "source");
|
|
4872
4875
|
__decorateClass$V([
|
|
4873
4876
|
modernIdoc.property({ fallback: 0 })
|
|
@@ -6201,7 +6204,7 @@ __decorateClass$S([
|
|
|
6201
6204
|
modernIdoc.property({ internal: true, fallback: "default" })
|
|
6202
6205
|
], exports.Node.prototype, "internalMode", 2);
|
|
6203
6206
|
__decorateClass$S([
|
|
6204
|
-
modernIdoc.property({
|
|
6207
|
+
modernIdoc.property({ internal: true })
|
|
6205
6208
|
], exports.Node.prototype, "mask", 2);
|
|
6206
6209
|
exports.Node = __decorateClass$S([
|
|
6207
6210
|
customNode("Node")
|
|
@@ -6885,7 +6888,7 @@ exports.Effect = class Effect extends exports.TimelineNode {
|
|
|
6885
6888
|
}
|
|
6886
6889
|
};
|
|
6887
6890
|
__decorateClass$O([
|
|
6888
|
-
modernIdoc.property({
|
|
6891
|
+
modernIdoc.property({ internal: true })
|
|
6889
6892
|
], exports.Effect.prototype, "material", 2);
|
|
6890
6893
|
__decorateClass$O([
|
|
6891
6894
|
modernIdoc.property()
|
|
@@ -7019,6 +7022,7 @@ var __decorateClass$L = (decorators, target, key, kind) => {
|
|
|
7019
7022
|
return result;
|
|
7020
7023
|
};
|
|
7021
7024
|
class SceneTree extends MainLoop {
|
|
7025
|
+
fonts;
|
|
7022
7026
|
input = new Input();
|
|
7023
7027
|
renderStack = new RenderStack();
|
|
7024
7028
|
root = new exports.Window(true).setTree(this);
|
|
@@ -8902,7 +8906,7 @@ void main(void) {
|
|
|
8902
8906
|
}`
|
|
8903
8907
|
}));
|
|
8904
8908
|
__decorateClass$w([
|
|
8905
|
-
modernIdoc.property({
|
|
8909
|
+
modernIdoc.property({ internal: true })
|
|
8906
8910
|
], exports.MaskEffect.prototype, "texture", 2);
|
|
8907
8911
|
__decorateClass$w([
|
|
8908
8912
|
modernIdoc.property({ fallback: "" })
|
|
@@ -9704,9 +9708,9 @@ class BaseElement2DText extends CoreObject {
|
|
|
9704
9708
|
constructor(parent) {
|
|
9705
9709
|
super();
|
|
9706
9710
|
this.parent = parent;
|
|
9707
|
-
this.base.setPropertyAccessor(this);
|
|
9711
|
+
this.base = new modernText.Text().setPropertyAccessor(this);
|
|
9708
9712
|
}
|
|
9709
|
-
base
|
|
9713
|
+
base;
|
|
9710
9714
|
measureResult;
|
|
9711
9715
|
_textureMap = /* @__PURE__ */ new Map();
|
|
9712
9716
|
setProperties(properties) {
|
|
@@ -9730,8 +9734,12 @@ class BaseElement2DText extends CoreObject {
|
|
|
9730
9734
|
break;
|
|
9731
9735
|
}
|
|
9732
9736
|
}
|
|
9733
|
-
|
|
9737
|
+
_updateBase() {
|
|
9738
|
+
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
9734
9739
|
this.base.update();
|
|
9740
|
+
}
|
|
9741
|
+
_updateTextureMap() {
|
|
9742
|
+
this._updateBase();
|
|
9735
9743
|
this._textureMap.clear();
|
|
9736
9744
|
const pGlyphBoxs = [];
|
|
9737
9745
|
this.base.paragraphs.forEach((p, pIndex) => {
|
|
@@ -9787,6 +9795,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9787
9795
|
this.content = modernIdoc.normalizeTextContent(content);
|
|
9788
9796
|
}
|
|
9789
9797
|
measure() {
|
|
9798
|
+
this._updateBase();
|
|
9790
9799
|
return this.base.measure();
|
|
9791
9800
|
}
|
|
9792
9801
|
updateMeasure() {
|
|
@@ -9809,7 +9818,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9809
9818
|
}
|
|
9810
9819
|
draw() {
|
|
9811
9820
|
const ctx = this.parent.context;
|
|
9812
|
-
this.
|
|
9821
|
+
this._updateBase();
|
|
9813
9822
|
this.base.pathSets.forEach((pathSet) => {
|
|
9814
9823
|
pathSet.paths.forEach((path) => {
|
|
9815
9824
|
const meta = path.getMeta();
|
|
@@ -10932,7 +10941,7 @@ exports.Image2D = class Image2D extends exports.Element2D {
|
|
|
10932
10941
|
}
|
|
10933
10942
|
};
|
|
10934
10943
|
__decorateClass$i([
|
|
10935
|
-
modernIdoc.property({
|
|
10944
|
+
modernIdoc.property({ internal: true })
|
|
10936
10945
|
], exports.Image2D.prototype, "texture", 2);
|
|
10937
10946
|
__decorateClass$i([
|
|
10938
10947
|
modernIdoc.property({ fallback: "" })
|
|
@@ -14171,6 +14180,7 @@ class Engine extends SceneTree {
|
|
|
14171
14180
|
height,
|
|
14172
14181
|
pixelRatio = DEVICE_PIXEL_RATIO,
|
|
14173
14182
|
backgroundColor = 0,
|
|
14183
|
+
fonts,
|
|
14174
14184
|
autoResize,
|
|
14175
14185
|
autoStart,
|
|
14176
14186
|
timeline,
|
|
@@ -14185,6 +14195,7 @@ class Engine extends SceneTree {
|
|
|
14185
14195
|
this._setupInput();
|
|
14186
14196
|
this.pixelRatio = pixelRatio;
|
|
14187
14197
|
this.backgroundColor = backgroundColor;
|
|
14198
|
+
this.fonts = fonts;
|
|
14188
14199
|
if (autoResize) {
|
|
14189
14200
|
if (!view && this.renderer.view) {
|
|
14190
14201
|
this.renderer.view.style.width = "100%";
|
|
@@ -14335,13 +14346,14 @@ async function start(sleep = 100) {
|
|
|
14335
14346
|
starting = false;
|
|
14336
14347
|
}
|
|
14337
14348
|
async function task(options) {
|
|
14338
|
-
const {
|
|
14349
|
+
const { debug = false, fonts, width, height, time = 0, data } = options;
|
|
14339
14350
|
engine ??= new Engine({
|
|
14340
14351
|
width: 1,
|
|
14341
14352
|
height: 1,
|
|
14342
14353
|
preserveDrawingBuffer: true
|
|
14343
14354
|
});
|
|
14344
14355
|
engine.debug = debug;
|
|
14356
|
+
engine.fonts = fonts;
|
|
14345
14357
|
engine.root.removeChildren();
|
|
14346
14358
|
engine.timeline.currentTime = time;
|
|
14347
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';
|
|
@@ -256,6 +256,7 @@ interface CoreObject {
|
|
|
256
256
|
declare class CoreObject extends Reactivable {
|
|
257
257
|
readonly instanceId: number;
|
|
258
258
|
get json(): Record<string, any>;
|
|
259
|
+
set json(val: Record<string, any>);
|
|
259
260
|
protected _nextTick(): Promise<void>;
|
|
260
261
|
equal(target: CoreObject | undefined | null): boolean;
|
|
261
262
|
}
|
|
@@ -1598,6 +1599,7 @@ declare class SceneTree extends MainLoop {
|
|
|
1598
1599
|
processPaused: boolean;
|
|
1599
1600
|
backgroundColor: Color$1 | undefined;
|
|
1600
1601
|
debug: boolean;
|
|
1602
|
+
fonts?: Fonts;
|
|
1601
1603
|
readonly input: Input;
|
|
1602
1604
|
readonly renderStack: RenderStack;
|
|
1603
1605
|
readonly root: Window;
|
|
@@ -2079,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
|
|
|
2079
2081
|
constructor(parent: BaseElement2D);
|
|
2080
2082
|
setProperties(properties?: Text$1): this;
|
|
2081
2083
|
protected _updateProperty(key: string, value: any, oldValue: any): void;
|
|
2084
|
+
protected _updateBase(): void;
|
|
2082
2085
|
protected _updateTextureMap(): void;
|
|
2083
2086
|
protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
|
|
2084
2087
|
protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
|
|
@@ -3300,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
|
|
|
3300
3303
|
height?: number;
|
|
3301
3304
|
pixelRatio?: number;
|
|
3302
3305
|
backgroundColor?: Color$1;
|
|
3306
|
+
fonts?: Fonts;
|
|
3303
3307
|
autoResize?: boolean;
|
|
3304
3308
|
autoStart?: boolean;
|
|
3305
3309
|
timeline?: Timeline;
|
|
@@ -3361,6 +3365,7 @@ interface RenderOptions {
|
|
|
3361
3365
|
height: number;
|
|
3362
3366
|
debug?: boolean;
|
|
3363
3367
|
time?: number;
|
|
3368
|
+
fonts?: Fonts;
|
|
3364
3369
|
onBeforeRender?: (engine: Engine) => void | Promise<void>;
|
|
3365
3370
|
}
|
|
3366
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';
|
|
@@ -256,6 +256,7 @@ interface CoreObject {
|
|
|
256
256
|
declare class CoreObject extends Reactivable {
|
|
257
257
|
readonly instanceId: number;
|
|
258
258
|
get json(): Record<string, any>;
|
|
259
|
+
set json(val: Record<string, any>);
|
|
259
260
|
protected _nextTick(): Promise<void>;
|
|
260
261
|
equal(target: CoreObject | undefined | null): boolean;
|
|
261
262
|
}
|
|
@@ -1598,6 +1599,7 @@ declare class SceneTree extends MainLoop {
|
|
|
1598
1599
|
processPaused: boolean;
|
|
1599
1600
|
backgroundColor: Color$1 | undefined;
|
|
1600
1601
|
debug: boolean;
|
|
1602
|
+
fonts?: Fonts;
|
|
1601
1603
|
readonly input: Input;
|
|
1602
1604
|
readonly renderStack: RenderStack;
|
|
1603
1605
|
readonly root: Window;
|
|
@@ -2079,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
|
|
|
2079
2081
|
constructor(parent: BaseElement2D);
|
|
2080
2082
|
setProperties(properties?: Text$1): this;
|
|
2081
2083
|
protected _updateProperty(key: string, value: any, oldValue: any): void;
|
|
2084
|
+
protected _updateBase(): void;
|
|
2082
2085
|
protected _updateTextureMap(): void;
|
|
2083
2086
|
protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
|
|
2084
2087
|
protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
|
|
@@ -3300,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
|
|
|
3300
3303
|
height?: number;
|
|
3301
3304
|
pixelRatio?: number;
|
|
3302
3305
|
backgroundColor?: Color$1;
|
|
3306
|
+
fonts?: Fonts;
|
|
3303
3307
|
autoResize?: boolean;
|
|
3304
3308
|
autoStart?: boolean;
|
|
3305
3309
|
timeline?: Timeline;
|
|
@@ -3361,6 +3365,7 @@ interface RenderOptions {
|
|
|
3361
3365
|
height: number;
|
|
3362
3366
|
debug?: boolean;
|
|
3363
3367
|
time?: number;
|
|
3368
|
+
fonts?: Fonts;
|
|
3364
3369
|
onBeforeRender?: (engine: Engine) => void | Promise<void>;
|
|
3365
3370
|
}
|
|
3366
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';
|
|
@@ -256,6 +256,7 @@ interface CoreObject {
|
|
|
256
256
|
declare class CoreObject extends Reactivable {
|
|
257
257
|
readonly instanceId: number;
|
|
258
258
|
get json(): Record<string, any>;
|
|
259
|
+
set json(val: Record<string, any>);
|
|
259
260
|
protected _nextTick(): Promise<void>;
|
|
260
261
|
equal(target: CoreObject | undefined | null): boolean;
|
|
261
262
|
}
|
|
@@ -1598,6 +1599,7 @@ declare class SceneTree extends MainLoop {
|
|
|
1598
1599
|
processPaused: boolean;
|
|
1599
1600
|
backgroundColor: Color$1 | undefined;
|
|
1600
1601
|
debug: boolean;
|
|
1602
|
+
fonts?: Fonts;
|
|
1601
1603
|
readonly input: Input;
|
|
1602
1604
|
readonly renderStack: RenderStack;
|
|
1603
1605
|
readonly root: Window;
|
|
@@ -2079,6 +2081,7 @@ declare class BaseElement2DText extends CoreObject {
|
|
|
2079
2081
|
constructor(parent: BaseElement2D);
|
|
2080
2082
|
setProperties(properties?: Text$1): this;
|
|
2081
2083
|
protected _updateProperty(key: string, value: any, oldValue: any): void;
|
|
2084
|
+
protected _updateBase(): void;
|
|
2082
2085
|
protected _updateTextureMap(): void;
|
|
2083
2086
|
protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
|
|
2084
2087
|
protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
|
|
@@ -3300,6 +3303,7 @@ interface EngineOptions extends WebGLContextAttributes {
|
|
|
3300
3303
|
height?: number;
|
|
3301
3304
|
pixelRatio?: number;
|
|
3302
3305
|
backgroundColor?: Color$1;
|
|
3306
|
+
fonts?: Fonts;
|
|
3303
3307
|
autoResize?: boolean;
|
|
3304
3308
|
autoStart?: boolean;
|
|
3305
3309
|
timeline?: Timeline;
|
|
@@ -3361,6 +3365,7 @@ interface RenderOptions {
|
|
|
3361
3365
|
height: number;
|
|
3362
3366
|
debug?: boolean;
|
|
3363
3367
|
time?: number;
|
|
3368
|
+
fonts?: Fonts;
|
|
3364
3369
|
onBeforeRender?: (engine: Engine) => void | Promise<void>;
|
|
3365
3370
|
}
|
|
3366
3371
|
declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
|