@lynx-js/react 0.106.4 → 0.107.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 (56) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/package.json +15 -2
  3. package/refresh/.turbo/turbo-build.log +1 -1
  4. package/refresh/package.json +1 -1
  5. package/runtime/jsx-dev-runtime/index.d.ts +12 -0
  6. package/runtime/jsx-runtime/index.d.ts +12 -0
  7. package/runtime/lib/index.js +7 -4
  8. package/runtime/lib/index.js.map +1 -1
  9. package/runtime/lib/lifecycle/patch/commit.d.ts +7 -1
  10. package/runtime/lib/lifecycle/patch/commit.js +44 -38
  11. package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
  12. package/runtime/lib/lifecycle/patch/updateMainThread.js +6 -4
  13. package/runtime/lib/lifecycle/patch/updateMainThread.js.map +1 -1
  14. package/runtime/lib/list.d.ts +13 -6
  15. package/runtime/lib/list.js.map +1 -1
  16. package/runtime/lib/lynx/calledByNative.js +2 -2
  17. package/runtime/lib/lynx/calledByNative.js.map +1 -1
  18. package/runtime/lib/lynx/component.js +1 -1
  19. package/runtime/lib/lynx/component.js.map +1 -1
  20. package/runtime/lib/lynx/performance.d.ts +24 -14
  21. package/runtime/lib/lynx/performance.js +42 -23
  22. package/runtime/lib/lynx/performance.js.map +1 -1
  23. package/runtime/lib/lynx/runWithForce.d.ts +1 -0
  24. package/runtime/lib/lynx/runWithForce.js +45 -0
  25. package/runtime/lib/lynx/runWithForce.js.map +1 -0
  26. package/runtime/lib/lynx/tt.d.ts +2 -1
  27. package/runtime/lib/lynx/tt.js +33 -61
  28. package/runtime/lib/lynx/tt.js.map +1 -1
  29. package/runtime/lib/lynx.d.ts +1 -0
  30. package/runtime/lib/lynx.js +1 -0
  31. package/runtime/lib/lynx.js.map +1 -1
  32. package/runtime/src/index.ts +7 -4
  33. package/runtime/src/lifecycle/patch/commit.ts +54 -41
  34. package/runtime/src/lifecycle/patch/updateMainThread.ts +6 -4
  35. package/runtime/src/list.ts +18 -10
  36. package/runtime/src/lynx/calledByNative.ts +2 -2
  37. package/runtime/src/lynx/component.ts +1 -1
  38. package/runtime/src/lynx/performance.ts +48 -22
  39. package/runtime/src/lynx/runWithForce.ts +52 -0
  40. package/runtime/src/lynx/tt.ts +47 -70
  41. package/runtime/src/lynx.ts +1 -0
  42. package/testing-library/README.md +70 -0
  43. package/testing-library/dist/env/vitest.js +548 -0
  44. package/testing-library/dist/index.d.ts +1504 -0
  45. package/testing-library/dist/index.js +12 -0
  46. package/testing-library/dist/pure.js +14729 -0
  47. package/testing-library/dist/pure.js.LICENSE.txt +17 -0
  48. package/testing-library/dist/vitest-global-setup.js +115 -0
  49. package/testing-library/dist/vitest.config.js +90 -0
  50. package/testing-library/types/entry.d.ts +257 -0
  51. package/testing-library/types/index.d.ts +15 -0
  52. package/testing-library/types/pure.d.ts +2 -0
  53. package/testing-library/types/vitest-config.d.ts +12 -0
  54. package/transform/dist/wasm.cjs +1 -1
  55. package/types/react.d.ts +31 -0
  56. package/LICENSE +0 -202
