@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
|
@@ -1,673 +1,19 @@
|
|
|
1
1
|
import { builtinEnvironments } from "vitest/environments";
|
|
2
|
-
import
|
|
3
|
-
import { Console } from "console";
|
|
4
|
-
function util_define(object, properties) {
|
|
5
|
-
for (const name of Object.getOwnPropertyNames(properties)){
|
|
6
|
-
const propDesc = Object.getOwnPropertyDescriptor(properties, name);
|
|
7
|
-
Object.defineProperty(object, name, propDesc);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function installOwnProperties(globalThis1) {
|
|
11
|
-
util_define(globalThis1, {
|
|
12
|
-
get globalThis () {
|
|
13
|
-
return globalThis1._globalProxy;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
const createGlobalThis = ()=>{
|
|
18
|
-
const globalThis1 = {};
|
|
19
|
-
globalThis1._globalObject = globalThis1._globalProxy = globalThis1;
|
|
20
|
-
installOwnProperties(globalThis1);
|
|
21
|
-
return globalThis1;
|
|
22
|
-
};
|
|
23
|
-
function _define_property(obj, key, value) {
|
|
24
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
25
|
-
value: value,
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true
|
|
29
|
-
});
|
|
30
|
-
else obj[key] = value;
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
const initElementTree = ()=>{
|
|
34
|
-
let uiSignNext = 0;
|
|
35
|
-
return new class {
|
|
36
|
-
countElement(element, parentComponentUniqueId) {
|
|
37
|
-
element.$$uiSign = uiSignNext++;
|
|
38
|
-
this.uniqueId2Element.set(element.$$uiSign, element);
|
|
39
|
-
element.parentComponentUniqueId = parentComponentUniqueId;
|
|
40
|
-
}
|
|
41
|
-
__CreatePage(_tag, parentComponentUniqueId) {
|
|
42
|
-
const page = this.__CreateElement('page', parentComponentUniqueId);
|
|
43
|
-
this.root = page;
|
|
44
|
-
document.body.innerHTML = '';
|
|
45
|
-
lynxTestingEnv.jsdom.window.document.body.appendChild(page);
|
|
46
|
-
return page;
|
|
47
|
-
}
|
|
48
|
-
__CreateRawText(text) {
|
|
49
|
-
const element = lynxTestingEnv.jsdom.window.document.createTextNode(text);
|
|
50
|
-
this.countElement(element, 0);
|
|
51
|
-
return element;
|
|
52
|
-
}
|
|
53
|
-
__GetElementUniqueID(e) {
|
|
54
|
-
return e.$$uiSign;
|
|
55
|
-
}
|
|
56
|
-
__SetClasses(e, cls) {
|
|
57
|
-
e.className = cls;
|
|
58
|
-
}
|
|
59
|
-
__CreateElement(tag, parentComponentUniqueId) {
|
|
60
|
-
if ('raw-text' === tag) return this.__CreateRawText('');
|
|
61
|
-
const element = lynxTestingEnv.jsdom.window.document.createElement(tag);
|
|
62
|
-
this.countElement(element, parentComponentUniqueId);
|
|
63
|
-
return element;
|
|
64
|
-
}
|
|
65
|
-
__CreateView(parentComponentUniqueId) {
|
|
66
|
-
return this.__CreateElement('view', parentComponentUniqueId);
|
|
67
|
-
}
|
|
68
|
-
__CreateScrollView(parentComponentUniqueId) {
|
|
69
|
-
return this.__CreateElement('scroll-view', parentComponentUniqueId);
|
|
70
|
-
}
|
|
71
|
-
__FirstElement(e) {
|
|
72
|
-
return e.firstChild;
|
|
73
|
-
}
|
|
74
|
-
__CreateText(parentComponentUniqueId) {
|
|
75
|
-
return this.__CreateElement('text', parentComponentUniqueId);
|
|
76
|
-
}
|
|
77
|
-
__CreateImage(parentComponentUniqueId) {
|
|
78
|
-
return this.__CreateElement('image', parentComponentUniqueId);
|
|
79
|
-
}
|
|
80
|
-
__CreateWrapperElement(parentComponentUniqueId) {
|
|
81
|
-
return this.__CreateElement('wrapper', parentComponentUniqueId);
|
|
82
|
-
}
|
|
83
|
-
__AddInlineStyle(e, key, value) {
|
|
84
|
-
e.style[key] = value;
|
|
85
|
-
}
|
|
86
|
-
__AppendElement(parent, child) {
|
|
87
|
-
parent.appendChild(child);
|
|
88
|
-
}
|
|
89
|
-
__SetCSSId(e, id, entryName) {
|
|
90
|
-
const cssId = `${entryName ?? '__Card__'}:${id}`;
|
|
91
|
-
if (Array.isArray(e)) e.forEach((item)=>{
|
|
92
|
-
item.cssId = cssId;
|
|
93
|
-
});
|
|
94
|
-
else e.cssId = cssId;
|
|
95
|
-
}
|
|
96
|
-
__SetAttribute(e, key, value) {
|
|
97
|
-
if ('style' === key || 'class' === key || 'className' === key || 'key' === key || 'id' === key || 'ref' === key || /^data-/.exec(key) || /^(bind|catch|global-bind|capture-bind|capture-catch)[A-Za-z]/.exec(key)) throw new Error(`Cannot use __SetAttribute for "${key}"`);
|
|
98
|
-
if ('update-list-info' === key) {
|
|
99
|
-
let listInfoStr = e.getAttribute(key);
|
|
100
|
-
let listInfo = listInfoStr ? JSON.parse(listInfoStr) : [];
|
|
101
|
-
listInfo.push(value);
|
|
102
|
-
e.setAttribute(key, JSON.stringify(listInfo));
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if ('text' === key) {
|
|
106
|
-
e.textContent = value;
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (null === value) return void e.removeAttribute(key);
|
|
110
|
-
if ('string' == typeof value) return void e.setAttribute(key, value);
|
|
111
|
-
e.setAttribute(key, JSON.stringify(value));
|
|
112
|
-
}
|
|
113
|
-
__AddEvent(e, eventType, eventName, eventHandler) {
|
|
114
|
-
if (e.eventMap?.[`${eventType}:${eventName}`]) {
|
|
115
|
-
e.removeEventListener(`${eventType}:${eventName}`, e.eventMap[`${eventType}:${eventName}`]);
|
|
116
|
-
delete e.eventMap[`${eventType}:${eventName}`];
|
|
117
|
-
}
|
|
118
|
-
if (void 0 === eventHandler) return;
|
|
119
|
-
if ('string' != typeof eventHandler && void 0 === eventHandler['type']) throw new Error(`event must be string, but got ${typeof eventHandler}`);
|
|
120
|
-
const listener = (evt)=>{
|
|
121
|
-
if ('object' == typeof eventHandler && 'worklet' === eventHandler['type']) {
|
|
122
|
-
const isBackground = !__MAIN_THREAD__;
|
|
123
|
-
globalThis.lynxTestingEnv.switchToMainThread();
|
|
124
|
-
runWorklet(eventHandler.value, [
|
|
125
|
-
Object.assign({}, evt)
|
|
126
|
-
]);
|
|
127
|
-
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
128
|
-
} else {
|
|
129
|
-
if ('catchEvent' === eventType || 'capture-catch' === eventType) evt.stopPropagation();
|
|
130
|
-
globalThis.lynxCoreInject.tt.publishEvent(eventHandler, evt);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
e.eventMap = e.eventMap ?? {};
|
|
134
|
-
e.eventMap[`${eventType}:${eventName}`] = listener;
|
|
135
|
-
e.addEventListener(`${eventType}:${eventName}`, listener, {
|
|
136
|
-
capture: 'capture-bind' === eventType || 'capture-catch' === eventType
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
__GetEvent(e, eventType, eventName) {
|
|
140
|
-
const jsFunction = e.eventMap?.[`${eventType}:${eventName}`];
|
|
141
|
-
if (void 0 !== jsFunction) return {
|
|
142
|
-
type: eventType,
|
|
143
|
-
name: eventName,
|
|
144
|
-
jsFunction
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
__SetID(e, id) {
|
|
148
|
-
e.id = id;
|
|
149
|
-
}
|
|
150
|
-
__SetInlineStyles(e, styles) {
|
|
151
|
-
if ('string' == typeof styles) e.setAttributeNS(null, 'style', styles);
|
|
152
|
-
else Object.assign(e.style, styles);
|
|
153
|
-
}
|
|
154
|
-
__AddDataset(e, key, value) {
|
|
155
|
-
e.dataset[key] = value;
|
|
156
|
-
}
|
|
157
|
-
__SetDataset(e, dataset) {
|
|
158
|
-
Object.assign(e.dataset, dataset);
|
|
159
|
-
}
|
|
160
|
-
__SetGestureDetector(e, id, type, config, relationMap) {
|
|
161
|
-
e.gesture = {
|
|
162
|
-
id,
|
|
163
|
-
type,
|
|
164
|
-
config,
|
|
165
|
-
relationMap
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
__GetDataset(e) {
|
|
169
|
-
return e.dataset;
|
|
170
|
-
}
|
|
171
|
-
__RemoveElement(parent, child) {
|
|
172
|
-
let ch = parent.firstChild;
|
|
173
|
-
while(ch){
|
|
174
|
-
if (ch === child) {
|
|
175
|
-
parent.removeChild(ch);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
ch = ch.nextSibling;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
__InsertElementBefore(parent, child, ref) {
|
|
182
|
-
if (void 0 === ref) parent.appendChild(child);
|
|
183
|
-
else parent.insertBefore(child, ref);
|
|
184
|
-
}
|
|
185
|
-
__ReplaceElement(newElement, oldElement) {
|
|
186
|
-
const parent = oldElement.parentNode;
|
|
187
|
-
if (!parent) throw new Error('unreachable');
|
|
188
|
-
parent.replaceChild(newElement, oldElement);
|
|
189
|
-
}
|
|
190
|
-
__FlushElementTree() {}
|
|
191
|
-
__UpdateListComponents(_list, _components) {}
|
|
192
|
-
__UpdateListCallbacks(list, componentAtIndex, enqueueComponent) {
|
|
193
|
-
Object.defineProperties(list, {
|
|
194
|
-
componentAtIndex: {
|
|
195
|
-
enumerable: false,
|
|
196
|
-
configurable: true,
|
|
197
|
-
value: componentAtIndex
|
|
198
|
-
},
|
|
199
|
-
enqueueComponent: {
|
|
200
|
-
enumerable: false,
|
|
201
|
-
configurable: true,
|
|
202
|
-
value: enqueueComponent
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
__CreateList(parentComponentUniqueId, componentAtIndex, enqueueComponent) {
|
|
207
|
-
const e = this.__CreateElement('list', parentComponentUniqueId);
|
|
208
|
-
Object.defineProperties(e, {
|
|
209
|
-
componentAtIndex: {
|
|
210
|
-
enumerable: false,
|
|
211
|
-
configurable: true,
|
|
212
|
-
value: componentAtIndex
|
|
213
|
-
},
|
|
214
|
-
enqueueComponent: {
|
|
215
|
-
enumerable: false,
|
|
216
|
-
configurable: true,
|
|
217
|
-
value: enqueueComponent
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
return e;
|
|
221
|
-
}
|
|
222
|
-
__GetTag(ele) {
|
|
223
|
-
return ele.nodeName;
|
|
224
|
-
}
|
|
225
|
-
__GetAttributeByName(ele, name) {
|
|
226
|
-
return ele.getAttribute(name);
|
|
227
|
-
}
|
|
228
|
-
__ElementAnimate(element, args) {
|
|
229
|
-
const [operation, name] = args;
|
|
230
|
-
switch(operation){
|
|
231
|
-
case 0:
|
|
232
|
-
{
|
|
233
|
-
const keyframes = args[2];
|
|
234
|
-
const options = args[3];
|
|
235
|
-
this.animationMap.set(name, {
|
|
236
|
-
element,
|
|
237
|
-
state: 'running',
|
|
238
|
-
keyframes,
|
|
239
|
-
options
|
|
240
|
-
});
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
case 1:
|
|
244
|
-
{
|
|
245
|
-
const anim = this.animationMap.get(name);
|
|
246
|
-
if (anim) anim.state = 'running';
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case 2:
|
|
250
|
-
{
|
|
251
|
-
const anim = this.animationMap.get(name);
|
|
252
|
-
if (anim) anim.state = 'paused';
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
case 3:
|
|
256
|
-
this.animationMap.delete(name);
|
|
257
|
-
break;
|
|
258
|
-
case 4:
|
|
259
|
-
{
|
|
260
|
-
const anim = this.animationMap.get(name);
|
|
261
|
-
if (anim) anim.state = 'finished';
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
clear() {
|
|
267
|
-
this.root = void 0;
|
|
268
|
-
}
|
|
269
|
-
toTree() {
|
|
270
|
-
return this.root;
|
|
271
|
-
}
|
|
272
|
-
enterListItemAtIndex(e, index, ...args) {
|
|
273
|
-
const { componentAtIndex, $$uiSign } = e;
|
|
274
|
-
return componentAtIndex(e, $$uiSign, index, ...args);
|
|
275
|
-
}
|
|
276
|
-
leaveListItem(e, uiSign) {
|
|
277
|
-
const { enqueueComponent, $$uiSign } = e;
|
|
278
|
-
enqueueComponent(e, $$uiSign, uiSign);
|
|
279
|
-
}
|
|
280
|
-
toJSON() {
|
|
281
|
-
return this.toTree();
|
|
282
|
-
}
|
|
283
|
-
__GetElementByUniqueId(uniqueId) {
|
|
284
|
-
return this.uniqueId2Element.get(uniqueId);
|
|
285
|
-
}
|
|
286
|
-
constructor(){
|
|
287
|
-
_define_property(this, "uniqueId2Element", new Map());
|
|
288
|
-
_define_property(this, "root", void 0);
|
|
289
|
-
_define_property(this, "animationMap", new Map());
|
|
290
|
-
}
|
|
291
|
-
}();
|
|
292
|
-
};
|
|
293
|
-
function GlobalEventEmitter_define_property(obj, key, value) {
|
|
294
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
295
|
-
value: value,
|
|
296
|
-
enumerable: true,
|
|
297
|
-
configurable: true,
|
|
298
|
-
writable: true
|
|
299
|
-
});
|
|
300
|
-
else obj[key] = value;
|
|
301
|
-
return obj;
|
|
302
|
-
}
|
|
303
|
-
class GlobalEventEmitter {
|
|
304
|
-
addListener(eventName, listener) {
|
|
305
|
-
this.listeners[eventName] ??= [];
|
|
306
|
-
this.listeners[eventName].push(listener);
|
|
307
|
-
}
|
|
308
|
-
removeListener(eventName, listener) {
|
|
309
|
-
if (!this.listeners[eventName]) return;
|
|
310
|
-
this.listeners[eventName] = this.listeners[eventName].filter((l)=>l !== listener);
|
|
311
|
-
}
|
|
312
|
-
emit(eventName, args) {
|
|
313
|
-
if (!this.listeners[eventName]) return;
|
|
314
|
-
this.listeners[eventName].forEach((listener)=>args ? listener(...args) : listener());
|
|
315
|
-
}
|
|
316
|
-
clear() {
|
|
317
|
-
this.listeners = {};
|
|
318
|
-
}
|
|
319
|
-
removeAllListeners(eventName) {
|
|
320
|
-
if (eventName) delete this.listeners[eventName];
|
|
321
|
-
else this.clear();
|
|
322
|
-
}
|
|
323
|
-
trigger(eventName, params) {
|
|
324
|
-
this.emit(eventName, [
|
|
325
|
-
params
|
|
326
|
-
]);
|
|
327
|
-
}
|
|
328
|
-
toggle(eventName, ...data) {
|
|
329
|
-
this.emit(eventName, data);
|
|
330
|
-
}
|
|
331
|
-
constructor(){
|
|
332
|
-
GlobalEventEmitter_define_property(this, "listeners", {});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function dist_define_property(obj, key, value) {
|
|
336
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
337
|
-
value: value,
|
|
338
|
-
enumerable: true,
|
|
339
|
-
configurable: true,
|
|
340
|
-
writable: true
|
|
341
|
-
});
|
|
342
|
-
else obj[key] = value;
|
|
343
|
-
return obj;
|
|
344
|
-
}
|
|
345
|
-
function __injectElementApi(target) {
|
|
346
|
-
const elementTree1 = initElementTree();
|
|
347
|
-
target.elementTree = elementTree1;
|
|
348
|
-
if (void 0 === target) target = globalThis;
|
|
349
|
-
for (const k of Object.getOwnPropertyNames(elementTree1.constructor.prototype))if (k.startsWith('__')) target[k] = elementTree1[k].bind(elementTree1);
|
|
350
|
-
target.$kTemplateAssembler = {};
|
|
351
|
-
target.registerDataProcessor = ()=>{
|
|
352
|
-
console.error('registerDataProcessor is not implemented');
|
|
353
|
-
};
|
|
354
|
-
target.__OnLifecycleEvent = (...args)=>{
|
|
355
|
-
const isMainThread = __MAIN_THREAD__;
|
|
356
|
-
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
357
|
-
globalThis.lynxCoreInject.tt.OnLifecycleEvent(...args);
|
|
358
|
-
if (isMainThread) globalThis.lynxTestingEnv.switchToMainThread();
|
|
359
|
-
};
|
|
360
|
-
target._ReportError = ()=>{};
|
|
361
|
-
}
|
|
362
|
-
function createPolyfills() {
|
|
363
|
-
const app = {
|
|
364
|
-
callLepusMethod: (...rLynxChange)=>{
|
|
365
|
-
const isBackground = !__MAIN_THREAD__;
|
|
366
|
-
globalThis.lynxTestingEnv.switchToMainThread();
|
|
367
|
-
globalThis[rLynxChange[0]](rLynxChange[1]);
|
|
368
|
-
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
369
|
-
rLynxChange[2]?.();
|
|
370
|
-
globalThis.lynxTestingEnv.switchToMainThread();
|
|
371
|
-
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
372
|
-
},
|
|
373
|
-
markTiming: ()=>{},
|
|
374
|
-
createJSObjectDestructionObserver: ()=>({})
|
|
375
|
-
};
|
|
376
|
-
const performance = {
|
|
377
|
-
__functionCallHistory: [],
|
|
378
|
-
_generatePipelineOptions: ()=>{
|
|
379
|
-
performance.__functionCallHistory.push([
|
|
380
|
-
'_generatePipelineOptions'
|
|
381
|
-
]);
|
|
382
|
-
return {
|
|
383
|
-
pipelineID: 'pipelineID',
|
|
384
|
-
needTimestamps: false
|
|
385
|
-
};
|
|
386
|
-
},
|
|
387
|
-
_onPipelineStart: (id)=>{
|
|
388
|
-
performance.__functionCallHistory.push([
|
|
389
|
-
'_onPipelineStart',
|
|
390
|
-
id
|
|
391
|
-
]);
|
|
392
|
-
},
|
|
393
|
-
_markTiming: (id, key)=>{
|
|
394
|
-
performance.__functionCallHistory.push([
|
|
395
|
-
'_markTiming',
|
|
396
|
-
id,
|
|
397
|
-
key
|
|
398
|
-
]);
|
|
399
|
-
},
|
|
400
|
-
_bindPipelineIdWithTimingFlag: (id, flag)=>{
|
|
401
|
-
performance.__functionCallHistory.push([
|
|
402
|
-
'_bindPipelineIdWithTimingFlag',
|
|
403
|
-
id,
|
|
404
|
-
flag
|
|
405
|
-
]);
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const ee = new events();
|
|
409
|
-
ee.dispatchEvent = ({ type, data })=>{
|
|
410
|
-
if (!globalThis.lynxTestingEnv) return;
|
|
411
|
-
const origin = __MAIN_THREAD__ ? 'CoreContext' : 'JSContext';
|
|
412
|
-
if ('CoreContext' === origin) lynxTestingEnv.switchToBackgroundThread();
|
|
413
|
-
else lynxTestingEnv.switchToMainThread();
|
|
414
|
-
ee.emit(type, {
|
|
415
|
-
data: data,
|
|
416
|
-
origin
|
|
417
|
-
});
|
|
418
|
-
if ('CoreContext' === origin) lynxTestingEnv.switchToMainThread();
|
|
419
|
-
else lynxTestingEnv.switchToBackgroundThread();
|
|
420
|
-
};
|
|
421
|
-
ee.addEventListener = ee.addListener;
|
|
422
|
-
ee.removeEventListener = ee.removeListener;
|
|
423
|
-
const CoreContext = ee;
|
|
424
|
-
const JsContext = ee;
|
|
425
|
-
function __LoadLepusChunk(chunkName, _options) {
|
|
426
|
-
const isBackground = !__MAIN_THREAD__;
|
|
427
|
-
globalThis.lynxTestingEnv.switchToMainThread();
|
|
428
|
-
let ans;
|
|
429
|
-
if ('worklet-runtime' === chunkName) ans = globalThis.onInitWorkletRuntime?.();
|
|
430
|
-
else throw new Error(`__LoadLepusChunk: Unknown chunk name: ${chunkName}`);
|
|
431
|
-
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
432
|
-
return ans;
|
|
433
|
-
}
|
|
434
|
-
return {
|
|
435
|
-
app,
|
|
436
|
-
performance,
|
|
437
|
-
CoreContext,
|
|
438
|
-
JsContext,
|
|
439
|
-
__LoadLepusChunk
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function createPreconfiguredConsole() {
|
|
443
|
-
const console1 = new Console(process.stdout, process.stderr);
|
|
444
|
-
console1.profile = ()=>{};
|
|
445
|
-
console1.profileEnd = ()=>{};
|
|
446
|
-
console1.alog = ()=>{};
|
|
447
|
-
return console1;
|
|
448
|
-
}
|
|
449
|
-
function injectMainThreadGlobals(target, polyfills) {
|
|
450
|
-
__injectElementApi(target);
|
|
451
|
-
const { performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
|
|
452
|
-
if (void 0 === target) target = globalThis;
|
|
453
|
-
target.__DEV__ = true;
|
|
454
|
-
target.__PROFILE__ = true;
|
|
455
|
-
target.__ALOG__ = true;
|
|
456
|
-
target.__ALOG_ELEMENT_API__ = true;
|
|
457
|
-
target.__JS__ = false;
|
|
458
|
-
target.__LEPUS__ = true;
|
|
459
|
-
target.__BACKGROUND__ = false;
|
|
460
|
-
target.__MAIN_THREAD__ = true;
|
|
461
|
-
target.__REF_FIRE_IMMEDIATELY__ = false;
|
|
462
|
-
target.__FIRST_SCREEN_SYNC_TIMING__ = 'immediately';
|
|
463
|
-
target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
|
|
464
|
-
target.__ENABLE_SSR__ = false;
|
|
465
|
-
target.globDynamicComponentEntry = '__Card__';
|
|
466
|
-
const native = {
|
|
467
|
-
_listeners: {},
|
|
468
|
-
onTriggerEvent: void 0,
|
|
469
|
-
postMessage: (_message)=>{},
|
|
470
|
-
addEventListener: (type, listener)=>{
|
|
471
|
-
if (!native._listeners[type]) native._listeners[type] = [];
|
|
472
|
-
native._listeners[type].push(listener);
|
|
473
|
-
},
|
|
474
|
-
removeEventListener: (type, listener)=>{
|
|
475
|
-
if (native._listeners[type]) native._listeners[type] = native._listeners[type].filter((l)=>l !== listener);
|
|
476
|
-
},
|
|
477
|
-
dispatchEvent: (event)=>{
|
|
478
|
-
const listeners = native._listeners[event.type];
|
|
479
|
-
if (listeners) listeners.forEach((listener)=>listener(event));
|
|
480
|
-
return {
|
|
481
|
-
canceled: false
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
target.lynx = {
|
|
486
|
-
performance,
|
|
487
|
-
getNative: ()=>native,
|
|
488
|
-
getCoreContext: ()=>CoreContext,
|
|
489
|
-
getJSContext: ()=>JsContext,
|
|
490
|
-
reportError: (e)=>{
|
|
491
|
-
throw e;
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
target.requestAnimationFrame = setTimeout;
|
|
495
|
-
target.cancelAnimationFrame = clearTimeout;
|
|
496
|
-
target.console = createPreconfiguredConsole();
|
|
497
|
-
target.__LoadLepusChunk = __LoadLepusChunk;
|
|
498
|
-
globalThis.onInjectMainThreadGlobals?.(target);
|
|
499
|
-
}
|
|
500
|
-
const IGNORE_LIST_GLOBALS = [
|
|
501
|
-
'globalThis',
|
|
502
|
-
'global'
|
|
503
|
-
];
|
|
504
|
-
class NodesRef {
|
|
505
|
-
invoke() {
|
|
506
|
-
throw new Error('not implemented');
|
|
507
|
-
}
|
|
508
|
-
path() {
|
|
509
|
-
throw new Error('not implemented');
|
|
510
|
-
}
|
|
511
|
-
fields() {
|
|
512
|
-
throw new Error('not implemented');
|
|
513
|
-
}
|
|
514
|
-
setNativeProps(props) {
|
|
515
|
-
return {
|
|
516
|
-
exec: ()=>{
|
|
517
|
-
const element = elementTree.uniqueId2Element.get(Number(this._nodeSelectToken.identifier));
|
|
518
|
-
if (!element) throw new Error(`[NodesRef.setNativeProps] Element not found for identifier=${this._nodeSelectToken.identifier}`);
|
|
519
|
-
if (element) for(const key in props)element.setAttributeNS(null, key, props[key]);
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
constructor(selectorQuery, nodeSelectToken){
|
|
524
|
-
dist_define_property(this, "_nodeSelectToken", void 0);
|
|
525
|
-
dist_define_property(this, "_selectorQuery", void 0);
|
|
526
|
-
this._nodeSelectToken = nodeSelectToken;
|
|
527
|
-
this._selectorQuery = selectorQuery;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
function injectBackgroundThreadGlobals(target, polyfills) {
|
|
531
|
-
const { app, performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
|
|
532
|
-
if (void 0 === target) target = globalThis;
|
|
533
|
-
target.__DEV__ = true;
|
|
534
|
-
target.__PROFILE__ = true;
|
|
535
|
-
target.__ALOG__ = true;
|
|
536
|
-
target.__ALOG_ELEMENT_API__ = true;
|
|
537
|
-
target.__JS__ = true;
|
|
538
|
-
target.__LEPUS__ = false;
|
|
539
|
-
target.__BACKGROUND__ = true;
|
|
540
|
-
target.__MAIN_THREAD__ = false;
|
|
541
|
-
target.__ENABLE_SSR__ = false;
|
|
542
|
-
target.globDynamicComponentEntry = '__Card__';
|
|
543
|
-
target.lynxCoreInject = {};
|
|
544
|
-
target.lynxCoreInject.tt = {
|
|
545
|
-
_params: {
|
|
546
|
-
initData: {},
|
|
547
|
-
updateData: {}
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
const globalEventEmitter = new GlobalEventEmitter();
|
|
551
|
-
target.lynx = {
|
|
552
|
-
getNativeApp: ()=>app,
|
|
553
|
-
performance,
|
|
554
|
-
createSelectorQuery: ()=>({
|
|
555
|
-
selectUniqueID: function(uniqueId) {
|
|
556
|
-
return new NodesRef({}, {
|
|
557
|
-
type: 2,
|
|
558
|
-
identifier: uniqueId.toString()
|
|
559
|
-
});
|
|
560
|
-
},
|
|
561
|
-
select: function(selector) {
|
|
562
|
-
const el = lynxTestingEnv.jsdom.window.document.querySelector(selector);
|
|
563
|
-
if (!el) throw new Error(`[createSelectorQuery.select] No element matches selector: ${selector}`);
|
|
564
|
-
return new NodesRef({}, {
|
|
565
|
-
type: 0,
|
|
566
|
-
identifier: el.$$uiSign.toString()
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
}),
|
|
570
|
-
getCoreContext: ()=>CoreContext,
|
|
571
|
-
getJSContext: ()=>JsContext,
|
|
572
|
-
getJSModule: (moduleName)=>{
|
|
573
|
-
if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
|
|
574
|
-
throw new Error(`getJSModule(${moduleName}) not implemented`);
|
|
575
|
-
},
|
|
576
|
-
reportError: (e)=>{
|
|
577
|
-
throw e;
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
target.requestAnimationFrame = setTimeout;
|
|
581
|
-
target.cancelAnimationFrame = clearTimeout;
|
|
582
|
-
target.console = createPreconfiguredConsole();
|
|
583
|
-
target.SystemInfo = {
|
|
584
|
-
platform: 'iOS',
|
|
585
|
-
pixelRatio: 3,
|
|
586
|
-
pixelWidth: 1170,
|
|
587
|
-
pixelHeight: 2532,
|
|
588
|
-
osVersion: '17.0.2',
|
|
589
|
-
enableKrypton: true,
|
|
590
|
-
runtimeType: 'quickjs',
|
|
591
|
-
lynxSdkVersion: '3.0'
|
|
592
|
-
};
|
|
593
|
-
target.__LoadLepusChunk = __LoadLepusChunk;
|
|
594
|
-
globalThis.onInjectBackgroundThreadGlobals?.(target);
|
|
595
|
-
}
|
|
596
|
-
class LynxTestingEnv {
|
|
597
|
-
injectGlobals() {
|
|
598
|
-
const polyfills = createPolyfills();
|
|
599
|
-
injectBackgroundThreadGlobals(this.backgroundThread.globalThis, polyfills);
|
|
600
|
-
injectMainThreadGlobals(this.mainThread.globalThis, polyfills);
|
|
601
|
-
}
|
|
602
|
-
switchToBackgroundThread() {
|
|
603
|
-
this.originals = new Map();
|
|
604
|
-
Object.getOwnPropertyNames(this.backgroundThread.globalThis).forEach((key)=>{
|
|
605
|
-
if (IGNORE_LIST_GLOBALS.includes(key)) return;
|
|
606
|
-
this.originals.set(key, global[key]);
|
|
607
|
-
global[key] = this.backgroundThread.globalThis[key];
|
|
608
|
-
});
|
|
609
|
-
globalThis?.onSwitchedToBackgroundThread?.();
|
|
610
|
-
}
|
|
611
|
-
switchToMainThread() {
|
|
612
|
-
this.originals = new Map();
|
|
613
|
-
Object.getOwnPropertyNames(this.mainThread.globalThis).forEach((key)=>{
|
|
614
|
-
if (IGNORE_LIST_GLOBALS.includes(key)) return;
|
|
615
|
-
this.originals.set(key, global[key]);
|
|
616
|
-
global[key] = this.mainThread.globalThis[key];
|
|
617
|
-
});
|
|
618
|
-
globalThis?.onSwitchedToMainThread?.();
|
|
619
|
-
}
|
|
620
|
-
clearGlobal() {
|
|
621
|
-
this.originals?.forEach((v, k)=>{
|
|
622
|
-
global[k] = v;
|
|
623
|
-
});
|
|
624
|
-
this.originals?.clear();
|
|
625
|
-
}
|
|
626
|
-
reset() {
|
|
627
|
-
this.injectGlobals();
|
|
628
|
-
this.switchToMainThread();
|
|
629
|
-
this.switchToBackgroundThread();
|
|
630
|
-
globalThis.onResetLynxTestingEnv?.();
|
|
631
|
-
}
|
|
632
|
-
constructor(jsdom){
|
|
633
|
-
dist_define_property(this, "originals", new Map());
|
|
634
|
-
dist_define_property(this, "backgroundThread", void 0);
|
|
635
|
-
dist_define_property(this, "mainThread", void 0);
|
|
636
|
-
dist_define_property(this, "jsdom", void 0);
|
|
637
|
-
this.jsdom = jsdom ?? global.jsdom;
|
|
638
|
-
if (!this.jsdom) throw new Error("LynxTestingEnv requires a JSDOM instance. Pass one to the constructor, or ensure your test runner sets global.jsdom (e.g., via a setup file).");
|
|
639
|
-
this.backgroundThread = createGlobalThis();
|
|
640
|
-
this.mainThread = createGlobalThis();
|
|
641
|
-
const globalPolyfills = {
|
|
642
|
-
console: this.jsdom.window['console'],
|
|
643
|
-
Event: this.jsdom.window.Event,
|
|
644
|
-
window: this.jsdom.window,
|
|
645
|
-
document: this.jsdom.window.document
|
|
646
|
-
};
|
|
647
|
-
Object.assign(this.mainThread.globalThis, globalPolyfills);
|
|
648
|
-
Object.assign(this.backgroundThread.globalThis, globalPolyfills);
|
|
649
|
-
this.injectGlobals();
|
|
650
|
-
this.switchToBackgroundThread();
|
|
651
|
-
}
|
|
652
|
-
}
|
|
2
|
+
import { installLynxTestingEnv, uninstallLynxTestingEnv } from "./index.js";
|
|
653
3
|
const env = {
|
|
654
4
|
name: 'lynxTestingEnv',
|
|
655
5
|
transformMode: 'web',
|
|
656
|
-
async setup (
|
|
6
|
+
async setup (global) {
|
|
657
7
|
const fakeGlobal = {};
|
|
658
|
-
await builtinEnvironments.jsdom.setup(fakeGlobal, {});
|
|
659
|
-
|
|
660
|
-
global1.lynxTestingEnv = lynxTestingEnv1;
|
|
661
|
-
global1.Node = lynxTestingEnv1.jsdom.window.Node;
|
|
8
|
+
const jsdomEnvironment = await builtinEnvironments.jsdom.setup(fakeGlobal, {});
|
|
9
|
+
installLynxTestingEnv(global, fakeGlobal.jsdom);
|
|
662
10
|
return {
|
|
663
|
-
teardown (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
delete global1.Node;
|
|
11
|
+
async teardown (global) {
|
|
12
|
+
await jsdomEnvironment.teardown(fakeGlobal);
|
|
13
|
+
uninstallLynxTestingEnv(global);
|
|
667
14
|
}
|
|
668
15
|
};
|
|
669
16
|
}
|
|
670
17
|
};
|
|
671
18
|
const vitest = env;
|
|
672
|
-
|
|
673
|
-
export default env_vitest;
|
|
19
|
+
export { vitest as default };
|