Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const makeContext = (files: Map<string, string>) => {
const configRegistry = {} as IConfigRegistry;
return new InitContext(appContext, libraryManager, configRegistry, {
// @ts-ignore
canvas: null,
container: null,
files,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type ApplicationContext } from "../application.context";
import { BaseContext } from "./base.context";

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

this._canvas = (options as IRunClientOptions)["canvas"];
this._container = (options as IRunClientOptions)["container"];
this._files = options.files;
this._env = options.env;
this._config = configRegistry;
}

get canvas(): IRunClientOptions["canvas"] | undefined {
return this._canvas;
get container(): IRunClientOptions["container"] | undefined {
return this._container;
}

get files(): IRunOptions["files"] {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/options/types/options.type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type IRunOptions = IRunClientOptions | IRunServerOptions;

export interface IRunClientOptions {
canvas: HTMLCanvasElement;
container: HTMLDivElement;
files: Map<string, string>;
env: Record<string, string | undefined>;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-editor/src/common/context/options.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Save } from "./save.type";
export type IEditorRunOptions = IEditorRunClientOptions | IEditorRunServerOptions;

export interface IEditorRunClientOptions {
canvas: HTMLCanvasElement;
container: HTMLDivElement;
files: Map<string, string>;
env: Record<string, string | undefined>;
editor: {
Expand Down
2 changes: 1 addition & 1 deletion packages/ecs-client/test/ecs-client-library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const appContext = new EditableApplicationContext(libraryManager);
const configRegistry = {} as IConfigRegistry;
const initContext = new InitContext(appContext, libraryManager, configRegistry, {
// @ts-ignore
canvas: null,
container: null,
files: new Map([["/libecs.wasm", "./lib/libecs.wasm"]]),
});
const clearContext = new ClearContext(appContext, libraryManager);
Expand Down
2 changes: 1 addition & 1 deletion packages/ecs-server/test/ecs-server-library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const appContext = new EditableApplicationContext(libraryManager);
const configRegistry = {} as IConfigRegistry;
const initContext = new InitContext(appContext, libraryManager, configRegistry, {
// @ts-ignore
canvas: null,
container: null,
files: new Map([["/libecs.wasm", "./lib/libecs.wasm"]]),
});
const clearContext = new ClearContext(appContext, libraryManager);
Expand Down
10 changes: 5 additions & 5 deletions packages/graphics-2d/src/graphics-2d.library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export class Graphics2DLibrary extends BaseGraphicsLibrary {
}

public override async __init(context: InitContext): Promise<void> {
if (!context.canvas) {
throw new Error("Can't initialize the canvas context");
if (!context.container) {
throw new Error("Can't initialize the container context");
}
this._stage = new Graphics.Stage({
container: context.canvas.parentElement as HTMLDivElement,
width: context.canvas.offsetWidth,
height: context.canvas.offsetHeight,
container: context.container,
width: context.container.offsetWidth,
height: context.container.offsetHeight,
});
this._baseLayer = new Graphics.Layer();
this._stage.add(this._baseLayer);
Expand Down
6 changes: 3 additions & 3 deletions packages/graphics-2d/test/graphics-2d.library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { EditableApplicationContext } from "../../core/src/common/context/contex
import { EditableLibraryManager } from "../../core/src/common/library/manager/library.manager";
import { Graphics2DLibrary } from "../src";

const makeContext = (canvas: HTMLCanvasElement | null) => {
const makeContext = (container: HTMLDivElement | null) => {
const libraryManager = new EditableLibraryManager();
const appContext = new EditableApplicationContext(libraryManager);
const configRegistry = {} as IConfigRegistry;
return new InitContext(appContext, libraryManager, configRegistry, {
// @ts-ignore
canvas,
container,
files: new Map(),
});
};
Expand All @@ -38,7 +38,7 @@ describe("Graphics2DLibrary", () => {
expect(() => library.baseLayer).toThrow();
});

it("should throw when __init is called with a null canvas", async () => {
it("should throw when __init is called with a null container", async () => {
await expect(library.__init(makeContext(null))).rejects.toThrow();
});
});
Expand Down
Loading