@lynx-js/react 0.120.0 → 0.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/package.json +35 -7
- package/runtime/lazy/compat.js +1 -0
- package/runtime/lazy/react.js +1 -0
- package/runtime/lib/core/hooks/mainThread.d.ts +1 -0
- package/runtime/lib/core/hooks/mainThread.js +7 -0
- package/runtime/lib/core/hooks/mainThread.js.map +1 -0
- package/runtime/lib/{snapshot/hooks/mainThread.d.ts → core/hooks/mainThreadImpl.d.ts} +2 -1
- package/runtime/lib/{snapshot/hooks/mainThread.js → core/hooks/mainThreadImpl.js} +45 -34
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -0
- package/runtime/lib/{snapshot → core}/hooks/react.js +1 -1
- package/runtime/lib/core/hooks/react.js.map +1 -0
- package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.d.ts +1 -1
- package/runtime/lib/{snapshot → core}/hooks/useLynxGlobalEventListener.js +1 -1
- package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/element-template/background/attr-slots.d.ts +2 -0
- package/runtime/lib/element-template/background/attr-slots.js +34 -0
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -0
- package/runtime/lib/element-template/background/commit-context.d.ts +13 -0
- package/runtime/lib/element-template/background/commit-context.js +25 -0
- package/runtime/lib/element-template/background/commit-context.js.map +1 -0
- package/runtime/lib/element-template/background/commit-hook.d.ts +7 -0
- package/runtime/lib/element-template/background/commit-hook.js +96 -0
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -0
- package/runtime/lib/element-template/background/destroy.d.ts +1 -0
- package/runtime/lib/element-template/background/destroy.js +17 -0
- package/runtime/lib/element-template/background/destroy.js.map +1 -0
- package/runtime/lib/element-template/background/document.d.ts +7 -0
- package/runtime/lib/element-template/background/document.js +27 -0
- package/runtime/lib/element-template/background/document.js.map +1 -0
- package/runtime/lib/element-template/background/hydrate.d.ts +4 -0
- package/runtime/lib/element-template/background/hydrate.js +219 -0
- package/runtime/lib/element-template/background/hydrate.js.map +1 -0
- package/runtime/lib/element-template/background/hydration-listener.d.ts +2 -0
- package/runtime/lib/element-template/background/hydration-listener.js +93 -0
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -0
- package/runtime/lib/element-template/background/instance.d.ts +39 -0
- package/runtime/lib/element-template/background/instance.js +349 -0
- package/runtime/lib/element-template/background/instance.js.map +1 -0
- package/runtime/lib/element-template/background/manager.d.ts +10 -0
- package/runtime/lib/element-template/background/manager.js +60 -0
- package/runtime/lib/element-template/background/manager.js.map +1 -0
- package/runtime/lib/element-template/client/root.d.ts +36 -0
- package/runtime/lib/element-template/client/root.js +33 -0
- package/runtime/lib/element-template/client/root.js.map +1 -0
- package/runtime/lib/element-template/debug/alog.d.ts +34 -0
- package/runtime/lib/element-template/debug/alog.js +93 -0
- package/runtime/lib/element-template/debug/alog.js.map +1 -0
- package/runtime/lib/element-template/debug/elementPAPICall.d.ts +1 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js +75 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -0
- package/runtime/lib/element-template/debug/profile.d.ts +3 -0
- package/runtime/lib/element-template/debug/profile.js +141 -0
- package/runtime/lib/element-template/debug/profile.js.map +1 -0
- package/runtime/lib/element-template/hooks/react.d.ts +14 -0
- package/runtime/lib/element-template/hooks/react.js +24 -0
- package/runtime/lib/element-template/hooks/react.js.map +1 -0
- package/runtime/lib/element-template/index.d.ts +7 -0
- package/runtime/lib/element-template/index.js +45 -0
- package/runtime/lib/element-template/index.js.map +1 -0
- package/runtime/lib/element-template/internal.d.ts +6 -0
- package/runtime/lib/element-template/internal.js +44 -0
- package/runtime/lib/element-template/internal.js.map +1 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.d.ts +1 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.js +5 -0
- package/runtime/lib/element-template/jsx-dev-runtime/index.js.map +1 -0
- package/runtime/lib/element-template/jsx-runtime/index.d.ts +19 -0
- package/runtime/lib/element-template/jsx-runtime/index.js +60 -0
- package/runtime/lib/element-template/jsx-runtime/index.js.map +1 -0
- package/runtime/lib/element-template/lynx/env.d.ts +1 -0
- package/runtime/lib/element-template/lynx/env.js +89 -0
- package/runtime/lib/element-template/lynx/env.js.map +1 -0
- package/runtime/lib/element-template/lynx/performance.d.ts +23 -0
- package/runtime/lib/element-template/lynx/performance.js +135 -0
- package/runtime/lib/element-template/lynx/performance.js.map +1 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.d.ts +1 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +8 -0
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -0
- package/runtime/lib/element-template/native/index.d.ts +1 -0
- package/runtime/lib/element-template/native/index.js +53 -0
- package/runtime/lib/element-template/native/index.js.map +1 -0
- package/runtime/lib/element-template/native/main-thread-api.d.ts +2 -0
- package/runtime/lib/element-template/native/main-thread-api.js +27 -0
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -0
- package/runtime/lib/element-template/native/mts-destroy.d.ts +3 -0
- package/runtime/lib/element-template/native/mts-destroy.js +37 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -0
- package/runtime/lib/element-template/native/patch-listener.d.ts +2 -0
- package/runtime/lib/element-template/native/patch-listener.js +66 -0
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/event-value.d.ts +1 -0
- package/runtime/lib/element-template/prop-adapters/event-value.js +7 -0
- package/runtime/lib/element-template/prop-adapters/event-value.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/event.d.ts +7 -0
- package/runtime/lib/element-template/prop-adapters/event.js +61 -0
- package/runtime/lib/element-template/prop-adapters/event.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +5 -0
- package/runtime/lib/element-template/prop-adapters/spread.js +45 -0
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +4 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js +9 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -0
- package/runtime/lib/element-template/protocol/opcodes.d.ts +7 -0
- package/runtime/lib/element-template/protocol/opcodes.js +10 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +50 -0
- package/runtime/lib/element-template/protocol/types.js +5 -0
- package/runtime/lib/element-template/protocol/types.js.map +1 -0
- package/runtime/lib/element-template/runtime/components/slot.d.ts +1 -0
- package/runtime/lib/element-template/runtime/components/slot.js +11 -0
- package/runtime/lib/element-template/runtime/components/slot.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/page.d.ts +2 -0
- package/runtime/lib/element-template/runtime/page/page.js +8 -0
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +10 -0
- package/runtime/lib/element-template/runtime/page/root-instance.js +17 -0
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -0
- package/runtime/lib/element-template/runtime/patch.d.ts +3 -0
- package/runtime/lib/element-template/runtime/patch.js +145 -0
- package/runtime/lib/element-template/runtime/patch.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +2 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +53 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +4 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +134 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +14 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +272 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +11 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +23 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -0
- package/runtime/lib/element-template/runtime/template/handle.js +23 -0
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/registry.d.ts +13 -0
- package/runtime/lib/element-template/runtime/template/registry.js +46 -0
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -0
- package/runtime/lib/index.d.ts +5 -3
- package/runtime/lib/index.js +7 -4
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +2 -3
- package/runtime/lib/internal.js +3 -4
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +1 -1
- package/runtime/lib/lynx-api.js +3 -3
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.d.ts +1 -1
- package/runtime/lib/lynx.js +3 -3
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/{snapshot/debug → shared}/component-stack.js +1 -1
- package/runtime/lib/shared/component-stack.js.map +1 -0
- package/runtime/lib/{snapshot/debug → shared}/profile.js +6 -4
- package/runtime/lib/shared/profile.js.map +1 -0
- package/runtime/lib/{snapshot/renderToOpcodes/constants.js → shared/render-constants.js} +1 -1
- package/runtime/lib/shared/render-constants.js.map +1 -0
- package/runtime/lib/snapshot/alog/elementPAPICall.js +1 -1
- package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -1
- package/runtime/lib/snapshot/alog/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/compat/initData.d.ts +2 -2
- package/runtime/lib/snapshot/compat/initData.js +1 -1
- package/runtime/lib/snapshot/compat/initData.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js +1 -1
- package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -1
- package/runtime/lib/snapshot/gesture/processGesture.d.ts +2 -0
- package/runtime/lib/snapshot/gesture/processGesture.js +16 -1
- package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -1
- package/runtime/lib/snapshot/legacy-react-runtime/index.d.ts +2 -2
- package/runtime/lib/snapshot/legacy-react-runtime/index.js +2 -2
- package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/jsReady.js +1 -1
- package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +2 -2
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.d.ts +15 -0
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js +102 -0
- package/runtime/lib/snapshot/lifecycle/patch/nodesRefApply.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +2 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +17 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +26 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +1 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +5 -3
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js +1 -1
- package/runtime/lib/snapshot/lifecycle/render.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +4 -1
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/component.js +1 -1
- package/runtime/lib/snapshot/lynx/component.js.map +1 -1
- package/runtime/lib/snapshot/lynx/element.d.ts +6 -0
- package/runtime/lib/snapshot/lynx/element.js +35 -0
- package/runtime/lib/snapshot/lynx/element.js.map +1 -0
- package/runtime/lib/snapshot/lynx/env.js +1 -1
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/nodesRef.d.ts +6 -0
- package/runtime/lib/snapshot/lynx/nodesRef.js +31 -0
- package/runtime/lib/snapshot/lynx/nodesRef.js.map +1 -0
- package/runtime/lib/snapshot/lynx/performance.js +1 -1
- package/runtime/lib/snapshot/lynx/performance.js.map +1 -1
- package/runtime/lib/snapshot/lynx/portals.d.ts +9 -0
- package/runtime/lib/snapshot/lynx/portals.js +120 -0
- package/runtime/lib/snapshot/lynx/portals.js.map +1 -0
- package/runtime/lib/snapshot/lynx/portalsPending.d.ts +10 -0
- package/runtime/lib/snapshot/lynx/portalsPending.js +38 -0
- package/runtime/lib/snapshot/lynx/portalsPending.js.map +1 -0
- package/runtime/lib/snapshot/lynx/runWithForce.js +1 -1
- package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.js +2 -2
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +20 -21
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/constants.d.ts +4 -0
- package/runtime/lib/snapshot/snapshot/constants.js +4 -0
- package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/definition.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/definition.js +49 -1
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/dynamicPartType.d.ts +12 -0
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js +12 -0
- package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/event.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/event.js +0 -4
- package/runtime/lib/snapshot/snapshot/event.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/gesture.js +9 -3
- package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.d.ts +14 -0
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js +27 -0
- package/runtime/lib/snapshot/snapshot/reconstructInstanceTree.js.map +1 -0
- package/runtime/lib/snapshot/snapshot/snapshot.js +62 -3
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +32 -1
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/utils.d.ts +1 -3
- package/runtime/lib/snapshot/snapshot/utils.js +5 -0
- package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/workletEvent.js +10 -5
- package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.d.ts +1 -1
- package/runtime/lib/snapshot/snapshot/workletRef.js +6 -3
- package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/workletRef.js +1 -1
- package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/utils.js +1 -1
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/observers.js +5 -3
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +1 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +5 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +1 -2
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/worklet-runtime/dev.js +8 -4
- package/runtime/worklet-runtime/main.js +1 -1
- package/testing-library/dist/env/index.js +25 -7
- package/testing-library/dist/fire-event.d.ts +21 -7
- package/testing-library/dist/index.d.ts +2 -0
- package/testing-library/dist/pure.js +27 -9
- package/testing-library/dist/type-entry/index.js +0 -0
- package/transform/dist/wasm.cjs +833 -285
- package/transform/index.d.ts +28 -1
- package/types/react.docs.d.ts +9 -1
- package/refresh/.gitignore +0 -1
- package/refresh/.npmignore +0 -3
- package/refresh/.turbo/turbo-build.log +0 -12
- package/refresh/package.json +0 -20
- package/refresh/rslib.config.ts +0 -24
- package/refresh/tsconfig.json +0 -4
- package/refresh/turbo.json +0 -15
- package/runtime/lib/snapshot/debug/component-stack.js.map +0 -1
- package/runtime/lib/snapshot/debug/profile.js.map +0 -1
- package/runtime/lib/snapshot/hooks/mainThread.js.map +0 -1
- package/runtime/lib/snapshot/hooks/react.js.map +0 -1
- package/runtime/lib/snapshot/hooks/useLynxGlobalEventListener.js.map +0 -1
- package/runtime/lib/snapshot/renderToOpcodes/constants.js.map +0 -1
- package/testing-library/README.md +0 -109
- /package/runtime/lib/{snapshot → core}/hooks/react.d.ts +0 -0
- /package/runtime/lib/{snapshot/debug → shared}/component-stack.d.ts +0 -0
- /package/runtime/lib/{snapshot/debug → shared}/profile.d.ts +0 -0
- /package/runtime/lib/{snapshot/renderToOpcodes/constants.d.ts → shared/render-constants.d.ts} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { options } from 'preact';
|
|
5
|
+
import { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';
|
|
6
|
+
import { hook } from '../../utils.js';
|
|
7
|
+
import { globalCommitContext } from '../background/commit-context.js';
|
|
8
|
+
const PerformanceTimingKeys = [
|
|
9
|
+
'updateSetStateTrigger',
|
|
10
|
+
'updateDiffVdomStart',
|
|
11
|
+
'updateDiffVdomEnd',
|
|
12
|
+
// updateSetStateTrigger, updateDiffVdomStart and updateDiffVdomEnd is deprecated
|
|
13
|
+
'diffVdomStart',
|
|
14
|
+
'diffVdomEnd',
|
|
15
|
+
'packChangesStart',
|
|
16
|
+
'packChangesEnd',
|
|
17
|
+
'parseChangesStart',
|
|
18
|
+
'parseChangesEnd',
|
|
19
|
+
'patchChangesStart',
|
|
20
|
+
'patchChangesEnd',
|
|
21
|
+
'hydrateParsePayloadStart',
|
|
22
|
+
'hydrateParsePayloadEnd',
|
|
23
|
+
'mtsRenderStart',
|
|
24
|
+
'mtsRenderEnd',
|
|
25
|
+
];
|
|
26
|
+
const PerformanceTimingFlags = {
|
|
27
|
+
reactLynxHydrate: 'react_lynx_hydrate',
|
|
28
|
+
};
|
|
29
|
+
const PipelineOrigins = {
|
|
30
|
+
reactLynxHydrate: 'reactLynxHydrate',
|
|
31
|
+
updateTriggeredByBts: 'updateTriggeredByBts',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated used by old timing api(setState timing flag)
|
|
35
|
+
*/
|
|
36
|
+
const PerfSpecificKey = '__lynx_timing_flag';
|
|
37
|
+
let timingFlag;
|
|
38
|
+
let shouldMarkDiffVdomStart = false;
|
|
39
|
+
let shouldMarkDiffVdomEnd = false;
|
|
40
|
+
let globalPipelineOptions;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated used by old timing api(setState timing flag)
|
|
43
|
+
*/
|
|
44
|
+
function markTimingLegacy(key, timingFlag_) {
|
|
45
|
+
switch (key) {
|
|
46
|
+
case 'updateSetStateTrigger': {
|
|
47
|
+
shouldMarkDiffVdomStart = true;
|
|
48
|
+
shouldMarkDiffVdomEnd = true;
|
|
49
|
+
timingFlag = timingFlag_;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'updateDiffVdomStart': {
|
|
53
|
+
if (!shouldMarkDiffVdomStart) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
shouldMarkDiffVdomStart = false;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'updateDiffVdomEnd': {
|
|
60
|
+
if (!shouldMarkDiffVdomEnd) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
shouldMarkDiffVdomEnd = false;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
lynx.getNativeApp().markTiming?.(timingFlag, key);
|
|
68
|
+
}
|
|
69
|
+
function beginPipeline(needTimestamps, pipelineOrigin, timingFlag) {
|
|
70
|
+
globalPipelineOptions = lynx.performance?._generatePipelineOptions?.();
|
|
71
|
+
if (globalPipelineOptions) {
|
|
72
|
+
globalPipelineOptions.needTimestamps = needTimestamps;
|
|
73
|
+
globalPipelineOptions.pipelineOrigin = pipelineOrigin;
|
|
74
|
+
globalPipelineOptions.dsl = 'reactLynx';
|
|
75
|
+
switch (pipelineOrigin) {
|
|
76
|
+
case PipelineOrigins.reactLynxHydrate:
|
|
77
|
+
globalPipelineOptions.stage = 'hydrate';
|
|
78
|
+
break;
|
|
79
|
+
case PipelineOrigins.updateTriggeredByBts:
|
|
80
|
+
globalPipelineOptions.stage = 'update';
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
lynx.performance?._onPipelineStart?.(globalPipelineOptions.pipelineID, globalPipelineOptions);
|
|
84
|
+
if (timingFlag) {
|
|
85
|
+
lynx.performance?._bindPipelineIdWithTimingFlag?.(globalPipelineOptions.pipelineID, timingFlag);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function setPipeline(pipeline) {
|
|
90
|
+
globalPipelineOptions = pipeline;
|
|
91
|
+
}
|
|
92
|
+
function markTiming(timestampKey, force) {
|
|
93
|
+
if (globalPipelineOptions && (force || globalPipelineOptions.needTimestamps)) {
|
|
94
|
+
lynx.performance?._markTiming?.(globalPipelineOptions.pipelineID, timestampKey);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function shouldStartUpdatePipeline() {
|
|
98
|
+
return globalCommitContext.ops.length > 0;
|
|
99
|
+
}
|
|
100
|
+
function initTimingAPI() {
|
|
101
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
102
|
+
const helper = () => {
|
|
103
|
+
// Check update ops to make sure this only runs after hydrate
|
|
104
|
+
if (__JS__ && shouldStartUpdatePipeline()) {
|
|
105
|
+
if (!globalPipelineOptions) {
|
|
106
|
+
beginPipeline(false, PipelineOrigins.updateTriggeredByBts);
|
|
107
|
+
markTiming('diffVdomStart', true);
|
|
108
|
+
}
|
|
109
|
+
if (shouldMarkDiffVdomStart) {
|
|
110
|
+
markTimingLegacy('updateDiffVdomStart');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
hook(options, RENDER_COMPONENT, (old, vnode, c) => {
|
|
115
|
+
helper();
|
|
116
|
+
/* v8 ignore start */
|
|
117
|
+
if (old) {
|
|
118
|
+
old(vnode, c);
|
|
119
|
+
}
|
|
120
|
+
/* v8 ignore stop */
|
|
121
|
+
});
|
|
122
|
+
hook(options, ROOT, (old, vnode, parentDom) => {
|
|
123
|
+
helper();
|
|
124
|
+
/* v8 ignore start */
|
|
125
|
+
if (old) {
|
|
126
|
+
old(vnode, parentDom);
|
|
127
|
+
}
|
|
128
|
+
/* v8 ignore stop */
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
export { PerformanceTimingFlags, PipelineOrigins, PerfSpecificKey, markTimingLegacy, initTimingAPI, beginPipeline, markTiming, setPipeline, globalPipelineOptions, };
|
|
135
|
+
//# sourceMappingURL=performance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../src/element-template/lynx/performance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGjC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,qBAAqB,GAAG;IAC5B,uBA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MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,6DAA6D;QAC7D,IAAI,MAAM,IAAI,yBAAyB,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC3B,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;gBAC3D,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,GAAG,EAAE,KAAY,EAAE,CAAC,EAAE,EAAE;QACvD,MAAM,EAAE,CAAC;QACT,qBAAqB;QACrB,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAChB,CAAC;QACD,oBAAoB;IACtB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,KAAY,EAAE,SAAS,EAAE,EAAE;QACnD,MAAM,EAAE,CAAC;QACT,qBAAqB;QACrB,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACxB,CAAC;QACD,oBAAoB;IACtB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,qBAAqB,GACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callDestroyLifetimeFun(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
5
|
+
export function callDestroyLifetimeFun() {
|
|
6
|
+
destroyElementTemplateBackgroundRuntime();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=callDestroyLifetimeFun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callDestroyLifetimeFun.js","sourceRoot":"","sources":["../../../src/element-template/native/callDestroyLifetimeFun.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AAEnF,MAAM,UAAU,sBAAsB;IACpC,uCAAuC,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../hooks/react.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import '../hooks/react.js';
|
|
5
|
+
import { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';
|
|
6
|
+
import { injectCalledByNative } from './main-thread-api.js';
|
|
7
|
+
import { installOnMtsDestruction } from './mts-destroy.js';
|
|
8
|
+
import { installElementTemplatePatchListener } from './patch-listener.js';
|
|
9
|
+
import { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';
|
|
10
|
+
import { installElementTemplateCommitHook } from '../background/commit-hook.js';
|
|
11
|
+
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
12
|
+
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
13
|
+
import { BackgroundElementTemplateInstance } from '../background/instance.js';
|
|
14
|
+
import { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';
|
|
15
|
+
import { initProfileHook } from '../debug/profile.js';
|
|
16
|
+
import { setupLynxEnv } from '../lynx/env.js';
|
|
17
|
+
import { initTimingAPI } from '../lynx/performance.js';
|
|
18
|
+
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
19
|
+
import { setRoot } from '../runtime/page/root-instance.js';
|
|
20
|
+
function init() {
|
|
21
|
+
if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {
|
|
22
|
+
initElementTemplatePAPICallAlog();
|
|
23
|
+
}
|
|
24
|
+
if (__MAIN_THREAD__) {
|
|
25
|
+
installMainThreadHooks();
|
|
26
|
+
injectCalledByNative();
|
|
27
|
+
installElementTemplatePatchListener();
|
|
28
|
+
installOnMtsDestruction();
|
|
29
|
+
if (__PROFILE__) {
|
|
30
|
+
initProfileHook();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (__BACKGROUND__) {
|
|
34
|
+
console.log('experimental_useElementTemplate:', __USE_ELEMENT_TEMPLATE__);
|
|
35
|
+
setRoot(new BackgroundElementTemplateInstance('root'));
|
|
36
|
+
setupBackgroundElementTemplateDocument();
|
|
37
|
+
installElementTemplateHydrationListener();
|
|
38
|
+
resetEventStateForRuntime();
|
|
39
|
+
lynxCoreInject.tt.callDestroyLifetimeFun = callDestroyLifetimeFun;
|
|
40
|
+
lynxCoreInject.tt.publishEvent = publishEvent;
|
|
41
|
+
lynxCoreInject.tt.publicComponentEvent = publicComponentEvent;
|
|
42
|
+
installElementTemplateCommitHook();
|
|
43
|
+
if (process.env['NODE_ENV'] !== 'test') {
|
|
44
|
+
initTimingAPI();
|
|
45
|
+
if (lynx.performance?.isProfileRecording?.()) {
|
|
46
|
+
initProfileHook();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setupLynxEnv();
|
|
51
|
+
}
|
|
52
|
+
init();
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AAC;YAChB,eAAe,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,iCAAiC,CAAC,MAAM,CAAC,CAAC,CAAC;QACvD,sCAAsC,EAAE,CAAC;QACzC,uCAAuC,EAAE,CAAC;QAC1C,yBAAyB,EAAE,CAAC;QAC5B,cAAc,CAAC,EAAE,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QAClE,cAAc,CAAC,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC;QAC9C,cAAc,CAAC,EAAE,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAC9D,gCAAgC,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;YACvC,aAAa,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;gBAC7C,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { setupPage } from '../runtime/page/page.js';
|
|
5
|
+
import { renderMainThread } from '../runtime/render/render-main-thread.js';
|
|
6
|
+
function injectCalledByNative() {
|
|
7
|
+
const calledByNative = {
|
|
8
|
+
renderPage,
|
|
9
|
+
updatePage: function () { },
|
|
10
|
+
updateGlobalProps: function () { },
|
|
11
|
+
getPageData: function () {
|
|
12
|
+
return null;
|
|
13
|
+
},
|
|
14
|
+
removeComponents: function () { },
|
|
15
|
+
};
|
|
16
|
+
Object.assign(globalThis, calledByNative);
|
|
17
|
+
}
|
|
18
|
+
function renderPage(data) {
|
|
19
|
+
lynx.__initData = data ?? {};
|
|
20
|
+
setupPage(__CreatePage('0', 0));
|
|
21
|
+
renderMainThread();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export { injectCalledByNative };
|
|
27
|
+
//# sourceMappingURL=main-thread-api.js.map
|
|
@@ -0,0 +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,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU,EAAE,cAAkB,CAAC;QAC/B,iBAAiB,EAAE,cAAkB,CAAC;QACtC,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,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAChC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
|
+
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
6
|
+
export function installOnMtsDestruction() {
|
|
7
|
+
lynx.getNative?.().addEventListener('__DestroyLifetime', onMtsDestruction);
|
|
8
|
+
}
|
|
9
|
+
export function onMtsDestruction() {
|
|
10
|
+
const performance = lynx.performance;
|
|
11
|
+
performance?.profileStart?.('ReactLynx::onMtsDestruction');
|
|
12
|
+
try {
|
|
13
|
+
destroyElementTemplateMainThreadRuntime();
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
performance?.profileEnd?.();
|
|
17
|
+
lynx.getNative?.().removeEventListener('__DestroyLifetime', onMtsDestruction);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function destroyElementTemplateMainThreadRuntime() {
|
|
21
|
+
let patchListenerResetError;
|
|
22
|
+
let didPatchListenerResetThrow = false;
|
|
23
|
+
try {
|
|
24
|
+
resetElementTemplatePatchListener();
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
patchListenerResetError = error;
|
|
28
|
+
didPatchListenerResetThrow = true;
|
|
29
|
+
}
|
|
30
|
+
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
31
|
+
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
32
|
+
elementTemplateRegistry.clear();
|
|
33
|
+
if (didPatchListenerResetThrow) {
|
|
34
|
+
throw patchListenerResetError;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=mts-destroy.js.map
|
|
@@ -0,0 +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,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,uBAAuB;IACrC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,WAAW,EAAE,YAAY,EAAE,CAAC,6BAA6B,CAAC,CAAC;IAC3D,IAAI,CAAC;QACH,uCAAuC,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uCAAuC;IACrD,IAAI,uBAAgC,CAAC;IACrC,IAAI,0BAA0B,GAAG,KAAK,CAAC;IACvC,IAAI,CAAC;QACH,iCAAiC,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uBAAuB,GAAG,KAAK,CAAC;QAChC,0BAA0B,GAAG,IAAI,CAAC;IACpC,CAAC;IAED,+EAA+E;IAC/E,iFAAiF;IACjF,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAEhC,IAAI,0BAA0B,EAAE,CAAC;QAC/B,MAAM,uBAAuB,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
5
|
+
import { markTiming, setPipeline } from '../lynx/performance.js';
|
|
6
|
+
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
7
|
+
import { __page } from '../runtime/page/page.js';
|
|
8
|
+
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
9
|
+
let listener;
|
|
10
|
+
export function installElementTemplatePatchListener() {
|
|
11
|
+
resetElementTemplatePatchListener();
|
|
12
|
+
listener = (event) => {
|
|
13
|
+
const { data } = event;
|
|
14
|
+
const payload = data;
|
|
15
|
+
const hasOps = Array.isArray(payload?.ops);
|
|
16
|
+
const flushOptions = payload?.flushOptions ?? {};
|
|
17
|
+
const pipelineOptions = flushOptions.pipelineOptions;
|
|
18
|
+
setPipeline(pipelineOptions);
|
|
19
|
+
const flowIds = Array.isArray(payload?.flowIds) && payload.flowIds.length > 0
|
|
20
|
+
? payload.flowIds
|
|
21
|
+
: undefined;
|
|
22
|
+
const shouldProfilePatch = hasOps
|
|
23
|
+
&& !!flowIds
|
|
24
|
+
&& typeof lynx.performance?.profileStart === 'function'
|
|
25
|
+
&& typeof lynx.performance?.profileEnd === 'function';
|
|
26
|
+
if (shouldProfilePatch) {
|
|
27
|
+
lynx.performance.profileStart('ReactLynx::patch', {
|
|
28
|
+
flowId: flowIds[0],
|
|
29
|
+
flowIds,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (hasOps) {
|
|
33
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
34
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
35
|
+
+ JSON.stringify({
|
|
36
|
+
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
37
|
+
flushOptions,
|
|
38
|
+
flowIds,
|
|
39
|
+
}, null, 2));
|
|
40
|
+
}
|
|
41
|
+
markTiming('mtsRenderStart');
|
|
42
|
+
markTiming('parseChangesStart');
|
|
43
|
+
markTiming('parseChangesEnd');
|
|
44
|
+
markTiming('patchChangesStart');
|
|
45
|
+
try {
|
|
46
|
+
applyElementTemplateUpdateCommands(payload.ops);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
markTiming('patchChangesEnd');
|
|
50
|
+
markTiming('mtsRenderEnd');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
__FlushElementTree(__page, flushOptions);
|
|
54
|
+
if (shouldProfilePatch) {
|
|
55
|
+
lynx.performance.profileEnd();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
59
|
+
}
|
|
60
|
+
export function resetElementTemplatePatchListener() {
|
|
61
|
+
if (listener) {
|
|
62
|
+
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
63
|
+
}
|
|
64
|
+
listener = undefined;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=patch-listener.js.map
|
|
@@ -0,0 +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;AAE1D,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEzE,IAAI,QAES,CAAC;AAEd,MAAM,UAAU,mCAAmC;IACjD,iCAAiC,EAAE,CAAC;IAEpC,QAAQ,GAAG,CAAC,KAAwB,EAAE,EAAE;QACtC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACvB,MAAM,OAAO,GAAG,IAA0C,CAAC;QAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,EAAE,CAAC;QACjD,MAAM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CAAC;YAC7B,CAAC;QACH,CAAC;QAED,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAEzC,IAAI,kBAAkB,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAChC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEventValue(handleId: number, attrSlotIndex: number, eventKey?: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
export function getEventValue(handleId, attrSlotIndex, eventKey = '') {
|
|
5
|
+
return `${handleId}:${attrSlotIndex}:${eventKey}`;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=event-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-value.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,aAAqB,EACrB,QAAQ,GAAG,EAAE;IAEb,OAAO,GAAG,QAAQ,IAAI,aAAa,IAAI,QAAQ,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type EtEventHandler = (data: EventDataType) => unknown;
|
|
2
|
+
export declare function clearEventState(): void;
|
|
3
|
+
export declare function resetEventStateForRuntime(): void;
|
|
4
|
+
export declare function getEventHandlerForEventValue(eventValue: string): EtEventHandler | undefined;
|
|
5
|
+
export declare function publishEvent(eventValue: string, data: EventDataType): void;
|
|
6
|
+
export declare function publicComponentEvent(_componentId: string, eventValue: string, data: EventDataType): void;
|
|
7
|
+
export declare function flushPendingEvents(): void;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { backgroundElementTemplateInstanceManager } from '../background/manager.js';
|
|
5
|
+
const pendingEvents = [];
|
|
6
|
+
let queuePendingEvents = false;
|
|
7
|
+
function dispatchEvent(eventValue, data) {
|
|
8
|
+
const handler = backgroundElementTemplateInstanceManager.getRawAttributeValueByEventValue(eventValue);
|
|
9
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
10
|
+
console.alog?.(`[ReactLynxDebug] ElementTemplate BTS received event:\n${JSON.stringify({
|
|
11
|
+
eventValue,
|
|
12
|
+
type: data.type,
|
|
13
|
+
jsFunctionName: typeof handler === 'function' ? handler.name : '',
|
|
14
|
+
hasHandler: typeof handler === 'function',
|
|
15
|
+
}, null, 2)}`);
|
|
16
|
+
}
|
|
17
|
+
if (typeof handler !== 'function') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
handler(data);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
lynx.reportError(error);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
export function clearEventState() {
|
|
29
|
+
pendingEvents.length = 0;
|
|
30
|
+
queuePendingEvents = false;
|
|
31
|
+
}
|
|
32
|
+
export function resetEventStateForRuntime() {
|
|
33
|
+
clearEventState();
|
|
34
|
+
queuePendingEvents = true;
|
|
35
|
+
}
|
|
36
|
+
export function getEventHandlerForEventValue(eventValue) {
|
|
37
|
+
const handler = backgroundElementTemplateInstanceManager.getRawAttributeValueByEventValue(eventValue);
|
|
38
|
+
return typeof handler === 'function' ? handler : undefined;
|
|
39
|
+
}
|
|
40
|
+
export function publishEvent(eventValue, data) {
|
|
41
|
+
if (dispatchEvent(eventValue, data)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (queuePendingEvents) {
|
|
45
|
+
pendingEvents.push([eventValue, data]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function publicComponentEvent(_componentId, eventValue, data) {
|
|
49
|
+
publishEvent(eventValue, data);
|
|
50
|
+
}
|
|
51
|
+
export function flushPendingEvents() {
|
|
52
|
+
queuePendingEvents = false;
|
|
53
|
+
if (pendingEvents.length === 0) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const events = pendingEvents.splice(0);
|
|
57
|
+
for (const [eventValue, data] of events) {
|
|
58
|
+
dispatchEvent(eventValue, data);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/event.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,wCAAwC,EAAE,MAAM,0BAA0B,CAAC;AAIpF,MAAM,aAAa,GAAqD,EAAE,CAAC;AAC3E,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,SAAS,aAAa,CAAC,UAAkB,EAAE,IAAmB;IAC5D,MAAM,OAAO,GAAG,wCAAwC,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC;IACtG,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,CAAC;QAChD,OAAO,CAAC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zC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,YAAoB,EACpB,UAAkB,EAClB,IAAmB;IAEnB,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,kBAAkB,GAAG,KAAK,CAAC;IAC3B,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvC,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;QACxC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SerializableValue } from '../protocol/types.js';
|
|
2
|
+
export interface SpreadAttrAdapterContext {
|
|
3
|
+
previousPreparedValue?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare function prepareSpreadAttrSlot(handleId: number, attrSlotIndex: number, value: unknown, _context?: SpreadAttrAdapterContext): SerializableValue | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { getEventValue } from './event-value.js';
|
|
5
|
+
const eventPropKeyRegExp = /^(?:global-bind|bind|catch|capture-bind|capture-catch)[A-Za-z]+$/;
|
|
6
|
+
const namespacedEventKeyRegExp = /^[A-Za-z-]+:(?:global-bind|bind|catch|capture-bind|capture-catch)[A-Za-z]+$/;
|
|
7
|
+
function isEventPropKey(key) {
|
|
8
|
+
return eventPropKeyRegExp.test(key);
|
|
9
|
+
}
|
|
10
|
+
function isSpreadRecord(value) {
|
|
11
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
export function prepareSpreadAttrSlot(handleId, attrSlotIndex, value, _context) {
|
|
14
|
+
if (value === false || !isSpreadRecord(value)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const prepared = {};
|
|
18
|
+
for (const key in value) {
|
|
19
|
+
const spreadValue = value[key];
|
|
20
|
+
if (key === '__spread' || key === '__self' || key === '__source') {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (key === 'class' || key === 'className') {
|
|
24
|
+
prepared['class'] = (spreadValue ?? '');
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (isEventPropKey(key)) {
|
|
28
|
+
prepared[key] = spreadValue === null || spreadValue === undefined || spreadValue === false
|
|
29
|
+
? null
|
|
30
|
+
: getEventValue(handleId, attrSlotIndex, key);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (spreadValue === undefined
|
|
34
|
+
|| key === 'ref'
|
|
35
|
+
|| key.endsWith(':ref')
|
|
36
|
+
|| key.endsWith(':gesture')
|
|
37
|
+
|| namespacedEventKeyRegExp.test(key)
|
|
38
|
+
|| typeof spreadValue === 'function') {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
prepared[key] = spreadValue;
|
|
42
|
+
}
|
|
43
|
+
return prepared;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=spread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spread.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/spread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD,MAAM,kBAAkB,GAAG,kEAAkE,CAAC;AAC9F,MAAM,wBAAwB,GAAG,6EAA6E,CAAC;AAE/G,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,kBAAkB,CAAC,IAAI,CAAC,G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I,CAAC,GAAG,CAAC;eAClC,OAAO,WAAW,KAAK,UAAU,EACpC,CAAC;YACD,SAAS;QACX,CAAC;QAED,QAAQ,CAAC,GAAG,CAAC,GAAG,WAAgC,CAAC;IACnD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export var ElementTemplateLifecycleConstant;
|
|
5
|
+
(function (ElementTemplateLifecycleConstant) {
|
|
6
|
+
ElementTemplateLifecycleConstant["hydrate"] = "rLynxElementTemplateHydrate";
|
|
7
|
+
ElementTemplateLifecycleConstant["update"] = "rLynxElementTemplateUpdate";
|
|
8
|
+
})(ElementTemplateLifecycleConstant || (ElementTemplateLifecycleConstant = {}));
|
|
9
|
+
//# sourceMappingURL=lifecycle-constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-constant.js","sourceRoot":"","sources":["../../../src/element-template/protocol/lifecycle-constant.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAN,IAAkB,gCAGjB;AAHD,WAAkB,gCAAgC;IAChD,2EAAuC,CAAA;IACvC,yEAAqC,CAAA;AACvC,CAAC,EAHiB,gCAAgC,KAAhC,gCAAgC,QAGjD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ElementTemplateUpdateOps: {
|
|
2
|
+
readonly createTemplate: 1;
|
|
3
|
+
readonly setAttribute: 2;
|
|
4
|
+
readonly insertNode: 3;
|
|
5
|
+
readonly removeNode: 4;
|
|
6
|
+
};
|
|
7
|
+
export type ElementTemplateUpdateOp = typeof ElementTemplateUpdateOps[keyof typeof ElementTemplateUpdateOps];
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export const ElementTemplateUpdateOps = {
|
|
5
|
+
createTemplate: 1,
|
|
6
|
+
setAttribute: 2,
|
|
7
|
+
insertNode: 3,
|
|
8
|
+
removeNode: 4,
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=opcodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/element-template/protocol/opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;CACL,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ElementTemplateUpdateOps } from './opcodes.js';
|
|
2
|
+
export type SerializableValue = string | number | boolean | null | SerializableValue[] | {
|
|
3
|
+
[key: string]: SerializableValue;
|
|
4
|
+
};
|
|
5
|
+
export type RuntimeOptions = Record<string, SerializableValue>;
|
|
6
|
+
export interface SerializedElementTemplate {
|
|
7
|
+
templateKey: string;
|
|
8
|
+
bundleUrl?: string;
|
|
9
|
+
attributeSlots?: SerializableValue[] | null;
|
|
10
|
+
elementSlots?: SerializedElementTemplate[][] | null;
|
|
11
|
+
uid: number | string;
|
|
12
|
+
}
|
|
13
|
+
export type CreateTemplateCommand = [
|
|
14
|
+
typeof ElementTemplateUpdateOps.createTemplate,
|
|
15
|
+
handleId: number,
|
|
16
|
+
templateKey: string,
|
|
17
|
+
bundleUrl: string | null | undefined,
|
|
18
|
+
attributeSlots: SerializableValue[] | null | undefined,
|
|
19
|
+
elementSlots: number[][] | null | undefined
|
|
20
|
+
];
|
|
21
|
+
export type SetAttributeCommand = [
|
|
22
|
+
typeof ElementTemplateUpdateOps.setAttribute,
|
|
23
|
+
targetHandleId: number,
|
|
24
|
+
attrSlotIndex: number,
|
|
25
|
+
value: SerializableValue | null
|
|
26
|
+
];
|
|
27
|
+
export type InsertNodeCommand = [
|
|
28
|
+
typeof ElementTemplateUpdateOps.insertNode,
|
|
29
|
+
targetHandleId: number,
|
|
30
|
+
elementSlotIndex: number,
|
|
31
|
+
childHandleId: number,
|
|
32
|
+
referenceHandleId: number
|
|
33
|
+
];
|
|
34
|
+
export type RemoveNodeCommand = [
|
|
35
|
+
typeof ElementTemplateUpdateOps.removeNode,
|
|
36
|
+
targetHandleId: number,
|
|
37
|
+
elementSlotIndex: number,
|
|
38
|
+
childHandleId: number,
|
|
39
|
+
removedSubtreeHandleIds: number[]
|
|
40
|
+
];
|
|
41
|
+
export type ElementTemplateUpdateCommand = CreateTemplateCommand | SetAttributeCommand | InsertNodeCommand | RemoveNodeCommand;
|
|
42
|
+
export type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];
|
|
43
|
+
export interface ElementTemplateFlushOptions {
|
|
44
|
+
pipelineOptions?: PipelineOptions;
|
|
45
|
+
}
|
|
46
|
+
export interface ElementTemplateUpdateCommitContext {
|
|
47
|
+
ops: ElementTemplateUpdateCommandStream;
|
|
48
|
+
flushOptions: ElementTemplateFlushOptions;
|
|
49
|
+
flowIds?: number[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { ElementTemplateUpdateOps } from './opcodes.js';
|
|
5
|
+
//# sourceMappingURL=types.js.map
|