Skip to content

Conversation

@ienaga
Copy link
Member

@ienaga ienaga commented Feb 10, 2026

player v3への対応、アトミックデザイン・MVVMの実装に合わせて、実装を変更

Copilot AI review requested due to automatic review settings February 10, 2026 06:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Next2D Framework v4.0.0として、player v3対応およびAtomic Design/MVVMの実装方針に合わせてアーキテクチャ(View/ViewModelライフサイクル、リクエスト/キャッシュ、ローディング/オーバーレイ)を刷新するPRです。

Changes:

  • View/ViewModel を抽象化し、initialize/onEnter/onExit を中心としたライフサイクルに再編(バインド/アンバインドはDomain Serviceへ移管)
  • routing に基づくリクエスト実行を RepositoryMap + 各Repository/Service に分割し、キャッシュ・コールバック処理を整理
  • ローディング/画面オーバーレイ/DefaultLoader を Domain Service/Entity として再構成し、関連のUseCaseを更新

Reviewed changes

Copilot reviewed 122 out of 126 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
vite.config.ts Vitest 実行設定に worker pool 設定を追加
tsconfig.json ビルド設定に rootDir を追加
src/view/ViewModel.ts ViewModel を抽象化し initialize() を必須化、旧 bind/unbind を削除
src/view/ViewModel.test.ts ViewModel 抽象化に合わせテストを更新/追加
src/view/View.ts View を抽象化、VM をコンストラクタ注入し lifecycle を Promise 化
src/view/View.test.ts View の抽象化・lifecycle 追加に合わせテストを更新/追加
src/shared/util/ToCamelCase.ts ルート/パス等を PascalCase へ変換する util を追加
src/shared/util/ToCamelCase.test.ts ToCamelCase のテスト追加
src/shared/util/NormalizeHttpMethod.ts HTTP method 正規化 util を追加
src/shared/util/NormalizeHttpMethod.test.ts NormalizeHttpMethod のテスト追加
src/interface/IRequestType.ts IRequestType を拡張可能な string 型に拡張
src/interface/IRequest.ts IRequest を拡充(IHttpMethod/IAccessType/callback/body 型など)
src/interface/IPackages.ts packages の型を [string, Constructor][] に再定義
src/interface/ILoading.ts loading start/end の型を関数シグネチャに改善
src/interface/IConfig.ts routing 型を Record<string, IRouting> に整理し doc を追加
src/interface/ICallback.ts Callback 実行用インターフェースを追加
src/interface/IAccessType.ts Custom request の access 型を追加
src/infrastructure/variable/Response.ts response 変数を新パスへ移動し型を unknown
src/infrastructure/variable/RepositoryMap.ts request type → repository executor の Map を追加
src/infrastructure/usecase/ResponseRemoveVariableUseCase.ts response/loaderInfoMap クリーンアップロジックを新パスへ移設/更新
src/infrastructure/usecase/ResponseRemoveVariableUseCase.test.ts UseCase のシグネチャ変更(requests 配列受け取り)に合わせ更新
src/infrastructure/usecase/RequestUseCase.ts routing 名から requests を取得し repositories を並列実行する UseCase を追加
src/infrastructure/usecase/RequestUseCase.test.ts import パス更新
src/infrastructure/service/RequestResponseProcessService.ts cache 保存 + ResponseDTO 生成の共通処理を追加
src/infrastructure/service/RequestResponseProcessService.test.ts RequestResponseProcessService のテスト追加
src/infrastructure/service/RequestCacheCheckService.ts cache ヒット時の ResponseDTO 返却サービスを追加
src/infrastructure/service/RequestCacheCheckService.test.ts RequestCacheCheckService のテスト追加
src/infrastructure/repository/JsonRepository.ts JSON fetch + cache/callback DTO 化を新 repository として追加
src/infrastructure/repository/JsonRepository.test.ts JsonRepository 用にテスト/モックを更新・エラー系を追加
src/infrastructure/repository/CustomRepository.ts packages から custom class を呼び出す repository を追加
src/infrastructure/repository/CustomRepository.test.ts CustomRepository のテスト追加
src/infrastructure/repository/ContentRepository.ts Next2D Loader/URLRequest 経由で content を取得する repository を追加
src/infrastructure/repository/ContentRepository.test.ts ContentRepository のテスト追加(Loader/URLRequest をモック)
src/infrastructure/dto/ResponseDTO.ts ResponseDTO を generic 化し callback 情報を保持
src/infrastructure/dto/ResponseDTO.test.ts ResponseDTO の新仕様(callback含む)に合わせテスト追加
src/infrastructure/Response/variable/Response.ts 旧 response 変数ファイルを削除
src/infrastructure/Response/dto/ResponseDTO.test.ts 旧 ResponseDTO テストを削除
src/infrastructure/Request/usecase/RequestUseCase.ts 旧 RequestUseCase 実装を削除(新UseCaseへ置換)
src/infrastructure/Request/repository/RequestJsonRepository.ts 旧 JSON repository を削除(新JsonRepositoryへ置換)
src/infrastructure/Request/repository/RequestCustomRepository.ts 旧 Custom repository を削除(新CustomRepositoryへ置換)
src/infrastructure/Request/repository/RequestCustomRepository.test.ts 旧 Custom repository テストを削除
src/infrastructure/Request/repository/RequestContentRepository.ts 旧 Content repository を削除(新ContentRepositoryへ置換)
src/index.ts バージョン表示を 4.0.0 に更新
src/domain/variable/Loading.ts Loading instance の型/可視性を見直し(null許容)
src/domain/service/ViewBinderService.ts View/ViewModel の生成・初期化・root 追加/削除を担うサービスを追加
src/domain/service/ViewBinderService.test.ts ViewBinderService のテスト追加
src/domain/service/ScreenOverlayService.ts 画面最前面の半透明オーバーレイを追加/削除するサービスを追加
src/domain/service/ScreenOverlayService.test.ts ScreenOverlayService のテスト追加
src/domain/service/LoadingService.ts config + packages から loader を作成/取得し start/end するサービスを追加
src/domain/service/LoadingService.test.ts LoadingService のテスト追加
src/domain/screen/Capture/service/DisposeCaptureService.ts 旧キャプチャ破棄サービスを削除(新ScreenOverlayへ統合)
src/domain/screen/Capture/service/DisposeCaptureService.test.ts 旧テスト削除
src/domain/screen/Capture/service/AddScreenCaptureService.ts 旧キャプチャ追加サービスを削除(新ScreenOverlayへ統合)
src/domain/screen/Capture/service/AddScreenCaptureService.test.ts 旧テスト削除
src/domain/screen/Capture.ts 旧キャプチャ共有変数を削除
src/domain/loading/Loading/service/LoadingStartService.ts 旧ローディング開始サービスを削除(新LoadingServiceへ統合)
src/domain/loading/Loading/service/LoadingStartService.test.ts 旧テスト削除
src/domain/loading/Loading/service/LoadingEndService.ts 旧ローディング終了サービスを削除(新LoadingServiceへ統合)
src/domain/loading/Loading/service/LoadingEndService.test.ts 旧テスト削除
src/domain/loading/DefaultLoading/service/DefaultLoadingInitializeService.ts 旧 DefaultLoader 初期化サービスを削除(Entityへ内包)
src/domain/loading/DefaultLoading/service/DefaultLoadingInitializeService.test.ts 旧テスト削除
src/domain/loading/DefaultLoading/service/DefaultLoaderStartService.ts 旧 start サービスを削除(Entityへ内包)
src/domain/loading/DefaultLoading/service/DefaultLoaderStartService.test.ts 旧テスト削除
src/domain/loading/DefaultLoading/service/DefaultLoaderEndService.ts 旧 end サービスを削除(Entityへ内包)
src/domain/loading/DefaultLoading/service/DefaultLoaderEndService.test.ts 旧テスト削除
src/domain/loading/DefaultLoader.ts 旧 DefaultLoader クラスを削除(Entityへ移動)
src/domain/entity/DefaultLoader.ts DefaultLoader を Entity として再実装(Tween job 管理を整理)
src/domain/entity/DefaultLoader.test.ts DefaultLoader(Entity) のテスト追加
src/application/variable/Query.ts query map の型を Map<string, string> に変更
src/application/variable/PopstateQueue.ts popstate の逐次実行キュー変数を追加
src/application/variable/PopstateQueue.test.ts PopstateQueue のテスト追加
src/application/variable/Packages.ts packages map の型を Constructor に揃え $setPackages を型付け
src/application/variable/Context.ts Context 未初期化時に例外を投げるよう変更
src/application/variable/Context.test.ts Context variable のテスト追加
src/application/variable/Cache.ts cache map の型を unknown に変更
src/application/usecase/ExecuteCallbackUseCase.ts callback 実行を UseCase 化し型安全性を改善
src/application/usecase/ExecuteCallbackUseCase.test.ts ExecuteCallbackUseCase のテスト更新/追加
src/application/usecase/ContextRunUseCase.ts Context 起動処理の import パス整理
src/application/usecase/ContextRunUseCase.test.ts ContextRunUseCase のテスト更新
src/application/usecase/ApplicationInitializeUseCase.ts popstate キューを PopstateQueue に移管して初期化処理を整理
src/application/usecase/ApplicationInitializeUseCase.test.ts ApplicationInitializeUseCase のテスト追加
src/application/usecase/ApplicationGotoViewUseCase.ts 画面遷移の流れを新 Request/ViewBinder/Loading/Overlay 構成へ更新
src/application/usecase/ApplicationGotoViewUseCase.test.ts ApplicationGotoViewUseCase のテスト追加
src/application/service/RoutingRequestsParserService.ts routing.requests の抽出処理を新パスへ整理
src/application/service/RoutingRequestsParserService.test.ts テストの import/名称更新
src/application/service/QueryStringParserService.ts QueryString 解析処理を整理(現状 query map 反映なし)
src/application/service/QueryStringParserService.test.ts QueryStringParserService のテスト更新
src/application/content/VideoContent.ts content 初期化呼び出しを削除し builder のみに整理
src/application/content/TextFieldContent.ts content 初期化呼び出しを削除し builder のみに整理
src/application/content/ShapeContent.ts content 初期化呼び出しを削除し builder のみに整理
src/application/content/MovieClipContent.ts content 初期化呼び出しを削除し builder のみに整理
src/application/content/Builder/service/ContentBuilderService.test.ts loaderInfoMap の初期化/分岐テスト追加
src/application/Context.ts Context の bind/unbind API を削除し単純な holder に変更
src/application/Application.ts UseCase 呼び出し構成へ更新、response/cache 型を unknown
src/application/Application.test.ts Application のテスト追加
specs/ja/config.md 設定ファイル仕様ドキュメント追加(日本語)
specs/ja/animation-tool.md AnimationTool 連携ドキュメント追加(日本語)
specs/en/routing.md ルーティング仕様ドキュメント追加(英語)
specs/en/config.md 設定ファイル仕様ドキュメント追加(英語)
specs/en/animation-tool.md AnimationTool 連携ドキュメント追加(英語)
specs/cn/routing.md ルーティング仕様ドキュメント追加(中国語)
specs/cn/config.md 設定ファイル仕様ドキュメント追加(中国語)
specs/cn/animation-tool.md AnimationTool 連携ドキュメント追加(中国語)
package.json version を 4.0.0 に更新、devDependencies を更新
.gitignore coverage を追加(package-lock の ignore を削除)
.github/workflows/publish.yml checkout/setup-node のバージョン更新と Node 24 設定等
.github/workflows/lint.yml checkout/setup-node のバージョン更新と Node 24 設定等
.github/workflows/integration.yml checkout/setup-node のバージョン更新と Node 24 設定等
Comments suppressed due to low confidence (2)

