This is an Objective-C and TypeScript API that provides useful data to widgets running in WKWebViews.
The Objective-C layer provides all required extensions to WKWebView necessary to provide such data, and automatically injects the TypeScript API into said webviews.
It is built around a multi-process model:
WKWebView <-> SpringBoard (or whatever else) <-> daemon
iOS 10 and higher is supported.
Support for the following older widget data libraries is as follows:
- InfoStats 2: all functionality provided by the library itself, but no arbitrary calls on e.g. SpringBoard objects
- Widget Weather: all functionality, via interposing the loading of widgetweather.xml
- XenInfo: all functionality, implemented in the TypeScript API layer
This is currently only built for Xen HTML to integrate with. Using it in other tweaks really doesn't work right now; it'll lead to at least two instances of the daemon running, and class name clashes inside applications. You'll also have issues with dpkg
trying to overwrite libwidgetinfo.js
.
However, if Xen HTML is not installed, everything will be happy.
Anything running inside the process hosting a WKWebView
is in lib
.
TypeScript API lives in lib/middleware
.
The daemon
subfolder contains everything that runs out-of-process.
This project can be bundled by doing the following:
- Link
libwidgetinfo.a
,liblogger.a
andlibobjcipc.a
to the main tweak.dylib
- Add the following to your constructor in the tweak:
%ctor {
// If WidgetWeather is present, defer to it
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/WWRefresh.dylib"]) {
[XENDWidgetWeatherURLHandler setHandlerEnabled:NO];
}
// Set filesystem logging as required
[XENDLogger setFilesystemLoggingEnabled:YES];
// Initialise library
[XENDWidgetManager initialiseLibrary];
%init();
}
- Create a wrapper binary for
libwidgetinfodaemon.a
, and setupmain()
as follows:
#import "libwidgetinfo/daemon/Connection/XENDIPCDaemonListener.h"
int main (int argc, const char * argv[]) {
return libwidgetinfo_main_ipc();
}
-
Link
liblogger.a
andlibobjcipc.a
to the daemon wrapper binary -
Link
daemon/frameworks/IOKit.tbd
to the daemon wrapper binary -
Add a LaunchDaemon plist to
/Library/LaunchDaemons/
in the end.deb
, with the example contents fromdaemon/launchd.plist
. -
Compile the TypeScript layer:
- Install
npm
andyarn
cd
tolibwidgetinfo/lib/Middleware
- Run
yarn package
- Copy
libwidgetinfo/lib/Middleware/build/libwidgetinfo.js
to/Library/Application Support/Widgets/
in the end.deb
- Install
-
Generate documentation:
- Install
npm
andyarn
cd
tolibwidgetinfo/lib/Middleware
- Run
yarn docs
- Generated docs are then inside
libwidgetinfo/lib/Middleware/build/docs
- Install
The Testbed Xcode project allows for running libwidgetinfo in a Simulated mode.
This works out of the box, but you will need to update ViewController.m
to point to a widget on your local filesystem.
This project makes use of the following:
- libobjcipc (modified)
- ObjectiveGumbo (modified)
- cycript (modified)
- Reachability
libwidgetinfo is available under the AGPLv3.