@@ -0,0 +1,548 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_vitest_environments_fd1a84b1__ from "vitest/environments";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_events__ from "events";
3
+ function util_define(object, properties) {
4
+ for (const name of Object.getOwnPropertyNames(properties)){
5
+ const propDesc = Object.getOwnPropertyDescriptor(properties, name);
6
+ Object.defineProperty(object, name, propDesc);
7
+ }
8
+ }
9
+ function installOwnProperties(globalThis1) {
10
+ util_define(globalThis1, {
11
+ get globalThis () {
12
+ return globalThis1._globalProxy;
13
+ }
14
+ });
15
+ }
16
+ const createGlobalThis = ()=>{
17
+ const globalThis1 = {};
18
+ globalThis1._globalObject = globalThis1._globalProxy = globalThis1;
19
+ installOwnProperties(globalThis1);
20
+ return globalThis1;
21
+ };
22
+ function _define_property(obj, key, value) {
23
+ if (key in obj) Object.defineProperty(obj, key, {
24
+ value: value,
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true
28
+ });
29
+ else obj[key] = value;
30
+ return obj;
31
+ }
32
+ const initElementTree = ()=>{
33
+ let uiSignNext = 0;
34
+ const uniqueId2Element = new Map();
35
+ return new class {
36
+ countElement(element, parentComponentUniqueId) {
37
+ element.$$uiSign = uiSignNext++;
38
+ uniqueId2Element.set(element.$$uiSign, element);
39
+ element.parentComponentUniqueId = parentComponentUniqueId;
40
+ }
41
+ __CreatePage(_tag, parentComponentUniqueId) {
42
+ const page = this.__CreateElement('page', parentComponentUniqueId);
43
+ this.root = page;
44
+ lynxEnv.jsdom.window.document.body.appendChild(page);
45
+ return page;
46
+ }
47
+ __CreateRawText(text) {
48
+ const element = lynxEnv.jsdom.window.document.createTextNode(text);
49
+ this.countElement(element, 0);
50
+ return element;
51
+ }
52
+ __GetElementUniqueID(e) {
53
+ return e.$$uiSign;
54
+ }
55
+ __SetClasses(e, cls) {
56
+ e.className = cls;
57
+ }
58
+ __CreateElement(tag, parentComponentUniqueId) {
59
+ if ('raw-text' === tag) return this.__CreateRawText('');
60
+ const element = lynxEnv.jsdom.window.document.createElement(tag);
61
+ this.countElement(element, parentComponentUniqueId);
62
+ return element;
63
+ }
64
+ __CreateView(parentComponentUniqueId) {
65
+ return this.__CreateElement('view', parentComponentUniqueId);
66
+ }
67
+ __CreateScrollView(parentComponentUniqueId) {
68
+ return this.__CreateElement('scroll-view', parentComponentUniqueId);
69
+ }
70
+ __FirstElement(e) {
71
+ return e.firstChild;
72
+ }
73
+ __CreateText(parentComponentUniqueId) {
74
+ return this.__CreateElement('text', parentComponentUniqueId);
75
+ }
76
+ __CreateImage(parentComponentUniqueId) {
77
+ return this.__CreateElement('image', parentComponentUniqueId);
78
+ }
79
+ __CreateWrapperElement(parentComponentUniqueId) {
80
+ return this.__CreateElement('wrapper', parentComponentUniqueId);
81
+ }
82
+ __AddInlineStyle(e, key, value) {
83
+ e.style[key] = value;
84
+ }
85
+ __AppendElement(parent, child) {
86
+ parent.appendChild(child);
87
+ }
88
+ __SetCSSId(e, id, entryName) {
89
+ const cssId = `${entryName ?? '__Card__'}:${id}`;
90
+ if (Array.isArray(e)) e.forEach((item)=>{
91
+ item.cssId = cssId;
92
+ });
93
+ else e.cssId = cssId;
94
+ }
95
+ __SetAttribute(e, key, value) {
96
+ if ('style' === key || 'class' === key || 'className' === key || 'key' === key || 'id' === key || 'ref' === key || /^data-/.exec(key) || /^(bind|catch|global-bind|capture-bind|capture-catch)[A-Za-z]/.exec(key)) throw new Error(`Cannot use __SetAttribute for "${key}"`);
97
+ if ('update-list-info' === key) {
98
+ let listInfoStr = e.getAttribute(key);
99
+ let listInfo = listInfoStr ? JSON.parse(listInfoStr) : [];
100
+ listInfo.push(value);
101
+ e.setAttribute(key, JSON.stringify(listInfo));
102
+ return;
103
+ }
104
+ if ('text' === key) {
105
+ e.textContent = value;
106
+ return;
107
+ }
108
+ if (null === value) return void e.removeAttribute(key);
109
+ if ('string' == typeof value) return void e.setAttribute(key, value);
110
+ e.setAttribute(key, JSON.stringify(value));
111
+ }
112
+ __AddEvent(e, eventType, eventName, eventHandler) {
113
+ var _e_eventMap;
114
+ if (null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`]) {
115
+ e.removeEventListener(`${eventType}:${eventName}`, e.eventMap[`${eventType}:${eventName}`]);
116
+ delete e.eventMap[`${eventType}:${eventName}`];
117
+ }
118
+ if (void 0 === eventHandler) return;
119
+ if ('string' != typeof eventHandler && void 0 === eventHandler['type']) throw new Error(`event must be string, but got ${typeof eventHandler}`);
120
+ const listener = (evt)=>{
121
+ if ('object' == typeof eventHandler && 'worklet' === eventHandler['type']) {
122
+ const isBackground = !__MAIN_THREAD__;
123
+ globalThis.lynxEnv.switchToMainThread();
124
+ runWorklet(eventHandler.value, [
125
+ Object.assign({}, evt)
126
+ ]);
127
+ if (isBackground) globalThis.lynxEnv.switchToBackgroundThread();
128
+ } else {
129
+ if ('catchEvent' === eventType || 'capture-catch' === eventType) evt.stopPropagation();
130
+ globalThis.lynxCoreInject.tt.publishEvent(eventHandler, evt);
131
+ }
132
+ };
133
+ e.eventMap = e.eventMap ?? {};
134
+ e.eventMap[`${eventType}:${eventName}`] = listener;
135
+ e.addEventListener(`${eventType}:${eventName}`, listener, {
136
+ capture: 'capture-bind' === eventType || 'capture-catch' === eventType
137
+ });
138
+ }
139
+ __GetEvent(e, eventType, eventName) {
140
+ var _e_eventMap;
141
+ const jsFunction = null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`];
142
+ if (void 0 !== jsFunction) return {
143
+ type: eventType,
144
+ name: eventName,
145
+ jsFunction
146
+ };
147
+ }
148
+ __SetID(e, id) {
149
+ e.id = id;
150
+ }
151
+ __SetInlineStyles(e, styles) {
152
+ if ('string' == typeof styles) e.style.cssText = styles;
153
+ else Object.assign(e.style, styles);
154
+ }
155
+ __AddDataset(e, key, value) {
156
+ e.dataset[key] = value;
157
+ }
158
+ __SetDataset(e, dataset) {
159
+ Object.assign(e.dataset, dataset);
160
+ }
161
+ __SetGestureDetector(e, id, type, config, relationMap) {
162
+ e.gesture = {
163
+ id,
164
+ type,
165
+ config,
166
+ relationMap
167
+ };
168
+ }
169
+ __GetDataset(e) {
170
+ return e.dataset;
171
+ }
172
+ __RemoveElement(parent, child) {
173
+ let ch = parent.firstChild;
174
+ while(ch)if (ch === child) {
175
+ parent.removeChild(ch);
176
+ break;
177
+ }
178
+ }
179
+ __InsertElementBefore(parent, child, ref) {
180
+ if (void 0 === ref) parent.appendChild(child);
181
+ else parent.insertBefore(child, ref);
182
+ }
183
+ __ReplaceElement(newElement, oldElement) {
184
+ const parent = oldElement.parentNode;
185
+ if (!parent) throw new Error('unreachable');
186
+ parent.replaceChild(newElement, oldElement);
187
+ }
188
+ __FlushElementTree() {}
189
+ __UpdateListComponents(_list, _components) {}
190
+ __UpdateListCallbacks(list, componentAtIndex, enqueueComponent) {
191
+ Object.defineProperties(list, {
192
+ componentAtIndex: {
193
+ enumerable: false,
194
+ configurable: true,
195
+ value: componentAtIndex
196
+ },
197
+ enqueueComponent: {
198
+ enumerable: false,
199
+ configurable: true,
200
+ value: enqueueComponent
201
+ }
202
+ });
203
+ }
204
+ __CreateList(parentComponentUniqueId, componentAtIndex, enqueueComponent) {
205
+ const e = this.__CreateElement('list', parentComponentUniqueId);
206
+ Object.defineProperties(e, {
207
+ componentAtIndex: {
208
+ enumerable: false,
209
+ configurable: true,
210
+ value: componentAtIndex
211
+ },
212
+ enqueueComponent: {
213
+ enumerable: false,
214
+ configurable: true,
215
+ value: enqueueComponent
216
+ }
217
+ });
218
+ return e;
219
+ }
220
+ __GetTag(ele) {
221
+ return ele.nodeName;
222
+ }
223
+ __GetAttributeByName(ele, name) {
224
+ return ele.getAttribute(name);
225
+ }
226
+ clear() {
227
+ this.root = void 0;
228
+ }
229
+ toTree() {
230
+ return this.root;
231
+ }
232
+ enterListItemAtIndex(e, index, ...args) {
233
+ const { componentAtIndex, $$uiSign } = e;
234
+ return componentAtIndex(e, $$uiSign, index, ...args);
235
+ }
236
+ leaveListItem(e, uiSign) {
237
+ const { enqueueComponent, $$uiSign } = e;
238
+ enqueueComponent(e, $$uiSign, uiSign);
239
+ }
240
+ toJSON() {
241
+ return this.toTree();
242
+ }
243
+ __GetElementByUniqueId(uniqueId) {
244
+ return uniqueId2Element.get(uniqueId);
245
+ }
246
+ constructor(){
247
+ _define_property(this, "root", void 0);
248
+ }
249
+ }();
250
+ };
251
+ function dist_define_property(obj, key, value) {
252
+ if (key in obj) Object.defineProperty(obj, key, {
253
+ value: value,
254
+ enumerable: true,
255
+ configurable: true,
256
+ writable: true
257
+ });
258
+ else obj[key] = value;
259
+ return obj;
260
+ }
261
+ function __injectElementApi(target) {
262
+ const elementTree = initElementTree();
263
+ target.elementTree = elementTree;
264
+ if (void 0 === target) target = globalThis;
265
+ for (const k of Object.getOwnPropertyNames(elementTree.constructor.prototype))if (k.startsWith('__')) target[k] = elementTree[k].bind(elementTree);
266
+ target.$kTemplateAssembler = {};
267
+ target.registerDataProcessor = ()=>{
268
+ console.error('registerDataProcessor is not implemented');
269
+ };
270
+ target.__OnLifecycleEvent = (...args)=>{
271
+ const isMainThread = __MAIN_THREAD__;
272
+ globalThis.lynxEnv.switchToBackgroundThread();
273
+ globalThis.lynxCoreInject.tt.OnLifecycleEvent(...args);
274
+ if (isMainThread) globalThis.lynxEnv.switchToMainThread();
275
+ };
276
+ target._ReportError = ()=>{};
277
+ }
278
+ function createPolyfills() {
279
+ const app = {
280
+ callLepusMethod: (...rLynxChange)=>{
281
+ const isBackground = !__MAIN_THREAD__;
282
+ globalThis.lynxEnv.switchToMainThread();
283
+ globalThis[rLynxChange[0]](rLynxChange[1]);
284
+ globalThis.lynxEnv.switchToBackgroundThread();
285
+ rLynxChange[2]();
286
+ globalThis.lynxEnv.switchToMainThread();
287
+ if (isBackground) globalThis.lynxEnv.switchToBackgroundThread();
288
+ },
289
+ markTiming: ()=>{},
290
+ createJSObjectDestructionObserver: ()=>({})
291
+ };
292
+ const performance = {
293
+ __functionCallHistory: [],
294
+ _generatePipelineOptions: ()=>{
295
+ performance.__functionCallHistory.push([
296
+ '_generatePipelineOptions'
297
+ ]);
298
+ return {
299
+ pipelineID: 'pipelineID',
300
+ needTimestamps: false
301
+ };
302
+ },
303
+ _onPipelineStart: (id)=>{
304
+ performance.__functionCallHistory.push([
305
+ '_onPipelineStart',
306
+ id
307
+ ]);
308
+ },
309
+ _markTiming: (id, key)=>{
310
+ performance.__functionCallHistory.push([
311
+ '_markTiming',
312
+ id,
313
+ key
314
+ ]);
315
+ },
316
+ _bindPipelineIdWithTimingFlag: (id, flag)=>{
317
+ performance.__functionCallHistory.push([
318
+ '_bindPipelineIdWithTimingFlag',
319
+ id,
320
+ flag
321
+ ]);
322
+ }
323
+ };
324
+ const ee = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
325
+ ee.dispatchEvent = ({ type, data })=>{
326
+ const isMainThread = __MAIN_THREAD__;
327
+ lynxEnv.switchToBackgroundThread();
328
+ ee.emit(type, {
329
+ data: data
330
+ });
331
+ if (isMainThread) lynxEnv.switchToMainThread();
332
+ };
333
+ ee.addEventListener = ee.addListener;
334
+ ee.removeEventListener = ee.removeListener;
335
+ const CoreContext = ee;
336
+ const JsContext = ee;
337
+ function __LoadLepusChunk(chunkName, options) {
338
+ const isBackground = !__MAIN_THREAD__;
339
+ globalThis.lynxEnv.switchToMainThread();
340
+ if (process.env['DEBUG']) console.log('__LoadLepusChunk', chunkName, options);
341
+ let ans;
342
+ if ('worklet-runtime' === chunkName) {
343
+ var _globalThis_onInitWorkletRuntime, _globalThis;
344
+ ans = null == (_globalThis_onInitWorkletRuntime = (_globalThis = globalThis).onInitWorkletRuntime) ? void 0 : _globalThis_onInitWorkletRuntime.call(_globalThis);
345
+ } else throw new Error(`__LoadLepusChunk: Unknown chunk name: ${chunkName}`);
346
+ if (isBackground) globalThis.lynxEnv.switchToBackgroundThread();
347
+ return ans;
348
+ }
349
+ return {
350
+ app,
351
+ performance,
352
+ CoreContext,
353
+ JsContext,
354
+ __LoadLepusChunk
355
+ };
356
+ }
357
+ function injectMainThreadGlobals(target, polyfills) {
358
+ var _globalThis_onInjectMainThreadGlobals, _globalThis;
359
+ __injectElementApi(target);
360
+ const { performance, JsContext, __LoadLepusChunk } = polyfills || {};
361
+ if (void 0 === target) target = globalThis;
362
+ target.__DEV__ = true;
363
+ target.__PROFILE__ = true;
364
+ target.__JS__ = false;
365
+ target.__LEPUS__ = true;
366
+ target.__BACKGROUND__ = false;
367
+ target.__MAIN_THREAD__ = true;
368
+ target.__REF_FIRE_IMMEDIATELY__ = false;
369
+ target.__FIRST_SCREEN_SYNC_TIMING__ = 'immediately';
370
+ target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
371
+ target.__ENABLE_SSR__ = false;
372
+ target.globDynamicComponentEntry = '__Card__';
373
+ target.lynx = {
374
+ performance,
375
+ getJSContext: ()=>JsContext,
376
+ reportError: (e)=>{
377
+ throw e;
378
+ }
379
+ };
380
+ target.requestAnimationFrame = setTimeout;
381
+ target.cancelAnimationFrame = clearTimeout;
382
+ target.console.profile = ()=>{};
383
+ target.console.profileEnd = ()=>{};
384
+ target.__LoadLepusChunk = __LoadLepusChunk;
385
+ null == (_globalThis_onInjectMainThreadGlobals = (_globalThis = globalThis).onInjectMainThreadGlobals) || _globalThis_onInjectMainThreadGlobals.call(_globalThis, target);
386
+ }
387
+ const IGNORE_LIST_GLOBALS = [
388
+ 'globalThis',
389
+ 'global'
390
+ ];
391
+ class NodesRef {
392
+ invoke() {
393
+ throw new Error('not implemented');
394
+ }
395
+ path() {
396
+ throw new Error('not implemented');
397
+ }
398
+ fields() {
399
+ throw new Error('not implemented');
400
+ }
401
+ setNativeProps() {
402
+ throw new Error('not implemented');
403
+ }
404
+ constructor(selectorQuery, nodeSelectToken){
405
+ dist_define_property(this, "_nodeSelectToken", void 0);
406
+ dist_define_property(this, "_selectorQuery", void 0);
407
+ this._nodeSelectToken = nodeSelectToken;
408
+ this._selectorQuery = selectorQuery;
409
+ }
410
+ }
411
+ function injectBackgroundThreadGlobals(target, polyfills) {
412
+ var _globalThis_onInjectBackgroundThreadGlobals, _globalThis;
413
+ const { app, performance, CoreContext, __LoadLepusChunk } = polyfills || {};
414
+ if (void 0 === target) target = globalThis;
415
+ target.__DEV__ = true;
416
+ target.__PROFILE__ = true;
417
+ target.__JS__ = true;
418
+ target.__LEPUS__ = false;
419
+ target.__BACKGROUND__ = true;
420
+ target.__MAIN_THREAD__ = false;
421
+ target.__ENABLE_SSR__ = false;
422
+ target.globDynamicComponentEntry = '__Card__';
423
+ target.lynxCoreInject = {};
424
+ target.lynxCoreInject.tt = {
425
+ _params: {
426
+ initData: {},
427
+ updateData: {}
428
+ }
429
+ };
430
+ const globalEventEmitter = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
431
+ globalEventEmitter.trigger = globalEventEmitter.emit;
432
+ globalEventEmitter.toggle = globalEventEmitter.emit;
433
+ target.lynx = {
434
+ getNativeApp: ()=>app,
435
+ performance,
436
+ createSelectorQuery: ()=>({
437
+ selectUniqueID: function(uniqueId) {
438
+ return new NodesRef({}, {
439
+ type: 2,
440
+ identifier: uniqueId.toString()
441
+ });
442
+ }
443
+ }),
444
+ getCoreContext: ()=>CoreContext,
445
+ getJSModule: (moduleName)=>{
446
+ if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
447
+ throw new Error(`getJSModule(${moduleName}) not implemented`);
448
+ },
449
+ reportError: (e)=>{
450
+ throw e;
451
+ }
452
+ };
453
+ target.requestAnimationFrame = setTimeout;
454
+ target.cancelAnimationFrame = clearTimeout;
455
+ target.console.profile = ()=>{};
456
+ target.console.profileEnd = ()=>{};
457
+ target.SystemInfo = {
458
+ platform: 'iOS',
459
+ pixelRatio: 3,
460
+ pixelWidth: 1170,
461
+ pixelHeight: 2532,
462
+ osVersion: '17.0.2',
463
+ enableKrypton: true,
464
+ runtimeType: 'quickjs',
465
+ lynxSdkVersion: '3.0'
466
+ };
467
+ target.__LoadLepusChunk = __LoadLepusChunk;
468
+ null == (_globalThis_onInjectBackgroundThreadGlobals = (_globalThis = globalThis).onInjectBackgroundThreadGlobals) || _globalThis_onInjectBackgroundThreadGlobals.call(_globalThis, target);
469
+ }
470
+ class LynxEnv {
471
+ injectGlobals() {
472
+ const polyfills = createPolyfills();
473
+ injectBackgroundThreadGlobals(this.backgroundThread.globalThis, polyfills);
474
+ injectMainThreadGlobals(this.mainThread.globalThis, polyfills);
475
+ }
476
+ switchToBackgroundThread() {
477
+ var _globalThis_onSwitchedToBackgroundThread, _globalThis;
478
+ this.originals = new Map();
479
+ Object.getOwnPropertyNames(this.backgroundThread.globalThis).forEach((key)=>{
480
+ if (IGNORE_LIST_GLOBALS.includes(key)) return;
481
+ this.originals.set(key, global[key]);
482
+ global[key] = this.backgroundThread.globalThis[key];
483
+ });
484
+ null == (_globalThis = globalThis) || null == (_globalThis_onSwitchedToBackgroundThread = _globalThis.onSwitchedToBackgroundThread) || _globalThis_onSwitchedToBackgroundThread.call(_globalThis);
485
+ }
486
+ switchToMainThread() {
487
+ var _globalThis_onSwitchedToMainThread, _globalThis;
488
+ this.originals = new Map();
489
+ Object.getOwnPropertyNames(this.mainThread.globalThis).forEach((key)=>{
490
+ if (IGNORE_LIST_GLOBALS.includes(key)) return;
491
+ this.originals.set(key, global[key]);
492
+ global[key] = this.mainThread.globalThis[key];
493
+ });
494
+ null == (_globalThis = globalThis) || null == (_globalThis_onSwitchedToMainThread = _globalThis.onSwitchedToMainThread) || _globalThis_onSwitchedToMainThread.call(_globalThis);
495
+ }
496
+ clearGlobal() {
497
+ var _this_originals, _this_originals1;
498
+ null == (_this_originals = this.originals) || _this_originals.forEach((v, k)=>{
499
+ global[k] = v;
500
+ });
501
+ null == (_this_originals1 = this.originals) || _this_originals1.clear();
502
+ }
503
+ resetLynxEnv() {
504
+ var _globalThis_onResetLynxEnv, _globalThis;
505
+ this.injectGlobals();
506
+ this.switchToMainThread();
507
+ this.switchToBackgroundThread();
508
+ null == (_globalThis_onResetLynxEnv = (_globalThis = globalThis).onResetLynxEnv) || _globalThis_onResetLynxEnv.call(_globalThis);
509
+ }
510
+ constructor(){
511
+ dist_define_property(this, "originals", new Map());
512
+ dist_define_property(this, "backgroundThread", void 0);
513
+ dist_define_property(this, "mainThread", void 0);
514
+ dist_define_property(this, "jsdom", global.jsdom);
515
+ this.backgroundThread = createGlobalThis();
516
+ this.mainThread = createGlobalThis();
517
+ const globalPolyfills = {
518
+ console: this.jsdom.window['console'],
519
+ Event: this.jsdom.window.Event,
520
+ window: this.jsdom.window,
521
+ document: this.jsdom.window.document
522
+ };
523
+ Object.assign(this.mainThread.globalThis, globalPolyfills);
524
+ Object.assign(this.backgroundThread.globalThis, globalPolyfills);
525
+ this.injectGlobals();
526
+ this.switchToBackgroundThread();
527
+ }
528
+ }
529
+ const env = {
530
+ name: 'lynxEnv',
531
+ transformMode: 'web',
532
+ async setup (global1) {
533
+ const fakeGlobal = {};
534
+ await __WEBPACK_EXTERNAL_MODULE_vitest_environments_fd1a84b1__.builtinEnvironments.jsdom.setup(fakeGlobal, {});
535
+ global1.jsdom = fakeGlobal.jsdom;
536
+ const lynxEnv1 = new LynxEnv();
537
+ global1.lynxEnv = lynxEnv1;
538
+ return {
539
+ teardown (global1) {
540
+ delete global1.lynxEnv;
541
+ delete global1.jsdom;
542
+ }
543
+ };
544
+ }
545
+ };
546
+ const vitest = env;
547
+ const env_vitest = vitest;
548
+ export { env_vitest as default };