@lpdfio/lpdf 0.28.1 → 0.30.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/layout.js CHANGED
@@ -22,6 +22,17 @@ function frame(attrs, nodes = []) {
22
22
  function link(attrs, nodes = []) {
23
23
  return makeContainer('link', attrs, nodes);
24
24
  }
25
+ /**
26
+ * A list of items, which are `li` nodes. A bullet list marks each item with a shape; with `type: 'number'` the
27
+ * engine numbers them, in the `format` given, and the numbers follow the items that `data-source` makes.
28
+ */
29
+ function list(attrs, nodes = []) {
30
+ return { type: 'list', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
31
+ }
32
+ /** An item of a list. Its words go in a `text`; a `list` inside it is a list under the item. */
33
+ function li(attrs, nodes = []) {
34
+ return { type: 'li', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
35
+ }
25
36
  function table(attrs, nodes = []) {
26
37
  return { type: 'table', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
27
38
  }
@@ -37,15 +48,38 @@ function td(attrs, nodes = []) {
37
48
  function text(attrs, nodes = []) {
38
49
  return { type: 'text', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
39
50
  }
51
+ /**
52
+ * Code in a box that fills the width and grows with its lines. The strings are kept as they are written: every
53
+ * space, and a new line wherever a `\n` is. A line longer than the box wraps. The spans color parts of it.
54
+ */
55
+ function code(attrs, nodes = []) {
56
+ return { type: 'code', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
57
+ }
40
58
  function span(attrs, nodes = []) {
41
59
  return { type: 'span', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
42
60
  }
61
+ /** A run of code in the nodes of a text: its words in the code font on a tint. */
62
+ function codeSpan(attrs, nodes = []) {
63
+ return { type: 'code-span', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
64
+ }
65
+ /**
66
+ * A footnote, in the nodes of a text. The engine numbers it and puts a small raised number at its place in the
67
+ * text; its words go at the bottom of the page where that number lands. It has no attributes: pass `NoAttr`.
68
+ * The words are strings and spans.
69
+ */
70
+ function fn(attrs, nodes = []) {
71
+ return { type: 'fn', attrs: {}, nodes };
72
+ }
43
73
  function divider(attrs = null) {
44
74
  return { type: 'divider', attrs: (0, _shared_1.buildAttrs)(attrs) };
45
75
  }
46
76
  function img(attrs) {
47
77
  return { type: 'img', attrs: (0, _shared_1.buildAttrs)(attrs) };
48
78
  }
79
+ /** A rect, circle or ellipse that takes its box in the layout, as an image does. */
80
+ function shape(attrs) {
81
+ return { type: 'shape', attrs: (0, _shared_1.buildAttrs)(attrs) };
82
+ }
49
83
  function barcode(attrs) {
50
84
  return { type: 'barcode', attrs: (0, _shared_1.buildAttrs)(attrs) };
51
85
  }
@@ -66,12 +100,18 @@ exports.LpdfLayout = Object.freeze({
66
100
  column,
67
101
  row,
68
102
  grid,
103
+ list,
104
+ li,
69
105
  frame,
70
106
  link,
71
107
  text,
108
+ code,
72
109
  span,
110
+ codeSpan,
111
+ fn,
73
112
  divider,
74
113
  img,
114
+ shape,
75
115
  barcode,
76
116
  table,
77
117
  thead,
@@ -0,0 +1,75 @@
1
+ import type { MarkdownAttr, MarkdownStylesAttr, MarkdownH1Attr, MarkdownH2Attr, MarkdownH3Attr, MarkdownH4Attr, MarkdownH5Attr, MarkdownH6Attr, MarkdownPAttr, MarkdownCodeAttr, MarkdownQuoteAttr, MarkdownLiAttr, MarkdownAAttr, MarkdownStrongAttr, MarkdownEmAttr, MarkdownDelAttr, MarkdownTableAttr, MarkdownThAttr, MarkdownTdAttr } from './attrs';
2
+ /** A rule of a markdown's styles: the element it is named after, with the attributes it sets. */
3
+ export interface LpdfMarkdownRuleNode {
4
+ type: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'code' | 'quote' | 'li' | 'a' | 'strong' | 'em' | 'del' | 'table' | 'th' | 'td';
5
+ attrs: Record<string, string>;
6
+ }
7
+ /** The rules that say how the parts of a markdown look, with a file of them in `src` when it has one. */
8
+ export interface LpdfMarkdownStylesNode {
9
+ type: 'markdown-styles';
10
+ attrs: Record<string, string>;
11
+ nodes: LpdfMarkdownRuleNode[];
12
+ }
13
+ /** The Markdown itself, as strings. */
14
+ export interface LpdfMarkdownContentNode {
15
+ type: 'markdown-content';
16
+ attrs: Record<string, string>;
17
+ nodes: string[];
18
+ }
19
+ /** A markdown, which takes the place of a layout in a section and holds only Markdown. */
20
+ export interface LpdfMarkdownNode {
21
+ type: 'markdown';
22
+ attrs: Record<string, string>;
23
+ nodes: (LpdfMarkdownStylesNode | LpdfMarkdownContentNode)[];
24
+ }
25
+ /**
26
+ * Markdown as the content of a section, where a layout would go. It holds only Markdown: the `LMarkdown.styles`
27
+ * that say how each part looks, which are optional, and one `LMarkdown.content` with the text. What Markdown
28
+ * can't say, such as the page, a header, a footer or a cover, stays in the section around it: layers paint a
29
+ * header and a footer in the margin it leaves.
30
+ *
31
+ * ```ts
32
+ * L.markdown({ margin: '54pt', gap: 'm' }, [
33
+ * LMarkdown.styles(NoAttr, [LMarkdown.h1({ color: 'muted' })]),
34
+ * LMarkdown.content(NoAttr, [body]),
35
+ * ])
36
+ * ```
37
+ */
38
+ declare function markdown(attrs: MarkdownAttr | null, nodes?: (LpdfMarkdownStylesNode | LpdfMarkdownContentNode)[]): LpdfMarkdownNode;
39
+ /**
40
+ * The rules that say how the parts of a markdown look. A rule is named after the Markdown it styles and takes the
41
+ * attributes of the element it becomes. A rule here overrides the same rule of the file `src` names, which
42
+ * overrides the defaults.
43
+ */
44
+ declare function styles(attrs: MarkdownStylesAttr | null, nodes?: LpdfMarkdownRuleNode[]): LpdfMarkdownStylesNode;
45
+ /**
46
+ * The Markdown, as strings that make one text. The common indent of its lines is removed, so that indenting the
47
+ * code does not make a code block of it. It has no attributes: pass `NoAttr`.
48
+ */
49
+ declare function content(attrs: null, nodes?: string[]): LpdfMarkdownContentNode;
50
+ /** The parts of a markdown: its styles, its content and the rules of its styles. */
51
+ export declare const LMarkdown: Readonly<{
52
+ styles: typeof styles;
53
+ content: typeof content;
54
+ h1: (attrs?: MarkdownH1Attr | null) => LpdfMarkdownRuleNode;
55
+ h2: (attrs?: MarkdownH2Attr | null) => LpdfMarkdownRuleNode;
56
+ h3: (attrs?: MarkdownH3Attr | null) => LpdfMarkdownRuleNode;
57
+ h4: (attrs?: MarkdownH4Attr | null) => LpdfMarkdownRuleNode;
58
+ h5: (attrs?: MarkdownH5Attr | null) => LpdfMarkdownRuleNode;
59
+ h6: (attrs?: MarkdownH6Attr | null) => LpdfMarkdownRuleNode;
60
+ p: (attrs?: MarkdownPAttr | null) => LpdfMarkdownRuleNode;
61
+ code: (attrs?: MarkdownCodeAttr | null) => LpdfMarkdownRuleNode;
62
+ quote: (attrs?: MarkdownQuoteAttr | null) => LpdfMarkdownRuleNode;
63
+ li: (attrs?: MarkdownLiAttr | null) => LpdfMarkdownRuleNode;
64
+ a: (attrs?: MarkdownAAttr | null) => LpdfMarkdownRuleNode;
65
+ strong: (attrs?: MarkdownStrongAttr | null) => LpdfMarkdownRuleNode;
66
+ em: (attrs?: MarkdownEmAttr | null) => LpdfMarkdownRuleNode;
67
+ del: (attrs?: MarkdownDelAttr | null) => LpdfMarkdownRuleNode;
68
+ table: (attrs?: MarkdownTableAttr | null) => LpdfMarkdownRuleNode;
69
+ th: (attrs?: MarkdownThAttr | null) => LpdfMarkdownRuleNode;
70
+ td: (attrs?: MarkdownTdAttr | null) => LpdfMarkdownRuleNode;
71
+ }>;
72
+ export declare const LpdfMarkdown: Readonly<{
73
+ markdown: typeof markdown;
74
+ }>;
75
+ export {};
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LpdfMarkdown = exports.LMarkdown = void 0;
4
+ const _shared_1 = require("./_shared");
5
+ // ── The markdown of a section ─────────────────────────────────────────────────
6
+ /**
7
+ * Markdown as the content of a section, where a layout would go. It holds only Markdown: the `LMarkdown.styles`
8
+ * that say how each part looks, which are optional, and one `LMarkdown.content` with the text. What Markdown
9
+ * can't say, such as the page, a header, a footer or a cover, stays in the section around it: layers paint a
10
+ * header and a footer in the margin it leaves.
11
+ *
12
+ * ```ts
13
+ * L.markdown({ margin: '54pt', gap: 'm' }, [
14
+ * LMarkdown.styles(NoAttr, [LMarkdown.h1({ color: 'muted' })]),
15
+ * LMarkdown.content(NoAttr, [body]),
16
+ * ])
17
+ * ```
18
+ */
19
+ function markdown(attrs, nodes = []) {
20
+ return { type: 'markdown', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
21
+ }
22
+ // ── LMarkdown: the parts of a markdown ────────────────────────────────────────
23
+ /**
24
+ * The rules that say how the parts of a markdown look. A rule is named after the Markdown it styles and takes the
25
+ * attributes of the element it becomes. A rule here overrides the same rule of the file `src` names, which
26
+ * overrides the defaults.
27
+ */
28
+ function styles(attrs, nodes = []) {
29
+ return { type: 'markdown-styles', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
30
+ }
31
+ /**
32
+ * The Markdown, as strings that make one text. The common indent of its lines is removed, so that indenting the
33
+ * code does not make a code block of it. It has no attributes: pass `NoAttr`.
34
+ */
35
+ function content(attrs, nodes = []) {
36
+ return { type: 'markdown-content', attrs: {}, nodes };
37
+ }
38
+ function rule(type) {
39
+ return (attrs = null) => ({ type, attrs: (0, _shared_1.buildAttrs)(attrs) });
40
+ }
41
+ /** The parts of a markdown: its styles, its content and the rules of its styles. */
42
+ exports.LMarkdown = Object.freeze({
43
+ styles,
44
+ content,
45
+ h1: rule('h1'),
46
+ h2: rule('h2'),
47
+ h3: rule('h3'),
48
+ h4: rule('h4'),
49
+ h5: rule('h5'),
50
+ h6: rule('h6'),
51
+ p: rule('p'),
52
+ code: rule('code'),
53
+ quote: rule('quote'),
54
+ li: rule('li'),
55
+ a: rule('a'),
56
+ strong: rule('strong'),
57
+ em: rule('em'),
58
+ del: rule('del'),
59
+ table: rule('table'),
60
+ th: rule('th'),
61
+ td: rule('td'),
62
+ });
63
+ exports.LpdfMarkdown = Object.freeze({ markdown });
@@ -46,6 +46,20 @@ export class LpdfEngine {
46
46
  const len1 = WASM_VECTOR_LEN;
47
47
  wasm.lpdfengine_load_image(this.__wbg_ptr, ptr0, len0, ptr1, len1);
48
48
  }
49
+ /**
50
+ * Register the text of a file of Markdown rules, the root of which is a `<markdown-styles>`, for the
51
+ * `src` that names it. The engine reads no files: call this once for every `<markdown-styles src="…">`
52
+ * of the document before `render_pdf`, as `load_font` is called for a font.
53
+ * @param {string} src
54
+ * @param {string} xml
55
+ */
56
+ load_markdown_styles(src, xml) {
57
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ptr1 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len1 = WASM_VECTOR_LEN;
61
+ wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
62
+ }
49
63
  /**
50
64
  * @param {string} license_key
51
65
  */
@@ -152,26 +166,40 @@ export class LpdfEngine {
152
166
  wasm.lpdfengine_set_created_on(this.__wbg_ptr, ptr0, len0);
153
167
  }
154
168
  /**
155
- * Configure RC4-128 encryption applied to every subsequent `render_pdf` call.
169
+ * Configure encryption applied to every subsequent `render_pdf` call.
156
170
  *
157
171
  * `permissions_json` is a JSON object with boolean fields matching the
158
172
  * `Permissions` struct (`print`, `modify`, `copy`, `annotate`, `fill_forms`,
159
173
  * `accessibility`, `assemble`, `print_hq`). Omitted fields default to `true`.
160
174
  *
175
+ * `algorithm` is `"aes-256"` or `"rc4-128"`. AES-256 needs `entropy`: at least 32
176
+ * random bytes from the host's secure generator, from which the core cuts the file
177
+ * key, salts and IVs. RC4-128 ignores it. Fails when the algorithm is unknown or
178
+ * AES-256 gets too little entropy.
179
+ *
161
180
  * To apply permissions without an open password, pass an empty `user_password`
162
181
  * and a non-empty `owner_password`.
163
182
  * @param {string} user_password
164
183
  * @param {string} owner_password
165
184
  * @param {string} permissions_json
185
+ * @param {string} algorithm
186
+ * @param {Uint8Array} entropy
166
187
  */
167
- set_encryption(user_password, owner_password, permissions_json) {
188
+ set_encryption(user_password, owner_password, permissions_json, algorithm, entropy) {
168
189
  const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
190
  const len0 = WASM_VECTOR_LEN;
170
191
  const ptr1 = passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
171
192
  const len1 = WASM_VECTOR_LEN;
172
193
  const ptr2 = passStringToWasm0(permissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
194
  const len2 = WASM_VECTOR_LEN;
174
- wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
195
+ const ptr3 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
196
+ const len3 = WASM_VECTOR_LEN;
197
+ const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
198
+ const len4 = WASM_VECTOR_LEN;
199
+ const ret = wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
200
+ if (ret[1]) {
201
+ throw takeFromExternrefTable0(ret[0]);
202
+ }
175
203
  }
176
204
  /**
177
205
  * Inject glyph advance-width tables for custom fonts.
@@ -344,6 +372,132 @@ export function kit_to_xml(json) {
344
372
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
345
373
  }
346
374
  }
375
+
376
+ /**
377
+ * The template `template` with an `<image>` declared for each path of the JSON array `srcs`, named as
378
+ * `markdown_file_images` says.
379
+ * @param {string} template
380
+ * @param {string} srcs
381
+ * @returns {string}
382
+ */
383
+ export function markdown_declare_images(template, srcs) {
384
+ let deferred4_0;
385
+ let deferred4_1;
386
+ try {
387
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
388
+ const len0 = WASM_VECTOR_LEN;
389
+ const ptr1 = passStringToWasm0(srcs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
390
+ const len1 = WASM_VECTOR_LEN;
391
+ const ret = wasm.markdown_declare_images(ptr0, len0, ptr1, len1);
392
+ var ptr3 = ret[0];
393
+ var len3 = ret[1];
394
+ if (ret[3]) {
395
+ ptr3 = 0; len3 = 0;
396
+ throw takeFromExternrefTable0(ret[2]);
397
+ }
398
+ deferred4_0 = ptr3;
399
+ deferred4_1 = len3;
400
+ return getStringFromWasm0(ptr3, len3);
401
+ } finally {
402
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * The rules a `<markdown>` with no styles uses, as the file to start a style of one's own from.
408
+ * @returns {string}
409
+ */
410
+ export function markdown_default_styles() {
411
+ let deferred1_0;
412
+ let deferred1_1;
413
+ try {
414
+ const ret = wasm.markdown_default_styles();
415
+ deferred1_0 = ret[0];
416
+ deferred1_1 = ret[1];
417
+ return getStringFromWasm0(ret[0], ret[1]);
418
+ } finally {
419
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
420
+ }
421
+ }
422
+
423
+ /**
424
+ * The data a template gets for the `.md` file `markdown`, as JSON: the text as `markdown`, and the fields of its
425
+ * front matter, each a string.
426
+ * @param {string} markdown
427
+ * @returns {string}
428
+ */
429
+ export function markdown_file_data(markdown) {
430
+ let deferred2_0;
431
+ let deferred2_1;
432
+ try {
433
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
434
+ const len0 = WASM_VECTOR_LEN;
435
+ const ret = wasm.markdown_file_data(ptr0, len0);
436
+ deferred2_0 = ret[0];
437
+ deferred2_1 = ret[1];
438
+ return getStringFromWasm0(ret[0], ret[1]);
439
+ } finally {
440
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
441
+ }
442
+ }
443
+
444
+ /**
445
+ * The relative paths of the images of the `.md` file `markdown`, as a JSON array. The caller declares them with
446
+ * `markdown_declare_images` and loads each file, relative to the `.md`, under the name `markdown-image-N` where N
447
+ * counts from 1 in the order of the array.
448
+ * @param {string} markdown
449
+ * @returns {string}
450
+ */
451
+ export function markdown_file_images(markdown) {
452
+ let deferred2_0;
453
+ let deferred2_1;
454
+ try {
455
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
456
+ const len0 = WASM_VECTOR_LEN;
457
+ const ret = wasm.markdown_file_images(ptr0, len0);
458
+ deferred2_0 = ret[0];
459
+ deferred2_1 = ret[1];
460
+ return getStringFromWasm0(ret[0], ret[1]);
461
+ } finally {
462
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
463
+ }
464
+ }
465
+
466
+ /**
467
+ * The looks a `.md` file can start from besides the default one, as a JSON array of `name`, `label`, `description`
468
+ * and `styles`: the file of styles, to write beside the `.md` file and edit.
469
+ * @returns {string}
470
+ */
471
+ export function markdown_style_presets() {
472
+ let deferred1_0;
473
+ let deferred1_1;
474
+ try {
475
+ const ret = wasm.markdown_style_presets();
476
+ deferred1_0 = ret[0];
477
+ deferred1_1 = ret[1];
478
+ return getStringFromWasm0(ret[0], ret[1]);
479
+ } finally {
480
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
481
+ }
482
+ }
483
+
484
+ /**
485
+ * The template that wraps a `.md` file when it is rendered with no template of its own: A4, a margin and the
486
+ * page number. It reads the Markdown from the data `markdown`, the rest of which is the file's front matter.
487
+ * @returns {string}
488
+ */
489
+ export function markdown_template() {
490
+ let deferred1_0;
491
+ let deferred1_1;
492
+ try {
493
+ const ret = wasm.markdown_template();
494
+ deferred1_0 = ret[0];
495
+ deferred1_1 = ret[1];
496
+ return getStringFromWasm0(ret[0], ret[1]);
497
+ } finally {
498
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
499
+ }
500
+ }
347
501
  function __wbg_get_imports() {
348
502
  const import0 = {
349
503
  __proto__: null,
package/dist/wasm/lpdf.js CHANGED
@@ -46,6 +46,20 @@ class LpdfEngine {
46
46
  const len1 = WASM_VECTOR_LEN;
47
47
  wasm.lpdfengine_load_image(this.__wbg_ptr, ptr0, len0, ptr1, len1);
48
48
  }
49
+ /**
50
+ * Register the text of a file of Markdown rules, the root of which is a `<markdown-styles>`, for the
51
+ * `src` that names it. The engine reads no files: call this once for every `<markdown-styles src="…">`
52
+ * of the document before `render_pdf`, as `load_font` is called for a font.
53
+ * @param {string} src
54
+ * @param {string} xml
55
+ */
56
+ load_markdown_styles(src, xml) {
57
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ptr1 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len1 = WASM_VECTOR_LEN;
61
+ wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
62
+ }
49
63
  /**
50
64
  * @param {string} license_key
51
65
  */
@@ -152,26 +166,40 @@ class LpdfEngine {
152
166
  wasm.lpdfengine_set_created_on(this.__wbg_ptr, ptr0, len0);
153
167
  }
154
168
  /**
155
- * Configure RC4-128 encryption applied to every subsequent `render_pdf` call.
169
+ * Configure encryption applied to every subsequent `render_pdf` call.
156
170
  *
157
171
  * `permissions_json` is a JSON object with boolean fields matching the
158
172
  * `Permissions` struct (`print`, `modify`, `copy`, `annotate`, `fill_forms`,
159
173
  * `accessibility`, `assemble`, `print_hq`). Omitted fields default to `true`.
160
174
  *
175
+ * `algorithm` is `"aes-256"` or `"rc4-128"`. AES-256 needs `entropy`: at least 32
176
+ * random bytes from the host's secure generator, from which the core cuts the file
177
+ * key, salts and IVs. RC4-128 ignores it. Fails when the algorithm is unknown or
178
+ * AES-256 gets too little entropy.
179
+ *
161
180
  * To apply permissions without an open password, pass an empty `user_password`
162
181
  * and a non-empty `owner_password`.
163
182
  * @param {string} user_password
164
183
  * @param {string} owner_password
165
184
  * @param {string} permissions_json
185
+ * @param {string} algorithm
186
+ * @param {Uint8Array} entropy
166
187
  */
167
- set_encryption(user_password, owner_password, permissions_json) {
188
+ set_encryption(user_password, owner_password, permissions_json, algorithm, entropy) {
168
189
  const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
190
  const len0 = WASM_VECTOR_LEN;
170
191
  const ptr1 = passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
171
192
  const len1 = WASM_VECTOR_LEN;
172
193
  const ptr2 = passStringToWasm0(permissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
173
194
  const len2 = WASM_VECTOR_LEN;
174
- wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
195
+ const ptr3 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
196
+ const len3 = WASM_VECTOR_LEN;
197
+ const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
198
+ const len4 = WASM_VECTOR_LEN;
199
+ const ret = wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
200
+ if (ret[1]) {
201
+ throw takeFromExternrefTable0(ret[0]);
202
+ }
175
203
  }
176
204
  /**
177
205
  * Inject glyph advance-width tables for custom fonts.
@@ -349,6 +377,138 @@ function kit_to_xml(json) {
349
377
  }
350
378
  }
351
379
  exports.kit_to_xml = kit_to_xml;
380
+
381
+ /**
382
+ * The template `template` with an `<image>` declared for each path of the JSON array `srcs`, named as
383
+ * `markdown_file_images` says.
384
+ * @param {string} template
385
+ * @param {string} srcs
386
+ * @returns {string}
387
+ */
388
+ function markdown_declare_images(template, srcs) {
389
+ let deferred4_0;
390
+ let deferred4_1;
391
+ try {
392
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
393
+ const len0 = WASM_VECTOR_LEN;
394
+ const ptr1 = passStringToWasm0(srcs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
395
+ const len1 = WASM_VECTOR_LEN;
396
+ const ret = wasm.markdown_declare_images(ptr0, len0, ptr1, len1);
397
+ var ptr3 = ret[0];
398
+ var len3 = ret[1];
399
+ if (ret[3]) {
400
+ ptr3 = 0; len3 = 0;
401
+ throw takeFromExternrefTable0(ret[2]);
402
+ }
403
+ deferred4_0 = ptr3;
404
+ deferred4_1 = len3;
405
+ return getStringFromWasm0(ptr3, len3);
406
+ } finally {
407
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
408
+ }
409
+ }
410
+ exports.markdown_declare_images = markdown_declare_images;
411
+
412
+ /**
413
+ * The rules a `<markdown>` with no styles uses, as the file to start a style of one's own from.
414
+ * @returns {string}
415
+ */
416
+ function markdown_default_styles() {
417
+ let deferred1_0;
418
+ let deferred1_1;
419
+ try {
420
+ const ret = wasm.markdown_default_styles();
421
+ deferred1_0 = ret[0];
422
+ deferred1_1 = ret[1];
423
+ return getStringFromWasm0(ret[0], ret[1]);
424
+ } finally {
425
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
426
+ }
427
+ }
428
+ exports.markdown_default_styles = markdown_default_styles;
429
+
430
+ /**
431
+ * The data a template gets for the `.md` file `markdown`, as JSON: the text as `markdown`, and the fields of its
432
+ * front matter, each a string.
433
+ * @param {string} markdown
434
+ * @returns {string}
435
+ */
436
+ function markdown_file_data(markdown) {
437
+ let deferred2_0;
438
+ let deferred2_1;
439
+ try {
440
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
441
+ const len0 = WASM_VECTOR_LEN;
442
+ const ret = wasm.markdown_file_data(ptr0, len0);
443
+ deferred2_0 = ret[0];
444
+ deferred2_1 = ret[1];
445
+ return getStringFromWasm0(ret[0], ret[1]);
446
+ } finally {
447
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
448
+ }
449
+ }
450
+ exports.markdown_file_data = markdown_file_data;
451
+
452
+ /**
453
+ * The relative paths of the images of the `.md` file `markdown`, as a JSON array. The caller declares them with
454
+ * `markdown_declare_images` and loads each file, relative to the `.md`, under the name `markdown-image-N` where N
455
+ * counts from 1 in the order of the array.
456
+ * @param {string} markdown
457
+ * @returns {string}
458
+ */
459
+ function markdown_file_images(markdown) {
460
+ let deferred2_0;
461
+ let deferred2_1;
462
+ try {
463
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ret = wasm.markdown_file_images(ptr0, len0);
466
+ deferred2_0 = ret[0];
467
+ deferred2_1 = ret[1];
468
+ return getStringFromWasm0(ret[0], ret[1]);
469
+ } finally {
470
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
471
+ }
472
+ }
473
+ exports.markdown_file_images = markdown_file_images;
474
+
475
+ /**
476
+ * The looks a `.md` file can start from besides the default one, as a JSON array of `name`, `label`, `description`
477
+ * and `styles`: the file of styles, to write beside the `.md` file and edit.
478
+ * @returns {string}
479
+ */
480
+ function markdown_style_presets() {
481
+ let deferred1_0;
482
+ let deferred1_1;
483
+ try {
484
+ const ret = wasm.markdown_style_presets();
485
+ deferred1_0 = ret[0];
486
+ deferred1_1 = ret[1];
487
+ return getStringFromWasm0(ret[0], ret[1]);
488
+ } finally {
489
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
490
+ }
491
+ }
492
+ exports.markdown_style_presets = markdown_style_presets;
493
+
494
+ /**
495
+ * The template that wraps a `.md` file when it is rendered with no template of its own: A4, a margin and the
496
+ * page number. It reads the Markdown from the data `markdown`, the rest of which is the file's front matter.
497
+ * @returns {string}
498
+ */
499
+ function markdown_template() {
500
+ let deferred1_0;
501
+ let deferred1_1;
502
+ try {
503
+ const ret = wasm.markdown_template();
504
+ deferred1_0 = ret[0];
505
+ deferred1_1 = ret[1];
506
+ return getStringFromWasm0(ret[0], ret[1]);
507
+ } finally {
508
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
509
+ }
510
+ }
511
+ exports.markdown_template = markdown_template;
352
512
  function __wbg_get_imports() {
353
513
  const import0 = {
354
514
  __proto__: null,
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdfio/lpdf",
3
- "version": "0.28.1",
3
+ "version": "0.30.0",
4
4
  "description": "Node.js SDK for Lpdf — PDF as Code on every platform. You describe a document as code or XML. Lpdf renders a compact, pixel-perfect PDF — identical across platforms.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,5 +48,8 @@
48
48
  "@types/node": "^20.0.0",
49
49
  "esbuild": "^0.25.0",
50
50
  "typescript": "^5.0.0"
51
+ },
52
+ "allowScripts": {
53
+ "esbuild": false
51
54
  }
52
55
  }