modern-canvas 0.9.3 → 0.9.5
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 +20 -10
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +12 -12
- package/dist/index.mjs +20 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4476,7 +4476,7 @@ class VertexAttribute extends Resource {
|
|
|
4476
4476
|
}
|
|
4477
4477
|
}
|
|
4478
4478
|
__decorateClass$W([
|
|
4479
|
-
modernIdoc.property({
|
|
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({
|
|
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({
|
|
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({
|
|
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({
|
|
8909
|
+
modernIdoc.property({ internal: true })
|
|
8909
8910
|
], exports.MaskEffect.prototype, "texture", 2);
|
|
8910
8911
|
__decorateClass$w([
|
|
8911
8912
|
modernIdoc.property({ fallback: "" })
|
|
@@ -9707,9 +9708,10 @@ class BaseElement2DText extends CoreObject {
|
|
|
9707
9708
|
constructor(parent) {
|
|
9708
9709
|
super();
|
|
9709
9710
|
this.parent = parent;
|
|
9711
|
+
this.base = new modernText.Text();
|
|
9710
9712
|
this.base.setPropertyAccessor(this);
|
|
9711
9713
|
}
|
|
9712
|
-
base
|
|
9714
|
+
base;
|
|
9713
9715
|
measureResult;
|
|
9714
9716
|
_textureMap = /* @__PURE__ */ new Map();
|
|
9715
9717
|
setProperties(properties) {
|
|
@@ -9733,8 +9735,12 @@ class BaseElement2DText extends CoreObject {
|
|
|
9733
9735
|
break;
|
|
9734
9736
|
}
|
|
9735
9737
|
}
|
|
9736
|
-
|
|
9738
|
+
_updateBase() {
|
|
9739
|
+
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
9737
9740
|
this.base.update();
|
|
9741
|
+
}
|
|
9742
|
+
_updateTextureMap() {
|
|
9743
|
+
this._updateBase();
|
|
9738
9744
|
this._textureMap.clear();
|
|
9739
9745
|
const pGlyphBoxs = [];
|
|
9740
9746
|
this.base.paragraphs.forEach((p, pIndex) => {
|
|
@@ -9790,6 +9796,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9790
9796
|
this.content = modernIdoc.normalizeTextContent(content);
|
|
9791
9797
|
}
|
|
9792
9798
|
measure() {
|
|
9799
|
+
this._updateBase();
|
|
9793
9800
|
return this.base.measure();
|
|
9794
9801
|
}
|
|
9795
9802
|
updateMeasure() {
|
|
@@ -9812,7 +9819,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9812
9819
|
}
|
|
9813
9820
|
draw() {
|
|
9814
9821
|
const ctx = this.parent.context;
|
|
9815
|
-
this.
|
|
9822
|
+
this._updateBase();
|
|
9816
9823
|
this.base.pathSets.forEach((pathSet) => {
|
|
9817
9824
|
pathSet.paths.forEach((path) => {
|
|
9818
9825
|
const meta = path.getMeta();
|
|
@@ -10935,7 +10942,7 @@ exports.Image2D = class Image2D extends exports.Element2D {
|
|
|
10935
10942
|
}
|
|
10936
10943
|
};
|
|
10937
10944
|
__decorateClass$i([
|
|
10938
|
-
modernIdoc.property({
|
|
10945
|
+
modernIdoc.property({ internal: true })
|
|
10939
10946
|
], exports.Image2D.prototype, "texture", 2);
|
|
10940
10947
|
__decorateClass$i([
|
|
10941
10948
|
modernIdoc.property({ fallback: "" })
|
|
@@ -14174,6 +14181,7 @@ class Engine extends SceneTree {
|
|
|
14174
14181
|
height,
|
|
14175
14182
|
pixelRatio = DEVICE_PIXEL_RATIO,
|
|
14176
14183
|
backgroundColor = 0,
|
|
14184
|
+
fonts,
|
|
14177
14185
|
autoResize,
|
|
14178
14186
|
autoStart,
|
|
14179
14187
|
timeline,
|
|
@@ -14188,6 +14196,7 @@ class Engine extends SceneTree {
|
|
|
14188
14196
|
this._setupInput();
|
|
14189
14197
|
this.pixelRatio = pixelRatio;
|
|
14190
14198
|
this.backgroundColor = backgroundColor;
|
|
14199
|
+
this.fonts = fonts;
|
|
14191
14200
|
if (autoResize) {
|
|
14192
14201
|
if (!view && this.renderer.view) {
|
|
14193
14202
|
this.renderer.view.style.width = "100%";
|
|
@@ -14338,13 +14347,14 @@ async function start(sleep = 100) {
|
|
|
14338
14347
|
starting = false;
|
|
14339
14348
|
}
|
|
14340
14349
|
async function task(options) {
|
|
14341
|
-
const {
|
|
14350
|
+
const { debug = false, fonts, width, height, time = 0, data } = options;
|
|
14342
14351
|
engine ??= new Engine({
|
|
14343
14352
|
width: 1,
|
|
14344
14353
|
height: 1,
|
|
14345
14354
|
preserveDrawingBuffer: true
|
|
14346
14355
|
});
|
|
14347
14356
|
engine.debug = debug;
|
|
14357
|
+
engine.fonts = fonts;
|
|
14348
14358
|
engine.root.removeChildren();
|
|
14349
14359
|
engine.timeline.currentTime = time;
|
|
14350
14360
|
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>;
|