@lynx-js/react 0.121.1 → 0.122.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 +44 -0
- package/package.json +5 -5
- package/runtime/lazy/element-template-import.js +73 -0
- package/runtime/lazy/import.js +4 -0
- package/runtime/lazy/target.js +23 -0
- package/runtime/lib/core/background-function/exec-map.d.ts +11 -0
- package/runtime/lib/core/background-function/exec-map.js +39 -0
- package/runtime/lib/core/background-function/exec-map.js.map +1 -0
- package/runtime/lib/core/background-function/handle.d.ts +8 -0
- package/runtime/lib/core/background-function/handle.js +25 -0
- package/runtime/lib/core/background-function/handle.js.map +1 -0
- package/runtime/lib/core/background-function/run-on-background.d.ts +8 -0
- package/runtime/lib/{snapshot/worklet/call/runOnBackground.js → core/background-function/run-on-background.js} +39 -33
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -0
- package/runtime/lib/{snapshot/legacy-react-runtime/index.d.ts → core/compat/legacy-react-runtime.d.ts} +4 -4
- package/runtime/lib/{snapshot/legacy-react-runtime/index.js → core/compat/legacy-react-runtime.js} +6 -6
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -0
- package/runtime/lib/{snapshot → core}/compat/lynxComponent.d.ts +2 -1
- package/runtime/lib/{snapshot → core}/compat/lynxComponent.js +11 -5
- package/runtime/lib/core/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/core/component.d.ts +2 -0
- package/runtime/lib/{snapshot/lynx → core}/component.js +37 -31
- package/runtime/lib/core/component.js.map +1 -0
- package/runtime/lib/core/initData.js +35 -0
- package/runtime/lib/core/initData.js.map +1 -1
- package/runtime/lib/{snapshot/lynx/dynamic-js.js → core/lynx/dynamic-import.js} +1 -1
- package/runtime/lib/core/lynx/dynamic-import.js.map +1 -0
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/core/lynx/runtime-backend.d.ts +5 -0
- package/runtime/lib/core/lynx/runtime-backend.js +20 -0
- package/runtime/lib/core/lynx/runtime-backend.js.map +1 -0
- package/runtime/lib/core/lynx-page-data.js +6 -0
- package/runtime/lib/core/lynx-page-data.js.map +1 -1
- package/runtime/lib/core/lynx-update-data.js +6 -0
- package/runtime/lib/core/lynx-update-data.js.map +1 -1
- package/runtime/lib/core/performance.d.ts +30 -0
- package/runtime/lib/core/performance.js +145 -0
- package/runtime/lib/core/performance.js.map +1 -0
- package/runtime/lib/core/runtime-destroy.d.ts +4 -0
- package/runtime/lib/core/runtime-destroy.js +18 -0
- package/runtime/lib/core/runtime-destroy.js.map +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.d.ts +5 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +69 -0
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -0
- package/runtime/lib/core/thread-function-call/return-value.d.ts +2 -0
- package/runtime/lib/core/thread-function-call/return-value.js +67 -0
- package/runtime/lib/core/thread-function-call/return-value.js.map +1 -0
- package/runtime/lib/element-template/background/attr-slots.d.ts +1 -1
- package/runtime/lib/element-template/background/attr-slots.js +8 -7
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +81 -61
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +4 -0
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/document.js +7 -1
- package/runtime/lib/element-template/background/document.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.d.ts +2 -3
- package/runtime/lib/element-template/background/hydrate.js +237 -58
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +38 -38
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +31 -4
- package/runtime/lib/element-template/background/instance.js +219 -31
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/render-scope.d.ts +4 -0
- package/runtime/lib/element-template/background/render-scope.js +43 -0
- package/runtime/lib/element-template/background/render-scope.js.map +1 -0
- package/runtime/lib/element-template/debug/alog.d.ts +14 -0
- package/runtime/lib/element-template/debug/alog.js +23 -0
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/elementPAPICall.js +1 -0
- package/runtime/lib/element-template/debug/elementPAPICall.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +5 -2
- package/runtime/lib/element-template/index.js +8 -7
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +7 -0
- package/runtime/lib/element-template/internal.js +9 -9
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js +2 -0
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/lynx/performance.d.ts +0 -21
- package/runtime/lib/element-template/lynx/performance.js +4 -121
- package/runtime/lib/element-template/lynx/performance.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +3 -1
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +6 -0
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +42 -17
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.d.ts +1 -0
- package/runtime/lib/element-template/native/{reload.js → reload-background.js} +1 -26
- package/runtime/lib/element-template/native/reload-background.js.map +1 -0
- package/runtime/lib/element-template/native/{reload.d.ts → reload-main-thread.d.ts} +0 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +39 -0
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +1 -4
- package/runtime/lib/element-template/prop-adapters/spread.js +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +3 -0
- package/runtime/lib/element-template/protocol/opcodes.js +3 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/template-type.d.ts +25 -0
- package/runtime/lib/element-template/protocol/template-type.js +42 -0
- package/runtime/lib/element-template/protocol/template-type.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +38 -15
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/protocol/update-event.d.ts +15 -0
- package/runtime/lib/element-template/protocol/update-event.js +24 -0
- package/runtime/lib/element-template/protocol/update-event.js.map +1 -0
- package/runtime/lib/element-template/runtime/list/list.d.ts +65 -0
- package/runtime/lib/element-template/runtime/list/list.js +587 -0
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -0
- package/runtime/lib/element-template/runtime/patch.d.ts +1 -1
- package/runtime/lib/element-template/runtime/patch.js +198 -75
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +13 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +83 -43
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +32 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +7 -5
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +3 -2
- package/runtime/lib/element-template/runtime/template/handle.js +11 -0
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +10 -0
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +30 -0
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +15 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +91 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.d.ts +15 -0
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js +29 -0
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-function.d.ts +6 -0
- package/runtime/lib/element-template/runtime/template/main-thread-function.js +24 -0
- package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/registry.d.ts +2 -0
- package/runtime/lib/element-template/runtime/template/registry.js +5 -0
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime-backend-marker.js +6 -0
- package/runtime/lib/element-template/runtime-backend-marker.js.map +1 -0
- package/runtime/lib/index.d.ts +4 -2
- package/runtime/lib/index.js +5 -2
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/internal.d.ts +5 -4
- package/runtime/lib/internal.js +6 -5
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +1 -1
- package/runtime/lib/lynx-api.js +1 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/runtime-backend-marker.js +6 -0
- package/runtime/lib/runtime-backend-marker.js.map +1 -0
- package/runtime/lib/{snapshot/worklet/indexMap.d.ts → shared/index-map.d.ts} +2 -2
- package/runtime/lib/{snapshot/worklet/indexMap.js → shared/index-map.js} +5 -3
- package/runtime/lib/shared/index-map.js.map +1 -0
- 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/updateMainThread.js +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/lynx/children.d.ts +13 -0
- package/runtime/lib/snapshot/lynx/children.js +19 -0
- package/runtime/lib/snapshot/lynx/children.js.map +1 -0
- package/runtime/lib/snapshot/lynx/performance.d.ts +0 -21
- package/runtime/lib/snapshot/lynx/performance.js +7 -121
- package/runtime/lib/snapshot/lynx/performance.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/snapshot/backgroundSnapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +10 -31
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ctx.js +2 -2
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
- package/runtime/lib/snapshot/worklet/destroy.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/destroy.js +2 -5
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/observers.d.ts +7 -0
- package/runtime/lib/worklet-runtime/bindings/observers.js +14 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.d.ts +2 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +6 -2
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +3 -0
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +17 -2
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/worklet-runtime/dev.js +26 -9
- package/runtime/worklet-runtime/main.js +1 -1
- package/testing-library/dist/{rslib-runtime.js → 0~rslib-runtime.js} +14 -13
- package/testing-library/dist/env/vitest.js +1 -1
- package/testing-library/dist/plugins/index.js +1 -1
- package/testing-library/dist/pure.js +18 -18
- package/testing-library/dist/rstest-config.js +2 -4
- package/testing-library/dist/setupFiles/common/bootstrap.js +1 -0
- package/testing-library/dist/setupFiles/common/runtime-setup.js +1 -1
- package/testing-library/dist/setupFiles/inner/rstest.js +2 -1
- package/testing-library/dist/setupFiles/inner/vitest.js +2 -1
- package/testing-library/dist/type-entry/index.js +1 -0
- package/transform/dist/wasm.cjs +113 -40
- package/types/react.docs.d.ts +14 -0
- package/runtime/lib/element-template/native/reload.js.map +0 -1
- package/runtime/lib/snapshot/compat/lynxComponent.js.map +0 -1
- package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +0 -1
- package/runtime/lib/snapshot/lynx/component.js.map +0 -1
- package/runtime/lib/snapshot/lynx/dynamic-js.js.map +0 -1
- package/runtime/lib/snapshot/lynx/lazy-bundle.js.map +0 -1
- package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.d.ts +0 -3
- package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.js +0 -10
- package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.js.map +0 -1
- package/runtime/lib/snapshot/worklet/call/execMap.js +0 -43
- package/runtime/lib/snapshot/worklet/call/execMap.js.map +0 -1
- package/runtime/lib/snapshot/worklet/call/functionCall.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/call/functionCall.js +0 -33
- package/runtime/lib/snapshot/worklet/call/functionCall.js.map +0 -1
- package/runtime/lib/snapshot/worklet/call/runOnBackground.d.ts +0 -20
- package/runtime/lib/snapshot/worklet/call/runOnBackground.js.map +0 -1
- package/runtime/lib/snapshot/worklet/call/transformToWorklet.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/call/transformToWorklet.js +0 -22
- package/runtime/lib/snapshot/worklet/call/transformToWorklet.js.map +0 -1
- package/runtime/lib/snapshot/worklet/indexMap.js.map +0 -1
- package/testing-library/dist/881.js +0 -1
- /package/runtime/lib/{snapshot/lynx/dynamic-js.d.ts → core/lynx/dynamic-import.d.ts} +0 -0
- /package/runtime/lib/{snapshot → core}/lynx/lazy-bundle.d.ts +0 -0
- /package/runtime/lib/{snapshot → core}/lynx/lazy-bundle.js +0 -0
- /package/runtime/lib/{snapshot/lynx/component.d.ts → element-template/runtime-backend-marker.d.ts} +0 -0
- /package/runtime/lib/{snapshot/worklet/call/execMap.d.ts → runtime-backend-marker.d.ts} +0 -0
- /package/testing-library/dist/{0~123.js → 0~@rstest/adapter-rsbuild.js} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
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 { IndexMap } from '../../shared/index-map.js';
|
|
5
|
+
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
6
|
+
import { registerDestroyTask } from '../runtime-destroy.js';
|
|
7
|
+
let resolveMap;
|
|
8
|
+
let cleanupReturnValueListener;
|
|
9
|
+
let unregisterReturnValueCleanup;
|
|
10
|
+
function initReturnValueListener() {
|
|
11
|
+
const context = __JS__ ? lynx.getCoreContext() : lynx.getJSContext();
|
|
12
|
+
resolveMap = new IndexMap();
|
|
13
|
+
context.addEventListener(WorkletEvents.FunctionCallRet, onFunctionCallRet);
|
|
14
|
+
cleanupReturnValueListener = () => {
|
|
15
|
+
context.removeEventListener(WorkletEvents.FunctionCallRet, onFunctionCallRet);
|
|
16
|
+
resolveMap = undefined;
|
|
17
|
+
cleanupReturnValueListener = undefined;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export function onFunctionCall(resolve) {
|
|
24
|
+
ensureFunctionCallReturnCleanup();
|
|
25
|
+
if (!resolveMap) {
|
|
26
|
+
initReturnValueListener();
|
|
27
|
+
}
|
|
28
|
+
return resolveMap.add(resolve);
|
|
29
|
+
}
|
|
30
|
+
function ensureFunctionCallReturnCleanup() {
|
|
31
|
+
if (unregisterReturnValueCleanup) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
unregisterReturnValueCleanup = registerDestroyTask(() => {
|
|
35
|
+
resetFunctionCallReturnListener();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export function resetFunctionCallReturnListener() {
|
|
39
|
+
cleanupReturnValueListener?.();
|
|
40
|
+
unregisterReturnValueCleanup?.();
|
|
41
|
+
unregisterReturnValueCleanup = undefined;
|
|
42
|
+
}
|
|
43
|
+
export function dropFunctionCallReturnIds(resolveIds) {
|
|
44
|
+
if (!resolveMap) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
for (const resolveId of resolveIds) {
|
|
48
|
+
resolveMap.remove(resolveId);
|
|
49
|
+
}
|
|
50
|
+
if (resolveMap.size === 0) {
|
|
51
|
+
resetFunctionCallReturnListener();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function onFunctionCallRet(event) {
|
|
55
|
+
const data = JSON.parse(event.data);
|
|
56
|
+
const map = resolveMap;
|
|
57
|
+
if (!map) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const resolve = map.get(data.resolveId);
|
|
61
|
+
if (!resolve) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
map.remove(data.resolveId);
|
|
65
|
+
resolve(data.returnValue);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=return-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"return-value.js","sourceRoot":"","sources":["../../../src/core/thread-function-call/return-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,IAAI,UAAsD,CAAC;AAC3D,IAAI,0BAAoD,CAAC;AACzD,IAAI,4BAAsD,CAAC;AAE3D,SAAS,uBAAuB;IAC9B,MAAM,OAAO,GAAiB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;IAEnF,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC5B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAE3E,0BAA0B,GAAG,GAAG,EAAE;QAChC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QAC9E,UAAU,GAAG,SAAS,CAAC;QACvB,0BAA0B,GAAG,SAAS,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAA6B;IAC1D,+BAA+B,EAAE,CAAC;IAClC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,uBAAuB,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,UAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,+BAA+B;IACtC,IAAI,4BAA4B,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IACD,4BAA4B,GAAG,mBAAmB,CAAC,GAAG,EAAE;QACtD,+BAA+B,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,0BAA0B,EAAE,EAAE,CAAC;IAC/B,4BAA4B,EAAE,EAAE,CAAC;IACjC,4BAA4B,GAAG,SAAS,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,UAA6B;IACrE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC1B,+BAA+B,EAAE,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAyB;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAc,CAAyB,CAAC;IACtE,MAAM,GAAG,GAAG,UAAU,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SerializableValue } from '../protocol/types.js';
|
|
2
2
|
export interface PrepareAttributeSlotsOptions {
|
|
3
|
+
previousPreparedSlots?: readonly unknown[];
|
|
3
4
|
previousRawSlots?: readonly unknown[];
|
|
4
|
-
queueRefEffects?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare function prepareAttributeSlots(templateKey: string, handleId: number, rawSlots: readonly unknown[], options?: PrepareAttributeSlotsOptions): SerializableValue[];
|
|
7
7
|
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[]): void;
|
|
@@ -42,18 +42,19 @@ export function prepareAttributeSlots(templateKey, handleId, rawSlots, options)
|
|
|
42
42
|
const preparedSlots = normalizedSlots === rawSlots
|
|
43
43
|
? rawSlots.slice()
|
|
44
44
|
: normalizedSlots;
|
|
45
|
-
const
|
|
45
|
+
const previousPreparedSlots = options?.previousPreparedSlots;
|
|
46
46
|
const previousRawSlots = options?.previousRawSlots;
|
|
47
|
+
const adapterContext = previousPreparedSlots && previousRawSlots
|
|
48
|
+
? {
|
|
49
|
+
previousPreparedSlots,
|
|
50
|
+
previousRawSlots,
|
|
51
|
+
}
|
|
52
|
+
: undefined;
|
|
47
53
|
for (let planIndex = 0; planIndex < attrPlan.length; planIndex += 2) {
|
|
48
54
|
const attrSlotIndex = attrPlan[planIndex];
|
|
49
55
|
const adapter = attrPlan[planIndex + 1];
|
|
50
56
|
const rawValue = rawSlots[attrSlotIndex];
|
|
51
|
-
preparedSlots[attrSlotIndex] = adapter(handleId, attrSlotIndex, rawValue);
|
|
52
|
-
}
|
|
53
|
-
if (shouldQueueRefEffects) {
|
|
54
|
-
// Ref effects compare raw user refs, not prepared marker strings or the
|
|
55
|
-
// spread wrapper object.
|
|
56
|
-
queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlots, rawSlots);
|
|
57
|
+
preparedSlots[attrSlotIndex] = adapter(handleId, attrSlotIndex, rawValue, adapterContext);
|
|
57
58
|
}
|
|
58
59
|
return preparedSlots;
|
|
59
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wD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QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,mCAAmC,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { options } from 'preact';
|
|
5
5
|
import { globalCommitContext, resetGlobalCommitContext, takeRemovedSubtreesForPostDispatchTeardown, } from './commit-context.js';
|
|
6
|
+
import { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';
|
|
7
|
+
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';
|
|
6
8
|
import { getReloadVersion } from '../../core/reload-version.js';
|
|
9
|
+
import { delayedRunOnMainThreadData, takeDelayedRunOnMainThreadData, } from '../../core/thread-function-call/main-thread.js';
|
|
10
|
+
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
7
11
|
import { COMMIT } from '../../shared/render-constants.js';
|
|
8
12
|
import { hook, isEmptyObject } from '../../utils.js';
|
|
9
13
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
10
14
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
11
|
-
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../lynx/performance.js';
|
|
12
15
|
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
13
|
-
import {
|
|
16
|
+
import { createElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
14
17
|
let installed = false;
|
|
15
18
|
let hasHydrated = false;
|
|
16
19
|
const scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set();
|
|
@@ -22,6 +25,7 @@ export function isElementTemplateHydrated() {
|
|
|
22
25
|
}
|
|
23
26
|
export function resetElementTemplateCommitState() {
|
|
24
27
|
hasHydrated = false;
|
|
28
|
+
resetElementTemplateRenderScope();
|
|
25
29
|
resetGlobalCommitContext();
|
|
26
30
|
}
|
|
27
31
|
export function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown) {
|
|
@@ -31,7 +35,7 @@ export function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwai
|
|
|
31
35
|
const timer = setTimeout(() => {
|
|
32
36
|
scheduledRemovedSubtreeCleanupTimers.delete(timer);
|
|
33
37
|
for (const root of removedSubtreesAwaitingTeardown) {
|
|
34
|
-
root.
|
|
38
|
+
root.releaseDetachedSubtreeFromManager();
|
|
35
39
|
}
|
|
36
40
|
}, 10000);
|
|
37
41
|
scheduledRemovedSubtreeCleanupTimers.add(timer);
|
|
@@ -42,12 +46,83 @@ export function cancelElementTemplateRemovedSubtreeCleanup() {
|
|
|
42
46
|
}
|
|
43
47
|
scheduledRemovedSubtreeCleanupTimers.clear();
|
|
44
48
|
}
|
|
49
|
+
function flushElementTemplateCommitChanges() {
|
|
50
|
+
const hasNativeOps = globalCommitContext.ops.length > 0;
|
|
51
|
+
const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;
|
|
52
|
+
const hasUpdatePayload = hasNativeOps
|
|
53
|
+
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
54
|
+
|| hasDelayedRunOnMainThread;
|
|
55
|
+
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
56
|
+
let didFlushRefs = false;
|
|
57
|
+
let didDispatchUpdatePayload = false;
|
|
58
|
+
let delayedRunOnMainThreadPayload;
|
|
59
|
+
try {
|
|
60
|
+
if (hasUpdatePayload) {
|
|
61
|
+
markTimingLegacy('updateDiffVdomEnd');
|
|
62
|
+
markTiming('diffVdomEnd');
|
|
63
|
+
if (__PROFILE__) {
|
|
64
|
+
profileStart('ReactLynx::commitChanges');
|
|
65
|
+
}
|
|
66
|
+
markTiming('packChangesStart');
|
|
67
|
+
if (globalPipelineOptions) {
|
|
68
|
+
globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;
|
|
69
|
+
}
|
|
70
|
+
markTiming('packChangesEnd');
|
|
71
|
+
if (globalPipelineOptions) {
|
|
72
|
+
setPipeline(undefined);
|
|
73
|
+
}
|
|
74
|
+
if (__PROFILE__) {
|
|
75
|
+
profileEnd();
|
|
76
|
+
}
|
|
77
|
+
delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread
|
|
78
|
+
? takeDelayedRunOnMainThreadData()
|
|
79
|
+
: undefined;
|
|
80
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
81
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS update:\n'
|
|
82
|
+
+ JSON.stringify({
|
|
83
|
+
ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),
|
|
84
|
+
flushOptions: globalCommitContext.flushOptions,
|
|
85
|
+
flowIds: globalCommitContext.flowIds,
|
|
86
|
+
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
87
|
+
}, null, 2));
|
|
88
|
+
}
|
|
89
|
+
lynx.getCoreContext().dispatchEvent(createElementTemplateUpdateEvent({
|
|
90
|
+
ops: globalCommitContext.ops,
|
|
91
|
+
flushOptions: globalCommitContext.flushOptions,
|
|
92
|
+
reloadVersion: getReloadVersion(),
|
|
93
|
+
flowIds: globalCommitContext.flowIds,
|
|
94
|
+
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
95
|
+
}));
|
|
96
|
+
didDispatchUpdatePayload = true;
|
|
97
|
+
}
|
|
98
|
+
// When native ops exist, patch first so a newly attached ref observes the
|
|
99
|
+
// committed native state. Ref-only commits still flush through this path.
|
|
100
|
+
flushPendingRefs();
|
|
101
|
+
didFlushRefs = true;
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
if (delayedRunOnMainThreadPayload && !didDispatchUpdatePayload) {
|
|
105
|
+
dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));
|
|
106
|
+
}
|
|
107
|
+
if (!didFlushRefs) {
|
|
108
|
+
clearPendingRefs();
|
|
109
|
+
}
|
|
110
|
+
resetGlobalCommitContext();
|
|
111
|
+
// Match Snapshot's cleanup boundary: start the delayed teardown only
|
|
112
|
+
// after the bridge dispatch attempt, so background JS objects are not
|
|
113
|
+
// torn down before main-thread detach observes the same commit.
|
|
114
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
45
117
|
export function installElementTemplateCommitHook() {
|
|
46
118
|
if (installed) {
|
|
47
119
|
return;
|
|
48
120
|
}
|
|
49
121
|
installed = true;
|
|
50
122
|
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
123
|
+
if (__BACKGROUND__) {
|
|
124
|
+
clearElementTemplateRenderScope();
|
|
125
|
+
}
|
|
51
126
|
if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {
|
|
52
127
|
// User effects can run before ET hydrate arrives, so ordinary refs must be
|
|
53
128
|
// attached on the background commit even though native UI ops are delayed.
|
|
@@ -56,64 +131,9 @@ export function installElementTemplateCommitHook() {
|
|
|
56
131
|
else if (__BACKGROUND__ && hasHydrated
|
|
57
132
|
&& (globalCommitContext.ops.length > 0
|
|
58
133
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
59
|
-
|| hasPendingRefs()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
63
|
-
let didFlushRefs = false;
|
|
64
|
-
try {
|
|
65
|
-
if (hasUpdatePayload) {
|
|
66
|
-
markTimingLegacy('updateDiffVdomEnd');
|
|
67
|
-
markTiming('diffVdomEnd');
|
|
68
|
-
if (__PROFILE__) {
|
|
69
|
-
profileStart('ReactLynx::commitChanges');
|
|
70
|
-
}
|
|
71
|
-
markTiming('packChangesStart');
|
|
72
|
-
if (globalPipelineOptions) {
|
|
73
|
-
globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;
|
|
74
|
-
}
|
|
75
|
-
markTiming('packChangesEnd');
|
|
76
|
-
if (globalPipelineOptions) {
|
|
77
|
-
setPipeline(undefined);
|
|
78
|
-
}
|
|
79
|
-
if (__PROFILE__) {
|
|
80
|
-
profileEnd();
|
|
81
|
-
}
|
|
82
|
-
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
83
|
-
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS update:\n'
|
|
84
|
-
+ JSON.stringify({
|
|
85
|
-
ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),
|
|
86
|
-
flushOptions: globalCommitContext.flushOptions,
|
|
87
|
-
flowIds: globalCommitContext.flowIds,
|
|
88
|
-
}, null, 2));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (hasUpdatePayload) {
|
|
92
|
-
lynx.getCoreContext().dispatchEvent({
|
|
93
|
-
type: ElementTemplateLifecycleConstant.update,
|
|
94
|
-
data: {
|
|
95
|
-
ops: globalCommitContext.ops,
|
|
96
|
-
flushOptions: globalCommitContext.flushOptions,
|
|
97
|
-
flowIds: globalCommitContext.flowIds,
|
|
98
|
-
reloadVersion: getReloadVersion(),
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
// When native ops exist, patch first so a newly attached ref observes the
|
|
103
|
-
// committed native state. Ref-only commits still flush through this path.
|
|
104
|
-
flushPendingRefs();
|
|
105
|
-
didFlushRefs = true;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
if (!didFlushRefs) {
|
|
109
|
-
clearPendingRefs();
|
|
110
|
-
}
|
|
111
|
-
resetGlobalCommitContext();
|
|
112
|
-
// Match Snapshot's cleanup boundary: start the delayed teardown only
|
|
113
|
-
// after the bridge dispatch attempt, so background JS objects are not
|
|
114
|
-
// torn down before main-thread detach observes the same commit.
|
|
115
|
-
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
116
|
-
}
|
|
134
|
+
|| hasPendingRefs()
|
|
135
|
+
|| delayedRunOnMainThreadData.length > 0)) {
|
|
136
|
+
flushElementTemplateCommitChanges();
|
|
117
137
|
}
|
|
118
138
|
originalCommit?.(vnode, commitQueue);
|
|
119
139
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,MAAM,EA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,IAAI,CAAC;IAEjB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE;QAC3D,IAAI,cAAc,EAAE,CAAC;YACnB,+BAA+B,EAAE,CAAC;QACpC,CAAC;QAED,IAAI,cAAc,IAAI,CAAC,WAAW,IAAI,cAAc,EAAE,EAAE,CAAC;YACvD,2EAA2E;YAC3E,2EAA2E;YAC3E,gBAAgB,EAAE,CAAC;QACrB,CAAC;aAAM,IACL,cAAc,IAAI,WAAW;eAC1B,CACD,mBAAmB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;mBAC/B,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC;mBAChD,cAAc,EAAE;mBAChB,0BAA0B,CAAC,MAAM,GAAG,CAAC,CACzC,EACD,CAAC;YACD,iCAAiC,EAAE,CAAC;QACtC,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
|
5
5
|
import { clearEventState } from '../prop-adapters/event.js';
|
|
6
6
|
import { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';
|
|
7
7
|
import { __root } from '../runtime/page/root-instance.js';
|
|
8
|
+
import { resetElementTemplateBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
9
|
+
import { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/template/main-thread-function.js';
|
|
8
10
|
export function destroyElementTemplateBackgroundRuntime() {
|
|
9
11
|
resetElementTemplateHydrationListener();
|
|
10
12
|
cancelElementTemplateRemovedSubtreeCleanup();
|
|
@@ -13,6 +15,8 @@ export function destroyElementTemplateBackgroundRuntime() {
|
|
|
13
15
|
// the raw ref ownership needed to detach callbacks is gone.
|
|
14
16
|
flushPendingRefs();
|
|
15
17
|
resetElementTemplateCommitState();
|
|
18
|
+
resetElementTemplateBackgroundFunctionRuntime();
|
|
19
|
+
resetElementTemplateMainThreadFunctionRuntime();
|
|
16
20
|
clearEventState();
|
|
17
21
|
clearRefState();
|
|
18
22
|
backgroundElementTemplateInstanceManager.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,6CAA6C,EAAE,MAAM,wDAAwD,CAAC;AACvH,OAAO,EAAE,6CAA6C,EAAE,MAAM,6CAA6C,CAAC;AAE5G,MAAM,UAAU,uCAAuC;IACrD,qCAAqC,EAAE,CAAC;IACxC,0CAA0C,EAAE,CAAC;IAE7C,MAAM,CAAC,IAAI,EAAE,MAAkC,CAAC,CAAC;IACjD,gFAAgF;IAChF,4DAA4D;IAC5D,gBAAgB,EAAE,CAAC;IAEnB,+BAA+B,EAAE,CAAC;IAClC,6CAA6C,EAAE,CAAC;IAChD,6CAA6C,EAAE,CAAC;IAChD,eAAe,EAAE,CAAC;IAClB,aAAa,EAAE,CAAC;IAChB,wCAAwC,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { options } from 'preact';
|
|
5
|
-
import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, BackgroundElementTemplateInstance } from './instance.js';
|
|
5
|
+
import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, BackgroundElementTemplateInstance, BackgroundListElementTemplateInstance, } from './instance.js';
|
|
6
6
|
export function setupBackgroundElementTemplateDocument() {
|
|
7
7
|
const doc = {
|
|
8
8
|
createElement(type) {
|
|
9
|
+
if (type === 'list') {
|
|
10
|
+
return new BackgroundListElementTemplateInstance();
|
|
11
|
+
}
|
|
9
12
|
return new BackgroundElementTemplateInstance(type);
|
|
10
13
|
},
|
|
11
14
|
createElementNS(_ns, type) {
|
|
15
|
+
if (type === 'list') {
|
|
16
|
+
return new BackgroundListElementTemplateInstance();
|
|
17
|
+
}
|
|
12
18
|
return new BackgroundElementTemplateInstance(type);
|
|
13
19
|
},
|
|
14
20
|
createTextNode(text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../src/element-template/background/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,eAAe,CAAC;AAQvB,MAAM,UAAU,sCAAsC;IACpD,MAAM,GAAG,GAAG;QACV,aAAa,CAAC,IAAY;YACxB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,CAAC,GAAW,EAAE,IAAY;YACvC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,OAAO,IAAI,qCAAqC,EAAE,CAAC;YACrD,CAAC;YACD,OAAO,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC;QACrD,CAAC;QACD,cAAc,CAAC,IAAY;YACzB,OAAO,IAAI,iCAAiC,CAAC,6BAA6B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,GAA0B,CAAC;IAE9C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function hydrateIntoContext(serialized: SerializedElementTemplate, instance: BackgroundElementTemplateInstance): boolean;
|
|
2
|
+
import type { SerializedEtNode } from '../protocol/types.js';
|
|
3
|
+
export declare function hydrateRootChildrenIntoContext(serializedChildren: SerializedEtNode[], root: BackgroundElementTemplateInstance): boolean;
|