mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 13:26:38 +03:00
refine Webxdc documentation
This commit is contained in:
@@ -3699,19 +3699,21 @@ char* dc_msg_get_webxdc_blob (const dc_msg_t* msg, const char*
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get info from a webxdc message, in JSON format.
|
* Get info from a Webxdc extension, in JSON format.
|
||||||
|
* Messages are a Webxdx extensions if dc_msg_get_viewtype() returns @ref DC_MSG_WEBXDC.
|
||||||
|
*
|
||||||
* The returned JSON string has the following key/values:
|
* The returned JSON string has the following key/values:
|
||||||
*
|
*
|
||||||
* - name: The name of the app.
|
* - name: The name of the Webxdc extension.
|
||||||
* Defaults to the filename if not set in the manifest.
|
* Defaults to the filename if not set in the manifest.
|
||||||
* - icon: App icon file name.
|
* - icon: Icon file name.
|
||||||
* Defaults to an standard icon if nothing is set in the manifest.
|
* Defaults to an standard icon if nothing is set in the manifest.
|
||||||
* To get the file, use dc_msg_get_webxdc_blob().
|
* To get the file, use dc_msg_get_webxdc_blob().
|
||||||
* App icons should should be square,
|
* Webxdc extension icons should should be square,
|
||||||
* the implementations will add round corners etc. as needed.
|
* the implementations will add round corners etc. as needed.
|
||||||
* - summary: short string describing the state of the app,
|
* - summary: Short string describing the state of the Webxdc extension,
|
||||||
* sth. as "2 votes", "Highscore: 123",
|
* sth. as "2 votes", "Highscore: 123",
|
||||||
* can be changed by the apps and defaults to an empty string.
|
* can be changed by the Webxdc extensions and defaults to an empty string.
|
||||||
*
|
*
|
||||||
* @memberof dc_msg_t
|
* @memberof dc_msg_t
|
||||||
* @param msg The webxdc instance.
|
* @param msg The webxdc instance.
|
||||||
@@ -3973,9 +3975,9 @@ int dc_msg_is_forwarded (const dc_msg_t* msg);
|
|||||||
* These messages are typically shown in the center of the chat view,
|
* These messages are typically shown in the center of the chat view,
|
||||||
* dc_msg_get_text() returns a descriptive text about what is going on.
|
* dc_msg_get_text() returns a descriptive text about what is going on.
|
||||||
*
|
*
|
||||||
* For informational messages created by Webxdc apps,
|
* For informational messages created by Webxdc extensions,
|
||||||
* dc_msg_get_parent() usually returns the Webxdc instance;
|
* dc_msg_get_parent() usually returns the Webxdc instance;
|
||||||
* UIs can use that to scroll to the Webxdc app when the info is tapped.
|
* UIs can use that to scroll to the Webxdc extension when the info is tapped.
|
||||||
*
|
*
|
||||||
* There is no need to perform any action when seeing such a message - this is already done by the core.
|
* There is no need to perform any action when seeing such a message - this is already done by the core.
|
||||||
*
|
*
|
||||||
@@ -5602,11 +5604,11 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* webxdc status update received.
|
* Webxdc status update received.
|
||||||
* To get the received status update, use dc_get_webxdc_status_updates().
|
* To get the received status update, use dc_get_webxdc_status_updates().
|
||||||
* To send status updates, use dc_send_webxdc_status_update().
|
* To send status updates, use dc_send_webxdc_status_update().
|
||||||
*
|
*
|
||||||
* Note, that you do not get events that arrive when the app is not running;
|
* Note, that you do not get events that arrive when the Webxdc extension is not running;
|
||||||
* instead, you can use dc_get_webxdc_status_updates() to get all status updates
|
* instead, you can use dc_get_webxdc_status_updates() to get all status updates
|
||||||
* and catch up that way.
|
* and catch up that way.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
## Webxdc File Format
|
## Webxdc File Format
|
||||||
|
|
||||||
- a **Webxdc app** is a **ZIP-file** with the extension `.xdc`
|
- a **Webxdc extension** is a **ZIP-file** with the suffix `.xdc`
|
||||||
- the ZIP-file must use the default compression methods as of RFC 1950,
|
- the ZIP-file must use the default compression methods as of RFC 1950,
|
||||||
this is "Deflate" or "Store"
|
this is "Deflate" or "Store"
|
||||||
- the ZIP-file must contain at least the file `index.html`
|
- the ZIP-file must contain at least the file `index.html`
|
||||||
- if the Webxdc app is started, `index.html` is opened in a restricted webview
|
- if the Webxdc extension is tapped, `index.html` is opened in a restricted webview
|
||||||
that allow accessing resources only from the ZIP-file
|
that allow accessing resources only from the ZIP-file
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ no need to add `webxdc.js` to your ZIP-file):
|
|||||||
window.webxdc.sendUpdate(update, descr);
|
window.webxdc.sendUpdate(update, descr);
|
||||||
```
|
```
|
||||||
|
|
||||||
Webxdc apps are usually shared in a chat and run independently on each peer.
|
Webxdc extensions are usually shared in a chat and run independently on each peer.
|
||||||
To get a shared state, the peers use `sendUpdate()` to send updates to each other.
|
To get a shared state, the peers use `sendUpdate()` to send updates to each other.
|
||||||
|
|
||||||
- `update`: an object with the following fields:
|
- `update`: an object with the following fields:
|
||||||
@@ -35,7 +35,7 @@ To get a shared state, the peers use `sendUpdate()` to send updates to each othe
|
|||||||
eg. "Alice voted" or "Bob scored 123 in MyGame";
|
eg. "Alice voted" or "Bob scored 123 in MyGame";
|
||||||
usually only one line of text is shown,
|
usually only one line of text is shown,
|
||||||
use this option sparingly to not spam the chat.
|
use this option sparingly to not spam the chat.
|
||||||
- `update.summary`: optional, short text, shown beside app icon;
|
- `update.summary`: optional, short text, shown beside extension icon;
|
||||||
it is recommended to use some aggregated value, eg. "8 votes", "Highscore: 123"
|
it is recommended to use some aggregated value, eg. "8 votes", "Highscore: 123"
|
||||||
|
|
||||||
- `descr`: short, human-readable description what this update is about.
|
- `descr`: short, human-readable description what this update is about.
|
||||||
@@ -72,9 +72,9 @@ The callback is called for updates sent by you or other peers.
|
|||||||
updates = await window.webxdc.getAllUpdates();
|
updates = await window.webxdc.getAllUpdates();
|
||||||
```
|
```
|
||||||
|
|
||||||
In case your Webxdc was just started,
|
In case your Webxdc extension was just opened,
|
||||||
you may want to reconstruct the state from the last run -
|
you may want to reconstruct the state from the last run -
|
||||||
and also incorporate updates that may have arrived while the app was not running.
|
and also incorporate updates that may have arrived while the extension was not running.
|
||||||
|
|
||||||
- `updates`: All previous updates in an array,
|
- `updates`: All previous updates in an array,
|
||||||
eg. `[{payload: "foo"},{payload: "bar"}]`
|
eg. `[{payload: "foo"},{payload: "bar"}]`
|
||||||
@@ -120,17 +120,17 @@ some basic information are read and used from there.
|
|||||||
the `manifest.toml` has the following format
|
the `manifest.toml` has the following format
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
name = "My App Name"
|
name = "My Extension Name"
|
||||||
```
|
```
|
||||||
|
|
||||||
- **name** - The name of the app.
|
- **name** - The name of the extension.
|
||||||
If no name is set or if there is no manifest, the filename is used as the app name.
|
If no name is set or if there is no manifest, the filename is used as the extension name.
|
||||||
|
|
||||||
|
|
||||||
## App Icon
|
## Extension Icon
|
||||||
|
|
||||||
If the ZIP-root contains an `icon.png` or `icon.jpg`,
|
If the ZIP-root contains an `icon.png` or `icon.jpg`,
|
||||||
these files are used as the icon for the app.
|
these files are used as the icon for the extension.
|
||||||
The icon should be a square at reasonable width/height;
|
The icon should be a square at reasonable width/height;
|
||||||
round corners etc. will be added by the implementations as needed.
|
round corners etc. will be added by the implementations as needed.
|
||||||
If no icon is set, a default icon will be used.
|
If no icon is set, a default icon will be used.
|
||||||
@@ -172,7 +172,7 @@ The following example shows an input field and every input is show on all peers
|
|||||||
|
|
||||||
[Webxdc Development Tool](https://github.com/deltachat/webxdc-dev)
|
[Webxdc Development Tool](https://github.com/deltachat/webxdc-dev)
|
||||||
offers an **Webxdc Simulator** that can be used in many browsers without any installation needed.
|
offers an **Webxdc Simulator** that can be used in many browsers without any installation needed.
|
||||||
You can also use that repository as a template for your own app -
|
You can also use that repository as a template for your own extension -
|
||||||
just clone and start adapting things to your need.
|
just clone and start adapting things to your need.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1268,7 +1268,7 @@ sth_for_the = "future""#
|
|||||||
.await?;
|
.await?;
|
||||||
chat_id.set_draft(&t, Some(&mut instance)).await?;
|
chat_id.set_draft(&t, Some(&mut instance)).await?;
|
||||||
let info = instance.get_webxdc_info(&t).await?;
|
let info = instance.get_webxdc_info(&t).await?;
|
||||||
assert_eq!(info.name, "nice app!");
|
assert_eq!(info.name, "nice extension!");
|
||||||
assert_eq!(info.icon, WEBXDC_DEFAULT_ICON.to_string());
|
assert_eq!(info.icon, WEBXDC_DEFAULT_ICON.to_string());
|
||||||
|
|
||||||
let mut instance = create_webxdc_instance(
|
let mut instance = create_webxdc_instance(
|
||||||
@@ -1531,7 +1531,7 @@ sth_for_the = "future""#
|
|||||||
let chatlist = Chatlist::try_load(&t, 0, None, None).await?;
|
let chatlist = Chatlist::try_load(&t, 0, None, None).await?;
|
||||||
assert_eq!(chatlist.len(), 1);
|
assert_eq!(chatlist.len(), 1);
|
||||||
let summary = chatlist.get_summary(&t, 0, None).await?;
|
let summary = chatlist.get_summary(&t, 0, None).await?;
|
||||||
assert_eq!(summary.text, "nice app!".to_string());
|
assert_eq!(summary.text, "nice extension!".to_string());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user