@embedpdf/plugin-search 1.0.11 → 1.0.12

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.
Files changed (38) hide show
  1. package/dist/index.cjs +2 -306
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -231
  4. package/dist/index.js +16 -26
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/actions.d.ts +47 -0
  7. package/dist/lib/index.d.ts +10 -0
  8. package/dist/lib/manifest.d.ts +4 -0
  9. package/dist/lib/reducer.d.ts +5 -0
  10. package/dist/lib/search-plugin.d.ts +33 -0
  11. package/dist/{index.d.cts → lib/types.d.ts} +6 -85
  12. package/dist/preact/adapter.d.ts +5 -0
  13. package/dist/preact/core.d.ts +1 -0
  14. package/dist/preact/index.cjs +2 -116
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.d.ts +1 -31
  17. package/dist/preact/index.js +12 -15
  18. package/dist/preact/index.js.map +1 -1
  19. package/dist/react/adapter.d.ts +2 -0
  20. package/dist/react/core.d.ts +1 -0
  21. package/dist/react/index.cjs +2 -116
  22. package/dist/react/index.cjs.map +1 -1
  23. package/dist/react/index.d.ts +1 -29
  24. package/dist/react/index.js +11 -15
  25. package/dist/react/index.js.map +1 -1
  26. package/dist/shared-preact/components/index.d.ts +1 -0
  27. package/dist/shared-preact/components/search-layer.d.ts +10 -0
  28. package/dist/shared-preact/hooks/index.d.ts +1 -0
  29. package/dist/shared-preact/hooks/use-search.d.ts +15 -0
  30. package/dist/shared-preact/index.d.ts +2 -0
  31. package/dist/shared-react/components/index.d.ts +1 -0
  32. package/dist/shared-react/components/search-layer.d.ts +10 -0
  33. package/dist/shared-react/hooks/index.d.ts +1 -0
  34. package/dist/shared-react/hooks/use-search.d.ts +15 -0
  35. package/dist/shared-react/index.d.ts +2 -0
  36. package/package.json +14 -13
  37. package/dist/preact/index.d.cts +0 -31
  38. package/dist/react/index.d.cts +0 -29
@@ -1,10 +1,11 @@
1
- // src/preact/hooks/use-search.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/preact";
1
+ import { usePlugin, useCapability } from "@embedpdf/core/preact";
3
2
  import { SearchPlugin } from "@embedpdf/plugin-search";
