diff --git a/gluon.d.ts b/gluon.d.ts new file mode 100644 index 0000000..24b3313 --- /dev/null +++ b/gluon.d.ts @@ -0,0 +1,22 @@ +/** A browser that Gluon supports. */ +type Browser = 'chrome'|'chrome_canary'|'chromium'|'edge'|'firefox'|'firefox_nightly'; + +/** Additional options for opening */ +type OpenOptions = { + /** Function to evaluate in the web context once loaded. */ + onLoad?: function, + + /** Force Gluon to use a browser instead of automatically finding. */ + forceBrowser?: Browser, +}; + +/** + * Open a new Gluon window. + */ +export function open( + /** URL to load in the window. */ + url: string, + + /** Additional options for opening. */ + options: OpenOptions +); \ No newline at end of file diff --git a/package.json b/package.json index 0f483ca..b7d1b2f 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.6.0", "description": "Make websites into desktop apps with system installed browsers and NodeJS.", "main": "src/index.js", + "types": "gluon.d.ts", "scripts": {}, "repository": { "type": "git", diff --git a/src/index.js b/src/index.js index 6a516a3..88d6f73 100644 --- a/src/index.js +++ b/src/index.js @@ -13,10 +13,6 @@ import Firefox from './browser/firefox.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -/** - * @typedef {'chrome'|'chrome_canary'|'chromium'|'edge'|'firefox'|'firefox_nightly'} Browser - */ - const browserPaths = ({ win32: process.platform === 'win32' && { chrome: join(process.env.PROGRAMFILES, 'Google', 'Chrome', 'Application', 'chrome.exe'), @@ -108,15 +104,6 @@ const startBrowser = async (url, { windowSize, forceBrowser }) => { }); }; -/** - * Open a new Gluon window. - * - * @param {string} url - URL to load in the browser. - * @param {Object} options - Optional further options. - * @param {Function} [options.onLoad] - This function is evaluated in the web context once loaded. - * @param {Browser} [options.forceBrowser] - Force window to use a certain browser. - * @returns {any} - Instance of a Gluon window. - */ export const open = async (url, { windowSize, onLoad, forceBrowser } = {}) => { log('starting browser...');