ember-scoped-css 1.1.0 → 2.0.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.
Files changed (83) hide show
  1. package/README.md +203 -47
  2. package/dist/cjs/all-Du43cBa9.cjs +1308 -0
  3. package/dist/cjs/all.cjs +3 -0
  4. package/dist/cjs/babel.cjs +9 -0
  5. package/dist/cjs/rollup.cjs +8 -0
  6. package/dist/cjs/vite.cjs +8 -0
  7. package/dist/runtime/index.d.ts +11 -0
  8. package/dist/runtime/index.d.ts.map +1 -0
  9. package/dist/runtime/index.js +12 -8
  10. package/dist/runtime/index.js.map +1 -7
  11. package/{declarations → dist}/runtime/test-support.d.ts +5 -2
  12. package/dist/runtime/test-support.d.ts.map +1 -0
  13. package/dist/runtime/test-support.js +357 -182
  14. package/dist/runtime/test-support.js.map +1 -7
  15. package/package.json +21 -24
  16. package/src/build/babel-plugin.js +4 -1
  17. package/src/build/public-exports/all.js +10 -0
  18. package/src/build/public-exports/babel.js +5 -0
  19. package/src/build/public-exports/rollup.js +3 -0
  20. package/src/build/public-exports/vite.js +3 -0
  21. package/src/build/scoped-css-unplugin.js +10 -33
  22. package/src/build/template-plugin.js +9 -19
  23. package/src/build/template-plugin.test.ts +108 -19
  24. package/src/build/unplugin-colocated.js +103 -0
  25. package/src/build/unplugin-inline.js +71 -0
  26. package/src/lib/css/rewrite.js +8 -8
  27. package/src/lib/css/rewrite.test.ts +69 -128
  28. package/src/lib/path/const.js +19 -0
  29. package/src/lib/path/hash-from-absolute-path.js +3 -2
  30. package/src/lib/path/template-transform-paths.js +3 -2
  31. package/src/lib/path/utils.appPath.test.ts +2 -2
  32. package/src/lib/path/utils.hashFrom.test.ts +2 -2
  33. package/src/lib/path/utils.js +63 -20
  34. package/src/lib/request.js +58 -33
  35. package/src/runtime/index.ts +1 -1
  36. package/declarations/build/template-plugin.d.ts +0 -7
  37. package/declarations/build/template-plugin.d.ts.map +0 -1
  38. package/declarations/build/template-plugin.test.d.ts +0 -2
  39. package/declarations/build/template-plugin.test.d.ts.map +0 -1
  40. package/declarations/lib/css/rewrite.d.ts +0 -2
  41. package/declarations/lib/css/rewrite.d.ts.map +0 -1
  42. package/declarations/lib/css/rewrite.test.d.ts +0 -2
  43. package/declarations/lib/css/rewrite.test.d.ts.map +0 -1
  44. package/declarations/lib/css/utils.d.ts +0 -29
  45. package/declarations/lib/css/utils.d.ts.map +0 -1
  46. package/declarations/lib/path/hash-from-absolute-path.d.ts +0 -3
  47. package/declarations/lib/path/hash-from-absolute-path.d.ts.map +0 -1
  48. package/declarations/lib/path/hash-from-absolute-path.test.d.ts +0 -2
  49. package/declarations/lib/path/hash-from-absolute-path.test.d.ts.map +0 -1
  50. package/declarations/lib/path/hash-from-module-path.d.ts +0 -31
  51. package/declarations/lib/path/hash-from-module-path.d.ts.map +0 -1
  52. package/declarations/lib/path/md5.d.ts +0 -12
  53. package/declarations/lib/path/md5.d.ts.map +0 -1
  54. package/declarations/lib/path/template-transform-paths.d.ts +0 -11
  55. package/declarations/lib/path/template-transform-paths.d.ts.map +0 -1
  56. package/declarations/lib/path/template-transform-paths.test.d.ts +0 -2
  57. package/declarations/lib/path/template-transform-paths.test.d.ts.map +0 -1
  58. package/declarations/lib/path/utils.appPath.test.d.ts +0 -2
  59. package/declarations/lib/path/utils.appPath.test.d.ts.map +0 -1
  60. package/declarations/lib/path/utils.d.ts +0 -94
  61. package/declarations/lib/path/utils.d.ts.map +0 -1
  62. package/declarations/lib/path/utils.findWorkspacePath.test.d.ts +0 -2
  63. package/declarations/lib/path/utils.findWorkspacePath.test.d.ts.map +0 -1
  64. package/declarations/lib/path/utils.hashFrom.test.d.ts +0 -2
  65. package/declarations/lib/path/utils.hashFrom.test.d.ts.map +0 -1
  66. package/declarations/lib/path/utils.isRelevantFile.test.d.ts +0 -2
  67. package/declarations/lib/path/utils.isRelevantFile.test.d.ts.map +0 -1
  68. package/declarations/lib/path/utils.paths.test.d.ts +0 -5
  69. package/declarations/lib/path/utils.paths.test.d.ts.map +0 -1
  70. package/declarations/lib/renameClass.d.ts +0 -9
  71. package/declarations/lib/renameClass.d.ts.map +0 -1
  72. package/declarations/lib/request.d.ts +0 -8
  73. package/declarations/lib/request.d.ts.map +0 -1
  74. package/declarations/lib/rewriteHbs.d.ts +0 -17
  75. package/declarations/lib/rewriteHbs.d.ts.map +0 -1
  76. package/declarations/runtime/index.d.ts +0 -8
  77. package/declarations/runtime/index.d.ts.map +0 -1
  78. package/declarations/runtime/test-support.d.ts.map +0 -1
  79. package/dist/cjs/babel-plugin.cjs +0 -176
  80. package/dist/cjs/index.cjs +0 -968
  81. package/dist/cjs/template-plugin.cjs +0 -856
  82. package/src/build/index.js +0 -7
  83. package/src/build/vite.js +0 -3
