mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-08 16:27:31 +00:00
Compare commits
No commits in common. "67713c60d4bc108ddbdbb57b20ba300d8a3db7a2" and "f4306ad1c3523784139ab153cff729c158dea187" have entirely different histories.
67713c60d4
...
f4306ad1c3
@ -13,7 +13,7 @@ class PluginLocalStorageApi {
|
|||||||
required this.pluginName,
|
required this.pluginName,
|
||||||
}) {
|
}) {
|
||||||
runtime.onMessage("LocalStorage.getItem", (args) {
|
runtime.onMessage("LocalStorage.getItem", (args) {
|
||||||
final key = args[0]["key"];
|
final key = args[0];
|
||||||
final value = getItem(key);
|
final value = getItem(key);
|
||||||
runtime.evaluate(
|
runtime.evaluate(
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -70,11 +70,4 @@ class PluginSetIntervalApi {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
|
||||||
for (var timer in _timers.values) {
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
_timers.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class PluginTotpGenerator {
|
|||||||
|
|
||||||
runtime.evaluate(
|
runtime.evaluate(
|
||||||
"""
|
"""
|
||||||
eventEmitter.emit('TotpGenerator.generate', '$otp');
|
eventEmitter.emit('Totp.generate', '$otp');
|
||||||
""",
|
""",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -49,17 +49,13 @@ class PluginWebViewApi {
|
|||||||
}
|
}
|
||||||
showWebView(
|
showWebView(
|
||||||
url: args[0]["url"] as String,
|
url: args[0]["url"] as String,
|
||||||
initialSettings: args[0]["initialSettings"] != null
|
initialSettings: WebviewInitialSettings.fromJson(
|
||||||
? WebviewInitialSettings.fromJson(
|
|
||||||
args[0]["initialSettings"],
|
args[0]["initialSettings"],
|
||||||
)
|
),
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Webview? webviewWindow;
|
|
||||||
|
|
||||||
Future showWebView({
|
Future showWebView({
|
||||||
required String url,
|
required String url,
|
||||||
WebviewInitialSettings? initialSettings,
|
WebviewInitialSettings? initialSettings,
|
||||||
@ -121,8 +117,6 @@ class PluginWebViewApi {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
webviewWindow = webview;
|
|
||||||
|
|
||||||
runtime.onMessage("WebView.close", (args) {
|
runtime.onMessage("WebView.close", (args) {
|
||||||
webview.close();
|
webview.close();
|
||||||
});
|
});
|
||||||
@ -140,7 +134,7 @@ class PluginWebViewApi {
|
|||||||
"domain": e.domain,
|
"domain": e.domain,
|
||||||
"path": e.path,
|
"path": e.path,
|
||||||
};
|
};
|
||||||
}).toList();
|
});
|
||||||
|
|
||||||
runtime.evaluate(
|
runtime.evaluate(
|
||||||
"""
|
"""
|
||||||
@ -163,9 +157,4 @@ class PluginWebViewApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
|
||||||
webviewWindow?.close();
|
|
||||||
webviewWindow = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,19 @@ class MetadataApiSignature {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final res = runtime.evaluate(
|
||||||
|
"""
|
||||||
|
;$libraryCode;
|
||||||
|
const metadataApi = new MetadataApi();
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (res.isError) {
|
||||||
|
AppLogger.reportError(
|
||||||
|
"Error evaluating code: $libraryCode\n${res.rawResult}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Create all the PluginAPIs after library code is evaluated
|
// Create all the PluginAPIs after library code is evaluated
|
||||||
final localStorageApi = PluginLocalStorageApi(
|
final localStorageApi = PluginLocalStorageApi(
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
@ -80,26 +93,12 @@ class MetadataApiSignature {
|
|||||||
setIntervalApi,
|
setIntervalApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
final res = runtime.evaluate(
|
|
||||||
"""
|
|
||||||
;$libraryCode;
|
|
||||||
const metadataApi = new MetadataApi();
|
|
||||||
""",
|
|
||||||
);
|
|
||||||
metadataApi._signatureFlags = await metadataApi._getSignatureFlags();
|
metadataApi._signatureFlags = await metadataApi._getSignatureFlags();
|
||||||
|
|
||||||
if (res.isError) {
|
|
||||||
AppLogger.reportError(
|
|
||||||
"Error evaluating code: $libraryCode\n${res.rawResult}",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return metadataApi;
|
return metadataApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
setIntervalApi.dispose();
|
|
||||||
webViewApi.dispose();
|
|
||||||
runtime.dispose();
|
runtime.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ class MetadataApiSignature {
|
|||||||
$method(...${args != null ? jsonEncode(args) : "[]"})
|
$method(...${args != null ? jsonEncode(args) : "[]"})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
try {
|
try {
|
||||||
sendMessage("$method", res ? JSON.stringify(res) : "[]");
|
sendMessage("$method", JSON.stringify(res));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to send message in $method.then: ", `\${e.toString()}\n\${e.stack.toString()}`);
|
console.error("Failed to send message in $method.then: ", `\${e.toString()}\n\${e.stack.toString()}`);
|
||||||
}
|
}
|
||||||
@ -157,10 +156,6 @@ class MetadataApiSignature {
|
|||||||
await invoke("metadataApi.authenticate");
|
await invoke("metadataApi.authenticate");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> logout() async {
|
|
||||||
await invoke("metadataApi.logout");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----- Track ------
|
// ----- Track ------
|
||||||
Future<SpotubeTrackObject> getTrack(String id) async {
|
Future<SpotubeTrackObject> getTrack(String id) async {
|
||||||
final result = await invoke("metadataApi.getTrack", [id]);
|
final result = await invoke("metadataApi.getTrack", [id]);
|
||||||
@ -502,12 +497,6 @@ class MetadataApiSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----- User ------
|
// ----- User ------
|
||||||
Future<SpotubeUserObject> getMe() async {
|
|
||||||
final res = await invoke("metadataApi.getMe");
|
|
||||||
|
|
||||||
return SpotubeUserObject.fromJson(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> followArtist(String userId, String artistId) async {
|
Future<void> followArtist(String userId, String artistId) async {
|
||||||
await invoke("metadataApi.followArtist", [userId, artistId]);
|
await invoke("metadataApi.followArtist", [userId, artistId]);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user