@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,305 @@
|
|
|
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 { hydrate } from './hydrate.js';
|
|
5
|
+
import { commitMainThreadPatchUpdate } from './lifecycle/patchUpdate.js';
|
|
6
|
+
// class ListUpdateInfoDiffing implements ListUpdateInfo {
|
|
7
|
+
// private oldChildNodes: SnapshotInstance[];
|
|
8
|
+
// constructor(private list: SnapshotInstance) {
|
|
9
|
+
// this.oldChildNodes = list.childNodes;
|
|
10
|
+
// }
|
|
11
|
+
// flush(): void {
|
|
12
|
+
// Object.defineProperty(SnapshotInstance.prototype, "key", {
|
|
13
|
+
// get: function () {
|
|
14
|
+
// return this.values[0]["item-key"];
|
|
15
|
+
// },
|
|
16
|
+
// });
|
|
17
|
+
// }
|
|
18
|
+
// onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}
|
|
19
|
+
// onRemoveChild(child: SnapshotInstance): void {}
|
|
20
|
+
// onSetAttribute(child: SnapshotInstance, attr: any): void {
|
|
21
|
+
// throw new Error("Method not implemented.");
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
export class ListUpdateInfoRecording {
|
|
25
|
+
list;
|
|
26
|
+
constructor(list) {
|
|
27
|
+
this.list = list;
|
|
28
|
+
this.oldChildNodes = list.childNodes;
|
|
29
|
+
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
30
|
+
}
|
|
31
|
+
// private __commitAndReset() {
|
|
32
|
+
// (this.__pendingAttributes ??= []).push(this.__toAttribute());
|
|
33
|
+
// this.oldChildNodes = this.list.childNodes;
|
|
34
|
+
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
35
|
+
// this.removeChild1.clear();
|
|
36
|
+
// this.removeChild2.clear();
|
|
37
|
+
// this.insertBefore.clear();
|
|
38
|
+
// this.appendChild.length = 0;
|
|
39
|
+
// this.platformInfoUpdate.clear();
|
|
40
|
+
// }
|
|
41
|
+
flush() {
|
|
42
|
+
const elementIndex = this.list.__snapshot_def.slot[0][1];
|
|
43
|
+
const listElement = this.list.__elements[elementIndex];
|
|
44
|
+
// this.__pendingAttributes?.forEach(pendingAttribute => {
|
|
45
|
+
// __SetAttribute(listElement, "update-list-info", pendingAttribute);
|
|
46
|
+
// __FlushElementTree(listElement);
|
|
47
|
+
// });
|
|
48
|
+
__SetAttribute(listElement, 'update-list-info', this.__toAttribute());
|
|
49
|
+
__UpdateListCallbacks(listElement, componentAtIndexFactory(this.list.childNodes), enqueueComponentFactory());
|
|
50
|
+
}
|
|
51
|
+
oldChildNodes;
|
|
52
|
+
// private oldChildNodesSet: Set<SnapshotInstance>;
|
|
53
|
+
removeChild = new Set();
|
|
54
|
+
insertBefore = new Map(); // insert V before K
|
|
55
|
+
appendChild = [];
|
|
56
|
+
platformInfoUpdate = new Map();
|
|
57
|
+
onInsertBefore(newNode, existingNode) {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
if (newNode.__parent) {
|
|
60
|
+
// if (!this.oldChildNodesSet.has(newNode)) {
|
|
61
|
+
// this.__commitAndReset();
|
|
62
|
+
// }
|
|
63
|
+
this.removeChild.add(newNode);
|
|
64
|
+
}
|
|
65
|
+
if (existingNode) {
|
|
66
|
+
// if (!this.oldChildNodesSet.has(existingNode)) {
|
|
67
|
+
// this.__commitAndReset();
|
|
68
|
+
// }
|
|
69
|
+
const newChildren = this.insertBefore.get(existingNode) ?? [];
|
|
70
|
+
newChildren.push(newNode);
|
|
71
|
+
this.insertBefore.set(existingNode, newChildren);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.appendChild.push(newNode);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
onRemoveChild(child) {
|
|
78
|
+
// if (!this.oldChildNodesSet.has(child)) {
|
|
79
|
+
// this.__commitAndReset();
|
|
80
|
+
// }
|
|
81
|
+
this.removeChild.add(child);
|
|
82
|
+
}
|
|
83
|
+
onSetAttribute(child, attr, _oldAttr) {
|
|
84
|
+
this.platformInfoUpdate.set(child, attr);
|
|
85
|
+
}
|
|
86
|
+
__toAttribute() {
|
|
87
|
+
const { removeChild, insertBefore, appendChild, platformInfoUpdate } = this;
|
|
88
|
+
const removals = [];
|
|
89
|
+
const insertions = [];
|
|
90
|
+
const updates = [];
|
|
91
|
+
let j = 0;
|
|
92
|
+
for (let i = 0; i < this.oldChildNodes.length; i++, j++) {
|
|
93
|
+
const child = this.oldChildNodes[i];
|
|
94
|
+
if (platformInfoUpdate.has(child)) {
|
|
95
|
+
updates.push({
|
|
96
|
+
...platformInfoUpdate.get(child),
|
|
97
|
+
from: +j,
|
|
98
|
+
to: +j,
|
|
99
|
+
// no flush
|
|
100
|
+
flush: false,
|
|
101
|
+
type: child.type,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (insertBefore.has(child)) {
|
|
105
|
+
const children = insertBefore.get(child);
|
|
106
|
+
children.forEach(c => {
|
|
107
|
+
insertions.push({
|
|
108
|
+
position: j,
|
|
109
|
+
type: c.type,
|
|
110
|
+
...c.__listItemPlatformInfo,
|
|
111
|
+
});
|
|
112
|
+
j++;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (removeChild.has(child)) {
|
|
116
|
+
removals.push(i);
|
|
117
|
+
removeChild.delete(child);
|
|
118
|
+
j--;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (let i = 0; i < appendChild.length; i++) {
|
|
122
|
+
const child = appendChild[i];
|
|
123
|
+
insertions.push({
|
|
124
|
+
position: j + i,
|
|
125
|
+
type: child.type,
|
|
126
|
+
...child.__listItemPlatformInfo,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
insertions.sort((a, b) => a.position - b.position);
|
|
130
|
+
removals.sort((a, b) => a - b);
|
|
131
|
+
if (SystemInfo.lynxSdkVersion === '2.14'
|
|
132
|
+
|| SystemInfo.lynxSdkVersion === '2.15'
|
|
133
|
+
|| SystemInfo.lynxSdkVersion === '2.16'
|
|
134
|
+
|| SystemInfo.lynxSdkVersion === '2.17'
|
|
135
|
+
|| SystemInfo.lynxSdkVersion === '2.18') {
|
|
136
|
+
const elementIndex = this.list.__snapshot_def.slot[0][1];
|
|
137
|
+
const listElement = this.list.__elements[elementIndex];
|
|
138
|
+
// `__GetAttributeByName` is avaiable since Lynx 2.14
|
|
139
|
+
if (__GetAttributeByName(listElement, 'custom-list-name') === 'list-container') {
|
|
140
|
+
// `updateAction` must be full (not incremental) when Lynx version <= 2.18 and
|
|
141
|
+
// when `custom-list-name` is `list-container` (avaiable when Lynx version >= 2.14) is true,
|
|
142
|
+
updates.length = 0;
|
|
143
|
+
this.list.childNodes.forEach((child, index) => {
|
|
144
|
+
updates.push({
|
|
145
|
+
...child.__listItemPlatformInfo,
|
|
146
|
+
from: index,
|
|
147
|
+
to: index,
|
|
148
|
+
// no flush
|
|
149
|
+
flush: false,
|
|
150
|
+
type: child.type,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
insertAction: insertions,
|
|
157
|
+
removeAction: removals,
|
|
158
|
+
updateAction: updates,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
toJSON() {
|
|
162
|
+
// if (this.__pendingAttributes) {
|
|
163
|
+
// return [...this.__pendingAttributes, this.__toAttribute()];
|
|
164
|
+
// } else {
|
|
165
|
+
// return [this.__toAttribute()];
|
|
166
|
+
// }
|
|
167
|
+
return [this.__toAttribute()];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export const __pendingListUpdates = {
|
|
171
|
+
values: {},
|
|
172
|
+
clear() {
|
|
173
|
+
this.values = {};
|
|
174
|
+
},
|
|
175
|
+
flush() {
|
|
176
|
+
Object.values(this.values).forEach(update => {
|
|
177
|
+
update.flush();
|
|
178
|
+
});
|
|
179
|
+
this.clear();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const gSignMap = {};
|
|
183
|
+
const gRecycleMap = {};
|
|
184
|
+
export function componentAtIndexFactory(ctx) {
|
|
185
|
+
const componentAtIndex = (list, listID, cellIndex, operationID, enableReuseNotification) => {
|
|
186
|
+
const signMap = gSignMap[listID];
|
|
187
|
+
const recycleMap = gRecycleMap[listID];
|
|
188
|
+
if (!signMap || !recycleMap) {
|
|
189
|
+
throw new Error('componentAtIndex called on removed list');
|
|
190
|
+
}
|
|
191
|
+
const childCtx = ctx[cellIndex];
|
|
192
|
+
if (!childCtx) {
|
|
193
|
+
throw new Error('childCtx not found');
|
|
194
|
+
}
|
|
195
|
+
const platformInfo = childCtx.__listItemPlatformInfo || {};
|
|
196
|
+
const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');
|
|
197
|
+
const recycleSignMap = recycleMap.get(uniqID);
|
|
198
|
+
if (childCtx.__elements) {
|
|
199
|
+
/**
|
|
200
|
+
* If this situation is encountered, there might be two cases:
|
|
201
|
+
* 1. Reusing with itself
|
|
202
|
+
* In this case, enqueueComponent will be triggered first, followed by componentAtIndex.
|
|
203
|
+
* 2. Moving
|
|
204
|
+
* In this case, the trigger order is uncertain; componentAtIndex might be triggered first, or enqueueComponent might be triggered first.
|
|
205
|
+
*
|
|
206
|
+
* When enqueueComponent is triggered first, there must be an item in the reuse pool with the same sign as here, which can be returned directly.
|
|
207
|
+
* When componentAtIndex is triggered first, a clone needs to be made first, then follow the logic for adding or reusing. The cloned item will enter the reuse pool in the subsequent enqueueComponent.
|
|
208
|
+
*/
|
|
209
|
+
const root = childCtx.__elements[0];
|
|
210
|
+
const sign = __GetElementUniqueID(root);
|
|
211
|
+
if (recycleSignMap?.has(sign)) {
|
|
212
|
+
signMap.set(sign, childCtx);
|
|
213
|
+
recycleSignMap.delete(sign);
|
|
214
|
+
__FlushElementTree(root, { triggerLayout: true, operationID, elementID: sign, listID });
|
|
215
|
+
return sign;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
const newCtx = childCtx.takeElements();
|
|
219
|
+
signMap.set(sign, newCtx);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (recycleSignMap && recycleSignMap.size > 0) {
|
|
223
|
+
const [first] = recycleSignMap;
|
|
224
|
+
const [sign, oldCtx] = first;
|
|
225
|
+
recycleSignMap.delete(sign);
|
|
226
|
+
hydrate(oldCtx, childCtx);
|
|
227
|
+
oldCtx.unRenderElements();
|
|
228
|
+
const root = childCtx.__element_root;
|
|
229
|
+
if (enableReuseNotification) {
|
|
230
|
+
__FlushElementTree(root, {
|
|
231
|
+
triggerLayout: true,
|
|
232
|
+
operationID,
|
|
233
|
+
elementID: sign,
|
|
234
|
+
listID,
|
|
235
|
+
listReuseNotification: {
|
|
236
|
+
listElement: list,
|
|
237
|
+
itemKey: platformInfo['item-key'],
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
__FlushElementTree(root, {
|
|
243
|
+
triggerLayout: true,
|
|
244
|
+
operationID,
|
|
245
|
+
elementID: sign,
|
|
246
|
+
listID,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
signMap.set(sign, childCtx);
|
|
250
|
+
commitMainThreadPatchUpdate(undefined);
|
|
251
|
+
return sign;
|
|
252
|
+
}
|
|
253
|
+
childCtx.ensureElements();
|
|
254
|
+
const root = childCtx.__element_root;
|
|
255
|
+
__AppendElement(list, root);
|
|
256
|
+
const sign = __GetElementUniqueID(root);
|
|
257
|
+
__FlushElementTree(root, {
|
|
258
|
+
triggerLayout: true,
|
|
259
|
+
operationID,
|
|
260
|
+
elementID: sign,
|
|
261
|
+
listID,
|
|
262
|
+
});
|
|
263
|
+
signMap.set(sign, childCtx);
|
|
264
|
+
commitMainThreadPatchUpdate(undefined);
|
|
265
|
+
return sign;
|
|
266
|
+
};
|
|
267
|
+
return componentAtIndex;
|
|
268
|
+
}
|
|
269
|
+
export function enqueueComponentFactory() {
|
|
270
|
+
const enqueueComponent = (_, listID, sign) => {
|
|
271
|
+
const signMap = gSignMap[listID];
|
|
272
|
+
const recycleMap = gRecycleMap[listID];
|
|
273
|
+
if (!signMap || !recycleMap) {
|
|
274
|
+
throw new Error('enqueueComponent called on removed list');
|
|
275
|
+
}
|
|
276
|
+
const childCtx = signMap.get(sign);
|
|
277
|
+
if (!childCtx) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const platformInfo = childCtx.__listItemPlatformInfo || {};
|
|
281
|
+
const uniqID = childCtx.type + (platformInfo['reuse-identifier'] ?? '');
|
|
282
|
+
if (!recycleMap.has(uniqID)) {
|
|
283
|
+
recycleMap.set(uniqID, new Map());
|
|
284
|
+
}
|
|
285
|
+
recycleMap.get(uniqID).set(sign, childCtx);
|
|
286
|
+
};
|
|
287
|
+
return enqueueComponent;
|
|
288
|
+
}
|
|
289
|
+
export function snapshotCreateList(pageId, _ctx, _expIndex) {
|
|
290
|
+
const signMap = new Map();
|
|
291
|
+
const recycleMap = new Map();
|
|
292
|
+
const list = __CreateList(pageId, componentAtIndexFactory([]), enqueueComponentFactory(), {});
|
|
293
|
+
const listID = __GetElementUniqueID(list);
|
|
294
|
+
gSignMap[listID] = signMap;
|
|
295
|
+
gRecycleMap[listID] = recycleMap;
|
|
296
|
+
return list;
|
|
297
|
+
}
|
|
298
|
+
export function snapshotDestroyList(si) {
|
|
299
|
+
const [, elementIndex] = si.__snapshot_def.slot[0];
|
|
300
|
+
const list = si.__elements[elementIndex];
|
|
301
|
+
const listID = __GetElementUniqueID(list);
|
|
302
|
+
delete gSignMap[listID];
|
|
303
|
+
delete gRecycleMap[listID];
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAuBzE,0DAA0D;AAC1D,+CAA+C;AAC/C,kDAAkD;AAClD,4CAA4C;AAC5C,MAAM;AACN,oBAAoB;AACpB,iEAAiE;AACjE,2BAA2B;AAC3B,6CAA6C;AAC7C,WAAW;AACX,UAAU;AAEV,MAAM;AACN,oGAAoG;AACpG,oDAAoD;AACpD,+DAA+D;AAC/D,kDAAkD;AAClD,MAAM;AACN,IAAI;AAEJ,MAAM,OAAO,uBAAuB;IACd;IAApB,YAAoB,IAAsB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OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 { __page, setupPage, SnapshotInstance } from '../snapshot.js';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { render as renderToString } from '../renderToOpcodes/index.js';
|
|
7
|
+
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
8
|
+
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
9
|
+
import { isEmptyObject } from '../utils.js';
|
|
10
|
+
import { __root, setRoot } from '../root.js';
|
|
11
|
+
import { reloadMainThread } from '../lifecycle/reload.js';
|
|
12
|
+
import { renderMainThread } from '../lifecycle/render.js';
|
|
13
|
+
import { hydrate } from '../hydrate.js';
|
|
14
|
+
import { markTiming, PerformanceTimingKeys, setPipeline } from './performance.js';
|
|
15
|
+
import { __pendingListUpdates } from '../list.js';
|
|
16
|
+
function injectCalledByNative() {
|
|
17
|
+
const calledByNative = {
|
|
18
|
+
renderPage,
|
|
19
|
+
updatePage,
|
|
20
|
+
updateGlobalProps,
|
|
21
|
+
getPageData: function () {
|
|
22
|
+
return null;
|
|
23
|
+
},
|
|
24
|
+
removeComponents: function () { },
|
|
25
|
+
};
|
|
26
|
+
Object.assign(globalThis, calledByNative);
|
|
27
|
+
}
|
|
28
|
+
function renderPage(data) {
|
|
29
|
+
// reset `jsReady` state
|
|
30
|
+
isJSReady = false;
|
|
31
|
+
jsReadyEventIdSwap = {};
|
|
32
|
+
lynx.__initData = data || {};
|
|
33
|
+
setupPage(__CreatePage('0', 0));
|
|
34
|
+
__root.ensureElements();
|
|
35
|
+
renderMainThread();
|
|
36
|
+
// always call this before `__FlushElementTree`
|
|
37
|
+
// (There is an implict `__FlushElementTree` in `renderPage`)
|
|
38
|
+
__pendingListUpdates.flush();
|
|
39
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ === 'immediately') {
|
|
40
|
+
jsReady();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
Object.assign(globalThis, {
|
|
44
|
+
[LifecycleConstant.jsReady]: jsReady,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function updatePage(data, options) {
|
|
49
|
+
if (options?.reloadTemplate) {
|
|
50
|
+
reloadMainThread(data, options);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (options?.resetPageData) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
lynx.__initData = {};
|
|
56
|
+
}
|
|
57
|
+
if (typeof data == 'object' && !isEmptyObject(data)) {
|
|
58
|
+
lynx.__initData ??= {};
|
|
59
|
+
Object.assign(lynx.__initData, data);
|
|
60
|
+
}
|
|
61
|
+
if (!isJSReady) {
|
|
62
|
+
const oldRoot = __root;
|
|
63
|
+
setRoot(new SnapshotInstance('root'));
|
|
64
|
+
__root.__jsx = oldRoot.__jsx;
|
|
65
|
+
setPipeline(options?.pipelineOptions);
|
|
66
|
+
markTiming(PerformanceTimingKeys.update_diff_vdom_start);
|
|
67
|
+
{
|
|
68
|
+
__pendingListUpdates.clear();
|
|
69
|
+
// ignore ref & unref before jsReady
|
|
70
|
+
takeGlobalRefPatchMap();
|
|
71
|
+
renderMainThread();
|
|
72
|
+
// As said by codename `jsReadyEventIdSwap`, this swap will only be used for event remap,
|
|
73
|
+
// because ref & unref cause by previous render will be ignored
|
|
74
|
+
hydrate(oldRoot, __root, { skipUnRef: true, swap: jsReadyEventIdSwap });
|
|
75
|
+
// always call this before `__FlushElementTree`
|
|
76
|
+
__pendingListUpdates.flush();
|
|
77
|
+
}
|
|
78
|
+
markTiming(PerformanceTimingKeys.update_diff_vdom_end);
|
|
79
|
+
}
|
|
80
|
+
if (options) {
|
|
81
|
+
__FlushElementTree(__page, options);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
__FlushElementTree();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function updateGlobalProps(_data, options) {
|
|
88
|
+
if (options) {
|
|
89
|
+
__FlushElementTree(__page, options);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
__FlushElementTree();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let isJSReady;
|
|
96
|
+
let jsReadyEventIdSwap;
|
|
97
|
+
function jsReady() {
|
|
98
|
+
__OnLifecycleEvent([
|
|
99
|
+
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
100
|
+
{
|
|
101
|
+
root: JSON.stringify(__root),
|
|
102
|
+
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
103
|
+
jsReadyEventIdSwap,
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
isJSReady = true;
|
|
107
|
+
jsReadyEventIdSwap = {};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export { injectCalledByNative };
|
|
113
|
+
//# sourceMappingURL=calledByNative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calledByNative.js","sourceRoot":"","sources":["../../src/lynx/calledByNative.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,aAAa;AACb,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7C,O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AAE,OAAsC;IAC3E,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,IAAI,SAAkB,CAAC;AACvB,IAAI,kBAA0C,CAAC;AAC/C,SAAS,OAAO;IACd,kBAAkB,CAAC;QACjB,iBAAiB,CAAC,WAAW,EAAE,kBAAkB;QACjD;YACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC;YACjD,kBAAkB;SACnB;KACF,CAAC,CAAC;IACH,SAAS,GAAG,IAAI,CAAC;IACjB,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { Component } from 'preact';
|
|
5
|
+
import { PerfSpecificKey, PerformanceTimingKeys, markTimingLegacy } from './performance.js';
|
|
6
|
+
import { globalFlushOptions } from '../lifecycle/patchUpdate.js';
|
|
7
|
+
import { NEXT_STATE } from '../renderToOpcodes/constants.js';
|
|
8
|
+
if (__JS__) {
|
|
9
|
+
const __Component = Component;
|
|
10
|
+
__Component.prototype._reactAppInstance = lynxCoreInject.tt;
|
|
11
|
+
__Component.prototype.getNodeRef = function (a, b) {
|
|
12
|
+
if (!__DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__) {
|
|
13
|
+
lynx.reportError(new Error('getNodeRef is deprecated and has different behavior in ReactLynx 3.0, please use ref or lynx.createSelectorQuery instead.'));
|
|
14
|
+
}
|
|
15
|
+
return lynxCoreInject.tt._reactLynx.ReactComponent.prototype.getNodeRef
|
|
16
|
+
.call({
|
|
17
|
+
_type: '',
|
|
18
|
+
_nativeApp: lynxCoreInject.tt._nativeApp,
|
|
19
|
+
_uiModule: lynxCoreInject.tt._nativeApp.nativeModuleProxy.LynxUIMethodModule,
|
|
20
|
+
_reactAppInstance: lynxCoreInject.tt,
|
|
21
|
+
}, a, b);
|
|
22
|
+
};
|
|
23
|
+
__Component.prototype.getNodeRefFromRoot = function (a) {
|
|
24
|
+
if (!__DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__) {
|
|
25
|
+
lynx.reportError(new Error('getNodeRefFromRoot is deprecated and has different behavior in ReactLynx 3.0, please use ref or lynx.createSelectorQuery instead.'));
|
|
26
|
+
}
|
|
27
|
+
return lynxCoreInject.tt._reactLynx.ReactComponent.prototype
|
|
28
|
+
.getNodeRefFromRoot.call({
|
|
29
|
+
_type: '',
|
|
30
|
+
_nativeApp: lynxCoreInject.tt._nativeApp,
|
|
31
|
+
_uiModule: lynxCoreInject.tt._nativeApp.nativeModuleProxy.LynxUIMethodModule,
|
|
32
|
+
_reactAppInstance: lynxCoreInject.tt,
|
|
33
|
+
}, a);
|
|
34
|
+
};
|
|
35
|
+
__Component.prototype.registerModule = function (name, module) {
|
|
36
|
+
this._reactAppInstance.registerModule(name, module);
|
|
37
|
+
};
|
|
38
|
+
__Component.prototype.getJSModule = function (name) {
|
|
39
|
+
return this._reactAppInstance.getJSModule(name);
|
|
40
|
+
};
|
|
41
|
+
__Component.prototype.addGlobalEventListener = function (eventName, callback, context) {
|
|
42
|
+
return this._reactAppInstance.getJSModule('GlobalEventEmitter').addListener(eventName, callback, context);
|
|
43
|
+
};
|
|
44
|
+
__Component.prototype.getElementById = function (id) {
|
|
45
|
+
if (!__DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__) {
|
|
46
|
+
lynx.reportError(new Error('getElementById on component instance is deprecated and has different behavior in ReactLynx 3.0, please use ref or lynx.getElementById instead.'));
|
|
47
|
+
}
|
|
48
|
+
return lynx.getElementById(id);
|
|
49
|
+
};
|
|
50
|
+
__Component.prototype.GlobalEventEmitter = lynxCoreInject.tt.GlobalEventEmitter;
|
|
51
|
+
__Component.prototype.createSelectorQuery = function (...args) {
|
|
52
|
+
if (!__DISABLE_CREATE_SELECTOR_QUERY_INCOMPATIBLE_WARNING__) {
|
|
53
|
+
lynx.reportError(new Error('createSelectorQuery on component instance is deprecated and has different behavior in ReactLynx 3.0, please use ref or lynx.createSelectorQuery instead.'));
|
|
54
|
+
}
|
|
55
|
+
return lynx.createSelectorQuery(...args);
|
|
56
|
+
};
|
|
57
|
+
const oldSetState = __Component.prototype.setState;
|
|
58
|
+
__Component.prototype.setState = function (state, callback) {
|
|
59
|
+
oldSetState.call(this, state, callback);
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
const timingFlag = this[NEXT_STATE][PerfSpecificKey];
|
|
62
|
+
if (timingFlag) {
|
|
63
|
+
globalFlushOptions.__lynx_timing_flag = timingFlag;
|
|
64
|
+
markTimingLegacy(PerformanceTimingKeys.update_set_state_trigger, timingFlag);
|
|
65
|
+
this[NEXT_STATE][PerfSpecificKey] = '';
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/lynx/component.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAA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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,kBAAkB,CAAC,kBAAkB,GAAG,UAAU,CAAC;YACnD,gBAAgB,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;YAC7E,IAAI,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { loadLazyBundle } from './lazy-bundle.js';
|
|
5
|
+
export function loadDynamicJS(url) {
|
|
6
|
+
if (__LEPUS__) {
|
|
7
|
+
_ReportError(new Error(`A dynamic import (to "${url}") is leaked to Lepus bundle.`), { errorCode: 202 });
|
|
8
|
+
return Promise.reject();
|
|
9
|
+
}
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
lynx.requireModuleAsync(url, (err, data) => {
|
|
13
|
+
if (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolve(data);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function __dynamicImport(url, options) {
|
|
23
|
+
const t = options?.with?.type;
|
|
24
|
+
if (t === 'component' || t === 'tsx' || t === 'jsx') {
|
|
25
|
+
return loadLazyBundle(url);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return loadDynamicJS(url);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=dynamic-js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-js.js","sourceRoot":"","sources":["../../src/lynx/dynamic-js.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,aAAa,CAAI,GAAW;IAC1C,IAAI,SAAS,EAAE,CAAC;QACd,YAAY,CACV,IAAI,KAAK,CAAC,yBAAyB,GAAG,+BAA+B,CAAC,EACtE,EAAE,SAAS,EAAE,GAAG,EAAE,CACnB,CAAC;QACF,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,aAAa;QACb,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAAI,GAAW,EAAE,OAAa;IAC3D,MAAM,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;IAC9B,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;QACpD,OAAO,cAAc,CAAM,GAAG,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setupLynxEnv(): void;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export function setupLynxEnv() {
|
|
2
|
+
if (!__LEPUS__) {
|
|
3
|
+
const { initData, updateData } = lynxCoreInject.tt._params;
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
lynx.__initData = { ...initData, ...updateData };
|
|
6
|
+
lynx.registerDataProcessors = function () { };
|
|
7
|
+
}
|
|
8
|
+
if (__LEPUS__) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
lynx.__initData = {
|
|
11
|
+
/* available only in renderPage */
|
|
12
|
+
};
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
globalThis.SystemInfo = lynx.SystemInfo || {};
|
|
15
|
+
lynx.reportError = function (e) {
|
|
16
|
+
_ReportError(e, {
|
|
17
|
+
errorCode: 1101, // ErrCode::LYNX_ERROR_CODE_LEPUS in Lynx/base/debug/error_code.h
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
lynx.triggerGlobalEventFromLepus = function (eventName, params) {
|
|
21
|
+
__OnLifecycleEvent(['globalEventFromLepus', [eventName, params]]);
|
|
22
|
+
};
|
|
23
|
+
{
|
|
24
|
+
function __name(empty) {
|
|
25
|
+
return `Native${empty}Modules`;
|
|
26
|
+
}
|
|
27
|
+
// TODO(hongzhiyuan.hzy): make sure this is run before any other code (especially code access `NativeModules`)
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
if (typeof globalThis[__name('')] === 'undefined') {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
globalThis[__name('')] = undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
lynx.registerDataProcessors = function (dataProcessorDefinition) {
|
|
35
|
+
let hasDefaultDataProcessorExecuted = false;
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
globalThis.processData = (data, processorName) => {
|
|
38
|
+
if (__PROFILE__) {
|
|
39
|
+
console.profile('processData');
|
|
40
|
+
}
|
|
41
|
+
let r;
|
|
42
|
+
try {
|
|
43
|
+
if (processorName) {
|
|
44
|
+
r = dataProcessorDefinition?.dataProcessors?.[processorName]?.(data)
|
|
45
|
+
?? data;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
r = dataProcessorDefinition?.defaultDataProcessor?.(data) ?? data;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
lynx.reportError(e);
|
|
53
|
+
// when there is an error
|
|
54
|
+
// we should perform like dataProcessor returns nothing
|
|
55
|
+
// so use `{}` rather than `data`
|
|
56
|
+
r = {};
|
|
57
|
+
}
|
|
58
|
+
if (__PROFILE__) {
|
|
59
|
+
console.profileEnd();
|
|
60
|
+
}
|
|
61
|
+
if (hasDefaultDataProcessorExecuted === false) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
if (globalThis.__I18N_RESOURCE_TRANSLATION__) {
|
|
64
|
+
r = {
|
|
65
|
+
...r,
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
__I18N_RESOURCE_TRANSLATION__: globalThis.__I18N_RESOURCE_TRANSLATION__,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
if (__EXTRACT_STR__) {
|
|
72
|
+
r = {
|
|
73
|
+
...r,
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
_EXTRACT_STR: __EXTRACT_STR_IDENT_FLAG__,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (processorName) {
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
hasDefaultDataProcessorExecuted = true;
|
|
83
|
+
}
|
|
84
|
+
return r;
|
|
85
|
+
// TODO
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
// register empty DataProcessors to make sure `globalThis.processData` is set
|
|
89
|
+
lynx.registerDataProcessors();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=env.js.map
|