Skip to content

Commit 3f778a8

Browse files
authored
Merge pull request #156 from Next2D/develop
v4.0.0
2 parents 1aff053 + 20acb99 commit 3f778a8

126 files changed

Lines changed: 13292 additions & 2087 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/integration.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ jobs:
1717
contents: read
1818
pull-requests: write
1919
steps:
20-
- uses: actions/setup-node@v5
21-
- uses: actions/checkout@v5
20+
- uses: actions/setup-node@v6
21+
with:
22+
node-version: 24
23+
registry-url: "https://registry.npmjs.org"
24+
- uses: actions/checkout@v6
2225
with:
2326
repository: Next2D/player
2427
ref: main
28+
- run: npm install -g npm@latest
2529
- run: npm install
2630
- run: npm run test
2731

@@ -31,11 +35,14 @@ jobs:
3135
contents: read
3236
pull-requests: write
3337
steps:
34-
- uses: actions/setup-node@v5
35-
- uses: actions/checkout@v5
38+
- uses: actions/setup-node@v6
39+
with:
40+
node-version: 24
41+
registry-url: "https://registry.npmjs.org"
42+
- uses: actions/checkout@v6
3643
with:
3744
repository: Next2D/player
3845
ref: main
46+
- run: npm install -g npm@latest
3947
- run: npm install
40-
- run: npm run test
41-
48+
- run: npm run test

.github/workflows/lint.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ jobs:
1717
contents: read
1818
pull-requests: write
1919
steps:
20-
- uses: actions/checkout@v5
21-
- uses: actions/setup-node@v5
20+
- uses: actions/checkout@v6
21+
- uses: actions/setup-node@v6
22+
with:
23+
node-version: 24
24+
registry-url: "https://registry.npmjs.org"
25+
- run: npm install -g npm@latest
2226
- run: npm install
2327
- run: npx eslint ./src/**/*.ts
2428

@@ -28,7 +32,11 @@ jobs:
2832
contents: read
2933
pull-requests: write
3034
steps:
31-
- uses: actions/checkout@v5
32-
- uses: actions/setup-node@v5
35+
- uses: actions/checkout@v6
36+
- uses: actions/setup-node@v6
37+
with:
38+
node-version: 24
39+
registry-url: "https://registry.npmjs.org"
40+
- run: npm install -g npm@latest
3341
- run: npm install
3442
- run: npx eslint ./src/**/*.ts

.github/workflows/publish.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
id-token: write
10+
contents: read
11+
812
jobs:
9-
build:
13+
publish:
1014
runs-on: ubuntu-latest
11-
permissions:
12-
contents: read
13-
pull-requests: write
1415
steps:
15-
- uses: actions/checkout@v5
16-
- uses: actions/setup-node@v5
16+
- uses: actions/checkout@v6
17+
- uses: actions/setup-node@v6
1718
with:
18-
node-version: "22.x"
19+
node-version: 24
1920
registry-url: "https://registry.npmjs.org"
21+
- run: npm install -g npm@latest
2022
- run: npm run create:package
2123
- run: npm install
2224
- run: npm run release
23-
- run: cd ~/work/framework/framework/dist && npm publish --access public
24-
env:
25-
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
25+
- run: npm publish
26+
working-directory: ./dist

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ dist-ssr
2323
*.sln
2424
*.sw?
2525

26-
package-lock.json
26+
coverage

Framework_Flowchart.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 236 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Next2D Framework
55
</div>
66

