quoid / userscripts

An open-source userscript manager for Safari
https://quoid.github.io/userscripts/
GNU General Public License v3.0
3.03k stars 157 forks source link

Better iCloud sync integration #424

Open ACTCD opened 1 year ago

ACTCD commented 1 year ago

Currently, we tell users in the README:

Tip: for optimal cross platform experience it's a good idea to use an iCloud folder for syncing between macOS and iOS

But the current iCloud sync has some doubts for users:

We may need to officially support iCloud features, and the synchronization mechanism and process will be managed by the App.

References: https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/Introduction/Introduction.html https://developer.apple.com/documentation/cloudkit/ https://developer.apple.com/documentation/technotes/tn3162-understanding-cloudkit-throttles

biuuu commented 1 year ago

Will the data saved with GM.setValue also be synced to iCloud?

ACTCD commented 1 year ago

@biuuu No, not at the moment.

keycommander commented 9 months ago

Send me the link so the .js i can copy over into a scriptable application or web extension. []()

ACTCD commented 9 months ago

@keycommander Sorry, I don't understand what you are talking about. Can you explain it in more detail?

keycommander commented 9 months ago

@keycommander Sorry, I don't understand what you are talking about. Can you explain it in more detail?

Im just wondering how I use this repository

ACTCD commented 9 months ago

@keycommander I don't understand what you are talking about, if your question is not related to this issue I will delete your comments.

Regarding this project, you should read the README, and any other questions you should ask and elaborate in Discussions.

To learn how to use GitHub, please refer to the community documentations.

2xsaiko commented 4 months ago

For devices with limited space, local files may be evictioned due to iCloud optimization

I just hit this and was confused as to why my scripts suddenly weren't working anymore. Seems like Userscripts doesn't pick up the files when they get evicted until manually downloaded again through Finder. Is this known?

ACTCD commented 4 months ago

@2xsaiko As I wrote. Since the extension does not currently use the iCloud related APIs, we won't know when the system decides to evict a file, and we won't be able to read it again. Thanks for your feedback.

2xsaiko commented 4 months ago

Sure, but usually, files will download on access, and non-downloaded files are visible in directories. You can see this by opening iCloud Drive in your terminal and e.g. running ls, cat or cp on a couple files. Everything is there, just accessing it might block a few seconds while it downloads, and these commands don't use the iCloud API either. Userscripts doesn't even pick the files up however.

ACTCD commented 4 months ago

@2xsaiko Check out our code, this is how it currently works, if you'd like to debug it, or know of a simple way to improve it, please let us know or submit a PR and we'll be happy to improve the experience.

https://github.com/quoid/userscripts/blob/7cb18578a9975335fae27f185bbf1a4e26f05450/xcode/Ext-Safari/Functions.swift#L695-L717

2xsaiko commented 4 months ago

Ah, that's the NSFileManager API. That might behave differently than the POSIX readdir, not sure. I'm not familiar with native macOS development at all apart from writing a handful lines of Objective-C. Might mess around with it.

ACTCD commented 4 months ago

@2xsaiko The same is true for us, learning native/swift from scratch, building and refactoring the extension.

I personally do not currently use icloud sync, and there's a lot more main refactoring to do. Therefore, this issue is not currently on the foreseeable task list, unless someone is willing to investigate and contribute. I will add a label to this issue.

2xsaiko commented 4 months ago

Well, a simple test program lists the files and automatically downloads the contents, so something else is going on here.

How do you get started with this? I tried just opening the project and running the "Mac" configuration in Xcode (not even sure if that would work for a Safari extension) but it said "No such file or directory" for Resources/_locales, /dist and /images.

ACTCD commented 4 months ago

@2xsaiko Please check: https://github.com/quoid/userscripts/blob/main/docs/dev.md

Those missing parts need to be built by executing the npm command.

2xsaiko commented 4 months ago

There we go: https://github.com/quoid/userscripts/pull/629

ACTCD commented 1 week ago

Interestingly, one issue should be officially resolved in the upcoming macOS 15 / iOS 18, with an additional menu item "Keep Downloaded" in the iCloud Drive of the new version of the system, which allows you to mark a specific folder not to be automatically evicted by the system.

We would like to thank our users (@JOJOforshaun) for providing us with the above information.