@nypl/web-reader 0.2.0-alpha.1 → 0.2.0-alpha.6
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 +83 -99
- package/dist/esm/index.js.map +2 -2
- package/dist/{css/HtmlReader/styles.css → html-styles.css} +1 -1
- package/dist/{css/HtmlReader/styles.css.map → html-styles.css.map} +1 -1
- package/dist/{css/PdfReader/styles.css → pdf-styles.css} +1 -1
- package/dist/{css/PdfReader/styles.css.map → pdf-styles.css.map} +1 -1
- 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 -19
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,
|
|
@@ -36759,7 +36743,6 @@ var WebReaderContent = (_a) => {
|
|
|
36759
36743
|
modifiers: ["small"],
|
|
36760
36744
|
iconRotation: import_design_system_react_components6.IconRotationTypes.rotate90
|
|
36761
36745
|
})), /* @__PURE__ */ createElement32(Flex, {
|
|
36762
|
-
width: "100vw",
|
|
36763
36746
|
bg: bgColor,
|
|
36764
36747
|
px: { sm: 10, md: "5vw" },
|
|
36765
36748
|
flexDir: "column",
|
|
@@ -39796,7 +39779,6 @@ function useMeasure() {
|
|
|
39796
39779
|
}
|
|
39797
39780
|
|
|
39798
39781
|
// src/PdfReader/index.tsx
|
|
39799
|
-
pdfjs4.GlobalWorkerOptions.workerSrc = `pdf.worker.min.js`;
|
|
39800
39782
|
var IFRAME_WRAPPER_ID = "iframe-wrapper";
|
|
39801
39783
|
function pdfReducer(state, action) {
|
|
39802
39784
|
switch (action.type) {
|
|
@@ -39820,10 +39802,6 @@ function pdfReducer(state, action) {
|
|
|
39820
39802
|
return __spreadProps(__spreadValues({}, state), {
|
|
39821
39803
|
pageNumber: action.pageNum
|
|
39822
39804
|
});
|
|
39823
|
-
case "SET_COLOR_MODE":
|
|
39824
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
39825
|
-
colorMode: action.mode
|
|
39826
|
-
});
|
|
39827
39805
|
case "SET_SCROLL":
|
|
39828
39806
|
return __spreadProps(__spreadValues({}, state), {
|
|
39829
39807
|
isScrolling: action.isScrolling
|
|
@@ -39862,6 +39840,9 @@ var loadResource = (resourceUrl, proxyUrl) => __async(void 0, null, function* ()
|
|
|
39862
39840
|
return array;
|
|
39863
39841
|
});
|
|
39864
39842
|
function usePdfReader(args) {
|
|
39843
|
+
if (args == null ? void 0 : args.pdfWorkerSrc) {
|
|
39844
|
+
pdfjs4.GlobalWorkerOptions.workerSrc = args.pdfWorkerSrc;
|
|
39845
|
+
}
|
|
39865
39846
|
const { webpubManifestUrl, manifest, proxyUrl } = args != null ? args : {};
|
|
39866
39847
|
const [state, dispatch] = useReducer(pdfReducer, {
|
|
39867
39848
|
colorMode: "day",
|
|
@@ -39970,28 +39951,22 @@ function usePdfReader(args) {
|
|
|
39970
39951
|
state.pageNumber,
|
|
39971
39952
|
state.resourceIndex
|
|
39972
39953
|
]);
|
|
39973
|
-
const setColorMode = useCallback19(() => __async(this, null, function* () {
|
|
39974
|
-
console.log("unimplemented");
|
|
39975
|
-
}), []);
|
|
39976
39954
|
const setScroll = useCallback19((val) => __async(this, null, function* () {
|
|
39977
39955
|
const isScrolling = val === "scrolling";
|
|
39978
39956
|
dispatch({ type: "SET_SCROLL", isScrolling });
|
|
39979
39957
|
}), []);
|
|
39980
|
-
const
|
|
39958
|
+
const zoomIn = useCallback19(() => __async(this, null, function* () {
|
|
39981
39959
|
dispatch({
|
|
39982
39960
|
type: "SET_SCALE",
|
|
39983
39961
|
scale: state.scale + 0.1
|
|
39984
39962
|
});
|
|
39985
39963
|
}), [state.scale]);
|
|
39986
|
-
const
|
|
39964
|
+
const zoomOut = useCallback19(() => __async(this, null, function* () {
|
|
39987
39965
|
dispatch({
|
|
39988
39966
|
type: "SET_SCALE",
|
|
39989
39967
|
scale: state.scale - 0.1
|
|
39990
39968
|
});
|
|
39991
39969
|
}), [state.scale]);
|
|
39992
|
-
const setFontFamily = useCallback19(() => __async(this, null, function* () {
|
|
39993
|
-
console.log("unimplemented");
|
|
39994
|
-
}), []);
|
|
39995
39970
|
const goToPage = useCallback19((href) => __async(this, null, function* () {
|
|
39996
39971
|
const getIndexFromHref = (href2) => {
|
|
39997
39972
|
var _a;
|
|
@@ -40029,10 +40004,8 @@ function usePdfReader(args) {
|
|
|
40029
40004
|
navigator: {
|
|
40030
40005
|
goForward,
|
|
40031
40006
|
goBackward,
|
|
40032
|
-
|
|
40033
|
-
|
|
40034
|
-
setFontFamily,
|
|
40035
|
-
setColorMode,
|
|
40007
|
+
zoomIn,
|
|
40008
|
+
zoomOut,
|
|
40036
40009
|
setScroll,
|
|
40037
40010
|
goToPage
|
|
40038
40011
|
}
|
|
@@ -40089,11 +40062,9 @@ function usePdfReader(args) {
|
|
|
40089
40062
|
navigator: {
|
|
40090
40063
|
goForward,
|
|
40091
40064
|
goBackward,
|
|
40092
|
-
setColorMode,
|
|
40093
40065
|
setScroll,
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
setFontFamily,
|
|
40066
|
+
zoomIn,
|
|
40067
|
+
zoomOut,
|
|
40097
40068
|
goToPage
|
|
40098
40069
|
}
|
|
40099
40070
|
};
|
|
@@ -88520,6 +88491,9 @@ function useHtmlReader(args) {
|
|
|
88520
88491
|
navHeight: HEADER_HEIGHT,
|
|
88521
88492
|
margin: 0
|
|
88522
88493
|
},
|
|
88494
|
+
rights: {
|
|
88495
|
+
autoGeneratePositions: false
|
|
88496
|
+
},
|
|
88523
88497
|
api: {
|
|
88524
88498
|
getContent
|
|
88525
88499
|
}
|
|
@@ -88651,7 +88625,7 @@ var r2FamilyToFamily = {
|
|
|
88651
88625
|
};
|
|
88652
88626
|
|
|
88653
88627
|
// src/WebpubManifestTypes/ConformsTo.ts
|
|
88654
|
-
var WebpubPdfConformsTo = "
|
|
88628
|
+
var WebpubPdfConformsTo = "http://librarysimplified.org/terms/profiles/pdf";
|
|
88655
88629
|
var AxisNowEpubConformsTo = "stub/webpub+axisnow";
|
|
88656
88630
|
|
|
88657
88631
|
// src/useWebReader.tsx
|
|
@@ -88668,7 +88642,7 @@ function getReaderType(conformsTo) {
|
|
|
88668
88642
|
}
|
|
88669
88643
|
}
|
|
88670
88644
|
function useWebReader(args) {
|
|
88671
|
-
const { webpubManifestUrl, getContent, proxyUrl } = args;
|
|
88645
|
+
const { webpubManifestUrl, getContent, proxyUrl, pdfWorkerSrc } = args;
|
|
88672
88646
|
const [manifest, setManifest] = React67.useState(null);
|
|
88673
88647
|
const readerType = getReaderType(manifest ? manifest.metadata.conformsTo : null);
|
|
88674
88648
|
const htmlReader = useHtmlReader(readerType === "HTML" && manifest ? {
|
|
@@ -88679,7 +88653,8 @@ function useWebReader(args) {
|
|
|
88679
88653
|
const pdfReader = usePdfReader(readerType === "PDF" && manifest ? {
|
|
88680
88654
|
webpubManifestUrl,
|
|
88681
88655
|
manifest,
|
|
88682
|
-
proxyUrl
|
|
88656
|
+
proxyUrl,
|
|
88657
|
+
pdfWorkerSrc
|
|
88683
88658
|
} : void 0);
|
|
88684
88659
|
React67.useEffect(() => {
|
|
88685
88660
|
fetchJson(webpubManifestUrl).then(setManifest);
|
|
@@ -88704,18 +88679,27 @@ function useWebReader(args) {
|
|
|
88704
88679
|
}
|
|
88705
88680
|
|
|
88706
88681
|
// src/index.tsx
|
|
88707
|
-
var WebReader = ({
|
|
88708
|
-
|
|
88709
|
-
|
|
88710
|
-
|
|
88711
|
-
|
|
88712
|
-
|
|
88682
|
+
var WebReader = (_a) => {
|
|
88683
|
+
var _b = _a, {
|
|
88684
|
+
webpubManifestUrl,
|
|
88685
|
+
proxyUrl,
|
|
88686
|
+
getContent,
|
|
88687
|
+
headerLeft
|
|
88688
|
+
} = _b, props = __objRest(_b, [
|
|
88689
|
+
"webpubManifestUrl",
|
|
88690
|
+
"proxyUrl",
|
|
88691
|
+
"getContent",
|
|
88692
|
+
"headerLeft"
|
|
88693
|
+
]);
|
|
88694
|
+
const webReader = useWebReader(__spreadValues({
|
|
88713
88695
|
webpubManifestUrl,
|
|
88714
88696
|
proxyUrl,
|
|
88715
88697
|
getContent
|
|
88716
|
-
});
|
|
88698
|
+
}, props));
|
|
88717
88699
|
const { content } = webReader;
|
|
88718
|
-
return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
|
|
88700
|
+
return /* @__PURE__ */ React68.createElement(manager_default, __spreadValues({
|
|
88701
|
+
headerLeft
|
|
88702
|
+
}, webReader), content);
|
|
88719
88703
|
};
|
|
88720
88704
|
var src_default2 = WebReader;
|
|
88721
88705
|
export {
|