@@ -1,228 +1,403 @@
1
- // src/lib/path/md5.js
1
+ //#region src/lib/path/md5.js
2
+ /**
3
+ * Add integers, wrapping at 2^32.
4
+ * This uses 16-bit operations internally to work around bugs in interpreters.
5
+ *
6
+ * @param {number} x First integer
7
+ * @param {number} y Second integer
8
+ * @returns {number} Sum
9
+ */
2
10
  function safeAdd(x, y) {
3
- var lsw = (x & 65535) + (y & 65535);
4
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
5
- return msw << 16 | lsw & 65535;
11
+ var lsw = (x & 65535) + (y & 65535);
12
+ return (x >> 16) + (y >> 16) + (lsw >> 16) << 16 | lsw & 65535;
6
13
  }
14
+ /**
15
+ * Bitwise rotate a 32-bit number to the left.
16
+ *
17
+ * @param {number} num 32-bit number
18
+ * @param {number} cnt Rotation count
19
+ * @returns {number} Rotated number
20
+ */
7
21
  function bitRotateLeft(num, cnt) {
8
- return num << cnt | num >>> 32 - cnt;
22
+ return num << cnt | num >>> 32 - cnt;
9
23
  }
24
+ /**
25
+ * Basic operation the algorithm uses.
26
+ *
27
+ * @param {number} q q
28
+ * @param {number} a a
29
+ * @param {number} b b
30
+ * @param {number} x x
31
+ * @param {number} s s
32
+ * @param {number} t t
33
+ * @returns {number} Result
34
+ */
10
35
  function md5cmn(q, a, b, x, s, t) {
11
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
36
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
12
37
  }
