Code Monkey home page Code Monkey logo

r2-navigator-swift's Introduction

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

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

r2-navigator-swift's People

Contributors

acamill avatar aferditamuriqi avatar alexc4m avatar cbaltzer avatar classwizard avatar ehapmgs avatar ettore avatar iaomw avatar iosdevedrlab avatar iyaseen avatar jerome65536 avatar jokez80 avatar llemeurfr avatar maverlck avatar mickael-menu avatar mickael-menu-mantano avatar nikitaevidentpoint avatar openm1nd avatar rocxteady avatar sebbo176 avatar stevenzeck avatar tooolbox avatar ullstrm avatar

Stargazers

 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

r2-navigator-swift's Issues

second page word hi-lighter is not working in landscape

i am using readium library for epub and i am trying with javascript to select the word by it's text-id . In landscape it's working fine for 1st page but for second page it's not working. i am using changeTextColor(fragmentId: String) function for hi-lighter , in this function fragmentId printing correctly for second page also, but text is not getting hi-lighted.

func changeTextColor(fragmentId: String) {
          print(fragmentId)
       let scc = "document.getElementById('\(fragmentId)').style.color='#EA4343'; setTimeout(function(){ document.getElementById('\(fragmentId)').style.color = \"#000000\";}, 1500);"
       
       let script = "spread.eval('', \"\(scc.replacingOccurrences(of: "\"", with: "\\\""))\");"

        webView.evaluateJavaScript(script, completionHandler: nil)
}

RTL navigation is broken

Navigating through an RTL EPUB is currently broken in the Swift Navigator. I think it's caused by the changes I made a few months ago for the FXL 2-page spreads.

HTML <media> elements keep playing after turning pages

When turning an EPUB's pages with <media> elements playing, the playback is not interrupted. It keeps going until the page is destroyed which can take 2 additional page turns for FXL.

/// Number of positions (as in `Publication.positionList`) to preload before the current page.
public var preloadPreviousPositionCount = 2
/// Number of positions (as in `Publication.positionList`) to preload after the current page.
public var preloadNextPositionCount = 6

Two questions:

  • Should we interrupt playback when navigating to another resource? (I think so)
  • Should we interrupt playback in a single reflowable resource, when the element is out of screen? (I'm not so sure)

tapping left or right to change pages goes the wrong direction.

this can be reproduced easily when tapping a bit quicker to get to the next or previous page.

it seems like the tap is registered while the page is still in motion and triggers the wrong action.

this also can be seen when reached the very end of a publication and trying to tap to go next, then instead the toggle navigation bar is executed.

Customizing the default user settings

We want to change the default value of "Publishers default" to true. I can change in the imported r2-navigator but then you need to remember this if we upgrade and thats not good.

iOS versions 12 & 13 can't open a book since Readium 2.1.0

Bug Report

Try to present the ebook reader

What happened?

Stuck on loading screen (just an activity indicator rotates in the center of the screen)

Expected behavior

An ebook first page should be shown

How to reproduce?

Just try to present the ebook reader

Environment

iOS 13, 12

Readium versions

  • r2-shared-swift: 2.1.0
  • r2-streamer-swift: 2.1.0
  • r2-navigator-swift: 2.1.0
  • r2-opds-swift: 2.1.0
  • r2-lcp-swift: 2.1.0

Development environment

macOS: 11.6
platform: x86_64
carthage: 0.38.0

Testing device

  • iOS version: iOS 12
  • Model (e.g. iPhone 6):
  • Is it an emulator? No
  • iOS version: iOS 13
  • Model (e.g. iPhone 6S):
  • Is it an emulator? Yes

Additional context

I see only this error:

❌ EPUBSpreadView.swift:162: Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}

Please, note that I am using "readium" variable in the JS that throws this error. The problem still persist If I remove all of my custom js

Simulator Screen Shot - iPhone 6s - 2021-10-06 at 14 46 07

Webview Crash

Hi!

