Match-id-b078d7aff2ccd280f952cbc2be1dce941dbb61ab

This commit is contained in:
* 2023-02-17 17:37:23 +08:00
parent 2f7787c1cf
commit 2293727e6b
1 changed files with 20 additions and 2 deletions

View File

@ -25,6 +25,7 @@ function makeStoreSnapshot({ type, data }) {
return snapshot; return snapshot;
} }
<<<<<<< Updated upstream
// safely serializes variables containing values wrapped in Proxy object // safely serializes variables containing values wrapped in Proxy object
function getType(value) { function getType(value) {
if (!value) return 'nullish'; if (!value) return 'nullish';
@ -41,6 +42,9 @@ function getType(value) {
} }
function makeProxySnapshot(obj) { function makeProxySnapshot(obj) {
const type = getType(obj); const type = getType(obj);
=======
function makeProxySnapshot(obj, visited: any[] = []) {
>>>>>>> Stashed changes
let clone; let clone;
try { try {
@ -54,6 +58,7 @@ function makeProxySnapshot(obj) {
if (type === 'function') { if (type === 'function') {
return obj.toString(); return obj.toString();
} }
<<<<<<< Updated upstream
// VNODE // VNODE
if (type === 'vnode') { if (type === 'vnode') {
return { return {
@ -93,14 +98,23 @@ function makeProxySnapshot(obj) {
} }
// ARRAY // ARRAY
if (type === 'array') { if (type === 'array') {
=======
if (Array.isArray(obj)) {
if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`;
>>>>>>> Stashed changes
clone = []; clone = [];
obj.forEach(item => clone.push(makeProxySnapshot(item))); obj.forEach(item => clone.push(makeProxySnapshot(item, visited.concat([obj]))));
return clone; return clone;
<<<<<<< Updated upstream
} }
// OBJECT // OBJECT
if (type === 'object') { if (type === 'object') {
=======
} else if (typeof obj === 'object') {
if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`;
>>>>>>> Stashed changes
clone = {}; clone = {};
Object.entries(obj).forEach(([id, value]) => (clone[id] = makeProxySnapshot(value))); Object.entries(obj).forEach(([id, value]) => (clone[id] = makeProxySnapshot(value, visited.concat([obj]))));
return clone; return clone;
} }
// PRIMITIVE // PRIMITIVE
@ -134,6 +148,10 @@ function getAffectedComponents() {
const keys = Object.keys(allStores); const keys = Object.keys(allStores);
let res = {}; let res = {};
keys.forEach(key => { keys.forEach(key => {
if (!allStores[key].$config.state._horizonObserver.keyVNodes) {
res[key] = [];
return;
}
const subRes = new Set(); const subRes = new Set();
const process = Array.from(allStores[key].$config.state._horizonObserver.keyVNodes.values()); const process = Array.from(allStores[key].$config.state._horizonObserver.keyVNodes.values());
while (process.length) { while (process.length) {