diff --git a/src/adapter/debug.ts b/src/adapter/debug.ts index a91c6840..e6df8074 100644 --- a/src/adapter/debug.ts +++ b/src/adapter/debug.ts @@ -198,11 +198,17 @@ export function fromSnapshot(events: string[]): number[] { } } - out.push(...flushTable(new Map(strings.map((x, i) => [x, i])))); + const strs = flushTable(new Map(strings.map((x, i) => [x, i]))); + for (let i = 0; i < strs.length; i++) { + out.push(strs[i]); + } if (unmounts.length > 0) { out.push(MsgTypes.REMOVE_VNODE, unmounts.length, ...unmounts); } - out.push(...operations); + + for (let i = 0; i < operations.length; i++) { + out.push(operations[i]); + } return out; } diff --git a/src/adapter/protocol/events.ts b/src/adapter/protocol/events.ts index 753d3665..ce4a688e 100644 --- a/src/adapter/protocol/events.ts +++ b/src/adapter/protocol/events.ts @@ -93,9 +93,12 @@ export function flush(commit: Commit) { if (unmountIds.length > 0) { msg.push(MsgTypes.REMOVE_VNODE, unmountIds.length, ...unmountIds); } - msg.push(...operations); + + for (let i = 0; i < operations.length; i++) { + msg.push(operations[i]); + } if (stats !== null) { - msg.push(...stats2ops(stats)); + stats2ops(stats, msg); } return { type: "operation_v2", data: msg }; @@ -201,7 +204,8 @@ export function applyEvent(store: Store, type: keyof DevtoolEvents, data: any) { store.profiler.isSupported.value = !!data.supportsProfiling; } if (!store.profiler.supportsRenderReasons.value) { - store.profiler.supportsRenderReasons.value = !!data.supportsRenderReasons; + store.profiler.supportsRenderReasons.value = + !!data.supportsRenderReasons; } if (!store.supports.hooks.value) { diff --git a/src/adapter/shared/stats.ts b/src/adapter/shared/stats.ts index 2dcabdd9..0b0e7fa4 100644 --- a/src/adapter/shared/stats.ts +++ b/src/adapter/shared/stats.ts @@ -113,44 +113,52 @@ export function createStats(): Stats { }; } -export function stats2ops(stats: Stats): number[] { - return [ - MsgTypes.COMMIT_STATS, - ...stats.roots, - ...stats.classComponents, - ...stats.functionComponents, - ...stats.fragments, - ...stats.forwardRef, - ...stats.memo, - ...stats.suspense, - ...stats.elements, - stats.text, - - ...stats.keyed, - ...stats.unkeyed, - ...stats.mixed, - - stats.mounts.components, - stats.mounts.elements, - stats.mounts.text, - stats.updates.components, - stats.updates.elements, - stats.updates.text, - stats.unmounts.components, - stats.unmounts.elements, - stats.unmounts.text, - - // Single child types - stats.singleChildType.roots, - stats.singleChildType.classComponents, - stats.singleChildType.functionComponents, - stats.singleChildType.fragments, - stats.singleChildType.forwardRef, - stats.singleChildType.memo, - stats.singleChildType.suspense, - stats.singleChildType.elements, - stats.singleChildType.text, - ]; +export function stats2ops(stats: Stats, out: number[]): void { + out.push(MsgTypes.COMMIT_STATS); + + pushStatsChildren(out, stats.roots); + pushStatsChildren(out, stats.classComponents); + pushStatsChildren(out, stats.functionComponents); + pushStatsChildren(out, stats.fragments); + pushStatsChildren(out, stats.forwardRef); + pushStatsChildren(out, stats.memo); + pushStatsChildren(out, stats.suspense); + pushStatsChildren(out, stats.elements); + + out.push(stats.text); + + pushStatsChildren(out, stats.keyed); + pushStatsChildren(out, stats.unkeyed); + pushStatsChildren(out, stats.mixed); + + out.push(stats.mounts.components); + out.push(stats.mounts.elements); + out.push(stats.mounts.text); + out.push(stats.updates.components); + out.push(stats.updates.elements); + out.push(stats.updates.text); + out.push(stats.unmounts.components); + out.push(stats.unmounts.elements); + out.push(stats.unmounts.text); + + // Single child types + out.push(stats.singleChildType.roots); + out.push(stats.singleChildType.classComponents); + out.push(stats.singleChildType.functionComponents); + out.push(stats.singleChildType.fragments); + out.push(stats.singleChildType.forwardRef); + out.push(stats.singleChildType.memo); + out.push(stats.singleChildType.suspense); + out.push(stats.singleChildType.elements); + out.push(stats.singleChildType.text); +} + +function pushStatsChildren(out: number[], stats: StatsChildren): void { + out.push(stats[0]); + out.push(stats[1]); + out.push(stats[2]); + out.push(stats[3]); + out.push(stats[4]); } export interface ParsedStats {