Closed cryptofyre closed 4 months ago
We'd love to use this in our app Cider but it's kind of a pain at the moment due to the lack of types.
Hello, I'm not at home this week I will do it during the weekend
Awesome thanks!
Typescript definitions would be super helpful! Pretty sure these can be generated super easily. https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
I am not personally to familiar with creating definition files though. Hopefully they get added soon!
Skimmed over the examples and source js to throw this together. Maybe it will help someone who knows the win api / C++ fix the package.
Create a mica-electron.d.ts
at the same directory level as your main process' entry point.
type _Internal_ExtractValuesRecursive<T extends Record<string, unknown>> = T extends Record<
string,
infer V
>
? V extends Record<string, unknown>
? _Internal_ExtractValuesRecursive<V>
: V
: never
declare module 'mica-electron' {
export type _32BitInteger = number
export type Param = _Internal_ExtractValuesRecursive<typeof PARAMS>
export type Value = _Internal_ExtractValuesRecursive<typeof VALUE>
export class MicaBrowserWindow extends Electron.BrowserWindow {
lastEffect: number
lastTheme: number
constructor(
options?: Electron.BrowserWindowConstructorOptions & { effect?: number; theme?: number }
)
setVisualEffect(param: Param, value: Value): void
}
export function executeDwm(HWDN: _32BitInteger, param: Param)
export function redraw(
hwnd: _32BitInteger,
x: number,
y: number,
width: number,
height: number,
_internal_arg?: _32BitInteger
): void
export const PARAMS: {
BACKGROUND: {
AUTO: 0
NONE: 1
ACRYLIC: 3
MICA: 2
TABBED_MICA: 4
}
CORNER: 5
BORDER_COLOR: 6
CAPTION_COLOR: 7
TEXT_COLOR: 8
FRAME: 9
}
export const VALUE: {
THEME: {
AUTO: 0
DARK: 1
LIGHT: 2
}
CORNER: {
DEFAULT: 0
DONOTROUND: 1
ROUND: 2
ROUNDSMALL: 3
}
COLOR: {
RED: 0x000000ff
GREEN: 0x0000ff00
BLUE: 0x00ff0000
BLACK: 0x00000000
WHITE: 0x00ffffff
FROM_RGB: (red: number, green: number, blue: number) => number
}
FALSE: 0
TRUE: 1
}
}
I forked this repo and published mica-electron-ts!
@DeMineArchiver Maybe make a pull request for the main module?
We'd love to use this in our app Cider but it's kind of a pain at the moment due to the lack of types.