juce-framework-frontend-mirror
Advanced tools
Comparing version
@@ -71,6 +71,12 @@ /* | ||
constructor() { | ||
/** @type {Map<number, (args: any) => any>} */ | ||
this.listeners = new Map(); | ||
/** @type {number} */ | ||
this.listenerId = 0; | ||
} | ||
/** | ||
* @param {(args: any) => any} fn | ||
* @returns number | ||
*/ | ||
addListener(fn) { | ||
@@ -82,2 +88,5 @@ const newListenerId = this.listenerId++; | ||
/** | ||
* @param {number} id | ||
*/ | ||
removeListener(id) { | ||
@@ -98,5 +107,11 @@ if (this.listeners.has(id)) { | ||
constructor() { | ||
/** @type {Map<any, ListenerList>} */ | ||
this.eventListeners = new Map(); | ||
} | ||
/** | ||
* @param {string} eventId | ||
* @param {(args: any) => any} fn | ||
* @returns {[string, number]} | ||
*/ | ||
addEventListener(eventId, fn) { | ||
@@ -111,2 +126,5 @@ if (!this.eventListeners.has(eventId)) | ||
/** | ||
* @param {[eventId: string, id: number]} | ||
*/ | ||
removeEventListener([eventId, id]) { | ||
@@ -118,2 +136,6 @@ if (this.eventListeners.has(eventId)) { | ||
/** | ||
* @param {string} eventId | ||
* @param {any} object | ||
*/ | ||
emitEvent(eventId, object) { | ||
@@ -127,5 +149,11 @@ if (this.eventListeners.has(eventId)) | ||
constructor() { | ||
/** @type {EventListenerList} */ | ||
this.listeners = new EventListenerList(); | ||
} | ||
/** | ||
* @param {string} eventId | ||
* @param {(args: any) => any} fn | ||
* @returns {[string, number]} | ||
*/ | ||
addEventListener(eventId, fn) { | ||
@@ -135,6 +163,13 @@ return this.listeners.addEventListener(eventId, fn); | ||
/** | ||
* @param {[eventId: string, id: number]} param0 | ||
*/ | ||
removeEventListener([eventId, id]) { | ||
this.listeners.removeEventListener(eventId, id); | ||
this.listeners.removeEventListener([eventId, id]); | ||
} | ||
/** | ||
* @param {string} eventId | ||
* @param {any} object | ||
*/ | ||
emitEvent(eventId, object) { | ||
@@ -146,2 +181,6 @@ window.__JUCE__.postMessage( | ||
/** | ||
* @param {string} eventId | ||
* @param {any} object | ||
*/ | ||
emitByBackend(eventId, object) { | ||
@@ -148,0 +187,0 @@ this.listeners.emitEvent(eventId, JSON.parse(object)); |
219
index.d.ts
@@ -1,13 +0,80 @@ | ||
export class PromiseHandler { | ||
lastPromiseId: number; | ||
promises: Map<number, any>; | ||
createPromise(): [number, Promise<any>]; | ||
/// <reference path="global.d.ts" /> | ||
/** | ||
* Returns a function object that calls a function registered on the JUCE backend and forwards all | ||
* parameters to it. | ||
* | ||
* The provided name should be the same as the name argument passed to | ||
* WebBrowserComponent::Options.withNativeFunction() on the backend. | ||
* | ||
* @param {string} name | ||
*/ | ||
export function getNativeFunction(name: string): (...args: any[]) => Promise<any>; | ||
/** | ||
* Returns a SliderState object that is connected to the backend WebSliderRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebSliderRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {string} name | ||
*/ | ||
export function getSliderState(name: string): SliderState | undefined; | ||
/** | ||
* Returns a ToggleState object that is connected to the backend WebToggleButtonRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebToggleButtonRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {string} name | ||
*/ | ||
export function getToggleState(name: string): ToggleState | undefined; | ||
/** | ||
* Returns a ComboBoxState object that is connected to the backend WebComboBoxRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebComboBoxRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {string} name | ||
*/ | ||
export function getComboBoxState(name: string): ComboBoxState | undefined; | ||
/** | ||
* Appends a platform-specific prefix to the path to ensure that a request sent to this address will | ||
* be received by the backend's ResourceProvider. | ||
* @param {string} path | ||
*/ | ||
export function getBackendResourceAddress(path: string): string; | ||
/** | ||
* This helper class is intended to aid the implementation of | ||
* AudioProcessorEditor::getControlParameterIndex() for editors using a WebView interface. | ||
* | ||
* Create an instance of this class and call its handleMouseMove() method in each mousemove event. | ||
* | ||
* This class can be used to continuously report the controlParameterIndexAnnotation attribute's | ||
* value related to the DOM element that is currently under the mouse pointer. | ||
* | ||
* This value is defined at all times as follows | ||
* * the annotation attribute's value for the DOM element directly under the mouse, if it has it, | ||
* * the annotation attribute's value for the first parent element, that has it, | ||
* * -1 otherwise. | ||
* | ||
* Whenever there is a change in this value, an event is emitted to the frontend with the new value. | ||
* You can use a ControlParameterIndexReceiver object on the backend to listen to these events. | ||
*/ | ||
export class ControlParameterIndexUpdater { | ||
/** | ||
* @param {string} controlParameterIndexAnnotation | ||
*/ | ||
constructor(controlParameterIndexAnnotation: string); | ||
/** @type {string} */ | ||
controlParameterIndexAnnotation: string; | ||
/** @type {Element | null} */ | ||
lastElement: Element | null; | ||
/** @type {string | -1 | null} */ | ||
lastControlParameterIndex: string | -1 | null; | ||
handleMouseMove(event: any): void; | ||
#private; | ||
} | ||
export class ListenerList { | ||
listeners: Map<number, any>; | ||
listenerId: number; | ||
addListener(fn: any): number; | ||
removeListener(id: any): void; | ||
callListeners(payload: any): void; | ||
} | ||
/** | ||
@@ -19,6 +86,7 @@ * SliderState encapsulates data and callbacks that are synchronised with a WebSliderRelay object | ||
* WebSliderRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
export class SliderState { | ||
declare class SliderState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name: string); | ||
@@ -47,3 +115,3 @@ name: string; | ||
* | ||
* @param {String} name | ||
* @param {number} newValue | ||
*/ | ||
@@ -73,9 +141,15 @@ setNormalisedValue(newValue: number): void; | ||
* AudioProcessorParameter::getValue() (C++). | ||
* | ||
* @param {String} name | ||
*/ | ||
getNormalisedValue(): number; | ||
/** Internal. */ | ||
/** | ||
* @param {number} normalisedValue | ||
* @returns {number} | ||
* @internal | ||
*/ | ||
normalisedToScaledValue(normalisedValue: number): number; | ||
/** Internal. */ | ||
/** | ||
* @param {number} value | ||
* @returns {number} | ||
* @internal | ||
*/ | ||
snapToLegalValue(value: number): number; | ||
@@ -89,6 +163,7 @@ } | ||
* WebToggleRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
export class ToggleState { | ||
declare class ToggleState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name: string); | ||
@@ -106,3 +181,6 @@ name: string; | ||
getValue(): boolean; | ||
/** Informs the backend to change the associated WebToggleRelay's (C++) state. */ | ||
/** | ||
* Informs the backend to change the associated WebToggleRelay's (C++) state. | ||
* @param {boolean} newValue | ||
*/ | ||
setValue(newValue: boolean): void; | ||
@@ -118,6 +196,7 @@ /** Internal. */ | ||
* WebComboBoxRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
export class ComboBoxState { | ||
declare class ComboBoxState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name: string); | ||
@@ -146,2 +225,4 @@ name: string; | ||
* properties.choices array. | ||
* | ||
* @param {number} index | ||
*/ | ||
@@ -152,74 +233,16 @@ setChoiceIndex(index: number): void; | ||
} | ||
/** | ||
* Returns a function object that calls a function registered on the JUCE backend and forwards all | ||
* parameters to it. | ||
* | ||
* The provided name should be the same as the name argument passed to | ||
* WebBrowserComponent::Options.withNativeFunction() on the backend. | ||
* | ||
* @param {String} name | ||
*/ | ||
export function getNativeFunction(name: string): (...args: any[]) => number | Promise<any>; | ||
/** | ||
* Returns a SliderState object that is connected to the backend WebSliderRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebSliderRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {String} name | ||
*/ | ||
export function getSliderState(name: string): SliderState; | ||
/** | ||
* Returns a ToggleState object that is connected to the backend WebToggleButtonRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebToggleButtonRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {String} name | ||
*/ | ||
export function getToggleState(name: string): ToggleState; | ||
/** | ||
* Returns a ComboBoxState object that is connected to the backend WebComboBoxRelay object that was | ||
* created with the same name argument. | ||
* | ||
* To register a WebComboBoxRelay object create one with the right name and add it to the | ||
* WebBrowserComponent::Options struct using withOptionsFrom. | ||
* | ||
* @param {String} name | ||
*/ | ||
export function getComboBoxState(name: string): ComboBoxState; | ||
/** | ||
* Appends a platform-specific prefix to the path to ensure that a request sent to this address will | ||
* be received by the backend's ResourceProvider. | ||
* @param {String} path | ||
*/ | ||
export function getBackendResourceAddress(path: string): string; | ||
/** | ||
* This helper class is intended to aid the implementation of | ||
* AudioProcessorEditor::getControlParameterIndex() for editors using a WebView interface. | ||
* | ||
* Create an instance of this class and call its handleMouseMove() method in each mousemove event. | ||
* | ||
* This class can be used to continuously report the controlParameterIndexAnnotation attribute's | ||
* value related to the DOM element that is currently under the mouse pointer. | ||
* | ||
* This value is defined at all times as follows | ||
* * the annotation attribute's value for the DOM element directly under the mouse, if it has it, | ||
* * the annotation attribute's value for the first parent element, that has it, | ||
* * -1 otherwise. | ||
* | ||
* Whenever there is a change in this value, an event is emitted to the frontend with the new value. | ||
* You can use a ControlParameterIndexReceiver object on the backend to listen to these events. | ||
* | ||
* @param {String} controlParameterIndexAnnotation | ||
*/ | ||
export class ControlParameterIndexUpdater { | ||
constructor(controlParameterIndexAnnotation: any); | ||
controlParameterIndexAnnotation: any; | ||
lastElement: any; | ||
lastControlParameterIndex: any; | ||
handleMouseMove(event: any): void; | ||
#private; | ||
declare class ListenerList { | ||
/** @type {Map<number, (args: any) => any>} */ | ||
listeners: Map<number, (args: any) => any>; | ||
listenerId: number; | ||
/** | ||
* @param {(args: any) => any} fn | ||
*/ | ||
addListener(fn: (args: any) => any): number; | ||
/** | ||
* @param {number} id | ||
*/ | ||
removeListener(id: number): void; | ||
callListeners(payload: any): void; | ||
} | ||
export {}; |
76
index.js
@@ -39,3 +39,5 @@ /* | ||
constructor() { | ||
/** @type {number} */ | ||
this.lastPromiseId = 0; | ||
/** @type {Map<number, any>} */ | ||
this.promises = new Map(); | ||
@@ -54,2 +56,5 @@ | ||
/** | ||
* @returns {[number, Promise<any>]} | ||
*/ | ||
createPromise() { | ||
@@ -73,3 +78,3 @@ const promiseId = this.lastPromiseId++; | ||
* | ||
* @param {String} name | ||
* @param {string} name | ||
*/ | ||
@@ -101,2 +106,3 @@ function getNativeFunction(name) { | ||
constructor() { | ||
/** @type {Map<number, (args: any) => any>} */ | ||
this.listeners = new Map(); | ||
@@ -106,2 +112,5 @@ this.listenerId = 0; | ||
/** | ||
* @param {(args: any) => any} fn | ||
*/ | ||
addListener(fn) { | ||
@@ -113,2 +122,5 @@ const newListenerId = this.listenerId++; | ||
/** | ||
* @param {number} id | ||
*/ | ||
removeListener(id) { | ||
@@ -138,6 +150,7 @@ if (this.listeners.has(id)) { | ||
* WebSliderRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
class SliderState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name) { | ||
@@ -183,3 +196,3 @@ if (!window.__JUCE__.initialisationData.__juce__sliders.includes(name)) | ||
* | ||
* @param {String} name | ||
* @param {number} newValue | ||
*/ | ||
@@ -244,4 +257,2 @@ setNormalisedValue(newValue) { | ||
* AudioProcessorParameter::getValue() (C++). | ||
* | ||
* @param {String} name | ||
*/ | ||
@@ -256,3 +267,7 @@ getNormalisedValue() { | ||
/** Internal. */ | ||
/** | ||
* @param {number} normalisedValue | ||
* @returns {number} | ||
* @internal | ||
*/ | ||
normalisedToScaledValue(normalisedValue) { | ||
@@ -266,3 +281,7 @@ return ( | ||
/** Internal. */ | ||
/** | ||
* @param {number} value | ||
* @returns {number} | ||
* @internal | ||
*/ | ||
snapToLegalValue(value) { | ||
@@ -284,2 +303,3 @@ const interval = this.properties.interval; | ||
/** @type {Map<string, SliderState>} */ | ||
const sliderStates = new Map(); | ||
@@ -297,3 +317,3 @@ | ||
* | ||
* @param {String} name | ||
* @param {string} name | ||
*/ | ||
@@ -312,6 +332,7 @@ function getSliderState(name) { | ||
* WebToggleRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
class ToggleState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name) { | ||
@@ -349,3 +370,6 @@ if (!window.__JUCE__.initialisationData.__juce__toggles.includes(name)) | ||
/** Informs the backend to change the associated WebToggleRelay's (C++) state. */ | ||
/** | ||
* Informs the backend to change the associated WebToggleRelay's (C++) state. | ||
* @param {boolean} newValue | ||
*/ | ||
setValue(newValue) { | ||
@@ -375,2 +399,3 @@ this.value = newValue; | ||
/** @type {Map<string, ToggleState>} */ | ||
const toggleStates = new Map(); | ||
@@ -388,3 +413,3 @@ | ||
* | ||
* @param {String} name | ||
* @param {string} name | ||
*/ | ||
@@ -403,6 +428,7 @@ function getToggleState(name) { | ||
* WebComboBoxRelay backend object that was created using the same unique name. | ||
* | ||
* @param {String} name | ||
*/ | ||
class ComboBoxState { | ||
/** | ||
* @param {string} name | ||
*/ | ||
constructor(name) { | ||
@@ -422,2 +448,3 @@ if (!window.__JUCE__.initialisationData.__juce__comboBoxes.includes(name)) | ||
parameterIndex: -1, | ||
/** @type {any[]} */ | ||
choices: [], | ||
@@ -452,2 +479,4 @@ }; | ||
* properties.choices array. | ||
* | ||
* @param {number} index | ||
*/ | ||
@@ -479,2 +508,3 @@ setChoiceIndex(index) { | ||
/** @type {Map<string, ComboBoxState>} */ | ||
const comboBoxStates = new Map(); | ||
@@ -492,3 +522,3 @@ | ||
* | ||
* @param {String} name | ||
* @param {string} name | ||
*/ | ||
@@ -505,3 +535,3 @@ function getComboBoxState(name) { | ||
* be received by the backend's ResourceProvider. | ||
* @param {String} path | ||
* @param {string} path | ||
*/ | ||
@@ -542,9 +572,13 @@ function getBackendResourceAddress(path) { | ||
* You can use a ControlParameterIndexReceiver object on the backend to listen to these events. | ||
* | ||
* @param {String} controlParameterIndexAnnotation | ||
*/ | ||
class ControlParameterIndexUpdater { | ||
/** | ||
* @param {string} controlParameterIndexAnnotation | ||
*/ | ||
constructor(controlParameterIndexAnnotation) { | ||
/** @type {string} */ | ||
this.controlParameterIndexAnnotation = controlParameterIndexAnnotation; | ||
/** @type {Element | null} */ | ||
this.lastElement = null; | ||
/** @type {string | -1 | null} */ | ||
this.lastControlParameterIndex = null; | ||
@@ -577,2 +611,6 @@ } | ||
//============================================================================== | ||
/** | ||
* @param {Element} element | ||
* @returns {string | -1 | null} | ||
*/ | ||
#getControlParameterIndex(element) { | ||
@@ -579,0 +617,0 @@ const isValidNonRootElement = (e) => { |
{ | ||
"name": "juce-framework-frontend-mirror", | ||
"version": "7.0.11", | ||
"version": "8.0.7", | ||
"description": "javascript for JUCE WebBrowserComponent", | ||
@@ -12,4 +12,6 @@ "main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"check_native_interop.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"global.d.ts" | ||
], | ||
@@ -22,3 +24,3 @@ "keywords": [ | ||
"homepage": "https://github.com/m1m0zzz/juce-framework-frontend-mirror", | ||
"license": "AGPL-3.0-only", | ||
"license": "AGPL-3.0", | ||
"publishConfig": { | ||
@@ -25,0 +27,0 @@ "access": "public" |
@@ -7,7 +7,25 @@ # juce-framework-frontend-mirror | ||
```bash | ||
npm i juce-framework-frontend-mirror | ||
npm i juce-framework-frontend-mirror@next | ||
``` | ||
## This project is not semver. | ||
I gave up semver to match the version with JUCE from which it was mirrored. | ||
And I decided to use the RC (release candidate) version when upgrading for patches. | ||
So please use `npm i juce-framework-frontend-mirror@next` to get the latest version of the package. | ||
## Background of development (ja) | ||
https://mimoz-blog.vercel.app/juce-framework-frontend-mirror | ||
## Issues & Pull Request | ||
First, thank you for your interest in this project. | ||
If you find any problems or bugs, please report them in [Issues](https://github.com/m1m0zzz/juce-framework-frontend-mirror/issues/new) first. | ||
If you have a solution for it, please send us a Pull Request. | ||
## Note | ||
npm: https://www.npmjs.com/package/juce-framework-frontend-mirror |
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
69016
6.66%7
16.67%974
17.63%31
138.46%