@energy8platform/game-engine 0.14.6 → 0.14.8
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/dist/debug.d.ts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/lua.cjs.js +3 -1
- package/dist/lua.cjs.js.map +1 -1
- package/dist/lua.d.ts +4 -1
- package/dist/lua.esm.js +3 -1
- package/dist/lua.esm.js.map +1 -1
- package/dist/react.cjs.js +39 -7
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.esm.js +39 -7
- package/dist/react.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-simulate.mjs +5 -4
- package/src/lua/LuaEngine.ts +3 -1
- package/src/lua/types.ts +4 -1
- package/src/react/reconciler.ts +32 -7
package/src/react/reconciler.ts
CHANGED
|
@@ -22,6 +22,18 @@ function isSuspendable(obj: any): obj is Suspendable {
|
|
|
22
22
|
/** Layout containers that need flush after commit phase */
|
|
23
23
|
const pendingLayoutFlush = new Set<Suspendable>();
|
|
24
24
|
|
|
25
|
+
/** Suspend a layout container and all its suspendable ancestors, add them to pending flush */
|
|
26
|
+
function suspendWithAncestors(instance: any): void {
|
|
27
|
+
let current = instance;
|
|
28
|
+
while (current) {
|
|
29
|
+
if (isSuspendable(current)) {
|
|
30
|
+
current.suspendLayout();
|
|
31
|
+
pendingLayoutFlush.add(current);
|
|
32
|
+
}
|
|
33
|
+
current = current.parent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
/** Extract FlexItemConfig from props if any flex item props are present */
|
|
26
38
|
function extractFlexItemConfig(props: Record<string, any>): FlexItemConfig | undefined {
|
|
27
39
|
let config: FlexItemConfig | undefined;
|
|
@@ -196,6 +208,13 @@ const hostConfig: Reconciler.HostConfig<
|
|
|
196
208
|
},
|
|
197
209
|
|
|
198
210
|
commitUpdate(instance, _updatePayload, _type, oldProps, newProps) {
|
|
211
|
+
// Suspend this instance and ancestors before applying changes —
|
|
212
|
+
// prevents intermediate relayouts with partially-updated tree
|
|
213
|
+
const dimensionsChanged = newProps.width !== oldProps.width || newProps.height !== oldProps.height;
|
|
214
|
+
if (isSuspendable(instance) || dimensionsChanged) {
|
|
215
|
+
suspendWithAncestors(instance);
|
|
216
|
+
}
|
|
217
|
+
|
|
199
218
|
if (typeof instance.updateConfig === 'function') {
|
|
200
219
|
const changed = diffConfig(newProps, oldProps);
|
|
201
220
|
if (Object.keys(changed).length > 0) {
|
|
@@ -226,11 +245,9 @@ const hostConfig: Reconciler.HostConfig<
|
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
247
|
|
|
229
|
-
//
|
|
230
|
-
if (newFlexConfig || oldFlexConfig ||
|
|
231
|
-
|
|
232
|
-
instance.parent.updateLayout();
|
|
233
|
-
}
|
|
248
|
+
// Mark ancestors dirty if flex config or dimensions changed
|
|
249
|
+
if (newFlexConfig || oldFlexConfig || dimensionsChanged) {
|
|
250
|
+
suspendWithAncestors(instance);
|
|
234
251
|
}
|
|
235
252
|
|
|
236
253
|
if (hasEventProps(newProps) && instance.eventMode === 'auto') {
|
|
@@ -271,8 +288,16 @@ const hostConfig: Reconciler.HostConfig<
|
|
|
271
288
|
},
|
|
272
289
|
|
|
273
290
|
resetAfterCommit() {
|
|
274
|
-
|
|
275
|
-
|
|
291
|
+
if (pendingLayoutFlush.size === 0) return;
|
|
292
|
+
|
|
293
|
+
// Sort by depth (deepest first) so children compute sizes before parents lay out
|
|
294
|
+
const sorted = [...pendingLayoutFlush].sort((a, b) => {
|
|
295
|
+
let da = 0; let n: any = a; while (n.parent) { da++; n = n.parent; }
|
|
296
|
+
let db = 0; n = b; while (n.parent) { db++; n = n.parent; }
|
|
297
|
+
return db - da; // deepest first
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
for (const fc of sorted) {
|
|
276
301
|
fc.resumeLayout();
|
|
277
302
|
}
|
|
278
303
|
pendingLayoutFlush.clear();
|