@designsystemsinternational/email 0.0.3 → 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 +1 -1
- package/dist/cjs/index.cjs +23 -3
- package/dist/esm/browser.js +1 -1
- package/dist/esm/index.js +23 -3
- package/package.json +1 -1
- package/src/packageBrowser.js +2 -2
- package/src/packageNode.js +24 -3
- package/src/packagers/node/s3.js +1 -1
package/dist/cjs/browser.cjs
CHANGED
|
@@ -212,7 +212,7 @@ const preparePackageFactory =
|
|
|
212
212
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
213
213
|
);
|
|
214
214
|
|
|
215
|
-
const hash =
|
|
215
|
+
const hash = hashFromString(`${data}`);
|
|
216
216
|
|
|
217
217
|
const filename = alt
|
|
218
218
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
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) => {
|
|
@@ -215,7 +223,7 @@ const preparePackageFactory =
|
|
|
215
223
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
216
224
|
);
|
|
217
225
|
|
|
218
|
-
const hash =
|
|
226
|
+
const hash = hashFromString(`${data}`);
|
|
219
227
|
|
|
220
228
|
const filename = alt
|
|
221
229
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
|
@@ -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
|
@@ -210,7 +210,7 @@ const preparePackageFactory =
|
|
|
210
210
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
211
211
|
);
|
|
212
212
|
|
|
213
|
-
const hash =
|
|
213
|
+
const hash = hashFromString(`${data}`);
|
|
214
214
|
|
|
215
215
|
const filename = alt
|
|
216
216
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
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) => {
|
|
@@ -213,7 +221,7 @@ const preparePackageFactory =
|
|
|
213
221
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
214
222
|
);
|
|
215
223
|
|
|
216
|
-
const hash =
|
|
224
|
+
const hash = hashFromString(`${data}`);
|
|
217
225
|
|
|
218
226
|
const filename = alt
|
|
219
227
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
|
@@ -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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import posthtml from 'posthtml';
|
|
4
4
|
|
|
5
5
|
import { BASE64_REGEX } from './constants.js';
|
|
6
|
-
import { formatFilename } from './util/string.js';
|
|
6
|
+
import { formatFilename, hashFromString } from './util/string.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Turns base64 inlined images into image buffers and updates their src
|
|
@@ -30,7 +30,7 @@ export const preparePackageFactory =
|
|
|
30
30
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
-
const hash =
|
|
33
|
+
const hash = hashFromString(`${data}`);
|
|
34
34
|
|
|
35
35
|
const filename = alt
|
|
36
36
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
package/src/packageNode.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
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';
|
|
5
|
-
import { formatFilename } from './util/string.js';
|
|
8
|
+
import { formatFilename, hashFromString } from './util/string.js';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Turns base64 inlined images into image buffers and updates their src
|
|
@@ -15,10 +18,16 @@ import { formatFilename } 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) => {
|
|
@@ -29,7 +38,7 @@ export const preparePackageFactory =
|
|
|
29
38
|
/data:image\/([a-zA-Z]*);base64,(.*)/,
|
|
30
39
|
);
|
|
31
40
|
|
|
32
|
-
const hash =
|
|
41
|
+
const hash = hashFromString(`${data}`);
|
|
33
42
|
|
|
34
43
|
const filename = alt
|
|
35
44
|
? `${formatFilename(alt)}-text-${hash}.${ext}`
|
|
@@ -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
|
});
|