@embedpdf/plugin-search 1.4.0 → 1.5.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.
|
@@ -10,6 +10,6 @@ export declare const useSearchCapability: () => {
|
|
|
10
10
|
ready: Promise<void>;
|
|
11
11
|
};
|
|
12
12
|
export declare const useSearch: () => {
|
|
13
|
-
readonly state: SearchState;
|
|
14
13
|
readonly provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
|
|
14
|
+
state: SearchState;
|
|
15
15
|
};
|
package/dist/svelte/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-search");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const o=i(e),s=()=>t.useCapability(r.SearchPlugin.id);var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-search");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const o=i(e),s=()=>t.useCapability(r.SearchPlugin.id);var a=o.from_html("<div></div>"),n=o.from_html("<div></div>");exports.SearchLayer=function(e,t){o.push(t,!0);const r=o.prop(t,"highlightColor",3,"#FFFF00"),i=o.prop(t,"activeHighlightColor",3,"#FFBF00"),l=o.rest_props(t,["$$slots","$$events","$$legacy","pageIndex","scale","highlightColor","activeHighlightColor"]),c=s();let p=o.state(null);o.user_effect((()=>{if(c.provides)return c.provides.onSearchResultStateChange((e=>{o.set(p,e,!0)}))}));const g=o.derived((()=>o.get(p)?o.get(p).results.map(((e,t)=>({result:e,originalIndex:t}))).filter((({result:e})=>e.pageIndex===t.pageIndex)):[]));var u=o.comment(),d=o.first_child(u),h=e=>{var s=n();o.attribute_effect(s,(()=>({...l}))),o.each(s,21,(()=>o.get(g)),o.index,((e,s)=>{var n=o.comment(),l=o.first_child(n);o.each(l,17,(()=>o.get(s).result.rects),o.index,((e,n)=>{var l=a();let c;o.template_effect((e=>c=o.set_style(l,"",c,e)),[()=>({position:"absolute",top:o.get(n).origin.y*t.scale+"px",left:o.get(n).origin.x*t.scale+"px",width:o.get(n).size.width*t.scale+"px",height:o.get(n).size.height*t.scale+"px","background-color":o.get(s).originalIndex===o.get(p).activeResultIndex?i():r(),"mix-blend-mode":"multiply",transform:"scale(1.02)","transform-origin":"center",transition:"opacity .3s ease-in-out",opacity:"1"})]),o.append(e,l)})),o.append(e,n)})),o.reset(s),o.append(e,s)};o.if(d,(e=>{o.get(p)&&e(h)})),o.append(e,u),o.pop()},exports.useSearch=()=>{const e=s(),t=o.proxy({get provides(){return e.provides},state:r.initialState});return o.user_effect((()=>{if(e.provides)return e.provides.onStateChange((e=>{t.state=e}))})),t},exports.useSearchCapability=s,exports.useSearchPlugin=()=>t.usePlugin(r.SearchPlugin.id),Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-search.svelte.ts","../../src/svelte/components/SearchLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { initialState, 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
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-search.svelte.ts","../../src/svelte/components/SearchLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { initialState, 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 capability = useSearchCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n state: initialState as SearchState,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n return capability.provides.onStateChange((newState) => {\n state.state = newState;\n });\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { SearchResultState } from '@embedpdf/plugin-search';\n import { useSearchCapability } from '../hooks';\n import type { HTMLAttributes } from 'svelte/elements';\n\n interface Props extends HTMLAttributes<HTMLDivElement> {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n }\n\n const {\n pageIndex,\n scale,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...divProps\n }: Props = $props();\n\n const searchCapability = useSearchCapability();\n let searchResultState = $state<SearchResultState | null>(null);\n\n $effect(() => {\n if (!searchCapability.provides) return;\n return searchCapability.provides.onSearchResultStateChange((state) => {\n searchResultState = state;\n });\n });\n\n const pageResults = $derived(\n searchResultState\n ? searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex)\n : [],\n );\n</script>\n\n{#if searchResultState}\n <div {...divProps}>\n {#each pageResults as { result, originalIndex }}\n {#each result.rects as rect}\n <div\n style:position=\"absolute\"\n style:top=\"{rect.origin.y * scale}px\"\n style:left=\"{rect.origin.x * scale}px\"\n style:width=\"{rect.size.width * scale}px\"\n style:height=\"{rect.size.height * scale}px\"\n style:background-color={originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor}\n style:mix-blend-mode=\"multiply\"\n style:transform=\"scale(1.02)\"\n style:transform-origin=\"center\"\n style:transition=\"opacity .3s ease-in-out\"\n style:opacity=\"1\"\n ></div>\n {/each}\n {/each}\n </div>\n{/if}\n"],"names":["useSearchCapability","useCapability","SearchPlugin","id","highlightColor","activeHighlightColor","divProps","$","rest_props","$$props","searchCapability","searchResultState","user_effect","provides","onSearchResultStateChange","state","$__namespace","set","pageResults","get","results","map","result","originalIndex","filter","pageIndex","index","$$anchor","$$item","rects","rect","origin","y","scale","x","size","width","height","activeResultIndex","consequent","capability","initialState","onStateChange","newState","usePlugin"],"mappings":"sgBAIaA,EAA4B,IAAAC,gBAA4BC,EAAAA,aAAaC,iHCW9E,MAAAC,8BAAiB,WACjBC,oCAAuB,WACpBC,EAAOC,EAAAC,WAAAC,EAAA,+FAGNC,EAAmBV,IACrB,IAAAW,UAAqD,MAEzDJ,EAAAK,aAAc,KACP,GAAAF,EAAiBG,SACf,OAAAH,EAAiBG,SAASC,2BAA2BC,IAC1DC,EAAAC,IAAAN,EAAoBI,GAAK,EAAA,GAC1B,IAGG,MAAAG,uBACJP,GACIJ,EAAAY,IAAAR,GAAkBS,QACfC,KAAK,CAAAC,EAAQC,KAAa,CAAQD,SAAQC,oBAC1CC,QAAM,EAAIF,YAAaA,EAAOG,YAAShB,EAAAgB,qGAMvCnB,6BACAY,IAAWX,EAAAmB,OAAA,CAAAC,EAAAC,oEAAON,OACTO,OAAKtB,EAAAmB,OAAA,CAAAC,EAAIG,yGAGPA,GAAKC,OAAOC,EAACvB,EAAAwB,sBACZH,GAAKC,OAAOG,EAACzB,EAAAwB,uBACZH,GAAKK,KAAKC,MAAK3B,EAAAwB,wBACdH,GAAKK,KAAKE,OAAM5B,EAAAwB,WACP,4BARGV,sBAQeZ,GAAkB2B,kBACxDjC,IACAD,uNAZTO,MAAiB4B,EAAA,yBAFtB,yBD9BQ,MAAAC,EAAaxC,IAEbe,WACA,YAAAF,GACK,OAAA2B,EAAW3B,QACpB,EACAE,MAAO0B,EAAAA,eAUF,OAPPlC,EAAAK,kBACO,GAAA4B,EAAW3B,SACT,OAAA2B,EAAW3B,SAAS6B,eAAeC,IACxC5B,EAAMA,MAAQ4B,CAAA,GACf,IAGI5B,CAAA,wDApB4B,IAAA6B,YAAwB1C,EAAAA,aAAaC"}
|
package/dist/svelte/index.js
CHANGED
|
@@ -6,22 +6,20 @@ import "svelte/internal/disclose-version";
|
|
|
6
6
|
const useSearchPlugin = () => usePlugin(SearchPlugin.id);
|
|
7
7
|
const useSearchCapability = () => useCapability(SearchPlugin.id);
|
|
8
8
|
const useSearch = () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const capability = useSearchCapability();
|
|
10
|
+
const state = $.proxy({
|
|
11
|
+
get provides() {
|
|
12
|
+
return capability.provides;
|
|
13
|
+
},
|
|
14
|
+
state: initialState
|
|
15
|
+
});
|
|
11
16
|
$.user_effect(() => {
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
14
|
-
|
|
17
|
+
if (!capability.provides) return;
|
|
18
|
+
return capability.provides.onStateChange((newState) => {
|
|
19
|
+
state.state = newState;
|
|
15
20
|
});
|
|
16
21
|
});
|
|
17
|
-
return
|
|
18
|
-
get state() {
|
|
19
|
-
return $.get(searchState);
|
|
20
|
-
},
|
|
21
|
-
get provides() {
|
|
22
|
-
return $.get(provides);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
22
|
+
return state;
|
|
25
23
|
};
|
|
26
24
|
var root_3 = $.from_html(`<div></div>`);
|
|
27
25
|
var root_1 = $.from_html(`<div></div>`);
|
|
@@ -36,11 +34,11 @@ function SearchLayer($$anchor, $$props) {
|
|
|
36
34
|
"highlightColor",
|
|
37
35
|
"activeHighlightColor"
|
|
38
36
|
]);
|
|
39
|
-
const
|
|
37
|
+
const searchCapability = useSearchCapability();
|
|
40
38
|
let searchResultState = $.state(null);
|
|
41
39
|
$.user_effect(() => {
|
|
42
|
-
if (!
|
|
43
|
-
return
|
|
40
|
+
if (!searchCapability.provides) return;
|
|
41
|
+
return searchCapability.provides.onSearchResultStateChange((state) => {
|
|
44
42
|
$.set(searchResultState, state, true);
|
|
45
43
|
});
|
|
46
44
|
});
|
package/dist/svelte/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-search.svelte.ts","../../src/svelte/components/SearchLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { initialState, 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
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-search.svelte.ts","../../src/svelte/components/SearchLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { initialState, 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 capability = useSearchCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n state: initialState as SearchState,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n return capability.provides.onStateChange((newState) => {\n state.state = newState;\n });\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { SearchResultState } from '@embedpdf/plugin-search';\n import { useSearchCapability } from '../hooks';\n import type { HTMLAttributes } from 'svelte/elements';\n\n interface Props extends HTMLAttributes<HTMLDivElement> {\n pageIndex: number;\n scale: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n }\n\n const {\n pageIndex,\n scale,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...divProps\n }: Props = $props();\n\n const searchCapability = useSearchCapability();\n let searchResultState = $state<SearchResultState | null>(null);\n\n $effect(() => {\n if (!searchCapability.provides) return;\n return searchCapability.provides.onSearchResultStateChange((state) => {\n searchResultState = state;\n });\n });\n\n const pageResults = $derived(\n searchResultState\n ? searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex)\n : [],\n );\n</script>\n\n{#if searchResultState}\n <div {...divProps}>\n {#each pageResults as { result, originalIndex }}\n {#each result.rects as rect}\n <div\n style:position=\"absolute\"\n style:top=\"{rect.origin.y * scale}px\"\n style:left=\"{rect.origin.x * scale}px\"\n style:width=\"{rect.size.width * scale}px\"\n style:height=\"{rect.size.height * scale}px\"\n style:background-color={originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor}\n style:mix-blend-mode=\"multiply\"\n style:transform=\"scale(1.02)\"\n style:transform-origin=\"center\"\n style:transition=\"opacity .3s ease-in-out\"\n style:opacity=\"1\"\n ></div>\n {/each}\n {/each}\n </div>\n{/if}\n"],"names":["$$anchor"],"mappings":";;;;;AAGa,MAAA,kBAAwB,MAAA,UAAwB,aAAa,EAAE;AAC/D,MAAA,sBAA4B,MAAA,cAA4B,aAAa,EAAE;AAEvE,MAAA,kBAAkB;AACvB,QAAA,aAAa,oBAAoB;QAEjC;IACA,IAAA,WAAW;AACN,aAAA,WAAW;AAAA,IACpB;AAAA,IACA,OAAO;AAAA;AAGT,IAAA,kBAAc;AACP,QAAA,CAAA,WAAW,SAAU;AACnB,WAAA,WAAW,SAAS,cAAe,CAAA,aAAa;AACrD,YAAM,QAAQ;AAAA,KACf;AAAA,GACF;SAEM;AACT;;;wCCxBA;;AAeI,QAAA,sDAAiB,SAAS,GAC1B,kEAAuB,SAAS,GAC7B,WAAO,EAAA,WAAA,SAAA;AAAA;;;;;;;;AAGN,QAAA,mBAAmB,oBAAmB;AACxC,MAAA,4BAAqD,IAAI;AAE7D,IAAA,YAAc,MAAA;AACP,QAAA,CAAA,iBAAiB,SAAQ;AACvB,WAAA,iBAAiB,SAAS,0BAAyB,CAAE,UAAU;AACpE,QAAA,IAAA,mBAAoB,OAAK,IAAA;AAAA,KAC1B;AAAA,GACF;AAEK,QAAA,oCACJ,iBAAgB,IACZ,EAAA,IAAA,iBAAiB,EAAC,QACf,IAAK,CAAA,QAAQ,mBAAa,EAAQ,QAAQ,kBAC1C,OAAM,CAAA,EAAI,OAAM,MAAO,OAAO,cAAS,QAAA,SAAA;;;;;;0CAMvC,SAAQ,EAAA;kCACR,WAAW,GAAA,EAAA,OAAA,CAAAA,WAAA,WAAA;AAAO,YAAA,6BAAA;AAAQ,YAAA,oCAAA;;;iCACxB,OAAM,EAAC,OAAK,EAAA,OAAA,CAAAA,WAAI,SAAI;;;;;;4BAGX,IAAI,EAAC,OAAO,IAAC,QAAA,KAAA;AAAA,6BACZ,IAAI,EAAC,OAAO,IAAC,QAAA,KAAA;AAAA,8BACZ,IAAI,EAAC,KAAK,QAAK,QAAA,KAAA;AAAA,+BACd,IAAI,EAAC,KAAK,SAAM,QAAA,KAAA;AAAA,cACP,oBAAA,0BAAkB,iBAAiB,EAAC,oBACxD,yBACA,eAAc;AAAA;;;;;;;;;;;;;;;gBAZvB,iBAAiB,EAAA,UAAA,UAAA;AAAA;;;;AAFtB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@embedpdf/models": "1.
|
|
37
|
+
"@embedpdf/models": "1.5.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.2.0",
|
|
41
41
|
"typescript": "^5.0.0",
|
|
42
42
|
"@embedpdf/build": "1.1.0",
|
|
43
|
-
"@embedpdf/core": "1.
|
|
44
|
-
"@embedpdf/plugin-loader": "1.
|
|
43
|
+
"@embedpdf/core": "1.5.0",
|
|
44
|
+
"@embedpdf/plugin-loader": "1.5.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"preact": "^10.26.4",
|
|
50
50
|
"vue": ">=3.2.0",
|
|
51
51
|
"svelte": ">=5 <6",
|
|
52
|
-
"@embedpdf/core": "1.
|
|
53
|
-
"@embedpdf/plugin-loader": "1.
|
|
52
|
+
"@embedpdf/core": "1.5.0",
|
|
53
|
+
"@embedpdf/plugin-loader": "1.5.0"
|
|
54
54
|
},
|
|
55
55
|
"files": [
|
|
56
56
|
"dist",
|