@embedpdf/plugin-search 1.0.20 → 1.0.21

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-search");require("preact");const r=require("preact/hooks"),i=require("preact/jsx-runtime"),s=()=>e.useCapability(t.SearchPlugin.id);exports.SearchLayer=function({pageIndex:e,scale:t,style:l,highlightColor:a="#FFFF00",activeHighlightColor:o="#FFBF00",...n}){const{provides:u}=s(),[c,d]=r.useState(null);if(r.useEffect((()=>null==u?void 0:u.onSearchResultStateChange((e=>{d(e)}))),[u]),!c)return null;const p=c.results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:t})=>t.pageIndex===e));return i.jsx("div",{style:{...l},...n,children:p.map((({result:e,originalIndex:r})=>e.rects.map((e=>i.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:r===c.activeResultIndex?o:a,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1}})))))})},exports.useSearch=()=>{const{provides:e}=s(),[t,i]=r.useState({flags:[],results:[],total:0,activeResultIndex:0,showAllResults:!0,query:"",loading:!1,active:!1});return r.useEffect((()=>null==e?void 0:e.onStateChange((e=>i(e)))),[e]),{state:t,provides:e}},exports.useSearchCapability=s,exports.useSearchPlugin=()=>e.usePlugin(t.SearchPlugin.id);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-search");require("preact");const r=require("preact/hooks"),i=require("preact/jsx-runtime"),s=()=>e.useCapability(t.SearchPlugin.id);exports.SearchLayer=function({pageIndex:e,scale:t,style:o,highlightColor:a="#FFFF00",activeHighlightColor:l="#FFBF00",...n}){const{provides:u}=s(),[c,p]=r.useState(null);if(r.useEffect((()=>null==u?void 0:u.onSearchResultStateChange((e=>{p(e)}))),[u]),!c)return null;const d=c.results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:t})=>t.pageIndex===e));return i.jsx("div",{style:{...o},...n,children:d.map((({result:e,originalIndex:r})=>e.rects.map((e=>i.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:r===c.activeResultIndex?l:a,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1}})))))})},exports.useSearch=()=>{const{provides:e}=s(),[t,i]=r.useState({flags:[],results:[],total:0,activeResultIndex:0,showAllResults:!0,query:"",loading:!1,active:!1});return r.useEffect((()=>null==e?void 0:e.onStateChange((e=>i(e)))),[e]),{state:t,provides:e}},exports.useSearchCapability=s,exports.useSearchPlugin=()=>e.usePlugin(t.SearchPlugin.id),Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,6 @@
1
1
  import { usePlugin, useCapability } from "@embedpdf/core/preact";
2
2
  import { SearchPlugin } from "@embedpdf/plugin-search";
3
+ export * from "@embedpdf/plugin-search";
3
4
  import "preact";
4
5
  import { useState, useEffect } from "preact/hooks";
5
6
  import { jsx } from "preact/jsx-runtime";
@@ -1 +1 @@
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,a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;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;"}
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,CAAC,UAAU,eAAe,KAAK;AAAA,EAAC,GAC9D,CAAC,QAAQ,CAAC;AAEN,SAAA;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;ACfO,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;AACP,WAAA,iDAAgB,0BAA0B,CAAC,UAAU;AAC1D,2BAAqB,KAAK;AAAA,IAAA;AAAA,EAC3B,GACA,CAAC,cAAc,CAAC;AAEnB,MAAI,CAAC,mBAAmB;AACf,WAAA;AAAA,EAAA;AAIT,QAAM,cAAc,kBAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,gBAAgB,EAC1D,OAAO,CAAC,EAAE,aAAa,OAAO,cAAc,SAAS;AAGtD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH,UAAY,YAAA;AAAA,QAAI,CAAC,EAAE,QAAQ,oBAC1B,OAAO,MAAM,IAAI,CAAC,SAChB;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;"}
@@ -1,2 +1,2 @@
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);
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-search"),r=require("react"),i=require("react/jsx-runtime"),s=()=>e.useCapability(t.SearchPlugin.id);exports.SearchLayer=function({pageIndex:e,scale:t,style:l,highlightColor:a="#FFFF00",activeHighlightColor:o="#FFBF00",...n}){const{provides:u}=s(),[c,d]=r.useState(null);if(r.useEffect((()=>null==u?void 0:u.onSearchResultStateChange((e=>{d(e)}))),[u]),!c)return null;const p=c.results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:t})=>t.pageIndex===e));return i.jsx("div",{style:{...l},...n,children:p.map((({result:e,originalIndex:r})=>e.rects.map((e=>i.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:r===c.activeResultIndex?o:a,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1}})))))})},exports.useSearch=()=>{const{provides:e}=s(),[t,i]=r.useState({flags:[],results:[],total:0,activeResultIndex:0,showAllResults:!0,query:"",loading:!1,active:!1});return r.useEffect((()=>null==e?void 0:e.onStateChange((e=>i(e)))),[e]),{state:t,provides:e}},exports.useSearchCapability=s,exports.useSearchPlugin=()=>e.usePlugin(t.SearchPlugin.id),Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,6 @@
1
1
  import { usePlugin, useCapability } from "@embedpdf/core/react";
