chore: checkpoint web Blender migration source, tools and docs
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

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>
This commit is contained in:
mes123456
2026-11-10 11:18:01 +08:00
parent 122142c26c
commit f3e21c6b98
6887 changed files with 257154 additions and 12294 deletions

View File

@@ -0,0 +1,64 @@
"""Persistent console and text execution with top-level await."""
import ast
import asyncio
import codeop
import inspect
import linecache
import sys
import types
import web_blender
_main_module = types.ModuleType('__main__')
_namespace = _main_module.__dict__
_namespace['__builtins__'] = __builtins__
_compiler = codeop.CommandCompiler()
_compiler.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT
_lines = []
_filenames = []
async def execute(source, filename, console, run_id):
global _lines
if console:
_lines.append(source)
source = '\n'.join(_lines)
try:
if len(source.encode('utf-8')) > 1048576:
raise ValueError('PYTHON_SOURCE_LIMIT: incomplete console input exceeds 1 MiB')
code = _compiler(source, filename, 'single')
except BaseException:
_lines = []
raise
if code is None:
return 'MORE'
_lines = []
else:
code = compile(source, filename, 'exec', flags=ast.PyCF_ALLOW_TOP_LEVEL_AWAIT)
_namespace['__file__'] = filename
linecache.cache[filename] = (len(source), None, source.splitlines(True), filename)
if filename in _filenames:
_filenames.remove(filename)
_filenames.append(filename)
while len(_filenames) > 32:
linecache.cache.pop(_filenames.pop(0), None)
token = web_blender._session_run.set(run_id)
existing_tasks = asyncio.all_tasks()
previous_main = sys.modules.get('__main__')
sys.modules['__main__'] = _main_module
try:
result = eval(code, _namespace, _namespace)
if inspect.isawaitable(result):
await result
finally:
if previous_main is not None:
sys.modules['__main__'] = previous_main
else:
sys.modules.pop('__main__', None)
web_blender._session_run.reset(token)
for task in asyncio.all_tasks() - existing_tasks:
task.cancel()
return 'MORE' if _lines else 'DONE'
def version():
return sys.version

View File

@@ -0,0 +1,49 @@
"""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)