Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#88 TypeScriptでの開発環境の調整 #108

Merged
merged 2 commits into from
Jul 4, 2023
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
9 changes: 7 additions & 2 deletions __tests__/application/ApplicationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { $createContext } from "../../src/application/variable/Context";

describe("ApplicationTest", () =>
{
test("initialize test", () => {
test("run test", () => {

const config = {
"platform": "web",
Expand All @@ -34,7 +34,12 @@ describe("ApplicationTest", () =>

const app = new Application(config, packages);

expect(app.initialize()).toBe(undefined);
app
.run()
.then(() =>
{
expect(app instanceof Application).toBe(true);
});
});

test("loading test", () =>
Expand Down
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 {Promise}
* @method
* @abstract
* @public
*/
// eslint-disable-next-line no-empty-function
initialize (): void {}
run (): Promise<void>
{
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
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 { 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 @@ -15,7 +16,7 @@
import { loaderInfoMap } from "./application/variable/LoaderInfoMap";

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

Check warning on line 19 in src/index.ts

View workflow job for this annotation

GitHub Actions / windows-browser-test

Unexpected console statement

Check warning on line 19 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 All @@ -29,6 +30,7 @@
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