@lynx-js/react 0.129.0 → 0.129.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/globalProps.test.ts +27 -6
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
- package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
- package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +118 -2
- package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
- package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
- package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
- package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
- package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
- package/runtime/__test__/shared/component-stack.test.ts +211 -0
- package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
- package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- package/runtime/__test__/snapshot/ref.test.jsx +30 -0
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
- package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
- package/runtime/lazy/element-template-internal.js +1 -1
- package/runtime/lazy/internal.js +1 -1
- package/runtime/lazy/jsx-dev-runtime.js +1 -1
- package/runtime/lazy/jsx-runtime.js +1 -1
- package/runtime/lazy/legacy-react-runtime.js +1 -1
- package/runtime/lazy/react-lepus.js +1 -1
- package/runtime/lazy/react.js +1 -1
- package/runtime/lib/core/capture-main-thread-object.js +2 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/globalProps.js +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
- package/runtime/lib/core/lynx-data-processors.js +3 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.js +1 -1
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/document.js +0 -5
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.js +5 -2
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +11 -12
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +16 -11
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +23 -0
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/client/root.d.ts +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +1 -1
- package/runtime/lib/element-template/debug/alog.js +4 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +2 -2
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +2 -2
- package/runtime/lib/element-template/internal.js +1 -14
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/flush.d.ts +1 -0
- package/runtime/lib/element-template/native/flush.js +9 -0
- package/runtime/lib/element-template/native/flush.js.map +1 -0
- package/runtime/lib/element-template/native/main-thread-api.js +3 -7
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +8 -2
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +57 -50
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +1 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +7 -1
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +31 -2
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +2 -125
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/shared/component-stack.d.ts +0 -4
- package/runtime/lib/shared/component-stack.js +21 -5
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/capture-main-thread-object.ts +2 -1
- package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
- package/runtime/src/core/globalProps.ts +1 -1
- package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
- package/runtime/src/core/lynx-data-processors.ts +124 -1
- package/runtime/src/core/runtime-destroy.ts +1 -1
- package/runtime/src/document.ts +0 -6
- package/runtime/src/element-template/background/attr-slots.ts +5 -1
- package/runtime/src/element-template/background/commit-hook.ts +18 -12
- package/runtime/src/element-template/background/destroy.ts +16 -13
- package/runtime/src/element-template/background/hydrate.ts +23 -0
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/debug/alog.ts +5 -2
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +1 -20
- package/runtime/src/element-template/lynx/env.ts +1 -1
- package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
- package/runtime/src/element-template/native/flush.ts +10 -0
- package/runtime/src/element-template/native/main-thread-api.ts +3 -6
- package/runtime/src/element-template/native/mts-destroy.ts +7 -2
- package/runtime/src/element-template/native/patch-listener.ts +62 -57
- package/runtime/src/element-template/native/reload-background.ts +1 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
- package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
- package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
- package/runtime/src/element-template/protocol/opcodes.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +8 -13
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +38 -0
- package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
- package/runtime/src/element-template/types.d.ts +6 -0
- package/runtime/src/internal.ts +1 -1
- package/runtime/src/lynx-api.ts +2 -124
- package/runtime/src/shared/component-stack.ts +22 -5
- package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
- package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
- package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
- package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/worklet-runtime/README.md +30 -10
- package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
- package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
- package/runtime/types/types.d.ts +2 -1
- package/runtime/vitest.config.ts +0 -2
- package/testing-library/.turbo/turbo-build.log +7 -7
- package/testing-library/src/__tests__/act.test.jsx +0 -7
- package/testing-library/src/__tests__/alog.test.jsx +12 -54
- package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
- package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
- package/testing-library/src/__tests__/worklet.test.jsx +49 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
- package/transform/__test__/defines.spec.js +30 -0
- package/transform/__test__/fixture.spec.js +11 -11
- package/transform/__test__/main-thread-object-compat.spec.js +111 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
- package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
- package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/package.json +0 -1
- package/transform/src/lib.rs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
- package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
- package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/hmr.js +0 -28
- package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
- package/runtime/src/snapshot/worklet/hmr.ts +0 -34
- /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
- /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
|
@@ -37,6 +37,12 @@ declare global {
|
|
|
37
37
|
// explicit flush options. It is not an Element Template handle.
|
|
38
38
|
function __FlushElementTree(element: undefined, options: FlushOptions): void;
|
|
39
39
|
|
|
40
|
+
// Materializes the instance on demand; parent mounting and layout may still be pending.
|
|
41
|
+
function __GetElementByAttrSlot(
|
|
42
|
+
templateInstance: ElementTemplateHandle,
|
|
43
|
+
attrSlotIndex: number,
|
|
44
|
+
): ElementRef | null;
|
|
45
|
+
|
|
40
46
|
function __CreateElementTemplate(
|
|
41
47
|
templateKey: string,
|
|
42
48
|
bundleUrl: string | null | undefined,
|
package/runtime/src/internal.ts
CHANGED
|
@@ -98,8 +98,8 @@ export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory
|
|
|
98
98
|
export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
|
|
99
99
|
|
|
100
100
|
export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
|
|
101
|
-
export { registerWorkletOnBackground } from './snapshot/worklet/hmr.js';
|
|
102
101
|
|
|
102
|
+
export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
|
|
103
103
|
export { captureMainThreadObject } from './core/capture-main-thread-object.js';
|
|
104
104
|
|
|
105
105
|
if (__DEV__) {
|
package/runtime/src/lynx-api.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { createGlobalProps } from './core/globalProps.js';
|
|
|
10
10
|
import type { GlobalProps } from './core/globalProps.js';
|
|
11
11
|
import { useLynxGlobalEventListener } from './core/hooks/useLynxGlobalEventListener.js';
|
|
12
12
|
import { factory, withInitDataInState } from './core/initData.js';
|
|
13
|
+
import type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from './core/lynx-data-processors.js';
|
|
13
14
|
import { __root } from './root.js';
|
|
14
15
|
import { profileEnd, profileStart } from './shared/profile.js';
|
|
15
16
|
import { LifecycleConstant } from './snapshot/lifecycle/constant.js';
|
|
@@ -338,132 +339,9 @@ export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.us
|
|
|
338
339
|
export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps
|
|
339
340
|
.useChanged();
|
|
340
341
|
|
|
341
|
-
|
|
342
|
-
* The interface you can extends so that the `defaultDataProcessor` parameter can be customized
|
|
343
|
-
*
|
|
344
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
345
|
-
*
|
|
346
|
-
* @public
|
|
347
|
-
*
|
|
348
|
-
* @group Types
|
|
349
|
-
*/
|
|
350
|
-
export interface InitDataRaw {}
|
|
351
|
-
/**
|
|
352
|
-
* The interface you can extends so that the `defaultDataProcessor` returning value can be customized
|
|
353
|
-
*
|
|
354
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
355
|
-
*
|
|
356
|
-
* @public
|
|
357
|
-
*
|
|
358
|
-
* @group Types
|
|
359
|
-
*/
|
|
360
|
-
export interface InitData {}
|
|
361
|
-
|
|
342
|
+
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw };
|
|
362
343
|
export { withInitDataInState };
|
|
363
344
|
|
|
364
|
-
/**
|
|
365
|
-
* The data processors that registered with {@link Lynx.registerDataProcessors}.
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
*
|
|
369
|
-
* Extending `dataProcessors` interface
|
|
370
|
-
*
|
|
371
|
-
* ```ts
|
|
372
|
-
* import type { DataProcessors as WellKnownDataProcessors } from '@lynx-js/react';
|
|
373
|
-
*
|
|
374
|
-
* declare module '@lynx-js/react' {
|
|
375
|
-
* interface DataProcessors extends WellKnownDataProcessors {
|
|
376
|
-
* foo(bar: string): number;
|
|
377
|
-
* }
|
|
378
|
-
* }
|
|
379
|
-
* ```
|
|
380
|
-
*
|
|
381
|
-
* Then you can use `lynx.registerDataProcessors` with types.
|
|
382
|
-
*
|
|
383
|
-
* ```js
|
|
384
|
-
* lynx.registerDataProcessors({
|
|
385
|
-
* dataProcessors: {
|
|
386
|
-
* foo(bar) {
|
|
387
|
-
* return 1;
|
|
388
|
-
* }
|
|
389
|
-
* }
|
|
390
|
-
* })
|
|
391
|
-
* ```
|
|
392
|
-
*
|
|
393
|
-
* @public
|
|
394
|
-
*
|
|
395
|
-
* @group Types
|
|
396
|
-
*/
|
|
397
|
-
export interface DataProcessors {
|
|
398
|
-
/**
|
|
399
|
-
* Optional processor to override screen metrics used by the app
|
|
400
|
-
*
|
|
401
|
-
* @param metrics - The physical screen dimensions in pixels
|
|
402
|
-
*
|
|
403
|
-
* @returns New screen dimensions to be used by the app
|
|
404
|
-
*
|
|
405
|
-
* @example
|
|
406
|
-
*
|
|
407
|
-
* ```ts
|
|
408
|
-
* lynx.registerDataProcessors({
|
|
409
|
-
* dataProcessors: {
|
|
410
|
-
* getScreenMetricsOverride: (metrics) => {
|
|
411
|
-
* // Force a specific aspect ratio
|
|
412
|
-
* return {
|
|
413
|
-
* width: metrics.width,
|
|
414
|
-
* height: metrics.width * (16/9)
|
|
415
|
-
* };
|
|
416
|
-
* }
|
|
417
|
-
* }
|
|
418
|
-
* });
|
|
419
|
-
* ```
|
|
420
|
-
*/
|
|
421
|
-
getScreenMetricsOverride?(metrics: {
|
|
422
|
-
/**
|
|
423
|
-
* The physical pixel width of the screen
|
|
424
|
-
*/
|
|
425
|
-
width: number;
|
|
426
|
-
/**
|
|
427
|
-
* The physical pixel height of the screen
|
|
428
|
-
*/
|
|
429
|
-
height: number;
|
|
430
|
-
}): { width: number; height: number };
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Custom unknown data processors.
|
|
434
|
-
*
|
|
435
|
-
* @remarks
|
|
436
|
-
*
|
|
437
|
-
* You may extends the `DataProcessors` interface for better TypeScript types. See {@link DataProcessors}.
|
|
438
|
-
*/
|
|
439
|
-
[processorName: string]: (...args: any[]) => any;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Definition of DataProcessor(s)
|
|
444
|
-
* @public
|
|
445
|
-
*
|
|
446
|
-
* @group Types
|
|
447
|
-
*/
|
|
448
|
-
export interface DataProcessorDefinition {
|
|
449
|
-
/**
|
|
450
|
-
* You can custom input and output type of `defaultDataProcessor` by extends {@link InitDataRaw} and {@link InitData}
|
|
451
|
-
*
|
|
452
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
453
|
-
*
|
|
454
|
-
* @param rawInitData - initData passed from native code
|
|
455
|
-
* @returns
|
|
456
|
-
* @public
|
|
457
|
-
*/
|
|
458
|
-
defaultDataProcessor?: (rawInitData: InitDataRaw) => InitData;
|
|
459
|
-
/**
|
|
460
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
461
|
-
*
|
|
462
|
-
* @public
|
|
463
|
-
*/
|
|
464
|
-
dataProcessors?: DataProcessors;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
345
|
/**
|
|
468
346
|
* APIs under `lynx` global variable that added by ReactLynx.
|
|
469
347
|
*
|
|
@@ -44,7 +44,7 @@ interface PatchedVNode extends VNode {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get human readable name of the component/dom node
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
function getVNodeDisplayName(vnode: PatchedVNode): string {
|
|
48
48
|
if (vnode.type === Fragment) {
|
|
49
49
|
return 'Fragment';
|
|
50
50
|
} else if (typeof vnode.type == 'function') {
|
|
@@ -81,6 +81,7 @@ const renderStack: PatchedVNode[] = [];
|
|
|
81
81
|
* optimization. In these cases the `_owner` will be different.
|
|
82
82
|
*/
|
|
83
83
|
let ownerStack: PatchedVNode[] = [];
|
|
84
|
+
let didInstallComponentStack = false;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* Get the currently rendered `vnode`
|
|
@@ -108,7 +109,7 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
return stack.reduce((acc, owner) => {
|
|
111
|
-
acc += ` in ${
|
|
112
|
+
acc += ` in ${getVNodeDisplayName(owner)}`;
|
|
112
113
|
|
|
113
114
|
const source = owner.__source;
|
|
114
115
|
if (source) {
|
|
@@ -125,6 +126,13 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
125
126
|
* debug messages for `this.setState` where the `vnode` is `undefined`.
|
|
126
127
|
*/
|
|
127
128
|
export function setupComponentStack(): void {
|
|
129
|
+
renderStack.length = 0;
|
|
130
|
+
ownerStack = [];
|
|
131
|
+
if (didInstallComponentStack) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
didInstallComponentStack = true;
|
|
135
|
+
|
|
128
136
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
129
137
|
const oldDiff = options[DIFF];
|
|
130
138
|
const oldDiffed = options[DIFFED];
|
|
@@ -135,9 +143,15 @@ export function setupComponentStack(): void {
|
|
|
135
143
|
|
|
136
144
|
options[DIFFED] = vnode => {
|
|
137
145
|
if (isPossibleOwner(vnode)) {
|
|
138
|
-
ownerStack.
|
|
146
|
+
const ownerIndex = ownerStack.lastIndexOf(vnode);
|
|
147
|
+
if (ownerIndex !== -1) {
|
|
148
|
+
ownerStack.length = ownerIndex;
|
|
149
|
+
}
|
|
150
|
+
const renderIndex = renderStack.lastIndexOf(vnode);
|
|
151
|
+
if (renderIndex !== -1) {
|
|
152
|
+
renderStack.length = renderIndex;
|
|
153
|
+
}
|
|
139
154
|
}
|
|
140
|
-
renderStack.pop();
|
|
141
155
|
if (oldDiffed) oldDiffed(vnode);
|
|
142
156
|
};
|
|
143
157
|
|
|
@@ -149,7 +163,10 @@ export function setupComponentStack(): void {
|
|
|
149
163
|
};
|
|
150
164
|
|
|
151
165
|
options[ROOT] = (vnode, parent) => {
|
|
152
|
-
|
|
166
|
+
if (!(parent as { parentNode?: unknown } | null | undefined)?.parentNode) {
|
|
167
|
+
renderStack.length = 0;
|
|
168
|
+
ownerStack = [];
|
|
169
|
+
}
|
|
153
170
|
if (oldRoot) oldRoot(vnode, parent);
|
|
154
171
|
};
|
|
155
172
|
|
|
@@ -8,6 +8,7 @@ import { delayedEvents } from './event/delayEvents.js';
|
|
|
8
8
|
import { delayedLifecycleEvents } from './event/delayLifecycleEvents.js';
|
|
9
9
|
import { globalCommitTaskMap } from './patch/commit.js';
|
|
10
10
|
import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
|
|
11
|
+
import { delayedUiOps } from './ref/delay.js';
|
|
11
12
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
12
13
|
import { withSyncEffectFlush } from '../../utils.js';
|
|
13
14
|
import { resetSnapshotMainThreadFunctionRuntime } from '../worklet/call/runOnMainThread.js';
|
|
@@ -20,25 +21,29 @@ function destroyBackground(): void {
|
|
|
20
21
|
|
|
21
22
|
deinitGlobalSnapshotPatch();
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
try {
|
|
25
|
+
withSyncEffectFlush(() => {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
27
|
+
render(null, __root as any);
|
|
28
|
+
});
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
delayedEvents
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
globalCommitTaskMap.forEach(task => {
|
|
31
|
+
task();
|
|
32
|
+
});
|
|
33
|
+
} finally {
|
|
34
|
+
globalCommitTaskMap.clear();
|
|
35
|
+
// Clear delayed events which should not be executed after destroyed.
|
|
36
|
+
// This is important when the page is performing a reload.
|
|
37
|
+
delayedLifecycleEvents.length = 0;
|
|
38
|
+
if (delayedEvents) {
|
|
39
|
+
delayedEvents.length = 0;
|
|
40
|
+
}
|
|
41
|
+
delayedUiOps.length = 0;
|
|
42
|
+
resetSnapshotBackgroundFunctionRuntime();
|
|
43
|
+
resetSnapshotMainThreadFunctionRuntime();
|
|
44
|
+
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
45
|
+
profileEnd();
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
|
|
@@ -18,7 +18,6 @@ export const SnapshotOperation = {
|
|
|
18
18
|
nodesRefRemoveChild: 6,
|
|
19
19
|
|
|
20
20
|
DEV_ONLY_AddSnapshot: 100,
|
|
21
|
-
DEV_ONLY_RegisterWorklet: 101,
|
|
22
21
|
DEV_ONLY_SetSnapshotEntryName: 102,
|
|
23
22
|
} as const;
|
|
24
23
|
|
|
@@ -64,10 +63,6 @@ export const SnapshotOperationParams: Record<number, { name: string; params: str
|
|
|
64
63
|
'snapshotCreator', /* string */
|
|
65
64
|
],
|
|
66
65
|
},
|
|
67
|
-
[SnapshotOperation.DEV_ONLY_RegisterWorklet]: {
|
|
68
|
-
name: 'DEV_ONLY_RegisterWorklet',
|
|
69
|
-
params: ['hash', /* string */ 'fnStr' /* string */],
|
|
70
|
-
},
|
|
71
66
|
[SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {
|
|
72
67
|
name: 'DEV_ONLY_SetSnapshotEntryName',
|
|
73
68
|
params: ['uniqID', /* string */ 'entryName' /* string */],
|
|
@@ -161,16 +161,6 @@ export function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: numbe
|
|
|
161
161
|
}
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
|
-
// case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
|
|
165
|
-
// // HMR-related
|
|
166
|
-
// if (__DEV__) {
|
|
167
|
-
// const hash: string = snapshotPatch[++i];
|
|
168
|
-
// const fnStr: string = snapshotPatch[++i];
|
|
169
|
-
// const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
|
|
170
|
-
// registerWorklet('main-thread', hash, fn);
|
|
171
|
-
// }
|
|
172
|
-
// break;
|
|
173
|
-
// }
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
}
|
|
@@ -36,72 +36,76 @@ function updateMainThread(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
setPipeline(patchOptions.pipelineOptions);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
try {
|
|
40
|
+
markTiming('mtsRenderStart');
|
|
41
|
+
markTiming('parseChangesStart');
|
|
42
|
+
const parsedData = JSON.parse(data) as PatchList;
|
|
43
|
+
const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
46
|
+
console.alog?.(
|
|
47
|
+
'[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify(
|
|
48
|
+
{
|
|
49
|
+
data: {
|
|
50
|
+
...parsedData,
|
|
51
|
+
patchList: parsedData.patchList.map(patch => ({
|
|
52
|
+
...patch,
|
|
53
|
+
snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
|
|
54
|
+
})),
|
|
55
|
+
},
|
|
56
|
+
patchOptions,
|
|
54
57
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
markTiming('parseChangesEnd');
|
|
64
|
-
markTiming('patchChangesStart');
|
|
65
|
-
if (patchOptions.isHydration) {
|
|
66
|
-
setMainThreadHydrating(true);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
for (const { snapshotPatch, id } of patchList) {
|
|
70
|
-
__pendingListUpdates.clearAttachedLists();
|
|
71
|
-
if (snapshotPatch) {
|
|
72
|
-
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
73
|
-
}
|
|
74
|
-
__pendingListUpdates.flush();
|
|
75
|
-
// console.debug('********** Lepus updatePatch:');
|
|
76
|
-
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
58
|
+
null,
|
|
59
|
+
2,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
77
62
|
}
|
|
78
|
-
|
|
79
|
-
markTiming('
|
|
80
|
-
markTiming('
|
|
63
|
+
|
|
64
|
+
markTiming('parseChangesEnd');
|
|
65
|
+
markTiming('patchChangesStart');
|
|
81
66
|
if (patchOptions.isHydration) {
|
|
82
|
-
setMainThreadHydrating(
|
|
67
|
+
setMainThreadHydrating(true);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
69
|
+
try {
|
|
70
|
+
for (const { snapshotPatch, id } of patchList) {
|
|
71
|
+
__pendingListUpdates.clearAttachedLists();
|
|
72
|
+
if (snapshotPatch) {
|
|
73
|
+
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
74
|
+
}
|
|
75
|
+
__pendingListUpdates.flush();
|
|
76
|
+
// console.debug('********** Lepus updatePatch:');
|
|
77
|
+
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
markTiming('patchChangesEnd');
|
|
81
|
+
markTiming('mtsRenderEnd');
|
|
82
|
+
if (patchOptions.isHydration) {
|
|
83
|
+
setMainThreadHydrating(false);
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
applyRefQueue();
|
|
87
|
+
if (delayedRunOnMainThreadData && isMtsEnabled()) {
|
|
88
|
+
setEomShouldFlushElementTree(false);
|
|
89
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
90
|
+
try {
|
|
91
|
+
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
92
|
+
/* v8 ignore next 3 */
|
|
93
|
+
} catch (e) {
|
|
94
|
+
lynx.reportError(e as Error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
setEomShouldFlushElementTree(true);
|
|
98
|
+
}
|
|
99
|
+
if (patchOptions.pipelineOptions) {
|
|
100
|
+
flushOptions.pipelineOptions = patchOptions.pipelineOptions;
|
|
101
|
+
}
|
|
102
|
+
__FlushElementTree(__page, flushOptions);
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (flowIds) {
|
|
105
|
+
lynx.performance.profileEnd();
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
setPipeline(undefined);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -17,26 +17,6 @@ export interface ListUpdateInfo {
|
|
|
17
17
|
onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// class ListUpdateInfoDiffing implements ListUpdateInfo {
|
|
21
|
-
// private oldChildNodes: SnapshotInstance[];
|
|
22
|
-
// constructor(private list: SnapshotInstance) {
|
|
23
|
-
// this.oldChildNodes = list.childNodes;
|
|
24
|
-
// }
|
|
25
|
-
// flush(): void {
|
|
26
|
-
// Object.defineProperty(SnapshotInstance.prototype, "key", {
|
|
27
|
-
// get: function () {
|
|
28
|
-
// return this.values[0]["item-key"];
|
|
29
|
-
// },
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
|
-
// }
|
|
33
|
-
// onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}
|
|
34
|
-
// onRemoveChild(child: SnapshotInstance): void {}
|
|
35
|
-
// onSetAttribute(child: SnapshotInstance, attr: any): void {
|
|
36
|
-
// throw new Error("Method not implemented.");
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
20
|
interface InsertAction {
|
|
41
21
|
position: number;
|
|
42
22
|
type: string;
|
|
@@ -58,30 +38,14 @@ interface ListOperations {
|
|
|
58
38
|
export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
59
39
|
constructor(private list: SnapshotInstance) {
|
|
60
40
|
this.oldChildNodes = list.childNodes;
|
|
61
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
62
41
|
}
|
|
63
42
|
|
|
64
|
-
// private __commitAndReset() {
|
|
65
|
-
// (this.__pendingAttributes ??= []).push(this.__toAttribute());
|
|
66
|
-
// this.oldChildNodes = this.list.childNodes;
|
|
67
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
68
|
-
// this.removeChild1.clear();
|
|
69
|
-
// this.removeChild2.clear();
|
|
70
|
-
// this.insertBefore.clear();
|
|
71
|
-
// this.appendChild.length = 0;
|
|
72
|
-
// this.platformInfoUpdate.clear();
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
43
|
flush(): undefined | number {
|
|
76
44
|
if (!this.list.__elements) {
|
|
77
45
|
return undefined;
|
|
78
46
|
}
|
|
79
47
|
const elementIndex = this.list.__snapshot_def.slot[0]![1];
|
|
80
48
|
const listElement = this.list.__elements[elementIndex]!;
|
|
81
|
-
// this.__pendingAttributes?.forEach(pendingAttribute => {
|
|
82
|
-
// __SetAttribute(listElement, "update-list-info", pendingAttribute);
|
|
83
|
-
// __FlushElementTree(listElement);
|
|
84
|
-
// });
|
|
85
49
|
const updateListInfo = this.__toAttribute();
|
|
86
50
|
|
|
87
51
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -132,7 +96,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
132
96
|
}
|
|
133
97
|
|
|
134
98
|
private oldChildNodes: SnapshotInstance[];
|
|
135
|
-
// private oldChildNodesSet: Set<SnapshotInstance>;
|
|
136
99
|
private removeChild = new Set<SnapshotInstance>();
|
|
137
100
|
private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K
|
|
138
101
|
private appendChild = [] as SnapshotInstance[];
|
|
@@ -140,15 +103,9 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
140
103
|
|
|
141
104
|
onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {
|
|
142
105
|
if (newNode.parentNode) {
|
|
143
|
-
// if (!this.oldChildNodesSet.has(newNode)) {
|
|
144
|
-
// this.__commitAndReset();
|
|
145
|
-
// }
|
|
146
106
|
this.removeChild.add(newNode);
|
|
147
107
|
}
|
|
148
108
|
if (existingNode) {
|
|
149
|
-
// if (!this.oldChildNodesSet.has(existingNode)) {
|
|
150
|
-
// this.__commitAndReset();
|
|
151
|
-
// }
|
|
152
109
|
const newChildren = this.insertBefore.get(existingNode) ?? [];
|
|
153
110
|
newChildren.push(newNode);
|
|
154
111
|
this.insertBefore.set(existingNode, newChildren);
|
|
@@ -158,9 +115,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
158
115
|
}
|
|
159
116
|
|
|
160
117
|
onRemoveChild(child: SnapshotInstance): void {
|
|
161
|
-
// if (!this.oldChildNodesSet.has(child)) {
|
|
162
|
-
// this.__commitAndReset();
|
|
163
|
-
// }
|
|
164
118
|
this.removeChild.add(child);
|
|
165
119
|
}
|
|
166
120
|
|
|
@@ -254,12 +208,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
254
208
|
}
|
|
255
209
|
|
|
256
210
|
toJSON(): [ListOperations] {
|
|
257
|
-
// if (this.__pendingAttributes) {
|
|
258
|
-
// return [...this.__pendingAttributes, this.__toAttribute()];
|
|
259
|
-
// } else {
|
|
260
|
-
// return [this.__toAttribute()];
|
|
261
|
-
// }
|
|
262
|
-
|
|
263
211
|
return [this.__toAttribute()] as const;
|
|
264
212
|
}
|
|
265
213
|
}
|
|
@@ -138,7 +138,7 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
138
138
|
|
|
139
139
|
setPipeline(options?.pipelineOptions);
|
|
140
140
|
markTiming('updateDiffVdomStart');
|
|
141
|
-
{
|
|
141
|
+
try {
|
|
142
142
|
__pendingListUpdates.clearAttachedLists();
|
|
143
143
|
renderMainThread();
|
|
144
144
|
// As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,
|
|
@@ -152,17 +152,19 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
152
152
|
// always call this before `__FlushElementTree`
|
|
153
153
|
__pendingListUpdates.flush();
|
|
154
154
|
applyRefQueue();
|
|
155
|
-
}
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
|
|
157
|
+
onFirstScreenTreeReady();
|
|
158
|
+
}
|
|
160
159
|
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
flushOptions.triggerDataUpdated = true;
|
|
161
|
+
markTiming('updateDiffVdomEnd');
|
|
163
162
|
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
if (typeof lepusng_gc === 'function') {
|
|
164
|
+
lepusng_gc();
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
setPipeline(undefined);
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
@@ -99,64 +99,6 @@ export function diffArrayLepus<A extends Typed, B extends Typed>(
|
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// export function diffIterableLepus<A extends Typed, B extends Typed>(
|
|
103
|
-
// before: A[],
|
|
104
|
-
// after: Iterable<B>,
|
|
105
|
-
// isSameType: (a: A, b: B) => boolean,
|
|
106
|
-
// onDiffChildren: (a: A, b: B) => void
|
|
107
|
-
// ): DiffResult<B> {
|
|
108
|
-
// let returnResult = EMPTY_DIFF_RESULT as DiffResult<B>;
|
|
109
|
-
// let lastPlacedIndex = 0;
|
|
110
|
-
// const result: DiffResult<B> = {
|
|
111
|
-
// $$diff: true,
|
|
112
|
-
// i: {},
|
|
113
|
-
// r: [],
|
|
114
|
-
// m: {},
|
|
115
|
-
// };
|
|
116
|
-
// const beforeMap: Record<string, Set<[A, number]>> = {};
|
|
117
|
-
|
|
118
|
-
// for (let i = 0; i < before.length; i++) {
|
|
119
|
-
// let node = before[i];
|
|
120
|
-
// (beforeMap[node.type] ??= new Set()).add([node, i]);
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
// let i = 0;
|
|
124
|
-
// for (const afterNode of after) {
|
|
125
|
-
// const beforeNodes = beforeMap[afterNode.type];
|
|
126
|
-
// let beforeNode: [A, number];
|
|
127
|
-
|
|
128
|
-
// if (beforeNodes && (([beforeNode] = beforeNodes), beforeNode) && isSameType(beforeNode[0], afterNode)) {
|
|
129
|
-
// // Reuse old node
|
|
130
|
-
// beforeNodes.delete(beforeNode);
|
|
131
|
-
|
|
132
|
-
// const oldIndex = beforeNode[1];
|
|
133
|
-
// onDiffChildren(beforeNode[0], afterNode);
|
|
134
|
-
// if (oldIndex < lastPlacedIndex) {
|
|
135
|
-
// result.m[oldIndex] = i;
|
|
136
|
-
// returnResult = result;
|
|
137
|
-
// i++;
|
|
138
|
-
// continue;
|
|
139
|
-
// } else {
|
|
140
|
-
// lastPlacedIndex = oldIndex;
|
|
141
|
-
// }
|
|
142
|
-
// } else {
|
|
143
|
-
// // Create new node
|
|
144
|
-
// result.i[i] = afterNode;
|
|
145
|
-
// returnResult = result;
|
|
146
|
-
// }
|
|
147
|
-
// i++;
|
|
148
|
-
// }
|
|
149
|
-
// // delete
|
|
150
|
-
// for (const k in beforeMap) {
|
|
151
|
-
// for (const [, i] of beforeMap[k]) {
|
|
152
|
-
// result.r.push(i);
|
|
153
|
-
// returnResult = result;
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// return result;
|
|
158
|
-
// }
|
|
159
|
-
|
|
160
102
|
export function diffArrayAction<T, K>(
|
|
161
103
|
before: T[],
|
|
162
104
|
diffResult: DiffResult<K>,
|