[ๆฅๆฌ่ช]
Next2D Frameworkใฏใใฏใชใผใณใขใผใญใใฏใใฃใผใใใกใคใณ้งๅ้็บใใในใ้งๅ้็บใMVVMใฎๅๅใซๅพใฃใฆ่จญ่จใใใใใๆ่ปๆงใๆกๅผตๆงใไฟๅฎๆงใซ้็นใ็ฝฎใใใขใผใญใใฏใใฃใผใจใใถใคใณๆๆณใงๅใฌใคใคใผใ็็ตๅใซไฟใคไบใๅฏ่ฝใงใใ
ๅพๆฅใฎCanvas/WebGLใขใใชใฑใผใทใงใณใงใฏๅฐ้ฃใ ใฃใURLใซใใใทใผใณ็ฎก็๏ผSPA๏ผใๅฏ่ฝใซใใใทใผใณๆฏใฎUI้็บใป็ป้ข็ขบ่ชใๅฏ่ฝใซใชใใพใใใUIๆง็ฏใซใฏใขใใใใฏใใถใคใณใๆจๅฅจใใฆใใใใณใณใใผใใณใใฎ็ดฐๅๅใๅๅฉ็จๅฏ่ฝใชใขใธใฅใผใซ่จญ่จใชใฉใๅน็็ใชUIๆง็ฏใจไฟๅฎใๅฏ่ฝใจใชใฃใฆใใพใใ
ใพใใใในใ้งๅ้็บใ้่ฆใใฆใใใใใใฆใใใใในใใ็ตฑๅใในใใUIใในใใชใฉใใใพใใพใชใฌใใซใงใในใใ่กใใชใใใ้ซๅ่ณชใชใณใผใใฎ้็บใใตใใผใใใพใใ
[English]
Next2D Framework is designed according to the principles of clean architecture, domain-driven development, test-driven development, and MVVM, with an emphasis on flexibility, scalability, and maintainability, and a design methodology that keeps each layer loosely coupled.
It is designed according to the principles of MVVM, with an architecture and design methodology that focuses on flexibility, scalability, and maintainability, and keeps each layer loosely coupled. The UI can be efficiently built and maintained by subdividing components and designing modules that can be reused.
In addition, the emphasis on test-driven development supports the development of high-quality code while testing at various levels, including unit tests, integration tests, and UI tests.
[็ฎไฝไธญๆ]
Next2Dๆกๆถๆฏๆ นๆฎ็ฎๆดๆถๆใ้ขๅ้ฉฑๅจๅผๅใๆต่ฏ้ฉฑๅจๅผๅๅMVVM็ๅๅ่ฎพ่ฎก็๏ผๅ
ถๆถๆๅ่ฎพ่ฎกๆนๆณๆณจ้็ตๆดปๆงใๅฏๆฉๅฑๆงๅๅฏ็ปดๆคๆง๏ผไฝฟๆฏไธๅฑ้ฝ่ฝไฟๆๆพๆฃ่ฆๅใ
ๅฎๅฏไปฅ้่ฟURL๏ผSPA๏ผๅฎ็ฐๅบๆฏ็ฎก็๏ผ่ฟๅจไผ ็ป็Canvas/WebGLๅบ็จ็จๅบไธญๆฏๅพ้พๅฎ็ฐ็๏ผๅนถไธๅฏไปฅไธบๆฏไธชๅบๆฏ่ฟ่กUIๅผๅๅๅฑๅนๆฃๆฅใ ่ฏฅ็ณป็ป่ฝๅคๅฎ็ฐ้ซๆ็UIๆๅปบๅ็ปดๆคใ
ๆญคๅค๏ผๅฏนๆต่ฏ้ฉฑๅจๅผๅ็ๅผบ่ฐๆฏๆ้ซ่ดจ้ไปฃ็ ็ๅผๅ๏ผๅๆถๅจๅไธชๅฑ้ข่ฟ่กๆต่ฏ๏ผๅ ๆฌๅๅ ๆต่ฏใ้ๆๆต่ฏๅUIๆต่ฏใ
src/
โโโ application/ # Application Layer
โ โโโ Application.ts # Main application class
โ โโโ Context.ts # View/ViewModel context management
โ โโโ Application/ # Application services and use cases
โ โโโ Config/ # Configuration services
โ โโโ Context/ # Context services and use cases
โ โโโ content/ # Content classes (MovieClip, Shape, TextField, Video)
โ โโโ variable/ # Application state (Config, Context, Cache, Packages, Query)
โโโ domain/ # Domain Layer
โ โโโ callback/ # Callback services
โ โโโ loading/ # Loading animation (DefaultLoader, Loading services)
โ โโโ screen/ # Screen capture services
โโโ infrastructure/ # Infrastructure Layer
โ โโโ Request/ # HTTP request handling (JSON, Content, Custom)
โ โโโ Response/ # Response data management
โโโ interface/ # TypeScript interfaces
โ โโโ IConfig.ts # Configuration interface
โ โโโ IRequest.ts # Request interface
โ โโโ IRouting.ts # Routing interface
โ โโโ ...
โโโ view/ # View Layer
โโโ View.ts # Base View class
โโโ ViewModel.ts # Base ViewModel class
[ๆฅๆฌ่ช]
ๆๆฐใใฅใผในใๆ่กๆ
ๅ ฑใฏใ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| LoadingStart[Start Loading]
LoadingCheck -->|NO| OnExit
LoadingStart --> OnExit
OnExit[Previous View: onExit] --> RemoveViewFromStage[Remove Previous View from Stage]
RemoveViewFromStage --> RemoveResponse[Remove Previous Response Data]
RemoveResponse --> 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] --> ViewModelInit[ViewModel: initialize]
ViewModelInit --> ViewInit[View: initialize]
ViewInit --> AddToStage[Add View to Stage]
AddToStage --> OnEnter[View: onEnter]
OnEnter --> CallbackCheck{use callback?<br/>Default: empty}
CallbackCheck -->|YES| CallbackStart[Start Callback]
CallbackCheck -->|NO| LoadingEndCheck
CallbackStart --> LoadingEndCheck
LoadingEndCheck{use loading?<br/>Default: true}
LoadingEndCheck -->|YES| LoadingEnd[End Loading]
LoadingEndCheck -->|NO| StartDrawing
LoadingEnd --> 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.