museria 0.2.48 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/.eslintrc +10 -2
  2. package/.github/workflows/build.yml +3 -3
  3. package/.github/workflows/publish.yml +3 -3
  4. package/README.md +56 -60
  5. package/bin/actions.js +28 -28
  6. package/bin/index.js +4 -4
  7. package/bin/runner.js +1 -1
  8. package/bin/utils.js +6 -2
  9. package/dist/client/museria.client.js +7 -7
  10. package/dist/face/45a265d0f07b31cde85f.ttf +0 -0
  11. package/dist/face/6205fd00fb1b573e9f0f.ttf +0 -0
  12. package/dist/face/8d3cabfc66809162fb4d.woff2 +0 -0
  13. package/dist/face/fb8184add5a3101ad0a3.woff2 +0 -0
  14. package/dist/face/museria.face.js +33 -13
  15. package/dist/face/style.css +13 -11
  16. package/package.json +41 -40
  17. package/src/browser/client/index.js +2 -1
  18. package/src/browser/face/client.js +2 -1
  19. package/src/browser/face/controllers/app/app.html +77 -69
  20. package/src/browser/face/controllers/app/app.js +14 -7
  21. package/src/browser/face/controllers/app/app.scss +2 -22
  22. package/src/browser/face/index.js +3 -3
  23. package/src/browser/face/styles/main.scss +91 -11
  24. package/src/browser/face/styles/vars.scss +0 -1
  25. package/src/client.js +73 -74
  26. package/src/collection/transports/music/index.js +20 -18
  27. package/src/db/transports/database/index.js +7 -5
  28. package/src/db/transports/loki/index.js +30 -25
  29. package/src/errors.js +2 -1
  30. package/src/index.js +8 -6
  31. package/src/node.js +315 -323
  32. package/src/schema.js +27 -29
  33. package/src/server/transports/express/api/butler/controllers.js +7 -10
  34. package/src/server/transports/express/api/butler/routes.js +5 -5
  35. package/src/server/transports/express/api/master/controllers.js +7 -10
  36. package/src/server/transports/express/api/master/routes.js +5 -5
  37. package/src/server/transports/express/api/node/controllers.js +52 -61
  38. package/src/server/transports/express/api/node/routes.js +10 -10
  39. package/src/server/transports/express/api/routes.js +1 -1
  40. package/src/server/transports/express/api/slave/controllers.js +7 -10
  41. package/src/server/transports/express/api/slave/routes.js +6 -6
  42. package/src/server/transports/express/client/controllers.js +40 -61
  43. package/src/server/transports/express/client/routes.js +33 -39
  44. package/src/server/transports/express/controllers.js +10 -21
  45. package/src/server/transports/express/index.js +23 -20
  46. package/src/server/transports/express/midds.js +67 -67
  47. package/src/server/transports/express/routes.js +12 -12
  48. package/src/utils.js +175 -184
  49. package/test/client.js +311 -305
  50. package/test/db/database.js +32 -28
  51. package/test/db/loki.js +78 -74
  52. package/test/group.js +161 -156
  53. package/test/index.js +20 -10
  54. package/test/node.js +461 -460
  55. package/test/routes.js +404 -399
  56. package/test/server/express.js +35 -31
  57. package/test/services.js +25 -18
  58. package/test/tools.js +8 -6
  59. package/test/utils.js +236 -234
  60. package/webpack.client.js +9 -7
  61. package/webpack.face.js +8 -6
  62. package/dist/face/fa-brands-400.eot +0 -0
  63. package/dist/face/fa-brands-400.svg +0 -3717
  64. package/dist/face/fa-brands-400.ttf +0 -0
  65. package/dist/face/fa-brands-400.woff +0 -0
  66. package/dist/face/fa-brands-400.woff2 +0 -0
  67. package/dist/face/fa-solid-900.eot +0 -0
  68. package/dist/face/fa-solid-900.svg +0 -5034
  69. package/dist/face/fa-solid-900.ttf +0 -0
  70. package/dist/face/fa-solid-900.woff +0 -0
  71. package/dist/face/fa-solid-900.woff2 +0 -0
  72. /package/dist/face/{open-sans.ttf → 17e98b9e5586529b13cc.ttf} +0 -0
  73. /package/dist/face/{proxima-nova.ttf → 326601dfabd91e3f016c.ttf} +0 -0
  74. /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": 2019
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: [14.x, 16.x, 18.x]
12
+ node-version: [20]
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v4
15
15
  - name: Run tests with ${{ matrix.node-version }}
16
- uses: actions/setup-node@v1
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@v2
10
- - uses: actions/setup-node@v1
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-node@v4
11
11
  with:
12
- node-version: 16
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
- const Node = require('museria').Node;
9
-
10
- (async () => {
11
- try {
12
- const node = new Node({
13
- port: 4000,
14
- hostname: 'localhost'
15
- });
16
- await node.init();
17
- }
18
- catch(err) {
19
- console.error(err.stack);
20
- process.exit(1);
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
- const Client = require('museria').Client;
27
- const utils = require('museria/src/utils');
28
-
29
- (async () => {
30
- try {
31
- const client = new Client({
32
- address: 'localhost:4000'
33
- });
34
- await client.init();
35
- const title = 'Artist - Title';
36
-
37
- // Prepare the song tags
38
- await utils.addSongTags('./audio.mp3', {
39
- fullTitle: title,
40
- APIC: './cover.jpg'
41
- });
42
-
43
- // Add the song
44
- await client.addSong('./audio.mp3');
45
-
46
- // Get the song info
47
- const info = await client.getSong(title);
48
-
49
- // Find songs
50
- const songs = await client.findSongs('arti', { limit: 5 });
51
-
52
- // Find the artist songs
53
- const artistSongs = await client.findArtistSongs('artist');
54
-
55
- // Get the song audio link
56
- const audioLink = await client.getSongAudioLink(title);
57
-
58
- // Get the song cover link
59
- const coverLink = await client.getSongCoverLink(title);
60
-
61
- // Remove the song
62
- await client.removeSong(title);
63
- }
64
- catch(err) {
65
- console.error(err.stack);
66
- process.exit(1);
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=85]__ - prepared cover quality from 0 to 100. It works only when music.prepareCover is true.
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|fs.ReadStream|Buffer|Blob} __file__ - mp3 audio file
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
- const chalk = require('chalk');
2
- const argv = require('yargs').argv;
3
- const srcUtils = require('../src/utils');
4
- const utils = require('./utils');
5
- const actions = Object.assign({}, require('metastocle/bin/actions'), require('storacle/bin/actions'));
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 "${ result.title }" has been added`));
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
- if(!link) {
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
- throw new Error(`There is no song with the title ${title}`);
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
- module.exports = actions;
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
- const runner = require('./runner');
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
- module.exports = require('spreadable/bin/runner');
1
+ export { default } from "spreadable/bin/runner";
package/bin/utils.js CHANGED
@@ -1,2 +1,6 @@
1
- const utils = Object.assign({}, require('metastocle/bin/utils'), require('storacle/bin/utils'));
2
- module.exports = utils;
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;