diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index d738b13ecc..7300f52f9b 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -351,8 +351,10 @@ public: Q_INVOKABLE void removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler); /**jsdoc - * Starts running another script in Interface. - *
Available in: | Interface Scripts | Avatar Scripts |
---|
Supported Script Types: Interface Scripts • Avatar Scripts
+ *See also, {@link ScriptDiscoveryService.loadScript}.
* @function Script.load * @param {string} filename - The URL of the script to load. This can be relative to the current script's URL. * @example"script"
or "folder"
.
+ * Deprecated: This property is deprecated and will be removed. It currently always has the value,
+ * "script"
.
type == "folder"
.
+ * Deprecated: This property is deprecated and will be removed. It currently is never present.
+ * @property {string} [url] - The full URL of the script — including the "file:///"
scheme at the start.
+ *
Only present if type == "script"
.
true
if the script is a local file (i.e., the scheme is "file"), false
+ * if it isn't (e.g., the scheme is "http").
+ * @property {string} name - The script's file name.
+ * @property {string} path - The script's path and file name — excluding the scheme if a local file.
+ * @property {string} url - The full URL of the script — including the scheme if a local file.
+ */
QVariantList ScriptEngines::getRunning() {
QVariantList result;
auto runningScripts = getRunningScripts();
diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h
index de836a3e09..484ccd8932 100644
--- a/libraries/script-engine/src/ScriptEngines.h
+++ b/libraries/script-engine/src/ScriptEngines.h
@@ -28,18 +28,26 @@
class ScriptEngine;
/**jsdoc
+ * The ScriptDiscoveryService
API provides facilities to work with Interface scripts.
+ *
* @namespace ScriptDiscoveryService
*
* @hifi-interface
- * @hifi-client-entity
* @hifi-avatar
+ * @hifi-client-entity
*
- * @property {string} debugScriptUrl
- * @property {string} defaultScriptsPath
- * @property {ScriptsModel} scriptsModel
- * @property {ScriptsModelFilter} scriptsModelFilter
+ * @property {string} debugScriptUrl="" - The path and name of a script to debug using the "API Debugger" developer tool
+ * (currentAPI.js). If set, the API Debugger dialog displays the objects and values exposed by the script using
+ * {@link Script.registerValue} and similar.
+ * @property {string} defaultScriptsPath - The path where the default scripts are located in the Interface installation.
+ * Read-only.
+ * @property {ScriptsModel} scriptsModel - Information on the scripts that are in the default scripts directory of the
+ * Interface installation.
+ * Read-only.
+ * @property {ScriptsModelFilter} scriptsModelFilter - Sorted and filtered information on the scripts that are in the default
+ * scripts directory of the Interface installation.
+ * Read-only.
*/
-
class NativeScriptInitializers : public ScriptInitializerMixin {
public:
bool registerNativeScriptInitializer(NativeScriptInitializer initializer) override;
@@ -77,61 +85,92 @@ public:
QString getDefaultScriptsLocation() const;
/**jsdoc
+ * Starts running an Interface script, if it isn't already running. The script is automatically loaded next time Interface
+ * starts.
+ * This is a synonym for calling {@link ScriptDiscoveryService.loadScript|loadScript} with just the script URL.
+ *Supported Script Types: Interface Scripts • Avatar Scripts
+ *See also, {@link Script.load}.
* @function ScriptDiscoveryService.loadOneScript - * @param {string} filename + * @param {string} url - The path and name of the script. If a local file, including the"file:///"
scheme is
+ * optional.
*/
Q_INVOKABLE void loadOneScript(const QString& scriptFilename);
/**jsdoc
+ * Starts running an Interface script, if it isn't already running.
+ * Supported Script Types: Interface Scripts • Avatar Scripts
+ *See also, {@link Script.load}.
* @function ScriptDiscoveryService.loadScript - * @param {string} [filename=""] - * @param {boolean} [isUserLoaded=true] - * @param {boolean} [loadScriptFromEditor=false] - * @param {boolean} [activateMainWindow=false] - * @param {boolean} [reload=false] - * @param {boolean} [quitWhenFinished=false] - * @returns {boolean} + * @param {string} [url=""] - The path and name of the script. If a local file, including the"file:///"
+ * scheme is optional.
+ * @param {boolean} [isUserLoaded=true] - true
if the user specifically loaded it, false
if not
+ * (e.g., a script loaded it). If false
, the script is not automatically loaded next time Interface starts.
+ * @param {boolean} [loadScriptFromEditor=false] - Not used.
+ * @param {boolean} [activateMainWindow=false] - Not used.
+ * @param {boolean} [reload=false] - true
to redownload the script, false
to use the copy from
+ * the cache if available.
+ * @param {boolean} [quitWhenFinished=false] - true
to close Interface when the script finishes,
+ * false
to not close Interface.
+ * @returns {object} An empty object, {}
.
*/
Q_INVOKABLE ScriptEnginePointer loadScript(const QUrl& scriptFilename = QString(),
bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false, bool quitWhenFinished = false);
/**jsdoc
+ * Stops or restarts an Interface script.
* @function ScriptDiscoveryService.stopScript
- * @param {string} scriptHash
- * @param {boolean} [restart=false]
- * @returns {boolean}
+ * @param {string} url - The path and name of the script. If a local file, including the "file:///"
scheme is
+ * optional.
+ * @param {boolean} [restart=false] - true
to redownload and restart the script, false
to stop
+ * it.
+ * @returns {boolean} true
if the script was successfully stopped or restarted, false
if it
+ * wasn't (e.g., the script couldn't be found).
*/
Q_INVOKABLE bool stopScript(const QString& scriptHash, bool restart = false);
/**jsdoc
- * @function ScriptDiscoveryService.reloadAllScripts
- */
+ * Restarts all Interface, avatar, and client entity scripts after clearing the scripts cache.
+ * @function ScriptDiscoveryService.reloadAllScripts
+ */
Q_INVOKABLE void reloadAllScripts();
/**jsdoc
+ * Stops or restarts all Interface scripts. The scripts cache is not cleared. If restarting, avatar and client entity
+ * scripts are also restarted.
* @function ScriptDiscoveryService.stopAllScripts
- * @param {boolean} [restart=false]
+ * @param {boolean} [restart=false] - true
to restart the scripts, false
to stop them.
*/
Q_INVOKABLE void stopAllScripts(bool restart = false);
/**jsdoc
+ * Gets a list of all Interface scripts that are currently running.
* @function ScriptDiscoveryService.getRunning
- * @returns {object[]}
+ * @returns {ScriptDiscoveryService.RunningScript[]} All Interface scripts that are currently running.
+ * @example ""
always.
* @returns {Signal}
*/
void scriptLoadError(const QString& filename, const QString& error);
/**jsdoc
+ * Triggered when any script prints a message to the program log via {@link print}, {@link Script.print},
+ * {@link console.log}, or {@link console.debug}.
* @function ScriptDiscoveryService.printedMessage
- * @param {string} message
- * @param {string} engineName
+ * @param {string} message - The message.
+ * @param {string} scriptName - The name of the script that generated the message.
* @returns {Signal}
*/
void printedMessage(const QString& message, const QString& engineName);
/**jsdoc
+ * Triggered when any script generates an error or {@link console.error} is called.
* @function ScriptDiscoveryService.errorMessage
- * @param {string} message
- * @param {string} engineName
+ * @param {string} message - The error message.
+ * @param {string} scriptName - The name of the script that generated the error message.
* @returns {Signal}
*/
void errorMessage(const QString& message, const QString& engineName);
/**jsdoc
+ * Triggered when any script generates a warning or {@link console.warn} is called.
* @function ScriptDiscoveryService.warningMessage
- * @param {string} message
- * @param {string} engineName
+ * @param {string} message - The warning message.
+ * @param {string} scriptName - The name of the script that generated the warning message.
* @returns {Signal}
*/
void warningMessage(const QString& message, const QString& engineName);
/**jsdoc
+ * Triggered when any script generates an information message or {@link console.info} is called.
* @function ScriptDiscoveryService.infoMessage
- * @param {string} message
- * @param {string} engineName
+ * @param {string} message - The information message.
+ * @param {string} scriptName - The name of the script that generated the informaton message.
* @returns {Signal}
*/
void infoMessage(const QString& message, const QString& engineName);
/**jsdoc
* @function ScriptDiscoveryService.errorLoadingScript
- * @param {string} url
+ * @param {string} url - URL.
* @returns {Signal}
+ * @deprecated This signal is deprecated and will be removed.
*/
+ // Deprecated because never emitted.
void errorLoadingScript(const QString& url);
/**jsdoc
+ * Triggered when the Debug Window is cleared.
* @function ScriptDiscoveryService.clearDebugWindow
* @returns {Signal}
*/
@@ -216,50 +272,64 @@ public slots:
/**jsdoc
* @function ScriptDiscoveryService.onPrintedMessage
- * @param {string} message
- * @param {string} scriptName
+ * @param {string} message - Message.
+ * @param {string} scriptName - Script name.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal.
void onPrintedMessage(const QString& message, const QString& scriptName);
/**jsdoc
* @function ScriptDiscoveryService.onErrorMessage
- * @param {string} message
- * @param {string} scriptName
+ * @param {string} message - Message.
+ * @param {string} scriptName - Script name.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal.
void onErrorMessage(const QString& message, const QString& scriptName);
/**jsdoc
* @function ScriptDiscoveryService.onWarningMessage
- * @param {string} message
- * @param {string} scriptName
+ * @param {string} message - Message.
+ * @param {string} scriptName - Script name.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal.
void onWarningMessage(const QString& message, const QString& scriptName);
/**jsdoc
* @function ScriptDiscoveryService.onInfoMessage
- * @param {string} message
- * @param {string} scriptName
+ * @param {string} message - Message.
+ * @param {string} scriptName - Script name.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal.
void onInfoMessage(const QString& message, const QString& scriptName);
/**jsdoc
* @function ScriptDiscoveryService.onErrorLoadingScript
- * @param {string} url
+ * @param {string} url - URL.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal. And it isn't used.
void onErrorLoadingScript(const QString& url);
/**jsdoc
* @function ScriptDiscoveryService.onClearDebugWindow
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because only use is to emit a signal.
void onClearDebugWindow();
protected slots:
/**jsdoc
* @function ScriptDiscoveryService.onScriptFinished
- * @param {string} filename
- * @param {object} engine
+ * @param {string} scriptName - Script name.
+ * @param {object} engine - Engine.
+ * @deprecated This function is deprecated and will be removed.
*/
+ // Deprecated because it wasn't intended to be in the API.
void onScriptFinished(const QString& fileNameString, ScriptEnginePointer engine);
protected:
diff --git a/libraries/script-engine/src/ScriptsModel.h b/libraries/script-engine/src/ScriptsModel.h
index adfb15affc..bd6c9687c1 100644
--- a/libraries/script-engine/src/ScriptsModel.h
+++ b/libraries/script-engine/src/ScriptsModel.h
@@ -64,14 +64,60 @@ public:
};
/**jsdoc
- * Provided as a property of {@link ScriptDiscoveryService}.
- *Has properties and functions below in addition to those of - * http://doc.qt.io/qt-5/qabstractitemmodel.html.
+ * Information on the scripts that are in the default scripts directory of the Interface installation. This is provided as a + * property of {@link ScriptDiscoveryService}. + * + *The information provided reflects the subdirectory structure. Methods and signals are per QT's + * QAbstractItemModel class, with the following details:
+ *columnCount(index)
returns 1
. Role | Value | Description |
---|---|---|
Display | 0 | The directory or script file name. |
Path | 256 | The path and filename of the data item if it is a script,
+ * undefined if it is a directory. |
null
for the root directory's index.Provided as a property of {@link ScriptDiscoveryService}.
- *Has properties and functions per - * http://doc.qt.io/qt-5/qsortfilterproxymodel.html.
+ * Sorted and filtered information on the scripts that are in the default scripts directory of the Interface installation. This + * is provided as a property of {@link ScriptDiscoveryService}. + * + *The information provided reflects the subdirectory structure. Properties, methods, and signals are per QT's + * QSortFilterProxyModel class, with the following details:
+ *columnCount(index)
returns 1
. Role | Value | Description |
---|---|---|
Display | 0 | The directory or script file name. |
Path | 256 | The path and filename of the data item if it is a script,
+ * undefined if it is a directory. |
null
for the root directory's index.