tauri-plugin-compmd
Shows CompMD documents in a Tauri app: the plugin brings @compmd/sandbox's frames, serves them from a scheme of their own, and tells the page where they are. The design, and why each rule is there, is docs/tauri-plugin.md.
It shares its version with the @compmd packages, and embeds the frames of @compmd/sandbox at that version, so a page uses the sandbox of the same version.
Versions:
- 0.6.0: the first version:
init(), which serves the embedded frames oncompmd://and gives the page their base;Builderfor another scheme or an app's own build of the frames; thebasecommand. (0.0.0is a placeholder with no code.)
Use
default
.plugin
import from "@compmd/sandbox";
const view = .;
view.;
That's all: no build step, nothing to bundle, no permission to grant. Use the @compmd/sandbox of the crate's version: they are released together, and a page of another version gets an error naming both.
If the app sets a content security policy (app.security.csp in tauri.conf.json; Tauri's template sets none), it adds:
frame-src compmd: http://compmd.localhost;
script-src 'self' compmd://localhost/frames/ http://compmd.localhost/frames/;
connect-src 'self' ipc: http://ipc.localhost compmd://localhost/frames/ http://compmd.localhost/frames/;
frame-ancestors 'none'
Customizing
new
.scheme // another scheme's name
.frames_dir // the app's own build of the frames
.build
An app builds its own frames to offer libraries beyond the runtimes (buildLibraries), or to use another scheme. It builds them before tauri build and tauri dev, into a folder it bundles as a resource, with its scheme as their source:
import from "@compmd/sandbox/build";
await ;
and its page asks for base, which the plugin's compmd:default permission grants:
const base = await ;
const view = .;
Keeping frames from the app's commands: a frame's code can't call a command, since Tauri gives its invoke key to the app's own page only. A capability doesn't do it: Tauri counts a page on a scheme the app registers as one of its own. Declare the app's commands (tauri_build::AppManifest) and grant them in the capability, as the example app does.
Building it from this repository
The crate embeds the frames, which cargo make tauri-frames builds into tauri/frames/ from @compmd/sandbox; cargo make tauri-plugin builds them, lints and tests the crate. A crate built without them warns, and serves none.
Status
In development, released with CompMD's packages at the same version. Tested on Linux (WebKitGTK) in CI by the example app, examples/tauri/, and by hand on macOS; iOS and Android aren't tested yet.