@embedpdf/plugin-stamp 3.0.0-next.19 → 3.0.0-next.20
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-CjGXUUDJ.d.ts → contract-BQP56Vp4.d.cts} +22 -4
- package/dist/{contract-CEeBOug9.d.cts → contract-D6Hs6iO3.d.ts} +22 -4
- package/dist/{contract-CJBvneyw.js → contract-DHcn38S9.js} +2 -1
- package/dist/contract-DHcn38S9.js.map +1 -0
- package/dist/{contract-lDLkRDYV.cjs → contract-Dj5KiMyW.cjs} +2 -1
- package/dist/contract-Dj5KiMyW.cjs.map +1 -0
- package/dist/contract.cjs +1 -1
- package/dist/contract.d.cts +2 -2
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +1 -1
- package/dist/index.cjs +30 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/contract-CJBvneyw.js.map +0 -1
- package/dist/contract-lDLkRDYV.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A 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 AssetFromAnnotationsInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AddAssetInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-BQP56Vp4.cjs";
|
|
2
2
|
//#region src/model.d.ts
|
|
3
3
|
interface StampModel {
|
|
4
4
|
readonly libraries: Readonly<Record<string, StampLibrary>>;
|
|
@@ -25,5 +25,5 @@ interface StampState {
|
|
|
25
25
|
}
|
|
26
26
|
declare const stampState: import("@embedpdf/core").StateDeclaration<StampCapability, StampState>;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { AddAssetInput, AssetFromAnnotationsInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, type StampState, StampToken, memoryStampStore, persistStampLibraries, restoreStampLibraries, stampPlugin, stampState };
|
|
28
|
+
export { AddAssetInput, AssetFromAnnotationsInput, 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
|
|
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 AssetFromAnnotationsInput, o as STAMP_DEFAULTS, p as StampAssetFilter, r as CreateLibraryOptions, s as StampArmChangedEvent, t as AddAssetInput, u as StampAssetCreatedEvent, v as StampCapability, w as StampLibraryCreatedEvent, x as StampFont, y as StampConfig } from "./contract-D6Hs6iO3.js";
|
|
2
2
|
//#region src/model.d.ts
|
|
3
3
|
interface StampModel {
|
|
4
4
|
readonly libraries: Readonly<Record<string, StampLibrary>>;
|
|
@@ -25,5 +25,5 @@ interface StampState {
|
|
|
25
25
|
}
|
|
26
26
|
declare const stampState: import("@embedpdf/core").StateDeclaration<StampCapability, StampState>;
|
|
27
27
|
//#endregion
|
|
28
|
-
export { AddAssetInput, AssetFromAnnotationsInput, CreateLibraryOptions, DEFAULT_LIBRARY_KIND, ImportLibraryOptions, MarkSource, STAMP_DEFAULTS, StampArmChangedEvent, StampArmOptions, StampAsset, StampAssetCreatedEvent, StampAssetDeletedEvent, StampAssetEngine, StampAssetFilter, StampAssetKind, StampAssetPatch, StampAssetPreview, StampAssetUpdatedEvent, StampCapability, StampConfig, StampDocumentOptions, StampLibrary, StampLibraryChangedEvent, StampLibraryCreatedEvent, StampLibraryDeletedEvent, StampLibraryFilter, StampLibraryKind, StampLibraryPatch, type StampLibraryStore, StampLibraryUpdatedEvent, type StampPlacement, StampSettings, type StampState, StampToken, memoryStampStore, persistStampLibraries, restoreStampLibraries, stampPlugin, stampState };
|
|
28
|
+
export { AddAssetInput, AssetFromAnnotationsInput, 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as assetIdFor, c as parseStampKey, d as stampPieceInfo, f as StampToken, i as STAMP_PIECEINFO_APP, l as stampKey, n as DEFAULT_LIBRARY_KIND, o as customStampName, r as STAMP_LIBRARY_PIECEINFO_APP, s as libraryKindFromPdfName, t as STAMP_DEFAULTS, u as stampLibraryPieceInfo } from "./contract-
|
|
1
|
+
import { a as assetIdFor, c as parseStampKey, d as stampPieceInfo, f as StampToken, i as STAMP_PIECEINFO_APP, l as stampKey, n as DEFAULT_LIBRARY_KIND, o as customStampName, r as STAMP_LIBRARY_PIECEINFO_APP, s as libraryKindFromPdfName, t as STAMP_DEFAULTS, u as stampLibraryPieceInfo } from "./contract-DHcn38S9.js";
|
|
2
2
|
import { DocumentsToken, PluginError, composeApi, definePlugin, defineState, toPluginError, toPluginErrorInfo } from "@embedpdf/core";
|
|
3
3
|
import { ActionsToken } from "@embedpdf/plugin-actions/contract";
|
|
4
4
|
import { AnnotationToken } from "@embedpdf/plugin-annotation/contract";
|
|
@@ -125,6 +125,31 @@ function createAssetEngine(ctx) {
|
|
|
125
125
|
}
|
|
126
126
|
return resolved.engine;
|
|
127
127
|
};
|
|
128
|
+
/** Each asset engine's fonts, by key: each read and registered once (a failed read is tried again). */
|
|
129
|
+
const registered = /* @__PURE__ */ new WeakMap();
|
|
130
|
+
/**
|
|
131
|
+
* Register the font a typed mark names on the asset engine, when it's one of the `fonts`
|
|
132
|
+
* setting's: a standard font, or one the engine has, needs nothing.
|
|
133
|
+
*/
|
|
134
|
+
const registerFont = async (key) => {
|
|
135
|
+
const font = settings.get().fonts.find((each) => each.key === key);
|
|
136
|
+
if (!font) return;
|
|
137
|
+
const engine = await assetEngine();
|
|
138
|
+
if (!isLocalEngine(engine)) return;
|
|
139
|
+
let byKey = registered.get(engine);
|
|
140
|
+
if (!byKey) registered.set(engine, byKey = /* @__PURE__ */ new Map());
|
|
141
|
+
let registering = byKey.get(key);
|
|
142
|
+
if (!registering) {
|
|
143
|
+
const fonts = byKey;
|
|
144
|
+
registering = font.load().then((data) => engine.fonts.register({
|
|
145
|
+
key,
|
|
146
|
+
data
|
|
147
|
+
})).then(() => void 0);
|
|
148
|
+
fonts.set(key, registering);
|
|
149
|
+
registering.catch(() => fonts.delete(key));
|
|
150
|
+
}
|
|
151
|
+
return registering;
|
|
152
|
+
};
|
|
128
153
|
/** Library PDFs are sliced and tagged (`/PieceInfo`) on a local engine only. */
|
|
129
154
|
const openAssetDocument = async (bytes) => {
|
|
130
155
|
const engine = await assetEngine();
|
|
@@ -166,6 +191,7 @@ function createAssetEngine(ctx) {
|
|
|
166
191
|
});
|
|
167
192
|
return {
|
|
168
193
|
openAssetDocument,
|
|
194
|
+
registerFont,
|
|
169
195
|
imageToPreview,
|
|
170
196
|
renderThumbnail,
|
|
171
197
|
/** Optimistic until an import finds the asset engine is not local (cloud). */
|
|
@@ -1036,7 +1062,7 @@ const textBounds = (text, fontSize) => ({
|
|
|
1036
1062
|
height: fontSize * 1.6
|
|
1037
1063
|
});
|
|
1038
1064
|
function createMarks({ assetEngine }) {
|
|
1039
|
-
const { openAssetDocument } = assetEngine;
|
|
1065
|
+
const { openAssetDocument, registerFont } = assetEngine;
|
|
1040
1066
|
/**
|
|
1041
1067
|
* A drawn or typed mark rendered to a one-page PDF: the annotation is
|
|
1042
1068
|
* authored on a scratch page and exported the way "stamp from selection"
|
|
@@ -1044,6 +1070,7 @@ function createMarks({ assetEngine }) {
|
|
|
1044
1070
|
* font subset-embedded. Self-contained and Acrobat-readable.
|
|
1045
1071
|
*/
|
|
1046
1072
|
const renderMark = async (mark) => {
|
|
1073
|
+
if (mark.kind === "text") await registerFont(mark.fontFamily);
|
|
1047
1074
|
const doc = await openAssetDocument(blankLibraryPdf());
|
|
1048
1075
|
try {
|
|
1049
1076
|
const scratch = (await doc.pages.list()).pages[0];
|
|
@@ -1366,7 +1393,7 @@ const stampPlugin = (config) => definePlugin({
|
|
|
1366
1393
|
settings: {
|
|
1367
1394
|
defaults: STAMP_DEFAULTS,
|
|
1368
1395
|
registered: config,
|
|
1369
|
-
whole: ["assetEngine"]
|
|
1396
|
+
whole: ["assetEngine", "fonts"]
|
|
1370
1397
|
},
|
|
1371
1398
|
create: createStampController,
|
|
1372
1399
|
inScope: (stamp, documentId) => {
|