@open-audio-stack/core 0.0.17 → 0.0.18

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.
@@ -1,3 +1,5 @@
1
+ import { PluginFile, PresetFile, ProjectFile } from '../index-browser.js';
1
2
  import { PackageValidationError, PackageValidationRec, PackageVersionType } from '../types/Package.js';
2
3
  export declare function packageRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
4
+ export declare function packageRecommendationsUrl(obj: PackageVersionType | PluginFile | PresetFile | ProjectFile, recs: PackageValidationRec[], field: string): void;
3
5
  export declare function packageValidate(pkgVersion: PackageVersionType): PackageValidationError[];
@@ -3,27 +3,17 @@ import { PackageValidation, } from '../types/Package.js';
3
3
  // TODO refactor all this using a proper validation library.
4
4
  export function packageRecommendations(pkgVersion) {
5
5
  const recs = [];
6
- // Urls
7
- if (!pkgVersion.url.startsWith('https://')) {
8
- recs.push({
9
- field: 'url',
10
- rec: 'should use https url',
11
- });
12
- }
13
- if (!pkgVersion.url.includes('github.com') && !pkgVersion.url.includes('github.io')) {
14
- recs.push({
15
- field: 'url',
16
- rec: 'should point to GitHub',
17
- });
18
- }
6
+ packageRecommendationsUrl(pkgVersion, recs, 'audio');
7
+ packageRecommendationsUrl(pkgVersion, recs, 'image');
8
+ packageRecommendationsUrl(pkgVersion, recs, 'url');
19
9
  // Image/audio previews
20
- if (pkgVersion.image && pkgVersion.image.includes('png')) {
10
+ if (pkgVersion.image && pkgVersion.image.endsWith('png')) {
21
11
  recs.push({
22
12
  field: 'image',
23
13
  rec: 'should use the jpg format',
24
14
  });
25
15
  }
26
- if (pkgVersion.audio && pkgVersion.audio.includes('wav')) {
16
+ if (pkgVersion.audio && pkgVersion.audio.endsWith('wav')) {
27
17
  recs.push({
28
18
  field: 'audio',
29
19
  rec: 'should use the flac format',
@@ -39,6 +29,7 @@ export function packageRecommendations(pkgVersion) {
39
29
  file.systems.forEach(system => {
40
30
  supportedSystems[system.type] = true;
41
31
  });
32
+ packageRecommendationsUrl(file, recs, 'url');
42
33
  });
43
34
  if (!supportedArchitectures.arm64)
44
35
  recs.push({ field: 'architectures', rec: 'should support arm64' });
@@ -63,6 +54,24 @@ export function packageRecommendations(pkgVersion) {
63
54
  }
64
55
  return recs;
65
56
  }
57
+ export function packageRecommendationsUrl(obj, recs, field) {
58
+ // @ts-expect-error indexing a field with multiple package types.
59
+ const val = obj[field];
60
+ if (typeof val !== 'string')
61
+ return;
62
+ if (!val.startsWith('https://')) {
63
+ recs.push({
64
+ field,
65
+ rec: 'should use https url',
66
+ });
67
+ }
68
+ if (!val.includes('github.com') && !val.includes('github.io')) {
69
+ recs.push({
70
+ field,
71
+ rec: 'should point to GitHub',
72
+ });
73
+ }
74
+ }
66
75
  export function packageValidate(pkgVersion) {
67
76
  const fields = [
68
77
  { name: 'audio', type: 'string' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",