rmapi-js 11.0.0 → 11.1.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.
@@ -0,0 +1,22 @@
1
+ /** a reMarkable device display */
2
+ export interface DeviceScreen {
3
+ /** the marketing name */
4
+ name: string;
5
+ /** native portrait width in pixels */
6
+ width: number;
7
+ /** native portrait height in pixels */
8
+ height: number;
9
+ /** display density in dots per inch */
10
+ dpi: number;
11
+ }
12
+ /** the model number of a known reMarkable device */
13
+ export type DeviceModel = "RM100" | "RM110" | "RM02A" | "RM03A" | "RM102";
14
+ /**
15
+ * display specs for known reMarkable devices, keyed by model number
16
+ *
17
+ * These feed the `customFit` zoom math: `customZoomPageWidth`/`customZoomPageHeight`
18
+ * are the source page in device pixels (`pagePt * dpi / 72`), and `width`/`height`
19
+ * give the screen aspect. Every model is 3:4 (0.75) except the Paper Pro Move,
20
+ * which is 9:16.
21
+ */
22
+ export declare const deviceScreens: Record<DeviceModel, DeviceScreen>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * display specs for known reMarkable devices, keyed by model number
3
+ *
4
+ * These feed the `customFit` zoom math: `customZoomPageWidth`/`customZoomPageHeight`
5
+ * are the source page in device pixels (`pagePt * dpi / 72`), and `width`/`height`
6
+ * give the screen aspect. Every model is 3:4 (0.75) except the Paper Pro Move,
7
+ * which is 9:16.
8
+ */
9
+ export const deviceScreens = {
10
+ RM100: { name: "reMarkable 1", width: 1404, height: 1872, dpi: 226 },
11
+ RM110: { name: "reMarkable 2", width: 1404, height: 1872, dpi: 226 },
12
+ RM02A: { name: "reMarkable Paper Pro", width: 1620, height: 2160, dpi: 229 },
13
+ RM03A: {
14
+ name: "reMarkable Paper Pro Move",
15
+ width: 954,
16
+ height: 1696,
17
+ dpi: 264,
18
+ },
19
+ RM102: { name: "reMarkable Paper Pure", width: 1404, height: 1872, dpi: 226 },
20
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type BackgroundFilter, type CollectionContent, type Content, type DocumentContent, type Metadata, type Orientation, type RawRemarkableApi, type SimpleEntry, type Tag, type TemplateContent, type TextAlignment, type ZoomMode } from "./raw.js";
2
+ export { type DeviceModel, type DeviceScreen, deviceScreens, } from "./devices.js";
2
3
  export { HashNotFoundError, ValidationError } from "./error.js";
3
4
  export type { BackgroundFilter, CollectionContent, Content, CPageNumberValue, CPagePage, CPageStringValue, CPages, CPageUUID, DocumentContent, DocumentMetadata, Entries, FileType, KeyboardMetadata, LegacyCollectionContent, LegacyDocumentContent, Metadata, Orientation, PageTag, RawEntry, RawRemarkableApi, SchemaVersion, SimpleEntry, Tag, TemplateContent, TextAlignment, UploadMimeType, ZoomMode, } from "./raw.js";
4
5
  /** common properties shared by collections and documents */