38
+ /**
39
+ * Basic operation the algorithm uses.
40
+ *
41
+ * @param {number} a a
42
+ * @param {number} b b
43
+ * @param {number} c c
44
+ * @param {number} d d
45
+ * @param {number} x x
46
+ * @param {number} s s
47
+ * @param {number} t t
48
+ * @returns {number} Result
49
+ */
13
50
  function md5ff(a, b, c, d, x, s, t) {
14
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
51
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
15
52
  }
53
+ /**
54
+ * Basic operation the algorithm uses.
55
+ *
56
+ * @param {number} a a
57
+ * @param {number} b b
58
+ * @param {number} c c
59
+ * @param {number} d d
60
+ * @param {number} x x
61
+ * @param {number} s s
62
+ * @param {number} t t
63
+ * @returns {number} Result
64
+ */
16
65
  function md5gg(a, b, c, d, x, s, t) {
17
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
66
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
18
67
  }
68
+ /**
69
+ * Basic operation the algorithm uses.
70
+ *
71
+ * @param {number} a a
72
+ * @param {number} b b
73
+ * @param {number} c c
74
+ * @param {number} d d
75
+ * @param {number} x x
76
+ * @param {number} s s
77
+ * @param {number} t t
78
+ * @returns {number} Result
79
+ */
19
80
  function md5hh(a, b, c, d, x, s, t) {
20
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
81
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
21
82
  }
83
+ /**
84
+ * Basic operation the algorithm uses.
85
+ *
86
+ * @param {number} a a
87
+ * @param {number} b b
88
+ * @param {number} c c
89
+ * @param {number} d d
90
+ * @param {number} x x
91
+ * @param {number} s s
92
+ * @param {number} t t
93
+ * @returns {number} Result
94
+ */
22
95
  function md5ii(a, b, c, d, x, s, t) {
23
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
96
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
24
97
  }
98
+ /**
99
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
100
+ *
101
+ * @param {Array} x Array of little-endian words
102
+ * @param {number} len Bit length
103
+ * @returns {Array<number>} MD5 Array
104
+ */
25
105
  function binlMD5(x, len) {
26
- x[len >> 5] |= 128 << len % 32;
27
- x[(len + 64 >>> 9 << 4) + 14] = len;
28
- var i;
29
- var olda;
30
- var oldb;
31
- var oldc;
32
- var oldd;
33
- var a = 1732584193;
34
- var b = -271733879;
35
- var c = -1732584194;
36
- var d = 271733878;
37
- for (i = 0; i < x.length; i += 16) {
38
- olda = a;
39
- oldb = b;
40
- oldc = c;
41
- oldd = d;
42
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
43
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
44
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
45
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
46
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
47
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
48
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
49
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
50
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
51
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
52
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
53
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
54
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
55
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
56
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
57
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
58
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
59
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
60
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
61
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
62
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
63
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
64
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
65
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
66
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
67
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
68
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
69
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
70
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
71
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
72
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
73
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
74
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
75
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
76
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
77
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
78
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
79
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
80
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
81
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
82
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
83
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
84
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
85
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
86
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
87
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
88
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
89
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
90
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
91
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
92
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
93
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
94
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
95
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
96
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
97
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
98
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
99
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
100
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
101
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
102
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
103
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
104
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
105
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
106
- a = safeAdd(a, olda);
107
- b = safeAdd(b, oldb);
108
- c = safeAdd(c, oldc);
109
- d = safeAdd(d, oldd);
110
- }
111
- return [a, b, c, d];
106
+ x[len >> 5] |= 128 << len % 32;
107
+ x[(len + 64 >>> 9 << 4) + 14] = len;
108
+ var i;
109
+ var olda;
110
+ var oldb;
111
+ var oldc;
112
+ var oldd;
113
+ var a = 1732584193;
114
+ var b = -271733879;
115
+ var c = -1732584194;
116
+ var d = 271733878;
117
+ for (i = 0; i < x.length; i += 16) {
118
+ olda = a;
119
+ oldb = b;
120
+ oldc = c;
121
+ oldd = d;
122
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
123
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
124
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
125
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
126
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
127
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
128
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
129
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
130
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
131
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
132
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
133
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
134
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
135
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
136
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
137
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
138
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
139
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
140
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
141
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
142
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
143
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
144
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
145
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
146
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
147
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
148
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
149
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
150
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
151
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
152
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
153
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
154
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
155
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
156
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
157
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
158
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
159
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
160
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
161
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
162
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
163
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
164
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
165
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
166
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
167
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
168
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
169
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
170
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
171
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
172
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
173
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
174
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
175
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
176
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
177
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
178
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
179
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
180
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
181
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
182
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
183
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
184
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
185
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
186
+ a = safeAdd(a, olda);
187
+ b = safeAdd(b, oldb);
188
+ c = safeAdd(c, oldc);
189
+ d = safeAdd(d, oldd);
190
+ }
191
+ return [
192
+ a,
193
+ b,
194
+ c,
195
+ d
196
+ ];
112
197
  }
