rmapi-js 12.0.3 → 14.0.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/codes.d.ts +35 -0
- package/dist/codes.js +61 -0
- package/dist/index.d.ts +185 -38
- package/dist/index.js +731 -237
- package/dist/lru.d.ts +4 -4
- package/dist/lru.js +4 -4
- package/dist/raw.d.ts +169 -36
- package/dist/raw.js +214 -74
- package/dist/rm5.d.ts +7 -31
- package/dist/rm5.js +3 -43
- package/dist/rm6.d.ts +45 -19
- package/dist/rm6.js +422 -42
- package/dist/rmapi-js.esm.min.js +77 -9
- package/package.json +7 -7
package/dist/rm6.d.ts
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
* of length-prefixed, tagged blocks. This module reads every block faithfully
|
|
6
6
|
* — preserving `CrdtId`s, `LwwValue` wrappers, and each block's unread tail —
|
|
7
7
|
* into an {@link RmScene | `RmScene`}, whose methods resolve the CRDT into
|
|
8
|
-
* ordered layers, strokes, and text.
|
|
9
|
-
*
|
|
8
|
+
* ordered layers, strokes, and text. Nothing is dropped, so
|
|
9
|
+
* {@link serializeRmScene | `serializeRmScene`} reproduces the original bytes
|
|
10
|
+
* exactly, including blocks it could not parse.
|
|
10
11
|
*
|
|
11
12
|
* @packageDocumentation
|
|
12
13
|
*/
|
|
14
|
+
import { type RmBrushCode, type RmColorCode } from "./codes.js";
|
|
13
15
|
/**
|
|
14
16
|
* a CRDT identifier: an `(authorId, counter)` pair, unique across replicas
|
|
15
17
|
*
|
|
@@ -44,7 +46,7 @@ export interface RmV6Point {
|
|
|
44
46
|
y: number;
|
|
45
47
|
/** pen speed */
|
|
46
48
|
speed: number;
|
|
47
|
-
/** stroke width */
|
|
49
|
+
/** stroke width; integral for version 2 points, fractional for version 1 */
|
|
48
50
|
width: number;
|
|
49
51
|
/** pen direction, 0–255 mapping onto 0–2π */
|
|
50
52
|
direction: number;
|
|
@@ -53,16 +55,20 @@ export interface RmV6Point {
|
|
|
53
55
|
}
|
|
54
56
|
/** a version 6 stroke */
|
|
55
57
|
export interface RmV6Line {
|
|
56
|
-
/** the
|
|
57
|
-
tool:
|
|
58
|
-
/** the
|
|
59
|
-
color:
|
|
58
|
+
/** the pen code, named by `rmBrushes` */
|
|
59
|
+
tool: RmBrushCode;
|
|
60
|
+
/** the color code, named by `rmColors` */
|
|
61
|
+
color: RmColorCode;
|
|
60
62
|
/** the stroke thickness scale */
|
|
61
63
|
thicknessScale: number;
|
|
62
64
|
/** the length at which the stroke starts */
|
|
63
65
|
startingLength: number;
|
|
64
66
|
/** the sampled points */
|
|
65
67
|
points: RmV6Point[];
|
|
68
|
+
/** the stroke's timestamp id, if the file carried one */
|
|
69
|
+
timestampId?: CrdtId;
|
|
70
|
+
/** the stroke's move id, if the file carried one */
|
|
71
|
+
moveId?: CrdtId;
|
|
66
72
|
/**
|
|
67
73
|
* a packed little-endian uint32 color, only present for highlighter strokes
|
|
68
74
|
*
|
|
@@ -89,8 +95,8 @@ export interface GlyphRange {
|
|
|
89
95
|
start?: number;
|
|
90
96
|
/** the length of the range */
|
|
91
97
|
length: number;
|
|
92
|
-
/** the
|
|
93
|
-
color:
|
|
98
|
+
/** the color code, named by `rmColors` */
|
|
99
|
+
color: RmColorCode;
|
|
94
100
|
/** the highlighted text */
|
|
95
101
|
text: string;
|
|
96
102
|
/** the bounding rectangles of the highlight */
|
|
@@ -128,6 +134,12 @@ export interface RmV6Text {
|
|
|
128
134
|
}
|
|
129
135
|
/** fields carried by every block */
|
|
130
136
|
interface BlockCommon {
|
|
137
|
+
/**
|
|
138
|
+
* the header byte between the block length and the versions
|
|
139
|
+
*
|
|
140
|
+
* Zero in every well-formed file seen, but preserved rather than assumed.
|
|
141
|
+
*/
|
|
142
|
+
reserved: number;
|
|
131
143
|
/** the block's minimum reader version */
|
|
132
144
|
minVersion: number;
|
|
133
145
|
/** the block's current version (selects the point encoding for lines) */
|
|
@@ -167,14 +179,19 @@ export interface TreeNodeBlock extends BlockCommon {
|
|
|
167
179
|
label: LwwValue<string>;
|
|
168
180
|
/** whether the layer is visible */
|
|
169
181
|
visible: LwwValue<boolean>;
|
|
170
|
-
/** the
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
/** where the node is anchored, when it is */
|
|
183
|
+
anchor?: TreeNodeAnchor;
|
|
184
|
+
}
|
|
185
|
+
/** the four values a tree node carries when it's anchored, always together */
|
|
186
|
+
export interface TreeNodeAnchor {
|
|
187
|
+
/** the anchor node's crdt id */
|
|
188
|
+
id: LwwValue<CrdtId>;
|
|
189
|
+
/** the anchor type */
|
|
190
|
+
type: LwwValue<number>;
|
|
191
|
+
/** the anchor threshold */
|
|
192
|
+
threshold: LwwValue<number>;
|
|
193
|
+
/** the anchor's horizontal origin */
|
|
194
|
+
originX: LwwValue<number>;
|
|
178
195
|
}
|
|
179
196
|
/** the `0x05` scene line item block — a stroke */
|
|
180
197
|
export interface SceneLineItemBlock extends BlockCommon {
|
|
@@ -242,8 +259,8 @@ export interface PageInfoBlock extends BlockCommon {
|
|
|
242
259
|
textCharsCount: number;
|
|
243
260
|
/** the number of text lines on the page */
|
|
244
261
|
textLinesCount: number;
|
|
245
|
-
/** the type-folio use count */
|
|
246
|
-
typeFolioUseCount
|
|
262
|
+
/** the type-folio use count, if the block carried one */
|
|
263
|
+
typeFolioUseCount?: number;
|
|
247
264
|
}
|
|
248
265
|
/** the `0x09` author ids block — the author-id to uuid table */
|
|
249
266
|
export interface AuthorIdsBlock extends BlockCommon {
|
|
@@ -273,6 +290,13 @@ export interface UnknownBlock extends BlockCommon {
|
|
|
273
290
|
blockType: number;
|
|
274
291
|
/** the raw block body bytes */
|
|
275
292
|
data: Uint8Array;
|
|
293
|
+
/**
|
|
294
|
+
* the length the block header declared, when it overran the file
|
|
295
|
+
*
|
|
296
|
+
* Corrupt files exist in the wild; keeping the original figure lets them
|
|
297
|
+
* round-trip byte for byte instead of being silently rewritten.
|
|
298
|
+
*/
|
|
299
|
+
declaredLength?: number;
|
|
276
300
|
}
|
|
277
301
|
/** any parsed version 6 block */
|
|
278
302
|
export type RmBlock = MigrationInfoBlock | SceneTreeBlock | TreeNodeBlock | SceneLineItemBlock | SceneGlyphItemBlock | SceneGroupItemBlock | SceneTextItemBlock | SceneTombstoneItemBlock | RootTextBlock | PageInfoBlock | AuthorIdsBlock | SceneInfoBlock | UnknownBlock;
|
|
@@ -329,6 +353,8 @@ export declare class RmScene {
|
|
|
329
353
|
/** the page's document text, if any */
|
|
330
354
|
text(): RmV6Text | undefined;
|
|
331
355
|
}
|
|
356
|
+
/** serialize a parsed scene back to version 6 `.rm` bytes */
|
|
357
|
+
export declare function serializeRmScene(scene: RmScene): Uint8Array;
|
|
332
358
|
/** parse a version 6 `.rm` file into a resolvable scene */
|
|
333
359
|
export declare function parseRmScene(data: Uint8Array): RmScene;
|
|
334
360
|
export {};
|