sourcemap 0.1.6.1 → 0.1.7
raw patch · 5 files changed
+28/−14 lines, 5 filesdep ~bytestring
Dependency ranges changed: bytestring
Files
- ChangeLog.md +10/−0
- sourcemap.cabal +4/−3
- src/SourceMap.hs +10/−7
- src/VLQ.hs +2/−2
- test/Node.hs +2/−2
+ ChangeLog.md view
@@ -0,0 +1,10 @@+# 0.1.7+- support aeson-2.0 (#1)++# 0.1.6.1+- allow newer base++----++# 0.1.6 and earlier+releases done by the original author, Chris Done
sourcemap.cabal view
@@ -1,5 +1,5 @@ name: sourcemap-version: 0.1.6.1+version: 0.1.7 synopsis: Implementation of source maps as proposed by Google and Mozilla. description: Implementation of source maps, revision 3, proposed by Google and Mozilla here <https://wiki.mozilla.org/DevTools/Features/SourceMap> and here@@ -13,7 +13,8 @@ copyright: 2012 Chris Done category: Development build-type: Simple-cabal-version: >=1.10+cabal-version: 1.18+extra-doc-files: ChangeLog.md source-repository head type: git@@ -26,7 +27,7 @@ other-modules: VLQ hs-source-dirs: src build-depends: base >= 4.5 && < 5,- bytestring >= 0.10.2 && < 0.11,+ bytestring >= 0.10.2, aeson, unordered-containers, attoparsec,
src/SourceMap.hs view
@@ -12,18 +12,21 @@ import Control.Monad hiding (forM_) import Control.Monad.ST import Data.Aeson hiding ((.=))+#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.KeyMap as Map+#else+import qualified Data.HashMap.Lazy as Map+#endif import Data.ByteString.Lazy (ByteString)-import qualified Data.ByteString.Lazy as Bytes-import Data.ByteString.Lazy.UTF8 (fromString)+import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy.UTF8 as U import Data.ByteString.Builder (Builder(), lazyByteString, toLazyByteString) import Data.Foldable (forM_)-import qualified Data.HashMap.Lazy as Map #if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>)) #endif import Data.List import Data.Maybe-import Data.Ord import Data.STRef import Data.Text (Text) import Data.Text.Lazy.Encoding (decodeUtf8)@@ -43,7 +46,7 @@ -- | Encode the mappings to the source map format. encodeMappings :: [FilePath] -> [Text] -> [Mapping] -> ByteString-encodeMappings sources names = go . sortBy (comparing mapGenerated) where+encodeMappings sources names = go . sortOn mapGenerated where go mappings = runST $ do -- State. prevGenCol <- newSTRef 0@@ -60,11 +63,11 @@ updating prevGenLine $ \previousGeneratedLine -> if posLine mapGenerated /= previousGeneratedLine then do prevGenCol .= 0- result += Bytes.replicate (fromIntegral (posLine mapGenerated - previousGeneratedLine))+ result += B.replicate (fromIntegral (posLine mapGenerated - previousGeneratedLine)) (fromIntegral (fromEnum ';')) return (posLine mapGenerated) else do when (i > 0)- (result += fromString ",")+ (result += U.fromString ",") return previousGeneratedLine -- Original generated column (also offsetted from previous entries). updating prevGenCol $ \previousGeneratedColumn -> do
src/VLQ.hs view
@@ -102,8 +102,8 @@ -- | Encode the given base 64 character to a number. decodeBase64 :: Word8 -> Word8-decodeBase64 i = fromMaybe (error "Not a valid base 65 digit.")- (lookup i (zip base64Chars [0..]))+decodeBase64 i = maybe (error "Not a valid base 65 digit.") toEnum+ (elemIndex i base64Chars) -- | Makes the code more familiar to read. Shift-left. (<<) :: Int32 -> Int -> Int32
test/Node.hs view
@@ -53,8 +53,8 @@ ["var s = require('source-map');" ,"" ,"var generator = new s.SourceMapGenerator({"] ++- [intercalate "," (["file: " ++ show smFile] ++- ["sourceRoot: " ++ show root | Just root <- [smSourceRoot]])] +++ [intercalate "," (("file: " ++ show smFile) :+ ["sourceRoot: " ++ show root | Just root <- [smSourceRoot]])] ++ ["});" ,""] ++ map addMapping smMappings ++