doc: use typedef instead

This commit is contained in:
CanadaHonk 2022-12-17 16:11:42 +00:00
parent 768a606684
commit 5463685bd5
3 changed files with 23 additions and 13 deletions

22
gluon.d.ts vendored Normal file
View File

@ -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
);

View File

@ -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",

View File

@ -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...');