doc: use typedef instead
This commit is contained in:
parent
768a606684
commit
5463685bd5
22
gluon.d.ts
vendored
Normal file
22
gluon.d.ts
vendored
Normal 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
|
||||
);
|
@ -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",
|
||||
|
13
src/index.js
13
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...');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user