@lynx-js/react 0.114.1 → 0.114.3
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/package.json +2 -2
- package/refresh/.turbo/turbo-build.log +1 -1
- package/refresh/dist/index.js +34 -45
- package/testing-library/dist/index.d.ts +0 -2
- package/testing-library/dist/vitest-global-setup.js +3 -4
- package/transform/dist/wasm.cjs +1 -1
- package/worklet-runtime/dist/dev.js +11 -4
- package/worklet-runtime/dist/main.js +1 -1
- package/worklet-runtime/lib/hydrate.js +10 -4
- package/worklet-runtime/lib/hydrate.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.114.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Initialize `ctxNotFoundEventListener` before each test in testing library ([#1888](https://github.com/lynx-family/lynx-stack/pull/1888))
|
|
8
|
+
|
|
9
|
+
- fix: main thread functions created during the initial render cannot correctly modify `MainThreadRef`s after hydration ([#1884](https://github.com/lynx-family/lynx-stack/pull/1884))
|
|
10
|
+
|
|
11
|
+
## 0.114.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- fix: main thread functions created during the initial render cannot correctly call `runOnBackground()` after hydration ([#1878](https://github.com/lynx-family/lynx-stack/pull/1878))
|
|
16
|
+
|
|
3
17
|
## 0.114.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.3",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@lynx-js/types": "3.4.11",
|
|
178
178
|
"@microsoft/api-extractor": "7.52.15",
|
|
179
|
-
"@types/react": "^18.3.
|
|
179
|
+
"@types/react": "^18.3.25"
|
|
180
180
|
},
|
|
181
181
|
"peerDependencies": {
|
|
182
182
|
"@lynx-js/types": "*",
|
package/refresh/dist/index.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
import { Component, options } from "@lynx-js/react/internal";
|
|
2
|
-
const VNODE_COMPONENT = '__c';
|
|
3
2
|
const NAMESPACE = '__PREFRESH__';
|
|
4
|
-
const COMPONENT_HOOKS = '__H';
|
|
5
|
-
const HOOKS_LIST = '__';
|
|
6
|
-
const EFFECTS_LIST = '__h';
|
|
7
|
-
const RERENDER_COUNT = '__r';
|
|
8
|
-
const CATCH_ERROR_OPTION = '__e';
|
|
9
|
-
const COMPONENT_DIRTY = '__d';
|
|
10
|
-
const COMPONENT_BITS = '__g';
|
|
11
|
-
const HOOK_VALUE = '__';
|
|
12
|
-
const HOOK_ARGS = '__H';
|
|
13
|
-
const HOOK_CLEANUP = '__c';
|
|
14
3
|
const COMPONENT_DIRTY_BIT = 8;
|
|
15
4
|
const isDirty = (vnode)=>{
|
|
16
|
-
if (vnode[
|
|
17
|
-
if (vnode[
|
|
5
|
+
if (vnode["__c"] && vnode["__c"]["__d"]) return true;
|
|
6
|
+
if (vnode["__c"] && vnode["__c"]["__g"] & COMPONENT_DIRTY_BIT) return true;
|
|
18
7
|
};
|
|
19
8
|
const unsetDirty = (vnode)=>{
|
|
20
|
-
if (vnode[
|
|
21
|
-
if (vnode[
|
|
22
|
-
if (vnode[
|
|
9
|
+
if (vnode["__c"]) {
|
|
10
|
+
if (vnode["__c"]["__d"]) vnode["__c"]["__d"] = false;
|
|
11
|
+
if (vnode["__c"]["__g"]) vnode["__c"]["__g"] &= ~COMPONENT_DIRTY_BIT;
|
|
23
12
|
}
|
|
24
13
|
};
|
|
25
|
-
const oldCatchError = options[
|
|
26
|
-
options[
|
|
14
|
+
const oldCatchError = options["__e"];
|
|
15
|
+
options["__e"] = (error, vnode, oldVNode, info)=>{
|
|
27
16
|
if (isDirty(vnode)) unsetDirty(vnode);
|
|
28
17
|
if (oldCatchError) oldCatchError(error, vnode, oldVNode, info);
|
|
29
18
|
};
|
|
@@ -33,7 +22,7 @@ options.debounceRendering = (process)=>{
|
|
|
33
22
|
try {
|
|
34
23
|
process();
|
|
35
24
|
} catch (e) {
|
|
36
|
-
process[
|
|
25
|
+
process["__r"] = 0;
|
|
37
26
|
throw e;
|
|
38
27
|
}
|
|
39
28
|
});
|
|
@@ -68,7 +57,7 @@ options.vnode = (vnode)=>{
|
|
|
68
57
|
]);
|
|
69
58
|
}
|
|
70
59
|
vnode.type = foundType;
|
|
71
|
-
if (vnode[
|
|
60
|
+
if (vnode["__c"] && 'prototype' in vnode.type && vnode.type.prototype.render) vnode["__c"].constructor = vnode.type;
|
|
72
61
|
}
|
|
73
62
|
if (oldVnode) oldVnode(vnode);
|
|
74
63
|
};
|
|
@@ -155,13 +144,13 @@ function replaceComponent(OldType, NewType, resetHookState) {
|
|
|
155
144
|
}
|
|
156
145
|
if (!vnode || !vnode.__c || !vnode.__c.__P) return;
|
|
157
146
|
vnode.type = NewType;
|
|
158
|
-
if (vnode[
|
|
159
|
-
vnode[
|
|
147
|
+
if (vnode["__c"]) {
|
|
148
|
+
vnode["__c"].constructor = vnode.type;
|
|
160
149
|
try {
|
|
161
|
-
if (vnode[
|
|
162
|
-
const oldInst = vnode[
|
|
163
|
-
const newInst = new NewType(vnode[
|
|
164
|
-
vnode[
|
|
150
|
+
if (vnode["__c"] instanceof OldType) {
|
|
151
|
+
const oldInst = vnode["__c"];
|
|
152
|
+
const newInst = new NewType(vnode["__c"].props, vnode["__c"].context);
|
|
153
|
+
vnode["__c"] = newInst;
|
|
165
154
|
for(let i in oldInst){
|
|
166
155
|
const type = typeof oldInst[i];
|
|
167
156
|
if (i in newInst) {
|
|
@@ -171,41 +160,41 @@ function replaceComponent(OldType, NewType, resetHookState) {
|
|
|
171
160
|
}
|
|
172
161
|
}
|
|
173
162
|
} catch (e) {
|
|
174
|
-
vnode[
|
|
163
|
+
vnode["__c"].constructor = NewType;
|
|
175
164
|
}
|
|
176
165
|
if (resetHookState) {
|
|
177
|
-
if (vnode[
|
|
178
|
-
if (possibleEffect[
|
|
179
|
-
possibleEffect[
|
|
180
|
-
possibleEffect[
|
|
181
|
-
} else if (possibleEffect[
|
|
182
|
-
const cleanupKey = Object.keys(possibleEffect).find((key)=>
|
|
166
|
+
if (vnode["__c"]["__H"] && vnode["__c"]["__H"]["__"] && vnode["__c"]["__H"]["__"].length) vnode["__c"]["__H"]["__"].forEach((possibleEffect)=>{
|
|
167
|
+
if (possibleEffect["__c"] && 'function' == typeof possibleEffect["__c"]) {
|
|
168
|
+
possibleEffect["__c"]();
|
|
169
|
+
possibleEffect["__c"] = void 0;
|
|
170
|
+
} else if (possibleEffect["__H"] && possibleEffect["__"] && 3 === Object.keys(possibleEffect).length) {
|
|
171
|
+
const cleanupKey = Object.keys(possibleEffect).find((key)=>"__H" !== key && "__" !== key);
|
|
183
172
|
if (cleanupKey && 'function' == typeof possibleEffect[cleanupKey]) {
|
|
184
173
|
possibleEffect[cleanupKey]();
|
|
185
174
|
possibleEffect[cleanupKey] = void 0;
|
|
186
175
|
}
|
|
187
176
|
}
|
|
188
177
|
});
|
|
189
|
-
vnode[
|
|
190
|
-
[
|
|
191
|
-
[
|
|
178
|
+
vnode["__c"]["__H"] = {
|
|
179
|
+
["__"]: [],
|
|
180
|
+
["__h"]: []
|
|
192
181
|
};
|
|
193
|
-
} else if (vnode[
|
|
194
|
-
vnode[
|
|
195
|
-
if (possibleEffect[
|
|
196
|
-
possibleEffect[
|
|
197
|
-
possibleEffect[
|
|
198
|
-
} else if (possibleEffect[
|
|
199
|
-
const cleanupKey = Object.keys(possibleEffect).find((key)=>
|
|
182
|
+
} else if (vnode["__c"]["__H"] && vnode["__c"]["__H"]["__"] && vnode["__c"]["__H"]["__"].length) {
|
|
183
|
+
vnode["__c"]["__H"]["__"].forEach((possibleEffect)=>{
|
|
184
|
+
if (possibleEffect["__c"] && 'function' == typeof possibleEffect["__c"]) {
|
|
185
|
+
possibleEffect["__c"]();
|
|
186
|
+
possibleEffect["__c"] = void 0;
|
|
187
|
+
} else if (possibleEffect["__H"] && possibleEffect["__"] && 3 === Object.keys(possibleEffect).length) {
|
|
188
|
+
const cleanupKey = Object.keys(possibleEffect).find((key)=>"__H" !== key && "__" !== key);
|
|
200
189
|
if (cleanupKey && 'function' == typeof possibleEffect[cleanupKey]) possibleEffect[cleanupKey]();
|
|
201
190
|
possibleEffect[cleanupKey] = void 0;
|
|
202
191
|
}
|
|
203
192
|
});
|
|
204
|
-
vnode[
|
|
193
|
+
vnode["__c"]["__H"]["__"].forEach((hook)=>{
|
|
205
194
|
if (hook.__H && Array.isArray(hook.__H)) hook.__H = void 0;
|
|
206
195
|
});
|
|
207
196
|
}
|
|
208
|
-
Component.prototype.forceUpdate.call(vnode[
|
|
197
|
+
Component.prototype.forceUpdate.call(vnode["__c"]);
|
|
209
198
|
}
|
|
210
199
|
});
|
|
211
200
|
}
|
|
@@ -970,8 +970,6 @@ export declare class LynxTestingEnv {
|
|
|
970
970
|
injectGlobals(): void;
|
|
971
971
|
switchToBackgroundThread(): void;
|
|
972
972
|
switchToMainThread(): void;
|
|
973
|
-
// we do not use it because we have to keep background thread
|
|
974
|
-
// otherwise we will get error on __MAIN_THREAD__/__BACKGROUND__/lynx not defined etc.
|
|
975
973
|
clearGlobal(): void;
|
|
976
974
|
reset(): void;
|
|
977
975
|
}
|
|
@@ -7,6 +7,7 @@ import { injectUpdateMainThread } from "../../runtime/lib/lifecycle/patch/update
|
|
|
7
7
|
import { injectUpdateMTRefInitValue } from "../../runtime/lib/worklet/ref/updateInitValue.js";
|
|
8
8
|
import { injectCalledByNative } from "../../runtime/lib/lynx/calledByNative.js";
|
|
9
9
|
import { flushDelayedLifecycleEvents, injectTt } from "../../runtime/lib/lynx/tt.js";
|
|
10
|
+
import { addCtxNotFoundEventListener } from "../../runtime/lib/lifecycle/patch/error.js";
|
|
10
11
|
import { setRoot } from "../../runtime/lib/root.js";
|
|
11
12
|
import { SnapshotInstance, backgroundSnapshotInstanceManager, snapshotInstanceManager } from "../../runtime/lib/snapshot.js";
|
|
12
13
|
import { destroyWorklet } from "../../runtime/lib/worklet/destroy.js";
|
|
@@ -98,10 +99,6 @@ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
|
|
|
98
99
|
}
|
|
99
100
|
target._document = setupBackgroundDocument({});
|
|
100
101
|
target.globalPipelineOptions = void 0;
|
|
101
|
-
const oldLynxCoreInject = globalThis.lynxCoreInject;
|
|
102
|
-
globalThis.lynxCoreInject = target.lynxCoreInject;
|
|
103
|
-
injectTt();
|
|
104
|
-
globalThis.lynxCoreInject = oldLynxCoreInject;
|
|
105
102
|
target.lynx.requireModuleAsync = async (url, callback)=>{
|
|
106
103
|
try {
|
|
107
104
|
callback(null, await __vite_ssr_dynamic_import__(url));
|
|
@@ -119,6 +116,8 @@ globalThis.onResetLynxTestingEnv = ()=>{
|
|
|
119
116
|
lynxTestingEnv.switchToMainThread();
|
|
120
117
|
initEventListeners();
|
|
121
118
|
lynxTestingEnv.switchToBackgroundThread();
|
|
119
|
+
injectTt();
|
|
120
|
+
addCtxNotFoundEventListener();
|
|
122
121
|
};
|
|
123
122
|
globalThis.onSwitchedToMainThread = ()=>{
|
|
124
123
|
if (onSwitchedToMainThread) onSwitchedToMainThread();
|