将页面依赖的资源与打包资源对比合并
@param resources
@param ret
@param fullPackHit 是否要求资源整体命中打包对象
@returns {Array}
function getPkgResource(resources, ret, fullPackHit) {
    var pkgList = {};
    var list = [];
    var handled = {};
    var idList = resources.map(function (resource) {
        return resource.id;
    });
    var resourceMap = {};
    resources.forEach(function (resource) {
        resourceMap[resource.id] = resource;
    });

    function fullPackPass(resource) {
        if (!fullPackHit) {
            return true;
        }
        var pkg = ret.map.pkg[ret.map.res[resource.id].pkg];
        var unHit = pkg.has.filter(function (id) {
            return idList.indexOf(id) == -1;
        });
        return unHit.length === 0;
    }

    function addPkg(id, pkg, srcId) {
        if (pkgList[id])
            return;
        var head = false;
        pkg.has.forEach(function (inPkg) {
            handled[inPkg] = true;
            if (resourceMap[inPkg]) {
                head = head || (resourceMap[inPkg].head || false);
            }
        });
        pkgList[id] = true;
        list.push({
            type: 'pkg',
            id: id,
            srcId: srcId,
            head: head
        });
    }

    resources.forEach(function (resource) {
        var id = resource.id;
        if (handled[id]) {
            return false;
        }
        //当前资源是pack打包后的结果
        if (ret.packMap.fileToPack[id]) {
            var pack = ret.packMap.fileToPack[id];
            addPkg(pack.id, pack.pkg, id);
            return true;
        }
        var res = ret.map.res[id];
        handled[id] = true;
        if (res.pkg && fullPackPass(resource)) {
            addPkg(res.pkg, ret.map.pkg[res.pkg], id);
        }
        else {
            list.push({
                type: 'res',
                id: id,
                single: resource.single,
                head: resource.head
            });
        }
    });
    return list;
}