Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/build_approved_native_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ADAPTER_MARKER = ('<script defer src="assets/approved-native-contract.js"></script>\n'
'<script defer src="assets/approved-device-view-model.js"></script>\n'
'<script defer src="assets/approved-channel-strip-view-model.js"></script>\n'
'<script defer src="assets/approved-fx-rack-view-model.js"></script>\n'
'<script defer src="assets/approved-native-bridge.js"></script>\n'
'<script defer src="assets/approved-native-context-menu.js"></script>\n'
'<script defer src="assets/approved-native-legal.js"></script>\n')
Expand Down Expand Up @@ -365,6 +366,8 @@ def stage(out: Path) -> dict:
out / "assets" / "approved-device-view-model.js")
shutil.copy2(ROOT / "web" / "approved-channel-strip-view-model.js",
out / "assets" / "approved-channel-strip-view-model.js")
shutil.copy2(ROOT / "web" / "approved-fx-rack-view-model.js",
out / "assets" / "approved-fx-rack-view-model.js")
native = native_html(approved.decode("utf-8")).encode("utf-8")
(out / "index.html").write_bytes(native)
files = [out / "index.html", *sorted(p for p in (out / "assets").rglob("*") if p.is_file())]
Expand Down
1 change: 1 addition & 0 deletions tests/approved_native_cold_start_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def main():
page.locator('.command-bar [data-native-io]').click()
assert page.evaluate("""()=>Boolean(
window.ArSonApprovedChannelStripViewModel &&
window.ArSonApprovedFxRackViewModel &&
window.__ARMIX_NATIVE_M2__?.inputChoices &&
window.__ARMIX_NATIVE_M2__?.outputChoices)"""), (
'native assembled GUI missing GUI-1 Channel Strip ViewModel')
Expand Down
6 changes: 6 additions & 0 deletions tests/approved_native_gui_bundle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self)
self.assertLess(native.index('assets/approved-device-view-model.js'),
native.index('assets/approved-channel-strip-view-model.js'))
self.assertLess(native.index('assets/approved-channel-strip-view-model.js'),
native.index('assets/approved-fx-rack-view-model.js'))
self.assertLess(native.index('assets/approved-fx-rack-view-model.js'),
native.index('assets/approved-native-bridge.js'))
self.assertNotIn('assets/approved-channel-strip-view-model.js', approved)
self.assertNotIn('assets/approved-fx-rack-view-model.js', approved)
self.assertEqual(
(out / 'assets/approved-channel-strip-view-model.js').read_bytes(),
(ROOT / 'web/approved-channel-strip-view-model.js').read_bytes())
self.assertEqual(
(out / 'assets/approved-fx-rack-view-model.js').read_bytes(),
(ROOT / 'web/approved-fx-rack-view-model.js').read_bytes())
vm_source = (ROOT / "web/approved-device-view-model.js").read_bytes()
self.assertEqual((out / "assets/approved-device-view-model.js").read_bytes(),
vm_source)
Expand Down
73 changes: 69 additions & 4 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,74 @@ const {readFileSync}=require("node:fs");
const protocol=require("../web/approved-native-contract.js");
const deviceVM=require("../web/approved-device-view-model.js");
const stripVM=require("../web/approved-channel-strip-view-model.js");
const fxRackVM=require("../web/approved-fx-rack-view-model.js");
const read=p=>readFileSync(p,"utf8");
const fixtures=JSON.parse(read("integration/console-v6/fixtures.json"));
const clone=x=>JSON.parse(JSON.stringify(x));