198
+ /**
199
+ * Convert an array of little-endian words to a string
200
+ *
201
+ * @param {Array<number>} input MD5 Array
202
+ * @returns {string} MD5 string
203
+ */
113
204
  function binl2rstr(input) {
114
- var i;
115
- var output = "";
116
- var length32 = input.length * 32;
117
- for (i = 0; i < length32; i += 8) {
118
- output += String.fromCharCode(input[i >> 5] >>> i % 32 & 255);
119
- }
120
- return output;
205
+ var i;
206
+ var output = "";
207
+ var length32 = input.length * 32;
208
+ for (i = 0; i < length32; i += 8) output += String.fromCharCode(input[i >> 5] >>> i % 32 & 255);
209
+ return output;
121
210
  }
211
+ /**
212
+ * Convert a raw string to an array of little-endian words
213
+ * Characters >255 have their high-byte silently ignored.
214
+ *
215
+ * @param {string} input Raw input string
216
+ * @returns {Array<number>} Array of little-endian words
217
+ */
122
218
  function rstr2binl(input) {
123
- var i;
124
- var output = [];
125
- output[(input.length >> 2) - 1] = void 0;
126
- for (i = 0; i < output.length; i += 1) {
127
- output[i] = 0;
128
- }
129
- var length8 = input.length * 8;
130
- for (i = 0; i < length8; i += 8) {
131
- output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << i % 32;
132
- }
133
- return output;
219
+ var i;
220
+ var output = [];
221
+ output[(input.length >> 2) - 1] = void 0;
222
+ for (i = 0; i < output.length; i += 1) output[i] = 0;
223
+ var length8 = input.length * 8;
224
+ for (i = 0; i < length8; i += 8) output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << i % 32;
225
+ return output;
134
226
  }
227
+ /**
228
+ * Calculate the MD5 of a raw string
229
+ *
230
+ * @param {string} s Input string
231
+ * @returns {string} Raw MD5 string
232
+ */
135
233
  function rstrMD5(s) {
136
- return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
234
+ return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
137
235
  }
236
+ /**
237
+ * Calculates the HMAC-MD5 of a key and some data (raw strings)
238
+ *
239
+ * @param {string} key HMAC key
240
+ * @param {string} data Raw input string
241
+ * @returns {string} Raw MD5 string
242
+ */
138
243
  function rstrHMACMD5(key, data) {
139
- var i;
140
- var bkey = rstr2binl(key);
141
- var ipad = [];
142
- var opad = [];
143
- var hash2;
144
- ipad[15] = opad[15] = void 0;
145
- if (bkey.length > 16) {
146
- bkey = binlMD5(bkey, key.length * 8);
147
- }
148
- for (i = 0; i < 16; i += 1) {
149
- ipad[i] = bkey[i] ^ 909522486;
150
- opad[i] = bkey[i] ^ 1549556828;
151
- }
152
- hash2 = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
153
- return binl2rstr(binlMD5(opad.concat(hash2), 512 + 128));
244
+ var i;
245
+ var bkey = rstr2binl(key);
246
+ var ipad = [];
247
+ var opad = [];
248
+ var hash$1;
249
+ ipad[15] = opad[15] = void 0;
250
+ if (bkey.length > 16) bkey = binlMD5(bkey, key.length * 8);
251
+ for (i = 0; i < 16; i += 1) {
252
+ ipad[i] = bkey[i] ^ 909522486;
253
+ opad[i] = bkey[i] ^ 1549556828;
254
+ }
255
+ hash$1 = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
256
+ return binl2rstr(binlMD5(opad.concat(hash$1), 640));
154
257
  }
