@lynx-js/react 0.110.1 → 0.111.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 +50 -0
- package/components/lib/DeferredListItem.d.ts +7 -0
- package/components/lib/DeferredListItem.jsx +40 -0
- package/components/lib/DeferredListItem.jsx.map +1 -0
- package/components/lib/index.d.ts +1 -0
- package/components/lib/index.js +1 -0
- package/components/lib/index.js.map +1 -1
- package/components/src/DeferredListItem.tsx +56 -0
- package/components/src/index.ts +1 -0
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +7 -3
- package/refresh/dist/index.js +223 -284
- package/refresh/package.json +3 -4
- package/refresh/rslib.config.ts +24 -0
- package/runtime/lazy/react-lepus.js +1 -0
- package/runtime/lazy/react.js +1 -0
- package/runtime/lepus/index.d.ts +1 -1
- package/runtime/lepus/index.js +44 -0
- package/runtime/lib/backgroundSnapshot.d.ts +2 -1
- package/runtime/lib/backgroundSnapshot.js +62 -40
- package/runtime/lib/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/compat/initData.js +10 -0
- package/runtime/lib/compat/initData.js.map +1 -1
- package/runtime/lib/index.d.ts +2 -2
- package/runtime/lib/index.js +2 -2
- package/runtime/lib/index.js.map +1 -1
- package/runtime/lib/lifecycle/patch/commit.js +5 -5
- package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatch.d.ts +9 -9
- package/runtime/lib/lifecycle/patch/snapshotPatch.js +9 -10
- package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.js +7 -8
- package/runtime/lib/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/lifecycleConstant.d.ts +2 -1
- package/runtime/lib/lifecycleConstant.js +1 -0
- package/runtime/lib/lifecycleConstant.js.map +1 -1
- package/runtime/lib/list.js +102 -12
- package/runtime/lib/list.js.map +1 -1
- package/runtime/lib/lynx/calledByNative.js +6 -9
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/lynx/component.js +11 -14
- package/runtime/lib/lynx/component.js.map +1 -1
- package/runtime/lib/lynx/env.js +1 -2
- package/runtime/lib/lynx/env.js.map +1 -1
- package/runtime/lib/lynx/lazy-bundle.js +48 -21
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/lynx/performance.d.ts +3 -19
- package/runtime/lib/lynx/performance.js +25 -26
- package/runtime/lib/lynx/performance.js.map +1 -1
- package/runtime/lib/lynx/tt.js +10 -5
- package/runtime/lib/lynx/tt.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +78 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/snapshot.d.ts +2 -0
- package/runtime/lib/snapshot.js +19 -5
- package/runtime/lib/snapshot.js.map +1 -1
- package/runtime/lib/utils.d.ts +1 -0
- package/runtime/lib/utils.js +6 -0
- package/runtime/lib/utils.js.map +1 -1
- package/runtime/src/backgroundSnapshot.ts +74 -55
- package/runtime/src/compat/initData.ts +10 -0
- package/runtime/src/index.ts +2 -0
- package/runtime/src/lifecycle/patch/commit.ts +5 -11
- package/runtime/src/lifecycle/patch/snapshotPatch.ts +9 -9
- package/runtime/src/lifecycle/patch/updateMainThread.ts +7 -8
- package/runtime/src/lifecycleConstant.ts +1 -0
- package/runtime/src/list.ts +118 -15
- package/runtime/src/lynx/calledByNative.ts +6 -8
- package/runtime/src/lynx/component.ts +17 -29
- package/runtime/src/lynx/env.ts +1 -2
- package/runtime/src/lynx/lazy-bundle.ts +55 -20
- package/runtime/src/lynx/performance.ts +26 -27
- package/runtime/src/lynx/tt.ts +10 -11
- package/runtime/src/lynx-api.ts +77 -1
- package/runtime/src/snapshot.ts +20 -5
- package/runtime/src/utils.ts +9 -0
- package/testing-library/dist/env/vitest.js +6 -3
- package/testing-library/dist/index.d.ts +4 -1
- package/testing-library/dist/pure.js +4 -2
- package/testing-library/dist/vitest-global-setup.js +2 -2
- package/testing-library/dist/vitest.config.js +38 -1
- package/testing-library/types/entry.d.ts +3 -2
- package/transform/dist/wasm.cjs +1 -1
- package/types/react.d.ts +21 -1
- package/types/react.docs.d.ts +1 -1
- package/worklet-runtime/dist/dev.js +403 -506
- package/worklet-runtime/dist/main.js +1 -517
- package/worklet-runtime/lib/workletRuntime.js +5 -5
- package/worklet-runtime/lib/workletRuntime.js.map +1 -1
package/refresh/dist/index.js
CHANGED
|
@@ -1,311 +1,250 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// ../../../node_modules/.pnpm/@prefresh+core@1.5.3_preact@10.23.2/node_modules/@prefresh/core/src/runtime/catchError.js
|
|
18
|
-
var oldCatchError = options[CATCH_ERROR_OPTION];
|
|
19
|
-
options[CATCH_ERROR_OPTION] = (error, vnode, oldVNode) => {
|
|
20
|
-
if (vnode[VNODE_COMPONENT] && vnode[VNODE_COMPONENT][COMPONENT_DIRTY]) {
|
|
21
|
-
vnode[VNODE_COMPONENT][COMPONENT_DIRTY] = false;
|
|
22
|
-
}
|
|
23
|
-
if (oldCatchError) oldCatchError(error, vnode, oldVNode);
|
|
1
|
+
import { Component, options } from "@lynx-js/react/internal";
|
|
2
|
+
const VNODE_COMPONENT = '__c';
|
|
3
|
+
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 HOOK_VALUE = '__';
|
|
11
|
+
const HOOK_ARGS = '__H';
|
|
12
|
+
const HOOK_CLEANUP = '__c';
|
|
13
|
+
const oldCatchError = options[CATCH_ERROR_OPTION];
|
|
14
|
+
options[CATCH_ERROR_OPTION] = (error, vnode, oldVNode)=>{
|
|
15
|
+
if (vnode[VNODE_COMPONENT] && vnode[VNODE_COMPONENT][COMPONENT_DIRTY]) vnode[VNODE_COMPONENT][COMPONENT_DIRTY] = false;
|
|
16
|
+
if (oldCatchError) oldCatchError(error, vnode, oldVNode);
|
|
24
17
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// ../../../node_modules/.pnpm/@prefresh+core@1.5.3_preact@10.23.2/node_modules/@prefresh/core/src/runtime/vnode.js
|
|
41
|
-
import { options as options3 } from "@lynx-js/react/internal";
|
|
42
|
-
|
|
43
|
-
// ../../../node_modules/.pnpm/@prefresh+core@1.5.3_preact@10.23.2/node_modules/@prefresh/core/src/runtime/vnodesForComponent.js
|
|
44
|
-
var vnodesForComponent = /* @__PURE__ */ new WeakMap();
|
|
45
|
-
var mappedVNodes = /* @__PURE__ */ new WeakMap();
|
|
46
|
-
|
|
47
|
-
// ../../../node_modules/.pnpm/@prefresh+core@1.5.3_preact@10.23.2/node_modules/@prefresh/core/src/runtime/vnode.js
|
|
48
|
-
var getMappedVnode = (type) => {
|
|
49
|
-
if (mappedVNodes.has(type)) {
|
|
50
|
-
return getMappedVnode(mappedVNodes.get(type));
|
|
51
|
-
}
|
|
52
|
-
return type;
|
|
18
|
+
const defer = 'function' == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;
|
|
19
|
+
options.debounceRendering = (process)=>{
|
|
20
|
+
defer(()=>{
|
|
21
|
+
try {
|
|
22
|
+
process();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
process[RERENDER_COUNT] = 0;
|
|
25
|
+
throw e;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
53
28
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
const vnodesForComponent = new WeakMap();
|
|
30
|
+
const mappedVNodes = new WeakMap();
|
|
31
|
+
const lastSeen = new Map();
|
|
32
|
+
const getMappedVnode = (type)=>{
|
|
33
|
+
if (mappedVNodes.has(type)) return getMappedVnode(mappedVNodes.get(type));
|
|
34
|
+
return type;
|
|
57
35
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
36
|
+
const BUILT_IN_COMPONENTS = [
|
|
37
|
+
'Fragment',
|
|
38
|
+
'Suspense',
|
|
39
|
+
'SuspenseList'
|
|
40
|
+
];
|
|
41
|
+
const isBuiltIn = (type)=>BUILT_IN_COMPONENTS.includes(type.name);
|
|
42
|
+
const oldVnode = options.vnode;
|
|
43
|
+
options.vnode = (vnode)=>{
|
|
44
|
+
if (vnode && 'function' == typeof vnode.type && !isBuiltIn(vnode.type)) {
|
|
45
|
+
const vnodes = vnodesForComponent.get(vnode.type);
|
|
46
|
+
if (vnodes) vnodes.push(vnode);
|
|
47
|
+
else vnodesForComponent.set(vnode.type, [
|
|
48
|
+
vnode
|
|
49
|
+
]);
|
|
50
|
+
const foundType = getMappedVnode(vnode.type);
|
|
51
|
+
if (foundType !== vnode.type) {
|
|
52
|
+
const vnodes = vnodesForComponent.get(foundType);
|
|
53
|
+
if (vnodes) vnodes.push(vnode);
|
|
54
|
+
else vnodesForComponent.set(foundType, [
|
|
55
|
+
vnode
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
vnode.type = foundType;
|
|
59
|
+
if (vnode[VNODE_COMPONENT] && 'prototype' in vnode.type && vnode.type.prototype.render) vnode[VNODE_COMPONENT].constructor = vnode.type;
|
|
79
60
|
}
|
|
80
|
-
|
|
81
|
-
if (oldVnode) oldVnode(vnode);
|
|
61
|
+
if (oldVnode) oldVnode(vnode);
|
|
82
62
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
const oldDiffed = options.diffed;
|
|
64
|
+
options.diffed = (vnode)=>{
|
|
65
|
+
if (vnode && 'function' == typeof vnode.type) {
|
|
66
|
+
const vnodes = vnodesForComponent.get(vnode.type);
|
|
67
|
+
lastSeen.set(vnode.__v, vnode);
|
|
68
|
+
if (vnodes) {
|
|
69
|
+
const matchingDom = vnodes.filter((p)=>p.__c === vnode.__c);
|
|
70
|
+
if (matchingDom.length > 1) {
|
|
71
|
+
const i = vnodes.findIndex((p)=>p === matchingDom[0]);
|
|
72
|
+
vnodes.splice(i, 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
93
75
|
}
|
|
94
|
-
|
|
95
|
-
if (oldDiffed) oldDiffed(vnode);
|
|
76
|
+
if (oldDiffed) oldDiffed(vnode);
|
|
96
77
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const index = vnodes.indexOf(vnode);
|
|
107
|
-
if (index !== -1) {
|
|
108
|
-
vnodes.splice(index, 1);
|
|
109
|
-
}
|
|
78
|
+
const oldUnmount = options.unmount;
|
|
79
|
+
options.unmount = (vnode)=>{
|
|
80
|
+
const type = (vnode || {}).type;
|
|
81
|
+
if ('function' == typeof type && vnodesForComponent.has(type)) {
|
|
82
|
+
const vnodes = vnodesForComponent.get(type);
|
|
83
|
+
if (vnodes) {
|
|
84
|
+
const index = vnodes.indexOf(vnode);
|
|
85
|
+
if (-1 !== index) vnodes.splice(index, 1);
|
|
86
|
+
}
|
|
110
87
|
}
|
|
111
|
-
|
|
112
|
-
if (oldUnmount) oldUnmount(vnode);
|
|
88
|
+
if (oldUnmount) oldUnmount(vnode);
|
|
113
89
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return fullKey;
|
|
90
|
+
const signaturesForType = new WeakMap();
|
|
91
|
+
const computeKey = (signature)=>{
|
|
92
|
+
let fullKey = signature.key;
|
|
93
|
+
let hooks;
|
|
94
|
+
try {
|
|
95
|
+
hooks = signature.getCustomHooks();
|
|
96
|
+
} catch (err) {
|
|
97
|
+
signature.forceReset = true;
|
|
98
|
+
return fullKey;
|
|
99
|
+
}
|
|
100
|
+
for(let i = 0; i < hooks.length; i++){
|
|
101
|
+
const hook = hooks[i];
|
|
102
|
+
if ('function' != typeof hook) {
|
|
103
|
+
signature.forceReset = true;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
const nestedHookSignature = signaturesForType.get(hook);
|
|
107
|
+
if (void 0 === nestedHookSignature) continue;
|
|
108
|
+
const nestedHookKey = computeKey(nestedHookSignature);
|
|
109
|
+
if (nestedHookSignature.forceReset) signature.forceReset = true;
|
|
110
|
+
fullKey += '\n---\n' + nestedHookKey;
|
|
136
111
|
}
|
|
137
|
-
|
|
138
|
-
if (nestedHookSignature === void 0) continue;
|
|
139
|
-
const nestedHookKey = computeKey(nestedHookSignature);
|
|
140
|
-
if (nestedHookSignature.forceReset) signature.forceReset = true;
|
|
141
|
-
fullKey += "\n---\n" + nestedHookKey;
|
|
142
|
-
}
|
|
143
|
-
return fullKey;
|
|
112
|
+
return fullKey;
|
|
144
113
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var typesById = /* @__PURE__ */ new Map();
|
|
148
|
-
var pendingUpdates = [];
|
|
114
|
+
let typesById = new Map();
|
|
115
|
+
let pendingUpdates = [];
|
|
149
116
|
function sign(type, key, forceReset, getCustomHooks, status) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
117
|
+
if (type) {
|
|
118
|
+
let signature = signaturesForType.get(type);
|
|
119
|
+
if ('begin' === status) {
|
|
120
|
+
signaturesForType.set(type, {
|
|
121
|
+
type,
|
|
122
|
+
key,
|
|
123
|
+
forceReset,
|
|
124
|
+
getCustomHooks: getCustomHooks || (()=>[])
|
|
125
|
+
});
|
|
126
|
+
return 'needsHooks';
|
|
127
|
+
}
|
|
128
|
+
if ('needsHooks' === status) signature.fullKey = computeKey(signature);
|
|
162
129
|
}
|
|
163
|
-
}
|
|
164
130
|
}
|
|
165
131
|
function replaceComponent(OldType, NewType, resetHookState) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
if (vnode[VNODE_COMPONENT] instanceof OldType) {
|
|
179
|
-
const oldInst = vnode[VNODE_COMPONENT];
|
|
180
|
-
const newInst = new NewType(
|
|
181
|
-
vnode[VNODE_COMPONENT].props,
|
|
182
|
-
vnode[VNODE_COMPONENT].context
|
|
183
|
-
);
|
|
184
|
-
vnode[VNODE_COMPONENT] = newInst;
|
|
185
|
-
for (let i in oldInst) {
|
|
186
|
-
const type = typeof oldInst[i];
|
|
187
|
-
if (!(i in newInst)) {
|
|
188
|
-
newInst[i] = oldInst[i];
|
|
189
|
-
} else if (type !== "function" && typeof newInst[i] === type) {
|
|
190
|
-
if (type === "object" && newInst[i] != null && newInst[i].constructor === oldInst[i].constructor) {
|
|
191
|
-
Object.assign(newInst[i], oldInst[i]);
|
|
192
|
-
} else {
|
|
193
|
-
newInst[i] = oldInst[i];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
132
|
+
const vnodes = vnodesForComponent.get(OldType);
|
|
133
|
+
if (!vnodes) return;
|
|
134
|
+
vnodesForComponent["delete"](OldType);
|
|
135
|
+
vnodesForComponent.set(NewType, vnodes);
|
|
136
|
+
mappedVNodes.set(OldType, NewType);
|
|
137
|
+
pendingUpdates = pendingUpdates.filter((p)=>p[0] !== OldType);
|
|
138
|
+
vnodes.forEach((node)=>{
|
|
139
|
+
let vnode = node;
|
|
140
|
+
if (!vnode.__c) {
|
|
141
|
+
vnode = lastSeen.get(vnode.__v, vnode);
|
|
142
|
+
lastSeen["delete"](vnode.__v);
|
|
197
143
|
}
|
|
198
|
-
|
|
199
|
-
vnode
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
possibleEffect[cleanupKey] = void 0;
|
|
144
|
+
if (!vnode || !vnode.__c || !vnode.__c.__P) return;
|
|
145
|
+
vnode.type = NewType;
|
|
146
|
+
if (vnode[VNODE_COMPONENT]) {
|
|
147
|
+
vnode[VNODE_COMPONENT].constructor = vnode.type;
|
|
148
|
+
try {
|
|
149
|
+
if (vnode[VNODE_COMPONENT] instanceof OldType) {
|
|
150
|
+
const oldInst = vnode[VNODE_COMPONENT];
|
|
151
|
+
const newInst = new NewType(vnode[VNODE_COMPONENT].props, vnode[VNODE_COMPONENT].context);
|
|
152
|
+
vnode[VNODE_COMPONENT] = newInst;
|
|
153
|
+
for(let i in oldInst){
|
|
154
|
+
const type = typeof oldInst[i];
|
|
155
|
+
if (i in newInst) {
|
|
156
|
+
if ('function' !== type && typeof newInst[i] === type) if ('object' === type && null != newInst[i] && newInst[i].constructor === oldInst[i].constructor) Object.assign(newInst[i], oldInst[i]);
|
|
157
|
+
else newInst[i] = oldInst[i];
|
|
158
|
+
} else newInst[i] = oldInst[i];
|
|
159
|
+
}
|
|
215
160
|
}
|
|
216
|
-
|
|
161
|
+
} catch (e) {
|
|
162
|
+
vnode[VNODE_COMPONENT].constructor = NewType;
|
|
217
163
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
164
|
+
if (resetHookState) {
|
|
165
|
+
if (vnode[VNODE_COMPONENT][COMPONENT_HOOKS] && vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST] && vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST].length) vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST].forEach((possibleEffect)=>{
|
|
166
|
+
if (possibleEffect[HOOK_CLEANUP] && 'function' == typeof possibleEffect[HOOK_CLEANUP]) {
|
|
167
|
+
possibleEffect[HOOK_CLEANUP]();
|
|
168
|
+
possibleEffect[HOOK_CLEANUP] = void 0;
|
|
169
|
+
} else if (possibleEffect[HOOK_ARGS] && possibleEffect[HOOK_VALUE] && 3 === Object.keys(possibleEffect).length) {
|
|
170
|
+
const cleanupKey = Object.keys(possibleEffect).find((key)=>key !== HOOK_ARGS && key !== HOOK_VALUE);
|
|
171
|
+
if (cleanupKey && 'function' == typeof possibleEffect[cleanupKey]) {
|
|
172
|
+
possibleEffect[cleanupKey]();
|
|
173
|
+
possibleEffect[cleanupKey] = void 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
vnode[VNODE_COMPONENT][COMPONENT_HOOKS] = {
|
|
178
|
+
[HOOKS_LIST]: [],
|
|
179
|
+
[EFFECTS_LIST]: []
|
|
180
|
+
};
|
|
181
|
+
} else if (vnode[VNODE_COMPONENT][COMPONENT_HOOKS] && vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST] && vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST].length) {
|
|
182
|
+
vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST].forEach((possibleEffect)=>{
|
|
183
|
+
if (possibleEffect[HOOK_CLEANUP] && 'function' == typeof possibleEffect[HOOK_CLEANUP]) {
|
|
184
|
+
possibleEffect[HOOK_CLEANUP]();
|
|
185
|
+
possibleEffect[HOOK_CLEANUP] = void 0;
|
|
186
|
+
} else if (possibleEffect[HOOK_ARGS] && possibleEffect[HOOK_VALUE] && 3 === Object.keys(possibleEffect).length) {
|
|
187
|
+
const cleanupKey = Object.keys(possibleEffect).find((key)=>key !== HOOK_ARGS && key !== HOOK_VALUE);
|
|
188
|
+
if (cleanupKey && 'function' == typeof possibleEffect[cleanupKey]) possibleEffect[cleanupKey]();
|
|
189
|
+
possibleEffect[cleanupKey] = void 0;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
vnode[VNODE_COMPONENT][COMPONENT_HOOKS][HOOKS_LIST].forEach((hook)=>{
|
|
193
|
+
if (hook.__H && Array.isArray(hook.__H)) hook.__H = void 0;
|
|
194
|
+
});
|
|
237
195
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (hook.__H && Array.isArray(hook.__H)) {
|
|
242
|
-
hook.__H = void 0;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
Component.prototype.forceUpdate.call(vnode[VNODE_COMPONENT]);
|
|
247
|
-
}
|
|
248
|
-
});
|
|
196
|
+
Component.prototype.forceUpdate.call(vnode[VNODE_COMPONENT]);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
249
199
|
}
|
|
250
200
|
globalThis[NAMESPACE] = {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
computeKey
|
|
201
|
+
getSignature: (type)=>signaturesForType.get(type),
|
|
202
|
+
register: (type, id)=>{
|
|
203
|
+
if ('function' != typeof type) return;
|
|
204
|
+
if (typesById.has(id)) {
|
|
205
|
+
const existing = typesById.get(id);
|
|
206
|
+
if (existing !== type) {
|
|
207
|
+
pendingUpdates.push([
|
|
208
|
+
existing,
|
|
209
|
+
type
|
|
210
|
+
]);
|
|
211
|
+
typesById.set(id, type);
|
|
212
|
+
}
|
|
213
|
+
} else typesById.set(id, type);
|
|
214
|
+
if (!signaturesForType.has(type)) signaturesForType.set(type, {
|
|
215
|
+
getCustomHooks: ()=>[],
|
|
216
|
+
type
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
getPendingUpdates: ()=>pendingUpdates,
|
|
220
|
+
flush: ()=>{
|
|
221
|
+
pendingUpdates = [];
|
|
222
|
+
},
|
|
223
|
+
replaceComponent,
|
|
224
|
+
sign,
|
|
225
|
+
computeKey: computeKey
|
|
277
226
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (prevSignature.key !== nextSignature.key || globalThis.__PREFRESH__.computeKey(prevSignature) !== globalThis.__PREFRESH__.computeKey(nextSignature) || nextSignature.forceReset) {
|
|
284
|
-
globalThis.__PREFRESH__.replaceComponent(prev, next, true);
|
|
285
|
-
} else {
|
|
286
|
-
globalThis.__PREFRESH__.replaceComponent(prev, next, false);
|
|
287
|
-
}
|
|
227
|
+
const compareSignatures = (prev, next)=>{
|
|
228
|
+
const prevSignature = globalThis.__PREFRESH__.getSignature(prev) || {};
|
|
229
|
+
const nextSignature = globalThis.__PREFRESH__.getSignature(next) || {};
|
|
230
|
+
if (prevSignature.key !== nextSignature.key || globalThis.__PREFRESH__.computeKey(prevSignature) !== globalThis.__PREFRESH__.computeKey(nextSignature) || nextSignature.forceReset) globalThis.__PREFRESH__.replaceComponent(prev, next, true);
|
|
231
|
+
else globalThis.__PREFRESH__.replaceComponent(prev, next, false);
|
|
288
232
|
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
233
|
+
const flush = ()=>{
|
|
234
|
+
const pending = [
|
|
235
|
+
...globalThis.__PREFRESH__.getPendingUpdates()
|
|
236
|
+
];
|
|
237
|
+
globalThis.__PREFRESH__.flush();
|
|
238
|
+
if (pending.length > 0) pending.forEach(([prev, next])=>{
|
|
239
|
+
compareSignatures(prev, next);
|
|
295
240
|
});
|
|
296
|
-
}
|
|
297
241
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
242
|
+
const isComponent = (exportValue)=>{
|
|
243
|
+
if ('function' == typeof exportValue) {
|
|
244
|
+
if (null != exportValue.prototype && exportValue.prototype.isReactComponent) return true;
|
|
245
|
+
const name = exportValue.name || exportValue.displayName;
|
|
246
|
+
return 'string' == typeof name && name[0] && name[0] == name[0].toUpperCase();
|
|
302
247
|
}
|
|
303
|
-
|
|
304
|
-
return typeof name === "string" && name[0] && name[0] == name[0].toUpperCase();
|
|
305
|
-
}
|
|
306
|
-
return false;
|
|
307
|
-
};
|
|
308
|
-
export {
|
|
309
|
-
flush,
|
|
310
|
-
isComponent
|
|
248
|
+
return false;
|
|
311
249
|
};
|
|
250
|
+
export { flush, isComponent };
|
package/refresh/package.json
CHANGED
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "rslib build"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@lynx-js/react": "workspace:*",
|
|
17
|
-
"@prefresh/core": "^1.5.
|
|
18
|
-
"@prefresh/utils": "^1.2.
|
|
19
|
-
"esbuild": "^0.25.5"
|
|
17
|
+
"@prefresh/core": "^1.5.5",
|
|
18
|
+
"@prefresh/utils": "^1.2.1"
|
|
20
19
|
}
|
|
21
20
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { defineConfig } from '@rslib/core';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
lib: [
|
|
9
|
+
{ format: 'esm', syntax: 'es2019' },
|
|
10
|
+
],
|
|
11
|
+
output: {
|
|
12
|
+
externals: [
|
|
13
|
+
{
|
|
14
|
+
'preact': '@lynx-js/react/internal',
|
|
15
|
+
'preact/hooks': '@lynx-js/react',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
source: {
|
|
20
|
+
define: {
|
|
21
|
+
self: 'globalThis',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
package/runtime/lazy/react.js
CHANGED
package/runtime/lepus/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
export { createElement } from 'react';
|
|
4
|
+
export { cloneElement, createElement } from 'react';
|