chromiumly 1.0.0 → 1.0.3

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.
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { Route } from "../main.config";
3
+ export declare abstract class Converter {
4
+ readonly endpoint: string;
5
+ constructor(route: Route);
6
+ generate(filename: string, buffer: Buffer): Promise<void>;
7
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ import { PathLike } from "fs";
3
+ import { PageProperties } from "./converter.types";
4
+ export interface IConverter {
5
+ convert({ ...args }: {
6
+ [x: string]: string | PathLike | PageProperties;
7
+ }): Promise<Buffer>;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=converter.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.interface.js","sourceRoot":"","sources":["../../src/common/converter.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Converter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const main_config_1 = require("../main.config");
8
+ class Converter {
9
+ constructor(route) {
10
+ this.endpoint = `${main_config_1.Chromiumly.endpoint}/${main_config_1.Chromiumly.path}/${main_config_1.Chromiumly.routes[route]}`;
11
+ }
12
+ generate(filename, buffer) {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ const __generated__ = path_1.default.resolve(process.cwd(), "__generated__");
15
+ yield fs_1.promises.mkdir(path_1.default.resolve(__generated__), { recursive: true });
16
+ yield fs_1.promises.writeFile(path_1.default.resolve(__generated__, filename), buffer);
17
+ });
18
+ }
19
+ }
20
+ exports.Converter = Converter;
21
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/common/converter.ts"],"names":[],"mappings":";;;;AAAA,2BAA8B;AAC9B,wDAAwB;AAExB,gDAAmD;AAEnD,MAAsB,SAAS;IAG7B,YAAY,KAAY;QACtB,IAAI,CAAC,QAAQ,GAAG,GAAG,wBAAU,CAAC,QAAQ,IAAI,wBAAU,CAAC,IAAI,IAAI,wBAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC1F,CAAC;IAEK,QAAQ,CAAC,QAAgB,EAAE,MAAc;;YAC7C,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;YACnE,MAAM,aAAQ,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACvE,MAAM,aAAQ,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;QAC1E,CAAC;KAAA;CACF;AAZD,8BAYC"}
@@ -0,0 +1,23 @@
1
+ declare type PageSize = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ declare type PageMargins = {
6
+ top: number;
7
+ bottom: number;
8
+ left: number;
9
+ right: number;
10
+ };
11
+ export declare type PageProperties = {
12
+ size?: PageSize;
13
+ margins?: PageMargins;
14
+ preferCssPageSize?: boolean;
15
+ printBackground?: boolean;
16
+ landscape?: boolean;
17
+ scale?: number;
18
+ nativePageRanges?: {
19
+ from: number;
20
+ to: number;
21
+ };
22
+ };
23
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=converter.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.types.js","sourceRoot":"","sources":["../../src/common/converter.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ import FormData from "form-data";
3
+ import { PageProperties } from "./converter.types";
4
+ export declare class ConverterUtils {
5
+ private static assert;
6
+ static injectPageProperties(data: FormData, pageProperties: PageProperties): void;
7
+ static fetch(endpoint: string, data: FormData): Promise<Buffer>;
8
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConverterUtils = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ class ConverterUtils {
7
+ static assert(condition, message) {
8
+ if (!condition) {
9
+ throw new Error(message);
10
+ }
11
+ }
12
+ static injectPageProperties(data, pageProperties) {
13
+ if (pageProperties) {
14
+ if (pageProperties.size) {
15
+ ConverterUtils.assert(pageProperties.size.width >= 1.0 && pageProperties.size.height >= 1.5, "size is smaller than the minimum printing requirements (i.e. 1.0 x 1.5 in)");
16
+ data.append("paperWidth", pageProperties.size.width);
17
+ data.append("paperHeight", pageProperties.size.height);
18
+ }
19
+ if (pageProperties.margins) {
20
+ ConverterUtils.assert(pageProperties.margins.top >= 0 &&
21
+ pageProperties.margins.bottom >= 0 &&
22
+ pageProperties.margins.left >= 0 &&
23
+ pageProperties.margins.left >= 0, "negative margins are not allowed");
24
+ data.append("marginTop", pageProperties.margins.top);
25
+ data.append("marginBottom", pageProperties.margins.bottom);
26
+ data.append("marginLeft", pageProperties.margins.left);
27
+ data.append("marginRight", pageProperties.margins.right);
28
+ }
29
+ if (pageProperties.preferCssPageSize) {
30
+ data.append("preferCssPageSize", String(pageProperties.preferCssPageSize));
31
+ }
32
+ if (pageProperties.printBackground) {
33
+ data.append("printBackground", String(pageProperties.printBackground));
34
+ }
35
+ if (pageProperties.landscape) {
36
+ data.append("landscape", String(pageProperties.landscape));
37
+ }
38
+ if (pageProperties.scale) {
39
+ ConverterUtils.assert(pageProperties.scale >= 0.1 && pageProperties.scale <= 2.0, "scale is outside of [0.1 - 2] range");
40
+ data.append("scale", pageProperties.scale);
41
+ }
42
+ if (pageProperties.nativePageRanges) {
43
+ ConverterUtils.assert(pageProperties.nativePageRanges.from > 0 &&
44
+ pageProperties.nativePageRanges.to > 0 &&
45
+ pageProperties.nativePageRanges.to >=
46
+ pageProperties.nativePageRanges.from, "page ranges syntax error");
47
+ data.append("nativePageRanges", `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`);
48
+ }
49
+ }
50
+ }
51
+ static fetch(endpoint, data) {
52
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
+ const response = yield (0, node_fetch_1.default)(endpoint, {
54
+ method: "post",
55
+ body: data,
56
+ headers: Object.assign({}, data.getHeaders()),
57
+ });
58
+ if (!response.ok) {
59
+ throw new Error(`${response.status} ${response.statusText}`);
60
+ }
61
+ return response.buffer();
62
+ });
63
+ }
64
+ }
65
+ exports.ConverterUtils = ConverterUtils;
66
+ //# sourceMappingURL=converter.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.utils.js","sourceRoot":"","sources":["../../src/common/converter.utils.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { PathLike } from "fs";
3
+ import { IConverter } from "../common/converter.interface";
4
+ import { PageProperties } from "../common/converter.types";
5
+ import { Converter } from "../common/converter";
6
+ export declare class HtmlConverter extends Converter implements IConverter {
7
+ constructor();
8
+ convert({ html, properties, }: {
9
+ html: PathLike;
10
+ properties?: PageProperties;
11
+ }): Promise<Buffer>;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HtmlConverter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
7
+ const converter_utils_1 = require("../common/converter.utils");
8
+ const converter_1 = require("../common/converter");
9
+ const main_config_1 = require("../main.config");
10
+ class HtmlConverter extends converter_1.Converter {
11
+ constructor() {
12
+ super(main_config_1.Route.HTML);
13
+ }
14
+ convert({ html, properties, }) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const data = new form_data_1.default();
17
+ data.append("index.html", (0, fs_1.createReadStream)(html));
18
+ if (properties) {
19
+ converter_utils_1.ConverterUtils.injectPageProperties(data, properties);
20
+ }
21
+ return converter_utils_1.ConverterUtils.fetch(this.endpoint, data);
22
+ });
23
+ }
24
+ }
25
+ exports.HtmlConverter = HtmlConverter;
26
+ //# sourceMappingURL=html.converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.converter.js","sourceRoot":"","sources":["../../src/converters/html.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAgD;AAEhD,kEAAiC;AAIjC,+DAA2D;AAC3D,mDAAgD;AAChD,gDAAuC;AAEvC,MAAa,aAAc,SAAQ,qBAAS;IAC1C;QACE,KAAK,CAAC,mBAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAEK,OAAO,CAAC,EACZ,IAAI,EACJ,UAAU,GAIX;;YACC,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;YAClD,IAAI,UAAU,EAAE;gBACd,gCAAc,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;aACvD;YACD,OAAO,gCAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;KAAA;CACF;AAnBD,sCAmBC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="node" />
2
+ import { PathLike } from "fs";
3
+ import { IConverter } from "../common/converter.interface";
4
+ import { PageProperties } from "../common/converter.types";
5
+ import { Converter } from "../common/converter";
6
+ export declare class MarkdownConverter extends Converter implements IConverter {
7
+ constructor();
8
+ convert({ html, markdown, properties, }: {
9
+ html: PathLike;
10
+ markdown: PathLike;
11
+ properties?: PageProperties;
12
+ }): Promise<Buffer>;
13
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MarkdownConverter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
7
+ const converter_utils_1 = require("../common/converter.utils");
8
+ const converter_1 = require("../common/converter");
9
+ const main_config_1 = require("../main.config");
10
+ class MarkdownConverter extends converter_1.Converter {
11
+ constructor() {
12
+ super(main_config_1.Route.MARKDOWN);
13
+ }
14
+ convert({ html, markdown, properties, }) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const data = new form_data_1.default();
17
+ data.append("index.html", (0, fs_1.createReadStream)(html));
18
+ data.append("file.md", (0, fs_1.createReadStream)(markdown));
19
+ if (properties) {
20
+ converter_utils_1.ConverterUtils.injectPageProperties(data, properties);
21
+ }
22
+ return converter_utils_1.ConverterUtils.fetch(this.endpoint, data);
23
+ });
24
+ }
25
+ }
26
+ exports.MarkdownConverter = MarkdownConverter;
27
+ //# sourceMappingURL=markdown.converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.converter.js","sourceRoot":"","sources":["../../src/converters/markdown.converter.ts"],"names":[],"mappings":";;;;AAAA,2BAAgD;AAEhD,kEAAiC;AAIjC,+DAA2D;AAC3D,mDAAgD;AAChD,gDAAuC;AAEvC,MAAa,iBAAkB,SAAQ,qBAAS;IAC9C;QACE,KAAK,CAAC,mBAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAEK,OAAO,CAAC,EACZ,IAAI,EACJ,QAAQ,EACR,UAAU,GAKX;;YACC,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAA,qBAAgB,EAAC,IAAI,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAA,qBAAgB,EAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,IAAI,UAAU,EAAE;gBACd,gCAAc,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;aACvD;YACD,OAAO,gCAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;KAAA;CACF;AAtBD,8CAsBC"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { IConverter } from "../common/converter.interface";
3
+ import { PageProperties } from "../common/converter.types";
4
+ import { Converter } from "../common/converter";
5
+ export declare class UrlConverter extends Converter implements IConverter {
6
+ constructor();
7
+ convert({ url, properties, }: {
8
+ url: string;
9
+ properties?: PageProperties;
10
+ }): Promise<Buffer>;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UrlConverter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const url_1 = require("url");
6
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
7
+ const converter_utils_1 = require("../common/converter.utils");
8
+ const converter_1 = require("../common/converter");
9
+ const main_config_1 = require("../main.config");
10
+ class UrlConverter extends converter_1.Converter {
11
+ constructor() {
12
+ super(main_config_1.Route.URL);
13
+ }
14
+ convert({ url, properties, }) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ const _url = new url_1.URL(url);
18
+ const data = new form_data_1.default();
19
+ data.append("url", _url.href);
20
+ if (properties) {
21
+ converter_utils_1.ConverterUtils.injectPageProperties(data, properties);
22
+ }
23
+ return converter_utils_1.ConverterUtils.fetch(this.endpoint, data);
24
+ }
25
+ catch (error) {
26
+ throw error;
27
+ }
28
+ });
29
+ }
30
+ }
31
+ exports.UrlConverter = UrlConverter;
32
+ //# sourceMappingURL=url.converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.converter.js","sourceRoot":"","sources":["../../src/converters/url.converter.ts"],"names":[],"mappings":";;;;AAAA,6BAA0B;AAE1B,kEAAiC;AAIjC,+DAA2D;AAC3D,mDAAgD;AAChD,gDAAuC;AAEvC,MAAa,YAAa,SAAQ,qBAAS;IACzC;QACE,KAAK,CAAC,mBAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEK,OAAO,CAAC,EACZ,GAAG,EACH,UAAU,GAIX;;YACC,IAAI;gBACF,MAAM,IAAI,GAAG,IAAI,SAAG,CAAC,GAAG,CAAC,CAAC;gBAC1B,MAAM,IAAI,GAAG,IAAI,mBAAQ,EAAE,CAAC;gBAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9B,IAAI,UAAU,EAAE;oBACd,gCAAc,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;iBACvD;gBACD,OAAO,gCAAc,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;aAClD;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;CACF;AAxBD,oCAwBC"}
@@ -0,0 +1,4 @@
1
+ import "dotenv/config";
2
+ export declare class Gotenberg {
3
+ static endpoint: string;
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Gotenberg = void 0;
4
+ const tslib_1 = require("tslib");
5
+ process.env.SUPPRESS_NO_CONFIG_WARNING = "y";
6
+ require("dotenv/config");
7
+ const config_1 = tslib_1.__importDefault(require("config"));
8
+ class Gotenberg {
9
+ }
10
+ exports.Gotenberg = Gotenberg;
11
+ Gotenberg.endpoint = process.env.GOTENBERG_ENDPOINT || config_1.default.get("gotenberg.endpoint");
12
+ //# sourceMappingURL=gotenberg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gotenberg.js","sourceRoot":"","sources":["../src/gotenberg.ts"],"names":[],"mappings":";;;;AAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,GAAG,CAAC;AAE7C,yBAAuB;AACvB,4DAA4B;AAE5B,MAAa,SAAS;;AAAtB,8BAGC;AAFe,kBAAQ,GACpB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,gBAAM,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare enum Route {
2
+ URL = "url",
3
+ HTML = "html",
4
+ MARKDOWN = "markdown"
5
+ }
6
+ export declare class Chromiumly {
7
+ private static readonly GOTENBERG_ENDPOINT;
8
+ private static readonly PATH;
9
+ private static readonly ROUTES;
10
+ static readonly endpoint: string;
11
+ static readonly path = "forms/chromium/convert";
12
+ static readonly routes: {
13
+ url: Route;
14
+ html: Route;
15
+ markdown: Route;
16
+ };
17
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Chromiumly = exports.Route = void 0;
4
+ const gotenberg_1 = require("./gotenberg");
5
+ var Route;
6
+ (function (Route) {
7
+ Route["URL"] = "url";
8
+ Route["HTML"] = "html";
9
+ Route["MARKDOWN"] = "markdown";
10
+ })(Route = exports.Route || (exports.Route = {}));
11
+ class Chromiumly {
12
+ }
13
+ exports.Chromiumly = Chromiumly;
14
+ Chromiumly.GOTENBERG_ENDPOINT = gotenberg_1.Gotenberg.endpoint;
15
+ Chromiumly.PATH = "forms/chromium/convert";
16
+ Chromiumly.ROUTES = {
17
+ url: Route.URL,
18
+ html: Route.HTML,
19
+ markdown: Route.MARKDOWN,
20
+ };
21
+ Chromiumly.endpoint = Chromiumly.GOTENBERG_ENDPOINT;
22
+ Chromiumly.path = Chromiumly.PATH;
23
+ Chromiumly.routes = Chromiumly.ROUTES;
24
+ //# sourceMappingURL=main.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.config.js","sourceRoot":"","sources":["../src/main.config.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,oBAAW,CAAA;IACX,sBAAa,CAAA;IACb,8BAAqB,CAAA;AACvB,CAAC,EAJW,KAAK,GAAL,aAAK,KAAL,aAAK,QAIhB;AAED,MAAa,UAAU;;AAAvB,gCAcC;AAbyB,6BAAkB,GAAG,qBAAS,CAAC,QAAQ,CAAC;AAExC,eAAI,GAAG,wBAAwB,CAAC;AAEhC,iBAAM,GAAG;IAC/B,GAAG,EAAE,KAAK,CAAC,GAAG;IACd,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;CACzB,CAAC;AAEqB,mBAAQ,GAAG,UAAU,CAAC,kBAAkB,CAAC;AACzC,eAAI,GAAG,UAAU,CAAC,IAAI,CAAC;AACvB,iBAAM,GAAG,UAAU,CAAC,MAAM,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { HtmlConverter } from "./converters/html.converter";
2
+ export { MarkdownConverter } from "./converters/markdown.converter";
3
+ export { UrlConverter } from "./converters/url.converter";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAAA,8DAA4D;AAAnD,+GAAA,aAAa,OAAA;AACtB,sEAAoE;AAA3D,uHAAA,iBAAiB,OAAA;AAC1B,4DAA0D;AAAjD,6GAAA,YAAY,OAAA"}
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "chromiumly",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "A lightweight Typescrpit library which interacts with Gotenberg's Chromium module to convert HTML documents to PDF.",
5
5
  "main": "dist/main.js",
6
+ "types": "dist/main.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
6
11
  "repository": {
7
12
  "type": "git",
8
13
  "url": "https://github.com/cherfia/chromiumly.git"
@@ -12,6 +17,13 @@
12
17
  "engines": {
13
18
  "node": "14.x"
14
19
  },
20
+ "keywords": [
21
+ "gotenberg",
22
+ "chromium",
23
+ "html",
24
+ "markdown",
25
+ "pdf"
26
+ ],
15
27
  "scripts": {
16
28
  "clean": "rm -rf dist build",
17
29
  "lint": "eslint src/ --ext .js,.ts",
package/src/.DS_Store ADDED
Binary file
@@ -1,17 +0,0 @@
1
- name: Publish
2
- on:
3
- release:
4
- types: [published]
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - uses: actions/setup-node@v2
11
- with:
12
- node-version: '14.x'
13
- registry-url: 'https://registry.npmjs.org'
14
- - run: yarn
15
- - run: yarn publish --access public
16
- env:
17
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "module": "commonjs",
5
- "moduleResolution": "node",
6
- "declaration": true,
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "strictFunctionTypes": true,
11
- "noUnusedLocals": true,
12
- "noUnusedParameters": true,
13
- "noImplicitReturns": true,
14
- "noFallthroughCasesInSwitch": true,
15
- "importHelpers": true,
16
- "skipLibCheck": true,
17
- "esModuleInterop": true,
18
- "allowSyntheticDefaultImports": true,
19
- "experimentalDecorators": true,
20
- "sourceMap": true,
21
- "outDir": "./dist",
22
- "types": ["node"],
23
- "lib": ["ES6"]
24
- },
25
- "include": ["src/**/*.ts"],
26
- "exclude": ["node_modules", "**/*.test.ts"]
27
- }