@lynx-js/react 0.121.0 → 0.121.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 +34 -0
- package/package.json +5 -5
- package/runtime/lazy/element-template-import.js +73 -0
- package/runtime/lazy/import.js +4 -0
- package/runtime/lazy/target.js +23 -0
- package/runtime/lib/core/commit-context.d.ts +8 -0
- package/runtime/lib/core/commit-context.js +18 -0
- package/runtime/lib/core/commit-context.js.map +1 -0
- package/runtime/lib/{snapshot/legacy-react-runtime/index.d.ts → core/compat/legacy-react-runtime.d.ts} +4 -4
- package/runtime/lib/{snapshot/legacy-react-runtime/index.js → core/compat/legacy-react-runtime.js} +6 -6
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -0
- package/runtime/lib/{snapshot → core}/compat/lynxComponent.d.ts +2 -1
- package/runtime/lib/{snapshot → core}/compat/lynxComponent.js +11 -5
- package/runtime/lib/core/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/core/component.d.ts +2 -0
- package/runtime/lib/core/component.js +79 -0
- package/runtime/lib/core/component.js.map +1 -0
- package/runtime/lib/core/forceRootRender.d.ts +7 -0
- package/runtime/lib/core/forceRootRender.js +40 -0
- package/runtime/lib/core/forceRootRender.js.map +1 -0
- package/runtime/lib/core/globalProps.d.ts +31 -0
- package/runtime/lib/core/globalProps.js +55 -0
- package/runtime/lib/core/globalProps.js.map +1 -0
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
- package/runtime/lib/{snapshot/compat → core}/initData.d.ts +1 -1
- package/runtime/lib/{snapshot/compat → core}/initData.js +4 -5
- package/runtime/lib/core/initData.js.map +1 -0
- package/runtime/lib/{snapshot/lynx/dynamic-js.js → core/lynx/dynamic-import.js} +1 -1
- package/runtime/lib/core/lynx/dynamic-import.js.map +1 -0
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/core/lynx/runtime-backend.d.ts +5 -0
- package/runtime/lib/core/lynx/runtime-backend.js +20 -0
- package/runtime/lib/core/lynx/runtime-backend.js.map +1 -0
- package/runtime/lib/core/lynx-data-processors.d.ts +2 -0
- package/runtime/lib/core/lynx-data-processors.js +53 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -0
- package/runtime/lib/core/lynx-page-data.d.ts +1 -0
- package/runtime/lib/core/lynx-page-data.js +14 -0
- package/runtime/lib/core/lynx-page-data.js.map +1 -0
- package/runtime/lib/core/lynx-update-data.d.ts +11 -0
- package/runtime/lib/core/lynx-update-data.js +21 -0
- package/runtime/lib/core/lynx-update-data.js.map +1 -0
- package/runtime/lib/core/performance.d.ts +30 -0
- package/runtime/lib/core/performance.js +145 -0
- package/runtime/lib/core/performance.js.map +1 -0
- package/runtime/lib/core/ref.d.ts +37 -0
- package/runtime/lib/core/ref.js +108 -0
- package/runtime/lib/core/ref.js.map +1 -0
- package/runtime/lib/core/reload-version.d.ts +2 -0
- package/runtime/lib/{snapshot/lifecycle/pass.js → core/reload-version.js} +4 -5
- package/runtime/lib/core/reload-version.js.map +1 -0
- package/runtime/lib/element-template/background/attr-slots.d.ts +6 -1
- package/runtime/lib/element-template/background/attr-slots.js +35 -2
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-context.d.ts +3 -3
- package/runtime/lib/element-template/background/commit-context.js +15 -18
- package/runtime/lib/element-template/background/commit-context.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.d.ts +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +68 -43
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +9 -6
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/document.js +5 -5
- package/runtime/lib/element-template/background/document.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.d.ts +2 -3
- package/runtime/lib/element-template/background/hydrate.js +247 -74
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +49 -22
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +38 -9
- package/runtime/lib/element-template/background/instance.js +292 -113
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/client/root.d.ts +7 -0
- package/runtime/lib/element-template/client/root.js +3 -6
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +21 -0
- package/runtime/lib/element-template/debug/alog.js +33 -0
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/elementPAPICall.js +5 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -1
- package/runtime/lib/element-template/hydration-map.d.ts +5 -0
- package/runtime/lib/element-template/hydration-map.js +12 -0
- package/runtime/lib/element-template/hydration-map.js.map +1 -0
- package/runtime/lib/element-template/index.d.ts +25 -3
- package/runtime/lib/element-template/index.js +38 -9
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +5 -1
- package/runtime/lib/element-template/internal.js +6 -7
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js +5 -48
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/lynx/performance.d.ts +0 -21
- package/runtime/lib/element-template/lynx/performance.js +4 -121
- package/runtime/lib/element-template/lynx/performance.js.map +1 -1
- package/runtime/lib/element-template/native/index.d.ts +1 -1
- package/runtime/lib/element-template/native/index.js +28 -2
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +27 -5
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +2 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +6 -2
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.d.ts +1 -0
- package/runtime/lib/element-template/native/reload-background.js +39 -0
- package/runtime/lib/element-template/native/reload-background.js.map +1 -0
- package/runtime/lib/element-template/native/reload-main-thread.d.ts +1 -0
- package/runtime/lib/element-template/native/reload-main-thread.js +35 -0
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/event.d.ts +1 -0
- package/runtime/lib/element-template/prop-adapters/event.js +4 -1
- package/runtime/lib/element-template/prop-adapters/event.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.d.ts +26 -0
- package/runtime/lib/element-template/prop-adapters/ref.js +107 -0
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.js +8 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +4 -0
- package/runtime/lib/element-template/protocol/opcodes.js +4 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/template-type.d.ts +6 -0
- package/runtime/lib/element-template/protocol/template-type.js +20 -0
- package/runtime/lib/element-template/protocol/template-type.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +74 -6
- package/runtime/lib/element-template/runtime/list/list.d.ts +65 -0
- package/runtime/lib/element-template/runtime/list/list.js +587 -0
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/page.d.ts +5 -2
- package/runtime/lib/element-template/runtime/page/page.js +12 -0
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +210 -38
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +3 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +38 -7
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +80 -43
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +41 -4
- 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 +1 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +4 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +3 -2
- package/runtime/lib/element-template/runtime/template/handle.js +5 -1
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/registry.d.ts +2 -0
- package/runtime/lib/element-template/runtime/template/registry.js +6 -1
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime-backend-marker.js +6 -0
- package/runtime/lib/element-template/runtime-backend-marker.js.map +1 -0
- package/runtime/lib/index.d.ts +1 -1
- package/runtime/lib/index.js +3 -1
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +5 -4
- package/runtime/lib/internal.js +6 -5
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +3 -8
- package/runtime/lib/lynx-api.js +8 -45
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/runtime-backend-marker.js +6 -0
- package/runtime/lib/runtime-backend-marker.js.map +1 -0
- package/runtime/lib/snapshot/debug/vnodeSource.js +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +4 -9
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +2 -2
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +6 -13
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +9 -30
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +2 -2
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +1 -1
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +3 -2
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +3 -9
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js +5 -51
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/performance.d.ts +0 -21
- package/runtime/lib/snapshot/lynx/performance.js +7 -121
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
- package/runtime/lib/snapshot/lynx/runWithForce.js +9 -39
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js +10 -30
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +4 -4
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/list.js +1 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.d.ts +3 -5
- package/runtime/lib/snapshot/snapshot/ref.js +16 -59
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/worklet-runtime/dev.js +2 -3
- package/runtime/worklet-runtime/main.js +1 -1
- package/testing-library/dist/{rslib-runtime.js → 0~rslib-runtime.js} +14 -13
- package/testing-library/dist/env/index.js +2 -8
- package/testing-library/dist/env/vitest.js +1 -1
- package/testing-library/dist/plugins/index.js +13 -2
- package/testing-library/dist/pure.js +18 -18
- package/testing-library/dist/rstest-config.js +2 -4
- package/testing-library/dist/setupFiles/common/bootstrap.js +1 -0
- package/testing-library/dist/setupFiles/common/runtime-setup.js +1 -1
- package/testing-library/dist/setupFiles/inner/rstest.js +2 -1
- package/testing-library/dist/setupFiles/inner/vitest.js +2 -1
- package/testing-library/dist/type-entry/index.js +1 -0
- package/transform/dist/wasm.cjs +113 -40
- package/runtime/lib/element-template/hooks/react.d.ts +0 -14
- package/runtime/lib/element-template/hooks/react.js +0 -24
- package/runtime/lib/element-template/hooks/react.js.map +0 -1
- package/runtime/lib/element-template/runtime/components/slot.js +0 -11
- package/runtime/lib/element-template/runtime/components/slot.js.map +0 -1
- package/runtime/lib/snapshot/compat/initData.js.map +0 -1
- package/runtime/lib/snapshot/compat/lynxComponent.js.map +0 -1
- package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +0 -1
- package/runtime/lib/snapshot/lifecycle/pass.d.ts +0 -3
- package/runtime/lib/snapshot/lifecycle/pass.js.map +0 -1
- package/runtime/lib/snapshot/lynx/component.js +0 -73
- package/runtime/lib/snapshot/lynx/component.js.map +0 -1
- package/runtime/lib/snapshot/lynx/dynamic-js.js.map +0 -1
- package/runtime/lib/snapshot/lynx/lazy-bundle.js.map +0 -1
- package/testing-library/dist/881.js +0 -1
- /package/runtime/lib/{snapshot/lynx/dynamic-js.d.ts → core/lynx/dynamic-import.d.ts} +0 -0
- /package/runtime/lib/{snapshot → core}/lynx/lazy-bundle.d.ts +0 -0
- /package/runtime/lib/{snapshot → core}/lynx/lazy-bundle.js +0 -0
- /package/runtime/lib/element-template/{runtime/components/slot.d.ts → runtime-backend-marker.d.ts} +0 -0
- /package/runtime/lib/{snapshot/lynx/component.d.ts → runtime-backend-marker.d.ts} +0 -0
- /package/testing-library/dist/{0~123.js → 0~@rstest/adapter-rsbuild.js} +0 -0
|
@@ -1,135 +1,18 @@
|
|
|
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
|
-
import {
|
|
5
|
-
import { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';
|
|
6
|
-
import { hook } from '../../utils.js';
|
|
4
|
+
import { initTimingAPI as initCoreTimingAPI } from '../../core/performance.js';
|
|
7
5
|
import { globalCommitContext } from '../background/commit-context.js';
|
|
8
|
-
const PerformanceTimingKeys = [
|
|
9
|
-
'updateSetStateTrigger',
|
|
10
|
-
'updateDiffVdomStart',
|
|
11
|
-
'updateDiffVdomEnd',
|
|
12
|
-
// updateSetStateTrigger, updateDiffVdomStart and updateDiffVdomEnd is deprecated
|
|
13
|
-
'diffVdomStart',
|
|
14
|
-
'diffVdomEnd',
|
|
15
|
-
'packChangesStart',
|
|
16
|
-
'packChangesEnd',
|
|
17
|
-
'parseChangesStart',
|
|
18
|
-
'parseChangesEnd',
|
|
19
|
-
'patchChangesStart',
|
|
20
|
-
'patchChangesEnd',
|
|
21
|
-
'hydrateParsePayloadStart',
|
|
22
|
-
'hydrateParsePayloadEnd',
|
|
23
|
-
'mtsRenderStart',
|
|
24
|
-
'mtsRenderEnd',
|
|
25
|
-
];
|
|
26
|
-
const PerformanceTimingFlags = {
|
|
27
|
-
reactLynxHydrate: 'react_lynx_hydrate',
|
|
28
|
-
};
|
|
29
|
-
const PipelineOrigins = {
|
|
30
|
-
reactLynxHydrate: 'reactLynxHydrate',
|
|
31
|
-
updateTriggeredByBts: 'updateTriggeredByBts',
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated used by old timing api(setState timing flag)
|
|
35
|
-
*/
|
|
36
|
-
const PerfSpecificKey = '__lynx_timing_flag';
|
|
37
|
-
let timingFlag;
|
|
38
|
-
let shouldMarkDiffVdomStart = false;
|
|
39
|
-
let shouldMarkDiffVdomEnd = false;
|
|
40
|
-
let globalPipelineOptions;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated used by old timing api(setState timing flag)
|
|
43
|
-
*/
|
|
44
|
-
function markTimingLegacy(key, timingFlag_) {
|
|
45
|
-
switch (key) {
|
|
46
|
-
case 'updateSetStateTrigger': {
|
|
47
|
-
shouldMarkDiffVdomStart = true;
|
|
48
|
-
shouldMarkDiffVdomEnd = true;
|
|
49
|
-
timingFlag = timingFlag_;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case 'updateDiffVdomStart': {
|
|
53
|
-
if (!shouldMarkDiffVdomStart) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
shouldMarkDiffVdomStart = false;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case 'updateDiffVdomEnd': {
|
|
60
|
-
if (!shouldMarkDiffVdomEnd) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
shouldMarkDiffVdomEnd = false;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
lynx.getNativeApp().markTiming?.(timingFlag, key);
|
|
68
|
-
}
|
|
69
|
-
function beginPipeline(needTimestamps, pipelineOrigin, timingFlag) {
|
|
70
|
-
globalPipelineOptions = lynx.performance?._generatePipelineOptions?.();
|
|
71
|
-
if (globalPipelineOptions) {
|
|
72
|
-
globalPipelineOptions.needTimestamps = needTimestamps;
|
|
73
|
-
globalPipelineOptions.pipelineOrigin = pipelineOrigin;
|
|
74
|
-
globalPipelineOptions.dsl = 'reactLynx';
|
|
75
|
-
switch (pipelineOrigin) {
|
|
76
|
-
case PipelineOrigins.reactLynxHydrate:
|
|
77
|
-
globalPipelineOptions.stage = 'hydrate';
|
|
78
|
-
break;
|
|
79
|
-
case PipelineOrigins.updateTriggeredByBts:
|
|
80
|
-
globalPipelineOptions.stage = 'update';
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
lynx.performance?._onPipelineStart?.(globalPipelineOptions.pipelineID, globalPipelineOptions);
|
|
84
|
-
if (timingFlag) {
|
|
85
|
-
lynx.performance?._bindPipelineIdWithTimingFlag?.(globalPipelineOptions.pipelineID, timingFlag);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function setPipeline(pipeline) {
|
|
90
|
-
globalPipelineOptions = pipeline;
|
|
91
|
-
}
|
|
92
|
-
function markTiming(timestampKey, force) {
|
|
93
|
-
if (globalPipelineOptions && (force || globalPipelineOptions.needTimestamps)) {
|
|
94
|
-
lynx.performance?._markTiming?.(globalPipelineOptions.pipelineID, timestampKey);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
6
|
function shouldStartUpdatePipeline() {
|
|
98
7
|
return globalCommitContext.ops.length > 0;
|
|
99
8
|
}
|
|
100
9
|
function initTimingAPI() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// Check update ops to make sure this only runs after hydrate
|
|
104
|
-
if (__JS__ && shouldStartUpdatePipeline()) {
|
|
105
|
-
if (!globalPipelineOptions) {
|
|
106
|
-
beginPipeline(false, PipelineOrigins.updateTriggeredByBts);
|
|
107
|
-
markTiming('diffVdomStart', true);
|
|
108
|
-
}
|
|
109
|
-
if (shouldMarkDiffVdomStart) {
|
|
110
|
-
markTimingLegacy('updateDiffVdomStart');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
hook(options, RENDER_COMPONENT, (old, vnode, c) => {
|
|
115
|
-
helper();
|
|
116
|
-
/* v8 ignore start */
|
|
117
|
-
if (old) {
|
|
118
|
-
old(vnode, c);
|
|
119
|
-
}
|
|
120
|
-
/* v8 ignore stop */
|
|
121
|
-
});
|
|
122
|
-
hook(options, ROOT, (old, vnode, parentDom) => {
|
|
123
|
-
helper();
|
|
124
|
-
/* v8 ignore start */
|
|
125
|
-
if (old) {
|
|
126
|
-
old(vnode, parentDom);
|
|
127
|
-
}
|
|
128
|
-
/* v8 ignore stop */
|
|
10
|
+
initCoreTimingAPI({
|
|
11
|
+
shouldStartUpdatePipeline,
|
|
129
12
|
});
|
|
130
13
|
}
|
|
131
14
|
/**
|
|
132
15
|
* @internal
|
|
133
16
|
*/
|
|
134
|
-
export {
|
|
17
|
+
export { initTimingAPI };
|
|
135
18
|
//# sourceMappingURL=performance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/element-template/lynx/performance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/element-template/lynx/performance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,SAAS,yBAAyB;IAChC,OAAO,mBAAmB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa;IACpB,iBAAiB,CAAC;QAChB,yBAAyB;KAC1B,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import '@lynx-js/react/hooks';
|
|
@@ -1,12 +1,17 @@
|
|
|
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
|
-
import '
|
|
4
|
+
import '@lynx-js/react/hooks';
|
|
5
|
+
import { render } from 'preact';
|
|
5
6
|
import { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';
|
|
6
7
|
import { injectCalledByNative } from './main-thread-api.js';
|
|
7
8
|
import { installOnMtsDestruction } from './mts-destroy.js';
|
|
8
9
|
import { installElementTemplatePatchListener } from './patch-listener.js';
|
|
10
|
+
import { reloadBackground } from './reload-background.js';
|
|
11
|
+
import { runWithForceRootRender } from '../../core/forceRootRender.js';
|
|
12
|
+
import { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';
|
|
9
13
|
import { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';
|
|
14
|
+
import { updateCardData } from '../../core/lynx-update-data.js';
|
|
10
15
|
import { installElementTemplateCommitHook } from '../background/commit-hook.js';
|
|
11
16
|
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
12
17
|
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
@@ -16,7 +21,25 @@ import { initProfileHook } from '../debug/profile.js';
|
|
|
16
21
|
import { setupLynxEnv } from '../lynx/env.js';
|
|
17
22
|
import { initTimingAPI } from '../lynx/performance.js';
|
|
18
23
|
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
19
|
-
import { setRoot } from '../runtime/page/root-instance.js';
|
|
24
|
+
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
25
|
+
function forceRootRender() {
|
|
26
|
+
runWithForceRootRender({
|
|
27
|
+
getRootVNode: () => __root.__jsx,
|
|
28
|
+
setRootVNode: (vnode) => {
|
|
29
|
+
// @ts-expect-error: __root.__jsx is a Preact VNode during background force render.
|
|
30
|
+
__root.__jsx = vnode;
|
|
31
|
+
},
|
|
32
|
+
render: () => {
|
|
33
|
+
render(__root.__jsx, __root);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const updateGlobalPropsOptions = {
|
|
38
|
+
forceRerender: forceRootRender,
|
|
39
|
+
};
|
|
40
|
+
function updateGlobalProps(newData) {
|
|
41
|
+
updateGlobalPropsCore(newData, updateGlobalPropsOptions);
|
|
42
|
+
}
|
|
20
43
|
function init() {
|
|
21
44
|
if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {
|
|
22
45
|
initElementTemplatePAPICallAlog();
|
|
@@ -39,6 +62,9 @@ function init() {
|
|
|
39
62
|
lynxCoreInject.tt.callDestroyLifetimeFun = callDestroyLifetimeFun;
|
|
40
63
|
lynxCoreInject.tt.publishEvent = publishEvent;
|
|
41
64
|
lynxCoreInject.tt.publicComponentEvent = publicComponentEvent;
|
|
65
|
+
lynxCoreInject.tt.updateGlobalProps = updateGlobalProps;
|
|
66
|
+
lynxCoreInject.tt.updateCardData = updateCardData;
|
|
67
|
+
lynxCoreInject.tt.onAppReload = reloadBackground;
|
|
42
68
|
installElementTemplateCommitHook();
|
|
43
69
|
if (process.env['NODE_ENV'] !== 'test') {
|
|
44
70
|
initTimingAPI();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,u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,CAAC;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;gBAC7C,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
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
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { reloadMainThread } from './reload-main-thread.js';
|
|
5
|
+
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
|
+
import { __page, createElementTemplatePage, setupPage } from '../runtime/page/page.js';
|
|
7
|
+
import { renderMainThread, resetMainThreadRootRefs } from '../runtime/render/render-main-thread.js';
|
|
6
8
|
function injectCalledByNative() {
|
|
7
9
|
const calledByNative = {
|
|
8
10
|
renderPage,
|
|
9
|
-
updatePage
|
|
10
|
-
updateGlobalProps
|
|
11
|
+
updatePage,
|
|
12
|
+
updateGlobalProps,
|
|
11
13
|
getPageData: function () {
|
|
12
14
|
return null;
|
|
13
15
|
},
|
|
@@ -17,9 +19,29 @@ function injectCalledByNative() {
|
|
|
17
19
|
}
|
|
18
20
|
function renderPage(data) {
|
|
19
21
|
lynx.__initData = data ?? {};
|
|
20
|
-
setupPage(
|
|
22
|
+
setupPage(createElementTemplatePage());
|
|
23
|
+
resetMainThreadRootRefs();
|
|
21
24
|
renderMainThread();
|
|
22
25
|
}
|
|
26
|
+
function updatePage(data, options) {
|
|
27
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ !== 'immediately') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (options?.reloadTemplate) {
|
|
31
|
+
reloadMainThread(data, options);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
applyUpdatePageData(data, options);
|
|
35
|
+
__FlushElementTree(__page, options ?? {});
|
|
36
|
+
}
|
|
37
|
+
function updateGlobalProps(_data, options) {
|
|
38
|
+
if (options) {
|
|
39
|
+
__FlushElementTree(__page, options);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
__FlushElementTree();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
/**
|
|
24
46
|
* @internal
|
|
25
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAEpG,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,uBAAuB,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,kBAAkB,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,OAA0B;IACnE,IAAI,OAAO,EAAE,CAAC;QACZ,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,kBAAkB,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
|
+
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
5
6
|
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
6
7
|
export function installOnMtsDestruction() {
|
|
7
8
|
lynx.getNative?.().addEventListener('__DestroyLifetime', onMtsDestruction);
|
|
@@ -29,6 +30,7 @@ export function destroyElementTemplateMainThreadRuntime() {
|
|
|
29
30
|
}
|
|
30
31
|
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
31
32
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
33
|
+
destroyAllElementTemplateListStates();
|
|
32
34
|
elementTemplateRegistry.clear();
|
|
33
35
|
if (didPatchListenerResetThrow) {
|
|
34
36
|
throw patchListenerResetError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mts-destroy.js","sourceRoot":"","sources":["../../../src/element-template/native/mts-destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,WAAW,EAAE,YAAY,EAAE,CAAC,6BAA6B,CAAC,CAAC;IAC3D,IAAI,CAAC;QACH,uCAAuC,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uCAAuC;IACrD,IAAI,uBAAgC,CAAC;IACrC,IAAI,0BAA0B,GAAG,KAAK,CAAC;IACvC,IAAI,CAAC;QACH,iCAAiC,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uBAAuB,GAAG,KAAK,CAAC;QAChC,0BAA0B,GAAG,IAAI,CAAC;IACpC,CAAC;IAED,+EAA+E;IAC/E,iFAAiF;IACjF,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAEhC,IAAI,0BAA0B,EAAE,CAAC;QAC/B,MAAM,uBAAuB,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"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|
// 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
|
+
import { markTiming, setPipeline } from '../../core/performance.js';
|
|
5
|
+
import { getReloadVersion } from '../../core/reload-version.js';
|
|
4
6
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
5
|
-
import { markTiming, setPipeline } from '../lynx/performance.js';
|
|
6
7
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
7
8
|
import { __page } from '../runtime/page/page.js';
|
|
8
9
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
@@ -12,7 +13,10 @@ export function installElementTemplatePatchListener() {
|
|
|
12
13
|
listener = (event) => {
|
|
13
14
|
const { data } = event;
|
|
14
15
|
const payload = data;
|
|
15
|
-
|
|
16
|
+
if (typeof payload?.reloadVersion === 'number' && payload.reloadVersion < getReloadVersion()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const hasOps = Array.isArray(payload?.ops) && payload.ops.length > 0;
|
|
16
20
|
const flushOptions = payload?.flushOptions ?? {};
|
|
17
21
|
const pipelineOptions = flushOptions.pipelineOptions;
|
|
18
22
|
setPipeline(pipelineOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,O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B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reloadBackground(updateData: unknown): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { render } from 'preact';
|
|
5
|
+
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
|
+
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
7
|
+
import { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
8
|
+
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
9
|
+
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
10
|
+
import { BackgroundElementTemplateInstance } from '../background/instance.js';
|
|
11
|
+
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
12
|
+
import { resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
13
|
+
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
14
|
+
export function reloadBackground(updateData) {
|
|
15
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
16
|
+
profileStart('ReactLynx::reloadBackground');
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const jsx = __root.__jsx;
|
|
20
|
+
destroyElementTemplateBackgroundRuntime();
|
|
21
|
+
increaseReloadVersion();
|
|
22
|
+
// Reload creates a new object so InitData Provider / Consumer observers do
|
|
23
|
+
// not retain the pre-reload object identity.
|
|
24
|
+
lynx.__initData = Object.assign({}, lynx.__initData);
|
|
25
|
+
applyUpdatePageData(updateData);
|
|
26
|
+
setRoot(new BackgroundElementTemplateInstance('root'));
|
|
27
|
+
__root.__jsx = jsx;
|
|
28
|
+
setupBackgroundElementTemplateDocument();
|
|
29
|
+
installElementTemplateHydrationListener();
|
|
30
|
+
resetEventStateForRuntime();
|
|
31
|
+
render(jsx, __root);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
35
|
+
profileEnd();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=reload-background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload-background.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-background.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,UAAU,gBAAgB,CAAC,UAAmB;IAClD,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;QACzB,uCAAuC,EAAE,CAAC;QAC1C,qBAAqB,EAAE,CAAC;QACxB,2EAA2E;QAC3E,6CAA6C;QAC7C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAEhC,OAAO,CAAC,IAAI,iCAAiC,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;QACnB,sCAAsC,EAAE,CAAC;QACzC,uCAAuC,EAAE,CAAC;QAC1C,yBAAyB,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAqB,EAAE,MAAkC,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;YACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function reloadMainThread(data: unknown, options: UpdatePageOption): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
5
|
+
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
6
|
+
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
7
|
+
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
8
|
+
import { __page } from '../runtime/page/page.js';
|
|
9
|
+
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
10
|
+
import { removeMainThreadRootRefs, renderMainThread } from '../runtime/render/render-main-thread.js';
|
|
11
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
12
|
+
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
13
|
+
export function reloadMainThread(data, options) {
|
|
14
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
15
|
+
profileStart('ReactLynx::reloadMainThread');
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
increaseReloadVersion();
|
|
19
|
+
applyUpdatePageData(data, options);
|
|
20
|
+
destroyAllElementTemplateListStates();
|
|
21
|
+
elementTemplateRegistry.clear();
|
|
22
|
+
resetTemplateId();
|
|
23
|
+
const oldRoot = __root;
|
|
24
|
+
removeMainThreadRootRefs();
|
|
25
|
+
setRoot({ __jsx: oldRoot.__jsx });
|
|
26
|
+
renderMainThread();
|
|
27
|
+
__FlushElementTree(__page, options);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
31
|
+
profileEnd();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=reload-main-thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,gBAAgB,CAAC,IAAa,EAAE,OAAyB;IACvE,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,qBAAqB,EAAE,CAAC;QACxB,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEnC,mCAAmC,EAAE,CAAC;QACtC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QAChC,eAAe,EAAE,CAAC;QAElB,MAAM,OAAO,GAAG,MAAM,CAAC;QACvB,wBAAwB,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAClC,gBAAgB,EAAE,CAAC;QAEnB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;YACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type EtEventHandler = (data: EventDataType) => unknown;
|
|
2
2
|
export declare function clearEventState(): void;
|
|
3
|
+
export declare function clearPendingEvents(): void;
|
|
3
4
|
export declare function resetEventStateForRuntime(): void;
|
|
4
5
|
export declare function getEventHandlerForEventValue(eventValue: string): EtEventHandler | undefined;
|
|
5
6
|
export declare function publishEvent(eventValue: string, data: EventDataType): void;
|
|
@@ -26,9 +26,12 @@ function dispatchEvent(eventValue, data) {
|
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
export function clearEventState() {
|
|
29
|
-
|
|
29
|
+
clearPendingEvents();
|
|
30
30
|
queuePendingEvents = false;
|
|
31
31
|
}
|
|
32
|
+
export function clearPendingEvents() {
|
|
33
|
+
pendingEvents.length = 0;
|
|
34
|
+
}
|
|
32
35
|
export function resetEventStateForRuntime() {
|
|
33
36
|
clearEventState();
|
|
34
37
|
queuePendingEvents = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,wCAAwC,EAAE,MAAM,0BAA0B,CAAC;AAIpF,MAAM,aAAa,GAAqD,EAAE,CAAC;AAC3E,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,SAAS,aAAa,CAAC,UAAkB,EAAE,IAAmB;IAC5D,MAAM,OAAO,GAAG,wCAAwC,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC;IACtG,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,EAAE,CACZ,yDACE,IAAI,CAAC,SAAS,CACZ;YACE,UAAU;YACV,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc,EAAE,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACjE,UAAU,EAAE,OAAO,OAAO,KAAK,UAAU;SAC1C,EACD,IAAI,EACJ,CAAC,CAEL,EAAE,CACH,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACF,OAA0B,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,wCAAwC,E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CAAC,UAAU,CAAC,CAAC;IACtG,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAE,OAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,IAAmB;IAClE,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO;IACT,CAAC;IACD,IAAI,kBAAkB,EAAE,CAAC;QACvB,aAAa,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,YAAoB,EACpB,UAAkB,EAClB,IAAmB;IAEnB,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,GAAG,KAAK,CAAC;IAC3B,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvC,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;QACxC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SelectorRefProxy } from '../../core/ref.js';
|
|
2
|
+
import type { OrdinaryRef, RefProxyForwardedMethods } from '../../core/ref.js';
|
|
3
|
+
import type { SerializableValue } from '../protocol/types.js';
|
|
4
|
+
export type EtRef = OrdinaryRef<ElementTemplateRefProxy>;
|
|
5
|
+
export declare function getRefValue(handleId: number, attrSlotIndex: number): string;
|
|
6
|
+
export declare function flushDelayedRefUiOps(): void;
|
|
7
|
+
export declare function clearDelayedRefUiOps(): void;
|
|
8
|
+
export declare class ElementTemplateRefProxy extends SelectorRefProxy<ElementTemplateRefProxy> {
|
|
9
|
+
private readonly handleId;
|
|
10
|
+
private readonly attrSlotIndex;
|
|
11
|
+
constructor(handleId: number, attrSlotIndex: number);
|
|
12
|
+
protected createProxyTarget(): ElementTemplateRefProxy;
|
|
13
|
+
protected runOrDelay(task: () => void): void;
|
|
14
|
+
get selector(): string;
|
|
15
|
+
}
|
|
16
|
+
export interface ElementTemplateRefProxy extends RefProxyForwardedMethods<ElementTemplateRefProxy> {
|
|
17
|
+
}
|
|
18
|
+
export declare function getRefFromValue(value: unknown): EtRef | null;
|
|
19
|
+
export declare function getSpreadRefFromValue(value: unknown): EtRef | null | undefined;
|
|
20
|
+
export declare function prepareRefAttrSlot(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null;
|
|
21
|
+
export declare function prepareSpreadRefAttrValue(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null | undefined;
|
|
22
|
+
export declare function queueRefAttrUpdate(oldValue: unknown, newValue: unknown, handleId: number, attrSlotIndex: number): void;
|
|
23
|
+
export declare function flushPendingRefs(): void;
|
|
24
|
+
export declare function clearPendingRefs(): void;
|
|
25
|
+
export declare function hasPendingRefs(): boolean;
|
|
26
|
+
export declare function clearRefState(): void;
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { OrdinaryRefEffectQueue, SelectorRefProxy, normalizeRefValue } from '../../core/ref.js';
|
|
5
|
+
import { hydrationMap } from '../hydration-map.js';
|
|
6
|
+
const refEffectQueue = /*#__PURE__*/ new OrdinaryRefEffectQueue();
|
|
7
|
+
const delayedRefUiOps = [];
|
|
8
|
+
let shouldDelayRefUiOps = true;
|
|
9
|
+
function resolveRefHandleId(handleId) {
|
|
10
|
+
// The proxy may have been handed to user code before hydrate; resolve the id
|
|
11
|
+
// at execution time so the same object follows the hydrated native handle.
|
|
12
|
+
return hydrationMap.get(handleId) ?? handleId;
|
|
13
|
+
}
|
|
14
|
+
function runOrDelayRefUiOp(task) {
|
|
15
|
+
if (!shouldDelayRefUiOps) {
|
|
16
|
+
task();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
delayedRefUiOps.push(task);
|
|
20
|
+
}
|
|
21
|
+
export function getRefValue(handleId, attrSlotIndex) {
|
|
22
|
+
return `${handleId}-${attrSlotIndex}`;
|
|
23
|
+
}
|
|
24
|
+
export function flushDelayedRefUiOps() {
|
|
25
|
+
const tasks = delayedRefUiOps.splice(0);
|
|
26
|
+
shouldDelayRefUiOps = false;
|
|
27
|
+
for (const task of tasks) {
|
|
28
|
+
task();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function clearDelayedRefUiOps() {
|
|
32
|
+
delayedRefUiOps.length = 0;
|
|
33
|
+
}
|
|
34
|
+
export class ElementTemplateRefProxy extends SelectorRefProxy {
|
|
35
|
+
handleId;
|
|
36
|
+
attrSlotIndex;
|
|
37
|
+
constructor(handleId, attrSlotIndex) {
|
|
38
|
+
super();
|
|
39
|
+
this.handleId = handleId;
|
|
40
|
+
this.attrSlotIndex = attrSlotIndex;
|
|
41
|
+
return this.createProxy();
|
|
42
|
+
}
|
|
43
|
+
createProxyTarget() {
|
|
44
|
+
return new ElementTemplateRefProxy(this.handleId, this.attrSlotIndex);
|
|
45
|
+
}
|
|
46
|
+
runOrDelay(task) {
|
|
47
|
+
runOrDelayRefUiOp(task);
|
|
48
|
+
}
|
|
49
|
+
get selector() {
|
|
50
|
+
return `[ref=${getRefValue(resolveRefHandleId(this.handleId), this.attrSlotIndex)}]`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function getRefFromValue(value) {
|
|
54
|
+
return normalizeRefValue(value) ?? null;
|
|
55
|
+
}
|
|
56
|
+
function hasOwnRef(value) {
|
|
57
|
+
return value !== null
|
|
58
|
+
&& typeof value === 'object'
|
|
59
|
+
&& !Array.isArray(value)
|
|
60
|
+
&& Object.prototype.hasOwnProperty.call(value, 'ref');
|
|
61
|
+
}
|
|
62
|
+
export function getSpreadRefFromValue(value) {
|
|
63
|
+
if (!hasOwnRef(value)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return getRefFromValue(value.ref);
|
|
67
|
+
}
|
|
68
|
+
export function prepareRefAttrSlot(handleId, attrSlotIndex, value) {
|
|
69
|
+
if (__LEPUS__ && value === 1) {
|
|
70
|
+
// The LEPUS transform cannot carry the background ref callback/object into
|
|
71
|
+
// first-screen create, so direct refs arrive here as an internal presence
|
|
72
|
+
// marker. Background JS still validates the real user ref before attaching.
|
|
73
|
+
return getRefValue(handleId, attrSlotIndex);
|
|
74
|
+
}
|
|
75
|
+
if (getRefFromValue(value) === null) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return getRefValue(handleId, attrSlotIndex);
|
|
79
|
+
}
|
|
80
|
+
export function prepareSpreadRefAttrValue(handleId, attrSlotIndex, value) {
|
|
81
|
+
const ref = getSpreadRefFromValue(value);
|
|
82
|
+
if (ref === undefined) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return ref === null ? null : getRefValue(handleId, attrSlotIndex);
|
|
86
|
+
}
|
|
87
|
+
export function queueRefAttrUpdate(oldValue, newValue, handleId, attrSlotIndex) {
|
|
88
|
+
const oldRef = getRefFromValue(oldValue);
|
|
89
|
+
const newRef = getRefFromValue(newValue);
|
|
90
|
+
refEffectQueue.queue(oldRef, newRef, [handleId, attrSlotIndex]);
|
|
91
|
+
}
|
|
92
|
+
export function flushPendingRefs() {
|
|
93
|
+
refEffectQueue.flush(([handleId, attrSlotIndex]) => new ElementTemplateRefProxy(handleId, attrSlotIndex));
|
|
94
|
+
}
|
|
95
|
+
export function clearPendingRefs() {
|
|
96
|
+
refEffectQueue.clear();
|
|
97
|
+
}
|
|
98
|
+
export function hasPendingRefs() {
|
|
99
|
+
return refEffectQueue.hasPending();
|
|
100
|
+
}
|
|
101
|
+
export function clearRefState() {
|
|
102
|
+
clearPendingRefs();
|
|
103
|
+
hydrationMap.clear();
|
|
104
|
+
clearDelayedRefUiOps();
|
|
105
|
+
shouldDelayRefUiOps = true;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/ref.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEhG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOnD,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,sBAAsB,EAAqC,CAAC;AACrG,MAAM,eAAe,GAAmB,EAAE,CAAC;AAC3C,IAAI,mBAAmB,GAAG,IAAI,CAAC;AAE/B,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,6EAA6E;IAC7E,2EAA2E;IAC3E,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAChD,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAgB;IACzC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,IAAI,EAAE,CAAC;QACP,OAAO;IACT,CAAC;IACD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB,EAAE,aAAqB;IACjE,OAAO,GAAG,QAAQ,IAAI,aAAa,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxC,mBAAmB,GAAG,KAAK,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,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