src/application/service/QueryStringParserService.ts:29

  • query Map is always cleared but never populated from either location.search or the ? portion of name. This contradicts the function’s JSDoc (“query mapに登録”) and makes query unusable for consumers. Parse queryString and fill query (or update the JSDoc and remove query if it’s no longer part of the design).
    src/infrastructure/usecase/ResponseRemoveVariableUseCase.ts:54
  • The function-level description says cached responses are not removed, but response.clear() unconditionally clears the entire response map (including entries for requests marked cache: true). If the intent is to always reset response and only preserve loaderInfoMap for cached content, please update the description to reflect that; otherwise, change the clearing logic to keep cached entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +104
it("should remove existing children before adding view", async () =>
{
$setConfig({
"platform": "web",
"spa": false,
"stage": {
"width": 800,
"height": 600,
"fps": 60
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test name says it removes existing children, but the assertions expect numChildren to increase from 2 to 3 (i.e., children are not removed). Please rename the test (or change the behavior) so the intent is clear.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +43
if (request_object.body) {
urlRequest.data = JSON.stringify(request_object.body);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRequest.body allows BodyInit, but this code always JSON.stringifys any body. That will break when body is already a string/FormData/Blob/etc. Consider either restricting body to JSON-serializable objects for content requests, or branching: if body is a string/BodyInit, pass through without stringify and set appropriate content type.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +84
const root = context.root;
if (!root) {
return;
}
root.removeChild(context.view);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing the view from root, context.view / context.viewModel are left pointing to the old instances. This can keep objects alive longer than necessary and makes it easier to accidentally use stale references. Consider setting them to null after successful unbind.

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +165
it("should remove all children and enable mouse", () =>
{
const root = new MovieClip();
$setContext(new Context(root));

root.mouseChildren = false;
root.mouseEnabled = false;
root.addChild(new Shape());
root.addChild(new Shape());

expect(root.numChildren).toBe(2);
expect(root.mouseChildren).toBe(false);
expect(root.mouseEnabled).toBe(false);
ScreenOverlayService.dispose();
expect(root.numChildren).toBe(2);
expect(root.mouseChildren).toBe(true);
expect(root.mouseEnabled).toBe(true);
});
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test name says it removes all children, but the assertions expect numChildren to remain 2 after dispose(). Rename the test to match actual behavior (removing only the overlay) to avoid confusion.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +39
if (request_object.headers) {
for (const [name, value] of Object.entries(request_object.headers)) {
urlRequest
.requestHeaders
.push({ name, value });
}
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRequest.headers is typed as HeadersInit, but Object.entries(request_object.headers) only works for plain objects. If callers pass a Headers instance or an array of tuples (also valid HeadersInit), this will fail or produce incorrect headers. Either narrow headers to Record<string, string> for this codepath, or handle all HeadersInit variants explicitly.

Copilot uses AI. Check for mistakes.
import { MovieClip } from "@next2d/display";
import { Context } from "./Context";
import { $setConfig, $getConfig } from "./variable/Config";
import { $setContext, $getContext } from "./variable/Context";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import $getContext.

Suggested change
import { $setContext, $getContext } from "./variable/Context";
import { $setContext } from "./variable/Context";

Copilot uses AI. Check for mistakes.
import { Context } from "./Context";
import { $setConfig, $getConfig } from "./variable/Config";
import { $setContext, $getContext } from "./variable/Context";
import { $setPackages, packages } from "./variable/Packages";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import $setPackages.

Suggested change
import { $setPackages, packages } from "./variable/Packages";
import { packages } from "./variable/Packages";

Copilot uses AI. Check for mistakes.
import { Context } from "../../application/Context";
import { $setContext } from "../../application/variable/Context";
import { $setConfig } from "../../application/variable/Config";
import { describe, expect, it, beforeEach, vi } from "vitest";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import vi.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,294 @@
import { ScreenOverlayService } from "./ScreenOverlayService";
import { MovieClip, Shape, BitmapData, stage } from "@next2d/display";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import BitmapData.

Copilot uses AI. Check for mistakes.
import { ScreenOverlayService } from "./ScreenOverlayService";
import { MovieClip, Shape, BitmapData, stage } from "@next2d/display";
import { Context } from "../../application/Context";
import { $setContext, $getContext } from "../../application/variable/Context";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import $getContext.

Copilot uses AI. Check for mistakes.
@ienaga ienaga merged commit 3f778a8 into main Feb 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant