@lynx-js/react 0.123.2 → 0.124.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.
- package/CHANGELOG.md +18 -0
- package/package.json +3 -3
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +9 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +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/snapshot/snapshot/definition.js +4 -2
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +5 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js +1 -0
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/testing-library/dist/env/index.js +35 -19
- package/testing-library/dist/index.d.ts +1 -0
- 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 +60 -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
|
@@ -220,6 +220,9 @@ const initElementTree = ()=>{
|
|
|
220
220
|
__GetAttributeByName(ele, name) {
|
|
221
221
|
return ele.getAttribute(name);
|
|
222
222
|
}
|
|
223
|
+
__GetAttributeNames(ele) {
|
|
224
|
+
return ele.getAttributeNames();
|
|
225
|
+
}
|
|
223
226
|
__GetComputedStyleByKey(ele, key) {
|
|
224
227
|
return lynxTestingEnv.env.window.getComputedStyle(ele).getPropertyValue(key);
|
|
225
228
|
}
|
|
@@ -431,23 +434,36 @@ function createPolyfills() {
|
|
|
431
434
|
]);
|
|
432
435
|
}
|
|
433
436
|
};
|
|
434
|
-
const
|
|
435
|
-
|
|
437
|
+
const createContextProxy = ()=>{
|
|
438
|
+
const ee = new node_events();
|
|
439
|
+
ee.addEventListener = ee.addListener;
|
|
440
|
+
ee.removeEventListener = ee.removeListener;
|
|
441
|
+
return ee;
|
|
442
|
+
};
|
|
443
|
+
const mainThreadContexts = {
|
|
444
|
+
CoreContext: createContextProxy(),
|
|
445
|
+
JsContext: createContextProxy()
|
|
446
|
+
};
|
|
447
|
+
const backgroundThreadContexts = {
|
|
448
|
+
CoreContext: createContextProxy(),
|
|
449
|
+
JsContext: createContextProxy()
|
|
450
|
+
};
|
|
451
|
+
const deliverEvent = (receiver, receiverThread, type, data, origin)=>{
|
|
436
452
|
if (!globalThis.lynxTestingEnv) return;
|
|
437
|
-
const
|
|
438
|
-
if ('
|
|
439
|
-
else lynxTestingEnv.
|
|
440
|
-
|
|
453
|
+
const wasMainThread = __MAIN_THREAD__;
|
|
454
|
+
if ('main' === receiverThread) lynxTestingEnv.switchToMainThread();
|
|
455
|
+
else lynxTestingEnv.switchToBackgroundThread();
|
|
456
|
+
receiver.emit(type, {
|
|
441
457
|
data: data,
|
|
442
458
|
origin
|
|
443
459
|
});
|
|
444
|
-
if (
|
|
460
|
+
if (wasMainThread) lynxTestingEnv.switchToMainThread();
|
|
445
461
|
else lynxTestingEnv.switchToBackgroundThread();
|
|
446
462
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
463
|
+
mainThreadContexts.CoreContext.dispatchEvent = ({ type, data })=>deliverEvent(mainThreadContexts.CoreContext, 'main', type, data, 'CoreContext');
|
|
464
|
+
mainThreadContexts.JsContext.dispatchEvent = ({ type, data })=>deliverEvent(backgroundThreadContexts.CoreContext, 'background', type, data, 'CoreContext');
|
|
465
|
+
backgroundThreadContexts.CoreContext.dispatchEvent = ({ type, data })=>deliverEvent(mainThreadContexts.JsContext, 'main', type, data, 'JSContext');
|
|
466
|
+
backgroundThreadContexts.JsContext.dispatchEvent = ({ type, data })=>deliverEvent(backgroundThreadContexts.JsContext, 'background', type, data, 'JSContext');
|
|
451
467
|
function __LoadLepusChunk(chunkName, _options) {
|
|
452
468
|
const isBackground = !__MAIN_THREAD__;
|
|
453
469
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
@@ -460,14 +476,14 @@ function createPolyfills() {
|
|
|
460
476
|
return {
|
|
461
477
|
app,
|
|
462
478
|
performance,
|
|
463
|
-
|
|
464
|
-
|
|
479
|
+
mainThreadContexts,
|
|
480
|
+
backgroundThreadContexts,
|
|
465
481
|
__LoadLepusChunk
|
|
466
482
|
};
|
|
467
483
|
}
|
|
468
484
|
function injectMainThreadGlobals(target, polyfills) {
|
|
469
485
|
__injectElementApi(target);
|
|
470
|
-
const { performance,
|
|
486
|
+
const { performance, mainThreadContexts, __LoadLepusChunk } = polyfills || {};
|
|
471
487
|
if (void 0 === target) target = globalThis;
|
|
472
488
|
target.__DEV__ = true;
|
|
473
489
|
target.__PROFILE__ = true;
|
|
@@ -505,8 +521,8 @@ function injectMainThreadGlobals(target, polyfills) {
|
|
|
505
521
|
target.lynx = {
|
|
506
522
|
performance,
|
|
507
523
|
getNative: ()=>native,
|
|
508
|
-
getCoreContext: ()=>CoreContext,
|
|
509
|
-
getJSContext: ()=>JsContext,
|
|
524
|
+
getCoreContext: ()=>mainThreadContexts.CoreContext,
|
|
525
|
+
getJSContext: ()=>mainThreadContexts.JsContext,
|
|
510
526
|
reportError: (e)=>{
|
|
511
527
|
throw e;
|
|
512
528
|
}
|
|
@@ -550,7 +566,7 @@ class NodesRef {
|
|
|
550
566
|
}
|
|
551
567
|
}
|
|
552
568
|
function injectBackgroundThreadGlobals(target, polyfills) {
|
|
553
|
-
const { app, performance,
|
|
569
|
+
const { app, performance, backgroundThreadContexts, __LoadLepusChunk } = polyfills || {};
|
|
554
570
|
if (void 0 === target) target = globalThis;
|
|
555
571
|
target.__DEV__ = true;
|
|
556
572
|
target.__PROFILE__ = true;
|
|
@@ -590,8 +606,8 @@ function injectBackgroundThreadGlobals(target, polyfills) {
|
|
|
590
606
|
});
|
|
591
607
|
}
|
|
592
608
|
}),
|
|
593
|
-
getCoreContext: ()=>CoreContext,
|
|
594
|
-
getJSContext: ()=>JsContext,
|
|
609
|
+
getCoreContext: ()=>backgroundThreadContexts.CoreContext,
|
|
610
|
+
getJSContext: ()=>backgroundThreadContexts.JsContext,
|
|
595
611
|
getJSModule: (moduleName)=>{
|
|
596
612
|
if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
|
|
597
613
|
throw new Error(`getJSModule(${moduleName}) not implemented`);
|
|
@@ -785,6 +785,7 @@ declare const initElementTree: () => {
|
|
|
785
785
|
__CreateList(parentComponentUniqueId: number, componentAtIndex: any, enqueueComponent: any): LynxElement;
|
|
786
786
|
__GetTag(ele: LynxElement): string;
|
|
787
787
|
__GetAttributeByName(ele: LynxElement, name: string): string | null;
|
|
788
|
+
__GetAttributeNames(ele: LynxElement): string[];
|
|
788
789
|
__GetComputedStyleByKey(ele: LynxElement, key: string): string;
|
|
789
790
|
/** @internal */
|
|
790
791
|
animationMap: Map<string, {
|
|
@@ -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
|
});
|