Skip to content
Closed
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?.powerPresentation &&
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,7 +67,13 @@ 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-fx-rack-view-model.js', approved)
self.assertEqual(
(out / 'assets/approved-fx-rack-view-model.js').read_bytes(),
(ROOT / 'web/approved-fx-rack-view-model.js').read_bytes())
self.assertNotIn('assets/approved-channel-strip-view-model.js', approved)
self.assertEqual(
(out / 'assets/approved-channel-strip-view-model.js').read_bytes(),
Expand Down
94 changes: 90 additions & 4 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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));
Expand Down Expand Up @@ -1249,7 +1250,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 @@ -1450,6 +1451,91 @@ test("M3 native-only Pages scope performs real bridge projection, fader intent a
assert.equal(sent.findLast(x=>x.name==="arMixConsoleIntent").payload.payload.changes[0].to,other.id);
});

// GUI-2: FX Rack projection is pure. No shadow DSP state, browser FX editor
// ownership, plugin reordering, or second routing/Apply command dispatcher.
test("GUI-2 native FX Rack projection keeps global, rack and insert bypass independent",()=>{
const ch={fxRackBypassed:false,inserts:[
{id:"9223372036854775808",bypassed:false,latencySamples:128},
{id:"9223372036854775810",bypassed:true,latencyChanged:true}
]};
const frozen=JSON.stringify(ch);
const base=fxRackVM.powerPresentation(ch,false,"Vocal");
assert.deepEqual(base.slots.map(x=>x.effective),[true,false]);
assert.deepEqual(base.slots.map(x=>x.slotEnabled),[true,false]);
assert.equal(base.headerPressed,true);
assert.equal(base.slots[0].latencyTitle,"Plugin delay: 128 samples · compensated");
assert.match(base.slots[1].latencyTitle,/Plugin delay changed/);
assert.equal(base.slots[1].buttonTitle,"Enable only insert 2");
const global=fxRackVM.powerPresentation(ch,true,"Vocal");
assert.deepEqual(global.slots.map(x=>x.effective),[false,false]);
assert.deepEqual(global.slots.map(x=>x.slotEnabled),[true,false]);
assert.equal(global.headerPressed,false);
const chain=fxRackVM.powerPresentation({...ch,fxRackBypassed:true},false,"Vocal");
assert.equal(chain.chainBypassed,true);
assert.deepEqual(chain.slots.map(x=>x.effective),[false,false]);
assert.equal(chain.slots[0].buttonTitle,"Bypass only insert 1");
assert.equal(JSON.stringify(ch),frozen,"projection cannot rewrite accepted insert flags");
assert.equal(fxRackVM.powerPresentation(ch,null,"Vocal"),null);
assert.equal(fxRackVM.powerPresentation({...ch,inserts:[{id:"",bypassed:false}]},false,"Vocal"),null);
});
test("GUI-2 FX Rack never paints stale mounted VST3 instance or slot order",()=>{
const view=fxRackVM.powerPresentation({fxRackBypassed:false,inserts:[
{id:"instance-A",bypassed:false},{id:"instance-B",bypassed:true}
]},false,"CH5");
const rows=[{slot:"0",instanceId:"instance-A",hasPower:true},
{slot:"1",instanceId:"instance-B",hasPower:true}];
assert.equal(fxRackVM.mountedCompatible(view,rows),true);
assert.equal(fxRackVM.mountedCompatible(view,[rows[1],rows[0]]),true,
"DOM order may differ; stable slot plus native token selects correct row");
assert.equal(fxRackVM.mountedCompatible(view,[rows[0],rows[0]]),false);
assert.equal(fxRackVM.mountedCompatible(view,[{...rows[0],instanceId:"instance-X"},rows[1]]),false);
assert.equal(fxRackVM.mountedCompatible(view,[rows[0],{...rows[1],hasPower:false}]),false);
assert.equal(fxRackVM.mountedCompatible(view,[rows[0]]),false);
});
test("GUI-2 FX Rack ACK alone cannot commit bypass, moved token cannot settle",()=>{
const p={acked:false,kind:"insert",channelId:"9007199254740993",
insertId:"fx-1",bypassed:true};
const ch={id:p.channelId,fxRackBypassed:false,
inserts:[{id:"fx-1",bypassed:true}]};
assert.equal(fxRackVM.powerReadbackConfirmed(p,[ch]),false);
assert.equal(fxRackVM.powerReadbackConfirmed({...p,acked:true},[ch]),true);
assert.equal(fxRackVM.powerReadbackConfirmed({...p,acked:true},
[{...ch,inserts:[{id:"fx-moved",bypassed:true}]}]),false);
assert.equal(fxRackVM.powerReadbackConfirmed({...p,acked:true},[
{...ch,fxRackBypassed:true,inserts:[{id:"fx-1",bypassed:false}]}]),false);
assert.equal(fxRackVM.powerReadbackConfirmed({...p,acked:true,kind:"rack",insertId:null},
[{...ch,fxRackBypassed:true}]),true);
const m4={authority:"M4",deviceEpoch:"18",routeRevision:"9",
channels:[{fxRackBypassed:true}]};
const pending={channel:0,epoch:"18",revision:"9",bypassed:true,acked:false};
assert.equal(fxRackVM.m4RackPendingState(pending,m4),"WAIT");
assert.equal(fxRackVM.m4RackPendingState({...pending,acked:true},m4),"CONFIRMED");
assert.equal(fxRackVM.m4RackPendingState({...pending,acked:true},
{...m4,deviceEpoch:"19"}),"STALE");
});
test("GUI-2 M4 catalog projection cannot modify native identity or resurrect deleted FX",()=>{
const rows=[{instanceId:"legacy-instance",catalogId:"external-eq",bypassed:true}];
const frozen=JSON.stringify(rows);
const m4=fxRackVM.m4Presentation(rows,new Map([
["external-eq",{name:"Parametric EQ"}]]),true);
assert.equal(m4.fxOn,false);
assert.deepEqual(m4.slots[0],{slot:0,name:"Parametric EQ",bypassed:true,
instance:{id:"legacy-instance",name:"Parametric EQ"}});
assert.equal(m4.slots[1].name,"None");
assert.equal(m4.slots[1].instance,null);
assert.equal(m4.slots.length,8);
assert.equal(fxRackVM.m4Presentation([],new Map(),undefined).fxOn,null);
assert.equal(JSON.stringify(rows),frozen);
const source=read("web/approved-native-bridge.js");
assert.match(source,/fxRackVM\.powerPresentation\(ch,globalFxBypassed,t\.name\)/);
assert.match(source,/fxRackVM\.mountedCompatible\(view,slots\)/);
assert.match(source,/fxRackVM\.m4Presentation\(m\.fxInstances\[lane\]/);
assert.match(source,/fxRackVM\.powerReadbackConfirmed\(pendingNativeFxPower/);
assert.doesNotMatch(source,/const effective=enabled&&globalEnabled&&!insert\.bypassed/);
assert.doesNotMatch(source,/const actual=p\.kind==="rack"\?ch\?\.fxRackBypassed/);
assert.equal((source.match(/action:"routingNativeFxRackBypass"/g)||[]).length,0,
"native action names must remain in the existing conditional dispatch only");
});
test("P0 native FX rack and per-slot readback update mounted strip without replacing fader DOM",()=>{
const vm=require("node:vm"),listeners=new Map(),sent=[];
let paints=0,serial=100,wire=300,strip=null;
Expand All @@ -1473,7 +1559,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 +1737,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 +1824,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
91 changes: 91 additions & 0 deletions web/approved-fx-rack-view-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// SPDX-License-Identifier: AGPL-3.0-only
// GUI-2: pure FX Rack presentation/readback. The ONE native mixer owns all
// plugin instances, graph revisions, bypass state and editor HWND lifetime.
(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";
// A rack and the global A/B gate do not rewrite any individual insert flag.
// Use the exact accepted instance ID for every projected power button.
function powerPresentation(channel,globalFxBypassed,trackName) {
if(typeof channel?.fxRackBypassed!=="boolean"||
!Array.isArray(channel.inserts)||
typeof globalFxBypassed!=="boolean")return null;
const enabled=!channel.fxRackBypassed;
const globalEnabled=!globalFxBypassed;
const slots=channel.inserts.map((insert,slot)=>{
if(!insert||typeof insert.id!=="string"||!insert.id||
typeof insert.bypassed!=="boolean")return null;
const effective=enabled&&globalEnabled&&!insert.bypassed;
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;
return {
slot,instanceId:insert.id,bypassed:insert.bypassed,
slotEnabled:!insert.bypassed,effective,latencyTitle,
buttonTitle:(insert.bypassed?"Enable":"Bypass")+" only insert "+(slot+1),
buttonLabel:(insert.bypassed?"Enable":"Bypass")+" only FX insert "+
(slot+1)+" in "+trackName
};
});
if(slots.some(slot=>!slot))return null;
return {
enabled,globalEnabled,chainBypassed:!enabled||!globalEnabled,
headerPressed:enabled&&globalEnabled,
headerTitle:(enabled?"Bypass":"Enable")+" all channel FX",
headerLabel:(enabled?"Bypass":"Enable")+" entire FX chain in "+trackName,
slots
};
}
// Pure mounted DOM compatibility guard. Never paint a reused row when its
// native processor lease or slot position has changed at the same revision.
function mountedCompatible(projection,rows) {
if(!projection||!Array.isArray(rows)||
rows.length!==projection.slots.length)return false;
const seen=new Set();
return rows.every(row=>{
if(!row||typeof row.slot!=="string"||
seen.has(row.slot)||row.hasPower!==true)return false;
seen.add(row.slot);
const slot=projection.slots.find(s=>String(s.slot)===row.slot);
return !!slot && row.instanceId===slot.instanceId;
});
}
// M4 catalog metadata may change but is NEVER authority to overwrite an
// installed CHANNEL_ID rack. The bridge enforces that authority boundary.
function m4Presentation(rows,catalog,acceptedRack) {
if(!Array.isArray(rows))return null;
const slots=Array.from({length:8},(_,slot)=>{
const live=rows[slot];
const entry=live && catalog?.get?.(live.catalogId);
const name=live?(entry?.name||"VST3 Loaded"):"None";
return {slot,name,bypassed:Boolean(live?.bypassed),
instance:live?{id:live.instanceId,name}:null};
});
return {fxOn:typeof acceptedRack==="boolean"?!acceptedRack:null,slots};
}
// ACK alone is insufficient. Confirm only the matching instance from the
// later installed ChannelId graph; a moved/deleted insert must not settle.
function powerReadbackConfirmed(pending,channels) {
if(pending?.acked!==true||!Array.isArray(channels))return false;
const channel=channels.find(ch=>ch.id===pending.channelId);
if(!channel)return false;
const value=pending.kind==="rack"?channel.fxRackBypassed:
pending.kind==="insert"?channel.inserts?.find(i=>i.id===pending.insertId)?.bypassed:
undefined;
return typeof value==="boolean"&&value===pending.bypassed;
}
function m4RackPendingState(pending,session) {
if(!pending||session?.authority!=="M4"||
session.deviceEpoch!==pending.epoch||
session.routeRevision!==pending.revision)return "STALE";
return pending.acked===true&&
session.channels?.[pending.channel]?.fxRackBypassed===pending.bypassed?
"CONFIRMED":"WAIT";
}
return Object.freeze({powerPresentation,mountedCompatible,m4Presentation,
powerReadbackConfirmed,m4RackPendingState});
});
Loading
Loading