Skip to content

Commit

Permalink
#88 TypeScriptでの開発環境の調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Jul 4, 2023
1 parent c31b6b6 commit 253a4de
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 42 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.11",
"version": "1.5.12",
"homepage": "https://next2d.app",
"bugs": "https://github.com/Next2D/Framework/issues/new",
"author": "Toshiyuki Ienaga <ienaga@tvon.jp> (https://github.com/ienaga/)",
Expand Down
61 changes: 24 additions & 37 deletions src/application/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class Application
private readonly _$removeResponse: RemoveResponse;
private _$popstate: boolean;
private _$currentName: string;
private readonly _$promises: Promise<void>[];

/**
* @constructor
Expand All @@ -45,8 +44,6 @@ export class Application
$setConfig(config);
$setPackages(packages);

this._$promises = [$createContext(config)];

/**
* @type {QueryParser}
* @private
Expand Down Expand Up @@ -108,21 +105,20 @@ export class Application
* @private
*/
this._$currentName = "top";

// initial processing
this.initialize();
}

/**
* @description constructorが起動した後にコールされます。(初回起動時のみコールされます。)
* Called after the constructor is invoked. (Called only the first time it is invoked.)
* @description Next2Dのアプリを起動します
* Launch the Next2D application
*
* @return {void}
* @return {Application}
* @method
* @abstract
* @public
*/
// eslint-disable-next-line no-empty-function
initialize (): void {}
run ()
{
return $createContext(config);
}

/**
* @description 指定のViewを起動して、描画を開始します。引数を指定しない場合はURLをパースしてViewを起動します。
Expand All @@ -136,32 +132,23 @@ export class Application
*/
gotoView (name: string = ""): Promise<void>
{
return Promise
.all(this._$promises)
.then((): Promise<Awaited<void>[]> =>
{
// reset
if (this._$promises.length) {
this._$promises.length = 0;
}

const promises: Promise<void>[] = [];
if (config.loading) {
/**
* ローディング表示を起動
* Launch loading display
*/
this._$loading.start();

/**
* 現時点の描画をBitmapにして処理の負担を減らす
* Reduce the processing burden by making the current drawing a Bitmap.
*/
promises.push(this._$capture.execute());
}
const promises: Promise<void>[] = [];
if (config.loading) {
/**
* ローディング表示を起動
* Launch loading display
*/
this._$loading.start();

/**
* 現時点の描画をBitmapにして処理の負担を減らす
* Reduce the processing burden by making the current drawing a Bitmap.
*/
promises.push(this._$capture.execute());
}

return Promise.all(promises);
})
return Promise
.all(promises)
.then((): Promise<void> =>
{
/**
Expand Down
1 change: 0 additions & 1 deletion src/application/Context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ToCamelCase } from "../domain/convert/ToCamelCase";
import { Event } from "@next2d/events";
import { packages } from "./variable/Packages";
import type { View } from "../view/View";
import type { ViewModel } from "../view/ViewModel";
Expand Down
3 changes: 1 addition & 2 deletions src/application/variable/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export let context: Context;
*/
export const $createContext = (config: ConfigImpl): Promise<void> =>
{
return window
.next2d
return next2d
.createRootMovieClip(
config.stage.width,
config.stage.height,
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MovieClipContent } from "./application/content/MovieClipContent";
import { ShapeContent } from "./application/content/ShapeContent";
import { TextFieldContent } from "./application/content/TextFieldContent";
import { VideoContent } from "./application/content/VideoContent";
import { ConfigImpl } from "./interface/ConfigImpl";
import { packages } from "./application/variable/Packages";
import { context } from "./application/variable/Context";
import { cache } from "./application/variable/Cache";
Expand All @@ -29,6 +30,7 @@ export {
ShapeContent,
TextFieldContent,
VideoContent,
ConfigImpl,
packages,
context,
cache,
Expand Down
6 changes: 5 additions & 1 deletion src/interface/ConfigImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { RoutingImpl } from "./RoutingImpl";
import { LoadingImpl } from "./LoadingImpl";
import { GotoViewImpl } from "./GotoViewImpl";

export interface ConfigImpl {
interface BaseConfigImpl {
[key: string]: any
}

export interface ConfigImpl extends BaseConfigImpl {
platform: string;
stage: StageImpl;
routing?: {
Expand Down

0 comments on commit 253a4de

Please sign in to comment.