77
[![UnitTest](https://github.com/Next2D/Framework/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/Next2D/Framework/actions/workflows/integration.yml)
8-
[![CodeQL](https://github.com/Next2D/Framework/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/Next2D/Framework/actions/workflows/codeql-analysis.yml)
8+
[![CodeQL](https://github.com/Next2D/framework/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/Next2D/framework/actions/workflows/github-code-scanning/codeql)
99
[![Lint](https://github.com/Next2D/Framework/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/Next2D/Framework/actions/workflows/lint.yml)
1010

1111
[![release](https://img.shields.io/github/v/release/Next2D/Framework)](https://github.com/Next2D/Framework/releases)
@@ -16,23 +16,78 @@ Next2D Framework
1616
[日本語]
1717
Next2D Frameworkは、クリーンアーキテクチャー、ドメイン駆動開発、テスト駆動開発、MVVMの原則に従って設計されおり、柔軟性、拡張性、保守性に重点を置いたアーキテクチャーとデザイン手法で各レイヤーを疎結合に保つ事が可能です。
1818

19-
従来のCanvas/WebGLアプリケーションでは困難だったURLによるシーン管理(SPA)を可能にし、シーン毎のUI開発・画面確認が可能になりました。UI構築にはアトミックデザインを推奨しており、コンポーネントの細分化、再利用可能なモジュール設計など、効率的なUI構築と保守が可能となっています。
19+
従来のCanvasアプリケーションでは困難だったURLによるシーン管理(SPA)を可能にし、シーン毎のUI開発・画面確認が可能になりました。UI構築にはアトミックデザインを推奨しており、コンポーネントの細分化、再利用可能なモジュール設計など、効率的なUI構築と保守が可能となっています。
2020

2121
また、テスト駆動開発を重視しているため、ユニットテスト、統合テスト、UIテストなど、さまざまなレベルでテストを行いながら、高品質なコードの開発をサポートします。
2222

2323
[English]
24-
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.
24+
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.
2525

26-
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.
27-
28-
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.
26+
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.
27+
28+
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.
2929

3030
[简体中文]
3131
Next2D框架是根据简洁架构、领域驱动开发、测试驱动开发和MVVM的原则设计的,其架构和设计方法注重灵活性、可扩展性和可维护性,使每一层都能保持松散耦合。
3232

33-
它可以通过URL(SPA)实现场景管理,这在传统的Canvas/WebGL应用程序中是很难实现的,并且可以为每个场景进行UI开发和屏幕检查。 该系统能够实现高效的UI构建和维护。
33+
它可以通过URL(SPA)实现场景管理,这在传统的Canvas应用程序中是很难实现的,并且可以为每个场景进行UI开发和屏幕检查。 该系统能够实现高效的UI构建和维护。
3434

3535
此外,对测试驱动开发的强调支持高质量代码的开发,同时在各个层面进行测试,包括单元测试、集成测试和UI测试。
36+
37+
## Architecture
38+
39+
```
40+
src/
41+
├── application/ # Application Layer
42+
│ ├── Application.ts # Main application class
43+
│ ├── Context.ts # View/ViewModel context management
44+
│ ├── content/ # Content classes (MovieClip, Shape, TextField, Video)
45+
│ ├── service/ # Application services (pure functions)
46+
│ │ ├── QueryStringParserService.ts
47+
│ │ └── RoutingRequestsParserService.ts
48+
│ ├── usecase/ # Application use cases (with side effects)
49+
│ │ ├── ApplicationGotoViewUseCase.ts
50+
│ │ ├── ApplicationInitializeUseCase.ts
51+
│ │ ├── ContextRunUseCase.ts
52+
│ │ └── ExecuteCallbackUseCase.ts
53+
│ └── variable/ # Application state (Config, Context, Cache, Packages, Query)
54+
├── domain/ # Domain Layer
55+
│ ├── entity/ # Domain entities
56+
│ │ └── DefaultLoader.ts
57+
│ ├── service/ # Domain services
58+
│ │ ├── LoadingService.ts
59+
│ │ ├── ScreenOverlayService.ts
60+
│ │ └── ViewBinderService.ts
61+
│ └── variable/ # Domain state
62+
├── infrastructure/ # Infrastructure Layer
63+
│ ├── dto/ # Data Transfer Objects
64+
│ │ └── ResponseDTO.ts
65+
│ ├── repository/ # External data access
66+
│ │ ├── ContentRepository.ts
67+
│ │ ├── CustomRepository.ts
68+
│ │ └── JsonRepository.ts
69+
│ ├── service/ # Infrastructure services
70+
│ │ ├── RequestCacheCheckService.ts
71+
│ │ └── RequestResponseProcessService.ts
72+
│ ├── usecase/ # Infrastructure use cases
73+
│ │ ├── RequestUseCase.ts
74+
│ │ └── ResponseRemoveVariableUseCase.ts
75+
│ └── variable/ # Infrastructure state
76+
├── interface/ # TypeScript interfaces
77+
│ ├── IConfig.ts # Configuration interface
78+
│ ├── IRequest.ts # Request interface
79+
│ ├── IRouting.ts # Routing interface
80+
│ └── ...
81+
├── shared/ # Shared utilities
82+
│ └── util/ # Pure utility functions
83+
│ ├── NormalizeHttpMethod.ts
84+
│ ├── ParseQueryString.ts
85+
│ └── ToCamelCase.ts
86+
└── view/ # View Layer
87+
├── View.ts # Base View class (abstract)
88+
└── ViewModel.ts # Base ViewModel class (abstract)
89+
```
90+
3691
## Support
3792

3893
[日本語]
@@ -69,8 +124,180 @@ cd app-name
69124
npm start
70125
```
71126

72-
## Flowchart
73-
![Flowchart](./Framework_Flowchart.svg)
127+
## API Reference
128+
129+
### Application
130+
131+
| Method | Description |
132+
|--------|-------------|
133+
| `gotoView(name?)` | Navigate to a View. If no argument, parses URL |
134+
| `getContext()` | Get the current Context |
135+
| `getResponse()` | Get the response data Map |
136+
| `getCache()` | Get the cache data Map |
137+
138+
### View Lifecycle
139+
140+
| Method | Description |
141+
|--------|-------------|
142+
| `initialize()` | Called after constructor |
143+
| `onEnter()` | Called when View is displayed |
144+
| `onExit()` | Called when View is hidden |
145+
146+
### ViewModel Lifecycle
147+
148+
| Method | Description |
149+
|--------|-------------|
150+
| `initialize()` | Called after constructor |
151+
152+
### Context
153+
154+
| Property/Method | Description |
155+
|-----------------|-------------|
156+
| `view` | Current View instance |
157+
| `viewModel` | Current ViewModel instance |
158+
| `root` | Root Sprite on Stage |
159+
160+
### Exported Classes
161+
162+
```typescript
163+
import {
164+
app, // Application instance
165+
View, // Base View class
166+
ViewModel, // Base ViewModel class
167+
MovieClipContent, // MovieClip content from Animation Tool
168+
ShapeContent, // Shape content from Animation Tool
169+
TextFieldContent, // TextField content from Animation Tool
170+
VideoContent // Video content from Animation Tool
171+
} from "@next2d/framework";
172+
```
173+
174+
## Configuration
175+
176+
### IConfig
177+
178+
```typescript
179+
interface IConfig {
180+
platform: string; // "web" | "app"
181+
spa: boolean; // Enable SPA mode
182+
defaultTop?: string; // Default top page name (default: "top")
183+
stage: {
184+
width: number; // Stage width
185+
height: number; // Stage height
186+
fps: number; // Frame rate
187+
options?: {
188+
base?: string;
189+
fullScreen?: boolean;
190+
tagId?: string;
191+
bgColor?: string;
192+
};
193+
};
194+
loading?: {
195+
callback: string; // Loading class name
196+
};
197+
gotoView?: {
198+
callback: string | string[]; // Callback after view transition
199+
};
200+
routing?: {
201+
[key: string]: {
202+
private?: boolean;
203+
redirect?: string;
204+
requests?: IRequest[];
205+
};
206+
};
207+
}
208+
```
209+
210+
### IRequest
211+
212+
```typescript
213+
interface IRequest {
214+
type: "json" | "content" | "custom" | "cluster";
215+
path?: string; // URL path
216+
name?: string; // Response key name
217+
cache?: boolean; // Enable caching
218+
callback?: string | string[];
219+
// For custom type
220+
class?: string;
221+
access?: "static" | "instance";
222+
method?: string;
223+
// For HTTP requests
224+
headers?: HeadersInit;
225+
body?: any;
226+
}
227+
```
228+
229+
## Flowchart
230+
231+
```mermaid
232+
graph TD
233+
User([User]) -->|Request| GotoView[gotoView Path]
234+
235+
GotoView --> LoadingCheck{use loading?<br/>Default: true}
236+
237+
LoadingCheck -->|YES| ScreenOverlay[Screen Overlay]
238+
LoadingCheck -->|NO| RemoveResponse
239+
ScreenOverlay --> LoadingStart[Start Loading]
240+
LoadingStart --> RemoveResponse
241+
242+
RemoveResponse[Remove Previous Response Data] --> ParseQuery[Parse Query String]
243+
ParseQuery --> UpdateHistory{SPA mode?}
244+
245+
UpdateHistory -->|YES| PushState[Push History State]
246+
UpdateHistory -->|NO| RequestType
247+
PushState --> RequestType
248+
249+
RequestType[Request Type]
250+
251+
RequestType --> JSON[JSON: Get external JSON data]
252+
RequestType --> CONTENT[CONTENT: Get Animation Tool JSON]
253+
RequestType --> CUSTOM[CUSTOM: Request to external API]
254+
255+
JSON --> CacheCheck{use cache?<br/>Default: false}
256+
CONTENT --> CacheCheck
257+
CUSTOM --> CacheCheck
258+
259+
CacheCheck -->|YES| CacheData[(Cache)]
260+
CacheCheck -->|NO| GlobalData{{Global Network}}
261+
262+
CacheData --> Cached{Cached?}
263+
264+
Cached -->|NO| GlobalData
265+
Cached -->|YES| RegisterResponse
266+
GlobalData --> RegisterResponse
267+
268+
RegisterResponse[Register Response Data] --> RequestCallback{request callback?}
269+
270+
RequestCallback -->|YES| ExecRequestCallback[Execute Request Callback]
271+
RequestCallback -->|NO| UnbindView
272+
ExecRequestCallback --> UnbindView
273+
274+
UnbindView[Previous View: onExit & Unbind] --> BindView[New View/ViewModel: Bind]
275+
BindView --> ViewModelInit[ViewModel: initialize]
276+
277+
ViewModelInit --> ViewInit[View: initialize]
278+
ViewInit --> AddToStage[Add View to Stage]
279+
AddToStage --> GotoViewCallback{gotoView callback?}
280+
281+
GotoViewCallback -->|YES| ExecGotoViewCallback[Execute gotoView Callback]
282+
GotoViewCallback -->|NO| LoadingEndCheck
283+
ExecGotoViewCallback --> LoadingEndCheck
284+
285+
LoadingEndCheck{use loading?<br/>Default: true}
286+
287+
LoadingEndCheck -->|YES| LoadingEnd[End Loading]
288+
LoadingEndCheck -->|NO| OnEnter
289+
LoadingEnd --> DisposeOverlay[Dispose Screen Overlay]
290+
DisposeOverlay --> OnEnter
291+
292+
OnEnter[View: onEnter] --> StartDrawing
293+
294+
StartDrawing[Start Drawing] -->|Response| User
295+
296+
style User fill:#d5e8d4,stroke:#82b366
297+
style StartDrawing fill:#dae8fc,stroke:#6c8ebf
298+
style CacheData fill:#fff2cc,stroke:#d6b656
299+
style GlobalData fill:#f5f5f5,stroke:#666666
300+
```
74301

75302
## License
76303
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)