Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

306 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Next2D Framework

Next2D Framework

UnitTest CodeQL Lint

release Github All Releases Discord Twitter

[ๆ—ฅๆœฌ่ชž]
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ๆต‹่ฏ•ใ€‚

Architecture

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)

Support

[ๆ—ฅๆœฌ่ชž]
ๆœ€ๆ–ฐใƒ‹ใƒฅใƒผใ‚นใ‚„ๆŠ€่ก“ๆƒ…ๅ ฑใฏใ€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ๅฏนไฝ ๆœ‰็”จ๏ผŒๆˆ‘ไปฌๅธŒๆœ›ไฝ ่ƒฝๆ”ฏๆŒๆˆ‘ไปฌ็š„้กน็›ฎใ€‚

Quick Start - JavaScript Development Environment

npx create-next2d-app sample-app --template @next2d/framework-template
cd app-name
npm start

Quick Start - TypeScript Development Environment

npx create-next2d-app sample-app --template @next2d/framework-typescript-template
cd app-name
npm start

API Reference

Application

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

View Lifecycle

Method Description
initialize() Called after constructor
onEnter() Called when View is displayed
onExit() Called when View is hidden

ViewModel Lifecycle

Method Description
initialize() Called after constructor

Context

Property/Method Description
view Current View instance
viewModel Current ViewModel instance
root Root Sprite on Stage

Exported Classes

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";

Configuration

IConfig

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[];
        };
    };
}

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;
}

Flowchart

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
Loading

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

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.

Topics

Resources

Security policy

Stars

38 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages