@embedpdf/core 1.0.20 → 1.0.21
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 +29 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/plugin/builder.d.ts +11 -0
- package/dist/lib/types/plugin.d.ts +19 -0
- package/dist/preact/adapter.d.ts +2 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +41 -64
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +41 -64
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/auto-mount.d.ts +8 -0
- package/dist/shared-preact/components/embed-pdf.d.ts +21 -1
- package/dist/shared-preact/components/index.d.ts +0 -1
- package/dist/shared-react/components/auto-mount.d.ts +8 -0
- package/dist/shared-react/components/embed-pdf.d.ts +21 -1
- package/dist/shared-react/components/index.d.ts +0 -1
- package/dist/vue/components/auto-mount.vue.d.ts +18 -0
- package/dist/vue/components/embed-pdf.vue.d.ts +15 -6
- package/dist/vue/components/nested-wrapper.vue.d.ts +17 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +88 -4
- package/dist/vue/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/shared-preact/components/counter-rotate-container.d.ts +0 -33
- package/dist/shared-react/components/counter-rotate-container.d.ts +0 -33
|
@@ -5,16 +5,25 @@ type __VLS_Props = {
|
|
|
5
5
|
logger?: Logger;
|
|
6
6
|
plugins: PluginBatchRegistration<any, any>[];
|
|
7
7
|
onInitialized?: (registry: PluginRegistry) => Promise<void>;
|
|
8
|
+
autoMountDomElements?: boolean;
|
|
8
9
|
};
|
|
9
|
-
declare var
|
|
10
|
-
registry:
|
|
11
|
-
isInitializing:
|
|
12
|
-
pluginsReady:
|
|
10
|
+
declare var __VLS_6: {
|
|
11
|
+
registry: any;
|
|
12
|
+
isInitializing: any;
|
|
13
|
+
pluginsReady: any;
|
|
14
|
+
}, __VLS_8: {
|
|
15
|
+
registry: any;
|
|
16
|
+
isInitializing: any;
|
|
17
|
+
pluginsReady: any;
|
|
13
18
|
};
|
|
14
19
|
type __VLS_Slots = {} & {
|
|
15
|
-
default?: (props: typeof
|
|
20
|
+
default?: (props: typeof __VLS_6) => any;
|
|
21
|
+
} & {
|
|
22
|
+
default?: (props: typeof __VLS_8) => any;
|
|
16
23
|
};
|
|
17
|
-
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
24
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
25
|
+
autoMountDomElements: boolean;
|
|
26
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
18
27
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
19
28
|
export default _default;
|
|
20
29
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
wrappers: any[];
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_12: {}, __VLS_14: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_12) => any;
|
|
7
|
+
} & {
|
|
8
|
+
default?: (props: typeof __VLS_14) => any;
|
|
9
|
+
};
|
|
10
|
+
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>;
|
|
11
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
14
|
+
new (): {
|
|
15
|
+
$slots: S;
|
|
16
|
+
};
|
|
17
|
+
};
|
package/dist/vue/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core"),n=Symbol("pdfKey");function r(){const t=e.inject(n);if(!t)throw new Error("useRegistry must be used inside <EmbedPDF>");return t}function o(t){const{registry:n}=r(),o=e.shallowRef(null),l=e.ref(!0),u=e.ref(new Promise((()=>{}))),s=()=>{var e;if(!n.value)return;const r=n.value.getPlugin(t);if(!r)throw new Error(`Plugin ${t} not found`);o.value=r,l.value=!1,u.value=(null==(e=r.ready)?void 0:e.call(r))??Promise.resolve()};return e.onMounted(s),e.watch(n,s),{plugin:o,isLoading:l,ready:u}}const l=e.defineComponent({__name:"nested-wrapper",props:{wrappers:{}},setup:t=>(t,n)=>{const r=e.resolveComponent("NestedWrapper",!0);return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.wrappers[0]),null,{default:e.withCtx((()=>[t.wrappers.length>1?(e.openBlock(),e.createBlock(r,{key:0,wrappers:t.wrappers.slice(1)},{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default")])),_:3},8,["wrappers"])):e.renderSlot(t.$slots,"default",{key:1})])),_:3})}}),u=e.defineComponent({__name:"auto-mount",props:{plugins:{}},setup(n){const r=n,o=e.computed((()=>{const e=[],n=[];for(const o of r.plugins){const r=o.package;if(t.hasAutoMountElements(r)){const t=r.autoMountElements()||[];for(const r of t)"utility"===r.type?e.push(r.component):"wrapper"===r.type&&n.push(r.component)}}return{utilities:e,wrappers:n}}));return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[o.value.wrappers.length>0?(e.openBlock(),e.createBlock(l,{key:0,wrappers:o.value.wrappers},{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default")])),_:3},8,["wrappers"])):e.renderSlot(t.$slots,"default",{key:1}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value.utilities,((t,n)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t),{key:`utility-${n}`})))),128))],64))}}),s=e.defineComponent({__name:"embed-pdf",props:{engine:{},logger:{},plugins:{},onInitialized:{},autoMountDomElements:{type:Boolean,default:!0}},setup(r){const o=r,l=e.shallowRef(null),s=e.ref(!0),i=e.ref(!1);return e.provide(n,{registry:l,isInitializing:s,pluginsReady:i}),e.onMounted((async()=>{var e;const n=new t.PluginRegistry(o.engine,{logger:o.logger});n.registerPluginBatch(o.plugins),await n.initialize(),await(null==(e=o.onInitialized)?void 0:e.call(o,n)),l.value=n,s.value=!1,n.pluginsReady().then((()=>i.value=!0))})),e.onBeforeUnmount((()=>{var e;return null==(e=l.value)?void 0:e.destroy()})),(t,n)=>i.value&&t.autoMountDomElements?(e.openBlock(),e.createBlock(u,{key:0,plugins:t.plugins},{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{registry:l.value,isInitializing:s.value,pluginsReady:i.value})])),_:3},8,["plugins"])):e.renderSlot(t.$slots,"default",{key:1,registry:l.value,isInitializing:s.value,pluginsReady:i.value})}});exports.EmbedPDF=s,exports.useCapability=function(t){const{plugin:n,isLoading:r,ready:l}=o(t);return{provides:e.computed((()=>{if(!n.value)return null;if(!n.value.provides)throw new Error(`Plugin ${t} does not implement provides()`);return n.value.provides()})),isLoading:r,ready:l}},exports.useCoreState=function(){const{registry:n}=r(),o=e.ref();return e.onMounted((()=>{const r=n.value.getStore();o.value=r.getState().core;const l=r.subscribe(((e,n,l)=>{r.isCoreAction(e)&&!t.arePropsEqual(n.core,l.core)&&(o.value=n.core)}));e.onBeforeUnmount(l)})),o},exports.usePlugin=o,exports.useRegistry=r,exports.useStoreState=function(){const{registry:t}=r(),n=e.ref();function o(){return t.value?(n.value=t.value.getStore().getState(),t.value.getStore().subscribe(((e,t)=>n.value=t))):()=>{}}let l=o();return e.watch(t,(()=>{null==l||l(),l=o()})),e.onBeforeUnmount((()=>null==l?void 0:l())),n};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/vue/index.cjs.map
CHANGED
|
@@ -1 +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 { Logger, PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\n\nconst props = defineProps<{\n engine: PdfEngine;\n logger?: Logger;\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, { logger: props.logger });\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\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n</template>\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 } 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","logger","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,6HC3BA,MAAMY,EAAQC,EAQRlB,EAAWE,aAAkC,MAC7CiB,EAASf,OAAI,GACbgB,EAAYhB,OAAI,UAGtBW,EAAAM,QAAyB7B,EAAQ,CAAEQ,WAAUsB,eAAgBH,EAAQI,aAAcH,IAEnFN,EAAAA,WAAUU,gBACF,MAAAC,EAAM,IAAIC,EAAAA,eAAeT,EAAMU,OAAQ,CAAEC,OAAQX,EAAMW,SACzDH,EAAAI,oBAAoBZ,EAAMa,eACxBL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AI/E,IAAIC,EAAcH,IAQX,OAPPvC,EAAAC,MAAMhB,GAAU,KACA,MAAAyD,GAAAA,IACdA,EAAcH,GAAO,IAGPvC,EAAAmB,iBAAA,IAAqB,MAAfuB,OAAe,EAAAA,MAE9BJ,CACT"}
|
|
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/nested-wrapper.vue","../../src/vue/components/auto-mount.vue","../../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\">\ndefineProps<{\n wrappers: any[];\n}>();\n</script>\n\n<template>\n <component :is=\"wrappers[0]\">\n <NestedWrapper v-if=\"wrappers.length > 1\" :wrappers=\"wrappers.slice(1)\">\n <slot />\n </NestedWrapper>\n <slot v-else />\n </component>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\nimport NestedWrapper from './nested-wrapper.vue';\n\nconst props = defineProps<{\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n}>();\n\nconst elements = computed(() => {\n const utilities: any[] = [];\n const wrappers: any[] = [];\n\n for (const reg of props.plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements() || [];\n\n for (const element of elements) {\n if (element.type === 'utility') {\n utilities.push(element.component);\n } else if (element.type === 'wrapper') {\n wrappers.push(element.component);\n }\n }\n }\n }\n\n return { utilities, wrappers };\n});\n</script>\n\n<template>\n <NestedWrapper v-if=\"elements.wrappers.length > 0\" :wrappers=\"elements.wrappers\">\n <slot />\n </NestedWrapper>\n <slot v-else />\n\n <component\n v-for=\"(utility, index) in elements.utilities\"\n :key=\"`utility-${index}`\"\n :is=\"utility\"\n />\n</template>\n","<script setup lang=\"ts\">\nimport { ref, provide, onMounted, onBeforeUnmount, shallowRef } from 'vue';\nimport { PluginRegistry, PluginBatchRegistration } from '@embedpdf/core';\nimport { Logger, PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\nimport AutoMount from './auto-mount.vue';\n\nconst props = withDefaults(\n defineProps<{\n engine: PdfEngine;\n logger?: Logger;\n plugins: PluginBatchRegistration<any, any>[];\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n autoMountDomElements?: boolean;\n }>(),\n {\n autoMountDomElements: true,\n },\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, { logger: props.logger });\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 <AutoMount v-if=\"pluginsOk && autoMountDomElements\" :plugins=\"plugins\">\n <!-- scoped slot keeps API parity with React version -->\n <slot :registry=\"registry\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n </AutoMount>\n\n <!-- No auto-mount or not ready yet -->\n <slot v-else :registry=\"registry\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n</template>\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 } 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","_openBlock","openBlock","_createBlock","_resolveDynamicComponent","resolveDynamicComponent","wrappers","length","_component_NestedWrapper","slice","_renderSlot","_ctx","$slots","renderSlot","key","props","__props","elements","computed","utilities","reg","plugins","pkg","package","hasAutoMountElements","autoMountElements","element","type","push","component","NestedWrapper","_createElementBlock","createElementBlock","_Fragment","utility","index","isInit","pluginsOk","provide","isInitializing","pluginsReady","async","PluginRegistry","engine","logger","registerPluginBatch","initialize","onInitialized","then","onBeforeUnmount","destroy","autoMountDomElements","AutoMount","provides","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,wIC1BE,OAAAY,EAAAC,YAAAC,EAAAA,YAKYC,EAAAC,wBALIC,EAAQA,SAAA,IAAA,KAAA,oBACtB,IAEgB,CAFKA,EAAAA,SAASC,OAAM,iBAApCJ,cAEgBK,EAAA,OAF2BF,SAAUA,EAAQA,SAACG,MAAK,wBACjE,IAAQ,CAARC,aAAQC,EAAAC,OAAA,oCAEVF,EAAeG,WAAAF,EAAAC,OAAA,UAAA,CAAAE,IAAA,qFCNnB,MAAMC,EAAQC,EAIRC,EAAWC,EAAAA,UAAS,KACxB,MAAMC,EAAmB,GACnBb,EAAkB,GAEb,IAAA,MAAAc,KAAOL,EAAMM,QAAS,CAC/B,MAAMC,EAAMF,EAAIG,QACZC,GAAAA,EAAAA,qBAAqBF,GAAM,CAC7B,MAAML,EAAWK,EAAIG,qBAAuB,GAE5C,IAAA,MAAWC,KAAWT,EACC,YAAjBS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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject, ref, onMounted, onBeforeUnmount, shallowRef, watch, computed, defineComponent,
|
|
2
|
-
import { arePropsEqual, PluginRegistry } from "@embedpdf/core";
|
|
1
|
+
import { inject, ref, onMounted, onBeforeUnmount, shallowRef, watch, computed, defineComponent, resolveComponent, createBlock, openBlock, resolveDynamicComponent, withCtx, renderSlot, createElementBlock, Fragment, renderList, provide } from "vue";
|
|
2
|
+
import { arePropsEqual, hasAutoMountElements, PluginRegistry } from "@embedpdf/core";
|
|
3
3
|
const pdfKey = Symbol("pdfKey");
|
|
4
4
|
function useRegistry() {
|
|
5
5
|
const ctx = inject(pdfKey);
|
|
@@ -68,13 +68,84 @@ function useStoreState() {
|
|
|
68
68
|
onBeforeUnmount(() => unsubscribe == null ? void 0 : unsubscribe());
|
|
69
69
|
return state;
|
|
70
70
|
}
|
|
71
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
72
|
+
__name: "nested-wrapper",
|
|
73
|
+
props: {
|
|
74
|
+
wrappers: {}
|
|
75
|
+
},
|
|
76
|
+
setup(__props) {
|
|
77
|
+
return (_ctx, _cache) => {
|
|
78
|
+
const _component_NestedWrapper = resolveComponent("NestedWrapper", true);
|
|
79
|
+
return openBlock(), createBlock(resolveDynamicComponent(_ctx.wrappers[0]), null, {
|
|
80
|
+
default: withCtx(() => [
|
|
81
|
+
_ctx.wrappers.length > 1 ? (openBlock(), createBlock(_component_NestedWrapper, {
|
|
82
|
+
key: 0,
|
|
83
|
+
wrappers: _ctx.wrappers.slice(1)
|
|
84
|
+
}, {
|
|
85
|
+
default: withCtx(() => [
|
|
86
|
+
renderSlot(_ctx.$slots, "default")
|
|
87
|
+
]),
|
|
88
|
+
_: 3
|
|
89
|
+
}, 8, ["wrappers"])) : renderSlot(_ctx.$slots, "default", { key: 1 })
|
|
90
|
+
]),
|
|
91
|
+
_: 3
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
97
|
+
__name: "auto-mount",
|
|
98
|
+
props: {
|
|
99
|
+
plugins: {}
|
|
100
|
+
},
|
|
101
|
+
setup(__props) {
|
|
102
|
+
const props = __props;
|
|
103
|
+
const elements = computed(() => {
|
|
104
|
+
const utilities = [];
|
|
105
|
+
const wrappers = [];
|
|
106
|
+
for (const reg of props.plugins) {
|
|
107
|
+
const pkg = reg.package;
|
|
108
|
+
if (hasAutoMountElements(pkg)) {
|
|
109
|
+
const elements2 = pkg.autoMountElements() || [];
|
|
110
|
+
for (const element of elements2) {
|
|
111
|
+
if (element.type === "utility") {
|
|
112
|
+
utilities.push(element.component);
|
|
113
|
+
} else if (element.type === "wrapper") {
|
|
114
|
+
wrappers.push(element.component);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return { utilities, wrappers };
|
|
120
|
+
});
|
|
121
|
+
return (_ctx, _cache) => {
|
|
122
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
123
|
+
elements.value.wrappers.length > 0 ? (openBlock(), createBlock(_sfc_main$2, {
|
|
124
|
+
key: 0,
|
|
125
|
+
wrappers: elements.value.wrappers
|
|
126
|
+
}, {
|
|
127
|
+
default: withCtx(() => [
|
|
128
|
+
renderSlot(_ctx.$slots, "default")
|
|
129
|
+
]),
|
|
130
|
+
_: 3
|
|
131
|
+
}, 8, ["wrappers"])) : renderSlot(_ctx.$slots, "default", { key: 1 }),
|
|
132
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(elements.value.utilities, (utility, index) => {
|
|
133
|
+
return openBlock(), createBlock(resolveDynamicComponent(utility), {
|
|
134
|
+
key: `utility-${index}`
|
|
135
|
+
});
|
|
136
|
+
}), 128))
|
|
137
|
+
], 64);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
});
|
|
71
141
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
72
142
|
__name: "embed-pdf",
|
|
73
143
|
props: {
|
|
74
144
|
engine: {},
|
|
75
145
|
logger: {},
|
|
76
146
|
plugins: {},
|
|
77
|
-
onInitialized: {
|
|
147
|
+
onInitialized: {},
|
|
148
|
+
autoMountDomElements: { type: Boolean, default: true }
|
|
78
149
|
},
|
|
79
150
|
setup(__props) {
|
|
80
151
|
const props = __props;
|
|
@@ -97,7 +168,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
97
168
|
return (_a = registry.value) == null ? void 0 : _a.destroy();
|
|
98
169
|
});
|
|
99
170
|
return (_ctx, _cache) => {
|
|
100
|
-
return
|
|
171
|
+
return pluginsOk.value && _ctx.autoMountDomElements ? (openBlock(), createBlock(_sfc_main$1, {
|
|
172
|
+
key: 0,
|
|
173
|
+
plugins: _ctx.plugins
|
|
174
|
+
}, {
|
|
175
|
+
default: withCtx(() => [
|
|
176
|
+
renderSlot(_ctx.$slots, "default", {
|
|
177
|
+
registry: registry.value,
|
|
178
|
+
isInitializing: isInit.value,
|
|
179
|
+
pluginsReady: pluginsOk.value
|
|
180
|
+
})
|
|
181
|
+
]),
|
|
182
|
+
_: 3
|
|
183
|
+
}, 8, ["plugins"])) : renderSlot(_ctx.$slots, "default", {
|
|
184
|
+
key: 1,
|
|
101
185
|
registry: registry.value,
|
|
102
186
|
isInitializing: isInit.value,
|
|
103
187
|
pluginsReady: pluginsOk.value
|
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +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 { Logger, PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\n\nconst props = defineProps<{\n engine: PdfEngine;\n logger?: Logger;\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, { logger: props.logger });\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\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n</template>\n"],"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,UAAgC,UAAmC;AAC3E,QAAA,EAAE,SAAS,IAAI,YAAY;AAE3B,QAAA,SAAS,WAAW,IAAI;AAExB,QAAA,YAAY,IAAI,IAAI;AAC1B,QAAM,QAAQ,IAAmB,IAAI,QAAQ,MAAM;AAAA,EAAA,CAAE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AAY,IAAI,KAAK;AAG3B,YAAyB,QAAQ,EAAE,UAAU,gBAAgB,QAAQ,cAAc,WAAW;AAE9F,cAAU,YAAY;;AACd,YAAA,MAAM,IAAI,eAAe,MAAM,QAAQ,EAAE,QAAQ,MAAM,QAAQ;AACjE,UAAA,oBAAoB,MAAM,OAAO;AACrC,YAAM,IAAI,WAAW;AACf,cAAA,WAAM,kBAAN,+BAAsB;AAE5B,eAAS,QAAQ;AACjB,aAAO,QAAQ;AAEf,UAAI,eAAe,KAAK,MAAO,UAAU,QAAQ,IAAK;AAAA,IAAA,CACvD;AAED,oBAAgB,MAAM;;AAAA,4BAAS,UAAT,mBAAgB;AAAA,KAAS;;AAK7C,aAAAA,WAAgF,KAAA,QAAA,WAAA;AAAA,QAAzE,UAAU,SAAQ;AAAA,QAAG,gBAAgB,OAAM;AAAA,QAAG,cAAc,UAAS;AAAA,MAAA;;;;"}
|
|
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/nested-wrapper.vue","../../src/vue/components/auto-mount.vue","../../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\">\ndefineProps<{\n wrappers: any[];\n}>();\n</script>\n\n<template>\n <component :is=\"wrappers[0]\">\n <NestedWrapper v-if=\"wrappers.length > 1\" :wrappers=\"wrappers.slice(1)\">\n <slot />\n </NestedWrapper>\n <slot v-else />\n </component>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\nimport NestedWrapper from './nested-wrapper.vue';\n\nconst props = defineProps<{\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n}>();\n\nconst elements = computed(() => {\n const utilities: any[] = [];\n const wrappers: any[] = [];\n\n for (const reg of props.plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements() || [];\n\n for (const element of elements) {\n if (element.type === 'utility') {\n utilities.push(element.component);\n } else if (element.type === 'wrapper') {\n wrappers.push(element.component);\n }\n }\n }\n }\n\n return { utilities, wrappers };\n});\n</script>\n\n<template>\n <NestedWrapper v-if=\"elements.wrappers.length > 0\" :wrappers=\"elements.wrappers\">\n <slot />\n </NestedWrapper>\n <slot v-else />\n\n <component\n v-for=\"(utility, index) in elements.utilities\"\n :key=\"`utility-${index}`\"\n :is=\"utility\"\n />\n</template>\n","<script setup lang=\"ts\">\nimport { ref, provide, onMounted, onBeforeUnmount, shallowRef } from 'vue';\nimport { PluginRegistry, PluginBatchRegistration } from '@embedpdf/core';\nimport { Logger, PdfEngine } from '@embedpdf/models';\nimport { pdfKey, PDFContextState } from '../context';\nimport AutoMount from './auto-mount.vue';\n\nconst props = withDefaults(\n defineProps<{\n engine: PdfEngine;\n logger?: Logger;\n plugins: PluginBatchRegistration<any, any>[];\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n autoMountDomElements?: boolean;\n }>(),\n {\n autoMountDomElements: true,\n },\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, { logger: props.logger });\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 <AutoMount v-if=\"pluginsOk && autoMountDomElements\" :plugins=\"plugins\">\n <!-- scoped slot keeps API parity with React version -->\n <slot :registry=\"registry\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n </AutoMount>\n\n <!-- No auto-mount or not ready yet -->\n <slot v-else :registry=\"registry\" :isInitializing=\"isInit\" :pluginsReady=\"pluginsOk\" />\n</template>\n"],"names":["_openBlock","_createBlock","_resolveDynamicComponent","wrappers","_renderSlot","elements","NestedWrapper","_createEl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AA,4BAAS,UAAT,mBAAgB;AAAA,KAAS;;AAI5B,aAAA,UAAA,SAAaO,KAAoB,qCAAlDR,YAGYS,aAAA;AAAA;QAHyC,SAASC,KAAO;AAAA,MAAA;yBAEnE,MAAgF;AAAA,UAAhFP,WAAgF,KAAA,QAAA,WAAA;AAAA,YAAzE,UAAU,SAAQ;AAAA,YAAG,gBAAgB,OAAM;AAAA,YAAG,cAAc,UAAS;AAAA;;;4BAI9EA,WAAuF,KAAA,QAAA,WAAA;AAAA;QAAzE,UAAU,SAAQ;AAAA,QAAG,gBAAgB,OAAM;AAAA,QAAG,cAAc,UAAS;AAAA,MAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@embedpdf/build": "1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@embedpdf/engines": "1.0.
|
|
37
|
-
"@embedpdf/models": "1.0.
|
|
36
|
+
"@embedpdf/engines": "1.0.21",
|
|
37
|
+
"@embedpdf/models": "1.0.21"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"preact": "^10.26.4",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Rect, Rotation } from '@embedpdf/models';
|
|
2
|
-
import { ReactNode, CSSProperties, PointerEvent, TouchEvent } from '../../preact/adapter.ts';
|
|
3
|
-
interface CounterRotateProps {
|
|
4
|
-
rect: Rect;
|
|
5
|
-
rotation: Rotation;
|
|
6
|
-
}
|
|
7
|
-
interface CounterTransformResult {
|
|
8
|
-
matrix: string;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Given an already-placed rect (left/top/width/height in px) and the page rotation,
|
|
14
|
-
* return the counter-rotation matrix + adjusted width/height.
|
|
15
|
-
*
|
|
16
|
-
* transform-origin is expected to be "0 0".
|
|
17
|
-
* left/top DO NOT change, apply them as-is.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult;
|
|
20
|
-
export interface MenuWrapperProps {
|
|
21
|
-
style: CSSProperties;
|
|
22
|
-
onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
|
|
23
|
-
onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;
|
|
24
|
-
}
|
|
25
|
-
interface CounterRotateComponentProps extends CounterRotateProps {
|
|
26
|
-
children: (props: {
|
|
27
|
-
matrix: string;
|
|
28
|
-
rect: Rect;
|
|
29
|
-
menuWrapperProps: MenuWrapperProps;
|
|
30
|
-
}) => ReactNode;
|
|
31
|
-
}
|
|
32
|
-
export declare function CounterRotate({ children, ...props }: CounterRotateComponentProps): import("preact").JSX.Element;
|
|
33
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Rect, Rotation } from '@embedpdf/models';
|
|
2
|
-
import { ReactNode, CSSProperties, PointerEvent, TouchEvent } from '../../react/adapter.ts';
|
|
3
|
-
interface CounterRotateProps {
|
|
4
|
-
rect: Rect;
|
|
5
|
-
rotation: Rotation;
|
|
6
|
-
}
|
|
7
|
-
interface CounterTransformResult {
|
|
8
|
-
matrix: string;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Given an already-placed rect (left/top/width/height in px) and the page rotation,
|
|
14
|
-
* return the counter-rotation matrix + adjusted width/height.
|
|
15
|
-
*
|
|
16
|
-
* transform-origin is expected to be "0 0".
|
|
17
|
-
* left/top DO NOT change, apply them as-is.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult;
|
|
20
|
-
export interface MenuWrapperProps {
|
|
21
|
-
style: CSSProperties;
|
|
22
|
-
onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
|
|
23
|
-
onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;
|
|
24
|
-
}
|
|
25
|
-
interface CounterRotateComponentProps extends CounterRotateProps {
|
|
26
|
-
children: (props: {
|
|
27
|
-
matrix: string;
|
|
28
|
-
rect: Rect;
|
|
29
|
-
menuWrapperProps: MenuWrapperProps;
|
|
30
|
-
}) => ReactNode;
|
|
31
|
-
}
|
|
32
|
-
export declare function CounterRotate({ children, ...props }: CounterRotateComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export {};
|