258
+ /**
259
+ * Convert a raw string to a hex string
260
+ *
261
+ * @param {string} input Raw input string
262
+ * @returns {string} Hex encoded string
263
+ */
155
264
  function rstr2hex(input) {
156
- var hexTab = "0123456789abcdef";
157
- var output = "";
158
- var x;
159
- var i;
160
- for (i = 0; i < input.length; i += 1) {
161
- x = input.charCodeAt(i);
162
- output += hexTab.charAt(x >>> 4 & 15) + hexTab.charAt(x & 15);
163
- }
164
- return output;
265
+ var hexTab = "0123456789abcdef";
266
+ var output = "";
267
+ var x;
268
+ var i;
269
+ for (i = 0; i < input.length; i += 1) {
270
+ x = input.charCodeAt(i);
271
+ output += hexTab.charAt(x >>> 4 & 15) + hexTab.charAt(x & 15);
272
+ }
273
+ return output;
165
274
  }
275
+ /**
276
+ * Encode a string as UTF-8
277
+ *
278
+ * @param {string} input Input string
279
+ * @returns {string} UTF8 string
280
+ */
166
281
  function str2rstrUTF8(input) {
167
- return unescape(encodeURIComponent(input));
282
+ return unescape(encodeURIComponent(input));
168
283
  }
284
+ /**
285
+ * Encodes input string as raw MD5 string
286
+ *
287
+ * @param {string} s Input string
288
+ * @returns {string} Raw MD5 string
289
+ */
169
290
  function rawMD5(s) {
170
- return rstrMD5(str2rstrUTF8(s));
291
+ return rstrMD5(str2rstrUTF8(s));
171
292
  }
293
+ /**
294
+ * Encodes input string as Hex encoded string
295
+ *
296
+ * @param {string} s Input string
297
+ * @returns {string} Hex encoded string
298
+ */
172
299
  function hexMD5(s) {
173
- return rstr2hex(rawMD5(s));
300
+ return rstr2hex(rawMD5(s));
174
301
  }
302
+ /**
303
+ * Calculates the raw HMAC-MD5 for the given key and data
304
+ *
305
+ * @param {string} k HMAC key
306
+ * @param {string} d Input string
307
+ * @returns {string} Raw MD5 string
308
+ */
175
309
  function rawHMACMD5(k, d) {
176
- return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
310
+ return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
177
311
  }
312
+ /**
313
+ * Calculates the Hex encoded HMAC-MD5 for the given key and data
314
+ *
315
+ * @param {string} k HMAC key
316
+ * @param {string} d Input string
317
+ * @returns {string} Raw MD5 string
318
+ */
178
319
  function hexHMACMD5(k, d) {
179
- return rstr2hex(rawHMACMD5(k, d));
320
+ return rstr2hex(rawHMACMD5(k, d));
180
321
  }
322
+ /**
323
+ * Calculates MD5 value for a given string.
324
+ * If a key is provided, calculates the HMAC-MD5 value.
325
+ * Returns a Hex encoded string unless the raw argument is given.
326
+ *
327
+ * @param {string} string Input string
328
+ * @param {string} [key] HMAC key
329
+ * @param {boolean} [raw] Raw output switch
330
+ * @returns {string} MD5 output
331
+ */
181
332
  function md5(string, key, raw) {
182
- if (!key) {
183
- if (!raw) {
184
- return hexMD5(string);
185
- }
186
- return rawMD5(string);
187
- }
188
- if (!raw) {
189
- return hexHMACMD5(key, string);
190
- }
191
- return rawHMACMD5(key, string);
333
+ if (!key) {
334
+ if (!raw) return hexMD5(string);
335
+ return rawMD5(string);
336
+ }
337
+ if (!raw) return hexHMACMD5(key, string);
338
+ return rawHMACMD5(key, string);
192
339
  }
