muhammara 5.1.0 → 5.3.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/CHANGELOG.md +22 -1
- package/README.md +3 -3
- package/lib/Recipe.js +18 -7
- package/lib/recipe/page.js +4 -3
- package/muhammara.d.ts +2 -2
- package/node_modules/debug/package.json +10 -5
- package/node_modules/debug/src/browser.js +1 -0
- package/node_modules/debug/src/common.js +57 -39
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.3.0] - 2024-12-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add electron 31.7.0, 33.1.0, 33.2.0, 33.3.0 [#439](https://github.com/julianhille/MuhammaraJS/issues/439)
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Fix recipe with new buffers [#372](https://github.com/julianhille/MuhammaraJS/issues/372)
|
|
19
|
+
- Wrong node versions for 2.2, 32.1 and 31.6 [#439](https://github.com/julianhille/MuhammaraJS/issues/439)
|
|
20
|
+
- Fix recipes createPage typescript definition and jsdoc, discourage
|
|
21
|
+
use of '-size' values for pageType [#369](https://github.com/julianhille/MuhammaraJS/issues/369)
|
|
22
|
+
|
|
23
|
+
## [5.2.0] - 2024-10-20
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Add electron 33.0, 32.1, 32.2, 31.5, 31.6, 30.5
|
|
28
|
+
|
|
10
29
|
## [5.1.0] - 2024-10-17
|
|
11
30
|
|
|
12
31
|
### Added
|
|
@@ -465,7 +484,9 @@ with the following changes.
|
|
|
465
484
|
|
|
466
485
|
- Initial release
|
|
467
486
|
|
|
468
|
-
:[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.
|
|
487
|
+
:[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.3.0...HEAD
|
|
488
|
+
[5.3.0]: https://github.com/julianhille/MuhammaraJS/compare/5.2.0...5.3.0
|
|
489
|
+
[5.2.0]: https://github.com/julianhille/MuhammaraJS/compare/5.1.0...5.2.0
|
|
469
490
|
[5.1.0]: https://github.com/julianhille/MuhammaraJS/compare/5.0.2...5.1.0
|
|
470
491
|
[5.0.2]: https://github.com/julianhille/MuhammaraJS/compare/5.0.1...5.0.2
|
|
471
492
|
[5.0.1]: https://github.com/julianhille/MuhammaraJS/compare/5.0.0...5.0.1
|
package/README.md
CHANGED
|
@@ -152,7 +152,7 @@ const pdfDoc = new Recipe("new", "output.pdf", {
|
|
|
152
152
|
subject: "A brand new PDF",
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
pdfDoc.createPage("letter
|
|
155
|
+
pdfDoc.createPage("letter").endPage().endPDF();
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
```javascript
|
|
@@ -161,7 +161,7 @@ const pdfDoc = new Recipe("new", "output.pdf");
|
|
|
161
161
|
|
|
162
162
|
pdfDoc
|
|
163
163
|
// 1st Page
|
|
164
|
-
.createPage("letter
|
|
164
|
+
.createPage("letter")
|
|
165
165
|
.circle("center", 100, 30, { stroke: "#3b7721", fill: "#eee000" })
|
|
166
166
|
.polygon(
|
|
167
167
|
[
|
|
@@ -243,7 +243,7 @@ const pdfDoc = new Recipe(Buffer.from("new"), null, {
|
|
|
243
243
|
subject: "A brand new PDF",
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
-
const pdfBuffer = pdfDoc.createPage("letter
|
|
246
|
+
const pdfBuffer = pdfDoc.createPage("letter").endPage().endPDF();
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
### Modify an existing PDF
|
package/lib/Recipe.js
CHANGED
|
@@ -28,7 +28,9 @@ class Recipe {
|
|
|
28
28
|
this.src = src;
|
|
29
29
|
// detect the src is Buffer or not
|
|
30
30
|
this.isBufferSrc = this.src instanceof Buffer;
|
|
31
|
-
this.isNewPDF =
|
|
31
|
+
this.isNewPDF =
|
|
32
|
+
(!this.isBufferSrc && src.toLowerCase() === "new") ||
|
|
33
|
+
(this.isBufferSrc && this.src.equals(Buffer.from("new")));
|
|
32
34
|
this.encryptOptions = this._getEncryptOptions(options, this.isNewPDF);
|
|
33
35
|
this.options = Object.assign({}, options, this.encryptOptions);
|
|
34
36
|
this.current = {};
|
|
@@ -75,12 +77,21 @@ class Recipe {
|
|
|
75
77
|
|
|
76
78
|
_createWriter() {
|
|
77
79
|
if (this.isNewPDF) {
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
if (!this.isBufferSrc) {
|
|
81
|
+
this.writer = muhammara.createWriter(
|
|
82
|
+
this.output,
|
|
83
|
+
Object.assign({}, this.encryptOptions, {
|
|
84
|
+
version: this._getVersion(this.options.version),
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
this.writer = muhammara.createWriter(
|
|
89
|
+
new muhammara.PDFStreamForResponse(this.outStream),
|
|
90
|
+
Object.assign({}, this.encryptOptions, {
|
|
91
|
+
log: this.logFile,
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
84
95
|
} else {
|
|
85
96
|
this.read();
|
|
86
97
|
try {
|
package/lib/recipe/page.js
CHANGED
|
@@ -2,13 +2,14 @@ const muhammara = require("../muhammara");
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a new page, specifying either actual width and height, or the name
|
|
5
|
-
* of a supported page size (eg. 'letter', )
|
|
5
|
+
* of a supported page size (eg. 'letter', 'letter-size')
|
|
6
|
+
* '-size' will be removed from string but is discouraged to use.
|
|
6
7
|
* @name createPage
|
|
7
8
|
* @function
|
|
8
9
|
* @memberof Recipe
|
|
9
|
-
* @param {number|string} [
|
|
10
|
+
* @param {number|string} [pageWidth] - The page width, or name of medium size.
|
|
10
11
|
* Known named medium sizes: executive, folio, legal, letter, ledger, tabloid, a0-a10, b0-b10, c0-c10, ra0-ra4, sra0-ara4
|
|
11
|
-
* @param {number} [
|
|
12
|
+
* @param {number} [pageHeight] - The page height, or rotation (90) when page size name given.
|
|
12
13
|
* @param {object} [margins] - page margin definitions.
|
|
13
14
|
* @param {number} [margins.left] - Left margin.
|
|
14
15
|
* @param {number} [margins.right] - Right margin.
|
package/muhammara.d.ts
CHANGED
|
@@ -1100,8 +1100,8 @@ declare module "muhammara" {
|
|
|
1100
1100
|
options?: Recipe.OverlayOptions,
|
|
1101
1101
|
): Recipe;
|
|
1102
1102
|
|
|
1103
|
-
createPage(pageWidth
|
|
1104
|
-
|
|
1103
|
+
createPage(pageWidth?: number, pageHeight?: number): Recipe;
|
|
1104
|
+
createPage(pageType: string, rotation?: number): Recipe;
|
|
1105
1105
|
endPage(): Recipe;
|
|
1106
1106
|
|
|
1107
1107
|
editPage(pageNumber: number): Recipe;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_from": "debug@4",
|
|
3
|
-
"_id": "debug@4.
|
|
3
|
+
"_id": "debug@4.4.0",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
|
6
6
|
"_location": "/debug",
|
|
7
7
|
"_phantomChildren": {},
|
|
8
8
|
"_requested": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"/https-proxy-agent",
|
|
21
21
|
"/mocha"
|
|
22
22
|
],
|
|
23
|
-
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.
|
|
24
|
-
"_shasum": "
|
|
23
|
+
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
|
24
|
+
"_shasum": "2b3f2aea2ffeb776477460267377dc8710faba8a",
|
|
25
25
|
"_spec": "debug@4",
|
|
26
26
|
"_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/https-proxy-agent",
|
|
27
27
|
"author": {
|
|
@@ -100,5 +100,10 @@
|
|
|
100
100
|
"test:coverage": "cat ./coverage/lcov.info | coveralls",
|
|
101
101
|
"test:node": "istanbul cover _mocha -- test.js test.node.js"
|
|
102
102
|
},
|
|
103
|
-
"version": "4.
|
|
103
|
+
"version": "4.4.0",
|
|
104
|
+
"xo": {
|
|
105
|
+
"rules": {
|
|
106
|
+
"import/extensions": "off"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
104
109
|
}
|
|
@@ -129,6 +129,7 @@ function useColors() {
|
|
|
129
129
|
|
|
130
130
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
|
131
131
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
132
|
+
// eslint-disable-next-line no-return-assign
|
|
132
133
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
133
134
|
// Is firebug? http://stackoverflow.com/a/398120/376773
|
|
134
135
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
@@ -166,24 +166,62 @@ function setup(env) {
|
|
|
166
166
|
createDebug.names = [];
|
|
167
167
|
createDebug.skips = [];
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
const split = (typeof namespaces === 'string' ? namespaces : '')
|
|
170
|
+
.trim()
|
|
171
|
+
.replace(' ', ',')
|
|
172
|
+
.split(',')
|
|
173
|
+
.filter(Boolean);
|
|
174
|
+
|
|
175
|
+
for (const ns of split) {
|
|
176
|
+
if (ns[0] === '-') {
|
|
177
|
+
createDebug.skips.push(ns.slice(1));
|
|
178
|
+
} else {
|
|
179
|
+
createDebug.names.push(ns);
|
|
177
180
|
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
178
183
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Checks if the given string matches a namespace template, honoring
|
|
186
|
+
* asterisks as wildcards.
|
|
187
|
+
*
|
|
188
|
+
* @param {String} search
|
|
189
|
+
* @param {String} template
|
|
190
|
+
* @return {Boolean}
|
|
191
|
+
*/
|
|
192
|
+
function matchesTemplate(search, template) {
|
|
193
|
+
let searchIndex = 0;
|
|
194
|
+
let templateIndex = 0;
|
|
195
|
+
let starIndex = -1;
|
|
196
|
+
let matchIndex = 0;
|
|
197
|
+
|
|
198
|
+
while (searchIndex < search.length) {
|
|
199
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
|
200
|
+
// Match character or proceed with wildcard
|
|
201
|
+
if (template[templateIndex] === '*') {
|
|
202
|
+
starIndex = templateIndex;
|
|
203
|
+
matchIndex = searchIndex;
|
|
204
|
+
templateIndex++; // Skip the '*'
|
|
205
|
+
} else {
|
|
206
|
+
searchIndex++;
|
|
207
|
+
templateIndex++;
|
|
208
|
+
}
|
|
209
|
+
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
|
210
|
+
// Backtrack to the last '*' and try to match more characters
|
|
211
|
+
templateIndex = starIndex + 1;
|
|
212
|
+
matchIndex++;
|
|
213
|
+
searchIndex = matchIndex;
|
|
183
214
|
} else {
|
|
184
|
-
|
|
215
|
+
return false; // No match
|
|
185
216
|
}
|
|
186
217
|
}
|
|
218
|
+
|
|
219
|
+
// Handle trailing '*' in template
|
|
220
|
+
while (templateIndex < template.length && template[templateIndex] === '*') {
|
|
221
|
+
templateIndex++;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return templateIndex === template.length;
|
|
187
225
|
}
|
|
188
226
|
|
|
189
227
|
/**
|
|
@@ -194,8 +232,8 @@ function setup(env) {
|
|
|
194
232
|
*/
|
|
195
233
|
function disable() {
|
|
196
234
|
const namespaces = [
|
|
197
|
-
...createDebug.names
|
|
198
|
-
...createDebug.skips.map(
|
|
235
|
+
...createDebug.names,
|
|
236
|
+
...createDebug.skips.map(namespace => '-' + namespace)
|
|
199
237
|
].join(',');
|
|
200
238
|
createDebug.enable('');
|
|
201
239
|
return namespaces;
|
|
@@ -209,21 +247,14 @@ function setup(env) {
|
|
|
209
247
|
* @api public
|
|
210
248
|
*/
|
|
211
249
|
function enabled(name) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let i;
|
|
217
|
-
let len;
|
|
218
|
-
|
|
219
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
220
|
-
if (createDebug.skips[i].test(name)) {
|
|
250
|
+
for (const skip of createDebug.skips) {
|
|
251
|
+
if (matchesTemplate(name, skip)) {
|
|
221
252
|
return false;
|
|
222
253
|
}
|
|
223
254
|
}
|
|
224
255
|
|
|
225
|
-
for (
|
|
226
|
-
if (
|
|
256
|
+
for (const ns of createDebug.names) {
|
|
257
|
+
if (matchesTemplate(name, ns)) {
|
|
227
258
|
return true;
|
|
228
259
|
}
|
|
229
260
|
}
|
|
@@ -231,19 +262,6 @@ function setup(env) {
|
|
|
231
262
|
return false;
|
|
232
263
|
}
|
|
233
264
|
|
|
234
|
-
/**
|
|
235
|
-
* Convert regexp to namespace
|
|
236
|
-
*
|
|
237
|
-
* @param {RegExp} regxep
|
|
238
|
-
* @return {String} namespace
|
|
239
|
-
* @api private
|
|
240
|
-
*/
|
|
241
|
-
function toNamespace(regexp) {
|
|
242
|
-
return regexp.toString()
|
|
243
|
-
.substring(2, regexp.toString().length - 2)
|
|
244
|
-
.replace(/\.\*\?$/, '*');
|
|
245
|
-
}
|
|
246
|
-
|
|
247
265
|
/**
|
|
248
266
|
* Coerce `val`.
|
|
249
267
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muhammara",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Create, read and modify PDF files and streams. A drop in replacement for hummusjs PDF library",
|
|
5
5
|
"homepage": "https://github.com/julianhille/Muhammarajs",
|
|
6
6
|
"license": "Apache-2.0",
|