@social-mail/social-mail-web-server 1.8.367 → 1.8.368

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.8.367",
3
+ "version": "1.8.368",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "console-log-colors": "^0.4.0",
39
39
  "decimal.js": "^10.6.0",
40
40
  "dns2": "^2.1.0",
41
- "firebase-admin": "^13.4.0",
41
+ "firebase-admin": "^13.5.0",
42
42
  "heic-convert": "^2.1.0",
43
43
  "iconv-lite": "^0.6.3",
44
44
  "ip": "^2.0.1",
@@ -59,7 +59,7 @@
59
59
  "socket.io": "^4.7.2",
60
60
  "stripe": "^17.3.1",
61
61
  "tesseract.js": "^5.1.1",
62
- "tldts": "^7.0.17",
62
+ "tldts": "7.0.13",
63
63
  "tmp": "^0.2.1",
64
64
  "tmp-promise": "^3.0.3",
65
65
  "twilio": "^5.6.0",
@@ -53,8 +53,8 @@ export default class BlogContentTransformer {
53
53
 
54
54
  const { urlService } = this;
55
55
 
56
- await t.run(async (c) => {
57
56
 
57
+ for(const c of t.all()) {
58
58
  const { node, element } = c;
59
59
 
60
60
  if (c.isTextNode) {
@@ -125,7 +125,9 @@ export default class BlogContentTransformer {
125
125
  }
126
126
  }
127
127
 
128
- });
128
+ }
129
+
130
+ await t.commit();
129
131
 
130
132
  if (trackerUrl) {
131
133
  const clean = t.root;
@@ -120,13 +120,14 @@ export class TransformContext {
120
120
  e.setAttribute(attributeName, src);
121
121
  }
122
122
 
123
- async [Symbol.asyncDispose]() {
123
+ async commit() {
124
124
  for (const a of this.queueActions) {
125
125
  const r = a();
126
126
  if((r as any)?.then) {
127
127
  await r;
128
128
  }
129
129
  }
130
+ this.queueActions.length = 0;
130
131
  }
131
132
  }
132
133
 
@@ -140,6 +141,8 @@ export default class HtmlTransform {
140
141
  return this.root.outerHTML;
141
142
  }
142
143
 
144
+ private context: TransformContext;
145
+
143
146
  constructor(html: string, public readonly url = defaultUrl) {
144
147
  const window = new JSDOM('', { url }).window as WindowLike;
145
148
  const purify = DOMPurify(window);
@@ -148,20 +151,18 @@ export default class HtmlTransform {
148
151
  RETURN_DOM: true
149
152
  }) as HTMLElement;
150
153
  this.document = window.document;
154
+ this.context = new TransformContext(this);
151
155
  }
152
156
 
153
- async run(transformer: (c: TransformContext) => void | Promise<void>) {
154
-
155
- await using c = new TransformContext(this.document);
156
-
157
- for (const node of descendentIterator(this.root)) {
158
- c.node = node;
159
- const r = transformer(c);
160
- if ((r as any)?.then) {
161
- await r;
162
- }
157
+ *all() {
158
+ for(const node of descendentIterator(this.root)) {
159
+ this.context.node = node;
160
+ yield this.context;
163
161
  }
162
+ }
164
163
 
164
+ async commit() {
165
+ await this.context.commit();
165
166
  }
166
167
 
167
168
  }