@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.
Files changed (117) hide show
  1. package/LICENSE +192 -21
  2. package/dist/index.cjs +864 -2
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +313 -0
  5. package/dist/index.d.ts +313 -1
  6. package/dist/index.js +816 -2124
  7. package/dist/index.js.map +1 -1
  8. package/package.json +22 -52
  9. package/README.md +0 -40
  10. package/dist/lib/base/base-plugin.d.ts +0 -190
  11. package/dist/lib/index.d.ts +0 -17
  12. package/dist/lib/plugin/builder.d.ts +0 -11
  13. package/dist/lib/registry/plugin-registry.d.ts +0 -104
  14. package/dist/lib/store/actions.d.ts +0 -154
  15. package/dist/lib/store/index.d.ts +0 -6
  16. package/dist/lib/store/initial-state.d.ts +0 -31
  17. package/dist/lib/store/plugin-store.d.ts +0 -48
  18. package/dist/lib/store/reducer-helpers.d.ts +0 -11
  19. package/dist/lib/store/reducer.d.ts +0 -4
  20. package/dist/lib/store/selectors.d.ts +0 -41
  21. package/dist/lib/store/store.d.ts +0 -106
  22. package/dist/lib/store/types.d.ts +0 -28
  23. package/dist/lib/types/errors.d.ts +0 -21
  24. package/dist/lib/types/permissions.d.ts +0 -55
  25. package/dist/lib/types/plugin.d.ts +0 -75
  26. package/dist/lib/utils/dependency-resolver.d.ts +0 -6
  27. package/dist/lib/utils/event-control.d.ts +0 -58
  28. package/dist/lib/utils/eventing.d.ts +0 -19
  29. package/dist/lib/utils/math.d.ts +0 -22
  30. package/dist/lib/utils/plugin-helpers.d.ts +0 -6
  31. package/dist/lib/utils/scoped-eventing.d.ts +0 -71
  32. package/dist/lib/utils/typed-object.d.ts +0 -12
  33. package/dist/preact/adapter.d.ts +0 -11
  34. package/dist/preact/index.cjs +0 -2
  35. package/dist/preact/index.cjs.map +0 -1
  36. package/dist/preact/index.d.ts +0 -1
  37. package/dist/preact/index.js +0 -323
  38. package/dist/preact/index.js.map +0 -1
  39. package/dist/react/adapter.d.ts +0 -2
  40. package/dist/react/index.cjs +0 -2
  41. package/dist/react/index.cjs.map +0 -1
  42. package/dist/react/index.d.ts +0 -1
  43. package/dist/react/index.js +0 -322
  44. package/dist/react/index.js.map +0 -1
  45. package/dist/shared/components/auto-mount.d.ts +0 -8
  46. package/dist/shared/components/embed-pdf.d.ts +0 -37
  47. package/dist/shared/components/index.d.ts +0 -1
  48. package/dist/shared/context.d.ts +0 -12
  49. package/dist/shared/hooks/index.d.ts +0 -7
  50. package/dist/shared/hooks/use-capability.d.ts +0 -16
  51. package/dist/shared/hooks/use-core-state.d.ts +0 -8
  52. package/dist/shared/hooks/use-document-permissions.d.ts +0 -35
  53. package/dist/shared/hooks/use-document-state.d.ts +0 -8
  54. package/dist/shared/hooks/use-plugin.d.ts +0 -16
  55. package/dist/shared/hooks/use-registry.d.ts +0 -6
  56. package/dist/shared/hooks/use-store-state.d.ts +0 -6
  57. package/dist/shared/index.d.ts +0 -3
  58. package/dist/shared-preact/components/auto-mount.d.ts +0 -8
  59. package/dist/shared-preact/components/embed-pdf.d.ts +0 -37
  60. package/dist/shared-preact/components/index.d.ts +0 -1
  61. package/dist/shared-preact/context.d.ts +0 -12
  62. package/dist/shared-preact/hooks/index.d.ts +0 -7
  63. package/dist/shared-preact/hooks/use-capability.d.ts +0 -16
  64. package/dist/shared-preact/hooks/use-core-state.d.ts +0 -8
  65. package/dist/shared-preact/hooks/use-document-permissions.d.ts +0 -35
  66. package/dist/shared-preact/hooks/use-document-state.d.ts +0 -8
  67. package/dist/shared-preact/hooks/use-plugin.d.ts +0 -16
  68. package/dist/shared-preact/hooks/use-registry.d.ts +0 -6
  69. package/dist/shared-preact/hooks/use-store-state.d.ts +0 -6
  70. package/dist/shared-preact/index.d.ts +0 -3
  71. package/dist/shared-react/components/auto-mount.d.ts +0 -8
  72. package/dist/shared-react/components/embed-pdf.d.ts +0 -37
  73. package/dist/shared-react/components/index.d.ts +0 -1
  74. package/dist/shared-react/context.d.ts +0 -12
  75. package/dist/shared-react/hooks/index.d.ts +0 -7
  76. package/dist/shared-react/hooks/use-capability.d.ts +0 -16
  77. package/dist/shared-react/hooks/use-core-state.d.ts +0 -8
  78. package/dist/shared-react/hooks/use-document-permissions.d.ts +0 -35
  79. package/dist/shared-react/hooks/use-document-state.d.ts +0 -8
  80. package/dist/shared-react/hooks/use-plugin.d.ts +0 -16
  81. package/dist/shared-react/hooks/use-registry.d.ts +0 -6
  82. package/dist/shared-react/hooks/use-store-state.d.ts +0 -6
  83. package/dist/shared-react/index.d.ts +0 -3
  84. package/dist/svelte/components/AutoMount.svelte.d.ts +0 -9
  85. package/dist/svelte/components/EmbedPDF.svelte.d.ts +0 -40
  86. package/dist/svelte/components/NestedWrapper.svelte.d.ts +0 -10
  87. package/dist/svelte/components/index.d.ts +0 -1
  88. package/dist/svelte/hooks/index.d.ts +0 -6
  89. package/dist/svelte/hooks/use-capability.svelte.d.ts +0 -14
  90. package/dist/svelte/hooks/use-core-state.svelte.d.ts +0 -9
  91. package/dist/svelte/hooks/use-document-permissions.svelte.d.ts +0 -35
  92. package/dist/svelte/hooks/use-document-state.svelte.d.ts +0 -9
  93. package/dist/svelte/hooks/use-plugin.svelte.d.ts +0 -14
  94. package/dist/svelte/hooks/use-registry.svelte.d.ts +0 -17
  95. package/dist/svelte/index.cjs +0 -2
  96. package/dist/svelte/index.cjs.map +0 -1
  97. package/dist/svelte/index.d.ts +0 -2
  98. package/dist/svelte/index.js +0 -430
  99. package/dist/svelte/index.js.map +0 -1
  100. package/dist/vue/components/auto-mount.vue.d.ts +0 -19
  101. package/dist/vue/components/embed-pdf.vue.d.ts +0 -104
  102. package/dist/vue/components/index.d.ts +0 -1
  103. package/dist/vue/components/nested-wrapper.vue.d.ts +0 -19
  104. package/dist/vue/composables/index.d.ts +0 -7
  105. package/dist/vue/composables/use-capability.d.ts +0 -15
  106. package/dist/vue/composables/use-core-state.d.ts +0 -9
  107. package/dist/vue/composables/use-document-permissions.d.ts +0 -36
  108. package/dist/vue/composables/use-document-state.d.ts +0 -8
  109. package/dist/vue/composables/use-plugin.d.ts +0 -8
  110. package/dist/vue/composables/use-registry.d.ts +0 -1
  111. package/dist/vue/composables/use-store-state.d.ts +0 -10
  112. package/dist/vue/context.d.ts +0 -13
  113. package/dist/vue/index.cjs +0 -2
  114. package/dist/vue/index.cjs.map +0 -1
  115. package/dist/vue/index.d.ts +0 -2
  116. package/dist/vue/index.js +0 -384
  117. package/dist/vue/index.js.map +0 -1
