Skip to content

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.

License

Notifications You must be signed in to change notification settings

Next2D/framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Next2D Framework

Next2D Framework

UnitTest CodeQL Lint

release Github All Releases Discord Twitter

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

Architecture

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

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

License

Security policy

Stars

Watchers

Forks

Sponsor this project