@embedpdf/plugin-search 1.0.0

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.
@@ -0,0 +1,27 @@
1
+ import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
+ import { SearchPlugin } from '@embedpdf/plugin-search';
3
+ import { JSX } from 'preact';
4
+
5
+ declare const useSearch: () => {
6
+ plugin: SearchPlugin | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useSearchCapability: () => {
11
+ provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ /** @jsxImportSource preact */
17
+
18
+ type SearchLayoutProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {
19
+ pageIndex: number;
20
+ scale: number;
21
+ highlightColor?: string;
22
+ activeHighlightColor?: string;
23
+ style?: JSX.CSSProperties;
24
+ };
25
+ declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): JSX.Element | null;
26
+
27
+ export { SearchLayer, useSearch, useSearchCapability };
@@ -0,0 +1,64 @@
1
+ // src/preact/hooks/use-search.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/preact";
3
+ import { SearchPlugin } from "@embedpdf/plugin-search";
4
+ var useSearch = () => usePlugin(SearchPlugin.id);
5
+ var useSearchCapability = () => useCapability(SearchPlugin.id);
6
+
7
+ // src/preact/components/search-layer.tsx
8
+ import { useEffect, useState } from "preact/hooks";
9
+ import { jsx } from "preact/jsx-runtime";
10
+ function SearchLayer({
11
+ pageIndex,
12
+ scale,
13
+ style,
14
+ highlightColor = "#FFFF00",
15
+ activeHighlightColor = "#FFBF00",
16
+ ...props
17
+ }) {
18
+ const { provides: searchProvides } = useSearchCapability();
19
+ const [searchResultState, setSearchResultState] = useState(null);
20
+ useEffect(() => {
21
+ return searchProvides?.onSearchResultStateChange((state) => {
22
+ setSearchResultState(state);
23
+ });
24
+ }, [searchProvides]);
25
+ if (!searchResultState) {
26
+ return null;
27
+ }
28
+ const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
29
+ return /* @__PURE__ */ jsx(
30
+ "div",
31
+ {
32
+ style: {
33
+ ...style
34
+ },
35
+ ...props,
36
+ children: pageResults.map(
37
+ ({ result, originalIndex }) => result.rects.map((rect) => /* @__PURE__ */ jsx(
38
+ "div",
39
+ {
40
+ style: {
41
+ position: "absolute",
42
+ top: rect.origin.y * scale,
43
+ left: rect.origin.x * scale,
44
+ width: rect.size.width * scale,
45
+ height: rect.size.height * scale,
46
+ backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
47
+ mixBlendMode: "multiply",
48
+ transform: "scale(1.02)",
49
+ transformOrigin: "center",
50
+ transition: "opacity .3s ease-in-out",
51
+ opacity: 1
52
+ }
53
+ }
54
+ ))
55
+ )
56
+ }
57
+ );
58
+ }
59
+ export {
60
+ SearchLayer,
61
+ useSearch,
62
+ useSearchCapability
63
+ };
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preact/hooks/use-search.ts","../../src/preact/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { SearchPlugin } from '@embedpdf/plugin-search';\n\nexport const useSearch = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n","/** @jsxImportSource preact */\nimport { ComponentChildren, Fragment, JSX } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: JSX.CSSProperties;\n};\n\nexport function SearchLayer({\n pageIndex,\n scale,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n\n useEffect(() => {\n return searchProvides?.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [searchProvides]);\n\n if (!searchResultState) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n {pageResults.map(({ result, originalIndex }) =>\n result.rects.map((rect) => (\n <div\n style={{\n position: 'absolute',\n top: rect.origin.y * scale,\n left: rect.origin.x * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,YAAY,MAAM,UAAwB,aAAa,EAAE;AAC/D,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACFpF,SAAS,WAAmB,gBAAgB;AAgDlC;AAnCH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAmC,IAAI;AAEzF,YAAU,MAAM;AACd,WAAO,gBAAgB,0BAA0B,CAAC,UAAU;AAC1D,2BAAqB,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,CAAC;AAEnB,MAAI,CAAC,mBAAmB;AACtB,WAAO;AAAA,EACT;AAGA,QAAM,cAAc,kBAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,cAAc,EAAE,EAC1D,OAAO,CAAC,EAAE,OAAO,MAAM,OAAO,cAAc,SAAS;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH,sBAAY;AAAA,QAAI,CAAC,EAAE,QAAQ,cAAc,MACxC,OAAO,MAAM,IAAI,CAAC,SAChB;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK,KAAK,OAAO,IAAI;AAAA,cACrB,MAAM,KAAK,OAAO,IAAI;AAAA,cACtB,OAAO,KAAK,KAAK,QAAQ;AAAA,cACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,cAC3B,iBACE,kBAAkB,kBAAkB,oBAChC,uBACA;AAAA,cACN,cAAc;AAAA,cACd,WAAW;AAAA,cACX,iBAAiB;AAAA,cACjB,YAAY;AAAA,cACZ,SAAS;AAAA,YACX;AAAA;AAAA,QACD,CACF;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/react/index.ts
21
+ var react_exports = {};
22
+ __export(react_exports, {
23
+ SearchLayer: () => SearchLayer,
24
+ useSearch: () => useSearch,
25
+ useSearchCapability: () => useSearchCapability
26
+ });
27
+ module.exports = __toCommonJS(react_exports);
28
+
29
+ // src/react/hooks/use-search.ts
30
+ var import_react = require("@embedpdf/core/react");
31
+ var import_plugin_search = require("@embedpdf/plugin-search");
32
+ var useSearch = () => (0, import_react.usePlugin)(import_plugin_search.SearchPlugin.id);
33
+ var useSearchCapability = () => (0, import_react.useCapability)(import_plugin_search.SearchPlugin.id);
34
+
35
+ // src/react/components/search-layer.tsx
36
+ var import_react2 = require("react");
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ function SearchLayer({
39
+ pageIndex,
40
+ scale,
41
+ style,
42
+ highlightColor = "#FFFF00",
43
+ activeHighlightColor = "#FFBF00",
44
+ ...props
45
+ }) {
46
+ const { provides: searchProvides } = useSearchCapability();
47
+ const [searchResultState, setSearchResultState] = (0, import_react2.useState)(null);
48
+ (0, import_react2.useEffect)(() => {
49
+ return searchProvides?.onSearchResultStateChange((state) => {
50
+ setSearchResultState(state);
51
+ });
52
+ }, [searchProvides]);
53
+ if (!searchResultState) {
54
+ return null;
55
+ }
56
+ const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ "div",
59
+ {
60
+ style: {
61
+ ...style
62
+ },
63
+ ...props,
64
+ children: pageResults.map(
65
+ ({ result, originalIndex }) => result.rects.map((rect) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
66
+ "div",
67
+ {
68
+ style: {
69
+ position: "absolute",
70
+ top: rect.origin.y * scale,
71
+ left: rect.origin.x * scale,
72
+ width: rect.size.width * scale,
73
+ height: rect.size.height * scale,
74
+ backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
75
+ mixBlendMode: "multiply",
76
+ transform: "scale(1.02)",
77
+ transformOrigin: "center",
78
+ transition: "opacity .3s ease-in-out",
79
+ opacity: 1
80
+ }
81
+ }
82
+ ))
83
+ )
84
+ }
85
+ );
86
+ }
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ SearchLayer,
90
+ useSearch,
91
+ useSearchCapability
92
+ });
93
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-search.ts","../../src/react/components/search-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { SearchPlugin } from '@embedpdf/plugin-search';\n\nexport const useSearch = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n","import { useEffect, useState } from 'react';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: React.CSSProperties;\n};\n\nexport function SearchLayer({\n pageIndex,\n scale,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n\n useEffect(() => {\n return searchProvides?.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [searchProvides]);\n\n if (!searchResultState) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n {pageResults.map(({ result, originalIndex }) =>\n result.rects.map((rect) => (\n <div\n style={{\n position: 'absolute',\n top: rect.origin.y * scale,\n left: rect.origin.x * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,2BAA6B;AAEtB,IAAM,YAAY,UAAM,wBAAwB,kCAAa,EAAE;AAC/D,IAAM,sBAAsB,UAAM,4BAA4B,kCAAa,EAAE;;;ACJpF,IAAAA,gBAAoC;AAgD1B;AAnCH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,mBAAmB,oBAAoB,QAAI,wBAAmC,IAAI;AAEzF,+BAAU,MAAM;AACd,WAAO,gBAAgB,0BAA0B,CAAC,UAAU;AAC1D,2BAAqB,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,CAAC;AAEnB,MAAI,CAAC,mBAAmB;AACtB,WAAO;AAAA,EACT;AAGA,QAAM,cAAc,kBAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,cAAc,EAAE,EAC1D,OAAO,CAAC,EAAE,OAAO,MAAM,OAAO,cAAc,SAAS;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH,sBAAY;AAAA,QAAI,CAAC,EAAE,QAAQ,cAAc,MACxC,OAAO,MAAM,IAAI,CAAC,SAChB;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK,KAAK,OAAO,IAAI;AAAA,cACrB,MAAM,KAAK,OAAO,IAAI;AAAA,cACtB,OAAO,KAAK,KAAK,QAAQ;AAAA,cACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,cAC3B,iBACE,kBAAkB,kBAAkB,oBAChC,uBACA;AAAA,cACN,cAAc;AAAA,cACd,WAAW;AAAA,cACX,iBAAiB;AAAA,cACjB,YAAY;AAAA,cACZ,SAAS;AAAA,YACX;AAAA;AAAA,QACD,CACF;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":["import_react"]}
@@ -0,0 +1,25 @@
1
+ import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
+ import { SearchPlugin } from '@embedpdf/plugin-search';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare const useSearch: () => {
6
+ plugin: SearchPlugin | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useSearchCapability: () => {
11
+ provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ type SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
17
+ pageIndex: number;
18
+ scale: number;
19
+ highlightColor?: string;
20
+ activeHighlightColor?: string;
21
+ style?: React.CSSProperties;
22
+ };
23
+ declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): react_jsx_runtime.JSX.Element | null;
24
+
25
+ export { SearchLayer, useSearch, useSearchCapability };
@@ -0,0 +1,25 @@
1
+ import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
+ import { SearchPlugin } from '@embedpdf/plugin-search';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare const useSearch: () => {
6
+ plugin: SearchPlugin | null;
7
+ isLoading: boolean;
8
+ ready: Promise<void>;
9
+ };
10
+ declare const useSearchCapability: () => {
11
+ provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
12
+ isLoading: boolean;
13
+ ready: Promise<void>;
14
+ };
15
+
16
+ type SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
17
+ pageIndex: number;
18
+ scale: number;
19
+ highlightColor?: string;
20
+ activeHighlightColor?: string;
21
+ style?: React.CSSProperties;
22
+ };
23
+ declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): react_jsx_runtime.JSX.Element | null;
24
+
25
+ export { SearchLayer, useSearch, useSearchCapability };
@@ -0,0 +1,64 @@
1
+ // src/react/hooks/use-search.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/react";
3
+ import { SearchPlugin } from "@embedpdf/plugin-search";
4
+ var useSearch = () => usePlugin(SearchPlugin.id);
5
+ var useSearchCapability = () => useCapability(SearchPlugin.id);
6
+
7
+ // src/react/components/search-layer.tsx
8
+ import { useEffect, useState } from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ function SearchLayer({
11
+ pageIndex,
12
+ scale,
13
+ style,
14
+ highlightColor = "#FFFF00",
15
+ activeHighlightColor = "#FFBF00",
16
+ ...props
17
+ }) {
18
+ const { provides: searchProvides } = useSearchCapability();
19
+ const [searchResultState, setSearchResultState] = useState(null);
20
+ useEffect(() => {
21
+ return searchProvides?.onSearchResultStateChange((state) => {
22
+ setSearchResultState(state);
23
+ });
24
+ }, [searchProvides]);
25
+ if (!searchResultState) {
26
+ return null;
27
+ }
28
+ const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
29
+ return /* @__PURE__ */ jsx(
30
+ "div",
31
+ {
32
+ style: {
33
+ ...style
34
+ },
35
+ ...props,
36
+ children: pageResults.map(
37
+ ({ result, originalIndex }) => result.rects.map((rect) => /* @__PURE__ */ jsx(
38
+ "div",
39
+ {
40
+ style: {
41
+ position: "absolute",
42
+ top: rect.origin.y * scale,
43
+ left: rect.origin.x * scale,
44
+ width: rect.size.width * scale,
45
+ height: rect.size.height * scale,
46
+ backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
47
+ mixBlendMode: "multiply",
48
+ transform: "scale(1.02)",
49
+ transformOrigin: "center",
50
+ transition: "opacity .3s ease-in-out",
51
+ opacity: 1
52
+ }
53
+ }
54
+ ))
55
+ )
56
+ }
57
+ );
58
+ }
59
+ export {
60
+ SearchLayer,
61
+ useSearch,
62
+ useSearchCapability
63
+ };
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/hooks/use-search.ts","../../src/react/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { SearchPlugin } from '@embedpdf/plugin-search';\n\nexport const useSearch = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n","import { useEffect, useState } from 'react';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: React.CSSProperties;\n};\n\nexport function SearchLayer({\n pageIndex,\n scale,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n\n useEffect(() => {\n return searchProvides?.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [searchProvides]);\n\n if (!searchResultState) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n {pageResults.map(({ result, originalIndex }) =>\n result.rects.map((rect) => (\n <div\n style={{\n position: 'absolute',\n top: rect.origin.y * scale,\n left: rect.origin.x * scale,\n width: rect.size.width * scale,\n height: rect.size.height * scale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,YAAY,MAAM,UAAwB,aAAa,EAAE;AAC/D,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACJpF,SAAS,WAAW,gBAAgB;AAgD1B;AAnCH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAmC,IAAI;AAEzF,YAAU,MAAM;AACd,WAAO,gBAAgB,0BAA0B,CAAC,UAAU;AAC1D,2BAAqB,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,CAAC;AAEnB,MAAI,CAAC,mBAAmB;AACtB,WAAO;AAAA,EACT;AAGA,QAAM,cAAc,kBAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,cAAc,EAAE,EAC1D,OAAO,CAAC,EAAE,OAAO,MAAM,OAAO,cAAc,SAAS;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH,sBAAY;AAAA,QAAI,CAAC,EAAE,QAAQ,cAAc,MACxC,OAAO,MAAM,IAAI,CAAC,SAChB;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK,KAAK,OAAO,IAAI;AAAA,cACrB,MAAM,KAAK,OAAO,IAAI;AAAA,cACtB,OAAO,KAAK,KAAK,QAAQ;AAAA,cACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,cAC3B,iBACE,kBAAkB,kBAAkB,oBAChC,uBACA;AAAA,cACN,cAAc;AAAA,cACd,WAAW;AAAA,cACX,iBAAiB;AAAA,cACjB,YAAY;AAAA,cACZ,SAAS;AAAA,YACX;AAAA;AAAA,QACD,CACF;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@embedpdf/plugin-search",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./preact": {
15
+ "types": "./dist/preact/index.d.ts",
16
+ "import": "./dist/preact/index.js",
17
+ "require": "./dist/preact/index.cjs"
18
+ },
19
+ "./react": {
20
+ "types": "./dist/react/index.d.ts",
21
+ "import": "./dist/react/index.js",
22
+ "require": "./dist/react/index.cjs"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@embedpdf/models": "1.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^18.2.0",
30
+ "tsup": "^8.0.0",
31
+ "typescript": "^5.0.0",
32
+ "@embedpdf/plugin-loader": "1.0.0",
33
+ "@embedpdf/core": "1.0.0"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=16.8.0",
37
+ "react-dom": ">=16.8.0",
38
+ "preact": "^10.26.4",
39
+ "@embedpdf/core": "1.0.0",
40
+ "@embedpdf/plugin-loader": "1.0.0"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/embedpdf/embed-pdf-viewer",
49
+ "directory": "packages/plugin-search"
50
+ },
51
+ "homepage": "https://www.embedpdf.com/docs",
52
+ "bugs": {
53
+ "url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "scripts": {
59
+ "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
60
+ "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
61
+ "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
62
+ "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
63
+ "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
64
+ "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
65
+ }
66
+ }