From 00ab5fc623f9a2b4820d62bb2e06e245af392e89 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 25 Jul 2025 23:50:08 +0100 Subject: [PATCH] Coral 3.0.1 web service JS APIs --- src/app/preload-webservice/znca-js-api.ts | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/app/preload-webservice/znca-js-api.ts b/src/app/preload-webservice/znca-js-api.ts index de2909f..1fc3c6e 100644 --- a/src/app/preload-webservice/znca-js-api.ts +++ b/src/app/preload-webservice/znca-js-api.ts @@ -152,6 +152,21 @@ interface WebServiceJsApi { * Opens a URL in the default browser. */ openExternalBrowser(url: string): void; + + /** + * Plays a preset vibration pattern. + * + * Used by ZELDA NOTES. + */ + func_2644(data: string): void; + + /** + * Requests a web service token from the Coral API. + * `window.znca._private.func_1d5e` is called with the returned token. + * + * Used by ZELDA NOTES. + */ + func_272e(): void; } // @@ -195,6 +210,17 @@ function requestGameWebToken() { }); } +function func_272e() { + debug('func_272e called'); + + ipc.requestGameWebToken().then(token => { + // @ts-expect-error + window.znca?._private?.func_1d5e?.call(null, token); + }).catch(async err => { + debug('Error requesting web service token', err); + }); +} + // // Persistent data // @@ -359,6 +385,21 @@ function openExternalBrowser(url: string) { window.open(url); } +export interface VibrateOptions { + pattern: VibratePattern; +} +export enum VibratePattern { + TAP = '0', + SUCCESS = '1', + ERROR = '2', +} + +function func_2644(/** JSON.stringify(data: VibrateOptions) */ data: string) { + const options: VibrateOptions = JSON.parse(data); + + debug('func_2644 called', options); +} + const api: WebServiceJsApi = { invokeNativeShare, invokeNativeShareUrl, @@ -378,6 +419,8 @@ const api: WebServiceJsApi = { reloadExtension, clearUnreadFlag, openExternalBrowser, + func_2644, + func_272e, }; window.jsBridge = api;