@embedpdf/plugin-document-manager 2.2.0 → 2.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-document-manager.svelte.ts","../../src/svelte/components/FilePicker.svelte","../../src/svelte/index.ts","../../src/svelte/components/DocumentContent.svelte","../../src/svelte/components/DocumentContext.svelte"],"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) {\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","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","<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","<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"],"names":["useDocumentManagerPlugin","usePlugin","DocumentManagerPlugin","id","useDocumentManagerCapability","useCapability","useActiveDocument","coreStateRef","useCoreState","activeDocumentId","_a","current","activeDocument","core","docId","documents","useOpenDocuments","getDocumentIds","documentIds","$","derived","get","map","filter","doc","documentOrder","documentManagerPlugin","documentManagerCapability","inputRef","state","taskRef","optionsRef","user_effect","plugin","onOpenFileRequest","task","options","set","click","input","root","__change","async","event","file","target","files","provides","buffer","arrayBuffer","openDocumentBuffer","name","documentId","scale","rotation","autoActivate","wait","result","resolve","error","fail","display","$$value","DocumentManagerPluginPackage","createPluginPackage","BaseDocumentManagerPackage","addUtility","FilePicker","build","docState","useDocumentState","$$props","isLoading","status","isError","isLoaded","documentState","$$render","consequent","openDocuments","activeDoc","capability","actions","select","setActiveDocument","close","closeDocument","move","toIndex","moveDocument","documentStates"],"mappings":"kjBAIaA,EAAA,IACXC,YAAiCC,EAAAA,sBAAsBC,IAC5CC,EAAA,IACXC,gBAAqCH,EAAAA,sBAAsBC,IAK7C,SAAAG,IAER,MAAAC,EAAeC,EAAAA,eAGfC,uBACG,OAAA,OAAAC,EAAAH,EAAaI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js","sources":["../../src/svelte/hooks/use-document-manager.svelte.ts","../../src/svelte/components/FilePicker.svelte","../../src/svelte/index.ts","../../src/svelte/components/DocumentContent.svelte","../../src/svelte/components/DocumentContext.svelte"],"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) {\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","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","<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","<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"],"names":["useDocumentManagerPlugin","usePlugin","DocumentManagerPlugin","id","useDocumentManagerCapability","useCapability","useActiveDocument","coreStateRef","useCoreState","activeDocumentId","_a","current","activeDocument","core","docId","documents","useOpenDocuments","getDocumentIds","documentIds","$","derived","get","map","filter","doc","documentOrder","documentManagerPlugin","documentManagerCapability","inputRef","state","taskRef","optionsRef","user_effect","plugin","onOpenFileRequest","task","options","set","click","input","root","__change","async","event","file","target","files","provides","buffer","arrayBuffer","openDocumentBuffer","name","documentId","scale","rotation","autoActivate","wait","result","resolve","error","fail","display","$$value","DocumentManagerPluginPackage","createPluginPackage","BaseDocumentManagerPackage","addUtility","FilePicker","build","docState","useDocumentState","$$props","isLoading","status","isError","isLoaded","documentState","$$render","consequent","openDocuments","activeDoc","capability","actions","select","setActiveDocument","close","closeDocument","move","toIndex","moveDocument","documentStates"],"mappings":"kjBAIaA,EAAA,IACXC,YAAiCC,EAAAA,sBAAsBC,IAC5CC,EAAA,IACXC,gBAAqCH,EAAAA,sBAAsBC,IAK7C,SAAAG,IAER,MAAAC,EAAeC,EAAAA,eAGfC,uBACG,OAAA,OAAAC,EAAAH,EAAaI,cAAb,EAAAD,EAAsBD,mBAAoB,OAG7CG,uBACEC,EAAON,EAAaI,QACrB,IAAAE,SAAa,WAEZC,EAAQD,EAAKJ,wBACZK,EAASD,EAAKE,UAAUD,IAAU,KAAQ,cAI7C,oB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,EAAAE,IAAEU,SAAFZ,EAAAA,EAAcoC,eAGnBC,KACNC,yBACC3B,OAAS4B,QAAQD,IAElBE,yBACC7B,OAAS8B,KAAKD,kBAMrBpB,EAAI,GAAA,CAAA,EAAA,CAAAsB,QAAA,qBAAJtB,EAAIuB,GAAA3C,EAAAkB,IACQT,EAAQkC,GAAA,IAAA3C,EAAAE,IAARO,eADZW,UAFO,wBC1CD,MAAMwB,EAA+BC,EAAAA,oBAAoBC,EAAAA,8BAC7DC,WAAWC,GACXC,2DCOK,MAAAC,EAAWC,EAAAA,iBAAgB,IAAAC,EAAAnB,YAE3BoB,uBAAqB,MAA6B,aAA7B,OAAA9D,EAAA2D,EAAS1D,kBAAS8D,UACvCC,uBAAmB,MAA6B,WAA7B,OAAAhE,EAAA2D,EAAS1D,kBAAS8D,UACrCE,uBAAoB,MAA6B,YAA7B,OAAAjE,EAAA2D,EAAS1D,kBAAS8D,2HAqB1CG,cAAeP,EAAS1D,QACxB6D,gBAAAA,GACAE,cAAAA,GACAC,eAAAA,gCALCN,EAAS1D,SAAOkE,EAAAC,0BAlBb,qDCDA,MAAAC,EAAgB/D,IAChBgE,EAAY1E,IACZ2E,EAAa7E,IAEb8E,EAAmB,CACvBC,OAAS/B,UACP,OAAA1C,EAAAuE,EAAWlC,aAAUqC,kBAAkBhC,IAEzCiC,MAAQjC,UACN,OAAA1C,EAAAuE,EAAWlC,aAAUuC,cAAclC,IAErCmC,KAAI,CAAGnC,EAAoBoC,WACzB,OAAA9E,EAAAuE,EAAWlC,WAAXrC,EAAqB+E,aAAarC,EAAYoC,2EA2BlDE,eAAgBX,EAAcpE,QAC9BF,iBAAkBuE,EAAUvE,iBAC5ByE,kCA1BM"}
@@ -1 +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) {\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,GAAa;mBACR,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;;IAGK,IAAA,UAAU;mBACL,SAAA;AAAA,IACT;AAAA;AAEJ;;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L;;4CCpDA;;AAuBQ,QAAA,gBAAgB,iBAAgB;AAChC,QAAA,YAAY,kBAAiB;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;"}
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) {\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,GAAa;mBACR,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;;IAGK,IAAA,UAAU;mBACL,SAAA;AAAA,IACT;AAAA;AAEJ;;uCCzEA;;AASQ,QAAA,wBAAwB,yBAAwB;AAChD,QAAA,4BAA4B,6BAA4B;MAE1D,WAAW,EAAA,MAAgC,IAAI;MAC/C,UAAU,EAAA,MAA0D,IAAI;MACxE,a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AuB;;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;;;AA1BM;4CCtCR;;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;;;;AAlBb;ACdD,MAAM,+BAA+B,oBAAoBC,8BAA0B,EACvF,WAAW,UAAU,EACrB,MAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-document-manager",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -34,12 +34,12 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@embedpdf/models": "2.2.0"
37
+ "@embedpdf/models": "2.4.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/react": "^18.2.0",
41
41
  "typescript": "^5.0.0",
42
- "@embedpdf/core": "2.2.0",
42
+ "@embedpdf/core": "2.4.0",
43
43
  "@embedpdf/build": "1.1.0"
44
44
  },
45
45
  "peerDependencies": {
@@ -48,7 +48,7 @@
48
48
  "preact": "^10.26.4",
49
49
  "vue": ">=3.2.0",
50
50
  "svelte": ">=5 <6",
51
- "@embedpdf/core": "2.2.0"
51
+ "@embedpdf/core": "2.4.0"
52
52
  },
53
53
  "files": [
54
54
  "dist",