polotno-node 2.12.18 → 2.12.21

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/README.md CHANGED
@@ -196,12 +196,12 @@ You can add `assetLoadTimeout` attribute to `attrs` object. It will be used to s
196
196
  const url = await instance.jsonToPDFDataURL(json, { assetLoadTimeout: 60000 });
197
197
  ```
198
198
 
199
- ### `attrs.assetFontTimeout`
199
+ ### `attrs.fontLoadTimeout`
200
200
 
201
201
  Timeout for loading fonts. By default it is 6000ms.
202
202
 
203
203
  ```js
204
- const url = await instance.jsonToPDFDataURL(json, { assetFontTimeout: 10000 });
204
+ const url = await instance.jsonToPDFDataURL(json, { fontLoadTimeout: 10000 });
205
205
  ```
206
206
 
207
207
  ### `attrs.htmlTextRenderEnabled`
@@ -307,42 +307,6 @@ const url = await instance.run(async (json) => {
307
307
  }, json);
308
308
  ```
309
309
 
310
- ## Video export
311
-
312
- **Video export is deprecated on this package and not supported anymore.**
313
-
314
- You may need to have ffmpeg available in your system to make it work.
315
- Also you need to manually dependencies:
316
-
317
- ```bash
318
- npm install fluent-ffmpeg axios
319
- ```
320
-
321
- ```js
322
- import { createInstance } from 'polotno-node';
323
- import { jsonToVideo } from 'polotno-node/video-parallel';
324
-
325
- // load sample json
326
- const json = JSON.parse(fs.readFileSync('./test-data/video.json'));
327
-
328
- await jsonToVideo(
329
- // first argument is a function that returns an instance
330
- // it can be a new instance on every call (useful for parallel rendering on local machine)
331
- // or it can be a single instance (useful for cloud functions)
332
- () =>
333
- createInstance({
334
- key: '...key...',
335
- }),
336
- json,
337
- {
338
- out: 'out.mp4', // output file name
339
- parallel: 4, // number of parallel rendering processes
340
- fps: 15, // frames per second
341
- keepInstance: false, // keep instance open after rendering, make sure to use true if use just one instance
342
- }
343
- );
344
- ```
345
-
346
310
  ## Your own client
347
311
 
348
312
  By default `polotno-node` ships with the default Polotno Editor with its (hopefully) last version. If you use experimental API such as `unstable_registerShapeModel` and `unstable_registerShapeComponent`, the rendering may fail if you use unknown elements types.
@@ -364,8 +328,6 @@ const instance = await createInstance({
364
328
 
365
329
  ## Usage on the cloud
366
330
 
367
- `polotno-node` should work by default on AWS Lambda. But in some cloud providers you may need to do extra steps to reduce function size.
368
-
369
331
  ### AWS EC2
370
332
 
371
333
  EC2 has some troubles with loading fonts. To fix the issue install Google Chrome, it will load all required libraries.
@@ -383,6 +345,7 @@ You can speed up your function execution a lot, if instead of using full browser
383
345
  Using browserless.io you can also make your function much smaller in size, so it will be possible to deploy to cloud provider with smaller limits, like Vercel.
384
346
 
385
347
  ```js
348
+ // (!) loading from polotno-node/instance will not import puppeteer and chromium-min dependencies
386
349
  const { createInstance } = require('polotno-node/instance');
387
350
  const puppeteer = require('puppeteer');
388
351
 
@@ -508,7 +471,9 @@ aws lambda publish-layer-version \
508
471
  ```
509
472
 
510
473
  ### 2. Create a JS file for a Lambda's handler
474
+
511
475
  #### Init a node project
476
+
512
477
  ```shell
513
478
  # create a folder
514
479
  mkdir handler && cd handler
@@ -521,6 +486,7 @@ npm install --save polotno-node puppeteer-core@19.8.0
521
486
  ```
522
487
 
523
488
  #### Create a handler
489
+
524
490
  ```shell
525
491
  # create a file handler
526
492
  touch index.mjs
@@ -599,9 +565,11 @@ export const handler = () => {
599
565
  }
600
566
  };
601
567
  ```
568
+
602
569
  </details>
603
570
 
604
571
  #### Create file with variables
572
+
605
573
  ```shell
606
574
  echo '{
607
575
  "Variables": {
@@ -616,7 +584,9 @@ zip -r index.zip ./*
616
584
  # copy to S3
617
585
  aws s3 cp index.zip s3://${BUCKET}/polotno-handler.zip
618
586
  ```
587
+
619
588
  #### Crete a trust policy
589
+
620
590
  ```shell
621
591
  echo '{
622
592
  "Version": "2012-10-17",
@@ -658,34 +628,39 @@ If you have faced an issue `Timeout for loading font <font name>`, please procee
658
628
  Lambda functions does not include any fonts by default, so we need to provide basic fonts (Arial and Times or their analogs) to make sure Polotno fonts functionality is working correctly.
659
629
 
660
630
  1. Create a `fonts` folder in the root of your handler project.
631
+
661
632
  ```shell
662
633
  mkdir fonts
663
634
  ```
635
+
664
636
  2. Put the `Arial.ttf` and `Times.ttf` files into the `fonts` folder. You can get them from your system fonts folder.
665
637
  3. Usage of fonts analogues is also possible:
638
+
666
639
  1. If you don't want to use system Arial and Times fonts, you can use [Liberation Fonts](https://github.com/liberationfonts/liberation-fonts) as free alternative. Download fonts from repository. Put `LiberationMono-Regular.ttf` and `LiberationSans-Regular.ttf` inside `fonts` folder.
667
640
  2. Create file `fonts.conf` inside `fonts` folder. It should contain the following lines:
668
- ```xml
641
+
642
+ ```xml
669
643
  <?xml version="1.0"?>
670
- <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
671
- <fontconfig>
672
- <alias>
673
- <family>Arial</family>
674
- <prefer>
675
- <family>Liberation Sans</family>
676
- </prefer>
677
- </alias>
678
- <alias>
679
- <family>Times New Roman</family>
680
- <prefer>
681
- <family>Liberation Serif</family>
682
- </prefer>
683
- </alias>
684
-
685
- <dir>/var/task/fonts</dir>
686
- </fontconfig>
644
+ <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
645
+ <fontconfig>
646
+ <alias>
647
+ <family>Arial</family>
648
+ <prefer>
649
+ <family>Liberation Sans</family>
650
+ </prefer>
651
+ </alias>
652
+ <alias>
653
+ <family>Times New Roman</family>
654
+ <prefer>
655
+ <family>Liberation Serif</family>
656
+ </prefer>
657
+ </alias>
658
+
659
+ <dir>/var/task/fonts</dir>
660
+ </fontconfig>
687
661
  ```
688
- 3. Upload your Lambda function as usual, fonts will be loaded automatically.
662
+
663
+ 4. Upload your Lambda function as usual, fonts will be loaded automatically.
689
664
 
690
665
  ## Troubleshooting
691
666
 
@@ -704,7 +679,7 @@ It may mean that Polotno Client Editor was not loaded in `puppeteer` instance. I
704
679
  "functions": {
705
680
  "api/render.js": {
706
681
  // remember to replace this line with your function name
707
- "includeFiles": "node_modules/polotno-node/\*\*"
682
+ "includeFiles": "node_modules/polotno-node/**"
708
683
  }
709
684
  }
710
685
  }