rapier-html 1.1.89 → 1.1.91
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 +46 -22
- package/dist/ledger/authorship.mjs +3 -3
- package/dist/ledger/carried.mjs +10 -10
- package/dist/ledger/format.mjs +44 -28
- package/dist/ledger/journal-records.mjs +216 -45
- package/dist/ledger/transport.mjs +318 -0
- package/dist/page.mjs +7 -7
- package/dist/rapier.html +35 -31
- package/dist/wrap.mjs +7 -7
- package/package.json +1 -1
package/dist/wrap.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {PAGE_SEED, returnAddress, returnExpiresAt} from './return-address.mjs';
|
|
|
5
5
|
|
|
6
6
|
const START = '<script type="text/markdown" id="rapier-document"';
|
|
7
7
|
const DRAWING_START = '<script type="text/plain" id="rapier-drawing"';
|
|
8
|
-
// The text
|
|
8
|
+
// The original text is a display reference: the page opens on its diff from the current document.
|
|
9
9
|
const END = '</script>';
|
|
10
10
|
// The page's search words (rapier.html's RAPIER_SEO regions: description, canonical address, previews, structured data and the plain guide
|
|
11
11
|
// a crawler reads) are rapier.website's own. A page that carries someone's document never claims that address or that description.
|
|
@@ -40,8 +40,8 @@ export function wrap(pageHtml, text, name, options) {
|
|
|
40
40
|
const drawingName = safeName(opts.drawingName, 'drawing.svg');
|
|
41
41
|
carriedBlocks += '\n' + DRAWING_START + ' data-name="' + drawingName + '">' + encodeCarried(opts.drawing) + END;
|
|
42
42
|
}
|
|
43
|
-
if ((opts.by != null || opts.at != null) && opts.base == null && previous.base == null) throw new Error('
|
|
44
|
-
let baseline = previous.
|
|
43
|
+
if ((opts.by != null || opts.at != null) && opts.base == null && previous.base == null) throw new Error('comparison attribution needs its original text');
|
|
44
|
+
let baseline = previous.comparisonBase;
|
|
45
45
|
if (!baseline && opts.base != null) {
|
|
46
46
|
if (typeof opts.base === 'object') baseline = readBase(opts.base);
|
|
47
47
|
else {
|
|
@@ -51,12 +51,12 @@ export function wrap(pageHtml, text, name, options) {
|
|
|
51
51
|
const carriedBase = /^\s*<!doctype html/i.test(opts.base) ? takeBase(opts.base).base : null;
|
|
52
52
|
const pageBase = !carriedBase && /^\s*<!doctype html/i.test(opts.base) ? unwrap(opts.base) : null;
|
|
53
53
|
const source = carriedBase ? {text: carriedBase.text} : pageBase?.text != null ? readDocument(pageBase.text) : readDocument(opts.base);
|
|
54
|
-
baseline = carriedBase || pageBase?.
|
|
54
|
+
baseline = carriedBase || pageBase?.comparisonBase || readBase({text: source.text, sha256: sha256(source.text),
|
|
55
55
|
revision: source.ledger?.head.root || pageBase?.ledger?.head.root || sha256(source.text), name: safeName(opts.baseName || pageBase?.name, docName),
|
|
56
56
|
by: opts.by == null ? 'Agent' : String(opts.by).trim(), at: opts.at == null ? new Date().toISOString() : String(opts.at)});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
//
|
|
59
|
+
// Rewrapping retains the original text, hash and revision; attribution names this comparison.
|
|
60
60
|
if (baseline) baseline = readBase({...baseline, ...(opts.by != null ? {by: String(opts.by).trim()} : {}), ...(opts.at != null ? {at: String(opts.at)} : {})});
|
|
61
61
|
carriedBlocks += '\n' + writeBase(text, baseline);
|
|
62
62
|
// The agent seed goes after the charset (or <head>), once: a page that already carries it, wrapped again, loses its old one.
|
|
@@ -102,7 +102,7 @@ export function unwrap(pageHtml) {
|
|
|
102
102
|
if (d > 0 && html[d - 1] === '\n') html = html.slice(0, d - 1) + html.slice(d);
|
|
103
103
|
}
|
|
104
104
|
const carriedBase = takeBase(html); html = carriedBase.html;
|
|
105
|
-
const
|
|
105
|
+
const comparisonBase = carriedBase.base;
|
|
106
106
|
const parts = takeParts(html, text);
|
|
107
|
-
return {...parts, text, name, view, drawing, drawingName,
|
|
107
|
+
return {...parts, text, name, view, drawing, drawingName, comparisonBase, base: comparisonBase?.text ?? null, baseName: comparisonBase?.name ?? null, baseSha256: comparisonBase?.sha256 ?? null, baseRevision: comparisonBase?.revision ?? null, by: comparisonBase?.by ?? null, at: comparisonBase?.at ?? null, return: address, return_expires_at: expiry};
|
|
108
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-html",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.91",
|
|
4
4
|
"description": "One command turns a Markdown file into one offline HTML file: the whole Rapier editor with the document inside. Opens in any browser, phone or desktop, with no install or account. Write, draw and paint watercolor, then Send back the edits to your AI agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|