@lynx-js/testing-environment 0.1.3 → 0.1.4

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/index.cjs CHANGED
@@ -116,21 +116,23 @@ function createPolyfills() {
116
116
  };
117
117
  const ee = new (external_events_default())();
118
118
  ee.dispatchEvent = ({ type, data })=>{
119
- const isMainThread = __MAIN_THREAD__;
120
- lynxTestingEnv.switchToBackgroundThread();
119
+ const origin = __MAIN_THREAD__ ? 'CoreContext' : 'JSContext';
120
+ if ('CoreContext' === origin) lynxTestingEnv.switchToBackgroundThread();
121
+ else lynxTestingEnv.switchToMainThread();
121
122
  ee.emit(type, {
122
- data: data
123
+ data: data,
124
+ origin
123
125
  });
124
- if (isMainThread) lynxTestingEnv.switchToMainThread();
126
+ if ('CoreContext' === origin) lynxTestingEnv.switchToMainThread();
127
+ else lynxTestingEnv.switchToBackgroundThread();
125
128
  };
126
129
  ee.addEventListener = ee.addListener;
127
130
  ee.removeEventListener = ee.removeListener;
128
131
  const CoreContext = ee;
129
132
  const JsContext = ee;
130
- function __LoadLepusChunk(chunkName, options) {
133
+ function __LoadLepusChunk(chunkName, _options) {
131
134
  const isBackground = !__MAIN_THREAD__;
132
135
  globalThis.lynxTestingEnv.switchToMainThread();
133
- if (process.env['DEBUG']) console.log('__LoadLepusChunk', chunkName, options);
134
136
  let ans;
135
137
  if ('worklet-runtime' === chunkName) {
136
138
  var _globalThis_onInitWorkletRuntime, _globalThis;
package/dist/index.js CHANGED
@@ -77,21 +77,23 @@ function createPolyfills() {
77
77
  };
78
78
  const ee = new events();
79
79
  ee.dispatchEvent = ({ type, data })=>{
80
- const isMainThread = __MAIN_THREAD__;
81
- lynxTestingEnv.switchToBackgroundThread();
80
+ const origin = __MAIN_THREAD__ ? 'CoreContext' : 'JSContext';
81
+ if ('CoreContext' === origin) lynxTestingEnv.switchToBackgroundThread();
82
+ else lynxTestingEnv.switchToMainThread();
82
83
  ee.emit(type, {
83
- data: data
84
+ data: data,
85
+ origin
84
86
  });
85
- if (isMainThread) lynxTestingEnv.switchToMainThread();
87
+ if ('CoreContext' === origin) lynxTestingEnv.switchToMainThread();
88
+ else lynxTestingEnv.switchToBackgroundThread();
86
89
  };
87
90
  ee.addEventListener = ee.addListener;
88
91
  ee.removeEventListener = ee.removeListener;
89
92
  const CoreContext = ee;
90
93
  const JsContext = ee;
91
- function __LoadLepusChunk(chunkName, options) {
94
+ function __LoadLepusChunk(chunkName, _options) {
92
95
  const isBackground = !__MAIN_THREAD__;
93
96
  globalThis.lynxTestingEnv.switchToMainThread();
94
- if (process.env['DEBUG']) console.log('__LoadLepusChunk', chunkName, options);
95
97
  let ans;
96
98
  if ('worklet-runtime' === chunkName) {
97
99
  var _globalThis_onInitWorkletRuntime, _globalThis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/testing-environment",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A subset of a Lynx environment to be useful for testing",
5
5
  "keywords": [
6
6
  "Lynx",