@lynx-js/react 0.129.0 → 0.129.2
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 +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/globalProps.test.ts +27 -6
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
- package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
- package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +118 -2
- package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
- package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
- package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
- package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
- package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
- package/runtime/__test__/shared/component-stack.test.ts +211 -0
- package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
- package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- package/runtime/__test__/snapshot/ref.test.jsx +30 -0
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
- package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
- package/runtime/lazy/element-template-internal.js +1 -1
- package/runtime/lazy/internal.js +1 -1
- package/runtime/lazy/jsx-dev-runtime.js +1 -1
- package/runtime/lazy/jsx-runtime.js +1 -1
- package/runtime/lazy/legacy-react-runtime.js +1 -1
- package/runtime/lazy/react-lepus.js +1 -1
- package/runtime/lazy/react.js +1 -1
- package/runtime/lib/core/capture-main-thread-object.js +2 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/globalProps.js +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
- package/runtime/lib/core/lynx-data-processors.js +3 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.js +1 -1
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/document.js +0 -5
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.js +5 -2
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +11 -12
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +16 -11
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +23 -0
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/client/root.d.ts +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +1 -1
- package/runtime/lib/element-template/debug/alog.js +4 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +2 -2
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +2 -2
- package/runtime/lib/element-template/internal.js +1 -14
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/flush.d.ts +1 -0
- package/runtime/lib/element-template/native/flush.js +9 -0
- package/runtime/lib/element-template/native/flush.js.map +1 -0
- package/runtime/lib/element-template/native/main-thread-api.js +3 -7
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +8 -2
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +57 -50
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +1 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +7 -1
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +31 -2
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +2 -125
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/shared/component-stack.d.ts +0 -4
- package/runtime/lib/shared/component-stack.js +21 -5
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.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/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/capture-main-thread-object.ts +2 -1
- package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
- package/runtime/src/core/globalProps.ts +1 -1
- package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
- package/runtime/src/core/lynx-data-processors.ts +124 -1
- package/runtime/src/core/runtime-destroy.ts +1 -1
- package/runtime/src/document.ts +0 -6
- package/runtime/src/element-template/background/attr-slots.ts +5 -1
- package/runtime/src/element-template/background/commit-hook.ts +18 -12
- package/runtime/src/element-template/background/destroy.ts +16 -13
- package/runtime/src/element-template/background/hydrate.ts +23 -0
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/debug/alog.ts +5 -2
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +1 -20
- package/runtime/src/element-template/lynx/env.ts +1 -1
- package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
- package/runtime/src/element-template/native/flush.ts +10 -0
- package/runtime/src/element-template/native/main-thread-api.ts +3 -6
- package/runtime/src/element-template/native/mts-destroy.ts +7 -2
- package/runtime/src/element-template/native/patch-listener.ts +62 -57
- package/runtime/src/element-template/native/reload-background.ts +1 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
- package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
- package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
- package/runtime/src/element-template/protocol/opcodes.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +8 -13
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +38 -0
- package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
- package/runtime/src/element-template/types.d.ts +6 -0
- package/runtime/src/internal.ts +1 -1
- package/runtime/src/lynx-api.ts +2 -124
- package/runtime/src/shared/component-stack.ts +22 -5
- package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
- package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
- package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
- package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/worklet-runtime/README.md +30 -10
- package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
- package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
- package/runtime/types/types.d.ts +2 -1
- package/runtime/vitest.config.ts +0 -2
- package/testing-library/.turbo/turbo-build.log +7 -7
- package/testing-library/src/__tests__/act.test.jsx +0 -7
- package/testing-library/src/__tests__/alog.test.jsx +12 -54
- package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
- package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
- package/testing-library/src/__tests__/worklet.test.jsx +49 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
- package/transform/__test__/defines.spec.js +30 -0
- package/transform/__test__/fixture.spec.js +11 -11
- package/transform/__test__/main-thread-object-compat.spec.js +111 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
- package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
- package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/package.json +0 -1
- package/transform/src/lib.rs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
- package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
- package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/hmr.js +0 -28
- package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
- package/runtime/src/snapshot/worklet/hmr.ts +0 -34
- /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
- /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
|
@@ -13,6 +13,7 @@ import { flushInitialElementTemplateListUpdates } from '../list/list.js';
|
|
|
13
13
|
import { __page } from '../page/page.js';
|
|
14
14
|
import { __root } from '../page/root-instance.js';
|
|
15
15
|
import { insertElementTemplateSubtree } from '../template/handle.js';
|
|
16
|
+
import { applyPendingMainThreadRefAttachments } from '../template/main-thread-dynamic-attr-state.js';
|
|
16
17
|
import { getElementTemplateNativeRef } from '../template/registry.js';
|
|
17
18
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
|
|
18
19
|
function renderMainThread() {
|
|
@@ -39,6 +40,7 @@ function renderMainThread() {
|
|
|
39
40
|
insertElementTemplateSubtree(__page, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, rootRef, null, rootSubtreeHandles[index]);
|
|
40
41
|
}
|
|
41
42
|
flushInitialListUpdates();
|
|
43
|
+
applyPendingMainThreadRefAttachments();
|
|
42
44
|
}
|
|
43
45
|
finally {
|
|
44
46
|
profileEnd();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-main-thread.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OA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,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAE,CAAC;YACjC,4BAA4B,CAC1B,MAAM,EACN,qCAAqC,EACrC,OAAO,EACP,IAAI,EACJ,kBAAkB,CAAC,KAAK,CAAE,CAC3B,CAAC;QACJ,CAAC;QACD,uBAAuB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"render-main-thread.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/render/render-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oCAAoC,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AAEtF,SAAS,gBAAgB;IACvB,IAAI,QAAQ,CAAC;IACb,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC5C,IAAI,CAAC;QACH,QAAQ,GAAG,uBAAuB,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAA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,MAAM,OAAO,GAAG,sCAAsC,EAAE,CAAC;IACzD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,2BAA2B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,+BAA+B,CAAC,OAAO,EAAE,mCAAmC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,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 IFR (Instant First-Frame Rendering) on main thread.\n */\n\nimport { renderToElementTemplate } from './render-direct.js';\nimport { getReloadVersion } from '../../../core/reload-version.js';\nimport { profileEnd, profileStart } from '../../debug/profile.js';\nimport { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';\nimport { ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../../protocol/page.js';\nimport type { ElementTemplateHydrateCommitContext, SerializedPageRoot } from '../../protocol/types.js';\nimport { flushInitialElementTemplateListUpdates } from '../list/list.js';\nimport { __page } from '../page/page.js';\nimport { __root } from '../page/root-instance.js';\nimport { insertElementTemplateSubtree } from '../template/handle.js';\nimport { applyPendingMainThreadRefAttachments } from '../template/main-thread-dynamic-attr-state.js';\nimport { getElementTemplateNativeRef } from '../template/registry.js';\nimport { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';\n\nfunction renderMainThread(): void {\n let rendered;\n profileStart('ReactLynx::renderMainThread');\n try {\n rendered = renderToElementTemplate(__root.__jsx, undefined);\n } catch (error) {\n // Like Snapshot, any failure during synchronous rendering is reported at\n // the lifecycle boundary before committing an empty result.\n lynx.reportError(error as Error);\n rendered = { pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] };\n } finally {\n profileEnd();\n }\n\n profileStart('ReactLynx::commitElementTemplate');\n try {\n const { pageAttributes, rootRefs, rootSubtreeHandles } = rendered;\n __SetAttributeOfElementTemplate(__page, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, pageAttributes);\n for (let index = 0; index < rootRefs.length; index += 1) {\n const rootRef = rootRefs[index]!;\n insertElementTemplateSubtree(\n __page,\n ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX,\n rootRef,\n null,\n rootSubtreeHandles[index]!,\n );\n }\n flushInitialListUpdates();\n applyPendingMainThreadRefAttachments();\n } finally {\n profileEnd();\n }\n\n profileStart('ReactLynx::packSerializedETInstance');\n try {\n const payload: ElementTemplateHydrateCommitContext = {\n page: __SerializeElementTemplate(__page) as SerializedPageRoot,\n reloadVersion: getReloadVersion(),\n };\n\n lynx.getJSContext().dispatchEvent({\n type: ElementTemplateLifecycleConstant.hydrate,\n data: payload,\n });\n } finally {\n profileEnd();\n }\n}\n\nfunction flushInitialListUpdates(): void {\n const results = flushInitialElementTemplateListUpdates();\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index]!;\n const listRef = getElementTemplateNativeRef(result.uid);\n if (listRef) {\n __SetAttributeOfElementTemplate(listRef, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, result.attributes);\n }\n }\n}\n\nexport { renderMainThread };\n"]}
|
|
@@ -7,12 +7,14 @@ export type EtAttrAdapter = (handleId: number, attrSlotIndex: number, value: unk
|
|
|
7
7
|
export type EtAttrPlan = (number | EtAttrAdapter)[];
|
|
8
8
|
export type EtAttrPlanMap = Record<string, EtAttrPlan | undefined>;
|
|
9
9
|
export declare const __etAttrPlanMap: EtAttrPlanMap;
|
|
10
|
-
export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref';
|
|
10
|
+
export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref' | 'gesture' | 'spread';
|
|
11
11
|
export declare function getMainThreadDynamicAttrSlotKinds(templateType: string): ReadonlyMap<number, MainThreadDynamicAttrKind> | undefined;
|
|
12
12
|
export declare function hasMainThreadRefAttrSlot(templateType: string): boolean;
|
|
13
13
|
export declare function adaptEventAttrSlot(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null;
|
|
14
14
|
export declare function adaptMTEventAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext): SerializableValue | null;
|
|
15
15
|
export declare function adaptRefAttrSlot(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null;
|
|
16
16
|
export declare function adaptMTRefAttrSlot(_handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext): SerializableValue | null;
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function adaptGestureAttrSlot(_handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext): SerializableValue | null;
|
|
18
|
+
export declare function adaptSpreadAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, context?: EtAttrAdapterContext): SerializableValue | null;
|
|
19
|
+
export declare function adaptTypedSpreadAttrSlot(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null;
|
|
18
20
|
export declare function clearEtAttrPlanMap(): void;
|
|
@@ -5,8 +5,9 @@ import { prepareMTEventCtxForNative } from './main-thread-event-ctx.js';
|
|
|
5
5
|
import { prepareMTRefForNative } from './main-thread-ref-ctx.js';
|
|
6
6
|
import { isMainThreadFunction } from '../../../core/main-thread-function.js';
|
|
7
7
|
import { getEventValue } from '../../prop-adapters/event-value.js';
|
|
8
|
+
import { prepareGestureForNative } from '../../prop-adapters/gesture.js';
|
|
8
9
|
import { prepareRefAttrSlot } from '../../prop-adapters/ref.js';
|
|
9
|
-
import { prepareSpreadAttrSlot } from '../../prop-adapters/spread.js';
|
|
10
|
+
import { prepareSpreadAttrSlot, prepareTypedSpreadAttrSlot } from '../../prop-adapters/spread.js';
|
|
10
11
|
export const __etAttrPlanMap = Object.create(null);
|
|
11
12
|
const mainThreadDynamicAttrSlotKinds = new Map();
|
|
12
13
|
export function getMainThreadDynamicAttrSlotKinds(templateType) {
|
|
@@ -23,9 +24,15 @@ export function getMainThreadDynamicAttrSlotKinds(templateType) {
|
|
|
23
24
|
if (adapter === adaptMTEventAttrSlot) {
|
|
24
25
|
kind = 'mt-event';
|
|
25
26
|
}
|
|
27
|
+
else if (adapter === adaptGestureAttrSlot) {
|
|
28
|
+
kind = 'gesture';
|
|
29
|
+
}
|
|
26
30
|
else if (adapter === adaptMTRefAttrSlot) {
|
|
27
31
|
kind = 'mt-ref';
|
|
28
32
|
}
|
|
33
|
+
else if (adapter === adaptSpreadAttrSlot) {
|
|
34
|
+
kind = 'spread';
|
|
35
|
+
}
|
|
29
36
|
if (kind) {
|
|
30
37
|
(slotKinds ??= new Map()).set(attrPlan[planIndex], kind);
|
|
31
38
|
}
|
|
@@ -40,7 +47,7 @@ export function hasMainThreadRefAttrSlot(templateType) {
|
|
|
40
47
|
return false;
|
|
41
48
|
}
|
|
42
49
|
for (const kind of slotKinds.values()) {
|
|
43
|
-
if (kind === 'mt-ref') {
|
|
50
|
+
if (kind === 'mt-ref' || kind === 'spread') {
|
|
44
51
|
return true;
|
|
45
52
|
}
|
|
46
53
|
}
|
|
@@ -70,8 +77,14 @@ export function adaptRefAttrSlot(handleId, attrSlotIndex, value) {
|
|
|
70
77
|
export function adaptMTRefAttrSlot(_handleId, attrSlotIndex, value, context) {
|
|
71
78
|
return prepareMTRefForNative(value, context?.previousPreparedSlots?.[attrSlotIndex], context?.previousRawSlots?.[attrSlotIndex]);
|
|
72
79
|
}
|
|
73
|
-
export function
|
|
74
|
-
return
|
|
80
|
+
export function adaptGestureAttrSlot(_handleId, attrSlotIndex, value, context) {
|
|
81
|
+
return prepareGestureForNative(value, context?.previousPreparedSlots[attrSlotIndex]);
|
|
82
|
+
}
|
|
83
|
+
export function adaptSpreadAttrSlot(handleId, attrSlotIndex, value, context) {
|
|
84
|
+
return prepareSpreadAttrSlot(handleId, attrSlotIndex, value, context);
|
|
85
|
+
}
|
|
86
|
+
export function adaptTypedSpreadAttrSlot(handleId, attrSlotIndex, value) {
|
|
87
|
+
return prepareTypedSpreadAttrSlot(handleId, attrSlotIndex, value);
|
|
75
88
|
}
|
|
76
89
|
export function clearEtAttrPlanMap() {
|
|
77
90
|
// The compiled output assigns into the exported side table directly, so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr-slot-plan.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/attr-slot-plan.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"attr-slot-plan.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/attr-slot-plan.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4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,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 { prepareMTEventCtxForNative } from './main-thread-event-ctx.js';\nimport { prepareMTRefForNative } from './main-thread-ref-ctx.js';\nimport { isMainThreadFunction } from '../../../core/main-thread-function.js';\nimport { getEventValue } from '../../prop-adapters/event-value.js';\nimport { prepareGestureForNative } from '../../prop-adapters/gesture.js';\nimport type { GestureSlotValue } from '../../prop-adapters/gesture.js';\nimport { prepareRefAttrSlot } from '../../prop-adapters/ref.js';\nimport { prepareSpreadAttrSlot, prepareTypedSpreadAttrSlot } from '../../prop-adapters/spread.js';\nimport type { SerializableValue } from '../../protocol/types.js';\n\nexport interface EtAttrAdapterContext {\n previousPreparedSlots: readonly unknown[];\n previousRawSlots: readonly unknown[];\n}\n\nexport type EtAttrAdapter = (\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n) => SerializableValue | null;\n\nexport type EtAttrPlan = (number | EtAttrAdapter)[];\n\nexport type EtAttrPlanMap = Record<\n string,\n EtAttrPlan | undefined\n>;\n\nexport const __etAttrPlanMap = Object.create(null) as EtAttrPlanMap;\n\nexport type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref' | 'gesture' | 'spread';\n\nconst mainThreadDynamicAttrSlotKinds = new Map<\n string,\n ReadonlyMap<number, MainThreadDynamicAttrKind> | null\n>();\n\nexport function getMainThreadDynamicAttrSlotKinds(\n templateType: string,\n): ReadonlyMap<number, MainThreadDynamicAttrKind> | undefined {\n const cached = mainThreadDynamicAttrSlotKinds.get(templateType);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n\n const attrPlan = __etAttrPlanMap[templateType];\n let slotKinds: Map<number, MainThreadDynamicAttrKind> | undefined;\n if (attrPlan) {\n for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {\n const adapter = attrPlan[planIndex + 1];\n let kind: MainThreadDynamicAttrKind | undefined;\n if (adapter === adaptMTEventAttrSlot) {\n kind = 'mt-event';\n } else if (adapter === adaptGestureAttrSlot) {\n kind = 'gesture';\n } else if (adapter === adaptMTRefAttrSlot) {\n kind = 'mt-ref';\n } else if (adapter === adaptSpreadAttrSlot) {\n kind = 'spread';\n }\n if (kind) {\n (slotKinds ??= new Map()).set(attrPlan[planIndex] as number, kind);\n }\n }\n }\n mainThreadDynamicAttrSlotKinds.set(templateType, slotKinds ?? null);\n return slotKinds;\n}\n\nexport function hasMainThreadRefAttrSlot(templateType: string): boolean {\n const slotKinds = getMainThreadDynamicAttrSlotKinds(templateType);\n if (!slotKinds) {\n return false;\n }\n for (const kind of slotKinds.values()) {\n if (kind === 'mt-ref' || kind === 'spread') {\n return true;\n }\n }\n return false;\n}\n\nexport function adaptEventAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n if (value === null || value === undefined || value === false) {\n return null;\n }\n return getEventValue(handleId, attrSlotIndex);\n}\n\nexport function adaptMTEventAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n if (value === null || value === undefined || value === false) {\n return null;\n }\n if (!isMainThreadFunction(value)) {\n if (__DEV__) {\n lynx.reportError(\n new Error(`ElementTemplate main-thread event slot ${handleId}:${attrSlotIndex} expects a worklet ctx object.`),\n );\n }\n return null;\n }\n return prepareMTEventCtxForNative(\n value,\n context?.previousPreparedSlots?.[attrSlotIndex],\n context?.previousRawSlots?.[attrSlotIndex],\n );\n}\n\nexport function adaptRefAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n return prepareRefAttrSlot(handleId, attrSlotIndex, value);\n}\n\nexport function adaptMTRefAttrSlot(\n _handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n return prepareMTRefForNative(\n value,\n context?.previousPreparedSlots?.[attrSlotIndex],\n context?.previousRawSlots?.[attrSlotIndex],\n );\n}\n\nexport function adaptGestureAttrSlot(\n _handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n return prepareGestureForNative(\n value,\n context?.previousPreparedSlots[attrSlotIndex] as GestureSlotValue | null | undefined,\n ) as unknown as SerializableValue | null;\n}\n\nexport function adaptSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n return prepareSpreadAttrSlot(handleId, attrSlotIndex, value, context);\n}\n\nexport function adaptTypedSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n return prepareTypedSpreadAttrSlot(handleId, attrSlotIndex, value);\n}\n\nexport function clearEtAttrPlanMap(): void {\n // The compiled output assigns into the exported side table directly, so the\n // object identity must stay stable when tests or teardown clear state.\n for (const templateKey in __etAttrPlanMap) {\n delete __etAttrPlanMap[templateKey];\n }\n mainThreadDynamicAttrSlotKinds.clear();\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { clearDelayedRunOnBackgroundFunctions, retainWorkletCtx } from '@lynx-js
|
|
|
5
5
|
import { createBackgroundFunctionHandle } from '../../../core/background-function/handle.js';
|
|
6
6
|
import { registerBackgroundFunctionCtx, resetBackgroundFunctionRuntime, runOnBackground, } from '../../../core/background-function/run-on-background.js';
|
|
7
7
|
import { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';
|
|
8
|
-
import { isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
|
|
8
|
+
import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
|
|
9
9
|
/**
|
|
10
10
|
* @internal transform-generated runtime helper for background JS function handles.
|
|
11
11
|
*/
|
|
@@ -16,6 +16,8 @@ export function registerMainThreadBackgroundFunctionCtx(ctx) {
|
|
|
16
16
|
registerBackgroundFunctionCtx(ctx);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
// Track the input before Native takes ownership. If Native rejects it, collection
|
|
20
|
+
// must still release its already-registered background execution; slot state commits later.
|
|
19
21
|
export function retainMainThreadBackgroundFunctionCtx(ctx) {
|
|
20
22
|
retainWorkletCtx(ctx);
|
|
21
23
|
}
|
|
@@ -24,6 +26,11 @@ export function resetElementTemplateBackgroundFunctionRuntime() {
|
|
|
24
26
|
resetFunctionCallReturnListener();
|
|
25
27
|
}
|
|
26
28
|
export function resetElementTemplateMainThreadBackgroundFunctionRuntime() {
|
|
29
|
+
const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;
|
|
30
|
+
if (manager) {
|
|
31
|
+
manager.dispose();
|
|
32
|
+
globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();
|
|
33
|
+
}
|
|
27
34
|
clearDelayedRunOnBackgroundFunctions();
|
|
28
35
|
resetFunctionCallReturnListener();
|
|
29
36
|
}
|
package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread-background-function.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-background-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oCAAoC,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAEjH,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,eAAe,GAChB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"main-thread-background-function.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/template/main-thread-background-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oCAAoC,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAEjH,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,eAAe,GAChB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAUvH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,UAAU,uCAAuC,CAAC,GAAoC;IAC1F,IAAI,MAAM,IAAI,wBAAwB,EAAE,EAAE,CAAC;QACzC,6BAA6B,CAAC,GAA4B,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,4FAA4F;AAC5F,MAAM,UAAU,qCAAqC,CAAC,GAAoC;IACxF,gBAAgB,CAAC,GAA8B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,6CAA6C;IAC3D,8BAA8B,EAAE,CAAC;IACjC,+BAA+B,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,uDAAuD;IACrE,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,2BAA2B,CAAC;IACxE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,UAAU,CAAC,eAAe,CAAC,2BAA2B,GAAG,IAAI,0BAA0B,EAAE,CAAC;IAC5F,CAAC;IACD,oCAAoC,EAAE,CAAC;IACvC,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright 2026 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 { clearDelayedRunOnBackgroundFunctions, retainWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { createBackgroundFunctionHandle } from '../../../core/background-function/handle.js';\nimport {\n registerBackgroundFunctionCtx,\n resetBackgroundFunctionRuntime,\n runOnBackground,\n} from '../../../core/background-function/run-on-background.js';\nimport { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';\nimport { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';\n\ntype BackgroundFunctionCtx = Parameters<typeof registerBackgroundFunctionCtx>[0];\ntype RetainableMainThreadCtx = Parameters<typeof retainWorkletCtx>[0];\n\ninterface MainThreadBackgroundFunctionCtx {\n _wkltId: string;\n [key: string]: unknown;\n}\n\n/**\n * @internal transform-generated runtime helper for background JS function handles.\n */\nexport const transformToWorklet = createBackgroundFunctionHandle;\nexport { runOnBackground };\n\nexport function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n if (__JS__ && isRunOnBackgroundEnabled()) {\n registerBackgroundFunctionCtx(ctx as BackgroundFunctionCtx);\n }\n}\n\n// Track the input before Native takes ownership. If Native rejects it, collection\n// must still release its already-registered background execution; slot state commits later.\nexport function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {\n retainWorkletCtx(ctx as RetainableMainThreadCtx);\n}\n\nexport function resetElementTemplateBackgroundFunctionRuntime(): void {\n resetBackgroundFunctionRuntime();\n resetFunctionCallReturnListener();\n}\n\nexport function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void {\n const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;\n if (manager) {\n manager.dispose();\n globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();\n }\n clearDelayedRunOnBackgroundFunctions();\n resetFunctionCallReturnListener();\n}\n"]}
|
|
@@ -12,13 +12,19 @@ export interface MainThreadDynamicAttrSubtreeHandle {
|
|
|
12
12
|
uid: number;
|
|
13
13
|
ref: ElementTemplateHandle;
|
|
14
14
|
}
|
|
15
|
+
export declare function isSpreadDynamicAttrSlot(handleId: number, attrSlotIndex: number): boolean;
|
|
16
|
+
export declare function prepareSpreadAttrSlotForNative(value: unknown): SerializableValue | null;
|
|
15
17
|
export declare function prepareMainThreadDynamicAttrSlotsForNative(templateType: string, attributeSlots: readonly unknown[] | null | undefined): SerializableValue[] | null | undefined;
|
|
16
18
|
export declare function clearMainThreadDynamicAttrState(): void;
|
|
17
19
|
export declare function getMainThreadDynamicAttrState(handleId: number, attrSlotIndex: number): MainThreadDynamicAttrState | undefined;
|
|
18
|
-
export declare function initializeMainThreadDynamicAttrSlots(handleId: number, templateType: string, attributeSlots: readonly unknown[] | null | undefined): void;
|
|
20
|
+
export declare function initializeMainThreadDynamicAttrSlots(handleId: number, templateType: string, attributeSlots: readonly unknown[] | null | undefined, isCreatedByPatch?: boolean): void;
|
|
21
|
+
export declare function updateGestureAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, isHydration?: boolean): void;
|
|
19
22
|
export declare function updateMainThreadEventAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, isHydration?: boolean): void;
|
|
20
23
|
export declare function updateMainThreadRefAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, nativeRef: ElementTemplateHandle, isHydration?: boolean): void;
|
|
24
|
+
export declare function updateSpreadAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, nativeRef: ElementTemplateHandle, isHydration?: boolean): void;
|
|
25
|
+
export declare function reconcileUnhydratedSpreadMTRefSlots(): void;
|
|
21
26
|
export declare function attachMainThreadDynamicAttrRefsForSubtree(handles: readonly MainThreadDynamicAttrSubtreeHandle[]): void;
|
|
27
|
+
export declare function applyPendingMainThreadRefAttachments(isHydration?: boolean): void;
|
|
22
28
|
export declare function detachMainThreadDynamicAttrRefsForSubtree(handles: readonly MainThreadDynamicAttrSubtreeHandle[]): void;
|
|
23
29
|
export declare function deleteMainThreadDynamicAttrStateForSubtree(handleIds: readonly number[]): void;
|
|
24
30
|
export {};
|