@potatosalad775/eqcaps-client 0.1.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 +21 -0
- package/README.md +39 -0
- package/dist/cache.d.ts +27 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +21 -0
- package/dist/cache.js.map +1 -0
- package/dist/client.d.ts +54 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +218 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/match.d.ts +54 -0
- package/dist/match.d.ts.map +1 -0
- package/dist/match.js +76 -0
- package/dist/match.js.map +1 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 potatosalad775
|
|
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,39 @@
|
|
|
1
|
+
# @potatosalad775/eqcaps-client
|
|
2
|
+
|
|
3
|
+
Fetches, caches and matches [eqcaps](https://github.com/potatosalad775/eqcaps) EQ constraint
|
|
4
|
+
profiles. Zero runtime dependencies besides `@potatosalad775/eqcaps-core`, no DOM types, works in
|
|
5
|
+
browsers, Node and WebViews.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createClient, webStorageStore } from '@potatosalad775/eqcaps-client';
|
|
9
|
+
import { fit, complete, validateList } from '@potatosalad775/eqcaps-core';
|
|
10
|
+
|
|
11
|
+
const client = createClient({ store: webStorageStore(localStorage) });
|
|
12
|
+
|
|
13
|
+
// What WebHID (or a native USB plugin) reports for the connected device.
|
|
14
|
+
const { best, matches } = await client.matchDevice({
|
|
15
|
+
usb: { vendorId: device.vendorId, productId: device.productId, productName: device.productName }
|
|
16
|
+
});
|
|
17
|
+
const profile = best && (await client.loadProfile(best.id));
|
|
18
|
+
if (profile) {
|
|
19
|
+
const problems = validateList(profile, filters); // while editing: flag, don't rewrite
|
|
20
|
+
const result = fit(profile, filters, preamp); // before writing: what to send
|
|
21
|
+
const slots = complete(profile, result.slots).filters; // every slot, neutral fillers included
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- **Never throws, never blocks.** Every failure (offline, HTTP error, malformed data, a full
|
|
26
|
+
cache) resolves to `null` or no matches and is reported to `onError`. The app keeps working
|
|
27
|
+
without constraints.
|
|
28
|
+
- **Caching.** `index.json` and `bundle.json` are fresh for `ttl` (default 24 h), then revalidated
|
|
29
|
+
with their ETag. Profiles are cached by the `sha256` the index lists for them. The store is
|
|
30
|
+
pluggable: `memoryStore()` (default), `webStorageStore(localStorage)`, or your own `CacheStore`.
|
|
31
|
+
- **Offline.** Pass an embedded `bundle.json` as `snapshot`; it answers whenever neither the network
|
|
32
|
+
nor the cache can.
|
|
33
|
+
- **Matching** follows the format's specificity rules: `best` is set only for a unique top match.
|
|
34
|
+
On a tie (`ambiguous`), let the user choose. Deprecated profiles never match.
|
|
35
|
+
|
|
36
|
+
The default `baseUrl` is the pre-freeze channel `NEXT_URL`
|
|
37
|
+
(`https://potatosalad775.github.io/eqcaps/next/`). The format is a draft until it is frozen as v1.
|
|
38
|
+
|
|
39
|
+
License: MIT. The data it fetches is CC0-1.0.
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A cached response. */
|
|
2
|
+
export interface CacheEntry {
|
|
3
|
+
body: string;
|
|
4
|
+
etag?: string;
|
|
5
|
+
/** Epoch ms of the last time the server confirmed this body (200 or 304). */
|
|
6
|
+
fetchedAt: number;
|
|
7
|
+
/** For profiles: the index sha256 this body was fetched under. */
|
|
8
|
+
sha256?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where the client keeps responses between sessions. Sync or async; failures are caught and
|
|
12
|
+
* treated as a cache miss, so a full or broken store never breaks the host app.
|
|
13
|
+
*/
|
|
14
|
+
export interface CacheStore {
|
|
15
|
+
get(key: string): CacheEntry | undefined | Promise<CacheEntry | undefined>;
|
|
16
|
+
set(key: string, entry: CacheEntry): void | Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** In-memory store, the default. Lives as long as the client. */
|
|
19
|
+
export declare function memoryStore(): CacheStore;
|
|
20
|
+
/** The part of the Web Storage API the client needs (localStorage, sessionStorage). */
|
|
21
|
+
export interface WebStorageLike {
|
|
22
|
+
getItem(key: string): string | null;
|
|
23
|
+
setItem(key: string, value: string): void;
|
|
24
|
+
}
|
|
25
|
+
/** A store on top of localStorage or anything shaped like it. Keys are prefixed. */
|
|
26
|
+
export declare function webStorageStore(storage: WebStorageLike, prefix?: string): CacheStore;
|
|
27
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAC3E,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,iEAAiE;AACjE,wBAAgB,WAAW,IAAI,UAAU,CAMxC;AAED,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAY,GAAG,UAAU,CAUvF"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** In-memory store, the default. Lives as long as the client. */
|
|
2
|
+
export function memoryStore() {
|
|
3
|
+
const map = new Map();
|
|
4
|
+
return {
|
|
5
|
+
get: (key) => map.get(key),
|
|
6
|
+
set: (key, entry) => void map.set(key, entry)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/** A store on top of localStorage or anything shaped like it. Keys are prefixed. */
|
|
10
|
+
export function webStorageStore(storage, prefix = 'eqcaps:') {
|
|
11
|
+
return {
|
|
12
|
+
get(key) {
|
|
13
|
+
const raw = storage.getItem(prefix + key);
|
|
14
|
+
return raw === null ? undefined : JSON.parse(raw);
|
|
15
|
+
},
|
|
16
|
+
set(key, entry) {
|
|
17
|
+
storage.setItem(prefix + key, JSON.stringify(entry));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAmBA,iEAAiE;AACjE,MAAM,UAAU,WAAW;IAC1B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC1C,OAAO;QACN,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;QAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;KAC7C,CAAC;AACH,CAAC;AAQD,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,OAAuB,EAAE,MAAM,GAAG,SAAS;IAC1E,OAAO;QACN,GAAG,CAAC,GAAG;YACN,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;YAC1C,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;QACnE,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,KAAK;YACb,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type DataBundle, type DataIndex, type IndexEntry, type Profile } from '@potatosalad775/eqcaps-core';
|
|
2
|
+
import { type CacheStore } from './cache.ts';
|
|
3
|
+
import { type DeviceIdentity, type MatchResult } from './match.ts';
|
|
4
|
+
/** Pre-freeze channel (SPEC §14). Becomes the default until v1 is published. */
|
|
5
|
+
export declare const NEXT_URL = "https://potatosalad775.github.io/eqcaps/next/";
|
|
6
|
+
/** Frozen v1 channel, published from the format freeze on (PLAN Phase 4). */
|
|
7
|
+
export declare const V1_URL = "https://potatosalad775.github.io/eqcaps/v1/";
|
|
8
|
+
/** The subset of `fetch` the client uses. */
|
|
9
|
+
export type FetchLike = (url: string, init: {
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
status: number;
|
|
13
|
+
ok: boolean;
|
|
14
|
+
headers: {
|
|
15
|
+
get(name: string): string | null;
|
|
16
|
+
};
|
|
17
|
+
text(): Promise<string>;
|
|
18
|
+
}>;
|
|
19
|
+
export interface ClientOptions {
|
|
20
|
+
/** Channel URL, ending in `/`. Default NEXT_URL. */
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
/** Default `globalThis.fetch`. */
|
|
23
|
+
fetch?: FetchLike;
|
|
24
|
+
/** Default an in-memory store. Use webStorageStore(localStorage) to persist. */
|
|
25
|
+
store?: CacheStore;
|
|
26
|
+
/** How long index.json and bundle.json count as fresh, in ms. Default 24 h. */
|
|
27
|
+
ttl?: number;
|
|
28
|
+
/** Per request, in ms. Default 10 s. */
|
|
29
|
+
timeout?: number;
|
|
30
|
+
/**
|
|
31
|
+
* An embedded bundle.json, used when neither the network nor the cache has an answer, so the
|
|
32
|
+
* app works offline and without the CDN (invariant 8).
|
|
33
|
+
*/
|
|
34
|
+
snapshot?: DataBundle;
|
|
35
|
+
/** Every failure is reported here and nowhere else; the client never throws. */
|
|
36
|
+
onError?: (error: unknown, context: string) => void;
|
|
37
|
+
/** Clock, for tests. */
|
|
38
|
+
now?: () => number;
|
|
39
|
+
}
|
|
40
|
+
export interface EqcapsClient {
|
|
41
|
+
/**
|
|
42
|
+
* index.json, from cache while fresh, revalidated with its ETag after. Falls back to a stale
|
|
43
|
+
* cache, then to an index derived from the snapshot (its entries have `sha256: ''`), then null.
|
|
44
|
+
*/
|
|
45
|
+
loadIndex(): Promise<DataIndex | null>;
|
|
46
|
+
/** One flat profile, cached by its index sha256. Null when unavailable. */
|
|
47
|
+
loadProfile(id: string): Promise<Profile | null>;
|
|
48
|
+
/** bundle.json, cached like the index. Falls back to the snapshot, then null. */
|
|
49
|
+
loadBundle(): Promise<DataBundle | null>;
|
|
50
|
+
/** matchDevice over the index (SPEC §3). No matches when nothing could be loaded. */
|
|
51
|
+
matchDevice(identity: DeviceIdentity): Promise<MatchResult<IndexEntry>>;
|
|
52
|
+
}
|
|
53
|
+
export declare function createClient(options?: ClientOptions): EqcapsClient;
|
|
54
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhF,gFAAgF;AAChF,eAAO,MAAM,QAAQ,kDAAkD,CAAC;AACxE,6EAA6E;AAC7E,eAAO,MAAM,MAAM,gDAAgD,CAAC;AAEpE,6CAA6C;AAC7C,MAAM,MAAM,SAAS,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM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@ -0,0 +1,218 @@
|
|
|
1
|
+
import { indexFields } from '@potatosalad775/eqcaps-core';
|
|
2
|
+
import { memoryStore } from "./cache.js";
|
|
3
|
+
import { matchDevice } from "./match.js";
|
|
4
|
+
/** Pre-freeze channel (SPEC §14). Becomes the default until v1 is published. */
|
|
5
|
+
export const NEXT_URL = 'https://potatosalad775.github.io/eqcaps/next/';
|
|
6
|
+
/** Frozen v1 channel, published from the format freeze on (PLAN Phase 4). */
|
|
7
|
+
export const V1_URL = 'https://potatosalad775.github.io/eqcaps/v1/';
|
|
8
|
+
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
9
|
+
/** Lenient check (SPEC §15): major version 1 and the fields a consumer relies on. */
|
|
10
|
+
const supported = (v) => typeof v === 'string' && /^1\.\d+$/.test(v);
|
|
11
|
+
function readIndex(v) {
|
|
12
|
+
if (!isObject(v) || !supported(v.schemaVersion) || !Array.isArray(v.profiles))
|
|
13
|
+
return null;
|
|
14
|
+
const profiles = v.profiles.filter((e) => isObject(e) && typeof e.id === 'string' && typeof e.path === 'string');
|
|
15
|
+
return { ...v, profiles };
|
|
16
|
+
}
|
|
17
|
+
function readProfile(v) {
|
|
18
|
+
if (!isObject(v) ||
|
|
19
|
+
!supported(v.schemaVersion) ||
|
|
20
|
+
typeof v.id !== 'string' ||
|
|
21
|
+
!isObject(v.band) ||
|
|
22
|
+
!isObject(v.device) ||
|
|
23
|
+
!isObject(v.meta) ||
|
|
24
|
+
!(v.bandCount === null || typeof v.bandCount === 'number')) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
function readBundle(v) {
|
|
30
|
+
if (!isObject(v) || !supported(v.schemaVersion) || !Array.isArray(v.profiles))
|
|
31
|
+
return null;
|
|
32
|
+
const profiles = v.profiles.map(readProfile).filter((p) => p !== null);
|
|
33
|
+
return { ...v, profiles };
|
|
34
|
+
}
|
|
35
|
+
/** An index for a bundle, so lookups and matching work offline. */
|
|
36
|
+
function indexOfBundle(bundle) {
|
|
37
|
+
return {
|
|
38
|
+
schemaVersion: bundle.schemaVersion,
|
|
39
|
+
dataVersion: bundle.dataVersion,
|
|
40
|
+
generatedAt: bundle.generatedAt,
|
|
41
|
+
profiles: bundle.profiles.map((p) => ({
|
|
42
|
+
...indexFields(p),
|
|
43
|
+
path: `profiles/${p.id}.json`,
|
|
44
|
+
sha256: '',
|
|
45
|
+
bytes: 0
|
|
46
|
+
}))
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createClient(options = {}) {
|
|
50
|
+
const platform = globalThis;
|
|
51
|
+
const baseUrl = options.baseUrl ?? NEXT_URL;
|
|
52
|
+
const doFetch = options.fetch ?? platform.fetch?.bind(globalThis);
|
|
53
|
+
const store = options.store ?? memoryStore();
|
|
54
|
+
const ttl = options.ttl ?? 24 * 60 * 60 * 1000;
|
|
55
|
+
const timeout = options.timeout ?? 10_000;
|
|
56
|
+
const now = options.now ?? (() => Date.now());
|
|
57
|
+
const report = (error, context) => {
|
|
58
|
+
try {
|
|
59
|
+
options.onError?.(error, context);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// A throwing error handler must not break the host either.
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const cacheGet = async (key) => {
|
|
66
|
+
try {
|
|
67
|
+
return await store.get(key);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
report(e, `cache read ${key}`);
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const cacheSet = async (key, entry) => {
|
|
75
|
+
try {
|
|
76
|
+
await store.set(key, entry);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
report(e, `cache write ${key}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const parse = (body, read, what) => {
|
|
83
|
+
try {
|
|
84
|
+
const value = read(JSON.parse(body));
|
|
85
|
+
if (value === null)
|
|
86
|
+
report(new Error(`${what}: unsupported or malformed`), what);
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
report(e, what);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** GET with If-None-Match. `null` body means 304. Undefined on any failure. */
|
|
95
|
+
const get = async (path, etag) => {
|
|
96
|
+
if (!doFetch) {
|
|
97
|
+
report(new Error('no fetch available'), path);
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
let timer;
|
|
101
|
+
try {
|
|
102
|
+
const timedOut = new Promise((_, reject) => {
|
|
103
|
+
timer = platform.setTimeout?.(() => reject(new Error(`timed out after ${timeout} ms`)), timeout);
|
|
104
|
+
});
|
|
105
|
+
const res = await Promise.race([
|
|
106
|
+
doFetch(baseUrl + path, { headers: etag ? { 'If-None-Match': etag } : {} }),
|
|
107
|
+
timedOut
|
|
108
|
+
]);
|
|
109
|
+
if (res.status === 304)
|
|
110
|
+
return { body: null, etag };
|
|
111
|
+
if (!res.ok)
|
|
112
|
+
throw new Error(`HTTP ${res.status}`);
|
|
113
|
+
const body = await Promise.race([res.text(), timedOut]);
|
|
114
|
+
return { body, etag: res.headers.get('ETag') ?? undefined };
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
report(e, `fetch ${baseUrl}${path}`);
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
platform.clearTimeout?.(timer);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/** TTL + ETag revalidation for index.json and bundle.json. */
|
|
125
|
+
const loadDocument = async (key, path, read) => {
|
|
126
|
+
const cached = await cacheGet(key);
|
|
127
|
+
if (cached && now() - cached.fetchedAt < ttl) {
|
|
128
|
+
const value = parse(cached.body, read, path);
|
|
129
|
+
if (value)
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
const res = await get(path, cached?.etag);
|
|
133
|
+
if (res?.body === null && cached) {
|
|
134
|
+
await cacheSet(key, { ...cached, fetchedAt: now() });
|
|
135
|
+
return parse(cached.body, read, path);
|
|
136
|
+
}
|
|
137
|
+
if (res?.body) {
|
|
138
|
+
const value = parse(res.body, read, path);
|
|
139
|
+
if (value) {
|
|
140
|
+
const entry = { body: res.body, fetchedAt: now() };
|
|
141
|
+
if (res.etag)
|
|
142
|
+
entry.etag = res.etag;
|
|
143
|
+
await cacheSet(key, entry);
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return cached ? parse(cached.body, read, path) : null;
|
|
148
|
+
};
|
|
149
|
+
const inFlight = new Map();
|
|
150
|
+
const once = (key, load) => {
|
|
151
|
+
let p = inFlight.get(key);
|
|
152
|
+
if (!p) {
|
|
153
|
+
p = load().finally(() => inFlight.delete(key));
|
|
154
|
+
inFlight.set(key, p);
|
|
155
|
+
}
|
|
156
|
+
return p;
|
|
157
|
+
};
|
|
158
|
+
const loadIndex = () => once('index', async () => {
|
|
159
|
+
const index = await loadDocument('index', 'index.json', readIndex);
|
|
160
|
+
return index ?? (options.snapshot ? indexOfBundle(options.snapshot) : null);
|
|
161
|
+
});
|
|
162
|
+
const loadBundle = () => once('bundle', async () => {
|
|
163
|
+
const bundle = await loadDocument('bundle', 'bundle.json', readBundle);
|
|
164
|
+
return bundle ?? options.snapshot ?? null;
|
|
165
|
+
});
|
|
166
|
+
const fromBundles = async (id) => {
|
|
167
|
+
const cached = await cacheGet('bundle');
|
|
168
|
+
const bundle = cached ? parse(cached.body, readBundle, 'bundle.json') : null;
|
|
169
|
+
return (bundle?.profiles.find((p) => p.id === id) ??
|
|
170
|
+
options.snapshot?.profiles.find((p) => p.id === id) ??
|
|
171
|
+
null);
|
|
172
|
+
};
|
|
173
|
+
const loadProfile = (id) => once(`profile:${id}`, async () => {
|
|
174
|
+
const index = await loadIndex();
|
|
175
|
+
const entry = index?.profiles.find((e) => e.id === id);
|
|
176
|
+
if (index && !entry)
|
|
177
|
+
return null;
|
|
178
|
+
const key = `profile:${id}`;
|
|
179
|
+
const path = entry?.path ?? `profiles/${encodeURIComponent(id)}.json`;
|
|
180
|
+
const cached = await cacheGet(key);
|
|
181
|
+
const ok = (p) => (p && p.id === id ? p : null);
|
|
182
|
+
if (cached && entry?.sha256 && cached.sha256 === entry.sha256) {
|
|
183
|
+
const p = ok(parse(cached.body, readProfile, path));
|
|
184
|
+
if (p)
|
|
185
|
+
return p;
|
|
186
|
+
}
|
|
187
|
+
const res = await get(path, cached?.etag);
|
|
188
|
+
const body = res?.body === null ? cached?.body : res?.body;
|
|
189
|
+
const profile = body === undefined ? null : ok(parse(body, readProfile, path));
|
|
190
|
+
if (profile && body !== undefined) {
|
|
191
|
+
const stored = { body, fetchedAt: now() };
|
|
192
|
+
const etag = res?.etag ?? cached?.etag;
|
|
193
|
+
if (etag)
|
|
194
|
+
stored.etag = etag;
|
|
195
|
+
if (entry?.sha256)
|
|
196
|
+
stored.sha256 = entry.sha256;
|
|
197
|
+
await cacheSet(key, stored);
|
|
198
|
+
return profile;
|
|
199
|
+
}
|
|
200
|
+
return (cached && ok(parse(cached.body, readProfile, path))) ?? (await fromBundles(id));
|
|
201
|
+
});
|
|
202
|
+
return {
|
|
203
|
+
loadIndex,
|
|
204
|
+
loadProfile,
|
|
205
|
+
loadBundle,
|
|
206
|
+
async matchDevice(identity) {
|
|
207
|
+
const index = await loadIndex();
|
|
208
|
+
try {
|
|
209
|
+
return matchDevice(index?.profiles ?? [], identity);
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
report(e, 'matchDevice');
|
|
213
|
+
return { matches: [], best: null, ambiguous: false };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EA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.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createClient, NEXT_URL, V1_URL } from './client.ts';
|
|
2
|
+
export type { ClientOptions, EqcapsClient, FetchLike } from './client.ts';
|
|
3
|
+
export { memoryStore, webStorageStore } from './cache.ts';
|
|
4
|
+
export type { CacheEntry, CacheStore, WebStorageLike } from './cache.ts';
|
|
5
|
+
export { matchDevice, usbId } from './match.ts';
|
|
6
|
+
export type { Candidate, DeviceIdentity, DeviceMatch, MatchResult } from './match.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/match.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type IndexEntry, type Match } from '@potatosalad775/eqcaps-core';
|
|
2
|
+
/**
|
|
3
|
+
* What a consumer knows about a connected device. Give whatever the transport exposes
|
|
4
|
+
* (WebHID: vendorId, productId, productName; Web Bluetooth: name, service UUIDs; …).
|
|
5
|
+
*/
|
|
6
|
+
export interface DeviceIdentity {
|
|
7
|
+
usb?: {
|
|
8
|
+
/** Number (0x2972) or hex string ("0x2972"). */
|
|
9
|
+
vendorId: number | string;
|
|
10
|
+
productId?: number | string;
|
|
11
|
+
/** Exactly as the device reports it, trailing spaces included. */
|
|
12
|
+
productName?: string;
|
|
13
|
+
};
|
|
14
|
+
bluetooth?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
serviceUuids?: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
/** Leave out when unknown: firmware ranges are then ignored (SPEC §3). */
|
|
19
|
+
firmware?: string;
|
|
20
|
+
}
|
|
21
|
+
/** A profile that matches, with how strongly. */
|
|
22
|
+
export interface DeviceMatch<E extends Candidate = Candidate> {
|
|
23
|
+
id: string;
|
|
24
|
+
/** SPEC §3: vid+pid+name 4, vid+pid 3, vid+name 3, bt name 2, bt namePrefix 1. */
|
|
25
|
+
specificity: number;
|
|
26
|
+
entry: E;
|
|
27
|
+
}
|
|
28
|
+
export interface MatchResult<E extends Candidate = Candidate> {
|
|
29
|
+
/** Every match, most specific first, then by id. */
|
|
30
|
+
matches: DeviceMatch<E>[];
|
|
31
|
+
/**
|
|
32
|
+
* The unique most specific match, or null. On a tie the consumer presents a choice and never
|
|
33
|
+
* picks silently (SPEC §3).
|
|
34
|
+
*/
|
|
35
|
+
best: DeviceMatch<E> | null;
|
|
36
|
+
/** True when two or more profiles tie for the highest specificity. */
|
|
37
|
+
ambiguous: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Anything with an id and a match: an index entry, or a profile (status read from meta). */
|
|
40
|
+
export type Candidate = Pick<IndexEntry, 'id'> & {
|
|
41
|
+
match?: Match;
|
|
42
|
+
status?: IndexEntry['status'];
|
|
43
|
+
meta?: {
|
|
44
|
+
status?: IndexEntry['status'];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/** `0x2972` from 0x2972, "0x2972", "2972" or "0X2972". Null if it isn't a 16-bit id. */
|
|
48
|
+
export declare function usbId(id: number | string | undefined): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Finds the profiles whose `match` fits a device (SPEC §3). Deprecated profiles are skipped:
|
|
51
|
+
* their `replacedBy` is what a device should get. Works on index entries or whole profiles.
|
|
52
|
+
*/
|
|
53
|
+
export declare function matchDevice<E extends Candidate>(candidates: Iterable<E>, identity: DeviceIdentity): MatchResult<E>;
|
|
54
|
+
//# sourceMappingURL=match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../src/match.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,KAAK,EAEV,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,GAAG,CAAC,EAAE;QACL,gDAAgD;QAChD,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC5B,kEAAkE;QAClE,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACjC,CAAC;IACF,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iDAAiD;AACjD,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC3D,EAAE,EAAE,MAAM,CAAC;IACX,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC;CACT;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC3D,oDAAoD;IACpD,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC5B,sEAAsE;IACtE,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,6FAA6F;AAC7F,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACzC,CAAC;AAEF,wFAAwF;AACxF,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKpE;AAkCD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAC9C,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,EACvB,QAAQ,EAAE,cAAc,GACtB,WAAW,CAAC,CAAC,CAAC,CAuBhB"}
|
package/dist/match.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { compareFirmware } from '@potatosalad775/eqcaps-core';
|
|
2
|
+
/** `0x2972` from 0x2972, "0x2972", "2972" or "0X2972". Null if it isn't a 16-bit id. */
|
|
3
|
+
export function usbId(id) {
|
|
4
|
+
if (id === undefined)
|
|
5
|
+
return null;
|
|
6
|
+
const n = typeof id === 'number' ? id : parseInt(id.replace(/^0x/i, ''), 16);
|
|
7
|
+
if (!Number.isInteger(n) || n < 0 || n > 0xffff)
|
|
8
|
+
return null;
|
|
9
|
+
return `0x${n.toString(16).padStart(4, '0')}`;
|
|
10
|
+
}
|
|
11
|
+
function usbSpecificity(e, d) {
|
|
12
|
+
if (e.vendorId !== usbId(d.vendorId))
|
|
13
|
+
return 0;
|
|
14
|
+
if (e.productId !== undefined && e.productId !== usbId(d.productId))
|
|
15
|
+
return 0;
|
|
16
|
+
if (e.productName !== undefined && e.productName !== d.productName)
|
|
17
|
+
return 0;
|
|
18
|
+
if (e.productId !== undefined && e.productName !== undefined)
|
|
19
|
+
return 4;
|
|
20
|
+
return 3;
|
|
21
|
+
}
|
|
22
|
+
function bluetoothSpecificity(e, d) {
|
|
23
|
+
const name = d.name;
|
|
24
|
+
if (name === undefined)
|
|
25
|
+
return 0;
|
|
26
|
+
if (e.name !== undefined && e.name !== name)
|
|
27
|
+
return 0;
|
|
28
|
+
if (e.namePrefix !== undefined && !name.startsWith(e.namePrefix))
|
|
29
|
+
return 0;
|
|
30
|
+
if (e.serviceUuid !== undefined &&
|
|
31
|
+
!(d.serviceUuids ?? []).some((u) => u.toLowerCase() === e.serviceUuid)) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
return e.name !== undefined ? 2 : 1;
|
|
35
|
+
}
|
|
36
|
+
function inFirmwareRange(range, firmware) {
|
|
37
|
+
if (!range || firmware === undefined)
|
|
38
|
+
return true;
|
|
39
|
+
if (range.min !== undefined && compareFirmware(firmware, range.min) < 0)
|
|
40
|
+
return false;
|
|
41
|
+
if (range.max !== undefined && compareFirmware(firmware, range.max) >= 0)
|
|
42
|
+
return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Finds the profiles whose `match` fits a device (SPEC §3). Deprecated profiles are skipped:
|
|
47
|
+
* their `replacedBy` is what a device should get. Works on index entries or whole profiles.
|
|
48
|
+
*/
|
|
49
|
+
export function matchDevice(candidates, identity) {
|
|
50
|
+
const matches = [];
|
|
51
|
+
for (const entry of candidates) {
|
|
52
|
+
const match = entry.match;
|
|
53
|
+
if (!match || (entry.status ?? entry.meta?.status) === 'deprecated')
|
|
54
|
+
continue;
|
|
55
|
+
if (!inFirmwareRange(match.firmware, identity.firmware))
|
|
56
|
+
continue;
|
|
57
|
+
let specificity = 0;
|
|
58
|
+
if (identity.usb) {
|
|
59
|
+
for (const e of match.usb ?? []) {
|
|
60
|
+
specificity = Math.max(specificity, usbSpecificity(e, identity.usb));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (identity.bluetooth) {
|
|
64
|
+
for (const e of match.bluetooth ?? []) {
|
|
65
|
+
specificity = Math.max(specificity, bluetoothSpecificity(e, identity.bluetooth));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (specificity > 0)
|
|
69
|
+
matches.push({ id: entry.id, specificity, entry });
|
|
70
|
+
}
|
|
71
|
+
matches.sort((a, b) => b.specificity - a.specificity || a.id.localeCompare(b.id));
|
|
72
|
+
const top = matches[0];
|
|
73
|
+
const ambiguous = top !== undefined && matches[1]?.specificity === top.specificity;
|
|
74
|
+
return { matches, best: top && !ambiguous ? top : null, ambiguous };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../src/match.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EAKf,MAAM,6BAA6B,CAAC;AAiDrC,wFAAwF;AACxF,MAAM,UAAU,KAAK,CAAC,EAA+B;IACpD,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,CAAC,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,KAAK,CA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;YACtE,CAAC;QACF,CAAC;QACD,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;YACxB,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;gBACvC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YAClF,CAAC;QACF,CAAC;QACD,IAAI,WAAW,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClF,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,SAAS,GAAG,GAAG,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,GAAG,CAAC,WAAW,CAAC;IACnF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;AACrE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@potatosalad775/eqcaps-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Fetches, caches and matches eqcaps EQ constraint profiles.",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/potatosalad775/eqcaps.git",
|
|
12
|
+
"directory": "packages/client"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"eqcaps:source": "./src/index.ts",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@potatosalad775/eqcaps-core": "0.1.0"
|
|
31
|
+
}
|
|
32
|
+
}
|