I updated now to r2-navigator-swift:1.1.4 and the webview crashes sometimes now when i try to start a EPUBViewController.

The only relevant change I did is to initialize the EPUBViewController with a resourcesServer and configuration object. Is there another step that I missed or something? :)

My code to start EPUBViewController.

let customInsets: [UIUserInterfaceSizeClass: EPUBContentInsets] = [
  .regular: (top: 64, bottom: 44)
]

var configuration = EPUBNavigatorViewController.Configuration()
configuration.contentInset = customInsets

epubViewer = EPUBNavigatorViewController(
    publication: publication,
    license: license,
    initialLocation: initialLocation,
    resourcesServer: server!,
    config: configuration
    )

Code that breaks - Webview.swift:

/// A custom web view which:
///  - Forwards selection actions to an EditingActionsController.
final class WebView: WKWebView {

    private let editingActions: EditingActionsController

    init(editingActions: EditingActionsController) {
        self.editingActions = editingActions
        super.init(frame: .zero, configuration: .init()) // <<< Crashes on this line
    }

Error log:

2019-10-02 11:04:04.379266+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.379551+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.393334+0200 Test-Bibblix[78441:944383] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(
	0   UIKitCore                           0x000000010e46fdda kFixedAnimationDuration_block_invoke_5 + 107
	1   libdispatch.dylib                   0x000000010691cdb5 _dispatch_client_callout + 8
	2   libdispatch.dylib                   0x000000010691e83c _dispatch_once_callout + 66
	3   UIKitCore                           0x000000010e46fd6d +[UIView(Animation) setAnimationsEnabled:] + 76
	4   UIKitCore                           0x000000010e46febb +[UIView(Animation) performWithoutAnimation:] + 84
	5   UIKitCore                           0x000000010e4327a6 -[UIImageView _updateImageViewForOldImage:newImage:] + 461
	6   UIKitCore                           0x000000010e42d649 -[UIImageView setImage:] + 369
	7   UIKitCore                           0x000000010e42c680 -[UIImageView initWithImage:] + 246
	8   UIKitCore                           0x000000010e40a0bc CreateScrollIndicator + 401
	9   UIKitCore                           0x000000010e4098af -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 149
	10  UIKitCore                           0x000000010e3f998f -[UIScrollView _updateForChangedScrollIndicatorRelatedInsets] + 165
	11  WebKit                              0x0000000117db06bb -[WKScrollView initWithFrame:] + 137
	12  WebKit                              0x0000000117cab3d8 -[WKWebView _initializeWithConfiguration:] + 4866
	13  WebKit                              0x0000000117cac51c -[WKWebView initWithFrame:configuration:] + 98
	14  R2Navigator                         0x0000000102fa425b $s11R2Navigator14EPUBSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0K5InsetAC0A6Shared11PublicationC_AA0C0V10Foundation0H0VSgAN7LocatorVAN07ContentL5StyleOAN07ReadingN0OAA04UserP0CSbAA07EditingT10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 603
	15  R2Navigator                         0x0000000102fb8a74 $s11R2Navigator24EPUBReflowableSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0L5InsetAC0A6Shared11PublicationC_AA10EPUBSpreadV10Foundation0I0VSgAN7LocatorVAN07ContentM5StyleOAN07ReadingO0OAA04UserQ0CSbAA07EditingU10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 260
	16  R2Navigator                         0x0000000102f92857 $s11R2Navigator27EPUBNavigatorViewControllerC010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA010PaginationD0C_Si0A6Shared7LocatorVtFTf4dnnn_n + 1287
	17  R2Navigator                         0x0000000102f8d8ff $s11R2Navigator27EPUBNavigatorViewControllerCAA010PaginationD8DelegateA2aDP010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA0fD0C_Si0A6Shared7LocatorVtFTW + 15
	18  R2Navigator                         0x0000000102f96210 $s11R2Navigator14PaginationViewC04loadD033_E5B6E692643F2C92B3A81F0E647DD191LL2at8locationAA04PageD0_So6UIViewCXcSgSi_0A6Shared7LocatorVtF + 272
	19  R2Navigator                         0x0000000102f95cf4 $s11R2Navigator14PaginationViewC15setCurrentIndex33_E5B6E692643F2C92B3A81F0E647DD191LL_8locationySi_0A6Shared7LocatorVSgtF + 1972
	20  R2Navigator                         0x0000000102f94c9c $s11R2Navigator14PaginationViewC13reloadAtIndex_8location9pageCount18readingProgressionySi_0A6Shared7LocatorVSgSiAH07ReadingL0OtF + 604
	21  R2Navigator                         0x0000000102f8b4c0 $s11R2Navigator27EPUBNavigatorViewControllerC13reloadSpreads33_E158D153422E135CD1F26B7E7CA576EFLL2aty0A6Shared7LocatorVSg_tF + 1280
	22  R2Navigator                         0x0000000102f89952 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfc + 978
	23  R2Navigator                         0x0000000102f89564 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfC + 100
	24  Test-Bibblix                        0x0000000101bf41d1 $s12Test_Bibblix18EpubViewControllerC13initNavigator11publication15initialLocation7license15callbackHandler6servery8R2Shared11PublicationC_AJ7LocatorVSgAJ10DRMLicense_pSgAA015CordovaCallbackM0_p0O8Streamer0Q6ServerCSgtF + 1361

Cartfile

github "weichsel/ZIPFoundation" == 0.9.8
github "krzyzanowskim/CryptoSwift" == 0.15.0
github "readium/r2-shared-swift" == 1.3.4
github "readium/r2-streamer-swift" == 1.1.6
github "readium/r2-navigator-swift" == 1.1.4
github "readium/r2-lcp-wrapper-swift" == 1.0.8
github "readium/r2-lcp-swift" == 1.1.2
github "onevcat/Kingfisher" == 4.10.1
github "jdg/MBProgressHUD"
github "stephencelis/SQLite.swift" == 0.11.5
github "swisspol/GCDWebServer" == 3.5.2
github "edrlab/Fuzi" == 2.2.2
github "tadija/AEXML" == 4.3.3
github "dexman/Minizip"

2-pages spread is broken with reflowable EPUB

When switching to 2 columns on a reflowable EPUB, the page hangs.
This is probably caused by the recent spread refactoring because the console displays this error message:

🔴 EPUBSpreadView.swift:165: Only one-page spreads are supported with EPUBReflowableSpreadView

HTML media elements keep playing when turning pages

When turning an EPUB's pages with <media> elements playing, the playback is not interrupted. It keeps going until the page is destroyed which can take 2 additional page turns for FXL.

/// Number of positions (as in `Publication.positionList`) to preload before the current page.
public var preloadPreviousPositionCount = 2
/// Number of positions (as in `Publication.positionList`) to preload after the current page.
public var preloadNextPositionCount = 6

Two questions:

  • Should we interrupt playback when navigating to another resource? (I think so)
  • Should we interrupt playback in a single reflowable resource, when the element is out of screen? (I'm not so sure)

Compile errors

Hello. This issue is really simple one. I have couple of trivial compile errors then try to build project in Xcode 11 with new 5.1 Swift compiler which prevents me to use the framework as Carthage dependency.

It's seems like pdfView.canGoToNextPage() and pdfView.canGoToPreviousPage() couldn't be used as methods any more. Just try it by yourself.

Thanks

word selection issue

i am useing readium library for epub .when i am holding on the first word then it's getting selected and when i am touching and holding on second word then it's get selected with previous one ,like whole sentence get's selected.

Can not load first two pages of EPUB.

I update r2 navigator last version(1.2.6) and r2 shared framework(1.4.3) after that can not load first two pages of EPUB but next pages are opened.

Locaters that overlap on one page

Sometimes two locaters might overlap on a single page and when you use scrollToPosition function it will snap the the previous locater that the user will be already done with

Check out the videos for more details

without snapping the offset
without

with snapping to the previous page (current behaviour)

with

Please check #93 as a suggested solution that snap the offset to the next page instead

Urgent - second page word hi-lighter is not working in landscape

Bug Report

i am using readium library for epub and i am trying with javascript to select the word by it's text-id . In landscape it's working fine for 1st page but for second page it's not working. i am using changeTextColor(fragmentId: String) function for hi-lighter , in this function fragmentId printing correctly for second page also, but text is not getting hi-lighted.

Second page word hi-lighter is not working in landscape

r2-shared-swift:
r2-streamer-swift:
r2-navigator-swift:
r2-opds-swift:
r2-lcp-swift:

macOS: 11.2
platform: x86_64
Xcode 12.4
Build version 12D4e

iOS version: 14.4
Model (e.g. iPhone 11 Pro Max): iPhone 12 Pro Max
Is it an emulator? Yes
func changeTextColor(fragmentId: String) {
          print(fragmentId)
       let scc = "document.getElementById('\(fragmentId)').style.color='#EA4343'; setTimeout(function(){ document.getElementById('\(fragmentId)').style.color = \"#000000\";}, 1500);"
       
       let script = "spread.eval('', \"\(scc.replacingOccurrences(of: "\"", with: "\\\""))\");"

        webView.evaluateJavaScript(script, completionHandler: nil)
}


As per your suggestion in the other issue i have implemented spread.eval() in spreadview.swift and it's not working for second page. readium/swift-toolkit#132

Our app is about to go live so can we have a session to resolve this issue.

word selection issue

i am useing readium library for epub .when i am holding on the first word then it's getting selected and when i am touching and holding on second word then it's get selected with previous one ,like whole sentence get's selected.

word selection issue

