@embedpdf/plugin-stamp 3.0.0-next.22 → 3.0.0-next.23
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/{contract-BQP56Vp4.d.cts → contract-Bazr1NDb.d.ts} +26 -26
- package/dist/{contract-D6Hs6iO3.d.ts → contract-CyQ2OdVy.d.cts} +26 -26
- package/dist/contract-DHcn38S9.js.map +1 -1
- package/dist/contract-Dj5KiMyW.cjs.map +1 -1
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, F as restoreStampLibraries, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, N as memoryStampStore, O as StampLibraryPatch, P as persistStampLibraries, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as
|
|
1
|
+
import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, F as restoreStampLibraries, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, N as memoryStampStore, O as StampLibraryPatch, P as persistStampLibraries, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as CreateAssetInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AssetFromAnnotationsInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-CyQ2OdVy.cjs";
|
|
2
2
|
//#region src/model.d.ts
|
|
3
3
|
interface StampModel {
|
|
4
4
|
readonly libraries: Readonly<Record<string, StampLibrary>>;
|
|
@@ -15,7 +15,7 @@ interface StampModel {
|
|
|
15
15
|
* document; placement targets a document through its annotation plugin.
|
|
16
16
|
* `config` is the settings the app registers, over {@link STAMP_DEFAULTS}.
|
|
17
17
|
*/
|
|
18
|
-
declare const stampPlugin: (config?: StampConfig) => import("@embedpdf/core").
|
|
18
|
+
declare const stampPlugin: (config?: StampConfig) => import("@embedpdf/core").PluginDefinition<StampModel, StampCapability, StampSettings>;
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/state.d.ts
|
|
21
21
|
/** The armed stamp. */
|
|
@@ -25,5 +25,5 @@ interface StampState {
|
|
|
25
25
|
}
|
|
26
26
|
declare const stampState: import("@embedpdf/core").StateDeclaration<StampCapability, StampState>;
|
|
27
27
|
//#endregion
|
|
28
|
-
export {
|
|
28
|
+
export { AssetFromAnnotationsInput, CreateAssetInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, type StampState, StampToken, memoryStampStore, persistStampLibraries, restoreStampLibraries, stampPlugin, stampState };
|
|
29
29
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, F as restoreStampLibraries, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, N as memoryStampStore, O as StampLibraryPatch, P as persistStampLibraries, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as
|
|
1
|
+
import { A as StampPlacement, C as StampLibraryChangedEvent, D as StampLibraryKind, E as StampLibraryFilter, F as restoreStampLibraries, I as DEFAULT_LIBRARY_KIND, L as StampToken, M as StampLibraryStore, N as memoryStampStore, O as StampLibraryPatch, P as persistStampLibraries, S as StampLibrary, T as StampLibraryDeletedEvent, _ as StampAssetUpdatedEvent, a as MarkSource, b as StampDocumentOptions, c as StampArmOptions, d as StampAssetDeletedEvent, f as StampAssetEngine, g as StampAssetPreview, h as StampAssetPatch, i as ImportLibraryOptions, j as StampSettings, k as StampLibraryUpdatedEvent, l as StampAsset, m as StampAssetKind, n as CreateAssetInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AssetFromAnnotationsInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-Bazr1NDb.js";
|
|
2
2
|
//#region src/model.d.ts
|
|
3
3
|
interface StampModel {
|
|
4
4
|
readonly libraries: Readonly<Record<string, StampLibrary>>;
|
|
@@ -15,7 +15,7 @@ interface StampModel {
|
|
|
15
15
|
* document; placement targets a document through its annotation plugin.
|
|
16
16
|
* `config` is the settings the app registers, over {@link STAMP_DEFAULTS}.
|
|
17
17
|
*/
|
|
18
|
-
declare const stampPlugin: (config?: StampConfig) => import("@embedpdf/core").
|
|
18
|
+
declare const stampPlugin: (config?: StampConfig) => import("@embedpdf/core").PluginDefinition<StampModel, StampCapability, StampSettings>;
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/state.d.ts
|
|
21
21
|
/** The armed stamp. */
|
|
@@ -25,5 +25,5 @@ interface StampState {
|
|
|
25
25
|
}
|
|
26
26
|
declare const stampState: import("@embedpdf/core").StateDeclaration<StampCapability, StampState>;
|
|
27
27
|
//#endregion
|
|
28
|
-
export {
|
|
28
|
+
export { AssetFromAnnotationsInput, CreateAssetInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampFont, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, type StampState, StampToken, memoryStampStore, persistStampLibraries, restoreStampLibraries, stampPlugin, stampState };
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ function createCatalog(ctx, { binaries, assetEngine, ghosts, targets }) {
|
|
|
78
78
|
mimeType: preview.mimeType ?? "image/png"
|
|
79
79
|
} : null;
|
|
80
80
|
}),
|
|
81
|
-
|
|
81
|
+
getAssetBytes: (assetId) => {
|
|
82
82
|
const bytes = assetBinaries.get(assetId)?.bytes;
|
|
83
83
|
return bytes ? new Uint8Array(bytes) : null;
|
|
84
84
|
},
|
|
@@ -172,7 +172,7 @@ function createAssetEngine(ctx) {
|
|
|
172
172
|
if (image.source.kind !== "bytes") throw stampError("unsupported", "the asset engine returned a URL-sourced render; asset engines must be local");
|
|
173
173
|
return {
|
|
174
174
|
bytes: image.source.bytes,
|
|
175
|
-
mimeType: image.
|
|
175
|
+
mimeType: image.mimeType
|
|
176
176
|
};
|
|
177
177
|
};
|
|
178
178
|
/** Thumbnail render of one library page (the small picker image). */
|
|
@@ -551,7 +551,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
551
551
|
ctx.state.update(addAsset, appended.asset);
|
|
552
552
|
libraryChanged.emit({
|
|
553
553
|
libraryId: liveLibrary.id,
|
|
554
|
-
|
|
554
|
+
type: "asset-created"
|
|
555
555
|
});
|
|
556
556
|
assetCreated.emit({
|
|
557
557
|
assetId: appended.asset.id,
|
|
@@ -602,7 +602,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
602
602
|
ctx.state.update(removeAsset, id);
|
|
603
603
|
libraryChanged.emit({
|
|
604
604
|
libraryId: library.id,
|
|
605
|
-
|
|
605
|
+
type: "asset-deleted"
|
|
606
606
|
});
|
|
607
607
|
assetDeleted.emit({
|
|
608
608
|
assetId: id,
|
|
@@ -620,13 +620,13 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
620
620
|
const asset = ctx.state.get().assets[id];
|
|
621
621
|
const library = asset ? ctx.state.get().libraries[asset.libraryId] : void 0;
|
|
622
622
|
if (!asset || !library) throw notFound("asset", id);
|
|
623
|
+
const { subject: _subject, ...withoutSubject } = asset;
|
|
623
624
|
const next = {
|
|
624
|
-
...asset,
|
|
625
|
+
...patch.subject === null ? withoutSubject : asset,
|
|
625
626
|
...patch.label !== void 0 ? { label: patch.label } : {},
|
|
626
|
-
...patch.categories !== void 0 ? { categories: patch.categories } : {}
|
|
627
|
+
...patch.categories !== void 0 ? { categories: patch.categories } : {},
|
|
628
|
+
...patch.subject !== void 0 && patch.subject !== null ? { subject: patch.subject } : {}
|
|
627
629
|
};
|
|
628
|
-
if (patch.subject === null) delete next.subject;
|
|
629
|
-
else if (patch.subject !== void 0) next.subject = patch.subject;
|
|
630
630
|
const canonicalBytes = libraryBinaries.get(library.id);
|
|
631
631
|
if (!canonicalBytes) throw stampError("operation-failed", `canonical bytes are missing for library '${library.id}'`);
|
|
632
632
|
const doc = await ctx.cancellable(signal, openAssetDocument(canonicalBytes));
|
|
@@ -650,7 +650,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
650
650
|
ctx.state.update(setAsset, next);
|
|
651
651
|
libraryChanged.emit({
|
|
652
652
|
libraryId: library.id,
|
|
653
|
-
|
|
653
|
+
type: "asset-updated"
|
|
654
654
|
});
|
|
655
655
|
assetUpdated.emit({
|
|
656
656
|
assetId: next.id,
|
|
@@ -803,7 +803,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
803
803
|
ctx.state.update(addLibrary, library);
|
|
804
804
|
libraryChanged.emit({
|
|
805
805
|
libraryId: id,
|
|
806
|
-
|
|
806
|
+
type: "created"
|
|
807
807
|
});
|
|
808
808
|
libraryCreated.emit({
|
|
809
809
|
libraryId: id,
|
|
@@ -879,7 +879,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
879
879
|
for (const descriptor of descriptors) {
|
|
880
880
|
const handle = doc.page(descriptor.page);
|
|
881
881
|
const entries = (await handle.pieceInfo.get("EMBD_Stamp"))?.entries ?? {};
|
|
882
|
-
const kind = options?.
|
|
882
|
+
const kind = options?.assetKind ?? kindFromPdfName(entryName(entries, "Kind")) ?? "stamp";
|
|
883
883
|
const subject = entryString(entries, "SubjectOverride");
|
|
884
884
|
const categories = entryStringArray(entries, "Categories");
|
|
885
885
|
const page = pagesByObjectNumber.get(descriptor.page.objectNumber);
|
|
@@ -935,7 +935,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
935
935
|
}
|
|
936
936
|
libraryChanged.emit({
|
|
937
937
|
libraryId: imported.library.id,
|
|
938
|
-
|
|
938
|
+
type: "imported"
|
|
939
939
|
});
|
|
940
940
|
libraryCreated.emit({
|
|
941
941
|
libraryId: imported.library.id,
|
|
@@ -963,7 +963,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
963
963
|
if (existed) {
|
|
964
964
|
libraryChanged.emit({
|
|
965
965
|
libraryId: id,
|
|
966
|
-
|
|
966
|
+
type: "deleted"
|
|
967
967
|
});
|
|
968
968
|
libraryDeleted.emit({
|
|
969
969
|
libraryId: id,
|
|
@@ -1003,7 +1003,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
1003
1003
|
ctx.state.update(setLibrary, next);
|
|
1004
1004
|
libraryChanged.emit({
|
|
1005
1005
|
libraryId: id,
|
|
1006
|
-
|
|
1006
|
+
type: "updated"
|
|
1007
1007
|
});
|
|
1008
1008
|
libraryUpdated.emit({
|
|
1009
1009
|
libraryId: id,
|
|
@@ -1232,8 +1232,8 @@ function createPlacement(ctx, { binaries, assetEngine, ghosts, targets }, { canP
|
|
|
1232
1232
|
preview: imageToPreview(image)
|
|
1233
1233
|
};
|
|
1234
1234
|
} finally {
|
|
1235
|
-
scripting?.
|
|
1236
|
-
realm?.
|
|
1235
|
+
scripting?.destroy();
|
|
1236
|
+
realm?.destroy();
|
|
1237
1237
|
await doc.close();
|
|
1238
1238
|
}
|
|
1239
1239
|
};
|
|
@@ -1501,9 +1501,9 @@ function persistStampLibraries(stamp, store, options = {}) {
|
|
|
1501
1501
|
if (fresh.next) run(libraryId, fresh.next);
|
|
1502
1502
|
});
|
|
1503
1503
|
};
|
|
1504
|
-
return stamp.onLibraryChanged(({ libraryId,
|
|
1504
|
+
return stamp.onLibraryChanged(({ libraryId, type }) => {
|
|
1505
1505
|
if (except.has(libraryId)) return;
|
|
1506
|
-
run(libraryId,
|
|
1506
|
+
run(libraryId, type === "deleted" ? "delete" : "save");
|
|
1507
1507
|
});
|
|
1508
1508
|
}
|
|
1509
1509
|
//#endregion
|