@lynx-js/react 0.123.3 → 0.125.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 +24 -0
- package/package.json +3 -3
- package/runtime/jsx-dev-runtime/index.d.ts +39 -1
- package/runtime/jsx-runtime/index.d.ts +39 -1
- package/runtime/lepus/jsx-runtime/index.js +17 -0
- package/runtime/lib/core/main-thread-function.d.ts +2 -0
- package/runtime/lib/core/main-thread-function.js +10 -0
- package/runtime/lib/core/main-thread-function.js.map +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -0
- package/runtime/lib/core/main-thread-ref-init-value.js +23 -0
- package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -0
- package/runtime/lib/{snapshot/worklet/ref/workletRef.d.ts → core/main-thread-ref.d.ts} +6 -7
- package/runtime/lib/{snapshot/worklet/ref/workletRef.js → core/main-thread-ref.js} +31 -36
- package/runtime/lib/core/main-thread-ref.js.map +1 -0
- package/runtime/lib/core/mts-capability.d.ts +1 -0
- package/runtime/lib/core/mts-capability.js +18 -0
- package/runtime/lib/core/mts-capability.js.map +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +4 -11
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.d.ts +3 -1
- package/runtime/lib/element-template/background/attr-slots.js +3 -3
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.d.ts +9 -0
- package/runtime/lib/element-template/background/commit-hook.js +23 -0
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +6 -4
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +4 -4
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +11 -0
- package/runtime/lib/element-template/background/instance.js +53 -29
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/background/manager.d.ts +1 -0
- package/runtime/lib/element-template/background/manager.js +8 -2
- package/runtime/lib/element-template/background/manager.js.map +1 -1
- package/runtime/lib/element-template/background/page-root-hydrate.d.ts +3 -0
- package/runtime/lib/element-template/background/page-root-hydrate.js +14 -0
- package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -0
- package/runtime/lib/element-template/index.d.ts +1 -0
- package/runtime/lib/element-template/index.js +1 -0
- 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 +1 -2
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +2 -2
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +1 -2
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +2 -2
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +9 -2
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/protocol/page.d.ts +3 -0
- package/runtime/lib/element-template/protocol/page.js +7 -0
- package/runtime/lib/element-template/protocol/page.js.map +1 -0
- package/runtime/lib/element-template/protocol/types.d.ts +6 -1
- package/runtime/lib/element-template/protocol/types.js +1 -0
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/authored-page.d.ts +8 -0
- package/runtime/lib/element-template/runtime/page/authored-page.js +15 -0
- package/runtime/lib/element-template/runtime/page/authored-page.js.map +1 -0
- package/runtime/lib/element-template/runtime/page/page.d.ts +0 -2
- package/runtime/lib/element-template/runtime/page/page.js +2 -10
- package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +5 -3
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.d.ts +1 -3
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +9 -24
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-opcodes.d.ts +2 -0
- package/runtime/lib/element-template/runtime/render/render-opcodes.js +36 -3
- package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +2 -0
- package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +13 -0
- 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 +1 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +7 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +3 -3
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +2 -2
- 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.js +2 -2
- 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-event-ctx.d.ts +0 -1
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js +4 -9
- package/runtime/lib/element-template/runtime/template/main-thread-event-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +9 -0
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +33 -0
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -0
- package/runtime/lib/element-template/runtime/template/registry.js +2 -1
- package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.d.ts +5 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +13 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -0
- 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/snapshot/lifecycle/patch/commit.d.ts +10 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +30 -2
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +9 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/definition.js +4 -2
- package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +8 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js +1 -0
- package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
- package/runtime/lib/snapshot/worklet/destroy.js +2 -2
- package/runtime/lib/snapshot/worklet/destroy.js.map +1 -1
- package/runtime/lib/snapshot/worklet/functionality.d.ts +1 -0
- package/runtime/lib/snapshot/worklet/functionality.js +2 -8
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +2 -2
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/testing-library/dist/env/index.js +3 -0
- package/testing-library/dist/index.d.ts +1 -0
- package/transform/dist/wasm.cjs +5 -5
- package/transform/index.d.ts +40 -0
- package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +0 -1
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.js +0 -23
- package/runtime/lib/snapshot/worklet/ref/workletRefPool.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.125.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add the `<background-only>` element, which renders its `fallback` on the main thread first screen and its children on the background thread. ([#3551](https://github.com/lynx-family/lynx-stack/pull/3551))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Tag main-thread vnodes with `$$typeof: Symbol.for('react.element')` so `isValidElement` recognizes them, matching the background thread. ([#3514](https://github.com/lynx-family/lynx-stack/pull/3514))
|
|
12
|
+
|
|
13
|
+
- Release worklet refs when list items are logically removed while preserving native element recycling. ([#3590](https://github.com/lynx-family/lynx-stack/pull/3590))
|
|
14
|
+
|
|
15
|
+
## 0.124.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Register the snapshot and worklet definitions collected from the background build on the main thread, so a definition the main-thread bundle dropped no longer fails with `Snapshot not found`. ([#3393](https://github.com/lynx-family/lynx-stack/pull/3393))
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Add `compat.transformLegacyEventAttributeNames` to disable legacy event attribute-name conversion independently from other compatibility transforms. ([#3475](https://github.com/lynx-family/lynx-stack/pull/3475))
|
|
24
|
+
|
|
25
|
+
- Fix `snapshotPatchApply failed: ctx not found` when a lazy bundle is loaded during first-screen direct render. ([#3452](https://github.com/lynx-family/lynx-stack/pull/3452))
|
|
26
|
+
|
|
3
27
|
## 0.123.3
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.125.0",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -223,9 +223,9 @@
|
|
|
223
223
|
"preact": "npm:@lynx-js/internal-preact@10.29.1-20260519060144-e6da44c"
|
|
224
224
|
},
|
|
225
225
|
"devDependencies": {
|
|
226
|
-
"@lynx-js/types": "4.
|
|
226
|
+
"@lynx-js/types": "4.1.0",
|
|
227
227
|
"@microsoft/api-extractor": "7.58.12",
|
|
228
|
-
"@types/react": "^19.2.
|
|
228
|
+
"@types/react": "^19.2.18"
|
|
229
229
|
},
|
|
230
230
|
"peerDependencies": {
|
|
231
231
|
"@lynx-js/types": "*",
|
|
@@ -19,5 +19,43 @@ export namespace JSX {
|
|
|
19
19
|
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
|
|
20
20
|
interface IntrinsicAttributes {}
|
|
21
21
|
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
22
|
-
interface IntrinsicElements extends Lynx.IntrinsicElements {
|
|
22
|
+
interface IntrinsicElements extends Lynx.IntrinsicElements {
|
|
23
|
+
/**
|
|
24
|
+
* Renders `fallback` on the main thread and `children` on the background thread.
|
|
25
|
+
*
|
|
26
|
+
* Resolved at compile time, so the main thread renders only `fallback`. Modules
|
|
27
|
+
* that nothing but `children` reference leave its bundle, including their
|
|
28
|
+
* top-level side effects, while the element definitions the deferred subtree
|
|
29
|
+
* needs stay behind so it can hydrate. The background thread renders `children`,
|
|
30
|
+
* which replace the fallback once it takes over.
|
|
31
|
+
*
|
|
32
|
+
* Only the `fallback` attribute is supported. Spread attributes are a build error.
|
|
33
|
+
*
|
|
34
|
+
* The fold is the same in development, so what renders there is what renders in
|
|
35
|
+
* production, at the cost of the deferred modules not being refreshable on the
|
|
36
|
+
* main thread.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <view>
|
|
41
|
+
* <background-only fallback={<Skeleton />}>
|
|
42
|
+
* <Feed />
|
|
43
|
+
* </background-only>
|
|
44
|
+
* </view>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
'background-only': {
|
|
50
|
+
/**
|
|
51
|
+
* Rendered on the main thread first screen in place of `children`.
|
|
52
|
+
* Defaults to rendering nothing.
|
|
53
|
+
*/
|
|
54
|
+
fallback?: React.JSX.Element | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Rendered on the background thread only.
|
|
57
|
+
*/
|
|
58
|
+
children?: React.ReactNode | undefined;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
23
61
|
}
|
|
@@ -22,5 +22,43 @@ export namespace JSX {
|
|
|
22
22
|
key?: React.Key | null | undefined;
|
|
23
23
|
}
|
|
24
24
|
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
25
|
-
interface IntrinsicElements extends Lynx.IntrinsicElements {
|
|
25
|
+
interface IntrinsicElements extends Lynx.IntrinsicElements {
|
|
26
|
+
/**
|
|
27
|
+
* Renders `fallback` on the main thread and `children` on the background thread.
|
|
28
|
+
*
|
|
29
|
+
* Resolved at compile time, so the main thread renders only `fallback`. Modules
|
|
30
|
+
* that nothing but `children` reference leave its bundle, including their
|
|
31
|
+
* top-level side effects, while the element definitions the deferred subtree
|
|
32
|
+
* needs stay behind so it can hydrate. The background thread renders `children`,
|
|
33
|
+
* which replace the fallback once it takes over.
|
|
34
|
+
*
|
|
35
|
+
* Only the `fallback` attribute is supported. Spread attributes are a build error.
|
|
36
|
+
*
|
|
37
|
+
* The fold is the same in development, so what renders there is what renders in
|
|
38
|
+
* production, at the cost of the deferred modules not being refreshable on the
|
|
39
|
+
* main thread.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <view>
|
|
44
|
+
* <background-only fallback={<Skeleton />}>
|
|
45
|
+
* <Feed />
|
|
46
|
+
* </background-only>
|
|
47
|
+
* </view>
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
'background-only': {
|
|
53
|
+
/**
|
|
54
|
+
* Rendered on the main thread first screen in place of `children`.
|
|
55
|
+
* Defaults to rendering nothing.
|
|
56
|
+
*/
|
|
57
|
+
fallback?: React.JSX.Element | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Rendered on the background thread only.
|
|
60
|
+
*/
|
|
61
|
+
children?: React.ReactNode | undefined;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
26
64
|
}
|
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { CHILDREN, COMPONENT, DIFF, DIRTY, DOM, FLAGS, INDEX, PARENT, SnapshotInstance } from '@lynx-js/react/internal';
|
|
5
5
|
|
|
6
|
+
// Kept in sync with `REACT_ELEMENT_TYPE` in preact/compat, whose `isValidElement`
|
|
7
|
+
// compares against it. Inlined rather than imported so the main thread does not
|
|
8
|
+
// have to pull in compat.
|
|
9
|
+
const REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
10
|
+
|
|
11
|
+
// A SnapshotInstance is the main thread's element, so it has to satisfy
|
|
12
|
+
// `isValidElement` too. Assigning per instance would add a property after the
|
|
13
|
+
// constructor has run, which costs a shape transition on a hot path, so put it
|
|
14
|
+
// on the prototype instead. Writable, so that the `$$typeof: undefined` in
|
|
15
|
+
// `renderToOpcodes` can still shadow it.
|
|
16
|
+
Object.defineProperty(SnapshotInstance.prototype, '$$typeof', {
|
|
17
|
+
value: REACT_ELEMENT_TYPE,
|
|
18
|
+
writable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
6
22
|
function createVNode(type, props, _key) {
|
|
7
23
|
if (typeof type === 'string') {
|
|
8
24
|
const r = new SnapshotInstance(type);
|
|
@@ -58,6 +74,7 @@ function createVNode(type, props, _key) {
|
|
|
58
74
|
// __v: --vnodeId,
|
|
59
75
|
[INDEX]: -1,
|
|
60
76
|
[FLAGS]: 0,
|
|
77
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
61
78
|
};
|
|
62
79
|
}
|
|
63
80
|
}
|
|
@@ -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 function isMainThreadFunction(value) {
|
|
5
|
+
return value != null
|
|
6
|
+
&& typeof value === 'object'
|
|
7
|
+
&& !Array.isArray(value)
|
|
8
|
+
&& typeof value._wkltId === 'string';
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=main-thread-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-function.js","sourceRoot":"","sources":["../../src/core/main-thread-function.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,IAAI,IAAI;WACf,OAAO,KAAK,KAAK,QAAQ;WACzB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;WACrB,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MainThreadRefInitValuePatch = [id: number, value: unknown][];
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { isMtsEnabled } from './mts-capability.js';
|
|
5
|
+
let mainThreadRefInitValuePatch = [];
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function addMainThreadRefInitValue(id, value) {
|
|
10
|
+
if (!isMtsEnabled()) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
mainThreadRefInitValuePatch.push([id, value]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export function takeMainThreadRefInitValuePatch() {
|
|
19
|
+
const patch = mainThreadRefInitValuePatch;
|
|
20
|
+
mainThreadRefInitValuePatch = [];
|
|
21
|
+
return patch;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=main-thread-ref-init-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-ref-init-value.js","sourceRoot":"","sources":["../../src/core/main-thread-ref-init-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,IAAI,2BAA2B,GAAgC,EAAE,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,EAAU,EAAE,KAAc;IAClE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IAED,2BAA2B,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC7C,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,2BAA2B,GAAG,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
set current(_: T);
|
|
6
|
-
}
|
|
2
|
+
import type { WorkletRefImpl } from '../worklet-runtime/bindings/types.js';
|
|
3
|
+
export declare function clearMainThreadRefLastIdForTesting(): void;
|
|
4
|
+
export declare function isMainThreadRef(value: unknown): value is WorkletRefImpl<unknown>;
|
|
7
5
|
/**
|
|
8
6
|
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
9
7
|
* states between main thread function calls.
|
|
@@ -11,8 +9,10 @@ declare abstract class WorkletRef<T> {
|
|
|
11
9
|
* multiple main thread functions.
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
|
-
export declare class MainThreadRef<T>
|
|
12
|
+
export declare class MainThreadRef<T> {
|
|
15
13
|
constructor(initValue: T);
|
|
14
|
+
get current(): T;
|
|
15
|
+
set current(_: T);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Create A `MainThreadRef`.
|
|
@@ -129,4 +129,3 @@ export declare function useMainThreadRef<T>(initValue: T | null): RefObject<T>;
|
|
|
129
129
|
* @public
|
|
130
130
|
*/
|
|
131
131
|
export declare function useMainThreadRef<T = undefined>(): MainThreadRef<T | undefined>;
|
|
132
|
-
export {};
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
// Split into two variables for testing purposes
|
|
1
|
+
import { useMemo } from './hooks/react.js';
|
|
2
|
+
import { addMainThreadRefInitValue } from './main-thread-ref-init-value.js';
|
|
3
|
+
import { WorkletEvents } from '../worklet-runtime/bindings/events.js';
|
|
4
|
+
// Split into two variables for testing purposes.
|
|
5
5
|
let lastIdBG = 0;
|
|
6
6
|
let lastIdMT = 0;
|
|
7
|
-
export function
|
|
7
|
+
export function clearMainThreadRefLastIdForTesting() {
|
|
8
8
|
lastIdBG = lastIdMT = 0;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
export function isMainThreadRef(value) {
|
|
11
|
+
return typeof value === 'object'
|
|
12
|
+
&& value !== null
|
|
13
|
+
&& typeof value._wvid === 'number';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
17
|
+
* states between main thread function calls.
|
|
18
|
+
* The data saved in `current` property of the `MainThreadRef` can be read and written in
|
|
19
|
+
* multiple main thread functions.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export class MainThreadRef {
|
|
11
23
|
/**
|
|
12
24
|
* @internal
|
|
13
25
|
*/
|
|
@@ -24,15 +36,21 @@ class WorkletRef {
|
|
|
24
36
|
* @internal
|
|
25
37
|
*/
|
|
26
38
|
_lifecycleObserver;
|
|
27
|
-
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
constructor(initValue, type) {
|
|
39
|
+
constructor(initValue) {
|
|
31
40
|
this._initValue = initValue;
|
|
32
|
-
this._type =
|
|
41
|
+
this._type = 'main-thread';
|
|
33
42
|
if (__JS__) {
|
|
34
43
|
this._wvid = ++lastIdBG;
|
|
35
|
-
|
|
44
|
+
addMainThreadRefInitValue(this._wvid, initValue);
|
|
45
|
+
const id = this._wvid;
|
|
46
|
+
this._lifecycleObserver = lynx.getNativeApp().createJSObjectDestructionObserver?.(() => {
|
|
47
|
+
lynx.getCoreContext?.().dispatchEvent({
|
|
48
|
+
type: WorkletEvents.releaseWorkletRef,
|
|
49
|
+
data: {
|
|
50
|
+
id,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
});
|
|
36
54
|
}
|
|
37
55
|
else {
|
|
38
56
|
this._wvid = --lastIdMT;
|
|
@@ -65,32 +83,9 @@ class WorkletRef {
|
|
|
65
83
|
};
|
|
66
84
|
}
|
|
67
85
|
}
|
|
68
|
-
/**
|
|
69
|
-
* A `MainThreadRef` is a ref that can only be accessed on the main thread. It is used to preserve
|
|
70
|
-
* states between main thread function calls.
|
|
71
|
-
* The data saved in `current` property of the `MainThreadRef` can be read and written in
|
|
72
|
-
* multiple main thread functions.
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
export class MainThreadRef extends WorkletRef {
|
|
76
|
-
constructor(initValue) {
|
|
77
|
-
super(initValue, 'main-thread');
|
|
78
|
-
if (__JS__) {
|
|
79
|
-
const id = this._wvid;
|
|
80
|
-
this._lifecycleObserver = lynx.getNativeApp().createJSObjectDestructionObserver?.(() => {
|
|
81
|
-
lynx.getCoreContext?.().dispatchEvent({
|
|
82
|
-
type: WorkletEvents.releaseWorkletRef,
|
|
83
|
-
data: {
|
|
84
|
-
id,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
86
|
export function useMainThreadRef(initValue) {
|
|
92
87
|
return useMemo(() => {
|
|
93
88
|
return new MainThreadRef(initValue);
|
|
94
89
|
}, []);
|
|
95
90
|
}
|
|
96
|
-
//# sourceMappingURL=
|
|
91
|
+
//# sourceMappingURL=main-thread-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-ref.js","sourceRoot":"","sources":["../../src/core/main-thread-ref.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAGtE,iDAAiD;AACjD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAM,UAAU,kCAAkC;IAChD,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ;WAC3B,KAAK,KAAK,IAAI;WACd,OAAQ,KAA6B,CAAC,KAAK,KAAK,QAAQ,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IACxB;;OAEG;IACO,KAAK,CAAS;IACxB;;OAEG;IACO,UAAU,CAAgB;IACpC;;OAEG;IACO,KAAK,CAAS;IACxB;;OAEG;IACO,kBAAkB,CAAU;IAEtC,YAAY,SAAY;QACtB,IAAI,CAAC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J,CAAC;CACF;AA2HD,MAAM,UAAU,gBAAgB,CAAI,SAAa;IAC/C,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { isSdkVersionGt } from '../utils.js';
|
|
5
|
+
let mtsEnabled;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function isMtsEnabled() {
|
|
10
|
+
return mtsEnabled ??= isSdkVersionGt(2, 13);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export function clearMtsConfigCacheForTesting() {
|
|
16
|
+
mtsEnabled = undefined;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=mts-capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mts-capability.js","sourceRoot":"","sources":["../../src/core/mts-capability.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,IAAI,UAA+B,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,KAAK,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B;IAC3C,UAAU,GAAG,SAAS,CAAC;AACzB,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { onFunctionCall } from './return-value.js';
|
|
|
5
5
|
import { isSdkVersionGt } from '../../utils.js';
|
|
6
6
|
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
7
7
|
import { registerBackgroundFunctionCtx } from '../background-function/run-on-background.js';
|
|
8
|
+
import { isMainThreadFunction } from '../main-thread-function.js';
|
|
9
|
+
import { isMtsEnabled } from '../mts-capability.js';
|
|
8
10
|
export let delayedRunOnMainThreadData = [];
|
|
9
11
|
export function enqueueDelayedRunOnMainThreadData(data) {
|
|
10
12
|
delayedRunOnMainThreadData.push(data);
|
|
@@ -22,7 +24,7 @@ export function createRunOnMainThread(options) {
|
|
|
22
24
|
if (__LEPUS__) {
|
|
23
25
|
throw new Error('runOnMainThread can only be used on the background thread.');
|
|
24
26
|
}
|
|
25
|
-
if (!
|
|
27
|
+
if (!isMtsEnabled()) {
|
|
26
28
|
throw new Error('runOnMainThread requires Lynx sdk version 2.14.');
|
|
27
29
|
}
|
|
28
30
|
return async (...params) => {
|
|
@@ -43,20 +45,11 @@ export function createRunOnMainThread(options) {
|
|
|
43
45
|
};
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
function isMainThreadFunctionSupported() {
|
|
47
|
-
return isSdkVersionGt(2, 13);
|
|
48
|
-
}
|
|
49
48
|
function isRunOnBackgroundSupported() {
|
|
50
49
|
return isSdkVersionGt(2, 15);
|
|
51
50
|
}
|
|
52
|
-
function isMainThreadFunctionCtx(value) {
|
|
53
|
-
return value != null
|
|
54
|
-
&& typeof value === 'object'
|
|
55
|
-
&& !Array.isArray(value)
|
|
56
|
-
&& typeof value._wkltId === 'string';
|
|
57
|
-
}
|
|
58
51
|
function prepareMainThreadFunctionCtx(worklet) {
|
|
59
|
-
if (
|
|
52
|
+
if (isMainThreadFunction(worklet) && isRunOnBackgroundSupported()) {
|
|
60
53
|
registerBackgroundFunctionCtx(worklet);
|
|
61
54
|
}
|
|
62
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread.js","sourceRoot":"","sources":["../../../src/core/thread-function-call/main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"main-thread.js","sourceRoot":"","sources":["../../../src/core/thread-function-call/main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,CAAC,IAAI,0BAA0B,GAAwB,EAAE,CAAC;AAEhE,MAAM,UAAU,iCAAiC,CAAC,IAAuB;IACvE,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,MAAM,IAAI,GAAG,0BAA0B,CAAC;IACxC,0BAA0B,GAAG,EAAE,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA+B;IAE/B,OAAO,CAAsC,EAAM,EAA2C,EAAE;QAC9F,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,KAAK,EAAE,GAAG,MAAsB,EAAc,EAAE;YACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,MAAM,OAAO,GAAG,EAAwB,CAAC;gBACzC,4BAA4B,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM,IAAI,GAAG;oBACX,OAAO;oBACP,MAAM;oBACN,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC;iBACd,CAAC;gBAEvB,IAAI,OAAO,CAAC,qCAAqC,EAAE,EAAE,CAAC;oBACpD,4BAA4B,CAAC,IAAI,CAAC,CAAC;oBACnC,OAAO;gBACT,CAAC;gBAED,iCAAiC,CAAC,IAAI,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B;IACjC,OAAO,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,4BAA4B,CAAC,OAAgB;IACpD,IAAI,oBAAoB,CAAC,OAAO,CAAC,IAAI,0BAA0B,EAAE,EAAE,CAAC;QAClE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAuB;IAC3D,IAAI,CAAC,cAAc,EAAE,CAAC,aAAa,CAAC;QAClC,IAAI,EAAE,aAAa,CAAC,aAAa;QACjC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { SerializableValue } from '../protocol/types.js';
|
|
2
|
+
import type { EtAttrPlan } from '../runtime/template/attr-slot-plan.js';
|
|
2
3
|
export interface PrepareAttributeSlotsOptions {
|
|
3
4
|
previousPreparedSlots?: readonly unknown[];
|
|
4
5
|
previousRawSlots?: readonly unknown[];
|
|
6
|
+
attributePlan?: EtAttrPlan | undefined;
|
|
5
7
|
}
|
|
6
8
|
export declare function prepareAttributeSlots(templateKey: string, handleId: number, rawSlots: readonly unknown[], options?: PrepareAttributeSlotsOptions): SerializableValue[];
|
|
7
|
-
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[]): void;
|
|
9
|
+
export declare function queueRefAttributeSlotUpdates(templateKey: string, handleId: number, previousRawSlots?: readonly unknown[], nextRawSlots?: readonly unknown[], attributePlan?: EtAttrPlan): void;
|
|
@@ -34,7 +34,7 @@ function queuePlannedRefAttributeSlotUpdates(handleId, attrPlan, previousRawSlot
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
export function prepareAttributeSlots(templateKey, handleId, rawSlots, options) {
|
|
37
|
-
const attrPlan = __etAttrPlanMap[templateKey];
|
|
37
|
+
const attrPlan = options?.attributePlan ?? __etAttrPlanMap[templateKey];
|
|
38
38
|
if (!attrPlan || attrPlan.length === 0) {
|
|
39
39
|
return normalizeAttributeSlots(rawSlots);
|
|
40
40
|
}
|
|
@@ -58,8 +58,8 @@ export function prepareAttributeSlots(templateKey, handleId, rawSlots, options)
|
|
|
58
58
|
}
|
|
59
59
|
return preparedSlots;
|
|
60
60
|
}
|
|
61
|
-
export function queueRefAttributeSlotUpdates(templateKey, handleId, previousRawSlots, nextRawSlots) {
|
|
62
|
-
const attrPlan = __etAttrPlanMap[templateKey];
|
|
61
|
+
export function queueRefAttributeSlotUpdates(templateKey, handleId, previousRawSlots, nextRawSlots, attributePlan) {
|
|
62
|
+
const attrPlan = attributePlan ?? __etAttrPlanMap[templateKey];
|
|
63
63
|
if (!attrPlan || attrPlan.length === 0) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"attr-slots.js","sourceRoot":"","sources":["../../../src/element-template/background/attr-slots.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAS/G,SAAS,uBAAuB,CAAC,QAA4B;IAC3D,IAAI,eAAgD,CAAC;IACrD,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QACD,eAAe,KAAK,QAAQ,CAAC,KAAK,EAAyB,CAAC;QAC5D,eAAe,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,eAAe,IAAI,QAA+B,CAAC;AAC5D,CAAC;AAED,SAAS,mCAAmC,CAC1C,QAAgB,EAChB,QAA6C,EAC7C,gBAAqC,EACrC,YAAiC;IAEjC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAW,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,G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c,GAAqC,qBAAqB,IAAI,gBAAgB;QAChG,CAAC,CAAC;YACA,qBAAqB;YACrB,gBAAgB;SACjB;QACD,CAAC,CAAC,SAAS,CAAC;IACd,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAW,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAkB,CAAC;QACzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;QACzC,aAAa,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC5F,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,WAAmB,EACnB,QAAgB,EAChB,gBAAqC,EACrC,YAAiC,EACjC,aAA0B;IAE1B,MAAM,QAAQ,GAAG,aAAa,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;IAC/D,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"}
|
|
@@ -5,3 +5,12 @@ export declare function resetElementTemplateCommitState(): void;
|
|
|
5
5
|
export declare function scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[]): void;
|
|
6
6
|
export declare function cancelElementTemplateRemovedSubtreeCleanup(): void;
|
|
7
7
|
export declare function installElementTemplateCommitHook(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Restores the commit option replaced by
|
|
10
|
+
* {@link installElementTemplateCommitHook} so tests can clean up the global
|
|
11
|
+
* Preact `options` object. Assumes the matching install was the most recent
|
|
12
|
+
* commit-option replacement; the snapshot and ElementTemplate runtimes are
|
|
13
|
+
* separate entrypoints and never install their commit hooks in the same
|
|
14
|
+
* context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function uninstallElementTemplateCommitHookForTesting(): void;
|
|
@@ -15,6 +15,7 @@ import { profileEnd, profileStart } from '../debug/profile.js';
|
|
|
15
15
|
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
16
16
|
import { createElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
17
17
|
let installed = false;
|
|
18
|
+
let previousCommit;
|
|
18
19
|
let hasHydrated = false;
|
|
19
20
|
const scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set();
|
|
20
21
|
export function markElementTemplateHydrated() {
|
|
@@ -122,6 +123,7 @@ export function installElementTemplateCommitHook() {
|
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
installed = true;
|
|
126
|
+
previousCommit = options[COMMIT];
|
|
125
127
|
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
126
128
|
if (__BACKGROUND__) {
|
|
127
129
|
clearElementTemplateRenderScope();
|
|
@@ -141,4 +143,25 @@ export function installElementTemplateCommitHook() {
|
|
|
141
143
|
originalCommit?.(vnode, commitQueue);
|
|
142
144
|
});
|
|
143
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Restores the commit option replaced by
|
|
148
|
+
* {@link installElementTemplateCommitHook} so tests can clean up the global
|
|
149
|
+
* Preact `options` object. Assumes the matching install was the most recent
|
|
150
|
+
* commit-option replacement; the snapshot and ElementTemplate runtimes are
|
|
151
|
+
* separate entrypoints and never install their commit hooks in the same
|
|
152
|
+
* context.
|
|
153
|
+
*/
|
|
154
|
+
export function uninstallElementTemplateCommitHookForTesting() {
|
|
155
|
+
if (!installed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
installed = false;
|
|
159
|
+
if (previousCommit) {
|
|
160
|
+
options[COMMIT] = previousCommit;
|
|
161
|
+
previousCommit = undefined;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
delete options[COMMIT];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
144
167
|
//# sourceMappingURL=commit-hook.js.map
|
|
@@ -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,+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,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,W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AE,MAAM;qBACvE,EACD,IAAI,EACJ,CAAC,CACF,CACJ,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,cAAc,EAAE,CAAC,aAAa,CAAC,gCAAgC,CAAC;gBACnE,GAAG,EAAE,mBAAmB,CAAC,GAAG;gBAC5B,YAAY,EAAE,mBAAmB,CAAC,YAAY;gBAC9C,aAAa,EAAE,gBAAgB,EAAE;gBACjC,OAAO,EAAE,mBAAmB,CAAC,OAAO;gBACpC,0BAA0B,EAAE,6BAA6B;aAC1D,CAAC,CAAC,CAAC;YACJ,wBAAwB,GAAG,IAAI,CAAC;QAClC,CAAC;QACD,0EAA0E;QAC1E,0EAA0E;QAC1E,gBAAgB,EAAE,CAAC;QACnB,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;YAAS,CAAC;QACT,IAAI,6BAA6B,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC/D,yBAAyB,CAAC,6BAA6B,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACvF,CAAC;QACD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,gBAAgB,EAAE,CAAC;QACrB,CAAC;QACD,wBAAwB,EAAE,CAAC;QAC3B,qEAAqE;QACrE,sEAAsE;QACtE,gEAAgE;QAChE,4CAA4C,CAAC,+BAA+B,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gCAAgC;IAC9C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IACD,SAAS,GAAG,IAAI,CAAC;
|
|
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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;;;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -7,18 +7,17 @@ import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
|
7
7
|
import { isDirectOrDeepEqual } from '../../utils.js';
|
|
8
8
|
import { hydrationMap } from '../hydration-map.js';
|
|
9
9
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
10
|
+
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';
|
|
10
11
|
import { elementTemplateIdentityKey, parseElementTemplateType } from '../protocol/template-type.js';
|
|
11
12
|
import { __etAttrPlanMap, adaptMTEventAttrSlot } from '../runtime/template/attr-slot-plan.js';
|
|
12
13
|
import { isMTEventNativeWrapper } from '../runtime/template/main-thread-event-ctx.js';
|
|
13
14
|
const MAIN_BUNDLE_URL_SENTINEL = '__Card__';
|
|
14
|
-
const PAGE_ROOT_TARGET_HANDLE_ID = 0;
|
|
15
|
-
const PAGE_ROOT_SLOT_ID = 0;
|
|
16
15
|
const COMPONENT_AT_INDEX_ATTR = 'component-at-index';
|
|
17
16
|
const COMPONENT_AT_INDEXES_ATTR = 'component-at-indexes';
|
|
18
17
|
const ENQUEUE_COMPONENT_ATTR = 'enqueue-component';
|
|
19
18
|
const UPDATE_LIST_INFO_ATTR = 'update-list-info';
|
|
20
19
|
export function hydrateRootChildrenIntoContext(serializedChildren, root) {
|
|
21
|
-
return hydrateChildListIntoContext(
|
|
20
|
+
return hydrateChildListIntoContext(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, serializedChildren, root.childNodes);
|
|
22
21
|
}
|
|
23
22
|
function isSerializedCompiledNode(serialized) {
|
|
24
23
|
return typeof serialized.templateKey === 'string';
|
|
@@ -297,7 +296,10 @@ function collectRemovableSerializedSubtreeHandleIdsInto(serialized, handles) {
|
|
|
297
296
|
}
|
|
298
297
|
function getRemovableSerializedHandleId(serialized) {
|
|
299
298
|
const handleId = serialized.uid;
|
|
300
|
-
if (__DEV__
|
|
299
|
+
if (__DEV__
|
|
300
|
+
&& (typeof handleId !== 'number'
|
|
301
|
+
|| !Number.isInteger(handleId)
|
|
302
|
+
|| handleId === ELEMENT_TEMPLATE_PAGE_HANDLE_ID)) {
|
|
301
303
|
lynx.reportError(new Error(`ElementTemplate hydrate remove received invalid uid ${String(handleId)}.`));
|
|
302
304
|
return null;
|
|
303
305
|
}
|