rapier-html 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUILD.json +4 -4
- package/README.md +12 -11
- package/dist/page.mjs +20 -9
- package/dist/rapier.html +54 -45
- package/dist/wrap.mjs +50 -0
- package/package.json +1 -1
package/BUILD.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "rapier-html",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"path": "dist/rapier.html",
|
|
5
|
-
"bytes":
|
|
6
|
-
"sha256": "
|
|
7
|
-
"builtAt": "2026-10-
|
|
5
|
+
"bytes": 5886529,
|
|
6
|
+
"sha256": "1fda3f30b4140f90c74cef0ea3fce795e9a9672ed7c37a4d393d42dfcf1de8c1",
|
|
7
|
+
"builtAt": "2026-10-16T19:38:46.299Z",
|
|
8
8
|
"node": "v22.23.3",
|
|
9
9
|
"canonical": true,
|
|
10
10
|
"packing": "zopfli",
|
package/README.md
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Turn Markdown into one offline HTML file that contains the full Rapier editor. It opens in any browser, on a phone or
|
|
4
4
|
computer, with no account. People read, edit, draw and paint; agents hand over documents, show what changed and get
|
|
5
|
-
the edited copy back. Start with `npx rapier-html@1.2.
|
|
5
|
+
the edited copy back. Start with `npx rapier-html@1.2.7 notes.md`.
|
|
6
6
|
|
|
7
7
|
Use it for a plan to rearrange, a guide to annotate, a draft to keep writing, or a revision to review. The file works
|
|
8
8
|
without any hosted workspace.
|
|
9
9
|
|
|
10
|
-
- The page writes,
|
|
11
|
-
|
|
10
|
+
- The page writes, saves Markdown, exports Word, PDF and a web page, and prints. It needs no account and fetches
|
|
11
|
+
nothing to open, edit or save. It is the base editor (about 1.7 MB) with the plug-ins the document displays with
|
|
12
|
+
(Math, Mermaid); `--include draw` adds drawing and painting. Notes never travel.
|
|
12
13
|
- `--return` adds a one-use Send back address from the agent door.
|
|
13
14
|
- `--view draw` opens on Draw. `--compare original.md` opens the edit with its diff; `--by <name>` attributes it.
|
|
14
15
|
- `wrap` and `unwrap` move a document into a page and back out, exactly.
|
|
@@ -16,14 +17,14 @@ without any hosted workspace.
|
|
|
16
17
|
Needs Node 22 or newer.
|
|
17
18
|
|
|
18
19
|
```sh
|
|
19
|
-
npx -- rapier-html@1.2.
|
|
20
|
-
npx -- rapier-html@1.2.
|
|
21
|
-
npx -- rapier-html@1.2.
|
|
22
|
-
npx -- rapier-html@1.2.
|
|
23
|
-
npx -- rapier-html@1.2.
|
|
24
|
-
npx -- rapier-html@1.2.
|
|
25
|
-
npx -- rapier-html@1.2.
|
|
26
|
-
npm install rapier-html@1.2.
|
|
20
|
+
npx -- rapier-html@1.2.7 notes.md # the editor, notes.md inside it, written beside the file
|
|
21
|
+
npx -- rapier-html@1.2.7 notes.md --view draw # opens on Draw: sketch and paint, the document behind it
|
|
22
|
+
npx -- rapier-html@1.2.7 notes.md --include draw,math # carries Draw and Math (default: what the document needs)
|
|
23
|
+
npx -- rapier-html@1.2.7 notes.md --drawing sketch.svg # carries a drawing, opened on Draw over the document
|
|
24
|
+
npx -- rapier-html@1.2.7 revised.md --compare original.md # opens showing what changed
|
|
25
|
+
npx -- rapier-html@1.2.7 notes.md --return "$RETURN_URL" --return-expires-at "$RETURN_EXPIRES_AT" # Send back
|
|
26
|
+
npx -- rapier-html@1.2.7 notes.md out.html # a named output
|
|
27
|
+
npm install rapier-html@1.2.7 # as a library: wrap, unwrap
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
The first `--` is for npm, so `--help` reaches the command. It never overwrites a file.
|
package/dist/page.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import {readFile, writeFile} from 'node:fs/promises';
|
|
3
3
|
import {basename, dirname, join} from 'node:path';
|
|
4
|
-
import {wrap} from './wrap.mjs';
|
|
4
|
+
import {wrap, carry, portableNeeds} from './wrap.mjs';
|
|
5
5
|
import {returnAddress, returnExpiresAt} from './return-address.mjs';
|
|
6
|
-
export {wrap, unwrap, encodeCarried, decodeCarried} from './wrap.mjs';
|
|
6
|
+
export {wrap, unwrap, carry, portableNeeds, encodeCarried, decodeCarried} from './wrap.mjs';
|
|
7
7
|
// Unknown options, a bare --drawing or --compare and a third name are refused.
|
|
8
|
-
const USAGE = 'usage: rapier-html <document.md> [out.html] [--view draw
|
|
8
|
+
const USAGE = 'usage: rapier-html <document.md> [out.html] [--include draw,math,mermaid] [--view draw] [--drawing sketch.svg] [--compare original.md [--by <your name>]] [--return <url> --return-expires-at <timestamp>]\n' +
|
|
9
9
|
' writes <document>.rapier.html beside the file: Rapier with the document inside it, one file, offline.\n' +
|
|
10
10
|
' It never overwrites: an output that already exists, the document itself included, is refused.\n' +
|
|
11
|
-
' --
|
|
11
|
+
' --include what the file carries beyond the base editor: draw (drawing and painting), math, mermaid, or none;\n' +
|
|
12
|
+
' by default, the plug-ins the document displays with, and Draw for --view draw or --drawing\n' +
|
|
13
|
+
' --view draw: opens the page on Draw (sketch and paint, the document behind it)\n' +
|
|
12
14
|
' --drawing carries an SVG drawing alongside the document, opened on Draw as the page boots\n' +
|
|
13
15
|
' --compare carries the original text; the page opens showing its diff from the current document\n' +
|
|
14
16
|
' --by with --compare: the name shown on the diff with the time the page was made\n' +
|
|
@@ -21,16 +23,22 @@ const text = async path => { try { return new TextDecoder('utf-8', {fatal: true,
|
|
|
21
23
|
|
|
22
24
|
export async function main(argv, pagesDir, {log = console.log} = {}) {
|
|
23
25
|
const names = [];
|
|
24
|
-
let drawingPath = null, basePath = null, by = null, view = null, address = null, expiry = null, onlyNames = false;
|
|
26
|
+
let drawingPath = null, basePath = null, by = null, view = null, address = null, expiry = null, include = null, onlyNames = false;
|
|
25
27
|
for (let i = 0; i < argv.length; i++) {
|
|
26
28
|
const arg = argv[i];
|
|
27
29
|
if (onlyNames || !arg.startsWith('-')) names.push(arg);
|
|
28
30
|
else if (arg === '--') onlyNames = true;
|
|
29
31
|
else if (arg === '--help') { log(USAGE); return null; }
|
|
30
32
|
else if (arg === '--view') {
|
|
31
|
-
if (view !== null ||
|
|
33
|
+
if (view !== null || argv[i + 1] !== 'draw') throw new Error('--view takes draw');
|
|
32
34
|
view = argv[++i];
|
|
33
35
|
}
|
|
36
|
+
else if (arg === '--include') {
|
|
37
|
+
const listed = argv[i + 1] === 'none' ? [] : String(argv[i + 1] || '').split(',');
|
|
38
|
+
if (include !== null || listed.some(item => !['draw', 'math', 'mermaid'].includes(item))) throw new Error('--include takes draw, math and mermaid, comma-separated, or none');
|
|
39
|
+
include = listed.map(item => item === 'draw' ? 'drawing' : item);
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
34
42
|
else if (arg === '--compare') {
|
|
35
43
|
if (basePath !== null || !argv[i + 1] || argv[i + 1].startsWith('-')) throw new Error('--compare takes one text file (write a name that starts with a dash as ./-original.md)');
|
|
36
44
|
basePath = argv[++i];
|
|
@@ -66,9 +74,12 @@ export async function main(argv, pagesDir, {log = console.log} = {}) {
|
|
|
66
74
|
if (address) wrapOptions.return = address;
|
|
67
75
|
if (expiry) wrapOptions.return_expires_at = expiry;
|
|
68
76
|
// Always a new file; 'wx' refuses any existing path, links included.
|
|
69
|
-
|
|
77
|
+
const carries = include || [...(view === 'draw' || drawingPath ? ['drawing'] : []), ...portableNeeds(source, {base: wrapOptions.base})];
|
|
78
|
+
const html = wrap(carry(page, carries), source, name, wrapOptions);
|
|
79
|
+
try { await writeFile(out, html, {flag: 'wx'}); }
|
|
70
80
|
catch (error) { throw error.code === 'EEXIST' ? new Error(out + ' already exists, and rapier-html never overwrites a file: name a new one') : error; }
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
const labels = {drawing: 'Draw', math: 'Math', mermaid: 'Mermaid'};
|
|
82
|
+
log(out + ' (' + name + ', ' + Buffer.byteLength(source) + ' bytes of document, ' + Buffer.byteLength(html) + ' bytes in all, the base editor' +
|
|
83
|
+
[...new Set(carries)].map(id => ' + ' + labels[id]).join('') + (view ? ', opens on Draw' : '') + (drawingPath ? ', ' + basename(drawingPath) + ' drawing' : '') + (basePath ? ', its diff from ' + basename(basePath) : '') + ')');
|
|
73
84
|
return out;
|
|
74
85
|
}
|