@shad0wz7/nestjs-pdf 1.0.2 → 1.1.0
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/README.md +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +41 -31
- package/dist/index.mjs +22 -13
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Main features:
|
|
|
8
8
|
- Add signature fields based on a text anchor in an existing PDF
|
|
9
9
|
- Simple API (module and service) to integrate easily into a Nest application
|
|
10
10
|
|
|
11
|
-
> Note: this repository contains the library source. To use it in another project you can either install it from npm
|
|
11
|
+
> Note: this repository contains the library source. To use it in another project, you can either install it from npm or import the local package from the source.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
package/dist/index.d.mts
CHANGED
|
@@ -116,4 +116,6 @@ declare class PuppeteerHandlebarsModule {
|
|
|
116
116
|
static forRootAsync(options: PuppeteerHandlebarsModuleAsyncOptions): DynamicModule;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare function getRelativePathToValue(moduleDir: string, relativeToModule: string): string;
|
|
120
|
+
|
|
121
|
+
export { NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions, PuppeteerHandlebarsModule, type PuppeteerHandlebarsModuleAsyncOptions, PuppeteerModule, type PuppeteerModuleAsyncOptions, type PuppeteerParameters, PuppeteerService, getRelativePathToValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -116,4 +116,6 @@ declare class PuppeteerHandlebarsModule {
|
|
|
116
116
|
static forRootAsync(options: PuppeteerHandlebarsModuleAsyncOptions): DynamicModule;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare function getRelativePathToValue(moduleDir: string, relativeToModule: string): string;
|
|
120
|
+
|
|
121
|
+
export { NestjsPdfModule, NestjsPdfService, type PdfLibModuleAsyncOptions, PuppeteerHandlebarsModule, type PuppeteerHandlebarsModuleAsyncOptions, PuppeteerModule, type PuppeteerModuleAsyncOptions, type PuppeteerParameters, PuppeteerService, getRelativePathToValue };
|
package/dist/index.js
CHANGED
|
@@ -4730,7 +4730,7 @@ async function fetchData(url, type = "text") {
|
|
|
4730
4730
|
}
|
|
4731
4731
|
return response.text();
|
|
4732
4732
|
}
|
|
4733
|
-
return new Promise((
|
|
4733
|
+
return new Promise((resolve3, reject) => {
|
|
4734
4734
|
const request = new XMLHttpRequest();
|
|
4735
4735
|
request.open("GET", url, true);
|
|
4736
4736
|
request.responseType = type === "bytes" ? "arraybuffer" : type;
|
|
@@ -4741,14 +4741,14 @@ async function fetchData(url, type = "text") {
|
|
|
4741
4741
|
if (request.status === 200 || request.status === 0) {
|
|
4742
4742
|
switch (type) {
|
|
4743
4743
|
case "bytes":
|
|
4744
|
-
|
|
4744
|
+
resolve3(new Uint8Array(request.response));
|
|
4745
4745
|
return;
|
|
4746
4746
|
case "blob":
|
|
4747
4747
|
case "json":
|
|
4748
|
-
|
|
4748
|
+
resolve3(request.response);
|
|
4749
4749
|
return;
|
|
4750
4750
|
}
|
|
4751
|
-
|
|
4751
|
+
resolve3(request.responseText);
|
|
4752
4752
|
return;
|
|
4753
4753
|
}
|
|
4754
4754
|
reject(new Error(request.statusText));
|
|
@@ -7804,13 +7804,13 @@ var init_pdf = __esm({
|
|
|
7804
7804
|
var aCallable = __webpack_require__2(9306);
|
|
7805
7805
|
var $TypeError = TypeError;
|
|
7806
7806
|
var PromiseCapability = /* @__PURE__ */ __name(function(C) {
|
|
7807
|
-
var
|
|
7807
|
+
var resolve3, reject;
|
|
7808
7808
|
this.promise = new C(function($$resolve, $$reject) {
|
|
7809
|
-
if (
|
|
7810
|
-
|
|
7809
|
+
if (resolve3 !== void 0 || reject !== void 0) throw new $TypeError("Bad Promise constructor");
|
|
7810
|
+
resolve3 = $$resolve;
|
|
7811
7811
|
reject = $$reject;
|
|
7812
7812
|
});
|
|
7813
|
-
this.resolve = aCallable(
|
|
7813
|
+
this.resolve = aCallable(resolve3);
|
|
7814
7814
|
this.reject = aCallable(reject);
|
|
7815
7815
|
}, "PromiseCapability");
|
|
7816
7816
|
module2.exports.f = function(C) {
|
|
@@ -12127,11 +12127,11 @@ var init_pdf = __esm({
|
|
|
12127
12127
|
const mustRemoveAspectRatioPromise = _ImageManager._isSVGFittingCanvas;
|
|
12128
12128
|
const fileReader = new FileReader();
|
|
12129
12129
|
const imageElement = new Image();
|
|
12130
|
-
const imagePromise = new Promise((
|
|
12130
|
+
const imagePromise = new Promise((resolve3, reject) => {
|
|
12131
12131
|
imageElement.onload = () => {
|
|
12132
12132
|
data.bitmap = imageElement;
|
|
12133
12133
|
data.isSvg = true;
|
|
12134
|
-
|
|
12134
|
+
resolve3();
|
|
12135
12135
|
};
|
|
12136
12136
|
fileReader.onload = async () => {
|
|
12137
12137
|
const url = data.svgUrl = fileReader.result;
|
|
@@ -12802,13 +12802,13 @@ var init_pdf = __esm({
|
|
|
12802
12802
|
return;
|
|
12803
12803
|
}
|
|
12804
12804
|
const {
|
|
12805
|
-
resolve:
|
|
12805
|
+
resolve: resolve3,
|
|
12806
12806
|
promise
|
|
12807
12807
|
} = Promise.withResolvers();
|
|
12808
12808
|
const onEditorsRendered = /* @__PURE__ */ __name((evt) => {
|
|
12809
12809
|
if (evt.pageNumber === pageNumber) {
|
|
12810
12810
|
this._eventBus._off("editorsrendered", onEditorsRendered);
|
|
12811
|
-
|
|
12811
|
+
resolve3();
|
|
12812
12812
|
}
|
|
12813
12813
|
}, "onEditorsRendered");
|
|
12814
12814
|
this._eventBus.on("editorsrendered", onEditorsRendered);
|
|
@@ -17746,8 +17746,8 @@ var init_pdf = __esm({
|
|
|
17746
17746
|
if (this.isSyncFontLoadingSupported) {
|
|
17747
17747
|
return;
|
|
17748
17748
|
}
|
|
17749
|
-
await new Promise((
|
|
17750
|
-
const request = this._queueLoadingCallback(
|
|
17749
|
+
await new Promise((resolve3) => {
|
|
17750
|
+
const request = this._queueLoadingCallback(resolve3);
|
|
17751
17751
|
this._prepareFontLoadEvent(font, request);
|
|
17752
17752
|
});
|
|
17753
17753
|
}
|
|
@@ -34336,7 +34336,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
34336
34336
|
input.type = "file";
|
|
34337
34337
|
input.accept = SupportedImageMimeTypes.join(",");
|
|
34338
34338
|
const signal = this._uiManager._signal;
|
|
34339
|
-
this.#bitmapPromise = new Promise((
|
|
34339
|
+
this.#bitmapPromise = new Promise((resolve3) => {
|
|
34340
34340
|
input.addEventListener("change", async () => {
|
|
34341
34341
|
if (!input.files || input.files.length === 0) {
|
|
34342
34342
|
this.remove();
|
|
@@ -34351,13 +34351,13 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
34351
34351
|
});
|
|
34352
34352
|
this.#getBitmapFetched(data);
|
|
34353
34353
|
}
|
|
34354
|
-
|
|
34354
|
+
resolve3();
|
|
34355
34355
|
}, {
|
|
34356
34356
|
signal
|
|
34357
34357
|
});
|
|
34358
34358
|
input.addEventListener("cancel", () => {
|
|
34359
34359
|
this.remove();
|
|
34360
|
-
|
|
34360
|
+
resolve3();
|
|
34361
34361
|
}, {
|
|
34362
34362
|
signal
|
|
34363
34363
|
});
|
|
@@ -36214,8 +36214,8 @@ var require_main = __commonJS({
|
|
|
36214
36214
|
const shortPaths = [];
|
|
36215
36215
|
for (const filePath of optionPaths) {
|
|
36216
36216
|
try {
|
|
36217
|
-
const
|
|
36218
|
-
shortPaths.push(
|
|
36217
|
+
const relative2 = path2.relative(process.cwd(), filePath);
|
|
36218
|
+
shortPaths.push(relative2);
|
|
36219
36219
|
} catch (e) {
|
|
36220
36220
|
if (debug) {
|
|
36221
36221
|
_debug(`failed to load ${filePath} ${e.message}`);
|
|
@@ -38173,7 +38173,7 @@ var require_config_module = __commonJS({
|
|
|
38173
38173
|
}
|
|
38174
38174
|
};
|
|
38175
38175
|
exports2.ConfigModule = ConfigModule2;
|
|
38176
|
-
ConfigModule2._envVariablesLoaded = new Promise((
|
|
38176
|
+
ConfigModule2._envVariablesLoaded = new Promise((resolve3) => ConfigModule_1.environmentVariablesLoadedSignal = resolve3);
|
|
38177
38177
|
exports2.ConfigModule = ConfigModule2 = ConfigModule_1 = __decorate([
|
|
38178
38178
|
(0, common_1.Module)({
|
|
38179
38179
|
imports: [
|
|
@@ -38514,7 +38514,8 @@ __export(index_exports, {
|
|
|
38514
38514
|
NestjsPdfService: () => NestjsPdfService,
|
|
38515
38515
|
PuppeteerHandlebarsModule: () => PuppeteerHandlebarsModule,
|
|
38516
38516
|
PuppeteerModule: () => PuppeteerModule,
|
|
38517
|
-
PuppeteerService: () => PuppeteerService
|
|
38517
|
+
PuppeteerService: () => PuppeteerService,
|
|
38518
|
+
getRelativePathToValue: () => getRelativePathToValue
|
|
38518
38519
|
});
|
|
38519
38520
|
module.exports = __toCommonJS(index_exports);
|
|
38520
38521
|
|
|
@@ -38869,7 +38870,7 @@ BrowserService = _ts_decorate([
|
|
|
38869
38870
|
])
|
|
38870
38871
|
], BrowserService);
|
|
38871
38872
|
|
|
38872
|
-
// src/
|
|
38873
|
+
// src/helpers/deepMergePdfparams.ts
|
|
38873
38874
|
var import_deepmerge_ts = require("deepmerge-ts");
|
|
38874
38875
|
function mergePuppeteerParameters(defaults, overrides) {
|
|
38875
38876
|
if (!overrides) {
|
|
@@ -39053,12 +39054,12 @@ function __rest(s, e) {
|
|
|
39053
39054
|
__name(__rest, "__rest");
|
|
39054
39055
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
39055
39056
|
function adopt(value) {
|
|
39056
|
-
return value instanceof P ? value : new P(function(
|
|
39057
|
-
|
|
39057
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
39058
|
+
resolve3(value);
|
|
39058
39059
|
});
|
|
39059
39060
|
}
|
|
39060
39061
|
__name(adopt, "adopt");
|
|
39061
|
-
return new (P || (P = Promise))(function(
|
|
39062
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
39062
39063
|
function fulfilled(value) {
|
|
39063
39064
|
try {
|
|
39064
39065
|
step(generator.next(value));
|
|
@@ -39076,7 +39077,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
39076
39077
|
}
|
|
39077
39078
|
__name(rejected, "rejected");
|
|
39078
39079
|
function step(result) {
|
|
39079
|
-
result.done ?
|
|
39080
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
39080
39081
|
}
|
|
39081
39082
|
__name(step, "step");
|
|
39082
39083
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -39520,9 +39521,9 @@ var toUint8Array = /* @__PURE__ */ __name(function(input) {
|
|
|
39520
39521
|
|
|
39521
39522
|
// node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/es/utils/async.js
|
|
39522
39523
|
var waitForTick = /* @__PURE__ */ __name(function() {
|
|
39523
|
-
return new Promise(function(
|
|
39524
|
+
return new Promise(function(resolve3) {
|
|
39524
39525
|
setTimeout(function() {
|
|
39525
|
-
return
|
|
39526
|
+
return resolve3();
|
|
39526
39527
|
}, 0);
|
|
39527
39528
|
});
|
|
39528
39529
|
}, "waitForTick");
|
|
@@ -43594,12 +43595,12 @@ var CustomFontSubsetEmbedder = (
|
|
|
43594
43595
|
};
|
|
43595
43596
|
CustomFontSubsetEmbedder2.prototype.serializeFont = function() {
|
|
43596
43597
|
var _this = this;
|
|
43597
|
-
return new Promise(function(
|
|
43598
|
+
return new Promise(function(resolve3, reject) {
|
|
43598
43599
|
var parts = [];
|
|
43599
43600
|
_this.subset.encodeStream().on("data", function(bytes) {
|
|
43600
43601
|
return parts.push(bytes);
|
|
43601
43602
|
}).on("end", function() {
|
|
43602
|
-
return
|
|
43603
|
+
return resolve3(mergeUint8Arrays(parts));
|
|
43603
43604
|
}).on("error", function(err) {
|
|
43604
43605
|
return reject(err);
|
|
43605
43606
|
});
|
|
@@ -57107,13 +57108,22 @@ PuppeteerHandlebarsModule = _ts_decorate6([
|
|
|
57107
57108
|
]
|
|
57108
57109
|
})
|
|
57109
57110
|
], PuppeteerHandlebarsModule);
|
|
57111
|
+
|
|
57112
|
+
// src/helpers/getRelativePath.helper.ts
|
|
57113
|
+
var import_node_path = require("path");
|
|
57114
|
+
function getRelativePathToValue(moduleDir, relativeToModule) {
|
|
57115
|
+
const fullTemplatePath = (0, import_node_path.resolve)(moduleDir, relativeToModule);
|
|
57116
|
+
return (0, import_node_path.relative)(process.cwd(), fullTemplatePath);
|
|
57117
|
+
}
|
|
57118
|
+
__name(getRelativePathToValue, "getRelativePathToValue");
|
|
57110
57119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57111
57120
|
0 && (module.exports = {
|
|
57112
57121
|
NestjsPdfModule,
|
|
57113
57122
|
NestjsPdfService,
|
|
57114
57123
|
PuppeteerHandlebarsModule,
|
|
57115
57124
|
PuppeteerModule,
|
|
57116
|
-
PuppeteerService
|
|
57125
|
+
PuppeteerService,
|
|
57126
|
+
getRelativePathToValue
|
|
57117
57127
|
});
|
|
57118
57128
|
/*! Bundled license information:
|
|
57119
57129
|
|
package/dist/index.mjs
CHANGED
|
@@ -4666,8 +4666,8 @@ var require_main = __commonJS({
|
|
|
4666
4666
|
const shortPaths = [];
|
|
4667
4667
|
for (const filePath of optionPaths) {
|
|
4668
4668
|
try {
|
|
4669
|
-
const
|
|
4670
|
-
shortPaths.push(
|
|
4669
|
+
const relative2 = path2.relative(process.cwd(), filePath);
|
|
4670
|
+
shortPaths.push(relative2);
|
|
4671
4671
|
} catch (e) {
|
|
4672
4672
|
if (debug) {
|
|
4673
4673
|
_debug(`failed to load ${filePath} ${e.message}`);
|
|
@@ -6625,7 +6625,7 @@ var require_config_module = __commonJS({
|
|
|
6625
6625
|
}
|
|
6626
6626
|
};
|
|
6627
6627
|
exports.ConfigModule = ConfigModule2;
|
|
6628
|
-
ConfigModule2._envVariablesLoaded = new Promise((
|
|
6628
|
+
ConfigModule2._envVariablesLoaded = new Promise((resolve3) => ConfigModule_1.environmentVariablesLoadedSignal = resolve3);
|
|
6629
6629
|
exports.ConfigModule = ConfigModule2 = ConfigModule_1 = __decorate([
|
|
6630
6630
|
(0, common_1.Module)({
|
|
6631
6631
|
imports: [
|
|
@@ -7310,7 +7310,7 @@ BrowserService = _ts_decorate([
|
|
|
7310
7310
|
])
|
|
7311
7311
|
], BrowserService);
|
|
7312
7312
|
|
|
7313
|
-
// src/
|
|
7313
|
+
// src/helpers/deepMergePdfparams.ts
|
|
7314
7314
|
import { deepmerge } from "deepmerge-ts";
|
|
7315
7315
|
function mergePuppeteerParameters(defaults, overrides) {
|
|
7316
7316
|
if (!overrides) {
|
|
@@ -7494,12 +7494,12 @@ function __rest(s, e) {
|
|
|
7494
7494
|
__name(__rest, "__rest");
|
|
7495
7495
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
7496
7496
|
function adopt(value) {
|
|
7497
|
-
return value instanceof P ? value : new P(function(
|
|
7498
|
-
|
|
7497
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
7498
|
+
resolve3(value);
|
|
7499
7499
|
});
|
|
7500
7500
|
}
|
|
7501
7501
|
__name(adopt, "adopt");
|
|
7502
|
-
return new (P || (P = Promise))(function(
|
|
7502
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
7503
7503
|
function fulfilled(value) {
|
|
7504
7504
|
try {
|
|
7505
7505
|
step(generator.next(value));
|
|
@@ -7517,7 +7517,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
7517
7517
|
}
|
|
7518
7518
|
__name(rejected, "rejected");
|
|
7519
7519
|
function step(result) {
|
|
7520
|
-
result.done ?
|
|
7520
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
7521
7521
|
}
|
|
7522
7522
|
__name(step, "step");
|
|
7523
7523
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -7961,9 +7961,9 @@ var toUint8Array = /* @__PURE__ */ __name(function(input) {
|
|
|
7961
7961
|
|
|
7962
7962
|
// node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/es/utils/async.js
|
|
7963
7963
|
var waitForTick = /* @__PURE__ */ __name(function() {
|
|
7964
|
-
return new Promise(function(
|
|
7964
|
+
return new Promise(function(resolve3) {
|
|
7965
7965
|
setTimeout(function() {
|
|
7966
|
-
return
|
|
7966
|
+
return resolve3();
|
|
7967
7967
|
}, 0);
|
|
7968
7968
|
});
|
|
7969
7969
|
}, "waitForTick");
|
|
@@ -12035,12 +12035,12 @@ var CustomFontSubsetEmbedder = (
|
|
|
12035
12035
|
};
|
|
12036
12036
|
CustomFontSubsetEmbedder2.prototype.serializeFont = function() {
|
|
12037
12037
|
var _this = this;
|
|
12038
|
-
return new Promise(function(
|
|
12038
|
+
return new Promise(function(resolve3, reject) {
|
|
12039
12039
|
var parts = [];
|
|
12040
12040
|
_this.subset.encodeStream().on("data", function(bytes) {
|
|
12041
12041
|
return parts.push(bytes);
|
|
12042
12042
|
}).on("end", function() {
|
|
12043
|
-
return
|
|
12043
|
+
return resolve3(mergeUint8Arrays(parts));
|
|
12044
12044
|
}).on("error", function(err) {
|
|
12045
12045
|
return reject(err);
|
|
12046
12046
|
});
|
|
@@ -25548,12 +25548,21 @@ PuppeteerHandlebarsModule = _ts_decorate6([
|
|
|
25548
25548
|
]
|
|
25549
25549
|
})
|
|
25550
25550
|
], PuppeteerHandlebarsModule);
|
|
25551
|
+
|
|
25552
|
+
// src/helpers/getRelativePath.helper.ts
|
|
25553
|
+
import { relative, resolve as resolve2 } from "path";
|
|
25554
|
+
function getRelativePathToValue(moduleDir, relativeToModule) {
|
|
25555
|
+
const fullTemplatePath = resolve2(moduleDir, relativeToModule);
|
|
25556
|
+
return relative(process.cwd(), fullTemplatePath);
|
|
25557
|
+
}
|
|
25558
|
+
__name(getRelativePathToValue, "getRelativePathToValue");
|
|
25551
25559
|
export {
|
|
25552
25560
|
NestjsPdfModule,
|
|
25553
25561
|
NestjsPdfService,
|
|
25554
25562
|
PuppeteerHandlebarsModule,
|
|
25555
25563
|
PuppeteerModule,
|
|
25556
|
-
PuppeteerService
|
|
25564
|
+
PuppeteerService,
|
|
25565
|
+
getRelativePathToValue
|
|
25557
25566
|
};
|
|
25558
25567
|
/*! Bundled license information:
|
|
25559
25568
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shad0wz7/nestjs-pdf",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A NestJS library for generating PDFs with Puppeteer and Handlebars.",
|
|
5
5
|
"author": "Emmanuel Boisset",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,6 +86,9 @@
|
|
|
86
86
|
"optionalDependencies": {
|
|
87
87
|
"@napi-rs/canvas": "^1.0.0"
|
|
88
88
|
},
|
|
89
|
+
"repository": {
|
|
90
|
+
"url": "https://github.com/ShadowZ11/nestjs-pdf"
|
|
91
|
+
},
|
|
89
92
|
"publishConfig": {
|
|
90
93
|
"access": "public",
|
|
91
94
|
"registry": "https://registry.npmjs.org/"
|