@@ -162,6 +163,18 @@ export interface PutOptions {
162
163
  zoomMode?: ZoomMode;
163
164
  /** the contrast filter setting */
164
165
  viewBackgroundFilter?: BackgroundFilter;
166
+ /** the custom zoom scale, applied when zoomMode is "customFit" */
167
+ customZoomScale?: number;
168
+ /** the horizontal center offset for customFit zoom */
169
+ customZoomCenterX?: number;
170
+ /** the vertical center offset for customFit zoom */
171
+ customZoomCenterY?: number;
172
+ /** the rendered page width in pixels, the unit customFit centers use */
173
+ customZoomPageWidth?: number;
174
+ /** the rendered page height in pixels, the unit customFit centers use */
175
+ customZoomPageHeight?: number;
176
+ /** the orientation the customFit zoom was set in */
177
+ customZoomOrientation?: Orientation;
165
178
  /**
166
179
  * whether to refresh current file structure before putting
167
180
  *
@@ -296,6 +309,28 @@ export interface RemarkableApi {
296
309
  * doesn't match the current server generation, requiring you to retry until
297
310
  * it works.
298
311
  *
312
+ * @remarks
313
+ * When `zoomMode` is `"customFit"` the `customZoom*` fields describe the view,
314
+ * all in the source page's device pixels: `customZoomPageWidth` and
315
+ * `customZoomPageHeight` are the page dimensions scaled by the device dpi
316
+ * (`pagePt * dpi / 72`, see {@link deviceScreens | `deviceScreens`}), and the
317
+ * centers are in those pixels.
318
+ *
319
+ * The view always has the device's aspect ratio — you control its height and
320
+ * position, not its shape. `customZoomScale` is a fit-to-height zoom: at `1`
321
+ * the page height fills the screen, and the linear magnification is
322
+ * `customZoomScale` squared. `customZoomCenterX` offsets the center of the
323
+ * view horizontally from the page center, and `customZoomCenterY` is the
324
+ * absolute distance of the center down from the top of the page; the view's
325
+ * width follows from its height and the device aspect ratio.
326
+ *
327
+ * The fields are a single document-wide setting, but `customZoomCenterY` is
328
+ * applied against each page's own rendered height. On a page rendered taller
329
+ * than `customZoomPageHeight` that distance is a smaller fraction of the page,
330
+ * so the view sits higher and cuts off the bottom; on a shorter page it sits
331
+ * lower and cuts off the top. `customZoomScale` (a ratio) and
332
+ * `customZoomCenterX` (an offset from center) do not shift with page size.
333
+ *
299
334
  * @param visibleName - the name to display on the reMarkable
300
335
  * @param buffer - the raw pdf
301
336
  * @param opts - put options
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ import { z } from "zod";
57
57
  import { HashNotFoundError, ValidationError } from "./error.js";
58
58
  import { LruCache } from "./lru.js";
59
59
  import { RawRemarkable, } from "./raw.js";
60
+ export { deviceScreens, } from "./devices.js";
60
61
  export { HashNotFoundError, ValidationError } from "./error.js";
61
62
  const AUTH_HOST = "https://webapp-prod.cloud.remarkable.engineering";
62
63
  const RAW_HOST = "https://eu.tectonic.remarkable.com";
@@ -292,7 +293,7 @@ class Remarkable {
292
293
  }
293
294
  return zip.generateAsync({ type: "uint8array" });
294
295
  }
295
- async #putFile(visibleName, fileType, buffer, { refresh, parent = "", pinned = false, zoomMode = "bestFit", viewBackgroundFilter, textScale = 1, textAlignment = "justify", fontName = "", coverPageNumber = -1, authors, title, publicationDate, publisher, extraMetadata = {}, lineHeight = -1, margins = 125, orientation = "portrait", tags, }) {
296
+ async #putFile(visibleName, fileType, buffer, { refresh, parent = "", pinned = false, zoomMode = "bestFit", viewBackgroundFilter, textScale = 1, textAlignment = "justify", fontName = "", coverPageNumber = -1, authors, title, publicationDate, publisher, extraMetadata = {}, lineHeight = -1, margins = 125, orientation = "portrait", tags, customZoomScale, customZoomCenterX, customZoomCenterY, customZoomPageWidth, customZoomPageHeight, customZoomOrientation, }) {
296
297
  if (parent && !idReg.test(parent)) {
297
298
  throw new ValidationError(parent, idReg, "parent must be a valid document id");
298
299
  }
@@ -322,6 +323,12 @@ class Remarkable {
322
323
  textAlignment,
323
324
  textScale,
324
325
  zoomMode,
326
+ customZoomScale,
327
+ customZoomCenterX,
328
+ customZoomCenterY,
329
+ customZoomPageWidth,
330
+ customZoomPageHeight,
331
+ customZoomOrientation,
325
332
  viewBackgroundFilter,
326
333
  // NOTE for some reason we need to "fake" the number of pages at 1, and
327
334
  // create "valid" output for that
package/dist/raw.d.ts CHANGED
@@ -226,38 +226,43 @@ export interface CommonDocumentContent {
226
226
  */
227
227
  textScale: number;
228
228
  /**
229
- * the center of the zoom for customFit zoom
229
+ * the horizontal center of a customFit zoom
230
230
  *
231
- * This is an absolute offset from the center of the page. Negative numbers
232
- * indicate shifted left and positive numbers indicate shifted right. The
233
- * units are relative to the document pixels, but it's not sure how the
234
- * document size is calculated.
231
+ * An offset in device pixels from the horizontal center of the page (0 =
232
+ * centered, negative = left, positive = right). This and
233
+ * {@link customZoomCenterY} are in the page's own frame, so device
234
+ * orientation does not affect them.
235
235
  */
236
236
  customZoomCenterX?: number;
237
237
  /**
238
- * the center of the zoom for customFit documents
238
+ * the vertical center of a customFit zoom
239
239
  *
240
- * This is an absolute number relative to the top of the page. Negative
241
- * numbers indicate shifted up, while positive numbers indicate shifted down.
242
- * The units are relative to the document pixels, but it's not sure how the
243
- * document size is calculated.
240
+ * An absolute distance in device pixels from the top of the page (negative =
241
+ * up, positive = down); centering is half the page's rendered height.
244
242
  */
245
243
  customZoomCenterY?: number;
246
- /** this seems unused */
244
+ /** the orientation the customFit zoom was set in */
247
245
  customZoomOrientation?: Orientation;
248
- /** this seems unused */
246
+ /**
247
+ * the rendered height of the pdf page, in device pixels
248
+ *
249
+ * Computed from the pdf page height in points and the device dpi as
250
+ * `heightPt * dpi / 72`; the dpi depends on the model (see
251
+ * {@link deviceScreens | `deviceScreens`}).
252
+ */
249
253
  customZoomPageHeight?: number;
250
- /** this seems unused */
254
+ /** the rendered width of the pdf page, in device pixels */
251
255
  customZoomPageWidth?: number;
252
256
  /**
253
- * the scale for customFit documents
257
+ * the scale for a customFit zoom
254
258
  *
255
- * 1 indicates no zoom, smaller numbers indicate zoomed out, larger numbers
256
- * indicate zoomed in. reMarkable generally allows setting this from 0.5 to 5,
257
- * but values outside that bound are still supported.
259
+ * Calibrated on the page's fit-to-height: at 1 the rendered page height fills
260
+ * the screen and the linear magnification is customZoomScale squared. 1
261
+ * indicates no zoom; reMarkable generally allows 0.5 to 5, but values outside
262
+ * that bound are still supported.
258
263
  */
259
264
  customZoomScale?: number;
260
- /** what zoom mode is set for the page */
265
+ /** the zoom mode; customFit applies the customZoom* fields, the rest auto-fit */
261
266
  zoomMode?: ZoomMode;
262
267
  /** [speculative] a transform matrix, a. la. css matrix transform */
263
268
  transform?: Partial<Record<`m${"1" | "2" | "3"}${"1" | "2" | "3"}`, number>>;