@social-mail/social-mail-web-server 1.7.481 → 1.7.482

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.7.481",
3
+ "version": "1.7.482",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-base-to-string */
2
2
  import { DOMWindow } from "jsdom";
3
+ import { cssEscape } from "./cssEscape.js";
3
4
 
4
5
  const keyFrameAttributes = [
5
6
  'styler-on-enter',
@@ -42,7 +43,7 @@ export default class DynamicStyles {
42
43
  return;
43
44
  }
44
45
  value = value.trim();
45
- const key = `[${a}=${this.win.CSS.escape(value)}]`;
46
+ const key = `[${a}=${cssEscape(value)}]`;
46
47
  if (keyFrameAttributes.includes(a)) {
47
48
 
48
49
  // replace with animation...
@@ -101,8 +102,8 @@ export default class DynamicStyles {
101
102
 
102
103
  if (a.startsWith("styler-on-enter")) {
103
104
  // set defaults...
104
- styleText = `:not(animated-text):not([styler-entered])[${a}=${CSS.escape(value)}],
105
- animated-text:not([styler-entered])[${a}=${CSS.escape(value)}] > * {
105
+ styleText = `:not(animated-text):not([styler-entered])[${a}=${cssEscape(value)}],
106
+ animated-text:not([styler-entered])[${a}=${cssEscape(value)}] > * {
106
107
  ${defaults.map(([k,v1]) => `${k}: ${v1};`).join("\t\n")}
107
108
  }
108
109
  `;
@@ -114,4 +115,5 @@ export default class DynamicStyles {
114
115
  console.error(error);
115
116
  }
116
117
  }
117
- }
118
+ }
119
+
@@ -0,0 +1,76 @@
1
+ /* eslint-disable eqeqeq */
2
+ export const cssEscape = function(value) {
3
+ if (!value) {
4
+ throw new TypeError('`CSS.escape` requires an argument.');
5
+ }
6
+ const stringValue = String(value);
7
+ const length = stringValue.length;
8
+ let index = -1;
9
+ let codeUnit;
10
+ let result = '';
11
+ const firstCodeUnit = stringValue.charCodeAt(0);
12
+
13
+ if (
14
+ // If the character is the first character and is a `-` (U+002D), and
15
+ // there is no second character, […]
16
+ length == 1 &&
17
+ firstCodeUnit == 0x002D
18
+ ) {
19
+ return '\\' + stringValue;
20
+ }
21
+
22
+ while (++index < length) {
23
+ codeUnit = stringValue.charCodeAt(index);
24
+ // Note: there’s no need to special-case astral symbols, surrogate
25
+ // pairs, or lone surrogates.
26
+
27
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
28
+ // (U+FFFD).
29
+ if (codeUnit == 0x0000) {
30
+ result += '\uFFFD';
31
+ continue;
32
+ }
33
+
34
+ if (
35
+ // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
36
+ // U+007F, […]
37
+ (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
38
+ // If the character is the first character and is in the range [0-9]
39
+ // (U+0030 to U+0039), […]
40
+ (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
41
+ // If the character is the second character and is in the range [0-9]
42
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
43
+ (
44
+ index == 1 &&
45
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
46
+ firstCodeUnit == 0x002D
47
+ )
48
+ ) {
49
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
50
+ result += '\\' + codeUnit.toString(16) + ' ';
51
+ continue;
52
+ }
53
+
54
+ // If the character is not handled by one of the above rules and is
55
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
56
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
57
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
58
+ if (
59
+ codeUnit >= 0x0080 ||
60
+ codeUnit == 0x002D ||
61
+ codeUnit == 0x005F ||
62
+ codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
63
+ codeUnit >= 0x0041 && codeUnit <= 0x005A ||
64
+ codeUnit >= 0x0061 && codeUnit <= 0x007A
65
+ ) {
66
+ // the character itself
67
+ result += stringValue.charAt(index);
68
+ continue;
69
+ }
70
+
71
+ // Otherwise, the escaped character.
72
+ // https://drafts.csswg.org/cssom/#escape-a-character
73
+ result += '\\' + stringValue.charAt(index);
74
+ }
75
+ return result;
76
+ };