@lynx-js/react 0.124.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/components/lib/Page.js +4 -2
- package/components/lib/Page.js.map +1 -1
- package/components/src/Page.ts +4 -2
- package/package.json +2 -2
- package/runtime/compat/index.d.ts +48 -1
- package/runtime/compat/index.js +7 -3
- package/runtime/jsx-dev-runtime/index.d.ts +39 -1
- package/runtime/jsx-runtime/index.d.ts +39 -1
- package/runtime/lazy/compat.js +2 -0
- package/runtime/lazy/internal.js +2 -1
- package/runtime/lepus/index.js +2 -2
- package/runtime/lepus/jsx-runtime/index.js +20 -8
- package/runtime/lib/core/component.js +3 -3
- package/runtime/lib/core/component.js.map +1 -1
- package/runtime/lib/core/forceRootRender.js +3 -2
- package/runtime/lib/core/forceRootRender.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/hooks/mainThreadImpl.js +2 -0
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.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/main-thread-function.d.ts +2 -0
- package/runtime/lib/core/main-thread-function.js +10 -0
- package/runtime/lib/core/main-thread-function.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.js +23 -0
- package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -0
- package/runtime/lib/{snapshot/worklet/ref/workletRef.d.ts → core/main-thread-ref.d.ts} +6 -7
- package/runtime/lib/{snapshot/worklet/ref/workletRef.js → core/main-thread-ref.js} +31 -36
- package/runtime/lib/core/main-thread-ref.js.map +1 -0
- package/runtime/lib/core/mts-capability.d.ts +1 -0
- package/runtime/lib/core/mts-capability.js +18 -0
- package/runtime/lib/core/mts-capability.js.map +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +4 -11
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.d.ts +5 -1
- package/runtime/lib/element-template/background/attr-slots.js +15 -4
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.d.ts +9 -0
- package/runtime/lib/element-template/background/commit-hook.js +83 -51
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +4 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +21 -25
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +22 -14
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +14 -1
- package/runtime/lib/element-template/background/instance.js +117 -52
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/manager.d.ts +1 -0
- package/runtime/lib/element-template/background/manager.js +8 -2
- package/runtime/lib/element-template/background/manager.js.map +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.d.ts +3 -0
- package/runtime/lib/element-template/background/page-root-hydrate.js +14 -0
- package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -0
- package/runtime/lib/element-template/debug/alog.d.ts +6 -0
- package/runtime/lib/element-template/debug/alog.js +14 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js +2 -2
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +1 -0
- package/runtime/lib/element-template/index.js +1 -0
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +2 -1
- package/runtime/lib/element-template/internal.js +2 -2
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/jsx-runtime/index.d.ts +3 -1
- package/runtime/lib/element-template/jsx-runtime/index.js +2 -4
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js +1 -2
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +2 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +8 -8
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +1 -2
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +14 -5
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +2 -2
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +28 -3
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +1 -4
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +2 -0
- package/runtime/lib/element-template/protocol/opcodes.js +2 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/page.d.ts +3 -0
- package/runtime/lib/element-template/protocol/page.js +7 -0
- package/runtime/lib/element-template/protocol/page.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +24 -3
- package/runtime/lib/element-template/protocol/types.js +1 -0
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/authored-page.d.ts +8 -0
- package/runtime/lib/element-template/runtime/page/authored-page.js +30 -0
- package/runtime/lib/element-template/runtime/page/authored-page.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/page.d.ts +0 -2
- package/runtime/lib/element-template/runtime/page/page.js +2 -10
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +53 -18
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +1 -3
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +12 -25
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +4 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +62 -20
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +2 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +23 -10
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +46 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +2 -0
- package/runtime/lib/element-template/runtime/template/handle.js +11 -3
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +3 -3
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +2 -2
- 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 +16 -7
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +134 -56
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.d.ts +0 -1
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js +4 -9
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +13 -0
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +62 -0
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/registry.js +2 -1
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.d.ts +5 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +13 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -0
- 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 +1 -1
- package/runtime/lib/lynx-api.js +1 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/shared/attribute-name.js +1 -2
- package/runtime/lib/shared/attribute-name.js.map +1 -1
- package/runtime/lib/shared/component-stack.js +2 -1
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/shared/render-constants.d.ts +3 -2
- package/runtime/lib/shared/render-constants.js +5 -2
- package/runtime/lib/shared/render-constants.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js +1 -0
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +2 -2
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js +1 -0
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +5 -2
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +10 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +31 -2
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.js +1 -2
- package/runtime/lib/snapshot/lynx/children.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js +1 -1
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js +1 -1
- package/runtime/lib/snapshot/lynx/suspense.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js +5 -5
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +8 -11
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +5 -0
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js +1 -3
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/snapshot.js +8 -0
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +2 -8
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/destroy.js +2 -2
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -1
- package/runtime/lib/snapshot/worklet/functionality.d.ts +1 -0
- package/runtime/lib/snapshot/worklet/functionality.js +2 -8
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +2 -2
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.d.ts +9 -0
- package/runtime/lib/utils.js +27 -0
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +5 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js +7 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js +2 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/worklet-runtime/dev.js +1 -1
- package/testing-library/dist/env/index.js +1 -2
- package/testing-library/dist/setupFiles/common/runtime-setup.js +3 -3
- package/transform/dist/wasm.cjs +5 -5
- package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +0 -1
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.js +0 -23
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export function isMainThreadFunction(value) {
|
|
5
|
+
return value != null
|
|
6
|
+
&& typeof value === 'object'
|
|
7
|
+
&& !Array.isArray(value)
|
|
8
|
+
&& typeof value._wkltId === 'string';
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=main-thread-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-function.js","sourceRoot":"","sources":["../../src/core/main-thread-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,IAAI,IAAI;WACf,OAAO,KAAK,KAAK,QAAQ;WACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;WACrB,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MainThreadRefInitValuePatch = [id: number, value: unknown][];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { isMtsEnabled } from './mts-capability.js';
|
|
5
|
+
let mainThreadRefInitValuePatch = [];
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function addMainThreadRefInitValue(id, value) {
|
|
10
|
+
if (!isMtsEnabled()) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
mainThreadRefInitValuePatch.push([id, value]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function takeMainThreadRefInitValuePatch() {
|
|
19
|
+
const patch = mainThreadRefInitValuePatch;
|
|
20
|
+
mainThreadRefInitValuePatch = [];
|
|
21
|
+
return patch;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=main-thread-ref-init-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-ref-init-value.js","sourceRoot":"","sources":["../../src/core/main-thread-ref-init-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,IAAI,2BAA2B,GAAgC,EAAE,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,EAAU,EAAE,KAAc;IAClE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IAED,2BAA2B,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC7C,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,2BAA2B,GAAG,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
set current(_: T);
|
|
6
|
-
}
|
|
2
|
+
import type { WorkletRefImpl } from '../worklet-runtime/bindings/types.js';
|
|
3
|
+
export declare function clearMainThreadRefLastIdForTesting(): void;
|
|
4
|
+
export declare function isMainThreadRef(value: unknown): value is WorkletRefImpl<unknown>;
|
|
7
5
|
/**
|
|
8
6
|
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
9
7
|
* states between main thread function calls.
|
|
@@ -11,8 +9,10 @@ declare abstract class WorkletRef<T> {
|
|
|
11
9
|
* multiple main thread functions.
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
|
-
export declare class MainThreadRef<T>
|
|
12
|
+
export declare class MainThreadRef<T> {
|
|
15
13
|
constructor(initValue: T);
|
|
14
|
+
get current(): T;
|
|
15
|
+
set current(_: T);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Create A `MainThreadRef`.
|
|
@@ -129,4 +129,3 @@ export declare function useMainThreadRef<T>(initValue: T | null): RefObject<T>;
|
|
|
129
129
|
* @public
|
|
130
130
|
*/
|
|
131
131
|
export declare function useMainThreadRef<T = undefined>(): MainThreadRef<T | undefined>;
|
|
132
|
-
export {};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
// Split into two variables for testing purposes
|
|
1
|
+
import { useMemo } from './hooks/react.js';
|
|
2
|
+
import { addMainThreadRefInitValue } from './main-thread-ref-init-value.js';
|
|
3
|
+
import { WorkletEvents } from '../worklet-runtime/bindings/events.js';
|
|
4
|
+
// Split into two variables for testing purposes.
|
|
5
5
|
let lastIdBG = 0;
|
|
6
6
|
let lastIdMT = 0;
|
|
7
|
-
export function
|
|
7
|
+
export function clearMainThreadRefLastIdForTesting() {
|
|
8
8
|
lastIdBG = lastIdMT = 0;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
export function isMainThreadRef(value) {
|
|
11
|
+
return typeof value === 'object'
|
|
12
|
+
&& value !== null
|
|
13
|
+
&& typeof value._wvid === 'number';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
17
|
+
* states between main thread function calls.
|
|
18
|
+
* The data saved in `current` property of the `MainThreadRef` can be read and written in
|
|
19
|
+
* multiple main thread functions.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export class MainThreadRef {
|
|
11
23
|
/**
|
|
12
24
|
* @internal
|
|
13
25
|
*/
|
|
@@ -24,15 +36,21 @@ class WorkletRef {
|
|
|
24
36
|
* @internal
|
|
25
37
|
*/
|
|
26
38
|
_lifecycleObserver;
|
|
27
|
-
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
constructor(initValue, type) {
|
|
39
|
+
constructor(initValue) {
|
|
31
40
|
this._initValue = initValue;
|
|
32
|
-
this._type =
|
|
41
|
+
this._type = 'main-thread';
|
|
33
42
|
if (__JS__) {
|
|
34
43
|
this._wvid = ++lastIdBG;
|
|
35
|
-
|
|
44
|
+
addMainThreadRefInitValue(this._wvid, initValue);
|
|
45
|
+
const id = this._wvid;
|
|
46
|
+
this._lifecycleObserver = lynx.getNativeApp().createJSObjectDestructionObserver?.(() => {
|
|
47
|
+
lynx.getCoreContext().dispatchEvent({
|
|
48
|
+
type: WorkletEvents.releaseWorkletRef,
|
|
49
|
+
data: {
|
|
50
|
+
id,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
});
|
|
36
54
|
}
|
|
37
55
|
else {
|
|
38
56
|
this._wvid = --lastIdMT;
|
|
@@ -65,32 +83,9 @@ class WorkletRef {
|
|
|
65
83
|
};
|
|
66
84
|
}
|
|
67
85
|
}
|
|
68
|
-
/**
|
|
69
|
-
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
70
|
-
* states between main thread function calls.
|
|
71
|
-
* The data saved in `current` property of the `MainThreadRef` can be read and written in
|
|
72
|
-
* multiple main thread functions.
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
export class MainThreadRef extends WorkletRef {
|
|
76
|
-
constructor(initValue) {
|
|
77
|
-
super(initValue, 'main-thread');
|
|
78
|
-
if (__JS__) {
|
|
79
|
-
const id = this._wvid;
|
|
80
|
-
this._lifecycleObserver = lynx.getNativeApp().createJSObjectDestructionObserver?.(() => {
|
|
81
|
-
lynx.getCoreContext?.().dispatchEvent({
|
|
82
|
-
type: WorkletEvents.releaseWorkletRef,
|
|
83
|
-
data: {
|
|
84
|
-
id,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
86
|
export function useMainThreadRef(initValue) {
|
|
92
87
|
return useMemo(() => {
|
|
93
88
|
return new MainThreadRef(initValue);
|
|
94
89
|
}, []);
|
|
95
90
|
}
|
|
96
|
-
//# sourceMappingURL=
|
|
91
|
+
//# sourceMappingURL=main-thread-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-ref.js","sourceRoot":"","sources":["../../src/core/main-thread-ref.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,iDAAiD;AACjD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,UAAU,kCAAkC;IAChD,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ;WAC3B,KAA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,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sFAAsF,CAAC,CAAC;QAC1G,CAAC;QACD,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;QAC/G,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF;AA2HD,MAAM,UAAU,gBAAgB,CAAI,SAAa;IAC/C,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { isSdkVersionGt } from '../utils.js';
|
|
5
|
+
let mtsEnabled;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function isMtsEnabled() {
|
|
10
|
+
return mtsEnabled ??= isSdkVersionGt(2, 13);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export function clearMtsConfigCacheForTesting() {
|
|
16
|
+
mtsEnabled = undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=mts-capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mts-capability.js","sourceRoot":"","sources":["../../src/core/mts-capability.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,IAAI,UAA+B,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,KAAK,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { onFunctionCall } from './return-value.js';
|
|
|
5
5
|
import { isSdkVersionGt } from '../../utils.js';
|
|
6
6
|
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
7
7
|
import { registerBackgroundFunctionCtx } from '../background-function/run-on-background.js';
|
|
8
|
+
import { isMainThreadFunction } from '../main-thread-function.js';
|
|
9
|
+
import { isMtsEnabled } from '../mts-capability.js';
|
|
8
10
|
export let delayedRunOnMainThreadData = [];
|
|
9
11
|
export function enqueueDelayedRunOnMainThreadData(data) {
|
|
10
12
|
delayedRunOnMainThreadData.push(data);
|
|
@@ -22,7 +24,7 @@ export function createRunOnMainThread(options) {
|
|
|
22
24
|
if (__LEPUS__) {
|
|
23
25
|
throw new Error('runOnMainThread can only be used on the background thread.');
|
|
24
26
|
}
|
|
25
|
-
if (!
|
|
27
|
+
if (!isMtsEnabled()) {
|
|
26
28
|
throw new Error('runOnMainThread requires Lynx sdk version 2.14.');
|
|
27
29
|
}
|
|
28
30
|
return async (...params) => {
|
|
@@ -43,20 +45,11 @@ export function createRunOnMainThread(options) {
|
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
function isMainThreadFunctionSupported() {
|
|
47
|
-
return isSdkVersionGt(2, 13);
|
|
48
|
-
}
|
|
49
48
|
function isRunOnBackgroundSupported() {
|
|
50
49
|
return isSdkVersionGt(2, 15);
|
|
51
50
|
}
|
|
52
|
-
function isMainThreadFunctionCtx(value) {
|
|
53
|
-
return value != null
|
|
54
|
-
&& typeof value === 'object'
|
|
55
|
-
&& !Array.isArray(value)
|
|
56
|
-
&& typeof value._wkltId === 'string';
|
|
57
|
-
}
|
|
58
51
|
function prepareMainThreadFunctionCtx(worklet) {
|
|
59
|
-
if (
|
|
52
|
+
if (isMainThreadFunction(worklet) && isRunOnBackgroundSupported()) {
|
|
60
53
|
registerBackgroundFunctionCtx(worklet);
|
|
61
54
|
}
|
|
62
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread.js","sourceRoot":"","sources":["../../../src/core/thread-function-call/main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"main-thread.js","sourceRoot":"","sources":["../../../src/core/thread-function-call/main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,CAAC,IAAI,0BAA0B,GAAwB,EAAE,CAAC;AAEhE,MAAM,UAAU,iCAAiC,CAAC,IAAuB;IACvE,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,MAAM,IAAI,GAAG,0BAA0B,CAAC;IACxC,0BAA0B,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I,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { ElementTemplateUpdateOp } from '../protocol/opcodes.js';
|
|
1
2
|
import type { SerializableValue } from '../protocol/types.js';
|
|
3
|
+
import type { EtAttrPlan } from '../runtime/template/attr-slot-plan.js';
|
|
2
4
|
export interface PrepareAttributeSlotsOptions {
|
|
3
5
|
previousPreparedSlots?: readonly unknown[];
|
|
4
6
|
previousRawSlots?: readonly unknown[];
|
|
7
|
+
attributePlan?: EtAttrPlan | undefined;
|
|
5
8
|
}
|
|
6
9
|
export declare function prepareAttributeSlots(templateKey: string, handleId: number, rawSlots: readonly unknown[], options?: PrepareAttributeSlotsOptions): SerializableValue[];
|
|
7
|
-
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[]): void;
|
|
10
|
+
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[], attributePlan?: EtAttrPlan): void;
|
|
11
|
+
export declare function getAttributeSlotUpdateOp(templateType: string, attrSlotIndex: number): ElementTemplateUpdateOp;
|
|
@@ -2,7 +2,8 @@
|
|
|
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 { getSpreadRefFromValue, queueRefAttrUpdate } from '../prop-adapters/ref.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
6
|
+
import { __etAttrPlanMap, adaptRefAttrSlot, adaptSpreadAttrSlot, getMainThreadDynamicAttrSlotKinds, } from '../runtime/template/attr-slot-plan.js';
|
|
6
7
|
function normalizeAttributeSlots(rawSlots) {
|
|
7
8
|
let normalizedSlots;
|
|
8
9
|
for (let slotIndex = 0; slotIndex < rawSlots.length; slotIndex += 1) {
|
|
@@ -34,7 +35,7 @@ function queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlot
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
export function prepareAttributeSlots(templateKey, handleId, rawSlots, options) {
|
|
37
|
-
const attrPlan = __etAttrPlanMap[templateKey];
|
|
38
|
+
const attrPlan = options?.attributePlan ?? __etAttrPlanMap[templateKey];
|
|
38
39
|
if (!attrPlan || attrPlan.length === 0) {
|
|
39
40
|
return normalizeAttributeSlots(rawSlots);
|
|
40
41
|
}
|
|
@@ -58,11 +59,21 @@ export function prepareAttributeSlots(templateKey, handleId, rawSlots, options)
|
|
|
58
59
|
}
|
|
59
60
|
return preparedSlots;
|
|
60
61
|
}
|
|
61
|
-
export function queueRefAttributeSlotUpdates(templateKey, handleId, previousRawSlots, nextRawSlots) {
|
|
62
|
-
const attrPlan = __etAttrPlanMap[templateKey];
|
|
62
|
+
export function queueRefAttributeSlotUpdates(templateKey, handleId, previousRawSlots, nextRawSlots, attributePlan) {
|
|
63
|
+
const attrPlan = attributePlan ?? __etAttrPlanMap[templateKey];
|
|
63
64
|
if (!attrPlan || attrPlan.length === 0) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlots, nextRawSlots);
|
|
67
68
|
}
|
|
69
|
+
export function getAttributeSlotUpdateOp(templateType, attrSlotIndex) {
|
|
70
|
+
const kind = getMainThreadDynamicAttrSlotKinds(templateType)?.get(attrSlotIndex);
|
|
71
|
+
if (kind === 'mt-event') {
|
|
72
|
+
return ElementTemplateUpdateOps.setMainThreadEvent;
|
|
73
|
+
}
|
|
74
|
+
if (kind === 'mt-ref') {
|
|
75
|
+
return ElementTemplateUpdateOps.setMainThreadRef;
|
|
76
|
+
}
|
|
77
|
+
return ElementTemplateUpdateOps.setAttribute;
|
|
78
|
+
}
|
|
68
79
|
//# sourceMappingURL=attr-slots.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,uCAAuC,CAAC;AAS/C,SAAS,uBAAuB,CAAC,QAA4B;IAC3D,IAAI,eAAgD,CAAC;IACrD,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,eAAe,KAAK,QAAQ,CAAC,KAAK,EAAyB,CAAC;QAC5D,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,eAAe,IAAI,QAA+B,CAAC;AAC5D,CAAC;AAED,SAAS,mCAAmC,CAC1C,QAAgB,EAChB,QAA6C,EAC7C,gBAAqC,EACrC,YAAiC;IAEjC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,aAAa,GAAG,QAAQ,CAA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Q,EAAE,CAAC;QACtB,OAAO,wBAAwB,CAAC,gBAAgB,CAAC;IACnD,CAAC;IACD,OAAO,wBAAwB,CAAC,YAAY,CAAC;AAC/C,CAAC"}
|
|
@@ -5,3 +5,12 @@ export declare function resetElementTemplateCommitState(): void;
|
|
|
5
5
|
export declare function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[]): void;
|
|
6
6
|
export declare function cancelElementTemplateRemovedSubtreeCleanup(): void;
|
|
7
7
|
export declare function installElementTemplateCommitHook(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Restores the commit option replaced by
|
|
10
|
+
* {@link installElementTemplateCommitHook} so tests can clean up the global
|
|
11
|
+
* Preact `options` object. Assumes the matching install was the most recent
|
|
12
|
+
* commit-option replacement; the snapshot and ElementTemplate runtimes are
|
|
13
|
+
* separate entrypoints and never install their commit hooks in the same
|
|
14
|
+
* context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function uninstallElementTemplateCommitHookForTesting(): void;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { options } from 'preact';
|
|
5
5
|
import { globalCommitContext, resetGlobalCommitContext, takeRemovedSubtreesForPostDispatchTeardown, } from './commit-context.js';
|
|
6
6
|
import { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';
|
|
7
|
+
import { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';
|
|
7
8
|
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';
|
|
8
9
|
import { getReloadVersion } from '../../core/reload-version.js';
|
|
9
10
|
import { delayedRunOnMainThreadData, takeDelayedRunOnMainThreadData, } from '../../core/thread-function-call/main-thread.js';
|
|
@@ -15,6 +16,7 @@ import { profileEnd, profileStart } from '../debug/profile.js';
|
|
|
15
16
|
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
16
17
|
import { createElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
17
18
|
let installed = false;
|
|
19
|
+
let previousCommit;
|
|
18
20
|
let hasHydrated = false;
|
|
19
21
|
const scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set();
|
|
20
22
|
export function markElementTemplateHydrated() {
|
|
@@ -46,40 +48,40 @@ export function cancelElementTemplateRemovedSubtreeCleanup() {
|
|
|
46
48
|
}
|
|
47
49
|
scheduledRemovedSubtreeCleanupTimers.clear();
|
|
48
50
|
}
|
|
49
|
-
function flushElementTemplateCommitChanges() {
|
|
51
|
+
function flushElementTemplateCommitChanges(mainThreadRefInitValuePatch) {
|
|
50
52
|
const hasNativeOps = globalCommitContext.ops.length > 0;
|
|
51
53
|
const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;
|
|
54
|
+
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
52
55
|
const hasUpdatePayload = hasNativeOps
|
|
53
56
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
54
|
-
|| hasDelayedRunOnMainThread
|
|
57
|
+
|| hasDelayedRunOnMainThread
|
|
58
|
+
|| hasMainThreadRefInitValuePatch;
|
|
55
59
|
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
? takeDelayedRunOnMainThreadData()
|
|
82
|
-
: undefined;
|
|
60
|
+
if (hasUpdatePayload) {
|
|
61
|
+
markTimingLegacy('updateDiffVdomEnd');
|
|
62
|
+
markTiming('diffVdomEnd');
|
|
63
|
+
if (__PROFILE__) {
|
|
64
|
+
profileStart('ReactLynx::commitChanges');
|
|
65
|
+
}
|
|
66
|
+
markTiming('packChangesStart');
|
|
67
|
+
if (globalPipelineOptions) {
|
|
68
|
+
globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;
|
|
69
|
+
}
|
|
70
|
+
markTiming('packChangesEnd');
|
|
71
|
+
if (globalPipelineOptions) {
|
|
72
|
+
setPipeline(undefined);
|
|
73
|
+
}
|
|
74
|
+
if (__PROFILE__) {
|
|
75
|
+
profileEnd();
|
|
76
|
+
}
|
|
77
|
+
if (!hasNativeOps && !hasDelayedRunOnMainThread) {
|
|
78
|
+
globalCommitContext.flushOptions.emptyPatch = true;
|
|
79
|
+
}
|
|
80
|
+
const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread
|
|
81
|
+
? takeDelayedRunOnMainThreadData()
|
|
82
|
+
: undefined;
|
|
83
|
+
let updateEvent;
|
|
84
|
+
try {
|
|
83
85
|
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
84
86
|
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS update:\n'
|
|
85
87
|
+ JSON.stringify({
|
|
@@ -87,41 +89,47 @@ function flushElementTemplateCommitChanges() {
|
|
|
87
89
|
flushOptions: globalCommitContext.flushOptions,
|
|
88
90
|
flowIds: globalCommitContext.flowIds,
|
|
89
91
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
92
|
+
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
90
93
|
}, null, 2));
|
|
91
94
|
}
|
|
92
|
-
|
|
95
|
+
updateEvent = createElementTemplateUpdateEvent({
|
|
93
96
|
ops: globalCommitContext.ops,
|
|
94
97
|
flushOptions: globalCommitContext.flushOptions,
|
|
95
98
|
reloadVersion: getReloadVersion(),
|
|
96
99
|
flowIds: globalCommitContext.flowIds,
|
|
97
100
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
102
|
+
? mainThreadRefInitValuePatch
|
|
103
|
+
: undefined,
|
|
104
|
+
});
|
|
100
105
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
if (delayedRunOnMainThreadPayload && !didDispatchUpdatePayload) {
|
|
108
|
-
dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));
|
|
109
|
-
}
|
|
110
|
-
if (!didFlushRefs) {
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (delayedRunOnMainThreadPayload) {
|
|
108
|
+
dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));
|
|
109
|
+
}
|
|
111
110
|
clearPendingRefs();
|
|
111
|
+
resetGlobalCommitContext();
|
|
112
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
113
|
+
throw error;
|
|
112
114
|
}
|
|
113
|
-
|
|
114
|
-
// Match Snapshot's cleanup boundary: start the delayed teardown only
|
|
115
|
-
// after the bridge dispatch attempt, so background JS objects are not
|
|
116
|
-
// torn down before main-thread detach observes the same commit.
|
|
117
|
-
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
115
|
+
lynx.getCoreContext().dispatchEvent(updateEvent);
|
|
118
116
|
}
|
|
117
|
+
// When native ops exist, patch first so a newly attached ref observes the
|
|
118
|
+
// committed native state. Ref-only commits still flush through this path.
|
|
119
|
+
flushPendingRefs();
|
|
120
|
+
resetGlobalCommitContext();
|
|
121
|
+
// Match Snapshot's cleanup boundary: start the delayed teardown only
|
|
122
|
+
// after the bridge dispatch, so background JS objects are not torn down
|
|
123
|
+
// before main-thread detach observes the same commit.
|
|
124
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
119
125
|
}
|
|
120
126
|
export function installElementTemplateCommitHook() {
|
|
121
127
|
if (installed) {
|
|
122
128
|
return;
|
|
123
129
|
}
|
|
124
130
|
installed = true;
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
132
|
+
previousCommit = options[COMMIT];
|
|
125
133
|
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
126
134
|
if (__BACKGROUND__) {
|
|
127
135
|
clearElementTemplateRenderScope();
|
|
@@ -131,14 +139,38 @@ export function installElementTemplateCommitHook() {
|
|
|
131
139
|
// attached on the background commit even though native UI ops are delayed.
|
|
132
140
|
flushPendingRefs();
|
|
133
141
|
}
|
|
134
|
-
else if (__BACKGROUND__ && hasHydrated
|
|
135
|
-
|
|
142
|
+
else if (__BACKGROUND__ && hasHydrated) {
|
|
143
|
+
const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();
|
|
144
|
+
if (globalCommitContext.ops.length > 0
|
|
136
145
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
137
146
|
|| hasPendingRefs()
|
|
138
|
-
|| delayedRunOnMainThreadData.length > 0
|
|
139
|
-
|
|
147
|
+
|| delayedRunOnMainThreadData.length > 0
|
|
148
|
+
|| mainThreadRefInitValuePatch.length > 0) {
|
|
149
|
+
flushElementTemplateCommitChanges(mainThreadRefInitValuePatch);
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
originalCommit?.(vnode, commitQueue);
|
|
142
153
|
});
|
|
143
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Restores the commit option replaced by
|
|
157
|
+
* {@link installElementTemplateCommitHook} so tests can clean up the global
|
|
158
|
+
* Preact `options` object. Assumes the matching install was the most recent
|
|
159
|
+
* commit-option replacement; the snapshot and ElementTemplate runtimes are
|
|
160
|
+
* separate entrypoints and never install their commit hooks in the same
|
|
161
|
+
* context.
|
|
162
|
+
*/
|
|
163
|
+
export function uninstallElementTemplateCommitHookForTesting() {
|
|
164
|
+
if (!installed) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
installed = false;
|
|
168
|
+
if (previousCommit) {
|
|
169
|
+
options[COMMIT] = previousCommit;
|
|
170
|
+
previousCommit = undefined;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
delete options[COMMIT];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
144
176
|
//# sourceMappingURL=commit-hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAErG,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,gDAAg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;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { render } from 'preact';
|
|
|
2
2
|
import { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';
|
|
3
3
|
import { resetElementTemplateHydrationListener } from './hydration-listener.js';
|
|
4
4
|
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
5
|
+
import { withSyncEffectFlush } from '../../utils.js';
|
|
5
6
|
import { clearEventState } from '../prop-adapters/event.js';
|
|
6
7
|
import { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';
|
|
7
8
|
import { __root } from '../runtime/page/root-instance.js';
|
|
@@ -10,7 +11,9 @@ import { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/templa
|
|
|
10
11
|
export function destroyElementTemplateBackgroundRuntime() {
|
|
11
12
|
resetElementTemplateHydrationListener();
|
|
12
13
|
cancelElementTemplateRemovedSubtreeCleanup();
|
|
13
|
-
|
|
14
|
+
withSyncEffectFlush(() => {
|
|
15
|
+
render(null, __root);
|
|
16
|
+
});
|
|
14
17
|
// Run user cleanup before dropping the backend side tables; after clearRefState
|
|
15
18
|
// the raw ref ownership needed to detach callbacks is gone.
|
|
16
19
|
flushPendingRefs();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,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