@embedpdf/plugin-stamp 3.0.0-next.21 → 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.cjs
CHANGED
|
@@ -79,7 +79,7 @@ function createCatalog(ctx, { binaries, assetEngine, ghosts, targets }) {
|
|
|
79
79
|
mimeType: preview.mimeType ?? "image/png"
|
|
80
80
|
} : null;
|
|
81
81
|
}),
|
|
82
|
-
|
|
82
|
+
getAssetBytes: (assetId) => {
|
|
83
83
|
const bytes = assetBinaries.get(assetId)?.bytes;
|
|
84
84
|
return bytes ? new Uint8Array(bytes) : null;
|
|
85
85
|
},
|
|
@@ -173,7 +173,7 @@ function createAssetEngine(ctx) {
|
|
|
173
173
|
if (image.source.kind !== "bytes") throw stampError("unsupported", "the asset engine returned a URL-sourced render; asset engines must be local");
|
|
174
174
|
return {
|
|
175
175
|
bytes: image.source.bytes,
|
|
176
|
-
mimeType: image.
|
|
176
|
+
mimeType: image.mimeType
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
179
|
/** Thumbnail render of one library page (the small picker image). */
|
|
@@ -552,7 +552,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
552
552
|
ctx.state.update(addAsset, appended.asset);
|
|
553
553
|
libraryChanged.emit({
|
|
554
554
|
libraryId: liveLibrary.id,
|
|
555
|
-
|
|
555
|
+
type: "asset-created"
|
|
556
556
|
});
|
|
557
557
|
assetCreated.emit({
|
|
558
558
|
assetId: appended.asset.id,
|
|
@@ -603,7 +603,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
603
603
|
ctx.state.update(removeAsset, id);
|
|
604
604
|
libraryChanged.emit({
|
|
605
605
|
libraryId: library.id,
|
|
606
|
-
|
|
606
|
+
type: "asset-deleted"
|
|
607
607
|
});
|
|
608
608
|
assetDeleted.emit({
|
|
609
609
|
assetId: id,
|
|
@@ -621,13 +621,13 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
621
621
|
const asset = ctx.state.get().assets[id];
|
|
622
622
|
const library = asset ? ctx.state.get().libraries[asset.libraryId] : void 0;
|
|
623
623
|
if (!asset || !library) throw notFound("asset", id);
|
|
624
|
+
const { subject: _subject, ...withoutSubject } = asset;
|
|
624
625
|
const next = {
|
|
625
|
-
...asset,
|
|
626
|
+
...patch.subject === null ? withoutSubject : asset,
|
|
626
627
|
...patch.label !== void 0 ? { label: patch.label } : {},
|
|
627
|
-
...patch.categories !== void 0 ? { categories: patch.categories } : {}
|
|
628
|
+
...patch.categories !== void 0 ? { categories: patch.categories } : {},
|
|
629
|
+
...patch.subject !== void 0 && patch.subject !== null ? { subject: patch.subject } : {}
|
|
628
630
|
};
|
|
629
|
-
if (patch.subject === null) delete next.subject;
|
|
630
|
-
else if (patch.subject !== void 0) next.subject = patch.subject;
|
|
631
631
|
const canonicalBytes = libraryBinaries.get(library.id);
|
|
632
632
|
if (!canonicalBytes) throw stampError("operation-failed", `canonical bytes are missing for library '${library.id}'`);
|
|
633
633
|
const doc = await ctx.cancellable(signal, openAssetDocument(canonicalBytes));
|
|
@@ -651,7 +651,7 @@ function createAssetWrites(ctx, { events, binaries, assetEngine, targets }, { re
|
|
|
651
651
|
ctx.state.update(setAsset, next);
|
|
652
652
|
libraryChanged.emit({
|
|
653
653
|
libraryId: library.id,
|
|
654
|
-
|
|
654
|
+
type: "asset-updated"
|
|
655
655
|
});
|
|
656
656
|
assetUpdated.emit({
|
|
657
657
|
assetId: next.id,
|
|
@@ -804,7 +804,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
804
804
|
ctx.state.update(addLibrary, library);
|
|
805
805
|
libraryChanged.emit({
|
|
806
806
|
libraryId: id,
|
|
807
|
-
|
|
807
|
+
type: "created"
|
|
808
808
|
});
|
|
809
809
|
libraryCreated.emit({
|
|
810
810
|
libraryId: id,
|
|
@@ -880,7 +880,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
880
880
|
for (const descriptor of descriptors) {
|
|
881
881
|
const handle = doc.page(descriptor.page);
|
|
882
882
|
const entries = (await handle.pieceInfo.get("EMBD_Stamp"))?.entries ?? {};
|
|
883
|
-
const kind = options?.
|
|
883
|
+
const kind = options?.assetKind ?? kindFromPdfName(entryName(entries, "Kind")) ?? "stamp";
|
|
884
884
|
const subject = entryString(entries, "SubjectOverride");
|
|
885
885
|
const categories = entryStringArray(entries, "Categories");
|
|
886
886
|
const page = pagesByObjectNumber.get(descriptor.page.objectNumber);
|
|
@@ -936,7 +936,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
936
936
|
}
|
|
937
937
|
libraryChanged.emit({
|
|
938
938
|
libraryId: imported.library.id,
|
|
939
|
-
|
|
939
|
+
type: "imported"
|
|
940
940
|
});
|
|
941
941
|
libraryCreated.emit({
|
|
942
942
|
libraryId: imported.library.id,
|
|
@@ -964,7 +964,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
964
964
|
if (existed) {
|
|
965
965
|
libraryChanged.emit({
|
|
966
966
|
libraryId: id,
|
|
967
|
-
|
|
967
|
+
type: "deleted"
|
|
968
968
|
});
|
|
969
969
|
libraryDeleted.emit({
|
|
970
970
|
libraryId: id,
|
|
@@ -1004,7 +1004,7 @@ function createLibraryWrites(ctx, { events, binaries, assetEngine }) {
|
|
|
1004
1004
|
ctx.state.update(setLibrary, next);
|
|
1005
1005
|
libraryChanged.emit({
|
|
1006
1006
|
libraryId: id,
|
|
1007
|
-
|
|
1007
|
+
type: "updated"
|
|
1008
1008
|
});
|
|
1009
1009
|
libraryUpdated.emit({
|
|
1010
1010
|
libraryId: id,
|
|
@@ -1233,8 +1233,8 @@ function createPlacement(ctx, { binaries, assetEngine, ghosts, targets }, { canP
|
|
|
1233
1233
|
preview: imageToPreview(image)
|
|
1234
1234
|
};
|
|
1235
1235
|
} finally {
|
|
1236
|
-
scripting?.
|
|
1237
|
-
realm?.
|
|
1236
|
+
scripting?.destroy();
|
|
1237
|
+
realm?.destroy();
|
|
1238
1238
|
await doc.close();
|
|
1239
1239
|
}
|
|
1240
1240
|
};
|
|
@@ -1502,9 +1502,9 @@ function persistStampLibraries(stamp, store, options = {}) {
|
|
|
1502
1502
|
if (fresh.next) run(libraryId, fresh.next);
|
|
1503
1503
|
});
|
|
1504
1504
|
};
|
|
1505
|
-
return stamp.onLibraryChanged(({ libraryId,
|
|
1505
|
+
return stamp.onLibraryChanged(({ libraryId, type }) => {
|
|
1506
1506
|
if (except.has(libraryId)) return;
|
|
1507
|
-
run(libraryId,
|
|
1507
|
+
run(libraryId, type === "deleted" ? "delete" : "save");
|
|
1508
1508
|
});
|
|
1509
1509
|
}
|
|
1510
1510
|
//#endregion
|