Skip to content

Commit 6ea75f4

Browse files
authored
fix(render): change specific container canva for general html div (#323)
1 parent aee8da7 commit 6ea75f4

8 files changed

Lines changed: 17 additions & 17 deletions

File tree

packages/asset-manager/test/asset-manager.library.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const makeContext = (files: Map<string, string>) => {
1111
const configRegistry = {} as IConfigRegistry;
1212
return new InitContext(appContext, libraryManager, configRegistry, {
1313
// @ts-ignore
14-
canvas: null,
14+
container: null,
1515
files,
1616
});
1717
};

packages/common/src/context/contexts/executions/init.context.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type ApplicationContext } from "../application.context";
44
import { BaseContext } from "./base.context";
55

66
export class InitContext extends BaseContext {
7-
private readonly _canvas: IRunClientOptions["canvas"] | undefined;
7+
private readonly _container: IRunClientOptions["container"] | undefined;
88
private readonly _files: IRunOptions["files"];
99
private readonly _env: Record<string, string | undefined>;
1010
private readonly _config: IConfigRegistry;
@@ -17,14 +17,14 @@ export class InitContext extends BaseContext {
1717
) {
1818
super(context, libraryManager);
1919

20-
this._canvas = (options as IRunClientOptions)["canvas"];
20+
this._container = (options as IRunClientOptions)["container"];
2121
this._files = options.files;
2222
this._env = options.env;
2323
this._config = configRegistry;
2424
}
2525

26-
get canvas(): IRunClientOptions["canvas"] | undefined {
27-
return this._canvas;
26+
get container(): IRunClientOptions["container"] | undefined {
27+
return this._container;
2828
}
2929

3030
get files(): IRunOptions["files"] {

packages/common/src/options/types/options.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export type IRunOptions = IRunClientOptions | IRunServerOptions;
22

33
export interface IRunClientOptions {
4-
canvas: HTMLCanvasElement;
4+
container: HTMLDivElement;
55
files: Map<string, string>;
66
env: Record<string, string | undefined>;
77
}

packages/core-editor/src/common/context/options.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type Save } from "./save.type";
44
export type IEditorRunOptions = IEditorRunClientOptions | IEditorRunServerOptions;
55

66
export interface IEditorRunClientOptions {
7-
canvas: HTMLCanvasElement;
7+
container: HTMLDivElement;
88
files: Map<string, string>;
99
env: Record<string, string | undefined>;
1010
editor: {

packages/ecs-client/test/ecs-client-library.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const appContext = new EditableApplicationContext(libraryManager);
3333
const configRegistry = {} as IConfigRegistry;
3434
const initContext = new InitContext(appContext, libraryManager, configRegistry, {
3535
// @ts-ignore
36-
canvas: null,
36+
container: null,
3737
files: new Map([["/libecs.wasm", "./lib/libecs.wasm"]]),
3838
});
3939
const clearContext = new ClearContext(appContext, libraryManager);

packages/ecs-server/test/ecs-server-library.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const appContext = new EditableApplicationContext(libraryManager);
3333
const configRegistry = {} as IConfigRegistry;
3434
const initContext = new InitContext(appContext, libraryManager, configRegistry, {
3535
// @ts-ignore
36-
canvas: null,
36+
container: null,
3737
files: new Map([["/libecs.wasm", "./lib/libecs.wasm"]]),
3838
});
3939
const clearContext = new ClearContext(appContext, libraryManager);

packages/graphics-2d/src/graphics-2d.library.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export class Graphics2DLibrary extends BaseGraphicsLibrary {
2121
}
2222

2323
public override async __init(context: InitContext): Promise<void> {
24-
if (!context.canvas) {
25-
throw new Error("Can't initialize the canvas context");
24+
if (!context.container) {
25+
throw new Error("Can't initialize the container context");
2626
}
2727
this._stage = new Graphics.Stage({
28-
container: context.canvas.parentElement as HTMLDivElement,
29-
width: context.canvas.offsetWidth,
30-
height: context.canvas.offsetHeight,
28+
container: context.container,
29+
width: context.container.offsetWidth,
30+
height: context.container.offsetHeight,
3131
});
3232
this._baseLayer = new Graphics.Layer();
3333
this._stage.add(this._baseLayer);

packages/graphics-2d/test/graphics-2d.library.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { EditableApplicationContext } from "../../core/src/common/context/contex
55
import { EditableLibraryManager } from "../../core/src/common/library/manager/library.manager";
66
import { Graphics2DLibrary } from "../src";
77

8-
const makeContext = (canvas: HTMLCanvasElement | null) => {
8+
const makeContext = (container: HTMLDivElement | null) => {
99
const libraryManager = new EditableLibraryManager();
1010
const appContext = new EditableApplicationContext(libraryManager);
1111
const configRegistry = {} as IConfigRegistry;
1212
return new InitContext(appContext, libraryManager, configRegistry, {
1313
// @ts-ignore
14-
canvas,
14+
container,
1515
files: new Map(),
1616
});
1717
};
@@ -38,7 +38,7 @@ describe("Graphics2DLibrary", () => {
3838
expect(() => library.baseLayer).toThrow();
3939
});
4040

41-
it("should throw when __init is called with a null canvas", async () => {
41+
it("should throw when __init is called with a null container", async () => {
4242
await expect(library.__init(makeContext(null))).rejects.toThrow();
4343
});
4444
});

0 commit comments

Comments
 (0)