@lynx-js/react-canary 0.114.0-canary-20250918-a84376fc → 0.114.0-canary-20250918-7cb4d973
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 +3 -1
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/lib/lifecycle/ref/delay.d.ts +9 -4
- package/runtime/lib/lifecycle/ref/delay.js +23 -16
- package/runtime/lib/lifecycle/ref/delay.js.map +1 -1
- package/testing-library/dist/vitest-global-setup.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
-
## 0.114.0-canary-
|
|
3
|
+
## 0.114.0-canary-20250918133146-7cb4d97315f56c5b4f0c5079e987dae1d509c37c
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
- Reduce extra snapshot when children are pure text ([#1562](https://github.com/lynx-family/lynx-stack/pull/1562))
|
|
16
16
|
|
|
17
|
+
- feat: Support `SelectorQuery` `animation` APIs ([#1768](https://github.com/lynx-family/lynx-stack/pull/1768))
|
|
18
|
+
|
|
17
19
|
- Fix spread props inside list-item caused redundant snapshot patch ([#1760](https://github.com/lynx-family/lynx-stack/pull/1760))
|
|
18
20
|
|
|
19
21
|
- fix: `ref is not initialized` error on template reload ([#1757](https://github.com/lynx-family/lynx-stack/pull/1757))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-canary",
|
|
3
|
-
"version": "0.114.0-canary-20250918-
|
|
3
|
+
"version": "0.114.0-canary-20250918-7cb4d973",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { NodesRef } from '@lynx-js/types';
|
|
2
|
+
type FunctionPropertyNames<T> = {
|
|
3
|
+
[K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? K : never;
|
|
4
|
+
}[keyof T];
|
|
5
|
+
type ForwardableNodesRefMethod = Exclude<FunctionPropertyNames<NodesRef>, 'exec'>;
|
|
2
6
|
/**
|
|
3
7
|
* A flag to indicate whether UI operations should be delayed.
|
|
4
8
|
* When set to true, UI operations will be queued in the `delayedUiOps` array
|
|
@@ -22,10 +26,11 @@ declare class RefProxy {
|
|
|
22
26
|
private task;
|
|
23
27
|
constructor(refAttr: [snapshotInstanceId: number, expIndex: number]);
|
|
24
28
|
private setTask;
|
|
25
|
-
invoke(...args: Parameters<NodesRef['invoke']>): RefProxy;
|
|
26
|
-
path(...args: Parameters<NodesRef['path']>): RefProxy;
|
|
27
|
-
fields(...args: Parameters<NodesRef['fields']>): RefProxy;
|
|
28
|
-
setNativeProps(...args: Parameters<NodesRef['setNativeProps']>): RefProxy;
|
|
29
29
|
exec(): void;
|
|
30
30
|
}
|
|
31
|
+
type RefProxyForwardedMethods = {
|
|
32
|
+
[K in ForwardableNodesRefMethod]: (...args: Parameters<NodesRef[K]>) => RefProxy;
|
|
33
|
+
};
|
|
34
|
+
interface RefProxy extends RefProxyForwardedMethods {
|
|
35
|
+
}
|
|
31
36
|
export {};
|
|
@@ -31,11 +31,12 @@ function runOrDelay(task) {
|
|
|
31
31
|
* Executes all delayed UI operations.
|
|
32
32
|
*/
|
|
33
33
|
function runDelayedUiOps() {
|
|
34
|
-
|
|
34
|
+
const tasks = delayedUiOps.slice();
|
|
35
|
+
delayedUiOps.length = 0;
|
|
36
|
+
shouldDelayUiOps.value = false;
|
|
37
|
+
for (const task of tasks) {
|
|
35
38
|
task();
|
|
36
39
|
}
|
|
37
|
-
shouldDelayUiOps.value = false;
|
|
38
|
-
delayedUiOps.length = 0;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* A proxy class designed for managing and executing reference-based tasks.
|
|
@@ -46,25 +47,31 @@ class RefProxy {
|
|
|
46
47
|
task;
|
|
47
48
|
constructor(refAttr) {
|
|
48
49
|
this.refAttr = refAttr;
|
|
50
|
+
this.task = undefined;
|
|
51
|
+
return new Proxy(this, {
|
|
52
|
+
get: (target, prop, receiver) => {
|
|
53
|
+
if (typeof prop === 'symbol'
|
|
54
|
+
|| prop === 'then'
|
|
55
|
+
|| prop in target
|
|
56
|
+
|| typeof prop !== 'string') {
|
|
57
|
+
return Reflect.get(target, prop, receiver);
|
|
58
|
+
}
|
|
59
|
+
const forward = (method) => {
|
|
60
|
+
return (...args) => {
|
|
61
|
+
return new RefProxy(target.refAttr).setTask(method, args);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
return forward(prop);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
49
67
|
}
|
|
50
68
|
setTask(method, args) {
|
|
51
69
|
this.task = (nodesRef) => {
|
|
52
|
-
|
|
70
|
+
const nodesRefMethod = nodesRef[method];
|
|
71
|
+
return nodesRefMethod.apply(nodesRef, args);
|
|
53
72
|
};
|
|
54
73
|
return this;
|
|
55
74
|
}
|
|
56
|
-
invoke(...args) {
|
|
57
|
-
return new RefProxy(this.refAttr).setTask('invoke', args);
|
|
58
|
-
}
|
|
59
|
-
path(...args) {
|
|
60
|
-
return new RefProxy(this.refAttr).setTask('path', args);
|
|
61
|
-
}
|
|
62
|
-
fields(...args) {
|
|
63
|
-
return new RefProxy(this.refAttr).setTask('fields', args);
|
|
64
|
-
}
|
|
65
|
-
setNativeProps(...args) {
|
|
66
|
-
return new RefProxy(this.refAttr).setTask('setNativeProps', args);
|
|
67
|
-
}
|
|
68
75
|
exec() {
|
|
69
76
|
runOrDelay(() => {
|
|
70
77
|
const realRefId = hydrationMap.get(this.refAttr[0]) ?? this.refAttr[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/lifecycle/ref/delay.ts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,eAAe,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { options } from "preact";
|
|
2
|
+
import { expect } from "vitest";
|
|
2
3
|
import { BackgroundSnapshotInstance } from "../../runtime/lib/backgroundSnapshot.js";
|
|
3
4
|
import { clearCommitTaskId, replaceCommitHook } from "../../runtime/lib/lifecycle/patch/commit.js";
|
|
4
5
|
import { deinitGlobalSnapshotPatch } from "../../runtime/lib/lifecycle/patch/snapshotPatch.js";
|
|
@@ -12,6 +13,22 @@ import { destroyWorklet } from "../../runtime/lib/worklet/destroy.js";
|
|
|
12
13
|
import { initApiEnv } from "../../worklet-runtime/lib/api/lynxApi.js";
|
|
13
14
|
import { initEventListeners } from "../../worklet-runtime/lib/listeners.js";
|
|
14
15
|
import { initWorklet } from "../../worklet-runtime/lib/workletRuntime.js";
|
|
16
|
+
expect.addSnapshotSerializer({
|
|
17
|
+
test (val) {
|
|
18
|
+
return Boolean(val && 'object' == typeof val && Array.isArray(val.refAttr) && Object.prototype.hasOwnProperty.call(val, 'task') && 'function' == typeof val.exec);
|
|
19
|
+
},
|
|
20
|
+
print (val, serialize) {
|
|
21
|
+
const printed = serialize({
|
|
22
|
+
refAttr: Array.isArray(val.refAttr) ? [
|
|
23
|
+
...val.refAttr
|
|
24
|
+
] : val.refAttr,
|
|
25
|
+
task: val.task
|
|
26
|
+
});
|
|
27
|
+
if (printed.startsWith('Object')) return printed.replace(/^Object/, 'RefProxy');
|
|
28
|
+
if (printed.startsWith('{')) return `RefProxy ${printed}`;
|
|
29
|
+
return printed;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
15
32
|
const { onInjectMainThreadGlobals, onInjectBackgroundThreadGlobals, onResetLynxTestingEnv, onSwitchedToMainThread, onSwitchedToBackgroundThread, onInitWorkletRuntime } = globalThis;
|
|
16
33
|
injectCalledByNative();
|
|
17
34
|
injectUpdateMainThread();
|