@embedpdf/core 2.0.0-next.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/lib/registry/plugin-registry.d.ts +0 -5
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/auto-mount.vue.d.ts +3 -3
- package/dist/vue/components/embed-pdf.vue.d.ts +33 -21
- package/dist/vue/components/nested-wrapper.vue.d.ts +3 -3
- package/package.json +3 -3
|
@@ -10,7 +10,6 @@ export declare class PluginRegistry {
|
|
|
10
10
|
private resolver;
|
|
11
11
|
private configurations;
|
|
12
12
|
private engine;
|
|
13
|
-
private engineInitialized;
|
|
14
13
|
private store;
|
|
15
14
|
private initPromise;
|
|
16
15
|
private logger;
|
|
@@ -26,10 +25,6 @@ export declare class PluginRegistry {
|
|
|
26
25
|
* Get the logger instance
|
|
27
26
|
*/
|
|
28
27
|
getLogger(): Logger;
|
|
29
|
-
/**
|
|
30
|
-
* Ensure engine is initialized before proceeding
|
|
31
|
-
*/
|
|
32
|
-
private ensureEngineInitialized;
|
|
33
28
|
/**
|
|
34
29
|
* Register a plugin without initializing it
|
|
35
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
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/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-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","<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 { type IPlugin, type PluginBatchRegistrations, PluginRegistry } 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 * The logger to use for the PDF viewer.\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 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 const reg = new PluginRegistry(engine, { logger });\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 { 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","Wrapper","$0","$","derived","$$props","wrappers","slice","length","consequent","$$render","alternate","utilities","proxy","user_effect","nextUtilities","nextWrappers","reg","plugins","pkg","package","hasAutoMountElements","elements","_a","autoMountElements","call","element","type","push","component","set","each","node_2","get","Utility","i","autoMountDomElements","latestInit","onInitialized","engine","PluginRegistry","logger","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","p","provides","getDocumentId","coreStateRef","documentId","documentState"],"mappings":"geAeaA,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,yECHU,MAAAoB,2BAAmB,mGAES,IAAAC,EAAAC,EAAAC,QAAA,IAAAC,EAAAC,SAAAC,MAAM,yNAKlC,MAAAN,2BAAmB,6OARfI,EAAAC,SAAAE,OAAS,IAACC,GAAAC,EAAAC,GAAA,0BAFxB,iECCMC,EAAgBT,EAAAZ,MAAAY,EAAAU,MAAA,KAChBP,EAAeH,EAAAZ,MAAAY,EAAAU,MAAA,KAGnBV,EAAAW,YAAO,iBACCC,EAAoB,GACpBC,EAAmB,GAEd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,eAAWwE,GACnBD,EAAavE,QAAQd,UAAAiB,EAAA8B,IAAUuC,KAAe,KAC/C,aAIA,WAAAxE,gBACKyE,EACT,EAEJ"}
|
|
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/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-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","<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 { type IPlugin, type PluginBatchRegistrations, PluginRegistry } 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 * The logger to use for the PDF viewer.\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 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 const reg = new PluginRegistry(engine, { logger });\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 { 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","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","_a","autoMountElements","call","element","type","push","component","set","each","node_2","get","Utility","i","Utility_1","autoMountDomElements","latestInit","onInitialized","engine","PluginRegistry","logger","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","documentId","documentState"],"mappings":"geAeaA,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,U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C9BL,EAAWM,eAAiB,KAC5BN,EAAWO,UAAS,CAAA,EACpBP,EAAWQ,eAAc,GAE7B,+CAKDsF,EAAStE,EAAA,sHAA6BxB,oHAErBA,6BAHfA,EAAWI,cAAgB0D,MAAoB5B,GAAAC,EAAAC,GAAA,0BAFpD,sDC7HoDzB,SAC5CoF,EAAIrF,EAAaC,GAEjBC,WACJoF,SAAU,KACVlF,WAAW,EACXC,MAAA,IAAWC,QAAA,iBAIbU,EAAAa,qBACOwD,EAAElF,cACLD,EAAMoF,SAAW,KACjBpF,EAAME,UAAYiF,EAAEjF,eACpBF,EAAMG,MAAQgF,EAAEhF,OAIb,IAAAgF,EAAElF,OAAOmF,SACF,MAAA,IAAA9E,gBAAgBP,mCAG5BC,EAAMoF,SAAWD,EAAElF,OAAOmF,WAC1BpF,EAAME,UAAYiF,EAAEjF,UACpBF,EAAMG,MAAQgF,EAAEhF,QAGXH,CACT,2DC/BiCqF,GACzB,MAAAC,EAAe/E,IAGfgF,YAAsBF,GAEtBG,EAAA1E,EAAAC,QAAA,IACJuE,EAAa7E,eAAW8E,GACnBD,EAAa7E,QAAQd,UAAAmB,EAAAgC,IAAUyC,KAAe,KAC/C,aAIA,WAAA9E,gBACK+E,EACT,EAEJ"}
|
package/dist/svelte/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/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","<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 { type IPlugin, type PluginBatchRegistrations, PluginRegistry } 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 * The logger to use for the PDF viewer.\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 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 const reg = new PluginRegistry(engine, { logger });\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":[],"mappings":";;;MAea;EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAC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A,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;;;;;;;;;;;;0DAIsC,UAAU;;;;;;;;;sDAE/B,UAAU;;;;UAHzB,WAAW,gBAAgB,uBAAoB,UAAA,UAAA;AAAA,UAAA,UAAA,WAAA,KAAA;AAAA;;;;AAFpD;"}
|
|
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/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","<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 { type IPlugin, type PluginBatchRegistrations, PluginRegistry } 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 * The logger to use for the PDF viewer.\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 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 const reg = new PluginRegistry(engine, { logger });\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,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A;;;;;;0DAA6B,UAAU;;;;;;;;;sDAE/B,UAAU;;;;UAHzB,WAAW,gBAAgB,uBAAoB,UAAA,UAAA;AAAA,UAAA,UAAA,WAAA,KAAA;AAAA;;;;AAFpD;"}
|
|
@@ -2,11 +2,11 @@ import { PluginBatchRegistration, IPlugin } from '../../lib/index.ts';
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
plugins: PluginBatchRegistration<IPlugin<any>, any>[];
|
|
4
4
|
};
|
|
5
|
-
declare var
|
|
5
|
+
declare var __VLS_7: {}, __VLS_9: {};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
|
-
default?: (props: typeof __VLS_5) => any;
|
|
8
|
-
} & {
|
|
9
7
|
default?: (props: typeof __VLS_7) => any;
|
|
8
|
+
} & {
|
|
9
|
+
default?: (props: typeof __VLS_9) => any;
|
|
10
10
|
};
|
|
11
11
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginRegistry, PluginBatchRegistrations } from '../../lib/index.ts';
|
|
1
|
+
import { PluginRegistry, PluginBatchRegistrations, DocumentState } from '../../lib/index.ts';
|
|
2
2
|
import { Logger, PdfEngine } from '@embedpdf/models';
|
|
3
3
|
export type { PluginBatchRegistrations };
|
|
4
4
|
type __VLS_Props = {
|
|
@@ -8,29 +8,41 @@ type __VLS_Props = {
|
|
|
8
8
|
onInitialized?: (registry: PluginRegistry) => Promise<void>;
|
|
9
9
|
autoMountDomElements?: boolean;
|
|
10
10
|
};
|
|
11
|
-
declare var
|
|
12
|
-
registry:
|
|
13
|
-
coreState:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
declare var __VLS_8: {
|
|
12
|
+
registry: PluginRegistry | null;
|
|
13
|
+
coreState: {
|
|
14
|
+
documents: Record<string, DocumentState>;
|
|
15
|
+
documentOrder: string[];
|
|
16
|
+
activeDocumentId: string | null;
|
|
17
|
+
defaultScale: number;
|
|
18
|
+
defaultRotation: import('@embedpdf/models').Rotation;
|
|
19
|
+
} | null;
|
|
20
|
+
isInitializing: boolean;
|
|
21
|
+
pluginsReady: true;
|
|
22
|
+
activeDocumentId: string | null;
|
|
23
|
+
activeDocument: DocumentState | null;
|
|
24
|
+
documents: Record<string, DocumentState>;
|
|
25
|
+
documentStates: DocumentState[];
|
|
26
|
+
}, __VLS_10: {
|
|
27
|
+
registry: PluginRegistry | null;
|
|
28
|
+
coreState: {
|
|
29
|
+
documents: Record<string, DocumentState>;
|
|
30
|
+
documentOrder: string[];
|
|
31
|
+
activeDocumentId: string | null;
|
|
32
|
+
defaultScale: number;
|
|
33
|
+
defaultRotation: import('@embedpdf/models').Rotation;
|
|
34
|
+
} | null;
|
|
35
|
+
isInitializing: boolean;
|
|
36
|
+
pluginsReady: boolean;
|
|
37
|
+
activeDocumentId: string | null;
|
|
38
|
+
activeDocument: DocumentState | null;
|
|
39
|
+
documents: Record<string, DocumentState>;
|
|
40
|
+
documentStates: DocumentState[];
|
|
29
41
|
};
|
|
30
42
|
type __VLS_Slots = {} & {
|
|
31
|
-
default?: (props: typeof __VLS_6) => any;
|
|
32
|
-
} & {
|
|
33
43
|
default?: (props: typeof __VLS_8) => any;
|
|
44
|
+
} & {
|
|
45
|
+
default?: (props: typeof __VLS_10) => any;
|
|
34
46
|
};
|
|
35
47
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
36
48
|
autoMountDomElements: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
type __VLS_Props = {
|
|
2
2
|
wrappers: any[];
|
|
3
3
|
};
|
|
4
|
-
declare var
|
|
4
|
+
declare var __VLS_14: {}, __VLS_16: {};
|
|
5
5
|
type __VLS_Slots = {} & {
|
|
6
|
-
default?: (props: typeof __VLS_12) => any;
|
|
7
|
-
} & {
|
|
8
6
|
default?: (props: typeof __VLS_14) => any;
|
|
7
|
+
} & {
|
|
8
|
+
default?: (props: typeof __VLS_16) => any;
|
|
9
9
|
};
|
|
10
10
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
11
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@embedpdf/build": "1.1.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@embedpdf/engines": "2.0.
|
|
44
|
-
"@embedpdf/models": "2.0.
|
|
43
|
+
"@embedpdf/engines": "2.0.1",
|
|
44
|
+
"@embedpdf/models": "2.0.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"preact": "^10.26.4",
|