From c7d97216bfa120da8ee437c4fe1cf70d2c06ae3a Mon Sep 17 00:00:00 2001 From: HuJean <7037477+HuJean@users.noreply.github.com> Date: Tue, 7 Apr 2026 19:20:26 +0800 Subject: [PATCH] refactor: code structure of runtime --- .changeset/bumpy-lizards-wear.md | 3 +++ .../react/runtime/__test__/lifecycle.test.jsx | 2 +- packages/react/runtime/__test__/list.test.jsx | 6 +++--- .../react/runtime/__test__/snapshot/ref.test.jsx | 2 +- .../react/runtime/__test__/utils/envManager.ts | 2 +- packages/react/runtime/src/debug/profile.ts | 3 +-- .../constant.ts} | 0 .../src/lifecycle/event/delayLifecycleEvents.ts | 2 +- .../react/runtime/src/lifecycle/event/jsReady.ts | 2 +- .../react/runtime/src/lifecycle/patch/commit.ts | 2 +- .../src/lifecycle/patch/updateMainThread.ts | 4 ++-- packages/react/runtime/src/lifecycle/reload.ts | 16 ++++++++-------- packages/react/runtime/src/{ => list}/list.ts | 8 ++++---- .../runtime/src/{ => list}/listUpdateInfo.ts | 7 +++---- .../runtime/src/{ => list}/pendingListUpdates.ts | 0 packages/react/runtime/src/lynx-api.ts | 2 +- .../react/runtime/src/lynx/calledByNative.ts | 10 +++++----- packages/react/runtime/src/lynx/tt.ts | 4 ++-- .../runtime/src/{ => renderToOpcodes}/hydrate.ts | 16 ++++++++-------- .../runtime/src/{ => renderToOpcodes}/opcodes.ts | 6 +++--- .../runtime/src/snapshot/backgroundSnapshot.ts | 10 +++++----- packages/react/runtime/src/snapshot/list.ts | 4 ++-- .../react/runtime/src/snapshot/platformInfo.ts | 4 ++-- packages/react/runtime/src/snapshot/snapshot.ts | 8 ++++---- packages/react/runtime/src/snapshot/spread.ts | 4 ++-- .../runtime/src/worklet/ref/updateInitValue.ts | 2 +- packages/react/runtime/types/types.d.ts | 2 +- .../testing-library/src/__tests__/list.test.jsx | 2 +- 28 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 .changeset/bumpy-lizards-wear.md rename packages/react/runtime/src/{lifecycleConstant.ts => lifecycle/constant.ts} (100%) rename packages/react/runtime/src/{ => list}/list.ts (97%) rename packages/react/runtime/src/{ => list}/listUpdateInfo.ts (97%) rename packages/react/runtime/src/{ => list}/pendingListUpdates.ts (100%) rename packages/react/runtime/src/{ => renderToOpcodes}/hydrate.ts (96%) rename packages/react/runtime/src/{ => renderToOpcodes}/opcodes.ts (96%) diff --git a/.changeset/bumpy-lizards-wear.md b/.changeset/bumpy-lizards-wear.md new file mode 100644 index 0000000000..853d812bb3 --- /dev/null +++ b/.changeset/bumpy-lizards-wear.md @@ -0,0 +1,3 @@ +--- + +--- diff --git a/packages/react/runtime/__test__/lifecycle.test.jsx b/packages/react/runtime/__test__/lifecycle.test.jsx index 1de785014c..29db60d394 100644 --- a/packages/react/runtime/__test__/lifecycle.test.jsx +++ b/packages/react/runtime/__test__/lifecycle.test.jsx @@ -6,7 +6,7 @@ import { globalEnvManager } from './utils/envManager'; import { waitSchedule } from './utils/nativeMethod'; import { globalCommitTaskMap, replaceCommitHook } from '../src/lifecycle/patch/commit'; import { deinitGlobalSnapshotPatch, initGlobalSnapshotPatch } from '../src/lifecycle/patch/snapshotPatch'; -import { LifecycleConstant } from '../src/lifecycleConstant'; +import { LifecycleConstant } from '../src/lifecycle/constant'; import { CATCH_ERROR } from '../src/renderToOpcodes/constants'; import { __root } from '../src/root'; import { setupPage, backgroundSnapshotInstanceManager } from '../src/snapshot'; diff --git a/packages/react/runtime/__test__/list.test.jsx b/packages/react/runtime/__test__/list.test.jsx index 3b6eba5114..70ea0303e0 100644 --- a/packages/react/runtime/__test__/list.test.jsx +++ b/packages/react/runtime/__test__/list.test.jsx @@ -2,12 +2,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { elementTree, nativeMethodQueue } from './utils/nativeMethod'; -import { hydrate } from '../src/hydrate'; -import { __pendingListUpdates } from '../src/pendingListUpdates'; +import { hydrate } from '../src/renderToOpcodes/hydrate'; +import { __pendingListUpdates } from '../src/list/pendingListUpdates'; import { SnapshotInstance, snapshotInstanceManager } from '../src/snapshot'; import { __root } from '../src/root'; import { globalEnvManager } from './utils/envManager'; -import { gRecycleMap, gSignMap } from '../src/list'; +import { gRecycleMap, gSignMap } from '../src/list/list'; const HOLE = null; diff --git a/packages/react/runtime/__test__/snapshot/ref.test.jsx b/packages/react/runtime/__test__/snapshot/ref.test.jsx index f5d9f88f78..b4027b873d 100644 --- a/packages/react/runtime/__test__/snapshot/ref.test.jsx +++ b/packages/react/runtime/__test__/snapshot/ref.test.jsx @@ -11,7 +11,7 @@ import { RefProxy, runDelayedUiOps, shouldDelayUiOps } from '../../src/lifecycle import { Component, createRef, useState } from '../../src/index'; import { clearCommitTaskId, replaceCommitHook } from '../../src/lifecycle/patch/commit'; import { injectUpdateMainThread } from '../../src/lifecycle/patch/updateMainThread'; -import { __pendingListUpdates } from '../../src/pendingListUpdates'; +import { __pendingListUpdates } from '../../src/list/pendingListUpdates'; import { __root } from '../../src/root'; import { setupPage } from '../../src/snapshot'; import { globalEnvManager } from '../utils/envManager'; diff --git a/packages/react/runtime/__test__/utils/envManager.ts b/packages/react/runtime/__test__/utils/envManager.ts index 54212540e9..9b6e2b84da 100644 --- a/packages/react/runtime/__test__/utils/envManager.ts +++ b/packages/react/runtime/__test__/utils/envManager.ts @@ -9,7 +9,7 @@ import { import { setupBackgroundDocument, setupDocument } from '../../src/document.js'; import { deinitGlobalSnapshotPatch } from '../../src/lifecycle/patch/snapshotPatch.js'; import { shouldDelayUiOps } from '../../src/lifecycle/ref/delay.js'; -import { clearListGlobal } from '../../src/list.js'; +import { clearListGlobal } from '../../src/list/list.js'; import { globalPipelineOptions, setPipeline } from '../../src/lynx/performance.js'; import { __root, setRoot } from '../../src/root.js'; import { SnapshotInstance, snapshotInstanceManager } from '../../src/snapshot/snapshot.js'; diff --git a/packages/react/runtime/src/debug/profile.ts b/packages/react/runtime/src/debug/profile.ts index 0fca5a70d0..232c78913d 100644 --- a/packages/react/runtime/src/debug/profile.ts +++ b/packages/react/runtime/src/debug/profile.ts @@ -2,13 +2,12 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ +import { noop } from '../utils.js'; export const isProfiling: boolean = /* @__PURE__ */ Boolean( lynx.performance?.isProfileRecording?.(), ); -const noop = () => {}; const noopFlowId = () => 0; export const profileStart = /* @__PURE__ */ ((() => { diff --git a/packages/react/runtime/src/lifecycleConstant.ts b/packages/react/runtime/src/lifecycle/constant.ts similarity index 100% rename from packages/react/runtime/src/lifecycleConstant.ts rename to packages/react/runtime/src/lifecycle/constant.ts diff --git a/packages/react/runtime/src/lifecycle/event/delayLifecycleEvents.ts b/packages/react/runtime/src/lifecycle/event/delayLifecycleEvents.ts index 6e044d096a..7e9fc0ba85 100644 --- a/packages/react/runtime/src/lifecycle/event/delayLifecycleEvents.ts +++ b/packages/react/runtime/src/lifecycle/event/delayLifecycleEvents.ts @@ -1,7 +1,7 @@ // Copyright 2025 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import type { LifecycleConstant } from '../../lifecycleConstant.js'; +import type { LifecycleConstant } from '../../lifecycle/constant.js'; const delayedLifecycleEvents: [type: LifecycleConstant, data: unknown][] = []; diff --git a/packages/react/runtime/src/lifecycle/event/jsReady.ts b/packages/react/runtime/src/lifecycle/event/jsReady.ts index ad01c39d7b..123b9ccea0 100644 --- a/packages/react/runtime/src/lifecycle/event/jsReady.ts +++ b/packages/react/runtime/src/lifecycle/event/jsReady.ts @@ -2,7 +2,7 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. import { profileEnd, profileStart } from '../../debug/profile.js'; -import { LifecycleConstant } from '../../lifecycleConstant.js'; +import { LifecycleConstant } from '../../lifecycle/constant.js'; import { __root } from '../../root.js'; let isJSReady: boolean; diff --git a/packages/react/runtime/src/lifecycle/patch/commit.ts b/packages/react/runtime/src/lifecycle/patch/commit.ts index 97d1224ed0..ffb4349e67 100644 --- a/packages/react/runtime/src/lifecycle/patch/commit.ts +++ b/packages/react/runtime/src/lifecycle/patch/commit.ts @@ -30,7 +30,7 @@ import { import { takeGlobalSnapshotPatch } from './snapshotPatch.js'; import type { SnapshotPatch } from './snapshotPatch.js'; import { profileEnd, profileStart } from '../../debug/profile.js'; -import { LifecycleConstant } from '../../lifecycleConstant.js'; +import { LifecycleConstant } from '../../lifecycle/constant.js'; import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../lynx/performance.js'; import { COMMIT } from '../../renderToOpcodes/constants.js'; import { backgroundSnapshotInstanceManager } from '../../snapshot/backgroundSnapshot.js'; diff --git a/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts b/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts index 7807338232..52ec94d6ef 100644 --- a/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts +++ b/packages/react/runtime/src/lifecycle/patch/updateMainThread.ts @@ -9,9 +9,9 @@ import type { PatchList, PatchOptions } from './commit.js'; import { setMainThreadHydrating } from './isMainThreadHydrating.js'; import { snapshotPatchApply } from './snapshotPatchApply.js'; import { prettyFormatSnapshotPatch } from '../../debug/formatPatch.js'; -import { LifecycleConstant } from '../../lifecycleConstant.js'; +import { LifecycleConstant } from '../../lifecycle/constant.js'; +import { __pendingListUpdates } from '../../list/pendingListUpdates.js'; import { markTiming, setPipeline } from '../../lynx/performance.js'; -import { __pendingListUpdates } from '../../pendingListUpdates.js'; import { __page } from '../../snapshot/definition.js'; import { applyRefQueue } from '../../snapshot/workletRef.js'; import { isMtsEnabled } from '../../worklet/functionality.js'; diff --git a/packages/react/runtime/src/lifecycle/reload.ts b/packages/react/runtime/src/lifecycle/reload.ts index c5c4c59141..79f4b013b7 100644 --- a/packages/react/runtime/src/lifecycle/reload.ts +++ b/packages/react/runtime/src/lifecycle/reload.ts @@ -9,21 +9,21 @@ import { render } from 'preact'; -import { hydrate } from '../hydrate.js'; -import { LifecycleConstant } from '../lifecycleConstant.js'; -import { __pendingListUpdates } from '../pendingListUpdates.js'; -import { __root, setRoot } from '../root.js'; import { destroyBackground } from './destroy.js'; +import { increaseReloadVersion } from './pass.js'; +import { renderMainThread } from './render.js'; +import { profileEnd, profileStart } from '../debug/profile.js'; +import { LifecycleConstant } from '../lifecycle/constant.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; +import { hydrate } from '../renderToOpcodes/hydrate.js'; +import { __root, setRoot } from '../root.js'; +import { __page } from '../snapshot/definition.js'; import { SnapshotInstance, snapshotInstanceManager } from '../snapshot/snapshot.js'; import { applyRefQueue } from '../snapshot/workletRef.js'; import { isEmptyObject } from '../utils.js'; import { clearJSReadyEventIdSwap, isJSReady } from './event/jsReady.js'; -import { increaseReloadVersion } from './pass.js'; import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js'; import { shouldDelayUiOps } from './ref/delay.js'; -import { renderMainThread } from './render.js'; -import { profileEnd, profileStart } from '../debug/profile.js'; -import { __page } from '../snapshot/definition.js'; function reloadMainThread(data: unknown, options: UpdatePageOption): void { if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) { diff --git a/packages/react/runtime/src/list.ts b/packages/react/runtime/src/list/list.ts similarity index 97% rename from packages/react/runtime/src/list.ts rename to packages/react/runtime/src/list/list.ts index 736303b2a8..7569ae4270 100644 --- a/packages/react/runtime/src/list.ts +++ b/packages/react/runtime/src/list/list.ts @@ -1,10 +1,10 @@ // Copyright 2024 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { LifecycleConstant } from './lifecycleConstant.js'; -import type { SnapshotInstance } from './snapshot/snapshot.js'; -import { applyRefQueue } from './snapshot/workletRef.js'; -import { maybePromise } from './utils.js'; +import { LifecycleConstant } from '../lifecycle/constant.js'; +import type { SnapshotInstance } from '../snapshot/snapshot.js'; +import { applyRefQueue } from '../snapshot/workletRef.js'; +import { maybePromise } from '../utils.js'; export const gSignMap: Record> = {}; export const gRecycleMap: Record>> = {}; diff --git a/packages/react/runtime/src/listUpdateInfo.ts b/packages/react/runtime/src/list/listUpdateInfo.ts similarity index 97% rename from packages/react/runtime/src/listUpdateInfo.ts rename to packages/react/runtime/src/list/listUpdateInfo.ts index 6c8db2c1ad..c53bc69bd4 100644 --- a/packages/react/runtime/src/listUpdateInfo.ts +++ b/packages/react/runtime/src/list/listUpdateInfo.ts @@ -1,11 +1,10 @@ // Copyright 2025 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. - -import { profileEnd, profileStart } from './debug/profile.js'; -import { hydrate } from './hydrate.js'; import { componentAtIndexFactory, enqueueComponentFactory } from './list.js'; -import type { SnapshotInstance } from './snapshot/snapshot.js'; +import { profileEnd, profileStart } from '../debug/profile.js'; +import { hydrate } from '../renderToOpcodes/hydrate.js'; +import type { SnapshotInstance } from '../snapshot/snapshot.js'; export interface ListUpdateInfo { flush(): number | undefined; diff --git a/packages/react/runtime/src/pendingListUpdates.ts b/packages/react/runtime/src/list/pendingListUpdates.ts similarity index 100% rename from packages/react/runtime/src/pendingListUpdates.ts rename to packages/react/runtime/src/list/pendingListUpdates.ts diff --git a/packages/react/runtime/src/lynx-api.ts b/packages/react/runtime/src/lynx-api.ts index e975250087..410c168171 100644 --- a/packages/react/runtime/src/lynx-api.ts +++ b/packages/react/runtime/src/lynx-api.ts @@ -9,7 +9,7 @@ import type { Consumer, FC, ReactNode } from 'react'; import { factory, withInitDataInState } from './compat/initData.js'; import { profileEnd, profileStart } from './debug/profile.js'; import { useLynxGlobalEventListener } from './hooks/useLynxGlobalEventListener.js'; -import { LifecycleConstant } from './lifecycleConstant.js'; +import { LifecycleConstant } from './lifecycle/constant.js'; import { flushDelayedLifecycleEvents } from './lynx/tt.js'; import { __root } from './root.js'; diff --git a/packages/react/runtime/src/lynx/calledByNative.ts b/packages/react/runtime/src/lynx/calledByNative.ts index cccd0bf927..7b397412ff 100644 --- a/packages/react/runtime/src/lynx/calledByNative.ts +++ b/packages/react/runtime/src/lynx/calledByNative.ts @@ -1,15 +1,15 @@ // Copyright 2024 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { hydrate } from '../hydrate.js'; +import { markTiming, setPipeline } from './performance.js'; +import { LifecycleConstant } from '../lifecycle/constant.js'; import { isJSReady, jsReady, jsReadyEventIdSwap, resetJSReady } from '../lifecycle/event/jsReady.js'; import { reloadMainThread } from '../lifecycle/reload.js'; import { renderMainThread } from '../lifecycle/render.js'; -import { LifecycleConstant } from '../lifecycleConstant.js'; -import { ssrHydrateByOpcodes } from '../opcodes.js'; -import { __pendingListUpdates } from '../pendingListUpdates.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; +import { hydrate } from '../renderToOpcodes/hydrate.js'; +import { ssrHydrateByOpcodes } from '../renderToOpcodes/opcodes.js'; import { __root, setRoot } from '../root.js'; -import { markTiming, setPipeline } from './performance.js'; import { __page, setupPage } from '../snapshot/definition.js'; import { SnapshotInstance } from '../snapshot/snapshot.js'; import { applyRefQueue } from '../snapshot/workletRef.js'; diff --git a/packages/react/runtime/src/lynx/tt.ts b/packages/react/runtime/src/lynx/tt.ts index 635dc0a664..55552c182e 100644 --- a/packages/react/runtime/src/lynx/tt.ts +++ b/packages/react/runtime/src/lynx/tt.ts @@ -3,13 +3,13 @@ // LICENSE file in the root directory of this source tree. import { process, render } from 'preact'; -import { LifecycleConstant, NativeUpdateDataType } from '../lifecycleConstant.js'; -import type { FirstScreenData } from '../lifecycleConstant.js'; import { PerformanceTimingFlags, PipelineOrigins, beginPipeline, markTiming } from './performance.js'; import { runWithForce } from './runWithForce.js'; import { printSnapshotInstanceToString } from '../debug/printSnapshot.js'; import { profileEnd, profileStart } from '../debug/profile.js'; import { getSnapshotVNodeSource } from '../debug/vnodeSource.js'; +import { LifecycleConstant, NativeUpdateDataType } from '../lifecycle/constant.js'; +import type { FirstScreenData } from '../lifecycle/constant.js'; import { destroyBackground } from '../lifecycle/destroy.js'; import { delayedEvents, delayedPublishEvent } from '../lifecycle/event/delayEvents.js'; import { delayLifecycleEvent, delayedLifecycleEvents } from '../lifecycle/event/delayLifecycleEvents.js'; diff --git a/packages/react/runtime/src/hydrate.ts b/packages/react/runtime/src/renderToOpcodes/hydrate.ts similarity index 96% rename from packages/react/runtime/src/hydrate.ts rename to packages/react/runtime/src/renderToOpcodes/hydrate.ts index 69b00fbfb0..cee54eaabe 100644 --- a/packages/react/runtime/src/hydrate.ts +++ b/packages/react/runtime/src/renderToOpcodes/hydrate.ts @@ -2,14 +2,14 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { profileEnd, profileStart } from './debug/profile.js'; -import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from './list.js'; -import { __pendingListUpdates } from './pendingListUpdates.js'; -import { DynamicPartType } from './snapshot/dynamicPartType.js'; -import type { PlatformInfo } from './snapshot/platformInfo.js'; -import { unref } from './snapshot/ref.js'; -import type { SnapshotInstance } from './snapshot/snapshot.js'; -import { isEmptyObject } from './utils.js'; +import { profileEnd, profileStart } from '../debug/profile.js'; +import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; +import { DynamicPartType } from '../snapshot/dynamicPartType.js'; +import type { PlatformInfo } from '../snapshot/platformInfo.js'; +import { unref } from '../snapshot/ref.js'; +import type { SnapshotInstance } from '../snapshot/snapshot.js'; +import { isEmptyObject } from '../utils.js'; const UNREACHABLE_ITEM_KEY_NOT_FOUND = 'UNREACHABLE_ITEM_KEY_NOT_FOUND'; diff --git a/packages/react/runtime/src/opcodes.ts b/packages/react/runtime/src/renderToOpcodes/opcodes.ts similarity index 96% rename from packages/react/runtime/src/opcodes.ts rename to packages/react/runtime/src/renderToOpcodes/opcodes.ts index 881bc6548a..365e2fc191 100644 --- a/packages/react/runtime/src/opcodes.ts +++ b/packages/react/runtime/src/renderToOpcodes/opcodes.ts @@ -2,9 +2,9 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. import { hydrate } from './hydrate.js'; -import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from './list.js'; -import { CHILDREN } from './renderToOpcodes/constants.js'; -import { SnapshotInstance } from './snapshot/snapshot.js'; +import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js'; +import { CHILDREN } from './constants.js'; +import { SnapshotInstance } from '../snapshot/snapshot.js'; const OpcodeBegin = 0; const OpcodeEnd = 1; diff --git a/packages/react/runtime/src/snapshot/backgroundSnapshot.ts b/packages/react/runtime/src/snapshot/backgroundSnapshot.ts index b2b610c5f9..18c56ed0f2 100644 --- a/packages/react/runtime/src/snapshot/backgroundSnapshot.ts +++ b/packages/react/runtime/src/snapshot/backgroundSnapshot.ts @@ -10,11 +10,6 @@ import type { Worklet } from '@lynx-js/react/worklet-runtime/bindings'; -import { profileEnd, profileStart } from '../debug/profile.js'; -import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js'; -import { processGestureBackground } from '../gesture/processGestureBagkround.js'; -import type { GestureKind } from '../gesture/types.js'; -import { diffArrayAction, diffArrayLepus } from '../hydrate.js'; import { snapshotManager } from './definition.js'; import type { Snapshot } from './definition.js'; import { DynamicPartType } from './dynamicPartType.js'; @@ -25,6 +20,10 @@ import { hydrationMap } from './snapshotInstanceHydrationMap.js'; import { transformSpread } from './spread.js'; import type { SerializedSnapshotInstance } from './types.js'; import { traverseSnapshotInstance } from './utils.js'; +import { profileEnd, profileStart } from '../debug/profile.js'; +import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js'; +import { processGestureBackground } from '../gesture/processGestureBagkround.js'; +import type { GestureKind } from '../gesture/types.js'; import { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js'; import { SnapshotOperation, @@ -34,6 +33,7 @@ import { } from '../lifecycle/patch/snapshotPatch.js'; import type { SnapshotPatch } from '../lifecycle/patch/snapshotPatch.js'; import { globalPipelineOptions } from '../lynx/performance.js'; +import { diffArrayAction, diffArrayLepus } from '../renderToOpcodes/hydrate.js'; import { isDirectOrDeepEqual } from '../utils.js'; import { onPostWorkletCtx } from '../worklet/ctx.js'; diff --git a/packages/react/runtime/src/snapshot/list.ts b/packages/react/runtime/src/snapshot/list.ts index 972433e888..426f80b2e9 100644 --- a/packages/react/runtime/src/snapshot/list.ts +++ b/packages/react/runtime/src/snapshot/list.ts @@ -2,8 +2,8 @@ // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { hydrate } from '../hydrate.js'; -import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list.js'; +import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js'; +import { hydrate } from '../renderToOpcodes/hydrate.js'; import type { SnapshotInstance } from '../snapshot/snapshot.js'; const destroyLifetimeHandlerMap = new Map void>(); diff --git a/packages/react/runtime/src/snapshot/platformInfo.ts b/packages/react/runtime/src/snapshot/platformInfo.ts index 4612033141..70f88a57b0 100644 --- a/packages/react/runtime/src/snapshot/platformInfo.ts +++ b/packages/react/runtime/src/snapshot/platformInfo.ts @@ -1,8 +1,8 @@ // Copyright 2025 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. -import { ListUpdateInfoRecording } from '../listUpdateInfo.js'; -import { __pendingListUpdates } from '../pendingListUpdates.js'; +import { ListUpdateInfoRecording } from '../list/listUpdateInfo.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; import type { SnapshotInstance } from '../snapshot/snapshot.js'; const platformInfoVirtualAttributes: Set = /* @__PURE__ */ new Set([ diff --git a/packages/react/runtime/src/snapshot/snapshot.ts b/packages/react/runtime/src/snapshot/snapshot.ts index 1464690583..e5b9722a64 100644 --- a/packages/react/runtime/src/snapshot/snapshot.ts +++ b/packages/react/runtime/src/snapshot/snapshot.ts @@ -10,10 +10,6 @@ import type { Worklet, WorkletRefImpl } from '@lynx-js/react/worklet-runtime/bindings'; -import { clearSnapshotVNodeSource } from '../debug/vnodeSource.js'; -import { SnapshotOperation, __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js'; -import { ListUpdateInfoRecording } from '../listUpdateInfo.js'; -import { __pendingListUpdates } from '../pendingListUpdates.js'; import { DEFAULT_CSS_ID, DEFAULT_ENTRY_NAME } from './constants.js'; import { snapshotManager } from './definition.js'; import type { Snapshot } from './definition.js'; @@ -23,6 +19,10 @@ import type { PlatformInfo } from './platformInfo.js'; import { unref } from './ref.js'; import type { SerializedSnapshotInstance } from './types.js'; import { traverseSnapshotInstance } from './utils.js'; +import { clearSnapshotVNodeSource } from '../debug/vnodeSource.js'; +import { SnapshotOperation, __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js'; +import { ListUpdateInfoRecording } from '../list/listUpdateInfo.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; import { isDirectOrDeepEqual } from '../utils.js'; export const snapshotInstanceManager: { diff --git a/packages/react/runtime/src/snapshot/spread.ts b/packages/react/runtime/src/snapshot/spread.ts index 14e8edb3fd..a68ffc45b9 100644 --- a/packages/react/runtime/src/snapshot/spread.ts +++ b/packages/react/runtime/src/snapshot/spread.ts @@ -12,8 +12,8 @@ import type { Element, Worklet, WorkletRefImpl } from '@lynx-js/react/worklet-runtime/bindings'; import type { BackgroundSnapshotInstance } from './backgroundSnapshot.js'; -import { ListUpdateInfoRecording } from '../listUpdateInfo.js'; -import { __pendingListUpdates } from '../pendingListUpdates.js'; +import { ListUpdateInfoRecording } from '../list/listUpdateInfo.js'; +import { __pendingListUpdates } from '../list/pendingListUpdates.js'; import { SnapshotInstance } from '../snapshot/snapshot.js'; import { isDirectOrDeepEqual, isEmptyObject, pick } from '../utils.js'; import { updateEvent } from './event.js'; diff --git a/packages/react/runtime/src/worklet/ref/updateInitValue.ts b/packages/react/runtime/src/worklet/ref/updateInitValue.ts index f547b3228d..379b4caf67 100644 --- a/packages/react/runtime/src/worklet/ref/updateInitValue.ts +++ b/packages/react/runtime/src/worklet/ref/updateInitValue.ts @@ -6,7 +6,7 @@ import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime import { takeWorkletRefInitValuePatch } from './workletRefPool.js'; import type { workletRefInitValuePatch } from './workletRefPool.js'; -import { LifecycleConstant } from '../../lifecycleConstant.js'; +import { LifecycleConstant } from '../../lifecycle/constant.js'; function updateMTRefInitValue({ data }: { data: string }): void { // This update ignores reloadVersion check. diff --git a/packages/react/runtime/types/types.d.ts b/packages/react/runtime/types/types.d.ts index c3a8333e31..c69a0ed1c2 100644 --- a/packages/react/runtime/types/types.d.ts +++ b/packages/react/runtime/types/types.d.ts @@ -4,7 +4,7 @@ import { EventEmitter } from '@lynx-js/types'; -import { LifecycleConstant } from '../src/lifecycleConstant.js'; +import { LifecycleConstant } from '../src/lifecycle/constant.js'; import { Lynx as LynxApi } from '../src/lynx-api.js'; import type { InitData, InitDataRaw } from '../src/lynx-api.js'; diff --git a/packages/react/testing-library/src/__tests__/list.test.jsx b/packages/react/testing-library/src/__tests__/list.test.jsx index 775a16cab7..cb718f18ef 100644 --- a/packages/react/testing-library/src/__tests__/list.test.jsx +++ b/packages/react/testing-library/src/__tests__/list.test.jsx @@ -8,7 +8,7 @@ import { describe, expect } from 'vitest'; import { Component, useState } from '@lynx-js/react'; import { render } from '..'; -import { __pendingListUpdates } from '../../../runtime/lib/pendingListUpdates.js'; +import { __pendingListUpdates } from '../../../runtime/lib/list/pendingListUpdates.js'; describe('list', () => { it('basic', async () => {