@lynx-js/react 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +250 -0
- package/LICENSE +202 -0
- package/README.md +20 -0
- package/components/lib/Page.d.ts +3 -0
- package/components/lib/Page.js +56 -0
- package/components/lib/Page.js.map +1 -0
- package/components/lib/index.d.ts +1 -0
- package/components/lib/index.js +5 -0
- package/components/lib/index.js.map +1 -0
- package/components/src/Page.ts +75 -0
- package/components/src/index.ts +5 -0
- package/package.json +162 -0
- package/refresh/.gitignore +1 -0
- package/refresh/.npmignore +3 -0
- package/refresh/.turbo/turbo-build.log +8 -0
- package/refresh/dist/index.js +311 -0
- package/refresh/package.json +21 -0
- package/refresh/src/index.ts +6 -0
- package/refresh/src/prefresh.d.ts +11 -0
- package/refresh/tsconfig.json +4 -0
- package/refresh/turbo.json +15 -0
- package/runtime/jsx-dev-runtime/index.d.ts +5 -0
- package/runtime/jsx-dev-runtime/index.js +4 -0
- package/runtime/jsx-runtime/index.d.ts +4 -0
- package/runtime/jsx-runtime/index.js +4 -0
- package/runtime/lazy/import.d.ts +1 -0
- package/runtime/lazy/import.js +55 -0
- package/runtime/lazy/internal.js +39 -0
- package/runtime/lazy/jsx-dev-runtime.js +12 -0
- package/runtime/lazy/jsx-runtime.js +12 -0
- package/runtime/lazy/legacy-react-runtime.js +20 -0
- package/runtime/lazy/react-lepus.js +9 -0
- package/runtime/lazy/react.js +46 -0
- package/runtime/lazy/target.js +11 -0
- package/runtime/lepus/index.d.ts +4 -0
- package/runtime/lepus/index.js +43 -0
- package/runtime/lepus/jsx-dev-runtime/index.js +4 -0
- package/runtime/lepus/jsx-runtime/index.js +66 -0
- package/runtime/lib/backgroundSnapshot.d.ts +23 -0
- package/runtime/lib/backgroundSnapshot.js +348 -0
- package/runtime/lib/backgroundSnapshot.js.map +1 -0
- package/runtime/lib/compat/componentIs.d.ts +4 -0
- package/runtime/lib/compat/componentIs.js +20 -0
- package/runtime/lib/compat/componentIs.js.map +1 -0
- package/runtime/lib/compat/initData.d.ts +43 -0
- package/runtime/lib/compat/initData.js +93 -0
- package/runtime/lib/compat/initData.js.map +1 -0
- package/runtime/lib/compat/lynxComponent.d.ts +5 -0
- package/runtime/lib/compat/lynxComponent.js +71 -0
- package/runtime/lib/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/debug/debug.d.ts +2 -0
- package/runtime/lib/debug/debug.js +9 -0
- package/runtime/lib/debug/debug.js.map +1 -0
- package/runtime/lib/debug/printSnapshot.d.ts +3 -0
- package/runtime/lib/debug/printSnapshot.js +21 -0
- package/runtime/lib/debug/printSnapshot.js.map +1 -0
- package/runtime/lib/debug/profile.d.ts +1 -0
- package/runtime/lib/debug/profile.js +51 -0
- package/runtime/lib/debug/profile.js.map +1 -0
- package/runtime/lib/document.d.ts +4 -0
- package/runtime/lib/document.js +49 -0
- package/runtime/lib/document.js.map +1 -0
- package/runtime/lib/gesture/processGesture.d.ts +4 -0
- package/runtime/lib/gesture/processGesture.js +48 -0
- package/runtime/lib/gesture/processGesture.js.map +1 -0
- package/runtime/lib/gesture/processGestureBagkround.d.ts +2 -0
- package/runtime/lib/gesture/processGestureBagkround.js +16 -0
- package/runtime/lib/gesture/processGestureBagkround.js.map +1 -0
- package/runtime/lib/gesture/types.d.ts +34 -0
- package/runtime/lib/gesture/types.js +13 -0
- package/runtime/lib/gesture/types.js.map +1 -0
- package/runtime/lib/hooks/react.d.ts +26 -0
- package/runtime/lib/hooks/react.js +35 -0
- package/runtime/lib/hooks/react.js.map +1 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.d.ts +29 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js +53 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/hydrate.d.ts +18 -0
- package/runtime/lib/hydrate.js +271 -0
- package/runtime/lib/hydrate.js.map +1 -0
- package/runtime/lib/index.d.ts +9 -0
- package/runtime/lib/index.js +46 -0
- package/runtime/lib/index.js.map +1 -0
- package/runtime/lib/internal.d.ts +26 -0
- package/runtime/lib/internal.js +41 -0
- package/runtime/lib/internal.js.map +1 -0
- package/runtime/lib/legacy-react-runtime/index.d.ts +7 -0
- package/runtime/lib/legacy-react-runtime/index.js +34 -0
- package/runtime/lib/legacy-react-runtime/index.js.map +1 -0
- package/runtime/lib/lifecycle/delayUnmount.d.ts +8 -0
- package/runtime/lib/lifecycle/delayUnmount.js +68 -0
- package/runtime/lib/lifecycle/delayUnmount.js.map +1 -0
- package/runtime/lib/lifecycle/destroy.d.ts +2 -0
- package/runtime/lib/lifecycle/destroy.js +21 -0
- package/runtime/lib/lifecycle/destroy.js.map +1 -0
- package/runtime/lib/lifecycle/pass.d.ts +3 -0
- package/runtime/lib/lifecycle/pass.js +12 -0
- package/runtime/lib/lifecycle/pass.js.map +1 -0
- package/runtime/lib/lifecycle/patchUpdate.d.ts +23 -0
- package/runtime/lib/lifecycle/patchUpdate.js +179 -0
- package/runtime/lib/lifecycle/patchUpdate.js.map +1 -0
- package/runtime/lib/lifecycle/reload.d.ts +3 -0
- package/runtime/lib/lifecycle/reload.js +63 -0
- package/runtime/lib/lifecycle/reload.js.map +1 -0
- package/runtime/lib/lifecycle/render.d.ts +2 -0
- package/runtime/lib/lifecycle/render.js +44 -0
- package/runtime/lib/lifecycle/render.js.map +1 -0
- package/runtime/lib/lifecycleConstant.d.ts +12 -0
- package/runtime/lib/lifecycleConstant.js +17 -0
- package/runtime/lib/lifecycleConstant.js.map +1 -0
- package/runtime/lib/list.d.ts +40 -0
- package/runtime/lib/list.js +305 -0
- package/runtime/lib/list.js.map +1 -0
- package/runtime/lib/lynx/calledByNative.d.ts +2 -0
- package/runtime/lib/lynx/calledByNative.js +113 -0
- package/runtime/lib/lynx/calledByNative.js.map +1 -0
- package/runtime/lib/lynx/component.d.ts +1 -0
- package/runtime/lib/lynx/component.js +69 -0
- package/runtime/lib/lynx/component.js.map +1 -0
- package/runtime/lib/lynx/dynamic-js.d.ts +2 -0
- package/runtime/lib/lynx/dynamic-js.js +31 -0
- package/runtime/lib/lynx/dynamic-js.js.map +1 -0
- package/runtime/lib/lynx/env.d.ts +1 -0
- package/runtime/lib/lynx/env.js +92 -0
- package/runtime/lib/lynx/env.js.map +1 -0
- package/runtime/lib/lynx/injectLepusMethods.d.ts +2 -0
- package/runtime/lib/lynx/injectLepusMethods.js +50 -0
- package/runtime/lib/lynx/injectLepusMethods.js.map +1 -0
- package/runtime/lib/lynx/lazy-bundle.d.ts +9 -0
- package/runtime/lib/lynx/lazy-bundle.js +119 -0
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/lynx/performance.d.ts +29 -0
- package/runtime/lib/lynx/performance.js +100 -0
- package/runtime/lib/lynx/performance.js.map +1 -0
- package/runtime/lib/lynx/tt.d.ts +4 -0
- package/runtime/lib/lynx/tt.js +193 -0
- package/runtime/lib/lynx/tt.js.map +1 -0
- package/runtime/lib/lynx-api.d.ts +311 -0
- package/runtime/lib/lynx-api.js +116 -0
- package/runtime/lib/lynx-api.js.map +1 -0
- package/runtime/lib/lynx.d.ts +2 -0
- package/runtime/lib/lynx.js +91 -0
- package/runtime/lib/lynx.js.map +1 -0
- package/runtime/lib/opcodes.d.ts +2 -0
- package/runtime/lib/opcodes.js +59 -0
- package/runtime/lib/opcodes.js.map +1 -0
- package/runtime/lib/renderToOpcodes/constants.d.ts +17 -0
- package/runtime/lib/renderToOpcodes/constants.js +23 -0
- package/runtime/lib/renderToOpcodes/constants.js.map +1 -0
- package/runtime/lib/renderToOpcodes/index.d.ts +13 -0
- package/runtime/lib/renderToOpcodes/index.js +227 -0
- package/runtime/lib/renderToOpcodes/index.js.map +1 -0
- package/runtime/lib/root.d.ts +7 -0
- package/runtime/lib/root.js +17 -0
- package/runtime/lib/root.js.map +1 -0
- package/runtime/lib/snapshot/event.d.ts +3 -0
- package/runtime/lib/snapshot/event.js +24 -0
- package/runtime/lib/snapshot/event.js.map +1 -0
- package/runtime/lib/snapshot/gesture.d.ts +2 -0
- package/runtime/lib/snapshot/gesture.js +18 -0
- package/runtime/lib/snapshot/gesture.js.map +1 -0
- package/runtime/lib/snapshot/platformInfo.d.ts +4 -0
- package/runtime/lib/snapshot/platformInfo.js +35 -0
- package/runtime/lib/snapshot/platformInfo.js.map +1 -0
- package/runtime/lib/snapshot/ref.d.ts +10 -0
- package/runtime/lib/snapshot/ref.js +119 -0
- package/runtime/lib/snapshot/ref.js.map +1 -0
- package/runtime/lib/snapshot/spread.d.ts +5 -0
- package/runtime/lib/snapshot/spread.js +289 -0
- package/runtime/lib/snapshot/spread.js.map +1 -0
- package/runtime/lib/snapshot/workletEvent.d.ts +3 -0
- package/runtime/lib/snapshot/workletEvent.js +22 -0
- package/runtime/lib/snapshot/workletEvent.js.map +1 -0
- package/runtime/lib/snapshot/workletRef.d.ts +5 -0
- package/runtime/lib/snapshot/workletRef.js +52 -0
- package/runtime/lib/snapshot/workletRef.js.map +1 -0
- package/runtime/lib/snapshot.d.ts +81 -0
- package/runtime/lib/snapshot.js +477 -0
- package/runtime/lib/snapshot.js.map +1 -0
- package/runtime/lib/snapshotPatch.d.ts +14 -0
- package/runtime/lib/snapshotPatch.js +31 -0
- package/runtime/lib/snapshotPatch.js.map +1 -0
- package/runtime/lib/snapshotPatchApply.d.ts +2 -0
- package/runtime/lib/snapshotPatchApply.js +110 -0
- package/runtime/lib/snapshotPatchApply.js.map +1 -0
- package/runtime/lib/utils.d.ts +4 -0
- package/runtime/lib/utils.js +32 -0
- package/runtime/lib/utils.js.map +1 -0
- package/runtime/lib/worklet/ctx.d.ts +1 -0
- package/runtime/lib/worklet/ctx.js +17 -0
- package/runtime/lib/worklet/ctx.js.map +1 -0
- package/runtime/lib/worklet/execMap.d.ts +1 -0
- package/runtime/lib/worklet/execMap.js +42 -0
- package/runtime/lib/worklet/execMap.js.map +1 -0
- package/runtime/lib/worklet/functionality.d.ts +1 -0
- package/runtime/lib/worklet/functionality.js +11 -0
- package/runtime/lib/worklet/functionality.js.map +1 -0
- package/runtime/lib/worklet/hmr.d.ts +1 -0
- package/runtime/lib/worklet/hmr.js +21 -0
- package/runtime/lib/worklet/hmr.js.map +1 -0
- package/runtime/lib/worklet/indexMap.d.ts +8 -0
- package/runtime/lib/worklet/indexMap.js +17 -0
- package/runtime/lib/worklet/indexMap.js.map +1 -0
- package/runtime/lib/worklet/jsImpl.d.ts +11 -0
- package/runtime/lib/worklet/jsImpl.js +68 -0
- package/runtime/lib/worklet/jsImpl.js.map +1 -0
- package/runtime/lib/worklet/runWorklet.d.ts +14 -0
- package/runtime/lib/worklet/runWorklet.js +82 -0
- package/runtime/lib/worklet/runWorklet.js.map +1 -0
- package/runtime/lib/worklet/workletRef.d.ts +131 -0
- package/runtime/lib/worklet/workletRef.js +96 -0
- package/runtime/lib/worklet/workletRef.js.map +1 -0
- package/runtime/lib/worklet/workletRefPool.d.ts +2 -0
- package/runtime/lib/worklet/workletRefPool.js +22 -0
- package/runtime/lib/worklet/workletRefPool.js.map +1 -0
- package/runtime/src/backgroundSnapshot.ts +452 -0
- package/runtime/src/compat/componentIs.ts +30 -0
- package/runtime/src/compat/initData.ts +140 -0
- package/runtime/src/compat/lynxComponent.ts +80 -0
- package/runtime/src/debug/debug.ts +9 -0
- package/runtime/src/debug/printSnapshot.ts +28 -0
- package/runtime/src/debug/profile.ts +54 -0
- package/runtime/src/document.ts +53 -0
- package/runtime/src/gesture/processGesture.ts +77 -0
- package/runtime/src/gesture/processGestureBagkround.ts +15 -0
- package/runtime/src/gesture/types.ts +39 -0
- package/runtime/src/hooks/react.ts +62 -0
- package/runtime/src/hooks/useLynxGlobalEventListener.ts +59 -0
- package/runtime/src/hydrate.ts +364 -0
- package/runtime/src/index.ts +89 -0
- package/runtime/src/internal.ts +60 -0
- package/runtime/src/legacy-react-runtime/index.ts +40 -0
- package/runtime/src/lifecycle/delayUnmount.ts +77 -0
- package/runtime/src/lifecycle/destroy.ts +26 -0
- package/runtime/src/lifecycle/pass.ts +14 -0
- package/runtime/src/lifecycle/patchUpdate.ts +240 -0
- package/runtime/src/lifecycle/reload.ts +79 -0
- package/runtime/src/lifecycle/render.ts +46 -0
- package/runtime/src/lifecycleConstant.ts +16 -0
- package/runtime/src/list.ts +375 -0
- package/runtime/src/lynx/calledByNative.ts +132 -0
- package/runtime/src/lynx/component.ts +116 -0
- package/runtime/src/lynx/dynamic-js.ts +33 -0
- package/runtime/src/lynx/env.ts +110 -0
- package/runtime/src/lynx/injectLepusMethods.ts +53 -0
- package/runtime/src/lynx/lazy-bundle.ts +126 -0
- package/runtime/src/lynx/performance.ts +117 -0
- package/runtime/src/lynx/tt.ts +212 -0
- package/runtime/src/lynx-api.ts +374 -0
- package/runtime/src/lynx.ts +105 -0
- package/runtime/src/opcodes.ts +64 -0
- package/runtime/src/renderToOpcodes/constants.ts +24 -0
- package/runtime/src/renderToOpcodes/index.ts +301 -0
- package/runtime/src/root.ts +19 -0
- package/runtime/src/snapshot/event.ts +33 -0
- package/runtime/src/snapshot/gesture.ts +25 -0
- package/runtime/src/snapshot/platformInfo.ts +48 -0
- package/runtime/src/snapshot/ref.ts +151 -0
- package/runtime/src/snapshot/spread.ts +287 -0
- package/runtime/src/snapshot/workletEvent.ts +33 -0
- package/runtime/src/snapshot/workletRef.ts +63 -0
- package/runtime/src/snapshot.ts +576 -0
- package/runtime/src/snapshotPatch.ts +56 -0
- package/runtime/src/snapshotPatchApply.ts +117 -0
- package/runtime/src/utils.ts +35 -0
- package/runtime/src/worklet/ctx.ts +22 -0
- package/runtime/src/worklet/execMap.ts +50 -0
- package/runtime/src/worklet/functionality.ts +12 -0
- package/runtime/src/worklet/hmr.ts +26 -0
- package/runtime/src/worklet/indexMap.ts +20 -0
- package/runtime/src/worklet/jsImpl.ts +86 -0
- package/runtime/src/worklet/runWorklet.ts +88 -0
- package/runtime/src/worklet/workletRef.ts +229 -0
- package/runtime/src/worklet/workletRefPool.ts +25 -0
- package/transform/cjs/main.cjs +6 -0
- package/transform/cjs/main.d.cts +3 -0
- package/transform/cjs/package.json +3 -0
- package/transform/dist/wasm.cjs +8478 -0
- package/transform/index.d.ts +187 -0
- package/transform/main.js +15 -0
- package/types/react.d.ts +147 -0
- package/types/react.docs.d.ts +74 -0
- package/worklet-runtime/dist/dev.js +414 -0
- package/worklet-runtime/dist/dev.js.map +8 -0
- package/worklet-runtime/dist/main.js +414 -0
- package/worklet-runtime/dist/main.js.map +8 -0
- package/worklet-runtime/lib/api/element.d.ts +14 -0
- package/worklet-runtime/lib/api/element.js +71 -0
- package/worklet-runtime/lib/api/element.js.map +1 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.d.ts +3 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js +23 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js.map +1 -0
- package/worklet-runtime/lib/api/lynxApi.d.ts +2 -0
- package/worklet-runtime/lib/api/lynxApi.js +35 -0
- package/worklet-runtime/lib/api/lynxApi.js.map +1 -0
- package/worklet-runtime/lib/bindings/bindings.d.ts +14 -0
- package/worklet-runtime/lib/bindings/bindings.js +61 -0
- package/worklet-runtime/lib/bindings/bindings.js.map +1 -0
- package/worklet-runtime/lib/bindings/events.d.ts +7 -0
- package/worklet-runtime/lib/bindings/events.js +9 -0
- package/worklet-runtime/lib/bindings/events.js.map +1 -0
- package/worklet-runtime/lib/bindings/index.d.ts +4 -0
- package/worklet-runtime/lib/bindings/index.js +7 -0
- package/worklet-runtime/lib/bindings/index.js.map +1 -0
- package/worklet-runtime/lib/bindings/loadRuntime.d.ts +8 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js +25 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js.map +1 -0
- package/worklet-runtime/lib/bindings/types.d.ts +35 -0
- package/worklet-runtime/lib/bindings/types.js +2 -0
- package/worklet-runtime/lib/bindings/types.js.map +1 -0
- package/worklet-runtime/lib/delayWorkletEvent.d.ts +11 -0
- package/worklet-runtime/lib/delayWorkletEvent.js +49 -0
- package/worklet-runtime/lib/delayWorkletEvent.js.map +1 -0
- package/worklet-runtime/lib/global.d.ts +15 -0
- package/worklet-runtime/lib/global.js +2 -0
- package/worklet-runtime/lib/global.js.map +1 -0
- package/worklet-runtime/lib/index.d.ts +1 -0
- package/worklet-runtime/lib/index.js +12 -0
- package/worklet-runtime/lib/index.js.map +1 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.d.ts +18 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js +55 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js.map +1 -0
- package/worklet-runtime/lib/listeners.d.ts +2 -0
- package/worklet-runtime/lib/listeners.js +17 -0
- package/worklet-runtime/lib/listeners.js.map +1 -0
- package/worklet-runtime/lib/utils/profile.d.ts +1 -0
- package/worklet-runtime/lib/utils/profile.js +20 -0
- package/worklet-runtime/lib/utils/profile.js.map +1 -0
- package/worklet-runtime/lib/utils/version.d.ts +1 -0
- package/worklet-runtime/lib/utils/version.js +10 -0
- package/worklet-runtime/lib/utils/version.js.map +1 -0
- package/worklet-runtime/lib/workletRef.d.ts +12 -0
- package/worklet-runtime/lib/workletRef.js +50 -0
- package/worklet-runtime/lib/workletRef.js.map +1 -0
- package/worklet-runtime/lib/workletRuntime.d.ts +2 -0
- package/worklet-runtime/lib/workletRuntime.js +128 -0
- package/worklet-runtime/lib/workletRuntime.js.map +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { sExportsJSXDevRuntime, target } from './target';
|
|
6
|
+
|
|
7
|
+
export const {
|
|
8
|
+
Fragment,
|
|
9
|
+
jsx,
|
|
10
|
+
jsxDEV,
|
|
11
|
+
jsxs,
|
|
12
|
+
} = target[sExportsJSXDevRuntime];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { sExportsJSXRuntime, target } from './target';
|
|
6
|
+
|
|
7
|
+
export const {
|
|
8
|
+
Fragment,
|
|
9
|
+
jsx,
|
|
10
|
+
jsxDEV,
|
|
11
|
+
jsxs,
|
|
12
|
+
} = target[sExportsJSXRuntime];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { sExportsLegacyReactRuntime, target } from './target';
|
|
6
|
+
|
|
7
|
+
export const {
|
|
8
|
+
Component,
|
|
9
|
+
PureComponent,
|
|
10
|
+
__runInJS,
|
|
11
|
+
createContext,
|
|
12
|
+
lazy,
|
|
13
|
+
useCallback,
|
|
14
|
+
useEffect,
|
|
15
|
+
useMemo,
|
|
16
|
+
useReducer,
|
|
17
|
+
useState,
|
|
18
|
+
} = target[sExportsLegacyReactRuntime];
|
|
19
|
+
|
|
20
|
+
export default target[sExportsLegacyReactRuntime]['default'];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { sExportsReactLepus, target } from './target';
|
|
6
|
+
|
|
7
|
+
export const {
|
|
8
|
+
createElement,
|
|
9
|
+
} = target[sExportsReactLepus];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { sExportsReact, target } from './target';
|
|
6
|
+
|
|
7
|
+
export const {
|
|
8
|
+
Children,
|
|
9
|
+
Component,
|
|
10
|
+
Fragment,
|
|
11
|
+
InitDataConsumer,
|
|
12
|
+
InitDataProvider,
|
|
13
|
+
MainThreadRef,
|
|
14
|
+
PureComponent,
|
|
15
|
+
Suspense,
|
|
16
|
+
createContext,
|
|
17
|
+
createElement,
|
|
18
|
+
createRef,
|
|
19
|
+
forwardRef,
|
|
20
|
+
isValidElement,
|
|
21
|
+
lazy,
|
|
22
|
+
memo,
|
|
23
|
+
root,
|
|
24
|
+
runOnBackground,
|
|
25
|
+
runOnMainThread,
|
|
26
|
+
useCallback,
|
|
27
|
+
useContext,
|
|
28
|
+
useDebugValue,
|
|
29
|
+
useEffect,
|
|
30
|
+
useErrorBoundary,
|
|
31
|
+
useId,
|
|
32
|
+
useImperativeHandle,
|
|
33
|
+
useInitData,
|
|
34
|
+
useInitDataChanged,
|
|
35
|
+
useLynxGlobalEventListener,
|
|
36
|
+
useLayoutEffect,
|
|
37
|
+
useMainThreadRef,
|
|
38
|
+
useMemo,
|
|
39
|
+
useReducer,
|
|
40
|
+
useRef,
|
|
41
|
+
useState,
|
|
42
|
+
useSyncExternalStore,
|
|
43
|
+
withInitDataInState,
|
|
44
|
+
} = target[sExportsReact];
|
|
45
|
+
|
|
46
|
+
export default target[sExportsReact]['default'];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export const target = __LEPUS__ ? globalThis : lynx;
|
|
5
|
+
|
|
6
|
+
export const sExportsReact = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react)');
|
|
7
|
+
export const sExportsReactLepus = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/lepus)');
|
|
8
|
+
export const sExportsReactInternal = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/internal)');
|
|
9
|
+
export const sExportsJSXRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-runtime)');
|
|
10
|
+
export const sExportsJSXDevRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/jsx-dev-runtime)');
|
|
11
|
+
export const sExportsLegacyReactRuntime = Symbol.for('__REACT_LYNX_EXPORTS__(@lynx-js/react/legacy-react-runtime)');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { jsx as createVNode } from './jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const slice = /* @__PURE__ */ [].slice;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create an virtual node (used for JSX)
|
|
10
|
+
* @param {VNode["type"]} type The node name or Component constructor for this
|
|
11
|
+
* virtual node
|
|
12
|
+
* @param {object | null | undefined} [props] The properties of the virtual node
|
|
13
|
+
* @param {Array<import('.').ComponentChildren>} [children] The children of the
|
|
14
|
+
* virtual node
|
|
15
|
+
* @returns {VNode}
|
|
16
|
+
*/
|
|
17
|
+
export function createElement(type, props, children) {
|
|
18
|
+
let normalizedProps = {},
|
|
19
|
+
key,
|
|
20
|
+
ref,
|
|
21
|
+
i;
|
|
22
|
+
for (i in props) {
|
|
23
|
+
if (i == 'key') key = props[i];
|
|
24
|
+
else if (i == 'ref') ref = props[i];
|
|
25
|
+
else normalizedProps[i] = props[i];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (arguments.length > 2) {
|
|
29
|
+
normalizedProps.children = arguments.length > 3 ? slice.call(arguments, 2) : children;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// If a Component VNode, check for and apply defaultProps
|
|
33
|
+
// Note: type may be undefined in development, must never error here.
|
|
34
|
+
if (typeof type == 'function' && type.defaultProps != null) {
|
|
35
|
+
for (i in type.defaultProps) {
|
|
36
|
+
if (normalizedProps[i] === undefined) {
|
|
37
|
+
normalizedProps[i] = type.defaultProps[i];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return createVNode(type, normalizedProps, key, ref, null);
|
|
43
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { SnapshotInstance } from '@lynx-js/react/internal';
|
|
5
|
+
|
|
6
|
+
function createVNode(type, props, _key) {
|
|
7
|
+
if (typeof type === 'string') {
|
|
8
|
+
const r = new SnapshotInstance(type);
|
|
9
|
+
|
|
10
|
+
r.props = props;
|
|
11
|
+
|
|
12
|
+
r.__k = null;
|
|
13
|
+
r.__ = null;
|
|
14
|
+
r.__b = 0;
|
|
15
|
+
r.__e = null;
|
|
16
|
+
r.__d = undefined;
|
|
17
|
+
r.__c = null;
|
|
18
|
+
// r.__v = --vnodeId;
|
|
19
|
+
r.__i = -1;
|
|
20
|
+
r.__u = 0;
|
|
21
|
+
|
|
22
|
+
return r;
|
|
23
|
+
} else if (typeof type === 'function') {
|
|
24
|
+
let normalizedProps = props;
|
|
25
|
+
|
|
26
|
+
// let ref;
|
|
27
|
+
if ('ref' in normalizedProps) {
|
|
28
|
+
normalizedProps = {};
|
|
29
|
+
for (let i in props) {
|
|
30
|
+
if (i == 'ref') {
|
|
31
|
+
// ref = props[i];
|
|
32
|
+
} else {
|
|
33
|
+
normalizedProps[i] = props[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let defaultProps;
|
|
39
|
+
if ((defaultProps = type.defaultProps)) {
|
|
40
|
+
for (let i in defaultProps) {
|
|
41
|
+
if (typeof normalizedProps[i] === 'undefined') {
|
|
42
|
+
normalizedProps[i] = defaultProps[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
type,
|
|
49
|
+
props: normalizedProps,
|
|
50
|
+
|
|
51
|
+
__k: null,
|
|
52
|
+
__: null,
|
|
53
|
+
__b: 0,
|
|
54
|
+
__e: null,
|
|
55
|
+
__d: void 0,
|
|
56
|
+
__c: null,
|
|
57
|
+
constructor: void 0,
|
|
58
|
+
// __v: --vnodeId,
|
|
59
|
+
__i: -1,
|
|
60
|
+
__u: 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { createVNode as jsx, createVNode as jsxs, createVNode as jsxDEV };
|
|
66
|
+
export { Fragment } from 'preact';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SerializedSnapshotInstance } from './snapshot.js';
|
|
2
|
+
import type { SnapshotPatch } from './snapshotPatch.js';
|
|
3
|
+
export declare class BackgroundSnapshotInstance {
|
|
4
|
+
type: string;
|
|
5
|
+
constructor(type: string);
|
|
6
|
+
__id: number;
|
|
7
|
+
__values: any[] | undefined;
|
|
8
|
+
private __parent;
|
|
9
|
+
private __firstChild;
|
|
10
|
+
private __lastChild;
|
|
11
|
+
private __previousSibling;
|
|
12
|
+
private __nextSibling;
|
|
13
|
+
get parentNode(): BackgroundSnapshotInstance | null;
|
|
14
|
+
get nextSibling(): BackgroundSnapshotInstance | null;
|
|
15
|
+
contains(child: BackgroundSnapshotInstance): boolean;
|
|
16
|
+
appendChild(child: BackgroundSnapshotInstance): void;
|
|
17
|
+
insertBefore(node: BackgroundSnapshotInstance, beforeNode?: BackgroundSnapshotInstance): void;
|
|
18
|
+
removeChild(node: BackgroundSnapshotInstance): void;
|
|
19
|
+
get childNodes(): BackgroundSnapshotInstance[];
|
|
20
|
+
setAttribute(key: string | number, value: any): void;
|
|
21
|
+
private setAttributeImpl;
|
|
22
|
+
}
|
|
23
|
+
export declare function hydrate(before: SerializedSnapshotInstance, after: BackgroundSnapshotInstance): SnapshotPatch;
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { diffArrayAction, diffArrayLepus } from './hydrate.js';
|
|
2
|
+
import { globalBackgroundSnapshotInstancesToRemove } from './lifecycle/patchUpdate.js';
|
|
3
|
+
import { markRefToRemove } from './snapshot/ref.js';
|
|
4
|
+
import { transformSpread } from './snapshot/spread.js';
|
|
5
|
+
import { DynamicPartType, backgroundSnapshotInstanceManager, snapshotManager, traverseSnapshotInstance, } from './snapshot.js';
|
|
6
|
+
import { SnapshotOperation, __globalSnapshotPatch, initGlobalSnapshotPatch, takeGlobalSnapshotPatch, } from './snapshotPatch.js';
|
|
7
|
+
import { isDirectOrDeepEqual } from './utils.js';
|
|
8
|
+
import { onPostWorkletCtx } from './worklet/ctx.js';
|
|
9
|
+
import { processGestureBackground } from './gesture/processGestureBagkround.js';
|
|
10
|
+
import { globalPipelineOptions } from './lynx/performance.js';
|
|
11
|
+
export class BackgroundSnapshotInstance {
|
|
12
|
+
type;
|
|
13
|
+
constructor(type) {
|
|
14
|
+
this.type = type;
|
|
15
|
+
let id;
|
|
16
|
+
id = this.__id = backgroundSnapshotInstanceManager.nextId += 1;
|
|
17
|
+
backgroundSnapshotInstanceManager.values.set(id, this);
|
|
18
|
+
__globalSnapshotPatch?.push(SnapshotOperation.CreateElement, type, id);
|
|
19
|
+
}
|
|
20
|
+
__id;
|
|
21
|
+
__values;
|
|
22
|
+
__parent = null;
|
|
23
|
+
__firstChild = null;
|
|
24
|
+
__lastChild = null;
|
|
25
|
+
__previousSibling = null;
|
|
26
|
+
__nextSibling = null;
|
|
27
|
+
get parentNode() {
|
|
28
|
+
return this.__parent;
|
|
29
|
+
}
|
|
30
|
+
get nextSibling() {
|
|
31
|
+
return this.__nextSibling;
|
|
32
|
+
}
|
|
33
|
+
// get isConnected() {
|
|
34
|
+
// return !!this.__parent;
|
|
35
|
+
// }
|
|
36
|
+
contains(child) {
|
|
37
|
+
return child.parentNode === this;
|
|
38
|
+
}
|
|
39
|
+
// TODO: write tests for this
|
|
40
|
+
// This will be called in `lazy`/`Suspense`.
|
|
41
|
+
// We currently ignore this since we did not find a way to test.
|
|
42
|
+
/* v8 ignore start */
|
|
43
|
+
appendChild(child) {
|
|
44
|
+
return this.insertBefore(child);
|
|
45
|
+
}
|
|
46
|
+
/* v8 ignore stop */
|
|
47
|
+
insertBefore(node, beforeNode) {
|
|
48
|
+
__globalSnapshotPatch?.push(SnapshotOperation.InsertBefore, this.__id, node.__id, beforeNode?.__id);
|
|
49
|
+
// If the node already has a parent, remove it from its current parent
|
|
50
|
+
const p = node.__parent;
|
|
51
|
+
if (p) {
|
|
52
|
+
if (node.__previousSibling) {
|
|
53
|
+
node.__previousSibling.__nextSibling = node.__nextSibling;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
p.__firstChild = node.__nextSibling;
|
|
57
|
+
}
|
|
58
|
+
if (node.__nextSibling) {
|
|
59
|
+
node.__nextSibling.__previousSibling = node.__previousSibling;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
p.__lastChild = node.__previousSibling;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// If beforeNode is not provided, add the new node as the last child
|
|
66
|
+
if (beforeNode) {
|
|
67
|
+
// If beforeNode is provided, insert the new node before beforeNode
|
|
68
|
+
if (beforeNode.__previousSibling) {
|
|
69
|
+
beforeNode.__previousSibling.__nextSibling = node;
|
|
70
|
+
node.__previousSibling = beforeNode.__previousSibling;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.__firstChild = node;
|
|
74
|
+
node.__previousSibling = null;
|
|
75
|
+
}
|
|
76
|
+
beforeNode.__previousSibling = node;
|
|
77
|
+
node.__nextSibling = beforeNode;
|
|
78
|
+
node.__parent = this;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (this.__lastChild) {
|
|
82
|
+
this.__lastChild.__nextSibling = node;
|
|
83
|
+
node.__previousSibling = this.__lastChild;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.__firstChild = node;
|
|
87
|
+
node.__previousSibling = null;
|
|
88
|
+
}
|
|
89
|
+
this.__lastChild = node;
|
|
90
|
+
node.__parent = this;
|
|
91
|
+
node.__nextSibling = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
removeChild(node) {
|
|
95
|
+
__globalSnapshotPatch?.push(SnapshotOperation.RemoveChild, this.__id, node.__id);
|
|
96
|
+
if (node.__parent !== this) {
|
|
97
|
+
throw new Error('The node to be removed is not a child of this node.');
|
|
98
|
+
}
|
|
99
|
+
if (node.__previousSibling) {
|
|
100
|
+
node.__previousSibling.__nextSibling = node.__nextSibling;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.__firstChild = node.__nextSibling;
|
|
104
|
+
}
|
|
105
|
+
if (node.__nextSibling) {
|
|
106
|
+
node.__nextSibling.__previousSibling = node.__previousSibling;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.__lastChild = node.__previousSibling;
|
|
110
|
+
}
|
|
111
|
+
node.__parent = null;
|
|
112
|
+
node.__previousSibling = null;
|
|
113
|
+
node.__nextSibling = null;
|
|
114
|
+
traverseSnapshotInstance(node, v => {
|
|
115
|
+
v.__parent = null;
|
|
116
|
+
globalBackgroundSnapshotInstancesToRemove.push(v.__id);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
get childNodes() {
|
|
120
|
+
const nodes = [];
|
|
121
|
+
let node = this.__firstChild;
|
|
122
|
+
while (node) {
|
|
123
|
+
nodes.push(node);
|
|
124
|
+
if (node === this.__lastChild) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
node = node.__nextSibling;
|
|
128
|
+
}
|
|
129
|
+
return nodes;
|
|
130
|
+
}
|
|
131
|
+
setAttribute(key, value) {
|
|
132
|
+
if (__PROFILE__) {
|
|
133
|
+
console.profile('setAttribute');
|
|
134
|
+
}
|
|
135
|
+
if (key === 'values') {
|
|
136
|
+
if (__globalSnapshotPatch) {
|
|
137
|
+
const oldValues = this.__values;
|
|
138
|
+
if (oldValues) {
|
|
139
|
+
for (let index = 0; index < value.length; index++) {
|
|
140
|
+
const { needUpdate, valueToCommit } = this.setAttributeImpl(value[index], oldValues[index], index);
|
|
141
|
+
if (needUpdate) {
|
|
142
|
+
__globalSnapshotPatch?.push(SnapshotOperation.SetAttribute, this.__id, index, valueToCommit);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const patch = [];
|
|
148
|
+
const length = value.length;
|
|
149
|
+
for (let index = 0; index < length; ++index) {
|
|
150
|
+
const { valueToCommit } = this.setAttributeImpl(value[index], null, index);
|
|
151
|
+
patch[index] = valueToCommit;
|
|
152
|
+
}
|
|
153
|
+
__globalSnapshotPatch?.push(SnapshotOperation.SetAttributes, this.__id, patch);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.__values = value;
|
|
157
|
+
if (__PROFILE__) {
|
|
158
|
+
console.profileEnd();
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// old path (`<__snapshot_xxxx_xxxx __0={} __1={} />` or `this.setAttribute(0, xxx)`)
|
|
163
|
+
// is reserved as slow path
|
|
164
|
+
const index = typeof key === 'string' ? Number(key.slice(2)) : key;
|
|
165
|
+
(this.__values ??= [])[index] = value;
|
|
166
|
+
__globalSnapshotPatch?.push(SnapshotOperation.SetAttribute, this.__id, index, value);
|
|
167
|
+
if (__PROFILE__) {
|
|
168
|
+
console.profileEnd();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
setAttributeImpl(newValue, oldValue, index) {
|
|
172
|
+
if (!newValue) {
|
|
173
|
+
if (oldValue && oldValue.__ref) {
|
|
174
|
+
markRefToRemove(`${this.__id}:${index}:`, oldValue);
|
|
175
|
+
}
|
|
176
|
+
return { needUpdate: oldValue !== newValue, valueToCommit: newValue };
|
|
177
|
+
}
|
|
178
|
+
const newType = typeof newValue;
|
|
179
|
+
if (newType === 'object') {
|
|
180
|
+
if (newValue.__spread) {
|
|
181
|
+
const oldSpread = oldValue ? oldValue.__spread : oldValue;
|
|
182
|
+
const newSpread = transformSpread(this, index, newValue);
|
|
183
|
+
const needUpdate = !isDirectOrDeepEqual(oldSpread, newSpread);
|
|
184
|
+
// use __spread to cache the transform result for next diff
|
|
185
|
+
newValue.__spread = newSpread;
|
|
186
|
+
if (needUpdate) {
|
|
187
|
+
if (oldSpread && oldSpread.ref) {
|
|
188
|
+
markRefToRemove(`${this.__id}:${index}:ref`, oldValue.ref);
|
|
189
|
+
}
|
|
190
|
+
for (let key in newSpread) {
|
|
191
|
+
const newSpreadValue = newSpread[key];
|
|
192
|
+
if (!newSpreadValue) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (newSpreadValue._wkltId) {
|
|
196
|
+
newSpread[key] = onPostWorkletCtx(newSpreadValue);
|
|
197
|
+
}
|
|
198
|
+
else if (newSpreadValue.__isGesture) {
|
|
199
|
+
processGestureBackground(newSpreadValue);
|
|
200
|
+
}
|
|
201
|
+
else if (key == '__lynx_timing_flag' && oldSpread?.[key] != newSpreadValue) {
|
|
202
|
+
if (globalPipelineOptions) {
|
|
203
|
+
globalPipelineOptions.needTimestamps = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { needUpdate, valueToCommit: newSpread };
|
|
209
|
+
}
|
|
210
|
+
if (newValue.__ref) {
|
|
211
|
+
// force update to update ref value
|
|
212
|
+
// TODO: ref: optimize this. The ref update maybe can be done on the background thread to reduce updating.
|
|
213
|
+
// The old ref must have a place to be stored because it needs to be cleared when the main thread returns.
|
|
214
|
+
markRefToRemove(`${this.__id}:${index}:`, oldValue);
|
|
215
|
+
// update ref. On the main thread, the ref id will be replaced with value's sign when updating.
|
|
216
|
+
return { needUpdate: true, valueToCommit: newValue.__ref };
|
|
217
|
+
}
|
|
218
|
+
if (newValue._wkltId) {
|
|
219
|
+
return { needUpdate: true, valueToCommit: onPostWorkletCtx(newValue) };
|
|
220
|
+
}
|
|
221
|
+
if (newValue.__isGesture) {
|
|
222
|
+
processGestureBackground(newValue);
|
|
223
|
+
return { needUpdate: true, valueToCommit: newValue };
|
|
224
|
+
}
|
|
225
|
+
if (newValue.__ltf) {
|
|
226
|
+
// __lynx_timing_flag
|
|
227
|
+
if (globalPipelineOptions && oldValue?.__ltf != newValue.__ltf) {
|
|
228
|
+
globalPipelineOptions.needTimestamps = true;
|
|
229
|
+
return { needUpdate: true, valueToCommit: newValue };
|
|
230
|
+
}
|
|
231
|
+
return { needUpdate: false, valueToCommit: newValue };
|
|
232
|
+
}
|
|
233
|
+
return { needUpdate: !isDirectOrDeepEqual(oldValue, newValue), valueToCommit: newValue };
|
|
234
|
+
}
|
|
235
|
+
if (newType === 'function') {
|
|
236
|
+
if (newValue.__ref) {
|
|
237
|
+
markRefToRemove(`${this.__id}:${index}:`, oldValue);
|
|
238
|
+
return { needUpdate: true, valueToCommit: newValue.__ref };
|
|
239
|
+
}
|
|
240
|
+
/* event */
|
|
241
|
+
return { needUpdate: !oldValue, valueToCommit: 1 };
|
|
242
|
+
}
|
|
243
|
+
return { needUpdate: oldValue !== newValue, valueToCommit: newValue };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
export function hydrate(before, after) {
|
|
247
|
+
initGlobalSnapshotPatch();
|
|
248
|
+
const helper2 = (afters, parentId) => {
|
|
249
|
+
for (const child of afters) {
|
|
250
|
+
const id = child.__id;
|
|
251
|
+
__globalSnapshotPatch.push(SnapshotOperation.CreateElement, child.type, id);
|
|
252
|
+
const values = child.__values;
|
|
253
|
+
if (values) {
|
|
254
|
+
child.__values = undefined;
|
|
255
|
+
child.setAttribute('values', values);
|
|
256
|
+
}
|
|
257
|
+
helper2(child.childNodes, id);
|
|
258
|
+
__globalSnapshotPatch.push(SnapshotOperation.InsertBefore, parentId, id, undefined);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const helper = (before, after) => {
|
|
262
|
+
backgroundSnapshotInstanceManager.updateId(after.__id, before.id);
|
|
263
|
+
after.__values?.forEach((value, index) => {
|
|
264
|
+
const old = before.values[index];
|
|
265
|
+
if (value) {
|
|
266
|
+
if (value.__spread) {
|
|
267
|
+
// `value.__spread` my contain event ids using snapshot ids before hydration. Remove it.
|
|
268
|
+
delete value.__spread;
|
|
269
|
+
value = transformSpread(after, index, value);
|
|
270
|
+
for (let key in value) {
|
|
271
|
+
if (value[key] && value[key]._wkltId) {
|
|
272
|
+
onPostWorkletCtx(value[key]);
|
|
273
|
+
}
|
|
274
|
+
else if (value[key] && value[key].__isGesture) {
|
|
275
|
+
processGestureBackground(value[key]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
after.__values[index].__spread = value;
|
|
279
|
+
}
|
|
280
|
+
else if (value.__ref) {
|
|
281
|
+
if (old) {
|
|
282
|
+
// skip patch
|
|
283
|
+
value = old;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
value = value.__ref;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else if (typeof value === 'function') {
|
|
290
|
+
value = `${after.__id}:${index}:`;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (value && value._wkltId) {
|
|
294
|
+
onPostWorkletCtx(value);
|
|
295
|
+
}
|
|
296
|
+
else if (value && value.__isGesture) {
|
|
297
|
+
processGestureBackground(value);
|
|
298
|
+
}
|
|
299
|
+
if (!isDirectOrDeepEqual(value, old)) {
|
|
300
|
+
__globalSnapshotPatch.push(SnapshotOperation.SetAttribute, after.__id, index, value);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
const { slot } = snapshotManager.values.get(after.type);
|
|
304
|
+
const beforeChildNodes = before.children || [];
|
|
305
|
+
const afterChildNodes = after.childNodes;
|
|
306
|
+
if (!slot) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
slot.forEach(([type], index) => {
|
|
310
|
+
switch (type) {
|
|
311
|
+
case DynamicPartType.Slot:
|
|
312
|
+
case DynamicPartType.MultiChildren: {
|
|
313
|
+
// TODO: the following null assertions are not 100% safe
|
|
314
|
+
const v1 = beforeChildNodes[index];
|
|
315
|
+
const v2 = afterChildNodes[index];
|
|
316
|
+
helper(v1, v2);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case DynamicPartType.Children:
|
|
320
|
+
case DynamicPartType.ListChildren: {
|
|
321
|
+
const diffResult = diffArrayLepus(beforeChildNodes, afterChildNodes, (a, b) => a.type === b.type, (a, b) => {
|
|
322
|
+
helper(a, b);
|
|
323
|
+
});
|
|
324
|
+
diffArrayAction(beforeChildNodes, diffResult, (node, target) => {
|
|
325
|
+
__globalSnapshotPatch.push(SnapshotOperation.CreateElement, node.type, node.__id);
|
|
326
|
+
helper2(node.childNodes, node.__id);
|
|
327
|
+
const values = node.__values;
|
|
328
|
+
if (values) {
|
|
329
|
+
node.__values = undefined;
|
|
330
|
+
node.setAttribute('values', values);
|
|
331
|
+
}
|
|
332
|
+
__globalSnapshotPatch.push(SnapshotOperation.InsertBefore, before.id, node.__id, target?.id);
|
|
333
|
+
return undefined;
|
|
334
|
+
}, node => {
|
|
335
|
+
__globalSnapshotPatch.push(SnapshotOperation.RemoveChild, before.id, node.id);
|
|
336
|
+
}, (node, target) => {
|
|
337
|
+
// changedList.push([SnapshotOperation.RemoveChild, before.id, node.id]);
|
|
338
|
+
__globalSnapshotPatch.push(SnapshotOperation.InsertBefore, before.id, node.id, target?.id);
|
|
339
|
+
});
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
helper(before, after);
|
|
346
|
+
return takeGlobalSnapshotPatch();
|
|
347
|
+
}
|
|
348
|
+
//# source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AAC,IAAI,CAAC,CAAC;wBACpC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;wBAC7B,IAAI,MAAM,EAAE,CAAC;4BACX,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;4BAC1B,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;wBACtC,CAAC;wBACD,qBAAsB,CAAC,IAAI,CACzB,iBAAiB,CAAC,YAAY,EAC9B,MAAM,CAAC,EAAE,EACT,IAAI,CAAC,IAAI,EACT,MAAM,EAAE,EAAE,CACX,CAAC;wBACF,OAAO,SAAkD,CAAC;oBAC5D,CAAC,EACD,IAAI,CAAC,EAAE;wBACL,qBAAsB,CAAC,IAAI,CACzB,iBAAiB,CAAC,WAAW,EAC7B,MAAM,CAAC,EAAE,EACT,IAAI,CAAC,EAAE,CACR,CAAC;oBACJ,CAAC,EACD,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;wBACf,yEAAyE;wBACzE,qBAAsB,CAAC,IAAI,CACzB,iBAAiB,CAAC,YAAY,EAC9B,MAAM,CAAC,EAAE,EACT,IAAI,CAAC,EAAE,EACP,MAAM,EAAE,EAAE,CACX,CAAC;oBACJ,CAAC,CACF,CAAC;oBACF,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtB,OAAO,uBAAuB,EAAG,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
// for better reuse if runtime is changed
|
|
5
|
+
export function factory({ createElement, useMemo, Suspense, lazy }, loadLazyBundle) {
|
|
6
|
+
/**
|
|
7
|
+
* @internal a polyfill for <component is=? />
|
|
8
|
+
*/
|
|
9
|
+
const __ComponentIsPolyfill = ({ is, ...props }) => {
|
|
10
|
+
if (typeof is !== 'string') {
|
|
11
|
+
lynx.reportError(new Error('You must provide a string to props `is` when using syntax `<component is=? />`.'));
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const D = useMemo(() => lazy(() => loadLazyBundle(is)), [is]);
|
|
16
|
+
return createElement(Suspense, { key: is }, createElement(D, props));
|
|
17
|
+
};
|
|
18
|
+
return __ComponentIsPolyfill;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=componentIs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentIs.js","sourceRoot":"","sources":["../../src/compat/componentIs.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,yCAAyC;AACzC,MAAM,UAAU,OAAO,CACrB,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAA0B,EAClE,cAAmB;IAEnB;;OAEG;IACH,MAAM,qBAAqB,GAAuB,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;QACrE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,WAAW,CACd,IAAI,KAAK,CACP,iFAAiF,CAClF,CACF,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,aAAa;QACb,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9D,OAAO,aAAa,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC;IAEF,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
|