[ๆฅๆฌ่ช]
Next2D Frameworkใฏใใฏใชใผใณใขใผใญใใฏใใฃใผใใใกใคใณ้งๅ้็บใใในใ้งๅ้็บใMVVMใฎๅๅใซๅพใฃใฆ่จญ่จใใใใใๆ่ปๆงใๆกๅผตๆงใไฟๅฎๆงใซ้็นใ็ฝฎใใใขใผใญใใฏใใฃใผใจใใถใคใณๆๆณใงๅใฌใคใคใผใ็็ตๅใซไฟใคไบใๅฏ่ฝใงใใ
ๅพๆฅใฎCanvasใขใใชใฑใผใทใงใณใงใฏๅฐ้ฃใ ใฃใURLใซใใใทใผใณ็ฎก็๏ผSPA๏ผใๅฏ่ฝใซใใใทใผใณๆฏใฎUI้็บใป็ป้ข็ขบ่ชใๅฏ่ฝใซใชใใพใใใUIๆง็ฏใซใฏใขใใใใฏใใถใคใณใๆจๅฅจใใฆใใใใณใณใใผใใณใใฎ็ดฐๅๅใๅๅฉ็จๅฏ่ฝใชใขใธใฅใผใซ่จญ่จใชใฉใๅน็็ใชUIๆง็ฏใจไฟๅฎใๅฏ่ฝใจใชใฃใฆใใพใใ
ใพใใใในใ้งๅ้็บใ้่ฆใใฆใใใใใใฆใใใใในใใ็ตฑๅใในใใUIใในใใชใฉใใใพใใพใชใฌใใซใงใในใใ่กใใชใใใ้ซๅ่ณชใชใณใผใใฎ้็บใใตใใผใใใพใใ
[English]
The Next2D Framework is designed according to principles of clean architecture, domain-driven development, test-driven development, and MVVM. Its architecture and design methodology prioritize flexibility, scalability, and maintainability, enabling loose coupling between layers.
It enables scene management via URLs (SPA), which was difficult with traditional Canvas applications, allowing UI development and screen verification per scene. We recommend Atomic Design for UI construction, enabling efficient UI development and maintenance through component granularity and reusable module design.
Furthermore, with a strong emphasis on test-driven development, it supports the creation of high-quality code by facilitating testing at various levels, including unit tests, integration tests, and UI tests.
[็ฎไฝไธญๆ]
Next2Dๆกๆถๆฏๆ นๆฎ็ฎๆดๆถๆใ้ขๅ้ฉฑๅจๅผๅใๆต่ฏ้ฉฑๅจๅผๅๅMVVM็ๅๅ่ฎพ่ฎก็๏ผๅ
ถๆถๆๅ่ฎพ่ฎกๆนๆณๆณจ้็ตๆดปๆงใๅฏๆฉๅฑๆงๅๅฏ็ปดๆคๆง๏ผไฝฟๆฏไธๅฑ้ฝ่ฝไฟๆๆพๆฃ่ฆๅใ
ๅฎๅฏไปฅ้่ฟURL๏ผSPA๏ผๅฎ็ฐๅบๆฏ็ฎก็๏ผ่ฟๅจไผ ็ป็Canvasๅบ็จ็จๅบไธญๆฏๅพ้พๅฎ็ฐ็๏ผๅนถไธๅฏไปฅไธบๆฏไธชๅบๆฏ่ฟ่กUIๅผๅๅๅฑๅนๆฃๆฅใ ่ฏฅ็ณป็ป่ฝๅคๅฎ็ฐ้ซๆ็UIๆๅปบๅ็ปดๆคใ
ๆญคๅค๏ผๅฏนๆต่ฏ้ฉฑๅจๅผๅ็ๅผบ่ฐๆฏๆ้ซ่ดจ้ไปฃ็ ็ๅผๅ๏ผๅๆถๅจๅไธชๅฑ้ข่ฟ่กๆต่ฏ๏ผๅ ๆฌๅๅ ๆต่ฏใ้ๆๆต่ฏๅUIๆต่ฏใ
src/
โโโ application/ # Application Layer
โ โโโ Application.ts # Main application class
โ โโโ Context.ts # View/ViewModel context management
โ โโโ content/ # Content classes (MovieClip, Shape, TextField, Video)
โ โโโ service/ # Application services (pure functions)
โ โ โโโ QueryStringParserService.ts
โ โ โโโ RoutingRequestsParserService.ts
โ โโโ usecase/ # Application use cases (with side effects)
โ โ โโโ ApplicationGotoViewUseCase.ts
โ โ โโโ ApplicationInitializeUseCase.ts
โ โ โโโ ContextRunUseCase.ts
โ โ โโโ ExecuteCallbackUseCase.ts
โ โโโ variable/ # Application state (Config, Context, Cache, Packages, Query)
โโโ domain/ # Domain Layer
โ โโโ entity/ # Domain entities
โ โ โโโ DefaultLoader.ts
โ โโโ service/ # Domain services
โ โ โโโ LoadingService.ts
โ โ โโโ ScreenOverlayService.ts
โ โ โโโ ViewBinderService.ts
โ โโโ variable/ # Domain state
โโโ infrastructure/ # Infrastructure Layer
โ โโโ dto/ # Data Transfer Objects
โ โ โโโ ResponseDTO.ts
โ โโโ repository/ # External data access
โ โ โโโ ContentRepository.ts
โ โ โโโ CustomRepository.ts
โ โ โโโ JsonRepository.ts
โ โโโ service/ # Infrastructure services
โ โ โโโ RequestCacheCheckService.ts
โ โ โโโ RequestResponseProcessService.ts
โ โโโ usecase/ # Infrastructure use cases
โ โ โโโ RequestUseCase.ts
โ โ โโโ ResponseRemoveVariableUseCase.ts
โ โโโ variable/ # Infrastructure state
โโโ interface/ # TypeScript interfaces
โ โโโ IConfig.ts # Configuration interface
โ โโโ IRequest.ts # Request interface
โ โโโ IRouting.ts # Routing interface
โ โโโ ...
โโโ shared/ # Shared utilities
โ โโโ util/ # Pure utility functions
โ โโโ NormalizeHttpMethod.ts
โ โโโ ParseQueryString.ts
โ โโโ ToCamelCase.ts
โโโ view/ # View Layer
โโโ View.ts # Base View class (abstract)
โโโ ViewModel.ts # Base ViewModel class (abstract)
[ๆฅๆฌ่ช]
ๆๆฐใใฅใผในใๆ่กๆ
ๅ ฑใฏใTwitterใฎ@Next2Dใๅ
ฌๅผใฎWebsiteใง็บไฟกใใฆใใใพใใฎใงใใใงใใฏใใฆใฟใฆใใ ใใใ
Next2Dใใๅฝนใซ็ซใคใใใงใใใใใใญใธใงใฏใใใๆฏๆดใใใ ใใใฐๅนธใใงใใ
[English]
Please check @Next2D on Twitter and the official website for the latest news and technical information.
If Next2D is useful to you, we hope you will support our project.
[็ฎไฝไธญๆ]
่ฏทๅจTwitterไธๆฅ็@Next2Dๅๅฎๆน็ฝ็ซ๏ผไบ่งฃๆๆฐ็ๆฐ้ปๅๆๆฏไฟกๆฏใ
ๅฆๆNext2Dๅฏนไฝ ๆ็จ๏ผๆไปฌๅธๆไฝ ่ฝๆฏๆๆไปฌ็้กน็ฎใ
npx create-next2d-app sample-app --template @next2d/framework-template
cd app-name
npm startnpx create-next2d-app sample-app --template @next2d/framework-typescript-template
cd app-name
npm start| Method | Description |
|---|---|
gotoView(name?) |
Navigate to a View. If no argument, parses URL |
getContext() |
Get the current Context |
getResponse() |
Get the response data Map |
getCache() |
Get the cache data Map |
| Method | Description |
|---|---|
initialize() |
Called after constructor |
onEnter() |
Called when View is displayed |
onExit() |
Called when View is hidden |
| Method | Description |
|---|---|
initialize() |
Called after constructor |
| Property/Method | Description |
|---|---|
view |
Current View instance |
viewModel |
Current ViewModel instance |
root |
Root Sprite on Stage |
import {
app, // Application instance
View, // Base View class
ViewModel, // Base ViewModel class
MovieClipContent, // MovieClip content from Animation Tool
ShapeContent, // Shape content from Animation Tool
TextFieldContent, // TextField content from Animation Tool
VideoContent // Video content from Animation Tool
} from "@next2d/framework";interface IConfig {
platform: string; // "web" | "app"
spa: boolean; // Enable SPA mode
defaultTop?: string; // Default top page name (default: "top")
stage: {
width: number; // Stage width
height: number; // Stage height
fps: number; // Frame rate
options?: {
base?: string;
fullScreen?: boolean;
tagId?: string;
bgColor?: string;
};
};
loading?: {
callback: string; // Loading class name
};
gotoView?: {
callback: string | string[]; // Callback after view transition
};
routing?: {
[key: string]: {
private?: boolean;
redirect?: string;
requests?: IRequest[];
};
};
}interface IRequest {
type: "json" | "content" | "custom" | "cluster";
path?: string; // URL path
name?: string; // Response key name
cache?: boolean; // Enable caching
callback?: string | string[];
// For custom type
class?: string;
access?: "static" | "instance";
method?: string;
// For HTTP requests
headers?: HeadersInit;
body?: any;
}graph TD
User([User]) -->|Request| GotoView[gotoView Path]
GotoView --> LoadingCheck{use loading?<br/>Default: true}
LoadingCheck -->|YES| ScreenOverlay[Screen Overlay]
LoadingCheck -->|NO| RemoveResponse
ScreenOverlay --> LoadingStart[Start Loading]
LoadingStart --> RemoveResponse
RemoveResponse[Remove Previous Response Data] --> ParseQuery[Parse Query String]
ParseQuery --> UpdateHistory{SPA mode?}
UpdateHistory -->|YES| PushState[Push History State]
UpdateHistory -->|NO| RequestType
PushState --> RequestType
RequestType[Request Type]
RequestType --> JSON[JSON: Get external JSON data]
RequestType --> CONTENT[CONTENT: Get Animation Tool JSON]
RequestType --> CUSTOM[CUSTOM: Request to external API]
JSON --> CacheCheck{use cache?<br/>Default: false}
CONTENT --> CacheCheck
CUSTOM --> CacheCheck
CacheCheck -->|YES| CacheData[(Cache)]
CacheCheck -->|NO| GlobalData{{Global Network}}
CacheData --> Cached{Cached?}
Cached -->|NO| GlobalData
Cached -->|YES| RegisterResponse
GlobalData --> RegisterResponse
RegisterResponse[Register Response Data] --> RequestCallback{request callback?}
RequestCallback -->|YES| ExecRequestCallback[Execute Request Callback]
RequestCallback -->|NO| UnbindView
ExecRequestCallback --> UnbindView
UnbindView[Previous View: onExit & Unbind] --> BindView[New View/ViewModel: Bind]
BindView --> ViewModelInit[ViewModel: initialize]
ViewModelInit --> ViewInit[View: initialize]
ViewInit --> AddToStage[Add View to Stage]
AddToStage --> GotoViewCallback{gotoView callback?}
GotoViewCallback -->|YES| ExecGotoViewCallback[Execute gotoView Callback]
GotoViewCallback -->|NO| LoadingEndCheck
ExecGotoViewCallback --> LoadingEndCheck
LoadingEndCheck{use loading?<br/>Default: true}
LoadingEndCheck -->|YES| LoadingEnd[End Loading]
LoadingEndCheck -->|NO| OnEnter
LoadingEnd --> DisposeOverlay[Dispose Screen Overlay]
DisposeOverlay --> OnEnter
OnEnter[View: onEnter] --> StartDrawing
StartDrawing[Start Drawing] -->|Response| User
style User fill:#d5e8d4,stroke:#82b366
style StartDrawing fill:#dae8fc,stroke:#6c8ebf
style CacheData fill:#fff2cc,stroke:#d6b656
style GlobalData fill:#f5f5f5,stroke:#666666
This project is licensed under the MIT License - see the LICENSE file for details.