rapier-html 1.2.7 → 1.2.8
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 +10 -10
- package/README.md +17 -16
- package/dist/cli.mjs +1 -0
- package/dist/page.d.mts +59 -0
- package/dist/page.mjs +10 -0
- package/dist/rapier.html +247 -68
- package/dist/wrap.mjs +4 -3
- package/package.json +6 -2
package/BUILD.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": "rapier-html",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"path": "dist/rapier.html",
|
|
5
|
-
"bytes":
|
|
6
|
-
"sha256": "
|
|
7
|
-
"builtAt": "2026-10-
|
|
5
|
+
"bytes": 5936307,
|
|
6
|
+
"sha256": "93e8ba922a0df18a75196a1a87971ac80d61b5a4a06630512abb25c94a23ff3f",
|
|
7
|
+
"builtAt": "2026-10-17T01:08:23.274Z",
|
|
8
8
|
"node": "v22.23.3",
|
|
9
9
|
"canonical": true,
|
|
10
10
|
"packing": "zopfli",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"delivery": "built-in",
|
|
15
15
|
"kind": "script",
|
|
16
16
|
"element": "rapier-plugin-math",
|
|
17
|
-
"bytes":
|
|
18
|
-
"packedBytes":
|
|
17
|
+
"bytes": 695410,
|
|
18
|
+
"packedBytes": 439180,
|
|
19
19
|
"files": [
|
|
20
20
|
{
|
|
21
21
|
"id": "rapier-math",
|
|
22
|
-
"name": "rapier-math-2.
|
|
23
|
-
"version": "2.
|
|
24
|
-
"bytes":
|
|
25
|
-
"sri": "
|
|
22
|
+
"name": "rapier-math-2.5.0.js",
|
|
23
|
+
"version": "2.5.0",
|
|
24
|
+
"bytes": 695410,
|
|
25
|
+
"sri": "VDN0hcZbJ7LFS7fJjiUV/8THDfLxUWNfbGZQkggQptiaw4JaNAjZOmyK0kDRLNN3"
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
},
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.8 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.
|
|
@@ -12,19 +12,19 @@ without any hosted workspace.
|
|
|
12
12
|
(Math, Mermaid); `--include draw` adds drawing and painting. Notes never travel.
|
|
13
13
|
- `--return` adds a one-use Send back address from the agent door.
|
|
14
14
|
- `--view draw` opens on Draw. `--compare original.md` opens the edit with its diff; `--by <name>` attributes it.
|
|
15
|
-
- `
|
|
15
|
+
- `writePage(text, name)` makes the page in one call; `unwrap` gives the document back, exactly.
|
|
16
16
|
|
|
17
17
|
Needs Node 22 or newer.
|
|
18
18
|
|
|
19
19
|
```sh
|
|
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
|
-
npx -- rapier-html@1.2.
|
|
27
|
-
npm install rapier-html@1.2.
|
|
20
|
+
npx -- rapier-html@1.2.8 notes.md # the editor, notes.md inside it, written beside the file
|
|
21
|
+
npx -- rapier-html@1.2.8 notes.md --view draw # opens on Draw: sketch and paint, the document behind it
|
|
22
|
+
npx -- rapier-html@1.2.8 notes.md --include draw,math # carries Draw and Math (default: what the document needs)
|
|
23
|
+
npx -- rapier-html@1.2.8 notes.md --drawing sketch.svg # carries a drawing, opened on Draw over the document
|
|
24
|
+
npx -- rapier-html@1.2.8 revised.md --compare original.md # opens showing what changed
|
|
25
|
+
npx -- rapier-html@1.2.8 notes.md --return "$RETURN_URL" --return-expires-at "$RETURN_EXPIRES_AT" # Send back
|
|
26
|
+
npx -- rapier-html@1.2.8 notes.md out.html # a named output
|
|
27
|
+
npm install rapier-html@1.2.8 # as a library: writePage, unwrap
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
The first `--` is for npm, so `--help` reaches the command. It never overwrites a file.
|
|
@@ -60,20 +60,21 @@ current document. After expiry or a refusal, Share offers Save instead; bring th
|
|
|
60
60
|
Save this as `example.mjs` in the folder you installed into, then run `node example.mjs`:
|
|
61
61
|
|
|
62
62
|
```js
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
63
|
+
import {writeFile} from 'node:fs/promises';
|
|
64
|
+
import {writePage, unwrap} from 'rapier-html';
|
|
65
65
|
|
|
66
|
-
const rapier = await readFile(new URL('./rapier.html', import.meta.resolve('rapier-html')), 'utf8');
|
|
67
66
|
const words = '# Hello\r\n\r\nA note about </script> and C:\\Users\\me.\n';
|
|
68
|
-
const page =
|
|
67
|
+
const page = await writePage(words, 'hello.md', {view: 'draw'}); // opens on Draw, the note behind it
|
|
69
68
|
console.log('words back exactly:', unwrap(page).text === words);
|
|
70
69
|
await writeFile('hello.rapier.html', page, {flag: 'wx'}); // 'wx': never over an existing file
|
|
71
70
|
```
|
|
72
71
|
|
|
73
|
-
- `
|
|
72
|
+
- `writePage(text, name, {include, view, drawing, drawingName, base, baseName, by, at, return: returnURL, return_expires_at})`
|
|
73
|
+
carries the editor with what the document displays with (`include` names the parts: `drawing`, `math`, `mermaid`).
|
|
74
|
+
- `wrap(rapierHtml, text, name, options)` does the same into a page you supply; `carry(rapierHtml, parts)` cuts one.
|
|
74
75
|
- `unwrap(pageHtml)` returns the same fields, plus the validated `comparisonBase` record, with `null` for anything the
|
|
75
76
|
page doesn't carry.
|
|
76
|
-
- Also exported: `encodeCarried`, `decodeCarried` and `main`.
|
|
77
|
+
- Also exported: `portableNeeds`, `encodeCarried`, `decodeCarried` and `main`. TypeScript declarations ship in `dist/page.d.mts`.
|
|
77
78
|
|
|
78
79
|
## How the page carries the document
|
|
79
80
|
|
package/dist/cli.mjs
CHANGED
package/dist/page.d.mts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// rapier-html: Markdown to one offline HTML file that carries its exact source, and back.
|
|
3
|
+
export type Part = 'drawing' | 'math' | 'mermaid';
|
|
4
|
+
export type DocKind = 'markdown' | 'text' | 'code';
|
|
5
|
+
export interface WrapOptions {
|
|
6
|
+
kind?: DocKind;
|
|
7
|
+
/** The view the page opens on, with the document behind it. */
|
|
8
|
+
view?: 'draw' | 'notes';
|
|
9
|
+
/** An SVG drawing carried beside the document, opened on Draw. */
|
|
10
|
+
drawing?: string;
|
|
11
|
+
drawingName?: string;
|
|
12
|
+
/** The original text (or a page carrying it); the page opens showing the diff. */
|
|
13
|
+
base?: string;
|
|
14
|
+
baseName?: string;
|
|
15
|
+
/** With base: the name and time shown on the diff. */
|
|
16
|
+
by?: string;
|
|
17
|
+
at?: string;
|
|
18
|
+
/** A one-use return URL and its expiry, both from the door's show {target: "return"}. */
|
|
19
|
+
return?: string;
|
|
20
|
+
return_expires_at?: string;
|
|
21
|
+
/** A rapier-ledger/2 history and its authorship projection, verified against the text. */
|
|
22
|
+
ledger?: unknown;
|
|
23
|
+
authorship?: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface Unwrapped {
|
|
26
|
+
/** The exact carried source, or null for a page without one. */
|
|
27
|
+
text: string | null;
|
|
28
|
+
name: string | null;
|
|
29
|
+
kind: DocKind | null;
|
|
30
|
+
view: 'draw' | 'notes' | null;
|
|
31
|
+
drawing: string | null;
|
|
32
|
+
drawingName: string | null;
|
|
33
|
+
base: string | null;
|
|
34
|
+
baseName: string | null;
|
|
35
|
+
baseSha256: string | null;
|
|
36
|
+
baseRevision: string | null;
|
|
37
|
+
by: string | null;
|
|
38
|
+
at: string | null;
|
|
39
|
+
return: string | null;
|
|
40
|
+
return_expires_at: string | null;
|
|
41
|
+
ledger: unknown;
|
|
42
|
+
authorship: unknown;
|
|
43
|
+
comparisonBase: unknown;
|
|
44
|
+
html: string;
|
|
45
|
+
}
|
|
46
|
+
/** Markdown to a page in one call: the editor this package carries, cut to what the document displays with. */
|
|
47
|
+
export function writePage(text: string, name?: string, options?: WrapOptions & {include?: Part[]}): Promise<string>;
|
|
48
|
+
/** Puts the document into a Rapier page you supply (for example a carry() of the packaged page). */
|
|
49
|
+
export function wrap(pageHtml: string, text: string, name?: string, options?: WrapOptions): string;
|
|
50
|
+
/** Reads the exact document back out of a page. */
|
|
51
|
+
export function unwrap(pageHtml: string): Unwrapped;
|
|
52
|
+
/** The page with only the named parts inline. */
|
|
53
|
+
export function carry(pageHtml: string, include?: Part[]): string;
|
|
54
|
+
/** The parts a document displays with: math, mermaid. */
|
|
55
|
+
export function portableNeeds(text: string, options?: {base?: string; flowchart?: (source: string) => boolean}): Part[];
|
|
56
|
+
export function encodeCarried(text: string): string;
|
|
57
|
+
export function decodeCarried(text: string): string;
|
|
58
|
+
/** The command line: rapier-html <document.md> [out.html] [options]. Resolves the written path, or null for --help. */
|
|
59
|
+
export function main(argv: string[], pagesDir: string, options?: {log?: (line: string) => void}): Promise<string | null>;
|
package/dist/page.mjs
CHANGED
|
@@ -4,6 +4,16 @@ import {basename, dirname, join} from 'node:path';
|
|
|
4
4
|
import {wrap, carry, portableNeeds} from './wrap.mjs';
|
|
5
5
|
import {returnAddress, returnExpiresAt} from './return-address.mjs';
|
|
6
6
|
export {wrap, unwrap, carry, portableNeeds, encodeCarried, decodeCarried} from './wrap.mjs';
|
|
7
|
+
|
|
8
|
+
// The page this package carries, read once on first use.
|
|
9
|
+
let carried = null;
|
|
10
|
+
const carriedPage = () => carried ??= readFile(new URL('./rapier.html', import.meta.url), 'utf8');
|
|
11
|
+
// One call from Markdown to a page: the carried editor, cut to what the document displays with (and Draw for
|
|
12
|
+
// view 'draw' or a drawing), with the document inside. `include` names the parts instead: drawing, math, mermaid.
|
|
13
|
+
export async function writePage(text, name = 'document.md', {include, ...options} = {}) {
|
|
14
|
+
const carries = include ?? [...(options.view === 'draw' || options.drawing != null ? ['drawing'] : []), ...portableNeeds(String(text), {base: options.base})];
|
|
15
|
+
return wrap(carry(await carriedPage(), carries), text, name, options);
|
|
16
|
+
}
|
|
7
17
|
// Unknown options, a bare --drawing or --compare and a third name are refused.
|
|
8
18
|
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
19
|
' writes <document>.rapier.html beside the file: Rapier with the document inside it, one file, offline.\n' +
|