@book.dev/sdk 1.69.2 → 1.71.0
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/dist/bookFolder.d.ts +36 -4
- package/dist/bookFolder.js +26 -3
- package/dist/bookFolder.js.map +1 -1
- package/dist/bookfile.d.ts +104 -1
- package/dist/bookfile.js +164 -30
- package/dist/bookfile.js.map +1 -1
- package/dist/import.d.ts +18 -0
- package/dist/import.js +26 -0
- package/dist/import.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/island.d.ts +48 -0
- package/dist/island.js +65 -0
- package/dist/island.js.map +1 -0
- package/package.json +1 -1
package/dist/bookFolder.d.ts
CHANGED
|
@@ -26,14 +26,46 @@ export interface SpaceSnapshot {
|
|
|
26
26
|
}
|
|
27
27
|
/** Lossless structured sidecar, parsed back by {@link parseBookFolder}. */
|
|
28
28
|
export declare const SPACE_BUNDLE_FILE = "openbook.space.json";
|
|
29
|
+
/**
|
|
30
|
+
* The whole-space **source-island** payload embedded in a standalone *site* HTML
|
|
31
|
+
* export: the full {@link SpaceSnapshot} (pages + databases + nesting via each
|
|
32
|
+
* page's `parentId`/`databaseId`) plus the root id shown first. Same structure as
|
|
33
|
+
* {@link SPACE_BUNDLE_FILE}, so a site export re-imports with structure intact.
|
|
34
|
+
*/
|
|
35
|
+
export interface SpaceIsland {
|
|
36
|
+
version: 1;
|
|
37
|
+
rootId: string;
|
|
38
|
+
space: SpaceSnapshot;
|
|
39
|
+
}
|
|
40
|
+
/** Wrap a whole-space bundle as its source-island `<script>` (versioned, escaped). */
|
|
41
|
+
export declare function spaceIslandScript(rootId: string, space: SpaceSnapshot, opts?: {
|
|
42
|
+
attrs?: string;
|
|
43
|
+
indent?: string;
|
|
44
|
+
}): string;
|
|
45
|
+
/** Read a site export's space island back, or `null` when absent/corrupt. */
|
|
46
|
+
export declare function readSpaceIsland(html: string): SpaceIsland | null;
|
|
47
|
+
/** Options for {@link spaceToBookFiles}. */
|
|
48
|
+
export interface SpaceToBookFilesOptions {
|
|
49
|
+
/** Include the lossless {@link SPACE_BUNDLE_FILE} sidecar. Default true. */
|
|
50
|
+
includeBundle?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The viewer runtime bundle's JS source (the compiled `OpenBookViewer` IIFE).
|
|
53
|
+
* When provided, ONE copy is emitted at {@link BOOK_RUNTIME_FILE}
|
|
54
|
+
* (`_openbook/viewer.js`) and every page file references it relatively, so a
|
|
55
|
+
* `.book.html` opened straight from `file://` hydrates into the interactive
|
|
56
|
+
* locked viewer with zero network — and the folder stays portable
|
|
57
|
+
* (moved/zipped whole). Omit it (bundle unavailable) and the writer emits NO
|
|
58
|
+
* reference: the files are the plain static articles, exactly as before.
|
|
59
|
+
*/
|
|
60
|
+
runtime?: string;
|
|
61
|
+
}
|
|
29
62
|
/**
|
|
30
63
|
* Serialise a space to its on-disk files. By default includes the lossless
|
|
31
64
|
* {@link SPACE_BUNDLE_FILE}; pass `includeBundle: false` for the human-readable
|
|
32
|
-
* HTML files only.
|
|
65
|
+
* HTML files only. Pass `runtime` (the viewer bundle source) to make the folder
|
|
66
|
+
* self-hydrating — see {@link SpaceToBookFilesOptions.runtime}.
|
|
33
67
|
*/
|
|
34
|
-
export declare function spaceToBookFiles(snapshot: SpaceSnapshot, opts?:
|
|
35
|
-
includeBundle?: boolean;
|
|
36
|
-
}): BookFolderFile[];
|
|
68
|
+
export declare function spaceToBookFiles(snapshot: SpaceSnapshot, opts?: SpaceToBookFilesOptions): BookFolderFile[];
|
|
37
69
|
/**
|
|
38
70
|
* Reconstruct a space from a folder's files. Prefers the lossless
|
|
39
71
|
* {@link SPACE_BUNDLE_FILE} when present; otherwise falls back to parsing the
|
package/dist/bookFolder.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import { pageToBookHtml, bookHtmlToPage, slugify } from './bookfile';
|
|
1
|
+
import { pageToBookHtml, bookHtmlToPage, slugify, BOOK_RUNTIME_FILE } from './bookfile';
|
|
2
|
+
import { islandScript, readIsland } from './island';
|
|
2
3
|
/** Lossless structured sidecar, parsed back by {@link parseBookFolder}. */
|
|
3
4
|
export const SPACE_BUNDLE_FILE = 'openbook.space.json';
|
|
5
|
+
/** Wrap a whole-space bundle as its source-island `<script>` (versioned, escaped). */
|
|
6
|
+
export function spaceIslandScript(rootId, space, opts = {}) {
|
|
7
|
+
return islandScript({ version: 1, rootId, space }, opts);
|
|
8
|
+
}
|
|
9
|
+
/** Read a site export's space island back, or `null` when absent/corrupt. */
|
|
10
|
+
export function readSpaceIsland(html) {
|
|
11
|
+
const parsed = readIsland(html);
|
|
12
|
+
if (!parsed || !parsed.space || !Array.isArray(parsed.space.pages))
|
|
13
|
+
return null;
|
|
14
|
+
return {
|
|
15
|
+
version: 1,
|
|
16
|
+
rootId: parsed.rootId ?? '',
|
|
17
|
+
space: {
|
|
18
|
+
pages: parsed.space.pages,
|
|
19
|
+
databases: Array.isArray(parsed.space.databases) ? parsed.space.databases : [],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
4
23
|
const MAX_DEPTH = 64;
|
|
5
24
|
const pageIcon = (page) => {
|
|
6
25
|
const icon = page.properties?.sys_icon;
|
|
@@ -27,12 +46,14 @@ function rootOf(page, byId, dbHost) {
|
|
|
27
46
|
/**
|
|
28
47
|
* Serialise a space to its on-disk files. By default includes the lossless
|
|
29
48
|
* {@link SPACE_BUNDLE_FILE}; pass `includeBundle: false` for the human-readable
|
|
30
|
-
* HTML files only.
|
|
49
|
+
* HTML files only. Pass `runtime` (the viewer bundle source) to make the folder
|
|
50
|
+
* self-hydrating — see {@link SpaceToBookFilesOptions.runtime}.
|
|
31
51
|
*/
|
|
32
52
|
export function spaceToBookFiles(snapshot, opts = {}) {
|
|
33
53
|
const { pages, databases } = snapshot;
|
|
34
54
|
const byId = new Map(pages.map((p) => [p.id, p]));
|
|
35
55
|
const dbHost = new Map(databases.map((d) => [d.id, d.pageId]));
|
|
56
|
+
const runtimeRef = typeof opts.runtime === 'string' && opts.runtime.length > 0;
|
|
36
57
|
const files = [];
|
|
37
58
|
for (const page of pages) {
|
|
38
59
|
const root = rootOf(page, byId, dbHost);
|
|
@@ -42,9 +63,11 @@ export function spaceToBookFiles(snapshot, opts = {}) {
|
|
|
42
63
|
icon: pageIcon(page),
|
|
43
64
|
updatedAt: page.updatedAt,
|
|
44
65
|
data: page.data,
|
|
45
|
-
});
|
|
66
|
+
}, { runtimeRef });
|
|
46
67
|
files.push({ path: `${folderName(root)}/${fileName(page)}`, contents: html });
|
|
47
68
|
}
|
|
69
|
+
if (runtimeRef)
|
|
70
|
+
files.push({ path: BOOK_RUNTIME_FILE, contents: opts.runtime });
|
|
48
71
|
if (opts.includeBundle !== false) {
|
|
49
72
|
files.push({ path: SPACE_BUNDLE_FILE, contents: JSON.stringify(snapshot, null, 2) });
|
|
50
73
|
}
|
package/dist/bookFolder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookFolder.js","sourceRoot":"","sources":["../src/bookFolder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"bookFolder.js","sourceRoot":"","sources":["../src/bookFolder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAC;AACtF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AA6BlD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAcvD,sFAAsF;AACtF,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,KAAoB,EACpB,OAA0C,EAAE;IAE5C,OAAO,YAAY,CAAC,EAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,K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,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE;QACtD,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/bookfile.d.ts
CHANGED
|
@@ -23,10 +23,113 @@ export interface BookPageRecord {
|
|
|
23
23
|
updatedAt: string;
|
|
24
24
|
data: PageSnapshot;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The canonical **page source-island** payload: a versioned {@link BookPageRecord}.
|
|
28
|
+
* This is exactly what a `.book.html` file AND a single-page / slide-deck HTML
|
|
29
|
+
* export embed, so `bookHtmlToPage` (or the generic `readIsland`) reads any of
|
|
30
|
+
* them back the same way. Downstream import consumes this shape.
|
|
31
|
+
*/
|
|
32
|
+
export interface PageIsland extends BookPageRecord {
|
|
33
|
+
version: 1;
|
|
34
|
+
}
|
|
35
|
+
/** Wrap a page record as its source-island `<script>` (versioned, escaped). */
|
|
36
|
+
export declare function pageIslandScript(record: BookPageRecord, opts?: {
|
|
37
|
+
attrs?: string;
|
|
38
|
+
indent?: string;
|
|
39
|
+
}): string;
|
|
40
|
+
/**
|
|
41
|
+
* Sanitize a **legacy EditorJS** inline-HTML string for the readable `.book.html`
|
|
42
|
+
* body (block-editor pages carry structured rich-text runs and never reach here;
|
|
43
|
+
* they are already fully escaped by {@link runHtml}). This closes a stored-XSS
|
|
44
|
+
* sink: a hostile EditorJS-shaped snapshot (a crafted import or a pre-migration
|
|
45
|
+
* page) otherwise renders raw `<script>` / `<img onerror>` / event handlers /
|
|
46
|
+
* `javascript:` hrefs straight into the static file, which execute when the
|
|
47
|
+
* mirrored/exported file is opened from `file://`.
|
|
48
|
+
*
|
|
49
|
+
* DEFAULT-INERT: escape the ENTIRE string first (so everything is neutralized),
|
|
50
|
+
* then restore ONLY the exact, attribute-less inline formatting tags above via a
|
|
51
|
+
* regex that requires the tag name be followed immediately by `>` — so
|
|
52
|
+
* `<b onclick=…>` (escaped, has an attribute) is never restored, only a bare
|
|
53
|
+
* `<b>`. Anchors are DELIBERATELY not restored: safely reconstructing an `href`
|
|
54
|
+
* would require attribute + scheme parsing (the classic sanitizer footgun) with
|
|
55
|
+
* no DOM available in this isomorphic module — a legacy link degrades to inert
|
|
56
|
+
* escaped text in this best-effort readable preview, while the JSON island keeps
|
|
57
|
+
* it losslessly and the page migrates to fully-rendered runs the first time it
|
|
58
|
+
* is opened. See the module's mirror byte-compat note.
|
|
59
|
+
*/
|
|
60
|
+
export declare function sanitizeLegacyInline(html: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Scheme-allowlist for an anchor `href` rendered into STATIC HTML (the readable
|
|
63
|
+
* `.book.html` body AND the standalone exports — both opened from a `file://`
|
|
64
|
+
* origin, where a `javascript:` link is click-to-execute XSS). `esc()` escapes
|
|
65
|
+
* the value as an attribute but does NOT touch the URI scheme, so schemes must
|
|
66
|
+
* be gated separately; callers degrade a rejected href to inert text.
|
|
67
|
+
*
|
|
68
|
+
* Permits: `http(s):`, `mailto:`, and relative / anchor / query links (`#`, `/`,
|
|
69
|
+
* `.`, `?`, or any path with no scheme). Denies everything else — `javascript:`,
|
|
70
|
+
* `data:`, `vbscript:`, `file:`, `tel:`, … — and **protocol-relative `//host`**
|
|
71
|
+
* (a benign relative link never starts `//`, and a protocol-relative URL is
|
|
72
|
+
* meaningless in a standalone file, so denying it closes a classic bypass).
|
|
73
|
+
*
|
|
74
|
+
* The scheme is tested on a NORMALIZED copy — ASCII control chars + whitespace
|
|
75
|
+
* removed and backslashes folded to `/`, then lower-cased — because browsers
|
|
76
|
+
* ignore embedded tabs/newlines and treat `\` as `/` when parsing a URL, so
|
|
77
|
+
* `jAvA\tscript:` or `/\/\host` would otherwise slip past a naive prefix check.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isSafeHref(raw: string): boolean;
|
|
80
|
+
/** The folder-level runtime directory name (never a valid book-folder slug). */
|
|
81
|
+
export declare const BOOK_RUNTIME_DIR = "_openbook";
|
|
82
|
+
/** Relative path (from the folder root) of the shared viewer runtime bundle. */
|
|
83
|
+
export declare const BOOK_RUNTIME_FILE = "_openbook/viewer.js";
|
|
84
|
+
/**
|
|
85
|
+
* The **byte-constant** runtime reference block a `.book.html` embeds in its
|
|
86
|
+
* `<head>` when the folder carries the shared viewer bundle (`_openbook/viewer.js`
|
|
87
|
+
* — ONE copy per folder, owner decision 2026-07-04: never vendored per-file).
|
|
88
|
+
*
|
|
89
|
+
* Stability contract: this block contains NO per-page and NO per-version variance
|
|
90
|
+
* (no content hash, no build id), so
|
|
91
|
+
* - a page save re-renders to the same reference bytes (no mirror churn), and
|
|
92
|
+
* - a viewer-bundle upgrade rewrites ONLY `_openbook/viewer.js`, never the N
|
|
93
|
+
* page files. Only gaining/losing the runtime altogether changes page bytes
|
|
94
|
+
* (a deliberate one-time, upgrade-class rewrite).
|
|
95
|
+
*
|
|
96
|
+
* The boot script:
|
|
97
|
+
* - loads after parse (the src script is `defer`; boot waits for DOMContentLoaded),
|
|
98
|
+
* so both tags sit safely in `<head>` where hostile body text (an unterminated
|
|
99
|
+
* `<!--`) can never swallow them;
|
|
100
|
+
* - extracts the island by REGEX over the serialized document — the sdk
|
|
101
|
+
* `readIslandRaw` pattern, never `querySelector`/DOMParser (see viewer/index.tsx:
|
|
102
|
+
* a DOM query misses an island a stray open comment swallowed, while the
|
|
103
|
+
* serialized comment text still matches the regex);
|
|
104
|
+
* - mounts the interactive viewer over the static `<article>` and hides it; ANY
|
|
105
|
+
* failure (bundle deleted, no global, corrupt island, mount throw) leaves the
|
|
106
|
+
* readable static article exactly as-is — the runtime is progressive
|
|
107
|
+
* enhancement over the no-JS fallback.
|
|
108
|
+
*
|
|
109
|
+
* Inside the inline script every `/` that could form `</script>` (the regex
|
|
110
|
+
* literal) is escaped as `<\/` so the block can never close itself early, and the
|
|
111
|
+
* island marker appears only in its regex-escaped form (`application\/openbook\+json`),
|
|
112
|
+
* which the sdk island reader does NOT match — the boot can never be mistaken for
|
|
113
|
+
* the island itself.
|
|
114
|
+
*/
|
|
115
|
+
export declare function bookRuntimeScripts(): string;
|
|
26
116
|
/** Lower-case, dash-separated, filesystem-safe slug (for the on-disk filename). */
|
|
27
117
|
export declare function slugify(input: string, fallback?: string): string;
|
|
118
|
+
/** Options for {@link pageToBookHtml}. */
|
|
119
|
+
export interface BookHtmlOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Reference the folder's shared viewer runtime (`_openbook/viewer.js`) so the
|
|
122
|
+
* file, opened directly in a browser, hydrates into the interactive locked
|
|
123
|
+
* viewer. Pass true ONLY when the writer also ships the bundle into the folder
|
|
124
|
+
* (sdk `spaceToBookFiles({runtime})` / server `BookMirror` with `runtimeBundle`)
|
|
125
|
+
* — a reference without the bundle degrades gracefully (static article), but
|
|
126
|
+
* writers keep the invariant anyway. Emitters MUST agree on this flag for the
|
|
127
|
+
* SDK/server byte-compatibility contract to hold.
|
|
128
|
+
*/
|
|
129
|
+
runtimeRef?: boolean;
|
|
130
|
+
}
|
|
28
131
|
/** Render a page to its on-disk book-file HTML (readable body + canonical island). */
|
|
29
|
-
export declare function pageToBookHtml(record: BookPageRecord): string;
|
|
132
|
+
export declare function pageToBookHtml(record: BookPageRecord, opts?: BookHtmlOptions): string;
|
|
30
133
|
/** Cheap metadata read from the `<html>` tag — id + conflict base + name. */
|
|
31
134
|
export declare function readBookHtmlMeta(html: string): {
|
|
32
135
|
id: string;
|
package/dist/bookfile.js
CHANGED
|
@@ -1,6 +1,147 @@
|
|
|
1
1
|
import { latestBlockMtime } from './mtime';
|
|
2
|
-
|
|
2
|
+
import { islandScript, readIsland } from './island';
|
|
3
|
+
/** Wrap a page record as its source-island `<script>` (versioned, escaped). */
|
|
4
|
+
export function pageIslandScript(record, opts = {}) {
|
|
5
|
+
const { id, name, icon, updatedAt, data } = record;
|
|
6
|
+
return islandScript({ version: 1, id, name, icon, updatedAt, data }, opts);
|
|
7
|
+
}
|
|
3
8
|
const esc = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
9
|
+
/**
|
|
10
|
+
* The attribute-less inline formatting tags a legacy EditorJS text string may
|
|
11
|
+
* carry, and the editor's own migration ({@link htmlToRuns} in the ui package)
|
|
12
|
+
* honors: bold / italic / underline / strike / code. Every one is a bare tag
|
|
13
|
+
* with NO attributes, so it can never carry a payload — that is the whole safety
|
|
14
|
+
* argument for the escape-then-restore approach below.
|
|
15
|
+
*/
|
|
16
|
+
const LEGACY_INLINE_TAGS = ['b', 'strong', 'i', 'em', 'u', 's', 'del', 'code'];
|
|
17
|
+
/**
|
|
18
|
+
* Sanitize a **legacy EditorJS** inline-HTML string for the readable `.book.html`
|
|
19
|
+
* body (block-editor pages carry structured rich-text runs and never reach here;
|
|
20
|
+
* they are already fully escaped by {@link runHtml}). This closes a stored-XSS
|
|
21
|
+
* sink: a hostile EditorJS-shaped snapshot (a crafted import or a pre-migration
|
|
22
|
+
* page) otherwise renders raw `<script>` / `<img onerror>` / event handlers /
|
|
23
|
+
* `javascript:` hrefs straight into the static file, which execute when the
|
|
24
|
+
* mirrored/exported file is opened from `file://`.
|
|
25
|
+
*
|
|
26
|
+
* DEFAULT-INERT: escape the ENTIRE string first (so everything is neutralized),
|
|
27
|
+
* then restore ONLY the exact, attribute-less inline formatting tags above via a
|
|
28
|
+
* regex that requires the tag name be followed immediately by `>` — so
|
|
29
|
+
* `<b onclick=…>` (escaped, has an attribute) is never restored, only a bare
|
|
30
|
+
* `<b>`. Anchors are DELIBERATELY not restored: safely reconstructing an `href`
|
|
31
|
+
* would require attribute + scheme parsing (the classic sanitizer footgun) with
|
|
32
|
+
* no DOM available in this isomorphic module — a legacy link degrades to inert
|
|
33
|
+
* escaped text in this best-effort readable preview, while the JSON island keeps
|
|
34
|
+
* it losslessly and the page migrates to fully-rendered runs the first time it
|
|
35
|
+
* is opened. See the module's mirror byte-compat note.
|
|
36
|
+
*/
|
|
37
|
+
export function sanitizeLegacyInline(html) {
|
|
38
|
+
let out = esc(html);
|
|
39
|
+
for (const tag of LEGACY_INLINE_TAGS) {
|
|
40
|
+
// Bare open/close tags only (no attributes) — `<b>` / `</b>`.
|
|
41
|
+
out = out
|
|
42
|
+
.replace(new RegExp(`<${tag}>`, 'gi'), `<${tag}>`)
|
|
43
|
+
.replace(new RegExp(`</${tag}>`, 'gi'), `</${tag}>`);
|
|
44
|
+
}
|
|
45
|
+
// `<br>` (void): the plain, self-closing, and spaced variants → a bare `<br>`.
|
|
46
|
+
out = out.replace(/<br\s*\/?>/gi, '<br>');
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Scheme-allowlist for an anchor `href` rendered into STATIC HTML (the readable
|
|
51
|
+
* `.book.html` body AND the standalone exports — both opened from a `file://`
|
|
52
|
+
* origin, where a `javascript:` link is click-to-execute XSS). `esc()` escapes
|
|
53
|
+
* the value as an attribute but does NOT touch the URI scheme, so schemes must
|
|
54
|
+
* be gated separately; callers degrade a rejected href to inert text.
|
|
55
|
+
*
|
|
56
|
+
* Permits: `http(s):`, `mailto:`, and relative / anchor / query links (`#`, `/`,
|
|
57
|
+
* `.`, `?`, or any path with no scheme). Denies everything else — `javascript:`,
|
|
58
|
+
* `data:`, `vbscript:`, `file:`, `tel:`, … — and **protocol-relative `//host`**
|
|
59
|
+
* (a benign relative link never starts `//`, and a protocol-relative URL is
|
|
60
|
+
* meaningless in a standalone file, so denying it closes a classic bypass).
|
|
61
|
+
*
|
|
62
|
+
* The scheme is tested on a NORMALIZED copy — ASCII control chars + whitespace
|
|
63
|
+
* removed and backslashes folded to `/`, then lower-cased — because browsers
|
|
64
|
+
* ignore embedded tabs/newlines and treat `\` as `/` when parsing a URL, so
|
|
65
|
+
* `jAvA\tscript:` or `/\/\host` would otherwise slip past a naive prefix check.
|
|
66
|
+
*/
|
|
67
|
+
export function isSafeHref(raw) {
|
|
68
|
+
// Stripping C0 control chars + space is the whole point (browsers ignore
|
|
69
|
+
// embedded tabs/newlines when parsing a scheme) — the control-char class is
|
|
70
|
+
// intentional, not the accidental bug no-control-regex guards against.
|
|
71
|
+
// eslint-disable-next-line no-control-regex
|
|
72
|
+
const probe = raw.replace(/[\u0000-\u0020]+/g, '').replace(/\\/g, '/').toLowerCase();
|
|
73
|
+
if (probe.startsWith('//'))
|
|
74
|
+
return false; // protocol-relative → deny
|
|
75
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/.exec(probe);
|
|
76
|
+
if (!scheme)
|
|
77
|
+
return true; // no scheme → relative / anchor / query, safe
|
|
78
|
+
return scheme[1] === 'http' || scheme[1] === 'https' || scheme[1] === 'mailto';
|
|
79
|
+
}
|
|
80
|
+
/** The folder-level runtime directory name (never a valid book-folder slug). */
|
|
81
|
+
export const BOOK_RUNTIME_DIR = '_openbook';
|
|
82
|
+
/** Relative path (from the folder root) of the shared viewer runtime bundle. */
|
|
83
|
+
export const BOOK_RUNTIME_FILE = `${BOOK_RUNTIME_DIR}/viewer.js`;
|
|
84
|
+
/**
|
|
85
|
+
* The **byte-constant** runtime reference block a `.book.html` embeds in its
|
|
86
|
+
* `<head>` when the folder carries the shared viewer bundle (`_openbook/viewer.js`
|
|
87
|
+
* — ONE copy per folder, owner decision 2026-07-04: never vendored per-file).
|
|
88
|
+
*
|
|
89
|
+
* Stability contract: this block contains NO per-page and NO per-version variance
|
|
90
|
+
* (no content hash, no build id), so
|
|
91
|
+
* - a page save re-renders to the same reference bytes (no mirror churn), and
|
|
92
|
+
* - a viewer-bundle upgrade rewrites ONLY `_openbook/viewer.js`, never the N
|
|
93
|
+
* page files. Only gaining/losing the runtime altogether changes page bytes
|
|
94
|
+
* (a deliberate one-time, upgrade-class rewrite).
|
|
95
|
+
*
|
|
96
|
+
* The boot script:
|
|
97
|
+
* - loads after parse (the src script is `defer`; boot waits for DOMContentLoaded),
|
|
98
|
+
* so both tags sit safely in `<head>` where hostile body text (an unterminated
|
|
99
|
+
* `<!--`) can never swallow them;
|
|
100
|
+
* - extracts the island by REGEX over the serialized document — the sdk
|
|
101
|
+
* `readIslandRaw` pattern, never `querySelector`/DOMParser (see viewer/index.tsx:
|
|
102
|
+
* a DOM query misses an island a stray open comment swallowed, while the
|
|
103
|
+
* serialized comment text still matches the regex);
|
|
104
|
+
* - mounts the interactive viewer over the static `<article>` and hides it; ANY
|
|
105
|
+
* failure (bundle deleted, no global, corrupt island, mount throw) leaves the
|
|
106
|
+
* readable static article exactly as-is — the runtime is progressive
|
|
107
|
+
* enhancement over the no-JS fallback.
|
|
108
|
+
*
|
|
109
|
+
* Inside the inline script every `/` that could form `</script>` (the regex
|
|
110
|
+
* literal) is escaped as `<\/` so the block can never close itself early, and the
|
|
111
|
+
* island marker appears only in its regex-escaped form (`application\/openbook\+json`),
|
|
112
|
+
* which the sdk island reader does NOT match — the boot can never be mistaken for
|
|
113
|
+
* the island itself.
|
|
114
|
+
*/
|
|
115
|
+
export function bookRuntimeScripts() {
|
|
116
|
+
return `<script src="../${BOOK_RUNTIME_FILE}" defer data-openbook-runtime></script>
|
|
117
|
+
<script data-openbook-runtime-boot>
|
|
118
|
+
(function () {
|
|
119
|
+
function boot() {
|
|
120
|
+
try {
|
|
121
|
+
if (typeof OpenBookViewer === 'undefined') return;
|
|
122
|
+
var m = document.documentElement.outerHTML.match(/<script[^>]*type="application\\/openbook\\+json"[^>]*>([\\s\\S]*?)<\\/script>/i);
|
|
123
|
+
if (!m) return;
|
|
124
|
+
var island = JSON.parse(m[1].trim());
|
|
125
|
+
var article = document.querySelector('article');
|
|
126
|
+
var host = document.createElement('div');
|
|
127
|
+
(article && article.parentNode ? article.parentNode : document.body).insertBefore(host, article);
|
|
128
|
+
// Inline display:none (not the hidden attribute): the bundle injects the
|
|
129
|
+
// app stylesheet, whose author-level display rules would defeat the UA's
|
|
130
|
+
// [hidden] mapping. The inline style always wins; mount failure restores it.
|
|
131
|
+
if (article) article.style.display = 'none';
|
|
132
|
+
try {
|
|
133
|
+
OpenBookViewer.mount(host, island);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
host.remove();
|
|
136
|
+
if (article) article.style.display = '';
|
|
137
|
+
}
|
|
138
|
+
} catch (err) { /* leave the static article untouched */ }
|
|
139
|
+
}
|
|
140
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', boot);
|
|
141
|
+
else boot();
|
|
142
|
+
})();
|
|
143
|
+
</script>`;
|
|
144
|
+
}
|
|
4
145
|
/** Lower-case, dash-separated, filesystem-safe slug (for the on-disk filename). */
|
|
5
146
|
export function slugify(input, fallback = 'untitled') {
|
|
6
147
|
const slug = (input || '')
|
|
@@ -36,7 +177,11 @@ function runHtml(run) {
|
|
|
36
177
|
out = `<s>${out}</s>`;
|
|
37
178
|
if (typeof a.m === 'string')
|
|
38
179
|
out = `<a class="ob-mention" data-page-id="${esc(a.m)}">${out}</a>`;
|
|
39
|
-
|
|
180
|
+
// Scheme-gate the href: esc() escapes the attribute but not the URI scheme, so
|
|
181
|
+
// a `javascript:`/`data:` link would render live and clickable in the static
|
|
182
|
+
// file. A rejected href degrades to inert text (no anchor) — same posture as
|
|
183
|
+
// the legacy-inline sanitizer.
|
|
184
|
+
else if (typeof a.a === 'string' && isSafeHref(a.a))
|
|
40
185
|
out = `<a href="${esc(a.a)}">${out}</a>`;
|
|
41
186
|
return out;
|
|
42
187
|
}
|
|
@@ -44,8 +189,10 @@ const runsHtml = (runs) => (runs ?? []).map(runHtml).join('');
|
|
|
44
189
|
/** Best-effort readable inner HTML for one block (the island stays authoritative). */
|
|
45
190
|
function blockInnerHtml(type, block) {
|
|
46
191
|
const d = block.data ?? {};
|
|
47
|
-
// Block-editor pages carry rich-text runs
|
|
48
|
-
|
|
192
|
+
// Block-editor pages carry rich-text runs (escaped by runHtml); legacy EditorJS
|
|
193
|
+
// pages carry raw inline-HTML strings — sanitize those before they reach the
|
|
194
|
+
// static body (default-inert allowlist; see sanitizeLegacyInline).
|
|
195
|
+
const textHtml = block.text ? runsHtml(block.text) : typeof d.text === 'string' ? sanitizeLegacyInline(d.text) : '';
|
|
49
196
|
switch (type) {
|
|
50
197
|
case 'heading':
|
|
51
198
|
case 'header': {
|
|
@@ -60,7 +207,7 @@ function blockInnerHtml(type, block) {
|
|
|
60
207
|
const items = Array.isArray(d.items) ? d.items : [];
|
|
61
208
|
const ordered = d.style === 'ordered';
|
|
62
209
|
const lis = items
|
|
63
|
-
.map((it) => `<li>${typeof it === 'string' ? it : esc(String(it?.content ?? ''))}</li>`)
|
|
210
|
+
.map((it) => `<li>${typeof it === 'string' ? sanitizeLegacyInline(it) : esc(String(it?.content ?? ''))}</li>`)
|
|
64
211
|
.join('');
|
|
65
212
|
return { tag: ordered ? 'ol' : 'ul', inner: lis };
|
|
66
213
|
}
|
|
@@ -81,7 +228,7 @@ function blockInnerHtml(type, block) {
|
|
|
81
228
|
}
|
|
82
229
|
}
|
|
83
230
|
/** Render a page to its on-disk book-file HTML (readable body + canonical island). */
|
|
84
|
-
export function pageToBookHtml(record) {
|
|
231
|
+
export function pageToBookHtml(record, opts = {}) {
|
|
85
232
|
const { id, name, icon, updatedAt, data } = record;
|
|
86
233
|
const title = (name ?? '').trim() || 'Untitled';
|
|
87
234
|
const mtime = new Map(data.mtimes ?? []);
|
|
@@ -93,24 +240,19 @@ export function pageToBookHtml(record) {
|
|
|
93
240
|
return tag === 'hr' ? ` <hr ${attrs}>` : ` <${tag} ${attrs}>${inner}</${tag}>`;
|
|
94
241
|
})
|
|
95
242
|
.join('\n');
|
|
96
|
-
// The island JSON is escaped so a literal `</script>` in content can't close
|
|
97
|
-
// the tag early; `<\/` is still valid JSON and parses back to `</`.
|
|
98
|
-
const island = JSON.stringify({ version: 1, id, name, icon, updatedAt, data }).replace(/<\//g, '<\\/');
|
|
99
243
|
return `<!doctype html>
|
|
100
244
|
<html lang="en" data-openbook="book-page" data-page-id="${esc(id)}" data-page-name="${esc(title)}" data-page-updated="${esc(updatedAt)}" data-page-mtime="${esc(pageMtime)}">
|
|
101
245
|
<head>
|
|
102
246
|
<meta charset="utf-8">
|
|
103
247
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
104
248
|
<title>${esc(title)}</title>
|
|
105
|
-
</head>
|
|
249
|
+
${opts.runtimeRef ? `${bookRuntimeScripts()}\n` : ''}</head>
|
|
106
250
|
<body class="ob-page">
|
|
107
251
|
<article>
|
|
108
252
|
<h1 class="ob-page-title">${icon ? `${esc(icon)} ` : ''}${esc(title)}</h1>
|
|
109
253
|
${body}
|
|
110
254
|
</article>
|
|
111
|
-
|
|
112
|
-
${island}
|
|
113
|
-
</script>
|
|
255
|
+
${pageIslandScript({ id, name, icon, updatedAt, data }, { attrs: 'data-openbook-snapshot', indent: ' ' })}
|
|
114
256
|
</body>
|
|
115
257
|
</html>
|
|
116
258
|
`;
|
|
@@ -137,23 +279,15 @@ const unesc = (s) => s.replace(/"/g, '"').replace(/>/g, '>').replace(/&l
|
|
|
137
279
|
* backups, moved files all preserve the island).
|
|
138
280
|
*/
|
|
139
281
|
export function bookHtmlToPage(html) {
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
282
|
+
const parsed = readIsland(html);
|
|
283
|
+
if (!parsed || !parsed.id || !parsed.data)
|
|
142
284
|
return null;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
icon: parsed.icon ?? null,
|
|
151
|
-
updatedAt: parsed.updatedAt ?? '',
|
|
152
|
-
data: parsed.data,
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
285
|
+
return {
|
|
286
|
+
id: parsed.id,
|
|
287
|
+
name: parsed.name ?? null,
|
|
288
|
+
icon: parsed.icon ?? null,
|
|
289
|
+
updatedAt: parsed.updatedAt ?? '',
|
|
290
|
+
data: parsed.data,
|
|
291
|
+
};
|
|
158
292
|
}
|
|
159
293
|
//# sourceMappingURL=bookfile.js.map
|
package/dist/bookfile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bookfile.js","sourceRoot":"","sources":["../src/bookfile.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"bookfile.js","sourceRoot":"","sources":["../src/bookfile.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAsBlD,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,MAAsB,EAAE,OAA0C,EAAE;IACnG,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC,GAAG,MAAM,CAAC;IACjD,OAAO,YAAY,CAAC,EAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAC,EAAE,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAChC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAE/F;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,IAAI,GAAG,GAAG,GAAG,CAAC,IAA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AE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,MAAM,GAAG,UAAU,CAAsB,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;QACjC,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
package/dist/import.d.ts
CHANGED
|
@@ -166,6 +166,24 @@ export declare function imagePlaceholderBlock(asset: ImportedAsset): ImportedBlo
|
|
|
166
166
|
* granularity via {@link imagePlaceholderBlock} on the row's body.
|
|
167
167
|
*/
|
|
168
168
|
export declare function imagePlaceholderCell(asset: ImportedAsset): string;
|
|
169
|
+
/**
|
|
170
|
+
* The marker prop on an `htmlArtifact` block whose document bytes have not been
|
|
171
|
+
* uploaded yet. The run-as-artifact import lands the page FIRST (`putAsset`
|
|
172
|
+
* needs the landed page id for the asset's read-gate ref), then uploads the
|
|
173
|
+
* file's bytes and rewrites the pending block to a real `assetId` — the same
|
|
174
|
+
* land-then-rehydrate order as {@link IMAGE_PLACEHOLDER_PROP} images. A block
|
|
175
|
+
* still carrying the marker (upload failed) renders as the editor's visible
|
|
176
|
+
* "add an artifact" placeholder — degraded, never dropped.
|
|
177
|
+
*/
|
|
178
|
+
export declare const HTML_ARTIFACT_PENDING_PROP = "importedArtifactPending";
|
|
179
|
+
/**
|
|
180
|
+
* An `htmlArtifact` IR block awaiting its document upload — the run-as-artifact
|
|
181
|
+
* counterpart of {@link imagePlaceholderBlock}, minimal by design: the bytes
|
|
182
|
+
* live outside the IR (they go straight to the asset store), so the block only
|
|
183
|
+
* carries the display title and the pending marker. Pure: the id derives from
|
|
184
|
+
* the title, so the same import always yields the same block id.
|
|
185
|
+
*/
|
|
186
|
+
export declare function htmlArtifactPendingBlock(title?: string): ImportedBlock;
|
|
169
187
|
/**
|
|
170
188
|
* Wrap a block list in a page snapshot the block editor reads — the same shape
|
|
171
189
|
* `templates.ts` ships (`editor:'blocks'`, blocks in `blockdoc.blocks`, NO CRDT
|
package/dist/import.js
CHANGED
|
@@ -85,6 +85,32 @@ export function imagePlaceholderBlock(asset) {
|
|
|
85
85
|
export function imagePlaceholderCell(asset) {
|
|
86
86
|
return asset.ref;
|
|
87
87
|
}
|
|
88
|
+
// ── HTML-artifact pending shim (run-as-artifact import) ──────────────────────
|
|
89
|
+
/**
|
|
90
|
+
* The marker prop on an `htmlArtifact` block whose document bytes have not been
|
|
91
|
+
* uploaded yet. The run-as-artifact import lands the page FIRST (`putAsset`
|
|
92
|
+
* needs the landed page id for the asset's read-gate ref), then uploads the
|
|
93
|
+
* file's bytes and rewrites the pending block to a real `assetId` — the same
|
|
94
|
+
* land-then-rehydrate order as {@link IMAGE_PLACEHOLDER_PROP} images. A block
|
|
95
|
+
* still carrying the marker (upload failed) renders as the editor's visible
|
|
96
|
+
* "add an artifact" placeholder — degraded, never dropped.
|
|
97
|
+
*/
|
|
98
|
+
export const HTML_ARTIFACT_PENDING_PROP = 'importedArtifactPending';
|
|
99
|
+
/**
|
|
100
|
+
* An `htmlArtifact` IR block awaiting its document upload — the run-as-artifact
|
|
101
|
+
* counterpart of {@link imagePlaceholderBlock}, minimal by design: the bytes
|
|
102
|
+
* live outside the IR (they go straight to the asset store), so the block only
|
|
103
|
+
* carries the display title and the pending marker. Pure: the id derives from
|
|
104
|
+
* the title, so the same import always yields the same block id.
|
|
105
|
+
*/
|
|
106
|
+
export function htmlArtifactPendingBlock(title) {
|
|
107
|
+
const clean = title?.trim() ?? '';
|
|
108
|
+
return {
|
|
109
|
+
id: `imp_art_${contentHash(clean)}`,
|
|
110
|
+
type: 'htmlArtifact',
|
|
111
|
+
props: { ...(clean ? { title: clean } : {}), [HTML_ARTIFACT_PENDING_PROP]: true },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
88
114
|
// ── Snapshot construction ────────────────────────────────────────────────────
|
|
89
115
|
/**
|
|
90
116
|
* Wrap a block list in a page snapshot the block editor reads — the same shape
|
package/dist/import.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAKH,OAAO,EAAC,iBAAiB,EAAqC,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAgHpC,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC;IACpE,OAAO;QACL,EAAE,EAAE,WAAW,WAAW,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE;QAC/D,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,CAAC,EAAC,CAAC,EAAE,KAAK,EAAC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MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnD,gFAAgF;IAChF,gFAAgF;IAChF,MAAM,kBAAkB,GAAa,EAAE,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAI,IAAI,CAAC,IAAI,CAAC,QAAmD,EAAE,MAAM,CAAC;QACtF,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC;YAAE,SAAS;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3C,IAAI,MAAM;YAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;QAC1C,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,EAAE;QACV,YAAY;QACZ,kBAAkB;KACnB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,MAAyB,EACzB,GAAgB,EAChB,OAAsB,EAAE;IAExB,OAAO,cAAc,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACtH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,13 +16,14 @@ export { authorize, isEmailAuthoritative, type Role, type EffectiveVisibility, t
|
|
|
16
16
|
export { snapshotText, paragraphBlocks, textSnapshot, appendTextToSnapshot, appendBlocksToSnapshot, type AppendBlock } from './content';
|
|
17
17
|
export { snapshotBlocks, contentHash, computeBlockMtimes, stampSnapshotMtimes, latestBlockMtime, type BlockDigest, } from './mtime';
|
|
18
18
|
export { computeBlockAuthors, stampSnapshotAuthors, stampSnapshotAuthorsPerBlock, latestSnapshotAuthor, type BlockAuthorResolver, } from './authors';
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
19
|
+
export { OPENBOOK_ISLAND_MARKER, encodeIsland, islandScript, readIsland, readIslandRaw, } from './island';
|
|
20
|
+
export { pageToBookHtml, bookHtmlToPage, readBookHtmlMeta, pageIslandScript, sanitizeLegacyInline, isSafeHref, slugify, bookRuntimeScripts, BOOK_RUNTIME_DIR, BOOK_RUNTIME_FILE, type BookHtmlOptions, type BookPageRecord, type PageIsland, } from './bookfile';
|
|
21
|
+
export { spaceToBookFiles, parseBookFolder, spaceIslandScript, readSpaceIsland, SPACE_BUNDLE_FILE, type BookFolderFile, type SpaceSnapshot, type SpaceToBookFilesOptions, type SpaceIsland, } from './bookFolder';
|
|
21
22
|
export { canonicalDigest, generateRegistryKeys, signPlugin, verifyPlugin, validateManifest, OPENBOOK_REGISTRY, type PluginManifest, type PluginAgentTool, type PluginPackage, type PluginSignature, type StoredPlugin, } from './plugins';
|
|
22
23
|
export { buildSampleDocument, seedSampleDocument, SAMPLE_DOCUMENT_NAME } from './sampleDocument';
|
|
23
24
|
export type { CommentRun, AuthoredIdentity, SuggestionAuthorKind, SuggestionKind, SuggestionStatus, SuggestionTarget, StoredSuggestion, SuggestionInput, SuggestionUpdate, StoredComment, CommentInput, } from './suggestions';
|
|
24
25
|
export { PAGE_TEMPLATES, instantiateTemplate, type PageTemplate } from './templates';
|
|
25
|
-
export { imagePlaceholderBlock, imagePlaceholderCell, importedBlocksToSnapshot, chooseStrategy, writeViaCreateApis, buildImportBundle, writeViaBundle, importDoc, IMAGE_PLACEHOLDER_KIND, IMAGE_PLACEHOLDER_PROP, type ImportInlineAttrs, type ImportTextRun, type ImportedBlock, type ImportedAsset, type ImportedRow, type ImportedDatabase, type ImportedPage, type ImportedDoc, type ImportStrategy, type ImportWriteClient, type ImportOptions, type BundleOptions, type ImportWriteResult, blocksHaveImagePlaceholder, } from './import';
|
|
26
|
+
export { imagePlaceholderBlock, imagePlaceholderCell, importedBlocksToSnapshot, chooseStrategy, writeViaCreateApis, buildImportBundle, writeViaBundle, importDoc, IMAGE_PLACEHOLDER_KIND, IMAGE_PLACEHOLDER_PROP, HTML_ARTIFACT_PENDING_PROP, htmlArtifactPendingBlock, type ImportInlineAttrs, type ImportTextRun, type ImportedBlock, type ImportedAsset, type ImportedRow, type ImportedDatabase, type ImportedPage, type ImportedDoc, type ImportStrategy, type ImportWriteClient, type ImportOptions, type BundleOptions, type ImportWriteResult, blocksHaveImagePlaceholder, } from './import';
|
|
26
27
|
export { markdownToBlocks, markdownToImportedDoc, type MarkdownImportOptions } from './markdownImport';
|
|
27
28
|
export { notionExportToImportedDoc, parseCsv } from './notionImport';
|
|
28
29
|
export { rehydrateImageUrls, rehydrateStoredImages, importedImageBlock, imagePlaceholderMeta, mimeFromRef, notionAssetResolver, urlAssetResolver, isHttpUrl, isDataUrlRef, IMAGE_BLOCK_TYPE, DEFAULT_MAX_ASSET_BYTES, type RehydrateUrlOptions, type RehydrateStoredClient, type RehydrateStoredOptions, type RehydrateStoredResult, type ImportAssetResolver, type AssetBytes, } from './importAssets';
|
package/dist/index.js
CHANGED
|
@@ -13,12 +13,13 @@ export { authorize, isEmailAuthoritative, } from './authorize';
|
|
|
13
13
|
export { snapshotText, paragraphBlocks, textSnapshot, appendTextToSnapshot, appendBlocksToSnapshot } from './content';
|
|
14
14
|
export { snapshotBlocks, contentHash, computeBlockMtimes, stampSnapshotMtimes, latestBlockMtime, } from './mtime';
|
|
15
15
|
export { computeBlockAuthors, stampSnapshotAuthors, stampSnapshotAuthorsPerBlock, latestSnapshotAuthor, } from './authors';
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
16
|
+
export { OPENBOOK_ISLAND_MARKER, encodeIsland, islandScript, readIsland, readIslandRaw, } from './island';
|
|
17
|
+
export { pageToBookHtml, bookHtmlToPage, readBookHtmlMeta, pageIslandScript, sanitizeLegacyInline, isSafeHref, slugify, bookRuntimeScripts, BOOK_RUNTIME_DIR, BOOK_RUNTIME_FILE, } from './bookfile';
|
|
18
|
+
export { spaceToBookFiles, parseBookFolder, spaceIslandScript, readSpaceIsland, SPACE_BUNDLE_FILE, } from './bookFolder';
|
|
18
19
|
export { canonicalDigest, generateRegistryKeys, signPlugin, verifyPlugin, validateManifest, OPENBOOK_REGISTRY, } from './plugins';
|
|
19
20
|
export { buildSampleDocument, seedSampleDocument, SAMPLE_DOCUMENT_NAME } from './sampleDocument';
|
|
20
21
|
export { PAGE_TEMPLATES, instantiateTemplate } from './templates';
|
|
21
|
-
export { imagePlaceholderBlock, imagePlaceholderCell, importedBlocksToSnapshot, chooseStrategy, writeViaCreateApis, buildImportBundle, writeViaBundle, importDoc, IMAGE_PLACEHOLDER_KIND, IMAGE_PLACEHOLDER_PROP, blocksHaveImagePlaceholder, } from './import';
|
|
22
|
+
export { imagePlaceholderBlock, imagePlaceholderCell, importedBlocksToSnapshot, chooseStrategy, writeViaCreateApis, buildImportBundle, writeViaBundle, importDoc, IMAGE_PLACEHOLDER_KIND, IMAGE_PLACEHOLDER_PROP, HTML_ARTIFACT_PENDING_PROP, htmlArtifactPendingBlock, blocksHaveImagePlaceholder, } from './import';
|
|
22
23
|
export { markdownToBlocks, markdownToImportedDoc } from './markdownImport';
|
|
23
24
|
export { notionExportToImportedDoc, parseCsv } from './notionImport';
|
|
24
25
|
export { rehydrateImageUrls, rehydrateStoredImages, importedImageBlock, imagePlaceholderMeta, mimeFromRef, notionAssetResolver, urlAssetResolver, isHttpUrl, isDataUrlRef, IMAGE_BLOCK_TYPE, DEFAULT_MAX_ASSET_BYTES, } from './importAssets';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAoC,M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,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,qBAAqB,EAAC,MAAM,cAAc,CAAC;AACpP,OAAO,EACL,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,GAGlB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,GAcnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,GASxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,oBAAoB,GAOrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAmB,MAAM,WAAW,CAAC;AACtI,OAAO,EACL,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GAEjB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,GAErB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAoC,MAAM,UAAU,CAAC;AAEhE,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,mB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MAAM,aAAa,CAAC;AACnF,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EAcxB,0BAA0B,GAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,gBAAgB,EAAE,qBAAqB,EAA6B,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAC,yBAAyB,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,uBAAuB,GAOxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,GASZ,MAAM,UAAU,CAAC;AAkBlB,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,MAAM,CAAC"}
|
package/dist/island.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared **source-island** mechanism (OB export format): a machine-readable
|
|
3
|
+
* JSON blob embedded in an otherwise human-visible HTML document, carrying the
|
|
4
|
+
* lossless OpenBook source so the file round-trips back into pglite. The visible
|
|
5
|
+
* body is a *rendering*; the island is *authoritative*.
|
|
6
|
+
*
|
|
7
|
+
* One mechanism, three surfaces:
|
|
8
|
+
* - the sync-folder `.book.html` format (one page island each) — {@link ./bookfile};
|
|
9
|
+
* - single-page / slide-deck standalone HTML exports (a page island) — ui `toHtml`;
|
|
10
|
+
* - whole-site standalone HTML exports (one space-bundle island) — ui `toHtmlSite`.
|
|
11
|
+
*
|
|
12
|
+
* ## Asset contract (for the future island-first import task)
|
|
13
|
+
* The island's block-doc references image `assetId`s (content-addressed, *not*
|
|
14
|
+
* inlined), while the surrounding visible HTML carries the resolved `data:` URIs
|
|
15
|
+
* (see the ui `exportAssets` pass). Re-import reads the island → gets faithful
|
|
16
|
+
* `assetId`s; recovering the actual bytes (from the sibling data-URIs, or by
|
|
17
|
+
* re-fetching) is the import task's job. This module keeps the island FAITHFUL:
|
|
18
|
+
* `assetId`s are never rewritten to data-URIs, so the source stays lossless and
|
|
19
|
+
* the id → capability read-gate is preserved.
|
|
20
|
+
*/
|
|
21
|
+
/** The `<script type>` marking an OpenBook JSON source island. */
|
|
22
|
+
export declare const OPENBOOK_ISLAND_MARKER = "application/openbook+json";
|
|
23
|
+
/**
|
|
24
|
+
* Serialise a value to an island JSON body, escaping `</` so a literal
|
|
25
|
+
* `</script>` — or any `</…>` — anywhere in the content can't close the tag
|
|
26
|
+
* early. `<\/` is still valid JSON and parses back to `</`, so the round-trip is
|
|
27
|
+
* lossless. This is the *only* escaping the island needs (it is inert data, not
|
|
28
|
+
* executed), and it is what makes the island immune to hostile page content.
|
|
29
|
+
*/
|
|
30
|
+
export declare function encodeIsland(value: unknown): string;
|
|
31
|
+
/**
|
|
32
|
+
* Wrap an island body in the canonical inert `<script>` tag. `attrs` adds extra
|
|
33
|
+
* tag attributes (e.g. `data-openbook-snapshot`); `indent` prefixes the tag lines
|
|
34
|
+
* so callers can keep their surrounding HTML pretty-printed. The browser never
|
|
35
|
+
* executes a non-JS `type`, so the island is pure carried data.
|
|
36
|
+
*/
|
|
37
|
+
export declare function islandScript(value: unknown, opts?: {
|
|
38
|
+
attrs?: string;
|
|
39
|
+
indent?: string;
|
|
40
|
+
}): string;
|
|
41
|
+
/** Extract the first island's raw (still `<\/`-escaped) JSON text, or `null`. */
|
|
42
|
+
export declare function readIslandRaw(html: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Parse the first island in an HTML string back to its value, or `null` when
|
|
45
|
+
* absent or corrupt. `JSON.parse` unescapes the `<\/` sequences for free (`\/`
|
|
46
|
+
* is a valid JSON escape for `/`), so no separate unescape step is needed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function readIsland<T = unknown>(html: string): T | null;
|
package/dist/island.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared **source-island** mechanism (OB export format): a machine-readable
|
|
3
|
+
* JSON blob embedded in an otherwise human-visible HTML document, carrying the
|
|
4
|
+
* lossless OpenBook source so the file round-trips back into pglite. The visible
|
|
5
|
+
* body is a *rendering*; the island is *authoritative*.
|
|
6
|
+
*
|
|
7
|
+
* One mechanism, three surfaces:
|
|
8
|
+
* - the sync-folder `.book.html` format (one page island each) — {@link ./bookfile};
|
|
9
|
+
* - single-page / slide-deck standalone HTML exports (a page island) — ui `toHtml`;
|
|
10
|
+
* - whole-site standalone HTML exports (one space-bundle island) — ui `toHtmlSite`.
|
|
11
|
+
*
|
|
12
|
+
* ## Asset contract (for the future island-first import task)
|
|
13
|
+
* The island's block-doc references image `assetId`s (content-addressed, *not*
|
|
14
|
+
* inlined), while the surrounding visible HTML carries the resolved `data:` URIs
|
|
15
|
+
* (see the ui `exportAssets` pass). Re-import reads the island → gets faithful
|
|
16
|
+
* `assetId`s; recovering the actual bytes (from the sibling data-URIs, or by
|
|
17
|
+
* re-fetching) is the import task's job. This module keeps the island FAITHFUL:
|
|
18
|
+
* `assetId`s are never rewritten to data-URIs, so the source stays lossless and
|
|
19
|
+
* the id → capability read-gate is preserved.
|
|
20
|
+
*/
|
|
21
|
+
/** The `<script type>` marking an OpenBook JSON source island. */
|
|
22
|
+
export const OPENBOOK_ISLAND_MARKER = 'application/openbook+json';
|
|
23
|
+
/**
|
|
24
|
+
* Serialise a value to an island JSON body, escaping `</` so a literal
|
|
25
|
+
* `</script>` — or any `</…>` — anywhere in the content can't close the tag
|
|
26
|
+
* early. `<\/` is still valid JSON and parses back to `</`, so the round-trip is
|
|
27
|
+
* lossless. This is the *only* escaping the island needs (it is inert data, not
|
|
28
|
+
* executed), and it is what makes the island immune to hostile page content.
|
|
29
|
+
*/
|
|
30
|
+
export function encodeIsland(value) {
|
|
31
|
+
return JSON.stringify(value).replace(/<\//g, '<\\/');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wrap an island body in the canonical inert `<script>` tag. `attrs` adds extra
|
|
35
|
+
* tag attributes (e.g. `data-openbook-snapshot`); `indent` prefixes the tag lines
|
|
36
|
+
* so callers can keep their surrounding HTML pretty-printed. The browser never
|
|
37
|
+
* executes a non-JS `type`, so the island is pure carried data.
|
|
38
|
+
*/
|
|
39
|
+
export function islandScript(value, opts = {}) {
|
|
40
|
+
const { attrs = '', indent = '' } = opts;
|
|
41
|
+
return `${indent}<script type="${OPENBOOK_ISLAND_MARKER}"${attrs ? ` ${attrs}` : ''}>\n${encodeIsland(value)}\n${indent}</script>`;
|
|
42
|
+
}
|
|
43
|
+
const ISLAND_RE = new RegExp(`<script[^>]*type="${OPENBOOK_ISLAND_MARKER.replace(/[/+]/g, '\\$&')}"[^>]*>([\\s\\S]*?)</script>`, 'i');
|
|
44
|
+
/** Extract the first island's raw (still `<\/`-escaped) JSON text, or `null`. */
|
|
45
|
+
export function readIslandRaw(html) {
|
|
46
|
+
const m = html.match(ISLAND_RE);
|
|
47
|
+
return m ? m[1].trim() : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse the first island in an HTML string back to its value, or `null` when
|
|
51
|
+
* absent or corrupt. `JSON.parse` unescapes the `<\/` sequences for free (`\/`
|
|
52
|
+
* is a valid JSON escape for `/`), so no separate unescape step is needed.
|
|
53
|
+
*/
|
|
54
|
+
export function readIsland(html) {
|
|
55
|
+
const raw = readIslandRaw(html);
|
|
56
|
+
if (raw === null)
|
|
57
|
+
return null;
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(raw);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=island.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