@rspack-debug/test-tools 1.3.14

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 (262) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +17 -0
  3. package/dist/case/builtin.d.ts +1 -0
  4. package/dist/case/builtin.js +39 -0
  5. package/dist/case/cache.d.ts +2 -0
  6. package/dist/case/cache.js +34 -0
  7. package/dist/case/compiler.d.ts +6 -0
  8. package/dist/case/compiler.js +17 -0
  9. package/dist/case/config.d.ts +3 -0
  10. package/dist/case/config.js +39 -0
  11. package/dist/case/defaults.d.ts +6 -0
  12. package/dist/case/defaults.js +39 -0
  13. package/dist/case/diagnostic.d.ts +1 -0
  14. package/dist/case/diagnostic.js +29 -0
  15. package/dist/case/diff.d.ts +3 -0
  16. package/dist/case/diff.js +126 -0
  17. package/dist/case/error.d.ts +6 -0
  18. package/dist/case/error.js +21 -0
  19. package/dist/case/hash.d.ts +3 -0
  20. package/dist/case/hash.js +30 -0
  21. package/dist/case/hook.d.ts +6 -0
  22. package/dist/case/hook.js +35 -0
  23. package/dist/case/hot-step.d.ts +2 -0
  24. package/dist/case/hot-step.js +32 -0
  25. package/dist/case/hot.d.ts +2 -0
  26. package/dist/case/hot.js +32 -0
  27. package/dist/case/index.d.ts +19 -0
  28. package/dist/case/index.js +35 -0
  29. package/dist/case/new-incremental.d.ts +6 -0
  30. package/dist/case/new-incremental.js +100 -0
  31. package/dist/case/normal.d.ts +1 -0
  32. package/dist/case/normal.js +29 -0
  33. package/dist/case/serial.d.ts +3 -0
  34. package/dist/case/serial.js +34 -0
  35. package/dist/case/stats-api.d.ts +6 -0
  36. package/dist/case/stats-api.js +21 -0
  37. package/dist/case/stats-output.d.ts +1 -0
  38. package/dist/case/stats-output.js +22 -0
  39. package/dist/case/treeshaking.d.ts +1 -0
  40. package/dist/case/treeshaking.js +23 -0
  41. package/dist/case/watch.d.ts +1 -0
  42. package/dist/case/watch.js +53 -0
  43. package/dist/compare/comparator.d.ts +17 -0
  44. package/dist/compare/comparator.js +52 -0
  45. package/dist/compare/compare.d.ts +17 -0
  46. package/dist/compare/compare.js +175 -0
  47. package/dist/compare/format-code.d.ts +16 -0
  48. package/dist/compare/format-code.js +239 -0
  49. package/dist/compare/index.d.ts +5 -0
  50. package/dist/compare/index.js +21 -0
  51. package/dist/compare/replace-module-argument.d.ts +1 -0
  52. package/dist/compare/replace-module-argument.js +8 -0
  53. package/dist/compare/replace-runtime-module-name.d.ts +1 -0
  54. package/dist/compare/replace-runtime-module-name.js +71 -0
  55. package/dist/compiler.d.ts +28 -0
  56. package/dist/compiler.js +111 -0
  57. package/dist/helper/directory.d.ts +12 -0
  58. package/dist/helper/directory.js +81 -0
  59. package/dist/helper/expect/diff.d.ts +3 -0
  60. package/dist/helper/expect/diff.js +21 -0
  61. package/dist/helper/expect/error.d.ts +5 -0
  62. package/dist/helper/expect/error.js +51 -0
  63. package/dist/helper/expect/placeholder.d.ts +1 -0
  64. package/dist/helper/expect/placeholder.js +41 -0
  65. package/dist/helper/expect/rspack.d.ts +3 -0
  66. package/dist/helper/expect/rspack.js +14 -0
  67. package/dist/helper/expect/to-be-typeof.d.ts +4 -0
  68. package/dist/helper/expect/to-be-typeof.js +12 -0
  69. package/dist/helper/expect/to-end-with.d.ts +4 -0
  70. package/dist/helper/expect/to-end-with.js +11 -0
  71. package/dist/helper/expect/to-match-file-snapshot.d.ts +23 -0
  72. package/dist/helper/expect/to-match-file-snapshot.js +108 -0
  73. package/dist/helper/hot-update/index.d.ts +1 -0
  74. package/dist/helper/hot-update/index.js +5 -0
  75. package/dist/helper/hot-update/loader.d.ts +1 -0
  76. package/dist/helper/hot-update/loader.js +32 -0
  77. package/dist/helper/hot-update/plugin.d.ts +17 -0
  78. package/dist/helper/hot-update/plugin.js +133 -0
  79. package/dist/helper/index.d.ts +7 -0
  80. package/dist/helper/index.js +23 -0
  81. package/dist/helper/legacy/EventSourceForNode.d.ts +8 -0
  82. package/dist/helper/legacy/EventSourceForNode.js +40 -0
  83. package/dist/helper/legacy/FakeDocument.d.ts +54 -0
  84. package/dist/helper/legacy/FakeDocument.js +278 -0
  85. package/dist/helper/legacy/asModule.d.ts +3 -0
  86. package/dist/helper/legacy/asModule.js +25 -0
  87. package/dist/helper/legacy/captureStdio.d.ts +8 -0
  88. package/dist/helper/legacy/captureStdio.js +32 -0
  89. package/dist/helper/legacy/checkArrayExpectation.d.ts +2 -0
  90. package/dist/helper/legacy/checkArrayExpectation.js +111 -0
  91. package/dist/helper/legacy/copyDiff.d.ts +2 -0
  92. package/dist/helper/legacy/copyDiff.js +33 -0
  93. package/dist/helper/legacy/createFakeWorker.d.ts +13 -0
  94. package/dist/helper/legacy/createFakeWorker.js +80 -0
  95. package/dist/helper/legacy/createLazyTestEnv.d.ts +10 -0
  96. package/dist/helper/legacy/createLazyTestEnv.js +116 -0
  97. package/dist/helper/legacy/createLogger.d.ts +23 -0
  98. package/dist/helper/legacy/createLogger.js +20 -0
  99. package/dist/helper/legacy/currentScript.d.ts +6 -0
  100. package/dist/helper/legacy/currentScript.js +8 -0
  101. package/dist/helper/legacy/fakeSystem.d.ts +9 -0
  102. package/dist/helper/legacy/fakeSystem.js +124 -0
  103. package/dist/helper/legacy/parseResource.d.ts +6 -0
  104. package/dist/helper/legacy/parseResource.js +15 -0
  105. package/dist/helper/legacy/supportsImportFn.d.ts +1 -0
  106. package/dist/helper/legacy/supportsImportFn.js +15 -0
  107. package/dist/helper/legacy/supportsWorker.d.ts +2 -0
  108. package/dist/helper/legacy/supportsWorker.js +17 -0
  109. package/dist/helper/legacy/urlToRelativePath.d.ts +2 -0
  110. package/dist/helper/legacy/urlToRelativePath.js +7 -0
  111. package/dist/helper/legacy/walkCssTokens.d.ts +40 -0
  112. package/dist/helper/legacy/walkCssTokens.js +761 -0
  113. package/dist/helper/legacy/warmup-webpack.d.ts +1 -0
  114. package/dist/helper/legacy/warmup-webpack.js +26 -0
  115. package/dist/helper/loaders/hot-update.d.ts +1 -0
  116. package/dist/helper/loaders/hot-update.js +40 -0
  117. package/dist/helper/parse-modules.d.ts +7 -0
  118. package/dist/helper/parse-modules.js +73 -0
  119. package/dist/helper/plugins/hot-update.d.ts +7 -0
  120. package/dist/helper/plugins/hot-update.js +40 -0
  121. package/dist/helper/plugins/index.d.ts +1 -0
  122. package/dist/helper/plugins/index.js +17 -0
  123. package/dist/helper/read-config-file.d.ts +2 -0
  124. package/dist/helper/read-config-file.js +13 -0
  125. package/dist/helper/serializers.d.ts +2 -0
  126. package/dist/helper/serializers.js +52 -0
  127. package/dist/helper/setup-env.d.ts +1 -0
  128. package/dist/helper/setup-env.js +80 -0
  129. package/dist/helper/setup-expect.d.ts +1 -0
  130. package/dist/helper/setup-expect.js +16 -0
  131. package/dist/helper/update-snapshot.d.ts +1 -0
  132. package/dist/helper/update-snapshot.js +6 -0
  133. package/dist/helper/util/checkSourceMap.d.ts +1 -0
  134. package/dist/helper/util/checkSourceMap.js +96 -0
  135. package/dist/helper/util/checkStats.d.ts +2 -0
  136. package/dist/helper/util/checkStats.js +43 -0
  137. package/dist/helper/util/currentWatchStep.d.ts +1 -0
  138. package/dist/helper/util/currentWatchStep.js +2 -0
  139. package/dist/helper/util/expectWarningFactory.d.ts +2 -0
  140. package/dist/helper/util/expectWarningFactory.js +21 -0
  141. package/dist/helper/util/filterUtil.d.ts +8 -0
  142. package/dist/helper/util/filterUtil.js +50 -0
  143. package/dist/helper/util/identifier.d.ts +76 -0
  144. package/dist/helper/util/identifier.js +339 -0
  145. package/dist/helper/util/replaceMitteDiagnostic.d.ts +2 -0
  146. package/dist/helper/util/replaceMitteDiagnostic.js +17 -0
  147. package/dist/helper/win.d.ts +1 -0
  148. package/dist/helper/win.js +10 -0
  149. package/dist/index.d.ts +12 -0
  150. package/dist/index.js +28 -0
  151. package/dist/plugin/index.d.ts +4 -0
  152. package/dist/plugin/index.js +20 -0
  153. package/dist/plugin/lazy-compilation-test-plugin.d.ts +4 -0
  154. package/dist/plugin/lazy-compilation-test-plugin.js +67 -0
  155. package/dist/plugin/rspack-diff-config-plugin.d.ts +7 -0
  156. package/dist/plugin/rspack-diff-config-plugin.js +42 -0
  157. package/dist/plugin/webpack-diff-config-plugin.d.ts +7 -0
  158. package/dist/plugin/webpack-diff-config-plugin.js +41 -0
  159. package/dist/plugin/webpack-module-placeholder-plugin.d.ts +3 -0
  160. package/dist/plugin/webpack-module-placeholder-plugin.js +107 -0
  161. package/dist/processor/basic.d.ts +24 -0
  162. package/dist/processor/basic.js +146 -0
  163. package/dist/processor/builtin.d.ts +9 -0
  164. package/dist/processor/builtin.js +171 -0
  165. package/dist/processor/cache.d.ts +20 -0
  166. package/dist/processor/cache.js +127 -0
  167. package/dist/processor/config.d.ts +11 -0
  168. package/dist/processor/config.js +81 -0
  169. package/dist/processor/defaults.d.ts +30 -0
  170. package/dist/processor/defaults.js +72 -0
  171. package/dist/processor/diagnostic.d.ts +15 -0
  172. package/dist/processor/diagnostic.js +102 -0
  173. package/dist/processor/diff.d.ts +30 -0
  174. package/dist/processor/diff.js +140 -0
  175. package/dist/processor/error.d.ts +23 -0
  176. package/dist/processor/error.js +95 -0
  177. package/dist/processor/hash.d.ts +10 -0
  178. package/dist/processor/hash.js +63 -0
  179. package/dist/processor/hook.d.ts +44 -0
  180. package/dist/processor/hook.js +204 -0
  181. package/dist/processor/hot-new-incremental.d.ts +14 -0
  182. package/dist/processor/hot-new-incremental.js +43 -0
  183. package/dist/processor/hot-step.d.ts +18 -0
  184. package/dist/processor/hot-step.js +299 -0
  185. package/dist/processor/hot.d.ts +17 -0
  186. package/dist/processor/hot.js +138 -0
  187. package/dist/processor/index.d.ts +20 -0
  188. package/dist/processor/index.js +36 -0
  189. package/dist/processor/multi.d.ts +17 -0
  190. package/dist/processor/multi.js +73 -0
  191. package/dist/processor/normal.d.ts +12 -0
  192. package/dist/processor/normal.js +150 -0
  193. package/dist/processor/simple.d.ts +23 -0
  194. package/dist/processor/simple.js +49 -0
  195. package/dist/processor/snapshot.d.ts +12 -0
  196. package/dist/processor/snapshot.js +62 -0
  197. package/dist/processor/stats-api.d.ts +18 -0
  198. package/dist/processor/stats-api.js +48 -0
  199. package/dist/processor/stats.d.ts +18 -0
  200. package/dist/processor/stats.js +206 -0
  201. package/dist/processor/treeshaking.d.ts +10 -0
  202. package/dist/processor/treeshaking.js +33 -0
  203. package/dist/processor/watch.d.ts +29 -0
  204. package/dist/processor/watch.js +234 -0
  205. package/dist/reporter/diff-html.d.ts +15 -0
  206. package/dist/reporter/diff-html.js +69 -0
  207. package/dist/reporter/diff-stats.d.ts +24 -0
  208. package/dist/reporter/diff-stats.js +131 -0
  209. package/dist/reporter/index.d.ts +2 -0
  210. package/dist/reporter/index.js +18 -0
  211. package/dist/runner/basic.d.ts +10 -0
  212. package/dist/runner/basic.js +63 -0
  213. package/dist/runner/cache.d.ts +5 -0
  214. package/dist/runner/cache.js +90 -0
  215. package/dist/runner/hot-step.d.ts +5 -0
  216. package/dist/runner/hot-step.js +87 -0
  217. package/dist/runner/hot.d.ts +5 -0
  218. package/dist/runner/hot.js +83 -0
  219. package/dist/runner/index.d.ts +9 -0
  220. package/dist/runner/index.js +25 -0
  221. package/dist/runner/multiple.d.ts +11 -0
  222. package/dist/runner/multiple.js +38 -0
  223. package/dist/runner/normal.d.ts +5 -0
  224. package/dist/runner/normal.js +20 -0
  225. package/dist/runner/runner/basic.d.ts +30 -0
  226. package/dist/runner/runner/basic.js +107 -0
  227. package/dist/runner/runner/cjs.d.ts +14 -0
  228. package/dist/runner/runner/cjs.js +151 -0
  229. package/dist/runner/runner/esm.d.ts +7 -0
  230. package/dist/runner/runner/esm.js +125 -0
  231. package/dist/runner/runner/index.d.ts +8 -0
  232. package/dist/runner/runner/index.js +24 -0
  233. package/dist/runner/runner/normal.d.ts +9 -0
  234. package/dist/runner/runner/normal.js +23 -0
  235. package/dist/runner/runner/watch.d.ts +16 -0
  236. package/dist/runner/runner/watch.js +27 -0
  237. package/dist/runner/runner/web/fake.d.ts +18 -0
  238. package/dist/runner/runner/web/fake.js +143 -0
  239. package/dist/runner/runner/web/jsdom.d.ts +26 -0
  240. package/dist/runner/runner/web/jsdom.js +219 -0
  241. package/dist/runner/runner/web.d.ts +15 -0
  242. package/dist/runner/runner/web.js +32 -0
  243. package/dist/runner/type.d.ts +42 -0
  244. package/dist/runner/type.js +9 -0
  245. package/dist/runner/watch.d.ts +7 -0
  246. package/dist/runner/watch.js +60 -0
  247. package/dist/test/context.d.ts +26 -0
  248. package/dist/test/context.js +108 -0
  249. package/dist/test/creator.d.ts +46 -0
  250. package/dist/test/creator.js +310 -0
  251. package/dist/test/simple.d.ts +5 -0
  252. package/dist/test/simple.js +43 -0
  253. package/dist/test/tester.d.ts +17 -0
  254. package/dist/test/tester.js +88 -0
  255. package/dist/type.d.ts +168 -0
  256. package/dist/type.js +22 -0
  257. package/jest.d.ts +25 -0
  258. package/package.json +116 -0
  259. package/template/diff.bundle.css +1 -0
  260. package/template/diff.bundle.js +144 -0
  261. package/template/diff.html +14 -0
  262. package/template/editor.worker.js +1 -0
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FakeSheet = exports.FakeElement = void 0;
4
+ // @ts-nocheck
5
+ const fs = require("node:fs");
6
+ const path = require("node:path");
7
+ const getPropertyValue = function (property) {
8
+ return this[property];
9
+ };
10
+ class FakeDocument {
11
+ constructor(basePath, options = {}) {
12
+ this.head = this.createElement("head");
13
+ this.body = this.createElement("body");
14
+ this.baseURI = "https://test.cases/path/index.html";
15
+ this._elementsByTagName = new Map([
16
+ ["head", [this.head]],
17
+ ["body", [this.body]]
18
+ ]);
19
+ this._basePath = basePath;
20
+ this.currentScript = undefined;
21
+ this._options = options || {};
22
+ }
23
+ createElement(type) {
24
+ return new FakeElement(this, type, this._basePath);
25
+ }
26
+ _onElementAttached(element) {
27
+ const type = element._type;
28
+ let list = this._elementsByTagName.get(type);
29
+ if (list === undefined) {
30
+ list = [];
31
+ this._elementsByTagName.set(type, list);
32
+ }
33
+ list.push(element);
34
+ }
35
+ _onElementRemoved(element) {
36
+ const type = element._type;
37
+ const list = this._elementsByTagName.get(type);
38
+ const idx = list.indexOf(element);
39
+ list.splice(idx, 1);
40
+ }
41
+ getElementsByTagName(name) {
42
+ return this._elementsByTagName.get(name) || [];
43
+ }
44
+ querySelectorAll(name) {
45
+ return this._elementsByTagName.get(name) || [];
46
+ }
47
+ getComputedStyle(element) {
48
+ const style = { getPropertyValue };
49
+ const links = this.getElementsByTagName("link");
50
+ for (const link of links) {
51
+ for (const rule of link.sheet.cssRules) {
52
+ if (rule.selectorText === element._type) {
53
+ Object.assign(style, rule.style);
54
+ }
55
+ }
56
+ }
57
+ return style;
58
+ }
59
+ }
60
+ exports.default = FakeDocument;
61
+ class FakeElement {
62
+ constructor(document, type, basePath) {
63
+ this._document = document;
64
+ this._type = type;
65
+ this._basePath = basePath;
66
+ this._children = [];
67
+ this._attributes = Object.create(null);
68
+ this._src = undefined;
69
+ this._href = undefined;
70
+ this.rel = undefined;
71
+ this.parentNode = undefined;
72
+ this.sheet = type === "link" ? new FakeSheet(this, basePath) : undefined;
73
+ }
74
+ cloneNode() {
75
+ return new FakeElement(this._document, this._type, this._basePath);
76
+ }
77
+ addEventListener() { }
78
+ insertBefore(node, before) {
79
+ this._document._onElementAttached(node);
80
+ node.parentNode = this;
81
+ this._children.unshift(node);
82
+ Promise.resolve().then(() => {
83
+ if (node.onload) {
84
+ node.onload({ type: "load", target: node });
85
+ }
86
+ });
87
+ }
88
+ appendChild(node) {
89
+ this._document._onElementAttached(node);
90
+ this._children.push(node);
91
+ node.parentNode = this;
92
+ if (node._type === "link") {
93
+ setTimeout(() => {
94
+ if (node.onload)
95
+ node.onload({ type: "load", target: node });
96
+ }, 100);
97
+ }
98
+ else if (node._type === "script") {
99
+ Promise.resolve().then(() => {
100
+ if (typeof this._document._options.onScript === "function") {
101
+ this._document._options.onScript(node);
102
+ }
103
+ if (node.onload) {
104
+ node.onload({
105
+ type: "load",
106
+ target: node
107
+ });
108
+ }
109
+ });
110
+ }
111
+ else {
112
+ if (node.onload) {
113
+ node.onload({ type: "load", target: node });
114
+ }
115
+ }
116
+ }
117
+ removeChild(node) {
118
+ const idx = this._children.indexOf(node);
119
+ if (idx >= 0) {
120
+ this._children.splice(idx, 1);
121
+ this._document._onElementRemoved(node);
122
+ node.parentNode = undefined;
123
+ }
124
+ }
125
+ setAttribute(name, value) {
126
+ if (this._type === "link" && name === "href") {
127
+ this.href(value);
128
+ }
129
+ else {
130
+ this._attributes[name] = value;
131
+ }
132
+ }
133
+ removeAttribute(name) {
134
+ delete this._attributes[name];
135
+ }
136
+ getAttribute(name) {
137
+ if (this._type === "link" && name === "href") {
138
+ return this.href;
139
+ }
140
+ return this._attributes[name];
141
+ }
142
+ _toRealUrl(value) {
143
+ if (/^\//.test(value)) {
144
+ return `https://test.cases${value}`;
145
+ }
146
+ else if (/^\.\.\//.test(value)) {
147
+ return `https://test.cases${value.slice(2)}`;
148
+ }
149
+ else if (/^\.\//.test(value)) {
150
+ return `https://test.cases/path${value.slice(1)}`;
151
+ }
152
+ else if (/^\w+:\/\//.test(value)) {
153
+ return value;
154
+ }
155
+ else if (/^\/\//.test(value)) {
156
+ return `https:${value}`;
157
+ }
158
+ else {
159
+ return `https://test.cases/path/${value}`;
160
+ }
161
+ }
162
+ set src(value) {
163
+ if (this._type === "script") {
164
+ this._src = this._toRealUrl(value);
165
+ }
166
+ }
167
+ get children() {
168
+ return this._children;
169
+ }
170
+ get src() {
171
+ return this._src;
172
+ }
173
+ set href(value) {
174
+ if (this._type === "link") {
175
+ this._href = this._toRealUrl(value);
176
+ }
177
+ }
178
+ get href() {
179
+ return this._href;
180
+ }
181
+ }
182
+ exports.FakeElement = FakeElement;
183
+ class FakeSheet {
184
+ constructor(element, basePath) {
185
+ this._element = element;
186
+ this._basePath = basePath;
187
+ this.cachedCss = undefined;
188
+ this.cachedCssRules = undefined;
189
+ }
190
+ get css() {
191
+ if (this.cachedCss) {
192
+ return this.cachedCss;
193
+ }
194
+ let css = fs.readFileSync(path.resolve(this._basePath, this._element.href
195
+ .replace(/^https:\/\/test\.cases\/path\//, "")
196
+ .replace(/^https:\/\/example\.com\//, "")), "utf-8");
197
+ css = css.replace(/@import url\("([^"]+)"\);/g, (match, url) => {
198
+ if (!/^https:\/\/test\.cases\/path\//.test(url)) {
199
+ return `@import url("${url}");`;
200
+ }
201
+ if (url.startsWith("#")) {
202
+ return url;
203
+ }
204
+ return fs.readFileSync(path.resolve(this._basePath, url.replace(/^https:\/\/test\.cases\/path\//, "")), "utf-8");
205
+ });
206
+ this.cachedCss = css;
207
+ return css;
208
+ }
209
+ get cssRules() {
210
+ if (this.cachedCssRules) {
211
+ return this.cachedCssRules;
212
+ }
213
+ const walkCssTokens = require("./walkCssTokens");
214
+ const rules = [];
215
+ let currentRule = { getPropertyValue };
216
+ let selector = undefined;
217
+ let last = 0;
218
+ const processDeclaration = str => {
219
+ const colon = str.indexOf(":");
220
+ if (colon > 0) {
221
+ const property = str.slice(0, colon).trim();
222
+ const value = str.slice(colon + 1);
223
+ currentRule[property] = value;
224
+ }
225
+ };
226
+ const filepath = /file:\/\//.test(this._element.href)
227
+ ? new URL(this._element.href)
228
+ : path.resolve(this._basePath, this._element.href
229
+ .replace(/^https:\/\/test\.cases\/path\//, "")
230
+ .replace(/^https:\/\/example\.com\/public\/path\//, "")
231
+ .replace(/^https:\/\/example\.com\//, ""));
232
+ let css = fs.readFileSync(filepath.replace(/\?hmr=\d*/, ""), "utf-8");
233
+ css = css.replace(/@import url\("([^"]+)"\);/g, (match, url) => {
234
+ if (!/^https:\/\/test\.cases\/path\//.test(url)) {
235
+ return url;
236
+ }
237
+ if (url.startsWith("#")) {
238
+ return url;
239
+ }
240
+ return fs.readFileSync(path.resolve(this._basePath, url.replace(/^https:\/\/test\.cases\/path\//, "")), "utf-8");
241
+ })
242
+ .replace(/\/\*[\s\S]*?\*\//g, '')
243
+ .replace("//", "");
244
+ walkCssTokens(css, {
245
+ isSelector() {
246
+ return selector === undefined;
247
+ },
248
+ leftCurlyBracket(source, start, end) {
249
+ if (selector === undefined) {
250
+ selector = source.slice(last, start).trim();
251
+ last = end;
252
+ }
253
+ return end;
254
+ },
255
+ rightCurlyBracket(source, start, end) {
256
+ processDeclaration(source.slice(last, start));
257
+ rules.push({
258
+ selectorText: selector,
259
+ style: currentRule,
260
+ // hack cssText, css hmr needs this fields to detect changes
261
+ cssText: css
262
+ });
263
+ last = end;
264
+ selector = undefined;
265
+ currentRule = { getPropertyValue };
266
+ return end;
267
+ },
268
+ semicolon(source, start, end) {
269
+ processDeclaration(source.slice(last, start));
270
+ last = end;
271
+ return end;
272
+ }
273
+ });
274
+ this.cachedCssRules = rules;
275
+ return rules;
276
+ }
277
+ }
278
+ exports.FakeSheet = FakeSheet;
@@ -0,0 +1,3 @@
1
+ declare function _exports(something: any, context: any, unlinked: any): Promise<vm.Module>;
2
+ export = _exports;
3
+ import vm = require("node:vm");
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ const vm = require("node:vm");
4
+ const SYNTHETIC_MODULES_STORE = "__SYNTHETIC_MODULES_STORE";
5
+ module.exports = async (something, context, unlinked) => {
6
+ if (something instanceof (vm.Module || /* node.js 10 */ vm.SourceTextModule)) {
7
+ return something;
8
+ }
9
+ context[SYNTHETIC_MODULES_STORE] = context[SYNTHETIC_MODULES_STORE] || [];
10
+ const i = context[SYNTHETIC_MODULES_STORE].length;
11
+ context[SYNTHETIC_MODULES_STORE].push(something);
12
+ const code = [...new Set(["default", ...Object.keys(something)])]
13
+ .map(name => `const _${name} = ${SYNTHETIC_MODULES_STORE}[${i}]${name === "default" ? "" : `[${JSON.stringify(name)}]`}; export { _${name} as ${name}};`)
14
+ .join("\n");
15
+ const m = new vm.SourceTextModule(code, {
16
+ context
17
+ });
18
+ if (unlinked)
19
+ return m;
20
+ await m.link(() => { });
21
+ if (m.instantiate)
22
+ m.instantiate();
23
+ await m.evaluate();
24
+ return m;
25
+ };
@@ -0,0 +1,8 @@
1
+ declare function _exports(stdio: any, tty: any): {
2
+ data: any[];
3
+ reset: () => never[];
4
+ toString: () => string;
5
+ toStringRaw: () => string;
6
+ restore(): void;
7
+ };
8
+ export = _exports;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ const { stripVTControlCharacters: stripAnsi } = require("node:util");
4
+ module.exports = (stdio, tty) => {
5
+ let logs = [];
6
+ const write = stdio.write;
7
+ const isTTY = stdio.isTTY;
8
+ stdio.write = str => {
9
+ logs.push(str);
10
+ };
11
+ if (tty !== undefined)
12
+ stdio.isTTY = tty;
13
+ return {
14
+ data: logs,
15
+ reset: () => (logs = []),
16
+ toString: () => {
17
+ return stripAnsi(logs.join("")).replace(/\([^)]+\) (\[[^\]]+\]\s*)?(Deprecation|Experimental)Warning.+(\n\(Use .node.+\))?(\n(\s|BREAKING CHANGE).*)*(\n\s+at .*)*\n?/g, "");
18
+ },
19
+ toStringRaw: () => {
20
+ return logs.join("");
21
+ },
22
+ restore() {
23
+ stdio.write = write;
24
+ stdio.isTTY = isTTY;
25
+ delete require.cache[require.resolve("../../")];
26
+ // delete require.cache[
27
+ // require.resolve("../../lib/node/NodeEnvironmentPlugin")
28
+ // ];
29
+ // delete require.cache[require.resolve("../../lib/node/nodeConsole")];
30
+ }
31
+ };
32
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(testDirectory: any, object: any, kind: any, filename: any, upperCaseKind: any, done: any): Promise<true | undefined>;
2
+ export = _exports;
@@ -0,0 +1,111 @@
1
+ // @ts-nocheck
2
+ "use strict";
3
+ const fs = require("graceful-fs");
4
+ const path = require("node:path");
5
+ const check = (expected, actual) => {
6
+ if (expected instanceof RegExp) {
7
+ expected = { message: expected };
8
+ }
9
+ if (Array.isArray(expected)) {
10
+ return expected.every(e => check(e, actual));
11
+ }
12
+ return Object.keys(expected).every(key => {
13
+ let value = actual[key];
14
+ if (typeof value === "object") {
15
+ value = JSON.stringify(value);
16
+ }
17
+ return expected[key].test(value);
18
+ });
19
+ };
20
+ const explain = object => {
21
+ if (object instanceof RegExp) {
22
+ object = { message: object };
23
+ }
24
+ return Object.keys(object)
25
+ .map(key => {
26
+ let value = object[key];
27
+ if (typeof value === "object" && !(value instanceof RegExp)) {
28
+ value = JSON.stringify(value);
29
+ }
30
+ let msg = `${key} = ${value}`;
31
+ if (key !== "stack" && key !== "details" && msg.length > 600)
32
+ msg = msg.slice(0, 597) + "...";
33
+ return msg;
34
+ })
35
+ .join("; ");
36
+ };
37
+ const diffItems = (actual, expected, kind) => {
38
+ const tooMuch = actual.slice();
39
+ const missing = expected.slice();
40
+ for (let i = 0; i < missing.length; i++) {
41
+ const current = missing[i];
42
+ for (let j = 0; j < tooMuch.length; j++) {
43
+ if (check(current, tooMuch[j])) {
44
+ tooMuch.splice(j, 1);
45
+ missing.splice(i, 1);
46
+ i--;
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ const diff = [];
52
+ if (missing.length > 0) {
53
+ diff.push(`The following expected ${kind}s are missing:
54
+ ${missing.map(item => `${explain(item)}`).join("\n\n")}`);
55
+ }
56
+ if (tooMuch.length > 0) {
57
+ diff.push(`The following ${kind}s are unexpected:
58
+ ${tooMuch.map(item => `${explain(item)}`).join("\n\n")}`);
59
+ }
60
+ return diff.join("\n\n");
61
+ };
62
+ module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, done) {
63
+ const usePromise = typeof done === "function";
64
+ done = typeof done === "function" ? done : error => {
65
+ throw error;
66
+ };
67
+ let array = object[`${kind}s`];
68
+ if (Array.isArray(array)) {
69
+ if (kind === "warning") {
70
+ array = array.filter(item => !/from Terser/.test(item));
71
+ }
72
+ }
73
+ if (fs.existsSync(path.join(testDirectory, `${filename}.js`))) {
74
+ // CHANGE: added file for sorting messages in multi-thread environment
75
+ if (fs.existsSync(path.join(testDirectory, `${filename}-sort.js`))) {
76
+ const sorter = require(path.join(testDirectory, `${filename}-sort.js`));
77
+ array = sorter(array);
78
+ }
79
+ const expectedFilename = path.join(testDirectory, `${filename}.js`);
80
+ const expected = require(expectedFilename);
81
+ const diff = diffItems(array, expected, kind);
82
+ if (expected.length < array.length) {
83
+ done(new Error(`More ${kind}s (${array.length} instead of ${expected.length}) while compiling than expected:\n\n${diff}\n\nCheck expected ${kind}s: ${expectedFilename}`));
84
+ return true;
85
+ }
86
+ if (expected.length > array.length) {
87
+ done(new Error(`Less ${kind}s (${array.length} instead of ${expected.length}) while compiling than expected:\n\n${diff}\n\nCheck expected ${kind}s: ${expectedFilename}`));
88
+ return true;
89
+ }
90
+ for (let i = 0; i < array.length; i++) {
91
+ if (Array.isArray(expected[i])) {
92
+ for (let j = 0; j < expected[i].length; j++) {
93
+ if (!check(expected[i][j], array[i])) {
94
+ done(new Error(`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[i][j])}`));
95
+ return true;
96
+ }
97
+ }
98
+ }
99
+ else if (!check(expected[i], array[i])) {
100
+ done(new Error(`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[i])}`));
101
+ return true;
102
+ }
103
+ }
104
+ }
105
+ else if (array.length > 0) {
106
+ done(new Error(`${upperCaseKind}s while compiling:\n\n${array
107
+ .map(explain)
108
+ .join("\n\n")}`));
109
+ return true;
110
+ }
111
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(src: any, dest: any, initial: any): void;
2
+ export = _exports;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+ const { rimrafSync } = require("rimraf");
6
+ module.exports = function copyDiff(src, dest, initial) {
7
+ fs.mkdirSync(dest, { recursive: true });
8
+ const files = fs.readdirSync(src);
9
+ for (const filename of files) {
10
+ const srcFile = path.join(src, filename);
11
+ const destFile = path.join(dest, filename);
12
+ const directory = fs.statSync(srcFile).isDirectory();
13
+ if (directory) {
14
+ copyDiff(srcFile, destFile, initial);
15
+ }
16
+ else {
17
+ const content = fs.readFileSync(srcFile);
18
+ if (/^DELETE\s*$/.test(content.toString("utf-8"))) {
19
+ fs.unlinkSync(destFile);
20
+ }
21
+ else if (/^DELETE_DIRECTORY\s*$/.test(content.toString("utf-8"))) {
22
+ rimrafSync(destFile);
23
+ }
24
+ else {
25
+ fs.writeFileSync(destFile, content);
26
+ if (initial) {
27
+ const longTimeAgo = Date.now() - 1000 * 60 * 60 * 24;
28
+ fs.utimesSync(destFile, Date.now() - longTimeAgo, Date.now() - longTimeAgo);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ };
@@ -0,0 +1,13 @@
1
+ declare function _exports(env: any, { outputDirectory }: {
2
+ outputDirectory: any;
3
+ }): {
4
+ new (url: any, options?: {}): {
5
+ url: any;
6
+ worker: import("worker_threads").Worker;
7
+ _onmessage: ((data: any) => void) | undefined;
8
+ onmessage: any;
9
+ postMessage(data: any): void;
10
+ terminate(): Promise<number>;
11
+ };
12
+ };
13
+ export = _exports;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ const path = require("node:path");
4
+ module.exports = (env, { outputDirectory }) => class Worker {
5
+ constructor(url, options = {}) {
6
+ env.expect(url).toBeInstanceOf(URL);
7
+ env.expect(url.origin).toBe("https://test.cases");
8
+ env.expect(url.pathname.startsWith("/path/")).toBe(true);
9
+ this.url = url;
10
+ const file = url.pathname.slice(6);
11
+ const workerBootstrap = `
12
+ const { parentPort } = require("worker_threads");
13
+ const { URL } = require("url");
14
+ const path = require("path");
15
+ const fs = require("fs");
16
+ global.self = global;
17
+ self.URL = URL;
18
+ self.location = new URL(${JSON.stringify(url.toString())});
19
+ const urlToPath = url => {
20
+ if(url.startsWith("https://test.cases/path/")) url = url.slice(24);
21
+ return path.resolve(${JSON.stringify(outputDirectory)}, \`./\${url}\`);
22
+ };
23
+ self.importScripts = url => {
24
+ ${options.type === "module"
25
+ ? `throw new Error("importScripts is not supported in module workers")`
26
+ : "require(urlToPath(url))"};
27
+ };
28
+ self.fetch = async url => {
29
+ try {
30
+ const buffer = await new Promise((resolve, reject) =>
31
+ fs.readFile(urlToPath(url), (err, b) =>
32
+ err ? reject(err) : resolve(b)
33
+ )
34
+ );
35
+ return {
36
+ status: 200,
37
+ ok: true,
38
+ json: async () => JSON.parse(buffer.toString("utf-8"))
39
+ };
40
+ } catch(err) {
41
+ if(err.code === "ENOENT") {
42
+ return {
43
+ status: 404,
44
+ ok: false
45
+ };
46
+ }
47
+ throw err;
48
+ }
49
+ };
50
+ parentPort.on("message", data => {
51
+ if(self.onmessage) self.onmessage({
52
+ data
53
+ });
54
+ });
55
+ self.postMessage = data => {
56
+ parentPort.postMessage(data);
57
+ };
58
+ require(${JSON.stringify(path.resolve(outputDirectory, file))});
59
+ `;
60
+ this.worker = new (require("node:worker_threads").Worker)(workerBootstrap, {
61
+ eval: true
62
+ });
63
+ this._onmessage = undefined;
64
+ }
65
+ set onmessage(value) {
66
+ if (this._onmessage)
67
+ this.worker.off("message", this._onmessage);
68
+ this.worker.on("message", (this._onmessage = data => {
69
+ value({
70
+ data
71
+ });
72
+ }));
73
+ }
74
+ postMessage(data) {
75
+ this.worker.postMessage(data);
76
+ }
77
+ terminate() {
78
+ return this.worker.terminate();
79
+ }
80
+ };
@@ -0,0 +1,10 @@
1
+ declare function _exports(globalTimeout?: number, nameSuffix?: string): {
2
+ setDefaultTimeout(time: any): void;
3
+ getNumberOfTests(): number;
4
+ it(...args: any[]): void;
5
+ beforeEach(...args: any[]): void;
6
+ afterEach(...args: any[]): void;
7
+ expect: jest.Expect;
8
+ jest: typeof jest;
9
+ };
10
+ export = _exports;