asma-doc-viewer 1.0.4 → 1.0.7

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.
@@ -1,8 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
3
6
  <component name="ChangeListManager">
4
7
  <list default="true" id="2420ee6f-9c38-476f-82bf-3c5a7aca550a" name="Changes" comment="">
5
- <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
9
  </list>
7
10
  <option name="SHOW_DIALOG" value="false" />
8
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -14,28 +17,78 @@
14
17
  </component>
15
18
  <component name="Git.Settings">
16
19
  <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
20
+ <option name="RESET_MODE" value="HARD" />
21
+ </component>
22
+ <component name="GitLabMergeRequestsSettings">{}</component>
23
+ <component name="GitToolBoxStore">
24
+ <option name="recentBranches">
25
+ <RecentBranches>
26
+ <option name="branchesForRepo">
27
+ <list>
28
+ <RecentBranchesForRepo>
29
+ <option name="branches">
30
+ <list>
31
+ <RecentBranch>
32
+ <option name="branchName" value="feat/ASMA-2845-new-api-webp" />
33
+ <option name="lastUsedInstant" value="1708986544" />
34
+ </RecentBranch>
35
+ <RecentBranch>
36
+ <option name="branchName" value="master" />
37
+ <option name="lastUsedInstant" value="1708986214" />
38
+ </RecentBranch>
39
+ </list>
40
+ </option>
41
+ <option name="repositoryRootUrl" value="file://$PROJECT_DIR$" />
42
+ </RecentBranchesForRepo>
43
+ </list>
44
+ </option>
45
+ </RecentBranches>
46
+ </option>
17
47
  </component>
48
+ <component name="GithubPullRequestsUISettings">{}</component>
49
+ <component name="KubernetesApiProvider">{}</component>
18
50
  <component name="MarkdownSettingsMigration">
19
51
  <option name="stateVersion" value="1" />
20
52
  </component>
53
+ <component name="ProjectColorInfo">{}</component>
21
54
  <component name="ProjectId" id="25ENHDhJCwOrfTBlC0Ap5oFVrBf" />
22
55
  <component name="ProjectViewState">
23
56
  <option name="hideEmptyMiddlePackages" value="true" />
24
57
  <option name="showLibraryContents" value="true" />
25
58
  </component>
26
- <component name="PropertiesComponent">
27
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
28
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
29
- <property name="WebServerToolWindowFactoryState" value="false" />
30
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
31
- <property name="node.js.detected.package.eslint" value="true" />
32
- <property name="node.js.selected.package.eslint" value="(autodetect)" />
33
- <property name="nodejs_package_manager_path" value="yarn" />
34
- <property name="project.structure.last.edited" value="Project" />
35
- <property name="project.structure.proportion" value="0.0" />
36
- <property name="project.structure.side.proportion" value="0.0" />
37
- <property name="settings.editor.selected.configurable" value="Settings.Markdown" />
38
- <property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
59
+ <component name="PropertiesComponent"><![CDATA[{
60
+ "keyToString": {
61
+ "git-widget-placeholder": "feat/ASMA-2845-new-api-webp",
62
+ "last_opened_file_path": "/Users/utopiaeh/Developer/carasent/srv/doc-viewer/src/plugins",
63
+ "node.js.selected.package.tslint": "(autodetect)",
64
+ "npm.build.executor": "Run",
65
+ "ts.external.directory.path": "/Users/utopiaeh/Developer/carasent/srv/doc-viewer/node_modules/typescript/lib"
66
+ }
67
+ }]]></component>
68
+ <component name="RecentsManager">
69
+ <key name="CopyFile.RECENT_KEYS">
70
+ <recent name="$PROJECT_DIR$/src/plugins" />
71
+ </key>
72
+ <key name="MoveFile.RECENT_KEYS">
73
+ <recent name="$PROJECT_DIR$" />
74
+ </key>
75
+ </component>
76
+ <component name="RunManager">
77
+ <configuration name="build" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
78
+ <package-json value="$PROJECT_DIR$/package.json" />
79
+ <command value="run" />
80
+ <scripts>
81
+ <script value="build" />
82
+ </scripts>
83
+ <node-interpreter value="project" />
84
+ <envs />
85
+ <method v="2" />
86
+ </configuration>
87
+ <recent_temporary>
88
+ <list>
89
+ <item itemvalue="npm.build" />
90
+ </list>
91
+ </recent_temporary>
39
92
  </component>
