Coder Social home page Coder Social logo

readium / r2-streamer-swift Goto Github PK

View Code? Open in Web Editor NEW
22.0 41.0 50.0 139.13 MB

License: BSD 3-Clause "New" or "Revised" License

Objective-C 0.24% Swift 52.83% JavaScript 2.12% CSS 1.59% HTML 42.95% Ruby 0.17% C 0.09% Makefile 0.01%
epub readium-2 swift ios streamer cbz

r2-streamer-swift's Introduction

⚠️ ᴛʜɪs ʀᴇᴘᴏsɪᴛᴏʀʏ ɪs ᴅᴇᴘʀᴇᴄᴀᴛᴇᴅ ⚠️

We moved all the r2-*-swift modules to a single repository: swift-toolkit.

r2-streamer-swift's People

Contributors

acamill avatar aferditamuriqi avatar alexc4m avatar ettore avatar iaomw avatar iosdevedrlab avatar johanpoirier avatar llemeurfr avatar mickael-menu avatar mickael-menu-mantano avatar olivierkorner avatar openm1nd avatar rkwright avatar stevenzeck avatar ullstrm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r2-streamer-swift's Issues

Add support for Media Overlays

The streamer should parse Media Overlay SMIL files referenced in the Package Document manifest.
Parsed information shoud be stored in a tree-like structure that can be serialized to JSON.

r2-streamer-swift doesn't build in empty Xcode Swift project

When I create a new project and I add the r2-streamer-swift pod, I can't build the project. There are a lot of missing types: MediaType, Encryption, EPUBLayout, essentially a bunch of stuff from R2Shared - however I see no issues building R2 shared, and r2shared does seem to be listed as a framework of R2Streamer.

I tried some naive poking around to see if I could fix it (changing swift version from 5 -> 4.2, adding CoreMedia as a framework) but nada.

(devenv: Xcode 14, was defaulted to Swift 5, but tried 4.2 as well, using head of 'develop' branch)

Special properties in the resources Links

In the Go version of the streamer, some properties are converted this way (see the contains nested array) :

{
    "href": "xhtml/svg-007.xhtml",
    "type": "application/xhtml+xml",
    "properties": {
        "contains": [
            "svg"
        ]
    }
}

In the swift streamer the Link's properties are stored in a simple String array.

Replace ObjectMapper by Marshal

The mapping library ObjectMapper is too strongly coupled with the model.

We only need Marshaling, but with objectmapper we implement Unmarshalling functions, then the it create the Marshaling methods by reflection.

Detailed explanations here.

Failed to build the module using cocoapods

after installing the module using pod install building the app from xcode fails with the following error

`
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not deserialize extension: top-level value not found
Cross-reference to module 'R2Streamer'
... GCDWebServerResponse

  1. While deserializing SIL function "$sSo20GCDWebServerResponseC8R2Shared8Loggable0D8StreamerAcDP3logyyAC13SeverityLevelO_ypSgS3SSitFZTW"
    0 swift 0x0000000109b1aa13 PrintStackTraceSignalHandler(void*) + 51
    1 swift 0x0000000109b1a1e6 SignalHandler(int) + 358
    2 libsystem_platform.dylib 0x00007fff634fab1d _sigtramp + 29
    3 libsystem_platform.dylib 0x00007fa42b0b1c00 _sigtramp + 3350950144
    4 libsystem_c.dylib 0x00007fff633d0a1c abort + 120
    5 swift 0x000000010637a314 swift::ModuleFile::fatal(llvm::Error) + 1828
    6 swift 0x0000000106393138 swift::ModuleFile::getDeclContext(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2216
    7 swift 0x00000001063922a9 swift::ModuleFile::readConformanceChecked(llvm::BitstreamCursor&, swift::GenericEnvironment*) + 2233
    8 swift 0x00000001063909b0 swift::TypeDeserializer::getTypeCheckedImpl() + 9072
    9 swift 0x000000010638c583 swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 243
    10 swift 0x000000010639fb34 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 628
    11 swift 0x00000001063b4385 swift::SILDeserializer::getAllSILFunctions() + 1349
    12 swift 0x000000010643b804 swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 180
    13 swift 0x0000000105a6a683 swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*) + 147
    14 swift 0x0000000105766375 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 33925
    15 swift 0x000000010575a6e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
    16 swift 0x00000001056e7be3 main + 1219
    17 libdyld.dylib 0x00007fff632f92e5 start + 1
    18 libdyld.dylib 0x00000000000000b2 start + 2630905294
    error: Abort trap: 6 (in target 'R2Streamer' from project 'Pods')`

environment
Xcode 11.2.1
Catalina 10.15.1
branch develop

Any hint ?

Use Absolute URIs for manifest resources

As a follow-up to #36 we're moving away from using paths relative to the OPF in the streamer.

We'll now stictly use absolute paths based on the root of the container instead.

The following resource types that we parsed are affected:

