@open-audio-stack/core 0.0.22 → 0.0.24
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/build/Config.d.ts +2 -1
- package/build/Config.js +16 -3
- package/build/Manager.d.ts +26 -0
- package/build/Manager.js +64 -0
- package/build/Registry.d.ts +10 -12
- package/build/Registry.js +39 -19
- package/build/helpers/file.js +4 -4
- package/build/helpers/package.js +15 -1
- package/build/index-browser.d.ts +1 -0
- package/build/index-browser.js +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/types/Config.d.ts +8 -0
- package/package.json +1 -1
package/build/Config.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import { SystemType } from './types/SystemType.js';
|
|
|
13
13
|
export declare class Config {
|
|
14
14
|
config: ConfigInterface;
|
|
15
15
|
constructor(config?: ConfigInterface);
|
|
16
|
-
get(): ConfigInterface;
|
|
16
|
+
get(key?: keyof ConfigInterface): string | ConfigInterface | import("./types/Config.js").ConfigRegistry[] | undefined;
|
|
17
|
+
set(key: keyof ConfigInterface, val: any): string | ConfigInterface | import("./types/Config.js").ConfigRegistry[] | undefined;
|
|
17
18
|
architecture(type: Architecture): import("./types/Architecture.js").ArchitectureOption;
|
|
18
19
|
architectures(): import("./types/Architecture.js").ArchitectureOption[];
|
|
19
20
|
fileFormat(format: FileFormat): import("./types/FileFormat.js").FileFormatOption;
|
package/build/Config.js
CHANGED
|
@@ -12,11 +12,24 @@ import { systemTypes } from './types/SystemType.js';
|
|
|
12
12
|
export class Config {
|
|
13
13
|
config;
|
|
14
14
|
constructor(config) {
|
|
15
|
-
this.config = Object.assign({
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
this.config = Object.assign({
|
|
16
|
+
registries: [
|
|
17
|
+
{
|
|
18
|
+
name: 'Open Audio Registry',
|
|
19
|
+
url: 'https://open-audio-stack.github.io/open-audio-stack-registry',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}, config);
|
|
23
|
+
}
|
|
24
|
+
get(key) {
|
|
25
|
+
if (key)
|
|
26
|
+
return this.config[key];
|
|
18
27
|
return this.config;
|
|
19
28
|
}
|
|
29
|
+
set(key, val) {
|
|
30
|
+
this.config[key] = val;
|
|
31
|
+
return this.get(key);
|
|
32
|
+
}
|
|
20
33
|
// Architectures.
|
|
21
34
|
architecture(type) {
|
|
22
35
|
return architectures.filter(architecture => type === architecture.value)[0];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Config } from './Config.js';
|
|
2
|
+
import { Registry } from './Registry.js';
|
|
3
|
+
import { PackageVersion } from './index-browser.js';
|
|
4
|
+
import { RegistryInterface, RegistryType } from './types/Registry.js';
|
|
5
|
+
export declare class Manager {
|
|
6
|
+
registry: Registry;
|
|
7
|
+
config: Config;
|
|
8
|
+
constructor();
|
|
9
|
+
addPackages(json: RegistryInterface, type: RegistryType): void;
|
|
10
|
+
scan(type?: RegistryType): Promise<void>;
|
|
11
|
+
search(field: keyof PackageVersion, value: string | number | object, type?: RegistryType): import("./index-browser.js").RegistryPackages | {
|
|
12
|
+
plugins: import("./index-browser.js").RegistryPackages;
|
|
13
|
+
presets: import("./index-browser.js").RegistryPackages;
|
|
14
|
+
projects: import("./index-browser.js").RegistryPackages;
|
|
15
|
+
};
|
|
16
|
+
getByOrg(org: string, type?: RegistryType): import("./index-browser.js").RegistryPackages | {
|
|
17
|
+
plugins: import("./index-browser.js").RegistryPackages;
|
|
18
|
+
presets: import("./index-browser.js").RegistryPackages;
|
|
19
|
+
projects: import("./index-browser.js").RegistryPackages;
|
|
20
|
+
};
|
|
21
|
+
getBySlug(slug: string, type?: RegistryType, version?: string): import("./index-browser.js").PluginInterface | import("./index-browser.js").PresetInterface | import("./index-browser.js").ProjectInterface | {
|
|
22
|
+
plugins: import("./index-browser.js").PackageVersionType;
|
|
23
|
+
presets: import("./index-browser.js").PackageVersionType;
|
|
24
|
+
projects: import("./index-browser.js").PackageVersionType;
|
|
25
|
+
};
|
|
26
|
+
}
|
package/build/Manager.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Config } from './Config.js';
|
|
2
|
+
import { Registry } from './Registry.js';
|
|
3
|
+
import { apiJson } from './helpers/api.js';
|
|
4
|
+
import { RegistryType } from './types/Registry.js';
|
|
5
|
+
export class Manager {
|
|
6
|
+
registry;
|
|
7
|
+
config;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.config = new Config();
|
|
10
|
+
this.registry = new Registry();
|
|
11
|
+
this.scan();
|
|
12
|
+
}
|
|
13
|
+
addPackages(json, type) {
|
|
14
|
+
for (const slug in json[type]) {
|
|
15
|
+
this.registry.packageAdd(type, slug, json.plugins[slug]);
|
|
16
|
+
}
|
|
17
|
+
console.log(`${type}: ${this.registry.packages(type).length}`);
|
|
18
|
+
}
|
|
19
|
+
async scan(type) {
|
|
20
|
+
this.registry.reset();
|
|
21
|
+
const registries = this.config.get('registries');
|
|
22
|
+
for (const index in registries) {
|
|
23
|
+
const json = await apiJson(registries[index].url);
|
|
24
|
+
if (type) {
|
|
25
|
+
this.addPackages(json, type);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.addPackages(json, RegistryType.Plugins);
|
|
29
|
+
this.addPackages(json, RegistryType.Presets);
|
|
30
|
+
this.addPackages(json, RegistryType.Projects);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
search(field, value, type) {
|
|
35
|
+
if (type) {
|
|
36
|
+
return this.registry.packagesSearch(type, field, value);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
plugins: this.registry.packagesSearch(RegistryType.Plugins, field, value),
|
|
40
|
+
presets: this.registry.packagesSearch(RegistryType.Presets, field, value),
|
|
41
|
+
projects: this.registry.packagesSearch(RegistryType.Projects, field, value),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getByOrg(org, type) {
|
|
45
|
+
if (type) {
|
|
46
|
+
return this.registry.packagesOrg(type, org);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
plugins: this.registry.packagesOrg(RegistryType.Plugins, org),
|
|
50
|
+
presets: this.registry.packagesOrg(RegistryType.Presets, org),
|
|
51
|
+
projects: this.registry.packagesOrg(RegistryType.Projects, org),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
getBySlug(slug, type, version) {
|
|
55
|
+
if (type) {
|
|
56
|
+
return this.registry.packageLatest(type, slug, version);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
plugins: this.registry.packageLatest(RegistryType.Plugins, slug, version),
|
|
60
|
+
presets: this.registry.packageLatest(RegistryType.Presets, slug, version),
|
|
61
|
+
projects: this.registry.packageLatest(RegistryType.Projects, slug, version),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
package/build/Registry.d.ts
CHANGED
|
@@ -2,22 +2,20 @@ import { PackageInterface, PackageVersion, PackageVersions, PackageVersionType }
|
|
|
2
2
|
import { RegistryInterface, RegistryPackages, RegistryType } from './types/Registry.js';
|
|
3
3
|
export declare class Registry {
|
|
4
4
|
registry: RegistryInterface;
|
|
5
|
-
constructor(
|
|
6
|
-
packageAdd(slug: string,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
versions: {};
|
|
10
|
-
};
|
|
11
|
-
packageVersionAdd(slug: string, type: RegistryType, version: string, pkgVersion: PackageVersionType): void;
|
|
12
|
-
package(slug: string, type: RegistryType): PackageInterface;
|
|
5
|
+
constructor();
|
|
6
|
+
packageAdd(type: RegistryType, slug: string, pkg?: PackageInterface): PackageInterface;
|
|
7
|
+
packageVersionAdd(type: RegistryType, slug: string, version: string, pkgVersion: PackageVersionType): void;
|
|
8
|
+
package(type: RegistryType, slug: string): PackageInterface;
|
|
13
9
|
packages(type: RegistryType): RegistryPackages;
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
packagesSearch(type: RegistryType, field: keyof PackageVersion, value: string | number | object): RegistryPackages;
|
|
11
|
+
packagesOrg(type: RegistryType, match: string): RegistryPackages;
|
|
12
|
+
packageLatest(type: RegistryType, slug: string, version?: string): PackageVersionType;
|
|
16
13
|
packageVersionLatest(versions: PackageVersions): string;
|
|
17
14
|
get(): RegistryInterface;
|
|
18
15
|
name(): string;
|
|
16
|
+
reset(): void;
|
|
19
17
|
url(): string;
|
|
20
18
|
version(): string;
|
|
21
|
-
packageRemove(
|
|
22
|
-
packageVersionRemove(
|
|
19
|
+
packageRemove(type: RegistryType, slug: string): void;
|
|
20
|
+
packageVersionRemove(type: RegistryType, slug: string, version: string): void;
|
|
23
21
|
}
|
package/build/Registry.js
CHANGED
|
@@ -1,45 +1,60 @@
|
|
|
1
1
|
import * as semver from 'semver';
|
|
2
2
|
export class Registry {
|
|
3
3
|
registry;
|
|
4
|
-
constructor(
|
|
5
|
-
this.registry =
|
|
4
|
+
constructor() {
|
|
5
|
+
this.registry = {
|
|
6
|
+
name: 'Open Audio Registry',
|
|
7
|
+
plugins: {},
|
|
8
|
+
presets: {},
|
|
9
|
+
projects: {},
|
|
10
|
+
url: 'https://open-audio-stack.github.io/open-audio-stack-registry',
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
};
|
|
6
13
|
}
|
|
7
|
-
packageAdd(slug,
|
|
8
|
-
return (this.registry[type][slug] = {
|
|
14
|
+
packageAdd(type, slug, pkg) {
|
|
15
|
+
return (this.registry[type][slug] = pkg || {
|
|
9
16
|
slug,
|
|
10
17
|
version: '',
|
|
11
18
|
versions: {},
|
|
12
19
|
});
|
|
13
20
|
}
|
|
14
|
-
packageVersionAdd(
|
|
21
|
+
packageVersionAdd(type, slug, version, pkgVersion) {
|
|
15
22
|
if (!semver.valid(version))
|
|
16
23
|
throw Error(`${version} is not a valid Semantic version`);
|
|
17
|
-
let pkg = this.package(
|
|
24
|
+
let pkg = this.package(type, slug);
|
|
18
25
|
if (!pkg) {
|
|
19
|
-
pkg = this.packageAdd(
|
|
26
|
+
pkg = this.packageAdd(type, slug);
|
|
20
27
|
}
|
|
21
28
|
pkg.versions[version] = pkgVersion;
|
|
22
29
|
pkg.version = this.packageVersionLatest(pkg.versions);
|
|
23
30
|
}
|
|
24
|
-
package(
|
|
31
|
+
package(type, slug) {
|
|
25
32
|
return this.registry[type][slug];
|
|
26
33
|
}
|
|
27
34
|
packages(type) {
|
|
28
35
|
return this.registry[type];
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
const
|
|
37
|
+
packagesSearch(type, field, value) {
|
|
38
|
+
const results = {};
|
|
32
39
|
Object.keys(this.registry[type]).forEach((slug) => {
|
|
33
|
-
if (this.packageLatest(
|
|
34
|
-
|
|
40
|
+
if (this.packageLatest(type, slug)[field] === value) {
|
|
41
|
+
results[slug] = this.registry[type][slug];
|
|
35
42
|
}
|
|
36
43
|
});
|
|
37
|
-
return
|
|
44
|
+
return results;
|
|
38
45
|
}
|
|
39
|
-
|
|
46
|
+
packagesOrg(type, match) {
|
|
47
|
+
const results = {};
|
|
48
|
+
for (const slug in this.registry[type]) {
|
|
49
|
+
if (slug.startsWith(match))
|
|
50
|
+
results[slug] = this.registry[type][slug];
|
|
51
|
+
}
|
|
52
|
+
return results;
|
|
53
|
+
}
|
|
54
|
+
packageLatest(type, slug, version) {
|
|
40
55
|
if (version && !semver.valid(version))
|
|
41
56
|
throw Error(`${version} is not a valid Semantic version`);
|
|
42
|
-
const pkg = this.package(
|
|
57
|
+
const pkg = this.package(type, slug);
|
|
43
58
|
const pkgVersion = this.packageVersionLatest(pkg.versions);
|
|
44
59
|
return pkg.versions[version || pkgVersion];
|
|
45
60
|
}
|
|
@@ -58,25 +73,30 @@ export class Registry {
|
|
|
58
73
|
name() {
|
|
59
74
|
return this.registry.name;
|
|
60
75
|
}
|
|
76
|
+
reset() {
|
|
77
|
+
this.registry.plugins = {};
|
|
78
|
+
this.registry.presets = {};
|
|
79
|
+
this.registry.projects = {};
|
|
80
|
+
}
|
|
61
81
|
url() {
|
|
62
82
|
return this.registry.url;
|
|
63
83
|
}
|
|
64
84
|
version() {
|
|
65
85
|
return this.registry.version;
|
|
66
86
|
}
|
|
67
|
-
packageRemove(
|
|
87
|
+
packageRemove(type, slug) {
|
|
68
88
|
delete this.registry[type][slug];
|
|
69
89
|
}
|
|
70
|
-
packageVersionRemove(
|
|
90
|
+
packageVersionRemove(type, slug, version) {
|
|
71
91
|
if (!semver.valid(version))
|
|
72
92
|
throw Error(`${version} is not a valid Semantic version`);
|
|
73
|
-
const pkg = this.package(
|
|
93
|
+
const pkg = this.package(type, slug);
|
|
74
94
|
if (pkg && pkg.versions[version]) {
|
|
75
95
|
delete pkg.versions[version];
|
|
76
96
|
pkg.version = this.packageVersionLatest(pkg.versions);
|
|
77
97
|
}
|
|
78
98
|
if (!Object.keys(pkg.versions).length) {
|
|
79
|
-
this.packageRemove(
|
|
99
|
+
this.packageRemove(type, slug);
|
|
80
100
|
}
|
|
81
101
|
}
|
|
82
102
|
}
|
package/build/helpers/file.js
CHANGED
|
@@ -184,19 +184,19 @@ export async function fileValidateMetadata(filePath, fileMetadata) {
|
|
|
184
184
|
if (fileMetadata.sha256 !== hash) {
|
|
185
185
|
errors.push({
|
|
186
186
|
code: ZodIssueCode.invalid_type,
|
|
187
|
-
expected:
|
|
187
|
+
expected: fileMetadata.sha256,
|
|
188
188
|
message: 'Required',
|
|
189
189
|
path: ['sha256'],
|
|
190
|
-
received:
|
|
190
|
+
received: hash,
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
if (fileMetadata.size !== fileSize(filePath)) {
|
|
194
194
|
errors.push({
|
|
195
195
|
code: ZodIssueCode.invalid_type,
|
|
196
|
-
expected: String(
|
|
196
|
+
expected: String(fileMetadata.size),
|
|
197
197
|
message: 'Required',
|
|
198
198
|
path: ['size'],
|
|
199
|
-
received: String(
|
|
199
|
+
received: String(fileSize(filePath)),
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
return errors;
|
package/build/helpers/package.js
CHANGED
|
@@ -58,9 +58,9 @@ export function packageRecommendations(pkgVersion) {
|
|
|
58
58
|
rec: 'should use the flac format',
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
// Architectures/systems
|
|
62
61
|
const supportedArchitectures = {};
|
|
63
62
|
const supportedSystems = {};
|
|
63
|
+
const supportedFileFormats = {};
|
|
64
64
|
pkgVersion.files.forEach(file => {
|
|
65
65
|
file.architectures.forEach(architecture => {
|
|
66
66
|
supportedArchitectures[architecture] = true;
|
|
@@ -68,18 +68,32 @@ export function packageRecommendations(pkgVersion) {
|
|
|
68
68
|
file.systems.forEach(system => {
|
|
69
69
|
supportedSystems[system.type] = true;
|
|
70
70
|
});
|
|
71
|
+
supportedFileFormats[file.format] = true;
|
|
71
72
|
packageRecommendationsUrl(file, recs, 'url');
|
|
72
73
|
});
|
|
74
|
+
// Architectures
|
|
73
75
|
if (!supportedArchitectures.arm64)
|
|
74
76
|
recs.push({ field: 'architectures', rec: 'should support arm64' });
|
|
75
77
|
if (!supportedArchitectures.x64)
|
|
76
78
|
recs.push({ field: 'architectures', rec: 'should support x64' });
|
|
79
|
+
// Systems
|
|
77
80
|
if (!supportedSystems.linux)
|
|
78
81
|
recs.push({ field: 'systems', rec: 'should support Linux' });
|
|
79
82
|
if (!supportedSystems.mac)
|
|
80
83
|
recs.push({ field: 'systems', rec: 'should support Mac' });
|
|
81
84
|
if (!supportedSystems.win)
|
|
82
85
|
recs.push({ field: 'systems', rec: 'should support Windows' });
|
|
86
|
+
// Formats
|
|
87
|
+
if (supportedFileFormats.deb)
|
|
88
|
+
recs.push({
|
|
89
|
+
field: 'format',
|
|
90
|
+
rec: 'should support all Linux distributions, consider using AppImage or Tarball instead',
|
|
91
|
+
});
|
|
92
|
+
if (supportedFileFormats.rpm)
|
|
93
|
+
recs.push({
|
|
94
|
+
field: 'format',
|
|
95
|
+
rec: 'should support all Linux distributions, consider using AppImage or Tarball instead',
|
|
96
|
+
});
|
|
83
97
|
// Tags
|
|
84
98
|
const pluginTags = pkgVersion.tags.map(tag => tag.toLowerCase());
|
|
85
99
|
if (pluginTags.length < 2)
|
package/build/index-browser.d.ts
CHANGED
package/build/index-browser.js
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
package/build/types/Config.d.ts
CHANGED