@lynx-js/react 0.129.0 → 0.129.1
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 +14 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- 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/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +83 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +31 -2
- 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 +197 -7
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -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 +121 -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/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- 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 +0 -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/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/commit-hook.js +11 -12
- package/runtime/lib/element-template/background/commit-hook.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/index.d.ts +2 -2
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -1
- package/runtime/lib/element-template/internal.js +0 -13
- 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/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-main-thread.js +2 -1
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -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 +4 -0
- 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/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 +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +41 -21
- 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 +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.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/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/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/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/commit-hook.ts +18 -12
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +0 -20
- package/runtime/src/element-template/lynx/env.ts +1 -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-main-thread.ts +2 -1
- package/runtime/src/element-template/protocol/types.ts +0 -13
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +5 -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/main-thread-background-function.ts +8 -1
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +51 -21
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +2 -2
- 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/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/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/vitest.config.ts +0 -2
- package/testing-library/.turbo/turbo-build.log +6 -6
- 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 +98 -376
- package/transform/__test__/defines.spec.js +30 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +56 -48
- 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_extract_member_expr_2_js.js +6 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +12 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_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 +113 -42
- 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 +273 -66
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/element-template/lynx/env.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,QAAQ,GAA4B,EAAE,CAAC;QAC3C,IAAI,UAAU,GAA4B,EAAE,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,G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Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { createProcessData } from '../../core/lynx-data-processors.js';\nimport type { DataProcessorDefinition } from '../../lynx-
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/element-template/lynx/env.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,QAAQ,GAA4B,EAAE,CAAC;QAC3C,IAAI,UAAU,GAA4B,EAAE,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;YACrC,IAAI,MAAM,EAAE,CAAC;gBACX,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACjC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,CAAC;QACjD,IAAI,CAAC,sBAAsB,GAAG,cAAY,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG;QAChB,kCAAkC;SACnC,CAAC;QACD,UAA2D,CAAC,UAAU;YACpE,IAA+C,CAAC,UAAU,IAAI,EAAE,CAAC;QAEpE,IAAI,CAAC,2BAA2B,GAAG,UACjC,SAAiB,EACjB,MAAW;YAEX,kBAAkB,CAAC,CAAC,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;QAEF,CAAC;YACC,+DAA+D;YAC/D,SAAS,MAAM,CAAC,KAAa;gBAC3B,OAAO,SAAS,KAAK,SAAS,CAAC;YACjC,CAAC;YACD,8GAA8G;YAC9G,wBAAwB;YACxB,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;gBAClD,wBAAwB;gBACxB,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;YACrC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,sBAAsB,GAAG,UAC5B,uBAAiD;YAEjD,UAAU,CAAC,WAAW,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;QACtE,CAAC,CAAC;QAEF,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { createProcessData } from '../../core/lynx-data-processors.js';\nimport type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';\n\nexport function setupLynxEnv(): void {\n if (!__LEPUS__) {\n let initData: Record<string, unknown> = {};\n let updateData: Record<string, unknown> = {};\n\n try {\n const params = lynx.getApp()._params;\n if (params) {\n initData = params.initData ?? {};\n updateData = params.updateData ?? {};\n }\n } catch {}\n\n lynx.__initData = { ...initData, ...updateData };\n lynx.registerDataProcessors = function() {};\n }\n\n if (__LEPUS__) {\n lynx.__initData = {\n /* available only in renderPage */\n };\n (globalThis as typeof globalThis & { SystemInfo?: unknown }).SystemInfo =\n (lynx as typeof lynx & { SystemInfo?: unknown }).SystemInfo ?? {};\n\n lynx.triggerGlobalEventFromLepus = function(\n eventName: string,\n params: any,\n ) {\n __OnLifecycleEvent(['globalEventFromLepus', [eventName, params]]);\n };\n\n {\n // eslint-disable-next-line unicorn/consistent-function-scoping\n function __name(empty: string) {\n return `Native${empty}Modules`;\n }\n // TODO(hongzhiyuan.hzy): make sure this is run before any other code (especially code access `NativeModules`)\n // @ts-expect-error hack\n if (typeof globalThis[__name('')] === 'undefined') {\n // @ts-expect-error hack\n globalThis[__name('')] = undefined;\n }\n }\n\n lynx.registerDataProcessors = function(\n dataProcessorDefinition?: DataProcessorDefinition,\n ) {\n globalThis.processData = createProcessData(dataProcessorDefinition);\n };\n\n lynx.registerDataProcessors();\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flushElementTemplate(options?: FlushOptions): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2026 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 { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
5
|
+
export function flushElementTemplate(options = {}) {
|
|
6
|
+
applyPendingMainThreadRefAttachments();
|
|
7
|
+
__FlushElementTree(undefined, options);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush.js","sourceRoot":"","sources":["../../../src/element-template/native/flush.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oCAAoC,EAAE,MAAM,uDAAuD,CAAC;AAE7G,MAAM,UAAU,oBAAoB,CAAC,UAAwB,EAAE;IAC7D,oCAAoC,EAAE,CAAC;IACvC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';\n\nexport function flushElementTemplate(options: FlushOptions = {}): void {\n applyPendingMainThreadRefAttachments();\n __FlushElementTree(undefined, options);\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { flushElementTemplate } from './flush.js';
|
|
4
5
|
import { reloadMainThread } from './reload-main-thread.js';
|
|
5
6
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
7
|
import { createElementTemplatePage, setupPage } from '../runtime/page/page.js';
|
|
@@ -31,15 +32,10 @@ function updatePage(data, options) {
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
applyUpdatePageData(data, options);
|
|
34
|
-
|
|
35
|
+
flushElementTemplate(options);
|
|
35
36
|
}
|
|
36
37
|
function updateGlobalProps(_data, options) {
|
|
37
|
-
|
|
38
|
-
__FlushElementTree(undefined, options);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
__FlushElementTree();
|
|
42
|
-
}
|
|
38
|
+
flushElementTemplate(options);
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
41
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,
|
|
1
|
+
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,OAA0B;IACnE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { flushElementTemplate } from './flush.js';\nimport { reloadMainThread } from './reload-main-thread.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { createElementTemplatePage, setupPage } from '../runtime/page/page.js';\nimport { renderMainThread } from '../runtime/render/render-main-thread.js';\n\nfunction injectCalledByNative(): void {\n const calledByNative: LynxCallByNative = {\n renderPage,\n updatePage,\n updateGlobalProps,\n getPageData: function() {\n return null;\n },\n removeComponents: function(): void {},\n };\n\n Object.assign(globalThis, calledByNative);\n}\n\nfunction renderPage(data: Record<string, unknown> | undefined): void {\n lynx.__initData = data ?? {};\n setupPage(createElementTemplatePage());\n renderMainThread();\n}\n\nfunction updatePage(data: Record<string, unknown> | undefined, options?: UpdatePageOption): void {\n if (__FIRST_SCREEN_SYNC_TIMING__ !== 'immediately') {\n return;\n }\n\n if (options?.reloadTemplate) {\n reloadMainThread(data, options);\n return;\n }\n\n applyUpdatePageData(data, options);\n flushElementTemplate(options);\n}\n\nfunction updateGlobalProps(_data: unknown, options?: UpdatePageOption): void {\n flushElementTemplate(options);\n}\n\n/**\n * @internal\n */\nexport { injectCalledByNative };\n"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
5
|
import { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
6
6
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
7
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
7
8
|
import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
8
9
|
import { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
9
10
|
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
@@ -36,8 +37,13 @@ export function destroyElementTemplateMainThreadRuntime() {
|
|
|
36
37
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
37
38
|
destroyAllElementTemplateListStates();
|
|
38
39
|
elementTemplateRegistry.clear();
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
try {
|
|
41
|
+
clearMainThreadDynamicAttrState();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
45
|
+
resetTemplateId();
|
|
46
|
+
}
|
|
41
47
|
if (didPatchListenerResetThrow) {
|
|
42
48
|
throw patchListenerResetError;
|
|
43
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mts-destroy.js","sourceRoot":"","sources":["../../../src/element-template/native/mts-destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAA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ACjF,mCAAmC,EAAE,CAAC;IACtC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,+BAA+B,EAAE,CAAC;IACpC,CAAC;YAAS,CAAC;QACT,uDAAuD,EAAE,CAAC;QAC1D,eAAe,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,0BAA0B,EAAE,CAAC;QAC/B,MAAM,uBAAuB,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { resetElementTemplatePatchListener } from './patch-listener.js';\nimport { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';\nimport { destroyAllElementTemplateListStates } from '../runtime/list/list.js';\nimport { resetTemplateId } from '../runtime/template/handle.js';\nimport { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\nimport { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';\nimport { elementTemplateRegistry } from '../runtime/template/registry.js';\n\nexport function installOnMtsDestruction(): void {\n lynx.getNative?.().addEventListener('__DestroyLifetime', onMtsDestruction);\n}\n\nexport function onMtsDestruction(): void {\n const performance = lynx.performance;\n performance?.profileStart?.('ReactLynx::onMtsDestruction');\n try {\n destroyElementTemplateMainThreadRuntime();\n } finally {\n performance?.profileEnd?.();\n lynx.getNative?.().removeEventListener('__DestroyLifetime', onMtsDestruction);\n }\n}\n\nexport function destroyElementTemplateMainThreadRuntime(): void {\n let patchListenerResetError: unknown;\n let didPatchListenerResetThrow = false;\n try {\n resetElementTemplatePatchListener();\n } catch (error) {\n patchListenerResetError = error;\n didPatchListenerResetThrow = true;\n }\n\n resetElementTemplateRefInitValueListener();\n\n // The registry is the main-thread strong-reference owner for ET refs. Clear it\n // even if listener reset fails so destroy does not leave removed pages retained.\n destroyAllElementTemplateListStates();\n elementTemplateRegistry.clear();\n try {\n clearMainThreadDynamicAttrState();\n } finally {\n resetElementTemplateMainThreadBackgroundFunctionRuntime();\n resetTemplateId();\n }\n\n if (didPatchListenerResetThrow) {\n throw patchListenerResetError;\n }\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { getReloadVersion } from '../../core/reload-version.js';
|
|
|
7
7
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
8
8
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
9
9
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
10
|
+
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
10
11
|
let listener;
|
|
11
12
|
export function installElementTemplatePatchListener() {
|
|
12
13
|
resetElementTemplatePatchListener();
|
|
@@ -23,70 +24,76 @@ export function installElementTemplatePatchListener() {
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
setPipeline(pipelineOptions);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const hasOps = payload.ops.length > 0;
|
|
39
|
-
const flushOptions = payload.flushOptions;
|
|
40
|
-
const isHydration = payload.isHydration === true;
|
|
41
|
-
const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;
|
|
42
|
-
if (hasOps) {
|
|
43
|
-
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
44
|
-
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
45
|
-
+ JSON.stringify({
|
|
46
|
-
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
47
|
-
flushOptions,
|
|
48
|
-
flowIds,
|
|
49
|
-
}, null, 2));
|
|
27
|
+
try {
|
|
28
|
+
markTiming('mtsRenderStart');
|
|
29
|
+
markTiming('parseChangesStart');
|
|
30
|
+
const payload = JSON.parse(event.data.payload);
|
|
31
|
+
markTiming('parseChangesEnd');
|
|
32
|
+
if (typeof patchOptions.reloadVersion === 'number'
|
|
33
|
+
&& patchOptions.reloadVersion < getReloadVersion()) {
|
|
34
|
+
markTiming('mtsRenderEnd');
|
|
35
|
+
if (shouldProfilePatch) {
|
|
36
|
+
lynx.performance.profileEnd();
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
50
39
|
}
|
|
51
|
-
|
|
40
|
+
const hasOps = payload.ops.length > 0;
|
|
41
|
+
const flushOptions = payload.flushOptions;
|
|
42
|
+
const isHydration = payload.isHydration === true;
|
|
43
|
+
const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;
|
|
52
44
|
try {
|
|
53
|
-
|
|
45
|
+
if (hasOps) {
|
|
46
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
47
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
48
|
+
+ JSON.stringify({
|
|
49
|
+
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
50
|
+
flushOptions,
|
|
51
|
+
flowIds,
|
|
52
|
+
}, null, 2));
|
|
53
|
+
}
|
|
54
|
+
markTiming('patchChangesStart');
|
|
55
|
+
try {
|
|
56
|
+
applyElementTemplateUpdateCommands(payload.ops, isHydration);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
markTiming('patchChangesEnd');
|
|
60
|
+
markTiming('mtsRenderEnd');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
markTiming('mtsRenderEnd');
|
|
65
|
+
}
|
|
66
|
+
applyPendingMainThreadRefAttachments();
|
|
54
67
|
}
|
|
55
68
|
finally {
|
|
56
|
-
markTiming('patchChangesEnd');
|
|
57
|
-
markTiming('mtsRenderEnd');
|
|
58
69
|
if (isHydration) {
|
|
59
70
|
flushDelayedRunOnBackgroundFunctions();
|
|
60
71
|
clearFirstScreenMainThreadRefs();
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
for (const data of delayedRunOnMainThreadData) {
|
|
75
|
-
try {
|
|
76
|
-
runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
lynx.reportError(error);
|
|
74
|
+
if (delayedRunOnMainThreadData?.length) {
|
|
75
|
+
setEomShouldFlushElementTree(false);
|
|
76
|
+
try {
|
|
77
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
78
|
+
try {
|
|
79
|
+
runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
lynx.reportError(error);
|
|
83
|
+
}
|
|
80
84
|
}
|
|
81
85
|
}
|
|
86
|
+
finally {
|
|
87
|
+
setEomShouldFlushElementTree(true);
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
__FlushElementTree(undefined, flushOptions);
|
|
91
|
+
if (shouldProfilePatch) {
|
|
92
|
+
lynx.performance.profileEnd();
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
lynx.performance.profileEnd();
|
|
95
|
+
finally {
|
|
96
|
+
setPipeline(undefined);
|
|
90
97
|
}
|
|
91
98
|
};
|
|
92
99
|
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,EACtB,4BAA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ACzB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,YAAY,EAAE,CAAC,gBAAgB,CAClC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,EAAE,CAAC,mBAAmB,CACrC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport {\n clearFirstScreenMainThreadRefs,\n flushDelayedRunOnBackgroundFunctions,\n runRunOnMainThreadTask,\n setEomShouldFlushElementTree,\n} from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { markTiming, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';\nimport type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';\nimport type { ElementTemplateUpdateEvent } from '../protocol/update-event.js';\nimport { applyElementTemplateUpdateCommands } from '../runtime/patch.js';\nimport { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';\n\nlet listener:\n | ((event: Pick<ElementTemplateUpdateEvent, 'data'>) => void)\n | undefined;\n\nexport function installElementTemplatePatchListener(): void {\n resetElementTemplatePatchListener();\n\n listener = (event: Pick<ElementTemplateUpdateEvent, 'data'>) => {\n const { patchOptions } = event.data;\n const { flowIds, pipelineOptions } = patchOptions;\n const shouldProfilePatch = !!flowIds\n && typeof lynx.performance?.profileStart === 'function'\n && typeof lynx.performance?.profileEnd === 'function';\n if (shouldProfilePatch) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n setPipeline(pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n\n const payload = JSON.parse(event.data.payload) as ElementTemplateUpdateCommitContext;\n markTiming('parseChangesEnd');\n\n if (\n typeof patchOptions.reloadVersion === 'number'\n && patchOptions.reloadVersion < getReloadVersion()\n ) {\n markTiming('mtsRenderEnd');\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n return;\n }\n\n const hasOps = payload.ops.length > 0;\n const flushOptions = payload.flushOptions;\n const isHydration = payload.isHydration === true;\n const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;\n try {\n if (hasOps) {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate main-thread patch:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(payload.ops),\n flushOptions,\n flowIds,\n },\n null,\n 2,\n ),\n );\n }\n markTiming('patchChangesStart');\n try {\n applyElementTemplateUpdateCommands(payload.ops, isHydration);\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n }\n } else {\n markTiming('mtsRenderEnd');\n }\n applyPendingMainThreadRefAttachments();\n } finally {\n if (isHydration) {\n flushDelayedRunOnBackgroundFunctions();\n clearFirstScreenMainThreadRefs();\n }\n }\n if (delayedRunOnMainThreadData?.length) {\n setEomShouldFlushElementTree(false);\n try {\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n } catch (error) {\n lynx.reportError(error as Error);\n }\n }\n } finally {\n setEomShouldFlushElementTree(true);\n }\n }\n\n __FlushElementTree(undefined, flushOptions);\n\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n };\n\n lynx.getJSContext().addEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n}\n\nexport function resetElementTemplatePatchListener(): void {\n if (listener) {\n lynx.getJSContext().removeEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n }\n listener = undefined;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2026 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 { flushElementTemplate } from './flush.js';
|
|
4
5
|
import { onMtsDestruction } from './mts-destroy.js';
|
|
5
6
|
import { canReEvalMainThreadEntry, installMainThreadReloadCompleter, reEvalMainThreadEntry, } from '../../core/entry-reload.js';
|
|
6
7
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
@@ -51,7 +52,7 @@ export function reloadMainThread(data, options) {
|
|
|
51
52
|
const oldRoot = __root;
|
|
52
53
|
setRoot({ __jsx: oldRoot.__jsx });
|
|
53
54
|
renderMainThread();
|
|
54
|
-
|
|
55
|
+
flushElementTemplate(options);
|
|
55
56
|
}
|
|
56
57
|
finally {
|
|
57
58
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qCAAqC,EAAE,MAAM,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C,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;YACD,0CAA0C,CAAC,gBAAgB,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,wBAAwB,EAAE,EAAE,CAAC;YAC/B,gBAAgB,EAAE,CAAC;YACnB,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,CAA0B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QACD,uBAAuB,CAAC,KAAK,EAAE,CAAC;QAChC,+BAA+B,EAAE,CAAC;QAClC,uDAAuD,EAAE,CAAC;QAC1D,eAAe,EAAE,CAAC;QAElB,2EAA2E;QAC3E,0EAA0E;QAC1E,qBAAqB,EAAE,CAAC;QAExB,MAAM,OAAO,GAAG,MAAM,CAAC;QACvB,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAClC,gBAAgB,EAAE,CAAC;QAEnB,
|
|
1
|
+
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,MAAM,E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,MAAM,YAAY,GAAI,IAA4D,CAAC,OAAO,EAAE,YAAY,CAAC;IACzG,KAAK,MAAM,KAAK,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QACvC,iCAAiC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { flushElementTemplate } from './flush.js';\nimport { onMtsDestruction } from './mts-destroy.js';\nimport {\n canReEvalMainThreadEntry,\n installMainThreadReloadCompleter,\n reEvalMainThreadEntry,\n} from '../../core/entry-reload.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { increaseReloadVersion } from '../../core/reload-version.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';\nimport type { SerializedEtNode, SerializedPageRoot } from '../protocol/types.js';\nimport { destroyAllElementTemplateListStates } from '../runtime/list/list.js';\nimport { __page, setupPage } from '../runtime/page/page.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\nimport { renderMainThread } from '../runtime/render/render-main-thread.js';\nimport { resetTemplateId } from '../runtime/template/handle.js';\nimport { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\nimport {\n clearMainThreadDynamicAttrState,\n deleteMainThreadDynamicAttrStateForSubtree,\n} from '../runtime/template/main-thread-dynamic-attr-state.js';\nimport { elementTemplateRegistry } from '../runtime/template/registry.js';\n\nexport function reloadMainThread(data: unknown, options: UpdatePageOption): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadMainThread');\n }\n\n try {\n applyUpdatePageData(data, options);\n\n destroyAllElementTemplateListStates();\n // TODO: Replace this cleanup-only serialization with a direct page-children\n // or clear-slot PAPI once native exposes one.\n const page = __SerializeElementTemplate(__page) as SerializedPageRoot;\n for (const root of page.childSlots?.[ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX] ?? []) {\n const rootRef = elementTemplateRegistry.get(root.uid)!;\n __RemoveNodeFromElementTemplate(__page, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, rootRef);\n const removedHandleIds: number[] = [];\n collectSerializedSubtreeHandleIds(root, removedHandleIds);\n for (const handleId of removedHandleIds) {\n elementTemplateRegistry.delete(handleId);\n }\n deleteMainThreadDynamicAttrStateForSubtree(removedHandleIds);\n }\n if (canReEvalMainThreadEntry()) {\n onMtsDestruction();\n increaseReloadVersion();\n reEvalMainThreadEntry<MainThreadReloadHandoff>({ page: __page, options });\n return;\n }\n elementTemplateRegistry.clear();\n clearMainThreadDynamicAttrState();\n resetElementTemplateMainThreadBackgroundFunctionRuntime();\n resetTemplateId();\n\n // Ref cleanup still belongs to the old page. Advance only before rendering\n // the new tree so calls queued by old ref/unmount callbacks remain stale.\n increaseReloadVersion();\n\n const oldRoot = __root;\n setRoot({ __jsx: oldRoot.__jsx });\n renderMainThread();\n\n flushElementTemplate(options);\n } finally {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n}\n\ninterface MainThreadReloadHandoff {\n page: ElementTemplateHandle;\n options: UpdatePageOption;\n}\n\nexport function completeMainThreadReload({ page, options }: MainThreadReloadHandoff): void {\n setupPage(page);\n renderMainThread();\n __FlushElementTree(undefined, options);\n}\n\ninstallMainThreadReloadCompleter(completeMainThreadReload);\n\nfunction collectSerializedSubtreeHandleIds(\n node: SerializedEtNode,\n handleIds: number[],\n): void {\n handleIds.push(node.uid as number);\n for (const slot of node.childSlots ?? []) {\n for (const child of slot ?? []) {\n collectSerializedSubtreeHandleIds(child, handleIds);\n }\n }\n const listChildren = (node as { options?: { listChildren?: SerializedEtNode[] } }).options?.listChildren;\n for (const child of listChildren ?? []) {\n collectSerializedSubtreeHandleIds(child, handleIds);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/element-template/protocol/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { ElementTemplateUpdateOps } from './opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from './page.js';\n\nexport type SerializableValue =\n | string\n | number\n | boolean\n | null\n | SerializableValue[]\n | { [key: string]: SerializableValue };\n\nexport type RuntimeOptionValue =\n | SerializableValue\n | FiberElement\n | RuntimeOptionValue[]\n | { [key: string]: RuntimeOptionValue };\n\nexport type RuntimeOptions = Record<string, RuntimeOptionValue>;\n\nexport type RuntimeAttributeSlotValue =\n | SerializableValue\n | ((...args: unknown[]) => unknown)\n | RuntimeAttributeSlotValue[]\n | { [key: string]: RuntimeAttributeSlotValue };\n\nexport type RuntimeTypedElementAttributes = Record<string, RuntimeAttributeSlotValue>;\n\nexport type TypedElementAttributesCommand = Record<string, SerializableValue>;\n\nexport type RuntimeChildSlots = Array<ElementTemplateHandle[] | null | undefined>;\n\nexport type ElementTemplateHandleSlotsCommand = Array<number[] | null | undefined>;\n\nexport type SerializedEtNodeChildSlots = Array<SerializedEtNode[] | null | undefined>;\n\nexport interface ElementTemplateHandleRefCommandValue {\n __etHandleRef: number;\n [key: string]: SerializableValue;\n}\n\nexport interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {\n type: string;\n platformInfo: Record<string, SerializableValue>;\n subtreeHandleIds: number[];\n}\n\nexport type RuntimeOptionsCommand = Record<string, SerializableValue>;\n\n// Deferred typed-list create carries logical item records here. Its future\n// main-thread consumer resolves these refs into the list-specific runtime carrier.\nexport interface TypedListOptionsCommand extends RuntimeOptionsCommand {\n listChildren: UpdateTypedListItemCommand[];\n}\n\nexport interface RuntimeTypedListOptions {\n listChildren: ElementTemplateHandle[];\n}\n\nexport type SerializedRuntimeOptions = Record<string, SerializableValue>;\n\nexport interface SerializedTypedListOptions {\n listChildren: SerializedEtNode[];\n}\n\nexport interface SerializedEtNodeBase {\n attributeSlots?: SerializableValue[] | null;\n childSlots?: SerializedEtNodeChildSlots | null;\n uid: number;\n options?: SerializedRuntimeOptions | null;\n}\n\nexport interface SerializedCompiledNode extends SerializedEtNodeBase {\n templateKey: string;\n bundleUrl?: string;\n attributeSlots?: SerializableValue[] | null;\n}\n\nexport interface SerializedTypedNode extends SerializedEtNodeBase {\n // Native __SerializeElementTemplate returns typed hosts as { tag, attributes }.\n tag: string;\n attributes?: TypedElementAttributesCommand | null;\n}\n\nexport interface SerializedTypedListNode extends Omit<SerializedEtNodeBase, 'options'> {\n tag: 'list';\n attributes?: TypedElementAttributesCommand | null;\n options?: SerializedTypedListOptions | null;\n}\n\nexport type SerializedEtNode = SerializedCompiledNode | SerializedTypedNode | SerializedTypedListNode;\n\nexport interface SerializedPageRoot extends SerializedTypedNode {\n tag: typeof ELEMENT_TEMPLATE_PAGE_TYPE;\n uid: typeof ELEMENT_TEMPLATE_PAGE_HANDLE_ID;\n}\n\nexport interface ElementTemplateHydrateCommitContext {\n page: SerializedPageRoot;\n reloadVersion: number;\n}\n\nexport type CreateTemplateCommand = [\n typeof ElementTemplateUpdateOps.createTemplate,\n handleId: number,\n templateKey: string,\n bundleUrl: string | null | undefined,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n];\n\nexport type SetAttributeCommand = [\n typeof ElementTemplateUpdateOps.setAttribute,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadEventCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadEvent,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadRefCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadRef,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type InsertNodeCommand = [\n typeof ElementTemplateUpdateOps.insertNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n referenceHandleId: number,\n attachedSubtreeHandleIds: number[] | null,\n];\n\nexport type RemoveNodeCommand = [\n typeof ElementTemplateUpdateOps.removeNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n removedSubtreeHandleIds: number[],\n];\n\nexport type CreateTypedElementCommand = [\n typeof ElementTemplateUpdateOps.createTypedElement,\n handleId: number,\n type: string,\n attributes: TypedElementAttributesCommand | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n options: RuntimeOptionsCommand | TypedListOptionsCommand | null | undefined,\n];\n\nexport type InsertTypedListItemCommand = [\n typeof ElementTemplateUpdateOps.insertTypedListItem,\n listHandleId: number,\n item: UpdateTypedListItemCommand,\n beforeHandleId: number,\n];\n\nexport type RemoveTypedListItemCommand = [\n typeof ElementTemplateUpdateOps.removeTypedListItem,\n listHandleId: number,\n itemHandleId: number,\n removedSubtreeHandleIds: number[],\n];\n\nexport type UpdateTypedListItemInfoCommand = [\n typeof ElementTemplateUpdateOps.updateTypedListItem,\n listHandleId: number,\n item: UpdateTypedListItemCommand,\n];\n\nexport type ElementTemplateUpdateCommand =\n | CreateTemplateCommand\n | SetAttributeCommand\n | SetMainThreadEventCommand\n | SetMainThreadRefCommand\n | InsertNodeCommand\n | RemoveNodeCommand\n | CreateTypedElementCommand\n | InsertTypedListItemCommand\n | RemoveTypedListItemCommand\n | UpdateTypedListItemInfoCommand;\n\n// Commands are transported as a flat stream to match the native update payload.\n// Tuple aliases above define each opcode's shape; this item union preserves the\n// existing flat buffer ergonomics while making command contracts explicit.\nexport type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];\n\nexport interface ElementTemplateFlushOptions {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/element-template/protocol/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { ElementTemplateUpdateOps } from './opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from './page.js';\n\nexport type SerializableValue =\n | string\n | number\n | boolean\n | null\n | SerializableValue[]\n | { [key: string]: SerializableValue };\n\nexport type RuntimeOptionValue =\n | SerializableValue\n | FiberElement\n | RuntimeOptionValue[]\n | { [key: string]: RuntimeOptionValue };\n\nexport type RuntimeOptions = Record<string, RuntimeOptionValue>;\n\nexport type RuntimeAttributeSlotValue =\n | SerializableValue\n | ((...args: unknown[]) => unknown)\n | RuntimeAttributeSlotValue[]\n | { [key: string]: RuntimeAttributeSlotValue };\n\nexport type RuntimeTypedElementAttributes = Record<string, RuntimeAttributeSlotValue>;\n\nexport type TypedElementAttributesCommand = Record<string, SerializableValue>;\n\nexport type RuntimeChildSlots = Array<ElementTemplateHandle[] | null | undefined>;\n\nexport type ElementTemplateHandleSlotsCommand = Array<number[] | null | undefined>;\n\nexport type SerializedEtNodeChildSlots = Array<SerializedEtNode[] | null | undefined>;\n\nexport interface ElementTemplateHandleRefCommandValue {\n __etHandleRef: number;\n [key: string]: SerializableValue;\n}\n\nexport interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {\n type: string;\n platformInfo: Record<string, SerializableValue>;\n subtreeHandleIds: number[];\n}\n\nexport type RuntimeOptionsCommand = Record<string, SerializableValue>;\n\n// Deferred typed-list create carries logical item records here. Its future\n// main-thread consumer resolves these refs into the list-specific runtime carrier.\nexport interface TypedListOptionsCommand extends RuntimeOptionsCommand {\n listChildren: UpdateTypedListItemCommand[];\n}\n\nexport interface RuntimeTypedListOptions {\n listChildren: ElementTemplateHandle[];\n}\n\nexport type SerializedRuntimeOptions = Record<string, SerializableValue>;\n\nexport interface SerializedTypedListOptions {\n listChildren: SerializedEtNode[];\n}\n\nexport interface SerializedEtNodeBase {\n attributeSlots?: SerializableValue[] | null;\n childSlots?: SerializedEtNodeChildSlots | null;\n uid: number;\n options?: SerializedRuntimeOptions | null;\n}\n\nexport interface SerializedCompiledNode extends SerializedEtNodeBase {\n templateKey: string;\n bundleUrl?: string;\n attributeSlots?: SerializableValue[] | null;\n}\n\nexport interface SerializedTypedNode extends SerializedEtNodeBase {\n // Native __SerializeElementTemplate returns typed hosts as { tag, attributes }.\n tag: string;\n attributes?: TypedElementAttributesCommand | null;\n}\n\nexport interface SerializedTypedListNode extends Omit<SerializedEtNodeBase, 'options'> {\n tag: 'list';\n attributes?: TypedElementAttributesCommand | null;\n options?: SerializedTypedListOptions | null;\n}\n\nexport type SerializedEtNode = SerializedCompiledNode | SerializedTypedNode | SerializedTypedListNode;\n\nexport interface SerializedPageRoot extends SerializedTypedNode {\n tag: typeof ELEMENT_TEMPLATE_PAGE_TYPE;\n uid: typeof ELEMENT_TEMPLATE_PAGE_HANDLE_ID;\n}\n\nexport interface ElementTemplateHydrateCommitContext {\n page: SerializedPageRoot;\n reloadVersion: number;\n}\n\nexport type CreateTemplateCommand = [\n typeof ElementTemplateUpdateOps.createTemplate,\n handleId: number,\n templateKey: string,\n bundleUrl: string | null | undefined,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n];\n\nexport type SetAttributeCommand = [\n typeof ElementTemplateUpdateOps.setAttribute,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadEventCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadEvent,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadRefCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadRef,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type InsertNodeCommand = [\n typeof ElementTemplateUpdateOps.insertNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n referenceHandleId: number,\n attachedSubtreeHandleIds: number[] | null,\n];\n\nexport type RemoveNodeCommand = [\n typeof ElementTemplateUpdateOps.removeNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n removedSubtreeHandleIds: number[],\n];\n\nexport type CreateTypedElementCommand = [\n typeof ElementTemplateUpdateOps.createTypedElement,\n handleId: number,\n type: string,\n attributes: TypedElementAttributesCommand | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n options: RuntimeOptionsCommand | TypedListOptionsCommand | null | undefined,\n];\n\nexport type InsertTypedListItemCommand = [\n typeof ElementTemplateUpdateOps.insertTypedListItem,\n listHandleId: number,\n item: UpdateTypedListItemCommand,\n beforeHandleId: number,\n];\n\nexport type RemoveTypedListItemCommand = [\n typeof ElementTemplateUpdateOps.removeTypedListItem,\n listHandleId: number,\n itemHandleId: number,\n removedSubtreeHandleIds: number[],\n];\n\nexport type UpdateTypedListItemInfoCommand = [\n typeof ElementTemplateUpdateOps.updateTypedListItem,\n listHandleId: number,\n item: UpdateTypedListItemCommand,\n];\n\nexport type ElementTemplateUpdateCommand =\n | CreateTemplateCommand\n | SetAttributeCommand\n | SetMainThreadEventCommand\n | SetMainThreadRefCommand\n | InsertNodeCommand\n | RemoveNodeCommand\n | CreateTypedElementCommand\n | InsertTypedListItemCommand\n | RemoveTypedListItemCommand\n | UpdateTypedListItemInfoCommand;\n\n// Commands are transported as a flat stream to match the native update payload.\n// Tuple aliases above define each opcode's shape; this item union preserves the\n// existing flat buffer ergonomics while making command contracts explicit.\nexport type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];\n\nexport interface ElementTemplateFlushOptions {\n pipelineOptions?: PipelineOptions;\n triggerDataUpdated?: boolean;\n emptyPatch?: boolean;\n}\n\nexport interface ElementTemplateUpdateCommitContext {\n ops: ElementTemplateUpdateCommandStream;\n flushOptions: ElementTemplateFlushOptions;\n flowIds?: number[] | undefined;\n isHydration?: boolean | undefined;\n reloadVersion?: number | undefined;\n delayedRunOnMainThreadData?: RunWorkletCtxData[] | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-instance.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/page/root-instance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AACH,IAAI,
|
|
1
|
+
{"version":3,"file":"root-instance.js","sourceRoot":"","sources":["../../../../src/element-template/runtime/page/root-instance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D;;GAEG;AACH,IAAI,MAGH,CAAC;AAEF,SAAS,OAAO,CAAC,IAAmB;IAClC,MAAM,GAAG,IAAI,CAAC;IAEd,kDAAkD;IAClD,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACtB,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,CAAC;AAEZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Element Template-only root for renderPage.\n */\nlet __root: {\n __jsx?: React.ReactNode;\n nodeType?: Element['nodeType'];\n};\n\nfunction setRoot(root: typeof __root): void {\n __root = root;\n\n // A fake ELEMENT_NODE to make preact/debug happy.\n if (__DEV__ && __root) {\n __root.nodeType = 1;\n }\n}\n\nsetRoot({});\n\nexport { __root, setRoot };\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { composeElementTemplateListAttributes, createElementTemplateListStateFromItems, flushInitialElementTemplateListUpdates, flushPendingElementTemplateListUpdates, insertElementTemplateListItem, markElementTemplateListDestroyed, registerElementTemplateListState, removeElementTemplateListItem, updateElementTemplateListAttributes, updateElementTemplateListItem, } from './list/list.js';
|
|
5
5
|
import { insertElementTemplateSubtree } from './template/handle.js';
|
|
6
|
+
import { retainMainThreadBackgroundFunctionCtx } from './template/main-thread-background-function.js';
|
|
6
7
|
import { elementTemplateRegistry } from './template/registry.js';
|
|
7
8
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from './template/typed-attributes.js';
|
|
8
9
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
@@ -68,6 +69,9 @@ export function applyElementTemplateUpdateCommands(stream, isHydration = false)
|
|
|
68
69
|
if (!nativeRef) {
|
|
69
70
|
continue;
|
|
70
71
|
}
|
|
72
|
+
if (value != null) {
|
|
73
|
+
retainMainThreadBackgroundFunctionCtx(value.value);
|
|
74
|
+
}
|
|
71
75
|
__SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);
|
|
72
76
|
updateMainThreadEventAttrSlot(targetId, attrSlotIndex, value, isHydration);
|
|
73
77
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/element-template/runtime/patch.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA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MAAM,WAAW,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,cAAc,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;IACzG,CAAC;IACD,IAAI,UAAU,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n composeElementTemplateListAttributes,\n createElementTemplateListStateFromItems,\n flushInitialElementTemplateListUpdates,\n flushPendingElementTemplateListUpdates,\n insertElementTemplateListItem,\n markElementTemplateListDestroyed,\n registerElementTemplateListState,\n removeElementTemplateListItem,\n updateElementTemplateListAttributes,\n updateElementTemplateListItem,\n} from './list/list.js';\nimport type { ETListFlushResult, ETListUpdateItem } from './list/list.js';\nimport { insertElementTemplateSubtree } from './template/handle.js';\nimport { elementTemplateRegistry } from './template/registry.js';\nimport { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from './template/typed-attributes.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateOp } from '../protocol/opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID } from '../protocol/page.js';\nimport {\n elementTemplateIdentityKey,\n elementTemplateTypeTag,\n parseElementTemplateType,\n} from '../protocol/template-type.js';\nimport type {\n ElementTemplateHandleSlotsCommand,\n ElementTemplateUpdateCommandStream,\n RuntimeChildSlots,\n RuntimeOptions,\n RuntimeOptionsCommand,\n RuntimeTypedElementAttributes,\n RuntimeTypedListOptions,\n SerializableValue,\n TypedElementAttributesCommand,\n UpdateTypedListItemCommand,\n} from '../protocol/types.js';\nimport {\n deleteMainThreadDynamicAttrStateForSubtree,\n initializeMainThreadDynamicAttrSlots,\n prepareMainThreadDynamicAttrSlotsForNative,\n updateMainThreadEventAttrSlot,\n updateMainThreadRefAttrSlot,\n} from './template/main-thread-dynamic-attr-state.js';\nimport type { MainThreadDynamicAttrSubtreeHandle } from './template/main-thread-dynamic-attr-state.js';\n\nexport type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';\n\n// The update event's JSON transport already normalizes array holes and undefined\n// entries to null. Consume those wire values without copying each attr array.\nexport function applyElementTemplateUpdateCommands(\n stream: ElementTemplateUpdateCommandStream,\n isHydration = false,\n): void {\n let i = 0;\n while (i < stream.length) {\n const op = stream[i++] as ElementTemplateUpdateOp;\n\n switch (op) {\n case ElementTemplateUpdateOps.createTemplate: {\n const handleId = stream[i++] as number;\n const templateKey = stream[i++] as string;\n const bundleUrl = stream[i++] as string | null | undefined;\n const attributeSlots = stream[i++] as SerializableValue[] | null | undefined;\n const childSlots = stream[i++] as ElementTemplateHandleSlotsCommand | null | undefined;\n\n if (__DEV__) {\n const createError = validateCreateTemplatePayload(\n handleId,\n attributeSlots,\n childSlots,\n );\n if (createError) {\n lynx.reportError(createError);\n continue;\n }\n }\n\n const resolvedChildSlots = resolveChildSlots(childSlots);\n if (resolvedChildSlots === undefined) {\n continue;\n }\n\n const templateType = elementTemplateTypeTag(templateKey, bundleUrl);\n const nativeAttributeSlots = prepareMainThreadDynamicAttrSlotsForNative(\n templateType,\n attributeSlots,\n );\n const nativeRef = __CreateElementTemplate(\n templateKey,\n bundleUrl,\n nativeAttributeSlots,\n resolvedChildSlots,\n handleId,\n );\n\n if (nativeRef) {\n elementTemplateRegistry.set(handleId, nativeRef);\n initializeMainThreadDynamicAttrSlots(\n handleId,\n templateType,\n attributeSlots,\n );\n }\n break;\n }\n\n case ElementTemplateUpdateOps.setAttribute: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n if (attrSlotIndex === TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX) {\n const listAttributes = updateElementTemplateListAttributes(\n targetId,\n value as RuntimeTypedElementAttributes | null,\n );\n if (listAttributes) {\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, listAttributes);\n break;\n }\n }\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);\n break;\n }\n\n case ElementTemplateUpdateOps.setMainThreadEvent: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);\n updateMainThreadEventAttrSlot(targetId, attrSlotIndex, value, isHydration);\n break;\n }\n\n case ElementTemplateUpdateOps.setMainThreadRef: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n updateMainThreadRefAttrSlot(targetId, attrSlotIndex, value, nativeRef, isHydration);\n break;\n }\n\n case ElementTemplateUpdateOps.createTypedElement: {\n const handleId = stream[i++] as number;\n const type = stream[i++] as string;\n const attributes = stream[i++] as TypedElementAttributesCommand | null | undefined;\n const childSlots = stream[i++] as ElementTemplateHandleSlotsCommand | null | undefined;\n const options = stream[i++] as RuntimeOptionsCommand | null | undefined;\n const isTypedList = type === 'list';\n\n if (__DEV__) {\n const createError = validateCreateHandleId(handleId);\n if (createError) {\n lynx.reportError(createError);\n continue;\n }\n }\n if (__DEV__ && childSlots != null && !Array.isArray(childSlots)) {\n lynx.reportError(\n new Error('ElementTemplate update create childSlots must be an array, null, or undefined.'),\n );\n continue;\n }\n if (\n __DEV__\n && isTypedList\n && !isTypedListChildSlotsEmpty(childSlots)\n ) {\n lynx.reportError(\n new Error('ElementTemplate typed list create must keep logical children in options.listChildren.'),\n );\n continue;\n }\n const resolvedChildSlots = isTypedList ? null : resolveChildSlots(childSlots);\n if (resolvedChildSlots === undefined) {\n continue;\n }\n let resolvedListItems: ETListUpdateItem[] | null = null;\n let nativeOptions: RuntimeOptions | RuntimeTypedListOptions | null | undefined;\n if (isTypedList) {\n const listChildren = getTypedListChildren(options);\n if (__DEV__ && !Array.isArray(listChildren)) {\n lynx.reportError(\n new Error('ElementTemplate typed list create must keep logical children in options.listChildren.'),\n );\n continue;\n }\n resolvedListItems = resolveTypedListItems(listChildren);\n if (resolvedListItems === null) {\n continue;\n }\n nativeOptions = resolveTypedListOptions(options, resolvedListItems);\n } else {\n nativeOptions = options as RuntimeOptions | null | undefined;\n }\n const listState = resolvedListItems\n ? createElementTemplateListStateFromItems(\n resolvedListItems,\n attributes,\n )\n : null;\n const typedAttributes = listState\n ? composeElementTemplateListAttributes(\n undefined,\n listState,\n )\n : attributes;\n\n const nativeRef = __CreateTypedElementTemplate(\n type,\n typedAttributes,\n isTypedList ? null : resolvedChildSlots!,\n handleId,\n nativeOptions,\n );\n\n if (nativeRef) {\n elementTemplateRegistry.set(handleId, nativeRef);\n if (listState) {\n registerElementTemplateListState(handleId, listState, true, nativeRef);\n }\n }\n break;\n }\n\n case ElementTemplateUpdateOps.insertTypedListItem: {\n const listId = stream[i++] as number;\n const item = stream[i++] as UpdateTypedListItemCommand;\n const beforeId = stream[i++] as number;\n const resolvedItem = resolveTypedListItem(item, 'typed list insert item');\n if (resolvedItem === null) {\n continue;\n }\n insertElementTemplateListItem(listId, resolvedItem, beforeId);\n break;\n }\n\n case ElementTemplateUpdateOps.removeTypedListItem: {\n const listId = stream[i++] as number;\n const itemId = stream[i++] as number;\n const removedSubtreeHandleIds = stream[i++] as number[];\n removeElementTemplateListItem(listId, itemId, removedSubtreeHandleIds);\n break;\n }\n\n case ElementTemplateUpdateOps.updateTypedListItem: {\n const listId = stream[i++] as number;\n const item = stream[i++] as UpdateTypedListItemCommand;\n const resolvedItem = resolveTypedListItem(item, 'typed list update item');\n if (resolvedItem === null) {\n continue;\n }\n updateElementTemplateListItem(listId, resolvedItem);\n break;\n }\n\n case ElementTemplateUpdateOps.insertNode: {\n const targetId = stream[i++] as number;\n const childSlotIndex = stream[i++] as number;\n const childId = stream[i++] as number;\n const referenceId = stream[i++] as number;\n const attachedSubtreeHandleIds = stream[i++] as number[] | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n const childRef = resolveTargetHandle(childId, 'child');\n const attachedSubtreeHandles = attachedSubtreeHandleIds === null\n ? null\n : resolveSubtreeHandles(attachedSubtreeHandleIds, 'insert subtree');\n if (\n !nativeRef\n || !childRef\n || (attachedSubtreeHandleIds !== null && attachedSubtreeHandles === null)\n ) {\n continue;\n }\n const referenceRef = referenceId === 0 ? null : resolveTargetHandle(referenceId, 'reference');\n if (referenceId !== 0 && !referenceRef) {\n continue;\n }\n insertElementTemplateSubtree(\n nativeRef,\n childSlotIndex,\n childRef,\n referenceRef,\n attachedSubtreeHandles,\n );\n break;\n }\n\n case ElementTemplateUpdateOps.removeNode: {\n const targetId = stream[i++] as number;\n const childSlotIndex = stream[i++] as number;\n const childId = stream[i++] as number;\n const removedSubtreeHandleIds = stream[i++] as number[];\n const nativeRef = resolveTargetHandle(targetId, 'target');\n const childRef = resolveTargetHandle(childId, 'child');\n if (!nativeRef || !childRef) {\n continue;\n }\n __RemoveNodeFromElementTemplate(nativeRef, childSlotIndex, childRef);\n releaseRemovedSubtreeHandles(removedSubtreeHandleIds);\n break;\n }\n\n default: {\n if (__DEV__) {\n lynx.reportError(new Error(`ElementTemplate update opcode ${String(op)} is not supported.`));\n }\n }\n }\n }\n flushPendingListUpdates();\n}\n\nfunction flushPendingListUpdates(): void {\n applyListFlushResults(flushPendingElementTemplateListUpdates());\n applyListFlushResults(flushInitialElementTemplateListUpdates());\n}\n\nfunction applyListFlushResults(results: ETListFlushResult[]): void {\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index]!;\n const listRef = resolveTargetHandle(result.uid, 'typed list');\n if (!listRef) {\n continue;\n }\n __SetAttributeOfElementTemplate(\n listRef,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n result.attributes,\n );\n if (result.removedSubtreeHandleIds) {\n releaseRemovedSubtreeHandles(result.removedSubtreeHandleIds);\n }\n }\n}\n\nfunction releaseRemovedSubtreeHandles(\n removedSubtreeHandleIds: number[],\n): void {\n for (const handleId of removedSubtreeHandleIds) {\n const pendingRemovedSubtreeHandleIds = markElementTemplateListDestroyed(handleId);\n elementTemplateRegistry.delete(handleId);\n deleteMainThreadDynamicAttrStateForSubtree([handleId]);\n if (pendingRemovedSubtreeHandleIds) {\n releaseRemovedSubtreeHandles(pendingRemovedSubtreeHandleIds);\n }\n }\n}\n\nfunction resolveChildSlots(\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n): RuntimeChildSlots | null | undefined {\n if (childSlots == null) {\n return null;\n }\n\n let hasError = false;\n const value: RuntimeChildSlots = [];\n for (let slotIndex = 0; slotIndex < childSlots.length; slotIndex += 1) {\n const children = childSlots[slotIndex];\n if (children == null) {\n continue;\n }\n if (__DEV__ && !Array.isArray(children)) {\n lynx.reportError(\n new Error(`ElementTemplate create slot ${slotIndex} must be an array of child handles, null, or undefined.`),\n );\n hasError = true;\n continue;\n }\n\n const resolvedChildren: ElementTemplateHandle[] = [];\n for (let childIndex = 0; childIndex < children.length; childIndex += 1) {\n const childId = children[childIndex]!;\n const childRef = resolveTargetHandle(childId, 'child');\n if (childRef === null) {\n hasError = true;\n continue;\n }\n resolvedChildren.push(childRef);\n }\n value[slotIndex] = resolvedChildren;\n }\n if (hasError) {\n return undefined;\n }\n return value;\n}\n\nfunction resolveTypedListOptions(\n options: RuntimeOptionsCommand | null | undefined,\n items: ETListUpdateItem[],\n): RuntimeTypedListOptions {\n return {\n ...options!,\n listChildren: items.map(item => item.ref),\n };\n}\n\nfunction getTypedListChildren(\n options: RuntimeOptionsCommand | null | undefined,\n): UpdateTypedListItemCommand[] {\n return (__DEV__ ? options?.['listChildren'] : options!['listChildren']!)! as UpdateTypedListItemCommand[];\n}\n\nfunction resolveTypedListItems(\n items: UpdateTypedListItemCommand[],\n): ETListUpdateItem[] | null {\n const resolvedItems: ETListUpdateItem[] = [];\n for (let index = 0; index < items.length; index += 1) {\n const resolvedItem = resolveTypedListItem(items[index]!, `typed list item ${index}`);\n if (resolvedItem === null) {\n return null;\n }\n resolvedItems.push(resolvedItem);\n }\n return resolvedItems;\n}\n\nfunction resolveTypedListItem(\n item: UpdateTypedListItemCommand,\n role: string,\n): ETListUpdateItem | null {\n const ref = resolveTargetHandle(item.__etHandleRef, role);\n if (ref === null) {\n return null;\n }\n // `item.type` is the full `${globDynamicComponentEntry}:${key}` tag; the\n // native list identifies items by the same identity key the templates were\n // registered under (see the `createTemplate` op above), so normalize it.\n const nativeTemplate = parseElementTemplateType(item.type);\n return {\n uid: item.__etHandleRef,\n ref,\n templateKey: elementTemplateIdentityKey(nativeTemplate.templateKey, nativeTemplate.bundleUrl),\n platformInfo: item.platformInfo,\n };\n}\n\nfunction resolveSubtreeHandles(\n subtreeHandleIds: readonly number[],\n role: string,\n): MainThreadDynamicAttrSubtreeHandle[] | null {\n const subtreeHandles: MainThreadDynamicAttrSubtreeHandle[] = [];\n for (let index = 0; index < subtreeHandleIds.length; index += 1) {\n const uid = subtreeHandleIds[index]!;\n const ref = resolveTargetHandle(uid, role);\n if (!ref) {\n return null;\n }\n subtreeHandles.push({ uid, ref });\n }\n return subtreeHandles;\n}\n\nfunction isTypedListChildSlotsEmpty(childSlots: ElementTemplateHandleSlotsCommand | null | undefined): boolean {\n if (!Array.isArray(childSlots)) {\n return true;\n }\n return childSlots.every(slot => slot == null || (Array.isArray(slot) && slot.length === 0));\n}\n\nfunction resolveTargetHandle(id: number, role: string): ElementTemplateHandle | null {\n const nativeRef = elementTemplateRegistry.getTarget(id);\n if (!nativeRef) {\n lynx.reportError(new Error(`ElementTemplate update ${role} handle ${id} not found.`));\n return null;\n }\n return nativeRef;\n}\n\nfunction isValidHandleId(handleId: number): boolean {\n return Number.isInteger(handleId) && handleId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID;\n}\n\nfunction validateCreateHandleId(handleId: number): Error | null {\n if (!isValidHandleId(handleId)) {\n return new Error(`ElementTemplate update has invalid handleId ${String(handleId)}.`);\n }\n if (elementTemplateRegistry.get(handleId)) {\n return new Error(`ElementTemplate update received duplicate handleId ${handleId}.`);\n }\n return null;\n}\n\nfunction validateCreateTemplatePayload(\n handleId: number,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n): Error | null {\n const handleError = validateCreateHandleId(handleId);\n if (handleError) {\n return handleError;\n }\n if (attributeSlots != null && !Array.isArray(attributeSlots)) {\n return new Error('ElementTemplate update create attributeSlots must be an array, null, or undefined.');\n }\n if (childSlots != null && !Array.isArray(childSlots)) {\n return new Error('ElementTemplate update create childSlots must be an array, null, or undefined.');\n }\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/element-template/runtime/patch.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,oCAAoC,EACpC,uCAAuC,EACvC,sCAAsC,EACtC,sCAAsC,EACtC,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,EAChC,6BAA6B,EAC7B,mCAAmC,EACnC,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AAEtG,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,C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,cAAc,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;IACzG,CAAC;IACD,IAAI,UAAU,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n composeElementTemplateListAttributes,\n createElementTemplateListStateFromItems,\n flushInitialElementTemplateListUpdates,\n flushPendingElementTemplateListUpdates,\n insertElementTemplateListItem,\n markElementTemplateListDestroyed,\n registerElementTemplateListState,\n removeElementTemplateListItem,\n updateElementTemplateListAttributes,\n updateElementTemplateListItem,\n} from './list/list.js';\nimport type { ETListFlushResult, ETListUpdateItem } from './list/list.js';\nimport { insertElementTemplateSubtree } from './template/handle.js';\nimport { retainMainThreadBackgroundFunctionCtx } from './template/main-thread-background-function.js';\nimport type { MTEventNativeWrapper } from './template/main-thread-event-ctx.js';\nimport { elementTemplateRegistry } from './template/registry.js';\nimport { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from './template/typed-attributes.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateOp } from '../protocol/opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID } from '../protocol/page.js';\nimport {\n elementTemplateIdentityKey,\n elementTemplateTypeTag,\n parseElementTemplateType,\n} from '../protocol/template-type.js';\nimport type {\n ElementTemplateHandleSlotsCommand,\n ElementTemplateUpdateCommandStream,\n RuntimeChildSlots,\n RuntimeOptions,\n RuntimeOptionsCommand,\n RuntimeTypedElementAttributes,\n RuntimeTypedListOptions,\n SerializableValue,\n TypedElementAttributesCommand,\n UpdateTypedListItemCommand,\n} from '../protocol/types.js';\nimport {\n deleteMainThreadDynamicAttrStateForSubtree,\n initializeMainThreadDynamicAttrSlots,\n prepareMainThreadDynamicAttrSlotsForNative,\n updateMainThreadEventAttrSlot,\n updateMainThreadRefAttrSlot,\n} from './template/main-thread-dynamic-attr-state.js';\nimport type { MainThreadDynamicAttrSubtreeHandle } from './template/main-thread-dynamic-attr-state.js';\n\nexport type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';\n\n// The update event's JSON transport already normalizes array holes and undefined\n// entries to null. Consume those wire values without copying each attr array.\nexport function applyElementTemplateUpdateCommands(\n stream: ElementTemplateUpdateCommandStream,\n isHydration = false,\n): void {\n let i = 0;\n while (i < stream.length) {\n const op = stream[i++] as ElementTemplateUpdateOp;\n\n switch (op) {\n case ElementTemplateUpdateOps.createTemplate: {\n const handleId = stream[i++] as number;\n const templateKey = stream[i++] as string;\n const bundleUrl = stream[i++] as string | null | undefined;\n const attributeSlots = stream[i++] as SerializableValue[] | null | undefined;\n const childSlots = stream[i++] as ElementTemplateHandleSlotsCommand | null | undefined;\n\n if (__DEV__) {\n const createError = validateCreateTemplatePayload(\n handleId,\n attributeSlots,\n childSlots,\n );\n if (createError) {\n lynx.reportError(createError);\n continue;\n }\n }\n\n const resolvedChildSlots = resolveChildSlots(childSlots);\n if (resolvedChildSlots === undefined) {\n continue;\n }\n\n const templateType = elementTemplateTypeTag(templateKey, bundleUrl);\n const nativeAttributeSlots = prepareMainThreadDynamicAttrSlotsForNative(\n templateType,\n attributeSlots,\n );\n const nativeRef = __CreateElementTemplate(\n templateKey,\n bundleUrl,\n nativeAttributeSlots,\n resolvedChildSlots,\n handleId,\n );\n\n if (nativeRef) {\n elementTemplateRegistry.set(handleId, nativeRef);\n initializeMainThreadDynamicAttrSlots(\n handleId,\n templateType,\n attributeSlots,\n );\n }\n break;\n }\n\n case ElementTemplateUpdateOps.setAttribute: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n if (attrSlotIndex === TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX) {\n const listAttributes = updateElementTemplateListAttributes(\n targetId,\n value as RuntimeTypedElementAttributes | null,\n );\n if (listAttributes) {\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, listAttributes);\n break;\n }\n }\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);\n break;\n }\n\n case ElementTemplateUpdateOps.setMainThreadEvent: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n if (value != null) {\n retainMainThreadBackgroundFunctionCtx((value as unknown as MTEventNativeWrapper).value);\n }\n __SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);\n updateMainThreadEventAttrSlot(targetId, attrSlotIndex, value, isHydration);\n break;\n }\n\n case ElementTemplateUpdateOps.setMainThreadRef: {\n const targetId = stream[i++] as number;\n const attrSlotIndex = stream[i++] as number;\n const value = stream[i++] as SerializableValue | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n if (!nativeRef) {\n continue;\n }\n updateMainThreadRefAttrSlot(targetId, attrSlotIndex, value, nativeRef, isHydration);\n break;\n }\n\n case ElementTemplateUpdateOps.createTypedElement: {\n const handleId = stream[i++] as number;\n const type = stream[i++] as string;\n const attributes = stream[i++] as TypedElementAttributesCommand | null | undefined;\n const childSlots = stream[i++] as ElementTemplateHandleSlotsCommand | null | undefined;\n const options = stream[i++] as RuntimeOptionsCommand | null | undefined;\n const isTypedList = type === 'list';\n\n if (__DEV__) {\n const createError = validateCreateHandleId(handleId);\n if (createError) {\n lynx.reportError(createError);\n continue;\n }\n }\n if (__DEV__ && childSlots != null && !Array.isArray(childSlots)) {\n lynx.reportError(\n new Error('ElementTemplate update create childSlots must be an array, null, or undefined.'),\n );\n continue;\n }\n if (\n __DEV__\n && isTypedList\n && !isTypedListChildSlotsEmpty(childSlots)\n ) {\n lynx.reportError(\n new Error('ElementTemplate typed list create must keep logical children in options.listChildren.'),\n );\n continue;\n }\n const resolvedChildSlots = isTypedList ? null : resolveChildSlots(childSlots);\n if (resolvedChildSlots === undefined) {\n continue;\n }\n let resolvedListItems: ETListUpdateItem[] | null = null;\n let nativeOptions: RuntimeOptions | RuntimeTypedListOptions | null | undefined;\n if (isTypedList) {\n const listChildren = getTypedListChildren(options);\n if (__DEV__ && !Array.isArray(listChildren)) {\n lynx.reportError(\n new Error('ElementTemplate typed list create must keep logical children in options.listChildren.'),\n );\n continue;\n }\n resolvedListItems = resolveTypedListItems(listChildren);\n if (resolvedListItems === null) {\n continue;\n }\n nativeOptions = resolveTypedListOptions(options, resolvedListItems);\n } else {\n nativeOptions = options as RuntimeOptions | null | undefined;\n }\n const listState = resolvedListItems\n ? createElementTemplateListStateFromItems(\n resolvedListItems,\n attributes,\n )\n : null;\n const typedAttributes = listState\n ? composeElementTemplateListAttributes(\n undefined,\n listState,\n )\n : attributes;\n\n const nativeRef = __CreateTypedElementTemplate(\n type,\n typedAttributes,\n isTypedList ? null : resolvedChildSlots!,\n handleId,\n nativeOptions,\n );\n\n if (nativeRef) {\n elementTemplateRegistry.set(handleId, nativeRef);\n if (listState) {\n registerElementTemplateListState(handleId, listState, true, nativeRef);\n }\n }\n break;\n }\n\n case ElementTemplateUpdateOps.insertTypedListItem: {\n const listId = stream[i++] as number;\n const item = stream[i++] as UpdateTypedListItemCommand;\n const beforeId = stream[i++] as number;\n const resolvedItem = resolveTypedListItem(item, 'typed list insert item');\n if (resolvedItem === null) {\n continue;\n }\n insertElementTemplateListItem(listId, resolvedItem, beforeId);\n break;\n }\n\n case ElementTemplateUpdateOps.removeTypedListItem: {\n const listId = stream[i++] as number;\n const itemId = stream[i++] as number;\n const removedSubtreeHandleIds = stream[i++] as number[];\n removeElementTemplateListItem(listId, itemId, removedSubtreeHandleIds);\n break;\n }\n\n case ElementTemplateUpdateOps.updateTypedListItem: {\n const listId = stream[i++] as number;\n const item = stream[i++] as UpdateTypedListItemCommand;\n const resolvedItem = resolveTypedListItem(item, 'typed list update item');\n if (resolvedItem === null) {\n continue;\n }\n updateElementTemplateListItem(listId, resolvedItem);\n break;\n }\n\n case ElementTemplateUpdateOps.insertNode: {\n const targetId = stream[i++] as number;\n const childSlotIndex = stream[i++] as number;\n const childId = stream[i++] as number;\n const referenceId = stream[i++] as number;\n const attachedSubtreeHandleIds = stream[i++] as number[] | null;\n const nativeRef = resolveTargetHandle(targetId, 'target');\n const childRef = resolveTargetHandle(childId, 'child');\n const attachedSubtreeHandles = attachedSubtreeHandleIds === null\n ? null\n : resolveSubtreeHandles(attachedSubtreeHandleIds, 'insert subtree');\n if (\n !nativeRef\n || !childRef\n || (attachedSubtreeHandleIds !== null && attachedSubtreeHandles === null)\n ) {\n continue;\n }\n const referenceRef = referenceId === 0 ? null : resolveTargetHandle(referenceId, 'reference');\n if (referenceId !== 0 && !referenceRef) {\n continue;\n }\n insertElementTemplateSubtree(\n nativeRef,\n childSlotIndex,\n childRef,\n referenceRef,\n attachedSubtreeHandles,\n );\n break;\n }\n\n case ElementTemplateUpdateOps.removeNode: {\n const targetId = stream[i++] as number;\n const childSlotIndex = stream[i++] as number;\n const childId = stream[i++] as number;\n const removedSubtreeHandleIds = stream[i++] as number[];\n const nativeRef = resolveTargetHandle(targetId, 'target');\n const childRef = resolveTargetHandle(childId, 'child');\n if (!nativeRef || !childRef) {\n continue;\n }\n __RemoveNodeFromElementTemplate(nativeRef, childSlotIndex, childRef);\n releaseRemovedSubtreeHandles(removedSubtreeHandleIds);\n break;\n }\n\n default: {\n if (__DEV__) {\n lynx.reportError(new Error(`ElementTemplate update opcode ${String(op)} is not supported.`));\n }\n }\n }\n }\n flushPendingListUpdates();\n}\n\nfunction flushPendingListUpdates(): void {\n applyListFlushResults(flushPendingElementTemplateListUpdates());\n applyListFlushResults(flushInitialElementTemplateListUpdates());\n}\n\nfunction applyListFlushResults(results: ETListFlushResult[]): void {\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index]!;\n const listRef = resolveTargetHandle(result.uid, 'typed list');\n if (!listRef) {\n continue;\n }\n __SetAttributeOfElementTemplate(\n listRef,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n result.attributes,\n );\n if (result.removedSubtreeHandleIds) {\n releaseRemovedSubtreeHandles(result.removedSubtreeHandleIds);\n }\n }\n}\n\nfunction releaseRemovedSubtreeHandles(\n removedSubtreeHandleIds: number[],\n): void {\n for (const handleId of removedSubtreeHandleIds) {\n const pendingRemovedSubtreeHandleIds = markElementTemplateListDestroyed(handleId);\n elementTemplateRegistry.delete(handleId);\n deleteMainThreadDynamicAttrStateForSubtree([handleId]);\n if (pendingRemovedSubtreeHandleIds) {\n releaseRemovedSubtreeHandles(pendingRemovedSubtreeHandleIds);\n }\n }\n}\n\nfunction resolveChildSlots(\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n): RuntimeChildSlots | null | undefined {\n if (childSlots == null) {\n return null;\n }\n\n let hasError = false;\n const value: RuntimeChildSlots = [];\n for (let slotIndex = 0; slotIndex < childSlots.length; slotIndex += 1) {\n const children = childSlots[slotIndex];\n if (children == null) {\n continue;\n }\n if (__DEV__ && !Array.isArray(children)) {\n lynx.reportError(\n new Error(`ElementTemplate create slot ${slotIndex} must be an array of child handles, null, or undefined.`),\n );\n hasError = true;\n continue;\n }\n\n const resolvedChildren: ElementTemplateHandle[] = [];\n for (let childIndex = 0; childIndex < children.length; childIndex += 1) {\n const childId = children[childIndex]!;\n const childRef = resolveTargetHandle(childId, 'child');\n if (childRef === null) {\n hasError = true;\n continue;\n }\n resolvedChildren.push(childRef);\n }\n value[slotIndex] = resolvedChildren;\n }\n if (hasError) {\n return undefined;\n }\n return value;\n}\n\nfunction resolveTypedListOptions(\n options: RuntimeOptionsCommand | null | undefined,\n items: ETListUpdateItem[],\n): RuntimeTypedListOptions {\n return {\n ...options!,\n listChildren: items.map(item => item.ref),\n };\n}\n\nfunction getTypedListChildren(\n options: RuntimeOptionsCommand | null | undefined,\n): UpdateTypedListItemCommand[] {\n return (__DEV__ ? options?.['listChildren'] : options!['listChildren']!)! as UpdateTypedListItemCommand[];\n}\n\nfunction resolveTypedListItems(\n items: UpdateTypedListItemCommand[],\n): ETListUpdateItem[] | null {\n const resolvedItems: ETListUpdateItem[] = [];\n for (let index = 0; index < items.length; index += 1) {\n const resolvedItem = resolveTypedListItem(items[index]!, `typed list item ${index}`);\n if (resolvedItem === null) {\n return null;\n }\n resolvedItems.push(resolvedItem);\n }\n return resolvedItems;\n}\n\nfunction resolveTypedListItem(\n item: UpdateTypedListItemCommand,\n role: string,\n): ETListUpdateItem | null {\n const ref = resolveTargetHandle(item.__etHandleRef, role);\n if (ref === null) {\n return null;\n }\n // `item.type` is the full `${globDynamicComponentEntry}:${key}` tag; the\n // native list identifies items by the same identity key the templates were\n // registered under (see the `createTemplate` op above), so normalize it.\n const nativeTemplate = parseElementTemplateType(item.type);\n return {\n uid: item.__etHandleRef,\n ref,\n templateKey: elementTemplateIdentityKey(nativeTemplate.templateKey, nativeTemplate.bundleUrl),\n platformInfo: item.platformInfo,\n };\n}\n\nfunction resolveSubtreeHandles(\n subtreeHandleIds: readonly number[],\n role: string,\n): MainThreadDynamicAttrSubtreeHandle[] | null {\n const subtreeHandles: MainThreadDynamicAttrSubtreeHandle[] = [];\n for (let index = 0; index < subtreeHandleIds.length; index += 1) {\n const uid = subtreeHandleIds[index]!;\n const ref = resolveTargetHandle(uid, role);\n if (!ref) {\n return null;\n }\n subtreeHandles.push({ uid, ref });\n }\n return subtreeHandles;\n}\n\nfunction isTypedListChildSlotsEmpty(childSlots: ElementTemplateHandleSlotsCommand | null | undefined): boolean {\n if (!Array.isArray(childSlots)) {\n return true;\n }\n return childSlots.every(slot => slot == null || (Array.isArray(slot) && slot.length === 0));\n}\n\nfunction resolveTargetHandle(id: number, role: string): ElementTemplateHandle | null {\n const nativeRef = elementTemplateRegistry.getTarget(id);\n if (!nativeRef) {\n lynx.reportError(new Error(`ElementTemplate update ${role} handle ${id} not found.`));\n return null;\n }\n return nativeRef;\n}\n\nfunction isValidHandleId(handleId: number): boolean {\n return Number.isInteger(handleId) && handleId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID;\n}\n\nfunction validateCreateHandleId(handleId: number): Error | null {\n if (!isValidHandleId(handleId)) {\n return new Error(`ElementTemplate update has invalid handleId ${String(handleId)}.`);\n }\n if (elementTemplateRegistry.get(handleId)) {\n return new Error(`ElementTemplate update received duplicate handleId ${handleId}.`);\n }\n return null;\n}\n\nfunction validateCreateTemplatePayload(\n handleId: number,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n): Error | null {\n const handleError = validateCreateHandleId(handleId);\n if (handleError) {\n return handleError;\n }\n if (attributeSlots != null && !Array.isArray(attributeSlots)) {\n return new Error('ElementTemplate update create attributeSlots must be an array, null, or undefined.');\n }\n if (childSlots != null && !Array.isArray(childSlots)) {\n return new Error('ElementTemplate update create childSlots must be an array, null, or undefined.');\n }\n return null;\n}\n"]}
|