wip fix
This commit is contained in:
parent
072b10d6ba
commit
ec6d906228
|
|
@ -219,12 +219,12 @@ const scanMeta = async (doc: DPage, sync: SyncConnection) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const comps: EPage["comps"] = {};
|
const comps: EPage["comps"] = {};
|
||||||
for (const [id, v] of Object.entries(mcomps)) {
|
// for (const [id, v] of Object.entries(mcomps)) {
|
||||||
const snap = snapshot.get("comp", id);
|
// const snap = snapshot.get("comp", id);
|
||||||
if (snap) {
|
// if (snap) {
|
||||||
comps[id] = { id, snapshot: await gzipAsync(snap.bin) };
|
// comps[id] = { id, snapshot: await gzipAsync(snap.bin) };
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return { meta: simplifyMeta(meta), comps, entry };
|
return { meta: simplifyMeta(meta), comps, entry };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export const applyRefIds = (
|
||||||
parentcomp.set("ref_ids", mref_ids);
|
parentcomp.set("ref_ids", mref_ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export const simplifyItem = (item: IItem) => {
|
||||||
newitem[k] = v;
|
newitem[k] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newitem as IItem;
|
return newitem as IItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -40,3 +41,12 @@ export const simplifyMeta = (allmeta: Record<string, IMeta>) => {
|
||||||
|
|
||||||
return smeta;
|
return smeta;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatBytes(bytes: number, decimals: number) {
|
||||||
|
if (bytes == 0) return "0 Bytes";
|
||||||
|
var k = 1024,
|
||||||
|
dm = decimals || 2,
|
||||||
|
sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
||||||
|
i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,10 @@ export type ClientEventObject = Parameters<typeof clientStartSync>[0]["events"];
|
||||||
export type ClientEvent = keyof ClientEventObject;
|
export type ClientEvent = keyof ClientEventObject;
|
||||||
|
|
||||||
const sendWs = (ws: WebSocket, msg: any) => {
|
const sendWs = (ws: WebSocket, msg: any) => {
|
||||||
if (WS_CONFIG.debug) console.log(`%c⬆`, "color:blue", msg);
|
const raw = packr.pack(msg);
|
||||||
ws.send(packr.pack(msg));
|
if (WS_CONFIG.debug)
|
||||||
|
console.log(`%c⬆`, "color:blue", formatBytes(raw.length, 0), msg);
|
||||||
|
ws.send(raw);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clientStartSync = async (arg: {
|
export const clientStartSync = async (arg: {
|
||||||
|
|
@ -192,7 +194,8 @@ const connect = (
|
||||||
ws.onmessage = async (e) => {
|
ws.onmessage = async (e) => {
|
||||||
const raw = e.data as Blob;
|
const raw = e.data as Blob;
|
||||||
const msg = packr.unpack(Buffer.from(await raw.arrayBuffer()));
|
const msg = packr.unpack(Buffer.from(await raw.arrayBuffer()));
|
||||||
if (WS_CONFIG.debug) console.log(`%c⬇`, `color:red`, msg);
|
if (WS_CONFIG.debug)
|
||||||
|
console.log(`%c⬇`, `color:red`, formatBytes(raw.size, 0), msg);
|
||||||
|
|
||||||
if (msg.type === SyncType.ClientID) {
|
if (msg.type === SyncType.ClientID) {
|
||||||
conf.client_id = msg.client_id;
|
conf.client_id = msg.client_id;
|
||||||
|
|
@ -271,3 +274,12 @@ const doAction = async <T>(arg: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatBytes(bytes: number, decimals: number) {
|
||||||
|
if (bytes == 0) return "0 Bytes";
|
||||||
|
var k = 1024,
|
||||||
|
dm = decimals || 2,
|
||||||
|
sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
||||||
|
i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue