@cloudpdf/engine 3.0.0-next.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/LICENSE +192 -0
- package/README.md +53 -0
- package/dist/index.cjs +2513 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +600 -0
- package/dist/index.d.ts +600 -0
- package/dist/index.js +2476 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { AbortError, AbortablePromise, AbortablePromise as AbortablePromise$1, AnnotationAppearanceImageOptions, AnnotationAppearanceImagesResult, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationDraft, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationPatch, AnnotationRef, AnnotationUpdateResult, AttachmentContent, AttachmentsCache, DocumentAccessInfo, DocumentActionsService, DocumentAnnotationsService, DocumentAnnotationsService as DocumentAnnotationsService$1, DocumentAttachmentsService, DocumentCapabilities, DocumentEventStream, DocumentFormsService, DocumentHandle, DocumentHandle as DocumentHandle$1, DocumentIdentity, DocumentMetadata, DocumentPagesService, DocumentPagesService as DocumentPagesService$1, DocumentRedactionService, DocumentRenderService, DocumentSearchService, DocumentSecurityService, DocumentSecurityService as DocumentSecurityService$1, DocumentSecurityState, DocumentUnlockInput, DocumentUnlockResult, Engine, Engine as Engine$1, EngineError, EngineErrorCode, EngineFactory, MetadataCache, MetadataPatch, MetadataService, MetadataService as MetadataService$1, MetadataUpdateResult, MutationMeta, OpenInput, OpenInput as OpenInput$1, OpenOptions, OpenOptions as OpenOptions$1, PageAnnotationsService, PageAnnotationsService as PageAnnotationsService$1, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometryService, PageGeometryService as PageGeometryService$1, PageGeometrySnapshot, PageHandle, PageHandle as PageHandle$1, PageImageHandle, PageImageOptions, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRaster, PageRenderOptions, PageRenderService, PageRenderService as PageRenderService$1, PageRotateResult, PageRotation, PageStructureCache, PageTextService, PageTextService as PageTextService$1, PageTextSnapshot, PdfSaveMode, PdfSaveMode as PdfSaveMode$1, SearchRequest, SearchSlice, TokenSource, WeakAnnotationEditSession } from "@embedpdf/engine-core/runtime";
|
|
2
|
+
import { CdnAccessInfoForApply, DocumentHead, DocumentManifest, LayerScopePlane } from "@embedpdf/engine-core/wire";
|
|
3
|
+
import { SessionEventPublisher } from "@embedpdf/engine-services";
|
|
4
|
+
//#region src/transport/HttpClient.d.ts
|
|
5
|
+
interface HttpClientOptions {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional bearer token. Either a string or a function that
|
|
9
|
+
* returns a fresh token on every call (so callers can rotate
|
|
10
|
+
* without re-creating the engine). When absent, requests go out
|
|
11
|
+
* without an `Authorization` header — useful for the public-share
|
|
12
|
+
* scenario where the doc-scoped token is provided per-`open` and
|
|
13
|
+
* the engine itself has no engine-level credentials.
|
|
14
|
+
*/
|
|
15
|
+
token?: string | (() => string | Promise<string>);
|
|
16
|
+
/**
|
|
17
|
+
* Engine-instance session id, sent as `X-Engine-Session-Id` on every
|
|
18
|
+
* request. The server stores it on mutation audit rows so this
|
|
19
|
+
* instance's SSE stream can drop its own echoes (exactly-once events).
|
|
20
|
+
*/
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
/** Replace the global fetch (e.g. in Node tests with undici). */
|
|
23
|
+
fetch?: typeof globalThis.fetch;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Per-document binding for CDN URL rewriting. `CloudDocumentHandle`
|
|
27
|
+
* calls `setCdnAccess` after `/v1/access` succeeds; the HttpClient
|
|
28
|
+
* then runs every outgoing request through `applyCdnAccess` so
|
|
29
|
+
* granted resources are routed to the CDN with the matching signed
|
|
30
|
+
* query params (or cookies/auth header for the cookie/header
|
|
31
|
+
* adapter modes).
|
|
32
|
+
*
|
|
33
|
+
* Set to `null` when the session is reset or when `/access` was
|
|
34
|
+
* never called (public-share with no CDN configured).
|
|
35
|
+
*/
|
|
36
|
+
interface CdnBinding {
|
|
37
|
+
readonly cdn: CdnAccessInfoForApply | null;
|
|
38
|
+
readonly docId: string;
|
|
39
|
+
readonly layerName: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A raw-bytes response plus its headers. The attachment-file leaves carry
|
|
43
|
+
* their metadata as headers (`Content-Type`, `X-EmbedPDF-File-Name`), so
|
|
44
|
+
* unlike `getBytes` the caller needs the `Headers` object back.
|
|
45
|
+
*/
|
|
46
|
+
interface HttpFileResponse {
|
|
47
|
+
bytes: Uint8Array;
|
|
48
|
+
headers: Headers;
|
|
49
|
+
}
|
|
50
|
+
declare class HttpClient {
|
|
51
|
+
private readonly baseUrl;
|
|
52
|
+
private readonly tokenFn;
|
|
53
|
+
private readonly fetchFn;
|
|
54
|
+
private readonly sessionId;
|
|
55
|
+
private cdnBinding;
|
|
56
|
+
constructor(opts: HttpClientOptions);
|
|
57
|
+
/**
|
|
58
|
+
* Return a clone of this client bound to a different bearer. Used
|
|
59
|
+
* by `CloudEngine.open` to mint a per-handle client carrying the
|
|
60
|
+
* per-open token, so each opened document's RPCs go out under
|
|
61
|
+
* the right authorization without disturbing the engine-level
|
|
62
|
+
* token.
|
|
63
|
+
*/
|
|
64
|
+
withToken(token: string | (() => string | Promise<string>)): HttpClient;
|
|
65
|
+
/**
|
|
66
|
+
* Raw streaming GET (the SSE channel). Same auth/session headers and
|
|
67
|
+
* error mapping as every other request; the caller owns the body stream.
|
|
68
|
+
*/
|
|
69
|
+
stream(path: string, headers: Record<string, string>, signal: AbortSignal): Promise<Response>;
|
|
70
|
+
/**
|
|
71
|
+
* Install (or clear) the per-session CDN binding. Pass `null` to
|
|
72
|
+
* route everything to origin again — useful on session close or
|
|
73
|
+
* when an adapter swap happens mid-session (rare).
|
|
74
|
+
*
|
|
75
|
+
* The HttpClient stays dumb about WHEN to do this; the cloud
|
|
76
|
+
* document handle pushes the binding in after /access succeeds.
|
|
77
|
+
*
|
|
78
|
+
* Side effect: in the browser, signedCookies are written to
|
|
79
|
+
* `document.cookie` once per setCdnAccess call so the CDN edge
|
|
80
|
+
* receives them on subsequent fetches. Node side ignores cookies
|
|
81
|
+
* for now (cookie jar wiring deferred until needed for tests).
|
|
82
|
+
*/
|
|
83
|
+
setCdnAccess(binding: CdnBinding | null): void;
|
|
84
|
+
/** Current CDN binding (or null). Exposed for diagnostics/tests. */
|
|
85
|
+
get currentCdnBinding(): CdnBinding | null;
|
|
86
|
+
absoluteUrl(path: string): string;
|
|
87
|
+
getBlob(path: string, signal: AbortSignal): Promise<Blob>;
|
|
88
|
+
getBytes(path: string, signal: AbortSignal): Promise<Uint8Array>;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the current bearer token. Awaits the user-supplied
|
|
91
|
+
* token factory if it returns a promise. Used by the cloud
|
|
92
|
+
* engine to read doc-scoped claims **without** verifying — the
|
|
93
|
+
* server is the verifier of record. Throws when no token is
|
|
94
|
+
* configured.
|
|
95
|
+
*/
|
|
96
|
+
currentToken(): Promise<string>;
|
|
97
|
+
getJson<T>(path: string, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
98
|
+
/**
|
|
99
|
+
* GET a versioned URL with transparent stale-version recovery. If
|
|
100
|
+
* the server returns 404 (the well-known "this version is gone"
|
|
101
|
+
* signal for content-addressed reads), call `onStaleVersion` (which
|
|
102
|
+
* the caller wires to a manifest refresh), then re-resolve `buildPath`
|
|
103
|
+
* and retry the GET exactly once. Any non-404 error propagates.
|
|
104
|
+
*
|
|
105
|
+
* The retry budget is hard-capped at 1: after a refresh, if the
|
|
106
|
+
* server's idea of the current version is still ahead of the
|
|
107
|
+
* client's view, the second request fails normally — this matches
|
|
108
|
+
* the CDN cache invariant ("a versioned URL's bytes are immutable
|
|
109
|
+
* for its lifetime").
|
|
110
|
+
*/
|
|
111
|
+
getJsonWithRefresh<T>(buildPath: (signal: AbortSignal) => Promise<string>, parser: (raw: unknown) => T, onStaleVersion: (signal: AbortSignal) => Promise<void>, signal: AbortSignal): Promise<T>;
|
|
112
|
+
/**
|
|
113
|
+
* GET a `multipart/form-data` body and parse it with the platform's
|
|
114
|
+
* `Response.formData()` (works in browsers and undici). Text parts come
|
|
115
|
+
* back as strings, parts with a filename as `Blob`s.
|
|
116
|
+
*/
|
|
117
|
+
getFormData(path: string, signal: AbortSignal): Promise<FormData>;
|
|
118
|
+
/**
|
|
119
|
+
* `getFormData` with the same single-retry stale-version recovery as
|
|
120
|
+
* {@link getJsonWithRefresh}: a 404 on a versioned URL triggers
|
|
121
|
+
* `onStaleVersion` (a manifest refresh) and one re-resolve + retry.
|
|
122
|
+
*/
|
|
123
|
+
getFormDataWithRefresh(buildPath: (signal: AbortSignal) => Promise<string>, onStaleVersion: (signal: AbortSignal) => Promise<void>, signal: AbortSignal): Promise<FormData>;
|
|
124
|
+
/**
|
|
125
|
+
* `getBlob` with the same single-retry stale-version recovery as
|
|
126
|
+
* {@link getJsonWithRefresh}: a 404 on a versioned URL triggers
|
|
127
|
+
* `onStaleVersion` (a manifest refresh) and one re-resolve + retry.
|
|
128
|
+
* Render blobs ride this rail: a scope flip re-resolves the
|
|
129
|
+
* doc-vs-layer path family instead of failing on a stale URL.
|
|
130
|
+
*/
|
|
131
|
+
getBlobWithRefresh(buildPath: (signal: AbortSignal) => Promise<string>, onStaleVersion: (signal: AbortSignal) => Promise<void>, signal: AbortSignal): Promise<Blob>;
|
|
132
|
+
/** GET raw bytes plus the response headers (attachment-file leaves). */
|
|
133
|
+
getFile(path: string, signal: AbortSignal): Promise<HttpFileResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* `getFile` with the same single-retry stale-version recovery as
|
|
136
|
+
* {@link getJsonWithRefresh}: a 404 on a versioned URL triggers
|
|
137
|
+
* `onStaleVersion` (a manifest refresh) and one re-resolve + retry.
|
|
138
|
+
*/
|
|
139
|
+
getFileWithRefresh(buildPath: (signal: AbortSignal) => Promise<string>, onStaleVersion: (signal: AbortSignal) => Promise<void>, signal: AbortSignal): Promise<HttpFileResponse>;
|
|
140
|
+
postMultipartJson<T>(path: string, body: FormData, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
141
|
+
/** PATCH counterpart of {@link postMultipartJson} (binary-carrying mutations). */
|
|
142
|
+
patchMultipartJson<T>(path: string, body: FormData, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
143
|
+
postJson<T>(path: string, body: unknown, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
144
|
+
/** POST a raw binary body (FDF/XFDF import) and parse the JSON response. */
|
|
145
|
+
postBytesJson<T>(path: string, bytes: Uint8Array, contentType: string, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
146
|
+
patchJson<T>(path: string, body: unknown, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
147
|
+
deleteJson<T>(path: string, parser: (raw: unknown) => T, signal: AbortSignal): Promise<T>;
|
|
148
|
+
deleteEmpty(path: string, signal: AbortSignal): Promise<void>;
|
|
149
|
+
postEmpty(path: string, body: unknown, signal: AbortSignal): Promise<void>;
|
|
150
|
+
private requestJson;
|
|
151
|
+
private request;
|
|
152
|
+
private parseJsonResponse;
|
|
153
|
+
/**
|
|
154
|
+
* Decide where this request actually goes. With no CDN binding (or
|
|
155
|
+
* binding's `cdn` is null) every request stays on origin. Otherwise
|
|
156
|
+
* `applyCdnAccess` decides per-request based on the resource the
|
|
157
|
+
* path resolves to (and whether the caller's scope granted CDN
|
|
158
|
+
* access to it).
|
|
159
|
+
*/
|
|
160
|
+
private resolveOutgoing;
|
|
161
|
+
private throwFromBody;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/CloudEngine.d.ts
|
|
165
|
+
interface CloudEngineOptions extends HttpClientOptions {}
|
|
166
|
+
/**
|
|
167
|
+
* Cloud engine: speaks the same Engine interface as @embedpdf/engine
|
|
168
|
+
* but routes everything through HTTPS to a remote @cloudpdf/server (or
|
|
169
|
+
* CloudPDF SaaS). Identical observable contract; only the transport differs.
|
|
170
|
+
*/
|
|
171
|
+
declare class CloudEngine implements Engine$1 {
|
|
172
|
+
private readonly http;
|
|
173
|
+
/** This engine instance's identity on every event's `origin.sessionId`. */
|
|
174
|
+
private readonly sessionId;
|
|
175
|
+
static fromOptions(opts: CloudEngineOptions): CloudEngine;
|
|
176
|
+
private destroyed;
|
|
177
|
+
private constructor();
|
|
178
|
+
open(input: OpenInput$1, options?: OpenOptions$1): AbortablePromise$1<DocumentHandle$1>;
|
|
179
|
+
destroy(): AbortablePromise$1<void>;
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/document/CloudDocumentSearchService.d.ts
|
|
183
|
+
/**
|
|
184
|
+
* Cloud search transport: versioned GETs, one per budgeted slice.
|
|
185
|
+
*
|
|
186
|
+
* Every slice URL is a canonical cache key — the search token pins the
|
|
187
|
+
* layer's content epoch (computed from the cached manifest), the
|
|
188
|
+
* CANONICAL query (default-fold literals collapse case/diacritic
|
|
189
|
+
* variants into one entry), and the resume position. Identical searches
|
|
190
|
+
* from any reader of the document hit the same CDN entry; matches are
|
|
191
|
+
* all that ever crosses the trust boundary, and the rects/full endpoint
|
|
192
|
+
* split keeps permission tiers in disjoint cache namespaces.
|
|
193
|
+
*
|
|
194
|
+
* Staleness rides the standard versioned-read signal: a first slice
|
|
195
|
+
* answered `NotFound` means OUR manifest is stale → refresh and retry
|
|
196
|
+
* once; a continuation answered `NotFound` means the document changed
|
|
197
|
+
* mid-search → `InvalidArg`, same contract as the local engine's cursor.
|
|
198
|
+
*/
|
|
199
|
+
declare class CloudDocumentSearchService implements DocumentSearchService {
|
|
200
|
+
private readonly http;
|
|
201
|
+
private readonly docId;
|
|
202
|
+
private readonly layerName;
|
|
203
|
+
private readonly isClosed;
|
|
204
|
+
private readonly manifest;
|
|
205
|
+
constructor(http: HttpClient, docId: string, layerName: string, isClosed: () => boolean, manifest: ManifestAccessor);
|
|
206
|
+
query(request: SearchRequest): AbortablePromise$1<SearchSlice>;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/document/CloudMetadataService.d.ts
|
|
210
|
+
declare class CloudMetadataService implements MetadataService$1 {
|
|
211
|
+
private readonly http;
|
|
212
|
+
private readonly docId;
|
|
213
|
+
private readonly layerName;
|
|
214
|
+
private readonly isClosed;
|
|
215
|
+
private readonly manifest;
|
|
216
|
+
private readonly publisher;
|
|
217
|
+
constructor(http: HttpClient, docId: string, layerName: string, isClosed: () => boolean, manifest: ManifestAccessor, publisher: SessionEventPublisher);
|
|
218
|
+
/**
|
|
219
|
+
* Document metadata read. The Info-dict JSON lives at the
|
|
220
|
+
* content-addressed `/metadata@metadataVersion=N` leaf (not in the
|
|
221
|
+
* manifest); the manifest only publishes the `metadataVersion` pointer.
|
|
222
|
+
* So `read()` pulls `metadataVersion` from the cached manifest, fetches
|
|
223
|
+
* the leaf, and on a 404 (stale pointer) transparently refreshes the
|
|
224
|
+
* manifest and retries once. `metadataVersion` bumps only on metadata
|
|
225
|
+
* writes, so this leaf stays cached across page and annotation edits.
|
|
226
|
+
*/
|
|
227
|
+
read(): AbortablePromise$1<DocumentMetadata>;
|
|
228
|
+
update(patch: MetadataPatch): AbortablePromise$1<MetadataUpdateResult>;
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/document/CloudDocumentHandle.d.ts
|
|
232
|
+
/**
|
|
233
|
+
* Read accessor handed to every `CloudPage…Service`. The closure
|
|
234
|
+
* captures `this` so the services don't carry a direct reference
|
|
235
|
+
* back to the document handle (smaller circular-ref surface, easier
|
|
236
|
+
* to mock in unit tests).
|
|
237
|
+
*/
|
|
238
|
+
interface ManifestAccessor {
|
|
239
|
+
/** Cached manifest (cold-fetched once, kept across requests). */
|
|
240
|
+
get(signal: AbortSignal): Promise<DocumentManifest>;
|
|
241
|
+
/** Force re-fetch of `/head` + `/manifest@docVersion=N`; replaces the cache. */
|
|
242
|
+
refresh(signal: AbortSignal): Promise<DocumentManifest>;
|
|
243
|
+
/**
|
|
244
|
+
* Absorb mutation-returned state/cache deltas when safe. `owns` names the
|
|
245
|
+
* planes this mutation kind takes ownership of (the monotone-flip
|
|
246
|
+
* rule): annotation/form writes own `annotations`; flatten and
|
|
247
|
+
* redaction-apply own `content + annotations`. The flip runs even when
|
|
248
|
+
* the version-gated delta merge is skipped — scopes only ever move
|
|
249
|
+
* base → layer, so any observed mutation proves the plane diverged.
|
|
250
|
+
*/
|
|
251
|
+
apply(meta: MutationMeta, owns: readonly LayerScopePlane[]): void;
|
|
252
|
+
/** Advance the cached manifest's docVersion + layoutVersion after a page
|
|
253
|
+
* STRUCTURE op that keeps the page set intact (move, rotate). */
|
|
254
|
+
applyPageStructure(cache: PageStructureCache): void;
|
|
255
|
+
/** Same advance for a page delete, additionally dropping the deleted
|
|
256
|
+
* pages' manifest rows so per-page leaf URLs stop resolving locally. */
|
|
257
|
+
applyPageDelete(cache: PageStructureCache, deletedPages: PageObjectNumber[]): void;
|
|
258
|
+
/** Advance the cached manifest's docVersion + metadataVersion after a metadata write. */
|
|
259
|
+
applyMetadata(cache: MetadataCache): void;
|
|
260
|
+
/** Advance the cached manifest's docVersion + attachmentsVersion after an
|
|
261
|
+
* attachment create/delete. */
|
|
262
|
+
applyAttachments(cache: AttachmentsCache): void;
|
|
263
|
+
}
|
|
264
|
+
declare class CloudDocumentHandle implements DocumentHandle$1 {
|
|
265
|
+
private readonly http;
|
|
266
|
+
private readonly layerName;
|
|
267
|
+
readonly id: string;
|
|
268
|
+
readonly capabilities: {
|
|
269
|
+
readonly weakAnnotationEditSessions: "required";
|
|
270
|
+
readonly pageEditSessions: "unsupported";
|
|
271
|
+
};
|
|
272
|
+
readonly metadata: CloudMetadataService;
|
|
273
|
+
readonly annotations: DocumentAnnotationsService$1;
|
|
274
|
+
readonly actions: DocumentActionsService;
|
|
275
|
+
readonly attachments: DocumentAttachmentsService;
|
|
276
|
+
readonly forms: DocumentFormsService;
|
|
277
|
+
readonly search: CloudDocumentSearchService;
|
|
278
|
+
readonly pages: DocumentPagesService$1;
|
|
279
|
+
readonly redaction: DocumentRedactionService;
|
|
280
|
+
readonly security: DocumentSecurityService$1;
|
|
281
|
+
readonly render: DocumentRenderService;
|
|
282
|
+
readonly events: DocumentEventStream;
|
|
283
|
+
private readonly publisher;
|
|
284
|
+
private readonly hub;
|
|
285
|
+
private readonly sessionId;
|
|
286
|
+
private sseClient;
|
|
287
|
+
private sseSubscribers;
|
|
288
|
+
private closed;
|
|
289
|
+
/**
|
|
290
|
+
* Cached current manifest. Populated on first read by `getManifest`
|
|
291
|
+
* (or any `page().*` call that needs to know a version). Replaced
|
|
292
|
+
* wholesale on `refreshManifest`. Cleared on `close`.
|
|
293
|
+
*
|
|
294
|
+
* Memory model: one DocumentManifest per open handle. Per-page
|
|
295
|
+
* version reads are O(pages.length) `.find(...)` lookups; if a
|
|
296
|
+
* profiling pass ever shows that as hot, swap for a Map keyed by
|
|
297
|
+
* `pageObjectNumber`. Today's documents are page-sparse so the
|
|
298
|
+
* scan is cheaper than the hash overhead.
|
|
299
|
+
*/
|
|
300
|
+
private manifestCache;
|
|
301
|
+
private inflightManifest;
|
|
302
|
+
private manifestFloorVersion;
|
|
303
|
+
private pendingInitialHead;
|
|
304
|
+
private readonly manifestAccessor;
|
|
305
|
+
constructor(http: HttpClient, id: string, layerName?: string, initialHead?: DocumentHead,
|
|
306
|
+
/**
|
|
307
|
+
* The doc-scoped JWT the engine was opened with, decoded
|
|
308
|
+
* unverified to populate the security service's local-fallback
|
|
309
|
+
* `effectiveScope` / `identity` accessors. Optional for backward
|
|
310
|
+
* compatibility; without it the local-fallback path returns an
|
|
311
|
+
* empty scope and null identity until /access is called.
|
|
312
|
+
*/
|
|
313
|
+
initialToken?: string | null, sessionId?: string);
|
|
314
|
+
page(pageObjectNumber: PageObjectNumber): PageHandle$1;
|
|
315
|
+
download(opts?: {
|
|
316
|
+
mode?: PdfSaveMode$1;
|
|
317
|
+
}): AbortablePromise$1<Uint8Array>;
|
|
318
|
+
/**
|
|
319
|
+
* Return the cached manifest, fetching cold-cache once if needed.
|
|
320
|
+
* Concurrent callers share a single inflight request (singleflight)
|
|
321
|
+
* so an N-page handle that opens N services in parallel still
|
|
322
|
+
* triggers exactly one `/head` + `/manifest@docVersion=N` round-trip.
|
|
323
|
+
*/
|
|
324
|
+
getManifest(signal: AbortSignal): Promise<DocumentManifest>;
|
|
325
|
+
/**
|
|
326
|
+
* Force re-fetch. Used by the transparent-retry path when a leaf
|
|
327
|
+
* URL returns 404 (stale version). Replaces `manifestCache`
|
|
328
|
+
* wholesale so the next `getManifest()` is a Map lookup.
|
|
329
|
+
*/
|
|
330
|
+
refreshManifest(signal: AbortSignal): Promise<DocumentManifest>;
|
|
331
|
+
/**
|
|
332
|
+
* Monotone plane-scope flip: mark the planes a mutation OWNS as layer-scoped in
|
|
333
|
+
* the cached manifest. Scopes only ever move base → layer (no revert op
|
|
334
|
+
* exists), so flipping is safe under ANY event ordering — a duplicate or
|
|
335
|
+
* out-of-order event still proves the plane diverged at some point — and
|
|
336
|
+
* the manifest fetch stays the authoritative source (the 404 → refresh
|
|
337
|
+
* rail heals any miss, e.g. a future mutation kind this client doesn't
|
|
338
|
+
* know about).
|
|
339
|
+
*/
|
|
340
|
+
private flipScopes;
|
|
341
|
+
absorbMutation(meta: MutationMeta, owns: readonly LayerScopePlane[]): void;
|
|
342
|
+
/**
|
|
343
|
+
* Patch the cached manifest after a set-preserving page-structure op (move,
|
|
344
|
+
* rotate). Both are purely structural: they advance `docVersion` (so leaf
|
|
345
|
+
* URLs re-resolve) and `layoutVersion` (so the /layout leaf re-fetches),
|
|
346
|
+
* but leave every per-page pin untouched — a rotate renders the SAME
|
|
347
|
+
* normalized bitmaps, a move the same pages. We raise the floor
|
|
348
|
+
* unconditionally and, when our cache is exactly one version behind,
|
|
349
|
+
* advance it in place; otherwise we drop it and refetch lazily.
|
|
350
|
+
*/
|
|
351
|
+
private absorbPageStructure;
|
|
352
|
+
/**
|
|
353
|
+
* Patch the cached manifest after a page delete: the shared structural
|
|
354
|
+
* advance plus dropping the deleted pages' manifest rows, so no leaf URL
|
|
355
|
+
* for a retired PON can be built from the cache (a stale request would
|
|
356
|
+
* 404 anyway — this keeps the failure local and instant).
|
|
357
|
+
*/
|
|
358
|
+
private absorbPageDelete;
|
|
359
|
+
/**
|
|
360
|
+
* Patch the cached manifest after a metadata write. Symmetric with
|
|
361
|
+
* {@link absorbPageMove}: a metadata edit advances `docVersion` (so leaf
|
|
362
|
+
* URLs re-resolve) and `metadataVersion` (so the /metadata leaf re-fetches),
|
|
363
|
+
* but leaves `layoutVersion` and every per-page pin untouched. Raise the
|
|
364
|
+
* floor unconditionally and, when our cache is exactly one version behind,
|
|
365
|
+
* advance it in place; otherwise drop it and refetch lazily.
|
|
366
|
+
*/
|
|
367
|
+
private absorbMetadata;
|
|
368
|
+
/**
|
|
369
|
+
* Patch the cached manifest after an attachment create/delete. Symmetric
|
|
370
|
+
* with {@link absorbMetadata}: an attachment write advances `docVersion`
|
|
371
|
+
* (so leaf URLs re-resolve) and `attachmentsVersion` (so the /attachments
|
|
372
|
+
* listing and /attachment-files leaves re-fetch), but leaves
|
|
373
|
+
* `layoutVersion` and every per-page pin untouched. Raise the floor
|
|
374
|
+
* unconditionally and, when our cache is exactly one version behind,
|
|
375
|
+
* advance it in place; otherwise drop it and refetch lazily.
|
|
376
|
+
*/
|
|
377
|
+
private absorbAttachments;
|
|
378
|
+
private startManifestFetch;
|
|
379
|
+
private fetchManifest;
|
|
380
|
+
private consumeInitialHead;
|
|
381
|
+
private fetchManifestForHead;
|
|
382
|
+
close(): AbortablePromise$1<void>;
|
|
383
|
+
private retainRemoteStream;
|
|
384
|
+
private releaseRemoteStream;
|
|
385
|
+
/** Patch the cached manifest from a REMOTE event's coherence pins — the
|
|
386
|
+
* same absorb rails local mutations use, so reads stay warm no matter
|
|
387
|
+
* whose hand caused the change. */
|
|
388
|
+
private absorbRemoteEvent;
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/document/CloudDocumentAnnotationsService.d.ts
|
|
392
|
+
declare class CloudDocumentAnnotationsService implements DocumentAnnotationsService$1 {
|
|
393
|
+
private readonly http;
|
|
394
|
+
private readonly docId;
|
|
395
|
+
private readonly layerName;
|
|
396
|
+
private readonly isClosed;
|
|
397
|
+
private readonly manifest;
|
|
398
|
+
constructor(http: HttpClient, docId: string, layerName: string, isClosed: () => boolean, manifest: ManifestAccessor);
|
|
399
|
+
listRawAll(): AbortablePromise$1<AnnotationListSnapshotAllPages>;
|
|
400
|
+
listRaw(pageObjectNumber: PageObjectNumber): AbortablePromise$1<AnnotationListPageSnapshot>;
|
|
401
|
+
beginWeakEdit(pageObjectNumbers: readonly PageObjectNumber[]): AbortablePromise$1<WeakAnnotationEditSession>;
|
|
402
|
+
private readCurrentPage;
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/document/CloudDocumentPagesService.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* Cloud-side document pages service. Mirrors `LocalDocumentPagesService`
|
|
408
|
+
* over HTTP: GET /pages for `list`, POST /pages/move for the reorder.
|
|
409
|
+
*
|
|
410
|
+
* Page identity rule (locked with the user, do not change):
|
|
411
|
+
* - Pages are addressed exclusively by their indirect
|
|
412
|
+
* `pageObjectNumber`. The wire never sends a page index for a
|
|
413
|
+
* mutation. This keeps multi-call client logic from having to
|
|
414
|
+
* account for index drift between requests.
|
|
415
|
+
* - Successful `move()` returns the new `layout` (order + geometry) plus
|
|
416
|
+
* cloud coherence pins. The server does NOT bump per-page revisions on a
|
|
417
|
+
* page move (page reorder is intentionally outside the weak-ref staleness
|
|
418
|
+
* model), only `docVersion` + `layoutVersion`.
|
|
419
|
+
*/
|
|
420
|
+
declare class CloudDocumentPagesService implements DocumentPagesService$1 {
|
|
421
|
+
private readonly http;
|
|
422
|
+
private readonly docId;
|
|
423
|
+
private readonly layerName;
|
|
424
|
+
private readonly isClosed;
|
|
425
|
+
private readonly manifest;
|
|
426
|
+
private readonly publisher;
|
|
427
|
+
constructor(http: HttpClient, docId: string, layerName: string, isClosed: () => boolean, manifest: ManifestAccessor, publisher: SessionEventPublisher);
|
|
428
|
+
/**
|
|
429
|
+
* Page-geometry list. The geometry bytes live at the content-addressed
|
|
430
|
+
* `/layout@layoutVersion=N` leaf (not in the manifest); the manifest only
|
|
431
|
+
* publishes the `layoutVersion` pointer. So `list()` reads `layoutVersion`
|
|
432
|
+
* from the cached manifest, fetches the layout leaf, and on a 404 (stale
|
|
433
|
+
* pointer) transparently refreshes the manifest and retries once — the
|
|
434
|
+
* same ladder the per-page text/geometry reads use. `layoutVersion` bumps
|
|
435
|
+
* only on structural page ops, so this leaf stays cached across content
|
|
436
|
+
* and annotation edits.
|
|
437
|
+
*/
|
|
438
|
+
list(): AbortablePromise$1<PageListSnapshot>;
|
|
439
|
+
move(pageObjectNumbers: PageObjectNumber[], destIndex: number): AbortablePromise$1<PageMoveResult>;
|
|
440
|
+
rotate(pageObjectNumbers: PageObjectNumber[], rotation: PageRotation): AbortablePromise$1<PageRotateResult>;
|
|
441
|
+
delete(pageObjectNumbers: PageObjectNumber[]): AbortablePromise$1<PageDeleteResult>;
|
|
442
|
+
flatten(pageObjectNumbers: PageObjectNumber[], usage?: PageFlattenUsage): AbortablePromise$1<PageFlattenResult>;
|
|
443
|
+
}
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/document/CloudPageAnnotationsService.d.ts
|
|
446
|
+
/**
|
|
447
|
+
* Cloud-side page annotation service. Mirrors the local wiring: each
|
|
448
|
+
* call produces an `AbortablePromise` that propagates `signal.abort()`
|
|
449
|
+
* down to `fetch` and validates the JSON response with the wire-stable
|
|
450
|
+
* Zod schema.
|
|
451
|
+
*
|
|
452
|
+
* Reads use immutable versioned layer URLs discovered from the
|
|
453
|
+
* manifest. Mutations use unversioned layer URLs and are never cached.
|
|
454
|
+
*/
|
|
455
|
+
declare class CloudPageAnnotationsService implements PageAnnotationsService$1 {
|
|
456
|
+
private readonly http;
|
|
457
|
+
private readonly docId;
|
|
458
|
+
private readonly layerName;
|
|
459
|
+
private readonly pageObjectNumber;
|
|
460
|
+
private readonly isClosed;
|
|
461
|
+
private readonly manifest;
|
|
462
|
+
private readonly publisher;
|
|
463
|
+
constructor(http: HttpClient, docId: string, layerName: string, pageObjectNumber: PageObjectNumber, isClosed: () => boolean, manifest: ManifestAccessor, publisher: SessionEventPublisher);
|
|
464
|
+
list(): AbortablePromise$1<AnnotationListPageSnapshot>;
|
|
465
|
+
renderAppearances(_options?: AnnotationAppearanceRenderOptions): AbortablePromise$1<AnnotationAppearancesResult>;
|
|
466
|
+
renderAppearanceImages(options?: AnnotationAppearanceImageOptions): AbortablePromise$1<AnnotationAppearanceImagesResult>;
|
|
467
|
+
/**
|
|
468
|
+
* Decode and return the file embedded in a FileAttachment annotation.
|
|
469
|
+
* A read over the immutable `attachment-files` leaf, pinned by the
|
|
470
|
+
* manifest's `attachmentsVersion` (annotation-level files re-key on the
|
|
471
|
+
* same pin as document-level ones), with the same stale-404 refresh
|
|
472
|
+
* retry as {@link list}. Weak `index` refs cannot be spliced into a GET
|
|
473
|
+
* URL (no body to carry the revision), so bytes reads require a stable
|
|
474
|
+
* id — the same `:annotKey` routing update()/delete() use.
|
|
475
|
+
*/
|
|
476
|
+
downloadFile(ref: AnnotationRef): AbortablePromise$1<AttachmentContent>;
|
|
477
|
+
create(draft: AnnotationDraft): AbortablePromise$1<AnnotationCreateResult>;
|
|
478
|
+
update(ref: AnnotationRef, patch: AnnotationPatch): AbortablePromise$1<AnnotationUpdateResult>;
|
|
479
|
+
/** PATCH as plain JSON, or as multipart when the patch carried binaries. */
|
|
480
|
+
private patchMutation;
|
|
481
|
+
delete(ref: AnnotationRef): AbortablePromise$1<AnnotationDeleteResult>;
|
|
482
|
+
move(refs: AnnotationRef[], toIndex: number): AbortablePromise$1<AnnotationMoveResult>;
|
|
483
|
+
/**
|
|
484
|
+
* Patch the cached manifest, then publish the mutation to the document's
|
|
485
|
+
* event stream (in that order — listeners reading the manifest in their
|
|
486
|
+
* callback must see post-mutation state). Each call site pairs the event
|
|
487
|
+
* `type` with the matching result by construction; the cast localizes that
|
|
488
|
+
* pairing here instead of widening every site.
|
|
489
|
+
*/
|
|
490
|
+
private absorbMutation;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/document/CloudPageGeometryService.d.ts
|
|
494
|
+
declare class CloudPageGeometryService implements PageGeometryService$1 {
|
|
495
|
+
private readonly http;
|
|
496
|
+
private readonly docId;
|
|
497
|
+
private readonly layerName;
|
|
498
|
+
private readonly pageObjectNumber;
|
|
499
|
+
private readonly isClosed;
|
|
500
|
+
private readonly manifest;
|
|
501
|
+
constructor(http: HttpClient, docId: string, layerName: string, pageObjectNumber: PageObjectNumber, isClosed: () => boolean, manifest: ManifestAccessor);
|
|
502
|
+
read(): AbortablePromise$1<PageGeometrySnapshot>;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/document/CloudPageRenderService.d.ts
|
|
506
|
+
declare class CloudPageRenderService implements PageRenderService$1 {
|
|
507
|
+
private readonly http;
|
|
508
|
+
private readonly docId;
|
|
509
|
+
private readonly layerName;
|
|
510
|
+
private readonly pageObjectNumber;
|
|
511
|
+
private readonly isClosed;
|
|
512
|
+
private readonly manifest;
|
|
513
|
+
constructor(http: HttpClient, docId: string, layerName: string, pageObjectNumber: PageObjectNumber, isClosed: () => boolean, manifest: ManifestAccessor);
|
|
514
|
+
image(options?: PageImageOptions): AbortablePromise$1<PageImageHandle>;
|
|
515
|
+
raw(_options?: PageRenderOptions): AbortablePromise$1<PageRaster>;
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/document/CloudPageTextService.d.ts
|
|
519
|
+
/**
|
|
520
|
+
* Cloud-side per-page text service. `read()` fetches the
|
|
521
|
+
* content-addressed URL `/v1/docs/:id/text/pages/:pon/data@contentVersion=N`, where
|
|
522
|
+
* `:P` is the page's current `contentVersion` from the cached
|
|
523
|
+
* manifest. On a 404 (stale version) the SDK transparently refreshes
|
|
524
|
+
* `/head` + `/manifest@docVersion=N`, rebuilds the URL with the fresh `cN`,
|
|
525
|
+
* and retries exactly once.
|
|
526
|
+
*/
|
|
527
|
+
declare class CloudPageTextService implements PageTextService$1 {
|
|
528
|
+
private readonly http;
|
|
529
|
+
private readonly docId;
|
|
530
|
+
private readonly layerName;
|
|
531
|
+
private readonly pageObjectNumber;
|
|
532
|
+
private readonly isClosed;
|
|
533
|
+
private readonly manifest;
|
|
534
|
+
constructor(http: HttpClient, docId: string, layerName: string, pageObjectNumber: PageObjectNumber, isClosed: () => boolean, manifest: ManifestAccessor);
|
|
535
|
+
read(): AbortablePromise$1<PageTextSnapshot>;
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/document/CloudPageHandle.d.ts
|
|
539
|
+
declare class CloudPageHandle implements PageHandle$1 {
|
|
540
|
+
readonly pageObjectNumber: PageObjectNumber;
|
|
541
|
+
readonly pageIndex: number;
|
|
542
|
+
readonly annotations: CloudPageAnnotationsService;
|
|
543
|
+
readonly text: CloudPageTextService;
|
|
544
|
+
readonly geometry: CloudPageGeometryService;
|
|
545
|
+
readonly render: CloudPageRenderService;
|
|
546
|
+
constructor(pageObjectNumber: PageObjectNumber, pageIndex: number, http: HttpClient, docId: string, layerName: string, isClosed: () => boolean, manifest: ManifestAccessor, publisher: SessionEventPublisher);
|
|
547
|
+
}
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/transport/decodeUnverifiedClaims.d.ts
|
|
550
|
+
/**
|
|
551
|
+
* Lightweight, **unverified** JWT payload decoder.
|
|
552
|
+
*
|
|
553
|
+
* We use this on the SDK side purely to extract routing information
|
|
554
|
+
* (the `doc_id` claim) so we know which `/v1/docs/:id/head` URL to
|
|
555
|
+
* hit. Signature verification is the server's job — Layer 2 of the
|
|
556
|
+
* token-class-confusion defense in `JwtVerifier.coerceClaims`
|
|
557
|
+
* rejects anything malformed before the bytes are accepted.
|
|
558
|
+
*
|
|
559
|
+
* This module is intentionally cryptography-free: it never imports
|
|
560
|
+
* `crypto` or `jose`. That keeps the SDK lean for browser bundles
|
|
561
|
+
* (jose adds ~50KB minified) and means a misconfigured customer
|
|
562
|
+
* can't accidentally rely on client-side verification.
|
|
563
|
+
*/
|
|
564
|
+
interface UnverifiedClaims {
|
|
565
|
+
doc_id?: string;
|
|
566
|
+
tenant_id?: string;
|
|
567
|
+
sub?: string;
|
|
568
|
+
exp?: number;
|
|
569
|
+
iat?: number;
|
|
570
|
+
/** Pass-through; we don't validate anything else SDK-side. */
|
|
571
|
+
[key: string]: unknown;
|
|
572
|
+
}
|
|
573
|
+
declare function decodeUnverifiedClaims(token: string): UnverifiedClaims;
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/index.d.ts
|
|
576
|
+
declare function createCloudEngine(opts: CloudEngineOptions): CloudEngine;
|
|
577
|
+
/**
|
|
578
|
+
* Create a cloud {@link CloudEngine} — the drop-in counterpart of
|
|
579
|
+
* `localEngine()`, so swapping local for cloud is a one-import change.
|
|
580
|
+
*
|
|
581
|
+
* Synchronous and cheap: no WASM to compile, no worker to spawn — the engine
|
|
582
|
+
* holds an HTTP client and nothing else. Like `localEngine()`, the returned
|
|
583
|
+
* instance is yours (call `destroy()` when done, usually never for a
|
|
584
|
+
* module-scope singleton); pass a thunk (`engine={() => cloudEngine(...)}`)
|
|
585
|
+
* to let a `<Viewer>` own the lifetime instead.
|
|
586
|
+
*
|
|
587
|
+
* Note the deliberate asymmetry with `localEngine()`: there is no `fonts`
|
|
588
|
+
* option. Fallback fonts are a SERVER policy on the cloud (`Engine.fonts` is
|
|
589
|
+
* `undefined` cloud-side), so they cannot be configured from the client. This
|
|
590
|
+
* is the local-vs-cloud split, surfaced in the API.
|
|
591
|
+
*
|
|
592
|
+
* ```ts
|
|
593
|
+
* const engine = cloudEngine({ baseUrl: 'https://pdf.example.com', token });
|
|
594
|
+
* <Viewer engine={engine} plugins={[stagePlugin(), renderPlugin()]} />
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
597
|
+
declare function cloudEngine(opts: CloudEngineOptions): CloudEngine;
|
|
598
|
+
//#endregion
|
|
599
|
+
export { AbortError, AbortablePromise, CloudDocumentAnnotationsService, CloudDocumentHandle, CloudDocumentPagesService, CloudEngine, type CloudEngineOptions, CloudMetadataService, CloudPageAnnotationsService, CloudPageGeometryService, CloudPageHandle, CloudPageRenderService, type DocumentAccessInfo, type DocumentAnnotationsService, type DocumentCapabilities, type DocumentHandle, type DocumentIdentity, type DocumentPagesService, type DocumentSecurityService, type DocumentSecurityState, type DocumentUnlockInput, type DocumentUnlockResult, type Engine, EngineError, EngineErrorCode, type EngineFactory, HttpClient, type HttpClientOptions, type MetadataService, type OpenInput, type OpenOptions, type PageAnnotationsService, type PageGeometryService, type PageHandle, type PageRenderService, type PageTextService, type PdfSaveMode, type TokenSource, type UnverifiedClaims, cloudEngine, createCloudEngine, decodeUnverifiedClaims };
|
|
600
|
+
//# sourceMappingURL=index.d.cts.map
|