40
93
  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
41
94
  <component name="TaskManager">
@@ -40,7 +40,7 @@ var ProxyRenderer = function () {
40
40
  var documents = state.documents, documentLoading = state.documentLoading, currentDocument = state.currentDocument;
41
41
  var size = (0, useWindowSize_1.useWindowSize)();
42
42
  var containerRef = (0, react_1.useCallback)(function (node) {
43
- node && dispatch((0, actions_1.setRendererRect)(node === null || node === void 0 ? void 0 : node.getBoundingClientRect()));
43
+ node && dispatch((0, actions_1.setRendererRect)(node.getBoundingClientRect()));
44
44
  },
45
45
  // eslint-disable-next-line react-hooks/exhaustive-deps
46
46
  [size]);
@@ -72,9 +72,9 @@ var ProxyRenderer = function () {
72
72
  react_1.default.createElement(Contents, null)));
73
73
  };
74
74
  exports.ProxyRenderer = ProxyRenderer;
75
- var Container = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n overflow-y: auto;\n"], ["\n display: flex;\n flex: 1;\n overflow-y: auto;\n"])));
76
- var LoadingContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n height: 75px;\n align-items: center;\n justify-content: center;\n"], ["\n display: flex;\n flex: 1;\n height: 75px;\n align-items: center;\n justify-content: center;\n"])));
77
- var spinAnim = (0, styled_components_1.keyframes)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"], ["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"])));
78
- var LoadingIconContainer = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n animation-name: ", ";\n animation-duration: 4s;\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n"], ["\n animation-name: ", ";\n animation-duration: 4s;\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n"])), spinAnim);
79
- var DownloadButton = (0, styled_components_1.default)(common_1.LinkButton)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 130px;\n height: 30px;\n background-color: ", ";\n @media (max-width: 768px) {\n width: 125px;\n height: 25px;\n }\n"], ["\n width: 130px;\n height: 30px;\n background-color: ", ";\n @media (max-width: 768px) {\n width: 125px;\n height: 25px;\n }\n"])), function (props) { return props.theme.primary; });
75
+ var Container = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n overflow-y: auto;\n"], ["\n display: flex;\n flex: 1;\n overflow-y: auto;\n"])));
76
+ var LoadingContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n height: 75px;\n align-items: center;\n justify-content: center;\n"], ["\n display: flex;\n flex: 1;\n height: 75px;\n align-items: center;\n justify-content: center;\n"])));
77
+ var spinAnim = (0, styled_components_1.keyframes)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"], ["\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n"])));
78
+ var LoadingIconContainer = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n animation-name: ", ";\n animation-duration: 4s;\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n"], ["\n animation-name: ", ";\n animation-duration: 4s;\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n"])), spinAnim);
79
+ var DownloadButton = (0, styled_components_1.default)(common_1.LinkButton)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 130px;\n height: 30px;\n background-color: ", ";\n @media (max-width: 768px) {\n width: 125px;\n height: 25px;\n }\n"], ["\n width: 130px;\n height: 30px;\n background-color: ", ";\n @media (max-width: 768px) {\n width: 125px;\n height: 25px;\n }\n"])), function (props) { return props.theme.primary; });
80
80
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -2,10 +2,10 @@ import { IStyledProps } from "../../types";
2
2
  interface ButtonProps extends IStyledProps {
3
3
  disabled?: boolean;
4
4
  }
