@embedpdf/plugin-document-manager 2.0.0-next.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.
- package/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +466 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/document-manager-plugin.d.ts +45 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/types.d.ts +80 -0
- package/dist/preact/adapter.d.ts +5 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.ts +1 -0
- package/dist/preact/index.js +136 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +135 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared/components/document-content.d.ts +27 -0
- package/dist/shared/components/document-context.d.ts +42 -0
- package/dist/shared/components/file-picker.d.ts +1 -0
- package/dist/shared/components/index.d.ts +3 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-document-manager.d.ts +23 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared-preact/components/document-content.d.ts +27 -0
- package/dist/shared-preact/components/document-context.d.ts +42 -0
- package/dist/shared-preact/components/file-picker.d.ts +1 -0
- package/dist/shared-preact/components/index.d.ts +3 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-document-manager.d.ts +23 -0
- package/dist/shared-preact/index.d.ts +4 -0
- package/dist/shared-react/components/document-content.d.ts +27 -0
- package/dist/shared-react/components/document-context.d.ts +42 -0
- package/dist/shared-react/components/file-picker.d.ts +1 -0
- package/dist/shared-react/components/index.d.ts +3 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-document-manager.d.ts +23 -0
- package/dist/shared-react/index.d.ts +4 -0
- package/dist/svelte/components/DocumentContent.svelte.d.ts +15 -0
- package/dist/svelte/components/DocumentContext.svelte.d.ts +18 -0
- package/dist/svelte/components/FilePicker.svelte.d.ts +3 -0
- package/dist/svelte/components/index.d.ts +3 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-document-manager.svelte.d.ts +26 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +175 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/vue/components/document-content.vue.d.ts +29 -0
- package/dist/vue/components/document-context.vue.d.ts +28 -0
- package/dist/vue/components/file-picker.vue.d.ts +3 -0
- package/dist/vue/components/index.d.ts +3 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-document-manager.d.ts +17 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +169 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { DocumentManagerPlugin, DocumentManagerPluginPackage as DocumentManagerPluginPackage$1 } from "@embedpdf/plugin-document-manager";
|
|
3
|
+
export * from "@embedpdf/plugin-document-manager";
|
|
4
|
+
import "svelte/internal/disclose-version";
|
|
5
|
+
import * as $ from "svelte/internal/client";
|
|
6
|
+
import { usePlugin, useCapability, useCoreState, useDocumentState } from "@embedpdf/core/svelte";
|
|
7
|
+
const useDocumentManagerPlugin = () => usePlugin(DocumentManagerPlugin.id);
|
|
8
|
+
const useDocumentManagerCapability = () => useCapability(DocumentManagerPlugin.id);
|
|
9
|
+
function useActiveDocument() {
|
|
10
|
+
const coreStateRef = useCoreState();
|
|
11
|
+
const activeDocumentId = $.derived(() => {
|
|
12
|
+
var _a;
|
|
13
|
+
return ((_a = coreStateRef.current) == null ? void 0 : _a.activeDocumentId) ?? null;
|
|
14
|
+
});
|
|
15
|
+
const activeDocument = $.derived(() => {
|
|
16
|
+
const core = coreStateRef.current;
|
|
17
|
+
if (!core) return null;
|
|
18
|
+
const docId = core.activeDocumentId;
|
|
19
|
+
return docId ? core.documents[docId] ?? null : null;
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
get activeDocumentId() {
|
|
23
|
+
return $.get(activeDocumentId);
|
|
24
|
+
},
|
|
25
|
+
get activeDocument() {
|
|
26
|
+
return $.get(activeDocument);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function useOpenDocuments(getDocumentIds) {
|
|
31
|
+
const coreStateRef = useCoreState();
|
|
32
|
+
const documentIds = $.derived(() => getDocumentIds ? getDocumentIds() : void 0);
|
|
33
|
+
const documents = $.derived(() => {
|
|
34
|
+
const core = coreStateRef.current;
|
|
35
|
+
if (!core) return [];
|
|
36
|
+
if ($.get(documentIds) && $.get(documentIds).length > 0) {
|
|
37
|
+
return $.get(documentIds).map((docId) => core.documents[docId]).filter((doc) => doc !== null && doc !== void 0);
|
|
38
|
+
}
|
|
39
|
+
return core.documentOrder.map((docId) => core.documents[docId]).filter((doc) => doc !== null && doc !== void 0);
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
get current() {
|
|
43
|
+
return $.get(documents);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var root = $.from_html(`<input type="file" accept="application/pdf"/>`);
|
|
48
|
+
function FilePicker($$anchor, $$props) {
|
|
49
|
+
$.push($$props, true);
|
|
50
|
+
const documentManagerPlugin = useDocumentManagerPlugin();
|
|
51
|
+
const documentManagerCapability = useDocumentManagerCapability();
|
|
52
|
+
let inputRef = $.state(null);
|
|
53
|
+
let taskRef = $.state(null);
|
|
54
|
+
let optionsRef = $.state(void 0);
|
|
55
|
+
$.user_effect(() => {
|
|
56
|
+
var _a;
|
|
57
|
+
if (!((_a = documentManagerPlugin.plugin) == null ? void 0 : _a.onOpenFileRequest)) return;
|
|
58
|
+
const unsubscribe = documentManagerPlugin.plugin.onOpenFileRequest(({ task, options }) => {
|
|
59
|
+
var _a2;
|
|
60
|
+
$.set(taskRef, task, true);
|
|
61
|
+
$.set(optionsRef, options, true);
|
|
62
|
+
(_a2 = $.get(inputRef)) == null ? void 0 : _a2.click();
|
|
63
|
+
});
|
|
64
|
+
return unsubscribe;
|
|
65
|
+
});
|
|
66
|
+
const onChange = async (event) => {
|
|
67
|
+
var _a, _b, _c, _d, _e;
|
|
68
|
+
const target = event.target;
|
|
69
|
+
const file = (_a = target.files) == null ? void 0 : _a[0];
|
|
70
|
+
if (!file || !documentManagerCapability.provides) return;
|
|
71
|
+
const buffer = await file.arrayBuffer();
|
|
72
|
+
const openTask = documentManagerCapability.provides.openDocumentBuffer({
|
|
73
|
+
name: file.name,
|
|
74
|
+
buffer,
|
|
75
|
+
documentId: (_b = $.get(optionsRef)) == null ? void 0 : _b.documentId,
|
|
76
|
+
scale: (_c = $.get(optionsRef)) == null ? void 0 : _c.scale,
|
|
77
|
+
rotation: (_d = $.get(optionsRef)) == null ? void 0 : _d.rotation,
|
|
78
|
+
autoActivate: (_e = $.get(optionsRef)) == null ? void 0 : _e.autoActivate
|
|
79
|
+
});
|
|
80
|
+
openTask.wait(
|
|
81
|
+
(result) => {
|
|
82
|
+
var _a2;
|
|
83
|
+
(_a2 = $.get(taskRef)) == null ? void 0 : _a2.resolve(result);
|
|
84
|
+
},
|
|
85
|
+
(error) => {
|
|
86
|
+
var _a2;
|
|
87
|
+
(_a2 = $.get(taskRef)) == null ? void 0 : _a2.fail(error);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
var input = root();
|
|
92
|
+
input.__change = onChange;
|
|
93
|
+
$.set_style(input, "", {}, { display: "none" });
|
|
94
|
+
$.bind_this(input, ($$value) => $.set(inputRef, $$value), () => $.get(inputRef));
|
|
95
|
+
$.append($$anchor, input);
|
|
96
|
+
$.pop();
|
|
97
|
+
}
|
|
98
|
+
$.delegate(["change"]);
|
|
99
|
+
function DocumentContext($$anchor, $$props) {
|
|
100
|
+
$.push($$props, true);
|
|
101
|
+
const openDocuments = useOpenDocuments();
|
|
102
|
+
const activeDoc = useActiveDocument();
|
|
103
|
+
const capability = useDocumentManagerCapability();
|
|
104
|
+
const actions = {
|
|
105
|
+
select: (documentId) => {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = capability.provides) == null ? void 0 : _a.setActiveDocument(documentId);
|
|
108
|
+
},
|
|
109
|
+
close: (documentId) => {
|
|
110
|
+
var _a;
|
|
111
|
+
(_a = capability.provides) == null ? void 0 : _a.closeDocument(documentId);
|
|
112
|
+
},
|
|
113
|
+
move: (documentId, toIndex) => {
|
|
114
|
+
var _a;
|
|
115
|
+
(_a = capability.provides) == null ? void 0 : _a.moveDocument(documentId, toIndex);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var fragment = $.comment();
|
|
119
|
+
var node = $.first_child(fragment);
|
|
120
|
+
$.snippet(node, () => $$props.children, () => ({
|
|
121
|
+
documentStates: openDocuments.current,
|
|
122
|
+
activeDocumentId: activeDoc.activeDocumentId,
|
|
123
|
+
actions
|
|
124
|
+
}));
|
|
125
|
+
$.append($$anchor, fragment);
|
|
126
|
+
$.pop();
|
|
127
|
+
}
|
|
128
|
+
function DocumentContent($$anchor, $$props) {
|
|
129
|
+
$.push($$props, true);
|
|
130
|
+
const docState = useDocumentState(() => $$props.documentId);
|
|
131
|
+
const isLoading = $.derived(() => {
|
|
132
|
+
var _a;
|
|
133
|
+
return ((_a = docState.current) == null ? void 0 : _a.status) === "loading";
|
|
134
|
+
});
|
|
135
|
+
const isError = $.derived(() => {
|
|
136
|
+
var _a;
|
|
137
|
+
return ((_a = docState.current) == null ? void 0 : _a.status) === "error";
|
|
138
|
+
});
|
|
139
|
+
const isLoaded = $.derived(() => {
|
|
140
|
+
var _a;
|
|
141
|
+
return ((_a = docState.current) == null ? void 0 : _a.status) === "loaded";
|
|
142
|
+
});
|
|
143
|
+
var fragment = $.comment();
|
|
144
|
+
var node = $.first_child(fragment);
|
|
145
|
+
{
|
|
146
|
+
var consequent = ($$anchor2) => {
|
|
147
|
+
var fragment_1 = $.comment();
|
|
148
|
+
var node_1 = $.first_child(fragment_1);
|
|
149
|
+
$.snippet(node_1, () => $$props.children, () => ({
|
|
150
|
+
documentState: docState.current,
|
|
151
|
+
isLoading: $.get(isLoading),
|
|
152
|
+
isError: $.get(isError),
|
|
153
|
+
isLoaded: $.get(isLoaded)
|
|
154
|
+
}));
|
|
155
|
+
$.append($$anchor2, fragment_1);
|
|
156
|
+
};
|
|
157
|
+
$.if(node, ($$render) => {
|
|
158
|
+
if (docState.current) $$render(consequent);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
$.append($$anchor, fragment);
|
|
162
|
+
$.pop();
|
|
163
|
+
}
|
|
164
|
+
const DocumentManagerPluginPackage = createPluginPackage(DocumentManagerPluginPackage$1).addUtility(FilePicker).build();
|
|
165
|
+
export {
|
|
166
|
+
DocumentContent,
|
|
167
|
+
DocumentContext,
|
|
168
|
+
DocumentManagerPluginPackage,
|
|
169
|
+
FilePicker,
|
|
170
|
+
useActiveDocument,
|
|
171
|
+
useDocumentManagerCapability,
|
|
172
|
+
useDocumentManagerPlugin,
|
|
173
|
+
useOpenDocuments
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-document-manager.svelte.ts","../../src/svelte/components/FilePicker.svelte","../../src/svelte/components/DocumentContext.svelte","../../src/svelte/components/DocumentContent.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin, useCoreState } from '@embedpdf/core/svelte';\nimport { DocumentManagerPlugin } from '@embedpdf/plugin-document-manager';\nimport type { DocumentState } from '@embedpdf/core';\n\nexport const useDocumentManagerPlugin = () =>\n usePlugin<DocumentManagerPlugin>(DocumentManagerPlugin.id);\nexport const useDocumentManagerCapability = () =>\n useCapability<DocumentManagerPlugin>(DocumentManagerPlugin.id);\n\n/**\n * Hook for active document state\n */\nexport function useActiveDocument() {\n // Keep reference to avoid destructuring - maintains reactivity\n const coreStateRef = useCoreState();\n\n // Use $derived.by for computed values that depend on the reactive coreState\n const activeDocumentId = $derived.by(() => {\n return coreStateRef.current?.activeDocumentId ?? null;\n });\n\n const activeDocument = $derived.by(() => {\n const core = coreStateRef.current;\n if (!core) return null;\n\n const docId = core.activeDocumentId;\n return docId ? (core.documents[docId] ?? null) : null;\n });\n\n return {\n get activeDocumentId() {\n return activeDocumentId;\n },\n get activeDocument() {\n return activeDocument;\n },\n };\n}\n\n/**\n * Hook for all open documents (in order)\n * @param getDocumentIds Optional getter function for specific document IDs to filter/order by\n */\nexport function useOpenDocuments(getDocumentIds?: () => string[] | undefined) {\n // Keep reference to avoid destructuring - maintains reactivity\n const coreStateRef = useCoreState();\n\n // Derive documentIds reactively if getter is provided\n const documentIds = $derived(getDocumentIds ? getDocumentIds() : undefined);\n\n // Use $derived.by for computed array of documents\n const documents = $derived.by(() => {\n const core = coreStateRef.current;\n if (!core) return [];\n\n // If specific documentIds are provided, use THEIR order\n if (documentIds && documentIds.length > 0) {\n return documentIds\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n }\n\n // Otherwise use the global document order\n return core.documentOrder\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n });\n\n return {\n get current() {\n return documents;\n },\n };\n}\n","<script lang=\"ts\">\n import { useDocumentManagerCapability, useDocumentManagerPlugin } from '../hooks';\n import type { Task } from '@embedpdf/models';\n import type { PdfErrorReason } from '@embedpdf/models';\n import type {\n OpenDocumentResponse,\n OpenFileDialogOptions,\n } from '@embedpdf/plugin-document-manager';\n\n const documentManagerPlugin = useDocumentManagerPlugin();\n const documentManagerCapability = useDocumentManagerCapability();\n\n let inputRef = $state<HTMLInputElement | null>(null);\n let taskRef = $state<Task<OpenDocumentResponse, PdfErrorReason> | null>(null);\n let optionsRef = $state<OpenFileDialogOptions | undefined>(undefined);\n\n $effect(() => {\n if (!documentManagerPlugin.plugin?.onOpenFileRequest) return;\n\n const unsubscribe = documentManagerPlugin.plugin.onOpenFileRequest(({ task, options }) => {\n taskRef = task;\n optionsRef = options;\n inputRef?.click();\n });\n\n return unsubscribe;\n });\n\n const onChange = async (event: Event) => {\n const target = event.target as HTMLInputElement;\n const file = target.files?.[0];\n if (!file || !documentManagerCapability.provides) return;\n\n const buffer = await file.arrayBuffer();\n const openTask = documentManagerCapability.provides.openDocumentBuffer({\n name: file.name,\n buffer,\n documentId: optionsRef?.documentId,\n scale: optionsRef?.scale,\n rotation: optionsRef?.rotation,\n autoActivate: optionsRef?.autoActivate,\n });\n\n openTask.wait(\n (result) => {\n taskRef?.resolve(result);\n },\n (error) => {\n taskRef?.fail(error);\n },\n );\n };\n</script>\n\n<input\n bind:this={inputRef}\n type=\"file\"\n accept=\"application/pdf\"\n style:display=\"none\"\n onchange={onChange}\n/>\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useOpenDocuments, useActiveDocument, useDocumentManagerCapability } from '../hooks';\n import type { DocumentState } from '@embedpdf/core';\n\n export interface TabActions {\n select: (documentId: string) => void;\n close: (documentId: string) => void;\n move: (documentId: string, toIndex: number) => void;\n }\n\n export interface DocumentContextRenderProps {\n documentStates: DocumentState[];\n activeDocumentId: string | null;\n actions: TabActions;\n }\n\n interface DocumentContextProps {\n children: Snippet<[DocumentContextRenderProps]>;\n }\n\n let { children }: DocumentContextProps = $props();\n\n const openDocuments = useOpenDocuments();\n const activeDoc = useActiveDocument();\n const capability = useDocumentManagerCapability();\n\n const actions: TabActions = {\n select: (documentId: string) => {\n capability.provides?.setActiveDocument(documentId);\n },\n close: (documentId: string) => {\n capability.provides?.closeDocument(documentId);\n },\n move: (documentId: string, toIndex: number) => {\n capability.provides?.moveDocument(documentId, toIndex);\n },\n };\n</script>\n\n<!--\n Headless component for managing document tabs\n Provides all state and actions, completely UI-agnostic\n \n @example\n <DocumentContext>\n {#snippet children({ documentStates, activeDocumentId, actions })}\n <div class=\"tabs\">\n {#each documentStates as doc (doc.id)}\n <button\n onclick={() => actions.select(doc.id)}\n class:active={doc.id === activeDocumentId}\n >\n {doc.name}\n <button onclick={(e) => { e.stopPropagation(); actions.close(doc.id); }}>×</button>\n </button>\n {/each}\n </div>\n {/snippet}\n </DocumentContext>\n-->\n{@render children({\n documentStates: openDocuments.current,\n activeDocumentId: activeDoc.activeDocumentId,\n actions,\n})}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { DocumentState } from '@embedpdf/core';\n\n export interface DocumentContentRenderProps {\n documentState: DocumentState;\n isLoading: boolean;\n isError: boolean;\n isLoaded: boolean;\n }\n\n interface DocumentContentProps {\n documentId: string | null;\n children: Snippet<[DocumentContentRenderProps]>;\n }\n\n let { documentId, children }: DocumentContentProps = $props();\n\n const docState = useDocumentState(() => documentId);\n\n const isLoading = $derived(docState.current?.status === 'loading');\n const isError = $derived(docState.current?.status === 'error');\n const isLoaded = $derived(docState.current?.status === 'loaded');\n</script>\n\n<!--\n Headless component for rendering document content with loading/error states\n \n @example\n <DocumentContent {documentId}>\n {#snippet children({ documentState, isLoading, isError, isLoaded })}\n {#if isLoading}\n <LoadingSpinner />\n {:else if isError}\n <ErrorMessage />\n {:else if isLoaded}\n <PDFViewer {documentState} />\n {/if}\n {/snippet}\n </DocumentContent>\n-->\n{#if docState.current}\n {@render children({\n documentState: docState.current,\n isLoading,\n isError,\n isLoaded,\n })}\n{/if}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { DocumentManagerPluginPackage as BaseDocumentManagerPackage } from '@embedpdf/plugin-document-manager';\n\nimport { FilePicker, DocumentContext, DocumentContent } from './components';\n\nexport * from './hooks';\nexport * from './components';\n\nexport * from '@embedpdf/plugin-document-manager';\n\nexport const DocumentManagerPluginPackage = createPluginPackage(BaseDocumentManagerPackage)\n .addUtility(FilePicker)\n .build();\n"],"names":["_a","BaseDocumentManagerPackage"],"mappings":";;;;;;AAIa,MAAA,2BAAA,MACX,UAAiC,sBAAsB,EAAE;AAC9C,MAAA,+BAAA,MACX,cAAqC,sBAAsB,EAAE;AAK/C,SAAA,oBAAoB;AAE5B,QAAA,eAAe,aAAA;AAGf,QAAA,mCAAqC;;AAClC,aAAA,kBAAa,YAAb,mBAAsB,qBAAoB;AAAA,EACnD,CAAC;AAEK,QAAA,iCAAmC;UACjC,OAAO,aAAa;AACrB,QAAA,CAAA,aAAa;UAEZ,QAAQ,KAAK;WACZ,QAAS,KAAK,UAAU,KAAK,KAAK,OAAQ;AAAA,EACnD,CAAC;;IAGK,IAAA,mBAAmB;mBACd,gBAAA;AAAA,IACT;AAAA,IACI,IAAA,iBAAiB;mBACZ,cAAA;AAAA,IACT;AAAA;AAEJ;SAMgB,iBAAiB,gBAA6C;AAEtE,QAAA,eAAe,aAAA;AAGf,QAAA,cAAA,EAAA,QAAA,MAAuB,iBAAiB,eAAA,UAA4B;AAGpE,QAAA,4BAA8B;UAC5B,OAAO,aAAa;SACrB,KAAA,QAAA,CAAA;AAGD,QAAA,EAAA,IAAA,WAAA,WAAe,WAAA,EAAY,SAAS,GAAG;mBAClC,WAAA,EACJ,IAAA,CAAK,UAAU,KAAK,UAAU,KAAK,GACnC,QAAQ,QAA8B,QAAQ,QAAQ,cAAiB;AAAA,IAC5E;WAGO,KAAK,cACT,KAAK,UAAU,KAAK,UAAU,KAAK,CAAA,EACnC,QAAQ,QAA8B,QAAQ,QAAQ,cAAiB;AAAA,EAC5E,CAAC;;I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AAiB;AAC7B,QAAA,aAAa,6BAA4B;QAEzC,UAAmB;AAAA,IACvB,QAAM,CAAG,eAAuB;;AAC9B,uBAAW,aAAX,mBAAqB,kBAAkB;AAAA,IACzC;AAAA,IACA,OAAK,CAAG,eAAuB;;AAC7B,uBAAW,aAAX,mBAAqB,cAAc;AAAA,IACrC;AAAA,IACA,MAAI,CAAG,YAAoB,YAAoB;;AAC7C,uBAAW,aAAX,mBAAqB,aAAa,YAAY;AAAA,IAChD;AAAA;;;;IA0BF,gBAAgB,cAAc;AAAA,IAC9B,kBAAkB,UAAU;AAAA,IAC5B;AAAA;;;AA1BF;4CCtCA;;AAmBQ,QAAA,WAAW,iBAAgB,MAAA,QAAA,UAAA;AAE3B,QAAA;;AAAqB,2BAAS,YAAT,mBAAkB,YAAW;AAAA,GAAS;AAC3D,QAAA;;AAAmB,2BAAS,YAAT,mBAAkB,YAAW;AAAA,GAAO;AACvD,QAAA;;AAAoB,2BAAS,YAAT,mBAAkB,YAAW;AAAA,GAAQ;;;;;;;;QAqB7D,eAAe,SAAS;AAAA,QACxB,iBAAA,SAAS;AAAA,QACT,eAAA,OAAO;AAAA,QACP,gBAAA,QAAQ;AAAA;;;;AALP,UAAA,SAAS,QAAO,UAAA,UAAA;AAAA;;;;AAlBrB;ACdO,MAAM,+BAA+B,oBAAoBC,8BAA0B,EACvF,WAAW,UAAU,EACrB,MAAA;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { DocumentState } from '@embedpdf/core';
|
|
3
|
+
export interface DocumentContentRenderProps {
|
|
4
|
+
documentState: DocumentState;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
isError: boolean;
|
|
7
|
+
isLoaded: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface DocumentContentProps {
|
|
10
|
+
documentId: MaybeRefOrGetter<string | null>;
|
|
11
|
+
}
|
|
12
|
+
declare var __VLS_1: {
|
|
13
|
+
documentState: any;
|
|
14
|
+
isLoading: any;
|
|
15
|
+
isError: any;
|
|
16
|
+
isLoaded: any;
|
|
17
|
+
};
|
|
18
|
+
type __VLS_Slots = {} & {
|
|
19
|
+
default?: (props: typeof __VLS_1) => any;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_base: import('vue').DefineComponent<DocumentContentProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<DocumentContentProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
23
|
+
declare const _default: typeof __VLS_export;
|
|
24
|
+
export default _default;
|
|
25
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DocumentState } from '@embedpdf/core';
|
|
2
|
+
export interface TabActions {
|
|
3
|
+
select: (documentId: string) => void;
|
|
4
|
+
close: (documentId: string) => void;
|
|
5
|
+
move: (documentId: string, toIndex: number) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface DocumentContextRenderProps {
|
|
8
|
+
documentStates: DocumentState[];
|
|
9
|
+
activeDocumentId: string | null;
|
|
10
|
+
actions: TabActions;
|
|
11
|
+
}
|
|
12
|
+
declare var __VLS_1: {
|
|
13
|
+
documentStates: any;
|
|
14
|
+
activeDocumentId: any;
|
|
15
|
+
actions: any;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_Slots = {} & {
|
|
18
|
+
default?: (props: typeof __VLS_1) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-document-manager';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DocumentState } from '@embedpdf/core';
|
|
2
|
+
import { DocumentManagerPlugin } from '../../lib/index.ts';
|
|
3
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
4
|
+
export declare const useDocumentManagerPlugin: () => import('@embedpdf/core/vue').PluginState<DocumentManagerPlugin>;
|
|
5
|
+
export declare const useDocumentManagerCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').DocumentManagerCapability>>;
|
|
6
|
+
/**
|
|
7
|
+
* Hook for active document state
|
|
8
|
+
*/
|
|
9
|
+
export declare function useActiveDocument(): {
|
|
10
|
+
activeDocumentId: import('vue').ComputedRef<string | null>;
|
|
11
|
+
activeDocument: import('vue').ComputedRef<DocumentState | null>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Hook for all open documents (in order)
|
|
15
|
+
* @param getDocumentIds Optional getter function, ref, or array of specific document IDs to filter/order by
|
|
16
|
+
*/
|
|
17
|
+
export declare function useOpenDocuments(getDocumentIds?: MaybeRefOrGetter<string[] | undefined>): import('vue').ComputedRef<DocumentState[]>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-document-manager"),n=require("vue"),u=require("@embedpdf/core/vue"),o=n.defineComponent({__name:"document-content",props:{documentId:{}},setup(e){const t=e,o=u.useDocumentState(()=>n.toValue(t.documentId)),l=n.computed(()=>{var e;return"loading"===(null==(e=o.value)?void 0:e.status)}),a=n.computed(()=>{var e;return"error"===(null==(e=o.value)?void 0:e.status)}),r=n.computed(()=>{var e;return"loaded"===(null==(e=o.value)?void 0:e.status)});return(e,t)=>n.unref(o)?n.renderSlot(e.$slots,"default",{key:0,documentState:n.unref(o),isLoading:l.value,isError:a.value,isLoaded:r.value}):n.createCommentVNode("",!0)}}),l=()=>u.usePlugin(t.DocumentManagerPlugin.id),a=()=>u.useCapability(t.DocumentManagerPlugin.id);function r(){const e=u.useCoreState();return{activeDocumentId:n.computed(()=>{var t;return(null==(t=e.value)?void 0:t.activeDocumentId)??null}),activeDocument:n.computed(()=>{const t=e.value;if(!t)return null;const n=t.activeDocumentId;return n?t.documents[n]??null:null})}}function c(e){const t=u.useCoreState();return n.computed(()=>{const u=t.value;if(!u)return[];const o=e?n.toValue(e):void 0;return o&&o.length>0?o.map(e=>u.documents[e]).filter(e=>null!=e):u.documentOrder.map(e=>u.documents[e]).filter(e=>null!=e)})}const i=n.defineComponent({__name:"document-context",setup(e){const t=c(),{activeDocumentId:u}=r(),{provides:o}=a(),l={select:e=>{var t;null==(t=o.value)||t.setActiveDocument(e)},close:e=>{var t;null==(t=o.value)||t.closeDocument(e)},move:(e,t)=>{var n;null==(n=o.value)||n.moveDocument(e,t)}};return(e,o)=>n.renderSlot(e.$slots,"default",{documentStates:n.unref(t),activeDocumentId:n.unref(u),actions:l})}}),s=n.defineComponent({__name:"file-picker",setup(e){const{plugin:t}=l(),{provides:u}=a(),o=n.ref(null),r=n.ref(null),c=n.ref(void 0);n.watch(t,(e,t,n)=>{if(!(null==e?void 0:e.onOpenFileRequest))return;n(e.onOpenFileRequest(({task:e,options:t})=>{var n;r.value=e,c.value=t,null==(n=o.value)||n.click()}))},{immediate:!0});const i=async e=>{var t,n,o,l,a;const i=null==(t=e.target.files)?void 0:t[0],s=u.value;if(!i||!s)return;const d=await i.arrayBuffer();s.openDocumentBuffer({name:i.name,buffer:d,documentId:null==(n=c.value)?void 0:n.documentId,scale:null==(o=c.value)?void 0:o.scale,rotation:null==(l=c.value)?void 0:l.rotation,autoActivate:null==(a=c.value)?void 0:a.autoActivate}).wait(e=>{var t;null==(t=r.value)||t.resolve(e)},e=>{var t;null==(t=r.value)||t.fail(e)})};return(e,t)=>(n.openBlock(),n.createElementBlock("input",{ref_key:"inputRef",ref:o,type:"file",accept:"application/pdf",style:{display:"none"},onChange:i},null,544))}}),d=e.createPluginPackage(t.DocumentManagerPluginPackage).addUtility(s).build();exports.DocumentContent=o,exports.DocumentContext=i,exports.DocumentManagerPluginPackage=d,exports.FilePicker=s,exports.useActiveDocument=r,exports.useDocumentManagerCapability=a,exports.useDocumentManagerPlugin=l,exports.useOpenDocuments=c,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/vue/components/document-content.vue","../../src/vue/hooks/use-document-manager.ts","../../src/vue/components/document-context.vue","../../src/vue/components/file-picker.vue","../../src/vue/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useDocumentState } from '@embedpdf/core/vue';\nimport type { DocumentState } from '@embedpdf/core';\n\nexport interface DocumentContentRenderProps {\n documentState: DocumentState;\n isLoading: boolean;\n isError: boolean;\n isLoaded: boolean;\n}\n\ninterface DocumentContentProps {\n documentId: MaybeRefOrGetter<string | null>;\n}\n\nconst props = defineProps<DocumentContentProps>();\nconst documentState = useDocumentState(() => toValue(props.documentId));\n\nconst isLoading = computed(() => documentState.value?.status === 'loading');\nconst isError = computed(() => documentState.value?.status === 'error');\nconst isLoaded = computed(() => documentState.value?.status === 'loaded');\n</script>\n\n<template>\n <!--\n Headless component for rendering document content with loading/error states\n \n @example\n <DocumentContent :documentId=\"activeDocumentId\">\n <template #default=\"{ documentState, isLoading, isError, isLoaded }\">\n <LoadingSpinner v-if=\"isLoading\" />\n <ErrorMessage v-else-if=\"isError\" />\n <PDFViewer v-else-if=\"isLoaded\" :document=\"documentState\" />\n </template>\n </DocumentContent>\n -->\n <slot\n v-if=\"documentState\"\n :documentState=\"documentState\"\n :isLoading=\"isLoading\"\n :isError=\"isError\"\n :isLoaded=\"isLoaded\"\n />\n</template>\n","import { DocumentState } from '@embedpdf/core';\nimport { useCapability, usePlugin, useCoreState } from '@embedpdf/core/vue';\nimport { DocumentManagerPlugin } from '@embedpdf/plugin-document-manager';\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue';\n\nexport const useDocumentManagerPlugin = () =>\n usePlugin<DocumentManagerPlugin>(DocumentManagerPlugin.id);\nexport const useDocumentManagerCapability = () =>\n useCapability<DocumentManagerPlugin>(DocumentManagerPlugin.id);\n\n/**\n * Hook for active document state\n */\nexport function useActiveDocument() {\n const coreState = useCoreState();\n\n const activeDocumentId = computed(() => {\n return coreState.value?.activeDocumentId ?? null;\n });\n\n const activeDocument = computed(() => {\n const core = coreState.value;\n if (!core) return null;\n\n const docId = core.activeDocumentId;\n return docId ? (core.documents[docId] ?? null) : null;\n });\n\n return {\n activeDocumentId,\n activeDocument,\n };\n}\n\n/**\n * Hook for all open documents (in order)\n * @param getDocumentIds Optional getter function, ref, or array of specific document IDs to filter/order by\n */\nexport function useOpenDocuments(getDocumentIds?: MaybeRefOrGetter<string[] | undefined>) {\n const coreState = useCoreState();\n\n const documents = computed(() => {\n const core = coreState.value;\n if (!core) return [];\n\n // Get documentIds reactively if provided\n const documentIds = getDocumentIds ? toValue(getDocumentIds) : undefined;\n\n // If specific documentIds are provided, use THEIR order\n if (documentIds && documentIds.length > 0) {\n return documentIds\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n }\n\n // Otherwise use the global document order\n return core.documentOrder\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n });\n\n return documents;\n}\n","<script setup lang=\"ts\">\nimport { useOpenDocuments, useActiveDocument, useDocumentManagerCapability } from '../hooks';\nimport type { DocumentState } from '@embedpdf/core';\n\nexport interface TabActions {\n select: (documentId: string) => void;\n close: (documentId: string) => void;\n move: (documentId: string, toIndex: number) => void;\n}\n\nexport interface DocumentContextRenderProps {\n documentStates: DocumentState[];\n activeDocumentId: string | null;\n actions: TabActions;\n}\n\nconst documentStates = useOpenDocuments();\nconst { activeDocumentId } = useActiveDocument();\nconst { provides } = useDocumentManagerCapability();\n\nconst actions: TabActions = {\n select: (documentId: string) => {\n provides.value?.setActiveDocument(documentId);\n },\n close: (documentId: string) => {\n provides.value?.closeDocument(documentId);\n },\n move: (documentId: string, toIndex: number) => {\n provides.value?.moveDocument(documentId, toIndex);\n },\n};\n</script>\n\n<template>\n <!--\n Headless component for managing document tabs\n Provides all state and actions, completely UI-agnostic\n \n @example\n <DocumentContext>\n <template #default=\"{ documentStates, activeDocumentId, actions }\">\n <div class=\"tabs\">\n <button\n v-for=\"doc in documentStates\"\n :key=\"doc.id\"\n @click=\"actions.select(doc.id)\"\n :class=\"{ active: doc.id === activeDocumentId }\"\n >\n {{ doc.name }}\n <button @click.stop=\"actions.close(doc.id)\">×</button>\n </button>\n </div>\n </template>\n </DocumentContext>\n -->\n <slot :documentStates=\"documentStates\" :activeDocumentId=\"activeDocumentId\" :actions=\"actions\" />\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watch } from 'vue';\nimport { useDocumentManagerCapability, useDocumentManagerPlugin } from '../hooks';\nimport type { Task } from '@embedpdf/models';\nimport type { PdfErrorReason } from '@embedpdf/models';\nimport type {\n OpenDocumentResponse,\n OpenFileDialogOptions,\n} from '@embedpdf/plugin-document-manager';\n\nconst { plugin } = useDocumentManagerPlugin();\nconst { provides } = useDocumentManagerCapability();\nconst inputRef = ref<HTMLInputElement | null>(null);\nconst taskRef = ref<Task<OpenDocumentResponse, PdfErrorReason> | null>(null);\nconst optionsRef = ref<OpenFileDialogOptions | undefined>(undefined);\n\nwatch(\n plugin,\n (pluginValue, _, onCleanup) => {\n if (!pluginValue?.onOpenFileRequest) return;\n\n const unsubscribe = pluginValue.onOpenFileRequest(({ task, options }) => {\n taskRef.value = task;\n optionsRef.value = options;\n inputRef.value?.click();\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n);\n\nconst onChange = async (event: Event) => {\n const target = event.target as HTMLInputElement;\n const file = target.files?.[0];\n const cap = provides.value;\n if (!file || !cap) return;\n\n const buffer = await file.arrayBuffer();\n const openTask = cap.openDocumentBuffer({\n name: file.name,\n buffer,\n documentId: optionsRef.value?.documentId,\n scale: optionsRef.value?.scale,\n rotation: optionsRef.value?.rotation,\n autoActivate: optionsRef.value?.autoActivate,\n });\n\n openTask.wait(\n (result) => {\n taskRef.value?.resolve(result);\n },\n (error) => {\n taskRef.value?.fail(error);\n },\n );\n};\n</script>\n\n<template>\n <input\n ref=\"inputRef\"\n type=\"file\"\n accept=\"application/pdf\"\n style=\"display: none\"\n @change=\"onChange\"\n />\n</template>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { DocumentManagerPluginPackage as BaseDocumentManagerPackage } from '@embedpdf/plugin-document-manager';\nimport { FilePicker } from './components';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-document-manager';\n\n// A convenience package that auto-registers our utilities\nexport const DocumentManagerPluginPackage = createPluginPackage(BaseDocumentManagerPackage)\n .addUtility(FilePicker) // headless utility consumers can mount once and call cap.openFileDialog()\n .build();\n"],"names":["props","__props","documentState","useDocumentState","toValue","documentId","isLoading","computed","_a","value","status","isError","isLoaded","_unref","_renderSlot","_ctx","$slots","useDocumentManagerPlugin","usePlugin","DocumentManagerPlugin","id","useDocumentManagerCapability","useCapability","useActiveDocument","coreState","useCoreState","activeDocumentId","activeDocument","core","docId","documents","useOpenDocuments","getDocumentIds","documentIds","length","map","filter","doc","documentOrder","documentStates","provides","actions","select","setActiveDocument","close","closeDocument","move","toIndex","moveDocument","plugin","inputRef","ref","taskRef","optionsRef","watch","pluginValue","_","onCleanup","onOpenFileRequest","task","options","click","immediate","onChange","async","event","file","target","files","cap","buffer","arrayBuffer","openDocumentBuffer","name","_b","scale","_c","rotation","_d","autoActivate","_e","wait","result","resolve","error","fail","_createElementBlock","type","accept","style","display","DocumentManagerPluginPackage","createPluginPackage","BaseDocumentManagerPackage","addUtility","FilePicker","build"],"mappings":"gSAgBA,MAAMA,EAAQC,EACRC,EAAgBC,EAAAA,iBAAiB,IAAMC,EAAAA,QAAQJ,EAAMK,aAErDC,EAAYC,EAAAA,SAAS,WAAM,MAAgC,aAAhC,OAAAC,EAAAN,EAAcO,gBAAOC,UAChDC,EAAUJ,EAAAA,SAAS,WAAM,MAAgC,WAAhC,OAAAC,EAAAN,EAAcO,gBAAOC,UAC9CE,EAAWL,EAAAA,SAAS,WAAM,MAAgC,YAAhC,OAAAC,EAAAN,EAAcO,gBAAOC,uBAiB3CG,EAAAA,MAAAX,GADRY,EAAAA,WAMEC,EAAAC,OAAA,UAAA,OAJCd,cAAeW,EAAAA,MAAAX,GACfI,UAAWA,EAAAG,MACXE,QAASA,EAAAF,MACTG,SAAUA,EAAAH,uCCrCFQ,EAA2B,IACtCC,YAAiCC,EAAAA,sBAAsBC,IAC5CC,EAA+B,IAC1CC,gBAAqCH,EAAAA,sBAAsBC,IAKtD,SAASG,IACd,MAAMC,EAAYC,EAAAA,eAclB,MAAO,CACLC,iBAbuBnB,EAAA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f,WAAKF,WAAaG,mBAAmB,OAQrCD,EANoBF,EAAYG,kBAAkB,EAAGC,OAAMC,oBACzDR,EAAQ3C,MAAQkD,EAChBN,EAAW5C,MAAQmD,EACnB,OAAApD,EAAA0C,EAASzC,QAATD,EAAgBqD,YAKpB,CAAEC,WAAW,IAGf,MAAMC,EAAWC,MAAOC,kBACtB,MACMC,EAAO,OAAA1D,EADEyD,EAAME,OACDC,YAAP,EAAA5D,EAAe,GACtB6D,EAAM7B,EAAS/B,MACrB,IAAKyD,IAASG,EAAK,OAEnB,MAAMC,QAAeJ,EAAKK,cACTF,EAAIG,mBAAmB,CACtCC,KAAMP,EAAKO,KACXH,SACAjE,WAAY,OAAAqE,EAAArB,EAAW5C,YAAX,EAAAiE,EAAkBrE,WAC9BsE,MAAO,OAAAC,EAAAvB,EAAW5C,YAAX,EAAAmE,EAAkBD,MACzBE,SAAU,OAAAC,EAAAzB,EAAW5C,YAAX,EAAAqE,EAAkBD,SAC5BE,aAAc,OAAAC,EAAA3B,EAAW5C,YAAX,EAAAuE,EAAkBD,eAGzBE,KACNC,UACC,OAAA1E,EAAA4C,EAAQ3C,QAARD,EAAe2E,QAAQD,IAExBE,UACC,OAAA5E,EAAA4C,EAAQ3C,QAARD,EAAe6E,KAAKD,kCAOxBE,EAAAA,mBAME,QAAA,SALI,WAAJnC,IAAID,EACJqC,KAAK,OACLC,OAAO,kBACPC,MAAA,CAAAC,QAAA,QACC3B,0BCxDQ4B,EAA+BC,EAAAA,oBAAoBC,EAAAA,8BAC7DC,WAAWC,GACXC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './hooks';
|
|
2
|
+
export * from './components';
|
|
3
|
+
export * from '../lib/index.ts';
|
|
4
|
+
export declare const DocumentManagerPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').DocumentManagerPlugin, import('../lib/index.ts').DocumentManagerPluginConfig, unknown, import('@embedpdf/core').Action>>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { DocumentManagerPlugin, DocumentManagerPluginPackage as DocumentManagerPluginPackage$1 } from "@embedpdf/plugin-document-manager";
|
|
3
|
+
export * from "@embedpdf/plugin-document-manager";
|
|
4
|
+
import { defineComponent, toValue, computed, renderSlot, createCommentVNode, unref, ref, watch, createElementBlock, openBlock } from "vue";
|
|
5
|
+
import { useDocumentState, usePlugin, useCapability, useCoreState } from "@embedpdf/core/vue";
|
|
6
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "document-content",
|
|
8
|
+
props: {
|
|
9
|
+
documentId: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const documentState = useDocumentState(() => toValue(props.documentId));
|
|
14
|
+
const isLoading = computed(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = documentState.value) == null ? void 0 : _a.status) === "loading";
|
|
17
|
+
});
|
|
18
|
+
const isError = computed(() => {
|
|
19
|
+
var _a;
|
|
20
|
+
return ((_a = documentState.value) == null ? void 0 : _a.status) === "error";
|
|
21
|
+
});
|
|
22
|
+
const isLoaded = computed(() => {
|
|
23
|
+
var _a;
|
|
24
|
+
return ((_a = documentState.value) == null ? void 0 : _a.status) === "loaded";
|
|
25
|
+
});
|
|
26
|
+
return (_ctx, _cache) => {
|
|
27
|
+
return unref(documentState) ? renderSlot(_ctx.$slots, "default", {
|
|
28
|
+
key: 0,
|
|
29
|
+
documentState: unref(documentState),
|
|
30
|
+
isLoading: isLoading.value,
|
|
31
|
+
isError: isError.value,
|
|
32
|
+
isLoaded: isLoaded.value
|
|
33
|
+
}) : createCommentVNode("", true);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const useDocumentManagerPlugin = () => usePlugin(DocumentManagerPlugin.id);
|
|
38
|
+
const useDocumentManagerCapability = () => useCapability(DocumentManagerPlugin.id);
|
|
39
|
+
function useActiveDocument() {
|
|
40
|
+
const coreState = useCoreState();
|
|
41
|
+
const activeDocumentId = computed(() => {
|
|
42
|
+
var _a;
|
|
43
|
+
return ((_a = coreState.value) == null ? void 0 : _a.activeDocumentId) ?? null;
|
|
44
|
+
});
|
|
45
|
+
const activeDocument = computed(() => {
|
|
46
|
+
const core = coreState.value;
|
|
47
|
+
if (!core) return null;
|
|
48
|
+
const docId = core.activeDocumentId;
|
|
49
|
+
return docId ? core.documents[docId] ?? null : null;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
activeDocumentId,
|
|
53
|
+
activeDocument
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function useOpenDocuments(getDocumentIds) {
|
|
57
|
+
const coreState = useCoreState();
|
|
58
|
+
const documents = computed(() => {
|
|
59
|
+
const core = coreState.value;
|
|
60
|
+
if (!core) return [];
|
|
61
|
+
const documentIds = getDocumentIds ? toValue(getDocumentIds) : void 0;
|
|
62
|
+
if (documentIds && documentIds.length > 0) {
|
|
63
|
+
return documentIds.map((docId) => core.documents[docId]).filter((doc) => doc !== null && doc !== void 0);
|
|
64
|
+
}
|
|
65
|
+
return core.documentOrder.map((docId) => core.documents[docId]).filter((doc) => doc !== null && doc !== void 0);
|
|
66
|
+
});
|
|
67
|
+
return documents;
|
|
68
|
+
}
|
|
69
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
70
|
+
__name: "document-context",
|
|
71
|
+
setup(__props) {
|
|
72
|
+
const documentStates = useOpenDocuments();
|
|
73
|
+
const { activeDocumentId } = useActiveDocument();
|
|
74
|
+
const { provides } = useDocumentManagerCapability();
|
|
75
|
+
const actions = {
|
|
76
|
+
select: (documentId) => {
|
|
77
|
+
var _a;
|
|
78
|
+
(_a = provides.value) == null ? void 0 : _a.setActiveDocument(documentId);
|
|
79
|
+
},
|
|
80
|
+
close: (documentId) => {
|
|
81
|
+
var _a;
|
|
82
|
+
(_a = provides.value) == null ? void 0 : _a.closeDocument(documentId);
|
|
83
|
+
},
|
|
84
|
+
move: (documentId, toIndex) => {
|
|
85
|
+
var _a;
|
|
86
|
+
(_a = provides.value) == null ? void 0 : _a.moveDocument(documentId, toIndex);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return (_ctx, _cache) => {
|
|
90
|
+
return renderSlot(_ctx.$slots, "default", {
|
|
91
|
+
documentStates: unref(documentStates),
|
|
92
|
+
activeDocumentId: unref(activeDocumentId),
|
|
93
|
+
actions
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
99
|
+
__name: "file-picker",
|
|
100
|
+
setup(__props) {
|
|
101
|
+
const { plugin } = useDocumentManagerPlugin();
|
|
102
|
+
const { provides } = useDocumentManagerCapability();
|
|
103
|
+
const inputRef = ref(null);
|
|
104
|
+
const taskRef = ref(null);
|
|
105
|
+
const optionsRef = ref(void 0);
|
|
106
|
+
watch(
|
|
107
|
+
plugin,
|
|
108
|
+
(pluginValue, _, onCleanup) => {
|
|
109
|
+
if (!(pluginValue == null ? void 0 : pluginValue.onOpenFileRequest)) return;
|
|
110
|
+
const unsubscribe = pluginValue.onOpenFileRequest(({ task, options }) => {
|
|
111
|
+
var _a;
|
|
112
|
+
taskRef.value = task;
|
|
113
|
+
optionsRef.value = options;
|
|
114
|
+
(_a = inputRef.value) == null ? void 0 : _a.click();
|
|
115
|
+
});
|
|
116
|
+
onCleanup(unsubscribe);
|
|
117
|
+
},
|
|
118
|
+
{ immediate: true }
|
|
119
|
+
);
|
|
120
|
+
const onChange = async (event) => {
|
|
121
|
+
var _a, _b, _c, _d, _e;
|
|
122
|
+
const target = event.target;
|
|
123
|
+
const file = (_a = target.files) == null ? void 0 : _a[0];
|
|
124
|
+
const cap = provides.value;
|
|
125
|
+
if (!file || !cap) return;
|
|
126
|
+
const buffer = await file.arrayBuffer();
|
|
127
|
+
const openTask = cap.openDocumentBuffer({
|
|
128
|
+
name: file.name,
|
|
129
|
+
buffer,
|
|
130
|
+
documentId: (_b = optionsRef.value) == null ? void 0 : _b.documentId,
|
|
131
|
+
scale: (_c = optionsRef.value) == null ? void 0 : _c.scale,
|
|
132
|
+
rotation: (_d = optionsRef.value) == null ? void 0 : _d.rotation,
|
|
133
|
+
autoActivate: (_e = optionsRef.value) == null ? void 0 : _e.autoActivate
|
|
134
|
+
});
|
|
135
|
+
openTask.wait(
|
|
136
|
+
(result) => {
|
|
137
|
+
var _a2;
|
|
138
|
+
(_a2 = taskRef.value) == null ? void 0 : _a2.resolve(result);
|
|
139
|
+
},
|
|
140
|
+
(error) => {
|
|
141
|
+
var _a2;
|
|
142
|
+
(_a2 = taskRef.value) == null ? void 0 : _a2.fail(error);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
return (_ctx, _cache) => {
|
|
147
|
+
return openBlock(), createElementBlock("input", {
|
|
148
|
+
ref_key: "inputRef",
|
|
149
|
+
ref: inputRef,
|
|
150
|
+
type: "file",
|
|
151
|
+
accept: "application/pdf",
|
|
152
|
+
style: { "display": "none" },
|
|
153
|
+
onChange
|
|
154
|
+
}, null, 544);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const DocumentManagerPluginPackage = createPluginPackage(DocumentManagerPluginPackage$1).addUtility(_sfc_main).build();
|
|
159
|
+
export {
|
|
160
|
+
_sfc_main$2 as DocumentContent,
|
|
161
|
+
_sfc_main$1 as DocumentContext,
|
|
162
|
+
DocumentManagerPluginPackage,
|
|
163
|
+
_sfc_main as FilePicker,
|
|
164
|
+
useActiveDocument,
|
|
165
|
+
useDocumentManagerCapability,
|
|
166
|
+
useDocumentManagerPlugin,
|
|
167
|
+
useOpenDocuments
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vue/components/document-content.vue","../../src/vue/hooks/use-document-manager.ts","../../src/vue/components/document-context.vue","../../src/vue/components/file-picker.vue","../../src/vue/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue';\nimport { useDocumentState } from '@embedpdf/core/vue';\nimport type { DocumentState } from '@embedpdf/core';\n\nexport interface DocumentContentRenderProps {\n documentState: DocumentState;\n isLoading: boolean;\n isError: boolean;\n isLoaded: boolean;\n}\n\ninterface DocumentContentProps {\n documentId: MaybeRefOrGetter<string | null>;\n}\n\nconst props = defineProps<DocumentContentProps>();\nconst documentState = useDocumentState(() => toValue(props.documentId));\n\nconst isLoading = computed(() => documentState.value?.status === 'loading');\nconst isError = computed(() => documentState.value?.status === 'error');\nconst isLoaded = computed(() => documentState.value?.status === 'loaded');\n</script>\n\n<template>\n <!--\n Headless component for rendering document content with loading/error states\n \n @example\n <DocumentContent :documentId=\"activeDocumentId\">\n <template #default=\"{ documentState, isLoading, isError, isLoaded }\">\n <LoadingSpinner v-if=\"isLoading\" />\n <ErrorMessage v-else-if=\"isError\" />\n <PDFViewer v-else-if=\"isLoaded\" :document=\"documentState\" />\n </template>\n </DocumentContent>\n -->\n <slot\n v-if=\"documentState\"\n :documentState=\"documentState\"\n :isLoading=\"isLoading\"\n :isError=\"isError\"\n :isLoaded=\"isLoaded\"\n />\n</template>\n","import { DocumentState } from '@embedpdf/core';\nimport { useCapability, usePlugin, useCoreState } from '@embedpdf/core/vue';\nimport { DocumentManagerPlugin } from '@embedpdf/plugin-document-manager';\nimport { computed, toValue, type MaybeRefOrGetter } from 'vue';\n\nexport const useDocumentManagerPlugin = () =>\n usePlugin<DocumentManagerPlugin>(DocumentManagerPlugin.id);\nexport const useDocumentManagerCapability = () =>\n useCapability<DocumentManagerPlugin>(DocumentManagerPlugin.id);\n\n/**\n * Hook for active document state\n */\nexport function useActiveDocument() {\n const coreState = useCoreState();\n\n const activeDocumentId = computed(() => {\n return coreState.value?.activeDocumentId ?? null;\n });\n\n const activeDocument = computed(() => {\n const core = coreState.value;\n if (!core) return null;\n\n const docId = core.activeDocumentId;\n return docId ? (core.documents[docId] ?? null) : null;\n });\n\n return {\n activeDocumentId,\n activeDocument,\n };\n}\n\n/**\n * Hook for all open documents (in order)\n * @param getDocumentIds Optional getter function, ref, or array of specific document IDs to filter/order by\n */\nexport function useOpenDocuments(getDocumentIds?: MaybeRefOrGetter<string[] | undefined>) {\n const coreState = useCoreState();\n\n const documents = computed(() => {\n const core = coreState.value;\n if (!core) return [];\n\n // Get documentIds reactively if provided\n const documentIds = getDocumentIds ? toValue(getDocumentIds) : undefined;\n\n // If specific documentIds are provided, use THEIR order\n if (documentIds && documentIds.length > 0) {\n return documentIds\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n }\n\n // Otherwise use the global document order\n return core.documentOrder\n .map((docId) => core.documents[docId])\n .filter((doc): doc is DocumentState => doc !== null && doc !== undefined);\n });\n\n return documents;\n}\n","<script setup lang=\"ts\">\nimport { useOpenDocuments, useActiveDocument, useDocumentManagerCapability } from '../hooks';\nimport type { DocumentState } from '@embedpdf/core';\n\nexport interface TabActions {\n select: (documentId: string) => void;\n close: (documentId: string) => void;\n move: (documentId: string, toIndex: number) => void;\n}\n\nexport interface DocumentContextRenderProps {\n documentStates: DocumentState[];\n activeDocumentId: string | null;\n actions: TabActions;\n}\n\nconst documentStates = useOpenDocuments();\nconst { activeDocumentId } = useActiveDocument();\nconst { provides } = useDocumentManagerCapability();\n\nconst actions: TabActions = {\n select: (documentId: string) => {\n provides.value?.setActiveDocument(documentId);\n },\n close: (documentId: string) => {\n provides.value?.closeDocument(documentId);\n },\n move: (documentId: string, toIndex: number) => {\n provides.value?.moveDocument(documentId, toIndex);\n },\n};\n</script>\n\n<template>\n <!--\n Headless component for managing document tabs\n Provides all state and actions, completely UI-agnostic\n \n @example\n <DocumentContext>\n <template #default=\"{ documentStates, activeDocumentId, actions }\">\n <div class=\"tabs\">\n <button\n v-for=\"doc in documentStates\"\n :key=\"doc.id\"\n @click=\"actions.select(doc.id)\"\n :class=\"{ active: doc.id === activeDocumentId }\"\n >\n {{ doc.name }}\n <button @click.stop=\"actions.close(doc.id)\">×</button>\n </button>\n </div>\n </template>\n </DocumentContext>\n -->\n <slot :documentStates=\"documentStates\" :activeDocumentId=\"activeDocumentId\" :actions=\"actions\" />\n</template>\n","<script setup lang=\"ts\">\nimport { ref, watch } from 'vue';\nimport { useDocumentManagerCapability, useDocumentManagerPlugin } from '../hooks';\nimport type { Task } from '@embedpdf/models';\nimport type { PdfErrorReason } from '@embedpdf/models';\nimport type {\n OpenDocumentResponse,\n OpenFileDialogOptions,\n} from '@embedpdf/plugin-document-manager';\n\nconst { plugin } = useDocumentManagerPlugin();\nconst { provides } = useDocumentManagerCapability();\nconst inputRef = ref<HTMLInputElement | null>(null);\nconst taskRef = ref<Task<OpenDocumentResponse, PdfErrorReason> | null>(null);\nconst optionsRef = ref<OpenFileDialogOptions | undefined>(undefined);\n\nwatch(\n plugin,\n (pluginValue, _, onCleanup) => {\n if (!pluginValue?.onOpenFileRequest) return;\n\n const unsubscribe = pluginValue.onOpenFileRequest(({ task, options }) => {\n taskRef.value = task;\n optionsRef.value = options;\n inputRef.value?.click();\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n);\n\nconst onChange = async (event: Event) => {\n const target = event.target as HTMLInputElement;\n const file = target.files?.[0];\n const cap = provides.value;\n if (!file || !cap) return;\n\n const buffer = await file.arrayBuffer();\n const openTask = cap.openDocumentBuffer({\n name: file.name,\n buffer,\n documentId: optionsRef.value?.documentId,\n scale: optionsRef.value?.scale,\n rotation: optionsRef.value?.rotation,\n autoActivate: optionsRef.value?.autoActivate,\n });\n\n openTask.wait(\n (result) => {\n taskRef.value?.resolve(result);\n },\n (error) => {\n taskRef.value?.fail(error);\n },\n );\n};\n</script>\n\n<template>\n <input\n ref=\"inputRef\"\n type=\"file\"\n accept=\"application/pdf\"\n style=\"display: none\"\n @change=\"onChange\"\n />\n</template>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { DocumentManagerPluginPackage as BaseDocumentManagerPackage } from '@embedpdf/plugin-document-manager';\nimport { FilePicker } from './components';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-document-manager';\n\n// A convenience package that auto-registers our utilities\nexport const DocumentManagerPluginPackage = createPluginPackage(BaseDocumentManagerPackage)\n .addUtility(FilePicker) // headless utility consumers can mount once and call cap.openFileDialog()\n .build();\n"],"names":["_unref","_renderSlot","_a","_createElementBlock","BaseDocumentManagerPackage","FilePicker"],"mappings":";;;;;;;;;;;AAgBA,UAAM,QAAQ;AACd,UAAM,gBAAgB,iBAAiB,MAAM,QAAQ,MAAM,UAAU,CAAC;AAEtE,UAAM,YAAY,SAAS,MAAA;;AAAM,kCAAc,UAAd,mBAAqB,YAAW;AAAA,KAAS;AAC1E,UAAM,UAAU,SAAS,MAAA;;AAAM,kCAAc,UAAd,mBAAqB,YAAW;AAAA,KAAO;AACtE,UAAM,WAAW,SAAS,MAAA;;AAAM,kCAAc,UAAd,mBAAqB,YAAW;AAAA,KAAQ;;aAiB9DA,MAAA,aAAA,IADRC,WAME,KAAA,QAAA,WAAA;AAAA;QAJC,eAAeD,MAAA,aAAA;AAAA,QACf,WAAW,UAAA;AAAA,QACX,SAAS,QAAA;AAAA,QACT,UAAU,SAAA;AAAA,MAAA;;;;ACrCR,MAAM,2BAA2B,MACtC,UAAiC,sBAAsB,EAAE;AACpD,MAAM,+BAA+B,MAC1C,cAAqC,sBAAsB,EAAE;AAKxD,SAAS,oBAAoB;AAClC,QAAM,YAAY,aAAA;AAElB,QAAM,mBAAmB,SAAS,MAAM;;AACtC,aAAO,eAAU,UAAV,mBAAiB,qBAAoB;AAAA,EAC9C,CAAC;AAED,QAAM,iBAAiB,SAAS,MAAM;AACpC,UAAM,OAAO,UAAU;AACvB,QAAI,CAAC,KAAM,QAAO;AAElB,UAAM,QAAQ,KAAK;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oBAAoBC,8BAA0B,EACvF,WAAWC,SAAU,EACrB,MAAA;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@embedpdf/plugin-document-manager",
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./preact": {
|
|
16
|
+
"types": "./dist/preact/index.d.ts",
|
|
17
|
+
"import": "./dist/preact/index.js",
|
|
18
|
+
"require": "./dist/preact/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react/index.d.ts",
|
|
22
|
+
"import": "./dist/react/index.js",
|
|
23
|
+
"require": "./dist/react/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./vue": {
|
|
26
|
+
"types": "./dist/vue/index.d.ts",
|
|
27
|
+
"import": "./dist/vue/index.js",
|
|
28
|
+
"require": "./dist/vue/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./svelte": {
|
|
31
|
+
"types": "./dist/svelte/index.d.ts",
|
|
32
|
+
"import": "./dist/svelte/index.js",
|
|
33
|
+
"require": "./dist/svelte/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@embedpdf/models": "2.0.0-next.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^18.2.0",
|
|
41
|
+
"typescript": "^5.0.0",
|
|
42
|
+
"@embedpdf/build": "1.1.0",
|
|
43
|
+
"@embedpdf/core": "2.0.0-next.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=16.8.0",
|
|
47
|
+
"react-dom": ">=16.8.0",
|
|
48
|
+
"preact": "^10.26.4",
|
|
49
|
+
"vue": ">=3.2.0",
|
|
50
|
+
"svelte": ">=5 <6",
|
|
51
|
+
"@embedpdf/core": "2.0.0-next.0"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"README.md"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "https://github.com/embedpdf/embed-pdf-viewer",
|
|
60
|
+
"directory": "packages/plugin-document-manager"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://www.embedpdf.com/docs",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build:base": "vite build --mode base",
|
|
71
|
+
"build:react": "vite build --mode react",
|
|
72
|
+
"build:preact": "vite build --mode preact",
|
|
73
|
+
"build:vue": "vite build --mode vue",
|
|
74
|
+
"build:svelte": "vite build --mode svelte",
|
|
75
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
76
|
+
"clean": "rimraf dist",
|
|
77
|
+
"lint": "eslint src --color",
|
|
78
|
+
"lint:fix": "eslint src --color --fix"
|
|
79
|
+
}
|
|
80
|
+
}
|