@embedpdf/core 2.15.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -21
- package/dist/index.cjs +864 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +313 -0
- package/dist/index.d.ts +313 -1
- package/dist/index.js +816 -2124
- package/dist/index.js.map +1 -1
- package/package.json +22 -52
- package/README.md +0 -40
- package/dist/lib/base/base-plugin.d.ts +0 -190
- package/dist/lib/index.d.ts +0 -17
- package/dist/lib/plugin/builder.d.ts +0 -11
- package/dist/lib/registry/plugin-registry.d.ts +0 -104
- package/dist/lib/store/actions.d.ts +0 -154
- package/dist/lib/store/index.d.ts +0 -6
- package/dist/lib/store/initial-state.d.ts +0 -31
- package/dist/lib/store/plugin-store.d.ts +0 -48
- package/dist/lib/store/reducer-helpers.d.ts +0 -11
- package/dist/lib/store/reducer.d.ts +0 -4
- package/dist/lib/store/selectors.d.ts +0 -41
- package/dist/lib/store/store.d.ts +0 -106
- package/dist/lib/store/types.d.ts +0 -28
- package/dist/lib/types/errors.d.ts +0 -21
- package/dist/lib/types/permissions.d.ts +0 -55
- package/dist/lib/types/plugin.d.ts +0 -75
- package/dist/lib/utils/dependency-resolver.d.ts +0 -6
- package/dist/lib/utils/event-control.d.ts +0 -58
- package/dist/lib/utils/eventing.d.ts +0 -19
- package/dist/lib/utils/math.d.ts +0 -22
- package/dist/lib/utils/plugin-helpers.d.ts +0 -6
- package/dist/lib/utils/scoped-eventing.d.ts +0 -71
- package/dist/lib/utils/typed-object.d.ts +0 -12
- package/dist/preact/adapter.d.ts +0 -11
- package/dist/preact/index.cjs +0 -2
- package/dist/preact/index.cjs.map +0 -1
- package/dist/preact/index.d.ts +0 -1
- package/dist/preact/index.js +0 -323
- package/dist/preact/index.js.map +0 -1
- package/dist/react/adapter.d.ts +0 -2
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -322
- package/dist/react/index.js.map +0 -1
- package/dist/shared/components/auto-mount.d.ts +0 -8
- package/dist/shared/components/embed-pdf.d.ts +0 -37
- package/dist/shared/components/index.d.ts +0 -1
- package/dist/shared/context.d.ts +0 -12
- package/dist/shared/hooks/index.d.ts +0 -7
- package/dist/shared/hooks/use-capability.d.ts +0 -16
- package/dist/shared/hooks/use-core-state.d.ts +0 -8
- package/dist/shared/hooks/use-document-permissions.d.ts +0 -35
- package/dist/shared/hooks/use-document-state.d.ts +0 -8
- package/dist/shared/hooks/use-plugin.d.ts +0 -16
- package/dist/shared/hooks/use-registry.d.ts +0 -6
- package/dist/shared/hooks/use-store-state.d.ts +0 -6
- package/dist/shared/index.d.ts +0 -3
- package/dist/shared-preact/components/auto-mount.d.ts +0 -8
- package/dist/shared-preact/components/embed-pdf.d.ts +0 -37
- package/dist/shared-preact/components/index.d.ts +0 -1
- package/dist/shared-preact/context.d.ts +0 -12
- package/dist/shared-preact/hooks/index.d.ts +0 -7
- package/dist/shared-preact/hooks/use-capability.d.ts +0 -16
- package/dist/shared-preact/hooks/use-core-state.d.ts +0 -8
- package/dist/shared-preact/hooks/use-document-permissions.d.ts +0 -35
- package/dist/shared-preact/hooks/use-document-state.d.ts +0 -8
- package/dist/shared-preact/hooks/use-plugin.d.ts +0 -16
- package/dist/shared-preact/hooks/use-registry.d.ts +0 -6
- package/dist/shared-preact/hooks/use-store-state.d.ts +0 -6
- package/dist/shared-preact/index.d.ts +0 -3
- package/dist/shared-react/components/auto-mount.d.ts +0 -8
- package/dist/shared-react/components/embed-pdf.d.ts +0 -37
- package/dist/shared-react/components/index.d.ts +0 -1
- package/dist/shared-react/context.d.ts +0 -12
- package/dist/shared-react/hooks/index.d.ts +0 -7
- package/dist/shared-react/hooks/use-capability.d.ts +0 -16
- package/dist/shared-react/hooks/use-core-state.d.ts +0 -8
- package/dist/shared-react/hooks/use-document-permissions.d.ts +0 -35
- package/dist/shared-react/hooks/use-document-state.d.ts +0 -8
- package/dist/shared-react/hooks/use-plugin.d.ts +0 -16
- package/dist/shared-react/hooks/use-registry.d.ts +0 -6
- package/dist/shared-react/hooks/use-store-state.d.ts +0 -6
- package/dist/shared-react/index.d.ts +0 -3
- package/dist/svelte/components/AutoMount.svelte.d.ts +0 -9
- package/dist/svelte/components/EmbedPDF.svelte.d.ts +0 -40
- package/dist/svelte/components/NestedWrapper.svelte.d.ts +0 -10
- package/dist/svelte/components/index.d.ts +0 -1
- package/dist/svelte/hooks/index.d.ts +0 -6
- package/dist/svelte/hooks/use-capability.svelte.d.ts +0 -14
- package/dist/svelte/hooks/use-core-state.svelte.d.ts +0 -9
- package/dist/svelte/hooks/use-document-permissions.svelte.d.ts +0 -35
- package/dist/svelte/hooks/use-document-state.svelte.d.ts +0 -9
- package/dist/svelte/hooks/use-plugin.svelte.d.ts +0 -14
- package/dist/svelte/hooks/use-registry.svelte.d.ts +0 -17
- package/dist/svelte/index.cjs +0 -2
- package/dist/svelte/index.cjs.map +0 -1
- package/dist/svelte/index.d.ts +0 -2
- package/dist/svelte/index.js +0 -430
- package/dist/svelte/index.js.map +0 -1
- package/dist/vue/components/auto-mount.vue.d.ts +0 -19
- package/dist/vue/components/embed-pdf.vue.d.ts +0 -104
- package/dist/vue/components/index.d.ts +0 -1
- package/dist/vue/components/nested-wrapper.vue.d.ts +0 -19
- package/dist/vue/composables/index.d.ts +0 -7
- package/dist/vue/composables/use-capability.d.ts +0 -15
- package/dist/vue/composables/use-core-state.d.ts +0 -9
- package/dist/vue/composables/use-document-permissions.d.ts +0 -36
- package/dist/vue/composables/use-document-state.d.ts +0 -8
- package/dist/vue/composables/use-plugin.d.ts +0 -8
- package/dist/vue/composables/use-registry.d.ts +0 -1
- package/dist/vue/composables/use-store-state.d.ts +0 -10
- package/dist/vue/context.d.ts +0 -13
- package/dist/vue/index.cjs +0 -2
- package/dist/vue/index.cjs.map +0 -1
- package/dist/vue/index.d.ts +0 -2
- package/dist/vue/index.js +0 -384
- package/dist/vue/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,71 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Pure, framework-free runtime for the EmbedPDF v3 viewer: store, typed capabilities, and plugin lifecycle. DOM-free and serializable.",
|
|
4
6
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
+
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
16
|
-
"types": "./dist/react/index.d.ts",
|
|
17
|
-
"import": "./dist/react/index.js",
|
|
18
|
-
"require": "./dist/react/index.cjs"
|
|
19
|
-
},
|
|
20
|
-
"./preact": {
|
|
21
|
-
"types": "./dist/preact/index.d.ts",
|
|
22
|
-
"import": "./dist/preact/index.js",
|
|
23
|
-
"require": "./dist/preact/index.cjs"
|
|
24
|
-
},
|
|
25
|
-
"./vue": {
|
|
26
|
-
"types": "./dist/vue/index.d.ts",
|
|
27
|
-
"import": "./dist/vue/index.js",
|
|
28
|
-
"require": "./dist/vue/index.cjs"
|
|
29
|
-
},
|
|
30
|
-
"./svelte": {
|
|
31
|
-
"types": "./dist/svelte/index.d.ts",
|
|
32
|
-
"import": "./dist/svelte/index.js",
|
|
33
|
-
"svelte": "./dist/svelte/index.js",
|
|
34
|
-
"require": "./dist/svelte/index.cjs"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/react": "^18.2.0",
|
|
39
|
-
"typescript": "^5.0.0",
|
|
40
|
-
"@embedpdf/build": "1.1.0"
|
|
15
|
+
"./package.json": "./package.json"
|
|
41
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
42
20
|
"dependencies": {
|
|
43
|
-
"@embedpdf/
|
|
44
|
-
"@embedpdf/engines": "2.15.0"
|
|
21
|
+
"@embedpdf/engine-core": "3.0.0-next.1"
|
|
45
22
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"svelte": ">=5 <6",
|
|
51
|
-
"vue": ">=3.2.0"
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.0.0",
|
|
25
|
+
"vitest": "^2.1.9",
|
|
26
|
+
"@embedpdf/tooling-build": "0.0.0"
|
|
52
27
|
},
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/embedpdf/embed-pdf-viewer.git",
|
|
33
|
+
"directory": "packages/core/main"
|
|
59
34
|
},
|
|
60
35
|
"scripts": {
|
|
61
|
-
"build
|
|
62
|
-
"build:react": "vite build --mode react",
|
|
63
|
-
"build:preact": "vite build --mode preact",
|
|
64
|
-
"build:vue": "vite build --mode vue",
|
|
65
|
-
"build:svelte": "vite build --mode svelte",
|
|
66
|
-
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
36
|
+
"build": "epdf-build",
|
|
67
37
|
"clean": "rimraf dist",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"test": "vitest run"
|
|
70
40
|
}
|
|
71
41
|
}
|
package/README.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# @embedpdf/core
|
|
2
|
-
|
|
3
|
-
Core package for CloudPDF.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @embedpdf/core
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
import { PDFCore } from '@embedpdf/core';
|
|
15
|
-
import { createPdfiumModule, PdfiumEngine } from '@embedpdf/engines';
|
|
16
|
-
import { NavigationPlugin } from '@embedpdf/plugin-navigation';
|
|
17
|
-
|
|
18
|
-
const wasmBinary = await loadWasmBinary();
|
|
19
|
-
const wasmModule = await createPdfiumModule({ wasmBinary });
|
|
20
|
-
const engine = new PdfiumEngine(wasmModule, new ConsoleLogger());
|
|
21
|
-
|
|
22
|
-
const core = new PDFCore(engine);
|
|
23
|
-
|
|
24
|
-
const navigationPlugin = new NavigationPlugin({
|
|
25
|
-
initialPage: 1,
|
|
26
|
-
defaultScrollMode: 'continuous',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
core.registerPlugin(navigationPlugin);
|
|
30
|
-
|
|
31
|
-
core.loadDocument('https://cloudpdf.io/example.pdf');
|
|
32
|
-
|
|
33
|
-
core.on('document:loaded', ({ pageCount }) => {
|
|
34
|
-
console.log(`Document loaded with ${pageCount} pages`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
core.on('navigation:pageChanged', ({ pageNumber }) => {
|
|
38
|
-
console.log(`Navigated to page ${pageNumber}`);
|
|
39
|
-
});
|
|
40
|
-
```
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { IPlugin } from '../types/plugin';
|
|
2
|
-
import { PluginRegistry } from '../registry/plugin-registry';
|
|
3
|
-
import { Action, CoreAction, CoreState, PluginStore, Store, StoreState } from '../store';
|
|
4
|
-
import { Logger, PdfEngine, PdfPermissionFlag } from '@embedpdf/models';
|
|
5
|
-
import { DocumentState } from '../store/initial-state';
|
|
6
|
-
export interface StateChangeHandler<TState> {
|
|
7
|
-
(state: TState): void;
|
|
8
|
-
}
|
|
9
|
-
export declare abstract class BasePlugin<TConfig = unknown, TCapability = unknown, TState = unknown, TAction extends Action = Action> implements IPlugin<TConfig> {
|
|
10
|
-
readonly id: string;
|
|
11
|
-
protected registry: PluginRegistry;
|
|
12
|
-
static readonly id: string;
|
|
13
|
-
protected pluginStore: PluginStore<TState, TAction>;
|
|
14
|
-
protected coreStore: Store<CoreState, CoreAction>;
|
|
15
|
-
protected readonly logger: Logger;
|
|
16
|
-
protected readonly engine: PdfEngine;
|
|
17
|
-
private cooldownActions;
|
|
18
|
-
private debouncedTimeouts;
|
|
19
|
-
private unsubscribeFromState;
|
|
20
|
-
private unsubscribeFromCoreStore;
|
|
21
|
-
private unsubscribeFromStartLoadingDocument;
|
|
22
|
-
private unsubscribeFromSetDocumentLoaded;
|
|
23
|
-
private unsubscribeFromCloseDocument;
|
|
24
|
-
private unsubscribeFromSetScale;
|
|
25
|
-
private unsubscribeFromSetRotation;
|
|
26
|
-
private _capability?;
|
|
27
|
-
private readyPromise;
|
|
28
|
-
private readyResolve;
|
|
29
|
-
constructor(id: string, registry: PluginRegistry);
|
|
30
|
-
/** Construct the public capability (called once & cached). */
|
|
31
|
-
protected abstract buildCapability(): TCapability;
|
|
32
|
-
provides(): Readonly<TCapability>;
|
|
33
|
-
/**
|
|
34
|
-
* Initialize plugin with config
|
|
35
|
-
*/
|
|
36
|
-
abstract initialize(config: TConfig): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Get a copy of the current state
|
|
39
|
-
*/
|
|
40
|
-
protected get state(): Readonly<TState>;
|
|
41
|
-
/**
|
|
42
|
-
* Get a copy of the current core state
|
|
43
|
-
*/
|
|
44
|
-
protected get coreState(): Readonly<StoreState<CoreState>>;
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated use `this.state` Get a copy of the current state
|
|
47
|
-
*/
|
|
48
|
-
protected getState(): TState;
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated use `this.coreState` Get a copy of the current core state
|
|
51
|
-
*/
|
|
52
|
-
protected getCoreState(): StoreState<CoreState>;
|
|
53
|
-
/**
|
|
54
|
-
* Core Dispatch
|
|
55
|
-
*/
|
|
56
|
-
protected dispatchCoreAction(action: CoreAction): StoreState<CoreState>;
|
|
57
|
-
/**
|
|
58
|
-
* Dispatch an action to all plugins
|
|
59
|
-
*/
|
|
60
|
-
protected dispatchToAllPlugins(action: TAction): StoreState<CoreState>;
|
|
61
|
-
/**
|
|
62
|
-
* Dispatch an action
|
|
63
|
-
*/
|
|
64
|
-
protected dispatch(action: TAction): TState;
|
|
65
|
-
/**
|
|
66
|
-
* Dispatch an action with a cooldown to prevent rapid repeated calls
|
|
67
|
-
* This executes immediately if cooldown has expired, then blocks subsequent calls
|
|
68
|
-
* @param action The action to dispatch
|
|
69
|
-
* @param cooldownTime Time in ms for cooldown (default: 100ms)
|
|
70
|
-
* @returns boolean indicating whether the action was dispatched or blocked
|
|
71
|
-
*/
|
|
72
|
-
protected cooldownDispatch(action: TAction, cooldownTime?: number): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Dispatch an action with true debouncing - waits for the delay after the last call
|
|
75
|
-
* Each new call resets the timer. Action only executes after no calls for the specified time.
|
|
76
|
-
* @param action The action to dispatch
|
|
77
|
-
* @param debounceTime Time in ms to wait after the last call
|
|
78
|
-
*/
|
|
79
|
-
protected debouncedDispatch(action: TAction, debounceTime?: number): void;
|
|
80
|
-
/**
|
|
81
|
-
* Cancel a pending debounced action
|
|
82
|
-
* @param actionType The action type to cancel
|
|
83
|
-
*/
|
|
84
|
-
protected cancelDebouncedDispatch(actionType: string): void;
|
|
85
|
-
/**
|
|
86
|
-
* Subscribe to state changes
|
|
87
|
-
*/
|
|
88
|
-
protected subscribe(listener: (action: TAction, state: TState) => void): () => void;
|
|
89
|
-
/**
|
|
90
|
-
* Subscribe to core store changes
|
|
91
|
-
*/
|
|
92
|
-
protected subscribeToCoreStore(listener: (action: Action, state: StoreState<CoreState>) => void): () => void;
|
|
93
|
-
/**
|
|
94
|
-
* Called when the plugin store state is updated
|
|
95
|
-
* @param oldState Previous state
|
|
96
|
-
* @param newState New state
|
|
97
|
-
*/
|
|
98
|
-
protected onStoreUpdated(oldState: TState, newState: TState): void;
|
|
99
|
-
/**
|
|
100
|
-
* Called when the core store state is updated
|
|
101
|
-
* @param oldState Previous state
|
|
102
|
-
* @param newState New state
|
|
103
|
-
*/
|
|
104
|
-
protected onCoreStoreUpdated(oldState: StoreState<CoreState>, newState: StoreState<CoreState>): void;
|
|
105
|
-
/**
|
|
106
|
-
* Called when a document is opened
|
|
107
|
-
* Override to initialize per-document state
|
|
108
|
-
* @param documentId The ID of the document that was opened
|
|
109
|
-
*/
|
|
110
|
-
protected onDocumentLoadingStarted(documentId: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* Called when a document is loaded
|
|
113
|
-
* @param documentId The ID of the document that is loaded
|
|
114
|
-
*/
|
|
115
|
-
protected onDocumentLoaded(documentId: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* Called when a document is closed
|
|
118
|
-
* Override to cleanup per-document state
|
|
119
|
-
* @param documentId The ID of the document that was closed
|
|
120
|
-
*/
|
|
121
|
-
protected onDocumentClosed(documentId: string): void;
|
|
122
|
-
/**
|
|
123
|
-
* Called when the active document changes
|
|
124
|
-
* @param previousId The ID of the previous active document
|
|
125
|
-
* @param currentId The ID of the new active document
|
|
126
|
-
*/
|
|
127
|
-
protected onActiveDocumentChanged(previousId: string | null, currentId: string | null): void;
|
|
128
|
-
protected onScaleChanged(documentId: string, scale: number): void;
|
|
129
|
-
protected onRotationChanged(documentId: string, rotation: number): void;
|
|
130
|
-
/**
|
|
131
|
-
* Cleanup method to be called when plugin is being destroyed
|
|
132
|
-
*/
|
|
133
|
-
destroy(): void;
|
|
134
|
-
/**
|
|
135
|
-
* Returns a promise that resolves when the plugin is ready
|
|
136
|
-
*/
|
|
137
|
-
ready(): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Mark the plugin as ready
|
|
140
|
-
*/
|
|
141
|
-
protected markReady(): void;
|
|
142
|
-
/**
|
|
143
|
-
* Reset the ready state (useful for plugins that need to reinitialize)
|
|
144
|
-
*/
|
|
145
|
-
protected resetReady(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Get the active document ID
|
|
148
|
-
* @throws Error if no active document exists
|
|
149
|
-
*/
|
|
150
|
-
protected getActiveDocumentId(): string;
|
|
151
|
-
/**
|
|
152
|
-
* Get the active document ID or null if none exists
|
|
153
|
-
*/
|
|
154
|
-
protected getActiveDocumentIdOrNull(): string | null;
|
|
155
|
-
/**
|
|
156
|
-
* Get core document state for a specific document
|
|
157
|
-
* @param documentId Document ID (optional, defaults to active document)
|
|
158
|
-
* @returns Document state or null if not found
|
|
159
|
-
*/
|
|
160
|
-
protected getCoreDocument(documentId?: string): DocumentState | null;
|
|
161
|
-
/**
|
|
162
|
-
* Get core document state for a specific document
|
|
163
|
-
* @param documentId Document ID (optional, defaults to active document)
|
|
164
|
-
* @throws Error if document not found
|
|
165
|
-
*/
|
|
166
|
-
protected getCoreDocumentOrThrow(documentId?: string): DocumentState;
|
|
167
|
-
/**
|
|
168
|
-
* Get the effective permission flags for a document.
|
|
169
|
-
* Applies layered resolution: per-document override → global override → PDF permission.
|
|
170
|
-
* Returns AllowAll if document not found.
|
|
171
|
-
* @param documentId Document ID (optional, defaults to active document)
|
|
172
|
-
*/
|
|
173
|
-
protected getDocumentPermissions(documentId?: string): number;
|
|
174
|
-
/**
|
|
175
|
-
* Check if a document has the required permissions (returns boolean).
|
|
176
|
-
* Applies layered resolution: per-document override → global override → PDF permission.
|
|
177
|
-
* Useful for conditional UI logic.
|
|
178
|
-
* @param documentId Document ID (optional, defaults to active document)
|
|
179
|
-
* @param flags Permission flags to check
|
|
180
|
-
*/
|
|
181
|
-
protected checkPermission(documentId: string | undefined, ...flags: PdfPermissionFlag[]): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Assert that a document has the required permissions.
|
|
184
|
-
* Applies layered resolution: per-document override → global override → PDF permission.
|
|
185
|
-
* Throws PermissionDeniedError if any flag is missing.
|
|
186
|
-
* @param documentId Document ID (optional, defaults to active document)
|
|
187
|
-
* @param flags Permission flags to require
|
|
188
|
-
*/
|
|
189
|
-
protected requirePermission(documentId: string | undefined, ...flags: PdfPermissionFlag[]): void;
|
|
190
|
-
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './registry/plugin-registry';
|
|
2
|
-
export * from './utils/dependency-resolver';
|
|
3
|
-
export * from './utils/plugin-helpers';
|
|
4
|
-
export * from './types/plugin';
|
|
5
|
-
export * from './types/errors';
|
|
6
|
-
export * from './types/permissions';
|
|
7
|
-
export * from './base/base-plugin';
|
|
8
|
-
export * from './store/types';
|
|
9
|
-
export * from './store/actions';
|
|
10
|
-
export * from './store/initial-state';
|
|
11
|
-
export * from './store/selectors';
|
|
12
|
-
export * from './utils/event-control';
|
|
13
|
-
export * from './utils/eventing';
|
|
14
|
-
export * from './utils/scoped-eventing';
|
|
15
|
-
export * from './utils/math';
|
|
16
|
-
export * from './utils/typed-object';
|
|
17
|
-
export * from './plugin/builder';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PluginPackage, WithAutoMount, StandaloneComponent, ContainerComponent, IPlugin } from '../types/plugin';
|
|
2
|
-
import { Action } from '../store/types';
|
|
3
|
-
export declare class PluginPackageBuilder<T extends IPlugin<TConfig>, TConfig = unknown, TState = unknown, TAction extends Action = Action> {
|
|
4
|
-
private package;
|
|
5
|
-
private autoMountElements;
|
|
6
|
-
constructor(basePackage: PluginPackage<T, TConfig, TState, TAction>);
|
|
7
|
-
addUtility(component: StandaloneComponent): this;
|
|
8
|
-
addWrapper(component: ContainerComponent): this;
|
|
9
|
-
build(): WithAutoMount<PluginPackage<T, TConfig, TState, TAction>>;
|
|
10
|
-
}
|
|
11
|
-
export declare function createPluginPackage<T extends IPlugin<TConfig>, TConfig = unknown, TState = unknown, TAction extends Action = Action>(basePackage: PluginPackage<T, TConfig, TState, TAction>): PluginPackageBuilder<T, TConfig, TState, TAction>;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { IPlugin, PluginStatus, PluginPackage, PluginRegistryConfig, PluginBatchRegistrations } from '../types/plugin';
|
|
2
|
-
import { Logger, PdfEngine } from '@embedpdf/models';
|
|
3
|
-
import { Action, CoreState, Store } from '../store';
|
|
4
|
-
import { CoreAction } from '../store/actions';
|
|
5
|
-
export declare class PluginRegistry {
|
|
6
|
-
private plugins;
|
|
7
|
-
private manifests;
|
|
8
|
-
private capabilities;
|
|
9
|
-
private status;
|
|
10
|
-
private resolver;
|
|
11
|
-
private configurations;
|
|
12
|
-
private engine;
|
|
13
|
-
private store;
|
|
14
|
-
private initPromise;
|
|
15
|
-
private logger;
|
|
16
|
-
private pendingRegistrations;
|
|
17
|
-
private processingRegistrations;
|
|
18
|
-
private initialized;
|
|
19
|
-
private isInitializing;
|
|
20
|
-
private initialCoreState;
|
|
21
|
-
private pluginsReadyPromise;
|
|
22
|
-
private destroyed;
|
|
23
|
-
constructor(engine: PdfEngine, config?: PluginRegistryConfig);
|
|
24
|
-
/**
|
|
25
|
-
* Get the logger instance
|
|
26
|
-
*/
|
|
27
|
-
getLogger(): Logger;
|
|
28
|
-
/**
|
|
29
|
-
* Register a plugin without initializing it
|
|
30
|
-
*/
|
|
31
|
-
registerPlugin<TPlugin extends IPlugin<TConfig>, TConfig = unknown, TState = unknown, TAction extends Action = Action>(pluginPackage: PluginPackage<TPlugin, TConfig, TState, TAction>, config?: Partial<TConfig>): void;
|
|
32
|
-
/**
|
|
33
|
-
* Get the central store instance
|
|
34
|
-
*/
|
|
35
|
-
getStore(): Store<CoreState, CoreAction>;
|
|
36
|
-
/**
|
|
37
|
-
* Get the engine instance
|
|
38
|
-
*/
|
|
39
|
-
getEngine(): PdfEngine;
|
|
40
|
-
/**
|
|
41
|
-
* Get a promise that resolves when all plugins are ready
|
|
42
|
-
*/
|
|
43
|
-
pluginsReady(): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* INITIALISE THE REGISTRY – runs once no-matter-how-many calls *
|
|
46
|
-
*/
|
|
47
|
-
initialize(): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Phase 2: Create instance and register capabilities
|
|
50
|
-
*/
|
|
51
|
-
private instantiatePlugin;
|
|
52
|
-
/**
|
|
53
|
-
* Phase 3: Run the initialize method
|
|
54
|
-
*/
|
|
55
|
-
private runPluginInitialization;
|
|
56
|
-
getPluginConfig<TConfig>(pluginId: string): TConfig;
|
|
57
|
-
private validateConfig;
|
|
58
|
-
updatePluginConfig<TConfig>(pluginId: string, config: Partial<TConfig>): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Register multiple plugins at once
|
|
61
|
-
*/
|
|
62
|
-
registerPluginBatch(registrations: PluginBatchRegistrations): void;
|
|
63
|
-
/**
|
|
64
|
-
* Unregister a plugin
|
|
65
|
-
*/
|
|
66
|
-
unregisterPlugin(pluginId: string): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Get a plugin instance
|
|
69
|
-
* @param pluginId The ID of the plugin to get
|
|
70
|
-
* @returns The plugin instance or null if not found
|
|
71
|
-
*/
|
|
72
|
-
getPlugin<T extends IPlugin>(pluginId: string): T | null;
|
|
73
|
-
/**
|
|
74
|
-
* Get a plugin that provides a specific capability
|
|
75
|
-
* @param capability The capability to get a provider for
|
|
76
|
-
* @returns The plugin providing the capability or null if not found
|
|
77
|
-
*/
|
|
78
|
-
getCapabilityProvider(capability: string): IPlugin | null;
|
|
79
|
-
/**
|
|
80
|
-
* Check if a capability is available
|
|
81
|
-
*/
|
|
82
|
-
hasCapability(capability: string): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Get all registered plugins
|
|
85
|
-
*/
|
|
86
|
-
getAllPlugins(): IPlugin[];
|
|
87
|
-
/**
|
|
88
|
-
* Get plugin status
|
|
89
|
-
*/
|
|
90
|
-
getPluginStatus(pluginId: string): PluginStatus;
|
|
91
|
-
/**
|
|
92
|
-
* Validate plugin object
|
|
93
|
-
*/
|
|
94
|
-
private validatePlugin;
|
|
95
|
-
/**
|
|
96
|
-
* Validate plugin manifest
|
|
97
|
-
*/
|
|
98
|
-
private validateManifest;
|
|
99
|
-
isDestroyed(): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* DESTROY EVERYTHING – waits for any ongoing initialise(), once *
|
|
102
|
-
*/
|
|
103
|
-
destroy(): Promise<void>;
|
|
104
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { PdfDocumentObject, PdfErrorCode, PdfPageObject, Rotation } from '@embedpdf/models';
|
|
2
|
-
import { PermissionConfig } from '../types/permissions';
|
|
3
|
-
export declare const START_LOADING_DOCUMENT = "START_LOADING_DOCUMENT";
|
|
4
|
-
export declare const UPDATE_DOCUMENT_LOADING_PROGRESS = "UPDATE_DOCUMENT_LOADING_PROGRESS";
|
|
5
|
-
export declare const SET_DOCUMENT_LOADED = "SET_DOCUMENT_LOADED";
|
|
6
|
-
export declare const SET_DOCUMENT_ERROR = "SET_DOCUMENT_ERROR";
|
|
7
|
-
export declare const RETRY_LOADING_DOCUMENT = "RETRY_LOADING_DOCUMENT";
|
|
8
|
-
export declare const CLOSE_DOCUMENT = "CLOSE_DOCUMENT";
|
|
9
|
-
export declare const SET_ACTIVE_DOCUMENT = "SET_ACTIVE_DOCUMENT";
|
|
10
|
-
export declare const REORDER_DOCUMENTS = "REORDER_DOCUMENTS";
|
|
11
|
-
export declare const MOVE_DOCUMENT = "MOVE_DOCUMENT";
|
|
12
|
-
export declare const UPDATE_DOCUMENT_SECURITY = "UPDATE_DOCUMENT_SECURITY";
|
|
13
|
-
export declare const REFRESH_DOCUMENT = "REFRESH_DOCUMENT";
|
|
14
|
-
export declare const REFRESH_PAGES = "REFRESH_PAGES";
|
|
15
|
-
export declare const SET_PAGES = "SET_PAGES";
|
|
16
|
-
export declare const SET_SCALE = "SET_SCALE";
|
|
17
|
-
export declare const SET_ROTATION = "SET_ROTATION";
|
|
18
|
-
export declare const SET_DEFAULT_SCALE = "SET_DEFAULT_SCALE";
|
|
19
|
-
export declare const SET_DEFAULT_ROTATION = "SET_DEFAULT_ROTATION";
|
|
20
|
-
export declare const CORE_ACTION_TYPES: readonly ["START_LOADING_DOCUMENT", "UPDATE_DOCUMENT_LOADING_PROGRESS", "SET_DOCUMENT_LOADED", "CLOSE_DOCUMENT", "SET_ACTIVE_DOCUMENT", "SET_DOCUMENT_ERROR", "RETRY_LOADING_DOCUMENT", "REFRESH_DOCUMENT", "REFRESH_PAGES", "SET_PAGES", "SET_SCALE", "SET_ROTATION", "SET_DEFAULT_SCALE", "SET_DEFAULT_ROTATION", "REORDER_DOCUMENTS", "MOVE_DOCUMENT", "UPDATE_DOCUMENT_SECURITY"];
|
|
21
|
-
export interface StartLoadingDocumentAction {
|
|
22
|
-
type: typeof START_LOADING_DOCUMENT;
|
|
23
|
-
payload: {
|
|
24
|
-
documentId: string;
|
|
25
|
-
name?: string;
|
|
26
|
-
scale?: number;
|
|
27
|
-
rotation?: Rotation;
|
|
28
|
-
passwordProvided?: boolean;
|
|
29
|
-
autoActivate?: boolean;
|
|
30
|
-
permissions?: PermissionConfig;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export interface UpdateDocumentLoadingProgressAction {
|
|
34
|
-
type: typeof UPDATE_DOCUMENT_LOADING_PROGRESS;
|
|
35
|
-
payload: {
|
|
36
|
-
documentId: string;
|
|
37
|
-
progress: number;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export interface SetDocumentLoadedAction {
|
|
41
|
-
type: typeof SET_DOCUMENT_LOADED;
|
|
42
|
-
payload: {
|
|
43
|
-
documentId: string;
|
|
44
|
-
document: PdfDocumentObject;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface SetDocumentErrorAction {
|
|
48
|
-
type: typeof SET_DOCUMENT_ERROR;
|
|
49
|
-
payload: {
|
|
50
|
-
documentId: string;
|
|
51
|
-
error: string;
|
|
52
|
-
errorCode?: PdfErrorCode;
|
|
53
|
-
errorDetails?: any;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export interface RetryLoadingDocumentAction {
|
|
57
|
-
type: typeof RETRY_LOADING_DOCUMENT;
|
|
58
|
-
payload: {
|
|
59
|
-
documentId: string;
|
|
60
|
-
passwordProvided?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface CloseDocumentAction {
|
|
64
|
-
type: typeof CLOSE_DOCUMENT;
|
|
65
|
-
payload: {
|
|
66
|
-
documentId: string;
|
|
67
|
-
nextActiveDocumentId?: string | null;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export interface SetActiveDocumentAction {
|
|
71
|
-
type: typeof SET_ACTIVE_DOCUMENT;
|
|
72
|
-
payload: string | null;
|
|
73
|
-
}
|
|
74
|
-
export interface ReorderDocumentsAction {
|
|
75
|
-
type: typeof REORDER_DOCUMENTS;
|
|
76
|
-
payload: string[];
|
|
77
|
-
}
|
|
78
|
-
export interface MoveDocumentAction {
|
|
79
|
-
type: typeof MOVE_DOCUMENT;
|
|
80
|
-
payload: {
|
|
81
|
-
documentId: string;
|
|
82
|
-
toIndex: number;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export interface UpdateDocumentSecurityAction {
|
|
86
|
-
type: typeof UPDATE_DOCUMENT_SECURITY;
|
|
87
|
-
payload: {
|
|
88
|
-
documentId: string;
|
|
89
|
-
permissions: number;
|
|
90
|
-
isOwnerUnlocked: boolean;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
export interface RefreshDocumentAction {
|
|
94
|
-
type: typeof REFRESH_DOCUMENT;
|
|
95
|
-
payload: {
|
|
96
|
-
documentId: string;
|
|
97
|
-
document: PdfDocumentObject;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export interface RefreshPagesAction {
|
|
101
|
-
type: typeof REFRESH_PAGES;
|
|
102
|
-
payload: {
|
|
103
|
-
documentId: string;
|
|
104
|
-
pageIndexes: number[];
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export interface SetPagesAction {
|
|
108
|
-
type: typeof SET_PAGES;
|
|
109
|
-
payload: {
|
|
110
|
-
documentId: string;
|
|
111
|
-
pages: PdfPageObject[][];
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
export interface SetScaleAction {
|
|
115
|
-
type: typeof SET_SCALE;
|
|
116
|
-
payload: {
|
|
117
|
-
documentId?: string;
|
|
118
|
-
scale: number;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
export interface SetRotationAction {
|
|
122
|
-
type: typeof SET_ROTATION;
|
|
123
|
-
payload: {
|
|
124
|
-
documentId?: string;
|
|
125
|
-
rotation: Rotation;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export interface SetDefaultScaleAction {
|
|
129
|
-
type: typeof SET_DEFAULT_SCALE;
|
|
130
|
-
payload: number;
|
|
131
|
-
}
|
|
132
|
-
export interface SetDefaultRotationAction {
|
|
133
|
-
type: typeof SET_DEFAULT_ROTATION;
|
|
134
|
-
payload: Rotation;
|
|
135
|
-
}
|
|
136
|
-
export type DocumentAction = StartLoadingDocumentAction | UpdateDocumentLoadingProgressAction | SetDocumentLoadedAction | SetDocumentErrorAction | RetryLoadingDocumentAction | CloseDocumentAction | SetActiveDocumentAction | RefreshDocumentAction | RefreshPagesAction | SetPagesAction | SetScaleAction | SetRotationAction | SetDefaultScaleAction | SetDefaultRotationAction | ReorderDocumentsAction | MoveDocumentAction | UpdateDocumentSecurityAction;
|
|
137
|
-
export type CoreAction = DocumentAction;
|
|
138
|
-
export declare const startLoadingDocument: (documentId: string, name?: string, scale?: number, rotation?: Rotation, passwordProvided?: boolean, autoActivate?: boolean, permissions?: PermissionConfig) => CoreAction;
|
|
139
|
-
export declare const updateDocumentLoadingProgress: (documentId: string, progress: number) => CoreAction;
|
|
140
|
-
export declare const setDocumentLoaded: (documentId: string, document: PdfDocumentObject) => CoreAction;
|
|
141
|
-
export declare const setDocumentError: (documentId: string, error: string, errorCode?: PdfErrorCode, errorDetails?: any) => CoreAction;
|
|
142
|
-
export declare const retryLoadingDocument: (documentId: string, passwordProvided?: boolean) => CoreAction;
|
|
143
|
-
export declare const closeDocument: (documentId: string, nextActiveDocumentId?: string | null) => CoreAction;
|
|
144
|
-
export declare const setActiveDocument: (documentId: string | null) => CoreAction;
|
|
145
|
-
export declare const refreshDocument: (documentId: string, document: PdfDocumentObject) => CoreAction;
|
|
146
|
-
export declare const refreshPages: (documentId: string, pageIndexes: number[]) => CoreAction;
|
|
147
|
-
export declare const setPages: (documentId: string, pages: PdfPageObject[][]) => CoreAction;
|
|
148
|
-
export declare const setScale: (scale: number, documentId?: string) => CoreAction;
|
|
149
|
-
export declare const setRotation: (rotation: Rotation, documentId?: string) => CoreAction;
|
|
150
|
-
export declare const setDefaultScale: (scale: number) => CoreAction;
|
|
151
|
-
export declare const setDefaultRotation: (rotation: Rotation) => CoreAction;
|
|
152
|
-
export declare const reorderDocuments: (order: string[]) => CoreAction;
|
|
153
|
-
export declare const moveDocument: (documentId: string, toIndex: number) => CoreAction;
|
|
154
|
-
export declare const updateDocumentSecurity: (documentId: string, permissions: number, isOwnerUnlocked: boolean) => CoreAction;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { PdfDocumentObject, PdfErrorCode, Rotation } from '@embedpdf/models';
|
|
2
|
-
import { PluginRegistryConfig } from '../types/plugin';
|
|
3
|
-
import { PermissionConfig } from '../types/permissions';
|
|
4
|
-
export type DocumentStatus = 'loading' | 'loaded' | 'error';
|
|
5
|
-
export interface DocumentState {
|
|
6
|
-
id: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
status: DocumentStatus;
|
|
9
|
-
loadingProgress?: number;
|
|
10
|
-
error: string | null;
|
|
11
|
-
errorCode?: PdfErrorCode;
|
|
12
|
-
errorDetails?: any;
|
|
13
|
-
passwordProvided?: boolean;
|
|
14
|
-
document: PdfDocumentObject | null;
|
|
15
|
-
scale: number;
|
|
16
|
-
rotation: Rotation;
|
|
17
|
-
pageRefreshVersions: Record<number, number>;
|
|
18
|
-
permissions?: PermissionConfig;
|
|
19
|
-
loadStartedAt: number;
|
|
20
|
-
loadedAt?: number;
|
|
21
|
-
}
|
|
22
|
-
export interface CoreState {
|
|
23
|
-
documents: Record<string, DocumentState>;
|
|
24
|
-
documentOrder: string[];
|
|
25
|
-
activeDocumentId: string | null;
|
|
26
|
-
defaultScale: number;
|
|
27
|
-
defaultRotation: Rotation;
|
|
28
|
-
/** Global permission configuration applied to all documents unless overridden per-document */
|
|
29
|
-
globalPermissions?: PermissionConfig;
|
|
30
|
-
}
|
|
31
|
-
export declare const initialCoreState: (config?: PluginRegistryConfig) => CoreState;
|