UNPKG

qz-tray

Version:

Connects a web client to the QZ Tray software. Enables printing and device communication from javascript.

1,700 lines (430 loc) 19.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Namespace: api</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Namespace: api</h1> <section> <header> <h2> <span class="ancestors"><a href="qz.html">qz</a>.</span>api</h2> </header> <article> <div class="container-overview"> <div class="description">Calls related to compatibility adjustments</div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2816">line 2816</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id=".isVersion"><span class="type-signature">(static) </span>isVersion<span class="type-signature"></span></h4> <div class="description"> Checks for the specified version of connected QZ Tray application. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2864">line 2864</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=".getTitle"><span class="type-signature">(static) </span>getTitle<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4> <div class="description"> Get internal branding title used by logs and exceptions (e.g "QZ Tray") </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2840">line 2840</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Internal title used for logs and exceptions </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> <h4 class="name" id=".getVersion"><span class="type-signature">(static) </span>getVersion<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(string|Error)>}</span></h4> <div class="description"> Get version of connected QZ Tray application. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2851">line 2851</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Version number of QZ Tray. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise.&lt;(string|Error)></span> </dd> </dl> <h4 class="name" id=".isVersionGreater"><span class="type-signature">(static) </span>isVersionGreater<span class="signature">(major, minor<span class="signature-attributes">opt</span>, patch<span class="signature-attributes">opt</span>, build<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Checks if the connected QZ Tray application is greater than the specified version. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>major</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">Major version to check</td> </tr> <tr> <td class="name"><code>minor</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Minor version to check</td> </tr> <tr> <td class="name"><code>patch</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Patch version to check</td> </tr> <tr> <td class="name"><code>build</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Build version to check</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-since">Since:</dt> <dd class="tag-since"><ul class="dummy"><li>2.1.0-4</li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2878">line 2878</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if connected version is greater than the version specified. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".isVersionLess"><span class="type-signature">(static) </span>isVersionLess<span class="signature">(major, minor<span class="signature-attributes">opt</span>, patch<span class="signature-attributes">opt</span>, build<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Checks if the connected QZ Tray application is less than the specified version. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>major</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last">Major version to check</td> </tr> <tr> <td class="name"><code>minor</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Minor version to check</td> </tr> <tr> <td class="name"><code>patch</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Patch version to check</td> </tr> <tr> <td class="name"><code>build</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Build version to check</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-since">Since:</dt> <dd class="tag-since"><ul class="dummy"><li>2.1.0-4</li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2894">line 2894</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if connected version is less than the version specified. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id=".setPromiseType"><span class="type-signature">(static) </span>setPromiseType<span class="signature">(promiser)</span><span class="type-signature"></span></h4> <div class="description"> Change the promise library used by QZ API. Should be called before any initialization to avoid possible errors. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>promiser</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><code>Function({function} resolver)</code> called to create new promises.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2906">line 2906</a> </li></ul></dd> </dl> <h4 class="name" id=".setSha256Type"><span class="type-signature">(static) </span>setSha256Type<span class="signature">(hasher)</span><span class="type-signature"></span></h4> <div class="description"> Change the SHA-256 hashing function used by QZ API. Should be called before any initialization to avoid possible errors. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>hasher</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><code>Function({function} message)</code> called to create hash of passed string.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2918">line 2918</a> </li></ul></dd> </dl> <h4 class="name" id=".setTitle"><span class="type-signature">(static) </span>setTitle<span class="signature">(title)</span><span class="type-signature"></span></h4> <div class="description"> Change the internal branding of "QZ Tray" for logs and exceptions Must be called before any connection attempts are made to appear in messaging </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>title</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Internal name to be used in place of "QZ Tray" for logs and exceptions</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2930">line 2930</a> </li></ul></dd> </dl> <h4 class="name" id=".setWebSocketType"><span class="type-signature">(static) </span>setWebSocketType<span class="signature">(ws)</span><span class="type-signature"></span></h4> <div class="description"> Change the WebSocket handler. Should be called before any initialization to avoid possible errors. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ws</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"><code>Function({function} WebSocket)</code> called to override the internal WebSocket handler.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2942">line 2942</a> </li></ul></dd> </dl> <h4 class="name" id=".showDebug"><span class="type-signature">(static) </span>showDebug<span class="signature">(show)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Show or hide QZ api debugging statements in the browser console. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>show</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="description last">Whether the debugging logs for QZ should be shown. Hidden by default.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line2828">line 2828</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Value of debugging flag </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="qz.html">qz</a></li><li><a href="qz.api.html">api</a></li><li><a href="qz.configs.html">configs</a></li><li><a href="qz.file.html">file</a></li><li><a href="qz.hid.html">hid</a></li><li><a href="qz.networking.html">networking</a></li><li><a href="qz.printers.html">printers</a></li><li><a href="qz.security.html">security</a></li><li><a href="qz.serial.html">serial</a></li><li><a href="qz.socket.html">socket</a></li><li><a href="qz.usb.html">usb</a></li><li><a href="qz.websocket.html">websocket</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Apr 02 2026 13:01:02 GMT-0400 (Eastern Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>