@pdfme/schemas 6.1.0 → 6.1.1-dev.4

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,379 @@
1
+ import { DEFAULT_FONT_NAME, b64toUint8Array, getDefaultFont, getFallbackFontName, isUrlSafeToFetch, mm2pt, pt2mm, pt2px } from "@pdfme/common";
2
+ import * as fontkit from "fontkit";
3
+ import { Buffer } from "buffer";
4
+ //#region src/text/constants.ts
5
+ var ALIGN_LEFT = "left";
6
+ var ALIGN_CENTER = "center";
7
+ var ALIGN_RIGHT = "right";
8
+ var ALIGN_JUSTIFY = "justify";
9
+ var DEFAULT_ALIGNMENT = ALIGN_LEFT;
10
+ var VERTICAL_ALIGN_MIDDLE = "middle";
11
+ var VERTICAL_ALIGN_BOTTOM = "bottom";
12
+ var DEFAULT_FONT_COLOR = "#000000";
13
+ var PLACEHOLDER_FONT_COLOR = "#A0A0A0";
14
+ var TEXT_FORMAT_PLAIN = "plain";
15
+ var TEXT_FORMAT_INLINE_MARKDOWN = "inline-markdown";
16
+ var DEFAULT_TEXT_FORMAT = TEXT_FORMAT_PLAIN;
17
+ var FONT_VARIANT_FALLBACK_SYNTHETIC = "synthetic";
18
+ var FONT_VARIANT_FALLBACK_PLAIN = "plain";
19
+ var FONT_VARIANT_FALLBACK_ERROR = "error";
20
+ var DEFAULT_FONT_VARIANT_FALLBACK = FONT_VARIANT_FALLBACK_SYNTHETIC;
21
+ var SYNTHETIC_BOLD_OFFSET_RATIO = .03;
22
+ var SYNTHETIC_BOLD_CSS_TEXT_SHADOW = "0.025em 0 0 currentColor";
23
+ var CODE_BACKGROUND_COLOR = "#f2f3f5";
24
+ var CODE_HORIZONTAL_PADDING = 1.5;
25
+ var DYNAMIC_FIT_VERTICAL = "vertical";
26
+ var DYNAMIC_FIT_HORIZONTAL = "horizontal";
27
+ var DEFAULT_DYNAMIC_FIT = DYNAMIC_FIT_VERTICAL;
28
+ var FONT_SIZE_ADJUSTMENT = .25;
29
+ var LINE_START_FORBIDDEN_CHARS = [
30
+ "、",
31
+ "。",
32
+ ",",
33
+ ".",
34
+ "」",
35
+ "』",
36
+ ")",
37
+ "}",
38
+ "】",
39
+ ">",
40
+ "≫",
41
+ "]",
42
+ "・",
43
+ "ー",
44
+ "―",
45
+ "-",
46
+ "!",
47
+ "!",
48
+ "?",
49
+ "?",
50
+ ":",
51
+ ":",
52
+ ";",
53
+ ";",
54
+ "/",
55
+ "/",
56
+ "ゝ",
57
+ "々",
58
+ "〃",
59
+ "ぁ",
60
+ "ぃ",
61
+ "ぅ",
62
+ "ぇ",
63
+ "ぉ",
64
+ "っ",
65
+ "ゃ",
66
+ "ゅ",
67
+ "ょ",
68
+ "ァ",
69
+ "ィ",
70
+ "ゥ",
71
+ "ェ",
72
+ "ォ",
73
+ "ッ",
74
+ "ャ",
75
+ "ュ",
76
+ "ョ"
77
+ ];
78
+ var LINE_END_FORBIDDEN_CHARS = [
79
+ "「",
80
+ "『",
81
+ "(",
82
+ "{",
83
+ "【",
84
+ "<",
85
+ "≪",
86
+ "[",
87
+ "〘",
88
+ "〖",
89
+ "〝",
90
+ "‘",
91
+ "“",
92
+ "⦅",
93
+ "«"
94
+ ];
95
+ //#endregion
96
+ //#region src/text/helper.ts
97
+ var getBrowserVerticalFontAdjustments = (fontKitFont, fontSize, lineHeight, verticalAlignment) => {
98
+ const { ascent, descent, unitsPerEm } = fontKitFont;
99
+ const fontBaseLineHeight = (ascent - descent) / unitsPerEm;
100
+ const topAdjustment = (fontBaseLineHeight * fontSize - fontSize) / 2;
101
+ if (verticalAlignment === "top") return {
102
+ topAdj: pt2px(topAdjustment),
103
+ bottomAdj: 0
104
+ };
105
+ let bottomAdjustment = 0;
106
+ if (lineHeight < fontBaseLineHeight) bottomAdjustment = (fontBaseLineHeight - lineHeight) * fontSize / 2;
107
+ return {
108
+ topAdj: 0,
109
+ bottomAdj: pt2px(bottomAdjustment)
110
+ };
111
+ };
112
+ var getFontDescentInPt = (fontKitFont, fontSize) => {
113
+ const { descent, unitsPerEm } = fontKitFont;
114
+ return descent / unitsPerEm * fontSize;
115
+ };
116
+ var heightOfFontAtSize = (fontKitFont, fontSize) => {
117
+ const { ascent, descent, bbox, unitsPerEm } = fontKitFont;
118
+ const scale = 1e3 / unitsPerEm;
119
+ let height = (ascent || bbox.maxY) * scale - (descent || bbox.minY) * scale;
120
+ height -= Math.abs(descent * scale) || 0;
121
+ return height / 1e3 * fontSize;
122
+ };
123
+ var calculateCharacterSpacing = (textContent, textCharacterSpacing) => {
124
+ return (textContent.length - 1) * textCharacterSpacing;
125
+ };
126
+ var TEXT_WIDTH_CACHE_LIMIT = 5e3;
127
+ var textWidthCache = /* @__PURE__ */ new WeakMap();
128
+ var getTextWidthCache = (fontKitFont) => {
129
+ let cache = textWidthCache.get(fontKitFont);
130
+ if (!cache) {
131
+ cache = /* @__PURE__ */ new Map();
132
+ textWidthCache.set(fontKitFont, cache);
133
+ }
134
+ return cache;
135
+ };
136
+ var widthOfTextAtSize = (text, fontKitFont, fontSize, characterSpacing) => {
137
+ const cache = getTextWidthCache(fontKitFont);
138
+ const cacheKey = `${fontSize}\0${characterSpacing}\0${text}`;
139
+ const cachedWidth = cache.get(cacheKey);
140
+ if (cachedWidth !== void 0) return cachedWidth;
141
+ const { glyphs } = fontKitFont.layout(text);
142
+ const scale = 1e3 / fontKitFont.unitsPerEm;
143
+ const width = glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) * (fontSize / 1e3) + calculateCharacterSpacing(text, characterSpacing);
144
+ if (cache.size >= TEXT_WIDTH_CACHE_LIMIT) cache.clear();
145
+ cache.set(cacheKey, width);
146
+ return width;
147
+ };
148
+ var getFallbackFont = (font) => {
149
+ return font[getFallbackFontName(font)];
150
+ };
151
+ var getCacheKey = (fontName) => `getFontKitFont-${fontName}`;
152
+ var fetchRemoteFontData = async (url) => {
153
+ if (!isUrlSafeToFetch(url)) throw Error("[@pdfme/schemas] Invalid or unsafe URL for font data. Only http: and https: URLs pointing to public hosts are allowed.");
154
+ try {
155
+ const response = await fetch(url);
156
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
157
+ return await response.arrayBuffer();
158
+ } catch (error) {
159
+ const reason = error instanceof Error ? error.message : String(error);
160
+ throw Error(`[@pdfme/schemas] Failed to fetch remote font data from ${url}. ${reason}`);
161
+ }
162
+ };
163
+ var getFontKitFont = async (fontName, font, _cache) => {
164
+ const fntNm = fontName || getFallbackFontName(font);
165
+ const cacheKey = getCacheKey(fntNm);
166
+ if (_cache.has(cacheKey)) return _cache.get(cacheKey);
167
+ let fontData = (font[fntNm] || getFallbackFont(font) || getDefaultFont()[DEFAULT_FONT_NAME]).data;
168
+ if (typeof fontData === "string") if (fontData.startsWith("http")) fontData = await fetchRemoteFontData(fontData);
169
+ else fontData = b64toUint8Array(fontData);
170
+ let fontDataBuffer;
171
+ if (fontData instanceof Buffer) fontDataBuffer = fontData;
172
+ else fontDataBuffer = Buffer.from(fontData);
173
+ const fontKitFont = fontkit.create(fontDataBuffer);
174
+ _cache.set(cacheKey, fontKitFont);
175
+ return fontKitFont;
176
+ };
177
+ /**
178
+ * If using dynamic font size, iteratively increment or decrement the
179
+ * font size to fit the containing box.
180
+ * Calculating space usage involves splitting lines where they exceed
181
+ * the box width based on the proposed size.
182
+ */
183
+ var calculateDynamicFontSize = ({ textSchema, fontKitFont, value, startingFontSize }) => {
184
+ const { fontSize: schemaFontSize, dynamicFontSize: dynamicFontSizeSetting, characterSpacing: schemaCharacterSpacing, width: boxWidth, height: boxHeight, lineHeight = 1 } = textSchema;
185
+ const fontSize = startingFontSize || schemaFontSize || 13;
186
+ if (!dynamicFontSizeSetting) return fontSize;
187
+ if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;
188
+ const characterSpacing = schemaCharacterSpacing ?? 0;
189
+ const paragraphs = value.split("\n");
190
+ let dynamicFontSize = fontSize;
191
+ if (dynamicFontSize < dynamicFontSizeSetting.min) dynamicFontSize = dynamicFontSizeSetting.min;
192
+ else if (dynamicFontSize > dynamicFontSizeSetting.max) dynamicFontSize = dynamicFontSizeSetting.max;
193
+ const dynamicFontFit = dynamicFontSizeSetting.fit ?? "vertical";
194
+ const calculateConstraints = (size) => {
195
+ let totalWidthInMm = 0;
196
+ let totalHeightInMm = 0;
197
+ const boxWidthInPt = mm2pt(boxWidth);
198
+ const firstLineHeightInMm = pt2mm(heightOfFontAtSize(fontKitFont, size) * lineHeight);
199
+ const otherRowHeightInMm = pt2mm(size * lineHeight);
200
+ paragraphs.forEach((paragraph, paraIndex) => {
201
+ getSplittedLinesBySegmenter(paragraph, {
202
+ font: fontKitFont,
203
+ fontSize: size,
204
+ characterSpacing,
205
+ boxWidthInPt
206
+ }).forEach((line, lineIndex) => {
207
+ if (dynamicFontFit === "vertical") {
208
+ const textWidthInMm = pt2mm(widthOfTextAtSize(line.replace("\n", ""), fontKitFont, size, characterSpacing));
209
+ totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
210
+ }
211
+ if (paraIndex + lineIndex === 0) totalHeightInMm += firstLineHeightInMm;
212
+ else totalHeightInMm += otherRowHeightInMm;
213
+ });
214
+ if (dynamicFontFit === "horizontal") {
215
+ const textWidthInMm = pt2mm(widthOfTextAtSize(paragraph, fontKitFont, size, characterSpacing));
216
+ totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);
217
+ }
218
+ });
219
+ return {
220
+ totalWidthInMm,
221
+ totalHeightInMm
222
+ };
223
+ };
224
+ const shouldFontGrowToFit = (totalWidthInMm, totalHeightInMm) => {
225
+ if (dynamicFontSize >= dynamicFontSizeSetting.max) return false;
226
+ if (dynamicFontFit === "horizontal") return totalWidthInMm < boxWidth;
227
+ return totalHeightInMm < boxHeight;
228
+ };
229
+ const shouldFontShrinkToFit = (totalWidthInMm, totalHeightInMm) => {
230
+ if (dynamicFontSize <= dynamicFontSizeSetting.min || dynamicFontSize <= 0) return false;
231
+ return totalWidthInMm > boxWidth || totalHeightInMm > boxHeight;
232
+ };
233
+ let { totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize);
234
+ while (shouldFontGrowToFit(totalWidthInMm, totalHeightInMm)) {
235
+ dynamicFontSize += FONT_SIZE_ADJUSTMENT;
236
+ const { totalWidthInMm: newWidth, totalHeightInMm: newHeight } = calculateConstraints(dynamicFontSize);
237
+ if (newHeight < boxHeight) {
238
+ totalWidthInMm = newWidth;
239
+ totalHeightInMm = newHeight;
240
+ } else {
241
+ dynamicFontSize -= FONT_SIZE_ADJUSTMENT;
242
+ break;
243
+ }
244
+ }
245
+ while (shouldFontShrinkToFit(totalWidthInMm, totalHeightInMm)) {
246
+ dynamicFontSize -= FONT_SIZE_ADJUSTMENT;
247
+ ({totalWidthInMm, totalHeightInMm} = calculateConstraints(dynamicFontSize));
248
+ }
249
+ return dynamicFontSize;
250
+ };
251
+ var splitTextToSize = (arg) => {
252
+ const { value, characterSpacing, fontSize, fontKitFont, boxWidthInPt } = arg;
253
+ const fontWidthCalcValues = {
254
+ font: fontKitFont,
255
+ fontSize,
256
+ characterSpacing,
257
+ boxWidthInPt
258
+ };
259
+ let lines = [];
260
+ value.split(/\r\n|\r|\n|\f|\v/g).forEach((line) => {
261
+ lines = lines.concat(getSplittedLinesBySegmenter(line, fontWidthCalcValues));
262
+ });
263
+ return lines;
264
+ };
265
+ var isFirefox = () => navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
266
+ var wordSegmenter;
267
+ var getWordSegmenter = () => {
268
+ wordSegmenter ?? (wordSegmenter = new Intl.Segmenter(void 0, { granularity: "word" }));
269
+ return wordSegmenter;
270
+ };
271
+ var getSplittedLinesBySegmenter = (line, calcValues) => {
272
+ if (line.trim() === "") return [""];
273
+ const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;
274
+ const iterator = getWordSegmenter().segment(line.trimEnd())[Symbol.iterator]();
275
+ let lines = [];
276
+ let lineCounter = 0;
277
+ let currentTextSize = 0;
278
+ while (true) {
279
+ const chunk = iterator.next();
280
+ if (chunk.done) break;
281
+ const segment = chunk.value.segment;
282
+ const textWidth = widthOfTextAtSize(segment, font, fontSize, characterSpacing);
283
+ if (currentTextSize + textWidth <= boxWidthInPt) if (lines[lineCounter]) {
284
+ lines[lineCounter] += segment;
285
+ currentTextSize += textWidth + characterSpacing;
286
+ } else {
287
+ lines[lineCounter] = segment;
288
+ currentTextSize = textWidth + characterSpacing;
289
+ }
290
+ else if (segment.trim() === "") {
291
+ lines[++lineCounter] = "";
292
+ currentTextSize = 0;
293
+ } else if (textWidth <= boxWidthInPt) {
294
+ lines[++lineCounter] = segment;
295
+ currentTextSize = textWidth + characterSpacing;
296
+ } else for (const char of segment) {
297
+ const size = widthOfTextAtSize(char, font, fontSize, characterSpacing);
298
+ if (currentTextSize + size <= boxWidthInPt) if (lines[lineCounter]) {
299
+ lines[lineCounter] += char;
300
+ currentTextSize += size + characterSpacing;
301
+ } else {
302
+ lines[lineCounter] = char;
303
+ currentTextSize = size + characterSpacing;
304
+ }
305
+ else {
306
+ lines[++lineCounter] = char;
307
+ currentTextSize = size + characterSpacing;
308
+ }
309
+ }
310
+ }
311
+ if (lines.some(containsJapanese)) return adjustEndOfLine(filterEndJP(filterStartJP(lines)));
312
+ else return adjustEndOfLine(lines);
313
+ };
314
+ var adjustEndOfLine = (lines) => {
315
+ return lines.map((line, index) => {
316
+ if (index === lines.length - 1) return line.trimEnd() + "\n";
317
+ else return line.trimEnd();
318
+ });
319
+ };
320
+ function containsJapanese(text) {
321
+ return /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u.test(text);
322
+ }
323
+ var filterStartJP = (lines) => {
324
+ const filtered = [];
325
+ let charToAppend = null;
326
+ lines.slice().reverse().forEach((line) => {
327
+ if (line.trim().length === 0) filtered.push("");
328
+ else {
329
+ const charAtStart = line.charAt(0);
330
+ if (LINE_START_FORBIDDEN_CHARS.includes(charAtStart)) if (line.trim().length === 1) {
331
+ filtered.push(line);
332
+ charToAppend = null;
333
+ } else {
334
+ if (charToAppend) filtered.push(line.slice(1) + charToAppend);
335
+ else filtered.push(line.slice(1));
336
+ charToAppend = charAtStart;
337
+ }
338
+ else if (charToAppend) {
339
+ filtered.push(line + charToAppend);
340
+ charToAppend = null;
341
+ } else filtered.push(line);
342
+ }
343
+ });
344
+ if (charToAppend) {
345
+ const firstItem = filtered.length > 0 ? filtered[0] : "";
346
+ return [String(charToAppend) + String(firstItem), ...filtered.slice(1)].reverse();
347
+ } else return filtered.reverse();
348
+ };
349
+ var filterEndJP = (lines) => {
350
+ const filtered = [];
351
+ let charToPrepend = null;
352
+ lines.forEach((line) => {
353
+ if (line.trim().length === 0) filtered.push("");
354
+ else {
355
+ const chartAtEnd = line.slice(-1);
356
+ if (LINE_END_FORBIDDEN_CHARS.includes(chartAtEnd)) if (line.trim().length === 1) {
357
+ filtered.push(line);
358
+ charToPrepend = null;
359
+ } else {
360
+ if (charToPrepend) filtered.push(charToPrepend + line.slice(0, -1));
361
+ else filtered.push(line.slice(0, -1));
362
+ charToPrepend = chartAtEnd;
363
+ }
364
+ else if (charToPrepend) {
365
+ filtered.push(charToPrepend + line);
366
+ charToPrepend = null;
367
+ } else filtered.push(line);
368
+ }
369
+ });
370
+ if (charToPrepend) {
371
+ const lastItem = filtered.length > 0 ? filtered[filtered.length - 1] : "";
372
+ const combinedItem = String(lastItem) + String(charToPrepend);
373
+ return [...filtered.slice(0, -1), combinedItem];
374
+ } else return filtered;
375
+ };
376
+ //#endregion
377
+ export { TEXT_FORMAT_INLINE_MARKDOWN as A, FONT_SIZE_ADJUSTMENT as C, PLACEHOLDER_FONT_COLOR as D, FONT_VARIANT_FALLBACK_SYNTHETIC as E, VERTICAL_ALIGN_BOTTOM as M, VERTICAL_ALIGN_MIDDLE as N, SYNTHETIC_BOLD_CSS_TEXT_SHADOW as O, DYNAMIC_FIT_VERTICAL as S, FONT_VARIANT_FALLBACK_PLAIN as T, DEFAULT_DYNAMIC_FIT as _, getFontKitFont as a, DEFAULT_TEXT_FORMAT as b, splitTextToSize as c, ALIGN_JUSTIFY as d, ALIGN_LEFT as f, DEFAULT_ALIGNMENT as g, CODE_HORIZONTAL_PADDING as h, getFontDescentInPt as i, TEXT_FORMAT_PLAIN as j, SYNTHETIC_BOLD_OFFSET_RATIO as k, widthOfTextAtSize as l, CODE_BACKGROUND_COLOR as m, fetchRemoteFontData as n, heightOfFontAtSize as o, ALIGN_RIGHT as p, getBrowserVerticalFontAdjustments as r, isFirefox as s, calculateDynamicFontSize as t, ALIGN_CENTER as u, DEFAULT_FONT_COLOR as v, FONT_VARIANT_FALLBACK_ERROR as w, DYNAMIC_FIT_HORIZONTAL as x, DEFAULT_FONT_VARIANT_FALLBACK as y };
378
+
379
+ //# sourceMappingURL=helper-6FilIoVM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper-6FilIoVM.js","names":[],"sources":["../src/text/constants.ts","../src/text/helper.ts"],"sourcesContent":["import {\n ALIGNMENT,\n VERTICAL_ALIGNMENT,\n DYNAMIC_FONT_SIZE_FIT,\n TEXT_FORMAT,\n FONT_VARIANT_FALLBACK,\n} from './types.js';\n\nexport const DEFAULT_FONT_SIZE = 13;\n\nexport const ALIGN_LEFT = 'left' as ALIGNMENT;\nexport const ALIGN_CENTER = 'center' as ALIGNMENT;\nexport const ALIGN_RIGHT = 'right' as ALIGNMENT;\nexport const ALIGN_JUSTIFY = 'justify' as ALIGNMENT;\nexport const DEFAULT_ALIGNMENT = ALIGN_LEFT;\nexport const VERTICAL_ALIGN_TOP = 'top' as VERTICAL_ALIGNMENT;\nexport const VERTICAL_ALIGN_MIDDLE = 'middle' as VERTICAL_ALIGNMENT;\nexport const VERTICAL_ALIGN_BOTTOM = 'bottom' as VERTICAL_ALIGNMENT;\nexport const DEFAULT_VERTICAL_ALIGNMENT = VERTICAL_ALIGN_TOP;\nexport const DEFAULT_LINE_HEIGHT = 1;\nexport const DEFAULT_CHARACTER_SPACING = 0;\nexport const DEFAULT_FONT_COLOR = '#000000';\nexport const PLACEHOLDER_FONT_COLOR = '#A0A0A0';\nexport const TEXT_FORMAT_PLAIN = 'plain' as const satisfies TEXT_FORMAT;\nexport const TEXT_FORMAT_INLINE_MARKDOWN = 'inline-markdown' as const satisfies TEXT_FORMAT;\nexport const DEFAULT_TEXT_FORMAT = TEXT_FORMAT_PLAIN;\nexport const FONT_VARIANT_FALLBACK_SYNTHETIC =\n 'synthetic' as const satisfies FONT_VARIANT_FALLBACK;\nexport const FONT_VARIANT_FALLBACK_PLAIN = 'plain' as const satisfies FONT_VARIANT_FALLBACK;\nexport const FONT_VARIANT_FALLBACK_ERROR = 'error' as const satisfies FONT_VARIANT_FALLBACK;\nexport const DEFAULT_FONT_VARIANT_FALLBACK = FONT_VARIANT_FALLBACK_SYNTHETIC;\nexport const SYNTHETIC_BOLD_OFFSET_RATIO = 0.03;\nexport const SYNTHETIC_BOLD_PDF_EXTRA_DRAWS = 2;\nexport const SYNTHETIC_BOLD_CSS_TEXT_SHADOW = '0.025em 0 0 currentColor';\nexport const SYNTHETIC_ITALIC_SKEW_DEGREES = 12;\nexport const CODE_BACKGROUND_COLOR = '#f2f3f5';\nexport const CODE_HORIZONTAL_PADDING = 1.5;\nexport const DYNAMIC_FIT_VERTICAL = 'vertical' as DYNAMIC_FONT_SIZE_FIT;\nexport const DYNAMIC_FIT_HORIZONTAL = 'horizontal' as DYNAMIC_FONT_SIZE_FIT;\nexport const DEFAULT_DYNAMIC_FIT = DYNAMIC_FIT_VERTICAL;\nexport const DEFAULT_DYNAMIC_MIN_FONT_SIZE = 4;\n\nexport const DEFAULT_DYNAMIC_MAX_FONT_SIZE = 72;\nexport const FONT_SIZE_ADJUSTMENT = 0.25;\n\nexport const LINE_START_FORBIDDEN_CHARS = [\n // 句読点\n '、',\n '。',\n ',',\n '.',\n\n // 閉じカッコ類\n '」',\n '』',\n ')',\n '}',\n '】',\n '>',\n '≫',\n ']',\n\n // 記号\n '・',\n 'ー',\n '―',\n '-',\n\n // 約物\n '!',\n '!',\n '?',\n '?',\n ':',\n ':',\n ';',\n ';',\n '/',\n '/',\n\n // 繰り返し記号\n 'ゝ',\n '々',\n '〃',\n\n // 拗音・促音(小書きのかな)\n 'ぁ',\n 'ぃ',\n 'ぅ',\n 'ぇ',\n 'ぉ',\n 'っ',\n 'ゃ',\n 'ゅ',\n 'ょ',\n 'ァ',\n 'ィ',\n 'ゥ',\n 'ェ',\n 'ォ',\n 'ッ',\n 'ャ',\n 'ュ',\n 'ョ',\n];\n\nexport const LINE_END_FORBIDDEN_CHARS = [\n // 始め括弧類\n '「',\n '『',\n '(',\n '{',\n '【',\n '<',\n '≪',\n '[',\n '〘',\n '〖',\n '〝',\n '‘',\n '“',\n '⦅',\n '«',\n];\n","import * as fontkit from 'fontkit';\nimport type { Font as FontKitFont } from 'fontkit';\nimport {\n b64toUint8Array,\n mm2pt,\n pt2mm,\n pt2px,\n Font,\n getFallbackFontName,\n getDefaultFont,\n DEFAULT_FONT_NAME,\n isUrlSafeToFetch,\n} from '@pdfme/common';\nimport { Buffer } from 'buffer';\nimport type { TextSchema, FontWidthCalcValues } from './types.js';\nimport {\n DEFAULT_FONT_SIZE,\n DEFAULT_CHARACTER_SPACING,\n DEFAULT_LINE_HEIGHT,\n FONT_SIZE_ADJUSTMENT,\n DEFAULT_DYNAMIC_FIT,\n DYNAMIC_FIT_HORIZONTAL,\n DYNAMIC_FIT_VERTICAL,\n VERTICAL_ALIGN_TOP,\n LINE_END_FORBIDDEN_CHARS,\n LINE_START_FORBIDDEN_CHARS,\n} from './constants.js';\n\nexport const getBrowserVerticalFontAdjustments = (\n fontKitFont: FontKitFont,\n fontSize: number,\n lineHeight: number,\n verticalAlignment: string,\n) => {\n const { ascent, descent, unitsPerEm } = fontKitFont;\n\n // Fonts have a designed line height that the browser renders when using `line-height: normal`\n const fontBaseLineHeight = (ascent - descent) / unitsPerEm;\n\n // For vertical alignment top\n // To achieve consistent positioning between browser and PDF, we apply the difference between\n // the font's actual height and the font size in pixels.\n // Browsers middle the font within this height, so we only need half of it to apply to the top.\n // This means the font renders a bit lower in the browser, but achieves PDF alignment\n const topAdjustment = (fontBaseLineHeight * fontSize - fontSize) / 2;\n\n if (verticalAlignment === VERTICAL_ALIGN_TOP) {\n return { topAdj: pt2px(topAdjustment), bottomAdj: 0 };\n }\n\n // For vertical alignment bottom and middle\n // When browsers render text in a non-form element (such as a <div>), some of the text may be\n // lowered below and outside the containing element if the line height used is less than\n // the base line-height of the font.\n // This behaviour does not happen in a <textarea> though, so we need to adjust the positioning\n // for consistency between editing and viewing to stop text jumping up and down.\n // This portion of text is half of the difference between the base line height and the used\n // line height. If using the same or higher line-height than the base font, then line-height\n // takes over in the browser and this adjustment is not needed.\n // Unlike the top adjustment - this is only driven by browser behaviour, not PDF alignment.\n let bottomAdjustment = 0;\n if (lineHeight < fontBaseLineHeight) {\n bottomAdjustment = ((fontBaseLineHeight - lineHeight) * fontSize) / 2;\n }\n\n return { topAdj: 0, bottomAdj: pt2px(bottomAdjustment) };\n};\n\nexport const getFontDescentInPt = (fontKitFont: FontKitFont, fontSize: number) => {\n const { descent, unitsPerEm } = fontKitFont;\n\n return (descent / unitsPerEm) * fontSize;\n};\n\nexport const heightOfFontAtSize = (fontKitFont: FontKitFont, fontSize: number) => {\n const { ascent, descent, bbox, unitsPerEm } = fontKitFont;\n\n const scale = 1000 / unitsPerEm;\n const yTop = (ascent || bbox.maxY) * scale;\n const yBottom = (descent || bbox.minY) * scale;\n\n let height = yTop - yBottom;\n height -= Math.abs(descent * scale) || 0;\n\n return (height / 1000) * fontSize;\n};\n\nconst calculateCharacterSpacing = (textContent: string, textCharacterSpacing: number) => {\n return (textContent.length - 1) * textCharacterSpacing;\n};\n\nconst TEXT_WIDTH_CACHE_LIMIT = 5000;\nconst textWidthCache = new WeakMap<FontKitFont, Map<string, number>>();\n\nconst getTextWidthCache = (fontKitFont: FontKitFont) => {\n let cache = textWidthCache.get(fontKitFont);\n if (!cache) {\n cache = new Map<string, number>();\n textWidthCache.set(fontKitFont, cache);\n }\n return cache;\n};\n\nexport const widthOfTextAtSize = (\n text: string,\n fontKitFont: FontKitFont,\n fontSize: number,\n characterSpacing: number,\n) => {\n const cache = getTextWidthCache(fontKitFont);\n const cacheKey = `${fontSize}\\0${characterSpacing}\\0${text}`;\n const cachedWidth = cache.get(cacheKey);\n if (cachedWidth !== undefined) {\n return cachedWidth;\n }\n\n const { glyphs } = fontKitFont.layout(text);\n const scale = 1000 / fontKitFont.unitsPerEm;\n const standardWidth =\n glyphs.reduce((totalWidth, glyph) => totalWidth + glyph.advanceWidth * scale, 0) *\n (fontSize / 1000);\n const width = standardWidth + calculateCharacterSpacing(text, characterSpacing);\n\n if (cache.size >= TEXT_WIDTH_CACHE_LIMIT) {\n cache.clear();\n }\n cache.set(cacheKey, width);\n\n return width;\n};\n\nconst getFallbackFont = (font: Font) => {\n const fallbackFontName = getFallbackFontName(font);\n return font[fallbackFontName];\n};\n\nconst getCacheKey = (fontName: string) => `getFontKitFont-${fontName}`;\n\nexport const fetchRemoteFontData = async (url: string): Promise<ArrayBuffer> => {\n if (!isUrlSafeToFetch(url)) {\n throw Error(\n '[@pdfme/schemas] Invalid or unsafe URL for font data. Only http: and https: URLs pointing to public hosts are allowed.',\n );\n }\n\n try {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`);\n }\n\n return await response.arrayBuffer();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw Error(`[@pdfme/schemas] Failed to fetch remote font data from ${url}. ${reason}`);\n }\n};\n\nexport const getFontKitFont = async (\n fontName: string | undefined,\n font: Font,\n _cache: Map<string | number, fontkit.Font>,\n) => {\n const fntNm = fontName || getFallbackFontName(font);\n const cacheKey = getCacheKey(fntNm);\n if (_cache.has(cacheKey)) {\n return _cache.get(cacheKey) as fontkit.Font;\n }\n\n const currentFont = font[fntNm] || getFallbackFont(font) || getDefaultFont()[DEFAULT_FONT_NAME];\n let fontData = currentFont.data;\n if (typeof fontData === 'string') {\n if (fontData.startsWith('http')) {\n fontData = await fetchRemoteFontData(fontData);\n } else {\n fontData = b64toUint8Array(fontData);\n }\n }\n\n // Convert fontData to Buffer if it's not already a Buffer\n let fontDataBuffer: Buffer;\n if (fontData instanceof Buffer) {\n fontDataBuffer = fontData;\n } else {\n fontDataBuffer = Buffer.from(fontData as ArrayBufferLike);\n }\n const fontKitFont = fontkit.create(fontDataBuffer) as fontkit.Font;\n _cache.set(cacheKey, fontKitFont);\n\n return fontKitFont;\n};\n\nconst isTextExceedingBoxWidth = (text: string, calcValues: FontWidthCalcValues) => {\n const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;\n const textWidth = widthOfTextAtSize(text, font, fontSize, characterSpacing);\n return textWidth > boxWidthInPt;\n};\n\n/**\n * Incrementally checks the current line for its real length\n * and returns the position where it exceeds the box width.\n * Returns `null` to indicate if textLine is shorter than the available box.\n */\nconst getOverPosition = (textLine: string, calcValues: FontWidthCalcValues) => {\n for (let i = 0; i <= textLine.length; i++) {\n if (isTextExceedingBoxWidth(textLine.slice(0, i + 1), calcValues)) {\n return i;\n }\n }\n\n return null;\n};\n\n/**\n * Line breakable chars depend on the language and writing system.\n * Western writing systems typically use spaces and hyphens as line breakable chars.\n * Other writing systems often break on word boundaries so the following\n * does not negatively impact them.\n * However, this might need to be revisited for broader language support.\n */\nconst isLineBreakableChar = (char: string) => {\n const lineBreakableChars = [' ', '-', '\\u2014', '\\u2013'];\n return lineBreakableChars.includes(char);\n};\n\n/**\n * Gets the position of the split. Splits the exceeding line at\n * the last breakable char prior to it exceeding the bounding box width.\n */\nconst getSplitPosition = (textLine: string, calcValues: FontWidthCalcValues) => {\n const overPos = getOverPosition(textLine, calcValues);\n if (overPos === null) return textLine.length; // input line is shorter than the available space\n\n if (textLine[overPos] === ' ') {\n // if the character immediately beyond the boundary is a space, split\n return overPos;\n }\n\n let overPosTmp = overPos - 1;\n while (overPosTmp >= 0) {\n if (isLineBreakableChar(textLine[overPosTmp])) {\n return overPosTmp + 1;\n }\n overPosTmp--;\n }\n\n // For very long lines with no breakable chars use the original overPos\n return overPos;\n};\n\n/**\n * Recursively splits the line at getSplitPosition.\n * If there is some leftover, split the rest again in the same manner.\n */\nexport const getSplittedLines = (textLine: string, calcValues: FontWidthCalcValues): string[] => {\n const splitPos = getSplitPosition(textLine, calcValues);\n const splittedLine = textLine.substring(0, splitPos).trimEnd();\n const rest = textLine.substring(splitPos).trimStart();\n\n if (rest === textLine) {\n // if we went so small that we want to split on the first char\n // then end recursion to avoid infinite loop\n return [textLine];\n }\n\n if (rest.length === 0) {\n // end recursion if there is no leftover\n return [splittedLine];\n }\n\n return [splittedLine, ...getSplittedLines(rest, calcValues)];\n};\n\n/**\n * If using dynamic font size, iteratively increment or decrement the\n * font size to fit the containing box.\n * Calculating space usage involves splitting lines where they exceed\n * the box width based on the proposed size.\n */\nexport const calculateDynamicFontSize = ({\n textSchema,\n fontKitFont,\n value,\n startingFontSize,\n}: {\n textSchema: TextSchema;\n fontKitFont: FontKitFont;\n value: string;\n startingFontSize?: number | undefined;\n}) => {\n const {\n fontSize: schemaFontSize,\n dynamicFontSize: dynamicFontSizeSetting,\n characterSpacing: schemaCharacterSpacing,\n width: boxWidth,\n height: boxHeight,\n lineHeight = DEFAULT_LINE_HEIGHT,\n } = textSchema;\n const fontSize = startingFontSize || schemaFontSize || DEFAULT_FONT_SIZE;\n if (!dynamicFontSizeSetting) return fontSize;\n if (dynamicFontSizeSetting.max < dynamicFontSizeSetting.min) return fontSize;\n\n const characterSpacing = schemaCharacterSpacing ?? DEFAULT_CHARACTER_SPACING;\n const paragraphs = value.split('\\n');\n\n let dynamicFontSize = fontSize;\n if (dynamicFontSize < dynamicFontSizeSetting.min) {\n dynamicFontSize = dynamicFontSizeSetting.min;\n } else if (dynamicFontSize > dynamicFontSizeSetting.max) {\n dynamicFontSize = dynamicFontSizeSetting.max;\n }\n const dynamicFontFit = dynamicFontSizeSetting.fit ?? DEFAULT_DYNAMIC_FIT;\n\n const calculateConstraints = (size: number) => {\n let totalWidthInMm = 0;\n let totalHeightInMm = 0;\n\n const boxWidthInPt = mm2pt(boxWidth);\n const firstLineTextHeight = heightOfFontAtSize(fontKitFont, size);\n const firstLineHeightInMm = pt2mm(firstLineTextHeight * lineHeight);\n const otherRowHeightInMm = pt2mm(size * lineHeight);\n\n paragraphs.forEach((paragraph, paraIndex) => {\n const lines = getSplittedLinesBySegmenter(paragraph, {\n font: fontKitFont,\n fontSize: size,\n characterSpacing,\n boxWidthInPt,\n });\n\n lines.forEach((line, lineIndex) => {\n if (dynamicFontFit === DYNAMIC_FIT_VERTICAL) {\n // For vertical fit we want to consider the width of text lines where we detect a split\n const textWidth = widthOfTextAtSize(\n line.replace('\\n', ''),\n fontKitFont,\n size,\n characterSpacing,\n );\n const textWidthInMm = pt2mm(textWidth);\n totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);\n }\n\n if (paraIndex + lineIndex === 0) {\n totalHeightInMm += firstLineHeightInMm;\n } else {\n totalHeightInMm += otherRowHeightInMm;\n }\n });\n if (dynamicFontFit === DYNAMIC_FIT_HORIZONTAL) {\n // For horizontal fit we want to consider the line's width 'unsplit'\n const textWidth = widthOfTextAtSize(paragraph, fontKitFont, size, characterSpacing);\n const textWidthInMm = pt2mm(textWidth);\n totalWidthInMm = Math.max(totalWidthInMm, textWidthInMm);\n }\n });\n\n return { totalWidthInMm, totalHeightInMm };\n };\n\n const shouldFontGrowToFit = (totalWidthInMm: number, totalHeightInMm: number) => {\n if (dynamicFontSize >= dynamicFontSizeSetting.max) {\n return false;\n }\n if (dynamicFontFit === DYNAMIC_FIT_HORIZONTAL) {\n return totalWidthInMm < boxWidth;\n }\n return totalHeightInMm < boxHeight;\n };\n\n const shouldFontShrinkToFit = (totalWidthInMm: number, totalHeightInMm: number) => {\n if (dynamicFontSize <= dynamicFontSizeSetting.min || dynamicFontSize <= 0) {\n return false;\n }\n return totalWidthInMm > boxWidth || totalHeightInMm > boxHeight;\n };\n\n let { totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize);\n\n // Attempt to increase the font size up to desired fit\n while (shouldFontGrowToFit(totalWidthInMm, totalHeightInMm)) {\n dynamicFontSize += FONT_SIZE_ADJUSTMENT;\n const { totalWidthInMm: newWidth, totalHeightInMm: newHeight } =\n calculateConstraints(dynamicFontSize);\n\n if (newHeight < boxHeight) {\n totalWidthInMm = newWidth;\n totalHeightInMm = newHeight;\n } else {\n dynamicFontSize -= FONT_SIZE_ADJUSTMENT;\n break;\n }\n }\n\n // Attempt to decrease the font size down to desired fit\n while (shouldFontShrinkToFit(totalWidthInMm, totalHeightInMm)) {\n dynamicFontSize -= FONT_SIZE_ADJUSTMENT;\n ({ totalWidthInMm, totalHeightInMm } = calculateConstraints(dynamicFontSize));\n }\n\n return dynamicFontSize;\n};\n\nexport const splitTextToSize = (arg: {\n value: string;\n characterSpacing: number;\n boxWidthInPt: number;\n fontSize: number;\n fontKitFont: fontkit.Font;\n}) => {\n const { value, characterSpacing, fontSize, fontKitFont, boxWidthInPt } = arg;\n const fontWidthCalcValues: FontWidthCalcValues = {\n font: fontKitFont,\n fontSize,\n characterSpacing,\n boxWidthInPt,\n };\n let lines: string[] = [];\n value.split(/\\r\\n|\\r|\\n|\\f|\\v/g).forEach((line: string) => {\n lines = lines.concat(getSplittedLinesBySegmenter(line, fontWidthCalcValues));\n });\n return lines;\n};\nexport const isFirefox = () => navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\nlet wordSegmenter: Intl.Segmenter | undefined;\n\nconst getWordSegmenter = () => {\n wordSegmenter ??= new Intl.Segmenter(undefined, { granularity: 'word' });\n return wordSegmenter;\n};\n\nconst getSplittedLinesBySegmenter = (line: string, calcValues: FontWidthCalcValues): string[] => {\n // nothing to process but need to keep this for new lines.\n if (line.trim() === '') {\n return [''];\n }\n\n const { font, fontSize, characterSpacing, boxWidthInPt } = calcValues;\n const segmenter = getWordSegmenter();\n const iterator = segmenter.segment(line.trimEnd())[Symbol.iterator]();\n\n let lines: string[] = [];\n let lineCounter: number = 0;\n let currentTextSize: number = 0;\n\n while (true) {\n const chunk = iterator.next();\n if (chunk.done) break;\n const segment = chunk.value.segment;\n const textWidth = widthOfTextAtSize(segment, font, fontSize, characterSpacing);\n if (currentTextSize + textWidth <= boxWidthInPt) {\n // the size of boxWidth is large enough to add the segment\n if (lines[lineCounter]) {\n lines[lineCounter] += segment;\n currentTextSize += textWidth + characterSpacing;\n } else {\n lines[lineCounter] = segment;\n currentTextSize = textWidth + characterSpacing;\n }\n } else if (segment.trim() === '') {\n // a segment can be consist of multiple spaces like ' '\n // if they overflow the box, treat them as a line break and move to the next line\n lines[++lineCounter] = '';\n currentTextSize = 0;\n } else if (textWidth <= boxWidthInPt) {\n // the segment is small enough to be added to the next line\n lines[++lineCounter] = segment;\n currentTextSize = textWidth + characterSpacing;\n } else {\n // the segment is too large to fit in the boxWidth, we wrap the segment\n for (const char of segment) {\n const size = widthOfTextAtSize(char, font, fontSize, characterSpacing);\n if (currentTextSize + size <= boxWidthInPt) {\n if (lines[lineCounter]) {\n lines[lineCounter] += char;\n currentTextSize += size + characterSpacing;\n } else {\n lines[lineCounter] = char;\n currentTextSize = size + characterSpacing;\n }\n } else {\n lines[++lineCounter] = char;\n currentTextSize = size + characterSpacing;\n }\n }\n }\n }\n\n if (lines.some(containsJapanese)) {\n return adjustEndOfLine(filterEndJP(filterStartJP(lines)));\n } else {\n return adjustEndOfLine(lines);\n }\n};\n\n// add a newline if the line is the end of the paragraph\nconst adjustEndOfLine = (lines: string[]): string[] => {\n return lines.map((line, index) => {\n if (index === lines.length - 1) {\n return line.trimEnd() + '\\n';\n } else {\n return line.trimEnd();\n }\n });\n};\n\nfunction containsJapanese(text: string): boolean {\n return /[\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Han}]/u.test(text);\n}\n//\n// 日本語禁則処理\n//\n// https://www.morisawa.co.jp/blogs/MVP/8760\n//\n// 行頭禁則\nexport const filterStartJP = (lines: string[]): string[] => {\n const filtered: string[] = [];\n let charToAppend: string | null = null;\n\n lines\n .slice()\n .reverse()\n .forEach((line) => {\n if (line.trim().length === 0) {\n filtered.push('');\n } else {\n const charAtStart: string = line.charAt(0);\n if (LINE_START_FORBIDDEN_CHARS.includes(charAtStart)) {\n if (line.trim().length === 1) {\n filtered.push(line);\n charToAppend = null;\n } else {\n if (charToAppend) {\n filtered.push(line.slice(1) + charToAppend);\n } else {\n filtered.push(line.slice(1));\n }\n charToAppend = charAtStart;\n }\n } else {\n if (charToAppend) {\n filtered.push(line + charToAppend);\n charToAppend = null;\n } else {\n filtered.push(line);\n }\n }\n }\n });\n\n if (charToAppend) {\n // Handle the case where filtered might be empty\n const firstItem = filtered.length > 0 ? filtered[0] : '';\n // Ensure we're concatenating strings\n const combinedItem = String(charToAppend) + String(firstItem);\n return [combinedItem, ...filtered.slice(1)].reverse();\n } else {\n return filtered.reverse();\n }\n};\n\n// 行末禁則\nexport const filterEndJP = (lines: string[]): string[] => {\n const filtered: string[] = [];\n let charToPrepend: string | null = null;\n\n lines.forEach((line) => {\n if (line.trim().length === 0) {\n filtered.push('');\n } else {\n const chartAtEnd = line.slice(-1);\n\n if (LINE_END_FORBIDDEN_CHARS.includes(chartAtEnd)) {\n if (line.trim().length === 1) {\n filtered.push(line);\n charToPrepend = null;\n } else {\n if (charToPrepend) {\n filtered.push(charToPrepend + line.slice(0, -1));\n } else {\n filtered.push(line.slice(0, -1));\n }\n charToPrepend = chartAtEnd;\n }\n } else {\n if (charToPrepend) {\n filtered.push(charToPrepend + line);\n charToPrepend = null;\n } else {\n filtered.push(line);\n }\n }\n }\n });\n\n if (charToPrepend) {\n // Handle the case where filtered might be empty\n const lastItem = filtered.length > 0 ? filtered[filtered.length - 1] : '';\n // Ensure we're concatenating strings\n const combinedItem = String(lastItem) + String(charToPrepend);\n return [...filtered.slice(0, -1), combinedItem];\n } else {\n return filtered;\n }\n};\n"],"mappings":";;;;AAUA,IAAa,aAAa;AAC1B,IAAa,eAAe;AAC5B,IAAa,c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AO,aAAa;AAClC,mBAAe;SAEf,UAAS,KAAK,KAAK;;GAIzB;AAEJ,KAAI,cAAc;EAEhB,MAAM,YAAY,SAAS,SAAS,IAAI,SAAS,KAAK;AAGtD,SAAO,CADc,OAAO,aAAa,GAAG,OAAO,UAAU,EACvC,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,SAAS;OAErD,QAAO,SAAS,SAAS;;AAK7B,IAAa,eAAe,UAA8B;CACxD,MAAM,WAAqB,EAAE;CAC7B,IAAI,gBAA+B;AAEnC,OAAM,SAAS,SAAS;AACtB,MAAI,KAAK,MAAM,CAAC,WAAW,EACzB,UAAS,KAAK,GAAG;OACZ;GACL,MAAM,aAAa,KAAK,MAAM,GAAG;AAEjC,OAAI,yBAAyB,SAAS,WAAW,CAC/C,KAAI,KAAK,MAAM,CAAC,WAAW,GAAG;AAC5B,aAAS,KAAK,KAAK;AACnB,oBAAgB;UACX;AACL,QAAI,cACF,UAAS,KAAK,gBAAgB,KAAK,MAAM,GAAG,GAAG,CAAC;QAEhD,UAAS,KAAK,KAAK,MAAM,GAAG,GAAG,CAAC;AAElC,oBAAgB;;YAGd,eAAe;AACjB,aAAS,KAAK,gBAAgB,KAAK;AACnC,oBAAgB;SAEhB,UAAS,KAAK,KAAK;;GAIzB;AAEF,KAAI,eAAe;EAEjB,MAAM,WAAW,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,KAAK;EAEvE,MAAM,eAAe,OAAO,SAAS,GAAG,OAAO,cAAc;AAC7D,SAAO,CAAC,GAAG,SAAS,MAAM,GAAG,GAAG,EAAE,aAAa;OAE/C,QAAO"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import multiVariableText from './multiVariableText/index.js';
2
2
  import text from './text/index.js';
3
+ import list from './list/index.js';
3
4
  import image from './graphics/image.js';
4
5
  import signature from './graphics/signature.js';
5
6
  import svg from './graphics/svg.js';
@@ -14,5 +15,6 @@ import select from './select/index.js';
14
15
  import radioGroup from './radioGroup/index.js';
15
16
  import checkbox from './checkbox/index.js';
16
17
  export { builtInPlugins } from './builtins.js';
17
- export { text, multiVariableText, image, signature, svg, table, barcodes, line, rectangle, ellipse, dateTime, date, time, select, radioGroup, checkbox, };
18
- export { getDynamicHeightsForTable } from './tables.js';
18
+ export { text, multiVariableText, list, image, signature, svg, table, barcodes, line, rectangle, ellipse, dateTime, date, time, select, radioGroup, checkbox, };
19
+ export { getDynamicHeightsForTable, getDynamicLayoutForTable } from './tables.js';
20
+ export { getDynamicLayoutForList } from './lists.js';