The US trade deficit shrank unexpectedly by over 4 percent in June, as a weak dollar boosted exports to an all-time high, according to official figures released Tuesday.   US Commerce Department statistics show the June trade deficit at $56.8 billion, down from $59.2 billion in May. Exports of goods and services rose 4 percent to a record $164.4 billion, offsetting a 1.8 percent rise in imports.    Although the dollar has recently gained ground against the euro and other currencies, its earlier decline helped export orders by making US goods cheaper abroad.    US Trade Representative Susan Schwab said the strong export growth showed that US companies were internationally competitive.    The rise in imports was brought about by a 14.6 percent surge in petroleum imports, but leaving oil aside, imports declined in June as the credit crunch and housing slump hit consumer demand.   Imports fell in nearly all categories except commodities, and exports peaked in industrial supplies and materials, food and beverage products and consumer goods.   The overall trade deficit in June was at its lowest since March this year, and the deficit in non-petroleum products was the smallest since February 2003.     *          *          *