test("GUI-2 pure FX power readback preserves independent rack/slot/global states and labels",()=>{
const channel={id:"9007199254740993",fxRackBypassed:false,inserts:[
{id:"instance-1",bypassed:false,latencySamples:96},
{id:"instance-2",bypassed:true,latencyChanged:true}
]};
const original=JSON.stringify(channel);
const normal=fxRackVM.powerReadback(channel,false,"Vocal");
assert.equal(normal.enabled,true);
assert.equal(normal.globalEnabled,true);
assert.equal(normal.chainBypassed,false);
assert.equal(normal.headerPressed,"true");
assert.equal(normal.slots[0].effective,true);
assert.equal(normal.slots[1].effective,false);
assert.equal(normal.slots[0].latencyTitle,"Plugin delay: 96 samples · compensated");
assert.match(normal.slots[1].latencyTitle,/Plugin delay changed/);
assert.equal(normal.slots[0].label,"Bypass only FX insert 1 in Vocal");
assert.equal(normal.slots[1].title,"Enable only insert 2");
const rackOff=fxRackVM.powerReadback({...channel,fxRackBypassed:true},false,"Vocal");
assert.equal(rackOff.enabled,false);
assert.equal(rackOff.slots[0].bypassed,false,
"rack bypass must never become an insert bypass");
assert.equal(rackOff.slots[0].effective,false);
const globalOff=fxRackVM.powerReadback(channel,true,"Vocal");
assert.equal(globalOff.globalEnabled,false);
assert.equal(globalOff.slots[0].effective,false);
assert.equal(globalOff.slots[0].bypassed,false);
assert.equal(globalOff.headerPressed,"false");
assert.equal(JSON.stringify(channel),original,"projection cannot mutate native graph");

// Missing/incomplete readback, including wrong type, is NOT a default ON.
assert.equal(fxRackVM.powerReadback({},false,"Vocal"),null);
assert.equal(fxRackVM.powerReadback(channel,undefined,"Vocal"),null);
assert.equal(fxRackVM.powerReadback({...channel,
inserts:[{id:"instance-1",bypassed:"false"}]},false,"Vocal"),null);
assert.equal(fxRackVM.powerReadback({...channel,
inserts:[{id:"",bypassed:false}]},false,"Vocal"),null);
});
test("GUI-2 exact mounted FX instance/power identity rejects stale, duplicate or missing rows",()=>{
const data=fxRackVM.powerReadback({fxRackBypassed:false,inserts:[
{id:"instance-1",bypassed:false},
{id:"instance-2",bypassed:true}
]},false,"Vocal");
const good=[
{index:0,insertId:"instance-1",hasPower:true},
{index:1,insertId:"instance-2",hasPower:true}
];
assert.equal(fxRackVM.mountedRackMatches(data,good,true),true);
assert.equal(fxRackVM.mountedRackMatches(data,[good[1],good[0]],true),true,
"DOM row order is not allowed to substitute native slot identity");
assert.equal(fxRackVM.mountedRackMatches(data,good,false),false);
assert.equal(fxRackVM.mountedRackMatches(data,good.slice(0,1),true),false);
assert.equal(fxRackVM.mountedRackMatches(data,[good[0],good[0]],true),false);
assert.equal(fxRackVM.mountedRackMatches(data,[good[0],
{...good[1],insertId:"new-plugin"}],true),false);
assert.equal(fxRackVM.mountedRackMatches(data,[good[0],
{...good[1],hasPower:false}],true),false);
assert.equal(fxRackVM.mountedRackMatches(data,null,true),false);
const bridge=read("web/approved-native-bridge.js");
assert.match(bridge,/fxRackVM\.powerReadback\(/);
assert.match(bridge,/fxRackVM\.mountedRackMatches\(/);
assert.doesNotMatch(bridge,/const effective=enabled&&globalEnabled&&!insert\.bypassed/,
"old duplicated FX bypass projection must be removed from DOM bridge");
});
function acceptedFixture(){
const s=clone(fixtures.g0);
s.device.epoch="18446744073709551610";
Expand Down Expand Up @@ -1249,7 +1314,7 @@ test("M3 native-only Pages scope performs real bridge projection, fader intent a
querySelector:()=>null,addEventListener(){}
};
const window={
__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},queueMicrotask(fn){microtasks.push(fn);},setTimeout(fn,ms){timers.push({fn,ms});return timers.length;}
};
vm.runInNewContext(read("web/approved-native-bridge.js"),{
Expand Down Expand Up @@ -1473,7 +1538,7 @@ test("P0 native FX rack and per-slot readback update mounted strip without repla
querySelector:selector=>selector.startsWith('.strip[data-id=')?strip:null,
addEventListener(){}
};
const win={__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
const win={__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}};
vm.runInNewContext(read("web/approved-native-bridge.js"),
Expand Down Expand Up @@ -1651,7 +1716,7 @@ test("P0 FIRST SOUND G0 offers verified input and leaves automatic MAIN to nativ
addEventListener(){}
};
win={
__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}
};
Expand Down Expand Up @@ -1738,7 +1803,7 @@ test("P0 native hardware IN remains selectable after ChannelId ownership, failed
id==="preview"?{disabled:true}:null,
querySelector:()=>null,addEventListener(){}
};
const win={__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
const win={__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},
queueMicrotask(fn){microtasks.push(fn);}};
Expand Down
3 changes: 2 additions & 1 deletion tests/live_fader_held_drag.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const vm=require("node:vm");
const protocol=require("../web/approved-native-contract.js");
const deviceVM=require("../web/approved-device-view-model.js");
const stripVM=require("../web/approved-channel-strip-view-model.js");
const fxRackVM=require("../web/approved-fx-rack-view-model.js");
const read=p=>readFileSync(p,"utf8");
const clone=x=>JSON.parse(JSON.stringify(x));
const fixture=JSON.parse(read("integration/console-v6/fixtures.json")).g0;
Expand Down Expand Up @@ -78,7 +79,7 @@ function harness({m4=false}={}){
};
const window={
__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,
ArSonApprovedChannelStripViewModel:stripVM,
ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(fn,delay=0){timers.push({fn,at:now+Math.max(0,Number(delay)||0)});return timers.length;}
};
Expand Down
68 changes: 68 additions & 0 deletions web/approved-fx-rack-view-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: AGPL-3.0-only
// GUI-2: pure FX Rack readback projection for the ONE approved /preview/ GUI.
// No DOM, timer, native dispatch, plugin lifecycle or accepted audio authority.
// Only the already-validated native snapshot may supply these values.
(function (root, factory) {
const api=factory();
if(typeof module==="object"&&module.exports)module.exports=api;
if(root)root.ArSonApprovedFxRackViewModel=api;
})(typeof globalThis==="object"?globalThis:undefined,function () {
"use strict";

// null means missing or incomplete readback, never a guess based on CSS or
// an optimistic click. Channel-local, global and insert bypass are distinct.
function powerReadback(channel,globalFxBypassed,channelName) {
if(typeof channel?.fxRackBypassed!=="boolean" ||
!Array.isArray(channel.inserts) ||
typeof globalFxBypassed!=="boolean")return null;
const enabled=!channel.fxRackBypassed,globalEnabled=!globalFxBypassed;
const name=String(channelName??"");
const slots=[];
for(let index=0;index<channel.inserts.length;index++) {
const insert=channel.inserts[index];
if(!insert || typeof insert.id!=="string" || !insert.id ||
typeof insert.bypassed!=="boolean")return null;
const effective=enabled&&globalEnabled&&!insert.bypassed;
const action=insert.bypassed?"Enable":"Bypass";
const latencyTitle=insert.latencyChanged===true?
"Plugin delay changed · aligned dry signal retained; reload the plugin before using its new delay":
Number.isInteger(insert.latencySamples)?
"Plugin delay: "+insert.latencySamples+" samples · compensated":null;
slots.push({
index,insertId:insert.id,bypassed:insert.bypassed,effective,
latencyTitle,
pressed:String(effective),
title:action+" only insert "+(index+1),
label:action+" only FX insert "+(index+1)+" in "+name
});
}
return {
enabled,globalEnabled,chainBypassed:!enabled||!globalEnabled,
headerPressed:String(enabled&&globalEnabled),
headerTitle:(enabled?"Bypass":"Enable")+" all channel FX",
headerLabel:(enabled?"Bypass":"Enable")+" entire FX chain in "+name,
slots
};
}

// A mounted strip belongs to a specific native FX instance and order.
// Check the FULL roster before the bridge writes any slot or button.
// An absent/duplicate/wrong slot or missing power control forces the
// existing authoritative structural re-projection instead of wrong-FX UI.
function mountedRackMatches(readback,mountedSlots,hasHeader) {
if(!readback || !hasHeader || !Array.isArray(mountedSlots) ||
mountedSlots.length!==readback.slots.length)return false;
const byIndex=new Map();
for(const mounted of mountedSlots) {
if(!Number.isInteger(mounted?.index) ||
byIndex.has(mounted.index))return false;
byIndex.set(mounted.index,mounted);
}
return readback.slots.every(slot=>{
const mounted=byIndex.get(slot.index);
return mounted?.insertId===slot.insertId && mounted?.hasPower===true;
});
}

return Object.freeze({powerReadback,mountedRackMatches});
});
Loading
Loading