rmapi-js 13.0.0 → 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 +3 -2
- package/dist/index.js +1 -1
- package/dist/rm5.d.ts +6 -30
- package/dist/rm5.js +3 -43
- package/dist/rm6.d.ts +7 -6
- package/dist/rm6.js +4 -3
- package/dist/rmapi-js.esm.min.js +76 -12
- package/package.json +7 -7
package/dist/codes.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pen and color codes a stroke carries, shared by every `.rm` version.
|
|
3
|
+
*
|
|
4
|
+
* A stroke stores its pen and its color as small integers. Both sets grew with
|
|
5
|
+
* the firmware, so a code from a newer device can name the same pen or color
|
|
6
|
+
* as an older one. Reading a page checks the codes against these lists.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/** a pen/tool name for a stroke */
|
|
12
|
+
export type RmBrush = "brush" | "pencil" | "ballpoint" | "marker" | "fineliner" | "highlighter" | "eraser" | "mechanicalPencil" | "eraseArea" | "calligraphy" | "shader";
|
|
13
|
+
/** a pen code that appears in a file */
|
|
14
|
+
export type RmBrushCode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 23;
|
|
15
|
+
export declare const rmBrushCode: z.ZodType<RmBrushCode>;
|
|
16
|
+
/**
|
|
17
|
+
* the reMarkable pens, by code
|
|
18
|
+
*
|
|
19
|
+
* The codes come in two firmware families, so two codes can name the same pen.
|
|
20
|
+
*/
|
|
21
|
+
export declare const rmBrushes: Readonly<Record<RmBrushCode, RmBrush>>;
|
|
22
|
+
/** a color name for a stroke */
|
|
23
|
+
export type RmColor = "black" | "gray" | "white" | "yellow" | "green" | "pink" | "blue" | "red" | "grayOverlap" | "highlight" | "cyan" | "magenta";
|
|
24
|
+
/** a color code that appears in a file */
|
|
25
|
+
export type RmColorCode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
|
|
26
|
+
export declare const rmColorCode: z.ZodType<RmColorCode>;
|
|
27
|
+
/**
|
|
28
|
+
* the reMarkable palette, by code
|
|
29
|
+
*
|
|
30
|
+
* The palette grew when colored annotations arrived and again for the Paper
|
|
31
|
+
* Pro, so two codes can name the same color. `"highlight"` is a marker rather
|
|
32
|
+
* than a color — the stroke's real color is its `colorRgba`. The shade a name
|
|
33
|
+
* renders as depends on the device.
|
|
34
|
+
*/
|
|
35
|
+
export declare const rmColors: Readonly<Record<RmColorCode, RmColor>>;
|
package/dist/codes.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pen and color codes a stroke carries, shared by every `.rm` version.
|
|
3
|
+
*
|
|
4
|
+
* A stroke stores its pen and its color as small integers. Both sets grew with
|
|
5
|
+
* the firmware, so a code from a newer device can name the same pen or color
|
|
6
|
+
* as an older one. Reading a page checks the codes against these lists.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
export const rmBrushCode = z.literal([0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 21, 23], { error: "unknown pen code" });
|
|
12
|
+
/**
|
|
13
|
+
* the reMarkable pens, by code
|
|
14
|
+
*
|
|
15
|
+
* The codes come in two firmware families, so two codes can name the same pen.
|
|
16
|
+
*/
|
|
17
|
+
export const rmBrushes = {
|
|
18
|
+
0: "brush",
|
|
19
|
+
12: "brush",
|
|
20
|
+
1: "pencil",
|
|
21
|
+
14: "pencil",
|
|
22
|
+
2: "ballpoint",
|
|
23
|
+
15: "ballpoint",
|
|
24
|
+
3: "marker",
|
|
25
|
+
16: "marker",
|
|
26
|
+
4: "fineliner",
|
|
27
|
+
17: "fineliner",
|
|
28
|
+
5: "highlighter",
|
|
29
|
+
18: "highlighter",
|
|
30
|
+
6: "eraser",
|
|
31
|
+
7: "mechanicalPencil",
|
|
32
|
+
13: "mechanicalPencil",
|
|
33
|
+
8: "eraseArea",
|
|
34
|
+
21: "calligraphy",
|
|
35
|
+
23: "shader",
|
|
36
|
+
};
|
|
37
|
+
export const rmColorCode = z.literal([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], { error: "unknown color code" });
|
|
38
|
+
/**
|
|
39
|
+
* the reMarkable palette, by code
|
|
40
|
+
*
|
|
41
|
+
* The palette grew when colored annotations arrived and again for the Paper
|
|
42
|
+
* Pro, so two codes can name the same color. `"highlight"` is a marker rather
|
|
43
|
+
* than a color — the stroke's real color is its `colorRgba`. The shade a name
|
|
44
|
+
* renders as depends on the device.
|
|
45
|
+
*/
|
|
46
|
+
export const rmColors = {
|
|
47
|
+
0: "black",
|
|
48
|
+
1: "gray",
|
|
49
|
+
2: "white",
|
|
50
|
+
3: "yellow",
|
|
51
|
+
4: "green",
|
|
52
|
+
5: "pink",
|
|
53
|
+
6: "blue",
|
|
54
|
+
7: "red",
|
|
55
|
+
8: "grayOverlap",
|
|
56
|
+
9: "highlight",
|
|
57
|
+
10: "green",
|
|
58
|
+
11: "cyan",
|
|
59
|
+
12: "magenta",
|
|
60
|
+
13: "yellow",
|
|
61
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type BackgroundFilter, type CollectionContent, type Content, type DocumentContent, type Highlight, type ItemRef, type Metadata, type Orientation, type PageMetadata, RawRemarkable, type RmPage, type Tag, type TemplateContent, type TextAlignment, type ZoomMode } from "./raw.js";
|
|
2
|
+
export type { RmBrush, RmBrushCode, RmColor, RmColorCode, } from "./codes.js";
|
|
3
|
+
export { rmBrushes, rmColors } from "./codes.js";
|
|
2
4
|
export { type DeviceModel, type DeviceScreen, deviceScreens, } from "./devices.js";
|
|
3
5
|
export { HashNotFoundError, ValidationError } from "./error.js";
|
|
4
6
|
export type { BackgroundFilter, CollectionContent, Content, CPageNumberValue, CPagePage, CPageStringValue, CPages, CPageUUID, DocumentContent, DocumentMetadata, Entries, EntryType, FileType, Highlight, HighlightRect, ItemRef, KeyboardMetadata, LegacyCollectionContent, LegacyDocumentContent, Metadata, Orientation, PageLayer, PageMetadata, PageTag, PendingEntry, RawEntry, RawRemarkableApi, RmPage, SchemaVersion, Tag, TemplateContent, TextAlignment, UploadMimeType, ZoomMode, } from "./raw.js";
|
|
5
|
-
export type {
|
|
6
|
-
export { decodeBrush, rmColors } from "./rm5.js";
|
|
7
|
+
export type { RmLayer, RmLine, RmPageV5, RmPoint, RmVersion, } from "./rm5.js";
|
|
7
8
|
export type { AuthorIdsBlock, CrdtId, GlyphRange, LwwValue, MigrationInfoBlock, PageInfoBlock, Rectangle, RmBlock, RmScene, RmSceneItem, RmSceneLayer, RmV6Line, RmV6Point, RmV6Text, RmV6TextValue, RootTextBlock, SceneGlyphItemBlock, SceneGroupItemBlock, SceneInfoBlock, SceneItem, SceneLineItemBlock, SceneTextItemBlock, SceneTombstoneItemBlock, SceneTreeBlock, TreeNodeAnchor, TreeNodeBlock, UnknownBlock, } from "./rm6.js";
|
|
8
9
|
export { crdtKey } from "./rm6.js";
|
|
9
10
|
/** common properties shared by collections and documents */
|
package/dist/index.js
CHANGED
|
@@ -110,9 +110,9 @@ import { z } from "zod";
|
|
|
110
110
|
import { HashNotFoundError, ValidationError } from "./error.js";
|
|
111
111
|
import { LruCache } from "./lru.js";
|
|
112
112
|
import { BYTES_PREFIX, CACHE_VERSION, parseMetadata, RawRemarkable, TEXT_PREFIX, } from "./raw.js";
|
|
113
|
+
export { rmBrushes, rmColors } from "./codes.js";
|
|
113
114
|
export { deviceScreens, } from "./devices.js";
|
|
114
115
|
export { HashNotFoundError, ValidationError } from "./error.js";
|
|
115
|
-
export { decodeBrush, rmColors } from "./rm5.js";
|
|
116
116
|
export { crdtKey } from "./rm6.js";
|
|
117
117
|
const AUTH_HOST = "https://webapp-prod.cloud.remarkable.engineering";
|
|
118
118
|
const RAW_HOST = "https://eu.tectonic.remarkable.com";
|
package/dist/rm5.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
+
import { type RmBrushCode, type RmColorCode } from "./codes.js";
|
|
16
17
|
/** the flat reMarkable `.lines` file versions read into an {@link RmPageV5} */
|
|
17
18
|
export type RmVersion = 3 | 5;
|
|
18
19
|
/** a single sampled point along a stroke */
|
|
@@ -30,20 +31,12 @@ export interface RmPoint {
|
|
|
30
31
|
/** the pen pressure, from 0 to 1 */
|
|
31
32
|
pressure: number;
|
|
32
33
|
}
|
|
33
|
-
/**
|
|
34
|
-
* a single stroke (called a "line") within a layer
|
|
35
|
-
*
|
|
36
|
-
* `brushType` and `color` are kept as raw integers because both are overloaded
|
|
37
|
-
* across firmware versions (there are two pen-code families, and the color
|
|
38
|
-
* field is reinterpreted as a palette index when colored annotations are
|
|
39
|
-
* enabled), so the right meaning can only be resolved with the source firmware
|
|
40
|
-
* in mind.
|
|
41
|
-
*/
|
|
34
|
+
/** a single stroke (called a "line") within a layer */
|
|
42
35
|
export interface RmLine {
|
|
43
|
-
/** the
|
|
44
|
-
brushType:
|
|
45
|
-
/** the
|
|
46
|
-
color:
|
|
36
|
+
/** the pen code, named by {@link rmBrushes | `rmBrushes`} */
|
|
37
|
+
brushType: RmBrushCode;
|
|
38
|
+
/** the color code, named by {@link rmColors | `rmColors`} */
|
|
39
|
+
color: RmColorCode;
|
|
47
40
|
/** a per-stroke padding field, typically 0 */
|
|
48
41
|
padding?: number;
|
|
49
42
|
/** the base brush size */
|
|
@@ -70,23 +63,6 @@ export interface RmPageV5 {
|
|
|
70
63
|
/** the drawing layers, back to front */
|
|
71
64
|
layers: RmLayer[];
|
|
72
65
|
}
|
|
73
|
-
/** a decoded pen/tool for a stroke */
|
|
74
|
-
export type RmBrush = "brush" | "pencil" | "ballpoint" | "marker" | "fineliner" | "highlighter" | "eraser" | "mechanicalPencil" | "eraseArea" | "calligraphy" | "shader";
|
|
75
|
-
/**
|
|
76
|
-
* decode a raw {@link RmLine.brushType | `brushType`} code to a pen name
|
|
77
|
-
*
|
|
78
|
-
* Best-effort and advisory: the reMarkable pen codes come in two firmware
|
|
79
|
-
* families and new ones appear over time, so an unrecognized code returns
|
|
80
|
-
* `undefined`. The raw `brushType` int stays authoritative.
|
|
81
|
-
*/
|
|
82
|
-
export declare function decodeBrush(code: number): RmBrush | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* the default (monochrome) reMarkable palette, by raw {@link RmLine.color | `color`}
|
|
85
|
-
*
|
|
86
|
-
* Advisory only: when "colored annotations" are enabled or on version 6, the
|
|
87
|
-
* `color` field is reinterpreted, so resolve against the source firmware.
|
|
88
|
-
*/
|
|
89
|
-
export declare const rmColors: Readonly<Record<number, string>>;
|
|
90
66
|
/** the length of the fixed `.lines` header, in bytes */
|
|
91
67
|
export declare const HEADER_LENGTH = 43;
|
|
92
68
|
/** the ascii prefix of the header, immediately followed by the version digit */
|
package/dist/rm5.js
CHANGED
|
@@ -13,47 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
0: "brush",
|
|
18
|
-
12: "brush",
|
|
19
|
-
1: "pencil",
|
|
20
|
-
14: "pencil",
|
|
21
|
-
2: "ballpoint",
|
|
22
|
-
15: "ballpoint",
|
|
23
|
-
3: "marker",
|
|
24
|
-
16: "marker",
|
|
25
|
-
4: "fineliner",
|
|
26
|
-
17: "fineliner",
|
|
27
|
-
5: "highlighter",
|
|
28
|
-
18: "highlighter",
|
|
29
|
-
6: "eraser",
|
|
30
|
-
7: "mechanicalPencil",
|
|
31
|
-
13: "mechanicalPencil",
|
|
32
|
-
8: "eraseArea",
|
|
33
|
-
21: "calligraphy",
|
|
34
|
-
23: "shader",
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* decode a raw {@link RmLine.brushType | `brushType`} code to a pen name
|
|
38
|
-
*
|
|
39
|
-
* Best-effort and advisory: the reMarkable pen codes come in two firmware
|
|
40
|
-
* families and new ones appear over time, so an unrecognized code returns
|
|
41
|
-
* `undefined`. The raw `brushType` int stays authoritative.
|
|
42
|
-
*/
|
|
43
|
-
export function decodeBrush(code) {
|
|
44
|
-
return BRUSHES[code];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* the default (monochrome) reMarkable palette, by raw {@link RmLine.color | `color`}
|
|
48
|
-
*
|
|
49
|
-
* Advisory only: when "colored annotations" are enabled or on version 6, the
|
|
50
|
-
* `color` field is reinterpreted, so resolve against the source firmware.
|
|
51
|
-
*/
|
|
52
|
-
export const rmColors = {
|
|
53
|
-
0: "black",
|
|
54
|
-
1: "gray",
|
|
55
|
-
2: "white",
|
|
56
|
-
};
|
|
16
|
+
import { rmBrushCode, rmColorCode, } from "./codes.js";
|
|
57
17
|
/** the length of the fixed `.lines` header, in bytes */
|
|
58
18
|
export const HEADER_LENGTH = 43;
|
|
59
19
|
/** the ascii prefix of the header, immediately followed by the version digit */
|
|
@@ -83,8 +43,8 @@ export function parseV5(data, version) {
|
|
|
83
43
|
const numLines = readInt();
|
|
84
44
|
const lines = [];
|
|
85
45
|
for (let line = 0; line < numLines; line++) {
|
|
86
|
-
const brushType = readInt();
|
|
87
|
-
const color = readInt();
|
|
46
|
+
const brushType = rmBrushCode.parse(readInt());
|
|
47
|
+
const color = rmColorCode.parse(readInt());
|
|
88
48
|
const padding = readInt();
|
|
89
49
|
const brushBaseSize = readFloat();
|
|
90
50
|
const unknown = version === 5 ? readInt() : undefined;
|
package/dist/rm6.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
+
import { type RmBrushCode, type RmColorCode } from "./codes.js";
|
|
14
15
|
/**
|
|
15
16
|
* a CRDT identifier: an `(authorId, counter)` pair, unique across replicas
|
|
16
17
|
*
|
|
@@ -54,10 +55,10 @@ export interface RmV6Point {
|
|
|
54
55
|
}
|
|
55
56
|
/** a version 6 stroke */
|
|
56
57
|
export interface RmV6Line {
|
|
57
|
-
/** the
|
|
58
|
-
tool:
|
|
59
|
-
/** the
|
|
60
|
-
color:
|
|
58
|
+
/** the pen code, named by `rmBrushes` */
|
|
59
|
+
tool: RmBrushCode;
|
|
60
|
+
/** the color code, named by `rmColors` */
|
|
61
|
+
color: RmColorCode;
|
|
61
62
|
/** the stroke thickness scale */
|
|
62
63
|
thicknessScale: number;
|
|
63
64
|
/** the length at which the stroke starts */
|
|
@@ -94,8 +95,8 @@ export interface GlyphRange {
|
|
|
94
95
|
start?: number;
|
|
95
96
|
/** the length of the range */
|
|
96
97
|
length: number;
|
|
97
|
-
/** the
|
|
98
|
-
color:
|
|
98
|
+
/** the color code, named by `rmColors` */
|
|
99
|
+
color: RmColorCode;
|
|
99
100
|
/** the highlighted text */
|
|
100
101
|
text: string;
|
|
101
102
|
/** the bounding rectangles of the highlight */
|
package/dist/rm6.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
+
import { rmBrushCode, rmColorCode, } from "./codes.js";
|
|
14
15
|
/** the scene-tree root node id */
|
|
15
16
|
export const ROOT_ID = { authorId: 0, counter: 1 };
|
|
16
17
|
/** the CRDT sequence end marker / unset id */
|
|
@@ -342,8 +343,8 @@ function readItemEnvelope(reader, readValue) {
|
|
|
342
343
|
return { parentId, item: { itemId, leftId, rightId, deletedLength, value } };
|
|
343
344
|
}
|
|
344
345
|
function readLineValue(reader, version) {
|
|
345
|
-
const tool = reader.readInt(1);
|
|
346
|
-
const color = reader.readInt(2);
|
|
346
|
+
const tool = rmBrushCode.parse(reader.readInt(1));
|
|
347
|
+
const color = rmColorCode.parse(reader.readInt(2));
|
|
347
348
|
const thicknessScale = reader.readDouble(3);
|
|
348
349
|
const startingLength = reader.readFloat(4);
|
|
349
350
|
const points = reader.subblock(5, () => {
|
|
@@ -394,7 +395,7 @@ function readGlyphValue(reader) {
|
|
|
394
395
|
const explicitLength = reader.hasTag(3, TAG_BYTE4)
|
|
395
396
|
? reader.readInt(3)
|
|
396
397
|
: undefined;
|
|
397
|
-
const color = reader.readInt(4);
|
|
398
|
+
const color = rmColorCode.parse(reader.readInt(4));
|
|
398
399
|
const text = reader.readString(5);
|
|
399
400
|
const rectangles = reader.subblock(6, () => {
|
|
400
401
|
const count = reader.varuint();
|