@designsystemsinternational/email 0.0.4 → 0.0.5
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/cjs/browser.cjs +0 -1
- package/dist/cjs/index.cjs +22 -2
- package/dist/esm/browser.js +0 -1
- package/dist/esm/index.js +22 -2
- package/package.json +1 -1
- package/src/packageBrowser.js +0 -1
- package/src/packageNode.js +22 -1
- package/src/packagers/node/s3.js +1 -1
package/dist/cjs/browser.cjs
CHANGED
package/dist/cjs/index.cjs
CHANGED
|
@@ -6,6 +6,8 @@ var removeAttributes = require('posthtml-remove-attributes');
|
|
|
6
6
|
var matchHelper = require('posthtml-match-helper');
|
|
7
7
|
var colorConvert = require('color-convert');
|
|
8
8
|
var unescape = require('lodash.unescape');
|
|
9
|
+
var path = require('node:path');
|
|
10
|
+
var fs = require('node:fs');
|
|
9
11
|
var compressing = require('compressing');
|
|
10
12
|
var getStream = require('get-stream');
|
|
11
13
|
var mailchimpAPI = require('@mailchimp/mailchimp_marketing');
|
|
@@ -201,10 +203,16 @@ const BASE64_REGEX = /data:image\/([a-zA-Z]*);base64,(.*)/;
|
|
|
201
203
|
*/
|
|
202
204
|
const preparePackageFactory =
|
|
203
205
|
({ urlPrefix = '', handlePackage }) =>
|
|
204
|
-
async (body,
|
|
206
|
+
async (body, _opts = {}) => {
|
|
205
207
|
let counter = 0;
|
|
206
208
|
const images = [];
|
|
207
209
|
|
|
210
|
+
const opts = Object.assign(
|
|
211
|
+
{},
|
|
212
|
+
{ basePath: '', includeLocalImages: false },
|
|
213
|
+
_opts,
|
|
214
|
+
);
|
|
215
|
+
|
|
208
216
|
const processed = await posthtml()
|
|
209
217
|
.use((tree) => {
|
|
210
218
|
tree.match({ tag: 'img' }, (node) => {
|
|
@@ -231,6 +239,18 @@ const preparePackageFactory =
|
|
|
231
239
|
});
|
|
232
240
|
|
|
233
241
|
counter++;
|
|
242
|
+
} else if (!src.startsWith('http') && opts.includeLocalImages) {
|
|
243
|
+
const filePath = path.join(opts.basePath, src);
|
|
244
|
+
|
|
245
|
+
const filename = src.split('/').pop();
|
|
246
|
+
node.attrs.src = `${urlPrefix}${filename}`;
|
|
247
|
+
|
|
248
|
+
const imgBuffer = fs.readFileSync(filePath);
|
|
249
|
+
|
|
250
|
+
images.push({
|
|
251
|
+
filename,
|
|
252
|
+
buffer: imgBuffer,
|
|
253
|
+
});
|
|
234
254
|
}
|
|
235
255
|
return node;
|
|
236
256
|
});
|
|
@@ -513,7 +533,7 @@ const packageToS3 = async (body, opts = {}) => {
|
|
|
513
533
|
},
|
|
514
534
|
});
|
|
515
535
|
|
|
516
|
-
return await runUpload(body);
|
|
536
|
+
return await runUpload(body, opts);
|
|
517
537
|
};
|
|
518
538
|
|
|
519
539
|
const sendEmailSes = async (
|
package/dist/esm/browser.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import removeAttributes from 'posthtml-remove-attributes';
|
|
|
4
4
|
import matchHelper from 'posthtml-match-helper';
|
|
5
5
|
import colorConvert from 'color-convert';
|
|
6
6
|
import unescape from 'lodash.unescape';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs';
|
|
7
9
|
import compressing from 'compressing';
|
|
8
10
|
import getStream from 'get-stream';
|
|
9
11
|
import mailchimpAPI from '@mailchimp/mailchimp_marketing';
|
|
@@ -199,10 +201,16 @@ const BASE64_REGEX = /data:image\/([a-zA-Z]*);base64,(.*)/;
|
|
|
199
201
|
*/
|
|
200
202
|
const preparePackageFactory =
|
|
201
203
|
({ urlPrefix = '', handlePackage }) =>
|
|
202
|
-
async (body,
|
|
204
|
+
async (body, _opts = {}) => {
|
|
203
205
|
let counter = 0;
|
|
204
206
|
const images = [];
|
|
205
207
|
|
|
208
|
+
const opts = Object.assign(
|
|
209
|
+
{},
|
|
210
|
+
{ basePath: '', includeLocalImages: false },
|
|
211
|
+
_opts,
|
|
212
|
+
);
|
|
213
|
+
|
|
206
214
|
const processed = await posthtml()
|
|
207
215
|
.use((tree) => {
|
|
208
216
|
tree.match({ tag: 'img' }, (node) => {
|
|
@@ -229,6 +237,18 @@ const preparePackageFactory =
|
|
|
229
237
|
});
|
|
230
238
|
|
|
231
239
|
counter++;
|
|
240
|
+
} else if (!src.startsWith('http') && opts.includeLocalImages) {
|
|
241
|
+
const filePath = path.join(opts.basePath, src);
|
|
242
|
+
|
|
243
|
+
const filename = src.split('/').pop();
|
|
244
|
+
node.attrs.src = `${urlPrefix}${filename}`;
|
|
245
|
+
|
|
246
|
+
const imgBuffer = fs.readFileSync(filePath);
|
|
247
|
+
|
|
248
|
+
images.push({
|
|
249
|
+
filename,
|
|
250
|
+
buffer: imgBuffer,
|
|
251
|
+
});
|
|
232
252
|
}
|
|
233
253
|
return node;
|
|
234
254
|
});
|
|
@@ -511,7 +531,7 @@ const packageToS3 = async (body, opts = {}) => {
|
|
|
511
531
|
},
|
|
512
532
|
});
|
|
513
533
|
|
|
514
|
-
return await runUpload(body);
|
|
534
|
+
return await runUpload(body, opts);
|
|
515
535
|
};
|
|
516
536
|
|
|
517
537
|
const sendEmailSes = async (
|
package/package.json
CHANGED
package/src/packageBrowser.js
CHANGED
package/src/packageNode.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// NODE.JS packacking factory
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
2
5
|
import posthtml from 'posthtml';
|
|
3
6
|
|
|
4
7
|
import { BASE64_REGEX } from './constants.js';
|
|
@@ -15,10 +18,16 @@ import { formatFilename, hashFromString } from './util/string.js';
|
|
|
15
18
|
*/
|
|
16
19
|
export const preparePackageFactory =
|
|
17
20
|
({ urlPrefix = '', handlePackage }) =>
|
|
18
|
-
async (body,
|
|
21
|
+
async (body, _opts = {}) => {
|
|
19
22
|
let counter = 0;
|
|
20
23
|
const images = [];
|
|
21
24
|
|
|
25
|
+
const opts = Object.assign(
|
|
26
|
+
{},
|
|
27
|
+
{ basePath: '', includeLocalImages: false },
|
|
28
|
+
_opts,
|
|
29
|
+
);
|
|
30
|
+
|
|
22
31
|
const processed = await posthtml()
|
|
23
32
|
.use((tree) => {
|
|
24
33
|
tree.match({ tag: 'img' }, (node) => {
|
|
@@ -45,6 +54,18 @@ export const preparePackageFactory =
|
|
|
45
54
|
});
|
|
46
55
|
|
|
47
56
|
counter++;
|
|
57
|
+
} else if (!src.startsWith('http') && opts.includeLocalImages) {
|
|
58
|
+
const filePath = path.join(opts.basePath, src);
|
|
59
|
+
|
|
60
|
+
const filename = src.split('/').pop();
|
|
61
|
+
node.attrs.src = `${urlPrefix}${filename}`;
|
|
62
|
+
|
|
63
|
+
const imgBuffer = fs.readFileSync(filePath);
|
|
64
|
+
|
|
65
|
+
images.push({
|
|
66
|
+
filename,
|
|
67
|
+
buffer: imgBuffer,
|
|
68
|
+
});
|
|
48
69
|
}
|
|
49
70
|
return node;
|
|
50
71
|
});
|