@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.121.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `addComponentElement` compat transforms so explicit `removeComponentElement={true}` is honored consistently even when it appears before a JSX spread like `{...props}`. ([#2758](https://github.com/lynx-family/lynx-stack/pull/2758))
|
|
8
|
+
|
|
9
|
+
Previously, the compat transform could short-circuit while scanning opening attributes and treat:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<Component removeComponentElement={true} {...props} />;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
differently from:
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
<Component {...props} removeComponentElement={true} />;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The transform now collects the full opening-attribute state first, so both prop orders compile the same way in normal and `compilerOnly` modes.
|
|
22
|
+
|
|
23
|
+
- Fix directive DCE for TypeScript async output with nested `"background only"` directives. ([#2830](https://github.com/lynx-family/lynx-stack/pull/2830))
|
|
24
|
+
|
|
25
|
+
- Rename the `bundle-url` element attribute to `lazy-bundle-url`. ([#2723](https://github.com/lynx-family/lynx-stack/pull/2723))
|
|
26
|
+
|
|
27
|
+
The attribute set on lazy bundle border elements (when a child belongs to a different lazy bundle entry than its parent) is renamed from `bundle-url` to `lazy-bundle-url` to make its purpose explicit.
|
|
28
|
+
|
|
29
|
+
## 0.121.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Disable vnode reuse of different slot index in preact's diff, fixing a bug that `__RemoveElement` was called with mismatched parent and child element. ([#2664](https://github.com/lynx-family/lynx-stack/pull/2664))
|
|
34
|
+
|
|
35
|
+
- Fix list update indices when existing items are updated after inserting siblings before them. ([#2518](https://github.com/lynx-family/lynx-stack/pull/2518))
|
|
36
|
+
|
|
3
37
|
## 0.121.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react",
|
|
3
|
-
"version": "0.121.
|
|
3
|
+
"version": "0.121.2",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
"default": "./runtime/lib/worklet-runtime/bindings/index.js"
|
|
113
113
|
},
|
|
114
114
|
"./legacy-react-runtime": {
|
|
115
|
-
"types": "./runtime/lib/
|
|
115
|
+
"types": "./runtime/lib/core/compat/legacy-react-runtime.d.ts",
|
|
116
116
|
"lazy": "./runtime/lazy/legacy-react-runtime.js",
|
|
117
|
-
"default": "./runtime/lib/
|
|
117
|
+
"default": "./runtime/lib/core/compat/legacy-react-runtime.js"
|
|
118
118
|
},
|
|
119
119
|
"./testing-library": {
|
|
120
120
|
"types": "./testing-library/types/index.d.ts",
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
"./runtime/lib/worklet-runtime/bindings/index.d.ts"
|
|
203
203
|
],
|
|
204
204
|
"legacy-react-runtime": [
|
|
205
|
-
"./runtime/lib/
|
|
205
|
+
"./runtime/lib/core/compat/legacy-react-runtime.d.ts"
|
|
206
206
|
]
|
|
207
207
|
}
|
|
208
208
|
},
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
"README.zh.md"
|
|
221
221
|
],
|
|
222
222
|
"dependencies": {
|
|
223
|
-
"preact": "npm:@lynx-js/internal-preact@10.29.1-
|
|
223
|
+
"preact": "npm:@lynx-js/internal-preact@10.29.1-20260519060144-e6da44c"
|
|
224
224
|
},
|
|
225
225
|
"devDependencies": {
|
|
226
226
|
"@lynx-js/types": "3.7.0",
|
|
@@ -0,0 +1,73 @@
|
|
|
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 * as ReactAPIs from '@lynx-js/react/element-template';
|
|
5
|
+
import * as ReactCompatAPIS from '@lynx-js/react/compat';
|
|
6
|
+
import * as ReactInternal from '@lynx-js/react/element-template/internal';
|
|
7
|
+
import * as ReactJSXDevRuntime from '@lynx-js/react/jsx-dev-runtime';
|
|
8
|
+
import * as ReactJSXRuntime from '@lynx-js/react/jsx-runtime';
|
|
9
|
+
import * as ReactLegacyReactRuntime from '@lynx-js/react/legacy-react-runtime';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
RUNTIME_BACKEND_ELEMENT_TEMPLATE,
|
|
13
|
+
registerLazyRuntimeBackend,
|
|
14
|
+
sExportsJSXDevRuntime,
|
|
15
|
+
sExportsJSXRuntime,
|
|
16
|
+
sExportsLegacyReactRuntime,
|
|
17
|
+
sExportsReact,
|
|
18
|
+
sExportsReactCompat,
|
|
19
|
+
sExportsReactInternal,
|
|
20
|
+
sExportsReactLepus,
|
|
21
|
+
target,
|
|
22
|
+
} from './target.js';
|
|
23
|
+
|
|
24
|
+
registerLazyRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
|
|
25
|
+
|
|
26
|
+
Object.defineProperty(target, sExportsReact, {
|
|
27
|
+
value: ReactAPIs,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
writable: false,
|
|
30
|
+
configurable: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Object.defineProperty(target, sExportsReactLepus, {
|
|
34
|
+
value: ReactAPIs,
|
|
35
|
+
enumerable: false,
|
|
36
|
+
writable: false,
|
|
37
|
+
configurable: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
Object.defineProperty(target, sExportsReactCompat, {
|
|
41
|
+
value: ReactCompatAPIS,
|
|
42
|
+
enumerable: false,
|
|
43
|
+
writable: false,
|
|
44
|
+
configurable: true,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
Object.defineProperty(target, sExportsReactInternal, {
|
|
48
|
+
value: ReactInternal,
|
|
49
|
+
enumerable: false,
|
|
50
|
+
writable: false,
|
|
51
|
+
configurable: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
Object.defineProperty(target, sExportsJSXRuntime, {
|
|
55
|
+
value: ReactJSXRuntime,
|
|
56
|
+
enumerable: false,
|
|
57
|
+
writable: false,
|
|
58
|
+
configurable: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
Object.defineProperty(target, sExportsJSXDevRuntime, {
|
|
62
|
+
value: ReactJSXDevRuntime,
|
|
63
|
+
enumerable: false,
|
|
64
|
+
writable: false,
|
|
65
|
+
configurable: true,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
Object.defineProperty(target, sExportsLegacyReactRuntime, {
|
|
69
|
+
value: ReactLegacyReactRuntime,
|
|
70
|
+
enumerable: false,
|
|
71
|
+
writable: false,
|
|
72
|
+
configurable: true,
|
|
73
|
+
});
|
package/runtime/lazy/import.js
CHANGED
|
@@ -10,6 +10,8 @@ import * as ReactLegacyReactRuntime from '@lynx-js/react/legacy-react-runtime';
|
|
|
10
10
|
import * as ReactLepusAPIs from '@lynx-js/react/lepus';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
+
RUNTIME_BACKEND_SNAPSHOT,
|
|
14
|
+
registerLazyRuntimeBackend,
|
|
13
15
|
sExportsJSXDevRuntime,
|
|
14
16
|
sExportsJSXRuntime,
|
|
15
17
|
sExportsLegacyReactRuntime,
|
|
@@ -20,6 +22,8 @@ import {
|
|
|
20
22
|
target,
|
|
21
23
|
} from './target.js';
|
|
22
24
|
|
|
25
|
+
registerLazyRuntimeBackend(RUNTIME_BACKEND_SNAPSHOT);
|
|
26
|
+
|
|
23
27
|
Object.defineProperty(target, sExportsReact, {
|
|
24
28
|
value: ReactAPIs,
|
|
25
29
|
enumerable: false,
|
package/runtime/lazy/target.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
export const target = __LEPUS__ ? globalThis : lynx;
|
|
5
5
|
|
|
6
|
+
export const RUNTIME_BACKEND_SNAPSHOT = 'Snapshot';
|
|
7
|
+
export const RUNTIME_BACKEND_ELEMENT_TEMPLATE = 'Element Template';
|
|
8
|
+
export const sRuntimeBackend = Symbol.for('__REACT_LYNX_RUNTIME_BACKEND__');
|
|
9
|
+
|
|
6
10
|
export const sExportsReact = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react)');
|
|
7
11
|
export const sExportsReactCompat = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/compat)');
|
|
8
12
|
export const sExportsReactLepus = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/lepus)');
|
|
@@ -10,3 +14,22 @@ export const sExportsReactInternal = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js
|
|
|
10
14
|
export const sExportsJSXRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-runtime)');
|
|
11
15
|
export const sExportsJSXDevRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-dev-runtime)');
|
|
12
16
|
export const sExportsLegacyReactRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/legacy-react-runtime)');
|
|
17
|
+
|
|
18
|
+
export function registerLazyRuntimeBackend(backend) {
|
|
19
|
+
const currentBackend = target[sRuntimeBackend];
|
|
20
|
+
|
|
21
|
+
if (currentBackend !== undefined && currentBackend !== backend) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`ReactLynx runtime backend mismatch: the current template uses ${
|
|
24
|
+
String(currentBackend)
|
|
25
|
+
}, but this bundle was built for ${backend}. Snapshot and Element Template templates cannot share lazy bundles. Rebuild the main template and lazy bundle with the same elementTemplate setting.`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Object.defineProperty(target, sRuntimeBackend, {
|
|
30
|
+
value: backend,
|
|
31
|
+
enumerable: false,
|
|
32
|
+
writable: false,
|
|
33
|
+
configurable: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface GlobalCommitContext<Ops = unknown[]> {
|
|
2
|
+
ops: Ops;
|
|
3
|
+
flushOptions: FlushOptions;
|
|
4
|
+
flowIds?: number[];
|
|
5
|
+
}
|
|
6
|
+
export declare const globalCommitContext: GlobalCommitContext;
|
|
7
|
+
export declare function resetGlobalCommitContext(): void;
|
|
8
|
+
export declare function takeGlobalFlushOptions(): FlushOptions;
|
|
@@ -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
|
+
export const globalCommitContext = {
|
|
5
|
+
ops: [],
|
|
6
|
+
flushOptions: {},
|
|
7
|
+
};
|
|
8
|
+
export function resetGlobalCommitContext() {
|
|
9
|
+
globalCommitContext.ops = [];
|
|
10
|
+
globalCommitContext.flushOptions = {};
|
|
11
|
+
delete globalCommitContext.flowIds;
|
|
12
|
+
}
|
|
13
|
+
export function takeGlobalFlushOptions() {
|
|
14
|
+
const flushOptions = globalCommitContext.flushOptions;
|
|
15
|
+
globalCommitContext.flushOptions = {};
|
|
16
|
+
return flushOptions;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=commit-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-context.js","sourceRoot":"","sources":["../../src/core/commit-context.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAQ1D,MAAM,CAAC,MAAM,mBAAmB,GAAwB;IACtD,GAAG,EAAE,EAAE;IACP,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,GAAG,GAAG,EAAE,CAAC;IAC7B,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,mBAAmB,CAAC,OAAO,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;IACtC,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRef } from 'preact';
|
|
2
|
-
import { useRef } from '
|
|
2
|
+
import { useRef } from '../hooks/react.js';
|
|
3
3
|
declare function __runInJS<T>(value: T): T | undefined | null;
|
|
4
|
-
export { ComponentFromReactRuntime as Component } from '
|
|
5
|
-
export { ComponentFromReactRuntime as PureComponent } from '
|
|
4
|
+
export { ComponentFromReactRuntime as Component } from './lynxComponent.js';
|
|
5
|
+
export { ComponentFromReactRuntime as PureComponent } from './lynxComponent.js';
|
|
6
6
|
export { createContext } from 'preact';
|
|
7
7
|
export { lazy } from 'preact/compat';
|
|
8
|
-
export { useState, useReducer, useEffect, useMemo, useCallback } from '
|
|
8
|
+
export { useState, useReducer, useEffect, useMemo, useCallback } from '../hooks/react.js';
|
|
9
9
|
export { __runInJS, createRef, useRef };
|
package/runtime/lib/{snapshot/legacy-react-runtime/index.js → core/compat/legacy-react-runtime.js}
RENAMED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { createContext, createRef } from 'preact';
|
|
5
5
|
import { lazy } from 'preact/compat';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ComponentFromReactRuntime as Component, ComponentFromReactRuntime as PureComponent } from './lynxComponent.js';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from '../hooks/react.js';
|
|
8
8
|
/* v8 ignore next 3 */
|
|
9
9
|
function __runInJS(value) {
|
|
10
10
|
return value;
|
|
11
11
|
}
|
|
12
12
|
// should mirror @lynx-js/react-runtime's exports
|
|
13
|
-
export { ComponentFromReactRuntime as Component } from '
|
|
14
|
-
export { ComponentFromReactRuntime as PureComponent } from '
|
|
13
|
+
export { ComponentFromReactRuntime as Component } from './lynxComponent.js';
|
|
14
|
+
export { ComponentFromReactRuntime as PureComponent } from './lynxComponent.js';
|
|
15
15
|
export { createContext } from 'preact';
|
|
16
16
|
export { lazy } from 'preact/compat';
|
|
17
|
-
export { useState, useReducer, useEffect, useMemo, useCallback /*, useInstance */ } from '
|
|
17
|
+
export { useState, useReducer, useEffect, useMemo, useCallback /*, useInstance */ } from '../hooks/react.js';
|
|
18
18
|
export { __runInJS, createRef, useRef };
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
@@ -33,4 +33,4 @@ export default {
|
|
|
33
33
|
useCallback,
|
|
34
34
|
__runInJS,
|
|
35
35
|
};
|
|
36
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=legacy-react-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-react-runtime.js","sourceRoot":"","sources":["../../../src/core/compat/legacy-react-runtime.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,yBAAyB,IAAI,SAAS,EAAE,yBAAyB,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElG,sBAAsB;AACtB,SAAS,SAAS,CAAI,KAAQ;IAC5B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iDAAiD;AACjD,OAAO,EAAE,yBAAyB,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAExC;;GAEG;AACH,eAAe;IACb,SAAS;IACT,aAAa;IACb,aAAa;IACb,SAAS;IACT,IAAI;IACJ,QAAQ;IACR,UAAU;IACV,MAAM;IACN,SAAS;IACT,OAAO;IACP,WAAW;IACX,SAAS;CACV,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component } from 'preact';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
export declare function wrapWithLynxComponent(jsxSnapshot: (c: ReactNode, spread?: Record<string,
|
|
3
|
+
export declare function wrapWithLynxComponent(jsxSnapshot: (c: ReactNode, spread?: Record<string, unknown>) => ReactNode, jsxComponent: ReactNode): ReactNode;
|
|
4
4
|
export declare class ComponentFromReactRuntime extends Component {
|
|
5
|
+
render(): null;
|
|
5
6
|
}
|
|
@@ -3,22 +3,28 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { Component } from 'preact';
|
|
5
5
|
export function wrapWithLynxComponent(jsxSnapshot, jsxComponent) {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const componentVNode = jsxComponent;
|
|
7
|
+
const C = componentVNode.type;
|
|
8
|
+
if (typeof C === 'function'
|
|
9
|
+
&& (C === ComponentFromReactRuntime
|
|
10
|
+
|| C.prototype instanceof ComponentFromReactRuntime)) {
|
|
8
11
|
if (jsxSnapshot.length === 1) {
|
|
9
12
|
return jsxSnapshot(jsxComponent);
|
|
10
13
|
}
|
|
11
14
|
else {
|
|
12
15
|
// spread
|
|
13
|
-
if (!
|
|
14
|
-
return jsxSnapshot(jsxComponent, takeComponentAttributes(
|
|
16
|
+
if (!componentVNode.props['removeComponentElement']) {
|
|
17
|
+
return jsxSnapshot(jsxComponent, takeComponentAttributes(componentVNode));
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
return jsxComponent;
|
|
19
22
|
}
|
|
20
|
-
// @ts-expect-error
|
|
21
23
|
export class ComponentFromReactRuntime extends Component {
|
|
24
|
+
/* v8 ignore next 3 -- marker component, never rendered directly. */
|
|
25
|
+
render() {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
const __COMPONENT_ATTRIBUTES__ = /* @__PURE__ */ new Set([
|
|
24
30
|
'name',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lynxComponent.js","sourceRoot":"","sources":["../../../src/core/compat/lynxComponent.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAQnC,MAAM,UAAU,qBAAqB,CACnC,WAA0E,EAC1E,YAAuB;IAEvB,MAAM,cAAc,GAAG,YAAoC,CAAC;IAC5D,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC;IAC9B,IACE,OAAO,CAAC,KAAK,UAAU;WACpB,CAAC,CAAC,KAAK,yBAAyB;eAC7B,CAA6B,CAAC,SAAS,YA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AChB,CAAC,KAAK,wBAAwB;eAC9B,CAAC,kEAAkE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;eAC5E,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EACjC,CAAC;YACD,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
/* eslint-disable */
|
|
5
|
+
import { Component } from 'preact';
|
|
6
|
+
import { globalCommitContext } from './commit-context.js';
|
|
7
|
+
import { PerfSpecificKey, markTimingLegacy } from './performance.js';
|
|
8
|
+
import { NEXT_STATE } from '../shared/render-constants.js';
|
|
9
|
+
const OriginalSetStateKey = '__reactLynxOriginalSetState';
|
|
10
|
+
function reportRefDeprecationError(fnName, newFnName) {
|
|
11
|
+
if (__DEV__ && !__DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__) {
|
|
12
|
+
lynx.reportError(new Error(`${fnName} is deprecated and has different behavior in ReactLynx 3.0, please use ref or ${newFnName} instead.`));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function getReactAppInstance() {
|
|
16
|
+
return lynxCoreInject.tt;
|
|
17
|
+
}
|
|
18
|
+
function getLegacyNativeApp() {
|
|
19
|
+
return lynxCoreInject.tt._nativeApp;
|
|
20
|
+
}
|
|
21
|
+
function getLegacyReactComponent() {
|
|
22
|
+
return lynxCoreInject.tt._reactLynx.ReactComponent.prototype;
|
|
23
|
+
}
|
|
24
|
+
function createLegacyComponentReceiver(reactAppInstance, nativeApp) {
|
|
25
|
+
return {
|
|
26
|
+
_type: '',
|
|
27
|
+
_nativeApp: nativeApp,
|
|
28
|
+
_uiModule: nativeApp.nativeModuleProxy.LynxUIMethodModule,
|
|
29
|
+
_reactAppInstance: reactAppInstance,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function installComponentCompat() {
|
|
33
|
+
if (!__JS__) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const __Component = Component;
|
|
37
|
+
const reactAppInstance = getReactAppInstance();
|
|
38
|
+
__Component.prototype._reactAppInstance = reactAppInstance;
|
|
39
|
+
__Component.prototype.getNodeRef = function (a, b) {
|
|
40
|
+
reportRefDeprecationError('getNodeRef', 'lynx.createSelectorQuery');
|
|
41
|
+
return getLegacyReactComponent().getNodeRef.call(createLegacyComponentReceiver(getReactAppInstance(), getLegacyNativeApp()), a, b);
|
|
42
|
+
};
|
|
43
|
+
__Component.prototype.getNodeRefFromRoot = function (a) {
|
|
44
|
+
reportRefDeprecationError('getNodeRefFromRoot', 'lynx.createSelectorQuery');
|
|
45
|
+
return getLegacyReactComponent().getNodeRefFromRoot.call(createLegacyComponentReceiver(getReactAppInstance(), getLegacyNativeApp()), a);
|
|
46
|
+
};
|
|
47
|
+
__Component.prototype.registerModule = function (name, module) {
|
|
48
|
+
this._reactAppInstance.registerModule(name, module);
|
|
49
|
+
};
|
|
50
|
+
__Component.prototype.getJSModule = function (name) {
|
|
51
|
+
return this._reactAppInstance.getJSModule(name);
|
|
52
|
+
};
|
|
53
|
+
__Component.prototype.addGlobalEventListener = function (eventName, callback, context) {
|
|
54
|
+
return this._reactAppInstance.getJSModule('GlobalEventEmitter').addListener(eventName, callback, context);
|
|
55
|
+
};
|
|
56
|
+
__Component.prototype.getElementById = function (id) {
|
|
57
|
+
reportRefDeprecationError('getElementById', 'lynx.getElementById');
|
|
58
|
+
return lynx.getElementById(id);
|
|
59
|
+
};
|
|
60
|
+
__Component.prototype.GlobalEventEmitter = reactAppInstance.GlobalEventEmitter;
|
|
61
|
+
__Component.prototype.createSelectorQuery = function () {
|
|
62
|
+
reportRefDeprecationError('createSelectorQuery on component instance', 'lynx.createSelectorQuery');
|
|
63
|
+
return lynx.createSelectorQuery();
|
|
64
|
+
};
|
|
65
|
+
const oldSetState = __Component.prototype[OriginalSetStateKey] ?? __Component.prototype.setState;
|
|
66
|
+
__Component.prototype[OriginalSetStateKey] = oldSetState;
|
|
67
|
+
__Component.prototype.setState = function (state, callback) {
|
|
68
|
+
oldSetState.call(this, state, callback);
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
const timingFlag = this[NEXT_STATE][PerfSpecificKey];
|
|
71
|
+
if (timingFlag) {
|
|
72
|
+
globalCommitContext.flushOptions.__lynx_timing_flag = timingFlag;
|
|
73
|
+
markTimingLegacy('updateSetStateTrigger', timingFlag);
|
|
74
|
+
this[NEXT_STATE][PerfSpecificKey] = '';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export { installComponentCompat };
|
|
79
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,oBAAoB;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAmB3D,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AAE1D,SAAS,yBAAyB,CAAC,MAAc,EAAE,SAAiB;IAClE,IAAI,OAAO,IAAI,CAAC,sDAAsD,EAAE,CAAC;QACvE,IAAI,CAAC,WAAW,CACd,IAAI,KAAK,CACP,GA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C,QAAQ,GAAG,UAAS,KAAU,EAAE,QAAa;QACjE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACxC,aAAa;QACb,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC;QACrD,IAAI,UAAU,EAAE,CAAC;YACf,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,GAAG,UAAU,CAAC;YACjE,gBAAgB,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;YACtD,IAAI,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VNode } from 'preact';
|
|
2
|
+
export interface ForceRootRenderOptions {
|
|
3
|
+
getRootVNode: () => unknown;
|
|
4
|
+
setRootVNode: (vnode: VNode) => void;
|
|
5
|
+
render: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function runWithForceRootRender({ getRootVNode, setRootVNode, render }: ForceRootRenderOptions): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { options as preactOptions } from 'preact';
|
|
5
|
+
import { COMPONENT, DIFF2, FORCE, ORIGINAL } from '../shared/render-constants.js';
|
|
6
|
+
export function runWithForceRootRender({ getRootVNode, setRootVNode, render }) {
|
|
7
|
+
// Preact can skip root render if `_original` is unchanged; bumping it keeps
|
|
8
|
+
// backend force renders aligned with Preact's own rerender path.
|
|
9
|
+
const rootVNode = getRootVNode();
|
|
10
|
+
if (rootVNode) {
|
|
11
|
+
const newVNode = Object.assign({}, rootVNode);
|
|
12
|
+
if (newVNode[ORIGINAL] != null) {
|
|
13
|
+
newVNode[ORIGINAL] += 1;
|
|
14
|
+
setRootVNode(newVNode);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const oldDiff = preactOptions[DIFF2];
|
|
18
|
+
preactOptions[DIFF2] = (vnode, oldVNode) => {
|
|
19
|
+
/* v8 ignore start */
|
|
20
|
+
if (oldDiff) {
|
|
21
|
+
oldDiff(vnode, oldVNode);
|
|
22
|
+
}
|
|
23
|
+
/* v8 ignore stop */
|
|
24
|
+
const c = oldVNode[COMPONENT];
|
|
25
|
+
if (c) {
|
|
26
|
+
c[FORCE] = true;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// mount phase of a new Component
|
|
30
|
+
// `isNew` is true, no need to set FORCE
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
render();
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
preactOptions[DIFF2] = oldDiff;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=forceRootRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forceRootRender.js","sourceRoot":"","sources":["../../src/core/forceRootRender.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAQlF,MAAM,UAAU,sBAAsB,CACpC,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAA0B;IAE9D,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAU,CAAC;QACvD,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;YAC/B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxB,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACrC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,KAAY,EAAE,QAAe,EAAE,EAAE;QACvD,qBAAqB;QACrB,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,oBAAoB;QAEpB,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,iCAAiC;YACjC,wCAAwC;QAC1C,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;IACX,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,KAAK,CAAC,GAAG,OAAkD,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Consumer, Provider } from 'preact';
|
|
2
|
+
import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
|
|
3
|
+
type Getter<T> = {
|
|
4
|
+
[key in keyof T]: () => T[key];
|
|
5
|
+
};
|
|
6
|
+
interface GlobalPropsRuntimeDeps {
|
|
7
|
+
createContext: typeof import('preact').createContext;
|
|
8
|
+
useState: typeof import('preact/hooks').useState;
|
|
9
|
+
createElement: typeof import('preact/compat').createElement;
|
|
10
|
+
useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
|
|
11
|
+
}
|
|
12
|
+
interface GlobalPropsApi<Data> {
|
|
13
|
+
Provider: Provider<Data>;
|
|
14
|
+
Consumer: Consumer<Data>;
|
|
15
|
+
use: () => Data;
|
|
16
|
+
useChanged: (callback: (data: Data) => void) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The interface you can extends so that the `useGlobalProps` returning value can be customized
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface GlobalProps {
|
|
24
|
+
}
|
|
25
|
+
export interface UpdateGlobalPropsOptions {
|
|
26
|
+
forceRerender?: (() => void) | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare function isGlobalPropsEventMode(): boolean;
|
|
29
|
+
export declare function createGlobalProps<Data = GlobalProps>(deps: GlobalPropsRuntimeDeps): Getter<GlobalPropsApi<Data>>;
|
|
30
|
+
export declare function updateGlobalProps(newData: Record<string, any>, { forceRerender }?: UpdateGlobalPropsOptions): void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { factory } from './initData.js';
|
|
2
|
+
export function isGlobalPropsEventMode() {
|
|
3
|
+
return typeof __GLOBAL_PROPS_MODE__ !== 'undefined' && __GLOBAL_PROPS_MODE__ === 'event';
|
|
4
|
+
}
|
|
5
|
+
export function createGlobalProps(deps) {
|
|
6
|
+
return isGlobalPropsEventMode()
|
|
7
|
+
? /* @__PURE__ */ factory(deps, '__globalProps', 'onGlobalPropsChanged')
|
|
8
|
+
: /* @__PURE__ */ createFallbackGlobalProps(deps.useLynxGlobalEventListener);
|
|
9
|
+
}
|
|
10
|
+
export function updateGlobalProps(newData, { forceRerender } = {}) {
|
|
11
|
+
if (isGlobalPropsEventMode()) {
|
|
12
|
+
// COW keeps Provider / Consumer state readers aligned in event mode.
|
|
13
|
+
lynx.__globalProps = Object.assign({}, lynx.__globalProps, newData);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
Object.assign(lynx.__globalProps, newData);
|
|
17
|
+
if (forceRerender) {
|
|
18
|
+
void Promise.resolve().then(forceRerender);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
lynxCoreInject.tt.GlobalEventEmitter.emit('onGlobalPropsChanged', [lynx.__globalProps]);
|
|
22
|
+
}
|
|
23
|
+
function warnGlobalPropsMode() {
|
|
24
|
+
if (typeof __LEPUS__ !== 'undefined' && !__LEPUS__ && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
25
|
+
console.warn(`No need to use this API when 'globalPropsMode' is not 'event', `
|
|
26
|
+
+ `updates will be triggered automatically by full re-render. `
|
|
27
|
+
+ `Please set 'globalPropsMode' to 'event' to enable optimized updates.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function FallbackProvider({ children }) {
|
|
31
|
+
warnGlobalPropsMode();
|
|
32
|
+
return children;
|
|
33
|
+
}
|
|
34
|
+
function FallbackConsumer({ children }) {
|
|
35
|
+
warnGlobalPropsMode();
|
|
36
|
+
return children(lynx.__globalProps);
|
|
37
|
+
}
|
|
38
|
+
function useFallbackGlobalProps() {
|
|
39
|
+
warnGlobalPropsMode();
|
|
40
|
+
return lynx.__globalProps;
|
|
41
|
+
}
|
|
42
|
+
function createFallbackGlobalProps(useListener) {
|
|
43
|
+
const useChanged = (callback) => {
|
|
44
|
+
if (typeof __LEPUS__ === 'undefined' || !__LEPUS__) {
|
|
45
|
+
useListener('onGlobalPropsChanged', callback);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
Provider: () => FallbackProvider,
|
|
50
|
+
Consumer: () => FallbackConsumer,
|
|
51
|
+
use: () => useFallbackGlobalProps,
|
|
52
|
+
useChanged: () => useChanged,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=globalProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalProps.js","sourceRoot":"","sources":["../../src/core/globalProps.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA+BxC,MAAM,UAAU,sBAAsB;IACpC,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B,CAAC;AAED,SAAS,gBAAgB,CAAO,EAAE,QAAQ,EAAmD;IAC3F,mBAAmB,EAAE,CAAC;IACtB,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAqB,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,sBAAsB;IAC7B,mBAAmB,EAAE,CAAC;IACtB,OAAO,IAAI,CAAC,aAAqB,CAAC;AACpC,CAAC;AAED,SAAS,yBAAyB,CAChC,WAA8C;IAE9C,MAAM,UAAU,GAAG,CAAC,QAA8B,EAAQ,EAAE;QAC1D,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE,CAAC;YACnD,WAAW,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB;QAChC,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAkC;QAClD,GAAG,EAAE,GAAG,EAAE,CAAC,sBAAoC;QAC/C,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { useEffect, useMemo, useRef } from '
|
|
4
|
+
import { useEffect, useMemo, useRef } from '@lynx-js/react/hooks';
|
|
5
5
|
/**
|
|
6
6
|
* `useLynxGlobalEventListener` helps you `addListener` as early as possible.
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLynxGlobalEventListener.js","sourceRoot":"","sources":["../../../src/core/hooks/useLynxGlobalEventListener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE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@
|
|
|
1
1
|
import type { Consumer, Context, Provider } from 'preact';
|
|
2
2
|
import type { ComponentClass } from 'react';
|
|
3
|
-
import { useLynxGlobalEventListener } from '
|
|
3
|
+
import type { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js';
|
|
4
4
|
type Getter<T> = {
|
|
5
5
|
[key in keyof T]: () => T[key];
|
|
6
6
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { globalFlushOptions } from '../lifecycle/patch/commit.js';
|
|
1
|
+
import { globalCommitContext } from './commit-context.js';
|
|
3
2
|
// for better reuse if runtime is changed
|
|
4
3
|
export function factory({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }, prop, eventName) {
|
|
5
4
|
const Context = createContext({});
|
|
@@ -7,7 +6,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
|
|
|
7
6
|
const [__, set] = useState(lynx[prop]);
|
|
8
7
|
const handleChange = () => {
|
|
9
8
|
if (prop === '__initData') {
|
|
10
|
-
|
|
9
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
11
10
|
}
|
|
12
11
|
set(lynx[prop]);
|
|
13
12
|
};
|
|
@@ -21,7 +20,7 @@ export function factory({ createContext, useState, createElement, useLynxGlobalE
|
|
|
21
20
|
const [__, set] = useState(lynx[prop]);
|
|
22
21
|
useChanged(() => {
|
|
23
22
|
if (prop === '__initData') {
|
|
24
|
-
|
|
23
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
25
24
|
}
|
|
26
25
|
set(lynx[prop]);
|
|
27
26
|
});
|
|
@@ -84,7 +83,7 @@ export function withInitDataInState(App) {
|
|
|
84
83
|
if (!__LEPUS__) {
|
|
85
84
|
lynx.getJSModule('GlobalEventEmitter').addListener('onDataChanged', this.h = (...args) => {
|
|
86
85
|
const [newData] = args;
|
|
87
|
-
|
|
86
|
+
globalCommitContext.flushOptions.triggerDataUpdated = true;
|
|
88
87
|
this.setState(newData);
|
|
89
88
|
});
|
|
90
89
|
}
|