@postalsys/ee-client 1.0.0 → 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 CHANGED
@@ -72,6 +72,7 @@ const client = new EmailEngineClient({
72
72
  - `account` (string, required): Account identifier
73
73
  - `accessToken` (string, optional): Access token for authentication
74
74
  - `container` (HTMLElement, optional): DOM container for UI components (browser only)
75
+ - `confirmMethod` (function, optional): Custom confirm dialog method. Can be sync or async. Defaults to browser's `confirm()`
75
76
 
76
77
  ### Methods
77
78
 
@@ -117,11 +118,49 @@ When used in a browser with a container element, the client automatically create
117
118
  apiUrl: 'https://your-emailengine-server.com',
118
119
  account: 'your-account-id',
119
120
  accessToken: 'your-access-token',
120
- container: document.getElementById('email-client')
121
+ container: document.getElementById('email-client'),
122
+ // Optional: Custom confirm dialog
123
+ confirmMethod: async message => {
124
+ return await myCustomDialog.confirm(message);
125
+ }
121
126
  });
122
127
  </script>
123
128
  ```
124
129
 
130
+ ### Custom Confirm Dialog
131
+
132
+ You can provide a custom confirm dialog method that will be used instead of the browser's default `confirm()`. This is useful for integrating with UI frameworks or custom dialog systems:
133
+
134
+ ```javascript
135
+ const client = new EmailEngineClient({
136
+ apiUrl: 'https://your-emailengine-server.com',
137
+ account: 'your-account-id',
138
+ accessToken: 'your-access-token',
139
+ container: document.getElementById('email-client'),
140
+ confirmMethod: async message => {
141
+ // Example with a custom async dialog
142
+ return await MyModal.confirm({
143
+ title: 'Confirm Action',
144
+ message: message,
145
+ buttons: ['Cancel', 'OK']
146
+ });
147
+ }
148
+ });
149
+ ```
150
+
151
+ The `confirmMethod` can be either synchronous or asynchronous:
152
+
153
+ ```javascript
154
+ // Synchronous example
155
+ confirmMethod: message => window.confirm(message);
156
+
157
+ // Asynchronous example
158
+ confirmMethod: async message => {
159
+ const result = await customDialog.show(message);
160
+ return result === 'ok';
161
+ };
162
+ ```
163
+
125
164
  ## License
126
165
 
127
166
  MIT © Postal Systems OÜ
package/index.cjs CHANGED
@@ -4,6 +4,7 @@ class EmailEngineClient {
4
4
  this.account = options.account;
5
5
  this.accessToken = options.accessToken;
6
6
  this.container = options.container;
7
+ this.confirmMethod = options.confirmMethod || (message => confirm(message));
7
8
 
8
9
  this.currentFolder = null;
9
10
  this.currentMessage = null;
@@ -12,6 +13,11 @@ class EmailEngineClient {
12
13
  this.nextPageCursor = null;
13
14
  this.prevPageCursor = null;
14
15
 
16
+ // Get page size from localStorage or options or default
17
+ const savedPageSize =
18
+ typeof window !== 'undefined' && window.localStorage ? localStorage.getItem('ee-client-page-size') : null;
19
+ this.pageSize = savedPageSize ? parseInt(savedPageSize) : options.pageSize || 20;
20
+
15
21
  if (this.container) {
16
22
  this.init();
17
23
  }
@@ -81,7 +87,7 @@ class EmailEngineClient {
81
87
  }
82
88
 
83
89
  try {
84
- const params = new URLSearchParams({ path: path, pageSize: 50 });
90
+ const params = new URLSearchParams({ path: path, pageSize: this.pageSize });
85
91
  if (cursor) {
86
92
  params.set('cursor', cursor);
87
93
  }
@@ -94,6 +100,7 @@ class EmailEngineClient {
94
100
 
95
101
  if (this.container) {
96
102
  this.renderMessageList();
103
+ this.renderFolderList(); // Re-render to update active state
97
104
  }
98
105
 
99
106
  return {
@@ -246,6 +253,99 @@ class EmailEngineClient {
246
253
  }
247
254
  }
248
255
 
256
+ formatFileSize(bytes) {
257
+ if (!bytes) {
258
+ return '';
259
+ }
260
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
261
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
262
+ return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
263
+ }
264
+
265
+ async downloadAttachment(attachmentId, suggestedFilename = null) {
266
+ try {
267
+ const headers = {};
268
+ if (this.accessToken) {
269
+ headers['Authorization'] = `Bearer ${this.accessToken}`;
270
+ }
271
+
272
+ const response = await fetch(`${this.apiUrl}/v1/account/${this.account}/attachment/${attachmentId}`, {
273
+ headers,
274
+ credentials: 'include'
275
+ });
276
+
277
+ if (!response.ok) {
278
+ throw new Error(`HTTP error! status: ${response.status}`);
279
+ }
280
+
281
+ // Get filename from Content-Disposition header if available
282
+ const contentDisposition = response.headers.get('content-disposition');
283
+ let filename = suggestedFilename || 'attachment';
284
+ if (contentDisposition) {
285
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
286
+ if (filenameMatch && filenameMatch[1]) {
287
+ filename = filenameMatch[1].replace(/['"]/g, '');
288
+ }
289
+ }
290
+
291
+ // Get the attachment data
292
+ const blob = await response.blob();
293
+
294
+ // Create a download link
295
+ const url = window.URL.createObjectURL(blob);
296
+ const a = document.createElement('a');
297
+ a.href = url;
298
+ a.download = filename;
299
+ document.body.appendChild(a);
300
+ a.click();
301
+ document.body.removeChild(a);
302
+ window.URL.revokeObjectURL(url);
303
+ } catch (error) {
304
+ console.error('Failed to download attachment:', error);
305
+ alert('Failed to download attachment');
306
+ }
307
+ }
308
+
309
+ async downloadOriginalMessage(messageId, subject = null) {
310
+ try {
311
+ const headers = {};
312
+ if (this.accessToken) {
313
+ headers['Authorization'] = `Bearer ${this.accessToken}`;
314
+ }
315
+
316
+ const response = await fetch(`${this.apiUrl}/v1/account/${this.account}/message/${messageId}/source`, {
317
+ headers,
318
+ credentials: 'include'
319
+ });
320
+
321
+ if (!response.ok) {
322
+ throw new Error(`HTTP error! status: ${response.status}`);
323
+ }
324
+
325
+ // Get the email data
326
+ const blob = await response.blob();
327
+
328
+ // Create filename based on subject and date
329
+ const now = new Date();
330
+ const dateStr = now.toISOString().split('T')[0];
331
+ const safeSubject = subject ? subject.replace(/[^a-z0-9]/gi, '_').substring(0, 50) : 'email';
332
+ const filename = `${dateStr}_${safeSubject}.eml`;
333
+
334
+ // Create a download link
335
+ const url = window.URL.createObjectURL(blob);
336
+ const a = document.createElement('a');
337
+ a.href = url;
338
+ a.download = filename;
339
+ document.body.appendChild(a);
340
+ a.click();
341
+ document.body.removeChild(a);
342
+ window.URL.revokeObjectURL(url);
343
+ } catch (error) {
344
+ console.error('Failed to download original message:', error);
345
+ alert('Failed to download original message');
346
+ }
347
+ }
348
+
249
349
  createStyles() {
250
350
  if (typeof document === 'undefined') {
251
351
  return;
@@ -271,9 +371,10 @@ class EmailEngineClient {
271
371
 
272
372
  .ee-sidebar {
273
373
  width: 200px;
274
- background: #f5f5f5;
374
+ background: #ffffff;
275
375
  border-right: 1px solid #ddd;
276
- overflow-y: auto;
376
+ display: flex;
377
+ flex-direction: column;
277
378
  }
278
379
 
279
380
  .ee-folder-list {
@@ -285,6 +386,7 @@ class EmailEngineClient {
285
386
  .ee-folder-item {
286
387
  cursor: pointer;
287
388
  border-bottom: 1px solid #e0e0e0;
389
+ position: relative;
288
390
  }
289
391
 
290
392
  .ee-folder-item:hover {
@@ -296,6 +398,16 @@ class EmailEngineClient {
296
398
  color: white;
297
399
  }
298
400
 
401
+ .ee-folder-item.active::before {
402
+ content: '';
403
+ position: absolute;
404
+ left: 0;
405
+ top: 0;
406
+ bottom: 0;
407
+ width: 3px;
408
+ background: #0056b3;
409
+ }
410
+
299
411
  .ee-folder-content {
300
412
  padding: 8px 16px 8px 0px;
301
413
  display: flex;
@@ -340,7 +452,9 @@ class EmailEngineClient {
340
452
  .ee-message-list {
341
453
  width: 350px;
342
454
  border-right: 1px solid #ddd;
343
- overflow-y: auto;
455
+ background: #ffffff;
456
+ display: flex;
457
+ flex-direction: column;
344
458
  }
345
459
 
346
460
  .ee-message-item {
@@ -382,10 +496,17 @@ class EmailEngineClient {
382
496
  }
383
497
 
384
498
  .ee-message-subject {
499
+ display: flex;
500
+ align-items: center;
501
+ margin-bottom: 2px;
502
+ }
503
+
504
+ .ee-message-subject-text {
385
505
  overflow: hidden;
386
506
  text-overflow: ellipsis;
387
507
  white-space: nowrap;
388
- margin-bottom: 2px;
508
+ flex: 1;
509
+ min-width: 0;
389
510
  }
390
511
 
391
512
  .ee-message-preview {
@@ -397,6 +518,17 @@ class EmailEngineClient {
397
518
  font-weight: normal;
398
519
  }
399
520
 
521
+ .ee-attachment-indicator {
522
+ display: inline-block;
523
+ font-size: 11px;
524
+ color: #666;
525
+ margin-left: 8px;
526
+ }
527
+
528
+ .ee-attachment-indicator::before {
529
+ content: "📎 ";
530
+ }
531
+
400
532
  .ee-message-viewer {
401
533
  flex: 1;
402
534
  display: flex;
@@ -405,20 +537,34 @@ class EmailEngineClient {
405
537
  }
406
538
 
407
539
  .ee-message-actions {
408
- padding: 12px 16px;
409
- background: #f5f5f5;
410
- border-bottom: 1px solid #ddd;
540
+ padding: 10px 16px;
541
+ background: #e9ecef;
542
+ background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
543
+ border-bottom: 2px solid #dee2e6;
411
544
  display: flex;
412
545
  gap: 8px;
546
+ height: 44px;
547
+ align-items: center;
548
+ flex-shrink: 0;
549
+ box-sizing: border-box;
550
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
413
551
  }
414
552
 
415
553
  .ee-button {
416
- padding: 6px 12px;
554
+ padding: 4px 10px;
417
555
  border: 1px solid #ddd;
418
556
  background: white;
419
557
  border-radius: 4px;
420
558
  cursor: pointer;
421
- font-size: 13px;
559
+ font-size: 12px;
560
+ height: 24px;
561
+ line-height: 1;
562
+ box-sizing: border-box;
563
+ }
564
+
565
+ select.ee-button {
566
+ padding: 3px 10px;
567
+ height: 24px;
422
568
  }
423
569
 
424
570
  .ee-button:hover:not(:disabled) {
@@ -464,6 +610,53 @@ class EmailEngineClient {
464
610
  height: auto;
465
611
  }
466
612
 
613
+ .ee-attachments {
614
+ margin-top: 16px;
615
+ padding-top: 16px;
616
+ border-top: 1px solid #e0e0e0;
617
+ }
618
+
619
+ .ee-attachments-title {
620
+ font-weight: 500;
621
+ margin-bottom: 8px;
622
+ color: #333;
623
+ }
624
+
625
+ .ee-attachment-item {
626
+ display: flex;
627
+ align-items: center;
628
+ padding: 8px;
629
+ margin-bottom: 4px;
630
+ background: #f8f8f8;
631
+ border: 1px solid #e0e0e0;
632
+ border-radius: 4px;
633
+ cursor: pointer;
634
+ transition: background 0.2s;
635
+ }
636
+
637
+ .ee-attachment-item:hover {
638
+ background: #f0f0f0;
639
+ }
640
+
641
+ .ee-attachment-icon {
642
+ margin-right: 8px;
643
+ font-size: 18px;
644
+ }
645
+
646
+ .ee-attachment-info {
647
+ flex: 1;
648
+ }
649
+
650
+ .ee-attachment-name {
651
+ font-weight: 500;
652
+ color: #333;
653
+ }
654
+
655
+ .ee-attachment-size {
656
+ font-size: 12px;
657
+ color: #666;
658
+ }
659
+
467
660
  .ee-empty-state {
468
661
  display: flex;
469
662
  align-items: center;
@@ -502,19 +695,64 @@ class EmailEngineClient {
502
695
  background: #2196F3;
503
696
  }
504
697
 
505
- .ee-pagination {
506
- padding: 8px 16px;
507
- background: #f8f9fa;
508
- border-top: 1px solid #e0e0e0;
509
- border-bottom: 1px solid #e0e0e0;
698
+ .ee-pane-header {
699
+ padding: 10px 16px;
700
+ background: #e9ecef;
701
+ background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
702
+ border-bottom: 2px solid #dee2e6;
510
703
  display: flex;
511
704
  justify-content: space-between;
512
705
  align-items: center;
706
+ height: 44px;
707
+ flex-shrink: 0;
708
+ box-sizing: border-box;
709
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
710
+ }
711
+
712
+ .ee-pane-title {
713
+ font-weight: 500;
714
+ font-size: 14px;
715
+ color: #333;
716
+ }
717
+
718
+ .ee-folder-tree {
719
+ flex: 1;
720
+ overflow-y: auto;
721
+ }
722
+
723
+ .ee-pagination-controls {
724
+ display: flex;
725
+ gap: 8px;
726
+ align-items: center;
513
727
  }
514
728
 
515
- .ee-pagination-btn {
729
+ .ee-page-size-selector {
730
+ display: flex;
731
+ gap: 4px;
732
+ align-items: center;
733
+ margin-left: auto;
734
+ }
735
+
736
+ .ee-page-size-label {
516
737
  font-size: 12px;
517
- padding: 4px 8px;
738
+ color: #666;
739
+ }
740
+
741
+ .ee-page-size-select {
742
+ font-size: 11px;
743
+ padding: 2px 4px;
744
+ border: 1px solid #ddd;
745
+ border-radius: 3px;
746
+ background: white;
747
+ cursor: pointer;
748
+ height: 22px;
749
+ }
750
+
751
+ .ee-pagination-btn {
752
+ font-size: 11px;
753
+ padding: 3px 8px;
754
+ height: 22px;
755
+ line-height: 1;
518
756
  }
519
757
 
520
758
  .ee-message-items {
@@ -600,8 +838,8 @@ class EmailEngineClient {
600
838
  return;
601
839
  }
602
840
 
603
- const sidebar = this.container.querySelector('.ee-sidebar');
604
- if (!sidebar) {
841
+ const folderTree = this.container.querySelector('.ee-folder-tree');
842
+ if (!folderTree) {
605
843
  return;
606
844
  }
607
845
 
@@ -628,9 +866,9 @@ class EmailEngineClient {
628
866
  .join('')}
629
867
  </ul>
630
868
  `;
