Gr3q / types-cjs

Typescript declarations for CJS - Cinnamon JavaScript
MIT License
5 stars 2 forks source link

Is it possible to use these type to dev applets? #17

Open vdakalov opened 2 years ago

vdakalov commented 2 years ago

I'm new in dev under Cinnamon, but it is looks like it is what I needed when dev my own applets. I'm right?

Gr3q commented 2 years ago

Yeah - if you plan to use Typescript. Just be vary that this is currently not versioned (meaning It's kinda following the latest Cinnamon version, so if you target 3.8 etc there might be differences).

Examples (published applets) of how you can use it: https://github.com/linuxmint/cinnamon-spices-applets/tree/master/radio%40driglu4it https://github.com/linuxmint/cinnamon-spices-applets/tree/master/weather%40mockturtl

jonath92 commented 2 years ago

@vdakalov you can also use this repo as a template: https://github.com/jonath92/cinnamon-template-applet. The repo is not perfect but AFAICs it is the easiest way to setup an applet in typescript - just follow the steps in the readme - and you should have a very basic working applet.

vdakalov commented 2 years ago

@jonath92 thank you for share but I'm already develop one for me. I published it in my repo just now. So you can check it out too if you want ;)

https://github.com/vdakalov/cinnamon-applet-template

jonath92 commented 2 years ago

Cool looks interesting. I am very glad to see someone new using the types as Gr3q and also myself have spend a lot of time in the types. There are imo not perfect but really good.

vdakalov commented 2 years ago

Yes guys, you did really a lot of good work. Thank you for these types. It will be great to make something useful for the project and I will if find any free time. For now I can say my suggestions to improve it, if you don't mind

  1. You suggest users insert import "@ci-types/cjs"; in code to use these types, but it's not convenient. It would be better to add types in tsconfig.json (e.g. compilerOptions.types: ["@ci-types/cjs"]). This way works fine for me.
  2. I'm not sure if it possible, but it will be great to develop some SDK that hide differences between cinnamon versions and allow users to develop applet for any cinnamon versions at the same time. I mean we can suggest users smart require function, for example.
  3. I faced with absent types of imports.applets and imports.appletManager. This is due to differences between cinnamon versions or it just hasn't been done yet?
Gr3q commented 2 years ago
  1. Yeah that's better, I'll update the readme.
  2. The real solution would be is that I would push separate versions for cinnamon versions. It is relatively easy to do that for the files in the root folder because are generated (well, I would have to obtain them from each cinnamon version). The real work would be for whatever is in the cinnamon folder, they are manually typed, so someone needs to go through the JS files and diff them for each version I guess. This is also fine, but as said, it takes time that I don't have atm.
  3. types are missing from the cinnamon version because they are either incomplete, outdated, I was not able to discern the types for them or just plain impossible to know the types before runtime (see AppletImports in imports.applets)