rapier-embed 1.2.52 → 1.2.56

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/README.md CHANGED
@@ -2,11 +2,6 @@
2
2
 
3
3
  Put Rapier's Markdown editor or reader in your web app, each one offline HTML file.
4
4
 
5
- <picture>
6
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jackskip22/rapier-plugins/main/assets/write-1280-dark.png">
7
- <img src="https://raw.githubusercontent.com/jackskip22/rapier-plugins/main/assets/write-1280-light.png" alt="The Rapier editor on a computer: a launch plan with an agent's change marked" width="960">
8
- </picture>
9
-
10
5
  Try the editor at [rapier.website](https://rapier.website).
11
6
  Install: `npm install rapier-embed`.
12
7
 
@@ -161,7 +156,7 @@ length and SHA-384 before it runs it, and keeps on the device. A file that fails
161
156
  | Plug-in | Adds | Size | Pages |
162
157
  | --- | --- | --- | --- |
163
158
  | `flowchart` | Draws Mermaid flowcharts and graphs natively, in the editor's own style. | 0.36 MB | The reader |
164
- | `docx` | Opens a Word document (.docx) as a Markdown document: headings, lists, tables, pictures and comments. | 0.92 MB | The reader |
159
+ | `docx` | Opens a Word document (.docx) as a Markdown document: headings, lists, tables, pictures and comments. | 0.94 MB | The reader |
165
160
  | `math` | Typesets TeX math ($...$ and $$...$$) as SVG. | 0.74 MB | Both |
166
161
  | `diagrams` | Draws every other Mermaid diagram: sequence, class, state, ER, Gantt, pie and more. | 1.14 MB (2 files) | Both |
167
162
  | `pdf` | Opens a PDF as a Markdown document: its text layer, or each page as a picture. Fetches the pdf.js files itself. | 6.16 MB (198 files) | Both |
@@ -172,7 +167,7 @@ length and SHA-384 before it runs it, and keeps on the device. A file that fails
172
167
  | `elements` | The Elements sheet's traced ornaments: 3,155 pieces from the ornament book. | 16.2 MB (51 files) | `rapier.html` |
173
168
  | `lettersets` | The Gallery's letter sets: 31 sets of ornamental capitals. | 2.82 MB (31 files) | `rapier.html` |
174
169
 
175
- Totals: the reader, 9.32 MB (31.0 MB with `ocr`); `rapier.html`, 57.2 MB. Release 1.2.52.
170
+ Totals: the reader, 9.34 MB (31.0 MB with `ocr`); `rapier.html`, 57.2 MB. Release 1.2.56.
176
171
  <!-- PLUGIN_TABLE_END -->
177
172
 
178
173
  The manifest lists every plug-in file and, in `builds`, the pages that use it. `rapier.html` has flowcharts and Word import
package/contract.d.mts CHANGED
@@ -34,8 +34,54 @@ export function normalizeSettings(value?: Settings, policy?: {features?: readonl
34
34
  export function snapshotSettings(value: Settings | undefined): Readonly<Partial<AcceptedSettings>> | undefined;
35
35
  /** Opens the device's file chooser; resolves null when canceled or aborted. */
36
36
  export function pickDeviceFile(document: Document, signal?: AbortSignal): Promise<File | null>;
37
- /** The editor page's open-file exchange; used by the page itself. */
38
- export function createFilePicker(ports: Record<string, unknown>): unknown;
37
+ export interface FilePickerSnapshot {
38
+ port: unknown;
39
+ portGeneration: unknown;
40
+ baseRevision: number | string | null;
41
+ timer?: ReturnType<typeof setTimeout>;
42
+ reading?: boolean;
43
+ committing?: boolean;
44
+ }
45
+ /** Ticket-owned fields replace or widen snapshot fields as the picker advances. */
46
+ export type FilePickerPending<Snapshot extends FilePickerSnapshot = FilePickerSnapshot> =
47
+ Omit<Snapshot, 'requestId' | 'controller' | 'started' | 'host' | 'timer' | 'reading' | 'committing'> & {
48
+ requestId: string;
49
+ controller: AbortController;
50
+ started(value: boolean): void;
51
+ host: boolean;
52
+ timer?: ReturnType<typeof setTimeout>;
53
+ reading?: boolean;
54
+ committing?: boolean;
55
+ };
56
+ export type FilePickerReply = {requestId: string; baseRevision: number | string | null} & (
57
+ {type: 'open-ack'; payload?: Record<string, never>} |
58
+ {type: 'open-result'; payload: {file: File | null}} |
59
+ {type: 'open-nack'; payload: {code: string; reason: string}}
60
+ );
61
+ export interface FilePickerPorts<Snapshot extends FilePickerSnapshot = FilePickerSnapshot> {
62
+ document: Document;
63
+ refusal(): string | null | undefined;
64
+ snapshot(): Snapshot;
65
+ current(row: FilePickerPending<Snapshot>): boolean;
66
+ settle(): boolean;
67
+ post(type: 'open-request' | 'open-cancel', payload: Record<string, never>, requestId: string, baseRevision: number | string | null): boolean;
68
+ /** The picker awaits completion but does not use the returned value. */
69
+ open(file: File, row: FilePickerPending<Snapshot>): unknown;
70
+ notify(code: string): void;
71
+ error(failure: unknown): void;
72
+ }
73
+ export interface FilePicker<Snapshot extends FilePickerSnapshot = FilePickerSnapshot> {
74
+ pending: FilePickerPending<Snapshot> | null;
75
+ refusal(): string | null | undefined;
76
+ current(row: FilePickerPending<Snapshot> | null | undefined): boolean;
77
+ check(): void;
78
+ cancel(code?: string, tellHost?: boolean): void;
79
+ begin(event?: Pick<Event, 'isTrusted'> | null): false | Promise<boolean>;
80
+ answer(data: FilePickerReply): string;
81
+ selected(file: File | null, row: FilePickerPending<Snapshot>): Promise<void>;
82
+ }
83
+ /** The page's open-file exchange, not a mount option. Call methods on the returned picker. */
84
+ export function createFilePicker<Snapshot extends FilePickerSnapshot>(ports: FilePickerPorts<Snapshot>): FilePicker<Snapshot>;
39
85
  /** An absolute HTTPS address without credentials, at most 4,096 code units; throws `asset_url_invalid`. */
40
86
  export function assetURL(value: string): string;
41
87
  /** Nonempty bytes within the picture limit; throws `asset_bytes_invalid` or `picture_too_large`. */
@@ -43,8 +89,34 @@ export function assetBytes(value: Uint8Array, limit?: number): Uint8Array;
43
89
  /** Lowercase hex SHA-256. */
44
90
  export function bytesHash(bytes: BufferSource): Promise<string>;
45
91
  export function externalImage(raw: string, asset: {label: string; title?: string}, url: string | null | undefined): string;
46
- /** The editor page's picture exchange; used by the page itself. */
47
- export function createAssetBroker(ports: Record<string, unknown>): unknown;
92
+ export interface BrokerAsset {
93
+ bytes: Uint8Array;
94
+ codec: AssetType;
95
+ [metadata: string]: unknown;
96
+ }
97
+ /** A shallow asset copy with owned bytes; metadata is not cloned or frozen. */
98
+ export interface RetainedAsset extends BrokerAsset { bytes: Uint8Array<ArrayBuffer>; }
99
+ export interface AssetBrokerState {
100
+ identity: unknown;
101
+ generation: unknown;
102
+ connected: boolean;
103
+ granted: boolean;
104
+ pictureBytes: number;
105
+ baseRevision: number | string | null;
106
+ }
107
+ export type AssetBrokerResult = {url: string} | {code: string};
108
+ export interface AssetBrokerPorts {
109
+ current(): AssetBrokerState;
110
+ send(type: 'asset-request', payload: {bytesSha256: string; mediaType: AssetType; bytes: Uint8Array<ArrayBuffer>}, requestId: string, baseRevision: number | string | null): boolean;
111
+ }
112
+ export interface AssetBroker {
113
+ request(asset: BrokerAsset): Promise<AssetBrokerResult>;
114
+ answer(message: {type: 'asset-ack' | 'asset-nack'; requestId: string; baseRevision: number | string | null; payload?: {url?: string; code?: string; reason?: string}}): AssetBrokerResult;
115
+ cancel(code?: string): void;
116
+ lookup(url: string): RetainedAsset | null;
117
+ }
118
+ /** The page's picture exchange, not the host's assets callback. */
119
+ export function createAssetBroker(ports: AssetBrokerPorts): Readonly<AssetBroker>;
48
120
  /** Not a mount option: the option is `baseUrl` on `load`. The host's picture base: returns a function that turns a relative picture address into an address under `baseUrl` (or null), with
49
121
  * `vouched`, the addresses it produced. Null when no base is given; throws `invalid_base_url` for anything but an absolute https address (or http on localhost). Used by the page itself. */
50
122
  export function pictureBase(value: string | null | undefined): (((src: string) => string | null) & {vouched: Set<string>}) | null;
package/embed.mjs CHANGED
@@ -271,7 +271,7 @@ function pictureBase(value) {
271
271
  return {FEATURES, LIMITS, ASSET_TYPES, refusal, coded, normalizeSettings, snapshotSettings, pickDeviceFile, createFilePicker, assetURL, assetBytes, bytesHash, externalImage, createAssetBroker, pictureBase};
272
272
  })();
273
273
  const BUILDS = Object.freeze({full: 'https://rapier.website/embed/rapier.html', reader: 'https://rapier.website/embed/rapier-reader.html'});
274
- const PACKAGE_VERSION = '1.2.52';
274
+ const PACKAGE_VERSION = '1.2.56';
275
275
  const OPTIONS = ['build', 'src', 'plugins', 'approvePlugins', 'sessionId', 'documentId', 'agent', 'agentName', 'theme', 'save', 'assets', 'openFile', 'load',
276
276
  'onState', 'compare', 'onClose', 'settings', 'style', 'title', 'onError', 'timeout'];
277
277
  const READER_FEATURES = ['find', 'readAloud', 'share'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-embed",
3
- "version": "1.2.52",
3
+ "version": "1.2.56",
4
4
  "description": "Embed the Rapier Markdown editor or its lightweight reader (about 360 kB) in your web app. Runs offline from your own copy, saves to your storage, and takes your CSS and fonts. Your app's AI agent edits directly over WebMCP under the Will. MIT, no dependencies.",
5
5
  "keywords": [
6
6
  "markdown",