From cf7a1e0b54fbc2660e34920315666bb016e09dd6 Mon Sep 17 00:00:00 2001 From: Sam Tsai Date: Wed, 19 Sep 2018 14:57:53 -0400 Subject: [PATCH 1/4] Use `PrintTypes` as type --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 43f7bf5..ec65223 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,7 +5,7 @@ declare type PrintTypes = 'pdf' | 'html' | 'image' | 'json'; export interface Configuration { printable: any; fallbackPrintable?: string; - type?: string; + type?: PrintTypes; documentTitle?: string; header?: any; headerStyle?: string; From c0bf252612d786745f29ec779a73ef50d437b2ac Mon Sep 17 00:00:00 2001 From: Sam Tsai Date: Wed, 19 Sep 2018 15:01:25 -0400 Subject: [PATCH 2/4] Add "types" field Though no required since it is the default named `index.d.ts` and at root, it is still advisable. @see https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index eaf7f39..8521040 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A tiny javascript library to help printing from the web.", "version": "1.0.51", "main": "dist/print.js", + "types": "./index.d.ts", "repository": "https://github.com/crabbly/Print.js", "license": "MIT", "dependences": {}, From ceac6c12c8e9f7df41e18a8cee9e4a1a1bbe0b96 Mon Sep 17 00:00:00 2001 From: Sam Tsai Date: Wed, 19 Sep 2018 15:04:48 -0400 Subject: [PATCH 3/4] Update usage to use `printJS` We need to use the exported `printJS` function. Previous instructions was slightly misleading as this can be used as a global library or an exported module function. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d80b3a7..ac59cf7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ yarn add print-js When installing via npm or yarn, import the library into your project: ``` -import print from 'print-js' +import printJS from 'print-js' ``` ## Documentation From cc4fa86c06c5a531d4b9cfd696134288dd73ad48 Mon Sep 17 00:00:00 2001 From: Sam Tsai Date: Thu, 20 Sep 2018 09:27:06 -0400 Subject: [PATCH 4/4] Make module name and typings consistent Change interface to use `printJS` both as an import as well as on window object. --- index.d.ts | 54 +++++++++++++++++++++++------------------------ src/index.js | 6 +++--- webpack.config.js | 2 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/index.d.ts b/index.d.ts index ec65223..be8279e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,33 +3,33 @@ import 'print-js/dist/print'; declare type PrintTypes = 'pdf' | 'html' | 'image' | 'json'; export interface Configuration { - printable: any; - fallbackPrintable?: string; - type?: PrintTypes; - documentTitle?: string; - header?: any; - headerStyle?: string; - maxWidth?: number; - font?: string; - font_size?: string; - honorMarginPadding?: boolean; - honorColor?: boolean; - targetStyle?: string | string[]; - targetStyles?: string | string[]; - properties?: any; - gridHeaderStyle?: string; - gridStyle?: string; - showModal?: boolean; - onLoadingStart?: () => void; - onLoadingEnd?: () => void; - modalMessage?: string; - frameId?: string; - ignoreElements?: string | string[]; - imageStyle?: string; - repeatTableHeader?: boolean; - css?: string | string[]; - style?: string; - scanStyles?: boolean; + printable: any; + fallbackPrintable?: string; + type?: PrintTypes; + documentTitle?: string; + header?: any; + headerStyle?: string; + maxWidth?: number; + font?: string; + font_size?: string; + honorMarginPadding?: boolean; + honorColor?: boolean; + targetStyle?: string | string[]; + targetStyles?: string | string[]; + properties?: any; + gridHeaderStyle?: string; + gridStyle?: string; + showModal?: boolean; + onLoadingStart?: () => void; + onLoadingEnd?: () => void; + modalMessage?: string; + frameId?: string; + ignoreElements?: string | string[]; + imageStyle?: string; + repeatTableHeader?: boolean; + css?: string | string[]; + style?: string; + scanStyles?: boolean; } declare var printJS: (params: string | Configuration) => void; diff --git a/src/index.js b/src/index.js index f6bc169..e4e40a3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,10 @@ import './sass/index.scss' import print from './js/init' -const printjs = print.init +const printJS = print.init if (typeof window !== 'undefined') { - window.printJS = printjs + window.printJS = printJS } -export default printjs +export default printJS diff --git a/webpack.config.js b/webpack.config.js index e589128..fc7b7af 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { './src/index.js' ], output: { - library: 'printJs', + library: 'printJS', libraryTarget: 'umd', path: path.resolve(__dirname, 'dist'), filename: 'print.js',