react-next-editor-js 0.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.
Files changed (102) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +877 -0
  3. package/dist/chunk-3QWXTDLY.cjs +486 -0
  4. package/dist/chunk-3QWXTDLY.cjs.map +1 -0
  5. package/dist/chunk-5F6SPYCN.cjs +180 -0
  6. package/dist/chunk-5F6SPYCN.cjs.map +1 -0
  7. package/dist/chunk-6NTSXJX4.js +174 -0
  8. package/dist/chunk-6NTSXJX4.js.map +1 -0
  9. package/dist/chunk-7VYJDBH7.js +261 -0
  10. package/dist/chunk-7VYJDBH7.js.map +1 -0
  11. package/dist/chunk-DBSFCCBG.cjs +1712 -0
  12. package/dist/chunk-DBSFCCBG.cjs.map +1 -0
  13. package/dist/chunk-EFE6RHDL.cjs +4 -0
  14. package/dist/chunk-EFE6RHDL.cjs.map +1 -0
  15. package/dist/chunk-G6YRIEK4.js +3 -0
  16. package/dist/chunk-G6YRIEK4.js.map +1 -0
  17. package/dist/chunk-GFNFJ3FL.cjs +119 -0
  18. package/dist/chunk-GFNFJ3FL.cjs.map +1 -0
  19. package/dist/chunk-IG2YLUFW.js +114 -0
  20. package/dist/chunk-IG2YLUFW.js.map +1 -0
  21. package/dist/chunk-JQXTWLHL.js +176 -0
  22. package/dist/chunk-JQXTWLHL.js.map +1 -0
  23. package/dist/chunk-NJCEHQV3.cjs +454 -0
  24. package/dist/chunk-NJCEHQV3.cjs.map +1 -0
  25. package/dist/chunk-O4GTLC3T.js +478 -0
  26. package/dist/chunk-O4GTLC3T.js.map +1 -0
  27. package/dist/chunk-ODHABIIC.cjs +82 -0
  28. package/dist/chunk-ODHABIIC.cjs.map +1 -0
  29. package/dist/chunk-PZ5AY32C.js +9 -0
  30. package/dist/chunk-PZ5AY32C.js.map +1 -0
  31. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  32. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  33. package/dist/chunk-QIUIYBCZ.js +80 -0
  34. package/dist/chunk-QIUIYBCZ.js.map +1 -0
  35. package/dist/chunk-QROUNVQK.js +450 -0
  36. package/dist/chunk-QROUNVQK.js.map +1 -0
  37. package/dist/chunk-T6FR37IC.js +41 -0
  38. package/dist/chunk-T6FR37IC.js.map +1 -0
  39. package/dist/chunk-TI44I654.cjs +265 -0
  40. package/dist/chunk-TI44I654.cjs.map +1 -0
  41. package/dist/chunk-TXPLBAH5.cjs +47 -0
  42. package/dist/chunk-TXPLBAH5.cjs.map +1 -0
  43. package/dist/chunk-U3O54IYI.cjs +187 -0
  44. package/dist/chunk-U3O54IYI.cjs.map +1 -0
  45. package/dist/chunk-VLC7SZMT.js +1669 -0
  46. package/dist/chunk-VLC7SZMT.js.map +1 -0
  47. package/dist/core/index.cjs +232 -0
  48. package/dist/core/index.cjs.map +1 -0
  49. package/dist/core/index.d.cts +122 -0
  50. package/dist/core/index.d.ts +122 -0
  51. package/dist/core/index.js +7 -0
  52. package/dist/core/index.js.map +1 -0
  53. package/dist/defaults-EQD5QKCU.js +4 -0
  54. package/dist/defaults-EQD5QKCU.js.map +1 -0
  55. package/dist/defaults-MLYXD2BG.cjs +49 -0
  56. package/dist/defaults-MLYXD2BG.cjs.map +1 -0
  57. package/dist/docx-BUrf4PFj.d.ts +49 -0
  58. package/dist/docx-DLfSdvXm.d.cts +49 -0
  59. package/dist/docx-LDETXV3L.js +5 -0
  60. package/dist/docx-LDETXV3L.js.map +1 -0
  61. package/dist/docx-N2LKIOK3.cjs +14 -0
  62. package/dist/docx-N2LKIOK3.cjs.map +1 -0
  63. package/dist/export/index.cjs +54 -0
  64. package/dist/export/index.cjs.map +1 -0
  65. package/dist/export/index.d.cts +60 -0
  66. package/dist/export/index.d.ts +60 -0
  67. package/dist/export/index.js +9 -0
  68. package/dist/export/index.js.map +1 -0
  69. package/dist/html-5BXJPQU3.js +7 -0
  70. package/dist/html-5BXJPQU3.js.map +1 -0
  71. package/dist/html-KU2KHLRF.cjs +24 -0
  72. package/dist/html-KU2KHLRF.cjs.map +1 -0
  73. package/dist/import/index.cjs +15 -0
  74. package/dist/import/index.cjs.map +1 -0
  75. package/dist/import/index.d.cts +37 -0
  76. package/dist/import/index.d.ts +37 -0
  77. package/dist/import/index.js +6 -0
  78. package/dist/import/index.js.map +1 -0
  79. package/dist/index.cjs +1035 -0
  80. package/dist/index.cjs.map +1 -0
  81. package/dist/index.d.cts +248 -0
  82. package/dist/index.d.ts +248 -0
  83. package/dist/index.js +885 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/persistence/index.cjs +37 -0
  86. package/dist/persistence/index.cjs.map +1 -0
  87. package/dist/persistence/index.d.cts +279 -0
  88. package/dist/persistence/index.d.ts +279 -0
  89. package/dist/persistence/index.js +4 -0
  90. package/dist/persistence/index.js.map +1 -0
  91. package/dist/sanitize-7IZ-SW1f.d.ts +361 -0
  92. package/dist/sanitize-CvmgqbsA.d.cts +361 -0
  93. package/dist/server/index.cjs +400 -0
  94. package/dist/server/index.cjs.map +1 -0
  95. package/dist/server/index.d.cts +229 -0
  96. package/dist/server/index.d.ts +229 -0
  97. package/dist/server/index.js +390 -0
  98. package/dist/server/index.js.map +1 -0
  99. package/dist/styles.css +680 -0
  100. package/dist/types-B4z0Quvv.d.cts +193 -0
  101. package/dist/types-B4z0Quvv.d.ts +193 -0
  102. package/package.json +183 -0
