rapier-html 1.2.5 → 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 CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "package": "rapier-html",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "path": "dist/rapier.html",
5
- "bytes": 4949290,
6
- "sha256": "5e2cbc912f760dd5ffad630f92dcec40151df5d55d0e6c7a2796ef907671d8bc",
7
- "builtAt": "2026-10-16T06:38:46.417Z",
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 notes.md`.
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, draws and paints, saves Markdown, exports Word, PDF and a web page, and prints. It needs no account
11
- and fetches nothing to open, edit or save.
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.5 notes.md # the editor, notes.md inside it, written beside the file
20
- npx -- rapier-html@1.2.5 notes.md --view draw # opens on Draw: sketch and paint, the document behind it
21
- npx -- rapier-html@1.2.5 notes.md --view notes # opens the Notes library
22
- npx -- rapier-html@1.2.5 notes.md --drawing sketch.svg # carries a drawing, opened on Draw over the document
23
- npx -- rapier-html@1.2.5 revised.md --compare original.md # opens showing what changed
24
- npx -- rapier-html@1.2.5 notes.md --return "$RETURN_URL" --return-expires-at "$RETURN_EXPIRES_AT" # Send back
25
- npx -- rapier-html@1.2.5 notes.md out.html # a named output
26
- npm install rapier-html@1.2.5 # as a library: wrap, unwrap
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.
@@ -108,7 +109,7 @@ objects, and `unwrap(page)` returns the checked parts beside the text. Both are
108
109
  without parts drops the old parts.
109
110
  - The published package carries its own MIT validator; no source checkout is needed.
110
111
 
111
- ## Licence
112
+ ## License
112
113
 
113
114
  AGPL-3.0-only (`LICENSE`): the page is the Rapier editor, with the notices of the libraries it carries. For the
114
115
  Markdown standard without the editor, use `rapier-markdown-kit` (MIT). Rapier is at https://rapier.website.
@@ -20,7 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
- Files under this licence carry `SPDX-License-Identifier: MIT` in their first lines: the standard's
23
+ Files under this license carry `SPDX-License-Identifier: MIT` in their first lines: the standard's
24
24
  grammar, marks and reference style (`spec/md-layout.mjs`, `spec/md-marks.mjs`, `spec/md-source.mjs`, `spec/flowchart.mjs`, `spec/markdown-style.css`), ink geometry
25
25
  (`spec/ink.mjs`),
26
26
  the layout model and line planner (`layout/model.mjs`, `layout/line-plan.mjs`, `layout/typography.mjs`, `layout/preparation.mjs`,
@@ -42,8 +42,8 @@ AGPL-3.0-only. The page wrapper (`skills/rapier-html/wrap.mjs`, `skills/rapier-h
42
42
  `kit/pdf-vectors.mjs`, `kit/pdf-glyphs.mjs`, `kit/stage.mjs` and MIT-marked conformance
43
43
  modules are covered too. These names describe the Rapier-owned files carrying the
44
44
  MIT notice, not a grant over the editor or third-party code. Other Rapier-owned
45
- files retain their stated licence; the editor is AGPL-3.0-only (see `LICENSE`).
46
- Third-party components retain their own copyright and licence notices.
45
+ files retain their stated license; the editor is AGPL-3.0-only (see `LICENSE`).
46
+ Third-party components retain their own copyright and license notices.
47
47
 
48
48
  The portable font helpers read document definitions and accept explicit host validation and
49
49
  subsetting functions. The application binding (`editor/export-fonts.mjs`), captured-font
@@ -39,7 +39,7 @@ export function separate(c, endA = c.before.length, endB = c.after.length) {
39
39
  for (const span of p.slice(0, 2)) { span[0] += shift; span[1] += shift; }
40
40
  }
41
41
  // Adjacent blocks deleted or inserted together: when the first carries the line break before it, each carries
42
- // its own, so any one restores apart from its neighbours.
42
+ // its own, so any one restores apart from its neighbors.
43
43
  if (!raw) for (let i = 1; i < c.result.length; i++) {
44
44
  const p = c.result[i - 1], q = c.result[i], kind = p[3][0], side = kind ? 1 : 0, text = side ? after : before;
45
45
  if (kind % 2 || q[3][0] !== kind || p[2] || q[2] || p[side][1] !== q[side][0] || p[1 - side][0] !== q[1 - side][0]) continue;
@@ -109,7 +109,7 @@ export function walker(c) {
109
109
  }
110
110
 
111
111
  // Unequal lines pair in order by shared words. A line sharing under a quarter of its words with every candidate is
112
- // replaced whole: an inserted line never borrows a neighbour's words, and a rewrite never reads as stray fragments.
112
+ // replaced whole: an inserted line never borrows a neighbor's words, and a rewrite never reads as stray fragments.
113
113
  function lines(x, y, context) {
114
114
  const n = x.length - 1, m = y.length - 1;
115
115
  if (n * m > 4096 || !spend(n * m + x[n] - x[0] + y[m] - y[0])) return row(x[0], x[n], y[0], y[m], context);
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|notes] [--drawing sketch.svg] [--compare original.md [--by <your name>]] [--return <url> --return-expires-at <timestamp>]\n' +
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
- ' --view opens the page on Draw (sketch and paint, the document behind it) or on Notes\n' +
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 || !['draw', 'notes'].includes(argv[i + 1])) throw new Error('--view takes draw or notes');
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
- try { await writeFile(out, wrap(page, source, name, wrapOptions), {flag: 'wx'}); }
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
- log(out + ' (' + name + ', ' + Buffer.byteLength(source) + ' bytes of document' +
72
- (view ? ', opens on ' + (view === 'draw' ? 'Draw' : 'Notes') : '') + (drawingPath ? ', ' + basename(drawingPath) + ' drawing' : '') + (basePath ? ', its diff from ' + basename(basePath) : '') + ')');
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
  }