193
340
 
194
- // src/lib/path/hash-from-module-path.js
341
+ //#endregion
342
+ //#region src/lib/path/hash-from-module-path.js
343
+ /**
344
+ * The intent of this function is to generate the suffix/postfix for the
345
+ * css classes, based on the module-scoped path name.
346
+ *
347
+ * for example,
348
+ * hash('my-app/components/foo')
349
+ * instead of
350
+ * hash('app/components/foo')
351
+ *
352
+ * (unless your app name is 'app')
353
+ *
354
+ * @param {string} modulePath
355
+ * @returns {string}
356
+ */
195
357
  function hash(modulePath) {
196
- return "e" + md5(modulePath).substring(0, 8);
358
+ return "e" + md5(modulePath).substring(0, 8);
359
+ }
360
+ if (import.meta.vitest) {
361
+ const { it, expect } = import.meta.vitest;
362
+ it("should return a string", function() {
363
+ expect(hash("foo.css")).to.be.a("string");
364
+ });
365
+ it("should return a string starting with \"e\"", function() {
366
+ expect(hash("foo.css")).to.match(/^e/);
367
+ });
368
+ it("should return a string of length 9", function() {
369
+ expect(hash("foo.css")).to.have.lengthOf(9);
370
+ });
197
371
  }
198
372
 
199
- // src/lib/renameClass.js
373
+ //#endregion
374
+ //#region src/lib/renameClass.js
375
+ /**
376
+ *
377
+ * @param {string} className
378
+ * @param {string} postfix
379
+ * @param {Set<string>} [classesInCss]
380
+ * @returns
381
+ */
200
382
  function renameClass(className, postfix, classesInCss) {
201
- const classes = className.split(/\s+/);
202
- const renamedClasses = classes.filter((c) => c).map((c) => c.trim()).map((c) => {
203
- if (!classesInCss || classesInCss.has(c)) {
204
- if (c.endsWith(postfix)) return c;
205
- return c + "_" + postfix;
206
- }
207
- return c;
208
- }).join(" ");
209
- const renamedWithPreservedSpaces = className.replace(
210
- className.trimStart().trimEnd(),
211
- renamedClasses
212
- );
213
- return renamedWithPreservedSpaces;
383
+ const renamedClasses = className.split(/\s+/).filter((c) => c).map((c) => c.trim()).map((c) => {
384
+ if (!classesInCss || classesInCss.has(c)) {
385
+ if (c.endsWith(postfix)) return c;
386
+ return c + "_" + postfix;
387
+ }
388
+ return c;
389
+ }).join(" ");
390
+ return className.replace(className.trimStart().trimEnd(), renamedClasses);
214
391
  }
215
392
 
216
- // src/runtime/test-support.ts
393
+ //#endregion
394
+ //#region src/runtime/test-support.ts
217
395
  function scopedClass(...args) {
218
- if (args.length === 1) {
219
- return hash(args[0]);
220
- }
221
- let [className, modulePath] = args;
222
- const postfix = hash(modulePath);
223
- return renameClass(className, postfix);
224
- }
225
- export {
226
- scopedClass
227
- };
228
- //# sourceMappingURL=test-support.js.map
396
+ if (args.length === 1) return hash(args[0]);
397
+ let [className, modulePath] = args;
398
+ return renameClass(className, hash(modulePath));
399
+ }
400
+
401
+ //#endregion
402
+ export { scopedClass };
403
+ //# sourceMappingURL=test-support.js.map