631
- sidebar.innerHTML = html;
869
+ folderTree.innerHTML = html;
632
870
 
633
- sidebar.querySelectorAll('.ee-folder-item').forEach(item => {
871
+ folderTree.querySelectorAll('.ee-folder-item').forEach(item => {
634
872
  item.addEventListener('click', () => {
635
873
  const path = item.getAttribute('data-path');
636
874
  this.loadMessages(path);
@@ -649,22 +887,41 @@ class EmailEngineClient {
649
887
  }
650
888
 
651
889
  if (!this.messages.length) {
652
- messageList.innerHTML = '<div class="ee-empty-state">No messages</div>';
890
+ messageList.innerHTML = `
891
+ <div class="ee-pane-header">
892
+ <span class="ee-pane-title">Messages</span>
893
+ </div>
894
+ <div class="ee-empty-state">No messages</div>
895
+ `;
653
896
  return;
654
897
  }
655
898
 
656
- const paginationHtml =
657
- this.nextPageCursor || this.prevPageCursor
658
- ? `
659
- <div class="ee-pagination">
660
- ${this.prevPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="prev-page">← Previous</button>` : ''}
661
- ${this.nextPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="next-page">Next →</button>` : ''}
662
- </div>
663
- `
664
- : '';
899
+ const hasPagination = this.nextPageCursor || this.prevPageCursor;
665
900
 
666
901
  const html = `
667
- ${paginationHtml}
902
+ <div class="ee-pane-header">
903
+ <span class="ee-pane-title">Messages</span>
904
+ <div class="ee-pagination-controls">
905
+ ${
906
+ hasPagination
907
+ ? `
908
+ ${this.prevPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="prev-page">← Previous</button>` : ''}
909
+ ${this.nextPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="next-page">Next →</button>` : ''}
910
+ `
911
+ : ''
912
+ }
913
+ <div class="ee-page-size-selector">
914
+ <span class="ee-page-size-label">Show:</span>
915
+ <select class="ee-page-size-select" data-action="page-size">
916
+ <option value="10" ${this.pageSize === 10 ? 'selected' : ''}>10</option>
917
+ <option value="20" ${this.pageSize === 20 ? 'selected' : ''}>20</option>
918
+ <option value="30" ${this.pageSize === 30 ? 'selected' : ''}>30</option>
919
+ <option value="50" ${this.pageSize === 50 ? 'selected' : ''}>50</option>
920
+ <option value="100" ${this.pageSize === 100 ? 'selected' : ''}>100</option>
921
+ </select>
922
+ </div>
923
+ </div>
924
+ </div>
668
925
  <div class="ee-message-items">
669
926
  ${this.messages
670
927
  .map(
@@ -674,14 +931,16 @@ class EmailEngineClient {
674
931
  <span class="ee-message-from">${msg.from ? msg.from.name || msg.from.address : 'Unknown'}</span>
675
932
  <span class="ee-message-date">${this.formatDate(msg.date)}</span>
676
933
  </div>
677
- <div class="ee-message-subject">${msg.subject || '(no subject)'}</div>
934
+ <div class="ee-message-subject">
935
+ <span class="ee-message-subject-text">${msg.subject || '(no subject)'}</span>
936
+ ${msg.attachments && msg.attachments.length > 0 ? `<span class="ee-attachment-indicator">${msg.attachments.length}</span>` : ''}
937
+ </div>
678
938
  <div class="ee-message-preview">${msg.intro || ''}</div>
679
939
  </div>
680
940
  `
681
941
  )
682
942
  .join('')}
683
943
  </div>
684
- ${paginationHtml}
685
944
  `;
686
945
  messageList.innerHTML = html;
687
946
 
@@ -703,6 +962,18 @@ class EmailEngineClient {
703
962
  this.loadMessages(this.currentFolder, this.nextPageCursor);
704
963
  });
705
964
  });
965
+
966
+ const pageSizeSelect = messageList.querySelector('[data-action="page-size"]');
967
+ if (pageSizeSelect) {
968
+ pageSizeSelect.addEventListener('change', e => {
969
+ this.pageSize = parseInt(e.target.value);
970
+ // Save to localStorage
971
+ if (typeof window !== 'undefined' && window.localStorage) {
972
+ localStorage.setItem('ee-client-page-size', this.pageSize.toString());
973
+ }
974
+ this.loadMessages(this.currentFolder);
975
+ });
976
+ }
706
977
  }
707
978
 
708
979
  renderMessage() {
@@ -726,6 +997,7 @@ class EmailEngineClient {
726
997
  <div class="ee-message-actions">
727
998
  <button class="ee-button" data-action="toggle-read">Mark as ${isUnseen ? 'seen' : 'unseen'}</button>
728
999
  <button class="ee-button" data-action="delete">Delete</button>
1000
+ <button class="ee-button" data-action="download-original">Download Original</button>
729
1001
  <select class="ee-button" data-action="move">
730
1002
  <option value="">Move to...</option>
731
1003
  ${this.buildFolderTree()
@@ -770,6 +1042,28 @@ class EmailEngineClient {
770
1042
  <div class="ee-message-body">
771
1043
  ${msg.text && msg.text.html ? msg.text.html : msg.text && msg.text.plain ? `<pre>${msg.text.plain}</pre>` : ''}
772
1044
  </div>
1045
+ ${
1046
+ msg.attachments && msg.attachments.length > 0
1047
+ ? `
1048
+ <div class="ee-attachments">
1049
+ <div class="ee-attachments-title">Attachments (${msg.attachments.length})</div>
1050
+ ${msg.attachments
1051
+ .map(
1052
+ att => `
1053
+ <div class="ee-attachment-item" data-attachment-id="${att.id}">
1054
+ <div class="ee-attachment-icon">📎</div>
1055
+ <div class="ee-attachment-info">
1056
+ <div class="ee-attachment-name">${att.filename || 'Unnamed attachment'}</div>
1057
+ ${att.size ? `<div class="ee-attachment-size">${this.formatFileSize(att.size)}</div>` : ''}
1058
+ </div>
1059
+ </div>
1060
+ `
1061
+ )
1062
+ .join('')}
1063
+ </div>
1064
+ `
1065
+ : ''
1066
+ }
773
1067
  </div>
774
1068
  `;
775
1069
  viewer.innerHTML = html;
@@ -779,18 +1073,32 @@ class EmailEngineClient {
779
1073
  this.markAsRead(msg.id, currentlyUnseen);
780
1074
  });
781
1075
 
782
- viewer.querySelector('[data-action="delete"]').addEventListener('click', () => {
783
- if (confirm('Delete this message?')) {
1076
+ viewer.querySelector('[data-action="delete"]').addEventListener('click', async () => {
1077
+ const result = await this.confirmMethod('Delete this message?');
1078
+ if (result) {
784
1079
  this.deleteMessage(msg.id);
785
1080
  }
786
1081
  });
787
1082
 
1083
+ viewer.querySelector('[data-action="download-original"]').addEventListener('click', () => {
1084
+ this.downloadOriginalMessage(msg.id, msg.subject);
1085
+ });
1086
+
788
1087
  viewer.querySelector('[data-action="move"]').addEventListener('change', e => {
789
1088
  const targetPath = e.target.value;
790
1089
  if (targetPath) {
791
1090
  this.moveMessage(msg.id, targetPath);
792
1091
  }
793
1092
  });
1093
+
1094
+ // Add click handlers for attachments
1095
+ viewer.querySelectorAll('.ee-attachment-item').forEach(item => {
1096
+ item.addEventListener('click', () => {
1097
+ const attachmentId = item.getAttribute('data-attachment-id');
1098
+ const attachment = msg.attachments.find(a => a.id === attachmentId);
1099
+ this.downloadAttachment(attachmentId, attachment ? attachment.filename : null);
1100
+ });
1101
+ });
794
1102
  }
795
1103
 
796
1104
  createLayout() {
@@ -801,9 +1109,17 @@ class EmailEngineClient {
801
1109
  this.container.innerHTML = `
802
1110
  <div class="ee-client">
803
1111
  <div class="ee-sidebar">
804
- <div class="ee-loading">Loading folders...</div>
1112
+ <div class="ee-pane-header">
1113
+ <span class="ee-pane-title">Folders</span>
1114
+ </div>
1115
+ <div class="ee-folder-tree">
1116
+ <div class="ee-loading">Loading folders...</div>
1117
+ </div>
805
1118
  </div>
806
1119
  <div class="ee-message-list">
1120
+ <div class="ee-pane-header">
1121
+ <span class="ee-pane-title">Messages</span>
1122
+ </div>
807
1123
  <div class="ee-empty-state">Select a folder</div>
808
1124
  </div>
809
1125
  <div class="ee-message-viewer">
@@ -821,16 +1137,19 @@ class EmailEngineClient {
821
1137
 
822
1138
  this.createStyles();
823
1139
  this.createLayout();
824
- this.loadFolders();
825
-
826
- setTimeout(() => {
827
- const inbox =
828
- this.folders.find(f => f.specialUse === '\\Inbox' || f.name.toLowerCase() === 'inbox') ||
829
- this.folders[0];
830
- if (inbox) {
831
- this.loadMessages(inbox.path);
832
- }
833
- }, 500);
1140
+ this.loadFolders()
1141
+ .then(() => {
1142
+ const inbox =
1143
+ this.folders.find(f => f.specialUse && f.specialUse.includes('\\Inbox')) ||
1144
+ this.folders.find(f => f.name.toLowerCase() === 'inbox') ||
1145
+ this.folders[0];
1146
+ if (inbox) {
1147
+ this.loadMessages(inbox.path);
1148
+ }
1149
+ })
1150
+ .catch(error => {
1151
+ console.error('Failed to auto-select inbox:', error);
1152
+ });
834
1153
  }
835
1154
  }
836
1155
 
package/index.d.ts CHANGED
@@ -50,6 +50,7 @@ export interface EmailEngineClientOptions {
50
50
  accessToken?: string;
51
51
  container?: HTMLElement;
52
52
  containerId?: string;
53
+ confirmMethod?: (message: string) => boolean | Promise<boolean>;
53
54
  }
54
55
 
55
56
  export declare class EmailEngineClient {
package/index.js CHANGED
@@ -4,6 +4,7 @@ export class EmailEngineClient {
4
4
  this.account = options.account;
5
5
  this.accessToken = options.accessToken;
6
6
  this.container = options.container;
7
+ this.confirmMethod = options.confirmMethod || (message => confirm(message));
7
8
 
8
9
  this.currentFolder = null;
9
10
  this.currentMessage = null;
@@ -12,6 +13,11 @@ export class EmailEngineClient {
12
13
  this.nextPageCursor = null;
13
14
  this.prevPageCursor = null;
14
15
 
16
+ // Get page size from localStorage or options or default
17
+ const savedPageSize =
18
+ typeof window !== 'undefined' && window.localStorage ? localStorage.getItem('ee-client-page-size') : null;
19
+ this.pageSize = savedPageSize ? parseInt(savedPageSize) : options.pageSize || 20;
20
+
15
21
  if (this.container) {
16
22
  this.init();
17
23
  }
@@ -81,7 +87,7 @@ export class EmailEngineClient {
81
87
  }
82
88
 
83
89
  try {
84
- const params = new URLSearchParams({ path: path, pageSize: 50 });
90
+ const params = new URLSearchParams({ path: path, pageSize: this.pageSize });
85
91
  if (cursor) {
86
92
  params.set('cursor', cursor);
87
93
  }
@@ -94,6 +100,7 @@ export class EmailEngineClient {
94
100
 
95
101
  if (this.container) {
96
102
  this.renderMessageList();
103
+ this.renderFolderList(); // Re-render to update active state
97
104
  }
98
105
 
99
106
  return {
@@ -246,6 +253,99 @@ export class EmailEngineClient {
246
253
  }
247
254
  }
248
255
 
256
+ formatFileSize(bytes) {
257
+ if (!bytes) {
258
+ return '';
259
+ }
260
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
261
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
262
+ return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
263
+ }
264
+
265
+ async downloadAttachment(attachmentId, suggestedFilename = null) {
266
+ try {
267
+ const headers = {};
268
+ if (this.accessToken) {
269
+ headers['Authorization'] = `Bearer ${this.accessToken}`;
270
+ }
271
+
272
+ const response = await fetch(`${this.apiUrl}/v1/account/${this.account}/attachment/${attachmentId}`, {
273
+ headers,
274
+ credentials: 'include'
275
+ });
276
+
277
+ if (!response.ok) {
278
+ throw new Error(`HTTP error! status: ${response.status}`);
279
+ }
280
+
281
+ // Get filename from Content-Disposition header if available
282
+ const contentDisposition = response.headers.get('content-disposition');
283
+ let filename = suggestedFilename || 'attachment';
284
+ if (contentDisposition) {
285
+ const filenameMatch = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
286
+ if (filenameMatch && filenameMatch[1]) {
287
+ filename = filenameMatch[1].replace(/['"]/g, '');
288
+ }
289
+ }
290
+
291
+ // Get the attachment data
292
+ const blob = await response.blob();
293
+
294
+ // Create a download link
295
+ const url = window.URL.createObjectURL(blob);
296
+ const a = document.createElement('a');
297
+ a.href = url;
298
+ a.download = filename;
299
+ document.body.appendChild(a);
300
+ a.click();
301
+ document.body.removeChild(a);
302
+ window.URL.revokeObjectURL(url);
303
+ } catch (error) {
304
+ console.error('Failed to download attachment:', error);
305
+ alert('Failed to download attachment');
306
+ }
307
+ }
308
+
309
+ async downloadOriginalMessage(messageId, subject = null) {
310
+ try {
311
+ const headers = {};
312
+ if (this.accessToken) {
313
+ headers['Authorization'] = `Bearer ${this.accessToken}`;
314
+ }
315
+
316
+ const response = await fetch(`${this.apiUrl}/v1/account/${this.account}/message/${messageId}/source`, {
317
+ headers,
318
+ credentials: 'include'
319
+ });
320
+
321
+ if (!response.ok) {
322
+ throw new Error(`HTTP error! status: ${response.status}`);
323
+ }
324
+
325
+ // Get the email data
326
+ const blob = await response.blob();
327
+
328
+ // Create filename based on subject and date
329
+ const now = new Date();
330
+ const dateStr = now.toISOString().split('T')[0];
331
+ const safeSubject = subject ? subject.replace(/[^a-z0-9]/gi, '_').substring(0, 50) : 'email';
332
+ const filename = `${dateStr}_${safeSubject}.eml`;
333
+
334
+ // Create a download link
335
+ const url = window.URL.createObjectURL(blob);
336
+ const a = document.createElement('a');
337
+ a.href = url;
338
+ a.download = filename;
339
+ document.body.appendChild(a);
340
+ a.click();
341
+ document.body.removeChild(a);
342
+ window.URL.revokeObjectURL(url);
343
+ } catch (error) {
344
+ console.error('Failed to download original message:', error);
345
+ alert('Failed to download original message');
346
+ }
347
+ }
348
+
249
349
  createStyles() {
250
350
  if (typeof document === 'undefined') {
251
351
  return;
@@ -271,9 +371,10 @@ export class EmailEngineClient {
271
371
 
272
372
  .ee-sidebar {
273
373
  width: 200px;
274
- background: #f5f5f5;
374
+ background: #ffffff;
275
375
  border-right: 1px solid #ddd;
276
- overflow-y: auto;
376
+ display: flex;
377
+ flex-direction: column;
277
378
  }
278
379
 
279
380
  .ee-folder-list {
@@ -285,6 +386,7 @@ export class EmailEngineClient {
285
386
  .ee-folder-item {
286
387
  cursor: pointer;
287
388
  border-bottom: 1px solid #e0e0e0;
389
+ position: relative;
288
390
  }
289
391
 
290
392
  .ee-folder-item:hover {
@@ -296,6 +398,16 @@ export class EmailEngineClient {
296
398
  color: white;
297
399
  }
298
400
 
401
+ .ee-folder-item.active::before {
402
+ content: '';
403
+ position: absolute;
404
+ left: 0;
405
+ top: 0;
406
+ bottom: 0;
407
+ width: 3px;
408
+ background: #0056b3;
409
+ }
410
+
299
411
  .ee-folder-content {
300
412
  padding: 8px 16px 8px 0px;
301
413
  display: flex;
@@ -340,7 +452,9 @@ export class EmailEngineClient {
340
452
  .ee-message-list {
341
453
  width: 350px;
342
454
  border-right: 1px solid #ddd;
343
- overflow-y: auto;
455
+ background: #ffffff;
456
+ display: flex;
457
+ flex-direction: column;
344
458
  }
345
459
 
346
460
  .ee-message-item {
@@ -382,10 +496,17 @@ export class EmailEngineClient {
382
496
  }
383
497
 
384
498
  .ee-message-subject {
499
+ display: flex;
500
+ align-items: center;
501
+ margin-bottom: 2px;
502
+ }
503
+
504
+ .ee-message-subject-text {
385
505
  overflow: hidden;
386
506
  text-overflow: ellipsis;
387
507
  white-space: nowrap;
388
- margin-bottom: 2px;
508
+ flex: 1;
509
+ min-width: 0;
389
510
  }
390
511
 
391
512
  .ee-message-preview {
@@ -397,6 +518,17 @@ export class EmailEngineClient {
397
518
  font-weight: normal;
398
519
  }
399
520
 
521
+ .ee-attachment-indicator {
522
+ display: inline-block;
523
+ font-size: 11px;
524
+ color: #666;
525
+ margin-left: 8px;
526
+ }
527
+
528
+ .ee-attachment-indicator::before {
529
+ content: "📎 ";
530
+ }
531
+
400
532
  .ee-message-viewer {
401
533
  flex: 1;
402
534
  display: flex;
@@ -405,20 +537,34 @@ export class EmailEngineClient {
405
537
  }
406
538
 
407
539
  .ee-message-actions {
408
- padding: 12px 16px;
409
- background: #f5f5f5;
410
- border-bottom: 1px solid #ddd;
540
+ padding: 10px 16px;
541
+ background: #e9ecef;
542
+ background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
543
+ border-bottom: 2px solid #dee2e6;
411
544
  display: flex;
412
545
  gap: 8px;
546
+ height: 44px;
547
+ align-items: center;
548
+ flex-shrink: 0;
549
+ box-sizing: border-box;
550
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
413
551
  }
414
552
 
415
553
  .ee-button {
416
- padding: 6px 12px;
554
+ padding: 4px 10px;
417
555
  border: 1px solid #ddd;
418
556
  background: white;
419
557
  border-radius: 4px;
420
558
  cursor: pointer;
421
- font-size: 13px;
559
+ font-size: 12px;
560
+ height: 24px;
561
+ line-height: 1;
562
+ box-sizing: border-box;
563
+ }
564
+
565
+ select.ee-button {
566
+ padding: 3px 10px;
567
+ height: 24px;
422
568
  }
423
569
 
424
570
  .ee-button:hover:not(:disabled) {
@@ -464,6 +610,53 @@ export class EmailEngineClient {
464
610
  height: auto;
465
611
  }
466
612
 
613
+ .ee-attachments {
614
+ margin-top: 16px;
615
+ padding-top: 16px;
616
+ border-top: 1px solid #e0e0e0;
617
+ }
618
+
619
+ .ee-attachments-title {
620
+ font-weight: 500;
621
+ margin-bottom: 8px;
622
+ color: #333;
623
+ }
624
+
625
+ .ee-attachment-item {
626
+ display: flex;
627
+ align-items: center;
628
+ padding: 8px;
629
+ margin-bottom: 4px;
630
+ background: #f8f8f8;
631
+ border: 1px solid #e0e0e0;
632
+ border-radius: 4px;
633
+ cursor: pointer;
634
+ transition: background 0.2s;
635
+ }
636
+
637
+ .ee-attachment-item:hover {
638
+ background: #f0f0f0;
639
+ }
640
+
641
+ .ee-attachment-icon {
642
+ margin-right: 8px;
643
+ font-size: 18px;
644
+ }
645
+
646
+ .ee-attachment-info {
647
+ flex: 1;
648
+ }
649
+
650
+ .ee-attachment-name {
651
+ font-weight: 500;
652
+ color: #333;
653
+ }
654
+
655
+ .ee-attachment-size {
656
+ font-size: 12px;
657
+ color: #666;
658
+ }
659
+
467
660
  .ee-empty-state {
468
661
  display: flex;
469
662
  align-items: center;
@@ -502,19 +695,64 @@ export class EmailEngineClient {
502
695
  background: #2196F3;
503
696
  }
504
697
 
505
- .ee-pagination {
506
- padding: 8px 16px;
507
- background: #f8f9fa;
508
- border-top: 1px solid #e0e0e0;
509
- border-bottom: 1px solid #e0e0e0;
698
+ .ee-pane-header {
699
+ padding: 10px 16px;
700
+ background: #e9ecef;
701
+ background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
702
+ border-bottom: 2px solid #dee2e6;
510
703
  display: flex;
511
704
  justify-content: space-between;
512
705
  align-items: center;
706
+ height: 44px;
707
+ flex-shrink: 0;
708
+ box-sizing: border-box;
709
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
710
+ }
711
+
712
+ .ee-pane-title {
713
+ font-weight: 500;
714
+ font-size: 14px;
715
+ color: #333;
716
+ }
717
+
718
+ .ee-folder-tree {
719
+ flex: 1;
720
+ overflow-y: auto;
721
+ }
722
+
723
+ .ee-pagination-controls {
724
+ display: flex;
725
+ gap: 8px;
726
+ align-items: center;
513
727
  }
514
728
 
515
- .ee-pagination-btn {
729
+ .ee-page-size-selector {
730
+ display: flex;
731
+ gap: 4px;
732
+ align-items: center;
733
+ margin-left: auto;
734
+ }
735
+
736
+ .ee-page-size-label {
516
737
  font-size: 12px;
517
- padding: 4px 8px;
738
+ color: #666;
739
+ }
740
+
741
+ .ee-page-size-select {
742
+ font-size: 11px;
743
+ padding: 2px 4px;
744
+ border: 1px solid #ddd;
745
+ border-radius: 3px;
746
+ background: white;
747
+ cursor: pointer;
748
+ height: 22px;
749
+ }
750
+
751
+ .ee-pagination-btn {
752
+ font-size: 11px;
753
+ padding: 3px 8px;
754
+ height: 22px;
755
+ line-height: 1;
518
756
  }
519
757
 
520
758
  .ee-message-items {
@@ -600,8 +838,8 @@ export class EmailEngineClient {
600
838
  return;
601
839
  }
602
840
 
603
- const sidebar = this.container.querySelector('.ee-sidebar');
604
- if (!sidebar) {
841
+ const folderTree = this.container.querySelector('.ee-folder-tree');
842
+ if (!folderTree) {
605
843
  return;
606
844
  }
607
845
 
@@ -628,9 +866,9 @@ export class EmailEngineClient {
628
866
  .join('')}
629
867
  </ul>
630
868
  `;
631
- sidebar.innerHTML = html;
869
+ folderTree.innerHTML = html;
632
870
 
633
- sidebar.querySelectorAll('.ee-folder-item').forEach(item => {
871
+ folderTree.querySelectorAll('.ee-folder-item').forEach(item => {
634
872
  item.addEventListener('click', () => {
635
873
  const path = item.getAttribute('data-path');
636
874
  this.loadMessages(path);
@@ -649,22 +887,41 @@ export class EmailEngineClient {
649
887
  }
650
888
 
651
889
  if (!this.messages.length) {
652
- messageList.innerHTML = '<div class="ee-empty-state">No messages</div>';
890
+ messageList.innerHTML = `
891
+ <div class="ee-pane-header">
892
+ <span class="ee-pane-title">Messages</span>
893
+ </div>
894
+ <div class="ee-empty-state">No messages</div>
895
+ `;
653
896
  return;
654
897
  }
655
898
 
656
- const paginationHtml =
657
- this.nextPageCursor || this.prevPageCursor
658
- ? `
659
- <div class="ee-pagination">
660
- ${this.prevPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="prev-page">← Previous</button>` : ''}
661
- ${this.nextPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="next-page">Next →</button>` : ''}
662
- </div>
663
- `
664
- : '';
899
+ const hasPagination = this.nextPageCursor || this.prevPageCursor;
665
900
 
666
901
  const html = `
667
- ${paginationHtml}
902
+ <div class="ee-pane-header">
903
+ <span class="ee-pane-title">Messages</span>
904
+ <div class="ee-pagination-controls">
905
+ ${
906
+ hasPagination
907
+ ? `
908
+ ${this.prevPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="prev-page">← Previous</button>` : ''}
909
+ ${this.nextPageCursor ? `<button class="ee-button ee-pagination-btn" data-action="next-page">Next →</button>` : ''}
910
+ `
911
+ : ''
912
+ }
913
+ <div class="ee-page-size-selector">
914
+ <span class="ee-page-size-label">Show:</span>
915
+ <select class="ee-page-size-select" data-action="page-size">
916
+ <option value="10" ${this.pageSize === 10 ? 'selected' : ''}>10</option>
917
+ <option value="20" ${this.pageSize === 20 ? 'selected' : ''}>20</option>
918
+ <option value="30" ${this.pageSize === 30 ? 'selected' : ''}>30</option>
919
+ <option value="50" ${this.pageSize === 50 ? 'selected' : ''}>50</option>
920
+ <option value="100" ${this.pageSize === 100 ? 'selected' : ''}>100</option>
921
+ </select>
922
+ </div>
923
+ </div>
924
+ </div>
668
925
  <div class="ee-message-items">
669
926
  ${this.messages
670
927
  .map(
@@ -674,14 +931,16 @@ export class EmailEngineClient {
674
931
  <span class="ee-message-from">${msg.from ? msg.from.name || msg.from.address : 'Unknown'}</span>
675
932
  <span class="ee-message-date">${this.formatDate(msg.date)}</span>
676
933
  </div>
677
- <div class="ee-message-subject">${msg.subject || '(no subject)'}</div>
934
+ <div class="ee-message-subject">
935
+ <span class="ee-message-subject-text">${msg.subject || '(no subject)'}</span>
936
+ ${msg.attachments && msg.attachments.length > 0 ? `<span class="ee-attachment-indicator">${msg.attachments.length}</span>` : ''}
937
+ </div>
678
938
  <div class="ee-message-preview">${msg.intro || ''}</div>
679
939
  </div>
680
940
  `
681
941
  )
682
942
  .join('')}
683
943
  </div>
684
- ${paginationHtml}
685
944
  `;
686
945
  messageList.innerHTML = html;
687
946
 
@@ -703,6 +962,18 @@ export class EmailEngineClient {
703
962
  this.loadMessages(this.currentFolder, this.nextPageCursor);
704
963
  });
705
964
  });
965
+
966
+ const pageSizeSelect = messageList.querySelector('[data-action="page-size"]');
967
+ if (pageSizeSelect) {
968
+ pageSizeSelect.addEventListener('change', e => {
969
+ this.pageSize = parseInt(e.target.value);
970
+ // Save to localStorage
971
+ if (typeof window !== 'undefined' && window.localStorage) {
972
+ localStorage.setItem('ee-client-page-size', this.pageSize.toString());
973
+ }
974
+ this.loadMessages(this.currentFolder);
975
+ });
976
+ }
706
977
  }
707
978
 
708
979
  renderMessage() {
@@ -726,6 +997,7 @@ export class EmailEngineClient {
726
997
  <div class="ee-message-actions">
727
998
  <button class="ee-button" data-action="toggle-read">Mark as ${isUnseen ? 'seen' : 'unseen'}</button>
728
999
  <button class="ee-button" data-action="delete">Delete</button>
1000
+ <button class="ee-button" data-action="download-original">Download Original</button>
729
1001
  <select class="ee-button" data-action="move">
730
1002
  <option value="">Move to...</option>
731
1003
  ${this.buildFolderTree()
@@ -770,6 +1042,28 @@ export class EmailEngineClient {
770
1042
  <div class="ee-message-body">
771
1043
  ${msg.text && msg.text.html ? msg.text.html : msg.text && msg.text.plain ? `<pre>${msg.text.plain}</pre>` : ''}
772
1044
  </div>
1045
+ ${
1046
+ msg.attachments && msg.attachments.length > 0
1047
+ ? `
1048
+ <div class="ee-attachments">
1049
+ <div class="ee-attachments-title">Attachments (${msg.attachments.length})</div>
1050
+ ${msg.attachments
1051
+ .map(
1052
+ att => `
1053
+ <div class="ee-attachment-item" data-attachment-id="${att.id}">
1054
+ <div class="ee-attachment-icon">📎</div>
1055
+ <div class="ee-attachment-info">
1056
+ <div class="ee-attachment-name">${att.filename || 'Unnamed attachment'}</div>
1057
+ ${att.size ? `<div class="ee-attachment-size">${this.formatFileSize(att.size)}</div>` : ''}
1058
+ </div>
1059
+ </div>
1060
+ `
1061
+ )
1062
+ .join('')}
1063
+ </div>
1064
+ `
1065
+ : ''
1066
+ }
773
1067
  </div>
774
1068
  `;
775
1069
  viewer.innerHTML = html;
@@ -779,18 +1073,32 @@ export class EmailEngineClient {
779
1073
  this.markAsRead(msg.id, currentlyUnseen);
780
1074
  });
781
1075
 
782
- viewer.querySelector('[data-action="delete"]').addEventListener('click', () => {
783
- if (confirm('Delete this message?')) {
1076
+ viewer.querySelector('[data-action="delete"]').addEventListener('click', async () => {
1077
+ const result = await this.confirmMethod('Delete this message?');
1078
+ if (result) {
784
1079
  this.deleteMessage(msg.id);
785
1080
  }
786
1081
  });
787
1082
 
1083
+ viewer.querySelector('[data-action="download-original"]').addEventListener('click', () => {
1084
+ this.downloadOriginalMessage(msg.id, msg.subject);
1085
+ });
1086
+
788
1087
  viewer.querySelector('[data-action="move"]').addEventListener('change', e => {
789
1088
  const targetPath = e.target.value;
790
1089
  if (targetPath) {
791
1090
  this.moveMessage(msg.id, targetPath);
792
1091
  }
793
1092
  });
1093
+
1094
+ // Add click handlers for attachments
1095
+ viewer.querySelectorAll('.ee-attachment-item').forEach(item => {
1096
+ item.addEventListener('click', () => {
1097
+ const attachmentId = item.getAttribute('data-attachment-id');
1098
+ const attachment = msg.attachments.find(a => a.id === attachmentId);
1099
+ this.downloadAttachment(attachmentId, attachment ? attachment.filename : null);
1100
+ });
1101
+ });
794
1102
  }
795
1103
 
796
1104
  createLayout() {
@@ -801,9 +1109,17 @@ export class EmailEngineClient {
801
1109
  this.container.innerHTML = `
802
1110
  <div class="ee-client">
803
1111
  <div class="ee-sidebar">
804
- <div class="ee-loading">Loading folders...</div>
1112
+ <div class="ee-pane-header">
1113
+ <span class="ee-pane-title">Folders</span>
1114
+ </div>
1115
+ <div class="ee-folder-tree">
1116
+ <div class="ee-loading">Loading folders...</div>
1117
+ </div>
805
1118
  </div>
806
1119
  <div class="ee-message-list">
1120
+ <div class="ee-pane-header">
1121
+ <span class="ee-pane-title">Messages</span>
1122
+ </div>
807
1123
  <div class="ee-empty-state">Select a folder</div>
808
1124
  </div>
809
1125
  <div class="ee-message-viewer">
@@ -821,16 +1137,19 @@ export class EmailEngineClient {
821
1137
 
822
1138
  this.createStyles();
823
1139
  this.createLayout();
824
- this.loadFolders();
825
-
826
- setTimeout(() => {
827
- const inbox =
828
- this.folders.find(f => f.specialUse === '\\Inbox' || f.name.toLowerCase() === 'inbox') ||
829
- this.folders[0];
830
- if (inbox) {
831
- this.loadMessages(inbox.path);
832
- }
833
- }, 500);
1140
+ this.loadFolders()
1141
+ .then(() => {
1142
+ const inbox =
1143
+ this.folders.find(f => f.specialUse && f.specialUse.includes('\\Inbox')) ||
1144
+ this.folders.find(f => f.name.toLowerCase() === 'inbox') ||
1145
+ this.folders[0];
1146
+ if (inbox) {
1147
+ this.loadMessages(inbox.path);
1148
+ }
1149
+ })
1150
+ .catch(error => {
1151
+ console.error('Failed to auto-select inbox:', error);
1152
+ });
834
1153
  }
835
1154
  }
836
1155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/ee-client",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "EmailEngine client library for browser and Node.js applications",
5
5
  "main": "index.js",
6
6
  "module": "index.js",