Files
workinf_Blender_Wasm/web/app/src/python/web_blender.py
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

50 lines
1.4 KiB
Python

"""Asynchronous access to the application's actual Blender WebEngine.
This is a WebEngine command interface, not the desktop bpy module.
"""
import json
import contextvars
from _web_blender_host import request as _request
_session_run = contextvars.ContextVar('web_blender_run', default=0)
async def _call(method, value):
response = await _request(_session_run.get(), method, json.dumps(value, allow_nan=False))
return json.loads(response)
async def snapshot():
"""Read the current authoritative scene snapshot."""
return await _call('snapshot', {})
async def context():
"""Read the active native workspace, screen, area and bound editor data."""
return await _call('context', {})
async def command(payload):
"""Apply one WebEngine command through the normal Main transaction path."""
if not isinstance(payload, dict):
raise TypeError('command requires a dictionary')
return await _call('command', payload)
async def operators():
"""List operators implemented by the compiled WebEngine."""
return await _call('operators', {})
async def operator(identifier, **properties):
"""Invoke a source-backed operator in the current WebEngine context."""
return await _call('operator', {'operator': identifier, 'properties': properties})
async def data_blocks(**query):
return await _call('data_blocks', query)
async def properties(**query):
return await _call('properties', query)