feat(wasm): route F host media APIs + GFM-first browser authoring

Ship bridge effects for file/canvas/audio/observers/drag-drop with
browser-media demo; add lib/browser and marqdo-dev skill so clients
use tables/helpers instead of json.set glue.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-04 10:05:46 +08:00
1 parent f19f614e0d
commit c080b79c5b
29 files changed
+3744 -239

No files matched your search

+236
View File
@@ -0,0 +1,236 @@
---
title: lib/browser
description: >-
Readable browser effect helpers for WASM clients. Prefer GFM tables + these
helpers; do not build effects with json.set chains.
import table:lib/table.mq.md
---
## set_text
+ `sel`
+ `text`
Build set_text effect map for the official bridge.
*`m` = > table.put in=None at=sel value=text*
**> table.put in=None at="set_text" value=m**
## set_html
+ `sel`
+ `html`
Build set_html effect map.
*`m` = > table.put in=None at=sel value=html*
**> table.put in=None at="set_html" value=m**
## set_value
+ `sel`
+ `value`
Build set_value effect map.
*`m` = > table.put in=None at=sel value=value*
**> table.put in=None at="set_value" value=m**
## set_class
+ `sel`
+ `class`
Build set_class effect map.
*`m` = > table.put in=None at=sel value=class*
**> table.put in=None at="set_class" value=m**
## set_attr
+ `sel`
+ `attrs`
Build set_attr effect map; attrs is usually a small map of attribute names to values.
*`m` = > table.put in=None at=sel value=attrs*
**> table.put in=None at="set_attr" value=m**
## wrap
+ `key`
+ `value`
Single-key effect map wrapper.
**> table.put in=None at=key value=value**
## merge
+ `a`
+ `b`
Merge two effect maps; right-hand keys win.
**> table.merge a=`a` b=`b`**
## canvas
+ `sel`
+ `commands`
+ `clear`=True
Build canvas effect; commands is usually an @ GFM table.
`spec` =
| sel | clear | commands |
|-----|-------|----------|
| `sel` | `clear` | `commands` |
**> table.put in=None at="canvas" value=spec**
## audio
+ `op`="play"
+ `id`="default"
+ `src`=""
+ `freq`=None
+ `ms`=None
+ `sel`=""
Build audio effect for the bridge.
*`spec` = > table.put in=None at="op" value=op*
*`spec` = > table.put in=`spec` at="id" value=id*
1. `src` != ""
*`spec` = > table.put in=`spec` at="src" value=src*
1. `freq` != None
*`spec` = > table.put in=`spec` at="freq" value=freq*
1. `ms` != None
*`spec` = > table.put in=`spec` at="ms" value=ms*
1. `sel` != ""
*`spec` = > table.put in=`spec` at="sel" value=sel*
**> table.put in=None at="audio" value=spec**
## read_file
+ `sel`
+ `then`
+ `as`="text"
Build read_file effect.
`spec` =
| sel | as | then |
|-----|----|------|
| `sel` | `as` | `then` |
**> table.put in=None at="read_file" value=spec**
## observe
+ `specs`
Build observe effect; specs is one map or an @ list of maps.
**> table.put in=None at="observe" value=specs**
## unobserve
+ `specs`
Build unobserve effect; specs is a map or @ list with id.
**> table.put in=None at="unobserve" value=specs**
## focus
+ `sel`
**> table.put in=None at="focus" value=sel**
## navigate
+ `url`
+ `replace`=False
`spec` =
| url | replace |
|-----|---------|
| `url` | `replace` |
**> table.put in=None at="navigate" value=spec**
## storage
+ `spec`
**> table.put in=None at="storage" value=spec**
## interval
+ `ms`
+ `then`
+ `id`="default"
`spec` =
| ms | then | id |
|----|------|----|
| `ms` | `then` | `id` |
**> table.put in=None at="interval" value=spec**
## clear_interval
+ `id`="default"
*`spec` = > table.put in=None at="id" value=id*
**> table.put in=None at="clear_interval" value=spec**
## fetch
+ `url`
+ `then`
+ `method`="GET"
`spec` =
| url | then | method |
|-----|------|--------|
| `url` | `then` | `method` |
**> table.put in=None at="fetch" value=spec**
## fetch_all
+ `requests`
+ `then`
`spec` =
| requests | then |
|----------|------|
| `requests` | `then` |
**> table.put in=None at="fetch_all" value=spec**
## after
+ `ms`
+ `then`
`spec` =
| ms | then |
|----|------|
| `ms` | `then` |
**> table.put in=None at="after" value=spec**
## ws
+ `spec`
**> table.put in=None at="ws" value=spec**
## clipboard
+ `text`
*`spec` = > table.put in=None at="text" value=text*
**> table.put in=None at="clipboard" value=spec**
## download
+ `body`
+ `filename`="download.txt"
+ `mime`="text/plain;charset=utf-8"
`spec` =
| body | filename | mime |
|------|----------|------|
| `body` | `filename` | `mime` |
**> table.put in=None at="download" value=spec**
+235
View File
@@ -0,0 +1,235 @@
---
title: lib/浏览器
description: >-
浏览器效应助手(WASM 客户端)。优先 GFM 表格 + 本库;勿用 json.set 链拼效应。
import table:lib/table.mq.md
---
## 设文本
+ `选择器`
+ `文本`
构造 set_text 效应。
*`m` = > table.put in=None at=选择器 value=文本*
**> table.put in=None at="set_text" value=m**
## 设HTML
+ `选择器`
+ `html`
构造 set_html 效应。
*`m` = > table.put in=None at=选择器 value=html*
**> table.put in=None at="set_html" value=m**
## 设值
+ `选择器`
+ `值`
构造 set_value 效应。
*`m` = > table.put in=None at=选择器 value=值*
**> table.put in=None at="set_value" value=m**
## 设类
+ `选择器`
+ `类`
构造 set_class 效应。
*`m` = > table.put in=None at=选择器 value=类*
**> table.put in=None at="set_class" value=m**
## 设属性
+ `选择器`
+ `属性`
构造 set_attr 效应。
*`m` = > table.put in=None at=选择器 value=属性*
**> table.put in=None at="set_attr" value=m**
## 包装
+ `键`
+ `值`
单键效应包装。
**> table.put in=None at=键 value=值**
## 合并
+ `甲`
+ `乙`
合并两张效应表,右侧优先。
**> table.merge a=`甲` b=`乙`**
## 画布
+ `选择器`
+ `命令`
+ `清空`=True
构造 canvas 效应;命令一般为 @ 行表。
`spec` =
| sel | clear | commands |
|-----|-------|----------|
| `选择器` | `清空` | `命令` |
**> table.put in=None at="canvas" value=spec**
## 音频
+ `操作`="play"
+ `id`="default"
+ `源`=""
+ `频率`=None
+ `毫秒`=None
+ `选择器`=""
构造 audio 效应。
*`spec` = > table.put in=None at="op" value=操作*
*`spec` = > table.put in=`spec` at="id" value=id*
1. `源` != ""
*`spec` = > table.put in=`spec` at="src" value=源*
1. `频率` != None
*`spec` = > table.put in=`spec` at="freq" value=频率*
1. `毫秒` != None
*`spec` = > table.put in=`spec` at="ms" value=毫秒*
1. `选择器` != ""
*`spec` = > table.put in=`spec` at="sel" value=选择器*
**> table.put in=None at="audio" value=spec**
## 读文件
+ `选择器`
+ `然后`
+ `格式`="text"
构造 read_file 效应。
`spec` =
| sel | as | then |
|-----|----|------|
| `选择器` | `格式` | `然后` |
**> table.put in=None at="read_file" value=spec**
## 观察
+ `规格`
构造 observe 效应。
**> table.put in=None at="observe" value=规格**
## 取消观察
+ `规格`
构造 unobserve 效应。
**> table.put in=None at="unobserve" value=规格**
## 聚焦
+ `选择器`
**> table.put in=None at="focus" value=选择器**
## 导航
+ `url`
+ `替换`=False
`spec` =
| url | replace |
|-----|---------|
| `url` | `替换` |
**> table.put in=None at="navigate" value=spec**
## 存储
+ `规格`
**> table.put in=None at="storage" value=规格**
## 定时
+ `毫秒`
+ `然后`
+ `id`="default"
`spec` =
| ms | then | id |
|----|------|----|
| `毫秒` | `然后` | `id` |
**> table.put in=None at="interval" value=spec**
## 清定时
+ `id`="default"
*`spec` = > table.put in=None at="id" value=id*
**> table.put in=None at="clear_interval" value=spec**
## 拉取
+ `url`
+ `然后`
+ `方法`="GET"
`spec` =
| url | then | method |
|-----|------|--------|
| `url` | `然后` | `方法` |
**> table.put in=None at="fetch" value=spec**
## 拉取全部
+ `请求`
+ `然后`
`spec` =
| requests | then |
|----------|------|
| `请求` | `然后` |
**> table.put in=None at="fetch_all" value=spec**
## 延后
+ `毫秒`
+ `然后`
`spec` =
| ms | then |
|----|------|
| `毫秒` | `然后` |
**> table.put in=None at="after" value=spec**
## 套接字
+ `规格`
**> table.put in=None at="ws" value=规格**
## 剪贴板
+ `文本`
*`spec` = > table.put in=None at="text" value=文本*
**> table.put in=None at="clipboard" value=spec**
## 下载
+ `正文`
+ `文件名`="download.txt"
+ `mime`="text/plain;charset=utf-8"
`spec` =
| body | filename | mime |
|------|----------|------|
| `正文` | `文件名` | `mime` |
**> table.put in=None at="download" value=spec**