@rstest/core 0.6.1 → 0.6.3

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/dist/0~463.js ADDED
@@ -0,0 +1,331 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ const LIVING_KEYS = [
4
+ 'DOMException',
5
+ 'URL',
6
+ 'URLSearchParams',
7
+ 'EventTarget',
8
+ 'NamedNodeMap',
9
+ 'Node',
10
+ 'Attr',
11
+ 'Element',
12
+ 'DocumentFragment',
13
+ 'DOMImplementation',
14
+ 'Document',
15
+ 'XMLDocument',
16
+ 'CharacterData',
17
+ 'Text',
18
+ 'CDATASection',
19
+ 'ProcessingInstruction',
20
+ 'Comment',
21
+ 'DocumentType',
22
+ 'NodeList',
23
+ 'RadioNodeList',
24
+ 'HTMLCollection',
25
+ 'HTMLOptionsCollection',
26
+ 'DOMStringMap',
27
+ 'DOMTokenList',
28
+ 'StyleSheetList',
29
+ 'HTMLElement',
30
+ 'HTMLHeadElement',
31
+ 'HTMLTitleElement',
32
+ 'HTMLBaseElement',
33
+ 'HTMLLinkElement',
34
+ 'HTMLMetaElement',
35
+ 'HTMLStyleElement',
36
+ 'HTMLBodyElement',
37
+ 'HTMLHeadingElement',
38
+ 'HTMLParagraphElement',
39
+ 'HTMLHRElement',
40
+ 'HTMLPreElement',
41
+ 'HTMLUListElement',
42
+ 'HTMLOListElement',
43
+ 'HTMLLIElement',
44
+ 'HTMLMenuElement',
45
+ 'HTMLDListElement',
46
+ 'HTMLDivElement',
47
+ 'HTMLAnchorElement',
48
+ 'HTMLAreaElement',
49
+ 'HTMLBRElement',
50
+ 'HTMLButtonElement',
51
+ 'HTMLCanvasElement',
52
+ 'HTMLDataElement',
53
+ 'HTMLDataListElement',
54
+ 'HTMLDetailsElement',
55
+ 'HTMLDialogElement',
56
+ 'HTMLDirectoryElement',
57
+ 'HTMLFieldSetElement',
58
+ 'HTMLFontElement',
59
+ 'HTMLFormElement',
60
+ 'HTMLHtmlElement',
61
+ 'HTMLImageElement',
62
+ 'HTMLInputElement',
63
+ 'HTMLLabelElement',
64
+ 'HTMLLegendElement',
65
+ 'HTMLMapElement',
66
+ 'HTMLMarqueeElement',
67
+ 'HTMLMediaElement',
68
+ 'HTMLMeterElement',
69
+ 'HTMLModElement',
70
+ 'HTMLOptGroupElement',
71
+ 'HTMLOptionElement',
72
+ 'HTMLOutputElement',
73
+ 'HTMLPictureElement',
74
+ 'HTMLProgressElement',
75
+ 'HTMLQuoteElement',
76
+ 'HTMLScriptElement',
77
+ 'HTMLSelectElement',
78
+ 'HTMLSlotElement',
79
+ 'HTMLSourceElement',
80
+ 'HTMLSpanElement',
81
+ 'HTMLTableCaptionElement',
82
+ 'HTMLTableCellElement',
83
+ 'HTMLTableColElement',
84
+ 'HTMLTableElement',
85
+ 'HTMLTimeElement',
86
+ 'HTMLTableRowElement',
87
+ 'HTMLTableSectionElement',
88
+ 'HTMLTemplateElement',
89
+ 'HTMLTextAreaElement',
90
+ 'HTMLUnknownElement',
91
+ 'HTMLFrameElement',
92
+ 'HTMLFrameSetElement',
93
+ 'HTMLIFrameElement',
94
+ 'HTMLEmbedElement',
95
+ 'HTMLObjectElement',
96
+ 'HTMLParamElement',
97
+ 'HTMLVideoElement',
98
+ 'HTMLAudioElement',
99
+ 'HTMLTrackElement',
100
+ 'HTMLFormControlsCollection',
101
+ 'SVGElement',
102
+ 'SVGGraphicsElement',
103
+ 'SVGSVGElement',
104
+ 'SVGGElement',
105
+ 'SVGDefsElement',
106
+ 'SVGDescElement',
107
+ 'SVGMetadataElement',
108
+ 'SVGTitleElement',
109
+ 'SVGSymbolElement',
110
+ 'SVGSwitchElement',
111
+ 'SVGAnimatedPreserveAspectRatio',
112
+ 'SVGAnimatedRect',
113
+ 'SVGAnimatedString',
114
+ 'SVGNumber',
115
+ 'SVGPreserveAspectRatio',
116
+ 'SVGRect',
117
+ 'SVGStringList',
118
+ 'Event',
119
+ 'BeforeUnloadEvent',
120
+ 'BlobEvent',
121
+ 'CloseEvent',
122
+ 'CustomEvent',
123
+ 'MessageEvent',
124
+ 'ErrorEvent',
125
+ 'HashChangeEvent',
126
+ 'PopStateEvent',
127
+ 'StorageEvent',
128
+ 'ProgressEvent',
129
+ 'PageTransitionEvent',
130
+ 'SubmitEvent',
131
+ 'UIEvent',
132
+ 'FocusEvent',
133
+ 'InputEvent',
134
+ 'MouseEvent',
135
+ 'KeyboardEvent',
136
+ 'TouchEvent',
137
+ 'CompositionEvent',
138
+ 'WheelEvent',
139
+ 'BarProp',
140
+ 'External',
141
+ 'Location',
142
+ 'History',
143
+ 'Screen',
144
+ 'Performance',
145
+ 'Navigator',
146
+ 'Crypto',
147
+ 'PluginArray',
148
+ 'MimeTypeArray',
149
+ 'Plugin',
150
+ 'MimeType',
151
+ 'FileReader',
152
+ 'Blob',
153
+ 'File',
154
+ 'FileList',
155
+ 'ValidityState',
156
+ 'DOMParser',
157
+ 'XMLSerializer',
158
+ 'FormData',
159
+ 'XMLHttpRequestEventTarget',
160
+ 'XMLHttpRequestUpload',
161
+ 'XMLHttpRequest',
162
+ 'WebSocket',
163
+ 'NodeFilter',
164
+ 'NodeIterator',
165
+ 'TreeWalker',
166
+ 'AbstractRange',
167
+ 'Range',
168
+ 'StaticRange',
169
+ 'Selection',
170
+ 'Storage',
171
+ 'CustomElementRegistry',
172
+ 'ElementInternals',
173
+ 'ShadowRoot',
174
+ 'MutationObserver',
175
+ 'MutationRecord',
176
+ 'Headers',
177
+ 'AbortController',
178
+ 'AbortSignal',
179
+ 'Uint8Array',
180
+ 'Uint16Array',
181
+ 'Uint32Array',
182
+ 'Uint8ClampedArray',
183
+ 'Int8Array',
184
+ 'Int16Array',
185
+ 'Int32Array',
186
+ 'Float32Array',
187
+ 'Float64Array',
188
+ 'ArrayBuffer',
189
+ 'DeviceMotionEventAcceleration',
190
+ 'DeviceMotionEventRotationRate',
191
+ 'DOMRectReadOnly',
192
+ 'DOMRect',
193
+ 'Image',
194
+ 'Audio',
195
+ 'Option',
196
+ 'CSS'
197
+ ];
198
+ const OTHER_KEYS = [
199
+ 'addEventListener',
200
+ 'alert',
201
+ 'blur',
202
+ 'cancelAnimationFrame',
203
+ 'close',
204
+ 'confirm',
205
+ 'createPopup',
206
+ 'dispatchEvent',
207
+ 'document',
208
+ 'focus',
209
+ 'frames',
210
+ 'getComputedStyle',
211
+ 'history',
212
+ 'innerHeight',
213
+ 'innerWidth',
214
+ 'length',
215
+ 'location',
216
+ 'matchMedia',
217
+ 'moveBy',
218
+ 'moveTo',
219
+ 'name',
220
+ 'navigator',
221
+ 'open',
222
+ 'outerHeight',
223
+ 'outerWidth',
224
+ 'pageXOffset',
225
+ 'pageYOffset',
226
+ 'parent',
227
+ 'postMessage',
228
+ 'print',
229
+ 'prompt',
230
+ 'removeEventListener',
231
+ 'requestAnimationFrame',
232
+ 'resizeBy',
233
+ 'resizeTo',
234
+ 'screen',
235
+ 'screenLeft',
236
+ 'screenTop',
237
+ 'screenX',
238
+ 'screenY',
239
+ 'scroll',
240
+ 'scrollBy',
241
+ 'scrollLeft',
242
+ 'scrollTo',
243
+ 'scrollTop',
244
+ 'scrollX',
245
+ 'scrollY',
246
+ 'self',
247
+ 'stop',
248
+ 'top',
249
+ 'Window',
250
+ 'window'
251
+ ];
252
+ const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
253
+ const SKIP_KEYS = [
254
+ 'window',
255
+ 'self',
256
+ 'top',
257
+ 'parent'
258
+ ];
259
+ function getWindowKeys(global, win, additionalKeys = []) {
260
+ const keysArray = [
261
+ ...additionalKeys,
262
+ ...KEYS
263
+ ];
264
+ return new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k)=>{
265
+ if (SKIP_KEYS.includes(k)) return false;
266
+ if (k in global) return keysArray.includes(k);
267
+ return true;
268
+ }));
269
+ }
270
+ function isClassLike(name) {
271
+ return name[0] === name[0]?.toUpperCase();
272
+ }
273
+ function installGlobal(global, win, options = {}) {
274
+ const { bindFunctions = true } = options || {};
275
+ const keys = getWindowKeys(global, win, options.additionalKeys);
276
+ const originals = new Map();
277
+ const overrides = new Map();
278
+ for (const key of keys){
279
+ const boundFunction = bindFunctions && 'function' == typeof win[key] && !isClassLike(key) && win[key].bind(win);
280
+ if (key in global) originals.set(key, global[key]);
281
+ Object.defineProperty(global, key, {
282
+ get () {
283
+ if (overrides.has(key)) return overrides.get(key);
284
+ if (boundFunction) return boundFunction;
285
+ return win[key];
286
+ },
287
+ set (v) {
288
+ overrides.set(key, v);
289
+ },
290
+ configurable: true
291
+ });
292
+ }
293
+ global.window = global;
294
+ global.self = global;
295
+ global.top = global;
296
+ global.parent = global;
297
+ if (global.global) global.global = global;
298
+ if (global.document?.defaultView) Object.defineProperty(global.document, 'defaultView', {
299
+ get: ()=>global,
300
+ enumerable: true,
301
+ configurable: true
302
+ });
303
+ for (const k of SKIP_KEYS)keys.add(k);
304
+ return ()=>{
305
+ for (const key of keys)delete global[key];
306
+ originals.forEach((v, k)=>{
307
+ global[k] = v;
308
+ });
309
+ };
310
+ }
311
+ function addDefaultErrorHandler(window) {
312
+ let userErrorListenerCount = 0;
313
+ const throwUnhandledError = (e)=>{
314
+ if (0 === userErrorListenerCount && null != e.error) process.emit('uncaughtException', e.error);
315
+ };
316
+ const addEventListener = window.addEventListener.bind(window);
317
+ const removeEventListener = window.removeEventListener.bind(window);
318
+ window.addEventListener('error', throwUnhandledError);
319
+ window.addEventListener = function(...args) {
320
+ if ('error' === args[0]) userErrorListenerCount++;
321
+ return addEventListener.apply(this, args);
322
+ };
323
+ window.removeEventListener = function(...args) {
324
+ if ('error' === args[0] && userErrorListenerCount) userErrorListenerCount--;
325
+ return removeEventListener.apply(this, args);
326
+ };
327
+ return ()=>{
328
+ window.removeEventListener('error', throwUnhandledError);
329
+ };
330
+ }
331
+ export { addDefaultErrorHandler, installGlobal };