mixxx icon indicating copy to clipboard operation
mixxx copied to clipboard

Declarations for engine and controller scripting API

Open JoergAtGithub opened this issue 3 years ago • 13 comments

These declarations allow modern code editors and IDEs, to show online syntax help and allows type checking (as far as JavaScript supports types).

To enable this, the mapping developer has to create a file jsconfig.json in the directory with the JavaScript mapping to edit. This file is editor independend an should work with all editors, which support the Language Server Protocol (LSP), like VS Code, Atom, Eclipse, Kate, Sublime, etc.

The jsconfig.json must have the a content like below, that allows the editor to find all include files and tells him to use ES6 syntax:

{
  "compilerOptions": {
    "target": "es6",
    "checkJs": true,
    "lib": ["ES6"]
  },
  "include": ["<mappingpath>/Traktor-Kontrol-Z2-hid-scripts.js",
    "<mixxxpath>/res/controllers/common-hid-packet-parser.js",
    "<mixxxpath>/res/controllers/common-controller-scripts.js",
    "<mixxxpath>/res/controllers/hid-controller-api.d.ts",
    "<mixxxpath>/res/controllers/engine-api.d.ts",
    "<mixxxpath>/res/controllers/console-api.d.ts"]
}

grafik

grafik

JoergAtGithub avatar May 12 '22 22:05 JoergAtGithub

Sounds reasonable. Does this put any mandatory work to the mapping developer, that makes work harder as a noob contributor?

daschuer avatar Jun 08 '22 06:06 daschuer

Nothing mandatory, if you don't create the jsconfig.json file next to your mapping file, everything is as before.

JoergAtGithub avatar Jun 08 '22 06:06 JoergAtGithub

Please ping me when this PR is ready for review. I'll take a look then.

Swiftb0y avatar Jun 08 '22 08:06 Swiftb0y

Please ping me when this PR is ready for review. I'll take a look then.

@Swiftb0y This is now ready for review!

JoergAtGithub avatar Jun 09 '22 20:06 JoergAtGithub

@JoergAtGithub please also take a look at my previous but abandoned attempt at this #2636

Swiftb0y avatar Jun 13 '22 21:06 Swiftb0y

@JoergAtGithub please also take a look at my previous but abandoned attempt at this #2636

Wasn't aware of this PR. I'm not at home this week, and will address your review comments the week after.

JoergAtGithub avatar Jun 13 '22 22:06 JoergAtGithub

No problem. I just wanted to supply some context for my review comments.

Swiftb0y avatar Jun 13 '22 22:06 Swiftb0y

Is this one again ready for review?

daschuer avatar Jul 04 '22 11:07 daschuer

FYI, most of my comments from the first review have not been addressed yet.

Swiftb0y avatar Jul 04 '22 12:07 Swiftb0y

How do we want to visualize that case? Back to draft, or a new lable?

daschuer avatar Jul 04 '22 12:07 daschuer

IMO stale?

Swiftb0y avatar Jul 04 '22 13:07 Swiftb0y

I will continue here. IMHO the status is clear, @Swiftb0y requested changes and I clicked not yet on the re-review button, which is visually indicated.

JoergAtGithub avatar Jul 04 '22 19:07 JoergAtGithub

Oh I am sorry for misusing your PR vor the general workflow questions. It is nothing wrong here. I will open a topic on Zulip for the general labling questions.

daschuer avatar Jul 04 '22 20:07 daschuer

This PR is marked as stale because it has been open 90 days with no activity.

github-actions[bot] avatar Oct 09 '22 00:10 github-actions[bot]

@JoergAtGithub do you consider this ready for review now?

daschuer avatar Feb 02 '23 08:02 daschuer

I need to address the review remarks from Niko first.

JoergAtGithub avatar Feb 02 '23 18:02 JoergAtGithub

I'll try to stay responsive if you reply on any of the open threads. Feel free to request a re-review once you see fit for it.

Swiftb0y avatar Feb 02 '23 20:02 Swiftb0y

Thanks Niko! I will do, but I haven't clarified all questions you raised in the last review of this PR yet.

JoergAtGithub avatar Feb 02 '23 20:02 JoergAtGithub

It would be nice if we could also lint the new typescript declaration files. Would you be willing to look into what it would take to add typescript-eslint to our eslint config?

Swiftb0y avatar Apr 07 '23 17:04 Swiftb0y

After getting the jsconfig to work, I'm really annoyed by the fact that a developer needs to edit the jsconfig to reference their mapping in order for everything to work. After a bit of research and trial and error, I don't think there is anything we can do against that, right?

We could get that working by making each mapping their own project (which would make sense) but that would require putting each mapping to its own folder. That's something I would like to do anyways in the future, but is out-of-scope for this PR.

I think we should include a jsconfig as well. Putting this into res/controllers/ should work:

{
    "compilerOptions": {
        "target": "es6",
        "checkJs": true,
        "lib": ["ES6"]
    },
    "include": [
        "*.d.ts",
        "common-hid-packet-parser.js",
        "common-controller-scripts.js",

        // add the filename of your own mapping here:
        ""

        // make sure to exclude any changes in this file from your submission
    ]
}

Swiftb0y avatar May 02 '23 20:05 Swiftb0y

I would not like to add a jsconfig.json in the scope of this PR.

JoergAtGithub avatar May 13 '23 12:05 JoergAtGithub

I would not like to add a jsconfig.json in the scope of this PR.

Thats fair. Though it certainly makes it more difficult to test.

Swiftb0y avatar May 13 '23 13:05 Swiftb0y

Done

JoergAtGithub avatar May 13 '23 16:05 JoergAtGithub

Time to celebrate twice - the PR is exactly 1 year old today. 🎂

JoergAtGithub avatar May 13 '23 18:05 JoergAtGithub

Sorry, this took this long... Highly appreciate the effort though.

Swiftb0y avatar May 13 '23 18:05 Swiftb0y

Thank you for the review!

JoergAtGithub avatar May 13 '23 18:05 JoergAtGithub