2
2
  import { SearchPlugin } from "@embedpdf/plugin-search";
3
+ export * from "@embedpdf/plugin-search";
3
4
  import { useState, useEffect } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  const useSearchPlugin = () => usePlugin(SearchPlugin.id);
@@ -1 +1 @@
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;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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;"}
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,CAAC,UAAU,eAAe,KAAK;AAAA,EAAC,GAC9D,CAAC,QAAQ,CAAC;AAEN,SAAA;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;ACfO,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;AACP,WAAA,iDAAgB,0BAA0B,CAAC,UAAU;AAC1D,2BAAqB,KAAK;AAAA,IAAA;AAAA,EAC3B,GACA,CAAC,cAAc,CAAC;AAEnB,MAAI,CAAC,mBAAmB;AACf,WAAA;AAAA,EAAA;AAIT,QAAM,cAAc,kBAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,gBAAgB,EAC1D,OAAO,CAAC,EAAE,aAAa,OAAO,cAAc,SAAS;AAGtD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEH,UAAY,YAAA;AAAA,QAAI,CAAC,EAAE,QAAQ,oBAC1B,OAAO,MAAM,IAAI,CAAC,SAChB;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;"}
@@ -1,2 +1,3 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
@@ -1,2 +1,3 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
@@ -0,0 +1 @@
1
+ export { default as SearchLayer } from './search-layer.vue';
@@ -0,0 +1,11 @@
1
+ interface SearchLayerProps {
2
+ pageIndex: number;
3
+ scale: number;
4
+ highlightColor?: string;
5
+ activeHighlightColor?: string;
6
+ }
7
+ declare const _default: import('vue').DefineComponent<SearchLayerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SearchLayerProps> & Readonly<{}>, {
8
+ highlightColor: string;
9
+ activeHighlightColor: string;
10
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
11
+ export default _default;
@@ -0,0 +1 @@
1
+ export * from './use-search';
@@ -0,0 +1,67 @@
1
+ import { SearchPlugin, SearchState } from '../../lib/index.ts';
2
+ export declare const useSearchPlugin: () => import('@embedpdf/core/vue').PluginState<SearchPlugin>;
3
+ export declare const useSearchCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').SearchCapability>>;
4
+ export declare const useSearch: () => {
5
+ state: import('vue').Ref<{
6
+ flags: import('@embedpdf/models').MatchFlag[];
7
+ results: {
8
+ pageIndex: number;
9
+ charIndex: number;
10
+ charCount: number;
11
+ rects: {
12
+ origin: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ size: {
17
+ width: number;
18
+ height: number;
19
+ };
20
+ }[];
21
+ context: {
22
+ before: string;
23
+ match: string;
24
+ after: string;
25
+ truncatedLeft: boolean;
26
+ truncatedRight: boolean;
27
+ };
28
+ }[];
29
+ total: number;
30
+ activeResultIndex: number;
31
+ showAllResults: boolean;
32
+ query: string;
33
+ loading: boolean;
34
+ active: boolean;
35
+ }, SearchState | {
36
+ flags: import('@embedpdf/models').MatchFlag[];
37
+ results: {
38
+ pageIndex: number;
39
+ charIndex: number;
40
+ charCount: number;
41
+ rects: {
42
+ origin: {
43
+ x: number;
44
+ y: number;
45
+ };
46
+ size: {
47
+ width: number;
48
+ height: number;
49
+ };
50
+ }[];
51
+ context: {
52
+ before: string;
53
+ match: string;
54
+ after: string;
55
+ truncatedLeft: boolean;
56
+ truncatedRight: boolean;
57
+ };
58
+ }[];
59
+ total: number;
60
+ activeResultIndex: number;
61
+ showAllResults: boolean;
62
+ query: string;
63
+ loading: boolean;
64
+ active: boolean;
65
+ }>;
66
+ provides: import('vue').Ref<Readonly<import('../../lib/index.ts').SearchCapability> | null, Readonly<import('../../lib/index.ts').SearchCapability> | null>;
67
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),l=require("@embedpdf/plugin-search"),r=()=>t.useCapability(l.SearchPlugin.id),o=e.defineComponent({__name:"search-layer",props:{pageIndex:{},scale:{},highlightColor:{default:"#FFFF00"},activeHighlightColor:{default:"#FFBF00"}},setup(t){const l=t,{provides:o}=r(),a=e.ref(null),n=e.computed((()=>a.value?a.value.results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:e})=>e.pageIndex===l.pageIndex)):[]));let i;return e.onMounted((()=>{o.value&&(i=o.value.onSearchResultStateChange((e=>{a.value=e})))})),e.onUnmounted((()=>{null==i||i()})),(t,l)=>a.value?(e.openBlock(),e.createElementBlock("div",e.normalizeProps(e.mergeProps({key:0},t.$attrs)),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(({result:l,originalIndex:r},o)=>(e.openBlock(),e.createElementBlock("div",{key:`result-${o}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.rects,((l,n)=>(e.openBlock(),e.createElementBlock("div",{key:`rect-${o}-${n}`,style:e.normalizeStyle({position:"absolute",top:l.origin.y*t.scale+"px",left:l.origin.x*t.scale+"px",width:l.size.width*t.scale+"px",height:l.size.height*t.scale+"px",backgroundColor:r===a.value.activeResultIndex?t.activeHighlightColor:t.highlightColor,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1})},null,4)))),128))])))),128))],16)):e.createCommentVNode("",!0)}});exports.SearchLayer=o,exports.useSearch=()=>{const{provides:t}=r(),l=e.ref({flags:[],results:[],total:0,activeResultIndex:0,showAllResults:!0,query:"",loading:!1,active:!1});return e.onMounted((()=>{if(!t.value)return;const r=t.value.onStateChange((e=>{l.value=e}));e.onUnmounted((()=>{r()}))})),{state:l,provides:t}},exports.useSearchCapability=r,exports.useSearchPlugin=()=>t.usePlugin(l.SearchPlugin.id),Object.keys(l).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>l[e]})}));
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-search.ts","../../src/vue/components/search-layer.vue"],"sourcesContent":["import { ref, onMounted, onUnmounted } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { SearchPlugin, SearchState } from '@embedpdf/plugin-search';\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 = ref<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 onMounted(() => {\n if (!provides.value) return;\n\n const unsubscribe = provides.value.onStateChange((state) => {\n searchState.value = state;\n });\n\n onUnmounted(() => {\n unsubscribe();\n });\n });\n\n return {\n state: searchState,\n provides,\n };\n};\n","<template>\n <div v-if=\"searchResultState\" v-bind=\"$attrs\">\n <div v-for=\"({ result, originalIndex }, idx) in pageResults\" :key=\"`result-${idx}`\">\n <div\n v-for=\"(rect, rectIdx) in result.rects\"\n :key=\"`rect-${idx}-${rectIdx}`\"\n :style=\"{\n position: 'absolute',\n top: `${rect.origin.y * scale}px`,\n left: `${rect.origin.x * scale}px`,\n width: `${rect.size.width * scale}px`,\n height: `${rect.size.height * scale}px`,\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 />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, onMounted, onUnmounted } from 'vue';\nimport type { SearchResultState } from '@embedpdf/plugin-search';\nimport { useSearchCapability } from '../hooks/use-search';\n\ninterface SearchLayerProps {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n}\n\nconst props = withDefaults(defineProps<SearchLayerProps>(), {\n highlightColor: '#FFFF00',\n activeHighlightColor: '#FFBF00',\n});\n\nconst { provides: searchProvides } = useSearchCapability();\nconst searchResultState = ref<SearchResultState | null>(null);\n\n// Filter results for current page while preserving original indices\nconst pageResults = computed(() => {\n if (!searchResultState.value) return [];\n\n return searchResultState.value.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === props.pageIndex);\n});\n\nlet unsubscribe: (() => void) | undefined;\n\nonMounted(() => {\n if (!searchProvides.value) return;\n\n unsubscribe = searchProvides.value.onSearchResultStateChange((state) => {\n searchResultState.value = state;\n });\n});\n\nonUnmounted(() => {\n unsubscribe?.();\n});\n</script>\n"],"names":["useSearchCapability","useCapability","SearchPlugin","id","props","__props","provides","searchProvides","searchResultState","ref","pageResults","computed","value","results","map","result","originalIndex","filter","pageIndex","unsubscribe","onMounted","onSearchResultStateChange","state","onUnmounted","_openBlock","openBlock","_createElementBlock","$attrs","_Fragment","idx","createElementBlock","key","rects","rect","rectIdx","style","_normalizeStyle","top","origin","y","scale","left","x","width","size","height","activeResultIndex","activeHighlightColor","highlightColor","searchState","flags","total","showAllResults","query","loading","active","onStateChange","usePlugin"],"mappings":"4KAKaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,kKCkClF,MAAMC,EAAQC,GAKNC,SAAUC,GAAmBP,IAC/BQ,EAAoBC,MAA8B,MAGlDC,EAAcC,EAAAA,UAAS,IACtBH,EAAkBI,MAEhBJ,EAAkBI,MAAMC,QAC5BC,KAAI,CAACC,EAAQC,KAAA,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AA,aAAY,KACEJ,GAAA,GACb,IAGI,CACLG,MAAO2B,EACP3C,WACF,wDA/B6B,IAAMmD,YAAwBvD,EAAAA,aAAaC"}
@@ -0,0 +1,3 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../lib/index.ts';
@@ -0,0 +1,95 @@
1
+ import { ref, onMounted, onUnmounted, defineComponent, computed, createElementBlock, createCommentVNode, openBlock, normalizeProps, mergeProps, Fragment, renderList, normalizeStyle } from "vue";
2
+ import { usePlugin, useCapability } from "@embedpdf/core/vue";
3
+ import { SearchPlugin } from "@embedpdf/plugin-search";
4
+ export * from "@embedpdf/plugin-search";
5
+ const useSearchPlugin = () => usePlugin(SearchPlugin.id);
6
+ const useSearchCapability = () => useCapability(SearchPlugin.id);
7
+ const useSearch = () => {
8
+ const { provides } = useSearchCapability();
9
+ const searchState = ref({
10
+ flags: [],
11
+ results: [],
12
+ total: 0,
13
+ activeResultIndex: 0,
14
+ showAllResults: true,
15
+ query: "",
16
+ loading: false,
17
+ active: false
18
+ });
19
+ onMounted(() => {
20
+ if (!provides.value) return;
21
+ const unsubscribe = provides.value.onStateChange((state) => {
22
+ searchState.value = state;
23
+ });
24
+ onUnmounted(() => {
25
+ unsubscribe();
26
+ });
27
+ });
28
+ return {
29
+ state: searchState,
30
+ provides
31
+ };
32
+ };
33
+ const _sfc_main = /* @__PURE__ */ defineComponent({
34
+ __name: "search-layer",
35
+ props: {
36
+ pageIndex: {},
37
+ scale: {},
38
+ highlightColor: { default: "#FFFF00" },
39
+ activeHighlightColor: { default: "#FFBF00" }
40
+ },
41
+ setup(__props) {
42
+ const props = __props;
43
+ const { provides: searchProvides } = useSearchCapability();
44
+ const searchResultState = ref(null);
45
+ const pageResults = computed(() => {
46
+ if (!searchResultState.value) return [];
47
+ return searchResultState.value.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === props.pageIndex);
48
+ });
49
+ let unsubscribe;
50
+ onMounted(() => {
51
+ if (!searchProvides.value) return;
52
+ unsubscribe = searchProvides.value.onSearchResultStateChange((state) => {
53
+ searchResultState.value = state;
54
+ });
55
+ });
56
+ onUnmounted(() => {
57
+ unsubscribe == null ? void 0 : unsubscribe();
58
+ });
59
+ return (_ctx, _cache) => {
60
+ return searchResultState.value ? (openBlock(), createElementBlock("div", normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), [
61
+ (openBlock(true), createElementBlock(Fragment, null, renderList(pageResults.value, ({ result, originalIndex }, idx) => {
62
+ return openBlock(), createElementBlock("div", {
63
+ key: `result-${idx}`
64
+ }, [
65
+ (openBlock(true), createElementBlock(Fragment, null, renderList(result.rects, (rect, rectIdx) => {
66
+ return openBlock(), createElementBlock("div", {
67
+ key: `rect-${idx}-${rectIdx}`,
68
+ style: normalizeStyle({
69
+ position: "absolute",
70
+ top: `${rect.origin.y * _ctx.scale}px`,
71
+ left: `${rect.origin.x * _ctx.scale}px`,
72
+ width: `${rect.size.width * _ctx.scale}px`,
73
+ height: `${rect.size.height * _ctx.scale}px`,
74
+ backgroundColor: originalIndex === searchResultState.value.activeResultIndex ? _ctx.activeHighlightColor : _ctx.highlightColor,
75
+ mixBlendMode: "multiply",
76
+ transform: "scale(1.02)",
77
+ transformOrigin: "center",
78
+ transition: "opacity .3s ease-in-out",
79
+ opacity: 1
80
+ })
81
+ }, null, 4);
82
+ }), 128))
83
+ ]);
84
+ }), 128))
85
+ ], 16)) : createCommentVNode("", true);
86
+ };
87
+ }
88
+ });
89
+ export {
90
+ _sfc_main as SearchLayer,
91
+ useSearch,
92
+ useSearchCapability,
93
+ useSearchPlugin
94
+ };
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-search.ts","../../src/vue/components/search-layer.vue"],"sourcesContent":["import { ref, onMounted, onUnmounted } from 'vue';\nimport { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { SearchPlugin, SearchState } from '@embedpdf/plugin-search';\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 = ref<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 onMounted(() => {\n if (!provides.value) return;\n\n const unsubscribe = provides.value.onStateChange((state) => {\n searchState.value = state;\n });\n\n onUnmounted(() => {\n unsubscribe();\n });\n });\n\n return {\n state: searchState,\n provides,\n };\n};\n","<template>\n <div v-if=\"searchResultState\" v-bind=\"$attrs\">\n <div v-for=\"({ result, originalIndex }, idx) in pageResults\" :key=\"`result-${idx}`\">\n <div\n v-for=\"(rect, rectIdx) in result.rects\"\n :key=\"`rect-${idx}-${rectIdx}`\"\n :style=\"{\n position: 'absolute',\n top: `${rect.origin.y * scale}px`,\n left: `${rect.origin.x * scale}px`,\n width: `${rect.size.width * scale}px`,\n height: `${rect.size.height * scale}px`,\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 />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, onMounted, onUnmounted } from 'vue';\nimport type { SearchResultState } from '@embedpdf/plugin-search';\nimport { useSearchCapability } from '../hooks/use-search';\n\ninterface SearchLayerProps {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n}\n\nconst props = withDefaults(defineProps<SearchLayerProps>(), {\n highlightColor: '#FFFF00',\n activeHighlightColor: '#FFBF00',\n});\n\nconst { provides: searchProvides } = useSearchCapability();\nconst searchResultState = ref<SearchResultState | null>(null);\n\n// Filter results for current page while preserving original indices\nconst pageResults = computed(() => {\n if (!searchResultState.value) return [];\n\n return searchResultState.value.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === props.pageIndex);\n});\n\nlet unsubscribe: (() => void) | undefined;\n\nonMounted(() => {\n if (!searchProvides.value) return;\n\n unsubscribe = searchProvides.value.onSearchResultStateChange((state) => {\n searchResultState.value = state;\n });\n});\n\nonUnmounted(() => {\n unsubscribe?.();\n});\n</script>\n"],"names":["_openBlock","_createElementBlock","$attrs","_Fragment","_normalizeStyle","scale","activeHighlightColor","highlightColor"],"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,IAAiB;AAAA,IACnC,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;AACV,QAAA,CAAC,SAAS,MAAO;AAErB,UAAM,cAAc,SAAS,MAAM,cAAc,CAAC,UAAU;AAC1D,kBAAY,QAAQ;AAAA,IAAA,CACrB;AAED,gBAAY,MAAM;AACJ,kBAAA;AAAA,IAAA,CACb;AAAA,EAAA,CACF;AAEM,SAAA;AAAA,IACL,OAAO;AAAA,IACP;AAAA,EACF;AACF;;;;;;;;;;ACGA,UAAM,QAAQ;AAKd,UAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACnD,UAAA,oBAAoB,IAA8B,IAAI;AAGtD,UAAA,cAAc,SAAS,MAAM;AACjC,UAAI,CAAC,kBAAkB,MAAO,QAAO,CAAC;AAE/B,aAAA,kBAAkB,MAAM,QAC5B,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,gBAAgB,EAC1D,OAAO,CAAC,EAAE,OAAA,MAAa,OAAO,cAAc,MAAM,SAAS;AAAA,IAAA,CAC/D;AAEG,QAAA;AAEJ,cAAU,MAAM;AACV,UAAA,CAAC,eAAe,MAAO;AAE3B,oBAAc,eAAe,MAAM,0BAA0B,CAAC,UAAU;AACtE,0BAAkB,QAAQ;AAAA,MAAA,CAC3B;AAAA,IAAA,CACF;AAED,gBAAY,MAAM;AACF;AAAA,IAAA,CACf;;aAnEY,kBAAiB,SAA5BA,UAAA,GAAAC,mBAuBM,6CAvBgCC,KAAM,MAAA,CAAA,GAAA;AAAA,SAC1CF,UAAA,IAAA,GAAAC,mBAqBME,2BArB0C,YAAW,OAAA,CAAA,EAA5C,QAAQ,cAAA,GAAiB,QAAG;8BAA3CF,mBAqBM,OAAA;AAAA,YArBwD,eAAe,GAAG;AAAA,UAAA;aAC9ED,UAAA,IAAA,GAAAC,mBAmBEE,2BAlB0B,OAAO,OAAzB,CAAA,MAAM,YAAO;kCADvBF,mBAmBE,OAAA;AAAA,gBAjBC,KAAG,QAAU,GAAG,IAAI,OAAO;AAAA,gBAC3B,OAAKG,eAAA;AAAA;kBAAsD,KAAA,GAAA,KAAK,OAAO,IAAIC,KAAK,KAAA;AAAA,kBAAyB,MAAA,GAAA,KAAK,OAAO,IAAIA,KAAK,KAAA;AAAA,kBAA0B,OAAA,GAAA,KAAK,KAAK,QAAQA,KAAK,KAAA;AAAA,kBAA2B,QAAA,GAAA,KAAK,KAAK,SAASA,KAAK,KAAA;AAAA,mCAA6C,kBAAkB,kBAAiB,MAAC,oBAAkCC,KAAoB,uBAAiBC,KAAc;AAAA;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-search",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,24 +20,30 @@
20
20
  "types": "./dist/react/index.d.ts",
21
21
  "import": "./dist/react/index.js",
22
22
  "require": "./dist/react/index.cjs"
23
+ },
24
+ "./vue": {
25
+ "types": "./dist/vue/index.d.ts",
26
+ "import": "./dist/vue/index.js",
27
+ "require": "./dist/vue/index.cjs"
23
28
  }
24
29
  },
25
30
  "dependencies": {
26
- "@embedpdf/models": "1.0.20"
31
+ "@embedpdf/models": "1.0.21"
27
32
  },
28
33
  "devDependencies": {
29
34
  "@types/react": "^18.2.0",
30
35
  "typescript": "^5.0.0",
36
+ "@embedpdf/core": "1.0.21",
31
37
  "@embedpdf/build": "1.0.0",
32
- "@embedpdf/core": "1.0.20",
33
- "@embedpdf/plugin-loader": "1.0.20"
38
+ "@embedpdf/plugin-loader": "1.0.21"
34
39
  },
35
40
  "peerDependencies": {
36
41
  "react": ">=16.8.0",
37
42
  "react-dom": ">=16.8.0",
38
43
  "preact": "^10.26.4",
39
- "@embedpdf/plugin-loader": "1.0.20",
40
- "@embedpdf/core": "1.0.20"
44
+ "vue": ">=3.2.0",
45
+ "@embedpdf/core": "1.0.21",
46
+ "@embedpdf/plugin-loader": "1.0.21"
41
47
  },
42
48
  "files": [
43
49
  "dist",
@@ -59,7 +65,8 @@
59
65
  "build:base": "vite build --mode base",
60
66
  "build:react": "vite build --mode react",
61
67
  "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\"",
68
+ "build:vue": "vite build --mode vue",
69
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
63
70
  "clean": "rimraf dist",
64
71
  "lint": "eslint src --color",
65
72
  "lint:fix": "eslint src --color --fix"