@lynx-js/react 0.123.1 → 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.
Files changed (34) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/runtime/lib/element-template/background/commit-hook.js +3 -0
  4. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  5. package/runtime/lib/element-template/prop-adapters/spread.js +11 -11
  6. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  7. package/runtime/lib/element-template/protocol/types.d.ts +1 -0
  8. package/runtime/lib/shared/attribute-name.d.ts +3 -0
  9. package/runtime/lib/shared/attribute-name.js +91 -0
  10. package/runtime/lib/shared/attribute-name.js.map +1 -0
  11. package/runtime/lib/snapshot/lifecycle/patch/commit.js +3 -0
  12. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
  13. package/runtime/lib/snapshot/lynx/portals.d.ts +25 -3
  14. package/runtime/lib/snapshot/lynx/portals.js +24 -1
  15. package/runtime/lib/snapshot/lynx/portals.js.map +1 -1
  16. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +19 -0
  17. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  18. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +97 -65
  19. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  20. package/runtime/lib/snapshot/snapshot/platformInfo.js +20 -9
  21. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  22. package/runtime/lib/snapshot/snapshot/spread.js +27 -17
  23. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  24. package/runtime/lib/snapshot/snapshot/utils.js +8 -3
  25. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
  26. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  27. package/testing-library/dist/env/index.js +37 -19
  28. package/testing-library/dist/index.d.ts +1 -0
  29. package/testing-library/dist/pure.js +1 -1
  30. package/testing-library/dist/rstest-config.js +1 -1
  31. package/transform/dist/wasm.cjs +1 -1
  32. package/transform/index.d.ts +63 -24
  33. /package/testing-library/dist/{0-@rstest/adapter-rsbuild.js → @rstest/adapter-rsbuild~0.js} +0 -0
  34. /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
+ __GetComputedStyleByKey(ele, key) {
224
+ return lynxTestingEnv.env.window.getComputedStyle(ele).getPropertyValue(key);
225
+ }
223
226
  __ElementAnimate(element, args) {
224
227
  const [operation, name] = args;
225
228
  switch(operation){
@@ -428,23 +431,36 @@ function createPolyfills() {
428
431
  ]);
429
432
  }
430
433
  };
431
- const ee = new node_events();
432
- ee.dispatchEvent = ({ type, data })=>{
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)=>{
433
449
  if (!globalThis.lynxTestingEnv) return;
434
- const origin = __MAIN_THREAD__ ? 'CoreContext' : 'JSContext';
435
- if ('CoreContext' === origin) lynxTestingEnv.switchToBackgroundThread();
436
- else lynxTestingEnv.switchToMainThread();
437
- ee.emit(type, {
450
+ const wasMainThread = __MAIN_THREAD__;
451
+ if ('main' === receiverThread) lynxTestingEnv.switchToMainThread();
452
+ else lynxTestingEnv.switchToBackgroundThread();
453
+ receiver.emit(type, {
438
454
  data: data,
439
455
  origin
440
456
  });
441
- if ('CoreContext' === origin) lynxTestingEnv.switchToMainThread();
457
+ if (wasMainThread) lynxTestingEnv.switchToMainThread();
442
458
  else lynxTestingEnv.switchToBackgroundThread();
443
459
  };
444
- ee.addEventListener = ee.addListener;
445
- ee.removeEventListener = ee.removeListener;
446
- const CoreContext = ee;
447
- const JsContext = ee;
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');
448
464
  function __LoadLepusChunk(chunkName, _options) {
449
465
  const isBackground = !__MAIN_THREAD__;
450
466
  globalThis.lynxTestingEnv.switchToMainThread();
@@ -457,14 +473,14 @@ function createPolyfills() {
457
473
  return {
458
474
  app,
459
475
  performance,
460
- CoreContext,
461
- JsContext,
476
+ mainThreadContexts,
477
+ backgroundThreadContexts,
462
478
  __LoadLepusChunk
463
479
  };
464
480
  }
465
481
  function injectMainThreadGlobals(target, polyfills) {
466
482
  __injectElementApi(target);
467
- const { performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
483
+ const { performance, mainThreadContexts, __LoadLepusChunk } = polyfills || {};
468
484
  if (void 0 === target) target = globalThis;
469
485
  target.__DEV__ = true;
470
486
  target.__PROFILE__ = true;
@@ -478,6 +494,7 @@ function injectMainThreadGlobals(target, polyfills) {
478
494
  target.__FIRST_SCREEN_SYNC_TIMING__ = 'immediately';
479
495
  target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
480
496
  target.__ENABLE_SSR__ = false;
497
+ target.__EXPERIMENTAL_TRANSFORM_BUILTIN_ATTRIBUTE_NAMES__ = false;
481
498
  target.globDynamicComponentEntry = '__Card__';
482
499
  const native = {
483
500
  _listeners: {},
@@ -501,8 +518,8 @@ function injectMainThreadGlobals(target, polyfills) {
501
518
  target.lynx = {
502
519
  performance,
503
520
  getNative: ()=>native,
504
- getCoreContext: ()=>CoreContext,
505
- getJSContext: ()=>JsContext,
521
+ getCoreContext: ()=>mainThreadContexts.CoreContext,
522
+ getJSContext: ()=>mainThreadContexts.JsContext,
506
523
  reportError: (e)=>{
507
524
  throw e;
508
525
  }
@@ -546,7 +563,7 @@ class NodesRef {
546
563
  }
547
564
  }
548
565
  function injectBackgroundThreadGlobals(target, polyfills) {
549
- const { app, performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
566
+ const { app, performance, backgroundThreadContexts, __LoadLepusChunk } = polyfills || {};
550
567
  if (void 0 === target) target = globalThis;
551
568
  target.__DEV__ = true;
552
569
  target.__PROFILE__ = true;
@@ -557,6 +574,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
557
574
  target.__BACKGROUND__ = true;
558
575
  target.__MAIN_THREAD__ = false;
559
576
  target.__ENABLE_SSR__ = false;
577
+ target.__EXPERIMENTAL_TRANSFORM_BUILTIN_ATTRIBUTE_NAMES__ = false;
560
578
  target.globDynamicComponentEntry = '__Card__';
561
579
  target.lynxCoreInject = {};
562
580
  target.lynxCoreInject.tt = {
@@ -585,8 +603,8 @@ function injectBackgroundThreadGlobals(target, polyfills) {
585
603
  });
586
604
  }
587
605
  }),
588
- getCoreContext: ()=>CoreContext,
589
- getJSContext: ()=>JsContext,
606
+ getCoreContext: ()=>backgroundThreadContexts.CoreContext,
607
+ getJSContext: ()=>backgroundThreadContexts.JsContext,
590
608
  getJSModule: (moduleName)=>{
591
609
  if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
592
610
  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
+ __GetComputedStyleByKey(ele: LynxElement, key: string): string;
788
789
  /** @internal */
789
790
  animationMap: Map<string, {
790
791
  element: LynxElement;
@@ -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 "./0-rslib-runtime.js";
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("./0-@rstest/adapter-rsbuild.js");
32
+ const { toRstestConfig } = await import("./@rstest/adapter-rsbuild~0.js");
33
33
  const rstestConfig = toRstestConfig({
34
34
  rsbuildConfig: lynxConfig.content
35
35
  });