Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarations for engine and controller scripting API #4759

Merged
merged 36 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8a9d07b
Declarations for engine and controller scripting API
JoergAtGithub May 12, 2022
b9310a5
Merge remote-tracking branch 'upstream/Main' into controllerApiDeclar…
JoergAtGithub Jun 6, 2022
b1d689c
Added missing declarations for QJSEngine::ConsoleExtension
JoergAtGithub Jun 6, 2022
3b146e9
Added/Improved documentation
JoergAtGithub Jun 7, 2022
9397e8a
Documented controlCallback functions
JoergAtGithub Jun 7, 2022
f7bf179
Marked engine.log as deprecated
JoergAtGithub Jun 7, 2022
92e35a0
Documented engine API functions
JoergAtGithub Jun 8, 2022
573a615
Formatting
JoergAtGithub Jun 8, 2022
a743f33
Documented MIDI API and corrected console command docu
JoergAtGithub Jun 9, 2022
fb8a3b6
--controllerDebug => --controller-debug
JoergAtGithub Jun 12, 2022
5fc2ca1
Changed text why console.profiling functions are not usable for mappi…
JoergAtGithub Jun 12, 2022
8d6edaf
Fixed typo
JoergAtGithub Jun 12, 2022
07abdf4
Add hyperlink for alias
JoergAtGithub Jun 26, 2022
039cf93
Added information about the 20ms minimum interval of JS timers
JoergAtGithub Jun 26, 2022
98502bf
Replaced declare class with declare namespace
JoergAtGithub Jun 26, 2022
28b9e1a
Added declaration for ColorMapper class
JoergAtGithub Jan 22, 2023
480205b
Merge remote-tracking branch 'upstream/2.4' into controllerApiDeclara…
JoergAtGithub Apr 4, 2023
fb18a2c
Improved console-api.d.ts
JoergAtGithub Apr 7, 2023
8deaaea
Adjusted spacing to the style used in the typescript docs
JoergAtGithub Apr 7, 2023
989619b
Removed wrong text "Javascript type Uint8Array"
JoergAtGithub Apr 7, 2023
a6fa34d
Added ScriptConnection class which is returned by makeConnection etc.…
JoergAtGithub Apr 7, 2023
ab94500
Added @typescript-eslint to pre-commit
JoergAtGithub Apr 7, 2023
a04280b
Fix pre-commit/eslint issues
JoergAtGithub Apr 7, 2023
8e9bb3b
Added type for timerId
JoergAtGithub Apr 7, 2023
95f06c9
Fixed codespell setup
JoergAtGithub Apr 7, 2023
5f937fa
Corrected return type of getInputReport and getFeatureReport
JoergAtGithub May 1, 2023
7ae4f68
Fixed typos an other textual review suggestions
JoergAtGithub May 2, 2023
f16c964
Fixed regexp to distinguish translation files from TypeScript files
JoergAtGithub May 13, 2023
b780d59
Declare ScriptConnection as interface, instead as class, which preven…
JoergAtGithub May 13, 2023
3b6b5b2
Fixed wrong namespace from controller to midi
JoergAtGithub May 13, 2023
29305e9
Added hyperlinks to Mixxx Controls manual page
JoergAtGithub May 13, 2023
992a7f9
Rewrote documentation for ColorMapper class
JoergAtGithub May 13, 2023
7c5130f
Adjusted indentation
JoergAtGithub May 13, 2023
3e28b75
Corrected English
JoergAtGithub May 13, 2023
e18c992
Adjusted indentation for GetInputReport
JoergAtGithub May 13, 2023
bda69bc
Adjusted indentation
JoergAtGithub May 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"extends": [ "eslint:recommended", "plugin:jsdoc/recommended" ],
"extends": [ "eslint:recommended",
"plugin:jsdoc/recommended",
"plugin:@typescript-eslint/recommended" ],

