@nypl/web-reader 0.2.0-alpha.3 → 0.2.0-alpha.4
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 +79 -79
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +80 -98
- package/dist/esm/index.js.map +2 -2
- package/dist/types/WebpubManifestTypes/ConformsTo.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +12 -4
- package/dist/types/ui/Header.d.ts +2 -5
- package/dist/types/ui/manager.d.ts +2 -2
- package/package.json +2 -3
package/dist/esm/index.js
CHANGED
|
@@ -36371,35 +36371,17 @@ var ToggleGroup_default = ToggleGroup;
|
|
|
36371
36371
|
|
|
36372
36372
|
// src/ui/PdfSettings.tsx
|
|
36373
36373
|
function PdfSettings(props) {
|
|
36374
|
-
const { navigator: navigator2,
|
|
36375
|
-
const {
|
|
36376
|
-
|
|
36377
|
-
setFontFamily,
|
|
36378
|
-
decreaseFontSize,
|
|
36379
|
-
increaseFontSize,
|
|
36380
|
-
setScroll
|
|
36381
|
-
} = navigator2;
|
|
36382
|
-
return /* @__PURE__ */ createElement29(Fragment4, null, /* @__PURE__ */ createElement29(ToggleGroup_default, {
|
|
36383
|
-
value: fontFamily,
|
|
36384
|
-
label: "text font options",
|
|
36385
|
-
onChange: setFontFamily
|
|
36386
|
-
}, /* @__PURE__ */ createElement29(ToggleButton_default, {
|
|
36387
|
-
value: "publisher"
|
|
36388
|
-
}, "Publisher"), /* @__PURE__ */ createElement29(ToggleButton_default, {
|
|
36389
|
-
value: "serif"
|
|
36390
|
-
}, "Serif"), /* @__PURE__ */ createElement29(ToggleButton_default, {
|
|
36391
|
-
value: "sans-serif"
|
|
36392
|
-
}, "Sans-Serif"), /* @__PURE__ */ createElement29(ToggleButton_default, {
|
|
36393
|
-
value: "open-dyslexic"
|
|
36394
|
-
}, "Dyslexia-Friendly")), /* @__PURE__ */ createElement29(ButtonGroup, {
|
|
36374
|
+
const { navigator: navigator2, paginationValue } = props;
|
|
36375
|
+
const { zoomOut, zoomIn, setScroll } = navigator2;
|
|
36376
|
+
return /* @__PURE__ */ createElement29(Fragment4, null, /* @__PURE__ */ createElement29(ButtonGroup, {
|
|
36395
36377
|
d: "flex",
|
|
36396
36378
|
spacing: 0
|
|
36397
36379
|
}, /* @__PURE__ */ createElement29(Button_default, {
|
|
36398
36380
|
flexGrow: 1,
|
|
36399
|
-
"aria-label": "Zoom
|
|
36400
|
-
onClick:
|
|
36381
|
+
"aria-label": "Zoom Out",
|
|
36382
|
+
onClick: zoomOut,
|
|
36401
36383
|
variant: "toggle"
|
|
36402
|
-
}, "Zoom", /* @__PURE__ */ createElement29(Circle, {
|
|
36384
|
+
}, "Zoom Out", /* @__PURE__ */ createElement29(Circle, {
|
|
36403
36385
|
border: "1px solid",
|
|
36404
36386
|
p: 1,
|
|
36405
36387
|
ml: 1,
|
|
@@ -36409,12 +36391,12 @@ function PdfSettings(props) {
|
|
|
36409
36391
|
decorative: true,
|
|
36410
36392
|
name: import_design_system_react_components2.IconNames.minus,
|
|
36411
36393
|
modifiers: ["small"]
|
|
36412
|
-
})
|
|
36394
|
+
}))), /* @__PURE__ */ createElement29(Button_default, {
|
|
36413
36395
|
flexGrow: 1,
|
|
36414
|
-
"aria-label": "Zoom
|
|
36415
|
-
onClick:
|
|
36396
|
+
"aria-label": "Zoom In",
|
|
36397
|
+
onClick: zoomIn,
|
|
36416
36398
|
variant: "toggle"
|
|
36417
|
-
}, "Zoom", /* @__PURE__ */ createElement29(Circle, {
|
|
36399
|
+
}, "Zoom In", /* @__PURE__ */ createElement29(Circle, {
|
|
36418
36400
|
border: "1px solid",
|
|
36419
36401
|
p: 1,
|
|
36420
36402
|
ml: 1,
|
|
@@ -36424,7 +36406,7 @@ function PdfSettings(props) {
|
|
|
36424
36406
|
decorative: true,
|
|
36425
36407
|
name: import_design_system_react_components2.IconNames.plus,
|
|
36426
36408
|
modifiers: ["small"]
|
|
36427
|
-
})
|
|
36409
|
+
})))), /* @__PURE__ */ createElement29(ToggleGroup_default, {
|
|
36428
36410
|
onChange: setScroll,
|
|
36429
36411
|
value: paginationValue,
|
|
36430
36412
|
label: "pagination options"
|
|
@@ -36507,11 +36489,11 @@ function HtmlSettings(props) {
|
|
|
36507
36489
|
|
|
36508
36490
|
// src/ui/SettingsButton.tsx
|
|
36509
36491
|
function SettingsCard(props) {
|
|
36492
|
+
var _a;
|
|
36510
36493
|
const [isOpen, setIsOpen] = useState16(false);
|
|
36511
36494
|
const open = () => setIsOpen(!isOpen);
|
|
36512
36495
|
const close = () => setIsOpen(false);
|
|
36513
|
-
const
|
|
36514
|
-
const paginationValue = (state == null ? void 0 : state.isScrolling) ? "scrolling" : "paginated";
|
|
36496
|
+
const paginationValue = ((_a = props.state) == null ? void 0 : _a.isScrolling) ? "scrolling" : "paginated";
|
|
36515
36497
|
const contentBgColor = useColorModeValue_default("ui.white", "ui.black", "ui.white");
|
|
36516
36498
|
return /* @__PURE__ */ createElement31(Fragment6, null, /* @__PURE__ */ createElement31(Popover, {
|
|
36517
36499
|
placement: "bottom",
|
|
@@ -36534,13 +36516,13 @@ function SettingsCard(props) {
|
|
|
36534
36516
|
}, /* @__PURE__ */ createElement31(PopoverBody, {
|
|
36535
36517
|
p: 0,
|
|
36536
36518
|
maxWidth: "95vw"
|
|
36537
|
-
}, type === "PDF" && /* @__PURE__ */ createElement31(PdfSettings, {
|
|
36538
|
-
navigator:
|
|
36539
|
-
readerState: state,
|
|
36519
|
+
}, props.type === "PDF" && /* @__PURE__ */ createElement31(PdfSettings, {
|
|
36520
|
+
navigator: props.navigator,
|
|
36521
|
+
readerState: props.state,
|
|
36540
36522
|
paginationValue
|
|
36541
|
-
}), type === "HTML" && /* @__PURE__ */ createElement31(HtmlSettings, {
|
|
36542
|
-
navigator:
|
|
36543
|
-
readerState: state,
|
|
36523
|
+
}), props.type === "HTML" && /* @__PURE__ */ createElement31(HtmlSettings, {
|
|
36524
|
+
navigator: props.navigator,
|
|
36525
|
+
readerState: props.state,
|
|
36544
36526
|
paginationValue
|
|
36545
36527
|
})))));
|
|
36546
36528
|
}
|
|
@@ -36646,15 +36628,29 @@ function TableOfContent({
|
|
|
36646
36628
|
}
|
|
36647
36629
|
|
|
36648
36630
|
// src/ui/Header.tsx
|
|
36631
|
+
var DefaultHeaderLeft = () => {
|
|
36632
|
+
const linkColor = useColorModeValue_default("gray.700", "gray.100", "gray.700");
|
|
36633
|
+
return /* @__PURE__ */ React50.createElement(Link, {
|
|
36634
|
+
href: "/",
|
|
36635
|
+
"aria-label": "Return to Homepage",
|
|
36636
|
+
tabIndex: 0,
|
|
36637
|
+
fontSize: 0,
|
|
36638
|
+
py: 1,
|
|
36639
|
+
textTransform: "uppercase",
|
|
36640
|
+
d: "flex",
|
|
36641
|
+
color: linkColor,
|
|
36642
|
+
height: "100%",
|
|
36643
|
+
alignItems: "center",
|
|
36644
|
+
_hover: {
|
|
36645
|
+
textDecoration: "none"
|
|
36646
|
+
}
|
|
36647
|
+
}, /* @__PURE__ */ React50.createElement(Text, {
|
|
36648
|
+
variant: "headerNav"
|
|
36649
|
+
}, "Back to Homepage"));
|
|
36650
|
+
};
|
|
36649
36651
|
function Header(props) {
|
|
36650
36652
|
const { headerLeft, state, navigator: navigator2, manifest } = props;
|
|
36651
|
-
const linkColor = useColorModeValue_default("gray.700", "gray.100", "gray.700");
|
|
36652
36653
|
const mainBgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
|
|
36653
|
-
const ChakraIcon = chakra(import_design_system_react_components5.Icon, {
|
|
36654
|
-
baseStyle: {
|
|
36655
|
-
height: "100%"
|
|
36656
|
-
}
|
|
36657
|
-
});
|
|
36658
36654
|
return /* @__PURE__ */ React50.createElement(Flex, {
|
|
36659
36655
|
as: "header",
|
|
36660
36656
|
position: "sticky",
|
|
@@ -36669,27 +36665,7 @@ function Header(props) {
|
|
|
36669
36665
|
borderBottom: "1px solid",
|
|
36670
36666
|
borderColor: "gray.100",
|
|
36671
36667
|
bgColor: mainBgColor
|
|
36672
|
-
}, headerLeft ? headerLeft : /* @__PURE__ */ React50.createElement(
|
|
36673
|
-
href: "https://www.nypl.org",
|
|
36674
|
-
"aria-label": "Return to NYPL",
|
|
36675
|
-
tabIndex: 0,
|
|
36676
|
-
fontSize: 0,
|
|
36677
|
-
py: 1,
|
|
36678
|
-
textTransform: "uppercase",
|
|
36679
|
-
d: "flex",
|
|
36680
|
-
color: linkColor,
|
|
36681
|
-
height: "100%",
|
|
36682
|
-
alignItems: "center",
|
|
36683
|
-
_hover: {
|
|
36684
|
-
textDecoration: "none"
|
|
36685
|
-
}
|
|
36686
|
-
}, /* @__PURE__ */ React50.createElement(ChakraIcon, {
|
|
36687
|
-
decorative: true,
|
|
36688
|
-
name: import_design_system_react_components5.LogoNames.logo_nypl,
|
|
36689
|
-
modifiers: ["xlarge"]
|
|
36690
|
-
}), /* @__PURE__ */ React50.createElement(Text, {
|
|
36691
|
-
variant: "headerNav"
|
|
36692
|
-
}, "Return to NYPL")), /* @__PURE__ */ React50.createElement(HStack, {
|
|
36668
|
+
}, headerLeft != null ? headerLeft : /* @__PURE__ */ React50.createElement(DefaultHeaderLeft, null), /* @__PURE__ */ React50.createElement(HStack, {
|
|
36693
36669
|
ml: "auto",
|
|
36694
36670
|
spacing: 1
|
|
36695
36671
|
}, /* @__PURE__ */ React50.createElement(TableOfContent, {
|
|
@@ -36741,14 +36717,22 @@ var ManagerUI = (props) => {
|
|
|
36741
36717
|
}, /* @__PURE__ */ createElement32(WebReaderContent, __spreadValues({}, props)));
|
|
36742
36718
|
};
|
|
36743
36719
|
var WebReaderContent = (_a) => {
|
|
36744
|
-
var _b = _a, {
|
|
36720
|
+
var _b = _a, {
|
|
36721
|
+
children,
|
|
36722
|
+
headerLeft
|
|
36723
|
+
} = _b, props = __objRest(_b, [
|
|
36724
|
+
"children",
|
|
36725
|
+
"headerLeft"
|
|
36726
|
+
]);
|
|
36745
36727
|
var _a2, _b2;
|
|
36746
36728
|
const bgColor = useColorModeValue_default("ui.white", "ui.black", "ui.sepia");
|
|
36747
36729
|
return /* @__PURE__ */ createElement32(Flex, {
|
|
36748
36730
|
flexDir: "column",
|
|
36749
36731
|
minHeight: "100vh",
|
|
36750
36732
|
w: "100vw"
|
|
36751
|
-
}, !props.isLoading && /* @__PURE__ */ createElement32(Header, __spreadValues({
|
|
36733
|
+
}, !props.isLoading && /* @__PURE__ */ createElement32(Header, __spreadValues({
|
|
36734
|
+
headerLeft
|
|
36735
|
+
}, props)), /* @__PURE__ */ createElement32(PageButton_default, {
|
|
36752
36736
|
onClick: (_a2 = props.navigator) == null ? void 0 : _a2.goBackward,
|
|
36753
36737
|
left: 0,
|
|
36754
36738
|
pr: 2,
|
|
@@ -39796,7 +39780,6 @@ function useMeasure() {
|
|
|
39796
39780
|
}
|
|
39797
39781
|
|
|
39798
39782
|
// src/PdfReader/index.tsx
|
|
39799
|
-
pdfjs4.GlobalWorkerOptions.workerSrc = `pdf.worker.min.js`;
|
|
39800
39783
|
var IFRAME_WRAPPER_ID = "iframe-wrapper";
|
|
39801
39784
|
function pdfReducer(state, action) {
|
|
39802
39785
|
switch (action.type) {
|
|
@@ -39820,10 +39803,6 @@ function pdfReducer(state, action) {
|
|
|
39820
39803
|
return __spreadProps(__spreadValues({}, state), {
|
|
39821
39804
|
pageNumber: action.pageNum
|
|
39822
39805
|
});
|
|
39823
|
-
case "SET_COLOR_MODE":
|
|
39824
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
39825
|
-
colorMode: action.mode
|
|
39826
|
-
});
|
|
39827
39806
|
case "SET_SCROLL":
|
|
39828
39807
|
return __spreadProps(__spreadValues({}, state), {
|
|
39829
39808
|
isScrolling: action.isScrolling
|
|
@@ -39862,6 +39841,9 @@ var loadResource = (resourceUrl, proxyUrl) => __async(void 0, null, function* ()
|
|
|
39862
39841
|
return array;
|
|
39863
39842
|
});
|
|
39864
39843
|
function usePdfReader(args) {
|
|
39844
|
+
if (args == null ? void 0 : args.pdfWorkerSrc) {
|
|
39845
|
+
pdfjs4.GlobalWorkerOptions.workerSrc = args.pdfWorkerSrc;
|
|
39846
|
+
}
|
|
39865
39847
|
const { webpubManifestUrl, manifest, proxyUrl } = args != null ? args : {};
|
|
39866
39848
|
const [state, dispatch] = useReducer(pdfReducer, {
|
|
39867
39849
|
colorMode: "day",
|
|
@@ -39970,28 +39952,22 @@ function usePdfReader(args) {
|
|
|
39970
39952
|
state.pageNumber,
|
|
39971
39953
|
state.resourceIndex
|
|
39972
39954
|
]);
|
|
39973
|
-
const setColorMode = useCallback19(() => __async(this, null, function* () {
|
|
39974
|
-
console.log("unimplemented");
|
|
39975
|
-
}), []);
|
|
39976
39955
|
const setScroll = useCallback19((val) => __async(this, null, function* () {
|
|
39977
39956
|
const isScrolling = val === "scrolling";
|
|
39978
39957
|
dispatch({ type: "SET_SCROLL", isScrolling });
|
|
39979
39958
|
}), []);
|
|
39980
|
-
const
|
|
39959
|
+
const zoomIn = useCallback19(() => __async(this, null, function* () {
|
|
39981
39960
|
dispatch({
|
|
39982
39961
|
type: "SET_SCALE",
|
|
39983
39962
|
scale: state.scale + 0.1
|
|
39984
39963
|
});
|
|
39985
39964
|
}), [state.scale]);
|
|
39986
|
-
const
|
|
39965
|
+
const zoomOut = useCallback19(() => __async(this, null, function* () {
|
|
39987
39966
|
dispatch({
|
|
39988
39967
|
type: "SET_SCALE",
|
|
39989
39968
|
scale: state.scale - 0.1
|
|
39990
39969
|
});
|
|
39991
39970
|
}), [state.scale]);
|
|
39992
|
-
const setFontFamily = useCallback19(() => __async(this, null, function* () {
|
|
39993
|
-
console.log("unimplemented");
|
|
39994
|
-
}), []);
|
|
39995
39971
|
const goToPage = useCallback19((href) => __async(this, null, function* () {
|
|
39996
39972
|
const getIndexFromHref = (href2) => {
|
|
39997
39973
|
var _a;
|
|
@@ -40029,10 +40005,8 @@ function usePdfReader(args) {
|
|
|
40029
40005
|
navigator: {
|
|
40030
40006
|
goForward,
|
|
40031
40007
|
goBackward,
|
|
40032
|
-
|
|
40033
|
-
|
|
40034
|
-
setFontFamily,
|
|
40035
|
-
setColorMode,
|
|
40008
|
+
zoomIn,
|
|
40009
|
+
zoomOut,
|
|
40036
40010
|
setScroll,
|
|
40037
40011
|
goToPage
|
|
40038
40012
|
}
|
|
@@ -40089,11 +40063,9 @@ function usePdfReader(args) {
|
|
|
40089
40063
|
navigator: {
|
|
40090
40064
|
goForward,
|
|
40091
40065
|
goBackward,
|
|
40092
|
-
setColorMode,
|
|
40093
40066
|
setScroll,
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
setFontFamily,
|
|
40067
|
+
zoomIn,
|
|
40068
|
+
zoomOut,
|
|
40097
40069
|
goToPage
|
|
40098
40070
|
}
|
|
40099
40071
|
};
|
|
@@ -88654,7 +88626,7 @@ var r2FamilyToFamily = {
|
|
|
88654
88626
|
};
|
|
88655
88627
|
|
|
88656
88628
|
// src/WebpubManifestTypes/ConformsTo.ts
|
|
88657
|
-
var WebpubPdfConformsTo = "
|
|
88629
|
+
var WebpubPdfConformsTo = "http://librarysimplified.org/terms/profiles/pdf";
|
|
88658
88630
|
var AxisNowEpubConformsTo = "stub/webpub+axisnow";
|
|
88659
88631
|
|
|
88660
88632
|
// src/useWebReader.tsx
|
|
@@ -88671,7 +88643,7 @@ function getReaderType(conformsTo) {
|
|
|
88671
88643
|
}
|
|
88672
88644
|
}
|
|
88673
88645
|
function useWebReader(args) {
|
|
88674
|
-
const { webpubManifestUrl, getContent, proxyUrl } = args;
|
|
88646
|
+
const { webpubManifestUrl, getContent, proxyUrl, pdfWorkerSrc } = args;
|
|
88675
88647
|
const [manifest, setManifest] = React67.useState(null);
|
|
88676
88648
|
const readerType = getReaderType(manifest ? manifest.metadata.conformsTo : null);
|
|
88677
88649
|
const htmlReader = useHtmlReader(readerType === "HTML" && manifest ? {
|
|
@@ -88682,7 +88654,8 @@ function useWebReader(args) {
|
|
|
88682
88654
|
const pdfReader = usePdfReader(readerType === "PDF" && manifest ? {
|
|
88683
88655
|
webpubManifestUrl,
|
|
88684
88656
|
manifest,
|
|
88685
|
-
proxyUrl
|
|
88657
|
+
proxyUrl,
|
|
88658
|
+
pdfWorkerSrc
|
|
88686
88659
|
} : void 0);
|
|
88687
88660
|
React67.useEffect(() => {
|
|
88688
88661
|
fetchJson(webpubManifestUrl).then(setManifest);
|
|
@@ -88707,18 +88680,27 @@ function useWebReader(args) {
|
|
|
88707
88680
|
}
|
|
88708
88681
|
|
|
88709
88682
|
// src/index.tsx
|
|
88710
|
-
var WebReader = ({
|
|
88711
|
-
|
|
88712
|
-
|
|
88713
|
-
|
|
88714
|
-
|
|
88715
|
-
|
|
88683
|
+
var WebReader = (_a) => {
|
|
88684
|
+
var _b = _a, {
|
|
88685
|
+
webpubManifestUrl,
|
|
88686
|
+
proxyUrl,
|
|
88687
|
+
getContent,
|
|
88688
|
+
headerLeft
|
|
88689
|
+
} = _b, props = __objRest(_b, [
|
|
88690
|
+
"webpubManifestUrl",
|
|
88691
|
+
"proxyUrl",
|
|
88692
|
+
"getContent",
|
|
88693
|
+
"headerLeft"
|
|
88694
|
+
]);
|
|
88695
|
+
const webReader = useWebReader(__spreadValues({
|
|
88716
88696
|
webpubManifestUrl,
|
|
88717
88697
|
proxyUrl,
|
|
88718
88698
|
getContent
|
|
88719
|
-
});
|
|
88699
|
+
}, props));
|
|
88720
88700
|
const { content } = webReader;
|
|
88721
|
-
return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
|
|
88701
|
+
return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
|
|
88702
|
+
headerLeft
|
|
88703
|
+
}, webReader), content);
|
|
88722
88704
|
};
|
|
88723
88705
|
var src_default2 = WebReader;
|
|
88724
88706
|
export {
|