packages feed

gltf-codec 0.1.0.1 → 0.1.0.2

raw patch · 4 files changed

+32/−10 lines, 4 filesdep ~aesonPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: aeson

API changes (from Hackage documentation)

+ Codec.GLB: fromByteString :: ByteString -> Either (ByteOffset, String) GLB
+ Codec.GlTF: fromByteString :: ByteString -> Either String GlTF
- Codec.GlTF.Prelude: (.!=) :: () => Parser (Maybe a) -> a -> Parser a
+ Codec.GlTF.Prelude: (.!=) :: Parser (Maybe a) -> a -> Parser a
- Codec.GlTF.Prelude: withObject :: () => String -> (Object -> Parser a) -> Value -> Parser a
+ Codec.GlTF.Prelude: withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- Codec.GlTF.Prelude: withText :: () => String -> (Text -> Parser a) -> Value -> Parser a
+ Codec.GlTF.Prelude: withText :: String -> (Text -> Parser a) -> Value -> Parser a

Files

ChangeLog.md view
@@ -1,7 +1,9 @@ # Changelog for `gltf-codec` -## Unreleased changes+## [0.1.0.2] - 2021-01-22 +* Added `fromByteString` for GlTF and GLB data.+ ## [0.1.0.1] - 2020-06-21  * Added pattern synonyms for newtyped "allowed values".@@ -10,5 +12,6 @@  * Initial import. +[0.1.0.2]: https://gitlab.com/dpwiz/gltf/tree/v0.1.0.2 [0.1.0.1]: https://gitlab.com/dpwiz/gltf/tree/v0.1.0.1 [0.1.0.0]: https://gitlab.com/dpwiz/gltf/tree/v0.1.0.0
gltf-codec.cabal view
@@ -4,17 +4,17 @@ -- -- see: https://github.com/sol/hpack ----- hash: d999cb91b06d0be5cac1d0bcc4f794a7d8acb692a0265b6b8642b4fb7366c33f+-- hash: 2f52be424a4774dd085e4a5a0c1bc5235726c9e9e754b1a11fe95bcb0b5a2519  name:           gltf-codec-version:        0.1.0.1+version:        0.1.0.2 synopsis:       glTF scene loader description:    The package provides basic types to process JSON and "binary" files.                 No further conversion is performed to keep dependencies to a minimum. category:       Graphics author:         Alexander Bondarenko maintainer:     aenor.realm@gmail.com-copyright:      2020 Alexander Bondarenko+copyright:      2021 Alexander Bondarenko license:        BSD3 license-file:   LICENSE build-type:     Simple@@ -55,7 +55,7 @@       src   default-extensions: ApplicativeDo BlockArguments DeriveGeneric DuplicateRecordFields FlexibleContexts GeneralizedNewtypeDeriving LambdaCase OverloadedStrings PatternSynonyms RecordWildCards StrictData   build-depends:-      aeson >=1.4 && <1.5+      aeson >=1.4 && <1.6     , base >=4.7 && <5     , base64-bytestring >=1 && <2     , binary >=0.8.7 && <1
src/Codec/GLB.hs view
@@ -2,17 +2,33 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} -module Codec.GLB where+module Codec.GLB+  ( GLB(..)+  , Header(..)+  , Chunk(..)+  , fromByteString+  , fromFile+  ) where  import Prelude hiding (length) -import Data.Binary (Binary(..), decodeFileOrFail)+import Data.Binary (Binary(..), decodeFileOrFail, decodeOrFail) import Data.Binary.Get (ByteOffset, getWord32le, getByteString, isEmpty) import Data.Binary.Put (putByteString, putWord32le) import Data.ByteString (ByteString) import Data.Vector (Vector, unfoldrM) import Data.Word (Word32) import GHC.Generics (Generic)++import qualified Data.ByteString.Lazy as BSL++fromByteString :: ByteString -> Either (ByteOffset, String) GLB+fromByteString bs =+  case decodeOrFail (BSL.fromStrict bs) of+    Right (_leftovers, _bytesLeft, ktx) ->+      Right ktx+    Left (_leftovers, bytesLeft, err) ->+      Left (bytesLeft, err)  fromFile :: FilePath -> IO (Either (ByteOffset, String) GLB) fromFile = decodeFileOrFail
src/Codec/GlTF.hs view
@@ -1,17 +1,20 @@-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE DuplicateRecordFields #-}- module Codec.GlTF   ( GlTF(..)+  , fromByteString   , fromFile   , fromChunk   ) where +import Data.ByteString (ByteString)+ import qualified Data.Aeson as JSON  import Codec.GlTF.Root (GlTF(..))  import qualified Codec.GLB  as GLB++fromByteString :: ByteString -> Either String GlTF+fromByteString = JSON.eitherDecodeStrict'  fromFile :: FilePath -> IO (Either String GlTF) fromFile = JSON.eitherDecodeFileStrict'