@lynx-js/react 0.110.0 → 0.111.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 +50 -0
- package/components/lib/DeferredListItem.d.ts +7 -0
- package/components/lib/DeferredListItem.jsx +40 -0
- package/components/lib/DeferredListItem.jsx.map +1 -0
- package/components/lib/Page.js.map +1 -1
- package/components/lib/index.d.ts +1 -0
- package/components/lib/index.js +1 -0
- package/components/lib/index.js.map +1 -1
- package/components/src/DeferredListItem.tsx +56 -0
- package/components/src/Page.ts +1 -1
- package/components/src/index.ts +1 -0
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/lazy/react-lepus.js +1 -0
- package/runtime/lazy/react.js +1 -0
- package/runtime/lepus/index.d.ts +1 -1
- package/runtime/lepus/index.js +44 -0
- package/runtime/lib/backgroundSnapshot.d.ts +2 -1
- package/runtime/lib/backgroundSnapshot.js +64 -41
- package/runtime/lib/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/compat/initData.d.ts +7 -5
- package/runtime/lib/compat/initData.js +11 -2
- package/runtime/lib/compat/initData.js.map +1 -1
- package/runtime/lib/compat/lynxComponent.js +10 -12
- package/runtime/lib/compat/lynxComponent.js.map +1 -1
- package/runtime/lib/debug/profile.js +1 -0
- package/runtime/lib/debug/profile.js.map +1 -1
- package/runtime/lib/gesture/processGestureBagkround.d.ts +1 -1
- package/runtime/lib/gesture/processGestureBagkround.js +4 -1
- package/runtime/lib/gesture/processGestureBagkround.js.map +1 -1
- package/runtime/lib/gesture/types.js.map +1 -1
- package/runtime/lib/hooks/useLynxGlobalEventListener.d.ts +1 -1
- package/runtime/lib/hydrate.d.ts +1 -1
- package/runtime/lib/hydrate.js +5 -4
- package/runtime/lib/hydrate.js.map +1 -1
- package/runtime/lib/index.d.ts +2 -2
- package/runtime/lib/index.js +2 -2
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +3 -2
- package/runtime/lib/internal.js +3 -2
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/legacy-react-runtime/index.js +1 -1
- package/runtime/lib/legacy-react-runtime/index.js.map +1 -1
- package/runtime/lib/lifecycle/patch/commit.js +5 -5
- package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatch.d.ts +9 -9
- package/runtime/lib/lifecycle/patch/snapshotPatch.js +9 -10
- package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.js +11 -12
- package/runtime/lib/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/lifecycle/reload.js +1 -1
- package/runtime/lib/lifecycle/reload.js.map +1 -1
- package/runtime/lib/lifecycleConstant.d.ts +2 -1
- package/runtime/lib/lifecycleConstant.js +1 -0
- package/runtime/lib/lifecycleConstant.js.map +1 -1
- package/runtime/lib/list.d.ts +2 -46
- package/runtime/lib/list.js +124 -211
- package/runtime/lib/list.js.map +1 -1
- package/runtime/lib/listUpdateInfo.d.ts +38 -0
- package/runtime/lib/listUpdateInfo.js +152 -0
- package/runtime/lib/listUpdateInfo.js.map +1 -0
- package/runtime/lib/lynx/calledByNative.js +8 -11
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/lynx/component.js +11 -14
- package/runtime/lib/lynx/component.js.map +1 -1
- package/runtime/lib/lynx/env.js +1 -2
- package/runtime/lib/lynx/env.js.map +1 -1
- package/runtime/lib/lynx/lazy-bundle.js +48 -21
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/lynx/performance.d.ts +3 -19
- package/runtime/lib/lynx/performance.js +25 -26
- package/runtime/lib/lynx/performance.js.map +1 -1
- package/runtime/lib/lynx/tt.js +10 -5
- package/runtime/lib/lynx/tt.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +78 -1
- package/runtime/lib/lynx-api.js +3 -0
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +1 -0
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/opcodes.js +2 -1
- package/runtime/lib/opcodes.js.map +1 -1
- package/runtime/lib/pendingListUpdates.d.ts +6 -0
- package/runtime/lib/pendingListUpdates.js +16 -0
- package/runtime/lib/pendingListUpdates.js.map +1 -0
- package/runtime/lib/renderToOpcodes/index.js +7 -7
- package/runtime/lib/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/dynamicPartType.d.ts +12 -0
- package/runtime/lib/snapshot/dynamicPartType.js +17 -0
- package/runtime/lib/snapshot/dynamicPartType.js.map +1 -0
- package/runtime/lib/snapshot/gesture.js +3 -0
- package/runtime/lib/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/list.d.ts +3 -0
- package/runtime/lib/snapshot/list.js +23 -0
- package/runtime/lib/snapshot/list.js.map +1 -0
- package/runtime/lib/snapshot/platformInfo.d.ts +10 -0
- package/runtime/lib/snapshot/platformInfo.js +6 -3
- package/runtime/lib/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/ref.d.ts +3 -0
- package/runtime/lib/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/spread.d.ts +2 -2
- package/runtime/lib/snapshot/spread.js +4 -5
- package/runtime/lib/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/workletEvent.js +1 -1
- package/runtime/lib/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/workletRef.d.ts +1 -1
- package/runtime/lib/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot.d.ts +7 -14
- package/runtime/lib/snapshot.js +36 -31
- package/runtime/lib/snapshot.js.map +1 -1
- package/runtime/lib/snapshotInstanceHydrationMap.js.map +1 -1
- package/runtime/lib/utils.d.ts +1 -0
- package/runtime/lib/utils.js +7 -1
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/src/backgroundSnapshot.ts +78 -63
- package/runtime/src/compat/initData.ts +20 -9
- package/runtime/src/compat/lynxComponent.ts +12 -13
- package/runtime/src/debug/profile.ts +1 -0
- package/runtime/src/gesture/processGestureBagkround.ts +5 -1
- package/runtime/src/gesture/types.ts +3 -0
- package/runtime/src/hooks/useLynxGlobalEventListener.ts +1 -1
- package/runtime/src/hydrate.ts +6 -4
- package/runtime/src/index.ts +2 -0
- package/runtime/src/internal.ts +3 -2
- package/runtime/src/legacy-react-runtime/index.ts +1 -1
- package/runtime/src/lifecycle/patch/commit.ts +5 -11
- package/runtime/src/lifecycle/patch/snapshotPatch.ts +9 -9
- package/runtime/src/lifecycle/patch/snapshotPatchApply.ts +1 -1
- package/runtime/src/lifecycle/patch/updateMainThread.ts +11 -12
- package/runtime/src/lifecycle/reload.ts +1 -1
- package/runtime/src/lifecycleConstant.ts +1 -0
- package/runtime/src/list.ts +143 -278
- package/runtime/src/listUpdateInfo.ts +221 -0
- package/runtime/src/lynx/calledByNative.ts +8 -10
- package/runtime/src/lynx/component.ts +17 -29
- package/runtime/src/lynx/env.ts +1 -2
- package/runtime/src/lynx/lazy-bundle.ts +55 -20
- package/runtime/src/lynx/performance.ts +26 -27
- package/runtime/src/lynx/tt.ts +10 -11
- package/runtime/src/lynx-api.ts +81 -2
- package/runtime/src/lynx.ts +1 -0
- package/runtime/src/opcodes.ts +2 -1
- package/runtime/src/pendingListUpdates.ts +18 -0
- package/runtime/src/renderToOpcodes/index.ts +7 -7
- package/runtime/src/snapshot/dynamicPartType.ts +16 -0
- package/runtime/src/snapshot/gesture.ts +3 -0
- package/runtime/src/snapshot/list.ts +36 -0
- package/runtime/src/snapshot/platformInfo.ts +19 -5
- package/runtime/src/snapshot/ref.ts +1 -0
- package/runtime/src/snapshot/spread.ts +42 -17
- package/runtime/src/snapshot/workletEvent.ts +1 -1
- package/runtime/src/snapshot/workletRef.ts +1 -1
- package/runtime/src/snapshot.ts +41 -34
- package/runtime/src/snapshotInstanceHydrationMap.ts +1 -1
- package/runtime/src/utils.ts +12 -3
- package/testing-library/dist/env/vitest.js +3 -3
- package/testing-library/dist/index.d.ts +4 -1
- package/testing-library/dist/pure.js +1 -1
- package/testing-library/dist/vitest.config.js +45 -8
- package/testing-library/types/entry.d.ts +3 -2
- package/transform/cjs/main.cjs +4 -0
- package/transform/dist/wasm.cjs +1 -1
- package/types/react.d.ts +21 -1
- package/types/react.docs.d.ts +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
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 type {
|
|
4
|
+
import type { ComponentChildren, Consumer, Context, Provider } from 'preact';
|
|
5
|
+
import type { ComponentClass } from 'react';
|
|
5
6
|
|
|
6
7
|
import { useLynxGlobalEventListener } from '../hooks/useLynxGlobalEventListener.js';
|
|
8
|
+
import { globalFlushOptions } from '../lifecycle/patch/commit.js';
|
|
7
9
|
|
|
8
10
|
type Getter<T> = {
|
|
9
11
|
[key in keyof T]: () => T[key];
|
|
@@ -11,26 +13,30 @@ type Getter<T> = {
|
|
|
11
13
|
|
|
12
14
|
// for better reuse if runtime is changed
|
|
13
15
|
export function factory<Data>(
|
|
14
|
-
{ createContext, useState, createElement, useLynxGlobalEventListener: useListener }:
|
|
16
|
+
{ createContext, useState, createElement, useLynxGlobalEventListener: useListener }: {
|
|
17
|
+
createContext: typeof import('preact').createContext;
|
|
18
|
+
useState: typeof import('preact/hooks').useState;
|
|
19
|
+
createElement: typeof import('preact').createElement;
|
|
15
20
|
useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
|
|
16
21
|
},
|
|
17
22
|
prop: '__globalProps' | '__initData',
|
|
18
23
|
eventName: string,
|
|
19
24
|
): Getter<{
|
|
20
25
|
Context: Context<Data>;
|
|
21
|
-
Provider:
|
|
22
|
-
children?: ReactNode | undefined;
|
|
23
|
-
}>;
|
|
26
|
+
Provider: Provider<Data>;
|
|
24
27
|
Consumer: Consumer<Data>;
|
|
25
28
|
use: () => Data;
|
|
26
29
|
useChanged: (callback: (data: Data) => void) => void;
|
|
27
30
|
}> {
|
|
28
31
|
const Context = createContext({} as Data);
|
|
29
32
|
|
|
30
|
-
const Provider
|
|
33
|
+
const Provider = ({ children }: { children?: ComponentChildren }) => {
|
|
31
34
|
const [__, set] = useState<Data>(lynx[prop] as Data);
|
|
32
35
|
|
|
33
36
|
const handleChange = () => {
|
|
37
|
+
if (prop === '__initData') {
|
|
38
|
+
globalFlushOptions.triggerDataUpdated = true;
|
|
39
|
+
}
|
|
34
40
|
set(lynx[prop] as Data);
|
|
35
41
|
};
|
|
36
42
|
|
|
@@ -50,6 +56,9 @@ export function factory<Data>(
|
|
|
50
56
|
const use = (): Data => {
|
|
51
57
|
const [__, set] = useState(lynx[prop]);
|
|
52
58
|
useChanged(() => {
|
|
59
|
+
if (prop === '__initData') {
|
|
60
|
+
globalFlushOptions.triggerDataUpdated = true;
|
|
61
|
+
}
|
|
53
62
|
set(lynx[prop]);
|
|
54
63
|
});
|
|
55
64
|
|
|
@@ -58,12 +67,12 @@ export function factory<Data>(
|
|
|
58
67
|
|
|
59
68
|
const useChanged = (callback: (__: Data) => void) => {
|
|
60
69
|
if (!__LEPUS__) {
|
|
61
|
-
|
|
62
|
-
useListener<(__: unknown) => void>(eventName, callback);
|
|
70
|
+
useListener(eventName, callback);
|
|
63
71
|
}
|
|
64
72
|
};
|
|
65
73
|
|
|
66
74
|
return {
|
|
75
|
+
/* v8 ignore next */
|
|
67
76
|
Context: () => Context,
|
|
68
77
|
Provider: () => Provider,
|
|
69
78
|
Consumer: () => Consumer,
|
|
@@ -98,7 +107,8 @@ export function factory<Data>(
|
|
|
98
107
|
* @public
|
|
99
108
|
*/
|
|
100
109
|
export function withInitDataInState<P, S>(App: ComponentClass<P, S>): ComponentClass<P, S> {
|
|
101
|
-
const isClassComponent = 'prototype' in App && App.prototype
|
|
110
|
+
const isClassComponent = 'prototype' in App && 'render' in App.prototype;
|
|
111
|
+
/* v8 ignore next 4 */
|
|
102
112
|
if (!isClassComponent) {
|
|
103
113
|
// return as-is when not class component
|
|
104
114
|
return App;
|
|
@@ -118,6 +128,7 @@ export function withInitDataInState<P, S>(App: ComponentClass<P, S>): ComponentC
|
|
|
118
128
|
lynx.getJSModule('GlobalEventEmitter').addListener(
|
|
119
129
|
'onDataChanged',
|
|
120
130
|
this.h = () => {
|
|
131
|
+
globalFlushOptions.triggerDataUpdated = true;
|
|
121
132
|
this.setState(lynx.__initData as S);
|
|
122
133
|
},
|
|
123
134
|
);
|
|
@@ -9,15 +9,15 @@ export function wrapWithLynxComponent(
|
|
|
9
9
|
jsxComponent: any,
|
|
10
10
|
): ReactNode {
|
|
11
11
|
const C = jsxComponent.type;
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
if (
|
|
13
|
+
typeof C === 'function' && (C === ComponentFromReactRuntime || C.prototype instanceof ComponentFromReactRuntime)
|
|
14
|
+
) {
|
|
15
|
+
if (jsxSnapshot.length === 1) {
|
|
16
|
+
return jsxSnapshot(jsxComponent);
|
|
17
|
+
} else {
|
|
18
|
+
// spread
|
|
19
|
+
if (!jsxComponent.props.removeComponentElement) {
|
|
20
|
+
return jsxSnapshot(jsxComponent, takeComponentAttributes(jsxComponent));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -25,8 +25,7 @@ export function wrapWithLynxComponent(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// @ts-expect-error
|
|
28
|
-
export class ComponentFromReactRuntime extends Component {
|
|
29
|
-
}
|
|
28
|
+
export class ComponentFromReactRuntime extends Component {}
|
|
30
29
|
|
|
31
30
|
const __COMPONENT_ATTRIBUTES__ = /* @__PURE__ */ new Set([
|
|
32
31
|
'name',
|
|
@@ -68,8 +67,8 @@ function takeComponentAttributes(jsxComponent: any): Record<string, any> {
|
|
|
68
67
|
|| k === 'dataSet'
|
|
69
68
|
|| k === 'data-set'
|
|
70
69
|
|| k === 'removeComponentElement'
|
|
71
|
-
||
|
|
72
|
-
||
|
|
70
|
+
|| (/^(global-bind|bind|catch|capture-bind|capture-catch)([A-Za-z]+)$/.exec(k))
|
|
71
|
+
|| (/^data-([A-Za-z]+)$/.exec(k))
|
|
73
72
|
) {
|
|
74
73
|
attributes[k] = jsxComponent.props[k];
|
|
75
74
|
delete jsxComponent.props[k];
|
|
@@ -29,6 +29,7 @@ export function initProfileHook(): void {
|
|
|
29
29
|
const oldRender = options[RENDER];
|
|
30
30
|
options[RENDER] = function(vnode: VNode & { [COMPONENT]: Component }) {
|
|
31
31
|
const displayName = getDisplayName(vnode.type as ComponentClass);
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
32
33
|
const originalRender = vnode[COMPONENT].render;
|
|
33
34
|
vnode[COMPONENT].render = function render(this, props, state, context) {
|
|
34
35
|
// This __PROFILE__ is used for DCE testing
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// Copyright 2025 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 { GestureTypeInner } from './types.js';
|
|
5
|
+
import type { BaseGesture, ComposedGesture, GestureKind } from './types.js';
|
|
1
6
|
import { onPostWorkletCtx } from '../worklet/ctx.js';
|
|
2
|
-
import { type GestureKind, GestureTypeInner, type ComposedGesture, type BaseGesture } from './types.js';
|
|
3
7
|
|
|
4
8
|
export function processGestureBackground(gesture: GestureKind): void {
|
|
5
9
|
if (gesture.type === GestureTypeInner.COMPOSED) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2025 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.
|
|
1
4
|
import type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';
|
|
2
5
|
|
|
3
6
|
export enum GestureTypeInner {
|
|
@@ -31,7 +31,7 @@ import { useEffect, useMemo, useRef } from 'preact/hooks';
|
|
|
31
31
|
* @param listener - Event handler
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
|
-
export function useLynxGlobalEventListener<T extends (...args:
|
|
34
|
+
export function useLynxGlobalEventListener<T extends (...args: any[]) => void>(
|
|
35
35
|
eventName: string,
|
|
36
36
|
listener: T,
|
|
37
37
|
): void {
|
package/runtime/src/hydrate.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { componentAtIndexFactory, enqueueComponentFactory } from './list.js';
|
|
6
|
+
import { __pendingListUpdates } from './pendingListUpdates.js';
|
|
7
|
+
import { DynamicPartType } from './snapshot/dynamicPartType.js';
|
|
6
8
|
import { unref } from './snapshot/ref.js';
|
|
7
|
-
import {
|
|
9
|
+
import type { SnapshotInstance } from './snapshot.js';
|
|
8
10
|
import { isEmptyObject } from './utils.js';
|
|
9
11
|
|
|
10
12
|
export interface DiffResult<K> {
|
|
@@ -215,7 +217,7 @@ export function hydrate(before: SnapshotInstance, after: SnapshotInstance, optio
|
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
let swap;
|
|
218
|
-
if (swap = options?.swap) {
|
|
220
|
+
if ((swap = options?.swap)) {
|
|
219
221
|
swap[before.__id] = after.__id;
|
|
220
222
|
}
|
|
221
223
|
|
|
@@ -349,7 +351,7 @@ export function hydrate(before: SnapshotInstance, after: SnapshotInstance, optio
|
|
|
349
351
|
|
|
350
352
|
const listElement = before.__elements![elementIndex]!;
|
|
351
353
|
__SetAttribute(listElement, 'update-list-info', info);
|
|
352
|
-
const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(afterChildNodes);
|
|
354
|
+
const [componentAtIndex, componentAtIndexes] = componentAtIndexFactory(afterChildNodes, hydrate);
|
|
353
355
|
__UpdateListCallbacks(
|
|
354
356
|
listElement,
|
|
355
357
|
componentAtIndex,
|
package/runtime/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
PureComponent,
|
|
12
12
|
Suspense,
|
|
13
13
|
lazy as backgroundLazy,
|
|
14
|
+
cloneElement,
|
|
14
15
|
createContext,
|
|
15
16
|
createElement,
|
|
16
17
|
createRef,
|
|
@@ -86,6 +87,7 @@ export {
|
|
|
86
87
|
Suspense,
|
|
87
88
|
lazy,
|
|
88
89
|
createElement,
|
|
90
|
+
cloneElement,
|
|
89
91
|
useSyncExternalStore,
|
|
90
92
|
};
|
|
91
93
|
|
package/runtime/src/internal.ts
CHANGED
|
@@ -9,10 +9,11 @@ import './lynx.js';
|
|
|
9
9
|
|
|
10
10
|
import { factory as factory2 } from './compat/componentIs.js';
|
|
11
11
|
import { useMemo } from './hooks/react.js';
|
|
12
|
-
import { snapshotCreateList } from './list.js';
|
|
13
12
|
import { loadLazyBundle } from './lynx/lazy-bundle.js';
|
|
14
13
|
import { __root } from './root.js';
|
|
15
|
-
import { DynamicPartType
|
|
14
|
+
import { DynamicPartType } from './snapshot/dynamicPartType.js';
|
|
15
|
+
import { snapshotCreateList } from './snapshot/list.js';
|
|
16
|
+
import { SnapshotInstance, __page, __pageId, createSnapshot, snapshotManager } from './snapshot.js';
|
|
16
17
|
|
|
17
18
|
export { __page, __pageId, __root };
|
|
18
19
|
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ComponentFromReactRuntime as Component,
|
|
9
9
|
ComponentFromReactRuntime as PureComponent,
|
|
10
10
|
} from '../compat/lynxComponent.js';
|
|
11
|
-
import { useCallback, useEffect, useMemo, useReducer,
|
|
11
|
+
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from '../hooks/react.js';
|
|
12
12
|
|
|
13
13
|
/* v8 ignore next 3 */
|
|
14
14
|
function __runInJS<T>(value: T): T | undefined | null {
|
|
@@ -23,13 +23,7 @@ import type { VNode } from 'preact';
|
|
|
23
23
|
import { options } from 'preact';
|
|
24
24
|
|
|
25
25
|
import { LifecycleConstant } from '../../lifecycleConstant.js';
|
|
26
|
-
import {
|
|
27
|
-
PerformanceTimingKeys,
|
|
28
|
-
globalPipelineOptions,
|
|
29
|
-
markTiming,
|
|
30
|
-
markTimingLegacy,
|
|
31
|
-
setPipeline,
|
|
32
|
-
} from '../../lynx/performance.js';
|
|
26
|
+
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../lynx/performance.js';
|
|
33
27
|
import { COMMIT } from '../../renderToOpcodes/constants.js';
|
|
34
28
|
import { applyQueuedRefs } from '../../snapshot/ref.js';
|
|
35
29
|
import { backgroundSnapshotInstanceManager } from '../../snapshot.js';
|
|
@@ -88,8 +82,8 @@ function replaceCommitHook(): void {
|
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
// Mark the end of virtual DOM diffing phase for performance tracking
|
|
91
|
-
markTimingLegacy(
|
|
92
|
-
markTiming(
|
|
85
|
+
markTimingLegacy('updateDiffVdomEnd');
|
|
86
|
+
markTiming('diffVdomEnd');
|
|
93
87
|
|
|
94
88
|
const backgroundSnapshotInstancesToRemove = globalBackgroundSnapshotInstancesToRemove;
|
|
95
89
|
globalBackgroundSnapshotInstancesToRemove = [];
|
|
@@ -167,7 +161,7 @@ function commitPatchUpdate(patchList: PatchList, patchOptions: Omit<PatchOptions
|
|
|
167
161
|
if (__PROFILE__) {
|
|
168
162
|
console.profile('commitChanges');
|
|
169
163
|
}
|
|
170
|
-
markTiming(
|
|
164
|
+
markTiming('packChangesStart');
|
|
171
165
|
const obj: {
|
|
172
166
|
data: string;
|
|
173
167
|
patchOptions: PatchOptions;
|
|
@@ -178,7 +172,7 @@ function commitPatchUpdate(patchList: PatchList, patchOptions: Omit<PatchOptions
|
|
|
178
172
|
reloadVersion: getReloadVersion(),
|
|
179
173
|
},
|
|
180
174
|
};
|
|
181
|
-
markTiming(
|
|
175
|
+
markTiming('packChangesEnd');
|
|
182
176
|
if (globalPipelineOptions) {
|
|
183
177
|
obj.patchOptions.pipelineOptions = globalPipelineOptions;
|
|
184
178
|
setPipeline(undefined);
|
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
* efficient transmission between threads and application to element tree.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export const
|
|
12
|
-
CreateElement,
|
|
13
|
-
InsertBefore,
|
|
14
|
-
RemoveChild,
|
|
15
|
-
SetAttribute,
|
|
16
|
-
SetAttributes,
|
|
11
|
+
export const SnapshotOperation = {
|
|
12
|
+
CreateElement: 0,
|
|
13
|
+
InsertBefore: 1,
|
|
14
|
+
RemoveChild: 2,
|
|
15
|
+
SetAttribute: 3,
|
|
16
|
+
SetAttributes: 4,
|
|
17
17
|
|
|
18
|
-
DEV_ONLY_AddSnapshot
|
|
19
|
-
DEV_ONLY_RegisterWorklet
|
|
20
|
-
}
|
|
18
|
+
DEV_ONLY_AddSnapshot: 100,
|
|
19
|
+
DEV_ONLY_RegisterWorklet: 101,
|
|
20
|
+
} as const;
|
|
21
21
|
|
|
22
22
|
// Operation format definitions:
|
|
23
23
|
//
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { sendCtxNotFoundEventToBackground } from './error.js';
|
|
17
17
|
import type { SnapshotPatch } from './snapshotPatch.js';
|
|
18
18
|
import { SnapshotOperation } from './snapshotPatch.js';
|
|
19
|
+
import type { DynamicPartType } from '../../snapshot/dynamicPartType.js';
|
|
19
20
|
import {
|
|
20
21
|
SnapshotInstance,
|
|
21
22
|
createSnapshot,
|
|
@@ -23,7 +24,6 @@ import {
|
|
|
23
24
|
snapshotInstanceManager,
|
|
24
25
|
snapshotManager,
|
|
25
26
|
} from '../../snapshot.js';
|
|
26
|
-
import type { DynamicPartType } from '../../snapshot.js';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Applies a patch of snapshot operations to the main thread.
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';
|
|
6
6
|
|
|
7
|
-
import { LifecycleConstant } from '../../lifecycleConstant.js';
|
|
8
|
-
import { __pendingListUpdates } from '../../list.js';
|
|
9
|
-
import { PerformanceTimingKeys, markTiming, setPipeline } from '../../lynx/performance.js';
|
|
10
|
-
import { __page } from '../../snapshot.js';
|
|
11
|
-
import { getReloadVersion } from '../pass.js';
|
|
12
7
|
import type { PatchList, PatchOptions } from './commit.js';
|
|
13
8
|
import { setMainThreadHydrationFinished } from './isMainThreadHydrationFinished.js';
|
|
14
9
|
import { snapshotPatchApply } from './snapshotPatchApply.js';
|
|
10
|
+
import { LifecycleConstant } from '../../lifecycleConstant.js';
|
|
11
|
+
import { markTiming, setPipeline } from '../../lynx/performance.js';
|
|
12
|
+
import { __pendingListUpdates } from '../../pendingListUpdates.js';
|
|
15
13
|
import { applyRefQueue } from '../../snapshot/workletRef.js';
|
|
14
|
+
import { __page } from '../../snapshot.js';
|
|
15
|
+
import { getReloadVersion } from '../pass.js';
|
|
16
16
|
|
|
17
17
|
function updateMainThread(
|
|
18
18
|
{ data, patchOptions }: {
|
|
@@ -25,12 +25,12 @@ function updateMainThread(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
setPipeline(patchOptions.pipelineOptions);
|
|
28
|
-
markTiming(
|
|
29
|
-
markTiming(
|
|
28
|
+
markTiming('mtsRenderStart');
|
|
29
|
+
markTiming('parseChangesStart');
|
|
30
30
|
const { patchList, flushOptions = {} } = JSON.parse(data) as PatchList;
|
|
31
31
|
|
|
32
|
-
markTiming(
|
|
33
|
-
markTiming(
|
|
32
|
+
markTiming('parseChangesEnd');
|
|
33
|
+
markTiming('patchChangesStart');
|
|
34
34
|
|
|
35
35
|
for (const { snapshotPatch, workletRefInitValuePatch } of patchList) {
|
|
36
36
|
updateWorkletRefInitValueChanges(workletRefInitValuePatch);
|
|
@@ -42,8 +42,8 @@ function updateMainThread(
|
|
|
42
42
|
// console.debug('********** Lepus updatePatch:');
|
|
43
43
|
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
44
44
|
}
|
|
45
|
-
markTiming(
|
|
46
|
-
markTiming(
|
|
45
|
+
markTiming('patchChangesEnd');
|
|
46
|
+
markTiming('mtsRenderEnd');
|
|
47
47
|
if (patchOptions.isHydration) {
|
|
48
48
|
setMainThreadHydrationFinished(true);
|
|
49
49
|
}
|
|
@@ -51,7 +51,6 @@ function updateMainThread(
|
|
|
51
51
|
if (patchOptions.pipelineOptions) {
|
|
52
52
|
flushOptions.pipelineOptions = patchOptions.pipelineOptions;
|
|
53
53
|
}
|
|
54
|
-
// TODO: triggerDataUpdated?
|
|
55
54
|
__FlushElementTree(__page, flushOptions);
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -11,7 +11,7 @@ import { render } from 'preact';
|
|
|
11
11
|
|
|
12
12
|
import { hydrate } from '../hydrate.js';
|
|
13
13
|
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
14
|
-
import { __pendingListUpdates } from '../
|
|
14
|
+
import { __pendingListUpdates } from '../pendingListUpdates.js';
|
|
15
15
|
import { __root, setRoot } from '../root.js';
|
|
16
16
|
import { destroyBackground } from './destroy.js';
|
|
17
17
|
import { applyRefQueue } from '../snapshot/workletRef.js';
|