museria 0.2.48 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc +10 -2
- package/.github/workflows/build.yml +3 -3
- package/.github/workflows/publish.yml +3 -3
- package/README.md +56 -60
- package/bin/actions.js +28 -28
- package/bin/index.js +4 -4
- package/bin/runner.js +1 -1
- package/bin/utils.js +6 -2
- package/dist/client/museria.client.js +7 -7
- package/dist/face/45a265d0f07b31cde85f.ttf +0 -0
- package/dist/face/6205fd00fb1b573e9f0f.ttf +0 -0
- package/dist/face/8d3cabfc66809162fb4d.woff2 +0 -0
- package/dist/face/fb8184add5a3101ad0a3.woff2 +0 -0
- package/dist/face/museria.face.js +33 -13
- package/dist/face/style.css +13 -11
- package/package.json +41 -40
- package/src/browser/client/index.js +2 -1
- package/src/browser/face/client.js +2 -1
- package/src/browser/face/controllers/app/app.html +77 -69
- package/src/browser/face/controllers/app/app.js +14 -7
- package/src/browser/face/controllers/app/app.scss +2 -22
- package/src/browser/face/index.js +3 -3
- package/src/browser/face/styles/main.scss +91 -11
- package/src/browser/face/styles/vars.scss +0 -1
- package/src/client.js +73 -74
- package/src/collection/transports/music/index.js +20 -18
- package/src/db/transports/database/index.js +7 -5
- package/src/db/transports/loki/index.js +30 -25
- package/src/errors.js +2 -1
- package/src/index.js +8 -6
- package/src/node.js +315 -323
- package/src/schema.js +27 -29
- package/src/server/transports/express/api/butler/controllers.js +7 -10
- package/src/server/transports/express/api/butler/routes.js +5 -5
- package/src/server/transports/express/api/master/controllers.js +7 -10
- package/src/server/transports/express/api/master/routes.js +5 -5
- package/src/server/transports/express/api/node/controllers.js +52 -61
- package/src/server/transports/express/api/node/routes.js +10 -10
- package/src/server/transports/express/api/routes.js +1 -1
- package/src/server/transports/express/api/slave/controllers.js +7 -10
- package/src/server/transports/express/api/slave/routes.js +6 -6
- package/src/server/transports/express/client/controllers.js +40 -61
- package/src/server/transports/express/client/routes.js +33 -39
- package/src/server/transports/express/controllers.js +10 -21
- package/src/server/transports/express/index.js +23 -20
- package/src/server/transports/express/midds.js +67 -67
- package/src/server/transports/express/routes.js +12 -12
- package/src/utils.js +175 -184
- package/test/client.js +311 -305
- package/test/db/database.js +32 -28
- package/test/db/loki.js +78 -74
- package/test/group.js +161 -156
- package/test/index.js +20 -10
- package/test/node.js +461 -460
- package/test/routes.js +404 -399
- package/test/server/express.js +35 -31
- package/test/services.js +25 -18
- package/test/tools.js +8 -6
- package/test/utils.js +236 -234
- package/webpack.client.js +9 -7
- package/webpack.face.js +8 -6
- package/dist/face/fa-brands-400.eot +0 -0
- package/dist/face/fa-brands-400.svg +0 -3717
- package/dist/face/fa-brands-400.ttf +0 -0
- package/dist/face/fa-brands-400.woff +0 -0
- package/dist/face/fa-brands-400.woff2 +0 -0
- package/dist/face/fa-solid-900.eot +0 -0
- package/dist/face/fa-solid-900.svg +0 -5034
- package/dist/face/fa-solid-900.ttf +0 -0
- package/dist/face/fa-solid-900.woff +0 -0
- package/dist/face/fa-solid-900.woff2 +0 -0
- /package/dist/face/{open-sans.ttf → 17e98b9e5586529b13cc.ttf} +0 -0
- /package/dist/face/{proxima-nova.ttf → 326601dfabd91e3f016c.ttf} +0 -0
- /package/dist/face/{logo.svg → ee9c6af64aa224827cec.svg} +0 -0
package/.eslintrc
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
{
|
2
|
+
"parser": "@babel/eslint-parser",
|
2
3
|
"parserOptions": {
|
3
|
-
"ecmaVersion":
|
4
|
+
"ecmaVersion": 2021,
|
5
|
+
"sourceType": "module",
|
6
|
+
"requireConfigFile": false,
|
7
|
+
"babelOptions": {
|
8
|
+
"plugins": [
|
9
|
+
"@babel/plugin-syntax-import-assertions"
|
10
|
+
]
|
11
|
+
}
|
4
12
|
},
|
5
13
|
"env": {
|
6
14
|
"browser": true,
|
@@ -12,4 +20,4 @@
|
|
12
20
|
"no-console": "warn"
|
13
21
|
},
|
14
22
|
"globals": {}
|
15
|
-
}
|
23
|
+
}
|
@@ -9,11 +9,11 @@ jobs:
|
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
node-version: [
|
12
|
+
node-version: [20]
|
13
13
|
steps:
|
14
|
-
- uses: actions/checkout@
|
14
|
+
- uses: actions/checkout@v4
|
15
15
|
- name: Run tests with ${{ matrix.node-version }}
|
16
|
-
uses: actions/setup-node@
|
16
|
+
uses: actions/setup-node@v4
|
17
17
|
with:
|
18
18
|
node-version: ${{ matrix.node-version }}
|
19
19
|
- run: npm install -g npm
|
@@ -6,10 +6,10 @@ jobs:
|
|
6
6
|
publish:
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
steps:
|
9
|
-
- uses: actions/checkout@
|
10
|
-
- uses: actions/setup-node@
|
9
|
+
- uses: actions/checkout@v4
|
10
|
+
- uses: actions/setup-node@v4
|
11
11
|
with:
|
12
|
-
node-version:
|
12
|
+
node-version: 20
|
13
13
|
- run: npm install -g npm
|
14
14
|
- run: npm ci
|
15
15
|
- run: npm ddp
|
package/README.md
CHANGED
@@ -5,67 +5,63 @@ Museria is a decentralized music storage based on [spreadable](https://github.co
|
|
5
5
|
There is [an article here](https://ortex.medium.com/museria-a-decentralized-music-storage-dc2041a5f196) with an explanation.
|
6
6
|
|
7
7
|
```javascript
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
|
-
})();
|
8
|
+
import { Node } from 'museria';
|
9
|
+
|
10
|
+
try {
|
11
|
+
const node = new Node({
|
12
|
+
port: 4000,
|
13
|
+
hostname: 'localhost'
|
14
|
+
});
|
15
|
+
await node.init();
|
16
|
+
}
|
17
|
+
catch(err) {
|
18
|
+
console.error(err.stack);
|
19
|
+
process.exit(1);
|
20
|
+
}
|
23
21
|
```
|
24
22
|
|
25
23
|
```javascript
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
68
|
-
})();
|
24
|
+
import { Client } from 'museria';
|
25
|
+
import utils from 'museria/src/utils.js';
|
26
|
+
|
27
|
+
try {
|
28
|
+
const client = new Client({
|
29
|
+
address: 'localhost:4000'
|
30
|
+
});
|
31
|
+
await client.init();
|
32
|
+
const title = 'Artist - Title';
|
33
|
+
|
34
|
+
// Prepare the song tags
|
35
|
+
await utils.addSongTags('./audio.mp3', {
|
36
|
+
fullTitle: title,
|
37
|
+
APIC: './cover.jpg'
|
38
|
+
});
|
39
|
+
|
40
|
+
// Add the song
|
41
|
+
await client.addSong('./audio.mp3');
|
42
|
+
|
43
|
+
// Get the song info
|
44
|
+
const info = await client.getSong(title);
|
45
|
+
|
46
|
+
// Find songs
|
47
|
+
const songs = await client.findSongs('arti', { limit: 5 });
|
48
|
+
|
49
|
+
// Find the artist songs
|
50
|
+
const artistSongs = await client.findArtistSongs('artist');
|
51
|
+
|
52
|
+
// Get the song audio link
|
53
|
+
const audioLink = await client.getSongAudioLink(title);
|
54
|
+
|
55
|
+
// Get the song cover link
|
56
|
+
const coverLink = await client.getSongCoverLink(title);
|
57
|
+
|
58
|
+
// Remove the song
|
59
|
+
await client.removeSong(title);
|
60
|
+
}
|
61
|
+
catch(err) {
|
62
|
+
console.error(err.stack);
|
63
|
+
process.exit(1);
|
64
|
+
}
|
69
65
|
```
|
70
66
|
|
71
67
|
## Browser client
|
@@ -132,7 +128,7 @@ When you create an instance of the node you can pass options below. Only specifi
|
|
132
128
|
|
133
129
|
* {boolean} __[music.prepareCover=true]__ - prepare the cover before addition or not. Preparation means bringing the size and image quality to the right values.
|
134
130
|
|
135
|
-
* {integer} __[music.coverQuality=
|
131
|
+
* {integer} __[music.coverQuality=80]__ - prepared cover quality from 0 to 100. It works only when music.prepareCover is true.
|
136
132
|
|
137
133
|
* {integer} __[music.coverMinSize=200]__ - minimum cover size in px. It works only when music.prepareCover is true.
|
138
134
|
|
@@ -145,7 +141,7 @@ When you create an instance of the node you can pass options below. Only specifi
|
|
145
141
|
## Client interface
|
146
142
|
|
147
143
|
async __Client.prototype.addSong()__ - add the file to the network.
|
148
|
-
* {string|
|
144
|
+
* {string|fse.ReadStream|Buffer|Blob} __file__ - mp3 audio file
|
149
145
|
* {object} __[options]__ - addition options
|
150
146
|
* {number} __[options.timeout]__ - addition timeout
|
151
147
|
* {integer} __[options.priority=0]__ - song priority -1, 1 or 0
|
package/bin/actions.js
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import chalk from "chalk";
|
2
|
+
import yargs from "yargs";
|
3
|
+
import srcUtils from "../src/utils.js";
|
4
|
+
import utils from "./utils.js";
|
5
|
+
import mtActions from "metastocle/bin/actions.js";
|
6
|
+
import stActions from "storacle/bin/actions.js";
|
7
|
+
|
8
|
+
const argv = yargs(process.argv).argv;
|
9
|
+
const actions = Object.assign({}, mtActions, stActions);
|
6
10
|
|
7
11
|
/**
|
8
12
|
* Clean up the music
|
9
13
|
*/
|
10
|
-
actions.cleanUpMusic = async node => {
|
14
|
+
actions.cleanUpMusic = async (node) => {
|
11
15
|
await node.cleanUpMusic();
|
12
16
|
//eslint-disable-next-line no-console
|
13
17
|
console.log(chalk.cyan('The music has been cleaned up'));
|
@@ -16,7 +20,7 @@ actions.cleanUpMusic = async node => {
|
|
16
20
|
/**
|
17
21
|
* Export all songs to another node
|
18
22
|
*/
|
19
|
-
actions.exportSongs = async node => {
|
23
|
+
actions.exportSongs = async (node) => {
|
20
24
|
await node.exportSongs(argv.address || argv.n);
|
21
25
|
//eslint-disable-next-line no-console
|
22
26
|
console.log(chalk.cyan('The songs have been exported'));
|
@@ -25,24 +29,22 @@ actions.exportSongs = async node => {
|
|
25
29
|
/**
|
26
30
|
* Add the song
|
27
31
|
*/
|
28
|
-
actions.addSong = async node => {
|
32
|
+
actions.addSong = async (node) => {
|
29
33
|
const filePath = utils.getAbsolutePath(argv.filePath || argv.f);
|
30
34
|
const result = await node.addSong(filePath);
|
31
35
|
//eslint-disable-next-line no-console
|
32
|
-
console.log(chalk.cyan(`The song "${
|
36
|
+
console.log(chalk.cyan(`The song "${result.title}" has been added`));
|
33
37
|
};
|
34
38
|
|
35
39
|
/**
|
36
40
|
* Get the song audio link
|
37
41
|
*/
|
38
|
-
actions.getSongAudioLink = async node => {
|
42
|
+
actions.getSongAudioLink = async (node) => {
|
39
43
|
const title = argv.title || argv.t;
|
40
44
|
const link = await node.getSongAudioLink(title);
|
41
|
-
|
42
|
-
|
43
|
-
throw new Error(`There is no song with the title ${title}`);
|
45
|
+
if (!link) {
|
46
|
+
throw new Error(`There is no song with the title ${title}`);
|
44
47
|
}
|
45
|
-
|
46
48
|
//eslint-disable-next-line no-console
|
47
49
|
console.log(chalk.cyan(`The song audio link is "${link}"`));
|
48
50
|
};
|
@@ -50,11 +52,11 @@ actions.getSongAudioLink = async node => {
|
|
50
52
|
/**
|
51
53
|
* Get the song cover link
|
52
54
|
*/
|
53
|
-
actions.getSongCoverLink = async node => {
|
55
|
+
actions.getSongCoverLink = async (node) => {
|
54
56
|
const title = argv.title || argv.t;
|
55
57
|
const link = await node.getSongCoverLink(title);
|
56
58
|
|
57
|
-
if(!link) {
|
59
|
+
if (!link) {
|
58
60
|
throw new Error(`There is no song with the title ${title}`);
|
59
61
|
}
|
60
62
|
|
@@ -65,17 +67,16 @@ actions.getSongCoverLink = async node => {
|
|
65
67
|
/**
|
66
68
|
* Get the song audio to the path
|
67
69
|
*/
|
68
|
-
actions.getSongAudioToPath = async node => {
|
70
|
+
actions.getSongAudioToPath = async (node) => {
|
69
71
|
const title = argv.title || argv.t;
|
70
72
|
const filePath = utils.getAbsolutePath(argv.filePath || argv.f);
|
71
73
|
const link = await node.getSongAudioLink(title);
|
72
|
-
|
73
|
-
if(!link) {
|
74
|
-
throw new Error(`There is no song with the title ${title}`);
|
74
|
+
|
75
|
+
if (!link) {
|
76
|
+
throw new Error(`There is no song with the title ${title}`);
|
75
77
|
}
|
76
78
|
|
77
79
|
await srcUtils.fetchFileToPath(filePath, link, node.createDefaultRequestOptions());
|
78
|
-
|
79
80
|
//eslint-disable-next-line no-console
|
80
81
|
console.log(chalk.cyan(`The song "${title}" has been saved to "${filePath}"`));
|
81
82
|
};
|
@@ -83,17 +84,16 @@ actions.getSongAudioToPath = async node => {
|
|
83
84
|
/**
|
84
85
|
* Get the song cover to the path
|
85
86
|
*/
|
86
|
-
actions.getSongCoverToPath = async node => {
|
87
|
+
actions.getSongCoverToPath = async (node) => {
|
87
88
|
const title = argv.title || argv.t;
|
88
89
|
const filePath = utils.getAbsolutePath(argv.filePath || argv.f);
|
89
90
|
const link = await node.getSongCoverLink(title);
|
90
91
|
|
91
|
-
if(!link) {
|
92
|
-
|
92
|
+
if (!link) {
|
93
|
+
throw new Error(`There is no song with the title ${title}`);
|
93
94
|
}
|
94
|
-
|
95
|
+
|
95
96
|
await srcUtils.fetchFileToPath(filePath, link, node.createDefaultRequestOptions());
|
96
|
-
|
97
97
|
//eslint-disable-next-line no-console
|
98
98
|
console.log(chalk.cyan(`The song "${title}" has been saved to "${filePath}"`));
|
99
99
|
};
|
@@ -101,11 +101,11 @@ actions.getSongCoverToPath = async node => {
|
|
101
101
|
/**
|
102
102
|
* Remove the song
|
103
103
|
*/
|
104
|
-
actions.removeSong = async node => {
|
104
|
+
actions.removeSong = async (node) => {
|
105
105
|
const title = argv.title || argv.t;
|
106
106
|
await node.removeSong(title);
|
107
107
|
//eslint-disable-next-line no-console
|
108
108
|
console.log(chalk.cyan(`The song "${title}" has been removed`));
|
109
109
|
};
|
110
110
|
|
111
|
-
|
111
|
+
export default actions;
|
package/bin/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
+
import runner from "./runner.js";
|
3
|
+
import { Node } from "../src/index.js";
|
4
|
+
import actions from "./actions.js";
|
2
5
|
|
3
|
-
|
4
|
-
const Node = require('../src').Node;
|
5
|
-
const actions = require('./actions');
|
6
|
-
runner('museria', Node, actions);
|
6
|
+
runner('museria', Node, actions);
|
package/bin/runner.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
export { default } from "spreadable/bin/runner";
|
package/bin/utils.js
CHANGED
@@ -1,2 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import mtUtils from "metastocle/bin/utils.js";
|
2
|
+
import stUtils from "storacle/bin/utils.js";
|
3
|
+
|
4
|
+
const utils = Object.assign({}, mtUtils, stUtils);
|
5
|
+
|
6
|
+
export default utils;
|