[
  {
    "path": ".gitignore",
    "content": "node_modules\n.vscode\nbin\nbuild/**"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=center>Mica Electron</h1>\n<div align=center>\n<img src=\"https://micadiscord.com/img/preview/title.png\" name=\"exemple\">\n\n<b>Mica Electron</b> is a tool to add mica effect on electron app.<br>\nThis is created by <a href=\"https://www.youtube.com/gregvido\">GregVido</a>.<br>\n<b>Mica electron is now compatible with windows 10</b>\n</div>\n\n<details>\n  <summary>Exemple of effects</summary>\n  <div align=center>\n\t<img src=\"https://micadiscord.com/img/preview/demo-1.png\" name=\"demo 0\" width=\"30%\">\n\t<img src=\"https://micadiscord.com/img/preview/demo-2.png\" name=\"demo 1\" width=\"30%\">\n\t<img src=\"https://micadiscord.com/img/preview/demo-3.png\" name=\"demo 2\" width=\"30%\"> \n\n  \n  <a href='https://micadiscord.com/img/mica-electron-preview.gif'>Click here to see the animation preview.</a>\n  </div> \n</details><br> \n\n## ☕ Support the project\n\nIf you like **Mica Electron** and want to support its development, you can buy me a coffee ❤️\n\n👉 https://www.buymeacoffee.com/gregvido\n\n\n\n## Quickstart\n```bash\n$ npm install mica-electron\n```\n```js\nconst electron = require('electron');\nconst { PARAMS, VALUE,  MicaBrowserWindow, IS_WINDOWS_11, WIN10 } = require('mica-electron');\nconst path = require('path');\n\nelectron.app.on('ready', () => {\n    const win = new MicaBrowserWindow({\n        width: 800,\n        height: 600,\n        autoHideMenuBar: true,\n        show: false,\n        // frame: false // -> now work, you can remove the frame properly !!\n    });\n\n    win.setDarkTheme();\n    win.setMicaEffect();\n\n    // win.alwaysFocused(true); // -> allows you to keep the mica effects even if the window is no focus (decrease performance)\n\n    win.loadFile(path.join(__dirname, 'files', 'index.html'));\n\n    win.webContents.once('dom-ready', () => {\n        win.show();\n    });\n});\n```\n\n<details>\n  <summary>Apply effect for windows 11</summary>\n    You can apply different mica effect :\n\n```js\nwin.setMicaEffect();        // Mica Effect\nwin.setMicaTabbedEffect();  // Mica Tabbed\nwin.setMicaAcrylicEffect(); // Acrylic for windows 11\n```\n<div align=center>\n<img src=\"https://micadiscord.com/img/preview/demo-1.png\" name=\"corner 0\" width=\"20%\">\n<img src=\"https://micadiscord.com/img/preview/demo-2.png\" name=\"corner 1\" width=\"20%\">\n<img src=\"https://micadiscord.com/img/preview/demo-3.png\" name=\"corner 2\" width=\"20%\"> \n</div>\n</details>\n\n<details>\n  <summary>Change theme for windows 11</summary>\n  You can change theme :\n\n```js\nwin.setAutoTheme();   // Same theme as computer\nwin.setLightTheme();  // Force light theme\nwin.setDarkTheme();   // Force dark theme\n```\n</details>\n\n<details>\n  <summary>Apply effect for windows 10</summary>\n  You can apply different blur effect :\n\n```js\nwin.setTransparent(); // Transparent window\nwin.setBlur();        // Blurred window\nwin.setAcrylic();     // Acrylic window\n```\n</details>\n\n<details>\n  <summary>Change radius</summary>\n    You can change corner radius :\n\n```js\nwin.setRoundedCorner();\t      // Rounded\nwin.setSmallRoundedCorner();  // Small rounded\nwin.setSquareCorner();\t      // Square\n```\n<div align=center>\n<img src=\"https://micadiscord.com/img/preview/corner-1.png\" name=\"corner 0\" width=\"10%\">\n<img src=\"https://micadiscord.com/img/preview/corner-2.png\" name=\"corner 1\" width=\"10%\">\n<img src=\"https://micadiscord.com/img/preview/corner-3.png\" name=\"corner 2\" width=\"10%\"> \n</div>\n</details>\n\n<details>\n  <summary>Change window colors</summary>\n    You can change window colors :\n\n```js\nwin.setBorderColor('#f40b0b');  // Border color\nwin.setBorderColor(null); // -> disable effect\n\nwin.setCaptionColor('#262626'); // Background titlebar color\nwin.setCaptionColor(null); // -> disable effect\n\nwin.setTitleTextColor('#fff');  // Title text color\nwin.setTitleTextColor(null); // -> disable effect\n```\n<div align=center>\n<img src=\"https://micadiscord.com/img/preview/border.png\" name=\"border\" width=\"50%\">\n</div>\n</details>\n\n<details>\n  <summary>Change custom transparent effect for windows 10 <b>NEW!</b></summary>\n    You can change window colors :\n\n```js\nwin.setCustomEffect(WIN10.TRANSPARENT, '#34ebc0', 0.5); // Transparent\nwin.setCustomEffect(WIN10.ACRYLIC, '#34ebc0', 0.4); // Acrylic\n```\n<div align=center>\n<img src=\"https://micadiscord.com/img/mica-electron-custom-exemple.png\" name=\"border\" width=\"40%\">\n<img src=\"https://micadiscord.com/img/mica-electron-custom-blur-exemple.png\" name=\"border\" width=\"40%\">\n</div>\n</details>\n\n<br>\n\n\n## Source Install / Manual Compilation\nTo compile from source it's easiest to use\n[`node-gyp`](https://github.com/TooTallNate/node-gyp):\n\n``` bash\n$ npm install -g node-gyp\n```\n\nNow you can compile `mica-electron`:\n\n``` bash\n$ cd .\\node_modules\\mica-electron\\\n$ ./build.bat\n```\n## Objects details\n<details>\n  <summary>PARAMS Object</summary>\n  The params is a number, you can has an object to help you:\n\n```js\n    const PARAMS = {\n        BACKGROUND: {\n            AUTO: 0,\n            NONE: 1,\n            ACRYLIC: 3,         // Acrylic\n            MICA: 2,            // Mica\n            TABBED_MICA: 4      // Mica tabbed\n        },\n        CORNER: 5,\n        BORDER_COLOR: 6,\n        CAPTION_COLOR: 7,\n        TEXT_COLOR: 8,\n        FRAME: 9\n    }\n```\n</details>\n\n<details>\n  <summary>VALUE Object</summary>\nThe value is a number, you can has an object to help you:\n\n```js\nconst VALUE = {\n    THEME: {\n        AUTO: 5,\t// select theme by the windows theme\n        DARK: 1,\t// select the dark theme\n        LIGHT: 2,\t// select the white theme\n    },\n    CORNER: {\n        DEFAULT: 0,\n        DONOTROUND: 1,\n        ROUND: 2,\n        ROUNDSMALL: 3\n    },\n    COLOR: {\n        RED: 0x000000FF,\n        GREEN: 0x0000FF00,\n        BLUE: 0x00FF0000,\n        BLACK: 0x00000000,\n        WHITE: 0x00FFFFFF,\n        FROM_RGB: (r, g, b) => {\n            return r + (g << 8) + (b << 16);\n        }\n    },\n    FALSE: 0,\n    TRUE: 1\n}\n```\n</details>\n\n<details>\n  <summary>IS_WINDOWS_11</summary>\nIS_WINDOWS_11 is a boolean constant to detect the OS version. If it is true then it's a windows 11 computer, otherwise it is another version (10, 8, 7 ...)\n</details>\n\n<details>\n  <summary>WIN10 Object</summary>\nThe value is a number, you can has an object to help you:\n\n```js\nconst WIN10 = {\n    TRANSPARENT: 2,\n    BLURBEHIND: 3, // didn't work on windows 11\n    ACRYLIC: 4\n}\n```\n</details><br>\n\n## FAQ\n<details>\n  <summary>Error: '...\\micaElectron.node' was compiled against a different Node.js version using ...</summary>\n  If you are an error of nodejs version, use electron-packager to rebuild the project with the good version.\n\n  ```bash\n  $ npm install electron\n  $ npm install electron-rebuild\n  $ .\\node_modules\\.bin\\electron-rebuild\n  ```\n</details>\n<details>\n  <summary>Build for 32 bits ?</summary>\n\n  If you want use `mica-electron` with 32 bits electron app, rebuild C++ script\n\n``` bash\n$ cd .\\node_modules\\mica-electron\\\n$ node-gyp rebuild --arch=ia32\n$ cd ..\\..\\\n$ .\\node_modules\\.bin\\electron-rebuild --arch=ia32\n```\n</details>\n<br>\n\n## Awesome applications using Mica-Electron\n\n- [MicaDiscord](https://www.micadiscord.com/) by GregVido and Arbitro\n- [Cider](https://github.com/ciderapp/Cider) by [Cider Collective](https://github.com/ciderapp)\n- [Fluent Browser](https://github.com/ThePiGuy3141/fluent-browser) by <a href=\"https://github.com/ThePiGuy3141\">ThePiGuy3141</a>\n- [Mica-Snap](https://github.com/GregVido/Mica-Snap) by GregVido\n- [SysMocap](https://github.com/xianfei/SysMocap) by [xianfei](https://github.com/xianfei)"
  },
  {
    "path": "build.bat",
    "content": "@echo off\n\nREM =========================\nREM ANSI colors\nREM =========================\nfor /f %%a in ('echo prompt $E ^| cmd') do set \"ESC=%%a\"\n\nset C_RESET=%ESC%[0m\nset C_TITLE=%ESC%[96m\nset C_INFO=%ESC%[94m\nset C_OK=%ESC%[92m\nset C_WARN=%ESC%[93m\nset C_ERR=%ESC%[91m\nset C_LINE=%ESC%[90m\n\nset INCLUDE_ARM64=true\n\nREM -------------------------\nREM Parse arguments\nREM -------------------------\nfor %%i in (%*) do (\n    if \"%%i\"==\"--include-arm64\" (\n        set INCLUDE_ARM64=true\n    )\n)\n\necho %C_LINE%-------------------------%C_RESET%\necho %C_TITLE%MicaElectron Builder v1.1%C_RESET%\necho %C_LINE%-------------------------%C_RESET%\necho.\n\nREM -------------------------\nREM Safety checks\nREM -------------------------\nwhere node >nul 2>&1 || (\n    echo %C_ERR%[ERROR]%C_RESET% Node.js not found in PATH\n    exit /b 1\n)\n\nwhere node-gyp >nul 2>&1 || (\n    echo %C_ERR%[ERROR]%C_RESET% node-gyp not found in PATH\n    exit /b 1\n)\n\nif exist data (\n    ren data binding.gyp || (\n        echo %C_ERR%[ERROR]%C_RESET% Failed to rename data to binding.gyp\n        exit /b 1\n    )\n)\n\nif not exist binding.gyp (\n    echo %C_ERR%[ERROR]%C_RESET% binding.gyp not found\n    exit /b 1\n)\n\nREM -------------------------\nREM Reset src folder\nREM -------------------------\necho %C_LINE%-------------------------%C_RESET%\necho %C_INFO%Resetting src folder...%C_RESET%\n\nif exist src (\n    rmdir /s /q src || (\n        echo %C_ERR%[ERROR]%C_RESET% Failed to remove src folder\n        goto restore_gyp\n    )\n)\n\nmkdir src || (\n    echo %C_ERR%[ERROR]%C_RESET% Failed to create src folder\n    goto restore_gyp\n)\n\nREM -------------------------\nREM Build x64\nREM -------------------------\necho %C_LINE%-------------------------%C_RESET%\n\nnode-gyp rebuild >nul 2>&1 | echo %C_INFO%Building x64...%C_RESET%\nif errorlevel 1 (\n    echo %C_ERR%[ERROR]%C_RESET% x64 build failed\n    goto restore_gyp\n)\n\nif not exist build\\Release\\micaElectron.node (\n    echo %C_ERR%[ERROR]%C_RESET% x64 output file not found\n    goto restore_gyp\n)\n\nmove build\\Release\\micaElectron.node src\\micaElectron_x64.node >nul || (\n    echo %C_ERR%[ERROR]%C_RESET% Failed to move x64 binary\n    goto restore_gyp\n)\n\necho %C_OK%[OK]%C_RESET% x64 build completed\necho.\n\nREM -------------------------\nREM Build ia32\nREM -------------------------\necho %C_LINE%-------------------------%C_RESET%\n\nnode-gyp rebuild --arch=ia32 >nul 2>&1 | echo %C_INFO%Building ia32...%C_RESET%\nif errorlevel 1 (\n    echo %C_ERR%[ERROR]%C_RESET% ia32 build failed\n    goto restore_gyp\n)\n\nif not exist build\\Release\\micaElectron.node (\n    echo %C_ERR%[ERROR]%C_RESET% ia32 output file not found\n    goto restore_gyp\n)\n\nmove build\\Release\\micaElectron.node src\\micaElectron_ia32.node >nul || (\n    echo %C_ERR%[ERROR]%C_RESET% Failed to move ia32 binary\n    goto restore_gyp\n)\n\necho %C_OK%[OK]%C_RESET% ia32 build completed\necho.\n\nREM -------------------------\nREM Build ARM64 (optional)\nREM -------------------------\nif \"%INCLUDE_ARM64%\"==\"true\" (\n    echo %C_LINE%-------------------------%C_RESET%\n\n    node-gyp rebuild --arch=arm64 >nul 2>&1 | echo %C_INFO%Building arm64...%C_RESET%\n    if errorlevel 1 (\n        echo %C_ERR%[ERROR]%C_RESET% arm64 build failed\n        goto restore_gyp\n    )\n\n    if not exist build\\Release\\micaElectron.node (\n        echo %C_ERR%[ERROR]%C_RESET% arm64 output file not found\n        goto restore_gyp\n    )\n\n    move build\\Release\\micaElectron.node src\\micaElectron_arm64.node >nul || (\n        echo %C_ERR%[ERROR]%C_RESET% Failed to move arm64 binary\n        goto restore_gyp\n    )\n\n    echo %C_OK%[OK]%C_RESET% arm64 build completed\n    echo.\n)\n\nREM -------------------------\nREM Cleanup\nREM -------------------------\necho %C_LINE%-------------------------%C_RESET%\necho %C_INFO%Cleaning build artifacts...%C_RESET%\n\nif exist build (\n    rmdir /s /q build || (\n        echo %C_ERR%[ERROR]%C_RESET% Failed to remove build folder\n        goto restore_gyp\n    )\n)\n\nREM -------------------------\nREM Restore binding.gyp\nREM -------------------------\n:restore_gyp\nif exist binding.gyp (\n    ren binding.gyp data\n)\n\necho %C_LINE%-------------------------%C_RESET%\necho %C_OK%Build finished successfully%C_RESET%\necho %C_LINE%-------------------------%C_RESET%\n\nexit /b 0"
  },
  {
    "path": "data",
    "content": "{\n  \"targets\": [\n    {\n      \"target_name\": \"micaElectron\",\n      \"sources\": [ \"module/app.cpp\" ]\n    }\n  ],\n  'variables':{\n    'openssl_fips':0\n  }\n}"
  },
  {
    "path": "exemple.js",
    "content": "const { app, ipcMain } = require('electron');\nconst { PARAMS, VALUE, MicaBrowserWindow, IS_WINDOWS_11, WIN10 } = require('./main.js');\nconst path = require('path');\n\napp.on('ready', () => {\n\n    const win = new MicaBrowserWindow({\n        width: 800,\n        height: 600,\n        autoHideMenuBar: true,\n        show: false,\n        // frame: false, // -> now work, you can remove the frame properly !!\n        webPreferences: {\n            nodeIntegration: true,\n            contextIsolation: false\n        }\n    });\n\n    win.setLightTheme();\n    \n    if (IS_WINDOWS_11)\n        win.setMicaTabbedEffect();\n\n    else\n        win.setCustomEffect(WIN10.ACRYLIC, '#401896', .2);\n\n    // win.alwaysFocused(true); // -> allows you to keep the mica effects even if the window is no focus (decrease performance)\n    win.loadFile(path.join(__dirname, 'files', 'index.html'));\n\n    win.webContents.once('dom-ready', () => {\n        win.show();\n    });\n\n    // Change theme\n    ipcMain.on('theme', (evt, newValue) => {\n        switch (newValue) {\n            case VALUE.THEME.AUTO:\n                win.setAutoTheme();\n                break\n\n            case VALUE.THEME.LIGHT:\n                win.setLightTheme();\n                break\n\n            case VALUE.THEME.DARK:\n                win.setDarkTheme();\n                break\n        }\n    });\n\n    // Change effect\n    ipcMain.on('effect', (evt, newParams) => {\n        switch (newParams) {\n            case PARAMS.BACKGROUND.MICA:\n                win.setMicaEffect();\n                break\n\n            case PARAMS.BACKGROUND.TABBED_MICA:\n                win.setMicaTabbedEffect();\n                break\n\n            case PARAMS.BACKGROUND.ACRYLIC:\n                win.setMicaAcrylicEffect();\n                break\n\n        }\n    });\n\n    // apply effect (corner, background-color, ...)\n    ipcMain.on('params', (evt, params, value) => {\n        switch (params) {\n            case PARAMS.CORNER:\n                switch (value) {\n                    case VALUE.CORNER.ROUND:\n                        win.setRoundedCorner();\n                        break\n\n                    case VALUE.CORNER.ROUNDSMALL:\n                        win.setSmallRoundedCorner();\n                        break\n\n                    case VALUE.CORNER.DONOTROUND:\n                        win.setSquareCorner();\n                        break\n                }\n                break\n\n            case PARAMS.BORDER_COLOR:\n                win.setBorderColor(value);\n                break\n\n            case PARAMS.CAPTION_COLOR:\n                win.setCaptionColor(value);\n                break\n\n            case PARAMS.TEXT_COLOR:\n                win.setTitleTextColor(value);\n                break\n\n            case 10:\n                switch (value) {\n                    case 0:\n                        win.setTransparent();\n                        break\n\n                    case 1:\n                        win.setBlur();\n                        break\n\n                    case 2:\n                        win.setAcrylic();\n                        break\n                }\n                break\n\n        }\n    });\n});"
  },
  {
    "path": "files/css/dark.css",
    "content": "main,\nfieldset {\n    background-color: #000000e3;\n    border: 1px solid #353535;\n    color: #fff;\n}\n\nfieldset {\n    background-color: #00000096;\n}\n\nbutton {\n    background: #000;\n    border: 1px solid rgb(24, 24, 24);\n    color: #fff;\n}\n\nbutton:hover  {\n    background: #141414;\n}\n\n/* Track */\n::-webkit-scrollbar-track {\n    background: #888;\n}\n\n/* Handle */\n::-webkit-scrollbar-thumb {\n    background: #f1f1f1;\n}\n\n/* Handle on hover */\n::-webkit-scrollbar-thumb:hover {\n    background: #f8f8f8;\n}"
  },
  {
    "path": "files/css/styles.css",
    "content": "body {\n    font-family: Arial, Helvetica, sans-serif;\n    background-color: transparent;\n    padding: 10px;\n}\n\nh1 {\n    -webkit-app-region: drag;\n}\n\nmain,\nfieldset {\n    margin: auto;\n    width: 60%;\n    text-align: center;\n    background-color: #ffffffe3;\n    padding: 10px;\n    border: 1px solid #cacaca;\n    border-radius: 15px;\n    color: #000;\n}\n\nfieldset {\n    margin-top: 10px;\n    background-color: #ffffff96;\n}\n\nlegend {\n    text-align: left;\n}\n\nbutton {\n    background: #fff;\n    border: 1px solid rgb(231, 231, 231);\n    padding: 7px 15px;\n    transition: .2s background;\n    color: #000;\n}\n\nbutton:hover {\n    background: #ebebeb;\n}\n\n/* width */\n::-webkit-scrollbar {\n    width: 4px;\n}\n\n/* Track */\n::-webkit-scrollbar-track {\n    background: #f1f1f1;\n}\n\n/* Handle */\n::-webkit-scrollbar-thumb {\n    background: #888;\n}\n\n/* Handle on hover */\n::-webkit-scrollbar-thumb:hover {\n    background: #555;\n}"
  },
  {
    "path": "files/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Hello World</title>\n    <link rel=\"stylesheet\" href=\"css/styles.css\">\n    <script src=\"js/scripts.js\"></script>\n</head>\n<body>\n    <main>\n        <h1>Hello World</h1>\n    </main>\n    <fieldset>\n        <legend>Effect</legend>\n        <button onclick=\"setEffect(3)\">Acrylic</button>\n        <button onclick=\"setEffect(2)\">Mica</button>\n        <button onclick=\"setEffect(4)\">Mica Tabbed</button>\n    </fieldset>\n    <fieldset>\n        <legend>Theme</legend>\n        <button onclick=\"setTheme(5)\">Auto</button>\n        <button onclick=\"setTheme(1)\">Dark</button>\n        <button onclick=\"setTheme(2)\">Light</button>\n    </fieldset>\n    <fieldset>\n        <legend>Corner</legend>\n        <button onclick=\"setParams(5, 2)\">Round</button>\n        <button onclick=\"setParams(5, 3)\">Small Round</button>\n        <button onclick=\"setParams(5, 1)\">Square</button>\n    </fieldset>\n    <fieldset>\n        <legend>Window Color</legend>\n\n        <input type=\"color\" id=\"colorBorder\" name=\"colorBorder\" value=\"#e6e6e6\">\n        <label for=\"colorBorder\">Border</label>\n\n        <input type=\"color\" id=\"colorCaption\" name=\"colorCaption\" value=\"#e6e6e6\">\n        <label for=\"colorCaption\">Caption</label>\n\n        <input type=\"color\" id=\"colorTitle\" name=\"colorTitle\" value=\"#e6e6e6\">\n        <label for=\"colorTitle\">Title</label>\n    </fieldset>\n    <fieldset>\n        <legend>Windows 10 Effect</legend>\n        <button onclick=\"setParams(10, 0)\">Transparent</button>\n        <button onclick=\"setParams(10, 1)\">Blur</button>\n        <button onclick=\"setParams(10, 2)\">Acrylic</button>\n    </fieldset>\n</body>\n</html>"
  },
  {
    "path": "files/js/scripts.js",
    "content": "const { ipcRenderer } = require('electron');\n\nconst darkTheme = document.createElement('link');\ndarkTheme.rel = 'stylesheet';\ndarkTheme.href = 'css/dark.css';\n\nfunction setTheme(theme) {\n    ipcRenderer.send('theme', theme);\n\n    if (theme == 1)\n        document.head.appendChild(darkTheme);\n\n    else\n        document.head.removeChild(darkTheme);\n}\n\nfunction setEffect(effect) {\n    ipcRenderer.send('effect', effect);\n}\n\nfunction setParams(params, value) {\n    ipcRenderer.send('params', params, value);\n}\n\nfunction htmlToColor(color) {\n    let r = color.slice(0, 2);\n    let g = color.slice(2, 4);\n    let b = color.slice(4, 6);\n\n    return parseInt(\"0x\" + b + g + r);\n}\n\nwindow.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {\n    document.head[event.matches ? 'appendChild' : 'removeChild'](darkTheme);\n});\n\nwindow.onload = () => {\n    const colorBorder = document.getElementById('colorBorder');\n    const colorCaption = document.getElementById('colorCaption');\n    const colorTitle = document.getElementById('colorTitle');\n\n    colorBorder.addEventListener('input', () => {\n        setParams(6, colorBorder.value);\n    });\n\n    colorCaption.addEventListener('input', () => {\n        setParams(7, colorCaption.value);\n    });\n\n    colorTitle.addEventListener('input', () => {\n        setParams(8, colorTitle.value);\n    });\n}"
  },
  {
    "path": "main.js",
    "content": "/*\nCopyright 2024 GregVido\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nconst electron = require('electron');\nconst os = require('os');\nconst fs = require('fs');\nconst path = require('path');\n\nconst IS_ELECTRON_RECENT_VERSION = process.versions.electron >= '27.0.0' && process.versions.electron <= '40.0.0';\n\nconst filepath = path.join(__dirname, 'src', '/micaElectron_' + process.arch);\n\nlet executeDwm, redraw, executeUser32;\n\nif (fs.existsSync(filepath + '.node')) {\n    /* If mica-electron is running on windows */\n    if (process.platform == 'win32') {\n        const micaBuild = require(filepath);\n\n        executeDwm = micaBuild.executeDwm;\n        redraw = micaBuild.redraw;\n        executeUser32 = micaBuild.executeUser32;\n    }\n    else {\n        console.log('Mica-Electron only works on Windows!');\n        console.log('Mica-Electron: Disabled');\n    }\n}\n\nelse {\n    console.log('./src/micaElectron_' + process.arch + '.node does not exist!');\n    console.log('Mica-Electron: Disabled');\n}\n\nelectron.app.commandLine.appendSwitch(\"enable-transparent-visuals\");\n\n/**\n * Detect if OS is windows 11\n * @returns {Boolean} True if windows 11\n */\nfunction isWin11() {\n    const version = os.release().split('.');\n    if (version.length == 3)\n        return version[2] >= '22000';\n    return false;\n}\n\nconst WINDOWS_11 = isWin11();\n\n/**\n * Remove a frame from a window\n * @param  {BrowserWindow} window Target to remove frame\n */\nfunction redrawFrame(window) {\n    if (redraw) {\n        const HWND = window.getNativeWindowHandle()[\"readInt32LE\"]();\n\n        const bounds = window.getBounds();\n\n        // executeDwm(HWND, PARAMS.FRAME, VALUE.FALSE);\n        redraw(HWND, bounds.x, bounds.y, bounds.width, bounds.height);\n    }\n}\n\nconst PARAMS = {\n    BACKGROUND: {\n        AUTO: 0,\n        NONE: 1,\n        ACRYLIC: 3,         // Acrylic\n        MICA: 2,            // Mica\n        TABBED_MICA: 4      // Mica tabbed\n    },\n    CORNER: 5,\n    BORDER_COLOR: 6,\n    CAPTION_COLOR: 7,\n    TEXT_COLOR: 8,\n    FRAME: 9,\n    MARGIN: 10\n}\n\nconst VALUE = {\n    THEME: {\n        AUTO: 5,\t// select theme by the windows theme\n        DARK: 1,\t// select the dark theme\n        LIGHT: 2,\t// select the white theme\n    },\n    CORNER: {\n        DEFAULT: 0,\n        DONOTROUND: 1,\n        ROUND: 2,\n        ROUNDSMALL: 3\n    },\n    COLOR: {\n        RED: 0x000000FF,\n        GREEN: 0x0000FF00,\n        BLUE: 0x00FF0000,\n        BLACK: 0x00000000,\n        WHITE: 0x00FFFFFF,\n        FROM_RGB: (r, g, b) => {\n            return r + (g << 8) + (b << 16);\n        }\n    },\n    FALSE: 0,\n    TRUE: 1\n}\n\nconst WIN10 = {\n    TRANSPARENT: 2,\n    BLURBEHIND: 3,\n    ACRYLIC: 4\n}\n\n/**\n * Convert HTML color to windows color\n * @param  {String} str HTML color\n * @return {Number}     windows color (int, 24 bits)\n */\nlet getColorByString = (str) => {\n    if (str.startsWith('#')) {\n        const hexs = str.slice(1);\n        if (hexs.length == 3) {\n            const r = parseInt(hexs[0] + hexs[0], 16);\n            const g = parseInt(hexs[1] + hexs[1], 16);\n            const b = parseInt(hexs[2] + hexs[2], 16);\n\n            return VALUE.COLOR.FROM_RGB(r, g, b);\n        }\n        else if (hexs.length == 6) {\n            const r = parseInt(hexs.slice(0, 2), 16);\n            const g = parseInt(hexs.slice(2, 4), 16);\n            const b = parseInt(hexs.slice(4, 6), 16);\n\n            return VALUE.COLOR.FROM_RGB(r, g, b);\n        }\n    }\n    else if (str.startsWith('rgb(')) {\n        const data = str.slice(4).split(')')[0].split(',');\n\n        const r = parseInt(data[0]);\n        const g = parseInt(data[1]);\n        const b = parseInt(data[2]);\n\n        return VALUE.COLOR.FROM_RGB(r, g, b);\n    }\n    else if (str.length == 8) { // color from getAccentColor()\n        const r = parseInt(str.slice(0, 2), 16);\n        const g = parseInt(str.slice(2, 4), 16);\n        const b = parseInt(str.slice(4, 6), 16);\n\n        return VALUE.COLOR.FROM_RGB(r, g, b);\n    }\n}\n\nclass BrowserWindow extends electron.BrowserWindow {\n\n    /** @type {Number} */\n    effect = PARAMS.BACKGROUND.AUTO;\n    /** @type {Number} */\n    theme = VALUE.THEME.AUTO;\n\n    /** @type {Boolean} */\n    useDWM = false;\n\n    /** @type {Boolean} */\n    hasFrameless = false;\n\n    /** @type {Boolean} */\n    forceFocus = false;\n\n    /** @type {Boolean} */\n    hasMargin = false;\n\n    /**\n     * Create electron BrowserWindow with mica effect features\n     * @param  {...Object} args \n     */\n    constructor(...args) {\n        if (args.length > 0) {\n            args[0].transparent = false;\n            args[0].backgroundColor = '#00ffffff';\n        } else\n            args.push({\n                backgroundColor: '#00ffffff'\n            });\n\n\n        if (IS_ELECTRON_RECENT_VERSION)\n            args[0].transparent = true;\n\n\n        super(...args);\n\n\n        this.hasFrameless = args[0].frame === false || args[0].titleBarStyle == 'hidden';\n\n        let applyEffect = () => {\n            if (args.length > 0 && this.useDWM) {\n                this.executeDwm(this.effect, this.theme);\n            }\n        }\n\n        let frameRemoved = true;\n\n\n        let onWindowShow = () => {\n            applyEffect();\n\n            if (frameRemoved) {\n                frameRemoved = false;\n\n                setTimeout(() => {\n                    this.hide();\n\n                    if (IS_ELECTRON_RECENT_VERSION) {\n                        this.interceptMessage();\n                        this.applyStyle();\n\n                        if (this.hasFrameless)\n                            this.removeCaption();\n                    }\n                    redrawFrame(this);\n                    this.show();\n                }, 60);\n            }\n        }\n\n        this.on('show', onWindowShow);\n        this.on('restore', onWindowShow);\n\n        this.on('close', () => {\n            if (this.marginTimer)\n                clearInterval(this.marginTimer);\n        });\n\n        this.on('resize', () => {\n            if (this.hasFrameless)\n                setTimeout(applyEffect, 60); // refresh effect\n        });\n\n    }\n\n    /**\n     * Enable resize/maximize for the window \n     */\n    applyStyle() {\n        this.executeDwm(PARAMS.FRAME, 1);\n    }\n\n    /**\n     * Restore the full screen action\n     */\n    interceptMessage() {\n        this.executeDwm(PARAMS.FRAME, 2);\n    }\n\n    /**\n     * Remove Window Caption\n     */\n    removeCaption() {\n        this.executeDwm(PARAMS.FRAME, 4);\n    }\n\n    /**\n     * Disable transparent for mica effect\n     */\n    disableMargin() {\n        if (this.marginTimer) {\n            clearInterval(this.marginTimer);\n            this.marginTimer = null;\n        }\n        if (this.useDWM)\n            this.executeDwm(PARAMS.MARGIN, 1);\n\n        this.hasMargin = false;\n    }\n\n    /**\n     * Enable transparent for mica effect\n     */\n    enableMargin() {\n        if (this.marginTimer)\n            clearInterval(this.marginTimer);\n\n        this.hasMargin = true;\n\n        if (!this.hasFrameless && !this.forceFocus)\n            this.executeDwm(PARAMS.MARGIN, 0);\n\n        else\n            this.marginTimer = setInterval(() => {\n                try {\n                    if (this.hasFrameless)\n                        this.executeDwm(PARAMS.MARGIN, 0);\n\n                    if (this.forceFocus)\n                        this.executeDwm(PARAMS.FRAME, 5);\n                } catch (e) {\n                    clearInterval(this.marginTimer);\n                    this.marginTimer = null;\n                }\n            }, 1);\n    }\n\n    /**\n     * Focus on the window all the time so as not to lose the mica effect (decrease performance)\n     * @param {Boolean} enable \n     */\n    alwaysFocused(enable) {\n        this.forceFocus = enable;\n\n        if (this.hasMargin)\n            this.enableMargin();\n    }\n\n    /**\n     * Apply MicaEffect (only windows 11)\n     */\n    setMicaEffect() {\n        this.disableUser32();\n        this.enableMargin();\n        this.executeDwm(PARAMS.BACKGROUND.MICA, this.theme);\n    }\n\n    /**\n     * Apply MicaTabbed Effect (only windows 11)\n     */\n    setMicaTabbedEffect() {\n        this.disableUser32();\n        this.enableMargin();\n        this.executeDwm(PARAMS.BACKGROUND.TABBED_MICA, this.theme);\n    }\n\n    /**\n     * Apply Acrylic Effect (only windows 11)\n     */\n    setMicaAcrylicEffect() {\n        this.disableUser32();\n        this.enableMargin();\n        this.executeDwm(PARAMS.BACKGROUND.ACRYLIC, this.theme);\n    }\n\n    /**\n     * Apply dark theme to the electron app\n     */\n    setDarkTheme() {\n        electron.nativeTheme.themeSource = 'dark';\n        if (WINDOWS_11)\n            this.executeDwm(this.effect, VALUE.THEME.DARK);\n    }\n\n    /**\n     * Apply light theme to the electron app\n     */\n    setLightTheme() {\n        electron.nativeTheme.themeSource = 'light';\n        if (WINDOWS_11)\n            this.executeDwm(this.effect, VALUE.THEME.LIGHT);\n    }\n\n    /**\n    * Apply auto detection theme to the electron app\n    */\n    setAutoTheme() {\n        electron.nativeTheme.themeSource = 'system';\n        if (WINDOWS_11)\n            this.executeDwm(this.effect, VALUE.THEME.AUTO);\n    }\n\n    /**\n    * Apply rounded corner to the electron app\n    */\n    setRoundedCorner() {\n        this.executeDwm(PARAMS.CORNER, VALUE.CORNER.ROUND);\n    }\n\n    /**\n    * Apply rounded corner to the electron app\n    */\n    setSmallRoundedCorner() {\n        this.executeDwm(PARAMS.CORNER, VALUE.CORNER.ROUNDSMALL);\n    }\n\n    /**\n    * Apply square corner to the electron app\n    */\n    setSquareCorner() {\n        this.executeDwm(PARAMS.CORNER, VALUE.CORNER.DONOTROUND);\n    }\n\n    /**\n    * Set border color to the electron app\n    * @param  {String} color HTML color (#RRGGBB, #RGB, or rgb(r, g, b))\n    */\n    setBorderColor(color) {\n        if (color != null) {\n            color = getColorByString(color);\n            this.executeDwm(PARAMS.BORDER_COLOR, color);\n        }\n        else\n            this.executeDwm(PARAMS.BORDER_COLOR, 0xFFFFFFFF);\n    }\n\n    /**\n    * Set caption color to the electron app\n    * @param  {String} color HTML color (#RRGGBB, #RGB, or rgb(r, g, b))\n    */\n    setCaptionColor(color) {\n        if (color != null) {\n            color = getColorByString(color);\n            this.executeDwm(PARAMS.CAPTION_COLOR, color);\n        }\n        else\n            this.executeDwm(PARAMS.CAPTION_COLOR, 0xFFFFFFFF);\n    }\n\n    /**\n    * Set title text color to the electron app\n    * @param  {String} color HTML color (#RRGGBB, #RGB, or rgb(r, g, b))\n    */\n    setTitleTextColor(color) {\n        if (color != null) {\n            color = getColorByString(color);\n            this.executeDwm(PARAMS.TEXT_COLOR, color);\n        }\n        else\n            this.executeDwm(PARAMS.TEXT_COLOR, 0xFFFFFFFF);\n    }\n\n    /**\n    * Apply transparent Effect (windows 7+)\n    */\n    setTransparent() {\n        if (WINDOWS_11)\n            this.disableDWM();\n        this.executeUser32(WIN10.TRANSPARENT, 0x00ffffff);\n    }\n\n    /**\n    * Apply blur Effect (windows 7+)\n    */\n    setBlur() {\n        if (WINDOWS_11)\n            this.disableDWM();\n        this.executeUser32(WIN10.BLURBEHIND, 0x00ffffff);\n    }\n\n    /**\n    * Apply Acrylic Effect (windows 7+)\n    */\n    setAcrylic() {\n        if (WINDOWS_11)\n            this.disableDWM();\n        this.executeUser32(WIN10.ACRYLIC, 0x00909090);\n    }\n\n    /**\n     * Apply custom effect of SetWindowCompositionAttribute (windows 7+)\n     * @param {Number} nAccentState \n     * @param {String} color HTML color\n     * @param {Number} a Alpha intensity (0 < a < 1)\n     */\n    setCustomEffect(nAccentState, color, a) {\n        if (WINDOWS_11)\n            this.disableDWM();\n\n        a = Math.min(Math.max(Math.round(a * 255), 0), 255);\n        const colorToInt = getColorByString(color);\n        this.executeUser32(nAccentState, (a << 24) + colorToInt);\n    }\n\n    /**\n    * Disable windows 10 effect\n    */\n    disableUser32() {\n        if (!this.useDWM)\n            this.executeUser32(0, 0xffffffff);\n        this.useDWM = true;\n    }\n\n    /**\n    * Disable windows 11 effect\n    */\n    disableDWM() {\n        if (this.useDWM)\n            this.executeDwm(PARAMS.BACKGROUND.NONE, this.theme);\n        this.disableMargin();\n        this.useDWM = false;\n    }\n\n    /**\n     * Execute function 'DwmSetWindowAttribute' from dwmapi.dll\n     * @param  {Number} params ID of the dwAttribute\n     * @param  {Number} value New value for the params\n     */\n    executeDwm(params, value) {\n        if (executeDwm) {\n            const HWND = this.getNativeWindowHandle()[\"readInt32LE\"]();\n            executeDwm(HWND, params, value);\n\n            if (params >= 0 && params <= 4) {\n                this.effect = params;\n                this.theme = value;\n            }\n        }\n    }\n\n    /**\n     * Execute function 'SetWindowCompositionAttribute' from user32.dll\n     * @param  {Number} params ID of the dwAttribute\n     * @param  {Number} value New value for the params\n     */\n    executeUser32(params, value) {\n        if (executeUser32) {\n            const HWND = this.getNativeWindowHandle()[\"readInt32LE\"]();\n            executeUser32(HWND, params, value);\n        }\n    }\n\n}\n\nmodule.exports = {\n    PARAMS: PARAMS,\n    VALUE: VALUE,\n    MicaBrowserWindow: BrowserWindow,\n    IS_WINDOWS_11: WINDOWS_11,\n    WIN10: WIN10\n};"
  },
  {
    "path": "module/app.cpp",
    "content": "/*\nCopyright 2024 GregVido\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n#pragma warning(disable : 4996) // GetVersion() was declared deprecated\n#pragma warning(disable : 4312) // long -> HWND size >\n\n#include <node_api.h>\n\n#include \"assets/win.cpp\"\n#include \"assets/winstyle.h\"\n#include \"assets/dwm.cpp\"\n#include \"assets/user32.cpp\"\n\n#include \"assets/types.h\"\n\nnamespace micaElectron\n{\n\n  napi_value executeDwm(napi_env env, napi_callback_info args)\n  {\n    size_t argc;\n    napi_get_cb_info(env, args, &argc, nullptr, nullptr, nullptr);\n\n    napi_value *argv = new napi_value[argc];\n    napi_get_cb_info(env, args, &argc, argv, nullptr, nullptr);\n\n    if (argc < 1)\n      napi_throw_error(env, nullptr, \"HWND argument missing.\");\n\n    else if (argc < 2)\n      napi_throw_error(env, nullptr, \"PARAMS argument missing.\");\n\n    else if (argc < 3)\n      napi_throw_error(env, nullptr, \"VALUE argument missing.\");\n\n    else\n    {\n      napi_valuetype HWNDType;\n      napi_valuetype ParamsType;\n      napi_valuetype ValueType;\n\n      napi_typeof(env, argv[0], &HWNDType);\n      napi_typeof(env, argv[1], &ParamsType);\n      napi_typeof(env, argv[2], &ValueType);\n\n      bool isHWNDNumber = HWNDType == napi_number;\n      bool isParamsNumber = ParamsType == napi_number;\n      bool isValueNumber = ValueType == napi_number;\n\n      if (!isHWNDNumber)\n        napi_throw_error(env, nullptr, \"HWND argument must be an integer.\");\n\n      else if (!isParamsNumber)\n        napi_throw_error(env, nullptr, \"PARAMS argument must be an integer.\");\n\n      else if (!isValueNumber)\n        napi_throw_error(env, nullptr, \"VALUE argument must be an integer.\");\n\n      else\n      {\n        int64_t hwnd64;\n        int32_t params32;\n        int32_t value32;\n\n        napi_get_value_int64(env, argv[0], &hwnd64);\n        napi_get_value_int32(env, argv[1], &params32);\n        napi_get_value_int32(env, argv[2], &value32);\n\n        HWND hwnd = (HWND)hwnd64;\n\n        int params = (int)params32;\n        int value = (int)value32;\n\n        if (params == WINDOW_EDIT)\n        {\n          switch (value)\n          {\n            case RESET_BORDER:\n              resetBorderApp(hwnd);\n              break;\n\n            case ENABLE_MAXIMIZE:\n              enableMaximizeBox(hwnd);\n              break;\n\n            case INTERCEPT_MSG:\n              interceptMessage(hwnd);\n              break;\n\n            case ENABLE_CAPTION:\n              disableCaption(hwnd);\n              break;\n\n            case DISABLE_CAPTION:\n              enableCaption(hwnd);\n              break;\n\n            case FOCUS_WINDOW:\n              SetFocus(hwnd);\n              break;\n\n            case 10:\n              SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);\n              SetWindowPos(hwnd, NULL, 0, 0, 1920, 1080, 0x0020);\n              break;\n\n            default:\n              break;\n          }\n        }\n\n        else if (!isWin11())\n          napi_throw_error(env, nullptr, \"Mica-Electron work only on Windows 11.\");\n\n        else\n        {\n\n          enableDWM();\n\n          if (params <= MICA_EFFECT)\n          {\n            setAppTheme(value, hwnd);\n            bool success = applyMicaEffect(params, hwnd);\n\n            if (!success)\n            {\n              napi_throw_error(env, nullptr, \"You use old version of windows 11, you have don't have ACRYLIC and MICA_TABBED.\");\n              return nullptr;\n            }\n          }\n\n          else\n          {\n            switch (params)\n            {\n\n            case CORNER_TYPE:\n              setCorner(value, hwnd);\n              break;\n\n            case BORDER_COLOR:\n              setBorderColor(value, hwnd);\n              break;\n\n            case CAPTION_COLOR:\n              setCaptionColor(value, hwnd);\n              break;\n\n            case TEXT_COLOR:\n              setTextColor(value, hwnd);\n              break;\n\n            case MARGIN_TYPE:\n              setMargin(value, hwnd);\n              break;\n\n            default:\n              break;\n            }\n          }\n\n          disableDWM();\n        }\n      }\n    }\n\n    return nullptr;\n  }\n\n  napi_value executeUser32(napi_env env, napi_callback_info args)\n  {\n    size_t argc;\n    napi_get_cb_info(env, args, &argc, nullptr, nullptr, nullptr);\n\n    napi_value *argv = new napi_value[argc];\n    napi_get_cb_info(env, args, &argc, argv, nullptr, nullptr);\n\n    if (argc < 1)\n      napi_throw_error(env, nullptr, \"HWND argument missing.\");\n\n    else if (argc < 2)\n      napi_throw_error(env, nullptr, \"PARAMS argument missing.\");\n\n    else if (argc < 3)\n      napi_throw_error(env, nullptr, \"VALUE argument missing.\");\n\n    else\n    {\n      napi_valuetype HWNDType;\n      napi_valuetype ParamsType;\n      napi_valuetype ValueType;\n\n      napi_typeof(env, argv[0], &HWNDType);\n      napi_typeof(env, argv[1], &ParamsType);\n      napi_typeof(env, argv[2], &ValueType);\n\n      bool isHWNDNumber = HWNDType == napi_number;\n      bool isParamsNumber = ParamsType == napi_number;\n      bool isValueNumber = ValueType == napi_number;\n\n      if (!isHWNDNumber)\n        napi_throw_error(env, nullptr, \"HWND argument must be an integer.\");\n\n      else if (!isParamsNumber)\n        napi_throw_error(env, nullptr, \"PARAMS argument must be an integer.\");\n\n      else if (!isValueNumber)\n        napi_throw_error(env, nullptr, \"VALUE argument must be an integer.\");\n\n      else\n      {\n\n        int64_t hwnd64;\n        int32_t params32;\n        int32_t value32;\n\n        napi_get_value_int64(env, argv[0], &hwnd64);\n        napi_get_value_int32(env, argv[1], &params32);\n        napi_get_value_int32(env, argv[2], &value32);\n\n        enableUser32();\n\n        HWND hwnd = (HWND)hwnd64;\n        int params = (int)params32;\n        int value = (int)value32;\n\n        applyWindows10Effect(params, value, hwnd);\n        disableUser32();\n      }\n    }\n\n    return nullptr;\n  }\n\n  napi_value redraw(napi_env env, napi_callback_info args)\n  {\n    size_t argc;\n    napi_get_cb_info(env, args, &argc, nullptr, nullptr, nullptr);\n\n    napi_value *argv = new napi_value[argc];\n    napi_get_cb_info(env, args, &argc, argv, nullptr, nullptr);\n\n    if (argc < 1)\n      napi_throw_error(env, nullptr, \"HWND argument missing.\");\n\n    else if (argc < 2)\n      napi_throw_error(env, nullptr, \"X argument missing.\");\n\n    else if (argc < 3)\n      napi_throw_error(env, nullptr, \"Y argument missing.\");\n\n    else if (argc < 4)\n      napi_throw_error(env, nullptr, \"WIDTH argument missing.\");\n\n    else if (argc < 5)\n      napi_throw_error(env, nullptr, \"HEIGHT argument missing.\");\n\n    else\n    {\n      napi_valuetype HWNDType;\n      napi_valuetype XType;\n      napi_valuetype YType;\n      napi_valuetype WidthType;\n      napi_valuetype HeightType;\n\n      napi_typeof(env, argv[0], &HWNDType);\n      napi_typeof(env, argv[1], &XType);\n      napi_typeof(env, argv[2], &YType);\n      napi_typeof(env, argv[3], &WidthType);\n      napi_typeof(env, argv[4], &HeightType);\n\n      bool isHWNDNumber = HWNDType == napi_number;\n      bool isXNumber = XType == napi_number;\n      bool isYNumber = YType == napi_number;\n      bool isWidthNumber = WidthType == napi_number;\n      bool isHeightNumber = HeightType == napi_number;\n\n      if (!isHWNDNumber)\n        napi_throw_error(env, nullptr, \"HWND argument must be an integer.\");\n\n      else if (!isXNumber)\n        napi_throw_error(env, nullptr, \"X argument must be an integer.\");\n\n      else if (!isYNumber)\n        napi_throw_error(env, nullptr, \"Y argument must be an integer.\");\n\n      else if (!isWidthNumber)\n        napi_throw_error(env, nullptr, \"WIDTH argument must be an integer.\");\n\n      else if (!isHeightNumber)\n        napi_throw_error(env, nullptr, \"HEIGHT argument must be an integer.\");\n\n      else\n      {\n\n        int64_t hwnd64;\n        int32_t x32;\n        int32_t y32;\n        int32_t width32;\n        int32_t height32;\n\n        napi_get_value_int64(env, argv[0], &hwnd64);\n        napi_get_value_int32(env, argv[1], &x32);\n        napi_get_value_int32(env, argv[2], &y32);\n        napi_get_value_int32(env, argv[3], &width32);\n        napi_get_value_int32(env, argv[4], &height32);\n\n        HWND hwnd = (HWND)hwnd64;\n        int x = (int)x32;\n        int y = (int)y32;\n        int width = (int)width32;\n        int height = (int)height32;\n\n        SetWindowPos(hwnd, 0, x, y, width, height, 0x0020);\n      }\n    }\n\n    return nullptr;\n  }\n\n  napi_value init(napi_env env, napi_value exports)\n  {\n    napi_status status;\n    napi_value fn1;\n    napi_value fn2;\n    napi_value fn3;\n\n    status = napi_create_function(env, nullptr, 0, executeDwm, nullptr, &fn1);\n    if (status != napi_ok)\n      return nullptr;\n\n    status = napi_set_named_property(env, exports, \"executeDwm\", fn1);\n    if (status != napi_ok)\n      return nullptr;\n\n    status = napi_create_function(env, nullptr, 0, executeUser32, nullptr, &fn2);\n    if (status != napi_ok)\n      return nullptr;\n\n    status = napi_set_named_property(env, exports, \"executeUser32\", fn2);\n    if (status != napi_ok)\n      return nullptr;\n\n    status = napi_create_function(env, nullptr, 0, redraw, nullptr, &fn3);\n    if (status != napi_ok)\n      return nullptr;\n\n    status = napi_set_named_property(env, exports, \"redraw\", fn3);\n    if (status != napi_ok)\n      return nullptr;\n\n    return exports;\n  }\n\n  NAPI_MODULE(NODE_GYP_MODULE_NAME, init)\n}\n"
  },
  {
    "path": "module/assets/dwm.cpp",
    "content": "/*\nCopyright 2024 GregVido\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n#include \"dwm.h\"\n#include \"winstyle.h\"\n#include <dwmapi.h>\n\nHINSTANCE dwmapi;\npDwmSetWindowAttribute SetWindowAttribute;\npDwmExtendFrameIntoClientArea ExtendFrameIntoClientArea;\n\nbool dwmEnabled = false;\n\nvoid enableDWM()\n{\n    dwmapi = LoadLibrary(TEXT(\"dwmapi.dll\"));\n    SetWindowAttribute = (pDwmSetWindowAttribute)GetProcAddress(dwmapi, \"DwmSetWindowAttribute\");\n    ExtendFrameIntoClientArea = (pDwmExtendFrameIntoClientArea)GetProcAddress(dwmapi, \"DwmExtendFrameIntoClientArea\");\n\n    dwmEnabled = true;\n}\n\nvoid disableDWM()\n{\n    FreeLibrary(dwmapi);\n    dwmEnabled = false;\n}\n\nvoid setAppTheme(int value, HWND hwnd)\n{\n    if (dwmEnabled)\n    {\n        int useDarkTheme = 0x00;\n\n        // if dark mod, apply dark effect\n        if (value == 1 /* DARK */ || (value == 5 /* AUTO */ && !is_light_theme()))\n            useDarkTheme = 0x01;\n\n        SetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &useDarkTheme, sizeof(int));\n    }\n}\n\nbool applyMicaEffect(int type, HWND hwnd)\n{\n    if(dwmEnabled) {\n        bool insider = isInsider();\n\n        if (insider)\n            SetWindowAttribute(hwnd, DWMWA_SYSTEMBACKDROP_TYPE, &type, sizeof(int));\n\n        else if (type > 2)\n            return false;\n        \n        else\n        {\n            int micaEnable = 0x00;\n\n            if (type == 1)\n                micaEnable = 0x02;\n\n            else if (type == 2)\n                micaEnable = 0x01;\n\n            SetWindowAttribute(hwnd, DWMWA_MICA_EFFECT, &micaEnable, sizeof(int));\n        }\n    }\n\n    return true;\n}\n\nvoid setCorner(int type, HWND hwnd) {\n    if(dwmEnabled)\n        SetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &type, sizeof(int));\n}\n\nvoid setBorderColor(int type, HWND hwnd) {\n    if(dwmEnabled)\n        SetWindowAttribute(hwnd, DWMWA_BORDER_COLOR, &type, sizeof(int));\n}\n\nvoid setCaptionColor(int type, HWND hwnd) {\n    if(dwmEnabled)\n        SetWindowAttribute(hwnd, DWMWA_CAPTION_COLOR, &type, sizeof(int));\n}\n\nvoid setTextColor(int type, HWND hwnd) {\n    if(dwmEnabled)\n        SetWindowAttribute(hwnd, DWMWA_TEXT_COLOR, &type, sizeof(int));\n}\n\nvoid setMargin(int type, HWND hwnd) {\n    if(dwmEnabled) {\n        MARGINS margins;\n        if(type == 0)\n            margins = {-1};\n\n        else \n             margins = {};\n        \n        ExtendFrameIntoClientArea(hwnd, &margins);\n    }\n}"
  },
  {
    "path": "module/assets/dwm.h",
    "content": "#ifndef DWM_H\n#define DWM_H\n\n#define DWMWA_MICA_EFFECT DWORD(1029)\n#define DWMWA_SYSTEMBACKDROP_TYPE DWORD(38)\n#define DWMWA_USE_IMMERSIVE_DARK_MODE DWORD(20)\n#define DWMWA_WINDOW_CORNER_PREFERENCE DWORD(33)\n#define DWMWA_BORDER_COLOR DWORD(34)\n#define DWMWA_CAPTION_COLOR DWORD(35)\n#define DWMWA_TEXT_COLOR DWORD(36)\n\n#endif"
  },
  {
    "path": "module/assets/types.h",
    "content": "#ifndef TYPE_H\n#define TYPE_H\n\n#define MICA_EFFECT 4\n#define CORNER_TYPE 5\n#define BORDER_COLOR 6\n#define CAPTION_COLOR 7\n#define TEXT_COLOR 8\n#define WINDOW_EDIT 9\n\n#define RESET_BORDER 0\n#define ENABLE_MAXIMIZE 1\n#define INTERCEPT_MSG 2\n#define ENABLE_CAPTION 3\n#define DISABLE_CAPTION 4\n#define FOCUS_WINDOW 5\n\n#define MARGIN_TYPE 10\n\n#endif"
  },
  {
    "path": "module/assets/user32.cpp",
    "content": "/*\nCopyright 2024 GregVido\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n#include \"winstyle.h\"\n\nHINSTANCE user32;\n\npSetWindowCompositionAttribute SetWindowCompositionAttributeUser32;\n\nbool user32Enabled = false;\n\nvoid enableUser32()\n{\n    user32 = LoadLibrary(TEXT(\"user32.dll\"));\n    SetWindowCompositionAttributeUser32 = (pSetWindowCompositionAttribute)GetProcAddress(user32, \"SetWindowCompositionAttribute\");\n    user32Enabled = true;\n}\n\nvoid disableUser32()\n{\n    FreeLibrary(user32);\n    user32Enabled = false;\n}\n\nvoid resetBorderApp(HWND hwnd)\n{\n    SetWindowLongA(hwnd, -16, 0x004F0000L);\n}\n\nvoid enableMaximizeBox(HWND hwnd)\n{\n    LONG_PTR style = GetWindowLongA(hwnd, GWL_STYLE);\n\n    style |= WS_SIZEBOX;\n    style |= WS_THICKFRAME;\n    style |= WS_MAXIMIZEBOX;\n\n    SetWindowLongA(hwnd, GWL_STYLE, style);\n}\n\nvoid interceptMessage(HWND hwnd)\n{\n    originalWndProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC);\n    SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WindowProc);\n}\n\nvoid disableCaption(HWND hwnd)\n{\n    LONG_PTR style = GetWindowLongA(hwnd, GWL_STYLE);\n    style &= ~WS_CAPTION;\n    SetWindowLongA(hwnd, GWL_STYLE, style);\n}\n\nvoid enableCaption(HWND hwnd)\n{\n    LONG_PTR style = GetWindowLongA(hwnd, GWL_STYLE);\n    style |= WS_CAPTION;\n    SetWindowLongA(hwnd, GWL_STYLE, style);\n}\n\nvoid applyWindows10Effect(int nAccentState, int nColor, HWND hwnd)\n{\n    if (user32Enabled)\n    {\n        ACCENTPOLICY policy;\n        policy.nAccentState = nAccentState;\n        policy.nFlags = 2;\n        policy.nColor = nColor;\n        policy.nAnimationId = 0;\n\n        WINCOMATTRPDATA data;\n        data.nAttribute = 19;\n        data.pData = &policy;\n        data.ulDataSize = sizeof(policy);\n\n        SetWindowCompositionAttributeUser32(hwnd, &data);\n    }\n}"
  },
  {
    "path": "module/assets/win.cpp",
    "content": "/*\nCopyright 2024 GregVido\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n#include <dwmapi.h>\n\n#include <vector>\n#include <string>\n#include <stdexcept>\n\nWNDPROC originalWndProc;\n\nLRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n\n  switch (uMsg)\n  {\n    case WM_SYSCOMMAND:\n      return DefWindowProc(hwnd, uMsg, wParam, lParam);\n\n    case WM_SIZE:\n/*\n      if (wParam == SIZE_MAXIMIZED)\n        return DefWindowProc(hwnd, uMsg, wParam, lParam);*/\n\n      return CallWindowProc(originalWndProc, hwnd, uMsg, wParam, lParam);\n\n    default:\n      return CallWindowProc(originalWndProc, hwnd, uMsg, wParam, lParam);\n  }\n}\n\nDWORD getBuild()\n{\n  DWORD dwVersion = 0;\n  DWORD dwMajorVersion = 0;\n  DWORD dwMinorVersion = 0;\n  DWORD dwBuild = 0;\n\n  dwVersion = GetVersion();\n\n  dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));\n  dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));\n\n  if (dwVersion < 0x80000000)\n    dwBuild = (DWORD)(HIWORD(dwVersion));\n\n  return dwBuild;\n}\n\nbool isInsider()\n{\n  return getBuild() >= 22621;\n}\n\nbool isWin11()\n{\n  return getBuild() >= 22000;\n}\n\nbool is_light_theme()\n{\n  // based on https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application\n\n  // The value is expected to be a REG_DWORD, which is a signed 32-bit little-endian\n  auto buffer = std::vector<char>(4);\n  auto cbData = static_cast<DWORD>(buffer.size() * sizeof(char));\n  auto res = RegGetValueW(\n      HKEY_CURRENT_USER,\n      L\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Themes\\\\Personalize\",\n      L\"AppsUseLightTheme\",\n      RRF_RT_REG_DWORD, // expected value type\n      nullptr,\n      buffer.data(),\n      &cbData);\n\n  if (res != ERROR_SUCCESS)\n  {\n    throw std::runtime_error(\"Error: error_code=\" + std::to_string(res));\n  }\n\n  // convert bytes written to our buffer to an int, assuming little-endian\n  auto i = int(buffer[3] << 24 |\n               buffer[2] << 16 |\n               buffer[1] << 8 |\n               buffer[0]);\n\n  return i == 1;\n}"
  },
  {
    "path": "module/assets/winstyle.h",
    "content": "#include <dwmapi.h>\n\n#ifndef WIN_STYLE_H\n#define WIN_STYLE_H\n\nstruct ACCENTPOLICY\n{\n\tint nAccentState;\n\tint nFlags;\n\tint nColor;\n\tint nAnimationId;\n};\n\nstruct WINCOMATTRPDATA\n{\n\tint nAttribute;\n\tPVOID pData;\n\tULONG ulDataSize;\n};\n\ntypedef BOOL(WINAPI *pSetWindowCompositionAttribute)(HWND, WINCOMATTRPDATA *);\ntypedef BOOL(WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, int *, int);\n\ntypedef BOOL(WINAPI *pSetLayeredWindowAttributes)(HWND, int, byte, int);\ntypedef BOOL(WINAPI *pDwmExtendFrameIntoClientArea)(HWND, MARGINS *);\n\ntypedef BOOL(WINAPI *pSetWindowPos)(HWND, HWND, int, int, int, int, int);\ntypedef HWND(WINAPI *pSetWindowLongA)(HWND, int, long);\ntypedef LONG(WINAPI *pGetWindowLongA)(HWND, int);\n\n#endif"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"mica-electron\",\n  \"version\": \"1.5.17\",\n  \"description\": \"Tool to add mica effect of windows 11 in electron app\",\n  \"main\": \"main.js\",\n  \"types\": \"./types/index.d.ts\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/GregVido/mica-electron.git\"\n  },\n  \"keywords\": [\n    \"electron\",\n    \"mica\",\n    \"windows 11\",\n    \"acrylic\",\n    \"transparent\",\n    \"glasstron\"\n  ],\n  \"author\": \"GregVido\",\n  \"license\": \"Apache-2.0\",\n  \"bugs\": {\n    \"url\": \"https://github.com/GregVido/mica-electron/issues\"\n  },\n  \"homepage\": \"https://github.com/GregVido/mica-electron\",\n  \"devDependencies\": {\n    \"electron\": \"^33.2.1\",\n    \"@electron/rebuild\": \"^3.7.1\"\n  }\n}\n"
  },
  {
    "path": "types/index.d.ts",
    "content": "import \"electron\";\n\ndeclare module \"mica-electron\" {\n    // TODO: rework CSS colors\n    // type HexColor = `#${string}`;\n    // type RGBColor = `rgb(${number}, ${number}, ${number})`;\n    // type CSSColor = string;\n\n    export class MicaBrowserWindow extends Electron.BrowserWindow {\n        /**\n         * Current theme value, represented by an integer\n         */\n        public theme: number;\n        /**\n         * Current effect value, represented by an integer\n         */\n        public effect: number;\n        /**\n         * Shows whether this window is using DWM or User32\n         */\n        public useDWM: boolean;\n        /**\n         * Shows whether this window is frameless\n         */\n        public hasFrameless: boolean;\n\n        /**\n         * Disable transparent for mica effect\n         */\n        public disableMargin(): void;\n\n        /**\n         * Enable transparent for mica effect\n         */\n        public enableMargin(): void;\n\n        /**\n         * Apply the Mica effect (Windows 11 only)\n         */\n        public setMicaEffect(): void;\n\n        /**\n         * Apply the Tabbed Mica effect (Windows 11 only)\n         */\n        public setMicaTabbedEffect(): void\n        /**\n         * Apply the Acrylic effect (Windows 11 only)\n         */\n        public setMicaAcrylicEffect(): void;\n\n        /**\n         * Change theme to dark\n         */\n        public setDarkTheme(): void;\n\n        /**\n         * Change theme to light\n         */\n        public setLightTheme(): void;\n\n        /**\n        * Make theme automatically adapt to the system\n        */\n        public setAutoTheme(): void;\n\n        /**\n        * Set corner radius to normal (Windows 11 only)\n        */\n        public setRoundedCorner(): void;\n\n        /**\n        * Set corner radius to small (Windows 11 only)\n        */\n        public setSmallRoundedCorner(): void;\n\n        /**\n        * Set corner radius to 0 (Windows 11 only)\n        */\n        public setSquareCorner(): void;\n\n        /**\n        * Change window's border color\n        */\n        public setBorderColor(color: string): void;\n\n        /**\n        * Change window's titlebar color\n        */\n        public setCaptionColor(color: string): void;\n\n        /**\n        * Change window's title text color\n        */\n        public setTitleTextColor(color: string): void;\n\n        /**\n        * Apply the Transparent Effect (Windows 7+)\n        */\n        public setTransparent(): void;\n\n        /**\n        * Apply the Blur Effect (Windows 7+)\n        */\n        public setBlur(): void;\n\n        /**\n        * Apply the Acrylic Effect (Windows 7+)\n        */\n        public setAcrylic(): void;\n\n        /**\n         * Apply a custom effect of SetWindowCompositionAttribute (Windows 7+)\n         */\n        public setCustomEffect(nAccentState: number, color: string, alpha: number): void;\n\n        /**\n        * Disables support for Windows 10 effects (Acrylic and Blur)\n        */\n        public disableUser32(): void;\n\n        /**\n        * Disables support for Windows 11 effects (Mica and Acrylic)\n        */\n        public disableDWM(): void;\n\n        /**\n         * Executes the `DwmSetWindowAttribute` function from `dwmapi.dll`\n         */\n        public executeDwm(params: number, value: number): void;\n\n        /**\n         * Executes the `SetWindowCompositionAttribute` function from `user32.dll`\n         */\n        public executeUser32(params: number, value: number): void;\n    }\n\n    /**\n     * Shows if the machine is running Windows 11\n     */\n    export const IS_WINDOWS_11: boolean;\n    /**\n     * Values specifying several window properties\n     */\n    export const PARAMS: {\n        /**\n         * Effects configuration\n         */\n        BACKGROUND: {\n            AUTO: 0,\n            NONE: 1,\n            /**\n             * Acrylic Effect\n             */\n            ACRYLIC: 3,\n            /**\n             * Mica Effect\n             */\n            MICA: 2,\n            /**\n             * Mica Tabbed Effect\n             */\n            TABBED_MICA: 4\n        },\n        /**\n         * Corner radius configuration\n         */\n        CORNER: 5,\n        /**\n         * Border color configuration\n         */\n        BORDER_COLOR: 6,\n        /**\n         * Titlebar color configuration\n         */\n        CAPTION_COLOR: 7,\n        /**\n         * Text color configuration\n         */\n        TEXT_COLOR: 8,\n        FRAME: 9,\n        MARGIN: 10\n    };\n    /**\n     * Values which can be used in several effects\n     */\n    export const VALUE: {\n        /**\n         * Theme values\n         */\n        THEME: {\n            /**\n             * Automatic theme\n             */\n            AUTO: 5,\n            /**\n             * Dark theme\n             */\n            DARK: 1,\n            /**\n             * Light theme\n             */\n            LIGHT: 2,\n        },\n        /**\n         * Corner radius values\n         */\n        CORNER: {\n            /**\n             * Default corners\n             */\n            DEFAULT: 0,\n            /**\n             * Square corners\n             */\n            DONOTROUND: 1,\n            /**\n             * Rounded corners\n             */\n            ROUND: 2,\n            /**\n             * Small rounded corners\n             */\n            ROUNDSMALL: 3\n        },\n        /**\n         * Color values\n         */\n        COLOR: {\n            RED: 0x000000FF,\n            GREEN: 0x0000FF00,\n            BLUE: 0x00FF0000,\n            BLACK: 0x00000000,\n            WHITE: 0x00FFFFFF,\n            /**\n             * Convert red, green and blue values into a single hex color\n             */\n            FROM_RGB: (red: number, green: number, blue: number) => number\n        },\n        /**\n         * Falsely value\n         */\n        FALSE: 0,\n        /**\n         * Truthful value\n         */\n        TRUE: 1\n    };\n    /**\n     * Windows 10 effects\n     */\n    export const WIN10: {\n        /**\n         * Transparent Effect\n         */\n        TRANSPARENT: 2,\n        /**\n         * Blur Effect\n         */\n        BLURBEHIND: 3,\n        /**\n         * Acrylic Effect\n         */\n        ACRYLIC: 4\n    }\n}\n"
  }
]