File tree Expand file tree Collapse file tree 7 files changed +113
-7
lines changed Expand file tree Collapse file tree 7 files changed +113
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default {
66 key : "customjs-convert-html-to-pdf" ,
77 name : "Convert HTML to PDF" ,
88 description : "Converts an HTML string to a PDF document. [See the documentation](https://www.customjs.space/api/docs#_1-html-to-pdf)" ,
9- version : "0.0.1 " ,
9+ version : "0.0.2 " ,
1010 type : "action" ,
1111 props : {
1212 customjs,
Original file line number Diff line number Diff line change 1+ import customjs from "../../customjs.app.mjs" ;
2+ import fs from "fs" ;
3+ import { normalizeFilepath } from "../common/utils.mjs" ;
4+
5+ export default {
6+ key : "customjs-convert-html-to-png" ,
7+ name : "Convert HTML to PNG" ,
8+ description : "Converts an HTML string to a PNG image. [See the documentation](https://www.customjs.space/api/docs#_4-html-to-png)" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ customjs,
13+ html : {
14+ type : "string" ,
15+ label : "HTML" ,
16+ description : "The HTML string to be converted to a PNG" ,
17+ } ,
18+ filename : {
19+ propDefinition : [
20+ customjs ,
21+ "filename" ,
22+ ] ,
23+ } ,
24+ } ,
25+ async run ( { $ } ) {
26+ const fileContent = await this . customjs . convertHtmlToPng ( {
27+ $,
28+ data : {
29+ input : this . html ,
30+ code : "const { HTML2PNG } = require('./utils'); return HTML2PNG(input);" ,
31+ returnBinary : "true" ,
32+ } ,
33+ } ) ;
34+
35+ const filepath = normalizeFilepath ( this . filename , "png" ) ;
36+ fs . writeFileSync ( filepath , Buffer . from ( fileContent ) ) ;
37+
38+ $ . export ( "$summary" , "Successfully converted HTML to PNG" ) ;
39+ return {
40+ filename : this . filename ,
41+ filepath,
42+ } ;
43+ } ,
44+ } ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default {
66 key : "customjs-create-screenshot" ,
77 name : "Create Screenshot" ,
88 description : "Create a screenshot of a website. [See the documentation](https://www.customjs.space/api/docs#_3-create-screenshot)" ,
9- version : "0.0.1 " ,
9+ version : "0.0.2 " ,
1010 type : "action" ,
1111 props : {
1212 customjs,
@@ -20,6 +20,7 @@ export default {
2020 customjs ,
2121 "filename" ,
2222 ] ,
23+ description : "Download the PNG file to the `/tmp` directory with the specified filename." ,
2324 } ,
2425 } ,
2526 async run ( { $ } ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default {
66 key : "customjs-merge-pdfs" ,
77 name : "Merge PDFs" ,
88 description : "Merges multiple PDF documents into one. [See the documentation](https://www.customjs.space/api/docs#_2-merge-pdfs)" ,
9- version : "0.0.1 " ,
9+ version : "0.0.2 " ,
1010 type : "action" ,
1111 props : {
1212 customjs,
Original file line number Diff line number Diff line change 1+ import customjs from "../../customjs.app.mjs" ;
2+ import fs from "fs" ;
3+ import { normalizeFilepath } from "../common/utils.mjs" ;
4+
5+ export default {
6+ key : "customjs-run-puppeteer" ,
7+ name : "Run Puppeteer" ,
8+ description : "Run Puppeteer. [See the documentation](https://www.customjs.space/api/docs#_5-run-puppeteer)" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ customjs,
13+ code : {
14+ type : "string" ,
15+ label : "Code" ,
16+ description : "Enter the code you want to run on puppeteer. For example: `await page.goto(\"https://example.com\");` will return a screenshot of https://example.com." ,
17+ } ,
18+ filename : {
19+ propDefinition : [
20+ customjs ,
21+ "filename" ,
22+ ] ,
23+ description : "Download the PNG file to the `/tmp` directory with the specified filename." ,
24+ } ,
25+ } ,
26+ async run ( { $ } ) {
27+ const fileContent = await this . customjs . runPuppeteer ( {
28+ $,
29+ data : {
30+ input : this . code ,
31+ code : "const { PUPPETEER } = require('./utils'); return PUPPETEER(input);" ,
32+ returnBinary : "true" ,
33+ } ,
34+ } ) ;
35+
36+ const filepath = normalizeFilepath ( this . filename , "png" ) ;
37+ fs . writeFileSync ( filepath , Buffer . from ( fileContent ) ) ;
38+
39+ $ . export ( "$summary" , "Successfully ran the puppeteer code." ) ;
40+ return {
41+ filename : this . filename ,
42+ filepath,
43+ } ;
44+ } ,
45+ } ;
Original file line number Diff line number Diff line change @@ -31,23 +31,39 @@ export default {
3131 convertHtmlToPdf ( opts = { } ) {
3232 return this . _makeRequest ( {
3333 headers : {
34- "customjs-origin" : "zapier/generatePDF" ,
34+ "customjs-origin" : "pipedream/generatePDF" ,
35+ } ,
36+ ...opts ,
37+ } ) ;
38+ } ,
39+ convertHtmlToPng ( opts = { } ) {
40+ return this . _makeRequest ( {
41+ headers : {
42+ "customjs-origin" : "pipedream/generatePNG" ,
3543 } ,
3644 ...opts ,
3745 } ) ;
3846 } ,
3947 createScreenshot ( opts = { } ) {
4048 return this . _makeRequest ( {
4149 headers : {
42- "customjs-origin" : "zapier /screenshot" ,
50+ "customjs-origin" : "pipedream /screenshot" ,
4351 } ,
4452 ...opts ,
4553 } ) ;
4654 } ,
4755 mergePdfs ( opts = { } ) {
4856 return this . _makeRequest ( {
4957 headers : {
50- "customjs-origin" : "zapier/mergePDFs" ,
58+ "customjs-origin" : "pipedream/mergePDFs" ,
59+ } ,
60+ ...opts ,
61+ } ) ;
62+ } ,
63+ runPuppeteer ( opts = { } ) {
64+ return this . _makeRequest ( {
65+ headers : {
66+ "customjs-origin" : "pipedream/puppeteer" ,
5167 } ,
5268 ...opts ,
5369 } ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/customjs" ,
3- "version" : " 0.1 .0" ,
3+ "version" : " 0.2 .0" ,
44 "description" : " Pipedream CustomJS Components" ,
55 "main" : " customjs.app.mjs" ,
66 "keywords" : [
You can’t perform that action at this time.
0 commit comments