@nypl/web-reader 3.2.0 → 3.2.1
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/dist/cjs/index.js +20 -17
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +243 -182
- package/dist/esm/index.js.map +3 -3
- package/dist/types/HtmlReader/useIframeLinkClick.d.ts +2 -1
- package/dist/types/ui/Footer.d.ts +9 -0
- package/dist/types/ui/LoadingSkeleton.d.ts +6 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -13746,7 +13746,7 @@ var require_debounce = __commonJS({
|
|
|
13746
13746
|
});
|
|
13747
13747
|
|
|
13748
13748
|
// src/index.tsx
|
|
13749
|
-
import
|
|
13749
|
+
import React68 from "react";
|
|
13750
13750
|
|
|
13751
13751
|
// node_modules/@emotion/react/dist/emotion-react.browser.esm.js
|
|
13752
13752
|
import * as React2 from "react";
|
|
@@ -36640,6 +36640,9 @@ var ErrorBoundary = class extends React40.Component {
|
|
|
36640
36640
|
var ErrorBoundary_default = ErrorBoundary;
|
|
36641
36641
|
|
|
36642
36642
|
// src/ui/manager.tsx
|
|
36643
|
+
import * as React43 from "react";
|
|
36644
|
+
|
|
36645
|
+
// src/ui/Footer.tsx
|
|
36643
36646
|
import * as React42 from "react";
|
|
36644
36647
|
|
|
36645
36648
|
// src/ui/PageButton.tsx
|
|
@@ -36660,12 +36663,55 @@ function PageButton(props) {
|
|
|
36660
36663
|
}
|
|
36661
36664
|
var PageButton_default = PageButton;
|
|
36662
36665
|
|
|
36666
|
+
// src/ui/Footer.tsx
|
|
36667
|
+
var Footer = (_a) => {
|
|
36668
|
+
var _b = _a, {
|
|
36669
|
+
state: state2,
|
|
36670
|
+
navigator: navigator2
|
|
36671
|
+
} = _b, rest = __objRest(_b, [
|
|
36672
|
+
"state",
|
|
36673
|
+
"navigator"
|
|
36674
|
+
]);
|
|
36675
|
+
const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
|
|
36676
|
+
const isAtStart = state2 == null ? void 0 : state2.atStart;
|
|
36677
|
+
const isAtEnd = state2 == null ? void 0 : state2.atEnd;
|
|
36678
|
+
return /* @__PURE__ */ React42.createElement(Flex, __spreadValues({
|
|
36679
|
+
as: "footer",
|
|
36680
|
+
position: "sticky",
|
|
36681
|
+
height: `${FOOTER_HEIGHT}px`,
|
|
36682
|
+
zIndex: "sticky",
|
|
36683
|
+
bottom: "0",
|
|
36684
|
+
justifyContent: "space-between",
|
|
36685
|
+
w: "100%",
|
|
36686
|
+
bg: bgColor,
|
|
36687
|
+
borderTop: "1px solid",
|
|
36688
|
+
borderColor: "gray.100"
|
|
36689
|
+
}, rest), /* @__PURE__ */ React42.createElement(PageButton_default, {
|
|
36690
|
+
onClick: navigator2 == null ? void 0 : navigator2.goBackward,
|
|
36691
|
+
"aria-label": "Previous Page",
|
|
36692
|
+
disabled: isAtStart
|
|
36693
|
+
}, /* @__PURE__ */ React42.createElement(Icon, {
|
|
36694
|
+
as: MdKeyboardArrowLeft,
|
|
36695
|
+
w: 6,
|
|
36696
|
+
h: 6
|
|
36697
|
+
}), "Previous"), /* @__PURE__ */ React42.createElement(PageButton_default, {
|
|
36698
|
+
onClick: navigator2 == null ? void 0 : navigator2.goForward,
|
|
36699
|
+
"aria-label": "Next Page",
|
|
36700
|
+
disabled: isAtEnd
|
|
36701
|
+
}, "Next ", /* @__PURE__ */ React42.createElement(Icon, {
|
|
36702
|
+
as: MdKeyboardArrowRight,
|
|
36703
|
+
w: 6,
|
|
36704
|
+
h: 6
|
|
36705
|
+
})));
|
|
36706
|
+
};
|
|
36707
|
+
var Footer_default = Footer;
|
|
36708
|
+
|
|
36663
36709
|
// src/ui/manager.tsx
|
|
36664
36710
|
var ManagerUI = (props) => {
|
|
36665
36711
|
var _a, _b;
|
|
36666
|
-
return /* @__PURE__ */
|
|
36712
|
+
return /* @__PURE__ */ React43.createElement(ThemeProvider3, {
|
|
36667
36713
|
theme: getTheme3((_b = (_a = props.state) == null ? void 0 : _a.settings) == null ? void 0 : _b.colorMode)
|
|
36668
|
-
}, /* @__PURE__ */
|
|
36714
|
+
}, /* @__PURE__ */ React43.createElement(WebReaderContent, __spreadValues({}, props)));
|
|
36669
36715
|
};
|
|
36670
36716
|
var WebReaderContent = (_a) => {
|
|
36671
36717
|
var _b = _a, {
|
|
@@ -36675,19 +36721,16 @@ var WebReaderContent = (_a) => {
|
|
|
36675
36721
|
"children",
|
|
36676
36722
|
"headerLeft"
|
|
36677
36723
|
]);
|
|
36678
|
-
var _a2, _b2, _c, _d;
|
|
36679
36724
|
const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
|
|
36680
|
-
const containerRef =
|
|
36681
|
-
|
|
36682
|
-
const isAtEnd = (_b2 = props.state) == null ? void 0 : _b2.atEnd;
|
|
36683
|
-
return /* @__PURE__ */ React42.createElement(Flex, {
|
|
36725
|
+
const containerRef = React43.useRef(null);
|
|
36726
|
+
return /* @__PURE__ */ React43.createElement(Flex, {
|
|
36684
36727
|
flexDir: "column",
|
|
36685
36728
|
w: "100%",
|
|
36686
36729
|
position: "relative"
|
|
36687
|
-
}, !props.isLoading && /* @__PURE__ */
|
|
36730
|
+
}, !props.isLoading && /* @__PURE__ */ React43.createElement(Header, __spreadValues({
|
|
36688
36731
|
headerLeft,
|
|
36689
36732
|
containerRef
|
|
36690
|
-
}, props)), /* @__PURE__ */
|
|
36733
|
+
}, props)), /* @__PURE__ */ React43.createElement(Flex, {
|
|
36691
36734
|
as: "main",
|
|
36692
36735
|
ref: containerRef,
|
|
36693
36736
|
position: "relative",
|
|
@@ -36695,39 +36738,15 @@ var WebReaderContent = (_a) => {
|
|
|
36695
36738
|
flexDir: "column",
|
|
36696
36739
|
alignItems: "stretch",
|
|
36697
36740
|
flex: "1 1 auto"
|
|
36698
|
-
}, children), /* @__PURE__ */
|
|
36699
|
-
|
|
36700
|
-
|
|
36701
|
-
|
|
36702
|
-
zIndex: "docked",
|
|
36703
|
-
bottom: "0",
|
|
36704
|
-
justifyContent: "space-between",
|
|
36705
|
-
w: "100%",
|
|
36706
|
-
bg: bgColor,
|
|
36707
|
-
borderTop: "1px solid",
|
|
36708
|
-
borderColor: "gray.100"
|
|
36709
|
-
}, /* @__PURE__ */ React42.createElement(PageButton_default, {
|
|
36710
|
-
onClick: (_c = props.navigator) == null ? void 0 : _c.goBackward,
|
|
36711
|
-
"aria-label": "Previous Page",
|
|
36712
|
-
disabled: isAtStart
|
|
36713
|
-
}, /* @__PURE__ */ React42.createElement(Icon, {
|
|
36714
|
-
as: MdKeyboardArrowLeft,
|
|
36715
|
-
w: 6,
|
|
36716
|
-
h: 6
|
|
36717
|
-
}), "Previous"), /* @__PURE__ */ React42.createElement(PageButton_default, {
|
|
36718
|
-
onClick: (_d = props.navigator) == null ? void 0 : _d.goForward,
|
|
36719
|
-
"aria-label": "Next Page",
|
|
36720
|
-
disabled: isAtEnd
|
|
36721
|
-
}, "Next ", /* @__PURE__ */ React42.createElement(Icon, {
|
|
36722
|
-
as: MdKeyboardArrowRight,
|
|
36723
|
-
w: 6,
|
|
36724
|
-
h: 6
|
|
36725
|
-
}))));
|
|
36741
|
+
}, children), /* @__PURE__ */ React43.createElement(Footer_default, {
|
|
36742
|
+
state: props.state,
|
|
36743
|
+
navigator: props.navigator
|
|
36744
|
+
}));
|
|
36726
36745
|
};
|
|
36727
36746
|
var manager_default = ManagerUI;
|
|
36728
36747
|
|
|
36729
36748
|
// src/useWebReader.tsx
|
|
36730
|
-
import
|
|
36749
|
+
import React66 from "react";
|
|
36731
36750
|
|
|
36732
36751
|
// src/utils/fetch.ts
|
|
36733
36752
|
function fetchJson(url) {
|
|
@@ -36887,7 +36906,7 @@ function _getPrototypeOf(o) {
|
|
|
36887
36906
|
// node_modules/react-pdf/dist/esm/Document.js
|
|
36888
36907
|
var import_prop_types3 = __toESM(require_prop_types());
|
|
36889
36908
|
var import_make_event_props2 = __toESM(require_entry());
|
|
36890
|
-
import
|
|
36909
|
+
import React45, { PureComponent } from "react";
|
|
36891
36910
|
|
|
36892
36911
|
// node_modules/make-cancellable-promise/dist/esm/index.js
|
|
36893
36912
|
function makeCancellablePromise(promise) {
|
|
@@ -36925,10 +36944,10 @@ var DocumentContext_default = /* @__PURE__ */ createContext13(null);
|
|
|
36925
36944
|
|
|
36926
36945
|
// node_modules/react-pdf/dist/esm/Message.js
|
|
36927
36946
|
var import_prop_types = __toESM(require_prop_types());
|
|
36928
|
-
import
|
|
36947
|
+
import React44 from "react";
|
|
36929
36948
|
function Message(_ref) {
|
|
36930
36949
|
var children = _ref.children, type = _ref.type;
|
|
36931
|
-
return /* @__PURE__ */
|
|
36950
|
+
return /* @__PURE__ */ React44.createElement("div", {
|
|
36932
36951
|
className: "react-pdf__message react-pdf__message--".concat(type)
|
|
36933
36952
|
}, children);
|
|
36934
36953
|
}
|
|
@@ -37752,7 +37771,7 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
|
|
|
37752
37771
|
key: "renderChildren",
|
|
37753
37772
|
value: function renderChildren() {
|
|
37754
37773
|
var children = this.props.children;
|
|
37755
|
-
return /* @__PURE__ */
|
|
37774
|
+
return /* @__PURE__ */ React45.createElement(DocumentContext_default.Provider, {
|
|
37756
37775
|
value: this.childContext
|
|
37757
37776
|
}, children);
|
|
37758
37777
|
}
|
|
@@ -37763,19 +37782,19 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
|
|
|
37763
37782
|
var pdf = this.state.pdf;
|
|
37764
37783
|
if (!file) {
|
|
37765
37784
|
var noData = this.props.noData;
|
|
37766
|
-
return /* @__PURE__ */
|
|
37785
|
+
return /* @__PURE__ */ React45.createElement(Message, {
|
|
37767
37786
|
type: "no-data"
|
|
37768
37787
|
}, typeof noData === "function" ? noData() : noData);
|
|
37769
37788
|
}
|
|
37770
37789
|
if (pdf === null) {
|
|
37771
37790
|
var loading = this.props.loading;
|
|
37772
|
-
return /* @__PURE__ */
|
|
37791
|
+
return /* @__PURE__ */ React45.createElement(Message, {
|
|
37773
37792
|
type: "loading"
|
|
37774
37793
|
}, typeof loading === "function" ? loading() : loading);
|
|
37775
37794
|
}
|
|
37776
37795
|
if (pdf === false) {
|
|
37777
37796
|
var error2 = this.props.error;
|
|
37778
|
-
return /* @__PURE__ */
|
|
37797
|
+
return /* @__PURE__ */ React45.createElement(Message, {
|
|
37779
37798
|
type: "error"
|
|
37780
37799
|
}, typeof error2 === "function" ? error2() : error2);
|
|
37781
37800
|
}
|
|
@@ -37785,7 +37804,7 @@ var Document = /* @__PURE__ */ function(_PureComponent) {
|
|
|
37785
37804
|
key: "render",
|
|
37786
37805
|
value: function render() {
|
|
37787
37806
|
var _this$props2 = this.props, className = _this$props2.className, inputRef = _this$props2.inputRef;
|
|
37788
|
-
return /* @__PURE__ */
|
|
37807
|
+
return /* @__PURE__ */ React45.createElement("div", _extends({
|
|
37789
37808
|
className: mergeClassNames("react-pdf__Document", className),
|
|
37790
37809
|
ref: inputRef
|
|
37791
37810
|
}, this.eventProps), this.renderContent());
|
|
@@ -37860,7 +37879,7 @@ Document.propTypes = _objectSpread(_objectSpread({}, eventProps), {}, {
|
|
|
37860
37879
|
// node_modules/react-pdf/dist/esm/Outline.js
|
|
37861
37880
|
var import_regenerator4 = __toESM(require_regenerator());
|
|
37862
37881
|
var import_prop_types5 = __toESM(require_prop_types());
|
|
37863
|
-
import
|
|
37882
|
+
import React47, { PureComponent as PureComponent3 } from "react";
|
|
37864
37883
|
var import_make_event_props3 = __toESM(require_entry());
|
|
37865
37884
|
|
|
37866
37885
|
// node_modules/react-pdf/dist/esm/OutlineContext.js
|
|
@@ -37870,7 +37889,7 @@ var OutlineContext_default = /* @__PURE__ */ createContext14(null);
|
|
|
37870
37889
|
// node_modules/react-pdf/dist/esm/OutlineItem.js
|
|
37871
37890
|
var import_regenerator3 = __toESM(require_regenerator());
|
|
37872
37891
|
var import_prop_types4 = __toESM(require_prop_types());
|
|
37873
|
-
import
|
|
37892
|
+
import React46, { PureComponent as PureComponent2 } from "react";
|
|
37874
37893
|
|
|
37875
37894
|
// node_modules/react-pdf/dist/esm/Ref.js
|
|
37876
37895
|
var Ref = /* @__PURE__ */ function() {
|
|
@@ -38064,8 +38083,8 @@ var OutlineItemInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38064
38083
|
return null;
|
|
38065
38084
|
}
|
|
38066
38085
|
var subitems = item.items;
|
|
38067
|
-
return /* @__PURE__ */
|
|
38068
|
-
return /* @__PURE__ */
|
|
38086
|
+
return /* @__PURE__ */ React46.createElement("ul", null, subitems.map(function(subitem, subitemIndex) {
|
|
38087
|
+
return /* @__PURE__ */ React46.createElement(OutlineItemInternal2, _extends({
|
|
38069
38088
|
key: typeof subitem.destination === "string" ? subitem.destination : subitemIndex,
|
|
38070
38089
|
item: subitem
|
|
38071
38090
|
}, otherProps));
|
|
@@ -38075,7 +38094,7 @@ var OutlineItemInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38075
38094
|
key: "render",
|
|
38076
38095
|
value: function render() {
|
|
38077
38096
|
var item = this.props.item;
|
|
38078
|
-
return /* @__PURE__ */
|
|
38097
|
+
return /* @__PURE__ */ React46.createElement("li", null, /* @__PURE__ */ React46.createElement("a", {
|
|
38079
38098
|
href: "#",
|
|
38080
38099
|
onClick: this.onClick
|
|
38081
38100
|
}, item.title), this.renderSubitems());
|
|
@@ -38097,9 +38116,9 @@ OutlineItemInternal.propTypes = {
|
|
|
38097
38116
|
pdf: isPdf.isRequired
|
|
38098
38117
|
};
|
|
38099
38118
|
var OutlineItem = function OutlineItem2(props) {
|
|
38100
|
-
return /* @__PURE__ */
|
|
38101
|
-
return /* @__PURE__ */
|
|
38102
|
-
return /* @__PURE__ */
|
|
38119
|
+
return /* @__PURE__ */ React46.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
|
|
38120
|
+
return /* @__PURE__ */ React46.createElement(OutlineContext_default.Consumer, null, function(outlineContext) {
|
|
38121
|
+
return /* @__PURE__ */ React46.createElement(OutlineItemInternal, _extends({}, documentContext, outlineContext, props));
|
|
38103
38122
|
});
|
|
38104
38123
|
});
|
|
38105
38124
|
};
|
|
@@ -38267,8 +38286,8 @@ var OutlineInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38267
38286
|
key: "renderOutline",
|
|
38268
38287
|
value: function renderOutline() {
|
|
38269
38288
|
var outline5 = this.state.outline;
|
|
38270
|
-
return /* @__PURE__ */
|
|
38271
|
-
return /* @__PURE__ */
|
|
38289
|
+
return /* @__PURE__ */ React47.createElement("ul", null, outline5.map(function(item, itemIndex) {
|
|
38290
|
+
return /* @__PURE__ */ React47.createElement(OutlineItem_default, {
|
|
38272
38291
|
key: typeof item.destination === "string" ? item.destination : itemIndex,
|
|
38273
38292
|
item
|
|
38274
38293
|
});
|
|
@@ -38283,10 +38302,10 @@ var OutlineInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38283
38302
|
return null;
|
|
38284
38303
|
}
|
|
38285
38304
|
var _this$props = this.props, className = _this$props.className, inputRef = _this$props.inputRef;
|
|
38286
|
-
return /* @__PURE__ */
|
|
38305
|
+
return /* @__PURE__ */ React47.createElement("div", _extends({
|
|
38287
38306
|
className: mergeClassNames("react-pdf__Outline", className),
|
|
38288
38307
|
ref: inputRef
|
|
38289
|
-
}, this.eventProps), /* @__PURE__ */
|
|
38308
|
+
}, this.eventProps), /* @__PURE__ */ React47.createElement(OutlineContext_default.Provider, {
|
|
38290
38309
|
value: this.childContext
|
|
38291
38310
|
}, this.renderOutline()));
|
|
38292
38311
|
}
|
|
@@ -38320,7 +38339,7 @@ OutlineInternal.propTypes = _objectSpread2({
|
|
|
38320
38339
|
// node_modules/react-pdf/dist/esm/Page.js
|
|
38321
38340
|
var import_regenerator8 = __toESM(require_regenerator());
|
|
38322
38341
|
var import_prop_types11 = __toESM(require_prop_types());
|
|
38323
|
-
import
|
|
38342
|
+
import React53, { PureComponent as PureComponent9 } from "react";
|
|
38324
38343
|
var import_make_event_props4 = __toESM(require_entry());
|
|
38325
38344
|
|
|
38326
38345
|
// node_modules/merge-refs/dist/esm/index.js
|
|
@@ -38349,7 +38368,7 @@ var PageContext_default = /* @__PURE__ */ createContext15(null);
|
|
|
38349
38368
|
|
|
38350
38369
|
// node_modules/react-pdf/dist/esm/Page/PageCanvas.js
|
|
38351
38370
|
var import_prop_types6 = __toESM(require_prop_types());
|
|
38352
|
-
import
|
|
38371
|
+
import React48, { PureComponent as PureComponent4 } from "react";
|
|
38353
38372
|
function _createSuper4(Derived) {
|
|
38354
38373
|
var hasNativeReflectConstruct = _isNativeReflectConstruct4();
|
|
38355
38374
|
return function _createSuperInternal() {
|
|
@@ -38464,7 +38483,7 @@ var PageCanvasInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38464
38483
|
value: function render() {
|
|
38465
38484
|
var _this2 = this;
|
|
38466
38485
|
var canvasRef = this.props.canvasRef;
|
|
38467
|
-
return /* @__PURE__ */
|
|
38486
|
+
return /* @__PURE__ */ React48.createElement("canvas", {
|
|
38468
38487
|
className: "react-pdf__Page__canvas",
|
|
38469
38488
|
dir: "ltr",
|
|
38470
38489
|
ref: mergeRefs2(canvasRef, function(ref) {
|
|
@@ -38508,15 +38527,15 @@ PageCanvasInternal.propTypes = {
|
|
|
38508
38527
|
scale: import_prop_types6.default.number.isRequired
|
|
38509
38528
|
};
|
|
38510
38529
|
function PageCanvas(props) {
|
|
38511
|
-
return /* @__PURE__ */
|
|
38512
|
-
return /* @__PURE__ */
|
|
38530
|
+
return /* @__PURE__ */ React48.createElement(PageContext_default.Consumer, null, function(context) {
|
|
38531
|
+
return /* @__PURE__ */ React48.createElement(PageCanvasInternal, _extends({}, context, props));
|
|
38513
38532
|
});
|
|
38514
38533
|
}
|
|
38515
38534
|
|
|
38516
38535
|
// node_modules/react-pdf/dist/esm/Page/PageSVG.js
|
|
38517
38536
|
var import_prop_types7 = __toESM(require_prop_types());
|
|
38518
38537
|
var pdfjs2 = __toESM(require_pdf());
|
|
38519
|
-
import
|
|
38538
|
+
import React49, { PureComponent as PureComponent5 } from "react";
|
|
38520
38539
|
function _createSuper5(Derived) {
|
|
38521
38540
|
var hasNativeReflectConstruct = _isNativeReflectConstruct5();
|
|
38522
38541
|
return function _createSuperInternal() {
|
|
@@ -38609,7 +38628,7 @@ var PageSVGInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38609
38628
|
value: function render() {
|
|
38610
38629
|
var _this2 = this;
|
|
38611
38630
|
var _this$viewport2 = this.viewport, width = _this$viewport2.width, height = _this$viewport2.height;
|
|
38612
|
-
return /* @__PURE__ */
|
|
38631
|
+
return /* @__PURE__ */ React49.createElement("div", {
|
|
38613
38632
|
className: "react-pdf__Page__svg",
|
|
38614
38633
|
ref: function ref(_ref) {
|
|
38615
38634
|
return _this2.drawPageOnContainer(_ref);
|
|
@@ -38644,20 +38663,20 @@ PageSVGInternal.propTypes = {
|
|
|
38644
38663
|
scale: import_prop_types7.default.number.isRequired
|
|
38645
38664
|
};
|
|
38646
38665
|
function PageSVG(props) {
|
|
38647
|
-
return /* @__PURE__ */
|
|
38648
|
-
return /* @__PURE__ */
|
|
38666
|
+
return /* @__PURE__ */ React49.createElement(PageContext_default.Consumer, null, function(context) {
|
|
38667
|
+
return /* @__PURE__ */ React49.createElement(PageSVGInternal, _extends({}, context, props));
|
|
38649
38668
|
});
|
|
38650
38669
|
}
|
|
38651
38670
|
|
|
38652
38671
|
// node_modules/react-pdf/dist/esm/Page/TextLayer.js
|
|
38653
38672
|
var import_regenerator6 = __toESM(require_regenerator());
|
|
38654
38673
|
var import_prop_types9 = __toESM(require_prop_types());
|
|
38655
|
-
import
|
|
38674
|
+
import React51, { PureComponent as PureComponent7 } from "react";
|
|
38656
38675
|
|
|
38657
38676
|
// node_modules/react-pdf/dist/esm/Page/TextLayerItem.js
|
|
38658
38677
|
var import_regenerator5 = __toESM(require_regenerator());
|
|
38659
38678
|
var import_prop_types8 = __toESM(require_prop_types());
|
|
38660
|
-
import
|
|
38679
|
+
import React50, { PureComponent as PureComponent6 } from "react";
|
|
38661
38680
|
function _createSuper6(Derived) {
|
|
38662
38681
|
var hasNativeReflectConstruct = _isNativeReflectConstruct6();
|
|
38663
38682
|
return function _createSuperInternal() {
|
|
@@ -38793,7 +38812,7 @@ var TextLayerItemInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
38793
38812
|
var _this2 = this;
|
|
38794
38813
|
var fontSize = this.fontSize, top2 = this.top, left2 = this.left;
|
|
38795
38814
|
var _this$props2 = this.props, customTextRenderer = _this$props2.customTextRenderer, scale2 = _this$props2.scale, text = _this$props2.str;
|
|
38796
|
-
return /* @__PURE__ */
|
|
38815
|
+
return /* @__PURE__ */ React50.createElement("span", {
|
|
38797
38816
|
ref: function ref(_ref) {
|
|
38798
38817
|
_this2.item = _ref;
|
|
38799
38818
|
},
|
|
@@ -38877,8 +38896,8 @@ TextLayerItemInternal.propTypes = {
|
|
|
38877
38896
|
width: import_prop_types8.default.number.isRequired
|
|
38878
38897
|
};
|
|
38879
38898
|
function TextLayerItem(props) {
|
|
38880
|
-
return /* @__PURE__ */
|
|
38881
|
-
return /* @__PURE__ */
|
|
38899
|
+
return /* @__PURE__ */ React50.createElement(PageContext_default.Consumer, null, function(context) {
|
|
38900
|
+
return /* @__PURE__ */ React50.createElement(TextLayerItemInternal, _extends({}, context, props));
|
|
38882
38901
|
});
|
|
38883
38902
|
}
|
|
38884
38903
|
|
|
@@ -39002,7 +39021,7 @@ var TextLayerInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39002
39021
|
return null;
|
|
39003
39022
|
}
|
|
39004
39023
|
return textItems.map(function(textItem, itemIndex) {
|
|
39005
|
-
return /* @__PURE__ */
|
|
39024
|
+
return /* @__PURE__ */ React51.createElement(TextLayerItem, _extends({
|
|
39006
39025
|
key: itemIndex,
|
|
39007
39026
|
itemIndex
|
|
39008
39027
|
}, textItem));
|
|
@@ -39012,7 +39031,7 @@ var TextLayerInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39012
39031
|
key: "render",
|
|
39013
39032
|
value: function render() {
|
|
39014
39033
|
var viewport2 = this.unrotatedViewport, rotate = this.rotate;
|
|
39015
|
-
return /* @__PURE__ */
|
|
39034
|
+
return /* @__PURE__ */ React51.createElement("div", {
|
|
39016
39035
|
className: "react-pdf__Page__textContent",
|
|
39017
39036
|
style: {
|
|
39018
39037
|
position: "absolute",
|
|
@@ -39052,8 +39071,8 @@ TextLayerInternal.propTypes = {
|
|
|
39052
39071
|
scale: import_prop_types9.default.number
|
|
39053
39072
|
};
|
|
39054
39073
|
function TextLayer(props) {
|
|
39055
|
-
return /* @__PURE__ */
|
|
39056
|
-
return /* @__PURE__ */
|
|
39074
|
+
return /* @__PURE__ */ React51.createElement(PageContext_default.Consumer, null, function(context) {
|
|
39075
|
+
return /* @__PURE__ */ React51.createElement(TextLayerInternal, _extends({}, context, props));
|
|
39057
39076
|
});
|
|
39058
39077
|
}
|
|
39059
39078
|
|
|
@@ -39061,7 +39080,7 @@ function TextLayer(props) {
|
|
|
39061
39080
|
var import_regenerator7 = __toESM(require_regenerator());
|
|
39062
39081
|
var import_prop_types10 = __toESM(require_prop_types());
|
|
39063
39082
|
var pdfjs3 = __toESM(require_pdf());
|
|
39064
|
-
import
|
|
39083
|
+
import React52, { PureComponent as PureComponent8 } from "react";
|
|
39065
39084
|
function _createSuper8(Derived) {
|
|
39066
39085
|
var hasNativeReflectConstruct = _isNativeReflectConstruct8();
|
|
39067
39086
|
return function _createSuperInternal() {
|
|
@@ -39215,7 +39234,7 @@ var AnnotationLayerInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39215
39234
|
key: "render",
|
|
39216
39235
|
value: function render() {
|
|
39217
39236
|
var _this2 = this;
|
|
39218
|
-
return /* @__PURE__ */
|
|
39237
|
+
return /* @__PURE__ */ React52.createElement("div", {
|
|
39219
39238
|
className: "react-pdf__Page__annotations annotationLayer",
|
|
39220
39239
|
ref: function ref(_ref2) {
|
|
39221
39240
|
_this2.annotationLayer = _ref2;
|
|
@@ -39247,9 +39266,9 @@ AnnotationLayerInternal.propTypes = {
|
|
|
39247
39266
|
scale: import_prop_types10.default.number
|
|
39248
39267
|
};
|
|
39249
39268
|
var AnnotationLayer2 = function AnnotationLayer3(props) {
|
|
39250
|
-
return /* @__PURE__ */
|
|
39251
|
-
return /* @__PURE__ */
|
|
39252
|
-
return /* @__PURE__ */
|
|
39269
|
+
return /* @__PURE__ */ React52.createElement(DocumentContext_default.Consumer, null, function(documentContext) {
|
|
39270
|
+
return /* @__PURE__ */ React52.createElement(PageContext_default.Consumer, null, function(pageContext) {
|
|
39271
|
+
return /* @__PURE__ */ React52.createElement(AnnotationLayerInternal, _extends({}, documentContext, pageContext, props));
|
|
39253
39272
|
});
|
|
39254
39273
|
});
|
|
39255
39274
|
};
|
|
@@ -39451,12 +39470,12 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39451
39470
|
case "none":
|
|
39452
39471
|
return null;
|
|
39453
39472
|
case "svg":
|
|
39454
|
-
return /* @__PURE__ */
|
|
39473
|
+
return /* @__PURE__ */ React53.createElement(PageSVG, {
|
|
39455
39474
|
key: "".concat(this.pageKeyNoScale, "_svg")
|
|
39456
39475
|
});
|
|
39457
39476
|
case "canvas":
|
|
39458
39477
|
default:
|
|
39459
|
-
return /* @__PURE__ */
|
|
39478
|
+
return /* @__PURE__ */ React53.createElement(PageCanvas, {
|
|
39460
39479
|
key: "".concat(this.pageKey, "_canvas"),
|
|
39461
39480
|
canvasRef
|
|
39462
39481
|
});
|
|
@@ -39469,7 +39488,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39469
39488
|
if (!renderTextLayer2) {
|
|
39470
39489
|
return null;
|
|
39471
39490
|
}
|
|
39472
|
-
return /* @__PURE__ */
|
|
39491
|
+
return /* @__PURE__ */ React53.createElement(TextLayer, {
|
|
39473
39492
|
key: "".concat(this.pageKey, "_text")
|
|
39474
39493
|
});
|
|
39475
39494
|
}
|
|
@@ -39480,7 +39499,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39480
39499
|
if (!renderAnnotationLayer2) {
|
|
39481
39500
|
return null;
|
|
39482
39501
|
}
|
|
39483
|
-
return /* @__PURE__ */
|
|
39502
|
+
return /* @__PURE__ */ React53.createElement(AnnotationLayer_default, {
|
|
39484
39503
|
key: "".concat(this.pageKey, "_annotations")
|
|
39485
39504
|
});
|
|
39486
39505
|
}
|
|
@@ -39488,7 +39507,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39488
39507
|
key: "renderChildren",
|
|
39489
39508
|
value: function renderChildren() {
|
|
39490
39509
|
var children = this.props.children;
|
|
39491
|
-
return /* @__PURE__ */
|
|
39510
|
+
return /* @__PURE__ */ React53.createElement(PageContext_default.Provider, {
|
|
39492
39511
|
value: this.childContext
|
|
39493
39512
|
}, this.renderMainLayer(), this.renderTextLayer(), this.renderAnnotationLayer(), children);
|
|
39494
39513
|
}
|
|
@@ -39500,19 +39519,19 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39500
39519
|
var page = this.state.page;
|
|
39501
39520
|
if (!pageNumber) {
|
|
39502
39521
|
var noData = this.props.noData;
|
|
39503
|
-
return /* @__PURE__ */
|
|
39522
|
+
return /* @__PURE__ */ React53.createElement(Message, {
|
|
39504
39523
|
type: "no-data"
|
|
39505
39524
|
}, typeof noData === "function" ? noData() : noData);
|
|
39506
39525
|
}
|
|
39507
39526
|
if (pdf === null || page === null) {
|
|
39508
39527
|
var loading = this.props.loading;
|
|
39509
|
-
return /* @__PURE__ */
|
|
39528
|
+
return /* @__PURE__ */ React53.createElement(Message, {
|
|
39510
39529
|
type: "loading"
|
|
39511
39530
|
}, typeof loading === "function" ? loading() : loading);
|
|
39512
39531
|
}
|
|
39513
39532
|
if (pdf === false || page === false) {
|
|
39514
39533
|
var error2 = this.props.error;
|
|
39515
|
-
return /* @__PURE__ */
|
|
39534
|
+
return /* @__PURE__ */ React53.createElement(Message, {
|
|
39516
39535
|
type: "error"
|
|
39517
39536
|
}, typeof error2 === "function" ? error2() : error2);
|
|
39518
39537
|
}
|
|
@@ -39523,7 +39542,7 @@ var PageInternal = /* @__PURE__ */ function(_PureComponent) {
|
|
|
39523
39542
|
value: function render() {
|
|
39524
39543
|
var pageNumber = this.pageNumber;
|
|
39525
39544
|
var _this$props3 = this.props, className = _this$props3.className, inputRef = _this$props3.inputRef;
|
|
39526
|
-
return /* @__PURE__ */
|
|
39545
|
+
return /* @__PURE__ */ React53.createElement("div", _extends({
|
|
39527
39546
|
className: mergeClassNames("react-pdf__Page", className),
|
|
39528
39547
|
"data-page-number": pageNumber,
|
|
39529
39548
|
ref: mergeRefs2(inputRef, this.ref),
|
|
@@ -39667,13 +39686,13 @@ PageInternal.propTypes = _objectSpread3(_objectSpread3({}, eventProps), {}, {
|
|
|
39667
39686
|
width: import_prop_types11.default.number
|
|
39668
39687
|
});
|
|
39669
39688
|
function Page(props, ref) {
|
|
39670
|
-
return /* @__PURE__ */
|
|
39671
|
-
return /* @__PURE__ */
|
|
39689
|
+
return /* @__PURE__ */ React53.createElement(DocumentContext_default.Consumer, null, function(context) {
|
|
39690
|
+
return /* @__PURE__ */ React53.createElement(PageInternal, _extends({
|
|
39672
39691
|
ref
|
|
39673
39692
|
}, context, props));
|
|
39674
39693
|
});
|
|
39675
39694
|
}
|
|
39676
|
-
var Page_default = /* @__PURE__ */
|
|
39695
|
+
var Page_default = /* @__PURE__ */ React53.forwardRef(Page);
|
|
39677
39696
|
|
|
39678
39697
|
// node_modules/react-pdf/dist/esm/entry.js
|
|
39679
39698
|
if (isLocalFileSystem) {
|
|
@@ -39682,10 +39701,10 @@ if (isLocalFileSystem) {
|
|
|
39682
39701
|
pdfjs4.GlobalWorkerOptions.workerSrc = "pdf.worker.js";
|
|
39683
39702
|
|
|
39684
39703
|
// src/PdfReader/index.tsx
|
|
39685
|
-
import * as
|
|
39704
|
+
import * as React57 from "react";
|
|
39686
39705
|
|
|
39687
39706
|
// src/PdfReader/useMeasure.tsx
|
|
39688
|
-
import * as
|
|
39707
|
+
import * as React54 from "react";
|
|
39689
39708
|
var DEFAULT_DIMENSION = {
|
|
39690
39709
|
x: 0,
|
|
39691
39710
|
y: 0,
|
|
@@ -39697,9 +39716,9 @@ var DEFAULT_DIMENSION = {
|
|
|
39697
39716
|
right: 0
|
|
39698
39717
|
};
|
|
39699
39718
|
function useMeasure() {
|
|
39700
|
-
const [element, ref] =
|
|
39701
|
-
const [rect, setRect] =
|
|
39702
|
-
const observer =
|
|
39719
|
+
const [element, ref] = React54.useState(null);
|
|
39720
|
+
const [rect, setRect] = React54.useState(DEFAULT_DIMENSION);
|
|
39721
|
+
const observer = React54.useMemo(() => new window.ResizeObserver((entries) => {
|
|
39703
39722
|
if (entries[0]) {
|
|
39704
39723
|
const {
|
|
39705
39724
|
x,
|
|
@@ -39714,7 +39733,7 @@ function useMeasure() {
|
|
|
39714
39733
|
setRect({ x, y, width, height, top: top2, left: left2, bottom: bottom2, right: right2 });
|
|
39715
39734
|
}
|
|
39716
39735
|
}), []);
|
|
39717
|
-
|
|
39736
|
+
React54.useLayoutEffect(() => {
|
|
39718
39737
|
if (!element)
|
|
39719
39738
|
return;
|
|
39720
39739
|
observer.observe(element);
|
|
@@ -39743,10 +39762,10 @@ var ChakraPage = chakra(Page_default, {
|
|
|
39743
39762
|
var ChakraPage_default = ChakraPage;
|
|
39744
39763
|
|
|
39745
39764
|
// src/PdfReader/ScrollPage.tsx
|
|
39746
|
-
import
|
|
39765
|
+
import React55 from "react";
|
|
39747
39766
|
|
|
39748
39767
|
// node_modules/react-intersection-observer/react-intersection-observer.m.js
|
|
39749
|
-
import { createElement as
|
|
39768
|
+
import { createElement as createElement33, Component as Component3, useRef as useRef19, useState as useState18, useCallback as useCallback15, useEffect as useEffect20 } from "react";
|
|
39750
39769
|
function _extends22() {
|
|
39751
39770
|
_extends22 = Object.assign || function(target) {
|
|
39752
39771
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -39937,7 +39956,7 @@ var InView = /* @__PURE__ */ function(_React$Component) {
|
|
|
39937
39956
|
});
|
|
39938
39957
|
}
|
|
39939
39958
|
var _this$props2 = this.props, children = _this$props2.children, as = _this$props2.as, tag2 = _this$props2.tag, props = _objectWithoutPropertiesLoose17(_this$props2, ["children", "as", "tag", "triggerOnce", "threshold", "root", "rootMargin", "onChange", "skip", "trackVisibility", "delay", "initialInView"]);
|
|
39940
|
-
return /* @__PURE__ */
|
|
39959
|
+
return /* @__PURE__ */ createElement33(as || tag2 || "div", _extends22({
|
|
39941
39960
|
ref: this.handleNode
|
|
39942
39961
|
}, props), children);
|
|
39943
39962
|
};
|
|
@@ -40005,7 +40024,7 @@ function useInView(_temp) {
|
|
|
40005
40024
|
|
|
40006
40025
|
// src/PdfReader/ScrollPage.tsx
|
|
40007
40026
|
var Placeholder = ({ width, height, pageNumber }) => {
|
|
40008
|
-
return /* @__PURE__ */
|
|
40027
|
+
return /* @__PURE__ */ React55.createElement("div", {
|
|
40009
40028
|
"data-page-number": pageNumber,
|
|
40010
40029
|
style: { width, height }
|
|
40011
40030
|
});
|
|
@@ -40022,15 +40041,15 @@ var ScrollPage = ({
|
|
|
40022
40041
|
threshold: 0,
|
|
40023
40042
|
triggerOnce: true
|
|
40024
40043
|
});
|
|
40025
|
-
return /* @__PURE__ */
|
|
40044
|
+
return /* @__PURE__ */ React55.createElement("div", {
|
|
40026
40045
|
ref
|
|
40027
|
-
}, inView ? /* @__PURE__ */
|
|
40046
|
+
}, inView ? /* @__PURE__ */ React55.createElement(ChakraPage_default, {
|
|
40028
40047
|
"data-page-number": pageNumber,
|
|
40029
40048
|
pageNumber,
|
|
40030
40049
|
scale: scale2,
|
|
40031
40050
|
width,
|
|
40032
40051
|
onLoadSuccess
|
|
40033
|
-
}) : /* @__PURE__ */
|
|
40052
|
+
}) : /* @__PURE__ */ React55.createElement(Placeholder, {
|
|
40034
40053
|
width: placeholderWidth,
|
|
40035
40054
|
height: placeholderHeight,
|
|
40036
40055
|
pageNumber
|
|
@@ -40039,33 +40058,51 @@ var ScrollPage = ({
|
|
|
40039
40058
|
var ScrollPage_default = ScrollPage;
|
|
40040
40059
|
|
|
40041
40060
|
// src/ui/LoadingSkeleton.tsx
|
|
40042
|
-
import
|
|
40043
|
-
|
|
40061
|
+
import React56 from "react";
|
|
40062
|
+
var LoadingSkeletonContent = ({
|
|
40044
40063
|
height
|
|
40045
|
-
}) {
|
|
40046
|
-
|
|
40064
|
+
}) => {
|
|
40065
|
+
const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
|
|
40066
|
+
return /* @__PURE__ */ React56.createElement(React56.Fragment, null, /* @__PURE__ */ React56.createElement(HeaderWrapper, {
|
|
40067
|
+
bg: bgColor
|
|
40068
|
+
}), /* @__PURE__ */ React56.createElement(Box, {
|
|
40047
40069
|
padding: "6",
|
|
40048
|
-
bg:
|
|
40049
|
-
mt: "
|
|
40070
|
+
bg: bgColor,
|
|
40071
|
+
mt: "0",
|
|
40050
40072
|
height,
|
|
40051
40073
|
"aria-label": "Loading book...",
|
|
40052
40074
|
"aria-busy": "true",
|
|
40053
40075
|
role: "progressbar"
|
|
40054
|
-
}, /* @__PURE__ */
|
|
40076
|
+
}, /* @__PURE__ */ React56.createElement(Flex, {
|
|
40055
40077
|
justifyContent: "center"
|
|
40056
|
-
}, /* @__PURE__ */
|
|
40078
|
+
}, /* @__PURE__ */ React56.createElement(Skeleton, {
|
|
40057
40079
|
height: "20px",
|
|
40058
40080
|
mb: "7",
|
|
40059
40081
|
w: "30%"
|
|
40060
|
-
})), /* @__PURE__ */
|
|
40082
|
+
})), /* @__PURE__ */ React56.createElement(SkeletonText, {
|
|
40061
40083
|
mb: "7",
|
|
40062
40084
|
noOfLines: 10,
|
|
40063
40085
|
spacing: "4"
|
|
40064
|
-
}), /* @__PURE__ */
|
|
40086
|
+
}), /* @__PURE__ */ React56.createElement(SkeletonText, {
|
|
40065
40087
|
mb: "7",
|
|
40066
40088
|
noOfLines: 5,
|
|
40067
40089
|
spacing: "4"
|
|
40068
|
-
}))
|
|
40090
|
+
})), /* @__PURE__ */ React56.createElement(Footer_default, {
|
|
40091
|
+
state: null,
|
|
40092
|
+
navigator: null,
|
|
40093
|
+
zIndex: "tooltip"
|
|
40094
|
+
}));
|
|
40095
|
+
};
|
|
40096
|
+
function LoadingSkeleton({
|
|
40097
|
+
height,
|
|
40098
|
+
state: state2
|
|
40099
|
+
}) {
|
|
40100
|
+
var _a;
|
|
40101
|
+
return /* @__PURE__ */ React56.createElement(ThemeProvider3, {
|
|
40102
|
+
theme: getTheme3((_a = state2 == null ? void 0 : state2.settings) == null ? void 0 : _a.colorMode)
|
|
40103
|
+
}, /* @__PURE__ */ React56.createElement(LoadingSkeletonContent, {
|
|
40104
|
+
height
|
|
40105
|
+
}));
|
|
40069
40106
|
}
|
|
40070
40107
|
|
|
40071
40108
|
// src/PdfReader/index.tsx
|
|
@@ -40179,7 +40216,7 @@ function usePdfReader(args) {
|
|
|
40179
40216
|
height = DEFAULT_HEIGHT,
|
|
40180
40217
|
growWhenScrolling = DEFAULT_SHOULD_GROW_WHEN_SCROLLING
|
|
40181
40218
|
} = args != null ? args : {};
|
|
40182
|
-
const [state2, dispatch] =
|
|
40219
|
+
const [state2, dispatch] = React57.useReducer(pdfReducer, {
|
|
40183
40220
|
state: "INACTIVE",
|
|
40184
40221
|
resourceIndex: 0,
|
|
40185
40222
|
resource: null,
|
|
@@ -40198,7 +40235,7 @@ function usePdfReader(args) {
|
|
|
40198
40235
|
const isParsed = typeof state2.numPages === "number";
|
|
40199
40236
|
const isSinglePDF = manifest && (manifest == null ? void 0 : manifest.readingOrder.length) === 1;
|
|
40200
40237
|
const [containerRef, containerSize] = useMeasure();
|
|
40201
|
-
|
|
40238
|
+
React57.useEffect(() => {
|
|
40202
40239
|
if (!webpubManifestUrl || !manifest) {
|
|
40203
40240
|
return dispatch({ type: "ARGS_CHANGED", args: void 0 });
|
|
40204
40241
|
}
|
|
@@ -40223,7 +40260,7 @@ function usePdfReader(args) {
|
|
|
40223
40260
|
height,
|
|
40224
40261
|
growWhenScrolling
|
|
40225
40262
|
]);
|
|
40226
|
-
|
|
40263
|
+
React57.useEffect(() => {
|
|
40227
40264
|
if (!manifest)
|
|
40228
40265
|
return;
|
|
40229
40266
|
if (!manifest.readingOrder || !manifest.readingOrder.length) {
|
|
@@ -40237,7 +40274,7 @@ function usePdfReader(args) {
|
|
|
40237
40274
|
});
|
|
40238
40275
|
});
|
|
40239
40276
|
}, [state2.resourceIndex, manifest, proxyUrl]);
|
|
40240
|
-
const resizePage =
|
|
40277
|
+
const resizePage = React57.useCallback((pdfWidth, pdfHeight, containerSize2) => {
|
|
40241
40278
|
const wRatio = pdfWidth / containerSize2.width;
|
|
40242
40279
|
const hRatio = pdfHeight / containerSize2.height;
|
|
40243
40280
|
const fitHorizontal = wRatio > hRatio;
|
|
@@ -40245,10 +40282,10 @@ function usePdfReader(args) {
|
|
|
40245
40282
|
const height2 = !fitHorizontal ? Math.round(containerSize2.height) : void 0;
|
|
40246
40283
|
dispatch({ type: "RESIZE_PAGE", width, height: height2 });
|
|
40247
40284
|
}, []);
|
|
40248
|
-
|
|
40285
|
+
React57.useEffect(() => {
|
|
40249
40286
|
resizePage(state2.pdfWidth, state2.pdfHeight, containerSize);
|
|
40250
40287
|
}, [containerSize, state2.pdfWidth, state2.pdfHeight, resizePage]);
|
|
40251
|
-
|
|
40288
|
+
React57.useEffect(() => {
|
|
40252
40289
|
var _a2;
|
|
40253
40290
|
if (!manifest || state2.state !== "ACTIVE")
|
|
40254
40291
|
return;
|
|
@@ -40278,7 +40315,7 @@ function usePdfReader(args) {
|
|
|
40278
40315
|
state2.resourceIndex,
|
|
40279
40316
|
isSinglePDF
|
|
40280
40317
|
]);
|
|
40281
|
-
const goForward =
|
|
40318
|
+
const goForward = React57.useCallback(() => __async(this, null, function* () {
|
|
40282
40319
|
var _a2;
|
|
40283
40320
|
if (!state2.numPages)
|
|
40284
40321
|
return;
|
|
@@ -40312,7 +40349,7 @@ function usePdfReader(args) {
|
|
|
40312
40349
|
state2.pageNumber,
|
|
40313
40350
|
state2.resourceIndex
|
|
40314
40351
|
]);
|
|
40315
|
-
const goBackward =
|
|
40352
|
+
const goBackward = React57.useCallback(() => __async(this, null, function* () {
|
|
40316
40353
|
if (!isParsed)
|
|
40317
40354
|
return;
|
|
40318
40355
|
if (state2.state !== "ACTIVE")
|
|
@@ -40339,23 +40376,23 @@ function usePdfReader(args) {
|
|
|
40339
40376
|
state2.pageNumber,
|
|
40340
40377
|
state2.resourceIndex
|
|
40341
40378
|
]);
|
|
40342
|
-
const setScroll =
|
|
40379
|
+
const setScroll = React57.useCallback((val) => __async(this, null, function* () {
|
|
40343
40380
|
const isScrolling = val === "scrolling";
|
|
40344
40381
|
dispatch({ type: "SET_SCROLL", isScrolling });
|
|
40345
40382
|
}), []);
|
|
40346
|
-
const zoomIn =
|
|
40383
|
+
const zoomIn = React57.useCallback(() => __async(this, null, function* () {
|
|
40347
40384
|
dispatch({
|
|
40348
40385
|
type: "SET_SCALE",
|
|
40349
40386
|
scale: state2.scale + SCALE_STEP
|
|
40350
40387
|
});
|
|
40351
40388
|
}), [state2.scale]);
|
|
40352
|
-
const zoomOut =
|
|
40389
|
+
const zoomOut = React57.useCallback(() => __async(this, null, function* () {
|
|
40353
40390
|
dispatch({
|
|
40354
40391
|
type: "SET_SCALE",
|
|
40355
40392
|
scale: state2.scale - SCALE_STEP
|
|
40356
40393
|
});
|
|
40357
40394
|
}), [state2.scale]);
|
|
40358
|
-
const goToPage =
|
|
40395
|
+
const goToPage = React57.useCallback((href) => __async(this, null, function* () {
|
|
40359
40396
|
const getIndexFromHref = (href2) => {
|
|
40360
40397
|
var _a2;
|
|
40361
40398
|
const index = (_a2 = manifest == null ? void 0 : manifest.readingOrder) == null ? void 0 : _a2.findIndex((link2) => {
|
|
@@ -40386,8 +40423,9 @@ function usePdfReader(args) {
|
|
|
40386
40423
|
return {
|
|
40387
40424
|
type: null,
|
|
40388
40425
|
isLoading: true,
|
|
40389
|
-
content: /* @__PURE__ */
|
|
40390
|
-
height
|
|
40426
|
+
content: /* @__PURE__ */ React57.createElement(LoadingSkeleton, {
|
|
40427
|
+
height,
|
|
40428
|
+
state: state2
|
|
40391
40429
|
}),
|
|
40392
40430
|
navigator: null,
|
|
40393
40431
|
manifest: null,
|
|
@@ -40417,7 +40455,7 @@ function usePdfReader(args) {
|
|
|
40417
40455
|
return {
|
|
40418
40456
|
type: "PDF",
|
|
40419
40457
|
isLoading: false,
|
|
40420
|
-
content: /* @__PURE__ */
|
|
40458
|
+
content: /* @__PURE__ */ React57.createElement(Flex, {
|
|
40421
40459
|
as: "main",
|
|
40422
40460
|
zIndex: "base",
|
|
40423
40461
|
flex: "1 0 auto",
|
|
@@ -40427,16 +40465,16 @@ function usePdfReader(args) {
|
|
|
40427
40465
|
id: IFRAME_WRAPPER_ID,
|
|
40428
40466
|
ref: containerRef,
|
|
40429
40467
|
height: finalHeight
|
|
40430
|
-
}, /* @__PURE__ */
|
|
40468
|
+
}, /* @__PURE__ */ React57.createElement("style", null, `
|
|
40431
40469
|
.react-pdf__Document {
|
|
40432
40470
|
height: calc(100vh - ${HEADER_HEIGHT + FOOTER_HEIGHT}px);
|
|
40433
40471
|
overflow-x: hidden;
|
|
40434
40472
|
overflow-y: auto;
|
|
40435
40473
|
}
|
|
40436
|
-
`), /* @__PURE__ */
|
|
40474
|
+
`), /* @__PURE__ */ React57.createElement(Document, {
|
|
40437
40475
|
file: state2.resource,
|
|
40438
40476
|
onLoadSuccess: onDocumentLoadSuccess
|
|
40439
|
-
}, isParsed && state2.numPages && /* @__PURE__ */
|
|
40477
|
+
}, isParsed && state2.numPages && /* @__PURE__ */ React57.createElement(React57.Fragment, null, state2.settings.isScrolling && Array.from(new Array(state2.numPages), (_, index) => /* @__PURE__ */ React57.createElement(ScrollPage_default, {
|
|
40440
40478
|
key: `page_${index + 1}`,
|
|
40441
40479
|
width: containerSize.width,
|
|
40442
40480
|
placeholderHeight: state2.pdfHeight,
|
|
@@ -40444,13 +40482,13 @@ function usePdfReader(args) {
|
|
|
40444
40482
|
scale: state2.scale,
|
|
40445
40483
|
pageNumber: index + 1,
|
|
40446
40484
|
onLoadSuccess: onRenderSuccess
|
|
40447
|
-
})), !state2.settings.isScrolling && /* @__PURE__ */
|
|
40485
|
+
})), !state2.settings.isScrolling && /* @__PURE__ */ React57.createElement(ChakraPage_default, {
|
|
40448
40486
|
pageNumber: state2.pageNumber,
|
|
40449
40487
|
onLoadSuccess: onRenderSuccess,
|
|
40450
40488
|
width: state2.pageWidth,
|
|
40451
40489
|
height: state2.pageHeight,
|
|
40452
40490
|
scale: state2.scale,
|
|
40453
|
-
loading: /* @__PURE__ */
|
|
40491
|
+
loading: /* @__PURE__ */ React57.createElement(React57.Fragment, null)
|
|
40454
40492
|
})))),
|
|
40455
40493
|
state: state2,
|
|
40456
40494
|
manifest,
|
|
@@ -40470,7 +40508,7 @@ function handleInvalidTransition(state2, action) {
|
|
|
40470
40508
|
}
|
|
40471
40509
|
|
|
40472
40510
|
// src/HtmlReader/index.tsx
|
|
40473
|
-
import
|
|
40511
|
+
import React65 from "react";
|
|
40474
40512
|
|
|
40475
40513
|
// src/HtmlReader/lib.ts
|
|
40476
40514
|
var FONT_SIZE_STEP = 4;
|
|
@@ -40522,10 +40560,15 @@ function getFromReadingOrder(href, manifest, baseUrl) {
|
|
|
40522
40560
|
} : void 0;
|
|
40523
40561
|
}
|
|
40524
40562
|
function isSameResource(href1, href2, baseUrl) {
|
|
40525
|
-
|
|
40526
|
-
|
|
40527
|
-
|
|
40528
|
-
|
|
40563
|
+
try {
|
|
40564
|
+
const url1 = new URL(href1, baseUrl);
|
|
40565
|
+
const url2 = new URL(href2, baseUrl);
|
|
40566
|
+
const doMatch = url1.origin === url2.origin && url1.pathname === url2.pathname;
|
|
40567
|
+
return doMatch;
|
|
40568
|
+
} catch (e) {
|
|
40569
|
+
console.error(e);
|
|
40570
|
+
}
|
|
40571
|
+
return false;
|
|
40529
40572
|
}
|
|
40530
40573
|
function linkToLocator(link2, baseUrl, locations = {}) {
|
|
40531
40574
|
var _a;
|
|
@@ -40644,7 +40687,7 @@ var familyToReadiumFamily = {
|
|
|
40644
40687
|
};
|
|
40645
40688
|
|
|
40646
40689
|
// src/utils/localstorage.ts
|
|
40647
|
-
import
|
|
40690
|
+
import React58 from "react";
|
|
40648
40691
|
function getLocalStorageLocation(identifier2, args) {
|
|
40649
40692
|
if (!(args == null ? void 0 : args.persistLastLocation))
|
|
40650
40693
|
return void 0;
|
|
@@ -40667,7 +40710,7 @@ function getLocalStorageSettings(args) {
|
|
|
40667
40710
|
return void 0;
|
|
40668
40711
|
}
|
|
40669
40712
|
function useUpdateLocalStorage(identifier2, state2, args) {
|
|
40670
|
-
|
|
40713
|
+
React58.useEffect(() => {
|
|
40671
40714
|
if (!identifier2 || !(args == null ? void 0 : args.persistLastLocation))
|
|
40672
40715
|
return;
|
|
40673
40716
|
if (state2.location) {
|
|
@@ -40688,7 +40731,7 @@ function useUpdateLocalStorage(identifier2, state2, args) {
|
|
|
40688
40731
|
}
|
|
40689
40732
|
}
|
|
40690
40733
|
}, [state2.location, identifier2, args == null ? void 0 : args.persistLastLocation]);
|
|
40691
|
-
|
|
40734
|
+
React58.useEffect(() => {
|
|
40692
40735
|
if (!identifier2 || !state2.settings || !(args == null ? void 0 : args.persistSettings))
|
|
40693
40736
|
return;
|
|
40694
40737
|
const settings = {
|
|
@@ -40707,10 +40750,10 @@ function clearWebReaderLocalStorage() {
|
|
|
40707
40750
|
}
|
|
40708
40751
|
|
|
40709
40752
|
// src/HtmlReader/useLocationQuery.ts
|
|
40710
|
-
import
|
|
40753
|
+
import React59 from "react";
|
|
40711
40754
|
var LOCATION_QUERY_TITLE = "location";
|
|
40712
40755
|
function useLocationQuery(state2) {
|
|
40713
|
-
|
|
40756
|
+
React59.useEffect(() => {
|
|
40714
40757
|
if (state2.state === "READY")
|
|
40715
40758
|
updateQuery(state2.location);
|
|
40716
40759
|
}, [state2.location, state2.state]);
|
|
@@ -41177,11 +41220,11 @@ function extractContentContainerSize(container3) {
|
|
|
41177
41220
|
}
|
|
41178
41221
|
|
|
41179
41222
|
// src/HtmlReader/useResource.tsx
|
|
41180
|
-
import
|
|
41223
|
+
import React60 from "react";
|
|
41181
41224
|
function useResource(manifest, state2, getContent, injectables, dispatch) {
|
|
41182
41225
|
var _a, _b;
|
|
41183
41226
|
const currentResourceUrl = (_b = (_a = state2.location) == null ? void 0 : _a.href) != null ? _b : null;
|
|
41184
|
-
|
|
41227
|
+
React60.useEffect(() => {
|
|
41185
41228
|
if (!currentResourceUrl) {
|
|
41186
41229
|
return;
|
|
41187
41230
|
}
|
|
@@ -41236,8 +41279,11 @@ function injectJS(body) {
|
|
|
41236
41279
|
function handleLinkClick(evt) {
|
|
41237
41280
|
// don't navigate
|
|
41238
41281
|
evt.preventDefault();
|
|
41239
|
-
|
|
41240
|
-
|
|
41282
|
+
const href = evt.currentTarget.href;
|
|
41283
|
+
if(href) {
|
|
41284
|
+
// send message to parent
|
|
41285
|
+
window.parent.postMessage( { type: 'LINK_CLICKED', href } );
|
|
41286
|
+
}
|
|
41241
41287
|
};
|
|
41242
41288
|
for ( var i = 0; i < links.length; i ++ ) {
|
|
41243
41289
|
links[i].addEventListener('click', handleLinkClick);
|
|
@@ -41251,9 +41297,9 @@ function injectJS(body) {
|
|
|
41251
41297
|
|
|
41252
41298
|
// src/HtmlReader/useWindowResize.ts
|
|
41253
41299
|
var import_debounce2 = __toESM(require_debounce());
|
|
41254
|
-
import
|
|
41300
|
+
import React61 from "react";
|
|
41255
41301
|
function useWindowResize(manifest, state2, dispatch) {
|
|
41256
|
-
|
|
41302
|
+
React61.useEffect(() => {
|
|
41257
41303
|
if (state2.state !== "NAVIGATING" && state2.state !== "READY")
|
|
41258
41304
|
return;
|
|
41259
41305
|
function handleResize() {
|
|
@@ -41274,11 +41320,11 @@ function useWindowResize(manifest, state2, dispatch) {
|
|
|
41274
41320
|
}
|
|
41275
41321
|
|
|
41276
41322
|
// src/HtmlReader/useUpdateScroll.ts
|
|
41277
|
-
import * as
|
|
41323
|
+
import * as React62 from "react";
|
|
41278
41324
|
var SCROLL_STOP_DEBOUNCE = 100;
|
|
41279
41325
|
function useUpdateScroll(state2, dispatch) {
|
|
41280
|
-
const timeout =
|
|
41281
|
-
|
|
41326
|
+
const timeout = React62.useRef();
|
|
41327
|
+
React62.useLayoutEffect(() => {
|
|
41282
41328
|
if (state2.state !== "READY")
|
|
41283
41329
|
return;
|
|
41284
41330
|
const iframeDocument = state2.iframe.contentDocument;
|
|
@@ -41297,9 +41343,9 @@ function useUpdateScroll(state2, dispatch) {
|
|
|
41297
41343
|
}
|
|
41298
41344
|
|
|
41299
41345
|
// src/HtmlReader/useUpdateCSS.ts
|
|
41300
|
-
import
|
|
41346
|
+
import React63 from "react";
|
|
41301
41347
|
function useUpdateCSS(state2, manifest) {
|
|
41302
|
-
|
|
41348
|
+
React63.useEffect(() => {
|
|
41303
41349
|
if (!manifest)
|
|
41304
41350
|
return;
|
|
41305
41351
|
if (state2.state !== "NAVIGATING" && state2.state !== "READY")
|
|
@@ -41312,19 +41358,32 @@ function useUpdateCSS(state2, manifest) {
|
|
|
41312
41358
|
}
|
|
41313
41359
|
|
|
41314
41360
|
// src/HtmlReader/useIframeLinkClick.ts
|
|
41315
|
-
import
|
|
41316
|
-
function useIframeLinkClick(dispatch) {
|
|
41317
|
-
|
|
41361
|
+
import React64 from "react";
|
|
41362
|
+
function useIframeLinkClick(baseUrl, manifest, dispatch) {
|
|
41363
|
+
React64.useEffect(() => {
|
|
41364
|
+
if (!baseUrl || !manifest)
|
|
41365
|
+
return;
|
|
41318
41366
|
window.addEventListener("message", ({ data }) => {
|
|
41319
41367
|
if (typeof data === "object" && data !== null && "type" in data) {
|
|
41320
41368
|
switch (data.type) {
|
|
41321
41369
|
case "LINK_CLICKED":
|
|
41322
|
-
|
|
41370
|
+
handleIframeLink(data.href, manifest, baseUrl, dispatch);
|
|
41323
41371
|
}
|
|
41324
41372
|
}
|
|
41325
41373
|
});
|
|
41326
|
-
}, [dispatch]);
|
|
41374
|
+
}, [dispatch, baseUrl, manifest]);
|
|
41327
41375
|
}
|
|
41376
|
+
var handleIframeLink = (href, manifest, baseUrl, dispatch) => {
|
|
41377
|
+
if (isExternalLink(href, manifest, baseUrl)) {
|
|
41378
|
+
window.open(href, "_blank");
|
|
41379
|
+
} else {
|
|
41380
|
+
dispatch({ type: "GO_TO_HREF", href });
|
|
41381
|
+
}
|
|
41382
|
+
};
|
|
41383
|
+
var isExternalLink = (href, manifest, baseUrl) => {
|
|
41384
|
+
const resource = getFromReadingOrder(href, manifest, baseUrl);
|
|
41385
|
+
return resource === void 0;
|
|
41386
|
+
};
|
|
41328
41387
|
|
|
41329
41388
|
// src/HtmlReader/index.tsx
|
|
41330
41389
|
var IFRAME_ID_SELECTOR = "html-reader-iframe";
|
|
@@ -41341,7 +41400,7 @@ function useHtmlReader(args) {
|
|
|
41341
41400
|
persistLastLocation = true,
|
|
41342
41401
|
persistSettings = true
|
|
41343
41402
|
} = args != null ? args : {};
|
|
41344
|
-
const [state2, dispatch] =
|
|
41403
|
+
const [state2, dispatch] = React65.useReducer(makeHtmlReducer(args), inactiveState);
|
|
41345
41404
|
const currentResourceUrl = (_b = (_a = state2.location) == null ? void 0 : _a.href) != null ? _b : null;
|
|
41346
41405
|
const injectables = ((_d = (_c = manifest == null ? void 0 : manifest.metadata) == null ? void 0 : _c.presentation) == null ? void 0 : _d.layout) === "fixed" ? injectablesFixed : injectablesReflowable;
|
|
41347
41406
|
useResource(manifest, state2, getContent, injectables, dispatch);
|
|
@@ -41351,8 +41410,8 @@ function useHtmlReader(args) {
|
|
|
41351
41410
|
useLocationQuery(state2);
|
|
41352
41411
|
useWindowResize(manifest, state2, dispatch);
|
|
41353
41412
|
useUpdateCSS(state2, manifest);
|
|
41354
|
-
useIframeLinkClick(dispatch);
|
|
41355
|
-
|
|
41413
|
+
useIframeLinkClick(webpubManifestUrl, manifest, dispatch);
|
|
41414
|
+
React65.useEffect(() => {
|
|
41356
41415
|
if (!webpubManifestUrl || !manifest) {
|
|
41357
41416
|
return dispatch({ type: "ARGS_CHANGED", args: void 0 });
|
|
41358
41417
|
}
|
|
@@ -41381,7 +41440,7 @@ function useHtmlReader(args) {
|
|
|
41381
41440
|
persistLastLocation,
|
|
41382
41441
|
persistSettings
|
|
41383
41442
|
]);
|
|
41384
|
-
|
|
41443
|
+
React65.useEffect(() => {
|
|
41385
41444
|
process.nextTick(() => {
|
|
41386
41445
|
if (state2.state === "NAVIGATING") {
|
|
41387
41446
|
const { fragment, progression, position: position3 } = state2.location.locations;
|
|
@@ -41403,7 +41462,7 @@ function useHtmlReader(args) {
|
|
|
41403
41462
|
(_g = state2.settings) == null ? void 0 : _g.isScrolling,
|
|
41404
41463
|
(_h = state2.location) == null ? void 0 : _h.locations
|
|
41405
41464
|
]);
|
|
41406
|
-
const navigator2 =
|
|
41465
|
+
const navigator2 = React65.useRef({
|
|
41407
41466
|
goToPage(href) {
|
|
41408
41467
|
dispatch({ type: "GO_TO_HREF", href });
|
|
41409
41468
|
},
|
|
@@ -41444,7 +41503,7 @@ function useHtmlReader(args) {
|
|
|
41444
41503
|
});
|
|
41445
41504
|
}
|
|
41446
41505
|
}).current;
|
|
41447
|
-
const setIframe =
|
|
41506
|
+
const setIframe = React65.useRef((el) => {
|
|
41448
41507
|
dispatch({ type: "SET_IFRAME", iframe: el });
|
|
41449
41508
|
}).current;
|
|
41450
41509
|
if (!webpubManifestUrl || !manifest)
|
|
@@ -41453,8 +41512,9 @@ function useHtmlReader(args) {
|
|
|
41453
41512
|
return {
|
|
41454
41513
|
type: null,
|
|
41455
41514
|
isLoading: true,
|
|
41456
|
-
content: /* @__PURE__ */
|
|
41457
|
-
height
|
|
41515
|
+
content: /* @__PURE__ */ React65.createElement(LoadingSkeleton, {
|
|
41516
|
+
height,
|
|
41517
|
+
state: state2
|
|
41458
41518
|
}),
|
|
41459
41519
|
navigator: null,
|
|
41460
41520
|
manifest: null,
|
|
@@ -41476,7 +41536,7 @@ function useHtmlReader(args) {
|
|
|
41476
41536
|
return {
|
|
41477
41537
|
type: "HTML",
|
|
41478
41538
|
isLoading: false,
|
|
41479
|
-
content: /* @__PURE__ */
|
|
41539
|
+
content: /* @__PURE__ */ React65.createElement(React65.Fragment, null, /* @__PURE__ */ React65.createElement("iframe", {
|
|
41480
41540
|
id: IFRAME_ID_SELECTOR,
|
|
41481
41541
|
onLoad: () => dispatch({ type: "IFRAME_LOADED" }),
|
|
41482
41542
|
ref: setIframe,
|
|
@@ -41528,8 +41588,8 @@ function useWebReader(args) {
|
|
|
41528
41588
|
persistLastLocation = true,
|
|
41529
41589
|
persistSettings = true
|
|
41530
41590
|
} = args;
|
|
41531
|
-
const [manifest, setManifest] =
|
|
41532
|
-
const [error2, setError] =
|
|
41591
|
+
const [manifest, setManifest] = React66.useState(null);
|
|
41592
|
+
const [error2, setError] = React66.useState(null);
|
|
41533
41593
|
if (error2) {
|
|
41534
41594
|
throw error2;
|
|
41535
41595
|
}
|
|
@@ -41555,14 +41615,15 @@ function useWebReader(args) {
|
|
|
41555
41615
|
persistLastLocation,
|
|
41556
41616
|
persistSettings
|
|
41557
41617
|
} : void 0);
|
|
41558
|
-
|
|
41618
|
+
React66.useEffect(() => {
|
|
41559
41619
|
fetchJson(webpubManifestUrl).then(setManifest).catch(setError);
|
|
41560
41620
|
}, [webpubManifestUrl]);
|
|
41561
41621
|
if (manifest === null) {
|
|
41562
41622
|
return {
|
|
41563
41623
|
isLoading: true,
|
|
41564
|
-
content: /* @__PURE__ */
|
|
41565
|
-
height
|
|
41624
|
+
content: /* @__PURE__ */ React66.createElement(LoadingSkeleton, {
|
|
41625
|
+
height,
|
|
41626
|
+
state: htmlReader == null ? void 0 : htmlReader.state
|
|
41566
41627
|
}),
|
|
41567
41628
|
manifest: null,
|
|
41568
41629
|
navigator: null,
|
|
@@ -41580,7 +41641,7 @@ function useWebReader(args) {
|
|
|
41580
41641
|
}
|
|
41581
41642
|
|
|
41582
41643
|
// src/ServiceWorker/client.ts
|
|
41583
|
-
import
|
|
41644
|
+
import React67 from "react";
|
|
41584
41645
|
|
|
41585
41646
|
// src/ServiceWorker/constants.ts
|
|
41586
41647
|
var PRECACHE_PUBLICATIONS = "PRECACHE_PUBLICATIONS";
|
|
@@ -41588,7 +41649,7 @@ var CACHE_EXPIRATION_SECONDS = 7 * 24 * 60 * 60;
|
|
|
41588
41649
|
|
|
41589
41650
|
// src/ServiceWorker/client.ts
|
|
41590
41651
|
function usePublicationSW(publications) {
|
|
41591
|
-
|
|
41652
|
+
React67.useEffect(() => {
|
|
41592
41653
|
var _a;
|
|
41593
41654
|
if ("serviceWorker" in navigator) {
|
|
41594
41655
|
const message = {
|
|
@@ -41619,12 +41680,12 @@ var WebReaderWithoutBoundary = (_a) => {
|
|
|
41619
41680
|
getContent
|
|
41620
41681
|
}, props));
|
|
41621
41682
|
const { content } = webReader;
|
|
41622
|
-
return /* @__PURE__ */
|
|
41683
|
+
return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
|
|
41623
41684
|
headerLeft
|
|
41624
41685
|
}, webReader), content);
|
|
41625
41686
|
};
|
|
41626
41687
|
var WebReader = (props) => {
|
|
41627
|
-
return /* @__PURE__ */
|
|
41688
|
+
return /* @__PURE__ */ React68.createElement(ErrorBoundary_default, __spreadValues({}, props), /* @__PURE__ */ React68.createElement(WebReaderWithoutBoundary, __spreadValues({}, props)));
|
|
41628
41689
|
};
|
|
41629
41690
|
var src_default = WebReader;
|
|
41630
41691
|
export {
|