5
- export declare const ButtonPrimaryStyle: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
6
- export declare const ButtonSecondaryStyle: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
5
+ export declare const ButtonPrimaryStyle: import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<IStyledProps, any>>;
6
+ export declare const ButtonSecondaryStyle: import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<IStyledProps, any>>;
7
7
  export declare const Button: import("styled-components").StyledComponent<"button", any, ButtonProps, never>;
8
- export declare const LinkButton: import("styled-components").StyledComponent<"a", any, {}, never>;
8
+ export declare const LinkButton: import("styled-components").StyledComponent<"a", any, IStyledProps, never>;
9
9
  export declare const ButtonPrimary: import("styled-components").StyledComponent<"button", any, ButtonProps, never>;
10
10
  export declare const ButtonSecondary: import("styled-components").StyledComponent<"button", any, ButtonProps, never>;
11
11
  export {};
@@ -1,8 +1,9 @@
1
+ import React from "react";
1
2
  export interface IIconProps {
2
3
  color?: string;
3
4
  size?: string | number | (string & {}) | undefined;
4
5
  reverse?: boolean;
5
6
  }
6
- export declare const PrevDocIcon: (props: IIconProps) => JSX.Element;
7
- export declare const NextDocIcon: (props: IIconProps) => JSX.Element;
8
- export declare const LoadingIcon: (props: IIconProps) => JSX.Element;
7
+ export declare const PrevDocIcon: (props: IIconProps) => React.JSX.Element;
8
+ export declare const NextDocIcon: (props: IIconProps) => React.JSX.Element;
9
+ export declare const LoadingIcon: (props: IIconProps) => React.JSX.Element;
@@ -34,12 +34,12 @@ var LoadingIcon = function (props) {
34
34
  return (react_1.default.createElement("svg", { width: size || "100%", height: size || "100%", version: "1.1", id: "Icons", viewBox: "0 0 32 32", xmlSpace: "preserve", style: { alignSelf: "center", justifySelf: "center" } },
35
35
  react_1.default.createElement("g", null,
36
36
  react_1.default.createElement("path", { fill: color || "#aaa", d: "M16,2c-0.6,0-1,0.4-1,1v5c0,0.6,0.4,1,1,1s1-0.4,1-1V3C17,2.4,16.6,2,16,2z" }),
37
- react_1.default.createElement("path", { fill: color || "#aaa", d: "M7.5,6.1c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l3.5,3.5c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.5,6.1\r\n\t\tz" }),
37
+ react_1.default.createElement("path", { fill: color || "#aaa", d: "M7.5,6.1c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l3.5,3.5c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.5,6.1\n\t\tz" }),
38
38
  react_1.default.createElement("path", { fill: color || "#aaa", d: "M9,16c0-0.6-0.4-1-1-1H3c-0.6,0-1,0.4-1,1s0.4,1,1,1h5C8.6,17,9,16.6,9,16z" }),
39
- react_1.default.createElement("path", { fill: color || "#aaa", d: "M9.6,20.9l-3.5,3.5c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l3.5-3.5c0.4-0.4,0.4-1,0-1.4\r\n\t\tS10,20.6,9.6,20.9z" }),
39
+ react_1.default.createElement("path", { fill: color || "#aaa", d: "M9.6,20.9l-3.5,3.5c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l3.5-3.5c0.4-0.4,0.4-1,0-1.4\n\t\tS10,20.6,9.6,20.9z" }),
40
40
  react_1.default.createElement("path", { fill: color || "#aaa", d: "M16,23c-0.6,0-1,0.4-1,1v5c0,0.6,0.4,1,1,1s1-0.4,1-1v-5C17,23.4,16.6,23,16,23z" }),
41
- react_1.default.createElement("path", { fill: color || "#aaa", d: "M22.4,20.9c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l3.5,3.5c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4\r\n\t\tL22.4,20.9z" }),
41
+ react_1.default.createElement("path", { fill: color || "#aaa", d: "M22.4,20.9c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l3.5,3.5c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4\n\t\tL22.4,20.9z" }),
42
42
  react_1.default.createElement("path", { fill: color || "#aaa", d: "M29,15h-5c-0.6,0-1,0.4-1,1s0.4,1,1,1h5c0.6,0,1-0.4,1-1S29.6,15,29,15z" }),
43
- react_1.default.createElement("path", { fill: color || "#aaa", d: "M21.7,11.3c0.3,0,0.5-0.1,0.7-0.3l3.5-3.5c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-3.5,3.5c-0.4,0.4-0.4,1,0,1.4\r\n\t\tC21.1,11.2,21.4,11.3,21.7,11.3z" }))));
43
+ react_1.default.createElement("path", { fill: color || "#aaa", d: "M21.7,11.3c0.3,0,0.5-0.1,0.7-0.3l3.5-3.5c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-3.5,3.5c-0.4,0.4-0.4,1,0,1.4\n\t\tC21.1,11.2,21.4,11.3,21.7,11.3z" }))));
44
44
  };
