polotno-node 3.0.0 → 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 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
- const fs = require('fs');
19
- const { createInstance } = require('polotno-node');
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
- const { createInstance } = require('polotno-node');
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
@@ -106,7 +106,7 @@ const instance = await createInstance({
106
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.
107
107
 
108
108
  ```js
109
- const { createBrowser, createInstance } = require('polotno-node');
109
+ import { createBrowser, createInstance } from 'polotno-node';
110
110
 
111
111
  // Create a browser
112
112
  const browser = await createBrowser({
@@ -301,21 +301,13 @@ const url = await instance.jsonToPDFDataURL(json, {
301
301
  });
302
302
  ```
303
303
 
304
- ### `attrs.richTextEnabled` (deprecated)
305
-
306
- ⚠️ **Deprecated:** No-op since polotno 4 — the new text rendering engine is always enabled. The option is still accepted, but it does nothing. Use `legacyRichTextEnabled` if you need the old renderer.
307
-
308
- ### `attrs.htmlTextRenderEnabled` (deprecated)
309
-
310
- ⚠️ **Deprecated:** No-op since polotno 4, same as `richTextEnabled`.
311
-
312
304
  ### `attrs.textVerticalResizeEnabled`
313
305
 
314
- Enabled vertical text resize and align. By default it is `false`.
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: true,
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
- const { args } = require('polotno-node');
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
- const { createInstance, args } = require('polotno-node');
427
- const chromium = require('@sparticuz/chromium');
428
- const puppeteer = require('puppeteer-core');
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
- const { createInstance, args } = require('polotno-node');
454
- const chromium = require('@sparticuz/chromium');
455
- const puppeteer = require('puppeteer-core');
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
- const { createInstance } = require('polotno-node');
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
- const { createInstance } = require('polotno-node');
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
- const { createInstance } = require('polotno-node');
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
- const { createInstance } = require('polotno-node/instance');
694
- const puppeteer = require('puppeteer');
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
- const { createInstance } = require('polotno-node/instance');
706
+ import { createInstance } from 'polotno-node/instance';
715
707
  // Import args from main entry point for optimal browser configuration
716
- const { args } = require('polotno-node');
717
- const chromium = require('@sparticuz/chromium-min');
718
- const puppeteer = require('puppeteer-core');
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({