69 lines
3.7 KiB
JavaScript
69 lines
3.7 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { readFileSync } = require('node:fs');
|
|
const { join } = require('node:path');
|
|
|
|
const root = __dirname;
|
|
const assets = JSON.parse(readFileSync(join(root, 'assets.json'), 'utf8'));
|
|
const group = assets.groups['feature:jamesdsp'];
|
|
|
|
test('JamesDSP runtime files live only in a lazy background group', () => {
|
|
assert.ok(group, 'feature group exists');
|
|
assert.equal(group.contract, 1);
|
|
assert.equal(group.eager, false);
|
|
assert.equal(group.background, true);
|
|
assert.equal(group.offlineOptIn, 'jamesDsp');
|
|
assert.deepEqual(group.dependencies, ['feature:eq-core', 'feature:vocal-reducer']);
|
|
assert.deepEqual(group.files, [
|
|
'/vendor/jamesdsp/jamesdsp-feature.js',
|
|
'/vendor/jamesdsp/jamesdsp-node.mjs',
|
|
'/vendor/jamesdsp/params.mjs',
|
|
'/vendor/jamesdsp/ir-utils.mjs',
|
|
'/vendor/jamesdsp/ir-builtins.mjs',
|
|
'/vendor/jamesdsp/ir-store.mjs',
|
|
'/vendor/jamesdsp/worklet.mjs',
|
|
'/vendor/jamesdsp/dsp/jamesdsp-a982b53.mjs',
|
|
'/vendor/jamesdsp/dsp/jamesdsp.wasm',
|
|
]);
|
|
for (const path of group.files) assert.equal(assets.groups.core.files.includes(path), false, `${path} is not core`);
|
|
const sw = readFileSync(join(root, 'sw.js'), 'utf8');
|
|
for (const path of group.files) assert.equal(sw.includes(`'${path}'`), false, `${path} is not in the legacy shell`);
|
|
});
|
|
|
|
test('JamesDSP resolves every module dependency through the page build manifest', () => {
|
|
const node = readFileSync(join(root, 'vendor/jamesdsp/jamesdsp-node.mjs'), 'utf8');
|
|
const worklet = readFileSync(join(root, 'vendor/jamesdsp/worklet.mjs'), 'utf8');
|
|
assert.match(node, /globalThis\.Lazy\?\.url\?\.\(path\)/);
|
|
assert.match(node, /assetURL\('\/vendor\/jamesdsp\/dsp\/jamesdsp\.wasm'/);
|
|
assert.match(node, /assetURL\('\/vendor\/jamesdsp\/params\.mjs'/);
|
|
assert.match(node, /processorOptions:\{wasmBytes\}/);
|
|
assert.match(worklet, /import createJamesDSP from '\.\/dsp\/jamesdsp-a982b53\.mjs'/);
|
|
assert.doesNotMatch(worklet, /import\(/);
|
|
assert.match(node, /context\.sampleRate<8000\|\|context\.sampleRate>96000/);
|
|
assert.match(node, /!\[1,2,4\]\.includes\(buffer\.numberOfChannels\) \|\| buffer\.length>65536/);
|
|
const feature = readFileSync(join(root, 'vendor/jamesdsp/jamesdsp-feature.js'), 'utf8');
|
|
assert.match(feature, /Lazy\.url\('\/vendor\/jamesdsp\/jamesdsp-node\.mjs'\)/);
|
|
assert.match(feature, /Lazy\.url\('\/vendor\/jamesdsp\/dsp\/jamesdsp\.wasm'\)/);
|
|
});
|
|
|
|
test('player wrapper rejects text effects while portable presets retain IR references', () => {
|
|
const node = readFileSync(join(root, 'vendor/jamesdsp/jamesdsp-node.mjs'), 'utf8');
|
|
const worklet = readFileSync(join(root, 'vendor/jamesdsp/worklet.mjs'), 'utf8');
|
|
assert.match(node, /Text effects are disabled in this player version/);
|
|
assert.match(node, /toJSON\(\) \{return \{version:2,params:/);
|
|
assert.match(node, /irCapFrames:view\.getUint32\(32,true\)/);
|
|
assert.match(node, /getIR\(preset\.irRef\.name\)/);
|
|
const feature = readFileSync(join(root, 'vendor/jamesdsp/jamesdsp-feature.js'), 'utf8');
|
|
assert.match(feature, /async function prepareIR\(context, buffer, maxFrames = 65536\)/);
|
|
assert.match(feature, /prepared\.length>Math\.min\(65536,maxFrames\)/);
|
|
assert.doesNotMatch(worklet, /data\.type==='text'/);
|
|
});
|
|
|
|
test('vendor provenance pins the source and retains both supplied license texts', () => {
|
|
const version = readFileSync(join(root, 'vendor/jamesdsp/VERSION.txt'), 'utf8');
|
|
assert.match(version, /a982b53c4ab347d1d9c50f4ce7ee3c2735eaa817/);
|
|
assert.match(version, /GPL-2\.0 text/);
|
|
assert.ok(readFileSync(join(root, 'vendor/jamesdsp/LICENSE.txt'), 'utf8').includes('Version 3'));
|
|
assert.ok(readFileSync(join(root, 'vendor/jamesdsp/UPSTREAM-MAIN-LICENSE.txt'), 'utf8').includes('Version 2'));
|
|
});
|