"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "script"
},
"env": {
"es6": true
},
"plugins": [ "jsdoc" ],
"plugins": [ "jsdoc", "@typescript-eslint" ],
"settings": {
"jsdoc": {
"preferredTypes": {
Expand Down Expand Up @@ -93,6 +97,12 @@
"console": "readonly"
},
"overrides": [
{
"files": [ "res/controllers/*.d.ts" ],
"rules": {
"no-unused-vars": "off"
}
},
{
"files": [ "**/*.mjs" ],
"parserOptions": {
Expand Down
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|mm|proto|vert)$
exclude: \.(c|cc|cxx|cpp|d.ts|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|mm|proto|vert)$
- id: no-commit-to-branch
# protect main and any branch that has a semver-like name
args: [-b, main, -p, '^\d+\.\d+(?:\.\d+)?$']
Expand All @@ -62,20 +62,22 @@ repos:
--ignore-regex,
"\\W(?:m_p*(?=[A-Z])|m_(?=\\w)|pp*(?=[A-Z])|k(?=[A-Z])|s_(?=\\w))",
]
exclude: ^(packaging/wix/LICENSE.rtf|src/dialog/dlgabout\.cpp|.*\.(?:pot?|ts|wxl|svg))$
exclude: ^(packaging/wix/LICENSE.rtf|src/dialog/dlgabout\.cpp|.*\.(?:pot?|(?<!d\.)ts|wxl|svg))$
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.25.0
hooks:
- id: eslint
args: [--fix, --report-unused-disable-directives]
files: \.m?js$
files: \.m?[jt]s$
types: [file]
stages:
- commit
- manual
additional_dependencies:
- eslint@^v8.6.0
- eslint-plugin-jsdoc@^v37.5.0
- "@typescript-eslint/eslint-plugin"
- "@typescript-eslint/parser"
- repo: local
hooks:
- id: clang-format
Expand Down
29 changes: 29 additions & 0 deletions res/controllers/color-mapper-api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

/** ColorMapperJSProxy */

declare class ColorMapper {
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
/**
* Constructs a ColorMapper object which maps RGB colors to device specific color codes
*
* @param availableColors List of number pairs (e.g. {0xFF0000: 1, 0x00FF00: 2} )
*/
constructor (availableColors: { [rgbColor: number]: number });

/**
* For a given RGB color code (e.g. 0xFF0000), this finds the nearest
* available color and returns a JS object with properties "red", "green",
* "blue" (each with value range 0-255).
*
* @param colorCode Device specific color code
*/
getNearestColor(colorCode: number): {[rgb: number]: number};

/**
* For a given RGB color code (e.g. 0xFF0000), this finds the nearest
* available color, then returns the value associated with that color
* (which could be a MIDI byte value for example).
*
* @param rgbColor RGB color (e.g. 0xFF00CC)
*/
getValueForNearestColor(rgbColor: number): number;
}
138 changes: 138 additions & 0 deletions res/controllers/console-api.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

/**
Mixxx installs the QJSEngine::ConsoleExtension for the use in controller mapping scripts.
See also:
https://doc.qt.io/qt-5/qtquick-debugging.html#console-api
https://developer.mozilla.org/en-US/docs/Web/API/console
https://console.spec.whatwg.org/
*/

declare namespace console {
/**
* Prints debugging information to the console, when
* QT_LOGGING_RULES="js.debug=true;" or
* Mixxx is started with --controller-debug
* This function is identical to console.debug
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function log(...data: any[]): void;

/**
* Prints debugging information to the console, when
* QT_LOGGING_RULES="js.debug=true;" or
* Mixxx is started with --controller-debug
* This function is identical to console.log
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function debug(...data: any[]): void;

/**
* Prints information to the console, when
* QT_LOGGING_RULES="js.info=true;" or
* Mixxx is started with --controller-debug
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function info(...data: any[]): void;

/**
* Prints a warning message to the console, when
* QT_LOGGING_RULES="js.warning=true;" or
* Mixxx is started with --controller-debug
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function warn(...data: any[]): void;

/**
* Prints an error message to the console, when
* QT_LOGGING_RULES="js.critical=true;" or
* Mixxx is started with --controller-debug
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function error(...data: any[]): void;

/**
* Tests that a boolean expression is true,
* if not, it writes an (optional) message to the console and prints the stack trace.
*
* @param condition If the condition is false, it prints message and stack trace
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function assert(condition: boolean, ...data: any[]): void;

/**
* Starts the time measurement, which will be printed by timeEnd
*
* @param label string argument that identifies the measurement.
*/
function time(label?: string): void;
/**
* Logs the time (in milliseconds) that was spent since the call of the time method.
*
* @param label string argument that identifies the measurement.
*/
function timeEnd(label?: string): void;

/**
* Prints the stack trace of the JavaScript execution at the point where it was called.
* This stack trace information contains the function name, file name, line number, and column number.
* The stack trace is limited to last 10 stack frames.
*
* Unfortunately this function does use the wrong logging category "default" instead of "js",
* which is set when you start Mixxx with --controller-debug. Without setting logging category
* "default" manually, you will not see any output.
* [see QTBUG-108673]{@link https://bugreports.qt.io/browse/QTBUG-108673}
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function trace(...data: any[]): void;

/**
* Prints the current number of times a particular piece of code has run, along with a message.
*
* @param label
*/
function count(label?: string): void;

/**
* Turns on the JavaScript profiler.
*
* @deprecated Not usable for controller mappings for now [see QTBUG-65419]{@link https://bugreports.qt.io/browse/QTBUG-65419}
*/
function profile(label?: string): void;

/**
* Turns off the JavaScript profiler.
*
* @deprecated Not usable for controller mappings for now [see QTBUG-65419]{@link https://bugreports.qt.io/browse/QTBUG-65419}
*/
function profileEnd(label?: string): void;

/**
* Prints an error message together with the stack trace of JavaScript execution at the point where it is called.
*
* @param data Message to print
* - Either a list of objects whose string representations get concatenated into the message string
* - Or a string containing zero or more substitution strings followed by a list of objects to replace them
*/
function exception(...data: any[]): void;

}
Loading