sonolus-deemo-engine 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +61 -0
- package/dist/EngineConfiguration +0 -0
- package/dist/EngineData +0 -0
- package/dist/Resource.cjs +20 -0
- package/dist/Resource.d.cts +9 -0
- package/dist/chart/convert.cjs +25 -0
- package/dist/chart/convert.d.cts +3 -0
- package/dist/chart/index.cjs +2 -0
- package/dist/chart/index.d.cts +15 -0
- package/dist/dc/convert.cjs +60 -0
- package/dist/dc/convert.d.cts +3 -0
- package/dist/dc/index.cjs +2 -0
- package/dist/dc/index.d.cts +20 -0
- package/dist/index.cjs +36 -0
- package/dist/index.d.cts +23 -0
- package/dist/thumbnail.png +0 -0
- package/package.json +33 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 NonSpicyBurrito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Sonolus Deemo Engine
|
|
2
|
+
|
|
3
|
+
A recreation of Deemo engine in [Sonolus](https://sonolus.com).
|
|
4
|
+
|
|
5
|
+
## Links
|
|
6
|
+
|
|
7
|
+
- [Sonolus Website](https://sonolus.com)
|
|
8
|
+
- [Sonolus Wiki](https://github.com/NonSpicyBurrito/sonolus-wiki)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npm install sonolus-deemo-engine
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
### `version`
|
|
19
|
+
|
|
20
|
+
Package version.
|
|
21
|
+
|
|
22
|
+
### `engineInfo`
|
|
23
|
+
|
|
24
|
+
Partial engine information compatible with [sonolus-express](https://github.com/NonSpicyBurrito/sonolus-express).
|
|
25
|
+
|
|
26
|
+
### `engineConfiguration`
|
|
27
|
+
|
|
28
|
+
Engine Configuration.
|
|
29
|
+
|
|
30
|
+
- `engineConfiguration.path`: path to file.
|
|
31
|
+
- `engineConfiguration.buffer`: buffer of file.
|
|
32
|
+
- `engineConfiguration.hash`: hash of file.
|
|
33
|
+
|
|
34
|
+
### `engineData`
|
|
35
|
+
|
|
36
|
+
Engine Data.
|
|
37
|
+
|
|
38
|
+
- `engineData.path`: path to file.
|
|
39
|
+
- `engineData.buffer`: buffer of file.
|
|
40
|
+
- `engineData.hash`: hash of file.
|
|
41
|
+
|
|
42
|
+
### `engineThumbnail`
|
|
43
|
+
|
|
44
|
+
Engine Thumbnail.
|
|
45
|
+
|
|
46
|
+
- `engineThumbnail.path`: path to file.
|
|
47
|
+
- `engineThumbnail.buffer`: buffer of file.
|
|
48
|
+
- `engineThumbnail.hash`: hash of file.
|
|
49
|
+
|
|
50
|
+
### `chartToDC(chart)`
|
|
51
|
+
|
|
52
|
+
Converts Deemo source chart to DC (Deemo Chart).
|
|
53
|
+
|
|
54
|
+
- `chart`: Deemo source chart.
|
|
55
|
+
|
|
56
|
+
### `dcToLevelData(dc, offset?)`
|
|
57
|
+
|
|
58
|
+
Converts DC (Deemo Chart) to Level Data.
|
|
59
|
+
|
|
60
|
+
- `dc`: Deemo chart.
|
|
61
|
+
- `offset`: offset (default: `0`).
|
|
Binary file
|
package/dist/EngineData
ADDED
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resource = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
class Resource {
|
|
8
|
+
constructor(path) {
|
|
9
|
+
this.path = (0, node_path_1.resolve)(__dirname, path);
|
|
10
|
+
}
|
|
11
|
+
get hash() {
|
|
12
|
+
this._hash ??= (0, node_crypto_1.createHash)('sha1').update(this.buffer).digest('hex');
|
|
13
|
+
return this._hash;
|
|
14
|
+
}
|
|
15
|
+
get buffer() {
|
|
16
|
+
this._buffer ??= (0, node_fs_1.readFileSync)(this.path);
|
|
17
|
+
return this._buffer;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Resource = Resource;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chartToDC = void 0;
|
|
4
|
+
const chartToDC = (chart) => {
|
|
5
|
+
const dc = [
|
|
6
|
+
{
|
|
7
|
+
type: 'bpm',
|
|
8
|
+
beat: 0,
|
|
9
|
+
bpm: 60,
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
const slideIds = chart.links.flatMap((link) => link.notes.map((note) => note.$ref));
|
|
13
|
+
for (const note of chart.notes) {
|
|
14
|
+
if (note.pos > 2)
|
|
15
|
+
continue;
|
|
16
|
+
dc.push({
|
|
17
|
+
type: slideIds.includes(note.$id) ? 'slide' : 'tap',
|
|
18
|
+
beat: note.time,
|
|
19
|
+
lane: note.pos * 4,
|
|
20
|
+
size: note.size * 2,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return dc;
|
|
24
|
+
};
|
|
25
|
+
exports.chartToDC = chartToDC;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dcToLevelData = void 0;
|
|
4
|
+
const sonolus_core_1 = require("sonolus-core");
|
|
5
|
+
const dcToLevelData = (dc, offset = 0) => {
|
|
6
|
+
const entities = [
|
|
7
|
+
{
|
|
8
|
+
archetype: 'Initialization',
|
|
9
|
+
data: [],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
archetype: 'InputManager',
|
|
13
|
+
data: [],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
archetype: 'Stage',
|
|
17
|
+
data: [],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
for (const object of dc) {
|
|
21
|
+
const { archetype, data } = handlers[object.type](object);
|
|
22
|
+
entities.push({
|
|
23
|
+
archetype,
|
|
24
|
+
data: Object.entries(data).map(([name, value]) => ({ name, value })),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
bgmOffset: offset,
|
|
29
|
+
entities,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.dcToLevelData = dcToLevelData;
|
|
33
|
+
const bpm = (object) => ({
|
|
34
|
+
archetype: sonolus_core_1.EngineArchetypeName.BpmChange,
|
|
35
|
+
data: {
|
|
36
|
+
[sonolus_core_1.EngineArchetypeDataName.Beat]: object.beat,
|
|
37
|
+
[sonolus_core_1.EngineArchetypeDataName.Bpm]: object.bpm,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const tap = (object) => ({
|
|
41
|
+
archetype: 'TapNote',
|
|
42
|
+
data: {
|
|
43
|
+
[sonolus_core_1.EngineArchetypeDataName.Beat]: object.beat,
|
|
44
|
+
lane: object.lane,
|
|
45
|
+
size: object.size,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const slide = (object) => ({
|
|
49
|
+
archetype: 'SlideNote',
|
|
50
|
+
data: {
|
|
51
|
+
[sonolus_core_1.EngineArchetypeDataName.Beat]: object.beat,
|
|
52
|
+
lane: object.lane,
|
|
53
|
+
size: object.size,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const handlers = {
|
|
57
|
+
bpm,
|
|
58
|
+
tap,
|
|
59
|
+
slide,
|
|
60
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type DC = ChartObject[];
|
|
2
|
+
export type ChartObject = BPMObject | TapNote | SlideNote;
|
|
3
|
+
type ObjectBase = {
|
|
4
|
+
beat: number;
|
|
5
|
+
};
|
|
6
|
+
export type BPMObject = ObjectBase & {
|
|
7
|
+
type: 'bpm';
|
|
8
|
+
bpm: number;
|
|
9
|
+
};
|
|
10
|
+
type NoteBase = ObjectBase & {
|
|
11
|
+
lane: number;
|
|
12
|
+
size: number;
|
|
13
|
+
};
|
|
14
|
+
export type TapNote = NoteBase & {
|
|
15
|
+
type: 'tap';
|
|
16
|
+
};
|
|
17
|
+
export type SlideNote = NoteBase & {
|
|
18
|
+
type: 'slide';
|
|
19
|
+
};
|
|
20
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.engineThumbnail = exports.engineData = exports.engineConfiguration = exports.engineInfo = exports.version = exports.dcToLevelData = exports.chartToDC = void 0;
|
|
4
|
+
const Resource_cjs_1 = require("./Resource.cjs");
|
|
5
|
+
var convert_cjs_1 = require("./chart/convert.cjs");
|
|
6
|
+
Object.defineProperty(exports, "chartToDC", { enumerable: true, get: function () { return convert_cjs_1.chartToDC; } });
|
|
7
|
+
var convert_cjs_2 = require("./dc/convert.cjs");
|
|
8
|
+
Object.defineProperty(exports, "dcToLevelData", { enumerable: true, get: function () { return convert_cjs_2.dcToLevelData; } });
|
|
9
|
+
exports.version = '1.0.0';
|
|
10
|
+
exports.engineInfo = {
|
|
11
|
+
name: 'deemo',
|
|
12
|
+
version: 8,
|
|
13
|
+
title: {
|
|
14
|
+
en: 'Deemo',
|
|
15
|
+
},
|
|
16
|
+
subtitle: {
|
|
17
|
+
en: 'Deemo',
|
|
18
|
+
},
|
|
19
|
+
author: {
|
|
20
|
+
en: 'Burrito',
|
|
21
|
+
},
|
|
22
|
+
description: {
|
|
23
|
+
en: [
|
|
24
|
+
'A recreation of Deemo engine in Sonolus.',
|
|
25
|
+
'',
|
|
26
|
+
'Version:',
|
|
27
|
+
exports.version,
|
|
28
|
+
'',
|
|
29
|
+
'GitHub Repository:',
|
|
30
|
+
'https://github.com/NonSpicyBurrito/sonolus-deemo-engine',
|
|
31
|
+
].join('\n'),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
exports.engineConfiguration = new Resource_cjs_1.Resource('EngineConfiguration');
|
|
35
|
+
exports.engineData = new Resource_cjs_1.Resource('EngineData');
|
|
36
|
+
exports.engineThumbnail = new Resource_cjs_1.Resource('thumbnail.png');
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Resource } from './Resource.cjs';
|
|
2
|
+
export { chartToDC } from './chart/convert.cjs';
|
|
3
|
+
export { dcToLevelData } from './dc/convert.cjs';
|
|
4
|
+
export declare const version = "1.0.0";
|
|
5
|
+
export declare const engineInfo: {
|
|
6
|
+
readonly name: "deemo";
|
|
7
|
+
readonly version: 8;
|
|
8
|
+
readonly title: {
|
|
9
|
+
readonly en: "Deemo";
|
|
10
|
+
};
|
|
11
|
+
readonly subtitle: {
|
|
12
|
+
readonly en: "Deemo";
|
|
13
|
+
};
|
|
14
|
+
readonly author: {
|
|
15
|
+
readonly en: "Burrito";
|
|
16
|
+
};
|
|
17
|
+
readonly description: {
|
|
18
|
+
readonly en: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const engineConfiguration: Resource;
|
|
22
|
+
export declare const engineData: Resource;
|
|
23
|
+
export declare const engineThumbnail: Resource;
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sonolus-deemo-engine",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A recreation of Deemo engine in Sonolus",
|
|
5
|
+
"author": "NonSpicyBurrito",
|
|
6
|
+
"repository": "github:NonSpicyBurrito/sonolus-deemo-engine",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"Sonolus"
|
|
10
|
+
],
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "sonolus-cli --dev",
|
|
17
|
+
"prebuild": "tsc -p . --noEmit && eslint --ext .mts ./src && eslint --ext .cts ./lib",
|
|
18
|
+
"build": "tsc -p ./lib/tsconfig.json && sonolus-cli --build && node ./lib/build.mjs"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^16.18.36",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^5.59.11",
|
|
23
|
+
"@typescript-eslint/parser": "^5.59.11",
|
|
24
|
+
"eslint": "^8.42.0",
|
|
25
|
+
"eslint-config-prettier": "^8.8.0",
|
|
26
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
27
|
+
"prettier": "^2.8.8",
|
|
28
|
+
"prettier-plugin-organize-imports": "^3.2.2",
|
|
29
|
+
"sonolus-core": "~7.0.0",
|
|
30
|
+
"sonolus.js": "~9.0.0",
|
|
31
|
+
"typescript": "~5.1.3"
|
|
32
|
+
}
|
|
33
|
+
}
|