polotno-node 2.15.19 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +10 -0
- package/README.md +33 -41
- package/dist/assets/{html2canvas-DyNBkGVl.js → html2canvas-BeKaVBkZ.js} +1 -1
- package/dist/assets/index-DFqP22V0.js +540 -0
- package/dist/assets/{index.es-Ci1IK4T_.js → index.es-DwOGAynS.js} +5 -5
- package/dist/assets/jspdf.es.min-BBVOPmzA.js +79 -0
- package/dist/assets/lib-CuK_SezV.js +65 -0
- package/dist/assets/purify.es-DlxR2Lg_.js +3 -0
- package/dist/index.html +1 -1
- package/lib/font-cache.d.ts +3 -0
- package/lib/font-cache.js +99 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +121 -0
- package/lib/instance.d.ts +41 -0
- package/lib/instance.js +740 -0
- package/lib/types.d.ts +76 -0
- package/lib/types.js +1 -0
- package/package.json +51 -31
- package/dist/assets/index-zOfyRUBK.js +0 -344
- package/dist/assets/jspdf.es.min-kwORMdcW.js +0 -79
- package/dist/assets/lib-BagY_77q.js +0 -65
- package/dist/assets/purify.es-D7J7JQWp.js +0 -3
- package/index.d.ts +0 -140
- package/index.js +0 -159
- package/instance.js +0 -881
- package/video-parallel.js +0 -414
- /package/dist/assets/{typeof-DmQ5kzpc.js → typeof-B5XbjTb1.js} +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Polotno SDK License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014–present Anton Lavrenov.
|
|
4
|
+
|
|
5
|
+
This package is part of the Polotno SDK. It is not open source. Use in
|
|
6
|
+
production requires a valid Polotno subscription.
|
|
7
|
+
|
|
8
|
+
Full license terms: https://polotno.com/legal/license
|
|
9
|
+
|
|
10
|
+
The software is provided "as is", without warranty of any kind.
|
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ npm install polotno-node
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
import fs from 'fs';
|
|
19
|
+
import { createInstance } from 'polotno-node';
|
|
20
20
|
|
|
21
21
|
async function run() {
|
|
22
22
|
// create working instance
|
|
@@ -47,7 +47,7 @@ run();
|
|
|
47
47
|
Create working instance of Polotno Node.
|
|
48
48
|
|
|
49
49
|
```js
|
|
50
|
-
|
|
50
|
+
import { createInstance } from 'polotno-node';
|
|
51
51
|
const instance = await createInstance({
|
|
52
52
|
// this is a demo key just for that project
|
|
53
53
|
// (!) please don't use it in your projects
|
|
@@ -71,6 +71,14 @@ const instance = await createInstance({
|
|
|
71
71
|
// see "Custom Browser Arguments" section for more details
|
|
72
72
|
browserArgs: ['--custom-arg'],
|
|
73
73
|
|
|
74
|
+
// useFontCache - cache Google Fonts responses (in memory + on disk in the
|
|
75
|
+
// OS temp folder, shared across processes) and serve them to every page.
|
|
76
|
+
// Every page starts with an empty HTTP cache, so without it each render
|
|
77
|
+
// re-downloads the same fonts and bursts of parallel renders may get
|
|
78
|
+
// throttled by Google Fonts (fonts time out and text falls back to a
|
|
79
|
+
// default font). Default is true.
|
|
80
|
+
useFontCache: true,
|
|
81
|
+
|
|
74
82
|
// requestInterceptor - optional function to intercept and modify network requests
|
|
75
83
|
// Useful when you need to:
|
|
76
84
|
// - Modify headers like User-Agent to access protected image resources
|
|
@@ -98,7 +106,7 @@ const instance = await createInstance({
|
|
|
98
106
|
Create a Puppeteer browser instance with optimized settings for Polotno rendering. This is useful when you want to create a browser separately from the instance.
|
|
99
107
|
|
|
100
108
|
```js
|
|
101
|
-
|
|
109
|
+
import { createBrowser, createInstance } from 'polotno-node';
|
|
102
110
|
|
|
103
111
|
// Create a browser
|
|
104
112
|
const browser = await createBrowser({
|
|
@@ -283,39 +291,23 @@ Timeout for loading fonts. By default it is 6000ms.
|
|
|
283
291
|
const url = await instance.jsonToPDFDataURL(json, { fontLoadTimeout: 10000 });
|
|
284
292
|
```
|
|
285
293
|
|
|
286
|
-
### `attrs.
|
|
294
|
+
### `attrs.legacyRichTextEnabled`
|
|
287
295
|
|
|
288
|
-
|
|
296
|
+
Use the legacy (pre polotno 4) rich text renderer. By default it is `false` — the new text rendering engine is always on.
|
|
289
297
|
|
|
290
298
|
```js
|
|
291
299
|
const url = await instance.jsonToPDFDataURL(json, {
|
|
292
|
-
|
|
293
|
-
});
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### `attrs.htmlTextRenderEnabled` (deprecated)
|
|
297
|
-
|
|
298
|
-
⚠️ **Deprecated:** Use `richTextEnabled` instead. This property is maintained for backward compatibility and works as a fallback.
|
|
299
|
-
|
|
300
|
-
```js
|
|
301
|
-
// Old (deprecated)
|
|
302
|
-
const url = await instance.jsonToPDFDataURL(json, {
|
|
303
|
-
htmlTextRenderEnabled: true,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// New (recommended)
|
|
307
|
-
const url = await instance.jsonToPDFDataURL(json, {
|
|
308
|
-
richTextEnabled: true,
|
|
300
|
+
legacyRichTextEnabled: true,
|
|
309
301
|
});
|
|
310
302
|
```
|
|
311
303
|
|
|
312
304
|
### `attrs.textVerticalResizeEnabled`
|
|
313
305
|
|
|
314
|
-
|
|
306
|
+
Vertical text resize and align. **On by default** — pass `false` to disable it.
|
|
315
307
|
|
|
316
308
|
```js
|
|
317
309
|
const url = await instance.jsonToPDFDataURL(json, {
|
|
318
|
-
textVerticalResizeEnabled:
|
|
310
|
+
textVerticalResizeEnabled: false,
|
|
319
311
|
});
|
|
320
312
|
```
|
|
321
313
|
|
|
@@ -409,7 +401,7 @@ const url = await instance.run(async (json) => {
|
|
|
409
401
|
`polotno-node` exports a carefully curated set of Chrome arguments (`args`) that are optimized for server-side rendering. These arguments are automatically used when you call `createInstance()` without providing your own browser.
|
|
410
402
|
|
|
411
403
|
```js
|
|
412
|
-
|
|
404
|
+
import { args } from 'polotno-node';
|
|
413
405
|
|
|
414
406
|
console.log(args);
|
|
415
407
|
// Will show the default arguments like:
|
|
@@ -423,9 +415,9 @@ console.log(args);
|
|
|
423
415
|
When you want to use your own browser instance (e.g., with browserless.io or custom puppeteer configuration), you should combine `chrome.args` (the base defaults) with polotno-node's `args` (additional optimizations):
|
|
424
416
|
|
|
425
417
|
```js
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
418
|
+
import { createInstance, args } from 'polotno-node';
|
|
419
|
+
import chromium from '@sparticuz/chromium';
|
|
420
|
+
import puppeteer from 'puppeteer-core';
|
|
429
421
|
|
|
430
422
|
// Combine chrome.args (base defaults) with polotno-node's args (optimizations)
|
|
431
423
|
// This works best on Linux/macOS
|
|
@@ -450,9 +442,9 @@ const instance = await createInstance({
|
|
|
450
442
|
If you need to add, remove, or replace specific arguments (Linux/macOS):
|
|
451
443
|
|
|
452
444
|
```js
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
445
|
+
import { createInstance, args } from 'polotno-node';
|
|
446
|
+
import chromium from '@sparticuz/chromium';
|
|
447
|
+
import puppeteer from 'puppeteer-core';
|
|
456
448
|
|
|
457
449
|
// Add custom arguments on top of chrome.args and polotno args
|
|
458
450
|
const browser = await puppeteer.launch({
|
|
@@ -487,7 +479,7 @@ const browser3 = await puppeteer.launch({
|
|
|
487
479
|
When using `createInstance()` or `createBrowser()`, you can provide additional arguments via `browserArgs` option. Internally, this automatically combines `chrome.args` + `args` + your custom `browserArgs`:
|
|
488
480
|
|
|
489
481
|
```js
|
|
490
|
-
|
|
482
|
+
import { createInstance } from 'polotno-node';
|
|
491
483
|
|
|
492
484
|
const instance = await createInstance({
|
|
493
485
|
key: 'your-key',
|
|
@@ -507,7 +499,7 @@ Pass `url` option to `createInstance` function with public url of your client ed
|
|
|
507
499
|
**Note: you will have to maintain the last version of your client editor by yourself. Better to keep using the last **
|
|
508
500
|
|
|
509
501
|
```js
|
|
510
|
-
|
|
502
|
+
import { createInstance } from 'polotno-node';
|
|
511
503
|
|
|
512
504
|
const instance = await createInstance({
|
|
513
505
|
key: 'KEY',
|
|
@@ -522,7 +514,7 @@ const instance = await createInstance({
|
|
|
522
514
|
`polotno-node` works with AWS Lambda out of the box. Here's a simple example:
|
|
523
515
|
|
|
524
516
|
```js
|
|
525
|
-
|
|
517
|
+
import { createInstance } from 'polotno-node';
|
|
526
518
|
|
|
527
519
|
export const handler = async (event) => {
|
|
528
520
|
const instance = await createInstance({
|
|
@@ -690,8 +682,8 @@ Using browserless.io you can also make your function much smaller in size, so it
|
|
|
690
682
|
|
|
691
683
|
```js
|
|
692
684
|
// (!) loading from polotno-node/instance will not import puppeteer and chromium-min dependencies
|
|
693
|
-
|
|
694
|
-
|
|
685
|
+
import { createInstance } from 'polotno-node/instance';
|
|
686
|
+
import puppeteer from 'puppeteer';
|
|
695
687
|
|
|
696
688
|
const instance = await createInstance({
|
|
697
689
|
key: 'nFA5H9elEytDyPyvKL7T',
|
|
@@ -711,11 +703,11 @@ npm install @sparticuz/chromium-min
|
|
|
711
703
|
```
|
|
712
704
|
|
|
713
705
|
```js
|
|
714
|
-
|
|
706
|
+
import { createInstance } from 'polotno-node/instance';
|
|
715
707
|
// Import args from main entry point for optimal browser configuration
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
708
|
+
import { args } from 'polotno-node';
|
|
709
|
+
import chromium from '@sparticuz/chromium-min';
|
|
710
|
+
import puppeteer from 'puppeteer-core';
|
|
719
711
|
|
|
720
712
|
const makeInstance = async () => {
|
|
721
713
|
const browser = await puppeteer.launch({
|