LogoPyloid
ApiPyloid js

BaseAPI

The BaseAPI class provides asynchronous methods to interact with the Pyloid backend via window.__PYLOID__. All methods automatically wait for Pyloid initialization before executing. baseAPI is an singleton instance of the BaseAPI class.


Window Management

getWindowId

Gets the unique identifier for the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.getWindowId().then((id) => console.log(`Window ID: ${id}`));

Returns

Promise<string>

getWindowProperties

Retrieves properties associated with the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.getWindowProperties().then((props) => console.log(props));

Returns

Promise<WindowProperties>

close

Closes the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.close().then(() => console.log('Window closed.'));

Returns

Promise<void>

hide

Hides the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.hide().then(() => console.log('Window hidden.'));

Returns

Promise<void>

show

Shows the current window if it is hidden.

import { baseAPI } from 'pyloid-js';

baseAPI.show().then(() => console.log('Window shown.'));

Returns

Promise<void>

focus

Brings the current window to the foreground and gives it focus.

import { baseAPI } from 'pyloid-js';

baseAPI.focus().then(() => console.log('Window focused.'));

Returns

Promise<void>

showAndFocus

Shows the window (if hidden) and brings it to the foreground with focus.

import { baseAPI } from 'pyloid-js';

baseAPI.showAndFocus().then(() => console.log('Window shown and focused.'));

Returns

Promise<void>

fullscreen

Makes the current window fullscreen.

import { baseAPI } from 'pyloid-js';

baseAPI.fullscreen().then(() => console.log('Window is now fullscreen.'));

Returns

Promise<void>A promise that resolves when the fullscreen operation is initiated.

toggleFullscreen

Toggles the fullscreen state of the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.toggleFullscreen().then(() => console.log('Fullscreen toggled.'));

Returns

Promise<void>A promise that resolves when the toggle operation is initiated.

minimize

Minimizes the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.minimize().then(() => console.log('Window minimized.'));

Returns

Promise<void>A promise that resolves when the minimize operation is initiated.

maximize

Maximizes the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.maximize().then(() => console.log('Window maximized.'));

Returns

Promise<void>A promise that resolves when the maximize operation is initiated.

unmaximize

Restores the window from a maximized state.

import { baseAPI } from 'pyloid-js';

baseAPI
  .unmaximize()
  .then(() => console.log('Window restored from maximized state.'));

Returns

Promise<void>A promise that resolves when the unmaximize operation is initiated.

toggleMaximize

Toggles the maximized state of the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.toggleMaximize().then(() => console.log('Maximize toggled.'));

Returns

Promise<void>A promise that resolves when the toggle operation is initiated.

isFullscreen

Checks if the current window is in fullscreen mode.

import { baseAPI } from 'pyloid-js';

baseAPI
  .isFullscreen()
  .then((isFullscreen) => console.log(`Is fullscreen: ${isFullscreen}`));

Returns

Promise<boolean>A promise that resolves with true if fullscreen, false otherwise.

isMaximized

Checks if the current window is maximized.

import { baseAPI } from 'pyloid-js';

baseAPI
  .isMaximized()
  .then((isMaximized) => console.log(`Is maximized: ${isMaximized}`));

Returns

Promise<boolean>A promise that resolves with true if maximized, false otherwise.

setTitle

Sets the title of the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.setTitle('New Title').then(() => console.log('Title set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the title is set.

setSize

Sets the size (width and height) of the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.setSize(1024, 768).then(() => console.log('Window size set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the size is set.

setPosition

Sets the position (x and y coordinates) of the current window.

import { baseAPI } from 'pyloid-js';

baseAPI.setPosition(100, 100).then(() => console.log('Window position set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the position is set.

setFrame

Sets whether the window should have a standard OS frame.

import { baseAPI } from 'pyloid-js';

baseAPI.setFrame(true).then(() => console.log('Frame set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the frame state is set.

getFrame

Gets the current frame state of the window.

import { baseAPI } from 'pyloid-js';

baseAPI.getFrame().then((frame) => console.log(`Frame visible: ${frame}`));

Returns

Promise<boolean>A promise that resolves with true if the frame is visible, false otherwise.

getTitle

Gets the current title of the window.

import { baseAPI } from 'pyloid-js';

baseAPI.getTitle().then((title) => console.log(`Window title: ${title}`));

Returns

Promise<string>A promise that resolves with the window title string.

getSize

Gets the current size (width and height) of the window.

import { baseAPI } from 'pyloid-js';

baseAPI
  .getSize()
  .then((size) => console.log(`Window size: ${size.width}x${size.height}`));

Returns

Promise<Size>A promise that resolves with an object containing the width and height.

getPosition

Gets the current position (x and y coordinates) of the window.

import { baseAPI } from 'pyloid-js';

baseAPI
  .getPosition()
  .then((position) =>
    console.log(`Window position: (${position.x}, ${position.y})`)
  );

Returns

Promise<Position>A promise that resolves with an object containing the x and y coordinates.

setClipboardText

Sets the system clipboard text content.

import { baseAPI } from 'pyloid-js';

baseAPI
  .setClipboardText('Hello, World!')
  .then(() => console.log('Clipboard text set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the clipboard text is set.

getClipboardText

Gets the current text content from the system clipboard.

import { baseAPI } from 'pyloid-js';

baseAPI
  .getClipboardText()
  .then((text) => console.log(`Clipboard text: ${text}`));

Returns

Promise<string>A promise that resolves with the clipboard text.

setClipboardImage

Sets the system clipboard image content from a file path.

import { baseAPI } from 'pyloid-js';

baseAPI
  .setClipboardImage('/path/to/image.png', 'png')
  .then(() => console.log('Clipboard image set.'));

Parameters

Prop

Type

Returns

Promise<void>A promise that resolves when the clipboard image is set.

getClipboardImage

Gets the current image content from the system clipboard.

import { baseAPI } from 'pyloid-js';

baseAPI
  .getClipboardImage()
  .then((imageData) => console.log(`Clipboard image data: ${imageData}`));

Returns

Promise<string>A promise that resolves with the clipboard image data.

quit

Quits the entire application.

import { baseAPI } from 'pyloid-js';

baseAPI.quit().then(() => console.log('Application quit.'));

Returns

Promise<void>A promise that resolves when the quit operation is initiated.

getPlatform

Gets the underlying operating system platform.

import { baseAPI } from 'pyloid-js';

baseAPI.getPlatform().then((platform) => console.log(`Platform: ${platform}`));

Returns

Promise<Platform>A promise that resolves with the platform name ("windows", "linux", or "macos").

isProduction

Checks if the application is running in production mode.

import { baseAPI } from 'pyloid-js';

baseAPI
  .isProduction()
  .then((isProd) => console.log(`Is production: ${isProd}`));

Returns

Promise<boolean>A promise that resolves with true if in production, false otherwise.

getProductionPath

Resolves a relative path to an absolute path within the application's production build directory.

import { baseAPI } from 'pyloid-js';

baseAPI
  .getProductionPath('assets/image.png')
  .then((absPath) => console.log(`Absolute path: ${absPath}`));

Parameters

Prop

Type

Returns

Promise<string>A promise that resolves with the absolute path.

getServerUrl

Retrieves the server URL.

import { baseAPI } from 'pyloid-js';

baseAPI.getServerUrl().then((url) => console.log(`server URL: ${url}`));

Returns

Promise<string>A promise that resolves with the server URL.