UNPKG

2.7 kBSource Map (JSON)View Raw
1{"version":3,"file":"resolved-nodes.js","names":["resolvedNodesCacheReducer","state","Map","action","type","key","nodes","payload","existingResolvedNodes","get","nodeId","resolvedFields","entries","previouslyResolvedNodeFields","set","merge"],"sources":["../../../src/redux/reducers/resolved-nodes.ts"],"sourcesContent":["import merge from \"lodash/merge\"\nimport { IGatsbyState, ActionsUnion } from \"../types\"\n\nexport const resolvedNodesCacheReducer = (\n state: IGatsbyState[\"resolvedNodesCache\"] = new Map(),\n action: ActionsUnion\n): IGatsbyState[\"resolvedNodesCache\"] => {\n switch (action.type) {\n case `DELETE_CACHE`:\n case `CREATE_NODE`:\n case `DELETE_NODE`:\n return new Map()\n\n case `SET_RESOLVED_NODES`: {\n const { key, nodes } = action.payload\n const existingResolvedNodes = state.get(key)\n if (existingResolvedNodes) {\n // merge new resolved fields for given type with previously existing ones\n for (const [nodeId, resolvedFields] of nodes.entries()) {\n const previouslyResolvedNodeFields = existingResolvedNodes.get(nodeId)\n if (previouslyResolvedNodeFields) {\n // merge new resolved fields for given node id with previously existing ones\n existingResolvedNodes.set(\n nodeId,\n merge(previouslyResolvedNodeFields, resolvedFields)\n )\n } else {\n // we didn't have any resolved fields for this node id, so we can just set new\n // ones as-is\n existingResolvedNodes.set(nodeId, resolvedFields)\n }\n }\n } else {\n // we didn't have resolved fields for this type yet, so\n // we can just set it\n state.set(key, nodes)\n }\n return state\n }\n\n default:\n return state\n }\n}\n"],"mappings":";;;;;AAAA;AAGO,MAAMA,yBAAyB,GAAG,CACvCC,KAAyC,GAAG,IAAIC,GAAG,EAAE,EACrDC,MAAoB,KACmB;EACvC,QAAQA,MAAM,CAACC,IAAI;IACjB,KAAM,cAAa;IACnB,KAAM,aAAY;IAClB,KAAM,aAAY;MAChB,OAAO,IAAIF,GAAG,EAAE;IAElB,KAAM,oBAAmB;MAAE;QACzB,MAAM;UAAEG,GAAG;UAAEC;QAAM,CAAC,GAAGH,MAAM,CAACI,OAAO;QACrC,MAAMC,qBAAqB,GAAGP,KAAK,CAACQ,GAAG,CAACJ,GAAG,CAAC;QAC5C,IAAIG,qBAAqB,EAAE;UACzB;UACA,KAAK,MAAM,CAACE,MAAM,EAAEC,cAAc,CAAC,IAAIL,KAAK,CAACM,OAAO,EAAE,EAAE;YACtD,MAAMC,4BAA4B,GAAGL,qBAAqB,CAACC,GAAG,CAACC,MAAM,CAAC;YACtE,IAAIG,4BAA4B,EAAE;cAChC;cACAL,qBAAqB,CAACM,GAAG,CACvBJ,MAAM,EACN,IAAAK,cAAK,EAACF,4BAA4B,EAAEF,cAAc,CAAC,CACpD;YACH,CAAC,MAAM;cACL;cACA;cACAH,qBAAqB,CAACM,GAAG,CAACJ,MAAM,EAAEC,cAAc,CAAC;YACnD;UACF;QACF,CAAC,MAAM;UACL;UACA;UACAV,KAAK,CAACa,GAAG,CAACT,GAAG,EAAEC,KAAK,CAAC;QACvB;QACA,OAAOL,KAAK;MACd;IAEA;MACE,OAAOA,KAAK;EAAA;AAElB,CAAC;AAAA"}
\No newline at end of file