Refactor executable library handbooks and improve document reading
This commit is contained in:
1 parent
16c44588d5
commit
c50c515c4a
191 files changed
+29572
-7816
No files matched your search
+490
-120
@@ -10,107 +10,255 @@ import:
|
||||
|
||||
Readable browser effect helpers for WASM clients. Prefer GFM tables + these helpers; do not build effects with json.set chains.
|
||||
|
||||
Build browser effects as ordinary structured values.
|
||||
|
||||
Behavior and limits: Constructing an effect is pure; the official WASM bridge performs it in a browser. Native construction does not prove a DOM update occurred. Keep business logic in Marqdo.
|
||||
|
||||
This single source file is the usage and development manual. Import it directly, or use marqdo call with a function heading below. Parameter tables give types and defaults; required parameters must be supplied. Return tables are progressive contracts; prose describes failure and limits.
|
||||
|
||||
Implementation: [crates/marqdo-wasm/js/marqdo-bridge.js](../crates/marqdo-wasm/js/marqdo-bridge.js)
|
||||
|
||||
For development, keep EN/ZH behavior aligned and compose public libraries first. Add host primitives only at OS or algorithm boundaries and declare their effects. Run marqdo check --narrative-ratio on this file and the real workflows in tests/stdlib_tasks.rs after edits.
|
||||
|
||||
## set_text
|
||||
+ `sel`
|
||||
+ `text`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| text | text | required | Text supplied by the caller |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_text effect map for the official bridge |
|
||||
|
||||
Use `sel`, `text` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Call this function directly:
|
||||
|
||||
```sh
|
||||
marqdo call lib/browser.mq.md set_text 'sel="#status"' 'text="Ready"' --effects none --json
|
||||
```
|
||||
|
||||
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*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`text`))**.
|
||||
Return *[Set the set_text field in the new record](table.put(in=None, at="set_text", value=`m`))*.
|
||||
|
||||
## set_html
|
||||
+ `sel`
|
||||
+ `html`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| html | any | required | HTML fragment; use set_text for ordinary untrusted text |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_html effect map |
|
||||
|
||||
Use `sel`, `html` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build set_html effect map.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=html**
|
||||
*> table.put in=None at="set_html" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`html`))**.
|
||||
Return *[Set the set_html field in the new record](table.put(in=None, at="set_html", value=`m`))*.
|
||||
|
||||
## set_value
|
||||
+ `sel`
|
||||
+ `value`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| value | any | required | Value to transform or store, without mutating the input |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_value effect map |
|
||||
|
||||
Use `sel`, `value` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build set_value effect map.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=value**
|
||||
*> table.put in=None at="set_value" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`value`))**.
|
||||
Return *[Set the set_value field in the new record](table.put(in=None, at="set_value", value=`m`))*.
|
||||
|
||||
## set_class
|
||||
+ `sel`
|
||||
+ `class`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| class | any | required | Space-separated CSS class names |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_class effect map |
|
||||
|
||||
Use `sel`, `class` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build set_class effect map.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=class**
|
||||
*> table.put in=None at="set_class" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`class`))**.
|
||||
Return *[Set the set_class field in the new record](table.put(in=None, at="set_class", value=`m`))*.
|
||||
|
||||
## add_class
|
||||
+ `sel`
|
||||
+ `class`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| class | any | required | Space-separated CSS class names |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build add_class effect map (classList.add; space-separated names OK) |
|
||||
|
||||
Use `sel`, `class` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build add_class effect map (classList.add; space-separated names OK).
|
||||
|
||||
**`m` = > table.put in=None at=sel value=class**
|
||||
*> table.put in=None at="add_class" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`class`))**.
|
||||
Return *[Set the add_class field in the new record](table.put(in=None, at="add_class", value=`m`))*.
|
||||
|
||||
## remove_class
|
||||
+ `sel`
|
||||
+ `class`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| class | any | required | Space-separated CSS class names |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build remove_class effect map |
|
||||
|
||||
Use `sel`, `class` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build remove_class effect map.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=class**
|
||||
*> table.put in=None at="remove_class" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`class`))**.
|
||||
Return *[Set the remove_class field in the new record](table.put(in=None, at="remove_class", value=`m`))*.
|
||||
|
||||
## toggle_class
|
||||
+ `sel`
|
||||
+ `class`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| class | any | required | Space-separated CSS class names |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build toggle_class effect map |
|
||||
|
||||
Use `sel`, `class` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build toggle_class effect map.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=class**
|
||||
*> table.put in=None at="toggle_class" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`class`))**.
|
||||
Return *[Set the toggle_class field in the new record](table.put(in=None, at="toggle_class", value=`m`))*.
|
||||
|
||||
## set_style
|
||||
+ `sel`
|
||||
+ `style`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| style | any | required | CSS property/value record for the target element |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_style effect map; style is a map of CSS properties or a cssText string |
|
||||
|
||||
Use `sel`, `style` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build set_style effect map; style is a map of CSS properties or a cssText string.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=style**
|
||||
*> table.put in=None at="set_style" value=m*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`style`))**.
|
||||
Return *[Set the set_style field in the new record](table.put(in=None, at="set_style", value=`m`))*.
|
||||
|
||||
## set_attr
|
||||
+ `sel`
|
||||
+ `attrs`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| attrs | any | required | HTML attribute/value record for the target element |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build set_attr effect map; attrs is usually a small map of attribute names to values |
|
||||
|
||||
Use `sel`, `attrs` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
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*
|
||||
We retain **`m` = [Return the updated structured value](table.put(in=None, at=`sel`, value=`attrs`))**.
|
||||
Return *[Set the set_attr field in the new record](table.put(in=None, at="set_attr", value=`m`))*.
|
||||
|
||||
## wrap
|
||||
+ `key`
|
||||
+ `value`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| key | text | required | Field name or key required by this operation |
|
||||
| value | any | required | Value to transform or store, without mutating the input |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Single-key effect map wrapper |
|
||||
|
||||
Use `key`, `value` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Single-key effect map wrapper.
|
||||
|
||||
*> table.put in=None at=key value=value*
|
||||
Return *[Return the updated structured value](table.put(in=None, at=`key`, value=`value`))*.
|
||||
|
||||
## merge
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| a | any | required | First browser effect record |
|
||||
| b | any | required | Browser effect record to merge over a |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Merge two effect maps; right-hand keys win |
|
||||
|
||||
Use `a`, `b` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Merge two effect maps; right-hand keys win.
|
||||
|
||||
*> table.merge a=`a` b=`b`*
|
||||
Return *[Merge](table.merge(a=`a`, b=`b`))*.
|
||||
|
||||
## canvas
|
||||
+ `sel`
|
||||
+ `commands`
|
||||
+ `clear`=True
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| commands | any | required | Ordered list of canvas drawing commands |
|
||||
| clear | any | True | Whether the canvas is cleared before drawing commands |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build canvas effect; commands is usually an @ GFM table |
|
||||
|
||||
Use `sel`, `commands`, `clear`=True as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build canvas effect; commands is usually an @ GFM table.
|
||||
|
||||
@@ -120,34 +268,58 @@ Build canvas effect; commands is usually an @ GFM table.
|
||||
|-----|-------|----------|
|
||||
| `sel` | `clear` | `commands` |
|
||||
|
||||
*> table.put in=None at="canvas" value=spec*
|
||||
Return *[Set the canvas field in the new record](table.put(in=None, at="canvas", value=`spec`))*.
|
||||
|
||||
## audio
|
||||
+ `op`="play"
|
||||
+ `id`="default"
|
||||
+ `src`=""
|
||||
+ `freq`=None
|
||||
+ `ms`=None
|
||||
+ `sel`=""
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| op | any | "play" | Audio command: play, pause or stop |
|
||||
| id | any | "default" | Audio channel identifier |
|
||||
| src | text | "" | Audio URL, or beep for a synthesized tone |
|
||||
| freq | any | None | Oscillator frequency in hertz |
|
||||
| ms | any | None | Duration or delay in milliseconds |
|
||||
| sel | any | "" | CSS selector of the target browser element |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build audio effect for the bridge |
|
||||
|
||||
Use `op`="play", `id`="default", `src`="", `freq`=None, `ms`=None, `sel`="" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build audio effect for the bridge.
|
||||
|
||||
**`spec` = > table.put in=None at="op" value=op**
|
||||
**`spec` = > table.put in=`spec` at="id" value=id**
|
||||
This function returns an effect record and plays no sound immediately. The bridge selects a source, synthesized frequency or audio element; browsers may require a prior user gesture.
|
||||
|
||||
We retain **`spec` = [Set the op field in the new record](table.put(in=None, at="op", value=`op`))**.
|
||||
We retain **`spec` = [Set the id field in the new record](table.put(in=`spec`, at="id", value=`id`))**.
|
||||
1. `src` != ""
|
||||
**`spec` = > table.put in=`spec` at="src" value=src**
|
||||
We retain **`spec` = [Set the src field in the new record](table.put(in=`spec`, at="src", value=`src`))**.
|
||||
1. `freq` != None
|
||||
**`spec` = > table.put in=`spec` at="freq" value=freq**
|
||||
We retain **`spec` = [Set the freq field in the new record](table.put(in=`spec`, at="freq", value=`freq`))**.
|
||||
1. `ms` != None
|
||||
**`spec` = > table.put in=`spec` at="ms" value=ms**
|
||||
We retain **`spec` = [Set the ms field in the new record](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*
|
||||
We retain **`spec` = [Set the sel field in the new record](table.put(in=`spec`, at="sel", value=`sel`))**.
|
||||
Return *[Set the audio field in the new record](table.put(in=None, at="audio", value=`spec`))*.
|
||||
|
||||
## read_file
|
||||
+ `sel`
|
||||
+ `then`
|
||||
+ `as`="text"
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
| as | any | "text" | File content representation expected by the browser bridge |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build read_file effect |
|
||||
|
||||
Use `sel`, `then`, `as`="text" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build read_file effect.
|
||||
|
||||
@@ -157,32 +329,80 @@ Build read_file effect.
|
||||
|-----|----|------|
|
||||
| `sel` | `as` | `then` |
|
||||
|
||||
*> table.put in=None at="read_file" value=spec*
|
||||
Return *[Set the read_file field in the new record](table.put(in=None, at="read_file", value=`spec`))*.
|
||||
|
||||
## observe
|
||||
+ `specs`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| specs | any | required | Effect specifications; use a record or an @ row-record list |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build observe effect; specs is one map or an @ list of maps |
|
||||
|
||||
Use `specs` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build observe effect; specs is one map or an @ list of maps.
|
||||
|
||||
*> table.put in=None at="observe" value=specs*
|
||||
Return *[Set the observe field in the new record](table.put(in=None, at="observe", value=`specs`))*.
|
||||
|
||||
## unobserve
|
||||
+ `specs`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| specs | any | required | Effect specifications; use a record or an @ row-record list |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build unobserve effect; specs is a map or @ list with id |
|
||||
|
||||
Use `specs` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build unobserve effect; specs is a map or @ list with id.
|
||||
|
||||
*> table.put in=None at="unobserve" value=specs*
|
||||
Return *[Set the unobserve field in the new record](table.put(in=None, at="unobserve", value=`specs`))*.
|
||||
|
||||
## focus
|
||||
+ `sel`
|
||||
|
||||
focus.
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| sel | any | required | CSS selector of the target browser element |
|
||||
|
||||
*> table.put in=None at="focus" value=sel*
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build a focus effect for the selected element; the browser bridge applies it after the handler returns |
|
||||
|
||||
Use `sel` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build a focus effect for the selected element; the browser bridge applies it after the handler returns.
|
||||
|
||||
Build the focus effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
Return *[Set the focus field in the new record](table.put(in=None, at="focus", value=`sel`))*.
|
||||
|
||||
## navigate
|
||||
+ `url`
|
||||
+ `replace`=False
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| url | text | required | Target URL; HTTP helpers accept http or https |
|
||||
| replace | any | False | Whether navigation replaces the current history entry |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the navigate effect record |
|
||||
|
||||
Use `url`, `replace`=False as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the navigate effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -190,13 +410,24 @@ focus.
|
||||
|-----|---------|
|
||||
| `url` | `replace` |
|
||||
|
||||
*> table.put in=None at="navigate" value=spec*
|
||||
Return *[Set the navigate field in the new record](table.put(in=None, at="navigate", value=`spec`))*.
|
||||
|
||||
## store_set
|
||||
+ `key`
|
||||
+ `value`
|
||||
+ `scope`="memory"
|
||||
+ `then`=""
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| key | text | required | Field name or key required by this operation |
|
||||
| value | any | required | Value to transform or store, without mutating the input |
|
||||
| scope | any | "memory" | Storage scope: memory, local or session |
|
||||
| then | any | "" | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | In-memory (or local/session) key write for SPA client state |
|
||||
|
||||
Use `key`, `value`, `scope`="memory", `then`="" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
In-memory (or local/session) key write for SPA client state. Prefer `scope=memory` for tab-local app state.
|
||||
Optional `then` is called after the write with `{ok, op, key, scope}`.
|
||||
@@ -204,31 +435,53 @@ Optional `then` is called after the write with `{ok, op, key, scope}`.
|
||||
`spec` =
|
||||
|
||||
| op | key | value | scope |
|
||||
|----|-----|-------|-------|
|
||||
| ---- | ----- | ------- | ------- |
|
||||
| set | `key` | `value` | `scope` |
|
||||
|
||||
1. `then` != ""
|
||||
**`spec` = > table.put in=spec at="then" value=then**
|
||||
*> table.put in=None at="storage" value=spec*
|
||||
We retain **`spec` = [Set the then field in the new record](table.put(in=`spec`, at="then", value=`then`))**.
|
||||
Return *[Set the storage field in the new record](table.put(in=None, at="storage", value=`spec`))*.
|
||||
|
||||
## store_get
|
||||
+ `key`
|
||||
+ `then`
|
||||
+ `scope`="memory"
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| key | text | required | Field name or key required by this operation |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
| scope | any | "memory" | Storage scope: memory, local or session |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Read a key then call `then` with `{ok, value, found, key, scope}` |
|
||||
|
||||
Use `key`, `then`, `scope`="memory" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Read a key then call `then` with `{ok, value, found, key, scope}`.
|
||||
|
||||
`spec` =
|
||||
|
||||
| op | key | then | scope |
|
||||
|----|-----|------|-------|
|
||||
| ---- | ----- | ------ | ------- |
|
||||
| get | `key` | `then` | `scope` |
|
||||
|
||||
*> table.put in=None at="storage" value=spec*
|
||||
Return *[Set the storage field in the new record](table.put(in=None, at="storage", value=`spec`))*.
|
||||
|
||||
## spa_goto
|
||||
+ `url`
|
||||
+ `replace`=False
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| url | text | required | Target URL; HTTP helpers accept http or https |
|
||||
| replace | any | False | Whether navigation replaces the current history entry |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | SPA navigation: `history.pushState` / `replaceState` via bridge `navigate` effect |
|
||||
|
||||
Use `url`, `replace`=False as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
SPA navigation: `history.pushState` / `replaceState` via bridge `navigate` effect.
|
||||
|
||||
@@ -238,19 +491,45 @@ SPA navigation: `history.pushState` / `replaceState` via bridge `navigate` effec
|
||||
|-----|---------|
|
||||
| `url` | `replace` |
|
||||
|
||||
*> table.put in=None at="navigate" value=spec*
|
||||
Return *[Set the navigate field in the new record](table.put(in=None, at="navigate", value=`spec`))*.
|
||||
|
||||
## storage
|
||||
+ `spec`
|
||||
|
||||
storage.
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| spec | any | required | Storage operation record: op, key, scope and optional value/then |
|
||||
|
||||
*> table.put in=None at="storage" value=spec*
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Wrap one storage specification as a browser effect; the bridge handles op, key, value, scope and then |
|
||||
|
||||
Use `spec` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Wrap one storage specification as a browser effect; the bridge handles op, key, value, scope and then.
|
||||
|
||||
Build the storage effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
Return *[Set the storage field in the new record](table.put(in=None, at="storage", value=`spec`))*.
|
||||
|
||||
## interval
|
||||
+ `ms`
|
||||
+ `then`
|
||||
+ `id`="default"
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| ms | any | required | Duration or delay in milliseconds |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
| id | any | "default" | Timer identifier, later passed to clear_interval |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the interval effect record |
|
||||
|
||||
Use `ms`, `then`, `id`="default" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the interval effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -258,20 +537,46 @@ storage.
|
||||
|----|------|----|
|
||||
| `ms` | `then` | `id` |
|
||||
|
||||
*> table.put in=None at="interval" value=spec*
|
||||
Return *[Set the interval field in the new record](table.put(in=None, at="interval", value=`spec`))*.
|
||||
|
||||
## clear_interval
|
||||
+ `id`="default"
|
||||
|
||||
clear_interval.
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| id | any | "default" | Identifier returned by the corresponding create/spawn operation |
|
||||
|
||||
**`spec` = > table.put in=None at="id" value=id**
|
||||
*> table.put in=None at="clear_interval" value=spec*
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build a cancellation effect using the same identifier previously supplied to interval |
|
||||
|
||||
Use `id`="default" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build a cancellation effect using the same identifier previously supplied to interval.
|
||||
|
||||
Build the clear_interval effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
We retain **`spec` = [Set the id field in the new record](table.put(in=None, at="id", value=`id`))**.
|
||||
Return *[Set the clear_interval field in the new record](table.put(in=None, at="clear_interval", value=`spec`))*.
|
||||
|
||||
## fetch
|
||||
+ `url`
|
||||
+ `then`
|
||||
+ `method`="GET"
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| url | text | required | Target URL; HTTP helpers accept http or https |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
| method | text | "GET" | HTTP method, for example GET or POST |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the fetch effect record |
|
||||
|
||||
Use `url`, `then`, `method`="GET" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the fetch effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -279,11 +584,24 @@ clear_interval.
|
||||
|-----|------|--------|
|
||||
| `url` | `then` | `method` |
|
||||
|
||||
*> table.put in=None at="fetch" value=spec*
|
||||
Return *[Set the fetch field in the new record](table.put(in=None, at="fetch", value=`spec`))*.
|
||||
|
||||
## fetch_all
|
||||
+ `requests`
|
||||
+ `then`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| requests | any | required | Ordered list of browser request specification records |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the fetch_all effect record |
|
||||
|
||||
Use `requests`, `then` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the fetch_all effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -291,11 +609,24 @@ clear_interval.
|
||||
|----------|------|
|
||||
| `requests` | `then` |
|
||||
|
||||
*> table.put in=None at="fetch_all" value=spec*
|
||||
Return *[Set the fetch_all field in the new record](table.put(in=None, at="fetch_all", value=`spec`))*.
|
||||
|
||||
## after
|
||||
+ `ms`
|
||||
+ `then`
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| ms | any | required | Duration or delay in milliseconds |
|
||||
| then | any | required | Marqdo callback name for the bridge result; empty text omits callback |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the after effect record |
|
||||
|
||||
Use `ms`, `then` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the after effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -303,27 +634,66 @@ clear_interval.
|
||||
|----|------|
|
||||
| `ms` | `then` |
|
||||
|
||||
*> table.put in=None at="after" value=spec*
|
||||
Return *[Set the after field in the new record](table.put(in=None, at="after", value=`spec`))*.
|
||||
|
||||
## ws
|
||||
+ `spec`
|
||||
|
||||
ws.
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| spec | any | required | One bridge effect specification record |
|
||||
|
||||
*> table.put in=None at="ws" value=spec*
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Wrap a WebSocket operation specification for the browser bridge; this function opens no native socket |
|
||||
|
||||
Use `spec` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Wrap a WebSocket operation specification for the browser bridge; this function opens no native socket.
|
||||
|
||||
Build the ws effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
Return *[Set the ws field in the new record](table.put(in=None, at="ws", value=`spec`))*.
|
||||
|
||||
## clipboard
|
||||
+ `text`
|
||||
|
||||
clipboard.
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| text | text | required | Text supplied by the caller |
|
||||
|
||||
**`spec` = > table.put in=None at="text" value=text**
|
||||
*> table.put in=None at="clipboard" value=spec*
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build a clipboard effect from the text; browser permissions and user-gesture requirements apply when consumed |
|
||||
|
||||
Use `text` as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build a clipboard effect from the text; browser permissions and user-gesture requirements apply when consumed.
|
||||
|
||||
Build the clipboard effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
We retain **`spec` = [Set the text field in the new record](table.put(in=None, at="text", value=`text`))**.
|
||||
Return *[Set the clipboard field in the new record](table.put(in=None, at="clipboard", value=`spec`))*.
|
||||
|
||||
## download
|
||||
+ `body`
|
||||
+ `filename`="download.txt"
|
||||
+ `mime`="text/plain;charset=utf-8"
|
||||
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| body | any | required | Request body, or replacement text for document operations |
|
||||
| filename | any | "download.txt" | Suggested download filename |
|
||||
| mime | any | "text/plain;charset=utf-8" | Content MIME type |
|
||||
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | map | Build the download effect record |
|
||||
|
||||
Use `body`, `filename`="download.txt", `mime`="text/plain;charset=utf-8" as the inputs for this operation.
|
||||
|
||||
Effects: pure.
|
||||
|
||||
Build the download effect record. The browser bridge consumes this record; this function itself does not change the page.
|
||||
|
||||
`spec` =
|
||||
|
||||
@@ -331,4 +701,4 @@ clipboard.
|
||||
|------|----------|------|
|
||||
| `body` | `filename` | `mime` |
|
||||
|
||||
*> table.put in=None at="download" value=spec*
|
||||
Return *[Set the download field in the new record](table.put(in=None, at="download", value=`spec`))*.
|
||||
Reference in new issue
Block a user