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.
- package/README.md +203 -47
- package/dist/cjs/all-Du43cBa9.cjs +1308 -0
- package/dist/cjs/all.cjs +3 -0
- package/dist/cjs/babel.cjs +9 -0
- package/dist/cjs/rollup.cjs +8 -0
- package/dist/cjs/vite.cjs +8 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +12 -8
- package/dist/runtime/index.js.map +1 -7
- package/{declarations → dist}/runtime/test-support.d.ts +5 -2
- package/dist/runtime/test-support.d.ts.map +1 -0
- package/dist/runtime/test-support.js +357 -182
- package/dist/runtime/test-support.js.map +1 -7
- package/package.json +21 -24
- package/src/build/babel-plugin.js +4 -1
- package/src/build/public-exports/all.js +10 -0
- package/src/build/public-exports/babel.js +5 -0
- package/src/build/public-exports/rollup.js +3 -0
- package/src/build/public-exports/vite.js +3 -0
- package/src/build/scoped-css-unplugin.js +10 -33
- package/src/build/template-plugin.js +9 -19
- package/src/build/template-plugin.test.ts +108 -19
- package/src/build/unplugin-colocated.js +103 -0
- package/src/build/unplugin-inline.js +71 -0
- package/src/lib/css/rewrite.js +8 -8
- package/src/lib/css/rewrite.test.ts +69 -128
- package/src/lib/path/const.js +19 -0
- package/src/lib/path/hash-from-absolute-path.js +3 -2
- package/src/lib/path/template-transform-paths.js +3 -2
- package/src/lib/path/utils.appPath.test.ts +2 -2
- package/src/lib/path/utils.hashFrom.test.ts +2 -2
- package/src/lib/path/utils.js +63 -20
- package/src/lib/request.js +58 -33
- package/src/runtime/index.ts +1 -1
- package/declarations/build/template-plugin.d.ts +0 -7
- package/declarations/build/template-plugin.d.ts.map +0 -1
- package/declarations/build/template-plugin.test.d.ts +0 -2
- package/declarations/build/template-plugin.test.d.ts.map +0 -1
- package/declarations/lib/css/rewrite.d.ts +0 -2
- package/declarations/lib/css/rewrite.d.ts.map +0 -1
- package/declarations/lib/css/rewrite.test.d.ts +0 -2
- package/declarations/lib/css/rewrite.test.d.ts.map +0 -1
- package/declarations/lib/css/utils.d.ts +0 -29
- package/declarations/lib/css/utils.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-absolute-path.d.ts +0 -3
- package/declarations/lib/path/hash-from-absolute-path.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-absolute-path.test.d.ts +0 -2
- package/declarations/lib/path/hash-from-absolute-path.test.d.ts.map +0 -1
- package/declarations/lib/path/hash-from-module-path.d.ts +0 -31
- package/declarations/lib/path/hash-from-module-path.d.ts.map +0 -1
- package/declarations/lib/path/md5.d.ts +0 -12
- package/declarations/lib/path/md5.d.ts.map +0 -1
- package/declarations/lib/path/template-transform-paths.d.ts +0 -11
- package/declarations/lib/path/template-transform-paths.d.ts.map +0 -1
- package/declarations/lib/path/template-transform-paths.test.d.ts +0 -2
- package/declarations/lib/path/template-transform-paths.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.appPath.test.d.ts +0 -2
- package/declarations/lib/path/utils.appPath.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.d.ts +0 -94
- package/declarations/lib/path/utils.d.ts.map +0 -1
- package/declarations/lib/path/utils.findWorkspacePath.test.d.ts +0 -2
- package/declarations/lib/path/utils.findWorkspacePath.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.hashFrom.test.d.ts +0 -2
- package/declarations/lib/path/utils.hashFrom.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.isRelevantFile.test.d.ts +0 -2
- package/declarations/lib/path/utils.isRelevantFile.test.d.ts.map +0 -1
- package/declarations/lib/path/utils.paths.test.d.ts +0 -5
- package/declarations/lib/path/utils.paths.test.d.ts.map +0 -1
- package/declarations/lib/renameClass.d.ts +0 -9
- package/declarations/lib/renameClass.d.ts.map +0 -1
- package/declarations/lib/request.d.ts +0 -8
- package/declarations/lib/request.d.ts.map +0 -1
- package/declarations/lib/rewriteHbs.d.ts +0 -17
- package/declarations/lib/rewriteHbs.d.ts.map +0 -1
- package/declarations/runtime/index.d.ts +0 -8
- package/declarations/runtime/index.d.ts.map +0 -1
- package/declarations/runtime/test-support.d.ts.map +0 -1
- package/dist/cjs/babel-plugin.cjs +0 -176
- package/dist/cjs/index.cjs +0 -968
- package/dist/cjs/template-plugin.cjs +0 -856
- package/src/build/index.js +0 -7
- package/src/build/vite.js +0 -3
|
@@ -1,228 +1,403 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/runtime/test-support.ts
|
|
217
395
|
function scopedClass(...args) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
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
|