@embedpdf/core 1.0.11 → 1.0.12

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.
Files changed (74) hide show
  1. package/dist/index.cjs +2 -1335
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +1 -585
  4. package/dist/index.js +55 -84
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/base/base-plugin.d.ts +98 -0
  7. package/dist/lib/index.d.ts +14 -0
  8. package/dist/lib/registry/plugin-registry.d.ts +100 -0
  9. package/dist/lib/store/actions.d.ts +39 -0
  10. package/dist/lib/store/index.d.ts +6 -0
  11. package/dist/lib/store/initial-state.d.ts +11 -0
  12. package/dist/lib/store/plugin-store.d.ts +48 -0
  13. package/dist/lib/store/reducer.d.ts +4 -0
  14. package/dist/lib/store/selectors.d.ts +3 -0
  15. package/dist/lib/store/store.d.ts +105 -0
  16. package/dist/lib/store/types.d.ts +28 -0
  17. package/dist/lib/types/errors.d.ts +21 -0
  18. package/dist/lib/types/plugin.d.ts +49 -0
  19. package/dist/lib/utils/dependency-resolver.d.ts +6 -0
  20. package/dist/lib/utils/event-control.d.ts +23 -0
  21. package/dist/lib/utils/eventing.d.ts +19 -0
  22. package/dist/lib/utils/math.d.ts +22 -0
  23. package/dist/lib/utils/plugin-helpers.d.ts +6 -0
  24. package/dist/lib/utils/typed-object.d.ts +12 -0
  25. package/dist/preact/adapter.d.ts +4 -0
  26. package/dist/preact/index.cjs +2 -188
  27. package/dist/preact/index.cjs.map +1 -1
  28. package/dist/preact/index.d.ts +1 -71
  29. package/dist/preact/index.js +11 -27
  30. package/dist/preact/index.js.map +1 -1
  31. package/dist/react/adapter.d.ts +2 -0
  32. package/dist/react/index.cjs +2 -188
  33. package/dist/react/index.cjs.map +1 -1
  34. package/dist/react/index.d.ts +1 -70
  35. package/dist/react/index.js +11 -28
  36. package/dist/react/index.js.map +1 -1
  37. package/dist/shared-preact/components/embed-pdf.d.ts +12 -0
  38. package/dist/shared-preact/components/index.d.ts +1 -0
  39. package/dist/shared-preact/context.d.ts +7 -0
  40. package/dist/shared-preact/hooks/index.d.ts +5 -0
  41. package/dist/shared-preact/hooks/use-capability.d.ts +16 -0
  42. package/dist/shared-preact/hooks/use-core-state.d.ts +6 -0
  43. package/dist/shared-preact/hooks/use-plugin.d.ts +16 -0
  44. package/dist/shared-preact/hooks/use-registry.d.ts +6 -0
  45. package/dist/shared-preact/hooks/use-store-state.d.ts +6 -0
  46. package/dist/shared-preact/index.d.ts +3 -0
  47. package/dist/shared-react/components/embed-pdf.d.ts +12 -0
  48. package/dist/shared-react/components/index.d.ts +1 -0
  49. package/dist/shared-react/context.d.ts +7 -0
  50. package/dist/shared-react/hooks/index.d.ts +5 -0
  51. package/dist/shared-react/hooks/use-capability.d.ts +16 -0
  52. package/dist/shared-react/hooks/use-core-state.d.ts +6 -0
  53. package/dist/shared-react/hooks/use-plugin.d.ts +16 -0
  54. package/dist/shared-react/hooks/use-registry.d.ts +6 -0
  55. package/dist/shared-react/hooks/use-store-state.d.ts +6 -0
  56. package/dist/shared-react/index.d.ts +3 -0
  57. package/dist/vue/components/embed-pdf.vue.d.ts +23 -0
  58. package/dist/vue/components/index.d.ts +1 -0
  59. package/dist/vue/composables/index.d.ts +5 -0
  60. package/dist/vue/composables/use-capability.d.ts +15 -0
  61. package/dist/vue/composables/use-core-state.d.ts +2 -0
  62. package/dist/vue/composables/use-plugin.d.ts +8 -0
  63. package/dist/vue/composables/use-registry.d.ts +1 -0
  64. package/dist/vue/composables/use-store-state.d.ts +10 -0
  65. package/dist/vue/context.d.ts +8 -0
  66. package/dist/vue/index.cjs +2 -0
  67. package/dist/vue/index.cjs.map +1 -0
  68. package/dist/vue/index.d.ts +2 -0
  69. package/dist/vue/index.js +115 -0
  70. package/dist/vue/index.js.map +1 -0
  71. package/package.json +20 -12
  72. package/dist/index.d.cts +0 -585
  73. package/dist/preact/index.d.cts +0 -71
  74. package/dist/react/index.d.cts +0 -70
