Skip to content

Commit

Permalink
#88 TypeScriptでの開発環境の調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Jun 22, 2023
1 parent e7992c0 commit e09d8fe
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next2d/framework",
"description": "It is a framework dedicated to Next2D that enables scene management by URL (SPA), which has been difficult with conventional Canvas/WebGL applications, and simplifies readability and shareability by fixing the development pattern (MVVM).",
"version": "1.5.6",
"version": "1.5.7",
"homepage": "https://next2d.app",
"bugs": "https://github.com/Next2D/Framework/issues/new",
"author": "Toshiyuki Ienaga <ienaga@tvon.jp>",
Expand Down
14 changes: 8 additions & 6 deletions src/application/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { packages } from "./variable/Packages";
import type { View } from "../view/View";
import type { ViewModel } from "../view/ViewModel";
import type { Sprite } from "@next2d/player/dist/player/next2d/display/Sprite";
import type { ViewImpl } from "../interface/ViewImpl";
import type { ViewModelImpl } from "../interface/ViewModelImpl";

/**
* メインコンテキスト、ViewとViewModelのunbind、bindをコントロールします。
Expand All @@ -13,8 +15,8 @@ import type { Sprite } from "@next2d/player/dist/player/next2d/display/Sprite";
*/
export class Context
{
private _$view: View | null;
private _$viewModel: ViewModel | null;
private _$view: ViewImpl<any> | null;
private _$viewModel: ViewModelImpl<any> | null;
private _$viewName: string;
private readonly _$root: Sprite;
private readonly _$toCamelCase: ToCamelCase;
Expand Down Expand Up @@ -84,7 +86,7 @@ export class Context
* @readonly
* @public
*/
get view (): View | null
get view (): ViewImpl<any> | null
{
return this._$view;
}
Expand All @@ -98,7 +100,7 @@ export class Context
* @readonly
* @public
*/
get viewModel (): ViewModel | null
get viewModel (): ViewModelImpl<any> | null
{
return this._$viewModel;
}
Expand Down Expand Up @@ -126,7 +128,7 @@ export class Context
* @method
* @public
*/
addChild (name: string): Promise<View | void>
addChild (name: string): Promise<ViewImpl<any> | void>
{
this._$viewName = this._$toCamelCase.execute(name);

Expand All @@ -146,7 +148,7 @@ export class Context
const ViewClass: typeof View = packages.get(viewName);
this._$view = new ViewClass();

this._$view.addEventListener(Event.REMOVED, (event: any) =>
this._$view.addEventListener(Event.REMOVED, (event: Event) =>
{
if (this._$viewModel) {
this._$viewModel.unbind(event.target);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { response } from "./application/variable/Response";
import { loaderInfoMap } from "./application/variable/LoaderInfoMap";

// output build version
console.log("%c Next2D Framework %c 1.5.6 %c https://next2d.app",
console.log("%c Next2D Framework %c 1.5.7 %c https://next2d.app",

Check warning on line 18 in src/index.ts

View workflow job for this annotation

GitHub Actions / windows-browser-test

Unexpected console statement

Check warning on line 18 in src/index.ts

View workflow job for this annotation

GitHub Actions / windows-browser-test

Unexpected console statement
"color: #fff; background: #5f5f5f",
"color: #fff; background: #4bc729",
"");
Expand Down
3 changes: 3 additions & 0 deletions src/interface/ViewImpl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { View } from "../view/View";

export type ViewImpl<T extends View> = T;
3 changes: 3 additions & 0 deletions src/interface/ViewModelImpl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ViewModel } from "../view/ViewModel";

export type ViewModelImpl<T extends ViewModel> = T;
8 changes: 4 additions & 4 deletions src/view/ViewModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { View } from "./View";
import type { ViewImpl } from "../interface/ViewImpl";

/**
* ViewModelの親クラス、抽象クラスとして存在しています。
Expand All @@ -18,7 +18,7 @@ export class ViewModel
* @method
* @abstract
*/
bind (view: View): Promise<View>
bind (view: ViewImpl<any>): Promise<ViewImpl<any>>
{
return this.factory(view);
}
Expand All @@ -33,7 +33,7 @@ export class ViewModel
* @public
*/
// eslint-disable-next-line no-unused-vars,no-empty-function
unbind (view: View): void {}
unbind (view: ViewImpl<any>): void {}

/**
* @description bind関数で非同期で処理を開始する共通関数です。
Expand All @@ -44,7 +44,7 @@ export class ViewModel
* @method
* @public
*/
factory (view: View): Promise<View>
factory (view: ViewImpl<any>): Promise<ViewImpl<any>>
{
return new Promise((resolve) =>
{
Expand Down

0 comments on commit e09d8fe

Please sign in to comment.