@jsxpdf/jsxpdf 0.0.1-alpha.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/index.js ADDED
@@ -0,0 +1,700 @@
1
+ // src/index.ts
2
+ import {
3
+ Canvas,
4
+ Circle,
5
+ Checkbox,
6
+ ClipPath,
7
+ Defs,
8
+ Document as Document2,
9
+ Ellipse,
10
+ Table,
11
+ TableBody,
12
+ TableCell,
13
+ TableFooter,
14
+ TableHead,
15
+ TableRow,
16
+ FieldSet,
17
+ G,
18
+ Image,
19
+ Line,
20
+ LinearGradient,
21
+ Link,
22
+ List,
23
+ Note,
24
+ Page as Page2,
25
+ PageBreak,
26
+ Path,
27
+ Polygon,
28
+ Polyline,
29
+ RadialGradient,
30
+ Rect,
31
+ Select,
32
+ Stop,
33
+ Svg,
34
+ Text,
35
+ TextInput,
36
+ Tspan,
37
+ View as View2
38
+ } from "@jsxpdf/core";
39
+ import { Font, StyleSheet } from "@jsxpdf/core";
40
+
41
+ // src/render.ts
42
+ import { concatUint8Arrays } from "@jsxpdf/core";
43
+ import {
44
+ createPdfRuntime
45
+ } from "@jsxpdf/render";
46
+ import { renderPdf } from "@jsxpdf/render-pdfkit";
47
+ var runtime = createPdfRuntime(renderPdf);
48
+ var chunkToUint8Array = (chunk2) => {
49
+ if (chunk2 instanceof Uint8Array) return chunk2;
50
+ if (typeof chunk2 === "string") return new TextEncoder().encode(chunk2);
51
+ return new Uint8Array(chunk2);
52
+ };
53
+ var collectStreamBytes = (stream) => new Promise((resolve, reject) => {
54
+ const chunks = [];
55
+ let ended = false;
56
+ let finished = false;
57
+ let settled = false;
58
+ let resolveTimer = null;
59
+ const settle = () => {
60
+ if (settled) return;
61
+ settled = true;
62
+ if (resolveTimer) clearTimeout(resolveTimer);
63
+ resolve(concatUint8Arrays(chunks));
64
+ };
65
+ const maybeResolve = () => {
66
+ if (settled) return;
67
+ if (ended && finished) return settle();
68
+ if (ended || finished) {
69
+ if (resolveTimer) clearTimeout(resolveTimer);
70
+ resolveTimer = setTimeout(settle, 0);
71
+ }
72
+ };
73
+ stream.on("data", (chunk2) => {
74
+ chunks.push(chunkToUint8Array(chunk2));
75
+ });
76
+ stream.on("end", () => {
77
+ ended = true;
78
+ maybeResolve();
79
+ });
80
+ stream.on("finish", () => {
81
+ finished = true;
82
+ maybeResolve();
83
+ });
84
+ stream.on("error", reject);
85
+ });
86
+ var wrapInstance = (instance) => ({
87
+ ...instance,
88
+ async toUint8Array() {
89
+ return collectStreamBytes(await instance.toStream());
90
+ },
91
+ async toBlob() {
92
+ const bytes = await this.toUint8Array();
93
+ return new Blob([Uint8Array.from(bytes)], { type: "application/pdf" });
94
+ }
95
+ });
96
+ var pdf = (initialValue, options = {}) => {
97
+ return wrapInstance(runtime.pdf(initialValue, options));
98
+ };
99
+ var renderToUint8Array = (element, options = {}) => pdf(element, options).toUint8Array();
100
+ var renderToBlob = (element, options = {}) => pdf(element, options).toBlob();
101
+ var compile = async (component, options = {}) => {
102
+ const template = await runtime.compile(component, options);
103
+ const toUint8Array = async (props, renderOptions = {}) => {
104
+ return collectStreamBytes(await template.toStream(props, renderOptions));
105
+ };
106
+ return {
107
+ ...template,
108
+ toUint8Array,
109
+ async toBlob(props, renderOptions = {}) {
110
+ const bytes = await toUint8Array(props, renderOptions);
111
+ return new Blob([Uint8Array.from(bytes)], { type: "application/pdf" });
112
+ }
113
+ };
114
+ };
115
+
116
+ // src/repeat.ts
117
+ import { Document, Page, View, createBindingToken, isBindingToken, materializeChildren, materializeElement, parseSizeValue } from "@jsxpdf/core";
118
+ import {
119
+ buildConcatenatedDocumentLayout,
120
+ compilePrecompiledTemplateSync,
121
+ initCompiledRenderState,
122
+ runSinglePageIncrementalPipeline
123
+ } from "@jsxpdf/layout";
124
+
125
+ // src/jsx-runtime.ts
126
+ import { Fragment, jsx, jsxs, jsxDEV } from "@jsxpdf/core/jsx-runtime";
127
+
128
+ // src/repeat.ts
129
+ var pageSizes = {
130
+ A0: [2383.94, 3370.39],
131
+ A1: [1683.78, 2383.94],
132
+ A2: [1190.55, 1683.78],
133
+ A3: [841.89, 1190.55],
134
+ A4: [595.28, 841.89],
135
+ A5: [419.53, 595.28],
136
+ A6: [297.64, 419.53],
137
+ LETTER: [612, 792],
138
+ LEGAL: [612, 1008],
139
+ TABLOID: [792, 1224]
140
+ };
141
+ var TRACKED_PATH_SYMBOL = /* @__PURE__ */ Symbol.for("jsxpdf.trackedPath");
142
+ var h = (type, props, ...children) => {
143
+ const normalizedChildren = children.flat(Infinity).filter((child) => child !== void 0 && child !== null && child !== false);
144
+ const nextProps = { ...props ?? {} };
145
+ if (normalizedChildren.length === 1) {
146
+ nextProps.children = normalizedChildren[0];
147
+ } else if (normalizedChildren.length > 1) {
148
+ nextProps.children = normalizedChildren;
149
+ }
150
+ const key = nextProps.key;
151
+ delete nextProps.key;
152
+ return Array.isArray(nextProps.children) ? jsxs(type, nextProps, key) : jsx(type, nextProps, key);
153
+ };
154
+ var chunk = (items, size) => {
155
+ const result = [];
156
+ for (let index = 0; index < items.length; index += size) {
157
+ result.push(items.slice(index, index + size));
158
+ }
159
+ return result;
160
+ };
161
+ var resolveRepeatPageSize = (size, orientation, dpi = 72) => {
162
+ let resolved;
163
+ if (typeof size === "string") {
164
+ resolved = pageSizes[size.toUpperCase()] ?? pageSizes.A4;
165
+ } else if (Array.isArray(size)) {
166
+ resolved = [
167
+ parseSizeValue(size[0], 0, dpi) ?? pageSizes.A4[0],
168
+ parseSizeValue(size[1], 0, dpi) ?? pageSizes.A4[1]
169
+ ];
170
+ } else if (typeof size === "number") {
171
+ resolved = [size, size];
172
+ } else if (size && typeof size === "object") {
173
+ resolved = [
174
+ parseSizeValue(size.width, 0, dpi) ?? pageSizes.A4[0],
175
+ parseSizeValue(size.height, 0, dpi) ?? pageSizes.A4[1]
176
+ ];
177
+ } else {
178
+ resolved = pageSizes.A4;
179
+ }
180
+ return orientation === "landscape" ? [resolved[1], resolved[0]] : resolved;
181
+ };
182
+ var reorderForColumnFill = (items, columns, rows) => {
183
+ const perPage = Math.max(1, columns * rows);
184
+ const reordered = [];
185
+ for (const pageItems of chunk(items, perPage)) {
186
+ for (let row = 0; row < rows; row += 1) {
187
+ for (let column = 0; column < columns; column += 1) {
188
+ const sourceIndex = column * rows + row;
189
+ const item = pageItems[sourceIndex];
190
+ if (item !== void 0) reordered.push(item);
191
+ }
192
+ }
193
+ }
194
+ return reordered;
195
+ };
196
+ var isElement = (value) => typeof value === "object" && value !== null && "type" in value && "props" in value;
197
+ var resolveTrackedPathValue = (root, path) => {
198
+ let current = root;
199
+ for (const segment of path) {
200
+ if (current == null) return void 0;
201
+ current = current[segment];
202
+ }
203
+ return current;
204
+ };
205
+ var resolveBindingValues = (value, rootProps) => {
206
+ if (isBindingToken(value)) {
207
+ return resolveTrackedPathValue(rootProps, value.path);
208
+ }
209
+ if (Array.isArray(value)) {
210
+ return value.map((entry) => resolveBindingValues(entry, rootProps));
211
+ }
212
+ if (value instanceof Date || value instanceof Uint8Array) return value;
213
+ if (typeof value === "function") return value;
214
+ if (value && typeof value === "object") {
215
+ const source = value;
216
+ const resolved = {};
217
+ for (const [key, entry] of Object.entries(source)) {
218
+ resolved[key] = resolveBindingValues(entry, rootProps);
219
+ }
220
+ return resolved;
221
+ }
222
+ return value;
223
+ };
224
+ var extractConcatDocuments = (value) => {
225
+ const resolved = materializeElement(value);
226
+ const children = materializeChildren(resolved);
227
+ const documents = [];
228
+ for (const child of children) {
229
+ const resolvedChild = materializeElement(child);
230
+ if (!isElement(resolvedChild)) continue;
231
+ if (resolvedChild.type === Document) {
232
+ documents.push(resolvedChild);
233
+ continue;
234
+ }
235
+ if (resolvedChild.type === Page) {
236
+ documents.push(h(Document, null, resolvedChild));
237
+ continue;
238
+ }
239
+ throw new Error(`Concat only accepts Document, RepeatedDocument, or Page children. Received ${String(resolvedChild.type)}.`);
240
+ }
241
+ return documents;
242
+ };
243
+ function CardSlot(props) {
244
+ const { __repeatSlotMetrics, padding = 0, overflow = "clip", clip, wrap, style, children, ...rest } = props;
245
+ if (!__repeatSlotMetrics) {
246
+ throw new Error("CardSlot must be used inside Repeat.");
247
+ }
248
+ const contentWidth = Math.max(0, __repeatSlotMetrics.width - padding * 2);
249
+ const contentHeight = Math.max(0, __repeatSlotMetrics.height - padding * 2);
250
+ return h(
251
+ View,
252
+ {
253
+ ...rest,
254
+ wrap: wrap ?? false,
255
+ clip: clip ?? overflow !== "error",
256
+ repeatSlotConfig: {
257
+ overflow,
258
+ contentWidth,
259
+ contentHeight
260
+ },
261
+ style: [
262
+ style,
263
+ {
264
+ left: __repeatSlotMetrics.x,
265
+ top: __repeatSlotMetrics.y,
266
+ width: __repeatSlotMetrics.width,
267
+ height: __repeatSlotMetrics.height,
268
+ paddingTop: padding,
269
+ paddingRight: padding,
270
+ paddingBottom: padding,
271
+ paddingLeft: padding,
272
+ position: "absolute"
273
+ }
274
+ ]
275
+ },
276
+ h(
277
+ View,
278
+ {
279
+ repeatSlotContent: true,
280
+ wrap: false,
281
+ style: {
282
+ width: contentWidth,
283
+ height: contentHeight,
284
+ position: "relative"
285
+ }
286
+ },
287
+ children
288
+ )
289
+ );
290
+ }
291
+ var getRepeatedDocumentPlan = (props) => {
292
+ if (isBindingToken(props.items)) {
293
+ throw new Error("jsxpdf.compile.unsupported: RepeatedDocument requires static items during layout.");
294
+ }
295
+ const items = props.fill === "column" ? reorderForColumnFill(props.items, props.slots.columns, props.slots.rows) : [...props.items];
296
+ const columns = Math.max(1, Math.floor(props.slots.columns));
297
+ const rows = Math.max(1, Math.floor(props.slots.rows));
298
+ const gap = Math.max(0, props.gap ?? 0);
299
+ const perPage = columns * rows;
300
+ const [pageWidth, pageHeight] = resolveRepeatPageSize(
301
+ props.page?.size,
302
+ props.page?.orientation,
303
+ props.page?.dpi
304
+ );
305
+ const totalHorizontalGap = gap * (columns - 1);
306
+ const totalVerticalGap = gap * (rows - 1);
307
+ const slotWidth = (pageWidth - totalHorizontalGap) / columns;
308
+ const slotHeight = (pageHeight - totalVerticalGap) / rows;
309
+ const pageCount = Math.ceil(items.length / perPage);
310
+ return {
311
+ items,
312
+ columns,
313
+ gap,
314
+ perPage,
315
+ pageWidth,
316
+ pageHeight,
317
+ pageCount,
318
+ slotWidth,
319
+ slotHeight
320
+ };
321
+ };
322
+ var createRepeatedPageDocument = (props, pageIndex) => {
323
+ const plan = getRepeatedDocumentPlan(props);
324
+ const pageItems = plan.items.slice(pageIndex * plan.perPage, pageIndex * plan.perPage + plan.perPage);
325
+ const trackedItemPaths = pageItems.map((item) => item && typeof item === "object" && Array.isArray(item[TRACKED_PATH_SYMBOL]) ? [...item[TRACKED_PATH_SYMBOL]] : null).filter((path) => Array.isArray(path) && path.length >= 2 && typeof path[path.length - 1] === "number");
326
+ const firstTrackedPath = trackedItemPaths[0];
327
+ const pageCollectionPath = firstTrackedPath && trackedItemPaths.every(
328
+ (path) => path.length === firstTrackedPath.length && path.slice(0, -1).every((segment, index) => segment === firstTrackedPath[index])
329
+ ) ? firstTrackedPath.slice(0, -1) : void 0;
330
+ const pageIndexRange = pageCollectionPath && trackedItemPaths.length > 0 ? [
331
+ Math.min(...trackedItemPaths.map((path) => path[path.length - 1])),
332
+ Math.max(...trackedItemPaths.map((path) => path[path.length - 1]))
333
+ ] : void 0;
334
+ return h(
335
+ Document,
336
+ {
337
+ key: `repeated-document-${pageIndex + 1}`
338
+ },
339
+ h(
340
+ Page,
341
+ {
342
+ key: `repeat-page-${pageIndex + 1}`,
343
+ size: [plan.pageWidth, plan.pageHeight],
344
+ dpi: props.page?.dpi,
345
+ __repeatTrackedCollectionPath: pageCollectionPath,
346
+ __repeatTrackedIndexRange: pageIndexRange,
347
+ style: [
348
+ {
349
+ padding: 0,
350
+ position: "relative"
351
+ },
352
+ props.page?.style
353
+ ]
354
+ },
355
+ ...pageItems.map((item, itemIndex) => {
356
+ const childIndex = pageIndex * plan.perPage + itemIndex;
357
+ const row = Math.floor(itemIndex / plan.columns);
358
+ const column = itemIndex % plan.columns;
359
+ const rendered = typeof props.children === "function" ? props.children(item, childIndex) : props.children;
360
+ const metrics = {
361
+ x: column * (plan.slotWidth + plan.gap),
362
+ y: row * (plan.slotHeight + plan.gap),
363
+ width: plan.slotWidth,
364
+ height: plan.slotHeight
365
+ };
366
+ const repeatTrackedItemPath = item && typeof item === "object" && Array.isArray(item[TRACKED_PATH_SYMBOL]) ? [...item[TRACKED_PATH_SYMBOL]] : void 0;
367
+ if (isElement(rendered) && rendered.type === CardSlot) {
368
+ return {
369
+ ...rendered,
370
+ props: {
371
+ ...rendered.props,
372
+ __repeatSlotMetrics: metrics,
373
+ __repeatTrackedItemPath: repeatTrackedItemPath
374
+ }
375
+ };
376
+ }
377
+ return h(CardSlot, {
378
+ key: `repeat-slot-${childIndex + 1}`,
379
+ __repeatSlotMetrics: metrics,
380
+ __repeatTrackedItemPath: repeatTrackedItemPath,
381
+ children: rendered
382
+ });
383
+ })
384
+ )
385
+ );
386
+ };
387
+ var createRepeatedPages = (props) => {
388
+ const plan = getRepeatedDocumentPlan(props);
389
+ return Array.from({ length: plan.pageCount }, (_, pageIndex) => {
390
+ const document = createRepeatedPageDocument(props, pageIndex);
391
+ return materializeChildren(document.props.children ?? [])[0];
392
+ });
393
+ };
394
+ var createRepeatedSlotElement = (props, item, itemIndex, metrics) => {
395
+ const rendered = typeof props.children === "function" ? props.children(item, itemIndex) : props.children;
396
+ const repeatTrackedItemPath = item && typeof item === "object" && Array.isArray(item[TRACKED_PATH_SYMBOL]) ? [...item[TRACKED_PATH_SYMBOL]] : void 0;
397
+ if (isElement(rendered) && rendered.type === CardSlot) {
398
+ return {
399
+ ...rendered,
400
+ props: {
401
+ ...rendered.props,
402
+ __repeatSlotMetrics: metrics,
403
+ __repeatTrackedItemPath: repeatTrackedItemPath
404
+ }
405
+ };
406
+ }
407
+ return h(CardSlot, {
408
+ key: `repeat-slot-${itemIndex + 1}`,
409
+ __repeatSlotMetrics: metrics,
410
+ __repeatTrackedItemPath: repeatTrackedItemPath,
411
+ children: rendered
412
+ });
413
+ };
414
+ var canCompileRepeatedSchema = (props) => {
415
+ if (!isBindingToken(props.items)) return false;
416
+ if (isBindingToken(props.page?.size) || isBindingToken(props.page?.orientation) || isBindingToken(props.page?.dpi)) return false;
417
+ if (isBindingToken(props.gap) || isBindingToken(props.fill)) return false;
418
+ if (isBindingToken(props.slots.columns) || isBindingToken(props.slots.rows)) return false;
419
+ return true;
420
+ };
421
+ var createRepeatedSchemaRender = (props) => {
422
+ if (!isBindingToken(props.items)) {
423
+ throw new Error("jsxpdf.compile.unsupported: RepeatedDocument schema render requires binding-token items.");
424
+ }
425
+ const itemsPath = [...props.items.path];
426
+ const staticPlan = getRepeatedDocumentPlan({
427
+ ...props,
428
+ items: []
429
+ });
430
+ const documentTemplate = compilePrecompiledTemplateSync(h(Document, {
431
+ title: props.title,
432
+ author: props.author,
433
+ subject: props.subject,
434
+ creator: props.creator,
435
+ keywords: props.keywords,
436
+ producer: props.producer,
437
+ language: props.language,
438
+ creationDate: props.creationDate,
439
+ modificationDate: props.modificationDate,
440
+ pdfVersion: props.pdfVersion,
441
+ tagged: props.tagged,
442
+ attachments: props.attachments,
443
+ xmp: props.xmp,
444
+ pdfaid: props.pdfaid,
445
+ pageMode: props.pageMode,
446
+ pageLayout: props.pageLayout
447
+ }));
448
+ const pageTemplate = compilePrecompiledTemplateSync(
449
+ h(
450
+ Document,
451
+ null,
452
+ h(
453
+ Page,
454
+ {
455
+ size: [staticPlan.pageWidth, staticPlan.pageHeight],
456
+ dpi: props.page?.dpi,
457
+ style: [
458
+ {
459
+ padding: 0,
460
+ position: "relative"
461
+ },
462
+ props.page?.style
463
+ ]
464
+ }
465
+ )
466
+ )
467
+ );
468
+ const slotTemplate = compilePrecompiledTemplateSync(
469
+ createRepeatedSlotElement(
470
+ props,
471
+ createBindingToken(["__repeatItem"], "", void 0, true),
472
+ 0,
473
+ {
474
+ x: 0,
475
+ y: 0,
476
+ width: staticPlan.slotWidth,
477
+ height: staticPlan.slotHeight
478
+ }
479
+ )
480
+ );
481
+ const declaredBindingPaths = [
482
+ itemsPath,
483
+ ...documentTemplate.placeholders.flatMap((entry) => [
484
+ ...entry.bindingPath ? [entry.bindingPath] : [],
485
+ ...entry.bindingPaths ?? []
486
+ ]),
487
+ ...pageTemplate.placeholders.flatMap((entry) => [
488
+ ...entry.bindingPath ? [entry.bindingPath] : [],
489
+ ...entry.bindingPaths ?? []
490
+ ]),
491
+ ...slotTemplate.placeholders.flatMap((entry) => [
492
+ ...entry.bindingPath ? [entry.bindingPath] : [],
493
+ ...entry.bindingPaths ?? []
494
+ ])
495
+ ].flatMap((path) => path[0] === "__repeatItem" ? [path] : Array.from({ length: path.length }, (_, index) => path.slice(0, index + 1)));
496
+ const uniqueBindingPaths = declaredBindingPaths.filter(
497
+ (path, index, all) => all.findIndex(
498
+ (candidate) => candidate.length === path.length && candidate.every((segment, segmentIndex) => segment === path[segmentIndex])
499
+ ) === index
500
+ );
501
+ const indexedSlotElements = Array.from({ length: staticPlan.perPage }, (_, i) => {
502
+ const row = Math.floor(i / staticPlan.columns);
503
+ const col = i % staticPlan.columns;
504
+ return createRepeatedSlotElement(
505
+ props,
506
+ createBindingToken(["__slots", i], "", void 0, true),
507
+ i,
508
+ {
509
+ x: col * (staticPlan.slotWidth + staticPlan.gap),
510
+ y: row * (staticPlan.slotHeight + staticPlan.gap),
511
+ width: staticPlan.slotWidth,
512
+ height: staticPlan.slotHeight
513
+ }
514
+ );
515
+ });
516
+ const perPageCompiledTemplate = compilePrecompiledTemplateSync(
517
+ h(
518
+ Document,
519
+ null,
520
+ h(Page, {
521
+ size: [staticPlan.pageWidth, staticPlan.pageHeight],
522
+ dpi: props.page?.dpi,
523
+ style: [{ padding: 0, position: "relative" }, props.page?.style]
524
+ }, ...indexedSlotElements)
525
+ )
526
+ );
527
+ let pageOptimizedStatePromise = null;
528
+ let renderQueue = Promise.resolve();
529
+ const getPageOptimizedState = () => {
530
+ if (!pageOptimizedStatePromise) {
531
+ pageOptimizedStatePromise = initCompiledRenderState(perPageCompiledTemplate).then(
532
+ ({ renderState, incrementalLayoutState }) => ({ renderState, incrementalState: incrementalLayoutState })
533
+ );
534
+ }
535
+ return pageOptimizedStatePromise;
536
+ };
537
+ return Object.assign(
538
+ (rootProps) => {
539
+ const resolvedItems = resolveTrackedPathValue(rootProps, itemsPath);
540
+ if (!Array.isArray(resolvedItems)) {
541
+ throw new Error("jsxpdf.compile.unsupported: RepeatedDocument items must resolve to an array at render time.");
542
+ }
543
+ const allItems = props.fill === "column" ? reorderForColumnFill(resolvedItems, staticPlan.columns, staticPlan.perPage / staticPlan.columns) : resolvedItems;
544
+ const pageCount = Math.ceil(allItems.length / staticPlan.perPage);
545
+ if (allItems.length > 0 && allItems.length % staticPlan.perPage === 0) {
546
+ const result = renderQueue.then(async () => {
547
+ const state = await getPageOptimizedState();
548
+ const pageLayouts = [];
549
+ for (let pageIndex = 0; pageIndex < pageCount; pageIndex++) {
550
+ const pageItems = allItems.slice(pageIndex * staticPlan.perPage, (pageIndex + 1) * staticPlan.perPage);
551
+ const { pageLayout, incrementalState: nextState } = await runSinglePageIncrementalPipeline(
552
+ state.renderState,
553
+ state.incrementalState,
554
+ { __slots: pageItems }
555
+ );
556
+ state.incrementalState = nextState;
557
+ pageLayouts.push(pageLayout);
558
+ }
559
+ const documentProps = resolveBindingValues({
560
+ title: props.title,
561
+ author: props.author,
562
+ subject: props.subject,
563
+ creator: props.creator,
564
+ keywords: props.keywords,
565
+ producer: props.producer,
566
+ language: props.language,
567
+ creationDate: props.creationDate,
568
+ modificationDate: props.modificationDate,
569
+ pdfVersion: props.pdfVersion,
570
+ tagged: props.tagged,
571
+ attachments: props.attachments,
572
+ xmp: props.xmp,
573
+ pdfaid: props.pdfaid,
574
+ pageMode: props.pageMode,
575
+ pageLayout: props.pageLayout
576
+ }, rootProps);
577
+ return buildConcatenatedDocumentLayout(documentProps, pageLayouts);
578
+ });
579
+ renderQueue = result.then(() => {
580
+ }).catch(() => {
581
+ });
582
+ return result;
583
+ }
584
+ const concreteProps = {
585
+ ...resolveBindingValues(props, rootProps),
586
+ items: resolvedItems
587
+ };
588
+ return materializeElement(createRepeatedDocumentElement(concreteProps));
589
+ },
590
+ { bindingPaths: uniqueBindingPaths }
591
+ );
592
+ };
593
+ var createRepeatedDocumentElement = (props) => {
594
+ const concatDocuments = createRepeatedPages(props).map((page) => h(Document, null, page));
595
+ return h(
596
+ Document,
597
+ {
598
+ title: props.title,
599
+ author: props.author,
600
+ subject: props.subject,
601
+ creator: props.creator,
602
+ keywords: props.keywords,
603
+ producer: props.producer,
604
+ language: props.language,
605
+ creationDate: props.creationDate,
606
+ modificationDate: props.modificationDate,
607
+ pdfVersion: props.pdfVersion,
608
+ tagged: props.tagged,
609
+ attachments: props.attachments,
610
+ xmp: props.xmp,
611
+ pdfaid: props.pdfaid,
612
+ pageMode: props.pageMode,
613
+ pageLayout: props.pageLayout,
614
+ concatDocuments
615
+ }
616
+ );
617
+ };
618
+ function RepeatedDocument(props) {
619
+ if (canCompileRepeatedSchema(props)) {
620
+ const schemaRender = createRepeatedSchemaRender(props);
621
+ return h(
622
+ Document,
623
+ {
624
+ title: typeof props.title === "string" ? props.title : void 0,
625
+ __compiledBindingPaths: schemaRender.bindingPaths,
626
+ __compiledSchemaRender: schemaRender
627
+ }
628
+ );
629
+ }
630
+ if (isBindingToken(props.items)) {
631
+ throw new Error("jsxpdf.compile.unsupported: RepeatedDocument requires static layout props during compile.");
632
+ }
633
+ return createRepeatedDocumentElement(props);
634
+ }
635
+ function Repeat(props) {
636
+ return h(Fragment, null, ...createRepeatedPages(props));
637
+ }
638
+ function Concat(props) {
639
+ const { children, ...documentProps } = props;
640
+ return h(
641
+ Document,
642
+ {
643
+ ...documentProps,
644
+ concatDocuments: extractConcatDocuments(children ?? [])
645
+ }
646
+ );
647
+ }
648
+
649
+ // src/index.ts
650
+ import { configureYogaRuntime, getYogaBackend } from "@jsxpdf/layout";
651
+ export {
652
+ Canvas,
653
+ CardSlot,
654
+ Checkbox,
655
+ Circle,
656
+ ClipPath,
657
+ Concat,
658
+ Defs,
659
+ Document2 as Document,
660
+ Ellipse,
661
+ FieldSet,
662
+ Font,
663
+ G,
664
+ Image,
665
+ Line,
666
+ LinearGradient,
667
+ Link,
668
+ List,
669
+ Note,
670
+ Page2 as Page,
671
+ PageBreak,
672
+ Path,
673
+ Polygon,
674
+ Polyline,
675
+ RadialGradient,
676
+ Rect,
677
+ Repeat,
678
+ RepeatedDocument,
679
+ Select,
680
+ Stop,
681
+ StyleSheet,
682
+ Svg,
683
+ Table,
684
+ TableBody,
685
+ TableCell,
686
+ TableFooter,
687
+ TableHead,
688
+ TableRow,
689
+ Text,
690
+ TextInput,
691
+ Tspan,
692
+ View2 as View,
693
+ compile,
694
+ configureYogaRuntime,
695
+ getYogaBackend,
696
+ pdf,
697
+ renderToBlob,
698
+ renderToUint8Array
699
+ };
700
+ //# sourceMappingURL=index.js.map