@lynx-js/react 0.118.0 → 0.120.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 +70 -0
- package/package.json +28 -6
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/lazy/internal.js +3 -0
- package/runtime/lib/document.d.ts +4 -4
- package/runtime/lib/document.js +14 -12
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/index.d.ts +3 -3
- package/runtime/lib/index.js +4 -4
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +23 -20
- package/runtime/lib/internal.js +27 -23
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +5 -5
- package/runtime/lib/lynx-api.js +9 -9
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.d.ts +2 -2
- package/runtime/lib/lynx.js +17 -17
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.d.ts +2 -2
- package/runtime/lib/root.js +2 -2
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.js +1 -0
- package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -0
- package/runtime/lib/snapshot/alog/index.js.map +1 -0
- package/runtime/lib/{alog → snapshot/alog}/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -0
- package/runtime/lib/snapshot/compat/componentIs.js.map +1 -0
- package/runtime/lib/snapshot/compat/initData.js.map +1 -0
- package/runtime/lib/snapshot/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/{debug → snapshot/debug}/component-stack.d.ts +0 -6
- package/runtime/lib/snapshot/debug/component-stack.js.map +1 -0
- package/runtime/lib/snapshot/debug/debug.js.map +1 -0
- package/runtime/lib/snapshot/debug/describeInvalidValue.js.map +1 -0
- package/runtime/lib/snapshot/debug/formatPatch.js.map +1 -0
- package/runtime/lib/snapshot/debug/printSnapshot.js.map +1 -0
- package/runtime/lib/{debug → snapshot/debug}/profile.js +1 -1
- package/runtime/lib/snapshot/debug/profile.js.map +1 -0
- package/runtime/lib/{debug → snapshot/debug}/profileHooks.js +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -0
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -0
- package/runtime/lib/snapshot/gesture/processGesture.js +172 -0
- package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -0
- package/runtime/lib/snapshot/gesture/processGestureBagkround.d.ts +9 -0
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js +80 -0
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +1 -0
- package/runtime/lib/snapshot/gesture/types.js.map +1 -0
- package/runtime/lib/snapshot/hooks/mainThread.d.ts +17 -0
- package/runtime/lib/snapshot/hooks/mainThread.js +152 -0
- package/runtime/lib/snapshot/hooks/mainThread.js.map +1 -0
- package/runtime/lib/{hooks → snapshot/hooks}/react.d.ts +1 -2
- package/runtime/lib/{hooks → snapshot/hooks}/react.js +8 -14
- package/runtime/lib/snapshot/hooks/react.js.map +1 -0
- package/runtime/lib/snapshot/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/snapshot/index.d.ts +1 -4
- package/runtime/lib/snapshot/index.js +2 -5
- package/runtime/lib/snapshot/index.js.map +1 -1
- package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.js +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/event/delayEvents.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/event/delayLifecycleEvents.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.js +4 -2
- package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.js +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/pass.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.js +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/globalState.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/isMainThreadHydrating.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.js +10 -2
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.js +2 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.js +2 -2
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -0
- package/runtime/lib/{lifecycle → snapshot/lifecycle}/render.js +1 -7
- package/runtime/lib/snapshot/lifecycle/render.js.map +1 -0
- package/runtime/lib/{list → snapshot/list}/list.js +1 -1
- package/runtime/lib/snapshot/list/list.js.map +1 -0
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -0
- package/runtime/lib/snapshot/list/pendingListUpdates.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/calledByNative.js +2 -2
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -0
- package/runtime/lib/snapshot/lynx/component.js.map +1 -0
- package/runtime/lib/snapshot/lynx/dynamic-js.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/env.js +0 -3
- package/runtime/lib/snapshot/lynx/env.js.map +1 -0
- package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -0
- package/runtime/lib/snapshot/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/performance.js +1 -1
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.js +1 -1
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/suspense.js +27 -17
- package/runtime/lib/snapshot/lynx/suspense.js.map +1 -0
- package/runtime/lib/{lynx → snapshot/lynx}/tt.js +1 -1
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -0
- package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/constants.d.ts +1 -0
- package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/constants.js +1 -0
- package/runtime/lib/snapshot/renderToOpcodes/constants.js.map +1 -0
- package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.js +21 -4
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -0
- package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.js +37 -14
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -0
- package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.js +4 -2
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -0
- package/runtime/lib/snapshot/{backgroundSnapshot.d.ts → snapshot/backgroundSnapshot.d.ts} +1 -0
- package/runtime/lib/snapshot/{backgroundSnapshot.js → snapshot/backgroundSnapshot.js} +82 -53
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/constants.js.map +1 -0
- package/runtime/lib/snapshot/{definition.d.ts → snapshot/definition.d.ts} +1 -0
- package/runtime/lib/snapshot/{definition.js → snapshot/definition.js} +6 -2
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -0
- package/runtime/lib/snapshot/{dynamicPartType.d.ts → snapshot/dynamicPartType.d.ts} +2 -0
- package/runtime/lib/snapshot/{dynamicPartType.js → snapshot/dynamicPartType.js} +2 -0
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/event.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/index.d.ts +4 -0
- package/runtime/lib/snapshot/snapshot/index.js +8 -0
- package/runtime/lib/snapshot/snapshot/index.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -0
- package/runtime/lib/snapshot/{ref.d.ts → snapshot/ref.d.ts} +1 -0
- package/runtime/lib/snapshot/{ref.js → snapshot/ref.js} +13 -1
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -0
- package/runtime/lib/snapshot/{snapshot.d.ts → snapshot/snapshot.d.ts} +1 -0
- package/runtime/lib/snapshot/{snapshot.js → snapshot/snapshot.js} +28 -8
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -0
- package/runtime/lib/snapshot/{spread.js → snapshot/spread.js} +4 -4
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -0
- package/runtime/lib/snapshot/{types.d.ts → snapshot/types.d.ts} +1 -0
- package/runtime/lib/snapshot/snapshot/types.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/utils.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/execMap.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/functionCall.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/runOnBackground.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -0
- package/runtime/lib/snapshot/worklet/call/transformToWorklet.js.map +1 -0
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -0
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -0
- package/runtime/lib/{worklet → snapshot/worklet}/functionality.js +1 -1
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -0
- package/runtime/lib/snapshot/worklet/hmr.js.map +1 -0
- package/runtime/lib/snapshot/worklet/indexMap.js.map +1 -0
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -0
- package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -0
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.js.map +1 -0
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.js +1 -1
- package/runtime/lib/utils.js.map +1 -1
- package/testing-library/README.md +48 -9
- package/testing-library/dist/0~123.js +43 -0
- package/testing-library/dist/881.js +1 -0
- package/testing-library/dist/entry.d.ts +1 -0
- package/testing-library/dist/env/index.d.ts +2 -0
- package/testing-library/dist/env/index.js +661 -0
- package/testing-library/dist/env/rstest.d.ts +1 -0
- package/testing-library/dist/env/rstest.js +6 -0
- package/testing-library/dist/env/vitest.d.ts +3 -0
- package/testing-library/dist/env/vitest.js +8 -662
- package/testing-library/dist/fire-event.d.ts +111 -0
- package/testing-library/dist/index.d.ts +18 -6
- package/testing-library/dist/plugins/index.d.ts +2 -0
- package/testing-library/dist/plugins/index.js +282 -0
- package/testing-library/dist/plugins/vitest.d.ts +26 -0
- package/testing-library/dist/pure.js +4 -4
- package/testing-library/dist/rstest-config.d.ts +25 -0
- package/testing-library/dist/rstest-config.js +61 -0
- package/testing-library/dist/setupFiles/common/bootstrap.js +2 -0
- package/testing-library/dist/setupFiles/common/runtime-setup.js +85 -0
- package/testing-library/dist/setupFiles/inner/rstest.js +7 -0
- package/testing-library/dist/setupFiles/inner/vitest.js +11 -0
- package/testing-library/dist/setupFiles/rstest.js +21 -0
- package/testing-library/dist/setupFiles/vitest.js +20 -0
- package/testing-library/dist/vitest.config.d.ts +6 -0
- package/testing-library/dist/vitest.config.js +4 -257
- package/transform/dist/wasm.cjs +450 -389
- package/transform/index.d.ts +10 -0
- package/types/react.docs.d.ts +1 -1
- package/runtime/lib/alog/elementPAPICall.js.map +0 -1
- package/runtime/lib/alog/index.js.map +0 -1
- package/runtime/lib/alog/render.js.map +0 -1
- package/runtime/lib/compat/componentIs.js.map +0 -1
- package/runtime/lib/compat/initData.js.map +0 -1
- package/runtime/lib/compat/lynxComponent.js.map +0 -1
- package/runtime/lib/debug/component-stack.js.map +0 -1
- package/runtime/lib/debug/debug.js.map +0 -1
- package/runtime/lib/debug/describeInvalidValue.js.map +0 -1
- package/runtime/lib/debug/formatPatch.js.map +0 -1
- package/runtime/lib/debug/printSnapshot.js.map +0 -1
- package/runtime/lib/debug/profile.js.map +0 -1
- package/runtime/lib/debug/profileHooks.js.map +0 -1
- package/runtime/lib/debug/vnodeSource.js.map +0 -1
- package/runtime/lib/gesture/processGesture.js +0 -58
- package/runtime/lib/gesture/processGesture.js.map +0 -1
- package/runtime/lib/gesture/processGestureBagkround.d.ts +0 -2
- package/runtime/lib/gesture/processGestureBagkround.js +0 -19
- package/runtime/lib/gesture/processGestureBagkround.js.map +0 -1
- package/runtime/lib/gesture/types.js.map +0 -1
- package/runtime/lib/hooks/react.js.map +0 -1
- package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +0 -1
- package/runtime/lib/legacy-react-runtime/index.js.map +0 -1
- package/runtime/lib/lifecycle/constant.js.map +0 -1
- package/runtime/lib/lifecycle/destroy.js.map +0 -1
- package/runtime/lib/lifecycle/event/delayEvents.js.map +0 -1
- package/runtime/lib/lifecycle/event/delayLifecycleEvents.js.map +0 -1
- package/runtime/lib/lifecycle/event/jsReady.js.map +0 -1
- package/runtime/lib/lifecycle/isRendering.js.map +0 -1
- package/runtime/lib/lifecycle/pass.js.map +0 -1
- package/runtime/lib/lifecycle/patch/commit.js.map +0 -1
- package/runtime/lib/lifecycle/patch/error.js.map +0 -1
- package/runtime/lib/lifecycle/patch/globalState.js.map +0 -1
- package/runtime/lib/lifecycle/patch/isMainThreadHydrating.js.map +0 -1
- package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +0 -1
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +0 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.js.map +0 -1
- package/runtime/lib/lifecycle/ref/delay.js.map +0 -1
- package/runtime/lib/lifecycle/reload.js.map +0 -1
- package/runtime/lib/lifecycle/render.js.map +0 -1
- package/runtime/lib/list/list.js.map +0 -1
- package/runtime/lib/list/listUpdateInfo.js.map +0 -1
- package/runtime/lib/list/pendingListUpdates.js.map +0 -1
- package/runtime/lib/lynx/calledByNative.js.map +0 -1
- package/runtime/lib/lynx/component.js.map +0 -1
- package/runtime/lib/lynx/dynamic-js.js.map +0 -1
- package/runtime/lib/lynx/env.js.map +0 -1
- package/runtime/lib/lynx/injectLepusMethods.js.map +0 -1
- package/runtime/lib/lynx/lazy-bundle.js.map +0 -1
- package/runtime/lib/lynx/performance.js.map +0 -1
- package/runtime/lib/lynx/runWithForce.js.map +0 -1
- package/runtime/lib/lynx/suspense.js.map +0 -1
- package/runtime/lib/lynx/tt.js.map +0 -1
- package/runtime/lib/renderToOpcodes/constants.js.map +0 -1
- package/runtime/lib/renderToOpcodes/hydrate.js.map +0 -1
- package/runtime/lib/renderToOpcodes/index.js.map +0 -1
- package/runtime/lib/renderToOpcodes/opcodes.js.map +0 -1
- package/runtime/lib/snapshot/backgroundSnapshot.js.map +0 -1
- package/runtime/lib/snapshot/constants.js.map +0 -1
- package/runtime/lib/snapshot/definition.js.map +0 -1
- package/runtime/lib/snapshot/dynamicPartType.js.map +0 -1
- package/runtime/lib/snapshot/event.js.map +0 -1
- package/runtime/lib/snapshot/gesture.js.map +0 -1
- package/runtime/lib/snapshot/list.js.map +0 -1
- package/runtime/lib/snapshot/platformInfo.js.map +0 -1
- package/runtime/lib/snapshot/ref.js.map +0 -1
- package/runtime/lib/snapshot/snapshot.js.map +0 -1
- package/runtime/lib/snapshot/snapshotInstanceHydrationMap.js.map +0 -1
- package/runtime/lib/snapshot/spread.js.map +0 -1
- package/runtime/lib/snapshot/types.js.map +0 -1
- package/runtime/lib/snapshot/utils.js.map +0 -1
- package/runtime/lib/snapshot/workletEvent.js.map +0 -1
- package/runtime/lib/snapshot/workletRef.js.map +0 -1
- package/runtime/lib/worklet/call/delayedRunOnMainThreadData.js.map +0 -1
- package/runtime/lib/worklet/call/execMap.js.map +0 -1
- package/runtime/lib/worklet/call/functionCall.js.map +0 -1
- package/runtime/lib/worklet/call/runOnBackground.js.map +0 -1
- package/runtime/lib/worklet/call/runOnMainThread.js.map +0 -1
- package/runtime/lib/worklet/call/transformToWorklet.js.map +0 -1
- package/runtime/lib/worklet/ctx.js.map +0 -1
- package/runtime/lib/worklet/destroy.js.map +0 -1
- package/runtime/lib/worklet/functionality.js.map +0 -1
- package/runtime/lib/worklet/hmr.js.map +0 -1
- package/runtime/lib/worklet/indexMap.js.map +0 -1
- package/runtime/lib/worklet/ref/updateInitValue.js.map +0 -1
- package/runtime/lib/worklet/ref/workletRef.js.map +0 -1
- package/runtime/lib/worklet/ref/workletRefPool.js.map +0 -1
- package/testing-library/dist/vitest-global-setup.js +0 -134
- package/testing-library/types/vitest-config.d.ts +0 -20
- /package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.d.ts +0 -0
- /package/runtime/lib/{alog → snapshot/alog}/index.d.ts +0 -0
- /package/runtime/lib/{alog → snapshot/alog}/index.js +0 -0
- /package/runtime/lib/{alog → snapshot/alog}/render.d.ts +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/componentIs.d.ts +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/componentIs.js +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/initData.d.ts +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/initData.js +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.d.ts +0 -0
- /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/component-stack.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/debug.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/debug.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/formatPatch.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/formatPatch.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.js +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/profile.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/profileHooks.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/vnodeSource.d.ts +0 -0
- /package/runtime/lib/{debug → snapshot/debug}/vnodeSource.js +0 -0
- /package/runtime/lib/{gesture → snapshot/gesture}/processGesture.d.ts +0 -0
- /package/runtime/lib/{gesture → snapshot/gesture}/types.d.ts +0 -0
- /package/runtime/lib/{gesture → snapshot/gesture}/types.js +0 -0
- /package/runtime/lib/{hooks → snapshot/hooks}/useLynxGlobalEventListener.d.ts +0 -0
- /package/runtime/lib/{hooks → snapshot/hooks}/useLynxGlobalEventListener.js +0 -0
- /package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.d.ts +0 -0
- /package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.js +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.d.ts +0 -0
- /package/runtime/lib/{lifecycle → snapshot/lifecycle}/render.d.ts +0 -0
- /package/runtime/lib/{list → snapshot/list}/list.d.ts +0 -0
- /package/runtime/lib/{list → snapshot/list}/listUpdateInfo.d.ts +0 -0
- /package/runtime/lib/{list → snapshot/list}/listUpdateInfo.js +0 -0
- /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.d.ts +0 -0
- /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.js +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/calledByNative.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/component.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/component.js +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.js +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/env.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.js +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.js +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/performance.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/suspense.d.ts +0 -0
- /package/runtime/lib/{lynx → snapshot/lynx}/tt.d.ts +0 -0
- /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.d.ts +0 -0
- /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.d.ts +0 -0
- /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.d.ts +0 -0
- /package/runtime/lib/snapshot/{constants.d.ts → snapshot/constants.d.ts} +0 -0
- /package/runtime/lib/snapshot/{constants.js → snapshot/constants.js} +0 -0
- /package/runtime/lib/snapshot/{event.d.ts → snapshot/event.d.ts} +0 -0
- /package/runtime/lib/snapshot/{event.js → snapshot/event.js} +0 -0
- /package/runtime/lib/snapshot/{gesture.d.ts → snapshot/gesture.d.ts} +0 -0
- /package/runtime/lib/snapshot/{gesture.js → snapshot/gesture.js} +0 -0
- /package/runtime/lib/snapshot/{list.d.ts → snapshot/list.d.ts} +0 -0
- /package/runtime/lib/snapshot/{list.js → snapshot/list.js} +0 -0
- /package/runtime/lib/snapshot/{platformInfo.d.ts → snapshot/platformInfo.d.ts} +0 -0
- /package/runtime/lib/snapshot/{platformInfo.js → snapshot/platformInfo.js} +0 -0
- /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.d.ts → snapshot/snapshotInstanceHydrationMap.d.ts} +0 -0
- /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.js → snapshot/snapshotInstanceHydrationMap.js} +0 -0
- /package/runtime/lib/snapshot/{spread.d.ts → snapshot/spread.d.ts} +0 -0
- /package/runtime/lib/snapshot/{types.js → snapshot/types.js} +0 -0
- /package/runtime/lib/snapshot/{utils.d.ts → snapshot/utils.d.ts} +0 -0
- /package/runtime/lib/snapshot/{utils.js → snapshot/utils.js} +0 -0
- /package/runtime/lib/snapshot/{workletEvent.d.ts → snapshot/workletEvent.d.ts} +0 -0
- /package/runtime/lib/snapshot/{workletEvent.js → snapshot/workletEvent.js} +0 -0
- /package/runtime/lib/snapshot/{workletRef.d.ts → snapshot/workletRef.d.ts} +0 -0
- /package/runtime/lib/snapshot/{workletRef.js → snapshot/workletRef.js} +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/execMap.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/execMap.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/transformToWorklet.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/call/transformToWorklet.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ctx.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ctx.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/destroy.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/destroy.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/functionality.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/hmr.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/hmr.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.js +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.d.ts +0 -0
- /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.js +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare const fireEvent: any;
|
|
2
|
+
export declare const eventMap: {
|
|
3
|
+
tap: {
|
|
4
|
+
defaultInit: {};
|
|
5
|
+
};
|
|
6
|
+
longtap: {
|
|
7
|
+
defaultInit: {};
|
|
8
|
+
};
|
|
9
|
+
bgload: {
|
|
10
|
+
defaultInit: {};
|
|
11
|
+
};
|
|
12
|
+
bgerror: {
|
|
13
|
+
defaultInit: {};
|
|
14
|
+
};
|
|
15
|
+
touchstart: {
|
|
16
|
+
defaultInit: {};
|
|
17
|
+
};
|
|
18
|
+
touchmove: {
|
|
19
|
+
defaultInit: {};
|
|
20
|
+
};
|
|
21
|
+
touchcancel: {
|
|
22
|
+
defaultInit: {};
|
|
23
|
+
};
|
|
24
|
+
touchend: {
|
|
25
|
+
defaultInit: {};
|
|
26
|
+
};
|
|
27
|
+
longpress: {
|
|
28
|
+
defaultInit: {};
|
|
29
|
+
};
|
|
30
|
+
transitionstart: {
|
|
31
|
+
defaultInit: {};
|
|
32
|
+
};
|
|
33
|
+
transitioncancel: {
|
|
34
|
+
defaultInit: {};
|
|
35
|
+
};
|
|
36
|
+
transitionend: {
|
|
37
|
+
defaultInit: {};
|
|
38
|
+
};
|
|
39
|
+
animationstart: {
|
|
40
|
+
defaultInit: {};
|
|
41
|
+
};
|
|
42
|
+
animationiteration: {
|
|
43
|
+
defaultInit: {};
|
|
44
|
+
};
|
|
45
|
+
animationcancel: {
|
|
46
|
+
defaultInit: {};
|
|
47
|
+
};
|
|
48
|
+
animationend: {
|
|
49
|
+
defaultInit: {};
|
|
50
|
+
};
|
|
51
|
+
mousedown: {
|
|
52
|
+
defaultInit: {};
|
|
53
|
+
};
|
|
54
|
+
mouseup: {
|
|
55
|
+
defaultInit: {};
|
|
56
|
+
};
|
|
57
|
+
mousemove: {
|
|
58
|
+
defaultInit: {};
|
|
59
|
+
};
|
|
60
|
+
mouseclick: {
|
|
61
|
+
defaultInit: {};
|
|
62
|
+
};
|
|
63
|
+
mousedblclick: {
|
|
64
|
+
defaultInit: {};
|
|
65
|
+
};
|
|
66
|
+
mouselongpress: {
|
|
67
|
+
defaultInit: {};
|
|
68
|
+
};
|
|
69
|
+
wheel: {
|
|
70
|
+
defaultInit: {};
|
|
71
|
+
};
|
|
72
|
+
keydown: {
|
|
73
|
+
defaultInit: {};
|
|
74
|
+
};
|
|
75
|
+
keyup: {
|
|
76
|
+
defaultInit: {};
|
|
77
|
+
};
|
|
78
|
+
focus: {
|
|
79
|
+
defaultInit: {};
|
|
80
|
+
};
|
|
81
|
+
blur: {
|
|
82
|
+
defaultInit: {};
|
|
83
|
+
};
|
|
84
|
+
layoutchange: {
|
|
85
|
+
defaultInit: {};
|
|
86
|
+
};
|
|
87
|
+
scrolltoupper: {
|
|
88
|
+
defaultInit: {};
|
|
89
|
+
};
|
|
90
|
+
scrolltolower: {
|
|
91
|
+
defaultInit: {};
|
|
92
|
+
};
|
|
93
|
+
scroll: {
|
|
94
|
+
defaultInit: {};
|
|
95
|
+
};
|
|
96
|
+
scrollend: {
|
|
97
|
+
defaultInit: {};
|
|
98
|
+
};
|
|
99
|
+
contentsizechanged: {
|
|
100
|
+
defaultInit: {};
|
|
101
|
+
};
|
|
102
|
+
scrolltoupperedge: {
|
|
103
|
+
defaultInit: {};
|
|
104
|
+
};
|
|
105
|
+
scrolltoloweredge: {
|
|
106
|
+
defaultInit: {};
|
|
107
|
+
};
|
|
108
|
+
scrolltonormalstate: {
|
|
109
|
+
defaultInit: {};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { act } from 'preact/test-utils';
|
|
2
2
|
import { ARIARole } from 'aria-query';
|
|
3
|
-
import { JSDOM } from 'jsdom';
|
|
4
3
|
import { OptionsReceived } from 'pretty-format';
|
|
5
4
|
import * as prettyFormat from 'pretty-format';
|
|
6
5
|
|
|
@@ -775,6 +774,7 @@ declare const initElementTree: () => {
|
|
|
775
774
|
__AddDataset(e: LynxElement, key: string, value: string): void;
|
|
776
775
|
__SetDataset(e: LynxElement, dataset: any): void;
|
|
777
776
|
__SetGestureDetector(e: LynxElement, id: number, type: number, config: any, relationMap: Record<string, number[]>): void;
|
|
777
|
+
__RemoveGestureDetector(e: LynxElement, id: number): void;
|
|
778
778
|
__GetDataset(e: LynxElement): DOMStringMap;
|
|
779
779
|
__RemoveElement(parent: LynxElement, child: LynxElement): void;
|
|
780
780
|
__InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement | undefined): void;
|
|
@@ -883,6 +883,15 @@ declare interface LynxElement extends HTMLElement {
|
|
|
883
883
|
parentNode: LynxElement;
|
|
884
884
|
}
|
|
885
885
|
|
|
886
|
+
/**
|
|
887
|
+
* The host environment used to initialize `LynxTestingEnv`.
|
|
888
|
+
*
|
|
889
|
+
* @public
|
|
890
|
+
*/
|
|
891
|
+
declare interface LynxEnv {
|
|
892
|
+
window: Window & typeof globalThis;
|
|
893
|
+
}
|
|
894
|
+
|
|
886
895
|
/**
|
|
887
896
|
* The `globalThis` object of Lynx dual thread environment.
|
|
888
897
|
*
|
|
@@ -904,8 +913,9 @@ declare interface LynxGlobalThis {
|
|
|
904
913
|
*
|
|
905
914
|
* ```ts
|
|
906
915
|
* import { LynxTestingEnv } from '@lynx-js/testing-environment';
|
|
916
|
+
* import { JSDOM } from 'jsdom';
|
|
907
917
|
*
|
|
908
|
-
* const lynxTestingEnv = new LynxTestingEnv(new JSDOM());
|
|
918
|
+
* const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
|
|
909
919
|
*
|
|
910
920
|
* lynxTestingEnv.switchToMainThread();
|
|
911
921
|
* // use the main thread Element PAPI
|
|
@@ -926,8 +936,9 @@ export declare class LynxTestingEnv {
|
|
|
926
936
|
*
|
|
927
937
|
* ```ts
|
|
928
938
|
* import { LynxTestingEnv } from '@lynx-js/testing-environment';
|
|
939
|
+
* import { JSDOM } from 'jsdom';
|
|
929
940
|
*
|
|
930
|
-
* const lynxTestingEnv = new LynxTestingEnv(new JSDOM());
|
|
941
|
+
* const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
|
|
931
942
|
*
|
|
932
943
|
* lynxTestingEnv.switchToBackgroundThread();
|
|
933
944
|
* // use the background thread global object
|
|
@@ -942,8 +953,9 @@ export declare class LynxTestingEnv {
|
|
|
942
953
|
*
|
|
943
954
|
* ```ts
|
|
944
955
|
* import { LynxTestingEnv } from '@lynx-js/testing-environment';
|
|
956
|
+
* import { JSDOM } from 'jsdom';
|
|
945
957
|
*
|
|
946
|
-
* const lynxTestingEnv = new LynxTestingEnv(new JSDOM());
|
|
958
|
+
* const lynxTestingEnv = new LynxTestingEnv({ window: new JSDOM().window });
|
|
947
959
|
*
|
|
948
960
|
* lynxTestingEnv.switchToMainThread();
|
|
949
961
|
* // use the main thread global object
|
|
@@ -953,8 +965,8 @@ export declare class LynxTestingEnv {
|
|
|
953
965
|
* ```
|
|
954
966
|
*/
|
|
955
967
|
mainThread: LynxGlobalThis & ElementTreeGlobals;
|
|
956
|
-
|
|
957
|
-
constructor(
|
|
968
|
+
env: LynxEnv;
|
|
969
|
+
constructor(env?: LynxEnv);
|
|
958
970
|
injectGlobals(): void;
|
|
959
971
|
switchToBackgroundThread(): void;
|
|
960
972
|
switchToMainThread(): void;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { VitestPackageInstaller } from "vitest/node";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createRequire } from "../881.js";
|
|
5
|
+
const vitest_filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const vitest_dirname = node_path.dirname(vitest_filename);
|
|
7
|
+
const vitest_require = createRequire(import.meta.url);
|
|
8
|
+
function testingLibraryPlugin(options) {
|
|
9
|
+
const runtimeOSSPkgName = '@lynx-js/react';
|
|
10
|
+
const runtimePkgName = options?.runtimePkgName ?? runtimeOSSPkgName;
|
|
11
|
+
const runtimeDir = node_path.dirname(vitest_require.resolve(`${runtimePkgName}/package.json`));
|
|
12
|
+
const runtimeOSSDir = node_path.dirname(vitest_require.resolve(`${runtimeOSSPkgName}/package.json`, {
|
|
13
|
+
paths: [
|
|
14
|
+
runtimeDir,
|
|
15
|
+
vitest_dirname
|
|
16
|
+
]
|
|
17
|
+
}));
|
|
18
|
+
const preactDir = node_path.dirname(vitest_require.resolve('preact/package.json', {
|
|
19
|
+
paths: [
|
|
20
|
+
runtimeOSSDir
|
|
21
|
+
]
|
|
22
|
+
}));
|
|
23
|
+
const runtimeOSSAlias = generateAlias(runtimeOSSPkgName, runtimeOSSDir, runtimeDir);
|
|
24
|
+
let runtimeAlias = [];
|
|
25
|
+
if (runtimePkgName !== runtimeOSSPkgName) runtimeAlias = generateAlias(runtimePkgName, runtimeDir, vitest_dirname);
|
|
26
|
+
const preactAlias = generateAlias('preact', preactDir, runtimeOSSDir);
|
|
27
|
+
preactAlias.forEach((alias)=>{
|
|
28
|
+
alias.replacement = alias.replacement.replace(/\.js$/, '.mjs');
|
|
29
|
+
});
|
|
30
|
+
const reactAlias = [
|
|
31
|
+
{
|
|
32
|
+
find: /^react$/,
|
|
33
|
+
replacement: vitest_require.resolve(runtimeOSSPkgName, {
|
|
34
|
+
paths: [
|
|
35
|
+
runtimeDir,
|
|
36
|
+
vitest_dirname
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
find: /^react\/jsx-runtime$/,
|
|
42
|
+
replacement: vitest_require.resolve(node_path.posix.join(runtimeOSSPkgName, 'jsx-runtime'), {
|
|
43
|
+
paths: [
|
|
44
|
+
runtimeDir,
|
|
45
|
+
vitest_dirname
|
|
46
|
+
]
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
find: /^react\/jsx-dev-runtime$/,
|
|
51
|
+
replacement: vitest_require.resolve(node_path.posix.join(runtimeOSSPkgName, 'jsx-dev-runtime'), {
|
|
52
|
+
paths: [
|
|
53
|
+
runtimeDir,
|
|
54
|
+
vitest_dirname
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
function transformReactCompilerPlugin() {
|
|
60
|
+
let rootContext, compilerDeps, babel;
|
|
61
|
+
function resolveCompilerDeps(rootContext) {
|
|
62
|
+
const missingBabelPackages = [];
|
|
63
|
+
const [babelPath, babelPluginReactCompilerPath, babelPluginSyntaxJsxPath, babelPluginSyntaxTypescriptPath] = [
|
|
64
|
+
'@babel/core',
|
|
65
|
+
'babel-plugin-react-compiler',
|
|
66
|
+
'@babel/plugin-syntax-jsx',
|
|
67
|
+
"@babel/plugin-syntax-typescript"
|
|
68
|
+
].map((name)=>{
|
|
69
|
+
try {
|
|
70
|
+
return vitest_require.resolve(name, {
|
|
71
|
+
paths: [
|
|
72
|
+
rootContext
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
} catch {
|
|
76
|
+
missingBabelPackages.push(name);
|
|
77
|
+
}
|
|
78
|
+
return '';
|
|
79
|
+
});
|
|
80
|
+
if (missingBabelPackages.length > 0) throw new Error(`With \`experimental_enableReactCompiler\` enabled, you need to install \`${missingBabelPackages.join('`, `')}\` in your project root to use React Compiler.`);
|
|
81
|
+
return {
|
|
82
|
+
babelPath,
|
|
83
|
+
babelPluginReactCompilerPath,
|
|
84
|
+
babelPluginSyntaxJsxPath,
|
|
85
|
+
babelPluginSyntaxTypescriptPath
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
name: 'transformReactCompilerPlugin',
|
|
90
|
+
enforce: 'pre',
|
|
91
|
+
config (config) {
|
|
92
|
+
rootContext = config.root;
|
|
93
|
+
const reactCompilerRuntimeAlias = [];
|
|
94
|
+
try {
|
|
95
|
+
reactCompilerRuntimeAlias.push({
|
|
96
|
+
find: /^react-compiler-runtime$/,
|
|
97
|
+
replacement: node_path.join(node_path.dirname(vitest_require.resolve('react-compiler-runtime/package.json', {
|
|
98
|
+
paths: [
|
|
99
|
+
rootContext
|
|
100
|
+
]
|
|
101
|
+
})), 'src', 'index.ts')
|
|
102
|
+
});
|
|
103
|
+
} catch (e) {}
|
|
104
|
+
let mergedAlias = [
|
|
105
|
+
...reactCompilerRuntimeAlias
|
|
106
|
+
];
|
|
107
|
+
if (config.test?.alias) mergedAlias = Array.isArray(config.test.alias) ? [
|
|
108
|
+
...config.test.alias,
|
|
109
|
+
...mergedAlias
|
|
110
|
+
] : [
|
|
111
|
+
...Object.entries(config.test.alias).map(([key, value])=>({
|
|
112
|
+
find: key,
|
|
113
|
+
replacement: value
|
|
114
|
+
})),
|
|
115
|
+
...mergedAlias
|
|
116
|
+
];
|
|
117
|
+
config.test = config.test || {};
|
|
118
|
+
config.test.alias = mergedAlias;
|
|
119
|
+
compilerDeps = resolveCompilerDeps(rootContext);
|
|
120
|
+
const { babelPath } = compilerDeps;
|
|
121
|
+
babel = vitest_require(babelPath);
|
|
122
|
+
},
|
|
123
|
+
async transform (sourceText, sourcePath) {
|
|
124
|
+
if (/\.(?:jsx|tsx)$/.test(sourcePath)) {
|
|
125
|
+
const { babelPluginReactCompilerPath, babelPluginSyntaxJsxPath, babelPluginSyntaxTypescriptPath } = compilerDeps;
|
|
126
|
+
const isTSX = sourcePath.endsWith('.tsx');
|
|
127
|
+
try {
|
|
128
|
+
const result = babel.transformSync(sourceText, {
|
|
129
|
+
plugins: [
|
|
130
|
+
[
|
|
131
|
+
babelPluginReactCompilerPath,
|
|
132
|
+
{
|
|
133
|
+
target: '17'
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
babelPluginSyntaxJsxPath,
|
|
137
|
+
isTSX ? [
|
|
138
|
+
babelPluginSyntaxTypescriptPath,
|
|
139
|
+
{
|
|
140
|
+
isTSX: true
|
|
141
|
+
}
|
|
142
|
+
] : null
|
|
143
|
+
].filter(Boolean),
|
|
144
|
+
filename: sourcePath,
|
|
145
|
+
ast: false,
|
|
146
|
+
sourceMaps: true
|
|
147
|
+
});
|
|
148
|
+
if (result?.code != null && result?.map != null) return {
|
|
149
|
+
code: result.code,
|
|
150
|
+
map: result.map
|
|
151
|
+
};
|
|
152
|
+
this.error(`babel-plugin-react-compiler transform failed for ${sourcePath}: ${result ? 'missing code or map' : 'no result'}`);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
this.error(e);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
let config;
|
|
162
|
+
function transformReactLynxPlugin() {
|
|
163
|
+
return {
|
|
164
|
+
name: 'transformReactLynxPlugin',
|
|
165
|
+
enforce: 'pre',
|
|
166
|
+
async buildStart () {
|
|
167
|
+
await ensurePackagesInstalled();
|
|
168
|
+
},
|
|
169
|
+
transform (sourceText, sourcePath) {
|
|
170
|
+
const id = sourcePath;
|
|
171
|
+
const regex = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)(\?.*)?$/;
|
|
172
|
+
if (!regex.test(id)) return null;
|
|
173
|
+
const { transformReactLynxSync } = vitest_require('@lynx-js/react/transform');
|
|
174
|
+
const relativePath = normalizeSlashes(node_path.relative(config.root, sourcePath));
|
|
175
|
+
const basename = node_path.basename(sourcePath);
|
|
176
|
+
const result = transformReactLynxSync(sourceText, {
|
|
177
|
+
mode: 'test',
|
|
178
|
+
pluginName: '',
|
|
179
|
+
filename: basename,
|
|
180
|
+
sourcemap: true,
|
|
181
|
+
snapshot: {
|
|
182
|
+
preserveJsx: false,
|
|
183
|
+
runtimePkg: `${runtimePkgName}/internal`,
|
|
184
|
+
jsxImportSource: runtimePkgName,
|
|
185
|
+
filename: relativePath,
|
|
186
|
+
target: 'MIXED'
|
|
187
|
+
},
|
|
188
|
+
engineVersion: options?.engineVersion ?? '',
|
|
189
|
+
dynamicImport: {
|
|
190
|
+
injectLazyBundle: false,
|
|
191
|
+
layer: 'test',
|
|
192
|
+
runtimePkg: `${runtimePkgName}/internal`
|
|
193
|
+
},
|
|
194
|
+
directiveDCE: false,
|
|
195
|
+
defineDCE: false,
|
|
196
|
+
shake: false,
|
|
197
|
+
compat: false,
|
|
198
|
+
worklet: {
|
|
199
|
+
filename: relativePath,
|
|
200
|
+
runtimePkg: `${runtimePkgName}/internal`,
|
|
201
|
+
target: 'MIXED'
|
|
202
|
+
},
|
|
203
|
+
refresh: false,
|
|
204
|
+
cssScope: false
|
|
205
|
+
});
|
|
206
|
+
if (result.errors.length > 0) result.errors.forEach((error)=>{
|
|
207
|
+
this.error(error.text ?? 'Unknown error', {
|
|
208
|
+
line: 1,
|
|
209
|
+
column: 1,
|
|
210
|
+
...error.location
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
if (result.warnings.length > 0) result.warnings.forEach((warning)=>{
|
|
214
|
+
this.warn(warning.text ?? 'Unknown warning', {
|
|
215
|
+
line: 1,
|
|
216
|
+
column: 1,
|
|
217
|
+
...warning.location
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
code: result.code,
|
|
222
|
+
map: result.map
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
config: ()=>({
|
|
226
|
+
test: {
|
|
227
|
+
environment: vitest_require.resolve(`${runtimeOSSDir}/testing-library/dist/env/vitest`),
|
|
228
|
+
globals: true,
|
|
229
|
+
setupFiles: [
|
|
230
|
+
vitest_require.resolve('../setupFiles/vitest')
|
|
231
|
+
],
|
|
232
|
+
alias: [
|
|
233
|
+
...runtimeOSSAlias,
|
|
234
|
+
...runtimeAlias,
|
|
235
|
+
...preactAlias,
|
|
236
|
+
...reactAlias
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
}),
|
|
240
|
+
configResolved (_config) {
|
|
241
|
+
config = _config;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return [
|
|
246
|
+
...options?.experimental_enableReactCompiler ? [
|
|
247
|
+
transformReactCompilerPlugin()
|
|
248
|
+
] : [],
|
|
249
|
+
transformReactLynxPlugin()
|
|
250
|
+
];
|
|
251
|
+
}
|
|
252
|
+
async function ensurePackagesInstalled() {
|
|
253
|
+
const installer = new VitestPackageInstaller();
|
|
254
|
+
const installed = await installer.ensureInstalled('jsdom', process.cwd());
|
|
255
|
+
if (!installed) {
|
|
256
|
+
console.log('ReactLynx Testing Library requires jsdom to be installed.');
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function generateAlias(pkgName, pkgDir, resolveDir) {
|
|
261
|
+
const pkgExports = vitest_require(node_path.join(pkgDir, 'package.json')).exports;
|
|
262
|
+
if (!pkgExports || 'object' != typeof pkgExports) return [];
|
|
263
|
+
const pkgAlias = [];
|
|
264
|
+
Object.keys(pkgExports).forEach((key)=>{
|
|
265
|
+
const name = node_path.posix.join(pkgName, key);
|
|
266
|
+
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
267
|
+
pkgAlias.push({
|
|
268
|
+
find: new RegExp('^' + escapedName + '$'),
|
|
269
|
+
replacement: vitest_require.resolve(name, {
|
|
270
|
+
paths: [
|
|
271
|
+
resolveDir,
|
|
272
|
+
vitest_dirname
|
|
273
|
+
]
|
|
274
|
+
})
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
return pkgAlias;
|
|
278
|
+
}
|
|
279
|
+
function normalizeSlashes(file) {
|
|
280
|
+
return file.replaceAll(node_path.win32.sep, '/');
|
|
281
|
+
}
|
|
282
|
+
export { testingLibraryPlugin as vitestTestingLibraryPlugin };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Vite } from 'vitest/node';
|
|
2
|
+
export interface TestingLibraryOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The package name of the ReactLynx runtime package.
|
|
5
|
+
*
|
|
6
|
+
* @default `@lynx-js/react`
|
|
7
|
+
*/
|
|
8
|
+
runtimePkgName?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The engine version to use for the transform.
|
|
11
|
+
*
|
|
12
|
+
* @default `''`
|
|
13
|
+
*/
|
|
14
|
+
engineVersion?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Enable experimental React Compiler support.
|
|
17
|
+
*
|
|
18
|
+
* Requires `@babel/core`, `babel-plugin-react-compiler`,
|
|
19
|
+
* `@babel/plugin-syntax-jsx`, and `@babel/plugin-syntax-typescript`
|
|
20
|
+
* to be installed in your project.
|
|
21
|
+
*
|
|
22
|
+
* @default `false`
|
|
23
|
+
*/
|
|
24
|
+
experimental_enableReactCompiler?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function testingLibraryPlugin(options?: TestingLibraryOptions): Vite.PluginOption;
|
|
@@ -5,7 +5,7 @@ import { cloneElement, createRef, h, render } from "preact";
|
|
|
5
5
|
import { useEffect } from "preact/hooks";
|
|
6
6
|
import { act } from "preact/test-utils";
|
|
7
7
|
import { __root } from "@lynx-js/react/internal";
|
|
8
|
-
import { flushDelayedLifecycleEvents } from "../../runtime/lib/lynx/tt.js";
|
|
8
|
+
import { flushDelayedLifecycleEvents } from "../../runtime/lib/snapshot/lynx/tt.js";
|
|
9
9
|
import { clearPage } from "../../runtime/lib/snapshot/index.js";
|
|
10
10
|
__webpack_require__.add({
|
|
11
11
|
"../../../node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js" (module1) {
|
|
@@ -14461,8 +14461,8 @@ function pure_render(ui, { queries, wrapper: WrapperComponent, enableMainThread
|
|
|
14461
14461
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
14462
14462
|
act(()=>{
|
|
14463
14463
|
render(compBackgroundThread, __root);
|
|
14464
|
-
flushDelayedLifecycleEvents();
|
|
14465
14464
|
});
|
|
14465
|
+
flushDelayedLifecycleEvents();
|
|
14466
14466
|
}
|
|
14467
14467
|
return {
|
|
14468
14468
|
container: lynxTestingEnv.mainThread.elementTree.root,
|
|
@@ -14477,7 +14477,7 @@ function pure_render(ui, { queries, wrapper: WrapperComponent, enableMainThread
|
|
|
14477
14477
|
});
|
|
14478
14478
|
},
|
|
14479
14479
|
asFragment: ()=>{
|
|
14480
|
-
const { document: document1 } = lynxTestingEnv.
|
|
14480
|
+
const { document: document1 } = lynxTestingEnv.env.window;
|
|
14481
14481
|
const container = lynxTestingEnv.mainThread.elementTree.root;
|
|
14482
14482
|
if ('function' == typeof document1.createRange) return document1.createRange().createContextualFragment(container.innerHTML);
|
|
14483
14483
|
{
|
|
@@ -14497,7 +14497,7 @@ function cleanup() {
|
|
|
14497
14497
|
});
|
|
14498
14498
|
lynxTestingEnv.mainThread.elementTree.root = void 0;
|
|
14499
14499
|
clearPage();
|
|
14500
|
-
lynxTestingEnv.
|
|
14500
|
+
lynxTestingEnv.env.window.document.body.innerHTML = '';
|
|
14501
14501
|
if (isMainThread) globalThis.lynxTestingEnv.switchToMainThread();
|
|
14502
14502
|
}
|
|
14503
14503
|
function renderHook(renderCallback, options) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExtendConfig, ExtendConfigFn } from '@rstest/core';
|
|
2
|
+
export interface LynxConfigOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The root path of the project.
|
|
5
|
+
*
|
|
6
|
+
* @default `process.cwd()`
|
|
7
|
+
*/
|
|
8
|
+
rootPath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The path to the Lynx config file.
|
|
11
|
+
*
|
|
12
|
+
* @default `lynx.config.ts`
|
|
13
|
+
*/
|
|
14
|
+
configPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RstestConfigOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Customize the generated rstest config.
|
|
19
|
+
*/
|
|
20
|
+
modifyRstestConfig?: (config: ExtendConfig) => ExtendConfig | Promise<ExtendConfig>;
|
|
21
|
+
}
|
|
22
|
+
export interface LynxRstestConfigOptions extends LynxConfigOptions, RstestConfigOptions {
|
|
23
|
+
}
|
|
24
|
+
export declare function withDefaultConfig(options?: RstestConfigOptions): ExtendConfigFn;
|
|
25
|
+
export declare function withLynxConfig(options?: LynxRstestConfigOptions): ExtendConfigFn;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createRequire } from "./881.js";
|
|
2
|
+
const rstest_config_require = createRequire(import.meta.url);
|
|
3
|
+
function createDefaultRstestConfig() {
|
|
4
|
+
return {
|
|
5
|
+
testEnvironment: 'jsdom',
|
|
6
|
+
setupFiles: [
|
|
7
|
+
rstest_config_require.resolve('./setupFiles/rstest')
|
|
8
|
+
],
|
|
9
|
+
globals: true
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function normalizeSetupFiles(setupFiles) {
|
|
13
|
+
if (!setupFiles) return [];
|
|
14
|
+
return Array.isArray(setupFiles) ? setupFiles : [
|
|
15
|
+
setupFiles
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
async function applyRstestConfigModifier(config, modifyRstestConfig) {
|
|
19
|
+
if (!modifyRstestConfig) return config;
|
|
20
|
+
return await modifyRstestConfig(config);
|
|
21
|
+
}
|
|
22
|
+
function withDefaultConfig(options) {
|
|
23
|
+
return async ()=>await applyRstestConfigModifier(createDefaultRstestConfig(), options?.modifyRstestConfig);
|
|
24
|
+
}
|
|
25
|
+
function withLynxConfig(options) {
|
|
26
|
+
return async ()=>{
|
|
27
|
+
const { loadConfig } = await import("@lynx-js/rspeedy");
|
|
28
|
+
const lynxConfig = await loadConfig({
|
|
29
|
+
cwd: options?.rootPath,
|
|
30
|
+
configPath: options?.configPath
|
|
31
|
+
});
|
|
32
|
+
const { toRstestConfig } = await import("./0~123.js").then((mod)=>({
|
|
33
|
+
toRstestConfig: mod.toRstestConfig
|
|
34
|
+
}));
|
|
35
|
+
const rstestConfig = toRstestConfig({
|
|
36
|
+
rsbuildConfig: lynxConfig.content
|
|
37
|
+
});
|
|
38
|
+
const defaultConfig = createDefaultRstestConfig();
|
|
39
|
+
const setupFiles = Array.from(new Set([
|
|
40
|
+
...normalizeSetupFiles(rstestConfig.setupFiles),
|
|
41
|
+
...normalizeSetupFiles(defaultConfig.setupFiles)
|
|
42
|
+
]));
|
|
43
|
+
const mergedConfig = {
|
|
44
|
+
...rstestConfig,
|
|
45
|
+
...defaultConfig,
|
|
46
|
+
plugins: [
|
|
47
|
+
...rstestConfig.plugins || [],
|
|
48
|
+
{
|
|
49
|
+
name: 'lynx-adapter:remove-useless-plugins',
|
|
50
|
+
remove: [
|
|
51
|
+
'lynx:rsbuild:qrcode'
|
|
52
|
+
],
|
|
53
|
+
setup: ()=>{}
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
setupFiles
|
|
57
|
+
};
|
|
58
|
+
return await applyRstestConfigModifier(mergedConfig, options?.modifyRstestConfig);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export { withDefaultConfig, withLynxConfig };
|