@@ -0,0 +1,229 @@
1
+ import { D as DocumentJSON, P as PageConfig } from '../types-B4z0Quvv.cjs';
2
+ import { T as TextConversionOptions, b as DocxNodeConverter } from '../docx-DLfSdvXm.cjs';
3
+ import 'docx';
4
+
5
+ /**
6
+ * Programmatic export service types (§5.6.2, §8.8). This module is server-side
7
+ * (Node) and never imports the React layer or any DOM. It consumes the same
8
+ * isomorphic converters the client uses, so output is consistent (F-6.11).
9
+ *
10
+ * It is OPTIONAL and additive (C-1): editing and offline/client export do not
11
+ * depend on it.
12
+ */
13
+ /** Supported programmatic export formats. */
14
+ type ServerExportFormat = 'docx' | 'pdf' | 'txt' | 'html';
15
+ /** MIME types for the supported formats. */
16
+ declare const CONTENT_TYPES: Record<ServerExportFormat, string>;
17
+ declare const FILE_EXTENSIONS: Record<ServerExportFormat, string>;
18
+ /** A single export request: a document (by id or inline) and a target format. */
19
+ interface ExportRequest {
20
+ /** Stored document id, resolved via the injected {@link DocumentStoreReader}. */
21
+ documentId?: string;
22
+ /** Inline document JSON (used instead of, or as a fallback for, `documentId`). */
23
+ documentJson?: DocumentJSON;
24
+ format: ServerExportFormat;
25
+ options?: {
26
+ page?: PageConfig;
27
+ title?: string;
28
+ /** Base filename (without extension). Defaults to documentId/title/'document'. */
29
+ filename?: string;
30
+ text?: TextConversionOptions;
31
+ };
32
+ /**
33
+ * When true (and a {@link StorageAdapter} is configured), the rendered file is
34
+ * written to storage and a reference/URL is returned (F-6.10). Otherwise the
35
+ * bytes are returned inline.
36
+ */
37
+ store?: boolean;
38
+ }
39
+ /** Result of a single export. Never throws; failures are reported here (F-6.17). */
40
+ interface ExportResult {
41
+ status: 'ok' | 'error';
42
+ format: ServerExportFormat;
43
+ filename: string;
44
+ contentType: string;
45
+ /** Present when not stored: the rendered bytes. */
46
+ bytes?: Uint8Array;
47
+ /** Present when stored: a URL to fetch the file. */
48
+ url?: string;
49
+ /** Present when stored: an opaque storage reference (e.g. a path or key). */
50
+ ref?: string;
51
+ /** Identifies which input produced this result in a batch. */
52
+ documentId?: string;
53
+ error?: string;
54
+ }
55
+ /**
56
+ * Reads stored document JSON by id, without a live editor (F-6.9). Inject your
57
+ * backend/data-store implementation.
58
+ */
59
+ interface DocumentStoreReader {
60
+ loadDocument(id: string): Promise<DocumentJSON | null>;
61
+ }
62
+ /**
63
+ * Persists rendered files to system/object storage and returns a reference/URL
64
+ * (F-6.10). Filesystem and in-memory implementations ship with the package.
65
+ */
66
+ interface StorageAdapter {
67
+ write(key: string, data: Uint8Array, contentType: string): Promise<{
68
+ url: string;
69
+ ref: string;
70
+ }>;
71
+ }
72
+ /**
73
+ * Renders the shared print HTML to a PDF using a headless browser (F-6.14).
74
+ * Injected so the package does not hard-depend on Puppeteer/Playwright. A
75
+ * Playwright-based factory is provided ({@link createPlaywrightPdfRenderer}).
76
+ */
77
+ interface PdfRenderer {
78
+ render(html: string, options?: {
79
+ page?: PageConfig;
80
+ }): Promise<Uint8Array>;
81
+ /** Release resources (e.g. close the browser). */
82
+ close?(): Promise<void>;
83
+ }
84
+ /** Context passed to the authorization hook (e.g. headers, token, user). */
85
+ interface ExportAuthContext {
86
+ headers?: Record<string, string | undefined>;
87
+ token?: string | null;
88
+ [key: string]: unknown;
89
+ }
90
+ interface ExportServiceOptions {
91
+ /** Resolves `documentId` to stored JSON (F-6.9). Required for id-based exports. */
92
+ store?: DocumentStoreReader;
93
+ /** Writes rendered files to storage (F-6.10). Required for `store: true` exports. */
94
+ storage?: StorageAdapter;
95
+ /** Server PDF renderer (F-6.14). Required for `format: 'pdf'`. */
96
+ pdfRenderer?: PdfRenderer;
97
+ /** Custom DOCX node converters, matching the client's (F-6.16). */
98
+ nodeConverters?: Record<string, DocxNodeConverter>;
99
+ /**
100
+ * Authorize a request and its document access (F-6.15). Return false to reject.
101
+ * Throwing is also treated as a rejection.
102
+ */
103
+ authorize?: (request: ExportRequest, context: ExportAuthContext) => Promise<boolean> | boolean;
104
+ }
105
+ /** Status of an asynchronous batch job (F-6.13). */
106
+ interface ExportJob {
107
+ id: string;
108
+ status: 'pending' | 'running' | 'completed' | 'failed';
109
+ total: number;
110
+ completed: number;
111
+ results: ExportResult[];
112
+ createdAt: number;
113
+ finishedAt?: number;
114
+ error?: string;
115
+ }
116
+
117
+ /**
118
+ * The programmatic export service (§8.8). Converts our own stored/inline JSON to
119
+ * DOCX/PDF/text/HTML using the shared isomorphic converters, optionally persists
120
+ * the result to storage, and reports per-document status. It is authenticated/
121
+ * access-controlled via the injected `authorize` hook (F-6.15) and never emits a
122
+ * malformed file silently — failures are returned as `status: 'error'` (F-6.17).
123
+ */
124
+ declare class ExportService {
125
+ private readonly options;
126
+ private readonly jobs;
127
+ private jobSeq;
128
+ constructor(options?: ExportServiceOptions);
129
+ /** Render a single export request (synchronous result). */
130
+ export(request: ExportRequest, context?: ExportAuthContext): Promise<ExportResult>;
131
+ /**
132
+ * Render multiple requests in one call (F-6.12), each with independent status
133
+ * (F-6.17). Failures of one item do not abort the others.
134
+ */
135
+ exportBatch(requests: ExportRequest[], context?: ExportAuthContext): Promise<ExportResult[]>;
136
+ /**
137
+ * Enqueue a batch as an asynchronous job (F-6.13). Returns immediately with a
138
+ * job id; poll {@link getJob} for status/results. This is a simple in-process
139
+ * runner — swap in a durable queue (e.g. BullMQ) for production scale.
140
+ */
141
+ enqueue(requests: ExportRequest[], context?: ExportAuthContext): {
142
+ jobId: string;
143
+ };
144
+ /** Look up an async job's status and results. */
145
+ getJob(jobId: string): ExportJob | null;
146
+ /** Release renderer resources (e.g. close the headless browser). */
147
+ close(): Promise<void>;
148
+ private baseResult;
149
+ private resolveDocument;
150
+ private render;
151
+ }
152
+ /** Create a configured {@link ExportService}. */
153
+ declare function createExportService(options?: ExportServiceOptions): ExportService;
154
+
155
+ /**
156
+ * A web-standard `(Request) => Promise<Response>` handler factory for the export
157
+ * service (F-6.8). It works directly as a Next.js App Router route handler, or
158
+ * in any Fetch-API server. Authentication is delegated to the service's
159
+ * `authorize` hook; the Bearer token (if any) is passed through as context.
160
+ *
161
+ * Request body shapes (POST, JSON):
162
+ * - `{ jobId }` → returns the async job status
163
+ * - `{ async: true, requests: [...] }` → enqueues a batch, returns `{ jobId }`
164
+ * - `{ requests: [...] }` → synchronous batch, returns `{ results }`
165
+ * - a single {@link ExportRequest} → returns the file (binary) or a `{ url }`
166
+ */
167
+ declare function createExportHandler(service: ExportService): (request: Request) => Promise<Response>;
168
+
169
+ /**
170
+ * In-memory {@link StorageAdapter} — useful for tests and serverless contexts
171
+ * that hand bytes off elsewhere. URLs are `memory:` references.
172
+ */
173
+ declare class MemoryStorage implements StorageAdapter {
174
+ private files;
175
+ write(key: string, data: Uint8Array, contentType: string): Promise<{
176
+ url: string;
177
+ ref: string;
178
+ }>;
179
+ get(key: string): {
180
+ data: Uint8Array;
181
+ contentType: string;
182
+ } | undefined;
183
+ keys(): string[];
184
+ }
185
+ interface FilesystemStorageOptions {
186
+ /** Directory rendered files are written under. */
187
+ baseDir: string;
188
+ /**
189
+ * Public base URL files are served from. The returned `url` is
190
+ * `${baseUrl}/${key}`. If omitted, `url` mirrors the on-disk path.
191
+ */
192
+ baseUrl?: string;
193
+ }
194
+ /**
195
+ * Filesystem {@link StorageAdapter} (F-6.10). Writes rendered files under a base
196
+ * directory and returns a URL/reference. Uses `node:fs` lazily so the module can
197
+ * be imported anywhere without eagerly pulling Node built-ins.
198
+ */
199
+ declare class FilesystemStorage implements StorageAdapter {
200
+ private readonly baseDir;
201
+ private readonly baseUrl?;
202
+ constructor(options: FilesystemStorageOptions);
203
+ write(key: string, data: Uint8Array, _contentType: string): Promise<{
204
+ url: string;
205
+ ref: string;
206
+ }>;
207
+ }
208
+
209
+ interface PlaywrightPdfOptions {
210
+ /** Print background colors/images. Default true. */
211
+ printBackground?: boolean;
212
+ /** Honour the document's `@page` size rules. Default true. */
213
+ preferCSSPageSize?: boolean;
214
+ /** Launch arguments forwarded to chromium. */
215
+ launchArgs?: string[];
216
+ }
217
+ /**
218
+ * PDF renderer backed by Playwright's bundled Chromium. Requires `playwright`
219
+ * to be installed in the host. The browser is launched lazily and reused;
220
+ * call `close()` to release it.
221
+ */
222
+ declare function createPlaywrightPdfRenderer(options?: PlaywrightPdfOptions): PdfRenderer;
223
+ /**
224
+ * PDF renderer backed by Puppeteer. Requires `puppeteer` to be installed.
225
+ * Equivalent behaviour to the Playwright renderer.
226
+ */
227
+ declare function createPuppeteerPdfRenderer(options?: PlaywrightPdfOptions): PdfRenderer;
228
+
229
+ export { CONTENT_TYPES, type DocumentStoreReader, type ExportAuthContext, type ExportJob, type ExportRequest, type ExportResult, ExportService, type ExportServiceOptions, FILE_EXTENSIONS, FilesystemStorage, type FilesystemStorageOptions, MemoryStorage, type PdfRenderer, type PlaywrightPdfOptions, type ServerExportFormat, type StorageAdapter, createExportHandler, createExportService, createPlaywrightPdfRenderer, createPuppeteerPdfRenderer };
@@ -0,0 +1,229 @@
1
+ import { D as DocumentJSON, P as PageConfig } from '../types-B4z0Quvv.js';
2
+ import { T as TextConversionOptions, b as DocxNodeConverter } from '../docx-BUrf4PFj.js';
3
+ import 'docx';
4
+
5
+ /**
6
+ * Programmatic export service types (§5.6.2, §8.8). This module is server-side
7
+ * (Node) and never imports the React layer or any DOM. It consumes the same
8
+ * isomorphic converters the client uses, so output is consistent (F-6.11).
9
+ *
10
+ * It is OPTIONAL and additive (C-1): editing and offline/client export do not
11
+ * depend on it.
12
+ */
13
+ /** Supported programmatic export formats. */
14
+ type ServerExportFormat = 'docx' | 'pdf' | 'txt' | 'html';
15
+ /** MIME types for the supported formats. */
16
+ declare const CONTENT_TYPES: Record<ServerExportFormat, string>;
17
+ declare const FILE_EXTENSIONS: Record<ServerExportFormat, string>;
18
+ /** A single export request: a document (by id or inline) and a target format. */
19
+ interface ExportRequest {
20
+ /** Stored document id, resolved via the injected {@link DocumentStoreReader}. */
21
+ documentId?: string;
22
+ /** Inline document JSON (used instead of, or as a fallback for, `documentId`). */
23
+ documentJson?: DocumentJSON;
24
+ format: ServerExportFormat;
25
+ options?: {
26
+ page?: PageConfig;
27
+ title?: string;
28
+ /** Base filename (without extension). Defaults to documentId/title/'document'. */
29
+ filename?: string;
30
+ text?: TextConversionOptions;
31
+ };
32
+ /**
33
+ * When true (and a {@link StorageAdapter} is configured), the rendered file is
34
+ * written to storage and a reference/URL is returned (F-6.10). Otherwise the
35
+ * bytes are returned inline.
36
+ */
37
+ store?: boolean;
38
+ }
39
+ /** Result of a single export. Never throws; failures are reported here (F-6.17). */
40
+ interface ExportResult {
41
+ status: 'ok' | 'error';
42
+ format: ServerExportFormat;
43
+ filename: string;
44
+ contentType: string;
45
+ /** Present when not stored: the rendered bytes. */
46
+ bytes?: Uint8Array;
47
+ /** Present when stored: a URL to fetch the file. */
48
+ url?: string;
49
+ /** Present when stored: an opaque storage reference (e.g. a path or key). */
50
+ ref?: string;
51
+ /** Identifies which input produced this result in a batch. */
52
+ documentId?: string;
53
+ error?: string;
54
+ }
55
+ /**
56
+ * Reads stored document JSON by id, without a live editor (F-6.9). Inject your
57
+ * backend/data-store implementation.
58
+ */
59
+ interface DocumentStoreReader {
60
+ loadDocument(id: string): Promise<DocumentJSON | null>;
61
+ }
62
+ /**
63
+ * Persists rendered files to system/object storage and returns a reference/URL
64
+ * (F-6.10). Filesystem and in-memory implementations ship with the package.
65
+ */
66
+ interface StorageAdapter {
67
+ write(key: string, data: Uint8Array, contentType: string): Promise<{
68
+ url: string;
69
+ ref: string;
70
+ }>;
71
+ }
72
+ /**
73
+ * Renders the shared print HTML to a PDF using a headless browser (F-6.14).
74
+ * Injected so the package does not hard-depend on Puppeteer/Playwright. A
75
+ * Playwright-based factory is provided ({@link createPlaywrightPdfRenderer}).
76
+ */
77
+ interface PdfRenderer {
78
+ render(html: string, options?: {
79
+ page?: PageConfig;
80
+ }): Promise<Uint8Array>;
81
+ /** Release resources (e.g. close the browser). */
82
+ close?(): Promise<void>;
83
+ }
84
+ /** Context passed to the authorization hook (e.g. headers, token, user). */
85
+ interface ExportAuthContext {
86
+ headers?: Record<string, string | undefined>;
87
+ token?: string | null;
88
+ [key: string]: unknown;
89
+ }
90
+ interface ExportServiceOptions {
91
+ /** Resolves `documentId` to stored JSON (F-6.9). Required for id-based exports. */
92
+ store?: DocumentStoreReader;
93
+ /** Writes rendered files to storage (F-6.10). Required for `store: true` exports. */
94
+ storage?: StorageAdapter;
95
+ /** Server PDF renderer (F-6.14). Required for `format: 'pdf'`. */
96
+ pdfRenderer?: PdfRenderer;
97
+ /** Custom DOCX node converters, matching the client's (F-6.16). */
98
+ nodeConverters?: Record<string, DocxNodeConverter>;
99
+ /**
100
+ * Authorize a request and its document access (F-6.15). Return false to reject.
101
+ * Throwing is also treated as a rejection.
102
+ */
103
+ authorize?: (request: ExportRequest, context: ExportAuthContext) => Promise<boolean> | boolean;
104
+ }
105
+ /** Status of an asynchronous batch job (F-6.13). */
106
+ interface ExportJob {
107
+ id: string;
108
+ status: 'pending' | 'running' | 'completed' | 'failed';
109
+ total: number;
110
+ completed: number;
111
+ results: ExportResult[];
112
+ createdAt: number;
113
+ finishedAt?: number;
114
+ error?: string;
115
+ }
116
+
117
+ /**
118
+ * The programmatic export service (§8.8). Converts our own stored/inline JSON to
119
+ * DOCX/PDF/text/HTML using the shared isomorphic converters, optionally persists
120
+ * the result to storage, and reports per-document status. It is authenticated/
121
+ * access-controlled via the injected `authorize` hook (F-6.15) and never emits a
122
+ * malformed file silently — failures are returned as `status: 'error'` (F-6.17).
123
+ */
124
+ declare class ExportService {
125
+ private readonly options;
126
+ private readonly jobs;
127
+ private jobSeq;
128
+ constructor(options?: ExportServiceOptions);
129
+ /** Render a single export request (synchronous result). */
130
+ export(request: ExportRequest, context?: ExportAuthContext): Promise<ExportResult>;
131
+ /**
132
+ * Render multiple requests in one call (F-6.12), each with independent status
133
+ * (F-6.17). Failures of one item do not abort the others.
134
+ */
135
+ exportBatch(requests: ExportRequest[], context?: ExportAuthContext): Promise<ExportResult[]>;
136
+ /**
137
+ * Enqueue a batch as an asynchronous job (F-6.13). Returns immediately with a
138
+ * job id; poll {@link getJob} for status/results. This is a simple in-process
139
+ * runner — swap in a durable queue (e.g. BullMQ) for production scale.
140
+ */
141
+ enqueue(requests: ExportRequest[], context?: ExportAuthContext): {
142
+ jobId: string;
143
+ };
144
+ /** Look up an async job's status and results. */
145
+ getJob(jobId: string): ExportJob | null;
146
+ /** Release renderer resources (e.g. close the headless browser). */
147
+ close(): Promise<void>;
148
+ private baseResult;
149
+ private resolveDocument;
150
+ private render;
151
+ }
152
+ /** Create a configured {@link ExportService}. */
153
+ declare function createExportService(options?: ExportServiceOptions): ExportService;
154
+
155
+ /**
156
+ * A web-standard `(Request) => Promise<Response>` handler factory for the export
157
+ * service (F-6.8). It works directly as a Next.js App Router route handler, or
158
+ * in any Fetch-API server. Authentication is delegated to the service's
159
+ * `authorize` hook; the Bearer token (if any) is passed through as context.
160
+ *
161
+ * Request body shapes (POST, JSON):
162
+ * - `{ jobId }` → returns the async job status
163
+ * - `{ async: true, requests: [...] }` → enqueues a batch, returns `{ jobId }`
164
+ * - `{ requests: [...] }` → synchronous batch, returns `{ results }`
165
+ * - a single {@link ExportRequest} → returns the file (binary) or a `{ url }`
166
+ */
167
+ declare function createExportHandler(service: ExportService): (request: Request) => Promise<Response>;
168
+
169
+ /**
170
+ * In-memory {@link StorageAdapter} — useful for tests and serverless contexts
171
+ * that hand bytes off elsewhere. URLs are `memory:` references.
172
+ */
173
+ declare class MemoryStorage implements StorageAdapter {
174
+ private files;
175
+ write(key: string, data: Uint8Array, contentType: string): Promise<{
176
+ url: string;
177
+ ref: string;
178
+ }>;
179
+ get(key: string): {
180
+ data: Uint8Array;
181
+ contentType: string;
182
+ } | undefined;
183
+ keys(): string[];
184
+ }
185
+ interface FilesystemStorageOptions {
186
+ /** Directory rendered files are written under. */
187
+ baseDir: string;
188
+ /**
189
+ * Public base URL files are served from. The returned `url` is
190
+ * `${baseUrl}/${key}`. If omitted, `url` mirrors the on-disk path.
191
+ */
192
+ baseUrl?: string;
193
+ }
194
+ /**
195
+ * Filesystem {@link StorageAdapter} (F-6.10). Writes rendered files under a base
196
+ * directory and returns a URL/reference. Uses `node:fs` lazily so the module can
197
+ * be imported anywhere without eagerly pulling Node built-ins.
198
+ */
199
+ declare class FilesystemStorage implements StorageAdapter {
200
+ private readonly baseDir;
201
+ private readonly baseUrl?;
202
+ constructor(options: FilesystemStorageOptions);
203
+ write(key: string, data: Uint8Array, _contentType: string): Promise<{
204
+ url: string;
205
+ ref: string;
206
+ }>;
207
+ }
208
+
209
+ interface PlaywrightPdfOptions {
210
+ /** Print background colors/images. Default true. */
211
+ printBackground?: boolean;
212
+ /** Honour the document's `@page` size rules. Default true. */
213
+ preferCSSPageSize?: boolean;
214
+ /** Launch arguments forwarded to chromium. */
215
+ launchArgs?: string[];
216
+ }
217
+ /**
218
+ * PDF renderer backed by Playwright's bundled Chromium. Requires `playwright`
219
+ * to be installed in the host. The browser is launched lazily and reused;
220
+ * call `close()` to release it.
221
+ */
222
+ declare function createPlaywrightPdfRenderer(options?: PlaywrightPdfOptions): PdfRenderer;
223
+ /**
224
+ * PDF renderer backed by Puppeteer. Requires `puppeteer` to be installed.
225
+ * Equivalent behaviour to the Playwright renderer.
226
+ */
227
+ declare function createPuppeteerPdfRenderer(options?: PlaywrightPdfOptions): PdfRenderer;
228
+
229
+ export { CONTENT_TYPES, type DocumentStoreReader, type ExportAuthContext, type ExportJob, type ExportRequest, type ExportResult, ExportService, type ExportServiceOptions, FILE_EXTENSIONS, FilesystemStorage, type FilesystemStorageOptions, MemoryStorage, type PdfRenderer, type PlaywrightPdfOptions, type ServerExportFormat, type StorageAdapter, createExportHandler, createExportService, createPlaywrightPdfRenderer, createPuppeteerPdfRenderer };