@lynx-js/react 0.123.2 → 0.123.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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/runtime/lib/snapshot/lynx/portals.d.ts +25 -3
- package/runtime/lib/snapshot/lynx/portals.js +24 -1
- package/runtime/lib/snapshot/lynx/portals.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/testing-library/dist/env/index.js +32 -19
- package/testing-library/dist/pure.js +1 -1
- package/testing-library/dist/rstest-config.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +20 -24
- /package/testing-library/dist/{0-@rstest/adapter-rsbuild.js → @rstest/adapter-rsbuild~0.js} +0 -0
- /package/testing-library/dist/{0-rslib-runtime.js → rslib-runtime-0.js} +0 -0
|
@@ -431,23 +431,36 @@ function createPolyfills() {
|
|
|
431
431
|
]);
|
|
432
432
|
}
|
|
433
433
|
};
|
|
434
|
-
const
|
|
435
|
-
|
|
434
|
+
const createContextProxy = ()=>{
|
|
435
|
+
const ee = new node_events();
|
|
436
|
+
ee.addEventListener = ee.addListener;
|
|
437
|
+
ee.removeEventListener = ee.removeListener;
|
|
438
|
+
return ee;
|
|
439
|
+
};
|
|
440
|
+
const mainThreadContexts = {
|
|
441
|
+
CoreContext: createContextProxy(),
|
|
442
|
+
JsContext: createContextProxy()
|
|
443
|
+
};
|
|
444
|
+
const backgroundThreadContexts = {
|
|
445
|
+
CoreContext: createContextProxy(),
|
|
446
|
+
JsContext: createContextProxy()
|
|
447
|
+
};
|
|
448
|
+
const deliverEvent = (receiver, receiverThread, type, data, origin)=>{
|
|
436
449
|
if (!globalThis.lynxTestingEnv) return;
|
|
437
|
-
const
|
|
438
|
-
if ('
|
|
439
|
-
else lynxTestingEnv.
|
|
440
|
-
|
|
450
|
+
const wasMainThread = __MAIN_THREAD__;
|
|
451
|
+
if ('main' === receiverThread) lynxTestingEnv.switchToMainThread();
|
|
452
|
+
else lynxTestingEnv.switchToBackgroundThread();
|
|
453
|
+
receiver.emit(type, {
|
|
441
454
|
data: data,
|
|
442
455
|
origin
|
|
443
456
|
});
|
|
444
|
-
if (
|
|
457
|
+
if (wasMainThread) lynxTestingEnv.switchToMainThread();
|
|
445
458
|
else lynxTestingEnv.switchToBackgroundThread();
|
|
446
459
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
460
|
+
mainThreadContexts.CoreContext.dispatchEvent = ({ type, data })=>deliverEvent(mainThreadContexts.CoreContext, 'main', type, data, 'CoreContext');
|
|
461
|
+
mainThreadContexts.JsContext.dispatchEvent = ({ type, data })=>deliverEvent(backgroundThreadContexts.CoreContext, 'background', type, data, 'CoreContext');
|
|
462
|
+
backgroundThreadContexts.CoreContext.dispatchEvent = ({ type, data })=>deliverEvent(mainThreadContexts.JsContext, 'main', type, data, 'JSContext');
|
|
463
|
+
backgroundThreadContexts.JsContext.dispatchEvent = ({ type, data })=>deliverEvent(backgroundThreadContexts.JsContext, 'background', type, data, 'JSContext');
|
|
451
464
|
function __LoadLepusChunk(chunkName, _options) {
|
|
452
465
|
const isBackground = !__MAIN_THREAD__;
|
|
453
466
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
@@ -460,14 +473,14 @@ function createPolyfills() {
|
|
|
460
473
|
return {
|
|
461
474
|
app,
|
|
462
475
|
performance,
|
|
463
|
-
|
|
464
|
-
|
|
476
|
+
mainThreadContexts,
|
|
477
|
+
backgroundThreadContexts,
|
|
465
478
|
__LoadLepusChunk
|
|
466
479
|
};
|
|
467
480
|
}
|
|
468
481
|
function injectMainThreadGlobals(target, polyfills) {
|
|
469
482
|
__injectElementApi(target);
|
|
470
|
-
const { performance,
|
|
483
|
+
const { performance, mainThreadContexts, __LoadLepusChunk } = polyfills || {};
|
|
471
484
|
if (void 0 === target) target = globalThis;
|
|
472
485
|
target.__DEV__ = true;
|
|
473
486
|
target.__PROFILE__ = true;
|
|
@@ -505,8 +518,8 @@ function injectMainThreadGlobals(target, polyfills) {
|
|
|
505
518
|
target.lynx = {
|
|
506
519
|
performance,
|
|
507
520
|
getNative: ()=>native,
|
|
508
|
-
getCoreContext: ()=>CoreContext,
|
|
509
|
-
getJSContext: ()=>JsContext,
|
|
521
|
+
getCoreContext: ()=>mainThreadContexts.CoreContext,
|
|
522
|
+
getJSContext: ()=>mainThreadContexts.JsContext,
|
|
510
523
|
reportError: (e)=>{
|
|
511
524
|
throw e;
|
|
512
525
|
}
|
|
@@ -550,7 +563,7 @@ class NodesRef {
|
|
|
550
563
|
}
|
|
551
564
|
}
|
|
552
565
|
function injectBackgroundThreadGlobals(target, polyfills) {
|
|
553
|
-
const { app, performance,
|
|
566
|
+
const { app, performance, backgroundThreadContexts, __LoadLepusChunk } = polyfills || {};
|
|
554
567
|
if (void 0 === target) target = globalThis;
|
|
555
568
|
target.__DEV__ = true;
|
|
556
569
|
target.__PROFILE__ = true;
|
|
@@ -590,8 +603,8 @@ function injectBackgroundThreadGlobals(target, polyfills) {
|
|
|
590
603
|
});
|
|
591
604
|
}
|
|
592
605
|
}),
|
|
593
|
-
getCoreContext: ()=>CoreContext,
|
|
594
|
-
getJSContext: ()=>JsContext,
|
|
606
|
+
getCoreContext: ()=>backgroundThreadContexts.CoreContext,
|
|
607
|
+
getJSContext: ()=>backgroundThreadContexts.JsContext,
|
|
595
608
|
getJSModule: (moduleName)=>{
|
|
596
609
|
if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
|
|
597
610
|
throw new Error(`getJSModule(${moduleName}) not implemented`);
|
|
@@ -6,7 +6,7 @@ import { act } from "preact/test-utils";
|
|
|
6
6
|
import { __root } from "@lynx-js/react/internal";
|
|
7
7
|
import { flushDelayedLifecycleEvents } from "../../runtime/lib/snapshot/lynx/tt.js";
|
|
8
8
|
import { clearPage } from "../../runtime/lib/snapshot/index.js";
|
|
9
|
-
import { __webpack_require__ } from "./
|
|
9
|
+
import { __webpack_require__ } from "./rslib-runtime-0.js";
|
|
10
10
|
__webpack_require__.add({
|
|
11
11
|
"../../../node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js" (module1) {
|
|
12
12
|
module1.exports = ({ onlyFirst = false } = {})=>{
|
|
@@ -29,7 +29,7 @@ function withLynxConfig(options) {
|
|
|
29
29
|
cwd: options?.rootPath,
|
|
30
30
|
configPath: options?.configPath
|
|
31
31
|
});
|
|
32
|
-
const { toRstestConfig } = await import("
|
|
32
|
+
const { toRstestConfig } = await import("./@rstest/adapter-rsbuild~0.js");
|
|
33
33
|
const rstestConfig = toRstestConfig({
|
|
34
34
|
rsbuildConfig: lynxConfig.content
|
|
35
35
|
});
|