Skip to content

API Reference parrot_formdesigner.renderers.worker_bridge

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.renderers.worker_bridge

View source

Web Worker boot block + patch allowlist (FEAT-459 / M13, OQ-7).

Generates the additive JS block injected into html5.py's _LIFECYCLE_SCRIPT_TEMPLATE. The Worker itself has NO DOM (G6) and communicates via postMessage; the HOST page applies patches through a fixed six-operation allowlist. The existing fetch-based remote bridge in _LIFECYCLE_SCRIPT_TEMPLATE is untouched — this module is purely additive.

Attribute ALLOWED_PATCH_OPERATIONS

Type: frozenset[str]

Attribute logger

Function render_worker_boot_block

Generate the additive Worker boot block for _LIFECYCLE_SCRIPT_TEMPLATE.

The returned string uses the sentinel SNIPPET_CLIENT_SOURCES (a JSON array of compiled JS strings, one per bundle with a client_source) — html5.py's _inject_lifecycle() must .replace() it the same way it already replaces FORM_ID etc.

render_worker_boot_block() -> str

Returns: str — A raw JS string (no Python f-string interpolation — matching the existing template's SENTINEL convention) implementing: 1. Worker instantiation from a Blob (so no separate static file is needed per form — the compiled snippet client_source(s) are embedded via the SNIPPET_CLIENT_SOURCES sentinel). 2. A postMessage listener applying ONLY the six allowlisted ops. 3. No DOM access inside the Worker's own script body.

Function validate_patch

True if patch names an allowlisted operation with a field_uid.

This is the Python-side mirror of the host-page's JS allowlist check — used wherever a patch is inspected/logged server-side (e.g. security auditing), NOT the actual client-side enforcement (which runs as generated JS in the browser, see render_worker_boot_block()).

validate_patch(patch: dict) -> bool

Parameter Type Default Description
patch dict

Returns: bool

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally