polotno-node 3.2.0 → 3.4.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/LICENSE.md +20 -6
- package/README.md +31 -15
- package/dist/assets/html2canvas-DCcDvdvP.js +5 -0
- package/dist/assets/id3-CBTtHQkE.js +16 -0
- package/dist/assets/index-B2B7pzVl.js +656 -0
- package/dist/assets/index.es-5v7ubLSO.js +5 -0
- package/dist/assets/jspdf.es.min-87BhH7b6.js +79 -0
- package/dist/assets/lib-C8V7BvzS.js +1 -0
- package/dist/assets/preload-helper-HclGiUj8.js +1 -0
- package/dist/assets/purify.es-JEAr64Sr.js +3 -0
- package/dist/assets/{rolldown-runtime-QTnfLwEv.js → rolldown-runtime-hePW80VL.js} +1 -1
- package/dist/index.html +4 -2
- package/lib/index.d.ts +3 -3
- package/lib/index.js +23 -101
- package/lib/instance.d.ts +6 -1
- package/lib/instance.js +97 -36
- package/lib/launch-options.d.ts +31 -0
- package/lib/launch-options.js +124 -0
- package/lib/ssrf-guard.d.ts +15 -0
- package/lib/ssrf-guard.js +132 -0
- package/lib/types.d.ts +23 -1
- package/package.json +13 -13
- package/dist/assets/html2canvas-BfZ04V3R.js +0 -5
- package/dist/assets/index-j-YZMZrC.js +0 -668
- package/dist/assets/index.es-DYERYDqN.js +0 -5
- package/dist/assets/jspdf.es.min-EyQhoXfa.js +0 -79
- package/dist/assets/lib-BguUsusU.js +0 -1
- package/dist/assets/purify.es-BT_A-1xG.js +0 -3
package/LICENSE.md
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
Polotno SDK License
|
|
1
|
+
# Polotno SDK License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014–present Anton Lavrenov.
|
|
3
|
+
Copyright (c) 2014–present Anton Lavrenov. All rights reserved.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
You can use this package for evaluation, development, and testing for 60 days.
|
|
6
|
+
After 60 days, all use requires a valid Polotno subscription.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Production use requires a valid Polotno subscription at any time. Production use
|
|
9
|
+
is use of this package in a live product, service, or internal tool, including a
|
|
10
|
+
tool that only your own employees use. Development, testing, continuous
|
|
11
|
+
integration, and evaluation are not production use, wherever they run.
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
An AI agent can use this package for you under the same terms. The agent gets no
|
|
14
|
+
rights of its own.
|
|
15
|
+
|
|
16
|
+
Do not reverse engineer, decompile, or change this package. Do not republish or
|
|
17
|
+
sublicense it. Do not bypass a license check or a technical limit.
|
|
18
|
+
|
|
19
|
+
This package is provided "as is", without warranty. To the maximum limit that
|
|
20
|
+
the law permits, the copyright holder has no liability for a claim or for
|
|
21
|
+
damages.
|
|
22
|
+
|
|
23
|
+
Subscription terms (payment, duration, support):
|
|
24
|
+
https://polotno.com/legal/license
|
package/README.md
CHANGED
|
@@ -71,6 +71,10 @@ const instance = await createInstance({
|
|
|
71
71
|
// see "Custom Browser Arguments" section for more details
|
|
72
72
|
browserArgs: ['--custom-arg'],
|
|
73
73
|
|
|
74
|
+
// executablePath - launch this browser binary instead of the one we pick,
|
|
75
|
+
// e.g. the Chrome installed in your container. Ignored if you pass `browser`.
|
|
76
|
+
executablePath: '/usr/bin/google-chrome-stable',
|
|
77
|
+
|
|
74
78
|
// useFontCache - cache Google Fonts responses (in memory + on disk in the
|
|
75
79
|
// OS temp folder, shared across processes) and serve them to every page.
|
|
76
80
|
// Every page starts with an empty HTTP cache, so without it each render
|
|
@@ -275,6 +279,17 @@ const url = await instance.jsonToVideoDataURL(json, {
|
|
|
275
279
|
|
|
276
280
|
When `skipDownloads` is enabled, `polotno-node` will skip both remote-media downloading and the conditional video preprocessing described above.
|
|
277
281
|
|
|
282
|
+
### Restricted media hosts
|
|
283
|
+
|
|
284
|
+
Server-side downloads block cloud-metadata addresses (e.g. `169.254.169.254`) by default. Normal URLs, `localhost`, and private hosts still work. To restrict further:
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
await instance.jsonToVideoFile(json, 'out.mp4', {
|
|
288
|
+
blockPrivateNetwork: true, // also block loopback / private IPs
|
|
289
|
+
fetchGuard: (url) => isAllowed(url), // custom allow rule (checked per redirect hop)
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
278
293
|
### `attrs.assetLoadTimeout`
|
|
279
294
|
|
|
280
295
|
You can add `assetLoadTimeout` attribute to `attrs` object. It will be used to set timeout for loading assets. By default it is 30000ms.
|
|
@@ -408,7 +423,7 @@ console.log(args);
|
|
|
408
423
|
// ['--disable-web-security', '--allow-file-access-from-files', '--disable-gpu', ...]
|
|
409
424
|
```
|
|
410
425
|
|
|
411
|
-
**Platform compatibility:**
|
|
426
|
+
**Platform compatibility:** `@sparticuz/chromium`'s args are tuned for the chromium binary that package ships, so `polotno-node` applies them only when it launches that binary — on **Linux**, when you did not pass an `executablePath` of your own. Any other browser (puppeteer's bundled Chromium on macOS and Windows, or one you supply) gets the polotno `args` alone. Keep the same pairing when you combine args by hand.
|
|
412
427
|
|
|
413
428
|
### Using with custom browser
|
|
414
429
|
|
|
@@ -420,10 +435,9 @@ import chromium from '@sparticuz/chromium';
|
|
|
420
435
|
import puppeteer from 'puppeteer-core';
|
|
421
436
|
|
|
422
437
|
// Combine chrome.args (base defaults) with polotno-node's args (optimizations)
|
|
423
|
-
//
|
|
438
|
+
// The @sparticuz/chromium binary is Linux-only, so this pairing is too
|
|
424
439
|
const browser = await puppeteer.launch({
|
|
425
440
|
args: [...chromium.args, ...args],
|
|
426
|
-
defaultViewport: chromium.defaultViewport,
|
|
427
441
|
executablePath: await chromium.executablePath(),
|
|
428
442
|
headless: true,
|
|
429
443
|
ignoreHTTPSErrors: true,
|
|
@@ -435,11 +449,11 @@ const instance = await createInstance({
|
|
|
435
449
|
});
|
|
436
450
|
```
|
|
437
451
|
|
|
438
|
-
**Note:** `polotno-node`'s `args` are designed to work on top of `@sparticuz/chromium`'s args for optimal server-side rendering on Linux
|
|
452
|
+
**Note:** `polotno-node`'s `args` are designed to work on top of `@sparticuz/chromium`'s args for optimal server-side rendering on Linux, where that binary runs.
|
|
439
453
|
|
|
440
454
|
### Modifying default arguments
|
|
441
455
|
|
|
442
|
-
If you need to add, remove, or replace specific arguments (Linux
|
|
456
|
+
If you need to add, remove, or replace specific arguments (Linux):
|
|
443
457
|
|
|
444
458
|
```js
|
|
445
459
|
import { createInstance, args } from 'polotno-node';
|
|
@@ -449,7 +463,6 @@ import puppeteer from 'puppeteer-core';
|
|
|
449
463
|
// Add custom arguments on top of chrome.args and polotno args
|
|
450
464
|
const browser = await puppeteer.launch({
|
|
451
465
|
args: [...chromium.args, ...args, '--custom-arg', '--another-custom-arg'],
|
|
452
|
-
defaultViewport: chromium.defaultViewport,
|
|
453
466
|
executablePath: await chromium.executablePath(),
|
|
454
467
|
});
|
|
455
468
|
|
|
@@ -457,7 +470,6 @@ const browser = await puppeteer.launch({
|
|
|
457
470
|
const filteredArgs = args.filter((arg) => arg !== '--disable-gpu');
|
|
458
471
|
const browser2 = await puppeteer.launch({
|
|
459
472
|
args: [...chromium.args, ...filteredArgs],
|
|
460
|
-
defaultViewport: chromium.defaultViewport,
|
|
461
473
|
executablePath: await chromium.executablePath(),
|
|
462
474
|
});
|
|
463
475
|
|
|
@@ -467,16 +479,15 @@ const customArgs = args.map((arg) =>
|
|
|
467
479
|
);
|
|
468
480
|
const browser3 = await puppeteer.launch({
|
|
469
481
|
args: [...chromium.args, ...customArgs],
|
|
470
|
-
defaultViewport: chromium.defaultViewport,
|
|
471
482
|
executablePath: await chromium.executablePath(),
|
|
472
483
|
});
|
|
473
484
|
```
|
|
474
485
|
|
|
475
|
-
**Note:** These examples assume Linux
|
|
486
|
+
**Note:** These examples assume a Linux environment, where the `@sparticuz/chromium` binary and its `args` belong together.
|
|
476
487
|
|
|
477
488
|
### Combining with `browserArgs` option
|
|
478
489
|
|
|
479
|
-
When using `createInstance()` or `createBrowser()`, you can provide additional arguments via `browserArgs` option. Internally, this
|
|
490
|
+
When using `createInstance()` or `createBrowser()`, you can provide additional arguments via `browserArgs` option. Internally, this combines the polotno `args` with your custom `browserArgs`, and adds `chromium.args` only when it launches the `@sparticuz/chromium` binary — that is, on Linux when you did not pass an `executablePath` of your own. Those flags are tuned for that binary and are not applied to a browser you supply:
|
|
480
491
|
|
|
481
492
|
```js
|
|
482
493
|
import { createInstance } from 'polotno-node';
|
|
@@ -485,7 +496,7 @@ const instance = await createInstance({
|
|
|
485
496
|
key: 'your-key',
|
|
486
497
|
browserArgs: ['--custom-arg', '--another-arg'],
|
|
487
498
|
});
|
|
488
|
-
//
|
|
499
|
+
// Merges: polotno args + browserArgs (+ chromium.args on the bundled binary)
|
|
489
500
|
```
|
|
490
501
|
|
|
491
502
|
## Your own client
|
|
@@ -595,7 +606,6 @@ export const handler = async (event) => {
|
|
|
595
606
|
// Combine chromium args with polotno-node's optimized args
|
|
596
607
|
// Works well on AWS Lambda (Linux environment)
|
|
597
608
|
args: [...chromium.args, ...args],
|
|
598
|
-
defaultViewport: chromium.defaultViewport,
|
|
599
609
|
executablePath: await chromium.executablePath(),
|
|
600
610
|
headless: true,
|
|
601
611
|
ignoreHTTPSErrors: true,
|
|
@@ -712,13 +722,11 @@ import puppeteer from 'puppeteer-core';
|
|
|
712
722
|
const makeInstance = async () => {
|
|
713
723
|
const browser = await puppeteer.launch({
|
|
714
724
|
// Combine chromium args with polotno-node's optimized args
|
|
715
|
-
// Best for Linux/macOS environments
|
|
716
725
|
args: [...chromium.args, ...args],
|
|
717
|
-
defaultViewport: chromium.defaultViewport,
|
|
718
726
|
executablePath: await chromium.executablePath(
|
|
719
727
|
'https://github.com/Sparticuz/chromium/releases/download/v110.0.1/chromium-v110.0.1-pack.tar',
|
|
720
728
|
),
|
|
721
|
-
headless:
|
|
729
|
+
headless: true,
|
|
722
730
|
ignoreHTTPSErrors: true,
|
|
723
731
|
});
|
|
724
732
|
|
|
@@ -753,3 +761,11 @@ It may mean that Polotno Client Editor was not loaded in `puppeteer` instance. I
|
|
|
753
761
|
}
|
|
754
762
|
}
|
|
755
763
|
```
|
|
764
|
+
|
|
765
|
+
## License
|
|
766
|
+
|
|
767
|
+
See [LICENSE.md](./LICENSE.md).
|
|
768
|
+
|
|
769
|
+
This package contains a compiled copy of the `polotno` editor in `dist/`. No
|
|
770
|
+
dependency entry shows this, so a dependency scan will not reveal it. The editor
|
|
771
|
+
obeys the same terms as this package.
|