@lynx-js/react 0.129.2 → 0.129.4
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 +24 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/refresh/.turbo/turbo-build.log +3 -3
- package/refresh/dist/index.js +113 -20
- package/refresh/rslib.config.ts +13 -3
- package/refresh/src/index.ts +100 -0
- package/refresh/src/self.ts +38 -0
- package/runtime/__test__/{snapshot → core}/attribute-name.test.ts +1 -1
- package/runtime/__test__/core/background-function.test.ts +37 -0
- package/runtime/__test__/{shared → core}/component-stack.test.ts +4 -4
- package/runtime/__test__/core/ref.test.ts +218 -1
- package/runtime/__test__/core/sync-effect-flush.test.ts +58 -0
- package/runtime/__test__/element-template/debug/alog.test.ts +20 -12
- package/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx +15 -34
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt +2 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt +6 -1
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.move-before-child → children.reconciles-raw-text-slots}/case.tsx +1 -1
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/list/mts/index.tsx +185 -0
- package/runtime/__test__/element-template/fixtures/page/render-page/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/case.tsx +2 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/ops.txt +1 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/ops.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/papi.txt +10 -5
- package/runtime/__test__/element-template/fixtures/render/component/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/papi.txt +2 -1
- package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/native-log.txt +2 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/papi.txt +14 -7
- package/runtime/__test__/element-template/fixtures/render/mixed-children/papi.txt +8 -4
- package/runtime/__test__/element-template/fixtures/render/multiple-text/papi.txt +38 -19
- package/runtime/__test__/element-template/fixtures/render/nested-templates/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/react-example/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/papi.txt +10 -5
- package/runtime/__test__/element-template/lynx/performance.test.ts +1 -0
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +1 -0
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +10 -15
- package/runtime/__test__/element-template/native/reload.test.ts +4 -7
- package/runtime/__test__/element-template/runtime/background/adapter/background-adapter.et.test.tsx +0 -32
- package/runtime/__test__/element-template/runtime/background/commit-context.test.ts +0 -14
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +10 -0
- package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +22 -0
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +197 -252
- package/runtime/__test__/element-template/runtime/background/instance.test.ts +277 -126
- package/runtime/__test__/element-template/runtime/background/passive-update-depth.test.tsx +496 -0
- package/runtime/__test__/element-template/runtime/background/render/preact.test.tsx +16 -22
- package/runtime/__test__/element-template/runtime/background/root-render.test.tsx +5 -3
- package/runtime/__test__/element-template/runtime/background/suspense.test.tsx +2 -0
- package/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +1 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +3 -4
- package/runtime/__test__/element-template/runtime/list/list-mts-compiled.test.ts +525 -0
- package/runtime/__test__/element-template/runtime/page/compiled-fixtures.test.tsx +2 -0
- package/runtime/__test__/element-template/runtime/page/root-instance.test.ts +2 -14
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +425 -1032
- package/runtime/__test__/element-template/runtime/patch/patch-listener-alog.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/event.test.ts +0 -20
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +2 -1
- package/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/ref.test.ts +65 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +12 -4
- package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +2 -5
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +56 -121
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +18 -17
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +5 -4
- package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -0
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +1 -60
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +32 -89
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +8 -6
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +34 -6
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.test.tsx +20 -12
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.ts +2 -28
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.test.ts +14 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.ts +1 -57
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +29 -13
- package/runtime/__test__/element-template/vitest.config.ts +1 -0
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +98 -77
- package/runtime/__test__/snapshot/compat/export.test.jsx +8 -2
- package/runtime/__test__/snapshot/debug/passive-update-depth.test.jsx +549 -0
- package/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx +3 -3
- package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +138 -1
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +1 -1
- package/runtime/__test__/snapshot/lifecycle/transfer.mts.test.jsx +194 -0
- package/runtime/__test__/snapshot/lifecycle/transfer.test.jsx +210 -0
- package/runtime/__test__/snapshot/list.test.jsx +109 -0
- package/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx +2 -2
- package/runtime/__test__/snapshot/ref.test.jsx +124 -1
- package/runtime/__test__/snapshot/utils/envManager.ts +5 -0
- package/runtime/__test__/snapshot/utils/globals.js +1 -0
- package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +22 -11
- package/runtime/__test__/worklet-runtime/hydrate.test.js +1 -0
- package/runtime/__test__/worklet-runtime/initEntry.test.js +12 -0
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +24 -16
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +188 -0
- package/runtime/__test__/worklet-runtime/workletRef.test.js +16 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +53 -1
- package/runtime/compat/index.d.ts +17 -1
- package/runtime/compat/index.js +3 -2
- package/runtime/lazy/compat.js +1 -0
- package/runtime/lazy/internal.js +1 -0
- package/runtime/lib/core/attribute-name.js.map +1 -0
- package/runtime/lib/core/background-function/run-on-background.js +7 -7
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/{shared → core}/component-stack.js +1 -1
- package/runtime/lib/core/component-stack.js.map +1 -0
- package/runtime/lib/core/deep-equal.d.ts +1 -0
- package/runtime/lib/core/deep-equal.js +31 -0
- package/runtime/lib/core/deep-equal.js.map +1 -0
- package/runtime/lib/core/hooks/mainThreadImpl.js +1 -1
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/lynx-page-data.js +1 -1
- package/runtime/lib/core/lynx-page-data.js.map +1 -1
- package/runtime/lib/core/mts-capability.js +1 -1
- package/runtime/lib/core/mts-capability.js.map +1 -1
- package/runtime/lib/core/performance.js +2 -1
- package/runtime/lib/core/performance.js.map +1 -1
- package/runtime/lib/core/ref.d.ts +1 -2
- package/runtime/lib/core/ref.js +60 -9
- package/runtime/lib/core/ref.js.map +1 -1
- package/runtime/lib/core/sync-effect-flush.d.ts +9 -0
- package/runtime/lib/core/sync-effect-flush.js +31 -0
- package/runtime/lib/core/sync-effect-flush.js.map +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +1 -1
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.d.ts +1 -0
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +1 -1
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +1 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +173 -85
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +7 -10
- package/runtime/lib/element-template/background/instance.js +65 -58
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/render-scope.js +2 -1
- package/runtime/lib/element-template/background/render-scope.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +1 -10
- package/runtime/lib/element-template/debug/alog.js +1 -16
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js +1 -1
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +2 -2
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +4 -8
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +0 -4
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.d.ts +2 -1
- package/runtime/lib/element-template/prop-adapters/ref.js +4 -4
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +0 -2
- package/runtime/lib/element-template/protocol/opcodes.js +0 -2
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +8 -30
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/list.d.ts +14 -54
- package/runtime/lib/element-template/runtime/list/list.js +82 -546
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/platform-info.d.ts +2 -0
- package/runtime/lib/element-template/runtime/list/platform-info.js +26 -0
- package/runtime/lib/element-template/runtime/list/platform-info.js.map +1 -0
- package/runtime/lib/element-template/runtime/patch.js +42 -119
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js +24 -21
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.d.ts +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +3 -6
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-direct.js +21 -20
- package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +0 -13
- 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 +8 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +3 -3
- package/runtime/lib/element-template/runtime/template/handle.js +2 -2
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +1 -6
- 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.d.ts +2 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +44 -28
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.d.ts +2 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +8 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -0
- package/runtime/lib/internal.js +1 -0
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.js +6 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +4 -4
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.d.ts +5 -1
- package/runtime/lib/root.js +12 -1
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/shared/microtask.d.ts +1 -0
- package/runtime/lib/shared/microtask.js +28 -0
- package/runtime/lib/shared/microtask.js.map +1 -0
- package/runtime/lib/shared/utils.d.ts +8 -0
- package/runtime/lib/shared/utils.js +27 -0
- package/runtime/lib/shared/utils.js.map +1 -0
- package/runtime/lib/{worklet-runtime/utils → shared}/version.d.ts +1 -0
- package/runtime/lib/shared/version.js +15 -0
- package/runtime/lib/shared/version.js.map +1 -0
- package/runtime/lib/snapshot/alog/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +2 -2
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js +2 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +7 -2
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +11 -6
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +2 -2
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +12 -3
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.d.ts +3 -1
- package/runtime/lib/snapshot/lynx/tt.js +7 -3
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/ref.js +2 -2
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +3 -2
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/transfer.d.ts +15 -0
- package/runtime/lib/snapshot/transfer.js +343 -0
- package/runtime/lib/snapshot/transfer.js.map +1 -0
- package/runtime/lib/snapshot/worklet/functionality.js +1 -1
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/api/element.js +1 -1
- package/runtime/lib/worklet-runtime/api/element.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -2
- package/runtime/lib/worklet-runtime/bindings/bindings.js +11 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js +9 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayWorkletEvent.d.ts +2 -4
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js +42 -44
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js.map +1 -1
- package/runtime/lib/worklet-runtime/global.d.ts +1 -2
- package/runtime/lib/worklet-runtime/global.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +2 -32
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/run-on-background/index.d.ts +28 -0
- package/runtime/lib/worklet-runtime/run-on-background/index.js +103 -0
- package/runtime/lib/worklet-runtime/run-on-background/index.js.map +1 -0
- package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.d.ts → run-on-background/lifecycle.d.ts} +2 -2
- package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.js → run-on-background/lifecycle.js} +12 -9
- package/runtime/lib/worklet-runtime/run-on-background/lifecycle.js.map +1 -0
- package/runtime/lib/worklet-runtime/workletRef.js +51 -54
- package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +5 -6
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/src/core/background-function/run-on-background.ts +7 -7
- package/runtime/src/{shared → core}/component-stack.ts +1 -1
- package/runtime/src/core/deep-equal.ts +33 -0
- package/runtime/src/core/hooks/mainThreadImpl.ts +1 -1
- package/runtime/src/core/lynx-page-data.ts +1 -1
- package/runtime/src/core/mts-capability.ts +1 -1
- package/runtime/src/core/performance.ts +2 -1
- package/runtime/src/core/ref.ts +92 -15
- package/runtime/src/core/sync-effect-flush.ts +30 -0
- package/runtime/src/core/thread-function-call/main-thread.ts +1 -1
- package/runtime/src/element-template/background/attr-slots.ts +2 -2
- package/runtime/src/element-template/background/commit-hook.ts +1 -1
- package/runtime/src/element-template/background/destroy.ts +1 -1
- package/runtime/src/element-template/background/hydrate.ts +229 -119
- package/runtime/src/element-template/background/instance.ts +82 -82
- package/runtime/src/element-template/background/render-scope.ts +2 -1
- package/runtime/src/element-template/debug/alog.ts +2 -30
- package/runtime/src/element-template/debug/profile.ts +1 -1
- package/runtime/src/element-template/native/index.ts +2 -2
- package/runtime/src/element-template/native/patch-listener.ts +6 -7
- package/runtime/src/element-template/native/reload-main-thread.ts +0 -4
- package/runtime/src/element-template/prop-adapters/ref.ts +12 -5
- package/runtime/src/element-template/prop-adapters/spread.ts +1 -1
- package/runtime/src/element-template/protocol/opcodes.ts +0 -2
- package/runtime/src/element-template/protocol/types.ts +10 -38
- package/runtime/src/element-template/runtime/list/list.ts +115 -744
- package/runtime/src/element-template/runtime/list/platform-info.ts +31 -0
- package/runtime/src/element-template/runtime/patch.ts +59 -163
- package/runtime/src/element-template/runtime/render/create-rendered-host.ts +27 -31
- package/runtime/src/element-template/runtime/render/render-components.ts +2 -5
- package/runtime/src/element-template/runtime/render/render-direct.ts +19 -18
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +0 -14
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +9 -0
- package/runtime/src/element-template/runtime/template/handle.ts +3 -2
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +1 -6
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +44 -30
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +17 -1
- package/runtime/src/element-template/types.d.ts +6 -22
- package/runtime/src/internal.ts +2 -0
- package/runtime/src/lynx-api.ts +6 -1
- package/runtime/src/lynx.ts +4 -4
- package/runtime/src/root.ts +17 -1
- package/runtime/src/shared/microtask.ts +26 -0
- package/runtime/src/shared/utils.ts +37 -0
- package/runtime/src/shared/version.ts +16 -0
- package/runtime/src/snapshot/alog/render.ts +1 -1
- package/runtime/src/snapshot/debug/profileHooks.ts +1 -1
- package/runtime/src/snapshot/lifecycle/destroy.ts +2 -2
- package/runtime/src/snapshot/lifecycle/isRendering.ts +2 -1
- package/runtime/src/snapshot/lifecycle/patch/commit.ts +28 -7
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +1 -1
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +5 -2
- package/runtime/src/snapshot/lifecycle/reload.ts +1 -1
- package/runtime/src/snapshot/list/list.ts +12 -3
- package/runtime/src/snapshot/lynx/tt.ts +8 -3
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +1 -1
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/snapshot/snapshot/platformInfo.ts +1 -1
- package/runtime/src/snapshot/snapshot/ref.ts +7 -4
- package/runtime/src/snapshot/snapshot/snapshot.ts +1 -1
- package/runtime/src/snapshot/snapshot/spread.ts +3 -2
- package/runtime/src/snapshot/transfer.ts +379 -0
- package/runtime/src/snapshot/worklet/functionality.ts +1 -1
- package/runtime/src/worklet-runtime/api/element.ts +1 -1
- package/runtime/src/worklet-runtime/api/lynxApi.ts +1 -1
- package/runtime/src/worklet-runtime/bindings/bindings.ts +12 -0
- package/runtime/src/worklet-runtime/bindings/observers.ts +9 -1
- package/runtime/src/worklet-runtime/bindings/types.ts +1 -0
- package/runtime/src/worklet-runtime/delayWorkletEvent.ts +49 -54
- package/runtime/src/worklet-runtime/global.ts +1 -2
- package/runtime/src/worklet-runtime/hydrate.ts +2 -35
- package/runtime/src/worklet-runtime/run-on-background/index.ts +145 -0
- package/runtime/src/worklet-runtime/{jsFunctionLifecycle.ts → run-on-background/lifecycle.ts} +11 -9
- package/runtime/src/worklet-runtime/workletRef.ts +63 -62
- package/runtime/src/worklet-runtime/workletRuntime.ts +10 -10
- package/testing-library/.turbo/turbo-build.log +10 -10
- package/testing-library/dist/pure.js +7 -4
- package/testing-library/dist/setupFiles/common/runtime-setup.js +3 -1
- package/testing-library/dist/setupFiles/inner/rstest.js +1 -1
- package/testing-library/dist/setupFiles/inner/vitest.js +1 -1
- package/testing-library/src/__tests__/list.test.jsx +52 -0
- package/testing-library/src/__tests__/worklet.test.jsx +81 -0
- package/testing-library/src/pure.jsx +5 -2
- package/testing-library/src/setupFiles/common/runtime-setup.js +2 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +88 -201
- package/transform/crates/swc_plugin_element_template/tests/element_template.rs +19 -45
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +0 -19
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +129 -156
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +282 -149
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt +0 -10
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx +0 -5
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/case.ts +0 -11
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/output.txt +0 -1
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/case.ts +0 -23
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/output.txt +0 -6
- package/runtime/__test__/element-template/runtime/page/authored-page.test.ts +0 -35
- package/runtime/__test__/element-template/runtime/patch/update-fixture-helper.test.tsx +0 -40
- package/runtime/__test__/snapshot/lynx-data-processors.test.ts +0 -3
- package/runtime/lib/shared/attribute-name.js.map +0 -1
- package/runtime/lib/shared/component-stack.js.map +0 -1
- package/runtime/lib/snapshot/alog/index.d.ts +0 -1
- package/runtime/lib/snapshot/alog/index.js +0 -8
- package/runtime/lib/snapshot/alog/index.js.map +0 -1
- package/runtime/lib/utils.d.ts +0 -19
- package/runtime/lib/utils.js +0 -119
- package/runtime/lib/utils.js.map +0 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.d.ts +0 -13
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +0 -29
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +0 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +0 -1
- package/runtime/lib/worklet-runtime/utils/version.js +0 -10
- package/runtime/lib/worklet-runtime/utils/version.js.map +0 -1
- package/runtime/src/snapshot/alog/index.ts +0 -8
- package/runtime/src/utils.ts +0 -134
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +0 -53
- package/runtime/src/worklet-runtime/utils/version.ts +0 -11
- /package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.raw-text-key-branches → children.reconciles-raw-text-slots}/output.txt +0 -0
- /package/runtime/lib/{shared → core}/attribute-name.d.ts +0 -0
- /package/runtime/lib/{shared → core}/attribute-name.js +0 -0
- /package/runtime/lib/{shared → core}/component-stack.d.ts +0 -0
- /package/runtime/src/{shared → core}/attribute-name.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/commit.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;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EG;AACH,SAAS,iBAAiB;IACxB,gBAAgB,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,yCAAyC,EACzC,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,GAGlB,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Implements the commit phase of the rendering lifecycle.\n * This module patches Preact's commit phase to integrate with the snapshot system,\n * handling the collection and transmission of patches between threads.\n *\n * The commit phase is responsible for:\n * - Collecting patches from the snapshot system\n * - Managing commit tasks and their execution\n * - Coordinating with the native layer for updates\n * - Handling performance timing and pipeline options\n */\n\n/**\n * This module patches Preact's commit phase by hacking into the internal of\n * its [options](https://preactjs.com/guide/v10/options/) API\n */\n\nimport { options } from 'preact';\n\nimport type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport {\n globalBackgroundSnapshotInstancesToRemove,\n setGlobalBackgroundSnapshotInstancesToRemove,\n} from './globalState.js';\nimport { takeGlobalSnapshotPatch } from './snapshotPatch.js';\nimport type { SnapshotPatch } from './snapshotPatch.js';\nimport { takeGlobalFlushOptions } from '../../../core/commit-context.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../../core/thread-function-call/main-thread.js';\nimport { profileEnd, profileStart } from '../../../shared/profile.js';\nimport { COMMIT } from '../../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../../utils.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { backgroundSnapshotInstanceManager } from '../../snapshot/backgroundSnapshot.js';\nimport { applyQueuedRefs } from '../../snapshot/ref.js';\nimport { sendMTRefInitValueToMainThread } from '../../worklet/ref/updateInitValue.js';\nimport { isRendering } from '../isRendering.js';\n\nconst globalCommitTaskMap: Map<number, () => void> = /*@__PURE__*/ new Map<number, () => void>();\nlet nextCommitTaskId = 1;\n\n/**\n * A single patch operation.\n */\ninterface Patch {\n // TODO: ref: do we need `id`?\n id: number;\n snapshotPatch?: SnapshotPatch;\n}\n\n/**\n * List of patches to be applied in a single update cycle with flush options.\n */\ninterface PatchList {\n patchList: Patch[];\n delayedRunOnMainThreadData?: RunWorkletCtxData[];\n flushOptions?: FlushOptions;\n}\n\n/**\n * Configuration options for patch operations\n */\ninterface PatchOptions {\n pipelineOptions?: PipelineOptions;\n reloadVersion: number;\n isHydration?: boolean;\n flowIds?: number[];\n}\n\n/**\n * Allow to pass options to the patch operation\n */\nexport type GlobalPatchOptions = Omit<PatchOptions, 'reloadVersion'>;\nexport let globalPatchOptions: GlobalPatchOptions = {};\n\nfunction takeGlobalPatchOptions(): GlobalPatchOptions {\n const res = globalPatchOptions;\n globalPatchOptions = {};\n return res;\n}\n\nlet commitHookInstalled = false;\nlet previousCommit: typeof options[typeof COMMIT];\n\n/**\n * Replaces Preact's default commit hook with our custom implementation.\n * Calling it again is a no-op until {@link removeCommitHookForTesting} is called.\n */\nfunction replaceCommitHook(): void {\n if (commitHookInstalled) {\n return;\n }\n commitHookInstalled = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(\n options,\n COMMIT,\n (\n originalPreactCommit, // This is actually not used since Preact use `hooks._commit` for callbacks of `useLayoutEffect`.\n vnode,\n commitQueue,\n ) => {\n // Skip commit phase for MT runtime\n if (typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__) {\n // for testing only\n commitQueue.length = 0;\n return;\n }\n\n isRendering.value = false;\n\n // Mark the end of virtual DOM diffing phase for performance tracking\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n const backgroundSnapshotInstancesToRemove = globalBackgroundSnapshotInstancesToRemove;\n setGlobalBackgroundSnapshotInstancesToRemove([]);\n\n const commitTaskId = genCommitTaskId();\n\n // Register the commit task\n globalCommitTaskMap.set(commitTaskId, () => {\n if (backgroundSnapshotInstancesToRemove.length) {\n setTimeout(() => {\n backgroundSnapshotInstancesToRemove.forEach(id => {\n backgroundSnapshotInstanceManager.values.get(id)?.tearDown();\n });\n }, 10000);\n }\n });\n\n sendMTRefInitValueToMainThread();\n\n // Collect patches for this update\n const snapshotPatch = takeGlobalSnapshotPatch();\n const flushOptions = takeGlobalFlushOptions();\n const patchOptions = takeGlobalPatchOptions();\n if (!snapshotPatch) {\n // before hydration, skip patch\n applyQueuedRefs();\n originalPreactCommit?.(vnode, commitQueue);\n return;\n }\n\n const patch: Patch = {\n id: commitTaskId,\n };\n // TODO: check all fields in `flushOptions` from runtime3\n if (snapshotPatch.length) {\n patch.snapshotPatch = snapshotPatch;\n }\n const patchList: PatchList = {\n patchList: [patch],\n };\n if (!snapshotPatch.length && !delayedRunOnMainThreadData.length) {\n flushOptions.emptyPatch = true;\n }\n if (!isEmptyObject(flushOptions)) {\n patchList.flushOptions = flushOptions;\n }\n if (delayedRunOnMainThreadData.length) {\n patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData();\n }\n const obj = commitPatchUpdate(patchList, patchOptions);\n\n // Send the update to the native layer\n lynx.getNativeApp().callLepusMethod(LifecycleConstant.patchUpdate, obj, () => {\n const commitTask = globalCommitTaskMap.get(commitTaskId);\n if (commitTask) {\n commitTask();\n globalCommitTaskMap.delete(commitTaskId);\n }\n });\n\n applyQueuedRefs();\n originalPreactCommit?.(vnode, commitQueue);\n },\n );\n}\n\n/**\n * Restores the commit option replaced by {@link replaceCommitHook} so tests\n * can clean up the global Preact `options` object. Assumes the matching\n * install was the most recent commit-option replacement; the snapshot and\n * ElementTemplate runtimes are separate entrypoints and never install their\n * commit hooks in the same context.\n */\nfunction removeCommitHookForTesting(): void {\n if (!commitHookInstalled) {\n return;\n }\n commitHookInstalled = false;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n\n/**\n * Prepares the patch update for transmission to the native layer\n */\nfunction commitPatchUpdate(patchList: PatchList, patchOptions: GlobalPatchOptions): {\n data: string;\n patchOptions: PatchOptions;\n} {\n // console.debug('********** JS update:');\n // printSnapshotInstance(\n // (backgroundSnapshotInstanceManager.values.get(1) ?? backgroundSnapshotInstanceManager.values.get(-1))!,\n // );\n // console.debug('commitPatchUpdate:', prettyFormatSnapshotPatch(patchList.patchList[0]?.snapshotPatch));\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n const obj: {\n data: string;\n patchOptions: PatchOptions;\n } = {\n data: JSON.stringify(patchList),\n patchOptions: {\n ...patchOptions,\n reloadVersion: getReloadVersion(),\n },\n };\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n obj.patchOptions.pipelineOptions = globalPipelineOptions;\n setPipeline(undefined);\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n\n return obj;\n}\n\n/**\n * Generates a unique ID for commit tasks\n */\nfunction genCommitTaskId(): number {\n return nextCommitTaskId++;\n}\n\n/**\n * Resets the commit task ID counter\n */\nfunction clearCommitTaskId(): void {\n nextCommitTaskId = 1;\n}\n\n/**\n * @internal\n */\nexport {\n clearCommitTaskId,\n commitPatchUpdate,\n genCommitTaskId,\n globalBackgroundSnapshotInstancesToRemove,\n globalCommitTaskMap,\n removeCommitHookForTesting,\n replaceCommitHook,\n type PatchList,\n type PatchOptions,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/commit.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;;;;;;;;GAUG;AAEH;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,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AO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,UAAU,EAAE,CAAC;IACf,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB;IACxB,gBAAgB,GAAG,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,yCAAyC,EACzC,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,GAIlB,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Implements the commit phase of the rendering lifecycle.\n * This module patches Preact's commit phase to integrate with the snapshot system,\n * handling the collection and transmission of patches between threads.\n *\n * The commit phase is responsible for:\n * - Collecting patches from the snapshot system\n * - Managing commit tasks and their execution\n * - Coordinating with the native layer for updates\n * - Handling performance timing and pipeline options\n */\n\n/**\n * This module patches Preact's commit phase by hacking into the internal of\n * its [options](https://preactjs.com/guide/v10/options/) API\n */\n\nimport { options } from 'preact';\nimport type { VNode } from 'preact';\n\nimport type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport {\n globalBackgroundSnapshotInstancesToRemove,\n setGlobalBackgroundSnapshotInstancesToRemove,\n} from './globalState.js';\nimport { takeGlobalSnapshotPatch } from './snapshotPatch.js';\nimport type { SnapshotPatch } from './snapshotPatch.js';\nimport { takeGlobalFlushOptions } from '../../../core/commit-context.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../../core/thread-function-call/main-thread.js';\nimport { profileEnd, profileStart } from '../../../shared/profile.js';\nimport { COMMIT } from '../../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../../shared/utils.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { backgroundSnapshotInstanceManager } from '../../snapshot/backgroundSnapshot.js';\nimport { applyQueuedRefs } from '../../snapshot/ref.js';\nimport { sendMTRefInitValueToMainThread } from '../../worklet/ref/updateInitValue.js';\nimport { isRendering } from '../isRendering.js';\n\nconst globalCommitTaskMap: Map<number, () => void> = /*@__PURE__*/ new Map<number, () => void>();\nlet nextCommitTaskId = 1;\n\n/**\n * A single patch operation.\n */\ninterface Patch {\n // TODO: ref: do we need `id`?\n id: number;\n snapshotPatch?: SnapshotPatch;\n}\n\n/**\n * List of patches to be applied in a single update cycle with flush options.\n */\ninterface PatchList {\n patchList: Patch[];\n delayedRunOnMainThreadData?: RunWorkletCtxData[];\n flushOptions?: FlushOptions;\n}\n\n/**\n * Configuration options for patch operations\n */\ninterface PatchOptions {\n pipelineOptions?: PipelineOptions;\n reloadVersion: number;\n isHydration?: boolean;\n flowIds?: number[];\n}\n\n/**\n * Allow to pass options to the patch operation\n */\nexport type GlobalPatchOptions = Omit<PatchOptions, 'reloadVersion'>;\nexport let globalPatchOptions: GlobalPatchOptions = {};\n\nfunction takeGlobalPatchOptions(): GlobalPatchOptions {\n const res = globalPatchOptions;\n globalPatchOptions = {};\n return res;\n}\n\n/**\n * Delivers a collected commit and calls `finish` once it has been applied.\n */\ntype CommitTransport = (\n vnode: VNode,\n patchList: PatchList,\n patchOptions: GlobalPatchOptions,\n finish: () => void,\n) => void;\n\nconst nativeTransport: CommitTransport = (_vnode, patchList, patchOptions, finish) => {\n // Send the update to the native layer\n lynx.getNativeApp().callLepusMethod(\n LifecycleConstant.patchUpdate,\n commitPatchUpdate(patchList, patchOptions),\n finish,\n );\n};\n\nlet commitHookInstalled = false;\nlet previousCommit: typeof options[typeof COMMIT];\nlet commitTransport: CommitTransport = nativeTransport;\n\n/**\n * Replaces Preact's default commit hook with our custom implementation.\n * Calling it again only replaces the transport until {@link removeCommitHookForTesting} is called.\n */\nfunction replaceCommitHook(transport: CommitTransport = nativeTransport): void {\n commitTransport = transport;\n if (commitHookInstalled) {\n return;\n }\n commitHookInstalled = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(\n options,\n COMMIT,\n (\n originalPreactCommit, // This is actually not used since Preact use `hooks._commit` for callbacks of `useLayoutEffect`.\n vnode,\n commitQueue,\n ) => {\n // Skip commit phase for MT runtime\n if (typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__) {\n // for testing only\n commitQueue.length = 0;\n return;\n }\n\n isRendering.value = false;\n\n // Mark the end of virtual DOM diffing phase for performance tracking\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n const backgroundSnapshotInstancesToRemove = globalBackgroundSnapshotInstancesToRemove;\n setGlobalBackgroundSnapshotInstancesToRemove([]);\n\n const commitTaskId = genCommitTaskId();\n\n // Register the commit task\n globalCommitTaskMap.set(commitTaskId, () => {\n if (backgroundSnapshotInstancesToRemove.length) {\n setTimeout(() => {\n backgroundSnapshotInstancesToRemove.forEach(id => {\n backgroundSnapshotInstanceManager.values.get(id)?.tearDown();\n });\n }, 10000);\n }\n });\n\n sendMTRefInitValueToMainThread();\n\n // Collect patches for this update\n const snapshotPatch = takeGlobalSnapshotPatch();\n const flushOptions = takeGlobalFlushOptions();\n const patchOptions = takeGlobalPatchOptions();\n if (!snapshotPatch) {\n // before hydration, skip patch\n applyQueuedRefs();\n originalPreactCommit?.(vnode, commitQueue);\n return;\n }\n\n const patch: Patch = {\n id: commitTaskId,\n };\n // TODO: check all fields in `flushOptions` from runtime3\n if (snapshotPatch.length) {\n patch.snapshotPatch = snapshotPatch;\n }\n const patchList: PatchList = {\n patchList: [patch],\n };\n if (!snapshotPatch.length && !delayedRunOnMainThreadData.length) {\n flushOptions.emptyPatch = true;\n }\n if (!isEmptyObject(flushOptions)) {\n patchList.flushOptions = flushOptions;\n }\n if (delayedRunOnMainThreadData.length) {\n patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData();\n }\n commitTransport(vnode, patchList, patchOptions, () => {\n const commitTask = globalCommitTaskMap.get(commitTaskId);\n if (commitTask) {\n commitTask();\n globalCommitTaskMap.delete(commitTaskId);\n }\n });\n\n applyQueuedRefs();\n originalPreactCommit?.(vnode, commitQueue);\n },\n );\n}\n\n/**\n * Restores the commit option replaced by {@link replaceCommitHook} so tests\n * can clean up the global Preact `options` object. Assumes the matching\n * install was the most recent commit-option replacement; the snapshot and\n * ElementTemplate runtimes are separate entrypoints and never install their\n * commit hooks in the same context.\n */\nfunction removeCommitHookForTesting(): void {\n if (!commitHookInstalled) {\n return;\n }\n commitHookInstalled = false;\n commitTransport = nativeTransport;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n\n/**\n * Prepares the patch update for transmission to the native layer\n */\nfunction commitPatchUpdate(patchList: PatchList, patchOptions: GlobalPatchOptions): {\n data: string;\n patchOptions: PatchOptions;\n} {\n // console.debug('********** JS update:');\n // printSnapshotInstance(\n // (backgroundSnapshotInstanceManager.values.get(1) ?? backgroundSnapshotInstanceManager.values.get(-1))!,\n // );\n // console.debug('commitPatchUpdate:', prettyFormatSnapshotPatch(patchList.patchList[0]?.snapshotPatch));\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n const obj: {\n data: string;\n patchOptions: PatchOptions;\n } = {\n data: JSON.stringify(patchList),\n patchOptions: {\n ...patchOptions,\n reloadVersion: getReloadVersion(),\n },\n };\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n obj.patchOptions.pipelineOptions = globalPipelineOptions;\n setPipeline(undefined);\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n\n return obj;\n}\n\n/**\n * Generates a unique ID for commit tasks\n */\nfunction genCommitTaskId(): number {\n return nextCommitTaskId++;\n}\n\n/**\n * Resets the commit task ID counter\n */\nfunction clearCommitTaskId(): void {\n nextCommitTaskId = 1;\n}\n\n/**\n * @internal\n */\nexport {\n clearCommitTaskId,\n commitPatchUpdate,\n genCommitTaskId,\n globalBackgroundSnapshotInstancesToRemove,\n globalCommitTaskMap,\n removeCommitHookForTesting,\n replaceCommitHook,\n type CommitTransport,\n type PatchList,\n type PatchOptions,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMainThread.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/updateMainThread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAG/G,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,SAAS,gBAAgB,CACvB,EAAE,IAAI,EAAE,YAAY,EAGnB;IAED,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC;QACtD,OAAO;IACT,CAAC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C;AAED,SAAS,sBAAsB;IAC7B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport { runRunOnMainThreadTask, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport type { PatchList, PatchOptions } from './commit.js';\nimport { setMainThreadHydrating } from './isMainThreadHydrating.js';\nimport { snapshotPatchApply } from './snapshotPatchApply.js';\nimport { markTiming, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport { prettyFormatSnapshotPatch } from '../../debug/formatPatch.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { __pendingListUpdates } from '../../list/pendingListUpdates.js';\nimport { __page } from '../../snapshot/definition.js';\nimport { applyRefQueue } from '../../snapshot/workletRef.js';\nimport { isMtsEnabled } from '../../worklet/functionality.js';\n\nfunction updateMainThread(\n { data, patchOptions }: {\n data: string;\n patchOptions: PatchOptions;\n },\n): void {\n if ((patchOptions.reloadVersion) < getReloadVersion()) {\n return;\n }\n\n const flowIds = patchOptions.flowIds;\n if (flowIds) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n\n setPipeline(patchOptions.pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n const parsedData = JSON.parse(data) as PatchList;\n const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BTS -> MTS updateMainThread:\\n' + JSON.stringify(\n {\n data: {\n ...parsedData,\n patchList: parsedData.patchList.map(patch => ({\n ...patch,\n snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),\n })),\n },\n patchOptions,\n },\n null,\n 2,\n ),\n );\n }\n\n markTiming('parseChangesEnd');\n markTiming('patchChangesStart');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(true);\n }\n try {\n for (const { snapshotPatch, id } of patchList) {\n __pendingListUpdates.clearAttachedLists();\n if (snapshotPatch) {\n snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);\n }\n __pendingListUpdates.flush();\n // console.debug('********** Lepus updatePatch:');\n // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);\n }\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(false);\n }\n }\n applyRefQueue();\n if (delayedRunOnMainThreadData && isMtsEnabled()) {\n setEomShouldFlushElementTree(false);\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n /* v8 ignore next 3 */\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n setEomShouldFlushElementTree(true);\n }\n if (patchOptions.pipelineOptions) {\n flushOptions.pipelineOptions = patchOptions.pipelineOptions;\n }\n __FlushElementTree(__page, flushOptions);\n\n if (flowIds) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n}\n\nfunction injectUpdateMainThread(): void {\n Object.assign(globalThis, { [LifecycleConstant.patchUpdate]: updateMainThread });\n}\n\n/**\n * @internal\n */\nexport { injectUpdateMainThread };\n"]}
|
|
1
|
+
{"version":3,"file":"updateMainThread.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/patch/updateMainThread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,yCAA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KAAK,CAAC,CAAC;YACpC,KAAK,MAAM,IAAI,IAAI,0BAA0B,EAAE,CAAC;gBAC9C,IAAI,CAAC;oBACH,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;oBACxF,sBAAsB;gBACxB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,IAAI,CAAC,WAAW,CAAC,CAAU,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;YACD,4BAA4B,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,YAAY,CAAC,eAAe,EAAE,CAAC;YACjC,YAAY,CAAC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;QAC9D,CAAC;QACD,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEzC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,WAAW,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACnF,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport { runRunOnMainThreadTask, setEomShouldFlushElementTree } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport type { PatchList, PatchOptions } from './commit.js';\nimport { setMainThreadHydrating } from './isMainThreadHydrating.js';\nimport { snapshotPatchApply } from './snapshotPatchApply.js';\nimport { markTiming, setPipeline } from '../../../core/performance.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport { prettyFormatSnapshotPatch } from '../../debug/formatPatch.js';\nimport { LifecycleConstant } from '../../lifecycle/constant.js';\nimport { __pendingListUpdates } from '../../list/pendingListUpdates.js';\nimport { __page } from '../../snapshot/definition.js';\nimport { applyRefQueue } from '../../snapshot/workletRef.js';\nimport { isMtsEnabled } from '../../worklet/functionality.js';\n\nfunction updateMainThread(\n { data, patchOptions }: {\n data: string;\n patchOptions: PatchOptions;\n },\n): void {\n if ((patchOptions.reloadVersion) < getReloadVersion()) {\n return;\n }\n\n const flowIds = patchOptions.flowIds;\n if (flowIds) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n\n setPipeline(patchOptions.pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n const parsedData = JSON.parse(data) as PatchList;\n const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;\n\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BTS -> MTS updateMainThread:\\n' + JSON.stringify(\n {\n data: {\n ...parsedData,\n patchList: parsedData.patchList.map(patch => ({\n ...patch,\n snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),\n })),\n },\n patchOptions,\n },\n null,\n 2,\n ),\n );\n }\n\n markTiming('parseChangesEnd');\n markTiming('patchChangesStart');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(true);\n }\n try {\n for (const { snapshotPatch, id } of patchList) {\n __pendingListUpdates.clearAttachedLists();\n if (snapshotPatch) {\n snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);\n }\n __pendingListUpdates.flush();\n // console.debug('********** Lepus updatePatch:');\n // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);\n }\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n if (patchOptions.isHydration) {\n setMainThreadHydrating(false);\n }\n }\n applyRefQueue();\n if (delayedRunOnMainThreadData && isMtsEnabled()) {\n setEomShouldFlushElementTree(false);\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n /* v8 ignore next 3 */\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n setEomShouldFlushElementTree(true);\n }\n if (patchOptions.pipelineOptions) {\n flushOptions.pipelineOptions = patchOptions.pipelineOptions;\n }\n __FlushElementTree(__page, flushOptions);\n\n if (flowIds) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n}\n\nfunction injectUpdateMainThread(): void {\n Object.assign(globalThis, { [LifecycleConstant.patchUpdate]: updateMainThread });\n}\n\n/**\n * @internal\n */\nexport { injectUpdateMainThread, updateMainThread };\n"]}
|
|
@@ -25,7 +25,7 @@ declare function runDelayedUiOps(): void;
|
|
|
25
25
|
*/
|
|
26
26
|
declare class RefProxy extends SelectorRefProxy<RefProxy> {
|
|
27
27
|
private readonly refAttr;
|
|
28
|
-
constructor(refAttr: [snapshotInstanceId: number, expIndex: number]);
|
|
28
|
+
constructor(refAttr: [snapshotInstanceId: number, expIndex: number], snapshotType?: string);
|
|
29
29
|
protected createProxyTarget(): RefProxy;
|
|
30
30
|
protected runOrDelay(task: () => void): void;
|
|
31
31
|
get selector(): string;
|
|
@@ -45,10 +45,10 @@ function runDelayedUiOps() {
|
|
|
45
45
|
*/
|
|
46
46
|
class RefProxy extends SelectorRefProxy {
|
|
47
47
|
refAttr;
|
|
48
|
-
constructor(refAttr) {
|
|
48
|
+
constructor(refAttr, snapshotType) {
|
|
49
49
|
super();
|
|
50
50
|
this.refAttr = refAttr;
|
|
51
|
-
return this.createProxy();
|
|
51
|
+
return this.createProxy(snapshotType);
|
|
52
52
|
}
|
|
53
53
|
createProxyTarget() {
|
|
54
54
|
return new RefProxy(this.refAttr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/ref/delay.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAEzC;;;GAGG;AACH,MAAM,YAAY,GAAmB,EAAE,CAAC;AAExC;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAgB;IAClC,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IACnC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACxB,gBAAgB,CAAC,KAAK,GAAG,KAAK,CAAC;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,EAAE,CAAC;IACT,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,QAAS,SAAQ,gBAA0B;IAC9B,OAAO,CAAiD;IAEzE,
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/ref/delay.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAEzC;;;GAGG;AACH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sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { SelectorRefProxy } from '../../../core/ref.js';\nimport type { RefProxyForwardedMethods } from '../../../core/ref.js';\nimport { hydrationMap } from '../../snapshot/snapshotInstanceHydrationMap.js';\n\n/**\n * A flag to indicate whether UI operations should be delayed.\n * When set to true, UI operations will be queued in the `delayedUiOps` array\n * and executed later when `runDelayedUiOps` is called.\n * This is used before hydration to ensure UI operations are batched\n * and executed at the appropriate time.\n */\nconst shouldDelayUiOps = { value: true };\n\n/**\n * An array of functions that will be executed later when `runDelayedUiOps` is called.\n * These functions contain UI operations that need to be delayed.\n */\nconst delayedUiOps: (() => void)[] = [];\n\n/**\n * Runs a task either immediately or delays it based on the `shouldDelayUiOps` flag.\n * @param task - The function to execute.\n */\nfunction runOrDelay(task: () => void): void {\n if (shouldDelayUiOps.value) {\n delayedUiOps.push(task);\n } else {\n task();\n }\n}\n\n/**\n * Executes all delayed UI operations.\n */\nfunction runDelayedUiOps(): void {\n const tasks = delayedUiOps.slice();\n delayedUiOps.length = 0;\n shouldDelayUiOps.value = false;\n\n for (const task of tasks) {\n task();\n }\n}\n\n/**\n * A proxy class designed for managing and executing reference-based tasks.\n * It delays the execution of tasks until hydration is complete.\n */\nclass RefProxy extends SelectorRefProxy<RefProxy> {\n private readonly refAttr: [snapshotInstanceId: number, expIndex: number];\n\n constructor(\n refAttr: [snapshotInstanceId: number, expIndex: number],\n snapshotType?: string,\n ) {\n super();\n this.refAttr = refAttr;\n\n return this.createProxy(snapshotType);\n }\n\n protected createProxyTarget(): RefProxy {\n return new RefProxy(this.refAttr);\n }\n\n protected runOrDelay(task: () => void): void {\n runOrDelay(task);\n }\n\n get selector(): string {\n const realRefId = hydrationMap.get(this.refAttr[0]) ?? this.refAttr[0];\n return `[react-ref-${realRefId}-${this.refAttr[1]}]`;\n }\n}\n\ninterface RefProxy extends RefProxyForwardedMethods<RefProxy> {}\n\n/**\n * @internal\n */\nexport { delayedUiOps, RefProxy, runDelayedUiOps, shouldDelayUiOps };\n"]}
|
|
@@ -14,7 +14,7 @@ import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
|
14
14
|
import { resetFunctionCallReturnListener } from '../../core/thread-function-call/return-value.js';
|
|
15
15
|
import { __root, setRoot } from '../../root.js';
|
|
16
16
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
17
|
-
import { isEmptyObject } from '../../utils.js';
|
|
17
|
+
import { isEmptyObject } from '../../shared/utils.js';
|
|
18
18
|
import { LifecycleConstant } from '../lifecycle/constant.js';
|
|
19
19
|
import { __pendingListUpdates } from '../list/pendingListUpdates.js';
|
|
20
20
|
import { hydrate } from '../renderToOpcodes/hydrate.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../../src/snapshot/lifecycle/reload.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,oCAAoC,EAAE,MAAM,yCAAyC,CAAC;AAE/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAA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AK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,UAAU,EAAE,CAAC;IACf,CAAC;AACH,CAAC;AAED,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Implements the reload (thinking of \"refresh\" in browser) for both main thread\n * and background thread.\n */\n\nimport { render } from 'preact';\n\nimport { clearDelayedRunOnBackgroundFunctions } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { destroyBackground } from './destroy.js';\nimport { renderMainThread } from './render.js';\nimport {\n canReEvalBackgroundEntry,\n canReEvalMainThreadEntry,\n installMainThreadReloadCompleter,\n reEvalBackgroundEntry,\n reEvalMainThreadEntry,\n} from '../../core/entry-reload.js';\nimport { increaseReloadVersion } from '../../core/reload-version.js';\nimport { resetFunctionCallReturnListener } from '../../core/thread-function-call/return-value.js';\nimport { __root, setRoot } from '../../root.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { isEmptyObject } from '../../shared/utils.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport { __pendingListUpdates } from '../list/pendingListUpdates.js';\nimport { hydrate } from '../renderToOpcodes/hydrate.js';\nimport { __page, setupPage } from '../snapshot/definition.js';\nimport { SnapshotInstance, snapshotInstanceManager } from '../snapshot/snapshot.js';\nimport { applyRefQueue } from '../snapshot/workletRef.js';\nimport { clearFirstScreenEventIdSwap, firstScreenSync } from './event/firstScreenSync.js';\nimport { shouldDelayUiOps } from './ref/delay.js';\n\nfunction reloadMainThread(data: unknown, options: UpdatePageOption): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadMainThread');\n }\n\n clearDelayedRunOnBackgroundFunctions();\n resetFunctionCallReturnListener();\n increaseReloadVersion();\n\n if (typeof data == 'object' && data !== null && !isEmptyObject(data)) {\n Object.assign(lynx.__initData, data);\n }\n\n snapshotInstanceManager.clear();\n __pendingListUpdates.clearAttachedLists();\n clearFirstScreenEventIdSwap();\n\n const oldRoot = __root;\n if (canReEvalMainThreadEntry()) {\n reEvalMainThreadEntry<MainThreadReloadHandoff>({ oldRoot: oldRoot as SnapshotInstance, page: __page, options });\n return;\n }\n setRoot(new SnapshotInstance('root'));\n __root.__jsx = oldRoot.__jsx;\n finishMainThreadReload(oldRoot as SnapshotInstance, options);\n}\n\ninterface MainThreadReloadHandoff {\n oldRoot: SnapshotInstance;\n page: FiberElement;\n options: UpdatePageOption;\n}\n\nfunction completeMainThreadReload({ oldRoot, page, options }: MainThreadReloadHandoff): void {\n setupPage(page);\n finishMainThreadReload(oldRoot, options);\n}\n\ninstallMainThreadReloadCompleter(completeMainThreadReload);\n\nfunction finishMainThreadReload(oldRoot: SnapshotInstance, options: UpdatePageOption): void {\n renderMainThread();\n hydrate(oldRoot, __root as SnapshotInstance, {\n skipUnRef: true,\n });\n\n // always call this before `__FlushElementTree`\n __pendingListUpdates.flush();\n applyRefQueue();\n\n if (typeof lepusng_gc === 'function') {\n lepusng_gc();\n }\n\n if (firstScreenSync.isSynced) {\n __OnLifecycleEvent([\n LifecycleConstant.firstScreen, /* FIRST_SCREEN */\n {\n root: JSON.stringify(__root),\n },\n ]);\n }\n\n __FlushElementTree(__page, options);\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nfunction reloadBackground(updateData: Record<string, any>, options?: Record<string, unknown>): void {\n if (canReEvalBackgroundEntry()) {\n reEvalBackgroundEntry(updateData, options, () => {\n // A queued `updateGlobalProps` callback must not render it again.\n __root.__jsx = undefined;\n });\n return;\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadBackground');\n }\n\n destroyBackground();\n increaseReloadVersion();\n\n // COW when modify `lynx.__initData` to make sure Provider & Consumer works\n lynx.__initData = Object.assign({}, lynx.__initData, updateData);\n\n shouldDelayUiOps.value = true;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n render(__root.__jsx, __root as any);\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nexport { completeMainThreadReload, reloadBackground, reloadMainThread };\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { cardLifetime } from '../../core/card-lifetime.js';
|
|
5
|
-
import { maybePromise } from '../../utils.js';
|
|
5
|
+
import { maybePromise } from '../../shared/utils.js';
|
|
6
6
|
import { LifecycleConstant } from '../lifecycle/constant.js';
|
|
7
7
|
import { applyRefQueue } from '../snapshot/workletRef.js';
|
|
8
8
|
export const gSignMap = /*#__PURE__*/ cardLifetime('listSignMap', () => ({}));
|
|
@@ -44,7 +44,7 @@ export function componentAtIndexFactory(ctx, hydrateFunction) {
|
|
|
44
44
|
// Kept as a safeguard in case the callback is somehow invoked after list removal.
|
|
45
45
|
throw new Error('componentAtIndex called on removed list');
|
|
46
46
|
}
|
|
47
|
-
/* v8 ignore
|
|
47
|
+
/* v8 ignore stop */
|
|
48
48
|
const platformInfo = childCtx.__listItemPlatformInfo ?? {};
|
|
49
49
|
// The lifecycle of this `__extraProps.isReady`:
|
|
50
50
|
// 0 -> Promise<number> -> 1
|
|
@@ -119,7 +119,16 @@ export function componentAtIndexFactory(ctx, hydrateFunction) {
|
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
const newCtx = childCtx.takeElements();
|
|
122
|
-
|
|
122
|
+
for (const id in gSignMap) {
|
|
123
|
+
if (gSignMap[id].get(sign) === childCtx) {
|
|
124
|
+
gSignMap[id].set(sign, newCtx);
|
|
125
|
+
}
|
|
126
|
+
gRecycleMap[id]?.forEach((pool) => {
|
|
127
|
+
if (pool.get(sign) === childCtx) {
|
|
128
|
+
pool.set(sign, newCtx);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
if (recycleSignMap && recycleSignMap.size > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/snapshot/list/list.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,QAAQ,GAAkD,aAAa,CAAC,YAAY,CAC/F,aAAa,EACb,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CACX,CAAC;AACF,MAAM,CAAC,MAAM,WAAW,GAA+D,aAAa,CAAC,YAAY,CAC/G,gBAAgB,EAChB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CACX,CAAC;AACF,MAAM,cAAc,GAAuC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;AACvF,MAAM,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AAE1D,MAAM,UAAU,eAAe;IAC7B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,GAAuB,EACvB,eAA4E;IAE5E,2FAA2F;IAC3F,wBAAwB;IACxB,qEAAqE;IACrE,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;Q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AAE,CAAC,CAAC;QACpC,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC;IACF,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { cardLifetime } from '../../core/card-lifetime.js';\nimport { maybePromise } from '../../utils.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport type { SnapshotInstance } from '../snapshot/snapshot.js';\nimport { applyRefQueue } from '../snapshot/workletRef.js';\n\nexport const gSignMap: Record<number, Map<number, SnapshotInstance>> = /*#__PURE__*/ cardLifetime(\n 'listSignMap',\n () => ({}),\n);\nexport const gRecycleMap: Record<number, Map<string, Map<number, SnapshotInstance>>> = /*#__PURE__*/ cardLifetime(\n 'listRecycleMap',\n () => ({}),\n);\nconst gParentWeakMap: WeakMap<SnapshotInstance, unknown> = /*#__PURE__*/ new WeakMap();\nconst resolvedPromise = /* @__PURE__ */ Promise.resolve();\n\nexport function clearListGlobal(): void {\n for (const key in gSignMap) {\n delete gSignMap[key];\n }\n for (const key in gRecycleMap) {\n delete gRecycleMap[key];\n }\n}\n\nexport function componentAtIndexFactory(\n ctx: SnapshotInstance[],\n hydrateFunction: (before: SnapshotInstance, after: SnapshotInstance) => void,\n): [ComponentAtIndexCallback, ComponentAtIndexesCallback] {\n // A hack workaround to ensure childCtx has no direct reference through `__parent` to list,\n // to avoid memory leak.\n // TODO(hzy): make `__parent` a WeakRef or `#__parent` in the future.\n ctx.forEach((childCtx) => {\n if (gParentWeakMap.has(childCtx)) {\n // do it only once\n } else {\n gParentWeakMap.set(childCtx, childCtx.parentNode!);\n Object.defineProperty(childCtx, '__parent', {\n get: () => gParentWeakMap.get(childCtx)!,\n set: (value: unknown) => {\n gParentWeakMap.set(childCtx, value);\n },\n });\n }\n });\n\n const componentAtChildCtx = (\n list: FiberElement,\n listID: number,\n childCtx: SnapshotInstance,\n operationID: number,\n enableReuseNotification: boolean,\n enableBatchRender: boolean = false,\n asyncFlush: boolean = false,\n ) => {\n const signMap = gSignMap[listID];\n const recycleMap = gRecycleMap[listID];\n\n /* v8 ignore start */\n if (!signMap || !recycleMap) {\n // Theoretically unreachable since snapshotDestroyList clears componentAtIndex with a noop function.\n // Kept as a safeguard in case the callback is somehow invoked after list removal.\n throw new Error('componentAtIndex called on removed list');\n }\n /* v8 ignore end */\n\n const platformInfo = childCtx.__listItemPlatformInfo ?? {};\n\n // The lifecycle of this `__extraProps.isReady`:\n // 0 -> Promise<number> -> 1\n // 0: The initial state, the list-item is not ready yet, we will send a event to background\n // when `componentAtIndex` is called on it\n // Promise<number>: A promise that will be resolved when the list-item is ready\n // 1: The list-item is ready, we can use it to render the list\n if (childCtx.__extraProps?.['isReady'] === 0) {\n if (\n typeof __GetAttributeByName === 'function'\n && __GetAttributeByName(list, 'custom-list-name') === 'list-container'\n ) {\n // we are in supported env\n // do not throw\n } else {\n throw new Error(\n 'Unsupported: `<list-item/>` with `defer={true}` must be used with `<list custom-list-name=\"list-container\"/>`',\n );\n }\n\n // send a event to background to render the list-item\n __OnLifecycleEvent([LifecycleConstant.publishEvent, {\n handlerName: `${childCtx.__id}:__extraProps:onComponentAtIndex`,\n data: {},\n }]);\n\n // use a promise to track the list-item's readiness\n let p: Promise<number>;\n return (p = new Promise<number>((resolve) => {\n Object.defineProperty(childCtx.__extraProps, 'isReady', {\n set(isReady) {\n if (isReady === 1) {\n delete childCtx.__extraProps!['isReady'];\n childCtx.__extraProps!['isReady'] = 1;\n\n void resolvedPromise.then(() => {\n // the cellIndex may be changed already, but the `childCtx` is the same\n resolve(componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification));\n });\n }\n },\n get() {\n return p;\n },\n });\n }));\n } else if (maybePromise<number>(childCtx.__extraProps?.['isReady'])) {\n throw new Error('componentAtIndex was called on a pending deferred list item');\n }\n\n const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');\n const recycleSignMap = recycleMap.get(uniqID);\n\n if (childCtx.__elements) {\n /**\n * If this situation is encountered, there might be two cases:\n * 1. Reusing with itself\n * In this case, enqueueComponent will be triggered first, followed by componentAtIndex.\n * 2. Moving\n * In this case, the trigger order is uncertain; componentAtIndex might be triggered first, or enqueueComponent might be triggered first.\n *\n * When enqueueComponent is triggered first, there must be an item in the reuse pool with the same sign as here, which can be returned directly.\n * When componentAtIndex is triggered first, a clone needs to be made first, then follow the logic for adding or reusing. The cloned item will enter the reuse pool in the subsequent enqueueComponent.\n */\n const root = childCtx.__elements[0]!;\n const sign = __GetElementUniqueID(root);\n\n if (recycleSignMap?.has(sign)) {\n signMap.set(sign, childCtx);\n recycleSignMap.delete(sign);\n if (!enableBatchRender) {\n __FlushElementTree(root, { triggerLayout: true, operationID, elementID: sign, listID });\n } else if (enableBatchRender && asyncFlush) {\n __FlushElementTree(root, { asyncFlush: true });\n }\n // enableBatchRender == true && asyncFlush == false\n // in this case, no need to invoke __FlushElementTree because in the end of componentAtIndexes(), the list will invoke __FlushElementTree.\n return sign;\n } else {\n const newCtx = childCtx.takeElements();\n signMap.set(sign, newCtx);\n }\n }\n\n if (recycleSignMap && recycleSignMap.size > 0) {\n const [first] = recycleSignMap;\n const [sign, oldCtx] = first!;\n recycleSignMap.delete(sign);\n hydrateFunction(oldCtx, childCtx);\n oldCtx.unRenderElements();\n if (!oldCtx.__id) {\n oldCtx.tearDown();\n } else if (oldCtx.__extraProps?.['isReady'] === 1) {\n // send a event to background to recycle the list-item\n __OnLifecycleEvent([LifecycleConstant.publishEvent, {\n handlerName: `${oldCtx.__id}:__extraProps:onRecycleComponent`,\n data: {},\n }]);\n }\n const root = childCtx.__element_root!;\n applyRefQueue();\n // In the defer `list-item` scenario, `componentAtIndex` occurs with delay.\n // Within `componentAtIndex`, nodes that quickly appear and disappear due to re-layout will be enqueued again,\n // causing the mapping relationship between sign and SnapshotInstance to become corrupted.\n // This results in a SnapshotInstance without `__elements` being enqueued.\n signMap.set(sign, childCtx);\n if (!enableBatchRender) {\n const flushOptions: FlushOptions = {\n triggerLayout: true,\n operationID,\n elementID: sign,\n listID,\n };\n if (enableReuseNotification) {\n flushOptions.listReuseNotification = {\n listElement: list,\n itemKey: platformInfo['item-key']!,\n };\n }\n __FlushElementTree(root, flushOptions);\n } else if (enableBatchRender && asyncFlush) {\n const flushOptions: FlushOptions = {\n asyncFlush: true,\n };\n if (enableReuseNotification) {\n flushOptions.listReuseNotification = {\n listElement: list,\n itemKey: platformInfo['item-key']!,\n };\n }\n __FlushElementTree(root, flushOptions);\n }\n return sign;\n }\n\n childCtx.ensureElements();\n const root = childCtx.__element_root!;\n __AppendElement(list, root);\n const sign = __GetElementUniqueID(root);\n applyRefQueue();\n signMap.set(sign, childCtx);\n if (!enableBatchRender) {\n __FlushElementTree(root, {\n triggerLayout: true,\n operationID,\n elementID: sign,\n listID,\n });\n } else if (enableBatchRender && asyncFlush) {\n __FlushElementTree(root, {\n asyncFlush: true,\n });\n }\n return sign;\n };\n\n function componentAtIndex(\n list: FiberElement,\n listID: number,\n cellIndex: number,\n operationID: number,\n enableReuseNotification: boolean,\n ) {\n const childCtx = ctx[cellIndex];\n if (!childCtx) {\n throw new Error('childCtx not found');\n }\n const r = componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification);\n\n /* v8 ignore start */\n if (process.env['NODE_ENV'] === 'test') {\n return r;\n } else {\n return typeof r === 'number' ? r : undefined;\n }\n /* v8 ignore end */\n }\n\n function componentAtIndexes(\n list: FiberElement,\n listID: number,\n cellIndexes: number[],\n operationIDs: number[],\n enableReuseNotification: boolean,\n asyncFlush: boolean,\n ) {\n let hasUnready = false;\n const p: Array<Promise<number> | number> = [];\n\n cellIndexes.forEach((cellIndex, index) => {\n const operationID = operationIDs[index]!;\n const childCtx = ctx[cellIndex];\n if (!childCtx) {\n throw new Error('childCtx not found');\n }\n\n const u = componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification, true, asyncFlush);\n if (typeof u === 'number') {\n // ready\n } else {\n hasUnready = true;\n }\n p.push(u);\n });\n\n // We need __FlushElementTree twice:\n // 1. The first time is sync, we flush the items that are ready, with unready items' uiSign as -1.\n // 2. The second time is async, with all the uiSigns.\n // NOTE: The `operationIDs` passed to __FlushElementTree must be the one passed in,\n // not the one generated by any code here, to workaround a bug of Lynx Engine.\n // So we CANNOT split the `operationIDs` into two parts: one for ready items, one for unready items.\n if (hasUnready) {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n void Promise.all(p).then((uiSigns) => {\n __FlushElementTree(list, {\n triggerLayout: true,\n operationIDs,\n elementIDs: uiSigns,\n listID,\n });\n });\n }\n __FlushElementTree(list, {\n triggerLayout: true,\n operationIDs,\n elementIDs: cellIndexes.map((_, index) => typeof p[index] === 'number' ? p[index] : -1),\n listID,\n });\n }\n return [componentAtIndex, componentAtIndexes] as const;\n}\n\nexport function enqueueComponentFactory(): EnqueueComponentCallback {\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const enqueueComponent = (_: FiberElement, listID: number, sign: number) => {\n const signMap = gSignMap[listID];\n const recycleMap = gRecycleMap[listID];\n if (!signMap || !recycleMap) {\n throw new Error('enqueueComponent called on removed list');\n }\n\n const childCtx = signMap.get(sign)!;\n if (!childCtx) {\n return;\n }\n\n const platformInfo = childCtx.__listItemPlatformInfo ?? {};\n\n const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');\n if (!recycleMap.has(uniqID)) {\n recycleMap.set(uniqID, new Map());\n }\n recycleMap.get(uniqID)!.set(sign, childCtx);\n };\n return enqueueComponent;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/snapshot/list/list.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAA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E,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC;IACF,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { cardLifetime } from '../../core/card-lifetime.js';\nimport { maybePromise } from '../../shared/utils.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport type { SnapshotInstance } from '../snapshot/snapshot.js';\nimport { applyRefQueue } from '../snapshot/workletRef.js';\n\nexport const gSignMap: Record<number, Map<number, SnapshotInstance>> = /*#__PURE__*/ cardLifetime(\n 'listSignMap',\n () => ({}),\n);\nexport const gRecycleMap: Record<number, Map<string, Map<number, SnapshotInstance>>> = /*#__PURE__*/ cardLifetime(\n 'listRecycleMap',\n () => ({}),\n);\nconst gParentWeakMap: WeakMap<SnapshotInstance, unknown> = /*#__PURE__*/ new WeakMap();\nconst resolvedPromise = /* @__PURE__ */ Promise.resolve();\n\nexport function clearListGlobal(): void {\n for (const key in gSignMap) {\n delete gSignMap[key];\n }\n for (const key in gRecycleMap) {\n delete gRecycleMap[key];\n }\n}\n\nexport function componentAtIndexFactory(\n ctx: SnapshotInstance[],\n hydrateFunction: (before: SnapshotInstance, after: SnapshotInstance) => void,\n): [ComponentAtIndexCallback, ComponentAtIndexesCallback] {\n // A hack workaround to ensure childCtx has no direct reference through `__parent` to list,\n // to avoid memory leak.\n // TODO(hzy): make `__parent` a WeakRef or `#__parent` in the future.\n ctx.forEach((childCtx) => {\n if (gParentWeakMap.has(childCtx)) {\n // do it only once\n } else {\n gParentWeakMap.set(childCtx, childCtx.parentNode!);\n Object.defineProperty(childCtx, '__parent', {\n get: () => gParentWeakMap.get(childCtx)!,\n set: (value: unknown) => {\n gParentWeakMap.set(childCtx, value);\n },\n });\n }\n });\n\n const componentAtChildCtx = (\n list: FiberElement,\n listID: number,\n childCtx: SnapshotInstance,\n operationID: number,\n enableReuseNotification: boolean,\n enableBatchRender: boolean = false,\n asyncFlush: boolean = false,\n ) => {\n const signMap = gSignMap[listID];\n const recycleMap = gRecycleMap[listID];\n\n /* v8 ignore start */\n if (!signMap || !recycleMap) {\n // Theoretically unreachable since snapshotDestroyList clears componentAtIndex with a noop function.\n // Kept as a safeguard in case the callback is somehow invoked after list removal.\n throw new Error('componentAtIndex called on removed list');\n }\n /* v8 ignore stop */\n\n const platformInfo = childCtx.__listItemPlatformInfo ?? {};\n\n // The lifecycle of this `__extraProps.isReady`:\n // 0 -> Promise<number> -> 1\n // 0: The initial state, the list-item is not ready yet, we will send a event to background\n // when `componentAtIndex` is called on it\n // Promise<number>: A promise that will be resolved when the list-item is ready\n // 1: The list-item is ready, we can use it to render the list\n if (childCtx.__extraProps?.['isReady'] === 0) {\n if (\n typeof __GetAttributeByName === 'function'\n && __GetAttributeByName(list, 'custom-list-name') === 'list-container'\n ) {\n // we are in supported env\n // do not throw\n } else {\n throw new Error(\n 'Unsupported: `<list-item/>` with `defer={true}` must be used with `<list custom-list-name=\"list-container\"/>`',\n );\n }\n\n // send a event to background to render the list-item\n __OnLifecycleEvent([LifecycleConstant.publishEvent, {\n handlerName: `${childCtx.__id}:__extraProps:onComponentAtIndex`,\n data: {},\n }]);\n\n // use a promise to track the list-item's readiness\n let p: Promise<number>;\n return (p = new Promise<number>((resolve) => {\n Object.defineProperty(childCtx.__extraProps, 'isReady', {\n set(isReady) {\n if (isReady === 1) {\n delete childCtx.__extraProps!['isReady'];\n childCtx.__extraProps!['isReady'] = 1;\n\n void resolvedPromise.then(() => {\n // the cellIndex may be changed already, but the `childCtx` is the same\n resolve(componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification));\n });\n }\n },\n get() {\n return p;\n },\n });\n }));\n } else if (maybePromise<number>(childCtx.__extraProps?.['isReady'])) {\n throw new Error('componentAtIndex was called on a pending deferred list item');\n }\n\n const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');\n const recycleSignMap = recycleMap.get(uniqID);\n\n if (childCtx.__elements) {\n /**\n * If this situation is encountered, there might be two cases:\n * 1. Reusing with itself\n * In this case, enqueueComponent will be triggered first, followed by componentAtIndex.\n * 2. Moving\n * In this case, the trigger order is uncertain; componentAtIndex might be triggered first, or enqueueComponent might be triggered first.\n *\n * When enqueueComponent is triggered first, there must be an item in the reuse pool with the same sign as here, which can be returned directly.\n * When componentAtIndex is triggered first, a clone needs to be made first, then follow the logic for adding or reusing. The cloned item will enter the reuse pool in the subsequent enqueueComponent.\n */\n const root = childCtx.__elements[0]!;\n const sign = __GetElementUniqueID(root);\n\n if (recycleSignMap?.has(sign)) {\n signMap.set(sign, childCtx);\n recycleSignMap.delete(sign);\n if (!enableBatchRender) {\n __FlushElementTree(root, { triggerLayout: true, operationID, elementID: sign, listID });\n } else if (enableBatchRender && asyncFlush) {\n __FlushElementTree(root, { asyncFlush: true });\n }\n // enableBatchRender == true && asyncFlush == false\n // in this case, no need to invoke __FlushElementTree because in the end of componentAtIndexes(), the list will invoke __FlushElementTree.\n return sign;\n } else {\n const newCtx = childCtx.takeElements();\n for (const id in gSignMap) {\n if (gSignMap[id]!.get(sign) === childCtx) {\n gSignMap[id]!.set(sign, newCtx);\n }\n gRecycleMap[id]?.forEach((pool) => {\n if (pool.get(sign) === childCtx) {\n pool.set(sign, newCtx);\n }\n });\n }\n }\n }\n\n if (recycleSignMap && recycleSignMap.size > 0) {\n const [first] = recycleSignMap;\n const [sign, oldCtx] = first!;\n recycleSignMap.delete(sign);\n hydrateFunction(oldCtx, childCtx);\n oldCtx.unRenderElements();\n if (!oldCtx.__id) {\n oldCtx.tearDown();\n } else if (oldCtx.__extraProps?.['isReady'] === 1) {\n // send a event to background to recycle the list-item\n __OnLifecycleEvent([LifecycleConstant.publishEvent, {\n handlerName: `${oldCtx.__id}:__extraProps:onRecycleComponent`,\n data: {},\n }]);\n }\n const root = childCtx.__element_root!;\n applyRefQueue();\n // In the defer `list-item` scenario, `componentAtIndex` occurs with delay.\n // Within `componentAtIndex`, nodes that quickly appear and disappear due to re-layout will be enqueued again,\n // causing the mapping relationship between sign and SnapshotInstance to become corrupted.\n // This results in a SnapshotInstance without `__elements` being enqueued.\n signMap.set(sign, childCtx);\n if (!enableBatchRender) {\n const flushOptions: FlushOptions = {\n triggerLayout: true,\n operationID,\n elementID: sign,\n listID,\n };\n if (enableReuseNotification) {\n flushOptions.listReuseNotification = {\n listElement: list,\n itemKey: platformInfo['item-key']!,\n };\n }\n __FlushElementTree(root, flushOptions);\n } else if (enableBatchRender && asyncFlush) {\n const flushOptions: FlushOptions = {\n asyncFlush: true,\n };\n if (enableReuseNotification) {\n flushOptions.listReuseNotification = {\n listElement: list,\n itemKey: platformInfo['item-key']!,\n };\n }\n __FlushElementTree(root, flushOptions);\n }\n return sign;\n }\n\n childCtx.ensureElements();\n const root = childCtx.__element_root!;\n __AppendElement(list, root);\n const sign = __GetElementUniqueID(root);\n applyRefQueue();\n signMap.set(sign, childCtx);\n if (!enableBatchRender) {\n __FlushElementTree(root, {\n triggerLayout: true,\n operationID,\n elementID: sign,\n listID,\n });\n } else if (enableBatchRender && asyncFlush) {\n __FlushElementTree(root, {\n asyncFlush: true,\n });\n }\n return sign;\n };\n\n function componentAtIndex(\n list: FiberElement,\n listID: number,\n cellIndex: number,\n operationID: number,\n enableReuseNotification: boolean,\n ) {\n const childCtx = ctx[cellIndex];\n if (!childCtx) {\n throw new Error('childCtx not found');\n }\n const r = componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification);\n\n /* v8 ignore start */\n if (process.env['NODE_ENV'] === 'test') {\n return r;\n } else {\n return typeof r === 'number' ? r : undefined;\n }\n /* v8 ignore end */\n }\n\n function componentAtIndexes(\n list: FiberElement,\n listID: number,\n cellIndexes: number[],\n operationIDs: number[],\n enableReuseNotification: boolean,\n asyncFlush: boolean,\n ) {\n let hasUnready = false;\n const p: Array<Promise<number> | number> = [];\n\n cellIndexes.forEach((cellIndex, index) => {\n const operationID = operationIDs[index]!;\n const childCtx = ctx[cellIndex];\n if (!childCtx) {\n throw new Error('childCtx not found');\n }\n\n const u = componentAtChildCtx(list, listID, childCtx, operationID, enableReuseNotification, true, asyncFlush);\n if (typeof u === 'number') {\n // ready\n } else {\n hasUnready = true;\n }\n p.push(u);\n });\n\n // We need __FlushElementTree twice:\n // 1. The first time is sync, we flush the items that are ready, with unready items' uiSign as -1.\n // 2. The second time is async, with all the uiSigns.\n // NOTE: The `operationIDs` passed to __FlushElementTree must be the one passed in,\n // not the one generated by any code here, to workaround a bug of Lynx Engine.\n // So we CANNOT split the `operationIDs` into two parts: one for ready items, one for unready items.\n if (hasUnready) {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n void Promise.all(p).then((uiSigns) => {\n __FlushElementTree(list, {\n triggerLayout: true,\n operationIDs,\n elementIDs: uiSigns,\n listID,\n });\n });\n }\n __FlushElementTree(list, {\n triggerLayout: true,\n operationIDs,\n elementIDs: cellIndexes.map((_, index) => typeof p[index] === 'number' ? p[index] : -1),\n listID,\n });\n }\n return [componentAtIndex, componentAtIndexes] as const;\n}\n\nexport function enqueueComponentFactory(): EnqueueComponentCallback {\n // eslint-disable-next-line unicorn/consistent-function-scoping\n const enqueueComponent = (_: FiberElement, listID: number, sign: number) => {\n const signMap = gSignMap[listID];\n const recycleMap = gRecycleMap[listID];\n if (!signMap || !recycleMap) {\n throw new Error('enqueueComponent called on removed list');\n }\n\n const childCtx = signMap.get(sign)!;\n if (!childCtx) {\n return;\n }\n\n const platformInfo = childCtx.__listItemPlatformInfo ?? {};\n\n const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');\n if (!recycleMap.has(uniqID)) {\n recycleMap.set(uniqID, new Map());\n }\n recycleMap.get(uniqID)!.set(sign, childCtx);\n };\n return enqueueComponent;\n}\n"]}
|
|
@@ -2,4 +2,6 @@ import { runWithForce } from './runWithForce.js';
|
|
|
2
2
|
export { runWithForce };
|
|
3
3
|
declare function injectTt(): void;
|
|
4
4
|
declare function flushDelayedLifecycleEvents(): void;
|
|
5
|
-
|
|
5
|
+
/** Dispatches native events to their background handlers instead of delaying them. */
|
|
6
|
+
declare function enablePublishEvent(): void;
|
|
7
|
+
export { enablePublishEvent, injectTt, flushDelayedLifecycleEvents };
|
|
@@ -119,8 +119,7 @@ function onLifecycleEventImpl(type, data) {
|
|
|
119
119
|
});
|
|
120
120
|
delayedEvents.length = 0;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
lynx.getApp().publicComponentEvent = publicComponentEvent;
|
|
122
|
+
enablePublishEvent();
|
|
124
123
|
// console.debug("********** After hydration:");
|
|
125
124
|
// printSnapshotInstance(__root as BackgroundSnapshotInstance);
|
|
126
125
|
const commitTaskId = genCommitTaskId();
|
|
@@ -214,6 +213,11 @@ function publishEvent(handlerName, data) {
|
|
|
214
213
|
function publicComponentEvent(_componentId, handlerName, data) {
|
|
215
214
|
publishEvent(handlerName, data);
|
|
216
215
|
}
|
|
216
|
+
/** Dispatches native events to their background handlers instead of delaying them. */
|
|
217
|
+
function enablePublishEvent() {
|
|
218
|
+
lynx.getApp().publishEvent = publishEvent;
|
|
219
|
+
lynx.getApp().publicComponentEvent = publicComponentEvent;
|
|
220
|
+
}
|
|
217
221
|
function delayedPublicComponentEvent(_componentId, handlerName, data) {
|
|
218
222
|
delayedPublishEvent(handlerName, data);
|
|
219
223
|
}
|
|
@@ -227,5 +231,5 @@ function updateGlobalProps(newData) {
|
|
|
227
231
|
},
|
|
228
232
|
});
|
|
229
233
|
}
|
|
230
|
-
export { injectTt, flushDelayedLifecycleEvents };
|
|
234
|
+
export { enablePublishEvent, injectTt, flushDelayedLifecycleEvents };
|
|
231
235
|
//# source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,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,iBAAiB,CAAC,OAA4B;IACrD,qBAAqB,CAAC,OAAO,EAAE;QAC7B,2EAA2E;QAC3E,+DAA+D;QAC/D,aAAa,EAAE,GAAG,EAAE;YAClB,iEAAiE;YACjE,YAAY,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAa,CAAC,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { process, render } from 'preact';\n\nimport { runWithForce } from './runWithForce.js';\nimport { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';\nimport { updateCardData } from '../../core/lynx-update-data.js';\nimport { PerformanceTimingFlags, PipelineOrigins, beginPipeline, markTiming } from '../../core/performance.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { __root } from '../../root.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { CHILDREN } from '../../shared/render-constants.js';\nimport { printSnapshotInstanceToString } from '../debug/printSnapshot.js';\nimport { getSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport type { FirstScreenData } from '../lifecycle/constant.js';\nimport { destroyBackground } from '../lifecycle/destroy.js';\nimport { delayedEvents, delayedPublishEvent } from '../lifecycle/event/delayEvents.js';\nimport { delayLifecycleEvent, delayedLifecycleEvents } from '../lifecycle/event/delayLifecycleEvents.js';\nimport { commitPatchUpdate, genCommitTaskId, globalCommitTaskMap } from '../lifecycle/patch/commit.js';\nimport type { PatchList } from '../lifecycle/patch/commit.js';\nimport { removeCtxNotFoundEventListener } from '../lifecycle/patch/error.js';\nimport { runDelayedUiOps } from '../lifecycle/ref/delay.js';\nimport { reloadBackground } from '../lifecycle/reload.js';\nimport {\n BackgroundSnapshotInstance,\n backgroundSnapshotInstanceManager,\n hydrate,\n} from '../snapshot/backgroundSnapshot.js';\nimport type { SerializedSnapshotInstance } from '../snapshot/types.js';\nimport { destroyWorklet } from '../worklet/destroy.js';\nimport { sendMTRefInitValueToMainThread } from '../worklet/ref/updateInitValue.js';\n\nexport { runWithForce };\n\nfunction injectTt(): void {\n const tt = lynx.getApp();\n tt.OnLifecycleEvent = onLifecycleEvent;\n tt.publishEvent = delayedPublishEvent;\n tt.publicComponentEvent = delayedPublicComponentEvent;\n tt.callDestroyLifetimeFun = () => {\n removeCtxNotFoundEventListener();\n destroyWorklet();\n destroyBackground();\n };\n tt.updateGlobalProps = updateGlobalProps;\n tt.updateCardData = updateCardData;\n tt.onAppReload = reloadBackground;\n tt.processCardConfig = () => {\n // used to updateTheme, no longer rely on this function\n };\n}\n\nfunction onLifecycleEvent([type, data]: [LifecycleConstant, unknown]) {\n const hasRootRendered = CHILDREN in __root;\n // never called `render(<App/>, __root)`\n // happens if user call `root.render()` async\n if (!hasRootRendered) {\n delayLifecycleEvent(type, data);\n return;\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart(`OnLifecycleEvent::${type}`);\n }\n\n try {\n onLifecycleEventImpl(type, data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nfunction onLifecycleEventImpl(type: LifecycleConstant, data: unknown): void {\n switch (type) {\n case LifecycleConstant.firstScreen: {\n let processErr;\n try {\n process();\n } catch (e) {\n processErr = e;\n }\n const { root: lepusSide, firstScreenEventIdSwap } = data as FirstScreenData;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::hydrate');\n }\n beginPipeline(true, PipelineOrigins.reactLynxHydrate, PerformanceTimingFlags.reactLynxHydrate);\n markTiming('hydrateParseSnapshotStart');\n const before = JSON.parse(lepusSide) as SerializedSnapshotInstance;\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] MTS -> BTS OnLifecycleEvent:\\n' + JSON.stringify(\n {\n ...data as object,\n // use parsed lepusSide to avoid extra escape characters ('\\\\')\n root: before,\n },\n null,\n 2,\n ),\n );\n console.alog?.(\n '[ReactLynxDebug] SnapshotInstance tree for first screen hydration:\\n'\n + printSnapshotInstanceToString(before),\n );\n console.alog?.(\n '[ReactLynxDebug] BackgroundSnapshotInstance tree before hydration:\\n'\n + printSnapshotInstanceToString(__root as BackgroundSnapshotInstance),\n );\n }\n markTiming('hydrateParseSnapshotEnd');\n markTiming('diffVdomStart');\n const snapshotPatch = hydrate(\n before,\n __root as BackgroundSnapshotInstance,\n );\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BackgroundSnapshotInstance after hydration:\\n'\n + printSnapshotInstanceToString(__root as BackgroundSnapshotInstance),\n );\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n markTiming('diffVdomEnd');\n\n // TODO: It seems `delayedEvents` and `delayedLifecycleEvents` should be merged into one array to ensure the proper order of events.\n flushDelayedLifecycleEvents();\n if (delayedEvents) {\n delayedEvents.forEach((args) => {\n const [handlerName, data] = args;\n // eslint-disable-next-line prefer-const\n let [idStr, ...rest] = handlerName.split(':');\n while (firstScreenEventIdSwap[idStr!]) idStr = firstScreenEventIdSwap[idStr!]?.toString();\n try {\n publishEvent([idStr, ...rest].join(':'), data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n });\n delayedEvents.length = 0;\n }\n\n lynx.getApp().publishEvent = publishEvent;\n lynx.getApp().publicComponentEvent = publicComponentEvent;\n\n // console.debug(\"********** After hydration:\");\n // printSnapshotInstance(__root as BackgroundSnapshotInstance);\n const commitTaskId = genCommitTaskId();\n const patchList: PatchList = {\n patchList: [{ snapshotPatch, id: commitTaskId }],\n };\n if (delayedRunOnMainThreadData.length) {\n patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData();\n }\n const obj = commitPatchUpdate(patchList, { isHydration: true });\n sendMTRefInitValueToMainThread();\n lynx.getNativeApp().callLepusMethod(LifecycleConstant.patchUpdate, obj, () => {\n globalCommitTaskMap.forEach((commitTask, id) => {\n if (id > commitTaskId) {\n return;\n }\n commitTask();\n globalCommitTaskMap.delete(id);\n });\n });\n runDelayedUiOps();\n\n if (processErr) {\n throw processErr;\n }\n break;\n }\n case LifecycleConstant.globalEventFromLepus: {\n const [eventName, params] = data as [string, Record<string, any>];\n lynx.getJSModule('GlobalEventEmitter').trigger(eventName, params);\n break;\n }\n case LifecycleConstant.publishEvent: {\n const { handlerName, data: d } = data as { handlerName: string; data: EventDataType };\n lynx.getApp().publishEvent(handlerName, d);\n break;\n }\n }\n}\n\nlet flushingDelayedLifecycleEvents = false;\nfunction flushDelayedLifecycleEvents(): void {\n // avoid stackoverflow\n if (flushingDelayedLifecycleEvents) return;\n flushingDelayedLifecycleEvents = true;\n if (delayedLifecycleEvents) {\n delayedLifecycleEvents.forEach((e) => {\n onLifecycleEvent(e);\n });\n delayedLifecycleEvents.length = 0;\n }\n flushingDelayedLifecycleEvents = false;\n}\n\nfunction publishEvent(handlerName: string, data: EventDataType) {\n lynx.getApp().callBeforePublishEvent?.(data);\n let snapshotId: number | undefined;\n const getSnapshotId = () => snapshotId ??= Number(handlerName.split(':')[0]);\n const eventHandler = backgroundSnapshotInstanceManager.getValueBySign(\n handlerName,\n ) as ((data: unknown) => void) | undefined;\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n const currentSnapshotId = getSnapshotId();\n profileStart(`ReactLynx::publishEvent`, {\n args: {\n handlerName,\n type: data.type,\n snapshotType: backgroundSnapshotInstanceManager.values.get(\n currentSnapshotId,\n )?.type ?? '',\n source: getSnapshotVNodeSource(currentSnapshotId) ?? '',\n jsFunctionName: eventHandler?.name ?? '',\n },\n });\n }\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n const currentSnapshotId = getSnapshotId();\n console.alog?.(\n `[ReactLynxDebug] BTS received event:\\n` + JSON.stringify(\n {\n handlerName,\n type: data.type,\n snapshotType: backgroundSnapshotInstanceManager.values.get(\n currentSnapshotId,\n )?.type ?? '',\n jsFunctionName: eventHandler?.name ?? '',\n },\n null,\n 2,\n ),\n );\n }\n\n if (eventHandler) {\n try {\n eventHandler(data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nfunction publicComponentEvent(_componentId: string, handlerName: string, data: EventDataType) {\n publishEvent(handlerName, data);\n}\n\nfunction delayedPublicComponentEvent(_componentId: string, handlerName: string, data: EventDataType) {\n delayedPublishEvent(handlerName, data);\n}\n\nfunction updateGlobalProps(newData: Record<string, any>): void {\n updateGlobalPropsCore(newData, {\n // Snapshot force render consumes any sync setState dirty flags produced by\n // onGlobalPropsChanged listeners, avoiding an extra diff pass.\n forceRerender: () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n runWithForce(() => render(__root.__jsx, __root as any));\n },\n });\n}\n\nexport { injectTt, flushDelayedLifecycleEvents };\n"]}
|
|
1
|
+
{"version":3,"file":"tt.js","sourceRoot":"","sources":["../../../src/snapshot/lynx/tt.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,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024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { process, render } from 'preact';\n\nimport { runWithForce } from './runWithForce.js';\nimport { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';\nimport { updateCardData } from '../../core/lynx-update-data.js';\nimport { PerformanceTimingFlags, PipelineOrigins, beginPipeline, markTiming } from '../../core/performance.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { __root } from '../../root.js';\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport { CHILDREN } from '../../shared/render-constants.js';\nimport { printSnapshotInstanceToString } from '../debug/printSnapshot.js';\nimport { getSnapshotVNodeSource } from '../debug/vnodeSource.js';\nimport { LifecycleConstant } from '../lifecycle/constant.js';\nimport type { FirstScreenData } from '../lifecycle/constant.js';\nimport { destroyBackground } from '../lifecycle/destroy.js';\nimport { delayedEvents, delayedPublishEvent } from '../lifecycle/event/delayEvents.js';\nimport { delayLifecycleEvent, delayedLifecycleEvents } from '../lifecycle/event/delayLifecycleEvents.js';\nimport { commitPatchUpdate, genCommitTaskId, globalCommitTaskMap } from '../lifecycle/patch/commit.js';\nimport type { PatchList } from '../lifecycle/patch/commit.js';\nimport { removeCtxNotFoundEventListener } from '../lifecycle/patch/error.js';\nimport { runDelayedUiOps } from '../lifecycle/ref/delay.js';\nimport { reloadBackground } from '../lifecycle/reload.js';\nimport {\n BackgroundSnapshotInstance,\n backgroundSnapshotInstanceManager,\n hydrate,\n} from '../snapshot/backgroundSnapshot.js';\nimport type { SerializedSnapshotInstance } from '../snapshot/types.js';\nimport { destroyWorklet } from '../worklet/destroy.js';\nimport { sendMTRefInitValueToMainThread } from '../worklet/ref/updateInitValue.js';\n\nexport { runWithForce };\n\nfunction injectTt(): void {\n const tt = lynx.getApp();\n tt.OnLifecycleEvent = onLifecycleEvent;\n tt.publishEvent = delayedPublishEvent;\n tt.publicComponentEvent = delayedPublicComponentEvent;\n tt.callDestroyLifetimeFun = () => {\n removeCtxNotFoundEventListener();\n destroyWorklet();\n destroyBackground();\n };\n tt.updateGlobalProps = updateGlobalProps;\n tt.updateCardData = updateCardData;\n tt.onAppReload = reloadBackground;\n tt.processCardConfig = () => {\n // used to updateTheme, no longer rely on this function\n };\n}\n\nfunction onLifecycleEvent([type, data]: [LifecycleConstant, unknown]) {\n const hasRootRendered = CHILDREN in __root;\n // never called `render(<App/>, __root)`\n // happens if user call `root.render()` async\n if (!hasRootRendered) {\n delayLifecycleEvent(type, data);\n return;\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart(`OnLifecycleEvent::${type}`);\n }\n\n try {\n onLifecycleEventImpl(type, data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nfunction onLifecycleEventImpl(type: LifecycleConstant, data: unknown): void {\n switch (type) {\n case LifecycleConstant.firstScreen: {\n let processErr;\n try {\n process();\n } catch (e) {\n processErr = e;\n }\n const { root: lepusSide, firstScreenEventIdSwap } = data as FirstScreenData;\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::hydrate');\n }\n beginPipeline(true, PipelineOrigins.reactLynxHydrate, PerformanceTimingFlags.reactLynxHydrate);\n markTiming('hydrateParseSnapshotStart');\n const before = JSON.parse(lepusSide) as SerializedSnapshotInstance;\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] MTS -> BTS OnLifecycleEvent:\\n' + JSON.stringify(\n {\n ...data as object,\n // use parsed lepusSide to avoid extra escape characters ('\\\\')\n root: before,\n },\n null,\n 2,\n ),\n );\n console.alog?.(\n '[ReactLynxDebug] SnapshotInstance tree for first screen hydration:\\n'\n + printSnapshotInstanceToString(before),\n );\n console.alog?.(\n '[ReactLynxDebug] BackgroundSnapshotInstance tree before hydration:\\n'\n + printSnapshotInstanceToString(__root as BackgroundSnapshotInstance),\n );\n }\n markTiming('hydrateParseSnapshotEnd');\n markTiming('diffVdomStart');\n const snapshotPatch = hydrate(\n before,\n __root as BackgroundSnapshotInstance,\n );\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BackgroundSnapshotInstance after hydration:\\n'\n + printSnapshotInstanceToString(__root as BackgroundSnapshotInstance),\n );\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n markTiming('diffVdomEnd');\n\n // TODO: It seems `delayedEvents` and `delayedLifecycleEvents` should be merged into one array to ensure the proper order of events.\n flushDelayedLifecycleEvents();\n if (delayedEvents) {\n delayedEvents.forEach((args) => {\n const [handlerName, data] = args;\n // eslint-disable-next-line prefer-const\n let [idStr, ...rest] = handlerName.split(':');\n while (firstScreenEventIdSwap[idStr!]) idStr = firstScreenEventIdSwap[idStr!]?.toString();\n try {\n publishEvent([idStr, ...rest].join(':'), data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n });\n delayedEvents.length = 0;\n }\n\n enablePublishEvent();\n\n // console.debug(\"********** After hydration:\");\n // printSnapshotInstance(__root as BackgroundSnapshotInstance);\n const commitTaskId = genCommitTaskId();\n const patchList: PatchList = {\n patchList: [{ snapshotPatch, id: commitTaskId }],\n };\n if (delayedRunOnMainThreadData.length) {\n patchList.delayedRunOnMainThreadData = takeDelayedRunOnMainThreadData();\n }\n const obj = commitPatchUpdate(patchList, { isHydration: true });\n sendMTRefInitValueToMainThread();\n lynx.getNativeApp().callLepusMethod(LifecycleConstant.patchUpdate, obj, () => {\n globalCommitTaskMap.forEach((commitTask, id) => {\n if (id > commitTaskId) {\n return;\n }\n commitTask();\n globalCommitTaskMap.delete(id);\n });\n });\n runDelayedUiOps();\n\n if (processErr) {\n throw processErr;\n }\n break;\n }\n case LifecycleConstant.globalEventFromLepus: {\n const [eventName, params] = data as [string, Record<string, any>];\n lynx.getJSModule('GlobalEventEmitter').trigger(eventName, params);\n break;\n }\n case LifecycleConstant.publishEvent: {\n const { handlerName, data: d } = data as { handlerName: string; data: EventDataType };\n lynx.getApp().publishEvent(handlerName, d);\n break;\n }\n }\n}\n\nlet flushingDelayedLifecycleEvents = false;\nfunction flushDelayedLifecycleEvents(): void {\n // avoid stackoverflow\n if (flushingDelayedLifecycleEvents) return;\n flushingDelayedLifecycleEvents = true;\n if (delayedLifecycleEvents) {\n delayedLifecycleEvents.forEach((e) => {\n onLifecycleEvent(e);\n });\n delayedLifecycleEvents.length = 0;\n }\n flushingDelayedLifecycleEvents = false;\n}\n\nfunction publishEvent(handlerName: string, data: EventDataType) {\n lynx.getApp().callBeforePublishEvent?.(data);\n let snapshotId: number | undefined;\n const getSnapshotId = () => snapshotId ??= Number(handlerName.split(':')[0]);\n const eventHandler = backgroundSnapshotInstanceManager.getValueBySign(\n handlerName,\n ) as ((data: unknown) => void) | undefined;\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n const currentSnapshotId = getSnapshotId();\n profileStart(`ReactLynx::publishEvent`, {\n args: {\n handlerName,\n type: data.type,\n snapshotType: backgroundSnapshotInstanceManager.values.get(\n currentSnapshotId,\n )?.type ?? '',\n source: getSnapshotVNodeSource(currentSnapshotId) ?? '',\n jsFunctionName: eventHandler?.name ?? '',\n },\n });\n }\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n const currentSnapshotId = getSnapshotId();\n console.alog?.(\n `[ReactLynxDebug] BTS received event:\\n` + JSON.stringify(\n {\n handlerName,\n type: data.type,\n snapshotType: backgroundSnapshotInstanceManager.values.get(\n currentSnapshotId,\n )?.type ?? '',\n jsFunctionName: eventHandler?.name ?? '',\n },\n null,\n 2,\n ),\n );\n }\n\n if (eventHandler) {\n try {\n eventHandler(data);\n } catch (e) {\n lynx.reportError(e as Error);\n }\n }\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n}\n\nfunction publicComponentEvent(_componentId: string, handlerName: string, data: EventDataType) {\n publishEvent(handlerName, data);\n}\n\n/** Dispatches native events to their background handlers instead of delaying them. */\nfunction enablePublishEvent(): void {\n lynx.getApp().publishEvent = publishEvent;\n lynx.getApp().publicComponentEvent = publicComponentEvent;\n}\n\nfunction delayedPublicComponentEvent(_componentId: string, handlerName: string, data: EventDataType) {\n delayedPublishEvent(handlerName, data);\n}\n\nfunction updateGlobalProps(newData: Record<string, any>): void {\n updateGlobalPropsCore(newData, {\n // Snapshot force render consumes any sync setState dirty flags produced by\n // onGlobalPropsChanged listeners, avoiding an extra diff pass.\n forceRerender: () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n runWithForce(() => render(__root.__jsx, __root as any));\n },\n });\n}\n\nexport { enablePublishEvent, injectTt, flushDelayedLifecycleEvents };\n"]}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
5
|
+
import { isEmptyObject } from '../../shared/utils.js';
|
|
5
6
|
import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js';
|
|
6
7
|
import { __pendingListUpdates } from '../list/pendingListUpdates.js';
|
|
7
8
|
import { DynamicPartType } from '../snapshot/dynamicPartType.js';
|
|
8
9
|
import { unref } from '../snapshot/ref.js';
|
|
9
|
-
import { isEmptyObject } from '../../utils.js';
|
|
10
10
|
const UNREACHABLE_ITEM_KEY_NOT_FOUND = 'UNREACHABLE_ITEM_KEY_NOT_FOUND';
|
|
11
11
|
export function isEmptyDiffResult(diffResult) {
|
|
12
12
|
const hasChanged = !isEmptyObject(diffResult.i)
|