diff --git a/sites/cheerpj/src/content/docs/11-guides/Intercept-external-commands.md b/sites/cheerpj/src/content/docs/11-guides/Intercept-external-commands.md index 934b1ad7..e65ed3cc 100644 --- a/sites/cheerpj/src/content/docs/11-guides/Intercept-external-commands.md +++ b/sites/cheerpj/src/content/docs/11-guides/Intercept-external-commands.md @@ -40,7 +40,7 @@ public class Example } ``` -In this example, the Java program uses `Runtime.getRuntime().exec(command)` to open a URL in the default web browser on a Linux system. The command `xdg-open` is typically used to launch a URL in the browser.On Windows, a similar behavior is achieved with the command `cmd /c start`. +In this example, the Java program uses `Runtime.getRuntime().exec(command)` to open a URL in the default web browser on a Linux system. The command `xdg-open` is typically used to launch a URL in the browser. On Windows, a similar behavior is achieved with the command `cmd /c start`. We can now implement the same behavior in JavaScript, here’s how: @@ -57,7 +57,7 @@ function execCb(cmdPath, argsArray) { In this JavaScript function, we check if the incoming command is `xdg-open`. If it matches, we use `window.open()` to open a new browser tab with the specified URL. -We can now pass this function to `cheerpjInit` using the [`execCallback`] option. This ensures that the function is invoked whenever an external command is executed in Java. +We can now pass this function to [`cheerpjInit`] using the [`execCallback`] option. This ensures that the function is invoked whenever an external command is executed in Java. ```ts title="index.html" function execCb(cmdPath, argsArray) { diff --git a/sites/cheerpj/src/content/docs/11-guides/cheerpj-debug.mdx b/sites/cheerpj/src/content/docs/11-guides/cheerpj-debug.mdx index db35251f..547941e9 100644 --- a/sites/cheerpj/src/content/docs/11-guides/cheerpj-debug.mdx +++ b/sites/cheerpj/src/content/docs/11-guides/cheerpj-debug.mdx @@ -26,6 +26,16 @@ If your application passes all these checks but still isn't working correctly, y If you do so, make sure to provide additional context, such as a HAR file and the browser's console output. This will make it easier for us to assist you. Instructions on how to generate these are provided in the following steps. +## Enable advanced debug logs in CheerpJ + +Before saving the browser console output, it's important to enable advanced debug logs in CheerpJ using the [`enableDebug`] CheerpJ [`initOption`]. + +```js +cheerpjInit({ enableDebug: true }); +``` + +This option enables advanced debug logging, which is helpful for troubleshooting issues with CheerpJ. It provides a lot of extra information in case an actual error occurs and will speed up the process of solving the problem you are encountering. + ## Saving the browser console output You can follow these steps to save the browser console output: @@ -57,3 +67,5 @@ You can save a HAR following these steps: [`cheerpjRunJar`]: /docs/reference/cheerpjRunJar [`cheerpjRunMain`]: /docs/reference/cheerpjRunMain [virtual filesystem]: /docs/guides/File-System-support +[`enableDebug`]: /docs/reference/cheerpjInit#enableDebug +[`initOption`]: /docs/reference/cheerpjInit diff --git a/sites/cheerpj/src/content/docs/12-reference/00-cheerpjInit.md b/sites/cheerpj/src/content/docs/12-reference/00-cheerpjInit.md index 907371df..fb5d7c54 100644 --- a/sites/cheerpj/src/content/docs/12-reference/00-cheerpjInit.md +++ b/sites/cheerpj/src/content/docs/12-reference/00-cheerpjInit.md @@ -26,7 +26,8 @@ async function cheerpjInit(options?: { tailscaleLoginUrlCb?: (url: string) => void; tailscaleIpCb?: (ip: string) => void; licenseKey?: string; - execCallback?: function(cmdPath, argsArray) {}; + execCallback?: (cmdPath: string, argsArray: string []) => void; + enableDebug?: boolean; }): Promise; ``` @@ -377,7 +378,7 @@ cheerpjInit({ licenseKey: "YourLicenseKey" }); ### `execCallback` ```ts -execCallback?: function(cmdPath, argsArray) {}; +execCallback?: (cmdPath: string, argsArray: string []) => void; ``` > [!note] Important @@ -402,6 +403,20 @@ cheerpjInit({ Learn more about the `execCallback` option in our [intercept external commands guide](/docs/guides/Intercept-external-commands). +### `enableDebug` + +```ts +enableDebug?: boolean; +``` + +This option enables advanced debug logging, which is helpful for troubleshooting issues with CheerpJ. + +Example of usage: + +```js +cheerpjInit({ enableDebug: true }); +``` + [cjGetRuntimeResources]: /docs/reference/cjGetRuntimeResources [Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise [`java`]: /docs/reference/cheerpjInit#java-mode