New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@embedpdf/core

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embedpdf/core - npm Package Compare versions

Comparing version
2.2.0
to
2.3.0
+1
-1
dist/svelte/index.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-registry.svelte.ts","../../src/svelte/hooks/use-plugin.svelte.ts","../../src/svelte/hooks/use-core-state.svelte.ts","../../src/lib/types/permissions.ts","../../src/lib/store/selectors.ts","../../src/svelte/components/NestedWrapper.svelte","../../src/svelte/components/AutoMount.svelte","../../src/svelte/components/EmbedPDF.svelte","../../src/svelte/hooks/use-capability.svelte.ts","../../src/svelte/hooks/use-document-permissions.svelte.ts","../../src/svelte/hooks/use-document-state.svelte.ts"],"sourcesContent":["import type { PluginRegistry, CoreState, DocumentState } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n coreState: CoreState | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n\n // Convenience accessors (always safe to use)\n activeDocumentId: string | null;\n activeDocument: DocumentState | null;\n documents: Record<string, DocumentState>;\n documentStates: DocumentState[];\n}\n\nexport const pdfContext = $state<PDFContextState>({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: [],\n});\n\n/**\n * Hook to access the PDF registry context.\n * @returns The PDF registry or null during initialization\n */\n\nexport const useRegistry = () => pdfContext;\n","import type { BasePlugin } from '@embedpdf/core';\nimport { pdfContext } from './use-registry.svelte.js';\n\n/**\n * Hook to access a plugin.\n * @param pluginId The ID of the plugin to access\n * @returns The plugin or null during initialization\n * @example\n * // Get zoom plugin\n * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']) {\n const { registry } = pdfContext;\n\n const state = $state({\n plugin: null as T | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n if (registry === null) {\n return state;\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n\n return state;\n}\n","import { useRegistry } from './use-registry.svelte';\n\n/**\n * Hook that provides access to the current core state.\n *\n * Note: This reads from the context which is already subscribed to core state changes\n * in the EmbedPDF component, so there's no additional subscription overhead.\n */\nexport function useCoreState() {\n const context = useRegistry();\n\n return {\n get current() {\n return context.coreState;\n },\n };\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\n\n/**\n * Human-readable permission names for use in configuration.\n */\nexport type PermissionName =\n | 'print'\n | 'modifyContents'\n | 'copyContents'\n | 'modifyAnnotations'\n | 'fillForms'\n | 'extractForAccessibility'\n | 'assembleDocument'\n | 'printHighQuality';\n\n/**\n * Map from human-readable names to PdfPermissionFlag values.\n */\nexport const PERMISSION_NAME_TO_FLAG: Record<PermissionName, PdfPermissionFlag> = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality,\n};\n\n/**\n * Permission overrides can use either numeric flags or human-readable string names.\n */\nexport type PermissionOverrides = Partial<\n Record<PdfPermissionFlag, boolean> & Record<PermissionName, boolean>\n>;\n\n/**\n * Configuration for overriding document permissions.\n * Can be applied globally (at PluginRegistry level) or per-document (when opening).\n */\nexport interface PermissionConfig {\n /**\n * When true (default): use PDF's permissions as the base, then apply overrides.\n * When false: treat document as having all permissions allowed, then apply overrides.\n */\n enforceDocumentPermissions?: boolean;\n\n /**\n * Explicit per-flag overrides. Supports both numeric flags and string names.\n * - true = force allow (even if PDF denies)\n * - false = force deny (even if PDF allows)\n * - undefined = use base permissions\n *\n * @example\n * // Using string names (recommended)\n * overrides: { print: false, modifyAnnotations: true }\n *\n * @example\n * // Using numeric flags\n * overrides: { [PdfPermissionFlag.Print]: false }\n */\n overrides?: PermissionOverrides;\n}\n\n/**\n * All permission flags for iteration when computing effective permissions.\n */\nexport const ALL_PERMISSION_FLAGS: PdfPermissionFlag[] = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality,\n];\n\n/**\n * All permission names for iteration.\n */\nexport const ALL_PERMISSION_NAMES: PermissionName[] = [\n 'print',\n 'modifyContents',\n 'copyContents',\n 'modifyAnnotations',\n 'fillForms',\n 'extractForAccessibility',\n 'assembleDocument',\n 'printHighQuality',\n];\n\n/**\n * Map from PdfPermissionFlag to human-readable name.\n */\nexport const PERMISSION_FLAG_TO_NAME: Record<PdfPermissionFlag, PermissionName> = {\n [PdfPermissionFlag.Print]: 'print',\n [PdfPermissionFlag.ModifyContents]: 'modifyContents',\n [PdfPermissionFlag.CopyContents]: 'copyContents',\n [PdfPermissionFlag.ModifyAnnotations]: 'modifyAnnotations',\n [PdfPermissionFlag.FillForms]: 'fillForms',\n [PdfPermissionFlag.ExtractForAccessibility]: 'extractForAccessibility',\n [PdfPermissionFlag.AssembleDocument]: 'assembleDocument',\n [PdfPermissionFlag.PrintHighQuality]: 'printHighQuality',\n};\n\n/**\n * Helper to get the override value for a permission flag, checking both numeric and string keys.\n */\nexport function getPermissionOverride(\n overrides: PermissionOverrides | undefined,\n flag: PdfPermissionFlag,\n): boolean | undefined {\n if (!overrides) return undefined;\n\n // Check numeric key first\n if (flag in overrides) {\n return (overrides as Record<PdfPermissionFlag, boolean>)[flag];\n }\n\n // Check string key\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return (overrides as Record<PermissionName, boolean>)[name];\n }\n\n return undefined;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { CoreState, DocumentState } from './initial-state';\nimport { ALL_PERMISSION_FLAGS, getPermissionOverride } from '../types/permissions';\n\n/**\n * Get the active document state\n */\nexport const getActiveDocumentState = (state: CoreState): DocumentState | null => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\n\n/**\n * Get document state by ID\n */\nexport const getDocumentState = (state: CoreState, documentId: string): DocumentState | null => {\n return state.documents[documentId] ?? null;\n};\n\n/**\n * Get all document IDs\n */\nexport const getDocumentIds = (state: CoreState): string[] => {\n return Object.keys(state.documents);\n};\n\n/**\n * Check if a document is loaded\n */\nexport const isDocumentLoaded = (state: CoreState, documentId: string): boolean => {\n return !!state.documents[documentId];\n};\n\n/**\n * Get the number of open documents\n */\nexport const getDocumentCount = (state: CoreState): number => {\n return Object.keys(state.documents).length;\n};\n\n// ─────────────────────────────────────────────────────────\n// Permission Selectors\n// ─────────────────────────────────────────────────────────\n\n/**\n * Check if a specific permission flag is effectively allowed for a document.\n * Applies layered resolution: per-document override → global override → enforceDocumentPermissions → PDF permission.\n *\n * @param state - The core state\n * @param documentId - The document ID to check permissions for\n * @param flag - The permission flag to check\n * @returns true if the permission is allowed, false otherwise\n */\nexport function getEffectivePermission(\n state: CoreState,\n documentId: string,\n flag: PdfPermissionFlag,\n): boolean {\n const docState = state.documents[documentId];\n const docConfig = docState?.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = docState?.document?.permissions ?? PdfPermissionFlag.AllowAll;\n\n // 1. Per-document override wins (supports both numeric and string keys)\n const docOverride = getPermissionOverride(docConfig?.overrides, flag);\n if (docOverride !== undefined) {\n return docOverride;\n }\n\n // 2. Global override (supports both numeric and string keys)\n const globalOverride = getPermissionOverride(globalConfig?.overrides, flag);\n if (globalOverride !== undefined) {\n return globalOverride;\n }\n\n // 3. Check enforce setting (per-doc takes precedence over global)\n const enforce =\n docConfig?.enforceDocumentPermissions ?? globalConfig?.enforceDocumentPermissions ?? true;\n\n if (!enforce) return true; // Not enforcing = allow all\n\n // 4. Use PDF permission\n return (pdfPermissions & flag) !== 0;\n}\n\n/**\n * Get all effective permissions as a bitmask for a document.\n * Combines all individual permission checks into a single bitmask.\n *\n * @param state - The core state\n * @param documentId - The document ID to get permissions for\n * @returns A bitmask of all effective permissions\n */\nexport function getEffectivePermissions(state: CoreState, documentId: string): number {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\n","<script lang=\"ts\">\n import { type Component, type Snippet } from 'svelte';\n import NestedWrapper from './NestedWrapper.svelte';\n\n interface Props {\n wrappers: Component[];\n children?: Snippet;\n }\n\n let { wrappers, children }: Props = $props();\n</script>\n\n{#if wrappers.length > 1}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n <NestedWrapper wrappers={wrappers.slice(1)}>\n {@render children?.()}\n </NestedWrapper>\n </Wrapper>\n{:else}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n {@render children?.()}\n </Wrapper>\n{/if}\n","<script lang=\"ts\">\n import { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\n import NestedWrapper from './NestedWrapper.svelte';\n import type { Snippet } from 'svelte';\n\n type Props = {\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: Snippet;\n };\n\n let { plugins, children }: Props = $props();\n let utilities: any[] = $state([]);\n let wrappers: any[] = $state([]);\n\n // recompute when plugins change\n $effect(() => {\n const nextUtilities: any[] = [];\n const nextWrappers: any[] = [];\n\n for (const reg of plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements?.() ?? [];\n for (const element of elements) {\n if (element.type === 'utility') {\n nextUtilities.push(element.component);\n } else if (element.type === 'wrapper') {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n\n utilities = nextUtilities;\n wrappers = nextWrappers;\n });\n</script>\n\n{#if wrappers.length > 0}\n <!-- wrap slot content inside all wrappers -->\n <NestedWrapper {wrappers} {children} />\n{:else}\n {@render children?.()}\n{/if}\n\n<!-- mount all utilities -->\n{#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n{/each}\n","<script lang=\"ts\">\n import type { Logger, PdfEngine } from '@embedpdf/models';\n import {\n type IPlugin,\n type PluginBatchRegistrations,\n type PluginRegistryConfig,\n PluginRegistry,\n } from '@embedpdf/core';\n import { type Snippet } from 'svelte';\n import AutoMount from './AutoMount.svelte';\n import { pdfContext, type PDFContextState } from '../hooks';\n\n export type { PluginBatchRegistrations };\n\n interface EmbedPDFProps {\n /**\n * The PDF engine to use for the PDF viewer.\n */\n engine: PdfEngine;\n /**\n * Registry configuration including logger, permissions, and defaults.\n */\n config?: PluginRegistryConfig;\n /**\n * @deprecated Use config.logger instead. Will be removed in next major version.\n */\n logger?: Logger;\n /**\n * The callback to call when the PDF viewer is initialized.\n */\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n /**\n * The plugins to use for the PDF viewer.\n */\n plugins: PluginBatchRegistrations;\n /**\n * The children to render for the PDF viewer.\n */\n children: Snippet<[PDFContextState]>;\n /**\n * Whether to auto-mount specific non-visual DOM elements from plugins.\n * @default true\n */\n autoMountDomElements?: boolean;\n }\n\n let {\n engine,\n config,\n logger,\n onInitialized,\n plugins,\n children,\n autoMountDomElements = true,\n }: EmbedPDFProps = $props();\n\n let latestInit = onInitialized;\n\n $effect(() => {\n if (onInitialized) {\n latestInit = onInitialized;\n }\n });\n\n $effect(() => {\n if (engine || (engine && plugins)) {\n // Merge deprecated logger prop into config (config.logger takes precedence)\n const finalConfig: PluginRegistryConfig = {\n ...config,\n logger: config?.logger ?? logger,\n };\n const reg = new PluginRegistry(engine, finalConfig);\n reg.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await reg.initialize();\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n return;\n }\n\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n // Only update if it's a core action and the core state changed\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n\n // Update convenience accessors\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument =\n activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder\n .map((docId) => documents[docId])\n .filter(\n (doc): doc is import('@embedpdf/core').DocumentState =>\n doc !== null && doc !== undefined,\n );\n }\n });\n\n /* always call the *latest* callback */\n await latestInit?.(reg);\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n\n // Provide the registry to children via context\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n\n return unsubscribe;\n };\n\n let cleanup: (() => void) | undefined;\n initialize()\n .then((unsub) => {\n cleanup = unsub;\n })\n .catch(console.error);\n\n return () => {\n cleanup?.();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n</script>\n\n{#if pdfContext.pluginsReady && autoMountDomElements}\n <AutoMount {plugins}>{@render children(pdfContext)}</AutoMount>\n{:else}\n {@render children(pdfContext)}\n{/if}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin.svelte.js';\n\n/**\n * Hook to access a plugin's capability.\n * @param pluginId The ID of the plugin to access\n * @returns The capability provided by the plugin or null during initialization\n * @example\n * // Get zoom capability\n * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function useCapability<T extends BasePlugin>(pluginId: T['id']) {\n const p = usePlugin<T>(pluginId);\n\n const state = $state({\n provides: null as ReturnType<NonNullable<T['provides']>> | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n // Use $effect to reactively update when plugin loads\n $effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n state.provides = p.plugin.provides() as ReturnType<NonNullable<T['provides']>>;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n\n return state;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { useCoreState } from './use-core-state.svelte';\nimport { getEffectivePermission, getEffectivePermissions } from '../../lib/store/selectors';\n\nexport interface DocumentPermissions {\n /** Effective permission flags after applying overrides */\n permissions: number;\n /** Raw PDF permission flags (before overrides) */\n pdfPermissions: number;\n /** Check if a specific permission flag is effectively allowed */\n hasPermission: (flag: PdfPermissionFlag) => boolean;\n /** Check if all specified flags are effectively allowed */\n hasAllPermissions: (...flags: PdfPermissionFlag[]) => boolean;\n\n // Shorthand booleans for all permission flags (using effective permissions):\n /** Can print (possibly degraded quality) */\n canPrint: boolean;\n /** Can modify document contents */\n canModifyContents: boolean;\n /** Can copy/extract text and graphics */\n canCopyContents: boolean;\n /** Can add/modify annotations and fill forms */\n canModifyAnnotations: boolean;\n /** Can fill in existing form fields */\n canFillForms: boolean;\n /** Can extract for accessibility */\n canExtractForAccessibility: boolean;\n /** Can assemble document (insert, rotate, delete pages) */\n canAssembleDocument: boolean;\n /** Can print high quality */\n canPrintHighQuality: boolean;\n}\n\n/**\n * Hook that provides reactive access to a document's effective permission flags.\n * Applies layered resolution: per-document override → global override → PDF permission.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns An object with reactive permission properties.\n */\nexport function useDocumentPermissions(getDocumentId: () => string): DocumentPermissions {\n const coreStateRef = useCoreState();\n\n const documentId = $derived(getDocumentId());\n const coreState = $derived(coreStateRef.current);\n\n const effectivePermissions = $derived(\n coreState ? getEffectivePermissions(coreState, documentId) : PdfPermissionFlag.AllowAll,\n );\n\n const pdfPermissions = $derived(\n coreState?.documents[documentId]?.document?.permissions ?? PdfPermissionFlag.AllowAll,\n );\n\n const hasPermission = (flag: PdfPermissionFlag) =>\n coreState ? getEffectivePermission(coreState, documentId, flag) : true;\n\n const hasAllPermissions = (...flags: PdfPermissionFlag[]) =>\n flags.every((flag) => (coreState ? getEffectivePermission(coreState, documentId, flag) : true));\n\n return {\n get permissions() {\n return effectivePermissions;\n },\n get pdfPermissions() {\n return pdfPermissions;\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.Print)\n : true;\n },\n get canModifyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyContents)\n : true;\n },\n get canCopyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.CopyContents)\n : true;\n },\n get canModifyAnnotations() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyAnnotations)\n : true;\n },\n get canFillForms() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.FillForms)\n : true;\n },\n get canExtractForAccessibility() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ExtractForAccessibility)\n : true;\n },\n get canAssembleDocument() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.AssembleDocument)\n : true;\n },\n get canPrintHighQuality() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.PrintHighQuality)\n : true;\n },\n };\n}\n","import { useCoreState } from './use-core-state.svelte';\n\n/**\n * Hook that provides reactive access to a specific document's state from the core store.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns The reactive DocumentState object or null if not found.\n */\nexport function useDocumentState(getDocumentId: () => string | null) {\n const coreStateRef = useCoreState();\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n const documentState = $derived(\n coreStateRef.current && documentId\n ? (coreStateRef.current.documents[documentId] ?? null)\n : null,\n );\n\n return {\n get current() {\n return documentState;\n },\n };\n}\n"],"names":["pdfContext","registry","coreState","isInitializing","pluginsReady","activeDocumentId","activeDocument","documents","documentStates","useRegistry","usePlugin","pluginId","state","plugin","isLoading","ready","Promise","getPlugin","Error","useCoreState","context","current","PdfPermissionFlag","Print","ModifyContents","CopyContents","ModifyAnnotations","FillForms","ExtractForAccessibility","AssembleDocument","PrintHighQuality","ALL_PERMISSION_FLAGS","PERMISSION_FLAG_TO_NAME","getPermissionOverride","overrides","flag","name","getEffectivePermission","documentId","docState","docConfig","permissions","globalConfig","globalPermissions","pdfPermissions","_a","document","AllowAll","docOverride","globalOverride","enforceDocumentPermissions","Wrapper","Wrapper_1","$$anchor","$0","$","derived","$$props","wrappers","slice","NestedWrapper","Wrapper_2","length","consequent","$$render","alternate","utilities","proxy","user_effect","nextUtilities","nextWrappers","reg","plugins","pkg","package","hasAutoMountElements","elements","autoMountElements","call","element","type","push","component","set","each","node_2","get","Utility","i","Utility_1","autoMountDomElements","latestInit","onInitialized","engine","finalConfig","logger","PluginRegistry","registerPluginBatch","cleanup","async","initialize","isDestroyed","store","getStore","getState","core","unsubscribe","subscribe","action","newState","oldState","isCoreAction","documentOrder","map","docId","filter","doc","then","unsub","catch","console","error","destroy","AutoMount","p","provides","getDocumentId","coreStateRef","effectivePermissions","reduce","acc","getEffectivePermissions","hasPermission","hasAllPermissions","flags","every","canPrint","canModifyContents","canCopyContents","canModifyAnnotations","canFillForms","canExtractForAccessibility","can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AkBK,UAEtE,EACI,8BAAAkH,gBACK3I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBM,wBAEtE,EACI,uBAAAkH,gBACK5I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBO,iBAEtE,EACI,uBAAAkH,gBACK7I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBQ,iBAEtE,EAEJ,oCCtGiCgG,GACzB,MAAAC,EAAe5G,IAGfmB,YAAsBwF,GAEtBkB,EAAAzF,EAAAC,QAAA,IACJuE,EAAa1G,eAAWiB,GACnByF,EAAa1G,QAAQd,UAAAgD,EAAA+B,IAAUhD,KAAe,KAC/C,aAIA,WAAAjB,gBACK2H,EACT,EAEJ"}
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-registry.svelte.ts","../../src/svelte/hooks/use-plugin.svelte.ts","../../src/svelte/hooks/use-core-state.svelte.ts","../../src/lib/types/permissions.ts","../../src/lib/store/selectors.ts","../../src/svelte/components/NestedWrapper.svelte","../../src/svelte/components/AutoMount.svelte","../../src/svelte/components/EmbedPDF.svelte","../../src/svelte/hooks/use-capability.svelte.ts","../../src/svelte/hooks/use-document-permissions.svelte.ts","../../src/svelte/hooks/use-document-state.svelte.ts"],"sourcesContent":["import type { PluginRegistry, CoreState, DocumentState } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n coreState: CoreState | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n\n // Convenience accessors (always safe to use)\n activeDocumentId: string | null;\n activeDocument: DocumentState | null;\n documents: Record<string, DocumentState>;\n documentStates: DocumentState[];\n}\n\nexport const pdfContext = $state<PDFContextState>({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: [],\n});\n\n/**\n * Hook to access the PDF registry context.\n * @returns The PDF registry or null during initialization\n */\n\nexport const useRegistry = () => pdfContext;\n","import type { BasePlugin } from '@embedpdf/core';\nimport { pdfContext } from './use-registry.svelte.js';\n\n/**\n * Hook to access a plugin.\n * @param pluginId The ID of the plugin to access\n * @returns The plugin or null during initialization\n * @example\n * // Get zoom plugin\n * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']) {\n const { registry } = pdfContext;\n\n const state = $state({\n plugin: null as T | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n if (registry === null) {\n return state;\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n\n return state;\n}\n","import { useRegistry } from './use-registry.svelte';\n\n/**\n * Hook that provides access to the current core state.\n *\n * Note: This reads from the context which is already subscribed to core state changes\n * in the EmbedPDF component, so there's no additional subscription overhead.\n */\nexport function useCoreState() {\n const context = useRegistry();\n\n return {\n get current() {\n return context.coreState;\n },\n };\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\n\n/**\n * Human-readable permission names for use in configuration.\n */\nexport type PermissionName =\n | 'print'\n | 'modifyContents'\n | 'copyContents'\n | 'modifyAnnotations'\n | 'fillForms'\n | 'extractForAccessibility'\n | 'assembleDocument'\n | 'printHighQuality';\n\n/**\n * Map from human-readable names to PdfPermissionFlag values.\n */\nexport const PERMISSION_NAME_TO_FLAG: Record<PermissionName, PdfPermissionFlag> = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality,\n};\n\n/**\n * Permission overrides can use either numeric flags or human-readable string names.\n */\nexport type PermissionOverrides = Partial<\n Record<PdfPermissionFlag, boolean> & Record<PermissionName, boolean>\n>;\n\n/**\n * Configuration for overriding document permissions.\n * Can be applied globally (at PluginRegistry level) or per-document (when opening).\n */\nexport interface PermissionConfig {\n /**\n * When true (default): use PDF's permissions as the base, then apply overrides.\n * When false: treat document as having all permissions allowed, then apply overrides.\n */\n enforceDocumentPermissions?: boolean;\n\n /**\n * Explicit per-flag overrides. Supports both numeric flags and string names.\n * - true = force allow (even if PDF denies)\n * - false = force deny (even if PDF allows)\n * - undefined = use base permissions\n *\n * @example\n * // Using string names (recommended)\n * overrides: { print: false, modifyAnnotations: true }\n *\n * @example\n * // Using numeric flags\n * overrides: { [PdfPermissionFlag.Print]: false }\n */\n overrides?: PermissionOverrides;\n}\n\n/**\n * All permission flags for iteration when computing effective permissions.\n */\nexport const ALL_PERMISSION_FLAGS: PdfPermissionFlag[] = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality,\n];\n\n/**\n * All permission names for iteration.\n */\nexport const ALL_PERMISSION_NAMES: PermissionName[] = [\n 'print',\n 'modifyContents',\n 'copyContents',\n 'modifyAnnotations',\n 'fillForms',\n 'extractForAccessibility',\n 'assembleDocument',\n 'printHighQuality',\n];\n\n/**\n * Map from PdfPermissionFlag to human-readable name.\n */\nexport const PERMISSION_FLAG_TO_NAME: Record<PdfPermissionFlag, PermissionName> = {\n [PdfPermissionFlag.Print]: 'print',\n [PdfPermissionFlag.ModifyContents]: 'modifyContents',\n [PdfPermissionFlag.CopyContents]: 'copyContents',\n [PdfPermissionFlag.ModifyAnnotations]: 'modifyAnnotations',\n [PdfPermissionFlag.FillForms]: 'fillForms',\n [PdfPermissionFlag.ExtractForAccessibility]: 'extractForAccessibility',\n [PdfPermissionFlag.AssembleDocument]: 'assembleDocument',\n [PdfPermissionFlag.PrintHighQuality]: 'printHighQuality',\n};\n\n/**\n * Helper to get the override value for a permission flag, checking both numeric and string keys.\n */\nexport function getPermissionOverride(\n overrides: PermissionOverrides | undefined,\n flag: PdfPermissionFlag,\n): boolean | undefined {\n if (!overrides) return undefined;\n\n // Check numeric key first\n if (flag in overrides) {\n return (overrides as Record<PdfPermissionFlag, boolean>)[flag];\n }\n\n // Check string key\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return (overrides as Record<PermissionName, boolean>)[name];\n }\n\n return undefined;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { CoreState, DocumentState } from './initial-state';\nimport { ALL_PERMISSION_FLAGS, getPermissionOverride } from '../types/permissions';\n\n/**\n * Get the active document state\n */\nexport const getActiveDocumentState = (state: CoreState): DocumentState | null => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\n\n/**\n * Get document state by ID\n */\nexport const getDocumentState = (state: CoreState, documentId: string): DocumentState | null => {\n return state.documents[documentId] ?? null;\n};\n\n/**\n * Get all document IDs\n */\nexport const getDocumentIds = (state: CoreState): string[] => {\n return Object.keys(state.documents);\n};\n\n/**\n * Check if a document is loaded\n */\nexport const isDocumentLoaded = (state: CoreState, documentId: string): boolean => {\n return !!state.documents[documentId];\n};\n\n/**\n * Get the number of open documents\n */\nexport const getDocumentCount = (state: CoreState): number => {\n return Object.keys(state.documents).length;\n};\n\n// ─────────────────────────────────────────────────────────\n// Permission Selectors\n// ─────────────────────────────────────────────────────────\n\n/**\n * Check if a specific permission flag is effectively allowed for a document.\n * Applies layered resolution: per-document override → global override → enforceDocumentPermissions → PDF permission.\n *\n * @param state - The core state\n * @param documentId - The document ID to check permissions for\n * @param flag - The permission flag to check\n * @returns true if the permission is allowed, false otherwise\n */\nexport function getEffectivePermission(\n state: CoreState,\n documentId: string,\n flag: PdfPermissionFlag,\n): boolean {\n const docState = state.documents[documentId];\n const docConfig = docState?.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = docState?.document?.permissions ?? PdfPermissionFlag.AllowAll;\n\n // 1. Per-document override wins (supports both numeric and string keys)\n const docOverride = getPermissionOverride(docConfig?.overrides, flag);\n if (docOverride !== undefined) {\n return docOverride;\n }\n\n // 2. Global override (supports both numeric and string keys)\n const globalOverride = getPermissionOverride(globalConfig?.overrides, flag);\n if (globalOverride !== undefined) {\n return globalOverride;\n }\n\n // 3. Check enforce setting (per-doc takes precedence over global)\n const enforce =\n docConfig?.enforceDocumentPermissions ?? globalConfig?.enforceDocumentPermissions ?? true;\n\n if (!enforce) return true; // Not enforcing = allow all\n\n // 4. Use PDF permission\n return (pdfPermissions & flag) !== 0;\n}\n\n/**\n * Get all effective permissions as a bitmask for a document.\n * Combines all individual permission checks into a single bitmask.\n *\n * @param state - The core state\n * @param documentId - The document ID to get permissions for\n * @returns A bitmask of all effective permissions\n */\nexport function getEffectivePermissions(state: CoreState, documentId: string): number {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\n","<script lang=\"ts\">\n import { type Component, type Snippet } from 'svelte';\n import NestedWrapper from './NestedWrapper.svelte';\n\n interface Props {\n wrappers: Component[];\n children?: Snippet;\n }\n\n let { wrappers, children }: Props = $props();\n</script>\n\n{#if wrappers.length > 1}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n <NestedWrapper wrappers={wrappers.slice(1)}>\n {@render children?.()}\n </NestedWrapper>\n </Wrapper>\n{:else}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n {@render children?.()}\n </Wrapper>\n{/if}\n","<script lang=\"ts\">\n import { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\n import NestedWrapper from './NestedWrapper.svelte';\n import type { Snippet } from 'svelte';\n\n type Props = {\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: Snippet;\n };\n\n let { plugins, children }: Props = $props();\n let utilities: any[] = $state([]);\n let wrappers: any[] = $state([]);\n\n // recompute when plugins change\n $effect(() => {\n const nextUtilities: any[] = [];\n const nextWrappers: any[] = [];\n\n for (const reg of plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements?.() ?? [];\n for (const element of elements) {\n if (element.type === 'utility') {\n nextUtilities.push(element.component);\n } else if (element.type === 'wrapper') {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n\n utilities = nextUtilities;\n wrappers = nextWrappers;\n });\n</script>\n\n{#if wrappers.length > 0}\n <!-- wrap slot content inside all wrappers -->\n <NestedWrapper {wrappers} {children} />\n{:else}\n {@render children?.()}\n{/if}\n\n<!-- mount all utilities -->\n{#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n{/each}\n","<script lang=\"ts\">\n import type { Logger, PdfEngine } from '@embedpdf/models';\n import {\n type IPlugin,\n type PluginBatchRegistrations,\n type PluginRegistryConfig,\n PluginRegistry,\n } from '@embedpdf/core';\n import { type Snippet } from 'svelte';\n import AutoMount from './AutoMount.svelte';\n import { pdfContext, type PDFContextState } from '../hooks';\n\n export type { PluginBatchRegistrations };\n\n interface EmbedPDFProps {\n /**\n * The PDF engine to use for the PDF viewer.\n */\n engine: PdfEngine;\n /**\n * Registry configuration including logger, permissions, and defaults.\n */\n config?: PluginRegistryConfig;\n /**\n * @deprecated Use config.logger instead. Will be removed in next major version.\n */\n logger?: Logger;\n /**\n * The callback to call when the PDF viewer is initialized.\n */\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n /**\n * The plugins to use for the PDF viewer.\n */\n plugins: PluginBatchRegistrations;\n /**\n * The children to render for the PDF viewer.\n */\n children: Snippet<[PDFContextState]>;\n /**\n * Whether to auto-mount specific non-visual DOM elements from plugins.\n * @default true\n */\n autoMountDomElements?: boolean;\n }\n\n let {\n engine,\n config,\n logger,\n onInitialized,\n plugins,\n children,\n autoMountDomElements = true,\n }: EmbedPDFProps = $props();\n\n let latestInit = onInitialized;\n\n $effect(() => {\n if (onInitialized) {\n latestInit = onInitialized;\n }\n });\n\n $effect(() => {\n if (engine || (engine && plugins)) {\n // Merge deprecated logger prop into config (config.logger takes precedence)\n const finalConfig: PluginRegistryConfig = {\n ...config,\n logger: config?.logger ?? logger,\n };\n const reg = new PluginRegistry(engine, finalConfig);\n reg.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await reg.initialize();\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n return;\n }\n\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n // Only update if it's a core action and the core state changed\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n\n // Update convenience accessors\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument =\n activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder\n .map((docId) => documents[docId])\n .filter(\n (doc): doc is import('@embedpdf/core').DocumentState =>\n doc !== null && doc !== undefined,\n );\n }\n });\n\n /* always call the *latest* callback */\n await latestInit?.(reg);\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n\n // Provide the registry to children via context\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n\n return unsubscribe;\n };\n\n let cleanup: (() => void) | undefined;\n initialize()\n .then((unsub) => {\n cleanup = unsub;\n })\n .catch(console.error);\n\n return () => {\n cleanup?.();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n</script>\n\n{#if pdfContext.pluginsReady && autoMountDomElements}\n <AutoMount {plugins}>{@render children(pdfContext)}</AutoMount>\n{:else}\n {@render children(pdfContext)}\n{/if}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin.svelte.js';\n\n/**\n * Hook to access a plugin's capability.\n * @param pluginId The ID of the plugin to access\n * @returns The capability provided by the plugin or null during initialization\n * @example\n * // Get zoom capability\n * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function useCapability<T extends BasePlugin>(pluginId: T['id']) {\n const p = usePlugin<T>(pluginId);\n\n const state = $state({\n provides: null as ReturnType<NonNullable<T['provides']>> | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n // Use $effect to reactively update when plugin loads\n $effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n state.provides = p.plugin.provides() as ReturnType<NonNullable<T['provides']>>;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n\n return state;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { useCoreState } from './use-core-state.svelte';\nimport { getEffectivePermission, getEffectivePermissions } from '../../lib/store/selectors';\n\nexport interface DocumentPermissions {\n /** Effective permission flags after applying overrides */\n permissions: number;\n /** Raw PDF permission flags (before overrides) */\n pdfPermissions: number;\n /** Check if a specific permission flag is effectively allowed */\n hasPermission: (flag: PdfPermissionFlag) => boolean;\n /** Check if all specified flags are effectively allowed */\n hasAllPermissions: (...flags: PdfPermissionFlag[]) => boolean;\n\n // Shorthand booleans for all permission flags (using effective permissions):\n /** Can print (possibly degraded quality) */\n canPrint: boolean;\n /** Can modify document contents */\n canModifyContents: boolean;\n /** Can copy/extract text and graphics */\n canCopyContents: boolean;\n /** Can add/modify annotations and fill forms */\n canModifyAnnotations: boolean;\n /** Can fill in existing form fields */\n canFillForms: boolean;\n /** Can extract for accessibility */\n canExtractForAccessibility: boolean;\n /** Can assemble document (insert, rotate, delete pages) */\n canAssembleDocument: boolean;\n /** Can print high quality */\n canPrintHighQuality: boolean;\n}\n\n/**\n * Hook that provides reactive access to a document's effective permission flags.\n * Applies layered resolution: per-document override → global override → PDF permission.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns An object with reactive permission properties.\n */\nexport function useDocumentPermissions(getDocumentId: () => string): DocumentPermissions {\n const coreStateRef = useCoreState();\n\n const documentId = $derived(getDocumentId());\n const coreState = $derived(coreStateRef.current);\n\n const effectivePermissions = $derived(\n coreState ? getEffectivePermissions(coreState, documentId) : PdfPermissionFlag.AllowAll,\n );\n\n const pdfPermissions = $derived(\n coreState?.documents[documentId]?.document?.permissions ?? PdfPermissionFlag.AllowAll,\n );\n\n const hasPermission = (flag: PdfPermissionFlag) =>\n coreState ? getEffectivePermission(coreState, documentId, flag) : true;\n\n const hasAllPermissions = (...flags: PdfPermissionFlag[]) =>\n flags.every((flag) => (coreState ? getEffectivePermission(coreState, documentId, flag) : true));\n\n return {\n get permissions() {\n return effectivePermissions;\n },\n get pdfPermissions() {\n return pdfPermissions;\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.Print)\n : true;\n },\n get canModifyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyContents)\n : true;\n },\n get canCopyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.CopyContents)\n : true;\n },\n get canModifyAnnotations() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyAnnotations)\n : true;\n },\n get canFillForms() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.FillForms)\n : true;\n },\n get canExtractForAccessibility() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ExtractForAccessibility)\n : true;\n },\n get canAssembleDocument() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.AssembleDocument)\n : true;\n },\n get canPrintHighQuality() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.PrintHighQuality)\n : true;\n },\n };\n}\n","import { useCoreState } from './use-core-state.svelte';\n\n/**\n * Hook that provides reactive access to a specific document's state from the core store.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns The reactive DocumentState object or null if not found.\n */\nexport function useDocumentState(getDocumentId: () => string | null) {\n const coreStateRef = useCoreState();\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n const documentState = $derived(\n coreStateRef.current && documentId\n ? (coreStateRef.current.documents[documentId] ?? null)\n : null,\n );\n\n return {\n get current() {\n return documentState;\n },\n };\n}\n"],"names":["pdfContext","registry","coreState","isInitializing","pluginsReady","activeDocumentId","activeDocument","documents","documentStates","useRegistry","usePlugin","pluginId","state","plugin","isLoading","ready","Promise","getPlugin","Error","useCoreState","context","current","PdfPermissionFlag","Print","ModifyContents","CopyContents","ModifyAnnotations","FillForms","ExtractForAccessibility","AssembleDocument","PrintHighQuality","ALL_PERMISSION_FLAGS","PERMISSION_FLAG_TO_NAME","getPermissionOverride","overrides","flag","name","getEffectivePermission","documentId","docState","docConfig","permissions","globalConfig","globalPermissions","pdfPermissions","_a","document","AllowAll","docOverride","globalOverride","enforceDocumentPermissions","Wrapper","Wrapper_1","$$anchor","$0","$","derived","$$props","wrappers","slice","NestedWrapper","Wrapper_2","length","consequent","$$render","alternate","utilities","proxy","user_effect","nextUtilities","nextWrappers","reg","plugins","pkg","package","hasAutoMountElements","elements","autoMountElements","call","element","type","push","component","set","each","node_2","get","Utility","i","Utility_1","autoMountDomElements","latestInit","onInitialized","engine","finalConfig","logger","PluginRegistry","registerPluginBatch","cleanup","async","initialize","isDestroyed","store","getStore","getState","core","unsubscribe","subscribe","action","newState","oldState","isCoreAction","documentOrder","map","docId","filter","doc","then","unsub","catch","console","error","destroy","AutoMount","p","provides","getDocumentId","coreStateRef","effectivePermissions","reduce","acc","getEffectivePermissions","hasPermission","hasAllPermissions","flags","every","canPrint","canModifyContents","canCopyContents","canModifyAnnotations","canFillForms","canExtractForAccessibility","canAssembleDocument","canPrintHighQuality","documentState"],"mappings":"8fAeaA,WACXC,SAAU,KACVC,UAAW,KACXC,gBAAgB,EAChBC,cAAc,EACdC,iBAAkB,KAClBC,eAAgB,KAChBC,aACAC,oBAQWC,MAAoBT,WCpBjBU,EAAgCC,GACtC,MAAAV,SAAAA,GAAaD,EAEfY,WACJC,OAAQ,KACRC,WAAW,EACXC,MAAA,IAAWC,QAAA,aAGI,OAAbf,SACKW,EAGH,MAAAC,EAASZ,EAASgB,UAAaN,GAEhC,IAAAE,EACO,MAAA,IAAAK,gBAAgBP,sBAG5BC,EAAMC,OAASA,EACfD,EAAME,WAAY,EAClBF,EAAMG,MAAQF,EAAOE,QAEdH,CACT,CC3BgB,SAAAO,IACR,MAAAC,EAAUX,WAGV,WAAAY,GACK,OAAAD,EAAQlB,SACjB,EAEJ,CCGSoB,EAAAA,kBAAkBC,MACTD,EAAAA,kBAAkBE,eACpBF,EAAAA,kBAAkBG,aACbH,EAAAA,kBAAkBI,kBAC1BJ,EAAAA,kBAAkBK,UACJL,EAAAA,kBAAkBM,wBACzBN,EAAAA,kBAAkBO,iBAClBP,EAAAA,kBAAkBQ,iBAyC/B,MAAMC,EAA4C,CACvDT,EAAAA,kBAAkBC,MAClBD,EAAAA,kBAAkBE,eAClBF,EAAAA,kBAAkBG,aAClBH,EAAAA,kBAAkBI,kBAClBJ,EAAAA,kBAAkBK,UAClBL,EAAAA,kBAAkBM,wBAClBN,EAAAA,kBAAkBO,iBAClBP,oBAAkBQ,kBAoBPE,EAAqE,CAChF,CAACV,EAAAA,kB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BACKxI,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBG,aAEtE,EACI,wBAAAkH,gBACKzI,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBI,kBAEtE,EACI,gBAAAkH,gBACK1I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBK,UAEtE,EACI,8BAAAkH,gBACK3I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBM,wBAEtE,EACI,uBAAAkH,gBACK5I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBO,iBAEtE,EACI,uBAAAkH,gBACK7I,IACHmC,QAAuBnC,GAAAqD,EAAA+B,IAAWhD,GAAYhB,EAAAA,kBAAkBQ,iBAEtE,EAEJ,oCCtGiCgG,GACzB,MAAAC,EAAe5G,IAGfmB,YAAsBwF,GAEtBkB,EAAAzF,EAAAC,QAAA,IACJuE,EAAa1G,eAAWiB,GACnByF,EAAa1G,QAAQd,UAAAgD,EAAA+B,IAAUhD,KAAe,KAC/C,aAIA,WAAAjB,gBACK2H,EACT,EAEJ"}

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-registry.svelte.ts","../../src/svelte/hooks/use-plugin.svelte.ts","../../src/svelte/hooks/use-capability.svelte.ts","../../src/svelte/hooks/use-core-state.svelte.ts","../../src/svelte/hooks/use-document-state.svelte.ts","../../src/lib/types/permissions.ts","../../src/lib/store/selectors.ts","../../src/svelte/hooks/use-document-permissions.svelte.ts","../../src/svelte/components/NestedWrapper.svelte","../../src/svelte/components/AutoMount.svelte","../../src/svelte/components/EmbedPDF.svelte"],"sourcesContent":["import type { PluginRegistry, CoreState, DocumentState } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n coreState: CoreState | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n\n // Convenience accessors (always safe to use)\n activeDocumentId: string | null;\n activeDocument: DocumentState | null;\n documents: Record<string, DocumentState>;\n documentStates: DocumentState[];\n}\n\nexport const pdfContext = $state<PDFContextState>({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: [],\n});\n\n/**\n * Hook to access the PDF registry context.\n * @returns The PDF registry or null during initialization\n */\n\nexport const useRegistry = () => pdfContext;\n","import type { BasePlugin } from '@embedpdf/core';\nimport { pdfContext } from './use-registry.svelte.js';\n\n/**\n * Hook to access a plugin.\n * @param pluginId The ID of the plugin to access\n * @returns The plugin or null during initialization\n * @example\n * // Get zoom plugin\n * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']) {\n const { registry } = pdfContext;\n\n const state = $state({\n plugin: null as T | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n if (registry === null) {\n return state;\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n\n return state;\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin.svelte.js';\n\n/**\n * Hook to access a plugin's capability.\n * @param pluginId The ID of the plugin to access\n * @returns The capability provided by the plugin or null during initialization\n * @example\n * // Get zoom capability\n * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function useCapability<T extends BasePlugin>(pluginId: T['id']) {\n const p = usePlugin<T>(pluginId);\n\n const state = $state({\n provides: null as ReturnType<NonNullable<T['provides']>> | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n // Use $effect to reactively update when plugin loads\n $effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n state.provides = p.plugin.provides() as ReturnType<NonNullable<T['provides']>>;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n\n return state;\n}\n","import { useRegistry } from './use-registry.svelte';\n\n/**\n * Hook that provides access to the current core state.\n *\n * Note: This reads from the context which is already subscribed to core state changes\n * in the EmbedPDF component, so there's no additional subscription overhead.\n */\nexport function useCoreState() {\n const context = useRegistry();\n\n return {\n get current() {\n return context.coreState;\n },\n };\n}\n","import { useCoreState } from './use-core-state.svelte';\n\n/**\n * Hook that provides reactive access to a specific document's state from the core store.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns The reactive DocumentState object or null if not found.\n */\nexport function useDocumentState(getDocumentId: () => string | null) {\n const coreStateRef = useCoreState();\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n const documentState = $derived(\n coreStateRef.current && documentId\n ? (coreStateRef.current.documents[documentId] ?? null)\n : null,\n );\n\n return {\n get current() {\n return documentState;\n },\n };\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\n\n/**\n * Human-readable permission names for use in configuration.\n */\nexport type PermissionName =\n | 'print'\n | 'modifyContents'\n | 'copyContents'\n | 'modifyAnnotations'\n | 'fillForms'\n | 'extractForAccessibility'\n | 'assembleDocument'\n | 'printHighQuality';\n\n/**\n * Map from human-readable names to PdfPermissionFlag values.\n */\nexport const PERMISSION_NAME_TO_FLAG: Record<PermissionName, PdfPermissionFlag> = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality,\n};\n\n/**\n * Permission overrides can use either numeric flags or human-readable string names.\n */\nexport type PermissionOverrides = Partial<\n Record<PdfPermissionFlag, boolean> & Record<PermissionName, boolean>\n>;\n\n/**\n * Configuration for overriding document permissions.\n * Can be applied globally (at PluginRegistry level) or per-document (when opening).\n */\nexport interface PermissionConfig {\n /**\n * When true (default): use PDF's permissions as the base, then apply overrides.\n * When false: treat document as having all permissions allowed, then apply overrides.\n */\n enforceDocumentPermissions?: boolean;\n\n /**\n * Explicit per-flag overrides. Supports both numeric flags and string names.\n * - true = force allow (even if PDF denies)\n * - false = force deny (even if PDF allows)\n * - undefined = use base permissions\n *\n * @example\n * // Using string names (recommended)\n * overrides: { print: false, modifyAnnotations: true }\n *\n * @example\n * // Using numeric flags\n * overrides: { [PdfPermissionFlag.Print]: false }\n */\n overrides?: PermissionOverrides;\n}\n\n/**\n * All permission flags for iteration when computing effective permissions.\n */\nexport const ALL_PERMISSION_FLAGS: PdfPermissionFlag[] = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality,\n];\n\n/**\n * All permission names for iteration.\n */\nexport const ALL_PERMISSION_NAMES: PermissionName[] = [\n 'print',\n 'modifyContents',\n 'copyContents',\n 'modifyAnnotations',\n 'fillForms',\n 'extractForAccessibility',\n 'assembleDocument',\n 'printHighQuality',\n];\n\n/**\n * Map from PdfPermissionFlag to human-readable name.\n */\nexport const PERMISSION_FLAG_TO_NAME: Record<PdfPermissionFlag, PermissionName> = {\n [PdfPermissionFlag.Print]: 'print',\n [PdfPermissionFlag.ModifyContents]: 'modifyContents',\n [PdfPermissionFlag.CopyContents]: 'copyContents',\n [PdfPermissionFlag.ModifyAnnotations]: 'modifyAnnotations',\n [PdfPermissionFlag.FillForms]: 'fillForms',\n [PdfPermissionFlag.ExtractForAccessibility]: 'extractForAccessibility',\n [PdfPermissionFlag.AssembleDocument]: 'assembleDocument',\n [PdfPermissionFlag.PrintHighQuality]: 'printHighQuality',\n};\n\n/**\n * Helper to get the override value for a permission flag, checking both numeric and string keys.\n */\nexport function getPermissionOverride(\n overrides: PermissionOverrides | undefined,\n flag: PdfPermissionFlag,\n): boolean | undefined {\n if (!overrides) return undefined;\n\n // Check numeric key first\n if (flag in overrides) {\n return (overrides as Record<PdfPermissionFlag, boolean>)[flag];\n }\n\n // Check string key\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return (overrides as Record<PermissionName, boolean>)[name];\n }\n\n return undefined;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { CoreState, DocumentState } from './initial-state';\nimport { ALL_PERMISSION_FLAGS, getPermissionOverride } from '../types/permissions';\n\n/**\n * Get the active document state\n */\nexport const getActiveDocumentState = (state: CoreState): DocumentState | null => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\n\n/**\n * Get document state by ID\n */\nexport const getDocumentState = (state: CoreState, documentId: string): DocumentState | null => {\n return state.documents[documentId] ?? null;\n};\n\n/**\n * Get all document IDs\n */\nexport const getDocumentIds = (state: CoreState): string[] => {\n return Object.keys(state.documents);\n};\n\n/**\n * Check if a document is loaded\n */\nexport const isDocumentLoaded = (state: CoreState, documentId: string): boolean => {\n return !!state.documents[documentId];\n};\n\n/**\n * Get the number of open documents\n */\nexport const getDocumentCount = (state: CoreState): number => {\n return Object.keys(state.documents).length;\n};\n\n// ─────────────────────────────────────────────────────────\n// Permission Selectors\n// ─────────────────────────────────────────────────────────\n\n/**\n * Check if a specific permission flag is effectively allowed for a document.\n * Applies layered resolution: per-document override → global override → enforceDocumentPermissions → PDF permission.\n *\n * @param state - The core state\n * @param documentId - The document ID to check permissions for\n * @param flag - The permission flag to check\n * @returns true if the permission is allowed, false otherwise\n */\nexport function getEffectivePermission(\n state: CoreState,\n documentId: string,\n flag: PdfPermissionFlag,\n): boolean {\n const docState = state.documents[documentId];\n const docConfig = docState?.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = docState?.document?.permissions ?? PdfPermissionFlag.AllowAll;\n\n // 1. Per-document override wins (supports both numeric and string keys)\n const docOverride = getPermissionOverride(docConfig?.overrides, flag);\n if (docOverride !== undefined) {\n return docOverride;\n }\n\n // 2. Global override (supports both numeric and string keys)\n const globalOverride = getPermissionOverride(globalConfig?.overrides, flag);\n if (globalOverride !== undefined) {\n return globalOverride;\n }\n\n // 3. Check enforce setting (per-doc takes precedence over global)\n const enforce =\n docConfig?.enforceDocumentPermissions ?? globalConfig?.enforceDocumentPermissions ?? true;\n\n if (!enforce) return true; // Not enforcing = allow all\n\n // 4. Use PDF permission\n return (pdfPermissions & flag) !== 0;\n}\n\n/**\n * Get all effective permissions as a bitmask for a document.\n * Combines all individual permission checks into a single bitmask.\n *\n * @param state - The core state\n * @param documentId - The document ID to get permissions for\n * @returns A bitmask of all effective permissions\n */\nexport function getEffectivePermissions(state: CoreState, documentId: string): number {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { useCoreState } from './use-core-state.svelte';\nimport { getEffectivePermission, getEffectivePermissions } from '../../lib/store/selectors';\n\nexport interface DocumentPermissions {\n /** Effective permission flags after applying overrides */\n permissions: number;\n /** Raw PDF permission flags (before overrides) */\n pdfPermissions: number;\n /** Check if a specific permission flag is effectively allowed */\n hasPermission: (flag: PdfPermissionFlag) => boolean;\n /** Check if all specified flags are effectively allowed */\n hasAllPermissions: (...flags: PdfPermissionFlag[]) => boolean;\n\n // Shorthand booleans for all permission flags (using effective permissions):\n /** Can print (possibly degraded quality) */\n canPrint: boolean;\n /** Can modify document contents */\n canModifyContents: boolean;\n /** Can copy/extract text and graphics */\n canCopyContents: boolean;\n /** Can add/modify annotations and fill forms */\n canModifyAnnotations: boolean;\n /** Can fill in existing form fields */\n canFillForms: boolean;\n /** Can extract for accessibility */\n canExtractForAccessibility: boolean;\n /** Can assemble document (insert, rotate, delete pages) */\n canAssembleDocument: boolean;\n /** Can print high quality */\n canPrintHighQuality: boolean;\n}\n\n/**\n * Hook that provides reactive access to a document's effective permission flags.\n * Applies layered resolution: per-document override → global override → PDF permission.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns An object with reactive permission properties.\n */\nexport function useDocumentPermissions(getDocumentId: () => string): DocumentPermissions {\n const coreStateRef = useCoreState();\n\n const documentId = $derived(getDocumentId());\n const coreState = $derived(coreStateRef.current);\n\n const effectivePermissions = $derived(\n coreState ? getEffectivePermissions(coreState, documentId) : PdfPermissionFlag.AllowAll,\n );\n\n const pdfPermissions = $derived(\n coreState?.documents[documentId]?.document?.permissions ?? PdfPermissionFlag.AllowAll,\n );\n\n const hasPermission = (flag: PdfPermissionFlag) =>\n coreState ? getEffectivePermission(coreState, documentId, flag) : true;\n\n const hasAllPermissions = (...flags: PdfPermissionFlag[]) =>\n flags.every((flag) => (coreState ? getEffectivePermission(coreState, documentId, flag) : true));\n\n return {\n get permissions() {\n return effectivePermissions;\n },\n get pdfPermissions() {\n return pdfPermissions;\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.Print)\n : true;\n },\n get canModifyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyContents)\n : true;\n },\n get canCopyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.CopyContents)\n : true;\n },\n get canModifyAnnotations() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyAnnotations)\n : true;\n },\n get canFillForms() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.FillForms)\n : true;\n },\n get canExtractForAccessibility() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ExtractForAccessibility)\n : true;\n },\n get canAssembleDocument() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.AssembleDocument)\n : true;\n },\n get canPrintHighQuality() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.PrintHighQuality)\n : true;\n },\n };\n}\n","<script lang=\"ts\">\n import { type Component, type Snippet } from 'svelte';\n import NestedWrapper from './NestedWrapper.svelte';\n\n interface Props {\n wrappers: Component[];\n children?: Snippet;\n }\n\n let { wrappers, children }: Props = $props();\n</script>\n\n{#if wrappers.length > 1}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n <NestedWrapper wrappers={wrappers.slice(1)}>\n {@render children?.()}\n </NestedWrapper>\n </Wrapper>\n{:else}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n {@render children?.()}\n </Wrapper>\n{/if}\n","<script lang=\"ts\">\n import { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\n import NestedWrapper from './NestedWrapper.svelte';\n import type { Snippet } from 'svelte';\n\n type Props = {\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: Snippet;\n };\n\n let { plugins, children }: Props = $props();\n let utilities: any[] = $state([]);\n let wrappers: any[] = $state([]);\n\n // recompute when plugins change\n $effect(() => {\n const nextUtilities: any[] = [];\n const nextWrappers: any[] = [];\n\n for (const reg of plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements?.() ?? [];\n for (const element of elements) {\n if (element.type === 'utility') {\n nextUtilities.push(element.component);\n } else if (element.type === 'wrapper') {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n\n utilities = nextUtilities;\n wrappers = nextWrappers;\n });\n</script>\n\n{#if wrappers.length > 0}\n <!-- wrap slot content inside all wrappers -->\n <NestedWrapper {wrappers} {children} />\n{:else}\n {@render children?.()}\n{/if}\n\n<!-- mount all utilities -->\n{#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n{/each}\n","<script lang=\"ts\">\n import type { Logger, PdfEngine } from '@embedpdf/models';\n import {\n type IPlugin,\n type PluginBatchRegistrations,\n type PluginRegistryConfig,\n PluginRegistry,\n } from '@embedpdf/core';\n import { type Snippet } from 'svelte';\n import AutoMount from './AutoMount.svelte';\n import { pdfContext, type PDFContextState } from '../hooks';\n\n export type { PluginBatchRegistrations };\n\n interface EmbedPDFProps {\n /**\n * The PDF engine to use for the PDF viewer.\n */\n engine: PdfEngine;\n /**\n * Registry configuration including logger, permissions, and defaults.\n */\n config?: PluginRegistryConfig;\n /**\n * @deprecated Use config.logger instead. Will be removed in next major version.\n */\n logger?: Logger;\n /**\n * The callback to call when the PDF viewer is initialized.\n */\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n /**\n * The plugins to use for the PDF viewer.\n */\n plugins: PluginBatchRegistrations;\n /**\n * The children to render for the PDF viewer.\n */\n children: Snippet<[PDFContextState]>;\n /**\n * Whether to auto-mount specific non-visual DOM elements from plugins.\n * @default true\n */\n autoMountDomElements?: boolean;\n }\n\n let {\n engine,\n config,\n logger,\n onInitialized,\n plugins,\n children,\n autoMountDomElements = true,\n }: EmbedPDFProps = $props();\n\n let latestInit = onInitialized;\n\n $effect(() => {\n if (onInitialized) {\n latestInit = onInitialized;\n }\n });\n\n $effect(() => {\n if (engine || (engine && plugins)) {\n // Merge deprecated logger prop into config (config.logger takes precedence)\n const finalConfig: PluginRegistryConfig = {\n ...config,\n logger: config?.logger ?? logger,\n };\n const reg = new PluginRegistry(engine, finalConfig);\n reg.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await reg.initialize();\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n return;\n }\n\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n // Only update if it's a core action and the core state changed\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n\n // Update convenience accessors\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument =\n activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder\n .map((docId) => documents[docId])\n .filter(\n (doc): doc is import('@embedpdf/core').DocumentState =>\n doc !== null && doc !== undefined,\n );\n }\n });\n\n /* always call the *latest* callback */\n await latestInit?.(reg);\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n\n // Provide the registry to children via context\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n\n return unsubscribe;\n };\n\n let cleanup: (() => void) | undefined;\n initialize()\n .then((unsub) => {\n cleanup = unsub;\n })\n .catch(console.error);\n\n return () => {\n cleanup?.();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n</script>\n\n{#if pdfContext.pluginsReady && autoMountDomElements}\n <AutoMount {plugins}>{@render children(pdfContext)}</AutoMount>\n{:else}\n {@render children(pdfContext)}\n{/if}\n"],"names":["$$anchor","NestedWrapper"],"mappings":";;;;MAea;EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB;EACA;;AAQW,MAAA,oBAAoB;SCpBjB,UAAgC,UAAmB;AACzD,QAAA,EAAA,aAAa;AAEf,QAAA,kBACJ,QAAQ,MACR,WAAW,MACX,OAAA,IAAW,QAAA,MAAoB;AAAA,EAAA,CAAE,EAAA,CAAA;MAG/B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AA,UAAA,UAAA,WAAA,KAAA;AAAA;;;;AAFpD;"}
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-registry.svelte.ts","../../src/svelte/hooks/use-plugin.svelte.ts","../../src/svelte/hooks/use-capability.svelte.ts","../../src/svelte/hooks/use-core-state.svelte.ts","../../src/svelte/hooks/use-document-state.svelte.ts","../../src/lib/types/permissions.ts","../../src/lib/store/selectors.ts","../../src/svelte/hooks/use-document-permissions.svelte.ts","../../src/svelte/components/NestedWrapper.svelte","../../src/svelte/components/AutoMount.svelte","../../src/svelte/components/EmbedPDF.svelte"],"sourcesContent":["import type { PluginRegistry, CoreState, DocumentState } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n coreState: CoreState | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n\n // Convenience accessors (always safe to use)\n activeDocumentId: string | null;\n activeDocument: DocumentState | null;\n documents: Record<string, DocumentState>;\n documentStates: DocumentState[];\n}\n\nexport const pdfContext = $state<PDFContextState>({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: [],\n});\n\n/**\n * Hook to access the PDF registry context.\n * @returns The PDF registry or null during initialization\n */\n\nexport const useRegistry = () => pdfContext;\n","import type { BasePlugin } from '@embedpdf/core';\nimport { pdfContext } from './use-registry.svelte.js';\n\n/**\n * Hook to access a plugin.\n * @param pluginId The ID of the plugin to access\n * @returns The plugin or null during initialization\n * @example\n * // Get zoom plugin\n * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']) {\n const { registry } = pdfContext;\n\n const state = $state({\n plugin: null as T | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n if (registry === null) {\n return state;\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n\n return state;\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin.svelte.js';\n\n/**\n * Hook to access a plugin's capability.\n * @param pluginId The ID of the plugin to access\n * @returns The capability provided by the plugin or null during initialization\n * @example\n * // Get zoom capability\n * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function useCapability<T extends BasePlugin>(pluginId: T['id']) {\n const p = usePlugin<T>(pluginId);\n\n const state = $state({\n provides: null as ReturnType<NonNullable<T['provides']>> | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n // Use $effect to reactively update when plugin loads\n $effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n state.provides = p.plugin.provides() as ReturnType<NonNullable<T['provides']>>;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n\n return state;\n}\n","import { useRegistry } from './use-registry.svelte';\n\n/**\n * Hook that provides access to the current core state.\n *\n * Note: This reads from the context which is already subscribed to core state changes\n * in the EmbedPDF component, so there's no additional subscription overhead.\n */\nexport function useCoreState() {\n const context = useRegistry();\n\n return {\n get current() {\n return context.coreState;\n },\n };\n}\n","import { useCoreState } from './use-core-state.svelte';\n\n/**\n * Hook that provides reactive access to a specific document's state from the core store.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns The reactive DocumentState object or null if not found.\n */\nexport function useDocumentState(getDocumentId: () => string | null) {\n const coreStateRef = useCoreState();\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n const documentState = $derived(\n coreStateRef.current && documentId\n ? (coreStateRef.current.documents[documentId] ?? null)\n : null,\n );\n\n return {\n get current() {\n return documentState;\n },\n };\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\n\n/**\n * Human-readable permission names for use in configuration.\n */\nexport type PermissionName =\n | 'print'\n | 'modifyContents'\n | 'copyContents'\n | 'modifyAnnotations'\n | 'fillForms'\n | 'extractForAccessibility'\n | 'assembleDocument'\n | 'printHighQuality';\n\n/**\n * Map from human-readable names to PdfPermissionFlag values.\n */\nexport const PERMISSION_NAME_TO_FLAG: Record<PermissionName, PdfPermissionFlag> = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality,\n};\n\n/**\n * Permission overrides can use either numeric flags or human-readable string names.\n */\nexport type PermissionOverrides = Partial<\n Record<PdfPermissionFlag, boolean> & Record<PermissionName, boolean>\n>;\n\n/**\n * Configuration for overriding document permissions.\n * Can be applied globally (at PluginRegistry level) or per-document (when opening).\n */\nexport interface PermissionConfig {\n /**\n * When true (default): use PDF's permissions as the base, then apply overrides.\n * When false: treat document as having all permissions allowed, then apply overrides.\n */\n enforceDocumentPermissions?: boolean;\n\n /**\n * Explicit per-flag overrides. Supports both numeric flags and string names.\n * - true = force allow (even if PDF denies)\n * - false = force deny (even if PDF allows)\n * - undefined = use base permissions\n *\n * @example\n * // Using string names (recommended)\n * overrides: { print: false, modifyAnnotations: true }\n *\n * @example\n * // Using numeric flags\n * overrides: { [PdfPermissionFlag.Print]: false }\n */\n overrides?: PermissionOverrides;\n}\n\n/**\n * All permission flags for iteration when computing effective permissions.\n */\nexport const ALL_PERMISSION_FLAGS: PdfPermissionFlag[] = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality,\n];\n\n/**\n * All permission names for iteration.\n */\nexport const ALL_PERMISSION_NAMES: PermissionName[] = [\n 'print',\n 'modifyContents',\n 'copyContents',\n 'modifyAnnotations',\n 'fillForms',\n 'extractForAccessibility',\n 'assembleDocument',\n 'printHighQuality',\n];\n\n/**\n * Map from PdfPermissionFlag to human-readable name.\n */\nexport const PERMISSION_FLAG_TO_NAME: Record<PdfPermissionFlag, PermissionName> = {\n [PdfPermissionFlag.Print]: 'print',\n [PdfPermissionFlag.ModifyContents]: 'modifyContents',\n [PdfPermissionFlag.CopyContents]: 'copyContents',\n [PdfPermissionFlag.ModifyAnnotations]: 'modifyAnnotations',\n [PdfPermissionFlag.FillForms]: 'fillForms',\n [PdfPermissionFlag.ExtractForAccessibility]: 'extractForAccessibility',\n [PdfPermissionFlag.AssembleDocument]: 'assembleDocument',\n [PdfPermissionFlag.PrintHighQuality]: 'printHighQuality',\n};\n\n/**\n * Helper to get the override value for a permission flag, checking both numeric and string keys.\n */\nexport function getPermissionOverride(\n overrides: PermissionOverrides | undefined,\n flag: PdfPermissionFlag,\n): boolean | undefined {\n if (!overrides) return undefined;\n\n // Check numeric key first\n if (flag in overrides) {\n return (overrides as Record<PdfPermissionFlag, boolean>)[flag];\n }\n\n // Check string key\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return (overrides as Record<PermissionName, boolean>)[name];\n }\n\n return undefined;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { CoreState, DocumentState } from './initial-state';\nimport { ALL_PERMISSION_FLAGS, getPermissionOverride } from '../types/permissions';\n\n/**\n * Get the active document state\n */\nexport const getActiveDocumentState = (state: CoreState): DocumentState | null => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\n\n/**\n * Get document state by ID\n */\nexport const getDocumentState = (state: CoreState, documentId: string): DocumentState | null => {\n return state.documents[documentId] ?? null;\n};\n\n/**\n * Get all document IDs\n */\nexport const getDocumentIds = (state: CoreState): string[] => {\n return Object.keys(state.documents);\n};\n\n/**\n * Check if a document is loaded\n */\nexport const isDocumentLoaded = (state: CoreState, documentId: string): boolean => {\n return !!state.documents[documentId];\n};\n\n/**\n * Get the number of open documents\n */\nexport const getDocumentCount = (state: CoreState): number => {\n return Object.keys(state.documents).length;\n};\n\n// ─────────────────────────────────────────────────────────\n// Permission Selectors\n// ─────────────────────────────────────────────────────────\n\n/**\n * Check if a specific permission flag is effectively allowed for a document.\n * Applies layered resolution: per-document override → global override → enforceDocumentPermissions → PDF permission.\n *\n * @param state - The core state\n * @param documentId - The document ID to check permissions for\n * @param flag - The permission flag to check\n * @returns true if the permission is allowed, false otherwise\n */\nexport function getEffectivePermission(\n state: CoreState,\n documentId: string,\n flag: PdfPermissionFlag,\n): boolean {\n const docState = state.documents[documentId];\n const docConfig = docState?.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = docState?.document?.permissions ?? PdfPermissionFlag.AllowAll;\n\n // 1. Per-document override wins (supports both numeric and string keys)\n const docOverride = getPermissionOverride(docConfig?.overrides, flag);\n if (docOverride !== undefined) {\n return docOverride;\n }\n\n // 2. Global override (supports both numeric and string keys)\n const globalOverride = getPermissionOverride(globalConfig?.overrides, flag);\n if (globalOverride !== undefined) {\n return globalOverride;\n }\n\n // 3. Check enforce setting (per-doc takes precedence over global)\n const enforce =\n docConfig?.enforceDocumentPermissions ?? globalConfig?.enforceDocumentPermissions ?? true;\n\n if (!enforce) return true; // Not enforcing = allow all\n\n // 4. Use PDF permission\n return (pdfPermissions & flag) !== 0;\n}\n\n/**\n * Get all effective permissions as a bitmask for a document.\n * Combines all individual permission checks into a single bitmask.\n *\n * @param state - The core state\n * @param documentId - The document ID to get permissions for\n * @returns A bitmask of all effective permissions\n */\nexport function getEffectivePermissions(state: CoreState, documentId: string): number {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { useCoreState } from './use-core-state.svelte';\nimport { getEffectivePermission, getEffectivePermissions } from '../../lib/store/selectors';\n\nexport interface DocumentPermissions {\n /** Effective permission flags after applying overrides */\n permissions: number;\n /** Raw PDF permission flags (before overrides) */\n pdfPermissions: number;\n /** Check if a specific permission flag is effectively allowed */\n hasPermission: (flag: PdfPermissionFlag) => boolean;\n /** Check if all specified flags are effectively allowed */\n hasAllPermissions: (...flags: PdfPermissionFlag[]) => boolean;\n\n // Shorthand booleans for all permission flags (using effective permissions):\n /** Can print (possibly degraded quality) */\n canPrint: boolean;\n /** Can modify document contents */\n canModifyContents: boolean;\n /** Can copy/extract text and graphics */\n canCopyContents: boolean;\n /** Can add/modify annotations and fill forms */\n canModifyAnnotations: boolean;\n /** Can fill in existing form fields */\n canFillForms: boolean;\n /** Can extract for accessibility */\n canExtractForAccessibility: boolean;\n /** Can assemble document (insert, rotate, delete pages) */\n canAssembleDocument: boolean;\n /** Can print high quality */\n canPrintHighQuality: boolean;\n}\n\n/**\n * Hook that provides reactive access to a document's effective permission flags.\n * Applies layered resolution: per-document override → global override → PDF permission.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns An object with reactive permission properties.\n */\nexport function useDocumentPermissions(getDocumentId: () => string): DocumentPermissions {\n const coreStateRef = useCoreState();\n\n const documentId = $derived(getDocumentId());\n const coreState = $derived(coreStateRef.current);\n\n const effectivePermissions = $derived(\n coreState ? getEffectivePermissions(coreState, documentId) : PdfPermissionFlag.AllowAll,\n );\n\n const pdfPermissions = $derived(\n coreState?.documents[documentId]?.document?.permissions ?? PdfPermissionFlag.AllowAll,\n );\n\n const hasPermission = (flag: PdfPermissionFlag) =>\n coreState ? getEffectivePermission(coreState, documentId, flag) : true;\n\n const hasAllPermissions = (...flags: PdfPermissionFlag[]) =>\n flags.every((flag) => (coreState ? getEffectivePermission(coreState, documentId, flag) : true));\n\n return {\n get permissions() {\n return effectivePermissions;\n },\n get pdfPermissions() {\n return pdfPermissions;\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.Print)\n : true;\n },\n get canModifyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyContents)\n : true;\n },\n get canCopyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.CopyContents)\n : true;\n },\n get canModifyAnnotations() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyAnnotations)\n : true;\n },\n get canFillForms() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.FillForms)\n : true;\n },\n get canExtractForAccessibility() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ExtractForAccessibility)\n : true;\n },\n get canAssembleDocument() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.AssembleDocument)\n : true;\n },\n get canPrintHighQuality() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.PrintHighQuality)\n : true;\n },\n };\n}\n","<script lang=\"ts\">\n import { type Component, type Snippet } from 'svelte';\n import NestedWrapper from './NestedWrapper.svelte';\n\n interface Props {\n wrappers: Component[];\n children?: Snippet;\n }\n\n let { wrappers, children }: Props = $props();\n</script>\n\n{#if wrappers.length > 1}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n <NestedWrapper wrappers={wrappers.slice(1)}>\n {@render children?.()}\n </NestedWrapper>\n </Wrapper>\n{:else}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n {@render children?.()}\n </Wrapper>\n{/if}\n","<script lang=\"ts\">\n import { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\n import NestedWrapper from './NestedWrapper.svelte';\n import type { Snippet } from 'svelte';\n\n type Props = {\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: Snippet;\n };\n\n let { plugins, children }: Props = $props();\n let utilities: any[] = $state([]);\n let wrappers: any[] = $state([]);\n\n // recompute when plugins change\n $effect(() => {\n const nextUtilities: any[] = [];\n const nextWrappers: any[] = [];\n\n for (const reg of plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements?.() ?? [];\n for (const element of elements) {\n if (element.type === 'utility') {\n nextUtilities.push(element.component);\n } else if (element.type === 'wrapper') {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n\n utilities = nextUtilities;\n wrappers = nextWrappers;\n });\n</script>\n\n{#if wrappers.length > 0}\n <!-- wrap slot content inside all wrappers -->\n <NestedWrapper {wrappers} {children} />\n{:else}\n {@render children?.()}\n{/if}\n\n<!-- mount all utilities -->\n{#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n{/each}\n","<script lang=\"ts\">\n import type { Logger, PdfEngine } from '@embedpdf/models';\n import {\n type IPlugin,\n type PluginBatchRegistrations,\n type PluginRegistryConfig,\n PluginRegistry,\n } from '@embedpdf/core';\n import { type Snippet } from 'svelte';\n import AutoMount from './AutoMount.svelte';\n import { pdfContext, type PDFContextState } from '../hooks';\n\n export type { PluginBatchRegistrations };\n\n interface EmbedPDFProps {\n /**\n * The PDF engine to use for the PDF viewer.\n */\n engine: PdfEngine;\n /**\n * Registry configuration including logger, permissions, and defaults.\n */\n config?: PluginRegistryConfig;\n /**\n * @deprecated Use config.logger instead. Will be removed in next major version.\n */\n logger?: Logger;\n /**\n * The callback to call when the PDF viewer is initialized.\n */\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n /**\n * The plugins to use for the PDF viewer.\n */\n plugins: PluginBatchRegistrations;\n /**\n * The children to render for the PDF viewer.\n */\n children: Snippet<[PDFContextState]>;\n /**\n * Whether to auto-mount specific non-visual DOM elements from plugins.\n * @default true\n */\n autoMountDomElements?: boolean;\n }\n\n let {\n engine,\n config,\n logger,\n onInitialized,\n plugins,\n children,\n autoMountDomElements = true,\n }: EmbedPDFProps = $props();\n\n let latestInit = onInitialized;\n\n $effect(() => {\n if (onInitialized) {\n latestInit = onInitialized;\n }\n });\n\n $effect(() => {\n if (engine || (engine && plugins)) {\n // Merge deprecated logger prop into config (config.logger takes precedence)\n const finalConfig: PluginRegistryConfig = {\n ...config,\n logger: config?.logger ?? logger,\n };\n const reg = new PluginRegistry(engine, finalConfig);\n reg.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await reg.initialize();\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n return;\n }\n\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n // Only update if it's a core action and the core state changed\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n\n // Update convenience accessors\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument =\n activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder\n .map((docId) => documents[docId])\n .filter(\n (doc): doc is import('@embedpdf/core').DocumentState =>\n doc !== null && doc !== undefined,\n );\n }\n });\n\n /* always call the *latest* callback */\n await latestInit?.(reg);\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n\n // Provide the registry to children via context\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n\n return unsubscribe;\n };\n\n let cleanup: (() => void) | undefined;\n initialize()\n .then((unsub) => {\n cleanup = unsub;\n })\n .catch(console.error);\n\n return () => {\n cleanup?.();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n</script>\n\n{#if pdfContext.pluginsReady && autoMountDomElements}\n <AutoMount {plugins}>{@render children(pdfContext)}</AutoMount>\n{:else}\n {@render children(pdfContext)}\n{/if}\n"],"names":["$$anchor","NestedWrapper"],"mappings":";;;;MAea;EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB;EACA;;AAQW,MAAA,oBAAoB;SCpBjB,UAAgC,UAAmB;AACzD,QAAA,EAAA,aAAa;AAEf,QAAA,kBACJ,QAAQ,MACR,WAAW,MACX,OAAA,IAAW,QAAA,MAAoB;AAAA,EAAA,CAAE,EAAA,CAAA;MAG/B,aAAa,MAAM;WACd;AAAA,EACT;AAEM,QAAA,SAAS,SAAS,UAAa,QAAQ;AAExC,MAAA,CAAA,QAAQ;AACD,UAAA,IAAA,gBAAgB,QAAQ,YAAA;AAAA,EACpC;AAEA,QAAM,SAAS;AACf,QAAM,YAAY;AAClB,QAAM,QAAQ,OAAO,MAAA;SAEd;AACT;SCxBgB,cAAoC,UAAmB;QAC/D,IAAI,UAAa,QAAQ;QAEzB;IACJ,UAAU;AAAA,IACV,WAAW;AAAA,IACX,OAAA,IAAW,QAAA,MAAoB;AAAA,IAAA,CAAE;AAAA;AAInC,IAAA,kBAAc;SACP,EAAE,QAAQ;AACb,YAAM,WAAW;AACjB,YAAM,YAAY,EAAE;AACpB,YAAM,QAAQ,EAAE;;IAElB;AAEK,QAAA,CAAA,EAAE,OAAO,UAAU;AACZ,YAAA,IAAA,gBAAgB,QAAQ,gCAAA;AAAA,IACpC;AAEA,UAAM,WAAW,EAAE,OAAO,SAAA;AAC1B,UAAM,YAAY,EAAE;AACpB,UAAM,QAAQ,EAAE;AAAA,EAClB,CAAC;SAEM;AACT;AC/BgB,SAAA,eAAe;AACvB,QAAA,UAAU,YAAA;;IAGV,IAAA,UAAU;AACL,aAAA,QAAQ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I;AACJ,iBAAU,EACP,KAAI,CAAE,UAAU;AACf,kBAAU;AAAA,MACZ,CAAC,EACA,MAAM,QAAQ,KAAK;AAET,aAAA,MAAA;AACX;AACA,YAAI,QAAO;AACX,mBAAW,WAAW;AACtB,mBAAW,YAAY;AACvB,mBAAW,iBAAiB;AAC5B,mBAAW,eAAe;AAC1B,mBAAW,mBAAmB;AAC9B,mBAAW,iBAAiB;AAC5B,mBAAW,YAAS,CAAA;AACpB,mBAAW,iBAAc,CAAA;AAAA,MAC3B;AAAA,IACF;AAAA,EACF,CAAC;;;;;AAIA,gBAASA,WAAA;AAAA;;;;;;0DAA6B,UAAU;;;;;;;;;sDAE/B,UAAU;;;;UAHzB,WAAW,gBAAgB,uBAAoB,UAAA,UAAA;AAAA,UAAA,UAAA,WAAA,KAAA;AAAA;;;;AAF5C;"}
{
"name": "@embedpdf/core",
"version": "2.2.0",
"version": "2.3.0",
"type": "module",

@@ -43,4 +43,4 @@ "license": "MIT",

"dependencies": {
"@embedpdf/engines": "2.2.0",
"@embedpdf/models": "2.2.0"
"@embedpdf/models": "2.3.0",
"@embedpdf/engines": "2.3.0"
},

@@ -47,0 +47,0 @@ "peerDependencies": {