Skip to content
Draft
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
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ git add [PluginName]/* .vscode/* .github/* bump_version.py
git commit -m "created [PluginName] based on TemplateProject"
```

## WebMCP agent bridge (Wasm builds)

Every Wasm host page registers WebMCP tools (`navigator.modelContext`) so a browser agent can
set parameters, snapshot/restore state, inspect and manipulate IGraphics controls, simulate
input and take screenshots. Without WebMCP the same tools are reachable from DevTools via
`window.__iplugWebMCPShim.list()` / `.call(name, input)`. See the "WebMCP Agent Bridge"
section of @iPlug2/Documentation/wasm.md.

## Additional Context

- iPlug2 framework: @iPlug2/CLAUDE.md
Expand Down
4 changes: 4 additions & 0 deletions TemplateProject/scripts/makedist-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmProcessor.js.template"
sed -i"$BAK_SUFFIX" "s/NAME_PLACEHOLDER_LC/$PROJECT_NAME_LC/g" "scripts/$PROJECT_NAME-processor.js"
sed -i"$BAK_SUFFIX" "s/NAME_PLACEHOLDER/$PROJECT_NAME/g" "scripts/$PROJECT_NAME-processor.js"

# Copy the shared host page scripts (footer UI + WebMCP agent bridge), used verbatim
cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmHostControls.js" scripts/IPlugWasmHostControls.js
cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmWebMCP.js" scripts/IPlugWasmWebMCP.js

# Copy and process HTML template
# IMPORTANT: Replace NAME_PLACEHOLDER_LC first (longer match) before NAME_PLACEHOLDER
cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/index.html" index.html
Expand Down
23 changes: 20 additions & 3 deletions TemplateProjectWebView/resources/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@

function OnControlChange(ctrlTag, value) {}

// Optional: expose an explicit action to browser agents (WebMCP) when the
// UI is hosted by the Wasm host page. Clickable elements can instead be
// annotated with data-iplug-action="id" (see the size buttons below).
window.iPlugWebMCP?.registerAction({
id: 'reset-gain',
label: 'Reset gain to its default',
run: async () => {
const info = window['parameters']?.[0];
const normalized = info ? (info.default - info.min) / (info.max - info.min) : 1;
BPCFUI(0);
SPVFUI(0, normalized);
EPCFUI(0);
OnParamChange(0, normalized);
return { normalized };
}
});

// Called by script.js for arbitrary messages from the plugin. The plugin
// sends the parameter list as JSON once the web content has loaded.
function OnMessage(msgTag, dataSize, data) {
Expand Down Expand Up @@ -133,9 +150,9 @@ <h1>TemplateProjectWebView</h1>

<div class="button-group">
<span class="group-label">Editor size</span>
<button-control onclick="SAMFUI(kMsgTagButtonSmall)">Small</button-control>
<button-control onclick="SAMFUI(kMsgTagButtonMedium)">Medium</button-control>
<button-control onclick="SAMFUI(kMsgTagButtonLarge)">Large</button-control>
<button-control data-iplug-action="size-small" onclick="SAMFUI(kMsgTagButtonSmall)">Small</button-control>
<button-control data-iplug-action="size-medium" onclick="SAMFUI(kMsgTagButtonMedium)">Medium</button-control>
<button-control data-iplug-action="size-large" onclick="SAMFUI(kMsgTagButtonLarge)">Large</button-control>
</div>
</div>
</body>
Expand Down
2 changes: 2 additions & 0 deletions TemplateProjectWebView/resources/web/knob-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class KnobControl extends HTMLElement {
width: var(--knob-size, 80px);
height: var(--knob-size, 80px);
}
/* Decorative strokes must not intercept the circle's pointer handlers. */
svg path, svg line { pointer-events: none; }
.hidden-cursor {
cursor: none;
}
Expand Down
2 changes: 1 addition & 1 deletion iPlug2
Submodule iPlug2 updated 45 files
+152 −0 Documentation/wasm.md
+1 −0 Examples/IPlugChunks/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugControls/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugConvoEngine/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugDrumSynth/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugEffect/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugInstrument/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugMidiEffect/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugResponsiveUI/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugSideChain/scripts/makedist-wasm.sh
+2 −0 Examples/IPlugSurroundEffect/CMakeLists.txt
+1 −0 Examples/IPlugSurroundEffect/scripts/makedist-wasm.sh
+1 −0 Examples/IPlugVisualizer/scripts/makedist-wasm.sh
+481 −0 IGraphics/IGraphicsIntrospect.cpp
+119 −0 IGraphics/IGraphicsIntrospect.h
+165 −0 IGraphics/IGraphicsJSON.h
+6 −88 IGraphics/IGraphicsLiveEdit.h
+6 −15 IGraphics/IGraphics_include_in_plug_src.h
+45 −59 IGraphics/Platforms/IGraphicsWeb.cpp
+291 −0 IGraphics/Platforms/IGraphicsWebMCP.cpp
+106 −0 IPlug/IPlugJSON.h
+252 −21 IPlug/WEB/IPlugWasmDSP.cpp
+4 −0 IPlug/WEB/IPlugWasmUI.cpp
+16 −0 IPlug/WEB/TemplateWasm/index.html
+124 −2 IPlug/WEB/TemplateWasm/scripts/IPlugWasmBundle.js.template
+53 −3 IPlug/WEB/TemplateWasm/scripts/IPlugWasmHostControls.js
+151 −0 IPlug/WEB/TemplateWasm/scripts/IPlugWasmProcessor.js.template
+1,135 −0 IPlug/WEB/TemplateWasm/scripts/IPlugWasmWebMCP.js
+1 −0 IPlug/WEB/TemplateWasm/serve.py
+19 −0 IPlug/WEB/TemplateWasm/webview.html
+1 −0 Scripts/cmake/FindiPlug2.cmake
+19 −10 Scripts/cmake/WASMDist.cmake
+10 −0 Scripts/cmake/WASMUI.cmake
+10 −0 Scripts/cmake/WEB.cmake
+1 −0 Scripts/makedist-wasm-webview.sh
+1 −0 Tests/IGraphicsStressTest/scripts/makedist-wasm.sh
+1 −0 Tests/IGraphicsTest/scripts/makedist-wasm.sh
+1 −0 Tests/MetaParamTest/scripts/makedist-wasm.sh
+127 −0 Tests/WebMCP/helpers.cjs
+64 −0 Tests/WebMCP/host-adapter.test.cjs
+87 −0 Tests/WebMCP/parameters.test.cjs
+389 −0 Tests/WebMCP/webmcp.test.cjs
+106 −0 Tests/WebMCP/webview.test.cjs
+11 −2 common-wasm.mk
+11 −2 common-web.mk
Loading