45
45
  exports.LoadingIcon = LoadingIcon;
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CSSProperties, FC } from "react";
1
+ import React, { CSSProperties, FC } from "react";
2
2
  import BMPRenderer from "./plugins/bmp";
3
3
  import HTMLRenderer from "./plugins/html";
4
4
  import ImageProxyRenderer from "./plugins/image";
@@ -16,6 +16,7 @@ export interface DocViewerProps {
16
16
  config?: IConfig;
17
17
  theme?: ITheme;
18
18
  pluginRenderers?: DocRenderer[];
19
+ children?: React.ReactNode;
19
20
  }
20
21
  declare const DocViewer: FC<DocViewerProps>;
21
22
  export default DocViewer;
@@ -12,6 +12,7 @@ var pdf_1 = __importDefault(require("./pdf"));
12
12
  var png_1 = __importDefault(require("./png"));
13
13
  var tiff_1 = __importDefault(require("./tiff"));
14
14
  var txt_1 = __importDefault(require("./txt"));
15
+ var webp_1 = __importDefault(require("./webp"));
15
16
  exports.DocViewerRenderers = [
16
17
  bmp_1.default,
17
18
  html_1.default,
@@ -21,4 +22,5 @@ exports.DocViewerRenderers = [
21
22
  png_1.default,
22
23
  tiff_1.default,
23
24
  txt_1.default,
25
+ webp_1.default,
24
26
  ];
@@ -38,13 +38,25 @@ var actions_1 = require("../state/actions");
38
38
  var reducer_1 = require("../state/reducer");
39
39
  var icons_1 = require("./icons");
40
40
  var PDFPagination_1 = __importDefault(require("./PDFPagination"));
41
+ var print_js_1 = __importDefault(require("print-js"));
41
42
  var PDFControls = function () {
42
43
  var _a = (0, react_1.useContext)(state_1.PDFContext), _b = _a.state, mainState = _b.mainState, paginated = _b.paginated, zoomLevel = _b.zoomLevel, numPages = _b.numPages, dispatch = _a.dispatch;
43
44
  var currentDocument = (mainState === null || mainState === void 0 ? void 0 : mainState.currentDocument) || null;
45
+ var handlePrint = function () {
46
+ var _a, _b;
47
+ var print_base64 = (_a = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileData) === null || _a === void 0 ? void 0 : _a.toString().slice(((_b = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileData) === null || _b === void 0 ? void 0 : _b.toString().indexOf(',')) + 1);
48
+ (0, print_js_1.default)({
49
+ printable: print_base64,
50
+ type: 'pdf',
51
+ base64: true,
52
+ });
53
+ };
44
54
  return (react_1.default.createElement(Container, { id: "pdf-controls" },
45
55
  paginated && numPages > 1 && react_1.default.createElement(PDFPagination_1.default, null),
46
56
  (currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileData) && (react_1.default.createElement(DownloadButton, { id: "pdf-download", href: currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileData, download: (currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileName) || (currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.uri) },
47
57
  react_1.default.createElement(icons_1.DownloadPDFIcon, { color: "#000", size: "75%" }))),
58
+ react_1.default.createElement(ControlButton, { id: "pdf-print", onClick: handlePrint },
59
+ react_1.default.createElement(icons_1.PrintPDFIcon, { color: "#000", size: "65%" })),
48
60
  react_1.default.createElement(ControlButton, { id: "pdf-zoom-out", onMouseDown: function () { return dispatch((0, actions_1.setZoomLevel)(zoomLevel - 0.1)); } },
49
61
  react_1.default.createElement(icons_1.ZoomOutPDFIcon, { color: "#000", size: "80%" })),
50
62
  react_1.default.createElement(ControlButton, { id: "pdf-zoom-in", onMouseDown: function () { return dispatch((0, actions_1.setZoomLevel)(zoomLevel + 0.1)); } },
@@ -1,8 +1,10 @@
1
+ import React from "react";
1
2
  import { IIconProps } from "../../../../components/icons";
2
- export declare const PrevPDFNavIcon: (props: IIconProps) => JSX.Element;
3
- export declare const NextPDFNavIcon: (props: IIconProps) => JSX.Element;
4
- export declare const DownloadPDFIcon: (props: IIconProps) => JSX.Element;
5
- export declare const ZoomInPDFIcon: (props: IIconProps) => JSX.Element;
6
- export declare const ZoomOutPDFIcon: (props: IIconProps) => JSX.Element;
7
- export declare const ResetZoomPDFIcon: (props: IIconProps) => JSX.Element;
8
- export declare const TogglePaginationPDFIcon: (props: IIconProps) => JSX.Element;
3
+ export declare const PrevPDFNavIcon: (props: IIconProps) => React.JSX.Element;
4
+ export declare const NextPDFNavIcon: (props: IIconProps) => React.JSX.Element;
5
+ export declare const DownloadPDFIcon: (props: IIconProps) => React.JSX.Element;
6
+ export declare const ZoomInPDFIcon: (props: IIconProps) => React.JSX.Element;
7
+ export declare const ZoomOutPDFIcon: (props: IIconProps) => React.JSX.Element;
8
+ export declare const ResetZoomPDFIcon: (props: IIconProps) => React.JSX.Element;
9
+ export declare const TogglePaginationPDFIcon: (props: IIconProps) => React.JSX.Element;
10
+ export declare const PrintPDFIcon: (props: IIconProps) => React.JSX.Element;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.TogglePaginationPDFIcon = exports.ResetZoomPDFIcon = exports.ZoomOutPDFIcon = exports.ZoomInPDFIcon = exports.DownloadPDFIcon = exports.NextPDFNavIcon = exports.PrevPDFNavIcon = void 0;
17
+ exports.PrintPDFIcon = exports.TogglePaginationPDFIcon = exports.ResetZoomPDFIcon = exports.ZoomOutPDFIcon = exports.ZoomInPDFIcon = exports.DownloadPDFIcon = exports.NextPDFNavIcon = exports.PrevPDFNavIcon = void 0;
18
18
  var react_1 = __importDefault(require("react"));
19
19
  var PrevPDFNavIcon = function (props) {
20
20
  return react_1.default.createElement(PDFNavArrow, __assign({}, props, { reverse: true }));
@@ -68,6 +68,12 @@ exports.ResetZoomPDFIcon = ResetZoomPDFIcon;
68
68
  var TogglePaginationPDFIcon = function (props) {
69
69
  var color = props.color, size = props.size, reverse = props.reverse;
70
70
  return (react_1.default.createElement("svg", { width: size || "100%", height: size || "100%", style: { transform: "".concat(reverse ? "rotate(90deg)" : "") }, version: "1.1", id: "Scroll_1", viewBox: "0 0 297 297", xmlSpace: "preserve" },
71
- react_1.default.createElement("path", { fill: color || "#aaa", d: "M206.004,200.723h-31.231V96.277h31.231c0.005,0,0.014,0,0.019,0c5.289,0,9.575-4.287,9.575-9.574\r\n c0-2.342-0.841-4.488-2.236-6.151L156.168,3.851C154.36,1.428,151.515,0,148.492,0c-3.023,0-5.868,1.428-7.675,3.851L83.302,80.98\r\n c-2.166,2.902-2.507,6.779-0.883,10.017c1.624,3.236,4.936,5.28,8.559,5.28h31.231v104.445H90.978c-3.623,0-6.934,2.044-8.559,5.28\r\n c-1.624,3.237-1.283,7.114,0.883,10.017l57.513,77.129c1.808,2.424,4.652,3.852,7.675,3.852c3.023,0,5.868-1.428,7.676-3.852\r\n l57.514-77.129c2.164-2.902,2.507-6.779,0.883-10.017C212.938,202.767,209.627,200.723,206.004,200.723z" })));
71
+ react_1.default.createElement("path", { fill: color || "#aaa", d: "M206.004,200.723h-31.231V96.277h31.231c0.005,0,0.014,0,0.019,0c5.289,0,9.575-4.287,9.575-9.574\n c0-2.342-0.841-4.488-2.236-6.151L156.168,3.851C154.36,1.428,151.515,0,148.492,0c-3.023,0-5.868,1.428-7.675,3.851L83.302,80.98\n c-2.166,2.902-2.507,6.779-0.883,10.017c1.624,3.236,4.936,5.28,8.559,5.28h31.231v104.445H90.978c-3.623,0-6.934,2.044-8.559,5.28\n c-1.624,3.237-1.283,7.114,0.883,10.017l57.513,77.129c1.808,2.424,4.652,3.852,7.675,3.852c3.023,0,5.868-1.428,7.676-3.852\n l57.514-77.129c2.164-2.902,2.507-6.779,0.883-10.017C212.938,202.767,209.627,200.723,206.004,200.723z" })));
72
72
  };
73
73
  exports.TogglePaginationPDFIcon = TogglePaginationPDFIcon;
74
+ var PrintPDFIcon = function (props) {
75
+ var color = props.color, size = props.size, reverse = props.reverse;
76
+ return (react_1.default.createElement("svg", { width: size || "100%", height: size || "100%", style: { transform: "".concat(reverse ? "rotate(180deg)" : "") }, id: "Layer_1", viewBox: "0 0 512 512" },
77
+ react_1.default.createElement("path", { d: "M128 0C92.7 0 64 28.7 64 64v96h64V64H354.7L384 93.3V160h64V93.3c0-17-6.7-33.3-18.7-45.3L400 18.7C388 6.7 371.7 0 354.7 0H128zM384 352v32 64H128V384 368 352H384zm64 32h32c17.7 0 32-14.3 32-32V256c0-35.3-28.7-64-64-64H64c-35.3 0-64 28.7-64 64v96c0 17.7 14.3 32 32 32H64v64c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V384zM432 248a24 24 0 1 1 0 48 24 24 0 1 1 0-48z" })));
78
+ };
79
+ exports.PrintPDFIcon = PrintPDFIcon;
@@ -22,4 +22,4 @@ export interface SetCurrentPage {
22
22
  value: number;
23
23
  }
24
24
  export declare const setCurrentPage: (value: number) => SetCurrentPage;
25
- export declare type PDFActions = SetZoomLevel | SetPDFPaginated | SetNumPages | SetCurrentPage;
25
+ export type PDFActions = SetZoomLevel | SetPDFPaginated | SetNumPages | SetCurrentPage;
@@ -1,4 +1,4 @@
1
- import React, { Dispatch, FC } from "react";
1
+ import React, { Dispatch, FC, ReactNode } from "react";
2
2
  import { IMainState } from "../../../state/reducer";
3
3
  import { PDFActions } from "./actions";
4
4
  import { IPDFState } from "./reducer";
@@ -8,5 +8,6 @@ declare const PDFContext: React.Context<{
8
8
  }>;
9
9
  declare const PDFProvider: FC<{
10
10
  mainState: IMainState;
11
+ children: ReactNode;
11
12
  }>;
12
13
  export { PDFContext, PDFProvider };
@@ -1,6 +1,6 @@
1
1
  import { IMainState } from "../../../state/reducer";
2
2
  import { PDFActions as PDFStateActions } from "./actions";
3
- export declare type IPDFState = {
3
+ export type IPDFState = {
4
4
  zoomLevel: number;
5
5
  paginated: boolean;
6
6
  numPages: number;
@@ -8,5 +8,5 @@ export declare type IPDFState = {
8
8
  mainState?: IMainState;
9
9
  };
10
10
  export declare const initialPDFState: IPDFState;
11
- export declare type PDFStateReducer = (state: IPDFState, action: PDFStateActions) => IPDFState;
11
+ export type PDFStateReducer = (state: IPDFState, action: PDFStateActions) => IPDFState;
12
12
  export declare const reducer: PDFStateReducer;
@@ -12,7 +12,9 @@ var styled_components_1 = __importDefault(require("styled-components"));
12
12
  var fileLoaders_1 = require("../../utils/fileLoaders");
13
13
  var TXTRenderer = function (_a) {
14
14
  var currentDocument = _a.mainState.currentDocument;
15
- return react_1.default.createElement(Container, { id: "txt-renderer" }, currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.fileData);
15
+ if (!currentDocument || !currentDocument.fileData)
16
+ return null;
17
+ return react_1.default.createElement(Container, { id: "txt-renderer" }, currentDocument.fileData);
16
18
  };
17
19
  exports.default = TXTRenderer;
18
20
  TXTRenderer.fileTypes = ["txt", "text/plain"];
@@ -0,0 +1,3 @@
1
+ import { DocRenderer } from "../../types";
2
+ declare const WEBPRenderer: DocRenderer;
3
+ export default WEBPRenderer;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var react_1 = __importStar(require("react"));
41
+ var image_1 = __importDefault(require("../image"));
42
+ var WEBPRenderer = function (props) {
43
+ var _a;
44
+ var _b = (0, react_1.useState)(), imageUrl = _b[0], setImageUrl = _b[1];
45
+ var webpBuffer = (_a = props.mainState.currentDocument) === null || _a === void 0 ? void 0 : _a.fileData;
46
+ (0, react_1.useEffect)(function () {
47
+ if (webpBuffer) {
48
+ var blob = new Blob([webpBuffer], { type: 'image/webp' });
49
+ var url = URL.createObjectURL(blob);
50
+ setImageUrl(url);
51
+ }
52
+ }, [webpBuffer]);
53
+ return (react_1.default.createElement(image_1.default, __assign({}, props),
54
+ react_1.default.createElement("picture", null,
55
+ react_1.default.createElement("source", { srcSet: imageUrl }))));
56
+ };
57
+ WEBPRenderer.fileTypes = ["webp", "image/webp"];
58
+ WEBPRenderer.weight = 0;
59
+ exports.default = WEBPRenderer;
@@ -39,4 +39,4 @@ export interface SetMainConfig {
39
39
  config: IConfig;
40
40
  }
41
41
  export declare const setMainConfig: (config: IConfig) => SetMainConfig;
42
- export declare type MainStateActions = SetAllDocuments | SetDocumentLoading | NextDocument | PreviousDocument | UpdateCurrentDocument | SetRendererRect | SetMainConfig;
42
+ export type MainStateActions = SetAllDocuments | SetDocumentLoading | NextDocument | PreviousDocument | UpdateCurrentDocument | SetRendererRect | SetMainConfig;
@@ -1,6 +1,6 @@
1
1
  import { DocRenderer, IConfig, IDocument } from "../types";
2
2
  import { MainStateActions } from "./actions";
3
- export declare type IMainState = {
3
+ export type IMainState = {
4
4
  currentFileNo: number;
5
5
  documents: IDocument[];
6
6
  documentLoading?: boolean;
@@ -10,5 +10,5 @@ export declare type IMainState = {
10
10
  pluginRenderers?: DocRenderer[];
11
11
  };
12
12
  export declare const initialState: IMainState;
13
- export declare type MainStateReducer = (state: IMainState, action: MainStateActions) => IMainState;
13
+ export type MainStateReducer = (state: IMainState, action: MainStateActions) => IMainState;
14
14
  export declare const mainStateReducer: MainStateReducer;
@@ -11,7 +11,7 @@ export interface IHeaderConfig {
11
11
  retainURLParams?: boolean;
12
12
  overrideComponent?: IHeaderOverride;
13
13
  }
14
- export declare type IHeaderOverride = (state: IMainState, previousDocument: () => void, nextDocument: () => void) => ReactElement<any, any> | null;
14
+ export type IHeaderOverride = (state: IMainState, previousDocument: () => void, nextDocument: () => void) => ReactElement<any, any> | null;
15
15
  export interface ITheme {
16
16
  primary?: string;
17
17
  secondary?: string;
@@ -32,6 +32,7 @@ export interface IDocument {
32
32
  }
33
33
  export interface DocRendererProps {
34
34
  mainState: IMainState;
35
+ children?: ReactElement<any, any> | null;
35
36
  }
36
37
  export interface DocRenderer extends FC<DocRendererProps> {
37
38
  fileTypes: string[];
@@ -3,8 +3,8 @@ export interface FileLoaderFuncProps {
3
3
  signal: AbortSignal;
4
4
  fileLoaderComplete: FileLoaderComplete;
5
5
  }
6
- export declare type FileLoaderComplete = (fileReader?: FileReader) => void;
7
- export declare type FileLoaderFunction = (props: FileLoaderFuncProps) => void;
6
+ export type FileLoaderComplete = (fileReader?: FileReader) => void;
7
+ export type FileLoaderFunction = (props: FileLoaderFuncProps) => void;
8
8
  export declare const arrayBufferFileLoader: FileLoaderFunction;
9
9
  export declare const dataURLFileLoader: FileLoaderFunction;
10
10
  export declare const textFileLoader: FileLoaderFunction;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asma-doc-viewer",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "test",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -11,6 +11,7 @@
11
11
  "types": "build/index.d.ts",
12
12
  "dependencies": {
13
13
  "pdfjs-dist": "2.4.456",
14
+ "print-js": "^1.6.0",
14
15
  "react-pdf": "5.0.0",
15
16
  "styled-components": "^5.3.5"
16
17
  },
@@ -29,11 +30,11 @@
29
30
  "react": "^18.0.14",
30
31
  "react-dom": "^18.0.14",
31
32
  "react-scripts": "5.0.1",
32
- "typescript": "^4.7.4"
33
+ "typescript": "^5.1.6"
33
34
  },
34
35
  "scripts": {
35
36
  "start": "react-scripts start",
36
- "build": "del -rf build & tsc -p tsconfig-npm.json",
37
+ "build": "rm -rf build/* && tsc -p tsconfig-npm.json",
37
38
  "test": "react-scripts test",
38
39
  "eject": "react-scripts eject",
39
40
  "version:patch": "npm run version:pre && npm run version:changelog && npm version patch && npm run version:post",