@lynx-js/react 0.129.0 → 0.129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +83 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +31 -2
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +197 -7
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +121 -26
- package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
- package/runtime/__test__/shared/component-stack.test.ts +211 -0
- package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
- package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
- package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
- package/runtime/lazy/element-template-internal.js +0 -1
- package/runtime/lazy/internal.js +1 -1
- package/runtime/lazy/jsx-dev-runtime.js +1 -1
- package/runtime/lazy/jsx-runtime.js +1 -1
- package/runtime/lazy/legacy-react-runtime.js +1 -1
- package/runtime/lazy/react-lepus.js +1 -1
- package/runtime/lazy/react.js +1 -1
- package/runtime/lib/core/capture-main-thread-object.js +2 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
- package/runtime/lib/core/lynx-data-processors.js +3 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.js +1 -1
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/document.js +0 -5
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +11 -12
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/client/root.d.ts +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +2 -2
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -1
- package/runtime/lib/element-template/internal.js +0 -13
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/native/flush.d.ts +1 -0
- package/runtime/lib/element-template/native/flush.js +9 -0
- package/runtime/lib/element-template/native/flush.js.map +1 -0
- package/runtime/lib/element-template/native/main-thread-api.js +3 -7
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +8 -2
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +57 -50
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +2 -1
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +4 -0
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +41 -21
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +2 -125
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/shared/component-stack.d.ts +0 -4
- package/runtime/lib/shared/component-stack.js +21 -5
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/capture-main-thread-object.ts +2 -1
- package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
- package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
- package/runtime/src/core/lynx-data-processors.ts +124 -1
- package/runtime/src/core/runtime-destroy.ts +1 -1
- package/runtime/src/document.ts +0 -6
- package/runtime/src/element-template/background/commit-hook.ts +18 -12
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +0 -20
- package/runtime/src/element-template/lynx/env.ts +1 -1
- package/runtime/src/element-template/native/flush.ts +10 -0
- package/runtime/src/element-template/native/main-thread-api.ts +3 -6
- package/runtime/src/element-template/native/mts-destroy.ts +7 -2
- package/runtime/src/element-template/native/patch-listener.ts +62 -57
- package/runtime/src/element-template/native/reload-main-thread.ts +2 -1
- package/runtime/src/element-template/protocol/types.ts +0 -13
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +5 -0
- package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +51 -21
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +2 -2
- package/runtime/src/element-template/types.d.ts +6 -0
- package/runtime/src/internal.ts +1 -1
- package/runtime/src/lynx-api.ts +2 -124
- package/runtime/src/shared/component-stack.ts +22 -5
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
- package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
- package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
- package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/worklet-runtime/README.md +30 -10
- package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
- package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
- package/runtime/vitest.config.ts +0 -2
- package/testing-library/.turbo/turbo-build.log +6 -6
- package/testing-library/src/__tests__/act.test.jsx +0 -7
- package/testing-library/src/__tests__/alog.test.jsx +12 -54
- package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
- package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
- package/testing-library/src/__tests__/worklet.test.jsx +49 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +98 -376
- package/transform/__test__/defines.spec.js +30 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +56 -48
- package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
- package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +6 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +12 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/package.json +0 -1
- package/transform/src/lib.rs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +113 -42
- package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +273 -66
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
- package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/hmr.js +0 -28
- package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
- package/runtime/src/snapshot/worklet/hmr.ts +0 -34
- /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
- /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
|
@@ -44,7 +44,7 @@ interface PatchedVNode extends VNode {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get human readable name of the component/dom node
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
function getVNodeDisplayName(vnode: PatchedVNode): string {
|
|
48
48
|
if (vnode.type === Fragment) {
|
|
49
49
|
return 'Fragment';
|
|
50
50
|
} else if (typeof vnode.type == 'function') {
|
|
@@ -81,6 +81,7 @@ const renderStack: PatchedVNode[] = [];
|
|
|
81
81
|
* optimization. In these cases the `_owner` will be different.
|
|
82
82
|
*/
|
|
83
83
|
let ownerStack: PatchedVNode[] = [];
|
|
84
|
+
let didInstallComponentStack = false;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* Get the currently rendered `vnode`
|
|
@@ -108,7 +109,7 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
return stack.reduce((acc, owner) => {
|
|
111
|
-
acc += ` in ${
|
|
112
|
+
acc += ` in ${getVNodeDisplayName(owner)}`;
|
|
112
113
|
|
|
113
114
|
const source = owner.__source;
|
|
114
115
|
if (source) {
|
|
@@ -125,6 +126,13 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
125
126
|
* debug messages for `this.setState` where the `vnode` is `undefined`.
|
|
126
127
|
*/
|
|
127
128
|
export function setupComponentStack(): void {
|
|
129
|
+
renderStack.length = 0;
|
|
130
|
+
ownerStack = [];
|
|
131
|
+
if (didInstallComponentStack) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
didInstallComponentStack = true;
|
|
135
|
+
|
|
128
136
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
129
137
|
const oldDiff = options[DIFF];
|
|
130
138
|
const oldDiffed = options[DIFFED];
|
|
@@ -135,9 +143,15 @@ export function setupComponentStack(): void {
|
|
|
135
143
|
|
|
136
144
|
options[DIFFED] = vnode => {
|
|
137
145
|
if (isPossibleOwner(vnode)) {
|
|
138
|
-
ownerStack.
|
|
146
|
+
const ownerIndex = ownerStack.lastIndexOf(vnode);
|
|
147
|
+
if (ownerIndex !== -1) {
|
|
148
|
+
ownerStack.length = ownerIndex;
|
|
149
|
+
}
|
|
150
|
+
const renderIndex = renderStack.lastIndexOf(vnode);
|
|
151
|
+
if (renderIndex !== -1) {
|
|
152
|
+
renderStack.length = renderIndex;
|
|
153
|
+
}
|
|
139
154
|
}
|
|
140
|
-
renderStack.pop();
|
|
141
155
|
if (oldDiffed) oldDiffed(vnode);
|
|
142
156
|
};
|
|
143
157
|
|
|
@@ -149,7 +163,10 @@ export function setupComponentStack(): void {
|
|
|
149
163
|
};
|
|
150
164
|
|
|
151
165
|
options[ROOT] = (vnode, parent) => {
|
|
152
|
-
|
|
166
|
+
if (!(parent as { parentNode?: unknown } | null | undefined)?.parentNode) {
|
|
167
|
+
renderStack.length = 0;
|
|
168
|
+
ownerStack = [];
|
|
169
|
+
}
|
|
153
170
|
if (oldRoot) oldRoot(vnode, parent);
|
|
154
171
|
};
|
|
155
172
|
|
|
@@ -18,7 +18,6 @@ export const SnapshotOperation = {
|
|
|
18
18
|
nodesRefRemoveChild: 6,
|
|
19
19
|
|
|
20
20
|
DEV_ONLY_AddSnapshot: 100,
|
|
21
|
-
DEV_ONLY_RegisterWorklet: 101,
|
|
22
21
|
DEV_ONLY_SetSnapshotEntryName: 102,
|
|
23
22
|
} as const;
|
|
24
23
|
|
|
@@ -64,10 +63,6 @@ export const SnapshotOperationParams: Record<number, { name: string; params: str
|
|
|
64
63
|
'snapshotCreator', /* string */
|
|
65
64
|
],
|
|
66
65
|
},
|
|
67
|
-
[SnapshotOperation.DEV_ONLY_RegisterWorklet]: {
|
|
68
|
-
name: 'DEV_ONLY_RegisterWorklet',
|
|
69
|
-
params: ['hash', /* string */ 'fnStr' /* string */],
|
|
70
|
-
},
|
|
71
66
|
[SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {
|
|
72
67
|
name: 'DEV_ONLY_SetSnapshotEntryName',
|
|
73
68
|
params: ['uniqID', /* string */ 'entryName' /* string */],
|
|
@@ -161,16 +161,6 @@ export function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: numbe
|
|
|
161
161
|
}
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
|
-
// case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
|
|
165
|
-
// // HMR-related
|
|
166
|
-
// if (__DEV__) {
|
|
167
|
-
// const hash: string = snapshotPatch[++i];
|
|
168
|
-
// const fnStr: string = snapshotPatch[++i];
|
|
169
|
-
// const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
|
|
170
|
-
// registerWorklet('main-thread', hash, fn);
|
|
171
|
-
// }
|
|
172
|
-
// break;
|
|
173
|
-
// }
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
}
|
|
@@ -36,72 +36,76 @@ function updateMainThread(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
setPipeline(patchOptions.pipelineOptions);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
try {
|
|
40
|
+
markTiming('mtsRenderStart');
|
|
41
|
+
markTiming('parseChangesStart');
|
|
42
|
+
const parsedData = JSON.parse(data) as PatchList;
|
|
43
|
+
const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
46
|
+
console.alog?.(
|
|
47
|
+
'[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify(
|
|
48
|
+
{
|
|
49
|
+
data: {
|
|
50
|
+
...parsedData,
|
|
51
|
+
patchList: parsedData.patchList.map(patch => ({
|
|
52
|
+
...patch,
|
|
53
|
+
snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
|
|
54
|
+
})),
|
|
55
|
+
},
|
|
56
|
+
patchOptions,
|
|
54
57
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
markTiming('parseChangesEnd');
|
|
64
|
-
markTiming('patchChangesStart');
|
|
65
|
-
if (patchOptions.isHydration) {
|
|
66
|
-
setMainThreadHydrating(true);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
for (const { snapshotPatch, id } of patchList) {
|
|
70
|
-
__pendingListUpdates.clearAttachedLists();
|
|
71
|
-
if (snapshotPatch) {
|
|
72
|
-
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
73
|
-
}
|
|
74
|
-
__pendingListUpdates.flush();
|
|
75
|
-
// console.debug('********** Lepus updatePatch:');
|
|
76
|
-
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
58
|
+
null,
|
|
59
|
+
2,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
77
62
|
}
|
|
78
|
-
|
|
79
|
-
markTiming('
|
|
80
|
-
markTiming('
|
|
63
|
+
|
|
64
|
+
markTiming('parseChangesEnd');
|
|
65
|
+
markTiming('patchChangesStart');
|
|
81
66
|
if (patchOptions.isHydration) {
|
|
82
|
-
setMainThreadHydrating(
|
|
67
|
+
setMainThreadHydrating(true);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
69
|
+
try {
|
|
70
|
+
for (const { snapshotPatch, id } of patchList) {
|
|
71
|
+
__pendingListUpdates.clearAttachedLists();
|
|
72
|
+
if (snapshotPatch) {
|
|
73
|
+
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
74
|
+
}
|
|
75
|
+
__pendingListUpdates.flush();
|
|
76
|
+
// console.debug('********** Lepus updatePatch:');
|
|
77
|
+
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
markTiming('patchChangesEnd');
|
|
81
|
+
markTiming('mtsRenderEnd');
|
|
82
|
+
if (patchOptions.isHydration) {
|
|
83
|
+
setMainThreadHydrating(false);
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
applyRefQueue();
|
|
87
|
+
if (delayedRunOnMainThreadData && isMtsEnabled()) {
|
|
88
|
+
setEomShouldFlushElementTree(false);
|
|
89
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
90
|
+
try {
|
|
91
|
+
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
92
|
+
/* v8 ignore next 3 */
|
|
93
|
+
} catch (e) {
|
|
94
|
+
lynx.reportError(e as Error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
setEomShouldFlushElementTree(true);
|
|
98
|
+
}
|
|
99
|
+
if (patchOptions.pipelineOptions) {
|
|
100
|
+
flushOptions.pipelineOptions = patchOptions.pipelineOptions;
|
|
101
|
+
}
|
|
102
|
+
__FlushElementTree(__page, flushOptions);
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (flowIds) {
|
|
105
|
+
lynx.performance.profileEnd();
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
setPipeline(undefined);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -17,26 +17,6 @@ export interface ListUpdateInfo {
|
|
|
17
17
|
onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// class ListUpdateInfoDiffing implements ListUpdateInfo {
|
|
21
|
-
// private oldChildNodes: SnapshotInstance[];
|
|
22
|
-
// constructor(private list: SnapshotInstance) {
|
|
23
|
-
// this.oldChildNodes = list.childNodes;
|
|
24
|
-
// }
|
|
25
|
-
// flush(): void {
|
|
26
|
-
// Object.defineProperty(SnapshotInstance.prototype, "key", {
|
|
27
|
-
// get: function () {
|
|
28
|
-
// return this.values[0]["item-key"];
|
|
29
|
-
// },
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
|
-
// }
|
|
33
|
-
// onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}
|
|
34
|
-
// onRemoveChild(child: SnapshotInstance): void {}
|
|
35
|
-
// onSetAttribute(child: SnapshotInstance, attr: any): void {
|
|
36
|
-
// throw new Error("Method not implemented.");
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
20
|
interface InsertAction {
|
|
41
21
|
position: number;
|
|
42
22
|
type: string;
|
|
@@ -58,30 +38,14 @@ interface ListOperations {
|
|
|
58
38
|
export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
59
39
|
constructor(private list: SnapshotInstance) {
|
|
60
40
|
this.oldChildNodes = list.childNodes;
|
|
61
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
62
41
|
}
|
|
63
42
|
|
|
64
|
-
// private __commitAndReset() {
|
|
65
|
-
// (this.__pendingAttributes ??= []).push(this.__toAttribute());
|
|
66
|
-
// this.oldChildNodes = this.list.childNodes;
|
|
67
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
68
|
-
// this.removeChild1.clear();
|
|
69
|
-
// this.removeChild2.clear();
|
|
70
|
-
// this.insertBefore.clear();
|
|
71
|
-
// this.appendChild.length = 0;
|
|
72
|
-
// this.platformInfoUpdate.clear();
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
43
|
flush(): undefined | number {
|
|
76
44
|
if (!this.list.__elements) {
|
|
77
45
|
return undefined;
|
|
78
46
|
}
|
|
79
47
|
const elementIndex = this.list.__snapshot_def.slot[0]![1];
|
|
80
48
|
const listElement = this.list.__elements[elementIndex]!;
|
|
81
|
-
// this.__pendingAttributes?.forEach(pendingAttribute => {
|
|
82
|
-
// __SetAttribute(listElement, "update-list-info", pendingAttribute);
|
|
83
|
-
// __FlushElementTree(listElement);
|
|
84
|
-
// });
|
|
85
49
|
const updateListInfo = this.__toAttribute();
|
|
86
50
|
|
|
87
51
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -132,7 +96,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
132
96
|
}
|
|
133
97
|
|
|
134
98
|
private oldChildNodes: SnapshotInstance[];
|
|
135
|
-
// private oldChildNodesSet: Set<SnapshotInstance>;
|
|
136
99
|
private removeChild = new Set<SnapshotInstance>();
|
|
137
100
|
private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K
|
|
138
101
|
private appendChild = [] as SnapshotInstance[];
|
|
@@ -140,15 +103,9 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
140
103
|
|
|
141
104
|
onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {
|
|
142
105
|
if (newNode.parentNode) {
|
|
143
|
-
// if (!this.oldChildNodesSet.has(newNode)) {
|
|
144
|
-
// this.__commitAndReset();
|
|
145
|
-
// }
|
|
146
106
|
this.removeChild.add(newNode);
|
|
147
107
|
}
|
|
148
108
|
if (existingNode) {
|
|
149
|
-
// if (!this.oldChildNodesSet.has(existingNode)) {
|
|
150
|
-
// this.__commitAndReset();
|
|
151
|
-
// }
|
|
152
109
|
const newChildren = this.insertBefore.get(existingNode) ?? [];
|
|
153
110
|
newChildren.push(newNode);
|
|
154
111
|
this.insertBefore.set(existingNode, newChildren);
|
|
@@ -158,9 +115,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
158
115
|
}
|
|
159
116
|
|
|
160
117
|
onRemoveChild(child: SnapshotInstance): void {
|
|
161
|
-
// if (!this.oldChildNodesSet.has(child)) {
|
|
162
|
-
// this.__commitAndReset();
|
|
163
|
-
// }
|
|
164
118
|
this.removeChild.add(child);
|
|
165
119
|
}
|
|
166
120
|
|
|
@@ -254,12 +208,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
254
208
|
}
|
|
255
209
|
|
|
256
210
|
toJSON(): [ListOperations] {
|
|
257
|
-
// if (this.__pendingAttributes) {
|
|
258
|
-
// return [...this.__pendingAttributes, this.__toAttribute()];
|
|
259
|
-
// } else {
|
|
260
|
-
// return [this.__toAttribute()];
|
|
261
|
-
// }
|
|
262
|
-
|
|
263
211
|
return [this.__toAttribute()] as const;
|
|
264
212
|
}
|
|
265
213
|
}
|
|
@@ -138,7 +138,7 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
138
138
|
|
|
139
139
|
setPipeline(options?.pipelineOptions);
|
|
140
140
|
markTiming('updateDiffVdomStart');
|
|
141
|
-
{
|
|
141
|
+
try {
|
|
142
142
|
__pendingListUpdates.clearAttachedLists();
|
|
143
143
|
renderMainThread();
|
|
144
144
|
// As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,
|
|
@@ -152,17 +152,19 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
152
152
|
// always call this before `__FlushElementTree`
|
|
153
153
|
__pendingListUpdates.flush();
|
|
154
154
|
applyRefQueue();
|
|
155
|
-
}
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
|
|
157
|
+
onFirstScreenTreeReady();
|
|
158
|
+
}
|
|
160
159
|
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
flushOptions.triggerDataUpdated = true;
|
|
161
|
+
markTiming('updateDiffVdomEnd');
|
|
163
162
|
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
if (typeof lepusng_gc === 'function') {
|
|
164
|
+
lepusng_gc();
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
setPipeline(undefined);
|
|
166
168
|
}
|
|
167
169
|
}
|
|
168
170
|
|
|
@@ -99,64 +99,6 @@ export function diffArrayLepus<A extends Typed, B extends Typed>(
|
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// export function diffIterableLepus<A extends Typed, B extends Typed>(
|
|
103
|
-
// before: A[],
|
|
104
|
-
// after: Iterable<B>,
|
|
105
|
-
// isSameType: (a: A, b: B) => boolean,
|
|
106
|
-
// onDiffChildren: (a: A, b: B) => void
|
|
107
|
-
// ): DiffResult<B> {
|
|
108
|
-
// let returnResult = EMPTY_DIFF_RESULT as DiffResult<B>;
|
|
109
|
-
// let lastPlacedIndex = 0;
|
|
110
|
-
// const result: DiffResult<B> = {
|
|
111
|
-
// $$diff: true,
|
|
112
|
-
// i: {},
|
|
113
|
-
// r: [],
|
|
114
|
-
// m: {},
|
|
115
|
-
// };
|
|
116
|
-
// const beforeMap: Record<string, Set<[A, number]>> = {};
|
|
117
|
-
|
|
118
|
-
// for (let i = 0; i < before.length; i++) {
|
|
119
|
-
// let node = before[i];
|
|
120
|
-
// (beforeMap[node.type] ??= new Set()).add([node, i]);
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
// let i = 0;
|
|
124
|
-
// for (const afterNode of after) {
|
|
125
|
-
// const beforeNodes = beforeMap[afterNode.type];
|
|
126
|
-
// let beforeNode: [A, number];
|
|
127
|
-
|
|
128
|
-
// if (beforeNodes && (([beforeNode] = beforeNodes), beforeNode) && isSameType(beforeNode[0], afterNode)) {
|
|
129
|
-
// // Reuse old node
|
|
130
|
-
// beforeNodes.delete(beforeNode);
|
|
131
|
-
|
|
132
|
-
// const oldIndex = beforeNode[1];
|
|
133
|
-
// onDiffChildren(beforeNode[0], afterNode);
|
|
134
|
-
// if (oldIndex < lastPlacedIndex) {
|
|
135
|
-
// result.m[oldIndex] = i;
|
|
136
|
-
// returnResult = result;
|
|
137
|
-
// i++;
|
|
138
|
-
// continue;
|
|
139
|
-
// } else {
|
|
140
|
-
// lastPlacedIndex = oldIndex;
|
|
141
|
-
// }
|
|
142
|
-
// } else {
|
|
143
|
-
// // Create new node
|
|
144
|
-
// result.i[i] = afterNode;
|
|
145
|
-
// returnResult = result;
|
|
146
|
-
// }
|
|
147
|
-
// i++;
|
|
148
|
-
// }
|
|
149
|
-
// // delete
|
|
150
|
-
// for (const k in beforeMap) {
|
|
151
|
-
// for (const [, i] of beforeMap[k]) {
|
|
152
|
-
// result.r.push(i);
|
|
153
|
-
// returnResult = result;
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// return result;
|
|
158
|
-
// }
|
|
159
|
-
|
|
160
102
|
export function diffArrayAction<T, K>(
|
|
161
103
|
before: T[],
|
|
162
104
|
diffResult: DiffResult<K>,
|
|
@@ -39,7 +39,7 @@ const isArray = /* @__PURE__ */ Array.isArray;
|
|
|
39
39
|
const assign = /* @__PURE__ */ Object.assign;
|
|
40
40
|
|
|
41
41
|
// Global state for the current render pass
|
|
42
|
-
let beforeDiff, beforeDiff2, afterDiff, renderHook,
|
|
42
|
+
let beforeDiff, beforeDiff2, afterDiff, renderHook, unmountHook;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Render Preact JSX + Components to an HTML string.
|
|
@@ -60,7 +60,7 @@ export function renderToString(vnode: any, context: any, into: SnapshotInstance)
|
|
|
60
60
|
beforeDiff2 = options[DIFF2];
|
|
61
61
|
afterDiff = options[DIFFED];
|
|
62
62
|
renderHook = options[RENDER];
|
|
63
|
-
|
|
63
|
+
unmountHook = options.unmount;
|
|
64
64
|
|
|
65
65
|
const parent = h(Fragment, null);
|
|
66
66
|
parent[CHILDREN] = [vnode];
|
|
@@ -194,7 +194,7 @@ function _renderToString(
|
|
|
194
194
|
opcodes,
|
|
195
195
|
/* v8 ignore start */
|
|
196
196
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
197
|
-
/* v8 ignore
|
|
197
|
+
/* v8 ignore stop */
|
|
198
198
|
into,
|
|
199
199
|
);
|
|
200
200
|
}
|
|
@@ -282,7 +282,7 @@ function _renderToString(
|
|
|
282
282
|
opcodes,
|
|
283
283
|
/* v8 ignore start */
|
|
284
284
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
285
|
-
/* v8 ignore
|
|
285
|
+
/* v8 ignore stop */
|
|
286
286
|
into,
|
|
287
287
|
);
|
|
288
288
|
} catch (e) {
|
|
@@ -312,7 +312,7 @@ function _renderToString(
|
|
|
312
312
|
opcodes,
|
|
313
313
|
/* v8 ignore start */
|
|
314
314
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
315
|
-
/* v8 ignore
|
|
315
|
+
/* v8 ignore stop */
|
|
316
316
|
into,
|
|
317
317
|
);
|
|
318
318
|
}
|
|
@@ -323,7 +323,7 @@ function _renderToString(
|
|
|
323
323
|
if (afterDiff) afterDiff(vnode);
|
|
324
324
|
vnode[PARENT] = undefined;
|
|
325
325
|
|
|
326
|
-
if (
|
|
326
|
+
if (unmountHook) unmountHook(vnode);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
return;
|
|
@@ -406,14 +406,14 @@ function _renderToString(
|
|
|
406
406
|
opcodes,
|
|
407
407
|
/* v8 ignore start */
|
|
408
408
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
409
|
-
/* v8 ignore
|
|
409
|
+
/* v8 ignore stop */
|
|
410
410
|
vnode,
|
|
411
411
|
);
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
if (afterDiff) afterDiff(vnode);
|
|
415
415
|
vnode[PARENT] = undefined;
|
|
416
|
-
if (
|
|
416
|
+
if (unmountHook) unmountHook(vnode);
|
|
417
417
|
|
|
418
418
|
if (__ENABLE_SSR__) {
|
|
419
419
|
opcodes.push(__OpEnd);
|
|
@@ -97,60 +97,3 @@ export function ssrHydrateByOpcodes(
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
// export function renderOpcodesInto(opcodes: any[], into: SnapshotInstance): void {
|
|
102
|
-
// let top: SnapshotInstance = into;
|
|
103
|
-
// const stack: SnapshotInstance[] = [into];
|
|
104
|
-
// for (let i = 0; i < opcodes.length;) {
|
|
105
|
-
// const opcode = opcodes[i];
|
|
106
|
-
// switch (opcode) {
|
|
107
|
-
// case OpcodeBegin: {
|
|
108
|
-
// const p = top;
|
|
109
|
-
// top = opcodes[i + 1];
|
|
110
|
-
// // @ts-ignore
|
|
111
|
-
// if (top.__parent) {
|
|
112
|
-
// // already inserted
|
|
113
|
-
// top = new SnapshotInstance(top.type);
|
|
114
|
-
// opcodes[i + 1] = top;
|
|
115
|
-
// }
|
|
116
|
-
// p.insertBefore(top);
|
|
117
|
-
// stack.push(top);
|
|
118
|
-
|
|
119
|
-
// i += 2;
|
|
120
|
-
// break;
|
|
121
|
-
// }
|
|
122
|
-
// case OpcodeEnd: {
|
|
123
|
-
// // @ts-ignore
|
|
124
|
-
// top[CHILDREN] = undefined;
|
|
125
|
-
|
|
126
|
-
// stack.pop();
|
|
127
|
-
// const p = stack[stack.length - 1];
|
|
128
|
-
// top = p!;
|
|
129
|
-
|
|
130
|
-
// i += 1;
|
|
131
|
-
// break;
|
|
132
|
-
// }
|
|
133
|
-
// case OpcodeAttr: {
|
|
134
|
-
// const key = opcodes[i + 1];
|
|
135
|
-
// const value = opcodes[i + 2];
|
|
136
|
-
// top.setAttribute(key, value);
|
|
137
|
-
|
|
138
|
-
// i += 3;
|
|
139
|
-
// break;
|
|
140
|
-
// }
|
|
141
|
-
// case OpcodeText: {
|
|
142
|
-
// const text = opcodes[i + 1];
|
|
143
|
-
// const s = new SnapshotInstance(null as unknown as string);
|
|
144
|
-
// if (__ENABLE_SSR__) {
|
|
145
|
-
// // We need store the just created SnapshotInstance, or it will be lost when we leave the function
|
|
146
|
-
// opcodes[i + 1] = [s, text];
|
|
147
|
-
// }
|
|
148
|
-
// s.setAttribute(0, text);
|
|
149
|
-
// top.insertBefore(s);
|
|
150
|
-
|
|
151
|
-
// i += 2;
|
|
152
|
-
// break;
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// }
|
|
@@ -28,7 +28,7 @@ import { globalPipelineOptions } from '../../core/performance.js';
|
|
|
28
28
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
29
29
|
import { isDirectOrDeepEqual } from '../../utils.js';
|
|
30
30
|
import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';
|
|
31
|
-
import { prepareGestureForCommit } from '../gesture/
|
|
31
|
+
import { prepareGestureForCommit } from '../gesture/processGestureBackground.js';
|
|
32
32
|
import type { GestureKind } from '../gesture/types.js';
|
|
33
33
|
import { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';
|
|
34
34
|
import {
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Element Template worklet identity
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Element Template Native storage must preserve the original JavaScript worklet
|
|
4
|
+
context in declared main-thread event slots, as Snapshot does. Native may snapshot
|
|
5
|
+
the event wrapper and ordinary attribute data, but it must retain the wrapper's
|
|
6
|
+
`value` as a live MTS object. Background element preparation must exclude live
|
|
7
|
+
event and gesture values from both its task input and prepared result.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
`runWorklet` transforms the context delivered by Native directly. The original
|
|
10
|
+
context and its captured callback objects remain ordinary JavaScript objects
|
|
11
|
+
accepted by `FinalizationRegistry.register`; no context identifier or reverse
|
|
12
|
+
lookup is needed. This runtime requires the corresponding Native storage behavior.
|
|
13
|
+
Older ET Native implementations that deep-copy worklet contexts are unsupported by
|
|
14
|
+
this integration.
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
Track a background input before calling Native. If Native rejects it, collecting
|
|
17
|
+
that input must still release its already-registered background execution. Only
|
|
18
|
+
Native success commits the slot's strong reference and hydration handoff;
|
|
19
|
+
committing does not register the context again. Removal drops the slot's reference.
|
|
20
|
+
Escaped callbacks follow the existing Snapshot capture and GC behavior.
|
|
21
|
+
|
|
22
|
+
Retire the previous lifecycle manager to stop old finalizers from sending release
|
|
23
|
+
events into the new runtime. Native event ingress must reject detached old
|
|
24
|
+
bindings so they cannot dispatch into a replacement runtime; `runWorklet` does not
|
|
25
|
+
reject contexts based on the lifecycle manager that originally retained them.
|
|
26
|
+
Snapshot observers continue to track references through the same lifecycle manager.
|
|
27
|
+
|
|
28
|
+
This integration keeps Snapshot's existing callback transformation, first-screen
|
|
29
|
+
hydration, and delayed-call replay semantics. It does not add per-binding callback
|
|
30
|
+
materialization, shared-capture isolation, or a new delayed queue representation.
|
|
31
|
+
Shared first-screen context mutation and escaped-callback lifetime limitations
|
|
32
|
+
that also occur in Snapshot remain unchanged. Registration atomicity and
|
|
33
|
+
consumed-queue cleanup remain unchanged.
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
|
|
5
|
+
import '../global.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Loads the legacy main-thread worklet chunk or reuses an initialized runtime.
|
|
9
|
+
* @param __schema - The dynamic component entry for loading the Lepus chunk.
|
|
10
|
+
* @returns Whether the worklet runtime was loaded and initialized successfully.
|
|
11
|
+
*/
|
|
12
|
+
function loadWorkletRuntime(__schema?: string): boolean {
|
|
13
|
+
if (typeof __LoadLepusChunk === 'undefined') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (globalThis.lynxWorkletImpl) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return __LoadLepusChunk('worklet-runtime', {
|
|
20
|
+
dynamicComponentEntry: __schema,
|
|
21
|
+
chunkType: 0,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { loadWorkletRuntime };
|