@lynx-js/react 0.126.2 → 0.128.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 +36 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/docs/directives.md +90 -0
- package/docs/global-events.md +50 -0
- package/docs/import-attributes.md +43 -0
- package/docs/macros.md +285 -0
- package/package.json +7 -14
- package/refresh/.turbo/turbo-build.log +2 -2
- package/refresh/dist/index.js +26 -6
- package/refresh/package.json +1 -1
- package/runtime/__test__/core/main-thread-object.test.js +149 -0
- package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +26 -3
- package/runtime/__test__/element-template/imports/main-thread-object-api.test.ts +10 -0
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +39 -48
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +11 -9
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +6 -3
- package/runtime/__test__/element-template/test-utils/mock/globals.js +6 -0
- package/runtime/__test__/element-template/vitest.config.ts +4 -0
- package/runtime/__test__/snapshot/ctxNotFound.test.ts +271 -0
- package/runtime/__test__/snapshot/event.test.jsx +7 -7
- package/runtime/__test__/snapshot/lazy.test.js +73 -1
- package/runtime/__test__/snapshot/lynx/portals.test.jsx +75 -37
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +59 -47
- package/runtime/__test__/snapshot/spread.test.jsx +10 -10
- package/runtime/__test__/snapshot/worklet/main-thread-object.test.jsx +306 -0
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +1 -0
- package/runtime/__test__/worklet-runtime/initEntry.test.js +109 -0
- package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +182 -0
- package/runtime/__test__/worklet-runtime/object-methods.test.js +59 -0
- package/runtime/__test__/worklet-runtime/workletRef.test.js +362 -2
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +246 -1
- package/runtime/lazy/compat.js +2 -0
- package/runtime/lazy/element-template-internal.js +1 -1
- package/runtime/lazy/element-template.js +2 -0
- package/runtime/lazy/internal.js +2 -1
- package/runtime/lazy/react.js +2 -0
- package/runtime/lib/core/background-function/exec-map.js.map +1 -1
- package/runtime/lib/core/background-function/handle.js.map +1 -1
- package/runtime/lib/core/background-function/run-on-background.d.ts +16 -0
- package/runtime/lib/core/background-function/run-on-background.js +16 -0
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/capture-main-thread-object.d.ts +1 -0
- package/runtime/lib/core/capture-main-thread-object.js +16 -0
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -0
- package/runtime/lib/core/commit-context.js.map +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/compat/lynxComponent.js.map +1 -1
- package/runtime/lib/core/component.js.map +1 -1
- package/runtime/lib/core/forceRootRender.js.map +1 -1
- package/runtime/lib/core/globalProps.d.ts +2 -0
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/hooks/mainThread.js.map +1 -1
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/hooks/react.d.ts +4 -0
- package/runtime/lib/core/hooks/react.js +4 -0
- package/runtime/lib/core/hooks/react.js.map +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.d.ts +2 -0
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +2 -0
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
- package/runtime/lib/core/initData.d.ts +2 -0
- package/runtime/lib/core/initData.js +2 -0
- package/runtime/lib/core/initData.js.map +1 -1
- package/runtime/lib/core/lynx/dynamic-import.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx/runtime-backend.js.map +1 -1
- package/runtime/lib/core/lynx/runtime-version.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/lynx-page-data.js.map +1 -1
- package/runtime/lib/core/lynx-update-data.js.map +1 -1
- package/runtime/lib/core/main-thread-function.js.map +1 -1
- package/runtime/lib/core/main-thread-object-handle-registry.d.ts +3 -0
- package/runtime/lib/core/main-thread-object-handle-registry.js +17 -0
- package/runtime/lib/core/main-thread-object-handle-registry.js.map +1 -0
- package/runtime/lib/core/main-thread-object.d.ts +77 -0
- package/runtime/lib/core/main-thread-object.js +258 -0
- package/runtime/lib/core/main-thread-object.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-id.d.ts +1 -0
- package/runtime/lib/core/main-thread-ref-id.js +14 -0
- package/runtime/lib/core/main-thread-ref-id.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -1
- package/runtime/lib/core/main-thread-ref-init-value.js +4 -2
- package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -1
- package/runtime/lib/core/main-thread-ref.d.ts +4 -0
- package/runtime/lib/core/main-thread-ref.js +5 -8
- package/runtime/lib/core/main-thread-ref.js.map +1 -1
- package/runtime/lib/core/mts-capability.js.map +1 -1
- package/runtime/lib/core/performance.js.map +1 -1
- package/runtime/lib/core/ref.js.map +1 -1
- package/runtime/lib/core/reload-version.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/core/thread-function-call/return-value.js.map +1 -1
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-context.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/document.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/manager.js.map +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/render-scope.js.map +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/hydration-map.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +2 -0
- package/runtime/lib/element-template/index.js +1 -0
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -1
- package/runtime/lib/element-template/internal.js +1 -1
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/lynx/performance.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/event.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/page.js.map +1 -1
- package/runtime/lib/element-template/protocol/template-type.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +1 -1
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/protocol/update-event.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/authored-page.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/element-template/runtime-marker.js.map +1 -1
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +34 -0
- package/runtime/lib/lynx-api.js +21 -0
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +4 -1
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/runtime-marker.js.map +1 -1
- package/runtime/lib/shared/attribute-name.js.map +1 -1
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/shared/index-map.js.map +1 -1
- package/runtime/lib/shared/profile.js.map +1 -1
- package/runtime/lib/shared/render-constants.js.map +1 -1
- package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -1
- package/runtime/lib/snapshot/alog/index.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/compat/componentIs.js.map +1 -1
- package/runtime/lib/snapshot/debug/debug.js.map +1 -1
- package/runtime/lib/snapshot/debug/describeInvalidValue.js.map +1 -1
- package/runtime/lib/snapshot/debug/formatPatch.js.map +1 -1
- package/runtime/lib/snapshot/debug/printSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +1 -1
- package/runtime/lib/snapshot/gesture/types.js.map +1 -1
- package/runtime/lib/snapshot/index.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/delayEvents.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/delayLifecycleEvents.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/error.d.ts +11 -1
- package/runtime/lib/snapshot/lifecycle/patch/error.js +24 -16
- package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/globalState.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/isMainThreadHydrating.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.d.ts +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +29 -7
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +2 -2
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/list/pendingListUpdates.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.d.ts +2 -0
- package/runtime/lib/snapshot/lynx/children.js.map +1 -1
- package/runtime/lib/snapshot/lynx/element.d.ts +8 -0
- package/runtime/lib/snapshot/lynx/element.js +4 -0
- package/runtime/lib/snapshot/lynx/element.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -1
- package/runtime/lib/snapshot/lynx/lazyBundleConstants.js.map +1 -1
- package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -1
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portals.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -1
- package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js.map +1 -1
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/event.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/index.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/types.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +2 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +2 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -1
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/snapshot/worklet/hmr.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/animation/animation.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/animation/effect.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/element.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lepusQuerySelector.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -3
- package/runtime/lib/worklet-runtime/bindings/bindings.js +9 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/events.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +0 -1
- package/runtime/lib/worklet-runtime/bindings/index.js +0 -1
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +3 -6
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js.map +1 -1
- package/runtime/lib/worklet-runtime/eomImpl.js.map +1 -1
- package/runtime/lib/worklet-runtime/eventPropagation.js.map +1 -1
- package/runtime/lib/worklet-runtime/global.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +26 -7
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/index.js +6 -0
- package/runtime/lib/worklet-runtime/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/listeners.js.map +1 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.d.ts +8 -0
- package/runtime/lib/worklet-runtime/mainThreadObject.js +67 -0
- package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -0
- package/runtime/lib/worklet-runtime/runOnMainThread.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/mainThreadFlushLoopGuard.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/profile.js.map +1 -1
- package/runtime/lib/worklet-runtime/utils/version.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRef.d.ts +11 -7
- package/runtime/lib/worklet-runtime/workletRef.js +72 -9
- package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +68 -9
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/background-function/run-on-background.ts +16 -0
- package/runtime/src/core/capture-main-thread-object.ts +17 -0
- package/runtime/src/core/globalProps.ts +2 -0
- package/runtime/src/core/hooks/react.ts +4 -0
- package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +2 -0
- package/runtime/src/core/initData.ts +2 -0
- package/runtime/src/core/main-thread-object-handle-registry.ts +25 -0
- package/runtime/src/core/main-thread-object.ts +380 -0
- package/runtime/src/core/main-thread-ref-id.ts +16 -0
- package/runtime/src/core/main-thread-ref-init-value.ts +12 -4
- package/runtime/src/core/main-thread-ref.ts +7 -8
- package/runtime/src/element-template/background/commit-hook.ts +1 -1
- package/runtime/src/element-template/index.ts +6 -0
- package/runtime/src/element-template/internal.ts +2 -1
- package/runtime/src/element-template/protocol/types.ts +1 -1
- package/runtime/src/internal.ts +1 -1
- package/runtime/src/lynx-api.ts +38 -0
- package/runtime/src/lynx.ts +5 -1
- package/runtime/src/snapshot/lifecycle/patch/error.ts +36 -19
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +29 -7
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +2 -2
- package/runtime/src/snapshot/lynx/children.ts +2 -0
- package/runtime/src/snapshot/lynx/element.ts +8 -0
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +2 -0
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +1 -1
- package/runtime/src/worklet-runtime/bindings/bindings.ts +17 -2
- package/runtime/src/worklet-runtime/bindings/index.ts +0 -1
- package/runtime/src/worklet-runtime/bindings/types.ts +7 -11
- package/runtime/src/worklet-runtime/hydrate.ts +43 -10
- package/runtime/src/worklet-runtime/index.ts +7 -0
- package/runtime/src/worklet-runtime/mainThreadObject.ts +117 -0
- package/runtime/src/worklet-runtime/workletRef.ts +120 -19
- package/runtime/src/worklet-runtime/workletRuntime.ts +83 -11
- package/runtime/tsconfig.json +2 -0
- package/runtime/vitest.config.ts +4 -0
- package/testing-library/.turbo/turbo-build.log +11 -11
- package/testing-library/dist/env/index.js +3 -15
- package/testing-library/dist/index.d.ts +165 -2
- package/testing-library/dist/plugins/index.js +10 -0
- package/testing-library/dist/rstest-config.js +15 -0
- package/testing-library/dist/setupFiles/common/worklet-runtime-init.js +11 -0
- package/testing-library/package.json +2 -1
- package/testing-library/rstest.config.ts +3 -0
- package/testing-library/src/__tests__/lynx.test.jsx +1 -1
- package/testing-library/src/__tests__/rstest-config.test.js +34 -1
- package/testing-library/src/__tests__/worklet.test.jsx +87 -33
- package/testing-library/src/plugins/vitest.ts +5 -1
- package/testing-library/src/rstest-config.ts +17 -1
- package/testing-library/src/setupFiles/common/worklet-runtime-init.js +22 -0
- package/testing-library/tsconfig.docs.json +9 -0
- package/testing-library/typedoc.json +22 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +135 -73
- package/transform/__test__/defines.spec.js +80 -12
- package/transform/__test__/fixture.spec.js +231 -71
- package/transform/__test__/object-methods.spec.js +82 -0
- package/transform/crates/swc_plugin_worklet/decl_collect.rs +10 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +14 -0
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +228 -13
- package/transform/crates/swc_plugin_worklet/lib.rs +599 -150
- package/transform/crates/swc_plugin_worklet/napi.rs +10 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +8 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +12 -7
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_js.js +27 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_lepus.js +43 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +16 -14
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +18 -18
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_lepus.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +7 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +9 -9
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_computed_object_method_key_lepus.js +22 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_globals.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_object_method_local_decls_lepus.js +14 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_type_annotations.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_destructure_from_closure.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_catch_clause_params.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_idents_inside_of_ctx.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_recursively.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +42 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +58 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_arrow_function.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_function_expr.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +3 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_lepus.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_alias.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general_mixed.js +2 -4
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets_in_func.js +3 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_lepus.js +14 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_lepus.js +2 -4
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +25 -1
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/src/lib.rs +193 -23
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +63 -467
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +340 -28
- package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
- package/transform/vitest.config.ts +5 -1
- package/types/react.docs.d.ts +130 -11
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +0 -8
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +0 -23
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +0 -1
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +0 -25
- package/runtime/worklet-runtime/dev.js +0 -638
- package/runtime/worklet-runtime/main.js +0 -1
- package/testing-library/node_modules/.bin/rsbuild +0 -68
- package/testing-library/node_modules/.bin/rspeedy +0 -68
- package/testing-library/node_modules/.bin/rstest +0 -68
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_inner_ident.js +0 -13
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_outer_ident.js +0 -13
- package/transform/node_modules/.bin/esbuild +0 -59
- package/transform/node_modules/.bin/napi +0 -68
|
@@ -521,12 +521,16 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
521
521
|
globalEnvManager.switchToMainThread();
|
|
522
522
|
lynx.getJSContext().dispatchEvent.mockClear();
|
|
523
523
|
expect(() =>
|
|
524
|
-
snapshotPatchApply(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
524
|
+
snapshotPatchApply(
|
|
525
|
+
[
|
|
526
|
+
SnapshotOperation.nodesRefInsertBefore,
|
|
527
|
+
'[react-ref-999-0]',
|
|
528
|
+
99999,
|
|
529
|
+
undefined,
|
|
530
|
+
],
|
|
531
|
+
42,
|
|
532
|
+
false,
|
|
533
|
+
)
|
|
530
534
|
).not.toThrow();
|
|
531
535
|
expect(lynx.getJSContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`
|
|
532
536
|
[
|
|
@@ -534,6 +538,11 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
534
538
|
{
|
|
535
539
|
"data": {
|
|
536
540
|
"id": 99999,
|
|
541
|
+
"options": {
|
|
542
|
+
"commitId": 42,
|
|
543
|
+
"isHydration": false,
|
|
544
|
+
"operation": "nodesRefInsertBefore",
|
|
545
|
+
},
|
|
537
546
|
},
|
|
538
547
|
"type": "Lynx.Error.CtxNotFound",
|
|
539
548
|
},
|
|
@@ -546,11 +555,15 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
546
555
|
globalEnvManager.switchToMainThread();
|
|
547
556
|
lynx.getJSContext().dispatchEvent.mockClear();
|
|
548
557
|
expect(() =>
|
|
549
|
-
snapshotPatchApply(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
558
|
+
snapshotPatchApply(
|
|
559
|
+
[
|
|
560
|
+
SnapshotOperation.nodesRefRemoveChild,
|
|
561
|
+
'[react-ref-999-0]',
|
|
562
|
+
99999,
|
|
563
|
+
],
|
|
564
|
+
43,
|
|
565
|
+
false,
|
|
566
|
+
)
|
|
554
567
|
).not.toThrow();
|
|
555
568
|
expect(lynx.getJSContext().dispatchEvent.mock.calls).toMatchInlineSnapshot(`
|
|
556
569
|
[
|
|
@@ -558,6 +571,11 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
558
571
|
{
|
|
559
572
|
"data": {
|
|
560
573
|
"id": 99999,
|
|
574
|
+
"options": {
|
|
575
|
+
"commitId": 43,
|
|
576
|
+
"isHydration": false,
|
|
577
|
+
"operation": "nodesRefRemoveChild",
|
|
578
|
+
},
|
|
561
579
|
},
|
|
562
580
|
"type": "Lynx.Error.CtxNotFound",
|
|
563
581
|
},
|
|
@@ -576,20 +594,28 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
576
594
|
it('throws when host selector cannot be resolved on insert', () => {
|
|
577
595
|
globalEnvManager.switchToMainThread();
|
|
578
596
|
const childId = -9999;
|
|
579
|
-
snapshotPatchApply(
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
597
|
+
snapshotPatchApply(
|
|
598
|
+
[
|
|
599
|
+
SnapshotOperation.CreateElement,
|
|
600
|
+
'__snapshot_a94a8_test_1',
|
|
601
|
+
childId,
|
|
602
|
+
],
|
|
603
|
+
42,
|
|
604
|
+
false,
|
|
605
|
+
);
|
|
584
606
|
expect(snapshotInstanceManager.values.has(childId)).toBe(true);
|
|
585
607
|
|
|
586
608
|
expect(() =>
|
|
587
|
-
snapshotPatchApply(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
609
|
+
snapshotPatchApply(
|
|
610
|
+
[
|
|
611
|
+
SnapshotOperation.nodesRefInsertBefore,
|
|
612
|
+
'[no-such-attr]',
|
|
613
|
+
childId,
|
|
614
|
+
undefined,
|
|
615
|
+
],
|
|
616
|
+
42,
|
|
617
|
+
false,
|
|
618
|
+
)
|
|
593
619
|
).toThrowErrorMatchingInlineSnapshot(
|
|
594
620
|
`[Error: [createPortal] cannot resolve host for selector "[no-such-attr]". The host element does not exist on the main thread — check that the \`NodesRef\` passed to \`createPortal\` points at a currently mounted element.]`,
|
|
595
621
|
);
|
|
@@ -600,21 +626,29 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
600
626
|
// Materialize a child with an `__element_root` (the realistic state at
|
|
601
627
|
// remove time — an earlier `nodesRefInsertBefore` op would have set it).
|
|
602
628
|
const childId = -9998;
|
|
603
|
-
snapshotPatchApply(
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
629
|
+
snapshotPatchApply(
|
|
630
|
+
[
|
|
631
|
+
SnapshotOperation.CreateElement,
|
|
632
|
+
'__snapshot_a94a8_test_1',
|
|
633
|
+
childId,
|
|
634
|
+
],
|
|
635
|
+
42,
|
|
636
|
+
false,
|
|
637
|
+
);
|
|
608
638
|
snapshotInstanceManager.values.get(childId).ensureElements();
|
|
609
639
|
|
|
610
640
|
// Remove must not throw even when the host is gone — see the comment
|
|
611
641
|
// on `applyNodesRefRemoveChild`. The portal child SI is still cleaned up.
|
|
612
642
|
expect(() =>
|
|
613
|
-
snapshotPatchApply(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
643
|
+
snapshotPatchApply(
|
|
644
|
+
[
|
|
645
|
+
SnapshotOperation.nodesRefRemoveChild,
|
|
646
|
+
'[no-such-attr]',
|
|
647
|
+
childId,
|
|
648
|
+
],
|
|
649
|
+
42,
|
|
650
|
+
false,
|
|
651
|
+
)
|
|
618
652
|
).not.toThrow();
|
|
619
653
|
expect(snapshotInstanceManager.values.has(childId)).toBe(false);
|
|
620
654
|
});
|
|
@@ -637,11 +671,15 @@ describe('snapshotPatchApply for nodesRef ops', () => {
|
|
|
637
671
|
expect(listElement.componentAtIndex).not.toBeNull();
|
|
638
672
|
|
|
639
673
|
globalEnvManager.switchToMainThread();
|
|
640
|
-
snapshotPatchApply(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
674
|
+
snapshotPatchApply(
|
|
675
|
+
[
|
|
676
|
+
SnapshotOperation.nodesRefRemoveChild,
|
|
677
|
+
'[no-such-attr]',
|
|
678
|
+
childId,
|
|
679
|
+
],
|
|
680
|
+
42,
|
|
681
|
+
false,
|
|
682
|
+
);
|
|
645
683
|
// After `snapshotDestroyList`, the cleanup trio replaces the real
|
|
646
684
|
// callbacks: `componentAtIndex` returns `-1`, the others are no-ops.
|
|
647
685
|
expect(listElement.componentAtIndex()).toBe(-1);
|
|
@@ -103,7 +103,7 @@ describe('createElement', () => {
|
|
|
103
103
|
`);
|
|
104
104
|
|
|
105
105
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
106
|
-
snapshotPatchApply(patch);
|
|
106
|
+
snapshotPatchApply(patch, 42, false);
|
|
107
107
|
expect(snapshotInstanceManager.values.size).toEqual(3);
|
|
108
108
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
109
109
|
si1.ensureElements();
|
|
@@ -158,7 +158,7 @@ describe('insertBefore', () => {
|
|
|
158
158
|
`);
|
|
159
159
|
|
|
160
160
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
161
|
-
snapshotPatchApply(patch);
|
|
161
|
+
snapshotPatchApply(patch, 42, false);
|
|
162
162
|
expect(snapshotInstanceManager.values.size).toEqual(3);
|
|
163
163
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
164
164
|
si1.ensureElements();
|
|
@@ -272,7 +272,7 @@ describe('insertBefore', () => {
|
|
|
272
272
|
`);
|
|
273
273
|
|
|
274
274
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
275
|
-
snapshotPatchApply(patch);
|
|
275
|
+
snapshotPatchApply(patch, 42, false);
|
|
276
276
|
expect(snapshotInstanceManager.values.size).toEqual(4);
|
|
277
277
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
278
278
|
si1.ensureElements();
|
|
@@ -352,23 +352,23 @@ describe('insertBefore', () => {
|
|
|
352
352
|
`);
|
|
353
353
|
|
|
354
354
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
355
|
-
snapshotPatchApply(patch);
|
|
355
|
+
snapshotPatchApply(patch, 42, false);
|
|
356
356
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
357
357
|
[
|
|
358
358
|
[
|
|
359
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
359
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, child: { id: 100, snapshot type: 'null', missing: true }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
360
360
|
{
|
|
361
361
|
"errorCode": 1101,
|
|
362
362
|
},
|
|
363
363
|
],
|
|
364
364
|
[
|
|
365
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
365
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: { id: 100, snapshot type: 'null', missing: true }, child: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
366
366
|
{
|
|
367
367
|
"errorCode": 1101,
|
|
368
368
|
},
|
|
369
369
|
],
|
|
370
370
|
[
|
|
371
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: '__snapshot_a94a8_test_3'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
371
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: '__snapshot_a94a8_test_3', parent: { id: 4, snapshot type: '__snapshot_a94a8_test_3', missing: true }, child: { id: 100, snapshot type: 'null', missing: true }, operation: 'InsertBefore', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
372
372
|
{
|
|
373
373
|
"errorCode": 1101,
|
|
374
374
|
},
|
|
@@ -402,7 +402,7 @@ describe('removeChild', () => {
|
|
|
402
402
|
const bsi2 = new BackgroundSnapshotInstance(snapshot2);
|
|
403
403
|
bsi1.insertBefore(bsi2);
|
|
404
404
|
let patch = takeGlobalSnapshotPatch();
|
|
405
|
-
snapshotPatchApply(patch);
|
|
405
|
+
snapshotPatchApply(patch, 42, false);
|
|
406
406
|
|
|
407
407
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
408
408
|
si1.ensureElements();
|
|
@@ -434,7 +434,7 @@ describe('removeChild', () => {
|
|
|
434
434
|
3,
|
|
435
435
|
]
|
|
436
436
|
`);
|
|
437
|
-
snapshotPatchApply(patch);
|
|
437
|
+
snapshotPatchApply(patch, 42, false);
|
|
438
438
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
439
439
|
<view>
|
|
440
440
|
<text>
|
|
@@ -454,7 +454,7 @@ describe('removeChild', () => {
|
|
|
454
454
|
bsi1.insertBefore(bsi2);
|
|
455
455
|
bsi1.insertBefore(bsi3);
|
|
456
456
|
let patch = takeGlobalSnapshotPatch();
|
|
457
|
-
snapshotPatchApply(patch);
|
|
457
|
+
snapshotPatchApply(patch, 42, false);
|
|
458
458
|
|
|
459
459
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
460
460
|
si1.ensureElements();
|
|
@@ -493,7 +493,7 @@ describe('removeChild', () => {
|
|
|
493
493
|
3,
|
|
494
494
|
]
|
|
495
495
|
`);
|
|
496
|
-
snapshotPatchApply(patch);
|
|
496
|
+
snapshotPatchApply(patch, 42, false);
|
|
497
497
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
498
498
|
<view>
|
|
499
499
|
<text>
|
|
@@ -525,19 +525,19 @@ describe('removeChild', () => {
|
|
|
525
525
|
1,
|
|
526
526
|
]
|
|
527
527
|
`);
|
|
528
|
-
snapshotPatchApply(patch);
|
|
528
|
+
snapshotPatchApply(patch, 42, false);
|
|
529
529
|
expect(_ReportError).toHaveBeenCalledTimes(2);
|
|
530
530
|
|
|
531
531
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
532
532
|
[
|
|
533
533
|
[
|
|
534
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
534
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root', parent: { id: 1, snapshot type: 'root', missing: true }, child: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, operation: 'RemoveChild', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
535
535
|
{
|
|
536
536
|
"errorCode": 1101,
|
|
537
537
|
},
|
|
538
538
|
],
|
|
539
539
|
[
|
|
540
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
540
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'root', parent: { id: 2, snapshot type: '__snapshot_a94a8_test_1', missing: false }, child: { id: 1, snapshot type: 'root', missing: true }, operation: 'RemoveChild', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
541
541
|
{
|
|
542
542
|
"errorCode": 1101,
|
|
543
543
|
},
|
|
@@ -572,7 +572,7 @@ describe('removeChild', () => {
|
|
|
572
572
|
4,
|
|
573
573
|
]
|
|
574
574
|
`);
|
|
575
|
-
snapshotPatchApply(patch);
|
|
575
|
+
snapshotPatchApply(patch, 42, false);
|
|
576
576
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
577
577
|
<view>
|
|
578
578
|
<text>
|
|
@@ -613,7 +613,7 @@ describe('setAttribute', () => {
|
|
|
613
613
|
`);
|
|
614
614
|
|
|
615
615
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
616
|
-
snapshotPatchApply(patch);
|
|
616
|
+
snapshotPatchApply(patch, 42, false);
|
|
617
617
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
618
618
|
si1.ensureElements();
|
|
619
619
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -647,7 +647,7 @@ describe('setAttribute', () => {
|
|
|
647
647
|
`);
|
|
648
648
|
|
|
649
649
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
650
|
-
snapshotPatchApply(patch);
|
|
650
|
+
snapshotPatchApply(patch, 42, false);
|
|
651
651
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
652
652
|
si1.ensureElements();
|
|
653
653
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -683,7 +683,7 @@ describe('setAttribute', () => {
|
|
|
683
683
|
patch.push(SnapshotOperation.SetAttributes, 2, ['attr 3', 'attr 4']);
|
|
684
684
|
|
|
685
685
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
686
|
-
snapshotPatchApply(patch);
|
|
686
|
+
snapshotPatchApply(patch, 42, false);
|
|
687
687
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
688
688
|
si1.ensureElements();
|
|
689
689
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
@@ -718,12 +718,12 @@ describe('setAttribute', () => {
|
|
|
718
718
|
patch.push(SnapshotOperation.SetAttributes, 2, ['attr 3', 'attr 4']);
|
|
719
719
|
|
|
720
720
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
721
|
-
snapshotPatchApply(patch);
|
|
721
|
+
snapshotPatchApply(patch, 42, false);
|
|
722
722
|
expect(_ReportError).toHaveBeenCalledTimes(1);
|
|
723
723
|
expect(_ReportError.mock.calls).toMatchInlineSnapshot(`
|
|
724
724
|
[
|
|
725
725
|
[
|
|
726
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
726
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: null, operation: 'SetAttributes', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
727
727
|
{
|
|
728
728
|
"errorCode": 1101,
|
|
729
729
|
},
|
|
@@ -762,12 +762,12 @@ describe('setAttribute', () => {
|
|
|
762
762
|
`);
|
|
763
763
|
|
|
764
764
|
expect(snapshotInstanceManager.values.size).toEqual(1);
|
|
765
|
-
snapshotPatchApply(patch);
|
|
765
|
+
snapshotPatchApply(patch, 42, false);
|
|
766
766
|
expect(_ReportError).toHaveBeenCalledTimes(1);
|
|
767
767
|
|
|
768
768
|
expect(_ReportError.mock.calls[0]).toMatchInlineSnapshot(`
|
|
769
769
|
[
|
|
770
|
-
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
770
|
+
[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: null, operation: 'SetAttribute', commitId: 42, isHydration: false. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.],
|
|
771
771
|
{
|
|
772
772
|
"errorCode": 1101,
|
|
773
773
|
},
|
|
@@ -864,7 +864,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
864
864
|
delete snapshotCreatorMap[uniqID1];
|
|
865
865
|
|
|
866
866
|
// Apply patches in main thread
|
|
867
|
-
snapshotPatchApply(patch);
|
|
867
|
+
snapshotPatchApply(patch, 42, false);
|
|
868
868
|
new SnapshotInstance(uniqID1);
|
|
869
869
|
|
|
870
870
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -969,7 +969,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
969
969
|
const fn = vi.fn();
|
|
970
970
|
vi.stubGlobal('__SetCSSId', fn);
|
|
971
971
|
// Apply patches in main thread
|
|
972
|
-
snapshotPatchApply(patch);
|
|
972
|
+
snapshotPatchApply(patch, 42, false);
|
|
973
973
|
new SnapshotInstance(uniqID1);
|
|
974
974
|
|
|
975
975
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1029,11 +1029,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1029
1029
|
|
|
1030
1030
|
expect(snapshotCreatorMap[uniqID1].toString()).toContain('[native code]');
|
|
1031
1031
|
expect(() =>
|
|
1032
|
-
snapshotPatchApply(
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1032
|
+
snapshotPatchApply(
|
|
1033
|
+
[
|
|
1034
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1035
|
+
uniqID1,
|
|
1036
|
+
'https://example.com/lazy-bundle.js',
|
|
1037
|
+
],
|
|
1038
|
+
42,
|
|
1039
|
+
false,
|
|
1040
|
+
)
|
|
1037
1041
|
).not.toThrow();
|
|
1038
1042
|
});
|
|
1039
1043
|
|
|
@@ -1048,11 +1052,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1048
1052
|
|
|
1049
1053
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
1050
1054
|
expect(() =>
|
|
1051
|
-
snapshotPatchApply(
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1055
|
+
snapshotPatchApply(
|
|
1056
|
+
[
|
|
1057
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1058
|
+
uniqID1,
|
|
1059
|
+
'https://example.com/lazy-bundle.js',
|
|
1060
|
+
],
|
|
1061
|
+
42,
|
|
1062
|
+
false,
|
|
1063
|
+
)
|
|
1056
1064
|
).not.toThrow();
|
|
1057
1065
|
expect(warn).toHaveBeenCalledTimes(1);
|
|
1058
1066
|
warn.mockRestore();
|
|
@@ -1060,11 +1068,15 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1060
1068
|
|
|
1061
1069
|
it('with a creator that is missing', () => {
|
|
1062
1070
|
expect(() =>
|
|
1063
|
-
snapshotPatchApply(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1071
|
+
snapshotPatchApply(
|
|
1072
|
+
[
|
|
1073
|
+
SnapshotOperation.DEV_ONLY_SetSnapshotEntryName,
|
|
1074
|
+
'first-screen-lazy-missing',
|
|
1075
|
+
'https://example.com/lazy-bundle.js',
|
|
1076
|
+
],
|
|
1077
|
+
42,
|
|
1078
|
+
false,
|
|
1079
|
+
)
|
|
1068
1080
|
).not.toThrow();
|
|
1069
1081
|
});
|
|
1070
1082
|
|
|
@@ -1141,7 +1153,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1141
1153
|
delete snapshotCreatorMap[uniqID1];
|
|
1142
1154
|
|
|
1143
1155
|
// Apply patches in main thread
|
|
1144
|
-
snapshotPatchApply(patch);
|
|
1156
|
+
snapshotPatchApply(patch, 42, false);
|
|
1145
1157
|
new SnapshotInstance(uniqID1);
|
|
1146
1158
|
|
|
1147
1159
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1236,7 +1248,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1236
1248
|
delete snapshotCreatorMap[uniqID1];
|
|
1237
1249
|
|
|
1238
1250
|
// Apply patches in main thread
|
|
1239
|
-
snapshotPatchApply(patch);
|
|
1251
|
+
snapshotPatchApply(patch, 42, false);
|
|
1240
1252
|
new SnapshotInstance(uniqID1);
|
|
1241
1253
|
|
|
1242
1254
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1326,7 +1338,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1326
1338
|
delete snapshotCreatorMap[uniqID1];
|
|
1327
1339
|
|
|
1328
1340
|
// Apply patches in main thread
|
|
1329
|
-
snapshotPatchApply(patch);
|
|
1341
|
+
snapshotPatchApply(patch, 42, false);
|
|
1330
1342
|
new SnapshotInstance(uniqID1);
|
|
1331
1343
|
|
|
1332
1344
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1416,7 +1428,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1416
1428
|
const fn = vi.fn();
|
|
1417
1429
|
vi.stubGlobal('__SetCSSId', fn);
|
|
1418
1430
|
// Apply patches in main thread
|
|
1419
|
-
snapshotPatchApply(patch);
|
|
1431
|
+
snapshotPatchApply(patch, 42, false);
|
|
1420
1432
|
new SnapshotInstance(uniqID1);
|
|
1421
1433
|
|
|
1422
1434
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1608,7 +1620,7 @@ describe('DEV_ONLY_addSnapshot', () => {
|
|
|
1608
1620
|
snapshotManager.values.delete(uniqID1);
|
|
1609
1621
|
delete snapshotCreatorMap[uniqID1];
|
|
1610
1622
|
|
|
1611
|
-
snapshotPatchApply(patch);
|
|
1623
|
+
snapshotPatchApply(patch, 42, false);
|
|
1612
1624
|
new SnapshotInstance(uniqID1);
|
|
1613
1625
|
|
|
1614
1626
|
expect(snapshotManager.values.size).toBe(originalSize);
|
|
@@ -1645,7 +1657,7 @@ describe.skip('DEV_ONLY_RegisterWorklet', () => {
|
|
|
1645
1657
|
`);
|
|
1646
1658
|
|
|
1647
1659
|
// Apply patches in main thread
|
|
1648
|
-
snapshotPatchApply(patch);
|
|
1660
|
+
snapshotPatchApply(patch, 42, false);
|
|
1649
1661
|
|
|
1650
1662
|
expect(globalThis.registerWorklet).toBeCalledTimes(1);
|
|
1651
1663
|
expect(globalThis.registerWorklet.mock.calls[0][0]).toMatch('main-thread');
|
|
@@ -1668,7 +1680,7 @@ describe('list', () => {
|
|
|
1668
1680
|
let patch;
|
|
1669
1681
|
patch = takeGlobalSnapshotPatch();
|
|
1670
1682
|
expect(patch.length).toMatchInlineSnapshot(`3`);
|
|
1671
|
-
snapshotPatchApply(patch);
|
|
1683
|
+
snapshotPatchApply(patch, 42, false);
|
|
1672
1684
|
const si1 = snapshotInstanceManager.values.get(bsi1.__id);
|
|
1673
1685
|
si1.ensureElements();
|
|
1674
1686
|
|
|
@@ -1677,7 +1689,7 @@ describe('list', () => {
|
|
|
1677
1689
|
bsi1.insertBefore(bsi2);
|
|
1678
1690
|
patch = takeGlobalSnapshotPatch();
|
|
1679
1691
|
expect(patch.length).toMatchInlineSnapshot(`11`);
|
|
1680
|
-
snapshotPatchApply(patch);
|
|
1692
|
+
snapshotPatchApply(patch, 42, false);
|
|
1681
1693
|
expect(si1.__element_root).toMatchInlineSnapshot(`
|
|
1682
1694
|
<view>
|
|
1683
1695
|
<text>
|
|
@@ -210,7 +210,7 @@ describe('spreadUpdate', () => {
|
|
|
210
210
|
render(<Comp />, scratchBackground);
|
|
211
211
|
patch = hydrate(JSON.parse(JSON.stringify(scratch)), scratchBackground);
|
|
212
212
|
globalEnvManager.switchToMainThread();
|
|
213
|
-
snapshotPatchApply(patch);
|
|
213
|
+
snapshotPatchApply(patch, 42, false);
|
|
214
214
|
globalEnvManager.switchToBackground();
|
|
215
215
|
initGlobalSnapshotPatch();
|
|
216
216
|
|
|
@@ -237,7 +237,7 @@ describe('spreadUpdate', () => {
|
|
|
237
237
|
`);
|
|
238
238
|
|
|
239
239
|
globalEnvManager.switchToMainThread();
|
|
240
|
-
snapshotPatchApply(patch);
|
|
240
|
+
snapshotPatchApply(patch, 42, false);
|
|
241
241
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
242
242
|
<page
|
|
243
243
|
cssId="default-entry-from-native:0"
|
|
@@ -314,7 +314,7 @@ describe('spreadUpdate', () => {
|
|
|
314
314
|
// this update could be removed later
|
|
315
315
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
316
316
|
globalEnvManager.switchToMainThread();
|
|
317
|
-
snapshotPatchApply(patch);
|
|
317
|
+
snapshotPatchApply(patch, 42, false);
|
|
318
318
|
globalEnvManager.switchToBackground();
|
|
319
319
|
initGlobalSnapshotPatch();
|
|
320
320
|
setSpread_({
|
|
@@ -340,7 +340,7 @@ describe('spreadUpdate', () => {
|
|
|
340
340
|
`);
|
|
341
341
|
|
|
342
342
|
globalEnvManager.switchToMainThread();
|
|
343
|
-
snapshotPatchApply(patch);
|
|
343
|
+
snapshotPatchApply(patch, 42, false);
|
|
344
344
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
345
345
|
<page
|
|
346
346
|
cssId="default-entry-from-native:0"
|
|
@@ -417,7 +417,7 @@ describe('spreadUpdate', () => {
|
|
|
417
417
|
// this update could be removed later
|
|
418
418
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
419
419
|
globalEnvManager.switchToMainThread();
|
|
420
|
-
snapshotPatchApply(patch);
|
|
420
|
+
snapshotPatchApply(patch, 42, false);
|
|
421
421
|
globalEnvManager.switchToBackground();
|
|
422
422
|
initGlobalSnapshotPatch();
|
|
423
423
|
setSpread_({});
|
|
@@ -433,7 +433,7 @@ describe('spreadUpdate', () => {
|
|
|
433
433
|
`);
|
|
434
434
|
|
|
435
435
|
globalEnvManager.switchToMainThread();
|
|
436
|
-
snapshotPatchApply(patch);
|
|
436
|
+
snapshotPatchApply(patch, 42, false);
|
|
437
437
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
438
438
|
<page
|
|
439
439
|
cssId="default-entry-from-native:0"
|
|
@@ -502,7 +502,7 @@ describe('spreadUpdate', () => {
|
|
|
502
502
|
// this update could be removed later
|
|
503
503
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
504
504
|
globalEnvManager.switchToMainThread();
|
|
505
|
-
snapshotPatchApply(patch);
|
|
505
|
+
snapshotPatchApply(patch, 42, false);
|
|
506
506
|
globalEnvManager.switchToBackground();
|
|
507
507
|
initGlobalSnapshotPatch();
|
|
508
508
|
setSpread_(null);
|
|
@@ -518,7 +518,7 @@ describe('spreadUpdate', () => {
|
|
|
518
518
|
`);
|
|
519
519
|
|
|
520
520
|
globalEnvManager.switchToMainThread();
|
|
521
|
-
snapshotPatchApply(patch);
|
|
521
|
+
snapshotPatchApply(patch, 42, false);
|
|
522
522
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
523
523
|
<page
|
|
524
524
|
cssId="default-entry-from-native:0"
|
|
@@ -625,7 +625,7 @@ describe('spreadUpdate', () => {
|
|
|
625
625
|
// this update could be removed later
|
|
626
626
|
expect(patch).toMatchInlineSnapshot(`[]`);
|
|
627
627
|
globalEnvManager.switchToMainThread();
|
|
628
|
-
snapshotPatchApply(patch);
|
|
628
|
+
snapshotPatchApply(patch, 42, false);
|
|
629
629
|
globalEnvManager.switchToBackground();
|
|
630
630
|
initGlobalSnapshotPatch();
|
|
631
631
|
setSpread_({});
|
|
@@ -645,7 +645,7 @@ describe('spreadUpdate', () => {
|
|
|
645
645
|
`);
|
|
646
646
|
|
|
647
647
|
globalEnvManager.switchToMainThread();
|
|
648
|
-
snapshotPatchApply(patch);
|
|
648
|
+
snapshotPatchApply(patch, 42, false);
|
|
649
649
|
expect(scratch.__element_root).toMatchInlineSnapshot(`
|
|
650
650
|
<page
|
|
651
651
|
cssId="default-entry-from-native:0"
|