  • r2-shared-swift:
  • r2-streamer-swift:
  • r2-navigator-swift:
  • r2-opds-swift:
  • r2-lcp-swift:

macOS: 11.2
platform: x86_64
Xcode 12.4
Build version 12D4e

iOS version: 14.4
Model (e.g. iPhone 11 Pro Max): iPhone 12 Pro Max
Is it an emulator? Yes

in utility.js

 document.addEventListener('selectionchange', debounce(50, function() {
        var info = {}
        var selection = document.getSelection();
       if (selection && selection.rangeCount > 0) {
            var rect = selection.getRangeAt(0).getBoundingClientRect();
            info['text'] = selection.toString().trim();
            info['frame'] = {
                'x': rect.left,
                'y': rect.top,
                'width': rect.width,
                'height': rect.height
            };
        }

        webkit.messageHandlers.selectionChanged.postMessage(info);
    }));

EPUB initial location breaks when calling updateUserSettingStyle

When calling updateUserSettingStyle before the EPUB navigator is fully loaded and positioned to the initial location will reset the initial location to the start of the Publication.

It would be useful to add to the Navigator API an event or an observable state to know when it is fully initialized.

Changing location on in view loaded in the background always will end up at the start

If you try to go the a location on view loaded in the background it will always end up at the start of the resource.

here I am trying to go to the last locater on the resource

location

The reason behind this that loadView(at index: Int, location: Locator) method will ignore the case were the view is loaded and won't create a new view with initialLocation of the parameter sent to it

check #95 as a suggested solution

Is there any access to watch page changing?

When I slide to next page, the epub could be another chapter. I want to show the chapter title on the top of my view.
I noticed that the delegate of navigator doesn't have such methods.Is there anything I can do to get noticed when page changes?

Possible memory leaks from webview

I was running the test app i have noticed that after opening some epub and navigating between chapters (webviews) that the memory kept increasing as you see in the picture even tho after navigating back to the main screen

Screen Shot 2019-04-17 at 7 44 54 PM

looking at safari develop tab it seems all the previous webviews loaded in the app

Screen Shot 2019-04-17 at 7 46 22 PM

and in the memory graph debugger i have noticed the webviews still allocating memory

Screen Shot 2019-04-17 at 7 47 15 PM

and deinit never being called in WebView class, can you advice on this ?

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.