@lynx-js/react 0.108.1 → 0.109.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 +16 -0
- package/package.json +2 -2
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/jsx-dev-runtime/index.d.ts +13 -7
- package/runtime/jsx-runtime/index.d.ts +17 -7
- package/runtime/lib/gesture/processGesture.d.ts +2 -2
- package/runtime/lib/gesture/processGesture.js +14 -7
- package/runtime/lib/gesture/processGesture.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js +2 -2
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/gesture.d.ts +1 -1
- package/runtime/lib/snapshot/gesture.js +4 -3
- package/runtime/lib/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/workletEvent.d.ts +1 -1
- package/runtime/lib/snapshot/workletEvent.js +3 -2
- package/runtime/lib/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/workletRef.js +4 -4
- package/runtime/lib/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot.d.ts +1 -0
- package/runtime/lib/snapshot.js +5 -4
- package/runtime/lib/snapshot.js.map +1 -1
- package/runtime/lib/worklet/runOnBackground.js +21 -12
- package/runtime/lib/worklet/runOnBackground.js.map +1 -1
- package/runtime/src/gesture/processGesture.ts +23 -15
- package/runtime/src/lifecycle/patch/snapshotPatchApply.ts +8 -2
- package/runtime/src/snapshot/gesture.ts +6 -4
- package/runtime/src/snapshot/workletEvent.ts +3 -2
- package/runtime/src/snapshot/workletRef.ts +5 -5
- package/runtime/src/snapshot.ts +6 -4
- package/runtime/src/worklet/runOnBackground.ts +37 -15
- package/testing-library/dist/vitest-global-setup.js +7 -0
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +443 -14
- package/types/react.d.ts +1 -1
- package/worklet-runtime/dist/dev.js +137 -49
- package/worklet-runtime/dist/dev.js.map +4 -4
- package/worklet-runtime/dist/main.js +137 -49
- package/worklet-runtime/dist/main.js.map +4 -4
- package/worklet-runtime/lib/api/element.d.ts +3 -3
- package/worklet-runtime/lib/api/element.js +3 -3
- package/worklet-runtime/lib/api/element.js.map +1 -1
- package/worklet-runtime/lib/api/lepusQuerySelector.js +1 -3
- package/worklet-runtime/lib/api/lepusQuerySelector.js.map +1 -1
- package/worklet-runtime/lib/api/lynxApi.js +10 -10
- package/worklet-runtime/lib/api/lynxApi.js.map +1 -1
- package/worklet-runtime/lib/bindings/bindings.d.ts +1 -1
- package/worklet-runtime/lib/bindings/bindings.js +20 -7
- package/worklet-runtime/lib/bindings/bindings.js.map +1 -1
- package/worklet-runtime/lib/bindings/events.d.ts +4 -1
- package/worklet-runtime/lib/bindings/events.js.map +1 -1
- package/worklet-runtime/lib/bindings/index.d.ts +1 -1
- package/worklet-runtime/lib/bindings/index.js +1 -1
- package/worklet-runtime/lib/bindings/index.js.map +1 -1
- package/worklet-runtime/lib/bindings/loadRuntime.js +0 -2
- package/worklet-runtime/lib/bindings/loadRuntime.js.map +1 -1
- package/worklet-runtime/lib/bindings/types.d.ts +8 -2
- package/worklet-runtime/lib/delayRunOnBackground.d.ts +12 -0
- package/worklet-runtime/lib/delayRunOnBackground.js +23 -0
- package/worklet-runtime/lib/delayRunOnBackground.js.map +1 -0
- package/worklet-runtime/lib/delayWorkletEvent.js +2 -2
- package/worklet-runtime/lib/delayWorkletEvent.js.map +1 -1
- package/worklet-runtime/lib/global.d.ts +6 -3
- package/worklet-runtime/lib/hydrate.d.ts +11 -0
- package/worklet-runtime/lib/hydrate.js +86 -0
- package/worklet-runtime/lib/hydrate.js.map +1 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js +2 -2
- package/worklet-runtime/lib/jsFunctionLifecycle.js.map +1 -1
- package/worklet-runtime/lib/listeners.js.map +1 -1
- package/worklet-runtime/lib/utils/profile.d.ts +1 -1
- package/worklet-runtime/lib/utils/version.js +1 -1
- package/worklet-runtime/lib/workletRef.d.ts +6 -3
- package/worklet-runtime/lib/workletRef.js +33 -6
- package/worklet-runtime/lib/workletRef.js.map +1 -1
- package/worklet-runtime/lib/workletRuntime.js +13 -18
- package/worklet-runtime/lib/workletRuntime.js.map +1 -1
- package/worklet-runtime/lib/ctxTrace.d.ts +0 -8
- package/worklet-runtime/lib/ctxTrace.js +0 -13
- package/worklet-runtime/lib/ctxTrace.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lynxApi.js","sourceRoot":"","sources":["../../src/api/lynxApi.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,SAAS,UAAU;IACjB,
|
|
1
|
+
{"version":3,"file":"lynxApi.js","sourceRoot":"","sources":["../../src/api/lynxApi.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,SAAS,UAAU;IACjB,wBAAwB;IACxB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACnC,wBAAwB;IACxB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IACzC,wBAAwB;IACxB,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,UAAyD,CAAC;IACvF,wBAAwB;IACxB,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAA0D,CAAC;IACzF,wBAAwB;IACxB,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,YAAyC,CAAC;IACzE,yGAAyG;IACzG,wBAAwB;IACxB,UAAU,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,iBAAiB,CAA8B,CAAC;IAEvG,CAAC;QACC,wBAAwB;QACxB,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAyD,CAAC;QAC7F,wBAAwB;QACxB,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,qBAAqB,GAAG,CAC9D,QAAoB,EACpB,EAAE;YACF,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;YACJ,CAAC;YACD,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAmD,CAAC;AAC7F,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -11,4 +11,4 @@ declare function runWorkletCtx(worklet: Worklet, params: ClosureValueType[]): un
|
|
|
11
11
|
* @param patch - An array containing the index and new value of the worklet value.
|
|
12
12
|
*/
|
|
13
13
|
declare function updateWorkletRefInitValueChanges(patch?: [number, unknown][]): void;
|
|
14
|
-
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, registerWorklet, };
|
|
14
|
+
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, registerWorklet, delayRunOnBackground, };
|
|
@@ -2,15 +2,19 @@
|
|
|
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
|
/**
|
|
5
|
-
*
|
|
6
|
-
* This function mast be called when a worklet context is updated.
|
|
5
|
+
* This function must be called when a worklet context is updated.
|
|
7
6
|
*
|
|
8
7
|
* @param worklet - The worklet to be updated
|
|
9
|
-
* @param
|
|
8
|
+
* @param oldWorklet - The old worklet context
|
|
9
|
+
* @param isFirstScreen - Whether it is before the hydration is finished
|
|
10
|
+
* @param element - The element
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
|
-
function onWorkletCtxUpdate(worklet, element) {
|
|
13
|
+
function onWorkletCtxUpdate(worklet, oldWorklet, isFirstScreen, element) {
|
|
13
14
|
globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager?.addRef(worklet._execId, worklet);
|
|
15
|
+
if (isFirstScreen && oldWorklet) {
|
|
16
|
+
globalThis.lynxWorkletImpl?._hydrateCtx(worklet, oldWorklet);
|
|
17
|
+
}
|
|
14
18
|
globalThis.lynxWorkletImpl?._eventDelayImpl.runDelayedWorklet(worklet, element);
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
@@ -42,12 +46,13 @@ function updateWorkletRefInitValueChanges(patch) {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* This must be called when the hydration is finished.
|
|
46
50
|
*
|
|
47
51
|
* @internal
|
|
48
52
|
*/
|
|
49
53
|
function onHydrationFinished() {
|
|
50
|
-
globalThis.lynxWorkletImpl?.
|
|
54
|
+
globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl.runDelayedBackgroundFunctions();
|
|
55
|
+
globalThis.lynxWorkletImpl?._refImpl.clearFirstScreenWorkletRefMap();
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
53
58
|
* Register a worklet.
|
|
@@ -57,5 +62,13 @@ function onHydrationFinished() {
|
|
|
57
62
|
function registerWorklet(type, id, worklet) {
|
|
58
63
|
globalThis.registerWorklet(type, id, worklet);
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Delay a runOnBackground after hydration.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
function delayRunOnBackground(fnObj, fn) {
|
|
71
|
+
globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl.delayRunOnBackground(fnObj, fn);
|
|
72
|
+
}
|
|
73
|
+
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, registerWorklet, delayRunOnBackground, };
|
|
61
74
|
//# sourceMappingURL=bindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/bindings/bindings.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/bindings/bindings.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAK1D;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CACzB,OAAgB,EAChB,UAAsC,EACtC,aAAsB,EACtB,OAAoB;IAEpB,UAAU,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC,OAAO,CAAC,OAAQ,EAAE,OAAO,CAAC,CAAC;IAC3F,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;QAChC,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;IACD,UAAU,CAAC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAAgB,EAAE,MAA0B;IACjE,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,UAAmC,EAAE,OAA2B;IACxF,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED;;;;GAIG;AACH,SAAS,gCAAgC,CAAC,KAA2B;IACnE,IAAI,KAAK,EAAE,CAAC;QACV,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB;IAC1B,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,6BAA6B,EAAE,CAAC;IACtF,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,6BAA6B,EAAE,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAY,EAAE,EAAU,EAAE,OAAwC;IACzF,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAiB,EAAE,EAA0C;IACzF,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxF,CAAC;AAED,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,gCAAgC,EAChC,mBAAmB,EACnB,eAAe,EACf,oBAAoB,GACrB,CAAC"}
|
|
@@ -15,4 +15,7 @@ interface RunWorkletCtxRetData {
|
|
|
15
15
|
resolveId: number;
|
|
16
16
|
returnValue: unknown;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
interface ReleaseWorkletRefData {
|
|
19
|
+
id: number;
|
|
20
|
+
}
|
|
21
|
+
export { WorkletEvents, type RunWorkletCtxData, type RunWorkletCtxRetData, type ReleaseWorkletRefData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/bindings/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/bindings/events.ts"],"names":[],"mappings":"AAKA,IAAW,aAMV;AAND,WAAW,aAAa;IACtB,6DAA4C,CAAA;IAC5C,iEAAgD,CAAA;IAChD,iEAAgD,CAAA;IAChD,yFAAwE,CAAA;IACxE,qEAAoD,CAAA;AACtD,CAAC,EANU,aAAa,KAAb,aAAa,QAMvB;AAiBD,OAAO,EAAE,aAAa,EAAiF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { loadWorkletRuntime } from './loadRuntime.js';
|
|
2
|
-
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, } from './bindings.js';
|
|
2
|
+
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, delayRunOnBackground, } from './bindings.js';
|
|
3
3
|
export type * from './types.js';
|
|
4
4
|
export { WorkletEvents, type RunWorkletCtxData, type RunWorkletCtxRetData } from './events.js';
|
|
@@ -2,6 +2,6 @@
|
|
|
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
|
export { loadWorkletRuntime } from './loadRuntime.js';
|
|
5
|
-
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, } from './bindings.js';
|
|
5
|
+
export { onWorkletCtxUpdate, runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, onHydrationFinished, delayRunOnBackground, } from './bindings.js';
|
|
6
6
|
export { WorkletEvents } from './events.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bindings/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,gCAAgC,EAChC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bindings/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,gCAAgC,EAChC,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,aAAa,EAAqD,MAAM,aAAa,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
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
|
-
/// <reference path="../types/elementApi.d.ts" />
|
|
5
4
|
import '../global.js';
|
|
6
5
|
/**
|
|
7
6
|
* Loads and initializes the Lepus chunk in the main thread.
|
|
@@ -16,7 +15,6 @@ function loadWorkletRuntime(__schema) {
|
|
|
16
15
|
return true;
|
|
17
16
|
}
|
|
18
17
|
return __LoadLepusChunk('worklet-runtime', {
|
|
19
|
-
// @ts-ignore
|
|
20
18
|
dynamicComponentEntry: __schema,
|
|
21
19
|
chunkType: 0,
|
|
22
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRuntime.js","sourceRoot":"","sources":["../../src/bindings/loadRuntime.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,
|
|
1
|
+
{"version":3,"file":"loadRuntime.js","sourceRoot":"","sources":["../../src/bindings/loadRuntime.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,cAAc,CAAC;AAEtB;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,QAAiB;IAC3C,IAAI,OAAO,gBAAgB,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,gBAAgB,CAAC,iBAAiB,EAAE;QACzC,qBAAqB,EAAE,QAAQ;QAC/B,SAAS,EAAE,CAAC;KACb,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -22,18 +22,24 @@ export interface Worklet {
|
|
|
22
22
|
_wkltId: string;
|
|
23
23
|
_workletType?: string;
|
|
24
24
|
_c?: Record<string, ClosureValueType>;
|
|
25
|
-
_lepusWorkletHash?: string;
|
|
26
25
|
_execId?: number;
|
|
27
26
|
_jsFn?: Record<string, string>;
|
|
28
27
|
_unmount?: () => void;
|
|
29
28
|
[key: string]: ClosureValueType;
|
|
29
|
+
_lepusWorkletHash?: string;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
34
|
export interface JsFnHandle {
|
|
35
|
-
_jsFnId
|
|
35
|
+
_jsFnId?: number;
|
|
36
36
|
_fn?: (...args: unknown[]) => unknown;
|
|
37
37
|
_execId?: number;
|
|
38
38
|
_error?: string;
|
|
39
|
+
_isFirstScreen?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Stores an array of indexes of runOnBackground tasks that should be processed with a delay.
|
|
42
|
+
* This is used before hydration.
|
|
43
|
+
*/
|
|
44
|
+
_delayIndices?: number[];
|
|
39
45
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JsFnHandle } from './bindings/types.js';
|
|
2
|
+
interface Details {
|
|
3
|
+
task: (fnId: number, execId: number) => void;
|
|
4
|
+
jsFnHandle?: JsFnHandle;
|
|
5
|
+
}
|
|
6
|
+
interface RunOnBackgroundDelayImpl {
|
|
7
|
+
delayedBackgroundFunctionArray: Details[];
|
|
8
|
+
delayRunOnBackground(fnObj: JsFnHandle, fn: (fnId: number, execId: number) => void): void;
|
|
9
|
+
runDelayedBackgroundFunctions(): void;
|
|
10
|
+
}
|
|
11
|
+
declare function initRunOnBackgroundDelay(): RunOnBackgroundDelayImpl;
|
|
12
|
+
export { type RunOnBackgroundDelayImpl, initRunOnBackgroundDelay };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
let impl;
|
|
2
|
+
function initRunOnBackgroundDelay() {
|
|
3
|
+
return (impl = {
|
|
4
|
+
delayedBackgroundFunctionArray: [],
|
|
5
|
+
delayRunOnBackground,
|
|
6
|
+
runDelayedBackgroundFunctions,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function delayRunOnBackground(fnObj, task) {
|
|
10
|
+
impl.delayedBackgroundFunctionArray.push({ task });
|
|
11
|
+
const delayIndices = fnObj._delayIndices ??= [];
|
|
12
|
+
delayIndices.push(impl.delayedBackgroundFunctionArray.length - 1);
|
|
13
|
+
}
|
|
14
|
+
function runDelayedBackgroundFunctions() {
|
|
15
|
+
for (const details of impl.delayedBackgroundFunctionArray) {
|
|
16
|
+
if (details.jsFnHandle) {
|
|
17
|
+
details.task(details.jsFnHandle._jsFnId, details.jsFnHandle._execId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
impl.delayedBackgroundFunctionArray.length = 0;
|
|
21
|
+
}
|
|
22
|
+
export { initRunOnBackgroundDelay };
|
|
23
|
+
//# sourceMappingURL=delayRunOnBackground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delayRunOnBackground.js","sourceRoot":"","sources":["../src/delayRunOnBackground.ts"],"names":[],"mappings":"AAmBA,IAAI,IAA0C,CAAC;AAE/C,SAAS,wBAAwB;IAC/B,OAAO,CAAC,IAAI,GAAG;QACb,8BAA8B,EAAE,EAAE;QAClC,oBAAoB;QACpB,6BAA6B;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAiB,EAAE,IAA4C;IAC3F,IAAK,CAAC,8BAA8B,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,KAAK,EAAE,CAAC;IAChD,YAAY,CAAC,IAAI,CAAC,IAAK,CAAC,8BAA8B,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,6BAA6B;IACpC,KAAK,MAAM,OAAO,IAAI,IAAK,CAAC,8BAA8B,EAAE,CAAC;QAC3D,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAQ,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IACD,IAAK,CAAC,8BAA8B,CAAC,MAAM,GAAG,CAAC,CAAC;AAClD,CAAC;AAED,OAAO,EAAiC,wBAAwB,EAAE,CAAC"}
|
|
@@ -27,8 +27,8 @@ function runDelayedWorklet(worklet, element) {
|
|
|
27
27
|
}
|
|
28
28
|
const leftParamsVec = [];
|
|
29
29
|
paramsVec.forEach((params) => {
|
|
30
|
-
|
|
31
|
-
if (
|
|
30
|
+
const firstParam = params[0];
|
|
31
|
+
if (firstParam?.currentTarget?.elementRefptr === element) {
|
|
32
32
|
setTimeout(() => {
|
|
33
33
|
profile('runDelayedWorklet', () => {
|
|
34
34
|
runWorklet(worklet, params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delayWorkletEvent.js","sourceRoot":"","sources":["../src/delayWorkletEvent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAQ7C,IAAI,IAAgC,CAAC;AAErC,SAAS,cAAc;IACrB,OAAO,CAAC,IAAI,GAAG;QACb,wBAAwB,EAAE,IAAI,GAAG,EAAE;QACnC,iBAAiB;QACjB,oBAAoB;KACrB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAC5B,IAAY,EACZ,MAA0B;IAE1B,OAAO,CAAC,yBAAyB,GAAG,IAAI,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EAAE,iBAAiB,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { ClosureValueType, Worklet } from './bindings/types.js';
|
|
2
|
+
import type { RunOnBackgroundDelayImpl } from './delayRunOnBackground.js';
|
|
2
3
|
import type { EventDelayImpl } from './delayWorkletEvent.js';
|
|
3
4
|
import type { JsFunctionLifecycleManager } from './jsFunctionLifecycle.js';
|
|
4
5
|
import type { RefImpl } from './workletRef.js';
|
|
5
6
|
declare global {
|
|
6
7
|
var lynxWorkletImpl: {
|
|
7
|
-
_workletMap: Record<string, (...args:
|
|
8
|
+
_workletMap: Record<string, (...args: unknown[]) => unknown>;
|
|
8
9
|
_jsFunctionLifecycleManager?: JsFunctionLifecycleManager;
|
|
9
10
|
_eventDelayImpl: EventDelayImpl;
|
|
10
11
|
_refImpl: RefImpl;
|
|
12
|
+
_runOnBackgroundDelayImpl: RunOnBackgroundDelayImpl;
|
|
13
|
+
_hydrateCtx: (worklet: Worklet, firstScreenWorklet: Worklet) => void;
|
|
11
14
|
};
|
|
12
15
|
function runWorklet(ctx: Worklet, params: ClosureValueType[]): unknown;
|
|
13
|
-
function registerWorklet(type: string, id: string, worklet: (...args:
|
|
14
|
-
function registerWorkletInternal(type: string, id: string, worklet: (...args:
|
|
16
|
+
function registerWorklet(type: string, id: string, worklet: (...args: unknown[]) => unknown): void;
|
|
17
|
+
function registerWorkletInternal(type: string, id: string, worklet: (...args: unknown[]) => unknown): void;
|
|
15
18
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Worklet } from './bindings/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hydrates a Worklet context with data from a first-screen Worklet context.
|
|
4
|
+
* This process is typically used to run all delayed `runOnBackground` functions
|
|
5
|
+
* and initialize `WorkletRef` values modified before hydration.
|
|
6
|
+
*
|
|
7
|
+
* @param ctx The target Worklet context to be hydrated.
|
|
8
|
+
* @param firstScreenCtx The Worklet context from the first screen rendering,
|
|
9
|
+
* containing the data to hydrate with.
|
|
10
|
+
*/
|
|
11
|
+
export declare function hydrateCtx(ctx: Worklet, firstScreenCtx: Worklet): void;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2024 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 { Element } from './api/element.js';
|
|
5
|
+
import { profile } from './utils/profile.js';
|
|
6
|
+
/**
|
|
7
|
+
* Hydrates a Worklet context with data from a first-screen Worklet context.
|
|
8
|
+
* This process is typically used to run all delayed `runOnBackground` functions
|
|
9
|
+
* and initialize `WorkletRef` values modified before hydration.
|
|
10
|
+
*
|
|
11
|
+
* @param ctx The target Worklet context to be hydrated.
|
|
12
|
+
* @param firstScreenCtx The Worklet context from the first screen rendering,
|
|
13
|
+
* containing the data to hydrate with.
|
|
14
|
+
*/
|
|
15
|
+
export function hydrateCtx(ctx, firstScreenCtx) {
|
|
16
|
+
profile('hydrateCtx', () => {
|
|
17
|
+
hydrateCtxImpl(ctx, firstScreenCtx, ctx._execId);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function hydrateCtxImpl(ctx, firstScreenCtx, execId) {
|
|
21
|
+
if (!ctx || typeof ctx !== 'object' || !firstScreenCtx || typeof firstScreenCtx !== 'object')
|
|
22
|
+
return;
|
|
23
|
+
const ctxObj = ctx;
|
|
24
|
+
const firstScreenCtxObj = firstScreenCtx;
|
|
25
|
+
if (ctxObj['_wkltId'] && ctxObj['_wkltId'] !== firstScreenCtxObj['_wkltId']) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-for-in-array
|
|
29
|
+
for (const key in ctx) {
|
|
30
|
+
if (key === '_wvid') {
|
|
31
|
+
hydrateMainThreadRef(ctxObj[key], firstScreenCtxObj);
|
|
32
|
+
}
|
|
33
|
+
else if (key === '_jsFn') {
|
|
34
|
+
hydrateDelayRunOnBackgroundTasks(ctxObj[key], firstScreenCtxObj[key], execId);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const firstScreenValue = typeof firstScreenCtxObj[key] === 'function'
|
|
38
|
+
? firstScreenCtxObj[key].ctx
|
|
39
|
+
: firstScreenCtxObj[key];
|
|
40
|
+
hydrateCtxImpl(ctxObj[key], firstScreenValue, execId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hydrates a WorkletRef on the main thread.
|
|
46
|
+
* This is used to update the WorkletRef's background initial value based on changes
|
|
47
|
+
* that occurred in the first-screen Worklet context before hydration.
|
|
48
|
+
*
|
|
49
|
+
* @param refId The ID of the WorkletRef to hydrate.
|
|
50
|
+
* @param value The new value for the WorkletRef.
|
|
51
|
+
*/
|
|
52
|
+
function hydrateMainThreadRef(refId, value) {
|
|
53
|
+
if ('_initValue' in value) {
|
|
54
|
+
// The ref has not been accessed yet.
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const ref = lynxWorkletImpl._refImpl._workletRefMap[refId];
|
|
58
|
+
if (ref.current instanceof Element) {
|
|
59
|
+
// Modified by `main-thread:ref`
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
ref.current = value.current;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Hydrates delayed `runOnBackground` tasks.
|
|
66
|
+
* This function ensures that any `runOnBackground` calls that were delayed
|
|
67
|
+
* during the first-screen rendering are correctly associated with their
|
|
68
|
+
* respective JavaScript function handles in the hydrated Worklet context.
|
|
69
|
+
*/
|
|
70
|
+
function hydrateDelayRunOnBackgroundTasks(fnObjs, // example: {"_jsFn1":{"_jsFnId":1}}
|
|
71
|
+
firstScreenFnObjs, // example: {"_jsFn1":{"_isFirstScreen":true,"_delayIndices":[0]}}
|
|
72
|
+
execId) {
|
|
73
|
+
for (const fnName in fnObjs) {
|
|
74
|
+
const fnObj = fnObjs[fnName];
|
|
75
|
+
const firstScreenFnObj = firstScreenFnObjs[fnName];
|
|
76
|
+
if (!firstScreenFnObj?._delayIndices) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
for (const index of firstScreenFnObj._delayIndices) {
|
|
80
|
+
const details = lynxWorkletImpl._runOnBackgroundDelayImpl.delayedBackgroundFunctionArray[index];
|
|
81
|
+
fnObj._execId = execId;
|
|
82
|
+
details.jsFnHandle = fnObj;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=hydrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.js","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY,EAAE,cAAuB;IAC9D,OAAO,CAAC,YAAY,EAAE,GAAG,EAAE;QACzB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,OAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAqB,EAAE,cAAgC,EAAE,MAAc;IAC7F,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ;QAAE,OAAO;IAErG,MAAM,MAAM,GAAG,GAAuC,CAAC;IACvD,MAAM,iBAAiB,GAAG,cAAkD,CAAC;IAE7E,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5E,OAAO;IACT,CAAC;IA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,CAAE,CAAC;QAC9B,MAAM,gBAAgB,GAA2B,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,gBAAgB,EAAE,aAAa,EAAE,CAAC;YACrC,SAAS;QACX,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,aAAa,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,eAAgB,CAAC,yBAAyB,CAAC,8BAA8B,CAAC,KAAK,CAAE,CAAC;YAClG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;YACvB,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -19,7 +19,7 @@ class JsFunctionLifecycleManager {
|
|
|
19
19
|
this.registry = new FinalizationRegistry(this.removeRef.bind(this));
|
|
20
20
|
}
|
|
21
21
|
addRef(execId, objToRef) {
|
|
22
|
-
this.execIdRefCount.set(execId, (this.execIdRefCount.get(execId)
|
|
22
|
+
this.execIdRefCount.set(execId, (this.execIdRefCount.get(execId) ?? 0) + 1);
|
|
23
23
|
this.registry.register(objToRef, execId);
|
|
24
24
|
}
|
|
25
25
|
removeRef(execId) {
|
|
@@ -32,7 +32,7 @@ class JsFunctionLifecycleManager {
|
|
|
32
32
|
this.execIdSetToFire.add(execId);
|
|
33
33
|
if (!this.willFire) {
|
|
34
34
|
this.willFire = true;
|
|
35
|
-
Promise.resolve().then(() => {
|
|
35
|
+
void Promise.resolve().then(() => {
|
|
36
36
|
this.fire();
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsFunctionLifecycle.js","sourceRoot":"","sources":["../src/jsFunctionLifecycle.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC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YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,IAAI;QACF,OAAO,CAAC,iCAAiC,EAAE,GAAG,EAAE;YAC9C,IAAI,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC;gBAChC,IAAI,EAAE,aAAa,CAAC,2BAA2B;gBAC/C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aACvC,CAAC,CAAC;YACH,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,wBAAwB;IAC/B,OAAO,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.js","sourceRoot":"","sources":["../src/listeners.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"listeners.js","sourceRoot":"","sources":["../src/listeners.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,SAAS,kBAAkB;IACzB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACtC,SAAS,CAAC,gBAAgB,CACxB,aAAa,CAAC,aAAa,EAC3B,CAAC,KAAY,EAAE,EAAE;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAc,CAAsB,CAAC;QACnE,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAA4B,CAAC,CAAC;QAChF,SAAS,CAAC,aAAa,CAAC;YACtB,IAAI,EAAE,aAAa,CAAC,eAAe;YACnC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,WAAW;aACY,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC,CACF,CAAC;IACF,SAAS,CAAC,gBAAgB,CACxB,aAAa,CAAC,iBAAiB,EAC/B,CAAC,KAAY,EAAE,EAAE;QACf,4BAA4B,CAAE,KAAK,CAAC,IAA8B,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC,CACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function profile<Ret, Fn extends (...args:
|
|
1
|
+
export declare function profile<Ret, Fn extends (...args: unknown[]) => Ret>(sliceName: string, f: Fn): Ret;
|
|
@@ -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
|
export function isSdkVersionGt(major, minor) {
|
|
5
|
-
const lynxSdkVersion = SystemInfo.lynxSdkVersion
|
|
5
|
+
const lynxSdkVersion = SystemInfo.lynxSdkVersion ?? '1.0';
|
|
6
6
|
const version = lynxSdkVersion.split('.');
|
|
7
7
|
return (Number(version[0]) > major
|
|
8
8
|
|| (Number(version[0]) == major && Number(version[1]) > minor));
|
|
@@ -2,11 +2,14 @@ import { Element } from './api/element.js';
|
|
|
2
2
|
import type { WorkletRef, WorkletRefId, WorkletRefImpl } from './bindings/types.js';
|
|
3
3
|
interface RefImpl {
|
|
4
4
|
_workletRefMap: Record<WorkletRefId, WorkletRef<unknown>>;
|
|
5
|
-
|
|
5
|
+
_firstScreenWorkletRefMap: Record<WorkletRefId, WorkletRef<unknown>>;
|
|
6
|
+
updateWorkletRef(refImpl: WorkletRefImpl<Element | null>, element: ElementNode | null): void;
|
|
6
7
|
updateWorkletRefInitValueChanges(patch: [number, unknown][]): void;
|
|
8
|
+
clearFirstScreenWorkletRefMap(): void;
|
|
7
9
|
}
|
|
8
10
|
declare function initWorkletRef(): RefImpl;
|
|
9
|
-
declare const
|
|
11
|
+
declare const createWorkletRef: <T>(id: WorkletRefId, value: T) => WorkletRef<T>;
|
|
12
|
+
declare const getFromWorkletRefMap: <T>(refImpl: WorkletRefImpl<T>) => WorkletRef<T>;
|
|
10
13
|
declare function removeValueFromWorkletRefMap(id: WorkletRefId): void;
|
|
11
14
|
declare function updateWorkletRefInitValueChanges(patch: [WorkletRefId, unknown][]): void;
|
|
12
|
-
export { type RefImpl, initWorkletRef, getFromWorkletRefMap, removeValueFromWorkletRefMap, updateWorkletRefInitValueChanges, };
|
|
15
|
+
export { type RefImpl, createWorkletRef, initWorkletRef, getFromWorkletRefMap, removeValueFromWorkletRefMap, updateWorkletRefInitValueChanges, };
|
|
@@ -7,8 +7,16 @@ let impl;
|
|
|
7
7
|
function initWorkletRef() {
|
|
8
8
|
return (impl = {
|
|
9
9
|
_workletRefMap: {},
|
|
10
|
+
/**
|
|
11
|
+
* Map of worklet refs that are created during first screen rendering.
|
|
12
|
+
* These refs are created with negative IDs and need to be hydrated
|
|
13
|
+
* when the app starts. The map is cleared after hydration is complete
|
|
14
|
+
* to free up memory.
|
|
15
|
+
*/
|
|
16
|
+
_firstScreenWorkletRefMap: {},
|
|
10
17
|
updateWorkletRef,
|
|
11
18
|
updateWorkletRefInitValueChanges,
|
|
19
|
+
clearFirstScreenWorkletRefMap,
|
|
12
20
|
});
|
|
13
21
|
}
|
|
14
22
|
const createWorkletRef = (id, value) => {
|
|
@@ -17,8 +25,22 @@ const createWorkletRef = (id, value) => {
|
|
|
17
25
|
_wvid: id,
|
|
18
26
|
};
|
|
19
27
|
};
|
|
20
|
-
const getFromWorkletRefMap = (
|
|
21
|
-
const
|
|
28
|
+
const getFromWorkletRefMap = (refImpl) => {
|
|
29
|
+
const id = refImpl._wvid;
|
|
30
|
+
let value;
|
|
31
|
+
if (id < 0) {
|
|
32
|
+
// At the first screen rendering, the worklet ref is created with a negative ID.
|
|
33
|
+
// Might be called in two scenarios:
|
|
34
|
+
// 1. In MTS events
|
|
35
|
+
// 2. In `main-thread:ref`
|
|
36
|
+
value = impl._firstScreenWorkletRefMap[id];
|
|
37
|
+
if (!value) {
|
|
38
|
+
value = impl._firstScreenWorkletRefMap[id] = createWorkletRef(id, refImpl._initValue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
value = impl._workletRefMap[id];
|
|
43
|
+
}
|
|
22
44
|
/* v8 ignore next 3 */
|
|
23
45
|
if (__DEV__ && value === undefined) {
|
|
24
46
|
throw new Error('Worklet: ref is not initialized: ' + id);
|
|
@@ -29,22 +51,27 @@ function removeValueFromWorkletRefMap(id) {
|
|
|
29
51
|
delete impl._workletRefMap[id];
|
|
30
52
|
}
|
|
31
53
|
/**
|
|
32
|
-
* Create an element instance of the given element node, then set worklet value to it.
|
|
54
|
+
* Create an element instance of the given element node, then set the worklet value to it.
|
|
33
55
|
* This is called in `snapshotContextUpdateWorkletRef`.
|
|
34
56
|
* @param handle handle of the worklet value.
|
|
35
57
|
* @param element the element node.
|
|
36
58
|
*/
|
|
37
59
|
function updateWorkletRef(handle, element) {
|
|
38
|
-
getFromWorkletRefMap(handle
|
|
60
|
+
getFromWorkletRefMap(handle).current = element
|
|
39
61
|
? new Element(element)
|
|
40
62
|
: null;
|
|
41
63
|
}
|
|
42
64
|
function updateWorkletRefInitValueChanges(patch) {
|
|
43
65
|
profile('updateWorkletRefInitValueChanges', () => {
|
|
44
66
|
patch.forEach(([id, value]) => {
|
|
45
|
-
impl._workletRefMap[id]
|
|
67
|
+
if (!impl._workletRefMap[id]) {
|
|
68
|
+
impl._workletRefMap[id] = createWorkletRef(id, value);
|
|
69
|
+
}
|
|
46
70
|
});
|
|
47
71
|
});
|
|
48
72
|
}
|
|
49
|
-
|
|
73
|
+
function clearFirstScreenWorkletRefMap() {
|
|
74
|
+
impl._firstScreenWorkletRefMap = {};
|
|
75
|
+
}
|
|
76
|
+
export { createWorkletRef, initWorkletRef, getFromWorkletRefMap, removeValueFromWorkletRefMap, updateWorkletRefInitValueChanges, };
|
|
50
77
|
//# sourceMappingURL=workletRef.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workletRef.js","sourceRoot":"","sources":["../src/workletRef.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"workletRef.js","sourceRoot":"","sources":["../src/workletRef.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAa7C,IAAI,IAAyB,CAAC;AAE9B,SAAS,cAAc;IACrB,OAAO,CAAC,IAAI,GAAG;QACb,cAAc,EAAE,EAAE;QAClB;;;;;WAKG;QACH,yBAAyB,EAAE,EAAE;QAC7B,gBAAgB;QAChB,gCAAgC;QAChC,6BAA6B;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,gBAAgB,GAAG,CACvB,EAAgB,EAChB,KAAQ,EACO,EAAE;IACjB,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,EAAE;KACV,CAAC;AACJ,CAAC,CAAC;AAEF,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AC,EAAE,CAAC,EAAE,CAAC;gBAC9B,IAAK,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,6BAA6B;IACpC,IAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC;AACvC,CAAC;AAED,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,4BAA4B,EAC5B,gCAAgC,GACjC,CAAC"}
|
|
@@ -2,16 +2,19 @@
|
|
|
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 { Element } from './api/element.js';
|
|
5
|
-
import {
|
|
5
|
+
import { initRunOnBackgroundDelay } from './delayRunOnBackground.js';
|
|
6
6
|
import { delayExecUntilJsReady, initEventDelay } from './delayWorkletEvent.js';
|
|
7
|
+
import { hydrateCtx } from './hydrate.js';
|
|
7
8
|
import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from './jsFunctionLifecycle.js';
|
|
8
9
|
import { profile } from './utils/profile.js';
|
|
9
10
|
import { getFromWorkletRefMap, initWorkletRef } from './workletRef.js';
|
|
10
11
|
function initWorklet() {
|
|
11
12
|
globalThis.lynxWorkletImpl = {
|
|
12
13
|
_workletMap: {},
|
|
13
|
-
_eventDelayImpl: initEventDelay(),
|
|
14
14
|
_refImpl: initWorkletRef(),
|
|
15
|
+
_runOnBackgroundDelayImpl: initRunOnBackgroundDelay(),
|
|
16
|
+
_hydrateCtx: hydrateCtx,
|
|
17
|
+
_eventDelayImpl: initEventDelay(),
|
|
15
18
|
};
|
|
16
19
|
if (isRunOnBackgroundEnabled()) {
|
|
17
20
|
globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();
|
|
@@ -48,15 +51,9 @@ function runWorklet(ctx, params) {
|
|
|
48
51
|
return runWorkletImpl(ctx, params);
|
|
49
52
|
}
|
|
50
53
|
function runWorkletImpl(ctx, params) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const params_ = profile('transformWorkletParams', () => transformWorklet(params || [], false));
|
|
55
|
-
return profile('runWorklet', () => worklet(...params_));
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
clearCurrentCtx();
|
|
59
|
-
}
|
|
54
|
+
const worklet = profile('transformWorkletCtx ' + ctx._wkltId, () => transformWorklet(ctx, true));
|
|
55
|
+
const params_ = profile('transformWorkletParams', () => transformWorklet(params || [], false));
|
|
56
|
+
return profile('runWorklet', () => worklet(...params_));
|
|
60
57
|
}
|
|
61
58
|
function validateWorklet(ctx) {
|
|
62
59
|
return typeof ctx === 'object' && ctx !== null && ('_wkltId' in ctx || '_lepusWorkletHash' in ctx);
|
|
@@ -80,17 +77,17 @@ function transformWorklet(ctx, isWorklet) {
|
|
|
80
77
|
}
|
|
81
78
|
return worklet.main;
|
|
82
79
|
}
|
|
83
|
-
const transformWorkletInner = (
|
|
80
|
+
const transformWorkletInner = (value, depth, ctx) => {
|
|
84
81
|
const limit = 1000;
|
|
85
82
|
if (++depth >= limit) {
|
|
86
83
|
throw new Error('Depth of value exceeds limit of ' + limit + '.');
|
|
87
84
|
}
|
|
88
85
|
/* v8 ignore next 3 */
|
|
89
|
-
if (typeof
|
|
86
|
+
if (typeof value !== 'object' || value === null) {
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
89
|
+
const obj = value;
|
|
92
90
|
for (const key in obj) {
|
|
93
|
-
// @ts-ignore
|
|
94
91
|
const subObj = obj[key];
|
|
95
92
|
if (typeof subObj !== 'object' || subObj === null) {
|
|
96
93
|
continue;
|
|
@@ -100,23 +97,21 @@ const transformWorkletInner = (obj, depth, ctx) => {
|
|
|
100
97
|
transformWorkletInner(subObj, depth, ctx);
|
|
101
98
|
}
|
|
102
99
|
if (isEventTarget) {
|
|
103
|
-
// @ts-ignore
|
|
104
100
|
obj[key] = new Element(subObj['elementRefptr']);
|
|
105
101
|
continue;
|
|
106
102
|
}
|
|
107
103
|
const isWorkletRef = '_wvid' in subObj;
|
|
108
104
|
if (isWorkletRef) {
|
|
109
|
-
|
|
110
|
-
obj[key] = getFromWorkletRefMap(subObj._wvid);
|
|
105
|
+
obj[key] = getFromWorkletRefMap(subObj);
|
|
111
106
|
continue;
|
|
112
107
|
}
|
|
113
108
|
const isWorklet = '_wkltId' in subObj;
|
|
114
109
|
if (isWorklet) {
|
|
115
110
|
// `subObj` is worklet ctx. Shallow copy it to prevent the transformed worklet from referencing ctx.
|
|
116
111
|
// This would result in the value of `workletCache` referencing its key.
|
|
117
|
-
// @ts-ignore
|
|
118
112
|
obj[key] = lynxWorkletImpl._workletMap[subObj._wkltId]
|
|
119
113
|
.bind({ ...subObj });
|
|
114
|
+
obj[key].ctx = subObj;
|
|
120
115
|
continue;
|
|
121
116
|
}
|
|
122
117
|
const isJsFn = '_jsFnId' in subObj;
|