@@ -1,430 +0,0 @@
1
- import * as $ from "svelte/internal/client";
2
- import { PdfPermissionFlag } from "@embedpdf/models";
3
- import "svelte/internal/disclose-version";
4
- import { hasAutoMountElements, PluginRegistry } from "@embedpdf/core";
5
- const pdfContext = $.proxy({
6
- registry: null,
7
- coreState: null,
8
- isInitializing: true,
9
- pluginsReady: false,
10
- activeDocumentId: null,
11
- activeDocument: null,
12
- documents: {},
13
- documentStates: []
14
- });
15
- const useRegistry = () => pdfContext;
16
- function usePlugin(pluginId) {
17
- const { registry } = pdfContext;
18
- const state = $.proxy({ plugin: null, isLoading: true, ready: new Promise(() => {
19
- }) });
20
- if (registry === null) {
21
- return state;
22
- }
23
- const plugin = registry.getPlugin(pluginId);
24
- if (!plugin) {
25
- throw new Error(`Plugin ${pluginId} not found`);
26
- }
27
- state.plugin = plugin;
28
- state.isLoading = false;
29
- state.ready = plugin.ready();
30
- return state;
31
- }
32
- function useCapability(pluginId) {
33
- const p = usePlugin(pluginId);
34
- const state = $.proxy({
35
- provides: null,
36
- isLoading: true,
37
- ready: new Promise(() => {
38
- })
39
- });
40
- $.user_effect(() => {
41
- if (!p.plugin) {
42
- state.provides = null;
43
- state.isLoading = p.isLoading;
44
- state.ready = p.ready;
45
- return;
46
- }
47
- if (!p.plugin.provides) {
48
- throw new Error(`Plugin ${pluginId} does not provide a capability`);
49
- }
50
- state.provides = p.plugin.provides();
51
- state.isLoading = p.isLoading;
52
- state.ready = p.ready;
53
- });
54
- return state;
55
- }
56
- function useCoreState() {
57
- const context = useRegistry();
58
- return {
59
- get current() {
60
- return context.coreState;
61
- }
62
- };
63
- }
64
- function useDocumentState(getDocumentId) {
65
- const coreStateRef = useCoreState();
66
- const documentId = $.derived(getDocumentId);
67
- const documentState = $.derived(() => coreStateRef.current && $.get(documentId) ? coreStateRef.current.documents[$.get(documentId)] ?? null : null);
68
- return {
69
- get current() {
70
- return $.get(documentState);
71
- }
72
- };
73
- }
74
- ({
75
- print: PdfPermissionFlag.Print,
76
- modifyContents: PdfPermissionFlag.ModifyContents,
77
- copyContents: PdfPermissionFlag.CopyContents,
78
- modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,
79
- fillForms: PdfPermissionFlag.FillForms,
80
- extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,
81
- assembleDocument: PdfPermissionFlag.AssembleDocument,
82
- printHighQuality: PdfPermissionFlag.PrintHighQuality
83
- });
84
- const ALL_PERMISSION_FLAGS = [
85
- PdfPermissionFlag.Print,
86
- PdfPermissionFlag.ModifyContents,
87
- PdfPermissionFlag.CopyContents,
88
- PdfPermissionFlag.ModifyAnnotations,
89
- PdfPermissionFlag.FillForms,
90
- PdfPermissionFlag.ExtractForAccessibility,
91
- PdfPermissionFlag.AssembleDocument,
92
- PdfPermissionFlag.PrintHighQuality
93
- ];
94
- const PERMISSION_FLAG_TO_NAME = {
95
- [PdfPermissionFlag.Print]: "print",
96
- [PdfPermissionFlag.ModifyContents]: "modifyContents",
97
- [PdfPermissionFlag.CopyContents]: "copyContents",
98
- [PdfPermissionFlag.ModifyAnnotations]: "modifyAnnotations",
99
- [PdfPermissionFlag.FillForms]: "fillForms",
100
- [PdfPermissionFlag.ExtractForAccessibility]: "extractForAccessibility",
101
- [PdfPermissionFlag.AssembleDocument]: "assembleDocument",
102
- [PdfPermissionFlag.PrintHighQuality]: "printHighQuality"
103
- };
104
- function getPermissionOverride(overrides, flag) {
105
- if (!overrides) return void 0;
106
- if (flag in overrides) {
107
- return overrides[flag];
108
- }
109
- const name = PERMISSION_FLAG_TO_NAME[flag];
110
- if (name && name in overrides) {
111
- return overrides[name];
112
- }
113
- return void 0;
114
- }
115
- function getEffectivePermission(state, documentId, flag) {
116
- var _a;
117
- const docState = state.documents[documentId];
118
- const docConfig = docState == null ? void 0 : docState.permissions;
119
- const globalConfig = state.globalPermissions;
120
- const pdfPermissions = ((_a = docState == null ? void 0 : docState.document) == null ? void 0 : _a.permissions) ?? PdfPermissionFlag.AllowAll;
121
- const docOverride = getPermissionOverride(docConfig == null ? void 0 : docConfig.overrides, flag);
122
- if (docOverride !== void 0) {
123
- return docOverride;
124
- }
125
- const globalOverride = getPermissionOverride(globalConfig == null ? void 0 : globalConfig.overrides, flag);
126
- if (globalOverride !== void 0) {
127
- return globalOverride;
128
- }
129
- const enforce = (docConfig == null ? void 0 : docConfig.enforceDocumentPermissions) ?? (globalConfig == null ? void 0 : globalConfig.enforceDocumentPermissions) ?? true;
130
- if (!enforce) return true;
131
- return (pdfPermissions & flag) !== 0;
132
- }
133
- function getEffectivePermissions(state, documentId) {
134
- return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {
135
- return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;
136
- }, 0);
137
- }
138
- function useDocumentPermissions(getDocumentId) {
139
- const coreStateRef = useCoreState();
140
- const documentId = $.derived(getDocumentId);
141
- const coreState = $.derived(() => coreStateRef.current);
142
- const effectivePermissions = $.derived(() => $.get(coreState) ? getEffectivePermissions($.get(coreState), $.get(documentId)) : PdfPermissionFlag.AllowAll);
143
- const pdfPermissions = $.derived(() => {
144
- var _a, _b, _c;
145
- return ((_c = (_b = (_a = $.get(coreState)) == null ? void 0 : _a.documents[$.get(documentId)]) == null ? void 0 : _b.document) == null ? void 0 : _c.permissions) ?? PdfPermissionFlag.AllowAll;
146
- });
147
- const hasPermission = (flag) => $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), flag) : true;
148
- const hasAllPermissions = (...flags) => flags.every((flag) => $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), flag) : true);
149
- return {
150
- get permissions() {
151
- return $.get(effectivePermissions);
152
- },
153
- get pdfPermissions() {
154
- return $.get(pdfPermissions);
155
- },
156
- hasPermission,
157
- hasAllPermissions,
158
- get canPrint() {
159
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.Print) : true;
160
- },
161
- get canModifyContents() {
162
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ModifyContents) : true;
163
- },
164
- get canCopyContents() {
165
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.CopyContents) : true;
166
- },
167
- get canModifyAnnotations() {
168
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ModifyAnnotations) : true;
169
- },
170
- get canFillForms() {
171
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.FillForms) : true;
172
- },
173
- get canExtractForAccessibility() {
174
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.ExtractForAccessibility) : true;
175
- },
176
- get canAssembleDocument() {
177
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.AssembleDocument) : true;
178
- },
179
- get canPrintHighQuality() {
180
- return $.get(coreState) ? getEffectivePermission($.get(coreState), $.get(documentId), PdfPermissionFlag.PrintHighQuality) : true;
181
- }
182
- };
183
- }
184
- var root_5 = $.from_html(`<!> <!>`, 1);
185
- function NestedWrapper_1($$anchor, $$props) {
186
- $.push($$props, true);
187
- let utilities = $.prop($$props, "utilities", 19, () => []);
188
- var fragment = $.comment();
189
- var node = $.first_child(fragment);
190
- {
191
- var consequent = ($$anchor2) => {
192
- const Wrapper = $.derived(() => $$props.wrappers[0]);
193
- var fragment_1 = $.comment();
194
- var node_1 = $.first_child(fragment_1);
195
- $.component(node_1, () => $.get(Wrapper), ($$anchor3, Wrapper_1) => {
196
- Wrapper_1($$anchor3, {
197
- children: ($$anchor4, $$slotProps) => {
198
- {
199
- let $0 = $.derived(() => $$props.wrappers.slice(1));
200
- NestedWrapper_1($$anchor4, {
201
- get wrappers() {
202
- return $.get($0);
203
- },
204
- get utilities() {
205
- return utilities();
206
- },
207
- children: ($$anchor5, $$slotProps2) => {
208
- var fragment_3 = $.comment();
209
- var node_2 = $.first_child(fragment_3);
210
- $.snippet(node_2, () => $$props.children ?? $.noop);
211
- $.append($$anchor5, fragment_3);
212
- },
213
- $$slots: { default: true }
214
- });
215
- }
216
- },
217
- $$slots: { default: true }
218
- });
219
- });
220
- $.append($$anchor2, fragment_1);
221
- };
222
- var alternate = ($$anchor2) => {
223
- const Wrapper = $.derived(() => $$props.wrappers[0]);
224
- var fragment_4 = $.comment();
225
- var node_3 = $.first_child(fragment_4);
226
- $.component(node_3, () => $.get(Wrapper), ($$anchor3, Wrapper_2) => {
227
- Wrapper_2($$anchor3, {
228
- children: ($$anchor4, $$slotProps) => {
229
- var fragment_5 = root_5();
230
- var node_4 = $.first_child(fragment_5);
231
- $.snippet(node_4, () => $$props.children ?? $.noop);
232
- var node_5 = $.sibling(node_4, 2);
233
- $.each(node_5, 19, utilities, (Utility, i) => `utility-${i}`, ($$anchor5, Utility) => {
234
- var fragment_6 = $.comment();
235
- var node_6 = $.first_child(fragment_6);
236
- $.component(node_6, () => $.get(Utility), ($$anchor6, Utility_1) => {
237
- Utility_1($$anchor6, {});
238
- });
239
- $.append($$anchor5, fragment_6);
240
- });
241
- $.append($$anchor4, fragment_5);
242
- },
243
- $$slots: { default: true }
244
- });
245
- });
246
- $.append($$anchor2, fragment_4);
247
- };
248
- $.if(node, ($$render) => {
249
- if ($$props.wrappers.length > 1) $$render(consequent);
250
- else $$render(alternate, false);
251
- });
252
- }
253
- $.append($$anchor, fragment);
254
- $.pop();
255
- }
256
- var root_2 = $.from_html(`<!> <!>`, 1);
257
- function AutoMount($$anchor, $$props) {
258
- $.push($$props, true);
259
- let utilities = $.state($.proxy([]));
260
- let wrappers = $.state($.proxy([]));
261
- $.user_effect(() => {
262
- var _a;
263
- const nextUtilities = [];
264
- const nextWrappers = [];
265
- for (const reg of $$props.plugins) {
266
- const pkg = reg.package;
267
- if (hasAutoMountElements(pkg)) {
268
- const elements = ((_a = pkg.autoMountElements) == null ? void 0 : _a.call(pkg)) ?? [];
269
- for (const element of elements) {
270
- if (element.type === "utility") {
271
- nextUtilities.push(element.component);
272
- } else if (element.type === "wrapper") {
273
- nextWrappers.push(element.component);
274
- }
275
- }
276
- }
277
- }
278
- $.set(utilities, nextUtilities, true);
279
- $.set(wrappers, nextWrappers, true);
280
- });
281
- var fragment = $.comment();
282
- var node = $.first_child(fragment);
283
- {
284
- var consequent = ($$anchor2) => {
285
- NestedWrapper_1($$anchor2, {
286
- get wrappers() {
287
- return $.get(wrappers);
288
- },
289
- get utilities() {
290
- return $.get(utilities);
291
- },
292
- get children() {
293
- return $$props.children;
294
- }
295
- });
296
- };
297
- var alternate = ($$anchor2) => {
298
- var fragment_2 = root_2();
299
- var node_1 = $.first_child(fragment_2);
300
- $.snippet(node_1, () => $$props.children ?? $.noop);
301
- var node_2 = $.sibling(node_1, 2);
302
- $.each(node_2, 19, () => $.get(utilities), (Utility, i) => `utility-${i}`, ($$anchor3, Utility) => {
303
- var fragment_3 = $.comment();
304
- var node_3 = $.first_child(fragment_3);
305
- $.component(node_3, () => $.get(Utility), ($$anchor4, Utility_1) => {
306
- Utility_1($$anchor4, {});
307
- });
308
- $.append($$anchor3, fragment_3);
309
- });
310
- $.append($$anchor2, fragment_2);
311
- };
312
- $.if(node, ($$render) => {
313
- if ($.get(wrappers).length > 0) $$render(consequent);
314
- else $$render(alternate, false);
315
- });
316
- }
317
- $.append($$anchor, fragment);
318
- $.pop();
319
- }
320
- function EmbedPDF($$anchor, $$props) {
321
- $.push($$props, true);
322
- let autoMountDomElements = $.prop($$props, "autoMountDomElements", 3, true);
323
- let latestInit = $$props.onInitialized;
324
- $.user_effect(() => {
325
- if ($$props.onInitialized) {
326
- latestInit = $$props.onInitialized;
327
- }
328
- });
329
- $.user_effect(() => {
330
- var _a;
331
- if ($$props.engine || $$props.engine && $$props.plugins) {
332
- const finalConfig = {
333
- ...$$props.config,
334
- logger: ((_a = $$props.config) == null ? void 0 : _a.logger) ?? $$props.logger
335
- };
336
- const reg = new PluginRegistry($$props.engine, finalConfig);
337
- reg.registerPluginBatch($$props.plugins);
338
- const initialize = async () => {
339
- await reg.initialize();
340
- if (reg.isDestroyed()) {
341
- return;
342
- }
343
- const store = reg.getStore();
344
- pdfContext.coreState = store.getState().core;
345
- const unsubscribe = store.subscribe((action, newState, oldState) => {
346
- if (store.isCoreAction(action) && newState.core !== oldState.core) {
347
- pdfContext.coreState = newState.core;
348
- const activeDocumentId = newState.core.activeDocumentId ?? null;
349
- const documents = newState.core.documents ?? {};
350
- const documentOrder = newState.core.documentOrder ?? [];
351
- pdfContext.activeDocumentId = activeDocumentId;
352
- pdfContext.activeDocument = activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;
353
- pdfContext.documents = documents;
354
- pdfContext.documentStates = documentOrder.map((docId) => documents[docId]).filter((doc) => doc !== null && doc !== void 0);
355
- }
356
- });
357
- await (latestInit == null ? void 0 : latestInit(reg));
358
- if (reg.isDestroyed()) {
359
- unsubscribe();
360
- return;
361
- }
362
- reg.pluginsReady().then(() => {
363
- if (!reg.isDestroyed()) {
364
- pdfContext.pluginsReady = true;
365
- }
366
- });
367
- pdfContext.registry = reg;
368
- pdfContext.isInitializing = false;
369
- return unsubscribe;
370
- };
371
- let cleanup;
372
- initialize().then((unsub) => {
373
- cleanup = unsub;
374
- }).catch(console.error);
375
- return () => {
376
- cleanup == null ? void 0 : cleanup();
377
- reg.destroy();
378
- pdfContext.registry = null;
379
- pdfContext.coreState = null;
380
- pdfContext.isInitializing = true;
381
- pdfContext.pluginsReady = false;
382
- pdfContext.activeDocumentId = null;
383
- pdfContext.activeDocument = null;
384
- pdfContext.documents = {};
385
- pdfContext.documentStates = [];
386
- };
387
- }
388
- });
389
- var fragment = $.comment();
390
- var node = $.first_child(fragment);
391
- {
392
- var consequent = ($$anchor2) => {
393
- AutoMount($$anchor2, {
394
- get plugins() {
395
- return $$props.plugins;
396
- },
397
- children: ($$anchor3, $$slotProps) => {
398
- var fragment_2 = $.comment();
399
- var node_1 = $.first_child(fragment_2);
400
- $.snippet(node_1, () => $$props.children, () => pdfContext);
401
- $.append($$anchor3, fragment_2);
402
- },
403
- $$slots: { default: true }
404
- });
405
- };
406
- var alternate = ($$anchor2) => {
407
- var fragment_3 = $.comment();
408
- var node_2 = $.first_child(fragment_3);
409
- $.snippet(node_2, () => $$props.children, () => pdfContext);
410
- $.append($$anchor2, fragment_3);
411
- };
412
- $.if(node, ($$render) => {
413
- if (pdfContext.pluginsReady && autoMountDomElements()) $$render(consequent);
414
- else $$render(alternate, false);
415
- });
416
- }
417
- $.append($$anchor, fragment);
418
- $.pop();
419
- }
420
- export {
421
- EmbedPDF,
422
- pdfContext,
423
- useCapability,
424
- useCoreState,
425
- useDocumentPermissions,
426
- useDocumentState,
427
- usePlugin,
428
- useRegistry
429
- };
430
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-registry.svelte.ts","../../src/svelte/hooks/use-plugin.svelte.ts","../../src/svelte/hooks/use-capability.svelte.ts","../../src/svelte/hooks/use-core-state.svelte.ts","../../src/svelte/hooks/use-document-state.svelte.ts","../../src/lib/types/permissions.ts","../../src/lib/store/selectors.ts","../../src/svelte/hooks/use-document-permissions.svelte.ts","../../src/svelte/components/NestedWrapper.svelte","../../src/svelte/components/AutoMount.svelte","../../src/svelte/components/EmbedPDF.svelte"],"sourcesContent":["import type { PluginRegistry, CoreState, DocumentState } from '@embedpdf/core';\n\nexport interface PDFContextState {\n registry: PluginRegistry | null;\n coreState: CoreState | null;\n isInitializing: boolean;\n pluginsReady: boolean;\n\n // Convenience accessors (always safe to use)\n activeDocumentId: string | null;\n activeDocument: DocumentState | null;\n documents: Record<string, DocumentState>;\n documentStates: DocumentState[];\n}\n\nexport const pdfContext = $state<PDFContextState>({\n registry: null,\n coreState: null,\n isInitializing: true,\n pluginsReady: false,\n activeDocumentId: null,\n activeDocument: null,\n documents: {},\n documentStates: [],\n});\n\n/**\n * Hook to access the PDF registry context.\n * @returns The PDF registry or null during initialization\n */\n\nexport const useRegistry = () => pdfContext;\n","import type { BasePlugin } from '@embedpdf/core';\nimport { pdfContext } from './use-registry.svelte.js';\n\n/**\n * Hook to access a plugin.\n * @param pluginId The ID of the plugin to access\n * @returns The plugin or null during initialization\n * @example\n * // Get zoom plugin\n * const zoom = usePlugin<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function usePlugin<T extends BasePlugin>(pluginId: T['id']) {\n const { registry } = pdfContext;\n\n const state = $state({\n plugin: null as T | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n if (registry === null) {\n return state;\n }\n\n const plugin = registry.getPlugin<T>(pluginId);\n\n if (!plugin) {\n throw new Error(`Plugin ${pluginId} not found`);\n }\n\n state.plugin = plugin;\n state.isLoading = false;\n state.ready = plugin.ready();\n\n return state;\n}\n","import type { BasePlugin } from '@embedpdf/core';\nimport { usePlugin } from './use-plugin.svelte.js';\n\n/**\n * Hook to access a plugin's capability.\n * @param pluginId The ID of the plugin to access\n * @returns The capability provided by the plugin or null during initialization\n * @example\n * // Get zoom capability\n * const zoom = useCapability<ZoomPlugin>(ZoomPlugin.id);\n */\nexport function useCapability<T extends BasePlugin>(pluginId: T['id']) {\n const p = usePlugin<T>(pluginId);\n\n const state = $state({\n provides: null as ReturnType<NonNullable<T['provides']>> | null,\n isLoading: true,\n ready: new Promise<void>(() => {}),\n });\n\n // Use $effect to reactively update when plugin loads\n $effect(() => {\n if (!p.plugin) {\n state.provides = null;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n return;\n }\n\n if (!p.plugin.provides) {\n throw new Error(`Plugin ${pluginId} does not provide a capability`);\n }\n\n state.provides = p.plugin.provides() as ReturnType<NonNullable<T['provides']>>;\n state.isLoading = p.isLoading;\n state.ready = p.ready;\n });\n\n return state;\n}\n","import { useRegistry } from './use-registry.svelte';\n\n/**\n * Hook that provides access to the current core state.\n *\n * Note: This reads from the context which is already subscribed to core state changes\n * in the EmbedPDF component, so there's no additional subscription overhead.\n */\nexport function useCoreState() {\n const context = useRegistry();\n\n return {\n get current() {\n return context.coreState;\n },\n };\n}\n","import { useCoreState } from './use-core-state.svelte';\n\n/**\n * Hook that provides reactive access to a specific document's state from the core store.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns The reactive DocumentState object or null if not found.\n */\nexport function useDocumentState(getDocumentId: () => string | null) {\n const coreStateRef = useCoreState();\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n const documentState = $derived(\n coreStateRef.current && documentId\n ? (coreStateRef.current.documents[documentId] ?? null)\n : null,\n );\n\n return {\n get current() {\n return documentState;\n },\n };\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\n\n/**\n * Human-readable permission names for use in configuration.\n */\nexport type PermissionName =\n | 'print'\n | 'modifyContents'\n | 'copyContents'\n | 'modifyAnnotations'\n | 'fillForms'\n | 'extractForAccessibility'\n | 'assembleDocument'\n | 'printHighQuality';\n\n/**\n * Map from human-readable names to PdfPermissionFlag values.\n */\nexport const PERMISSION_NAME_TO_FLAG: Record<PermissionName, PdfPermissionFlag> = {\n print: PdfPermissionFlag.Print,\n modifyContents: PdfPermissionFlag.ModifyContents,\n copyContents: PdfPermissionFlag.CopyContents,\n modifyAnnotations: PdfPermissionFlag.ModifyAnnotations,\n fillForms: PdfPermissionFlag.FillForms,\n extractForAccessibility: PdfPermissionFlag.ExtractForAccessibility,\n assembleDocument: PdfPermissionFlag.AssembleDocument,\n printHighQuality: PdfPermissionFlag.PrintHighQuality,\n};\n\n/**\n * Permission overrides can use either numeric flags or human-readable string names.\n */\nexport type PermissionOverrides = Partial<\n Record<PdfPermissionFlag, boolean> & Record<PermissionName, boolean>\n>;\n\n/**\n * Configuration for overriding document permissions.\n * Can be applied globally (at PluginRegistry level) or per-document (when opening).\n */\nexport interface PermissionConfig {\n /**\n * When true (default): use PDF's permissions as the base, then apply overrides.\n * When false: treat document as having all permissions allowed, then apply overrides.\n */\n enforceDocumentPermissions?: boolean;\n\n /**\n * Explicit per-flag overrides. Supports both numeric flags and string names.\n * - true = force allow (even if PDF denies)\n * - false = force deny (even if PDF allows)\n * - undefined = use base permissions\n *\n * @example\n * // Using string names (recommended)\n * overrides: { print: false, modifyAnnotations: true }\n *\n * @example\n * // Using numeric flags\n * overrides: { [PdfPermissionFlag.Print]: false }\n */\n overrides?: PermissionOverrides;\n}\n\n/**\n * All permission flags for iteration when computing effective permissions.\n */\nexport const ALL_PERMISSION_FLAGS: PdfPermissionFlag[] = [\n PdfPermissionFlag.Print,\n PdfPermissionFlag.ModifyContents,\n PdfPermissionFlag.CopyContents,\n PdfPermissionFlag.ModifyAnnotations,\n PdfPermissionFlag.FillForms,\n PdfPermissionFlag.ExtractForAccessibility,\n PdfPermissionFlag.AssembleDocument,\n PdfPermissionFlag.PrintHighQuality,\n];\n\n/**\n * All permission names for iteration.\n */\nexport const ALL_PERMISSION_NAMES: PermissionName[] = [\n 'print',\n 'modifyContents',\n 'copyContents',\n 'modifyAnnotations',\n 'fillForms',\n 'extractForAccessibility',\n 'assembleDocument',\n 'printHighQuality',\n];\n\n/**\n * Map from PdfPermissionFlag to human-readable name.\n */\nexport const PERMISSION_FLAG_TO_NAME: Record<PdfPermissionFlag, PermissionName> = {\n [PdfPermissionFlag.Print]: 'print',\n [PdfPermissionFlag.ModifyContents]: 'modifyContents',\n [PdfPermissionFlag.CopyContents]: 'copyContents',\n [PdfPermissionFlag.ModifyAnnotations]: 'modifyAnnotations',\n [PdfPermissionFlag.FillForms]: 'fillForms',\n [PdfPermissionFlag.ExtractForAccessibility]: 'extractForAccessibility',\n [PdfPermissionFlag.AssembleDocument]: 'assembleDocument',\n [PdfPermissionFlag.PrintHighQuality]: 'printHighQuality',\n};\n\n/**\n * Helper to get the override value for a permission flag, checking both numeric and string keys.\n */\nexport function getPermissionOverride(\n overrides: PermissionOverrides | undefined,\n flag: PdfPermissionFlag,\n): boolean | undefined {\n if (!overrides) return undefined;\n\n // Check numeric key first\n if (flag in overrides) {\n return (overrides as Record<PdfPermissionFlag, boolean>)[flag];\n }\n\n // Check string key\n const name = PERMISSION_FLAG_TO_NAME[flag];\n if (name && name in overrides) {\n return (overrides as Record<PermissionName, boolean>)[name];\n }\n\n return undefined;\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { CoreState, DocumentState } from './initial-state';\nimport { ALL_PERMISSION_FLAGS, getPermissionOverride } from '../types/permissions';\n\n/**\n * Get the active document state\n */\nexport const getActiveDocumentState = (state: CoreState): DocumentState | null => {\n if (!state.activeDocumentId) return null;\n return state.documents[state.activeDocumentId] ?? null;\n};\n\n/**\n * Get document state by ID\n */\nexport const getDocumentState = (state: CoreState, documentId: string): DocumentState | null => {\n return state.documents[documentId] ?? null;\n};\n\n/**\n * Get all document IDs\n */\nexport const getDocumentIds = (state: CoreState): string[] => {\n return Object.keys(state.documents);\n};\n\n/**\n * Check if a document is loaded\n */\nexport const isDocumentLoaded = (state: CoreState, documentId: string): boolean => {\n return !!state.documents[documentId];\n};\n\n/**\n * Get the number of open documents\n */\nexport const getDocumentCount = (state: CoreState): number => {\n return Object.keys(state.documents).length;\n};\n\n// ─────────────────────────────────────────────────────────\n// Permission Selectors\n// ─────────────────────────────────────────────────────────\n\n/**\n * Check if a specific permission flag is effectively allowed for a document.\n * Applies layered resolution: per-document override → global override → enforceDocumentPermissions → PDF permission.\n *\n * @param state - The core state\n * @param documentId - The document ID to check permissions for\n * @param flag - The permission flag to check\n * @returns true if the permission is allowed, false otherwise\n */\nexport function getEffectivePermission(\n state: CoreState,\n documentId: string,\n flag: PdfPermissionFlag,\n): boolean {\n const docState = state.documents[documentId];\n const docConfig = docState?.permissions;\n const globalConfig = state.globalPermissions;\n const pdfPermissions = docState?.document?.permissions ?? PdfPermissionFlag.AllowAll;\n\n // 1. Per-document override wins (supports both numeric and string keys)\n const docOverride = getPermissionOverride(docConfig?.overrides, flag);\n if (docOverride !== undefined) {\n return docOverride;\n }\n\n // 2. Global override (supports both numeric and string keys)\n const globalOverride = getPermissionOverride(globalConfig?.overrides, flag);\n if (globalOverride !== undefined) {\n return globalOverride;\n }\n\n // 3. Check enforce setting (per-doc takes precedence over global)\n const enforce =\n docConfig?.enforceDocumentPermissions ?? globalConfig?.enforceDocumentPermissions ?? true;\n\n if (!enforce) return true; // Not enforcing = allow all\n\n // 4. Use PDF permission\n return (pdfPermissions & flag) !== 0;\n}\n\n/**\n * Get all effective permissions as a bitmask for a document.\n * Combines all individual permission checks into a single bitmask.\n *\n * @param state - The core state\n * @param documentId - The document ID to get permissions for\n * @returns A bitmask of all effective permissions\n */\nexport function getEffectivePermissions(state: CoreState, documentId: string): number {\n return ALL_PERMISSION_FLAGS.reduce((acc, flag) => {\n return getEffectivePermission(state, documentId, flag) ? acc | flag : acc;\n }, 0);\n}\n","import { PdfPermissionFlag } from '@embedpdf/models';\nimport { useCoreState } from './use-core-state.svelte';\nimport { getEffectivePermission, getEffectivePermissions } from '../../lib/store/selectors';\n\nexport interface DocumentPermissions {\n /** Effective permission flags after applying overrides */\n permissions: number;\n /** Raw PDF permission flags (before overrides) */\n pdfPermissions: number;\n /** Check if a specific permission flag is effectively allowed */\n hasPermission: (flag: PdfPermissionFlag) => boolean;\n /** Check if all specified flags are effectively allowed */\n hasAllPermissions: (...flags: PdfPermissionFlag[]) => boolean;\n\n // Shorthand booleans for all permission flags (using effective permissions):\n /** Can print (possibly degraded quality) */\n canPrint: boolean;\n /** Can modify document contents */\n canModifyContents: boolean;\n /** Can copy/extract text and graphics */\n canCopyContents: boolean;\n /** Can add/modify annotations and fill forms */\n canModifyAnnotations: boolean;\n /** Can fill in existing form fields */\n canFillForms: boolean;\n /** Can extract for accessibility */\n canExtractForAccessibility: boolean;\n /** Can assemble document (insert, rotate, delete pages) */\n canAssembleDocument: boolean;\n /** Can print high quality */\n canPrintHighQuality: boolean;\n}\n\n/**\n * Hook that provides reactive access to a document's effective permission flags.\n * Applies layered resolution: per-document override → global override → PDF permission.\n *\n * @param getDocumentId Function that returns the document ID\n * @returns An object with reactive permission properties.\n */\nexport function useDocumentPermissions(getDocumentId: () => string): DocumentPermissions {\n const coreStateRef = useCoreState();\n\n const documentId = $derived(getDocumentId());\n const coreState = $derived(coreStateRef.current);\n\n const effectivePermissions = $derived(\n coreState ? getEffectivePermissions(coreState, documentId) : PdfPermissionFlag.AllowAll,\n );\n\n const pdfPermissions = $derived(\n coreState?.documents[documentId]?.document?.permissions ?? PdfPermissionFlag.AllowAll,\n );\n\n const hasPermission = (flag: PdfPermissionFlag) =>\n coreState ? getEffectivePermission(coreState, documentId, flag) : true;\n\n const hasAllPermissions = (...flags: PdfPermissionFlag[]) =>\n flags.every((flag) => (coreState ? getEffectivePermission(coreState, documentId, flag) : true));\n\n return {\n get permissions() {\n return effectivePermissions;\n },\n get pdfPermissions() {\n return pdfPermissions;\n },\n hasPermission,\n hasAllPermissions,\n get canPrint() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.Print)\n : true;\n },\n get canModifyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyContents)\n : true;\n },\n get canCopyContents() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.CopyContents)\n : true;\n },\n get canModifyAnnotations() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ModifyAnnotations)\n : true;\n },\n get canFillForms() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.FillForms)\n : true;\n },\n get canExtractForAccessibility() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.ExtractForAccessibility)\n : true;\n },\n get canAssembleDocument() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.AssembleDocument)\n : true;\n },\n get canPrintHighQuality() {\n return coreState\n ? getEffectivePermission(coreState, documentId, PdfPermissionFlag.PrintHighQuality)\n : true;\n },\n };\n}\n","<script lang=\"ts\">\n import { type Component, type Snippet } from 'svelte';\n import NestedWrapper from './NestedWrapper.svelte';\n\n interface Props {\n wrappers: Component[];\n utilities?: Component[];\n children?: Snippet;\n }\n\n let { wrappers, utilities = [], children }: Props = $props();\n</script>\n\n{#if wrappers.length > 1}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n <NestedWrapper wrappers={wrappers.slice(1)} {utilities}>\n {@render children?.()}\n </NestedWrapper>\n </Wrapper>\n{:else}\n {@const Wrapper = wrappers[0]}\n <Wrapper>\n {@render children?.()}\n <!-- Render utilities inside the innermost wrapper -->\n {#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n {/each}\n </Wrapper>\n{/if}\n","<script lang=\"ts\">\n import { hasAutoMountElements, type PluginBatchRegistration, type IPlugin } from '@embedpdf/core';\n import NestedWrapper from './NestedWrapper.svelte';\n import type { Snippet } from 'svelte';\n\n type Props = {\n plugins: PluginBatchRegistration<IPlugin<any>, any>[];\n children: Snippet;\n };\n\n let { plugins, children }: Props = $props();\n let utilities: any[] = $state([]);\n let wrappers: any[] = $state([]);\n\n // recompute when plugins change\n $effect(() => {\n const nextUtilities: any[] = [];\n const nextWrappers: any[] = [];\n\n for (const reg of plugins) {\n const pkg = reg.package;\n if (hasAutoMountElements(pkg)) {\n const elements = pkg.autoMountElements?.() ?? [];\n for (const element of elements) {\n if (element.type === 'utility') {\n nextUtilities.push(element.component);\n } else if (element.type === 'wrapper') {\n nextWrappers.push(element.component);\n }\n }\n }\n }\n\n utilities = nextUtilities;\n wrappers = nextWrappers;\n });\n</script>\n\n{#if wrappers.length > 0}\n <!-- wrap slot content and utilities inside all wrappers -->\n <NestedWrapper {wrappers} {utilities} {children} />\n{:else}\n <!-- No wrappers - render children and utilities directly -->\n {@render children?.()}\n {#each utilities as Utility, i (`utility-${i}`)}\n <Utility />\n {/each}\n{/if}\n","<script lang=\"ts\">\n import type { Logger, PdfEngine } from '@embedpdf/models';\n import {\n type IPlugin,\n type PluginBatchRegistrations,\n type PluginRegistryConfig,\n PluginRegistry,\n } from '@embedpdf/core';\n import { type Snippet } from 'svelte';\n import AutoMount from './AutoMount.svelte';\n import { pdfContext, type PDFContextState } from '../hooks';\n\n export type { PluginBatchRegistrations };\n\n interface EmbedPDFProps {\n /**\n * The PDF engine to use for the PDF viewer.\n */\n engine: PdfEngine;\n /**\n * Registry configuration including logger, permissions, and defaults.\n */\n config?: PluginRegistryConfig;\n /**\n * @deprecated Use config.logger instead. Will be removed in next major version.\n */\n logger?: Logger;\n /**\n * The callback to call when the PDF viewer is initialized.\n */\n onInitialized?: (registry: PluginRegistry) => Promise<void>;\n /**\n * The plugins to use for the PDF viewer.\n */\n plugins: PluginBatchRegistrations;\n /**\n * The children to render for the PDF viewer.\n */\n children: Snippet<[PDFContextState]>;\n /**\n * Whether to auto-mount specific non-visual DOM elements from plugins.\n * @default true\n */\n autoMountDomElements?: boolean;\n }\n\n let {\n engine,\n config,\n logger,\n onInitialized,\n plugins,\n children,\n autoMountDomElements = true,\n }: EmbedPDFProps = $props();\n\n let latestInit = onInitialized;\n\n $effect(() => {\n if (onInitialized) {\n latestInit = onInitialized;\n }\n });\n\n $effect(() => {\n if (engine || (engine && plugins)) {\n // Merge deprecated logger prop into config (config.logger takes precedence)\n const finalConfig: PluginRegistryConfig = {\n ...config,\n logger: config?.logger ?? logger,\n };\n const reg = new PluginRegistry(engine, finalConfig);\n reg.registerPluginBatch(plugins);\n\n const initialize = async () => {\n await reg.initialize();\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n return;\n }\n\n const store = reg.getStore();\n pdfContext.coreState = store.getState().core;\n\n const unsubscribe = store.subscribe((action, newState, oldState) => {\n // Only update if it's a core action and the core state changed\n if (store.isCoreAction(action) && newState.core !== oldState.core) {\n pdfContext.coreState = newState.core;\n\n // Update convenience accessors\n const activeDocumentId = newState.core.activeDocumentId ?? null;\n const documents = newState.core.documents ?? {};\n const documentOrder = newState.core.documentOrder ?? [];\n\n pdfContext.activeDocumentId = activeDocumentId;\n pdfContext.activeDocument =\n activeDocumentId && documents[activeDocumentId] ? documents[activeDocumentId] : null;\n pdfContext.documents = documents;\n pdfContext.documentStates = documentOrder\n .map((docId) => documents[docId])\n .filter(\n (doc): doc is import('@embedpdf/core').DocumentState =>\n doc !== null && doc !== undefined,\n );\n }\n });\n\n /* always call the *latest* callback */\n await latestInit?.(reg);\n\n // if the registry is destroyed, don't do anything\n if (reg.isDestroyed()) {\n unsubscribe();\n return;\n }\n\n reg.pluginsReady().then(() => {\n if (!reg.isDestroyed()) {\n pdfContext.pluginsReady = true;\n }\n });\n\n // Provide the registry to children via context\n pdfContext.registry = reg;\n pdfContext.isInitializing = false;\n\n return unsubscribe;\n };\n\n let cleanup: (() => void) | undefined;\n initialize()\n .then((unsub) => {\n cleanup = unsub;\n })\n .catch(console.error);\n\n return () => {\n cleanup?.();\n reg.destroy();\n pdfContext.registry = null;\n pdfContext.coreState = null;\n pdfContext.isInitializing = true;\n pdfContext.pluginsReady = false;\n pdfContext.activeDocumentId = null;\n pdfContext.activeDocument = null;\n pdfContext.documents = {};\n pdfContext.documentStates = [];\n };\n }\n });\n</script>\n\n{#if pdfContext.pluginsReady && autoMountDomElements}\n <AutoMount {plugins}>{@render children(pdfContext)}</AutoMount>\n{:else}\n {@render children(pdfContext)}\n{/if}\n"],"names":["$$anchor","NestedWrapper"],"mappings":";;;;MAea;EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB;EACA;;AAQW,MAAA,oBAAoB;SCpBjB,UAAgC,UAAmB;AACzD,QAAA,EAAA,aAAa;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AW;AACtB,mBAAW,YAAY;AACvB,mBAAW,iBAAiB;AAC5B,mBAAW,eAAe;AAC1B,mBAAW,mBAAmB;AAC9B,mBAAW,iBAAiB;AAC5B,mBAAW,YAAS,CAAA;AACpB,mBAAW,iBAAc,CAAA;AAAA,MAC3B;AAAA,IACF;AAAA,EACF,CAAC;;;;;AAIA,gBAASA,WAAA;AAAA;;;;;;0DAA6B,UAAU;;;;;;;;;sDAE/B,UAAU;;;;UAHzB,WAAW,gBAAgB,uBAAoB,UAAA,UAAA;AAAA,UAAA,UAAA,WAAA,KAAA;AAAA;;;;AAF5C;"}
@@ -1,19 +0,0 @@
1
- import { PluginBatchRegistration, IPlugin } from '../../lib/index.ts';
2
- type __VLS_Props = {
3
- plugins: PluginBatchRegistration<IPlugin<any>, any>[];
4
- };
5
- declare var __VLS_8: {}, __VLS_10: {};
6
- type __VLS_Slots = {} & {
7
- default?: (props: typeof __VLS_8) => any;
8
- } & {
9
- default?: (props: typeof __VLS_10) => any;
10
- };
11
- declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
13
- declare const _default: typeof __VLS_export;
14
- export default _default;
15
- type __VLS_WithSlots<T, S> = T & {
16
- new (): {
17
- $slots: S;
18
- };
19
- };
@@ -1,104 +0,0 @@
1
- import { PluginRegistry, PluginBatchRegistrations, PluginRegistryConfig, DocumentState } from '../../lib/index.ts';
2
- import { Logger, PdfEngine } from '@embedpdf/models';
3
- export type { PluginBatchRegistrations };
4
- type __VLS_Props = {
5
- engine: PdfEngine;
6
- /** Registry configuration including logger, permissions, and defaults. */
7
- config?: PluginRegistryConfig;
8
- /** @deprecated Use config.logger instead. Will be removed in next major version. */
9
- logger?: Logger;
10
- plugins: PluginBatchRegistrations;
11
- onInitialized?: (registry: PluginRegistry) => Promise<void>;
12
- autoMountDomElements?: boolean;
13
- };
14
- declare var __VLS_8: {
15
- registry: PluginRegistry | null;
16
- coreState: {
17
- documents: Record<string, DocumentState>;
18
- documentOrder: string[];
19
- activeDocumentId: string | null;
20
- defaultScale: number;
21
- defaultRotation: import('@embedpdf/models').Rotation;
22
- globalPermissions?: {
23
- enforceDocumentPermissions?: boolean | undefined;
24
- overrides?: {
25
- 4?: boolean | undefined;
26
- 8?: boolean | undefined;
27
- 16?: boolean | undefined;
28
- 32?: boolean | undefined;
29
- 256?: boolean | undefined;
30
- 512?: boolean | undefined;
31
- 1024?: boolean | undefined;
32
- 2048?: boolean | undefined;
33
- 3900?: boolean | undefined;
34
- print?: boolean | undefined;
35
- modifyContents?: boolean | undefined;
36
- copyContents?: boolean | undefined;
37
- modifyAnnotations?: boolean | undefined;
38
- fillForms?: boolean | undefined;
39
- extractForAccessibility?: boolean | undefined;
40
- assembleDocument?: boolean | undefined;
41
- printHighQuality?: boolean | undefined;
42
- } | undefined;
43
- } | undefined;
44
- } | null;
45
- isInitializing: boolean;
46
- pluginsReady: true;
47
- activeDocumentId: string | null;
48
- activeDocument: DocumentState | null;
49
- documents: Record<string, DocumentState>;
50
- documentStates: DocumentState[];
51
- }, __VLS_10: {
52
- registry: PluginRegistry | null;
53
- coreState: {
54
- documents: Record<string, DocumentState>;
55
- documentOrder: string[];
56
- activeDocumentId: string | null;
57
- defaultScale: number;
58
- defaultRotation: import('@embedpdf/models').Rotation;
59
- globalPermissions?: {
60
- enforceDocumentPermissions?: boolean | undefined;
61
- overrides?: {
62
- 4?: boolean | undefined;
63
- 8?: boolean | undefined;
64
- 16?: boolean | undefined;
65
- 32?: boolean | undefined;
66
- 256?: boolean | undefined;
67
- 512?: boolean | undefined;
68
- 1024?: boolean | undefined;
69
- 2048?: boolean | undefined;
70
- 3900?: boolean | undefined;
71
- print?: boolean | undefined;
72
- modifyContents?: boolean | undefined;
73
- copyContents?: boolean | undefined;
74
- modifyAnnotations?: boolean | undefined;
75
- fillForms?: boolean | undefined;
76
- extractForAccessibility?: boolean | undefined;
77
- assembleDocument?: boolean | undefined;
78
- printHighQuality?: boolean | undefined;
79
- } | undefined;
80
- } | undefined;
81
- } | null;
82
- isInitializing: boolean;
83
- pluginsReady: boolean;
84
- activeDocumentId: string | null;
85
- activeDocument: DocumentState | null;
86
- documents: Record<string, DocumentState>;
87
- documentStates: DocumentState[];
88
- };
89
- type __VLS_Slots = {} & {
90
- default?: (props: typeof __VLS_8) => any;
91
- } & {
92
- default?: (props: typeof __VLS_10) => any;
93
- };
94
- declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
95
- autoMountDomElements: boolean;
96
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
97
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
98
- declare const _default: typeof __VLS_export;
99
- export default _default;
100
- type __VLS_WithSlots<T, S> = T & {
101
- new (): {
102
- $slots: S;
103
- };
104
- };
@@ -1 +0,0 @@
1
- export { default as EmbedPDF } from './embed-pdf.vue';
@@ -1,19 +0,0 @@
1
- type __VLS_Props = {
2
- wrappers: any[];
3
- utilities?: any[];
4
- };
5
- declare var __VLS_14: {}, __VLS_16: {};
6
- type __VLS_Slots = {} & {
7
- default?: (props: typeof __VLS_14) => any;
8
- } & {
9
- default?: (props: typeof __VLS_16) => any;
10
- };
11
- declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
13
- declare const _default: typeof __VLS_export;
14
- export default _default;
15
- type __VLS_WithSlots<T, S> = T & {
16
- new (): {
17
- $slots: S;
18
- };
19
- };
@@ -1,7 +0,0 @@
1
- export * from './use-core-state';
2
- export * from './use-document-state';
3
- export * from './use-document-permissions';
4
- export * from './use-registry';
5
- export * from './use-plugin';
6
- export * from './use-capability';
7
- export * from './use-store-state';
@@ -1,15 +0,0 @@
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']>>>;