4
- import { useEffect, useState } from "preact/hooks";
5
- var useSearchPlugin = () => usePlugin(SearchPlugin.id);
6
- var useSearchCapability = () => useCapability(SearchPlugin.id);
7
- var useSearch = () => {
3
+ import "preact";
4
+ import { useState, useEffect } from "preact/hooks";
5
+ import { jsx } from "preact/jsx-runtime";
6
+ const useSearchPlugin = () => usePlugin(SearchPlugin.id);
7
+ const useSearchCapability = () => useCapability(SearchPlugin.id);
8
+ const useSearch = () => {
8
9
  const { provides } = useSearchCapability();
9
10
  const [searchState, setSearchState] = useState({
10
11
  flags: [],
@@ -17,17 +18,13 @@ var useSearch = () => {
17
18
  active: false
18
19
  });
19
20
  useEffect(() => {
20
- return provides?.onStateChange((state) => setSearchState(state));
21
+ return provides == null ? void 0 : provides.onStateChange((state) => setSearchState(state));
21
22
  }, [provides]);
22
23
  return {
23
24
  state: searchState,
24
25
  provides
25
26
  };
26
27
  };
27
-
28
- // src/preact/components/search-layer.tsx
29
- import { useEffect as useEffect2, useState as useState2 } from "preact/hooks";
30
- import { jsx } from "preact/jsx-runtime";
31
28
  function SearchLayer({
32
29
  pageIndex,
33
30
  scale,
@@ -37,9 +34,9 @@ function SearchLayer({
37
34
  ...props
38
35
  }) {
39
36
  const { provides: searchProvides } = useSearchCapability();
40
- const [searchResultState, setSearchResultState] = useState2(null);
41
- useEffect2(() => {
42
- return searchProvides?.onSearchResultStateChange((state) => {
37
+ const [searchResultState, setSearchResultState] = useState(null);
38
+ useEffect(() => {
39
+ return searchProvides == null ? void 0 : searchProvides.onSearchResultStateChange((state) => {
43
40
  setSearchResultState(state);
44
41
  });
45
42
  }, [searchProvides]);
@@ -83,4 +80,4 @@ export {
83
80
  useSearchCapability,
84
81
  useSearchPlugin
85
82
  };
86
- //# sourceMappingURL=index.js.map
83
+ //# sourceMappingURL=index.js.map
@@ -1 +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, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from 'preact/hooks';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\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,oBAAiC;AAC1C,SAAS,WAAW,gBAAgB;AAE7B,IAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,IAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,SAAS,IAAI,oBAAoB;AACzC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAsB;AAAA,IAC1D,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,OAAO;AAAA,IACP,mBAAmB;AAAA,IACnB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AAED,YAAU,MAAM;AACd,WAAO,UAAU,cAAc,CAAC,UAAU,eAAe,KAAK,CAAC;AAAA,EACjE,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;;;AC1BA,SAAS,aAAAA,YAAmB,YAAAC,iBAAgB;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,IAAIC,UAAmC,IAAI;AAEzF,EAAAC,WAAU,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":["useEffect","useState","useState","useEffect"]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SearchPlugin, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\n","import { useEffect, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: 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"],"names":[],"mappings":";;;;;AAIO,MAAM,kBAAkB,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ChB;AAAA,UAAC;AAAA,UAAA;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,YAAA;AAAA,UACX;AAAA,QAEH,CAAA;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ export { Fragment, useEffect, useRef, useState } from 'react';
2
+ export type { ReactNode, HTMLAttributes, CSSProperties } from 'react';
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/react';
@@ -1,116 +1,2 @@
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
- useSearchPlugin: () => useSearchPlugin
27
- });
28
- module.exports = __toCommonJS(react_exports);
29
-
30
- // src/react/hooks/use-search.ts
31
- var import_react = require("@embedpdf/core/react");
32
- var import_plugin_search = require("@embedpdf/plugin-search");
33
- var import_react2 = require("react");
34
- var useSearchPlugin = () => (0, import_react.usePlugin)(import_plugin_search.SearchPlugin.id);
35
- var useSearchCapability = () => (0, import_react.useCapability)(import_plugin_search.SearchPlugin.id);
36
- var useSearch = () => {
37
- const { provides } = useSearchCapability();
38
- const [searchState, setSearchState] = (0, import_react2.useState)({
39
- flags: [],
40
- results: [],
41
- total: 0,
42
- activeResultIndex: 0,
43
- showAllResults: true,
44
- query: "",
45
- loading: false,
46
- active: false
47
- });
48
- (0, import_react2.useEffect)(() => {
49
- return provides?.onStateChange((state) => setSearchState(state));
50
- }, [provides]);
51
- return {
52
- state: searchState,
53
- provides
54
- };
55
- };
56
-
57
- // src/react/components/search-layer.tsx
58
- var import_react3 = require("react");
59
- var import_jsx_runtime = require("react/jsx-runtime");
60
- function SearchLayer({
61
- pageIndex,
62
- scale,
63
- style,
64
- highlightColor = "#FFFF00",
65
- activeHighlightColor = "#FFBF00",
66
- ...props
67
- }) {
68
- const { provides: searchProvides } = useSearchCapability();
69
- const [searchResultState, setSearchResultState] = (0, import_react3.useState)(null);
70
- (0, import_react3.useEffect)(() => {
71
- return searchProvides?.onSearchResultStateChange((state) => {
72
- setSearchResultState(state);
73
- });
74
- }, [searchProvides]);
75
- if (!searchResultState) {
76
- return null;
77
- }
78
- const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
79
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
- "div",
81
- {
82
- style: {
83
- ...style
84
- },
85
- ...props,
86
- children: pageResults.map(
87
- ({ result, originalIndex }) => result.rects.map((rect) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
- "div",
89
- {
90
- style: {
91
- position: "absolute",
92
- top: rect.origin.y * scale,
93
- left: rect.origin.x * scale,
94
- width: rect.size.width * scale,
95
- height: rect.size.height * scale,
96
- backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
97
- mixBlendMode: "multiply",
98
- transform: "scale(1.02)",
99
- transformOrigin: "center",
100
- transition: "opacity .3s ease-in-out",
101
- opacity: 1
102
- }
103
- }
104
- ))
105
- )
106
- }
107
- );
108
- }
109
- // Annotate the CommonJS export names for ESM import in node:
110
- 0 && (module.exports = {
111
- SearchLayer,
112
- useSearch,
113
- useSearchCapability,
114
- useSearchPlugin
115
- });
116
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-search"),i=require("react"),r=require("react/jsx-runtime"),s=()=>e.useCapability(t.SearchPlugin.id);exports.SearchLayer=function({pageIndex:e,scale:t,style:l,highlightColor:a="#FFFF00",activeHighlightColor:n="#FFBF00",...o}){const{provides:u}=s(),[c,d]=i.useState(null);if(i.useEffect((()=>null==u?void 0:u.onSearchResultStateChange((e=>{d(e)}))),[u]),!c)return null;const g=c.results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:t})=>t.pageIndex===e));return r.jsx("div",{style:{...l},...o,children:g.map((({result:e,originalIndex:i})=>e.rects.map((e=>r.jsx("div",{style:{position:"absolute",top:e.origin.y*t,left:e.origin.x*t,width:e.size.width*t,height:e.size.height*t,backgroundColor:i===c.activeResultIndex?n:a,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1}})))))})},exports.useSearch=()=>{const{provides:e}=s(),[t,r]=i.useState({flags:[],results:[],total:0,activeResultIndex:0,showAllResults:!0,query:"",loading:!1,active:!1});return i.useEffect((()=>null==e?void 0:e.onStateChange((e=>r(e)))),[e]),{state:t,provides:e}},exports.useSearchCapability=s,exports.useSearchPlugin=()=>e.usePlugin(t.SearchPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +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, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from 'react';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\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;AAAA;;;ACAA,mBAAyC;AACzC,2BAA0C;AAC1C,IAAAA,gBAAoC;AAE7B,IAAM,kBAAkB,UAAM,wBAAwB,kCAAa,EAAE;AACrE,IAAM,sBAAsB,UAAM,4BAA4B,kCAAa,EAAE;AAE7E,IAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,SAAS,IAAI,oBAAoB;AACzC,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAsB;AAAA,IAC1D,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,OAAO;AAAA,IACP,mBAAmB;AAAA,IACnB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,EACV,CAAC;AAED,+BAAU,MAAM;AACd,WAAO,UAAU,cAAc,CAAC,UAAU,eAAe,KAAK,CAAC;AAAA,EACjE,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;;;AC5BA,IAAAC,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","import_react"]}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SearchPlugin, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\n","import { useEffect, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: 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"],"names":["useSearchCapability","useCapability","SearchPlugin","id","pageIndex","scale","style","highlightColor","activeHighlightColor","props","provides","searchProvides","searchResultState","setSearchResultState","useState","useEffect","onSearchResultStateChange","state","pageResults","results","map","result","originalIndex","filter","jsxRuntime","jsx","children","rects","rect","position","top","origin","y","left","x","width","size","height","backgroundColor","activeResultIndex","mixBlendMode","transform","transformOrigin","transition","opacity","searchState","setSearchState","flags","total","showAllResults","query","loading","active","onStateChange","usePlugin"],"mappings":"+MAKaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCQ3E,UAAqBC,UAC1BA,EAAAC,MACAA,EAAAC,MACAA,EAAAC,eACAA,EAAiB,UAAAC,qBACjBA,EAAuB,aACpBC,IAEH,MAAQC,SAAUC,GAAmBX,KAC9BY,EAAmBC,GAAwBC,EAAAA,SAAmC,MAQrF,GANAC,EAAAA,WAAU,IACD,MAAAJ,OAAA,EAAAA,EAAgBK,2BAA2BC,IAChDJ,EAAqBI,EAAK,KAE3B,CAACN,KAECC,EACI,OAAA,KAIT,MAAMM,EAAcN,EAAkBO,QACnCC,KAAI,CAACC,EAAQC,MAAqBD,SAAQC,oBAC1CC,QAAO,EAAGF,YAAaA,EAAOjB,YAAcA,IAG7C,OAAAoB,EAAAC,IAAC,MAAA,CACCnB,MAAO,IACFA,MAEDG,EAEHiB,SAAYR,EAAAE,KAAI,EAAGC,SAAQC,mBAC1BD,EAAOM,MAAMP,KAAKQ,GAChBJ,EAAAC,IAAC,MAAA,CACCnB,MAAO,CACLuB,SAAU,WACVC,IAAKF,EAAKG,OAAOC,EAAI3B,EACrB4B,KAAML,EAAKG,OAAOG,EAAI7B,EACtB8B,MAAOP,EAAKQ,KAAKD,MAAQ9B,EACzBgC,OAAQT,EAAKQ,KAAKC,OAAShC,EAC3BiC,gBACEhB,IAAkBV,EAAkB2B,kBAChC/B,EACAD,EACNiC,aAAc,WACdC,UAAW,cACXC,gBAAiB,SACjBC,WAAY,0BACZC,QAAS,UAOvB,oBD/DyB,KACjB,MAAAlC,SAAEA,GAAaV,KACd6C,EAAaC,GAAkBhC,WAAsB,CAC1DiC,MAAO,GACP5B,QAAS,GACT6B,MAAO,EACPT,kBAAmB,EACnBU,gBAAgB,EAChBC,MAAO,GACPC,SAAS,EACTC,QAAQ,IAOH,OAJPrC,EAAAA,WAAU,IACS,MAAVL,OAAU,EAAAA,EAAA2C,eAAepC,GAAU6B,EAAe7B,MACxD,CAACP,IAEG,CACLO,MAAO4B,EACPnC,WACF,wDAvB6B,IAAM4C,YAAwBpD,EAAAA,aAAaC"}
@@ -1,29 +1 @@
1
- import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
- import { SearchPlugin, SearchState } from '@embedpdf/plugin-search';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
- declare const useSearchPlugin: () => {
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
- declare const useSearch: () => {
16
- state: SearchState;
17
- provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
18
- };
19
-
20
- type SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
21
- pageIndex: number;
22
- scale: number;
23
- highlightColor?: string;
24
- activeHighlightColor?: string;
25
- style?: React.CSSProperties;
26
- };
27
- declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): react_jsx_runtime.JSX.Element | null;
28
-
29
- export { SearchLayer, useSearch, useSearchCapability, useSearchPlugin };
1
+ export * from '../shared-react';
@@ -1,10 +1,10 @@
1
- // src/react/hooks/use-search.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/react";
1
+ import { usePlugin, useCapability } from "@embedpdf/core/react";
3
2
  import { SearchPlugin } from "@embedpdf/plugin-search";
4
- import { useEffect, useState } from "react";
5
- var useSearchPlugin = () => usePlugin(SearchPlugin.id);
6
- var useSearchCapability = () => useCapability(SearchPlugin.id);
7
- var useSearch = () => {
3
+ import { useState, useEffect } from "react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const useSearchPlugin = () => usePlugin(SearchPlugin.id);
6
+ const useSearchCapability = () => useCapability(SearchPlugin.id);
7
+ const useSearch = () => {
8
8
  const { provides } = useSearchCapability();
9
9
  const [searchState, setSearchState] = useState({
10
10
  flags: [],
@@ -17,17 +17,13 @@ var useSearch = () => {
17
17
  active: false
18
18
  });
19
19
  useEffect(() => {
20
- return provides?.onStateChange((state) => setSearchState(state));
20
+ return provides == null ? void 0 : provides.onStateChange((state) => setSearchState(state));
21
21
  }, [provides]);
22
22
  return {
23
23
  state: searchState,
24
24
  provides
25
25
  };
26
26
  };
27
-
28
- // src/react/components/search-layer.tsx
29
- import { useEffect as useEffect2, useState as useState2 } from "react";
30
- import { jsx } from "react/jsx-runtime";
31
27
  function SearchLayer({
32
28
  pageIndex,
33
29
  scale,
@@ -37,9 +33,9 @@ function SearchLayer({
37
33
  ...props
38
34
  }) {
39
35
  const { provides: searchProvides } = useSearchCapability();
40
- const [searchResultState, setSearchResultState] = useState2(null);
41
- useEffect2(() => {
42
- return searchProvides?.onSearchResultStateChange((state) => {
36
+ const [searchResultState, setSearchResultState] = useState(null);
37
+ useEffect(() => {
38
+ return searchProvides == null ? void 0 : searchProvides.onSearchResultStateChange((state) => {
43
39
  setSearchResultState(state);
44
40
  });
45
41
  }, [searchProvides]);
@@ -83,4 +79,4 @@ export {
83
79
  useSearchCapability,
84
80
  useSearchPlugin
85
81
  };
86
- //# sourceMappingURL=index.js.map
82
+ //# sourceMappingURL=index.js.map
@@ -1 +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, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from 'react';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\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,oBAAiC;A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AAG;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":["useEffect","useState","useState","useEffect"]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SearchPlugin, SearchState } from '@embedpdf/plugin-search';\nimport { useEffect, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = () => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchState>({\n flags: [],\n results: [],\n total: 0,\n activeResultIndex: 0,\n showAllResults: true,\n query: '',\n loading: false,\n active: false,\n });\n\n useEffect(() => {\n return provides?.onStateChange((state) => setSearchState(state));\n }, [provides]);\n\n return {\n state: searchState,\n provides,\n };\n};\n","import { useEffect, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: 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"],"names":[],"mappings":";;;;AAIO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AACvB,QAAA,EAAE,SAAS,IAAI,oBAAoB;AACzC,QAAM,CAAC,aAAa,cAAc,IAAI,SAAsB;AAAA,IAC1D,OAAO,CAAC;AAAA,IACR,SAAS,CAAC;AAAA,IACV,OAAO;AAAA,IACP,mBAAmB;AAAA,IACnB,gBAAgB;AAAA,IAChB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,EAAA,CACT;AAED,YAAU,MAAM;AACd,WAAO,qCAAU,cAAc,CA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A;AAAA,IACH;AAAA,EACF;AAEJ;"}
@@ -0,0 +1 @@
1
+ export * from './search-layer';
@@ -0,0 +1,10 @@
1
+ import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
+ type SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ pageIndex: number;
4
+ scale: number;
5
+ highlightColor?: string;
6
+ activeHighlightColor?: string;
7
+ style?: CSSProperties;
8
+ };
9
+ export declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): import("preact").JSX.Element | null;
10
+ export {};
@@ -0,0 +1 @@
1
+ export * from './use-search';
@@ -0,0 +1,15 @@
1
+ import { SearchPlugin, SearchState } from '../../lib/index.ts';
2
+ export declare const useSearchPlugin: () => {
3
+ plugin: SearchPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useSearchCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
12
+ export declare const useSearch: () => {
13
+ state: SearchState;
14
+ provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
15
+ };
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ export * from './components';
@@ -0,0 +1 @@
1
+ export * from './search-layer';
@@ -0,0 +1,10 @@
1
+ import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
+ type SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
3
+ pageIndex: number;
4
+ scale: number;
5
+ highlightColor?: string;
6
+ activeHighlightColor?: string;
7
+ style?: CSSProperties;
8
+ };
9
+ export declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
@@ -0,0 +1 @@
1
+ export * from './use-search';
@@ -0,0 +1,15 @@
1
+ import { SearchPlugin, SearchState } from '../../lib/index.ts';
2
+ export declare const useSearchPlugin: () => {
3
+ plugin: SearchPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useSearchCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
12
+ export declare const useSearch: () => {
13
+ state: SearchState;
14
+ provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
15
+ };
@@ -0,0 +1,2 @@
1
+ export * from './hooks';
2
+ export * from './components';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-search",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -23,21 +23,21 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@embedpdf/models": "1.0.11"
26
+ "@embedpdf/models": "1.0.12"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/react": "^18.2.0",
30
- "tsup": "^8.0.0",
31
30
  "typescript": "^5.0.0",
32
- "@embedpdf/core": "1.0.11",
33
- "@embedpdf/plugin-loader": "1.0.11"
31
+ "@embedpdf/build": "1.0.0",
32
+ "@embedpdf/core": "1.0.12",
33
+ "@embedpdf/plugin-loader": "1.0.12"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=16.8.0",
37
37
  "react-dom": ">=16.8.0",
38
38
  "preact": "^10.26.4",
39
- "@embedpdf/core": "1.0.11",
40
- "@embedpdf/plugin-loader": "1.0.11"
39
+ "@embedpdf/plugin-loader": "1.0.12",
40
+ "@embedpdf/core": "1.0.12"
41
41
  },
42
42
  "files": [
43
43
  "dist",
@@ -56,11 +56,12 @@
56
56
  "access": "public"
57
57
  },
58
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"
59
+ "build:base": "vite build --mode base",
60
+ "build:react": "vite build --mode react",
61
+ "build:preact": "vite build --mode preact",
62
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
63
+ "clean": "rimraf dist",
64
+ "lint": "eslint src --color",
65
+ "lint:fix": "eslint src --color --fix"
65
66
  }
66
67
  }
@@ -1,31 +0,0 @@
1
- import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
- import { SearchPlugin, SearchState } from '@embedpdf/plugin-search';
3
- import { JSX } from 'preact';
4
-
5
- declare const useSearchPlugin: () => {
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
- declare const useSearch: () => {
16
- state: SearchState;
17
- provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
18
- };
19
-
20
- /** @jsxImportSource preact */
21
-
22
- type SearchLayoutProps = Omit<JSX.HTMLAttributes<HTMLDivElement>, 'style'> & {
23
- pageIndex: number;
24
- scale: number;
25
- highlightColor?: string;
26
- activeHighlightColor?: string;
27
- style?: JSX.CSSProperties;
28
- };
29
- declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): JSX.Element | null;
30
-
31
- export { SearchLayer, useSearch, useSearchCapability, useSearchPlugin };
@@ -1,29 +0,0 @@
1
- import * as _embedpdf_plugin_search from '@embedpdf/plugin-search';
2
- import { SearchPlugin, SearchState } from '@embedpdf/plugin-search';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
-
5
- declare const useSearchPlugin: () => {
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
- declare const useSearch: () => {
16
- state: SearchState;
17
- provides: Readonly<_embedpdf_plugin_search.SearchCapability> | null;
18
- };
19
-
20
- type SearchLayoutProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & {
21
- pageIndex: number;
22
- scale: number;
23
- highlightColor?: string;
24
- activeHighlightColor?: string;
25
- style?: React.CSSProperties;
26
- };
27
- declare function SearchLayer({ pageIndex, scale, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): react_jsx_runtime.JSX.Element | null;
28
-
29
- export { SearchLayer, useSearch, useSearchCapability, useSearchPlugin };