OPF
Navigation Document
NCX
SMIL
While encryption.xml parsing is not as directly affected by this change, we need to make sure that we still match resources correctly after this change.

In the streamer, we should now have absolute URIs in the following elements:

spine
resources
all ToC collections (toc, landmarks, loi, page-list, ...)
media overlay APIs

Need to add ! in two files

When you import r2streamer you need to go into
EPUBParser row 199 and and add a ! here: data: smilDataOptional!
Same with PDFParser on row 195: data: optionalData!

It would be good not to have to do this everytime you do pod update/install

Zip resources fetching randomly failing (Have to disable WkWebVIEW caching)

While implementing the font deobfuscation I found that the WKWebView caching was enabled by default. After disabling it for testing purpose I started to encounter problems when fetching resources from ZipInputStream.

This bug is also existing in the previous versions of the project if you add this piece of code to the launcher in the SpineItemViewController:

        if #available(iOS 9.0, *)
        {
            let websiteDataTypes = NSSet(array: [WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache])
            let date = NSDate(timeIntervalSince1970: 0)

            WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes as! Set<String>, modifiedSince: date as Date, completionHandler:{ })
        }
        else
        {
            var libraryPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, false).first!
            libraryPath += "/Cookies"

            do {
                try FileManager.default.removeItem(atPath: libraryPath)
            } catch {
                print("error")
            }
            URLCache.shared.removeAllCachedResponses()
        }

Aligning parsing results with Kotlin

As seen in readium/swift-toolkit#96, the Kotlin and Swift parsers are not producing strictly the same Publication objects. We should check the parsers to make sure they produce identical Publication across platforms.

A very helpful thing to have would be a shared Git repository of test cases: book files + associated JSON RWPM, to validate automatically the parsers.

Add CBZ format support

This should not be long to implement and it will clear the way for future format additions.

Tap gesture in javascript does not respect length of tap

A tap event is always sent from the javascript even if the touch event is long.

Steps to reproduce:

  • Begin a touch in the webview
  • Hold the touch for a couple of seconds without moving the finger
  • Release
  • Tap event is now sent via webkit.messageHandlers

There should instead be a check wether the touch was "short enough" for it to be recognised as a tap.

Unfortunately I do not know what the default value of a single tap in iOS is, but around 0.5 seconds could probably be a value to aim for.

Ps. This needs to be implemented in a more sophisticated way if support for double tap was to be implemented. Ds.

Parse subjects metadata

The parser should parse the <subject> elements of the metadata and add them to the Publication's metadata properties.

Release 1.2.5 doesn't compile since Xcode 12.5

Hi,

The last stable release of r2-streamer-swift (1.2.5) doesn't compile since Xcode 12.5.
It's because the version of CryptoSwift used by r2-streamer is not compatible with Xcode 12.5 :

Capture d’écran 2021-04-29 à 15 21 02

Could you please upgrade CryptoSwift version to at least 1.3.2 and make a new release ?

Ignore nil values during serialization of the WebPub Manifest

If not done before, will be fixed by fixing issue #13
From :

"links" : [
    {
      "href" : "images\/cover.jpg",
      "properties" : [

      ],
      "type" : "image\/jpeg",
      "rel" : [
        "cover"
      ]
    },
    //...
]

To :

"links" : [
    {
      "href" : "images\/cover.jpg",
      "type" : "image\/jpeg",
      "rel" : [
        "cover"
      ]
    }, 
    //...
]

The project does not compile on a case-sensitive file system

The project does not compile on a case-sensitive file system, because a few directory references in the project file are specified with capital letters while the actual directory on the file system are named with lower letters.

I've created a PR for this.

Use an array for representing the Contributors Roles

As it's been pointed out in the EPUB 3 maintenance group, EPUB 3.1 doesn't allow content producers to indicate more than a single role for a contributor.

In EPUB 3.0.x it was possible to indicate as many roles as you wanted:

<dc:contributor id="Olaf">Dr. Olaf Hoffmann</dc:contributor>
<meta refines="#Olaf" property="file-as">Dr. Hoffmann, Olaf</meta>
<meta refines="#Olaf" property="role" scheme="marc:relators">mrk</meta>
<meta refines="#Olaf" property="role" scheme="marc:relators">art</meta>
<meta refines="#Olaf" property="role" scheme="marc:relators">ill</meta>
<meta refines="#Olaf" property="role" scheme="marc:relators">aui</meta>
<meta refines="#Olaf" property="role" scheme="marc:relators">pfr</meta>

The Readium Web Publication Manifest is a direct descendent of the BFF project and was designed with 3.1 round-trippability in mind.

But in the context of Readium-2, we want to maximize compatibility with EPUB 2.0.1 and any 3.x revision, which means that instead of having a single string allowed for the role in a contributor element, we need to move to an array of string.

Parse spine or manifest item Link properties

Add following native properties (as opposed to and instead of entries in the properties property of Link) to Link model for page, spread, layout, orientation et overflow à la classe Link, qui remplace les propriétés rendition:* et page-spread-*

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.