@@ -1,15 +1,11 @@
1
- // src/react/context.ts
2
- import { createContext } from "react";
3
- var PDFContext = createContext({
1
+ import { createContext, useState, useRef, useEffect, useContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { PluginRegistry, arePropsEqual } from "@embedpdf/core";
4
+ const PDFContext = createContext({
4
5
  registry: null,
5
6
  isInitializing: true,
6
7
  pluginsReady: false
7
8
  });
8
-
9
- // src/react/components/embed-pdf.tsx
10
- import { useState, useEffect, useRef } from "react";
11
- import { PluginRegistry } from "@embedpdf/core";
12
- import { jsx } from "react/jsx-runtime";
13
9
  function EmbedPDF({ engine, onInitialized, plugins, children }) {
14
10
  const [registry, setRegistry] = useState(null);
15
11
  const [isInitializing, setIsInitializing] = useState(true);
@@ -22,11 +18,12 @@ function EmbedPDF({ engine, onInitialized, plugins, children }) {
22
18
  const pdfViewer = new PluginRegistry(engine);
23
19
  pdfViewer.registerPluginBatch(plugins);
24
20
  const initialize = async () => {
21
+ var _a;
25
22
  await pdfViewer.initialize();
26
23
  if (pdfViewer.isDestroyed()) {
27
24
  return;
28
25
  }
29
- await initRef.current?.(pdfViewer);
26
+ await ((_a = initRef.current) == null ? void 0 : _a.call(initRef, pdfViewer));
30
27
  if (pdfViewer.isDestroyed()) {
31
28
  return;
32
29
  }
@@ -48,9 +45,6 @@ function EmbedPDF({ engine, onInitialized, plugins, children }) {
48
45
  }, [engine, plugins]);
49
46
  return /* @__PURE__ */ jsx(PDFContext.Provider, { value: { registry, isInitializing, pluginsReady }, children: typeof children === "function" ? children({ registry, isInitializing, pluginsReady }) : children });
50
47
  }
51
-
52
- // src/react/hooks/use-registry.ts
53
- import { useContext } from "react";
54
48
  function useRegistry() {
55
49
  const contextValue = useContext(PDFContext);
56
50
  if (contextValue === void 0) {
@@ -65,8 +59,6 @@ function useRegistry() {
65
59
  }
66
60
  return contextValue;
67
61
  }
68
-
69
- // src/react/hooks/use-plugin.ts
70
62
  function usePlugin(pluginId) {
71
63
  const { registry } = useRegistry();
72
64
  if (registry === null) {
@@ -87,8 +79,6 @@ function usePlugin(pluginId) {
87
79
  ready: plugin.ready()
88
80
  };
89
81
  }
90
-
91
- // src/react/hooks/use-capability.ts
92
82
  function useCapability(pluginId) {
93
83
  const { plugin, isLoading, ready } = usePlugin(pluginId);
94
84
  if (!plugin) {
@@ -107,13 +97,10 @@ function useCapability(pluginId) {
107
97
  ready
108
98
  };
109
99
  }
110
-
111
- // src/react/hooks/use-store-state.ts
112
- import { useState as useState2, useEffect as useEffect2 } from "react";
113
100
  function useStoreState() {
114
101
  const { registry } = useRegistry();
115
- const [state, setState] = useState2(null);
116
- useEffect2(() => {
102
+ const [state, setState] = useState(null);
103
+ useEffect(() => {
117
104
  if (!registry) return;
118
105
  setState(registry.getStore().getState());
119
106
  const unsubscribe = registry.getStore().subscribe((_action, newState) => {
@@ -123,14 +110,10 @@ function useStoreState() {
123
110
  }, [registry]);
124
111
  return state;
125
112
  }
126
-
127
- // src/react/hooks/use-core-state.ts
128
- import { useState as useState3, useEffect as useEffect3 } from "react";
129
- import { arePropsEqual } from "@embedpdf/core";
130
113
  function useCoreState() {
131
114
  const { registry } = useRegistry();
132
- const [coreState, setCoreState] = useState3(null);
133
- useEffect3(() => {
115
+ const [coreState, setCoreState] = useState(null);
116
+ useEffect(() => {
134
117
  if (!registry) return;
135
118
  const store = registry.getStore();
136
119
  setCoreState(store.getState().core);
@@ -152,4 +135,4 @@ export {
152
135
  useRegistry,
153
136
  useStoreState
154
137
  };
155
- //# sourceMappingURL=index.js.map
138
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/context.ts","../../src/react/components/embed-pdf.tsx","../../src/react/hooks/use-registry.ts","../../src/react/hooks/use-plugin.ts","../../src/react/hooks/use-capability.ts","../../src/react/hooks/use-store-state.ts","../../src/react/hooks/use-core-state.ts"],"sourcesContent":["import { createContext } from 'react';\nimport type { PluginRegistry } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n}\n\nexport const PDFContext = createContext<PDFContextState>({\n registry: null,\n isInitializing: true,\n pluginsReady: false,\n});\n","import React, { useState, useEffect, useCallback, useRef } from 'react';\nimport { PdfEngine } from '@embedpdf/models';\nimport { PluginRegistry } from '@embedpdf/core';\nimport type { IPlugin, PluginBatchRegistration } from '@embedpdf/core';\n\nimport { PDFContext, PDFContextState } from '../context';\n\ninterface EmbedPDFProps {\n engine: PdfEngine;\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: React.ReactNode | ((state: PDFContextState) => React.ReactNode);\n}\n\nexport function EmbedPDF({ engine, onInitialized, plugins, children }: EmbedPDFProps) {\n const [registry, setRegistry] = useState<PluginRegistry | null>(null);\n const [isInitializing, setIsInitializing] = useState<boolean>(true);\n const [pluginsReady, setPluginsReady] = useState<boolean>(false);\n const initRef = useRef<EmbedPDFProps['onInitialized']>(onInitialized);\n\n useEffect(() => {\n initRef.current = onInitialized; // update without triggering re-runs\n }, [onInitialized]);\n\n useEffect(() => {\n const pdfViewer = new PluginRegistry(engine);\n pdfViewer.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await pdfViewer.initialize();\n // if the registry is destroyed, don't do anything\n if (pdfViewer.isDestroyed()) {\n return;\n }\n\n /* always call the *latest* callback */\n await initRef.current?.(pdfViewer);\n\n // if the registry is destroyed, don't do anything\n if (pdfViewer.isDestroyed()) {\n return;\n }\n\n pdfViewer.pluginsReady().then(() => {\n if (!pdfViewer.isDestroyed()) {\n setPluginsReady(true);\n }\n });\n\n // Provide the registry to children via context\n setRegistry(pdfViewer);\n setIsInitializing(false);\n };\n\n initialize().catch(console.error);\n\n return () => {\n pdfViewer.destroy();\n setRegistry(null);\n setIsInitializing(true);\n setPluginsReady(false);\n };\n }, [engine, plugins]);\n\n return (\n <PDFContext.Provider value={{ registry, isInitializing, pluginsReady }}>\n {typeof children === 'function'\n ? children({ registry, isInitializing, pluginsReady })\n : children}\n </PDFContext.Provider>\n );\n}\n","import { useContext } from 'react';\nimport { PDFContext, PDFContextState } from '../context';\n\n/**\n * Hook to access the PDF registry.\n * @returns The PDF registry or null during initialization\n */\nexport function useRegistry(): PDFContextState {\n const contextValue = useContext(PDFContext);\n\n // Error if used outside of context\n if (contextValue === undefined) {\n throw new Error('useCapability must be used within a PDFContext.Provider');\n }\n\n const { registry, isInitializing } = contextValue;\n\n // During initialization, return null instead of throwing an error\n if (isInitializing) {\n return contextValue;\n }\n\n // At this point, initialization is complete but registry is still null, which is unexpected\n if (registry === null) {\n throw new Error('PDF registry failed to initialize properly');\n }\n\n return contextValue;\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\ntype PluginState<T extends BasePlugin> = {\n plugin: T | null;\n isLoading: boolean;\n ready: Promise<void>;\n};\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']): PluginState<T> {\n const { registry } = useRegistry();\n\n if (registry === null) {\n return {\n plugin: null,\n isLoading: true,\n ready: new Promise(() => {}),\n };\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n return {\n plugin,\n isLoading: false,\n ready: plugin.ready(),\n };\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin';\n\ntype CapabilityState<T extends BasePlugin> = {\n provides: ReturnType<NonNullable<T['provides']>> | null;\n isLoading: boolean;\n ready: Promise<void>;\n};\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']): CapabilityState<T> {\n const { plugin, isLoading, ready } = usePlugin<T>(pluginId);\n\n if (!plugin) {\n return {\n provides: null,\n isLoading,\n ready,\n };\n }\n\n if (!plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n return {\n provides: plugin.provides() as ReturnType<NonNullable<T['provides']>>,\n isLoading,\n ready,\n };\n}\n","import { useState, useEffect } from 'react';\nimport { CoreState, StoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Hook that provides access to the current global store state\n * and re-renders the component when the state changes\n */\nexport function useStoreState<T = CoreState>(): StoreState<T> | null {\n const { registry } = useRegistry();\n const [state, setState] = useState<StoreState<T> | null>(null);\n\n useEffect(() => {\n if (!registry) return;\n\n // Get initial state\n setState(registry.getStore().getState() as StoreState<T>);\n\n // Subscribe to store changes\n const unsubscribe = registry.getStore().subscribe((_action, newState) => {\n setState(newState as StoreState<T>);\n });\n\n return () => unsubscribe();\n }, [registry]);\n\n return state;\n}\n","import { useState, useEffect } from 'react';\nimport { CoreState, arePropsEqual } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Hook that provides access to the current core state\n * and re-renders the component only when the core state changes\n */\nexport function useCoreState(): CoreState | null {\n const { registry } = useRegistry();\n const [coreState, setCoreState] = useState<CoreState | null>(null);\n\n useEffect(() => {\n if (!registry) return;\n\n const store = registry.getStore();\n\n // Get initial core state\n setCoreState(store.getState().core);\n\n // Create a single subscription that handles all core actions\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) && !arePropsEqual(newState.core, oldState.core)) {\n setCoreState(newState.core);\n }\n });\n\n return () => unsubscribe();\n }, [registry]);\n\n return coreState;\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AASvB,IAAM,aAAa,cAA+B;AAAA,EACvD,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,cAAc;AAChB,CAAC;;;ACbD,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AAS,EAAE,SAAS,CAAkB;AAGxD,UAAM,cAAc,SAAS,SAAS,EAAE,UAAU,CAAC,SAAS,aAAa;AACvE,eAAS,QAAyB;AAAA,IACpC,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;;;AC3BA,SAAS,YAAAC,WAAU,aAAAC,kBAAiB;AACpC,SAAoB,qBAAqB;AAOlC,SAAS,eAAiC;AAC/C,QAAM,EAAE,SAAS,IAAI,YAAY;AACjC,QAAM,CAAC,WAAW,YAAY,IAAIC,UAA2B,IAAI;AAEjE,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAEf,UAAM,QAAQ,SAAS,SAAS;AAGhC,iBAAa,MAAM,SAAS,EAAE,IAAI;AAGlC,UAAM,cAAc,MAAM,UAAU,CAAC,QAAQ,UAAU,aAAa;AAElE,UAAI,MAAM,aAAa,MAAM,KAAK,CAAC,cAAc,SAAS,MAAM,SAAS,IAAI,GAAG;AAC9E,qBAAa,SAAS,IAAI;AAAA,MAC5B;AAAA,IACF,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;","names":["useState","useEffect","useState","useEffect","useState","useEffect","useState","useEffect"]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/context.ts","../../src/shared/components/embed-pdf.tsx","../../src/shared/hooks/use-registry.ts","../../src/shared/hooks/use-plugin.ts","../../src/shared/hooks/use-capability.ts","../../src/shared/hooks/use-store-state.ts","../../src/shared/hooks/use-core-state.ts"],"sourcesContent":["import { createContext } from '@framework';\nimport type { PluginRegistry } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n}\n\nexport const PDFContext = createContext<PDFContextState>({\n registry: null,\n isInitializing: true,\n pluginsReady: false,\n});\n","import { useState, useEffect, useRef, ReactNode } from '@framework';\nimport { PdfEngine } from '@embedpdf/models';\nimport { PluginRegistry } from '@embedpdf/core';\nimport type { IPlugin, PluginBatchRegistration } from '@embedpdf/core';\n\nimport { PDFContext, PDFContextState } from '../context';\n\ninterface EmbedPDFProps {\n engine: PdfEngine;\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: ReactNode | ((state: PDFContextState) => ReactNode);\n}\n\nexport function EmbedPDF({ engine, onInitialized, plugins, children }: EmbedPDFProps) {\n const [registry, setRegistry] = useState<PluginRegistry | null>(null);\n const [isInitializing, setIsInitializing] = useState<boolean>(true);\n const [pluginsReady, setPluginsReady] = useState<boolean>(false);\n const initRef = useRef<EmbedPDFProps['onInitialized']>(onInitialized);\n\n useEffect(() => {\n initRef.current = onInitialized; // update without triggering re-runs\n }, [onInitialized]);\n\n useEffect(() => {\n const pdfViewer = new PluginRegistry(engine);\n pdfViewer.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await pdfViewer.initialize();\n // if the registry is destroyed, don't do anything\n if (pdfViewer.isDestroyed()) {\n return;\n }\n\n /* always call the *latest* callback */\n await initRef.current?.(pdfViewer);\n\n // if the registry is destroyed, don't do anything\n if (pdfViewer.isDestroyed()) {\n return;\n }\n\n pdfViewer.pluginsReady().then(() => {\n if (!pdfViewer.isDestroyed()) {\n setPluginsReady(true);\n }\n });\n\n // Provide the registry to children via context\n setRegistry(pdfViewer);\n setIsInitializing(false);\n };\n\n initialize().catch(console.error);\n\n return () => {\n pdfViewer.destroy();\n setRegistry(null);\n setIsInitializing(true);\n setPluginsReady(false);\n };\n }, [engine, plugins]);\n\n return (\n <PDFContext.Provider value={{ registry, isInitializing, pluginsReady }}>\n {typeof children === 'function'\n ? children({ registry, isInitializing, pluginsReady })\n : children}\n </PDFContext.Provider>\n );\n}\n","import { useContext } from '@framework';\nimport { PDFContext, PDFContextState } from '../context';\n\n/**\n * Hook to access the PDF registry.\n * @returns The PDF registry or null during initialization\n */\nexport function useRegistry(): PDFContextState {\n const contextValue = useContext(PDFContext);\n\n // Error if used outside of context\n if (contextValue === undefined) {\n throw new Error('useCapability must be used within a PDFContext.Provider');\n }\n\n const { registry, isInitializing } = contextValue;\n\n // During initialization, return null instead of throwing an error\n if (isInitializing) {\n return contextValue;\n }\n\n // At this point, initialization is complete but registry is still null, which is unexpected\n if (registry === null) {\n throw new Error('PDF registry failed to initialize properly');\n }\n\n return contextValue;\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\ntype PluginState<T extends BasePlugin> = {\n plugin: T | null;\n isLoading: boolean;\n ready: Promise<void>;\n};\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']): PluginState<T> {\n const { registry } = useRegistry();\n\n if (registry === null) {\n return {\n plugin: null,\n isLoading: true,\n ready: new Promise(() => {}),\n };\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n return {\n plugin,\n isLoading: false,\n ready: plugin.ready(),\n };\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin';\n\ntype CapabilityState<T extends BasePlugin> = {\n provides: ReturnType<NonNullable<T['provides']>> | null;\n isLoading: boolean;\n ready: Promise<void>;\n};\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']): CapabilityState<T> {\n const { plugin, isLoading, ready } = usePlugin<T>(pluginId);\n\n if (!plugin) {\n return {\n provides: null,\n isLoading,\n ready,\n };\n }\n\n if (!plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n return {\n provides: plugin.provides() as ReturnType<NonNullable<T['provides']>>,\n isLoading,\n ready,\n };\n}\n","import { useState, useEffect } from '@framework';\nimport { CoreState, StoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Hook that provides access to the current global store state\n * and re-renders the component when the state changes\n */\nexport function useStoreState<T = CoreState>(): StoreState<T> | null {\n const { registry } = useRegistry();\n const [state, setState] = useState<StoreState<T> | null>(null);\n\n useEffect(() => {\n if (!registry) return;\n\n // Get initial state\n setState(registry.getStore().getState() as StoreState<T>);\n\n // Subscribe to store changes\n const unsubscribe = registry.getStore().subscribe((_action, newState) => {\n setState(newState as StoreState<T>);\n });\n\n return () => unsubscribe();\n }, [registry]);\n\n return state;\n}\n","import { useState, useEffect } from '@framework';\nimport { CoreState, arePropsEqual } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Hook that provides access to the current core state\n * and re-renders the component only when the core state changes\n */\nexport function useCoreState(): CoreState | null {\n const { registry } = useRegistry();\n const [coreState, setCoreState] = useState<CoreState | null>(null);\n\n useEffect(() => {\n if (!registry) return;\n\n const store = registry.getStore();\n\n // Get initial core state\n setCoreState(store.getState().core);\n\n // Create a single subscription that handles all core actions\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) && !arePropsEqual(newState.core, oldState.core)) {\n setCoreState(newState.core);\n }\n });\n\n return () => unsubscribe();\n }, [registry]);\n\n return coreState;\n}\n"],"names":[],"mappings":";;;AASO,MAAM,aAAa,cAA+B;AAAA,EACvD,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,cAAc;AAChB,CAAC;ACCM,SAAS,SAAS,EAAE,QAAQ,eAAe,SAAS,YAA2B;AACpF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,IAAI;AACpE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAkB,IAAI;AAClE,QAAM,CAAC,c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AAU;AAET,UAAA,QAAQ,SAAS,SAAS;AAGnB,iBAAA,MAAM,SAAS,EAAE,IAAI;AAGlC,UAAM,cAAc,MAAM,UAAU,CAAC,QAAQ,UAAU,aAAa;AAE9D,UAAA,MAAM,aAAa,MAAM,KAAK,CAAC,cAAc,SAAS,MAAM,SAAS,IAAI,GAAG;AAC9E,qBAAa,SAAS,IAAI;AAAA,MAAA;AAAA,IAC5B,CACD;AAED,WAAO,MAAM,YAAY;AAAA,EAAA,GACxB,CAAC,QAAQ,CAAC;AAEN,SAAA;AACT;"}
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from '../../preact/adapter.ts';
2
+ import { PdfEngine } from '@embedpdf/models';
3
+ import { PluginRegistry, IPlugin, PluginBatchRegistration } from '../../lib/index.ts';
4
+ import { PDFContextState } from '../context';
5
+ interface EmbedPDFProps {
6
+ engine: PdfEngine;
7
+ onInitialized?: (registry: PluginRegistry) => Promise<void>;
8
+ plugins: PluginBatchRegistration<IPlugin<any>, any>[];
9
+ children: ReactNode | ((state: PDFContextState) => ReactNode);
10
+ }
11
+ export declare function EmbedPDF({ engine, onInitialized, plugins, children }: EmbedPDFProps): import("preact").JSX.Element;
12
+ export {};
@@ -0,0 +1 @@
1
+ export * from './embed-pdf';
@@ -0,0 +1,7 @@
1
+ import { PluginRegistry } from '../lib/index.ts';
2
+ export interface PDFContextState {
3
+ registry: PluginRegistry | null;
4
+ isInitializing: boolean;
5
+ pluginsReady: boolean;
6
+ }
7
+ export declare const PDFContext: import('preact').Context<PDFContextState>;
@@ -0,0 +1,5 @@
1
+ export * from './use-capability';
2
+ export * from './use-registry';
3
+ export * from './use-store-state';
4
+ export * from './use-core-state';
5
+ export * from './use-plugin';
@@ -0,0 +1,16 @@
1
+ import { BasePlugin } from '../../lib/index.ts';
2
+ type CapabilityState<T extends BasePlugin> = {
3
+ provides: ReturnType<NonNullable<T['provides']>> | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ /**
8
+ * Hook to access a plugin's capability.
9
+ * @param pluginId The ID of the plugin to access
10
+ * @returns The capability provided by the plugin or null during initialization
11
+ * @example
12
+ * // Get zoom capability
13
+ * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);
14
+ */
15
+ export declare function useCapability<T extends BasePlugin>(pluginId: T['id']): CapabilityState<T>;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import { CoreState } from '../../lib/index.ts';
2
+ /**
3
+ * Hook that provides access to the current core state
4
+ * and re-renders the component only when the core state changes
5
+ */
6
+ export declare function useCoreState(): CoreState | null;
@@ -0,0 +1,16 @@
1
+ import { BasePlugin } from '../../lib/index.ts';
2
+ type PluginState<T extends BasePlugin> = {
3
+ plugin: T | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ /**
8
+ * Hook to access a plugin.
9
+ * @param pluginId The ID of the plugin to access
10
+ * @returns The plugin or null during initialization
11
+ * @example
12
+ * // Get zoom plugin
13
+ * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);
14
+ */
15
+ export declare function usePlugin<T extends BasePlugin>(pluginId: T['id']): PluginState<T>;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import { PDFContextState } from '../context';
2
+ /**
3
+ * Hook to access the PDF registry.
4
+ * @returns The PDF registry or null during initialization
5
+ */
6
+ export declare function useRegistry(): PDFContextState;
@@ -0,0 +1,6 @@
1
+ import { CoreState, StoreState } from '../../lib/index.ts';
2
+ /**
3
+ * Hook that provides access to the current global store state
4
+ * and re-renders the component when the state changes
5
+ */
6
+ export declare function useStoreState<T = CoreState>(): StoreState<T> | null;
@@ -0,0 +1,3 @@
1
+ export * from './context';
2
+ export * from './components';
3
+ export * from './hooks';
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from '../../react/adapter.ts';
2
+ import { PdfEngine } from '@embedpdf/models';
3
+ import { PluginRegistry, IPlugin, PluginBatchRegistration } from '../../lib/index.ts';
4
+ import { PDFContextState } from '../context';
5
+ interface EmbedPDFProps {
6
+ engine: PdfEngine;
7
+ onInitialized?: (registry: PluginRegistry) => Promise<void>;
8
+ plugins: PluginBatchRegistration<IPlugin<any>, any>[];
9
+ children: ReactNode | ((state: PDFContextState) => ReactNode);
10
+ }
11
+ export declare function EmbedPDF({ engine, onInitialized, plugins, children }: EmbedPDFProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1 @@
1
+ export * from './embed-pdf';
@@ -0,0 +1,7 @@
1
+ import { PluginRegistry } from '../lib/index.ts';
2
+ export interface PDFContextState {
3
+ registry: PluginRegistry | null;
4
+ isInitializing: boolean;
5
+ pluginsReady: boolean;
6
+ }
7
+ export declare const PDFContext: import('react').Context<PDFContextState>;
@@ -0,0 +1,5 @@
1
+ export * from './use-capability';
2
+ export * from './use-registry';
3
+ export * from './use-store-state';
4
+ export * from './use-core-state';
5
+ export * from './use-plugin';
@@ -0,0 +1,16 @@
1
+ import { BasePlugin } from '../../lib/index.ts';
2
+ type CapabilityState<T extends BasePlugin> = {
3
+ provides: ReturnType<NonNullable<T['provides']>> | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ /**
8
+ * Hook to access a plugin's capability.
9
+ * @param pluginId The ID of the plugin to access
10
+ * @returns The capability provided by the plugin or null during initialization
11
+ * @example
12
+ * // Get zoom capability
13
+ * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);
14
+ */
15
+ export declare function useCapability<T extends BasePlugin>(pluginId: T['id']): CapabilityState<T>;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import { CoreState } from '../../lib/index.ts';
2
+ /**
3
+ * Hook that provides access to the current core state
4
+ * and re-renders the component only when the core state changes
5
+ */
6
+ export declare function useCoreState(): CoreState | null;
@@ -0,0 +1,16 @@
1
+ import { BasePlugin } from '../../lib/index.ts';
2
+ type PluginState<T extends BasePlugin> = {
3
+ plugin: T | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ /**
8
+ * Hook to access a plugin.
9
+ * @param pluginId The ID of the plugin to access
10
+ * @returns The plugin or null during initialization
11
+ * @example
12
+ * // Get zoom plugin
13
+ * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);
14
+ */
15
+ export declare function usePlugin<T extends BasePlugin>(pluginId: T['id']): PluginState<T>;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import { PDFContextState } from '../context';
2
+ /**
3
+ * Hook to access the PDF registry.
4
+ * @returns The PDF registry or null during initialization
5
+ */
6
+ export declare function useRegistry(): PDFContextState;
@@ -0,0 +1,6 @@
1
+ import { CoreState, StoreState } from '../../lib/index.ts';
2
+ /**
3
+ * Hook that provides access to the current global store state
4
+ * and re-renders the component when the state changes
5
+ */
6
+ export declare function useStoreState<T = CoreState>(): StoreState<T> | null;
@@ -0,0 +1,3 @@
1
+ export * from './context';
2
+ export * from './components';
3
+ export * from './hooks';
@@ -0,0 +1,23 @@
1
+ import { PluginRegistry, PluginBatchRegistration } from '../../lib/index.ts';
2
+ import { PdfEngine } from '@embedpdf/models';
3
+ type __VLS_Props = {
4
+ engine: PdfEngine;
5
+ plugins: PluginBatchRegistration<any, any>[];
6
+ onInitialized?: (registry: PluginRegistry) => Promise<void>;
7
+ };
8
+ declare var __VLS_1: {
9
+ registry: PluginRegistry | null;
10
+ isInitializing: boolean;
11
+ pluginsReady: boolean;
12
+ };
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_1) => any;
15
+ };
16
+ declare const __VLS_component: 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>;
17
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
+ export default _default;
19
+ type __VLS_WithSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };
@@ -0,0 +1 @@
1
+ export { default as EmbedPDF } from './embed-pdf.vue';
@@ -0,0 +1,5 @@
1
+ export * from './use-core-state';
2
+ export * from './use-registry';
3
+ export * from './use-plugin';
4
+ export * from './use-capability';
5
+ export * from './use-store-state';
@@ -0,0 +1,15 @@
1
+ import { BasePlugin } from '../../lib/index.ts';
2
+ import { Ref } from 'vue';
3
+ export interface CapabilityState<C> {
4
+ provides: Ref<C | null>;
5
+ isLoading: Ref<boolean>;
6
+ ready: Ref<Promise<void>>;
7
+ }
8
+ /**
9
+ * Access the public capability exposed by a plugin.
10
+ *
11
+ * @example
12
+ * const { provides: zoom } = useCapability<ZoomPlugin>(ZoomPlugin.id);
13
+ * zoom.value?.zoomIn();
14
+ */
15
+ export declare function useCapability<T extends BasePlugin>(pluginId: T['id']): CapabilityState<ReturnType<NonNullable<T['provides']>>>;
@@ -0,0 +1,2 @@
1
+ import { CoreState } from '../../lib/index.ts';
2
+ export declare function useCoreState(): import('vue').Ref<CoreState | undefined, CoreState | undefined>;
@@ -0,0 +1,8 @@
1
+ import { ShallowRef, Ref } from 'vue';
2
+ import { BasePlugin } from '../../lib/index.ts';
3
+ export interface PluginState<T extends BasePlugin> {
4
+ plugin: ShallowRef<T | null>;
5
+ isLoading: Ref<boolean>;
6
+ ready: Ref<Promise<void>>;
7
+ }
8
+ export declare function usePlugin<T extends BasePlugin>(pluginId: T['id']): PluginState<T>;
@@ -0,0 +1 @@
1
+ export declare function useRegistry(): import('../context').PDFContextState;
@@ -0,0 +1,10 @@
1
+ import { CoreState, StoreState } from '../../lib/index.ts';
2
+ /**
3
+ * Reactive getter for the *entire* global store.
4
+ * Re‑emits whenever any slice changes.
5
+ *
6
+ * @example
7
+ * const state = useStoreState(); // Ref<StoreState<CoreState>>
8
+ * console.log(state.value.core.scale);
9
+ */
10
+ export declare function useStoreState<T = CoreState>(): import('vue').Ref<StoreState<T> | undefined, StoreState<T> | undefined>;
@@ -0,0 +1,8 @@
1
+ import { InjectionKey, Ref, ShallowRef } from 'vue';
2
+ import { PluginRegistry } from '../lib/index.ts';
3
+ export interface PDFContextState {
4
+ registry: ShallowRef<PluginRegistry | null>;
5
+ isInitializing: Ref<boolean>;
6
+ pluginsReady: Ref<boolean>;
7
+ }
8
+ export declare const pdfKey: InjectionKey<PDFContextState>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),n=require("@embedpdf/core"),r=Symbol("pdfKey");function t(){const n=e.inject(r);if(!n)throw new Error("useRegistry must be used inside <EmbedPDF>");return n}function o(n){const{registry:r}=t(),o=e.shallowRef(null),i=e.ref(!0),u=e.ref(new Promise((()=>{}))),l=()=>{var e;if(!r.value)return;const t=r.value.getPlugin(n);if(!t)throw new Error(`Plugin ${n} not found`);o.value=t,i.value=!1,u.value=(null==(e=t.ready)?void 0:e.call(t))??Promise.resolve()};return e.onMounted(l),e.watch(r,l),{plugin:o,isLoading:i,ready:u}}const i=e.defineComponent({__name:"embed-pdf",props:{engine:{},plugins:{},onInitialized:{type:Function}},setup(t){const o=t,i=e.shallowRef(null),u=e.ref(!0),l=e.ref(!1);return e.provide(r,{registry:i,isInitializing:u,pluginsReady:l}),e.onMounted((async()=>{var e;const r=new n.PluginRegistry(o.engine);r.registerPluginBatch(o.plugins),await r.initialize(),await(null==(e=o.onInitialized)?void 0:e.call(o,r)),i.value=r,u.value=!1,r.pluginsReady().then((()=>l.value=!0))})),e.onBeforeUnmount((()=>{var e;return null==(e=i.value)?void 0:e.destroy()})),(n,r)=>e.renderSlot(n.$slots,"default",{registry:i.value,isInitializing:u.value,pluginsReady:l.value})}});exports.EmbedPDF=i,exports.useCapability=function(n){const{plugin:r,isLoading:t,ready:i}=o(n);return{provides:e.computed((()=>{if(!r.value)return null;if(!r.value.provides)throw new Error(`Plugin ${n} does not implement provides()`);return r.value.provides()})),isLoading:t,ready:i}},exports.useCoreState=function(){const{registry:r}=t(),o=e.ref();return e.onMounted((()=>{const t=r.value.getStore();o.value=t.getState().core;const i=t.subscribe(((e,r,i)=>{t.isCoreAction(e)&&!n.arePropsEqual(r.core,i.core)&&(o.value=r.core)}));e.onBeforeUnmount(i)})),o},exports.usePlugin=o,exports.useRegistry=t,exports.useStoreState=function(){const{registry:n}=t(),r=e.ref();function o(){return n.value?(r.value=n.value.getStore().getState(),n.value.getStore().subscribe(((e,n)=>r.value=n))):()=>{}}let i=o();return e.watch(n,(()=>{null==i||i(),i=o()})),e.onBeforeUnmount((()=>null==i?void 0:i())),r};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/context.ts","../../src/vue/composables/use-registry.ts","../../src/vue/composables/use-plugin.ts","../../src/vue/components/embed-pdf.vue","../../src/vue/composables/use-capability.ts","../../src/vue/composables/use-core-state.ts","../../src/vue/composables/use-store-state.ts"],"sourcesContent":["import { InjectionKey, Ref, ShallowRef } from 'vue';\nimport type { PluginRegistry } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: ShallowRef<PluginRegistry | null>;\n isInitializing: Ref<boolean>;\n pluginsReady: Ref<boolean>;\n}\n\nexport const pdfKey: InjectionKey<PDFContextState> = Symbol('pdfKey');\n","import { inject } from 'vue';\nimport { pdfKey } from '../context';\n\nexport function useRegistry() {\n const ctx = inject(pdfKey);\n if (!ctx) throw new Error('useRegistry must be used inside <EmbedPDF>');\n return ctx;\n}\n","import { shallowRef, ref, onMounted, watch, type ShallowRef, type Ref } from 'vue';\nimport type { BasePlugin } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\nexport interface PluginState<T extends BasePlugin> {\n plugin: ShallowRef<T | null>;\n isLoading: Ref<boolean>;\n ready: Ref<Promise<void>>;\n}\n\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']): PluginState<T> {\n const { registry } = useRegistry();\n\n const plugin = shallowRef(null) as ShallowRef<T | null>;\n\n const isLoading = ref(true);\n const ready = ref<Promise<void>>(new Promise(() => {}));\n\n const load = () => {\n if (!registry.value) return;\n\n const p = registry.value.getPlugin<T>(pluginId);\n if (!p) throw new Error(`Plugin ${pluginId} not found`);\n\n plugin.value = p;\n isLoading.value = false;\n ready.value = p.ready?.() ?? Promise.resolve();\n };\n\n onMounted(load);\n watch(registry, load);\n\n return { plugin, isLoading, ready };\n}\n","<script setup lang=\"ts\">\nimport { ref, provide, onMounted, onBeforeUnmount, shallowRef } from 'vue';\nimport { PluginRegistry, PluginBatchRegistration } from '@embedpdf/core';\nimport { PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\n\nconst props = defineProps<{\n engine: PdfEngine;\n plugins: PluginBatchRegistration<any, any>[];\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n}>();\n\n/* reactive state */\nconst registry = shallowRef<PluginRegistry | null>(null);\nconst isInit = ref(true);\nconst pluginsOk = ref(false);\n\n/* expose to children */\nprovide<PDFContextState>(pdfKey, { registry, isInitializing: isInit, pluginsReady: pluginsOk });\n\nonMounted(async () => {\n const reg = new PluginRegistry(props.engine);\n reg.registerPluginBatch(props.plugins);\n await reg.initialize();\n await props.onInitialized?.(reg);\n\n registry.value = reg;\n isInit.value = false;\n\n reg.pluginsReady().then(() => (pluginsOk.value = true));\n});\n\nonBeforeUnmount(() => registry.value?.destroy());\n</script>\n\n<template>\n <!-- scoped slot keeps API parity with React version -->\n <slot :registry=\"registry\"\n :isInitializing=\"isInit\"\n :pluginsReady=\"pluginsOk\" />\n</template>","import type { BasePlugin } from '@embedpdf/core';\nimport { computed, type Ref } from 'vue';\nimport { usePlugin } from './use-plugin';\n\nexport interface CapabilityState<C> {\n provides: Ref<C | null>;\n isLoading: Ref<boolean>;\n ready: Ref<Promise<void>>;\n}\n\n/**\n * Access the public capability exposed by a plugin.\n *\n * @example\n * const { provides: zoom } = useCapability<ZoomPlugin>(ZoomPlugin.id);\n * zoom.value?.zoomIn();\n */\nexport function useCapability<T extends BasePlugin>(\n pluginId: T['id'],\n): CapabilityState<ReturnType<NonNullable<T['provides']>>> {\n const { plugin, isLoading, ready } = usePlugin<T>(pluginId);\n\n const provides = computed(() => {\n if (!plugin.value) return null;\n if (!plugin.value.provides) {\n throw new Error(`Plugin ${pluginId} does not implement provides()`);\n }\n return plugin.value.provides() as ReturnType<NonNullable<T['provides']>>;\n });\n\n return { provides, isLoading, ready };\n}\n","import { ref, onMounted, onBeforeUnmount } from 'vue';\nimport { arePropsEqual, type CoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\nexport function useCoreState() {\n const { registry } = useRegistry();\n const core = ref<CoreState>();\n\n onMounted(() => {\n const store = registry.value!.getStore();\n core.value = store.getState().core;\n\n const unsub = store.subscribe((action, newSt, oldSt) => {\n if (store.isCoreAction(action) && !arePropsEqual(newSt.core, oldSt.core)) {\n core.value = newSt.core;\n }\n });\n onBeforeUnmount(unsub);\n });\n\n return core;\n}\n","import { ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport type { CoreState, StoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Reactive getter for the *entire* global store.\n * Re‑emits whenever any slice changes.\n *\n * @example\n * const state = useStoreState(); // Ref<StoreState<CoreState>>\n * console.log(state.value.core.scale);\n */\nexport function useStoreState<T = CoreState>() {\n const { registry } = useRegistry();\n const state = ref<StoreState<T>>();\n\n function attach() {\n if (!registry.value) return () => {};\n\n // initial snapshot\n state.value = registry.value.getStore().getState() as StoreState<T>;\n\n // live updates\n return registry.value\n .getStore()\n .subscribe((_action, newState) => (state.value = newState as StoreState<T>));\n }\n\n /* attach now and re‑attach if registry instance ever changes */\n let unsubscribe = attach();\n watch(registry, () => {\n unsubscribe?.();\n unsubscribe = attach();\n });\n\n onBeforeUnmount(() => unsubscribe?.());\n\n return state;\n}\n"],"names":["pdfKey","Symbol","useRegistry","ctx","inject","Error","usePlugin","pluginId","registry","plugin","shallowRef","isLoading","ref","ready","Promise","load","value","p","getPlugin","_a","call","resolve","onMounted","vue","watch","props","__props","isInit","pluginsOk","provide","isInitializing","pluginsReady","async","reg","PluginRegistry","engine","registerPluginBatch","plugins","initialize","onInitialized","then","onBeforeUnmount","destroy","_renderSlot","_ctx","$slots","provides","computed","core","store","getStore","core$1","getState","unsub","subscribe","action","newSt","oldSt","isCoreAction","arePropsEqual","state","attach","_action","newState","unsubscribe"],"mappings":"mIASaA,EAAwCC,OAAO,UCNrD,SAASC,IACR,MAAAC,EAAMC,SAAOJ,GACnB,IAAKG,EAAW,MAAA,IAAIE,MAAM,8CACnB,OAAAF,CACT,CCGO,SAASG,EAAgCC,GACxC,MAAAC,SAAEA,GAAaN,IAEfO,EAASC,aAAW,MAEpBC,EAAYC,OAAI,GAChBC,EAAQD,EAAAA,IAAmB,IAAIE,SAAQ,UAEvCC,EAAO,WACP,IAACP,EAASQ,MAAO,OAErB,MAAMC,EAAIT,EAASQ,MAAME,UAAaX,GACtC,IAAKU,EAAG,MAAM,IAAIZ,MAAM,UAAUE,eAElCE,EAAOO,MAAQC,EACfN,EAAUK,OAAQ,EAClBH,EAAMG,OAAQ,OAAAG,EAAAF,EAAEJ,YAAF,EAAAM,EAAAC,KAAAH,KAAeH,QAAQO,SAAQ,EAMxC,OAHPC,EAAAA,UAAUP,GACVQ,EAAAC,MAAMhB,EAAUO,GAET,CAAEN,SAAQE,YAAWE,QAC9B,mHC3BA,MAAMY,EAAQC,EAORlB,EAAWE,aAAkC,MAC7CiB,EAAaf,OAAI,GACjBgB,EAAahB,OAAI,UAGvBW,EAAAM,QAAyB7B,EAAQ,CAAEQ,WAAUsB,eAAgBH,EAAQI,aAAcH,IAEnFN,EAAAA,WAAUU,gBACR,MAAMC,EAAM,IAAIC,iBAAeT,EAAMU,QACjCF,EAAAG,oBAAoBX,EAAMY,eACxBJ,EAAIK,mBACJ,OAAAnB,EAAAM,EAAMc,oBAAgB,EAAApB,EAAAC,KAAAK,EAAAQ,IAE5BzB,EAASQ,MAAQiB,EACjBN,EAAOX,OAAU,EAEjBiB,EAAIF,eAAeS,MAAK,IAAOZ,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,CACT"}
@@ -0,0 +1,2 @@
1
+ export * from './composables';
2
+ export { EmbedPDF } from './components';
@@ -0,0 +1,115 @@
1
+ import { inject, ref, onMounted, onBeforeUnmount, shallowRef, watch, computed, defineComponent, provide, renderSlot } from "vue";
2
+ import { arePropsEqual, PluginRegistry } from "@embedpdf/core";
3
+ const pdfKey = Symbol("pdfKey");
4
+ function useRegistry() {
5
+ const ctx = inject(pdfKey);
6
+ if (!ctx) throw new Error("useRegistry must be used inside <EmbedPDF>");
7
+ return ctx;
8
+ }
9
+ function useCoreState() {
10
+ const { registry } = useRegistry();
11
+ const core = ref();
12
+ onMounted(() => {
13
+ const store = registry.value.getStore();
14
+ core.value = store.getState().core;
15
+ const unsub = store.subscribe((action, newSt, oldSt) => {
16
+ if (store.isCoreAction(action) && !arePropsEqual(newSt.core, oldSt.core)) {
17
+ core.value = newSt.core;
18
+ }
19
+ });
20
+ onBeforeUnmount(unsub);
21
+ });
22
+ return core;
23
+ }
24
+ function usePlugin(pluginId) {
25
+ const { registry } = useRegistry();
26
+ const plugin = shallowRef(null);
27
+ const isLoading = ref(true);
28
+ const ready = ref(new Promise(() => {
29
+ }));
30
+ const load = () => {
31
+ var _a;
32
+ if (!registry.value) return;
33
+ const p = registry.value.getPlugin(pluginId);
34
+ if (!p) throw new Error(`Plugin ${pluginId} not found`);
35
+ plugin.value = p;
36
+ isLoading.value = false;
37
+ ready.value = ((_a = p.ready) == null ? void 0 : _a.call(p)) ?? Promise.resolve();
38
+ };
39
+ onMounted(load);
40
+ watch(registry, load);
41
+ return { plugin, isLoading, ready };
42
+ }
43
+ function useCapability(pluginId) {
44
+ const { plugin, isLoading, ready } = usePlugin(pluginId);
45
+ const provides = computed(() => {
46
+ if (!plugin.value) return null;
47
+ if (!plugin.value.provides) {
48
+ throw new Error(`Plugin ${pluginId} does not implement provides()`);
49
+ }
50
+ return plugin.value.provides();
51
+ });
52
+ return { provides, isLoading, ready };
53
+ }
54
+ function useStoreState() {
55
+ const { registry } = useRegistry();
56
+ const state = ref();
57
+ function attach() {
58
+ if (!registry.value) return () => {
59
+ };
60
+ state.value = registry.value.getStore().getState();
61
+ return registry.value.getStore().subscribe((_action, newState) => state.value = newState);
62
+ }
63
+ let unsubscribe = attach();
64
+ watch(registry, () => {
65
+ unsubscribe == null ? void 0 : unsubscribe();
66
+ unsubscribe = attach();
67
+ });
68
+ onBeforeUnmount(() => unsubscribe == null ? void 0 : unsubscribe());
69
+ return state;
70
+ }
71
+ const _sfc_main = /* @__PURE__ */ defineComponent({
72
+ __name: "embed-pdf",
73
+ props: {
74
+ engine: {},
75
+ plugins: {},
76
+ onInitialized: { type: Function }
77
+ },
78
+ setup(__props) {
79
+ const props = __props;
80
+ const registry = shallowRef(null);
81
+ const isInit = ref(true);
82
+ const pluginsOk = ref(false);
83
+ provide(pdfKey, { registry, isInitializing: isInit, pluginsReady: pluginsOk });
84
+ onMounted(async () => {
85
+ var _a;
86
+ const reg = new PluginRegistry(props.engine);
87
+ reg.registerPluginBatch(props.plugins);
88
+ await reg.initialize();
89
+ await ((_a = props.onInitialized) == null ? void 0 : _a.call(props, reg));
90
+ registry.value = reg;
91
+ isInit.value = false;
92
+ reg.pluginsReady().then(() => pluginsOk.value = true);
93
+ });
94
+ onBeforeUnmount(() => {
95
+ var _a;
96
+ return (_a = registry.value) == null ? void 0 : _a.destroy();
97
+ });
98
+ return (_ctx, _cache) => {
99
+ return renderSlot(_ctx.$slots, "default", {
100
+ registry: registry.value,
101
+ isInitializing: isInit.value,
102
+ pluginsReady: pluginsOk.value
103
+ });
104
+ };
105
+ }
106
+ });
107
+ export {
108
+ _sfc_main as EmbedPDF,
109
+ useCapability,
110
+ useCoreState,
111
+ usePlugin,
112
+ useRegistry,
113
+ useStoreState
114
+ };
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/context.ts","../../src/vue/composables/use-registry.ts","../../src/vue/composables/use-core-state.ts","../../src/vue/composables/use-plugin.ts","../../src/vue/composables/use-capability.ts","../../src/vue/composables/use-store-state.ts","../../src/vue/components/embed-pdf.vue"],"sourcesContent":["import { InjectionKey, Ref, ShallowRef } from 'vue';\nimport type { PluginRegistry } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: ShallowRef<PluginRegistry | null>;\n isInitializing: Ref<boolean>;\n pluginsReady: Ref<boolean>;\n}\n\nexport const pdfKey: InjectionKey<PDFContextState> = Symbol('pdfKey');\n","import { inject } from 'vue';\nimport { pdfKey } from '../context';\n\nexport function useRegistry() {\n const ctx = inject(pdfKey);\n if (!ctx) throw new Error('useRegistry must be used inside <EmbedPDF>');\n return ctx;\n}\n","import { ref, onMounted, onBeforeUnmount } from 'vue';\nimport { arePropsEqual, type CoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\nexport function useCoreState() {\n const { registry } = useRegistry();\n const core = ref<CoreState>();\n\n onMounted(() => {\n const store = registry.value!.getStore();\n core.value = store.getState().core;\n\n const unsub = store.subscribe((action, newSt, oldSt) => {\n if (store.isCoreAction(action) && !arePropsEqual(newSt.core, oldSt.core)) {\n core.value = newSt.core;\n }\n });\n onBeforeUnmount(unsub);\n });\n\n return core;\n}\n","import { shallowRef, ref, onMounted, watch, type ShallowRef, type Ref } from 'vue';\nimport type { BasePlugin } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\nexport interface PluginState<T extends BasePlugin> {\n plugin: ShallowRef<T | null>;\n isLoading: Ref<boolean>;\n ready: Ref<Promise<void>>;\n}\n\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']): PluginState<T> {\n const { registry } = useRegistry();\n\n const plugin = shallowRef(null) as ShallowRef<T | null>;\n\n const isLoading = ref(true);\n const ready = ref<Promise<void>>(new Promise(() => {}));\n\n const load = () => {\n if (!registry.value) return;\n\n const p = registry.value.getPlugin<T>(pluginId);\n if (!p) throw new Error(`Plugin ${pluginId} not found`);\n\n plugin.value = p;\n isLoading.value = false;\n ready.value = p.ready?.() ?? Promise.resolve();\n };\n\n onMounted(load);\n watch(registry, load);\n\n return { plugin, isLoading, ready };\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { computed, type Ref } from 'vue';\nimport { usePlugin } from './use-plugin';\n\nexport interface CapabilityState<C> {\n provides: Ref<C | null>;\n isLoading: Ref<boolean>;\n ready: Ref<Promise<void>>;\n}\n\n/**\n * Access the public capability exposed by a plugin.\n *\n * @example\n * const { provides: zoom } = useCapability<ZoomPlugin>(ZoomPlugin.id);\n * zoom.value?.zoomIn();\n */\nexport function useCapability<T extends BasePlugin>(\n pluginId: T['id'],\n): CapabilityState<ReturnType<NonNullable<T['provides']>>> {\n const { plugin, isLoading, ready } = usePlugin<T>(pluginId);\n\n const provides = computed(() => {\n if (!plugin.value) return null;\n if (!plugin.value.provides) {\n throw new Error(`Plugin ${pluginId} does not implement provides()`);\n }\n return plugin.value.provides() as ReturnType<NonNullable<T['provides']>>;\n });\n\n return { provides, isLoading, ready };\n}\n","import { ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport type { CoreState, StoreState } from '@embedpdf/core';\nimport { useRegistry } from './use-registry';\n\n/**\n * Reactive getter for the *entire* global store.\n * Re‑emits whenever any slice changes.\n *\n * @example\n * const state = useStoreState(); // Ref<StoreState<CoreState>>\n * console.log(state.value.core.scale);\n */\nexport function useStoreState<T = CoreState>() {\n const { registry } = useRegistry();\n const state = ref<StoreState<T>>();\n\n function attach() {\n if (!registry.value) return () => {};\n\n // initial snapshot\n state.value = registry.value.getStore().getState() as StoreState<T>;\n\n // live updates\n return registry.value\n .getStore()\n .subscribe((_action, newState) => (state.value = newState as StoreState<T>));\n }\n\n /* attach now and re‑attach if registry instance ever changes */\n let unsubscribe = attach();\n watch(registry, () => {\n unsubscribe?.();\n unsubscribe = attach();\n });\n\n onBeforeUnmount(() => unsubscribe?.());\n\n return state;\n}\n","<script setup lang=\"ts\">\nimport { ref, provide, onMounted, onBeforeUnmount, shallowRef } from 'vue';\nimport { PluginRegistry, PluginBatchRegistration } from '@embedpdf/core';\nimport { PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\n\nconst props = defineProps<{\n engine: PdfEngine;\n plugins: PluginBatchRegistration<any, any>[];\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n}>();\n\n/* reactive state */\nconst registry = shallowRef<PluginRegistry | null>(null);\nconst isInit = ref(true);\nconst pluginsOk = ref(false);\n\n/* expose to children */\nprovide<PDFContextState>(pdfKey, { registry, isInitializing: isInit, pluginsReady: pluginsOk });\n\nonMounted(async () => {\n const reg = new PluginRegistry(props.engine);\n reg.registerPluginBatch(props.plugins);\n await reg.initialize();\n await props.onInitialized?.(reg);\n\n registry.value = reg;\n isInit.value = false;\n\n reg.pluginsReady().then(() => (pluginsOk.value = true));\n});\n\nonBeforeUnmount(() => registry.value?.destroy());\n</script>\n\n<template>\n <!-- scoped slot keeps API parity with React version -->\n <slot :registry=\"registry\"\n :isInitializing=\"isInit\"\n :pluginsReady=\"pluginsOk\" />\n</template>"],"names":["_renderSlot"],"mappings":";;AASa,MAAA,SAAwC,OAAO,QAAQ;ACN7D,SAAS,cAAc;AACtB,QAAA,MAAM,OAAO,MAAM;AACzB,MAAI,CAAC,IAAW,OAAA,IAAI,MAAM,4CAA4C;AAC/D,SAAA;AACT;ACHO,SAAS,eAAe;AACvB,QAAA,EAAE,SAAS,IAAI,YAAY;AACjC,QAAM,OAAO,IAAe;AAE5B,YAAU,MAAM;AACR,UAAA,QAAQ,SAAS,MAAO,SAAS;AAClC,SAAA,QAAQ,MAAM,SAAW,EAAA;AAE9B,UAAM,QAAQ,MAAM,UAAU,CAAC,QAAQ,OAAO,UAAU;AAClD,UAAA,MAAM,aAAa,MAAM,KAAK,CAAC,cAAc,MAAM,MAAM,MAAM,IAAI,GAAG;AACxE,aAAK,QAAQ,MAAM;AAAA,MAAA;AAAA,IACrB,CACD;AACD,oBAAgB,KAAK;AAAA,EAAA,CACtB;AAEM,SAAA;AACT;ACXO,SAAS,UAAg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