Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Latest commit

 

History

History
101 lines (86 loc) · 3.16 KB

README.md

File metadata and controls

101 lines (86 loc) · 3.16 KB

This project is discontinued

We no longer recommend using WinRT calls from JavaScript. Development focus is currently on the Chromium based engine for the Edge browser and Progressive Web App technology. Some of the features presented here are/will be replaced by a common standard API.

Please have a look at the PWA Builder components page to learn more about this new approach and for new code using standardized API calls.

Helpers for Progressive Web Apps running on Windows

Github

  • Download pwa.js from dist folder and add to your project

NPM: https://www.npmjs.com/package/ts-pwaapi

  • From the command line, run npm i ts-pwaapi

Example Importing the library:

import * as pwa from './pwa.js'

Functions:

createSecondaryTile(tileId, options)

Options group includes title, activationArguments, logoUri, foregroundText, backgroundColorWin, and backgroundColor{a,r,g,b}

Example:

pwa.createSecondaryTile(12345,{
    title: SecondaryTile,
    activationArguments: Args,
    logoUri: URI,
    foregroundText: light,
    backgroundColorWin: '',
    backgroundColor: {a: 255, r: 255, g: 255, b: 255}
    })

updateSecondaryTile(tileId, options)

Options group includes displayName, showNameOnSquare, foregroundText, squareMedUri, backgroundColorWin, and backgroundColor{a,r,g,b}

Example:

pwa.updateSecondaryTile(12345,{
    displayName: SecondaryTile,
    showNameOnSquare: 1, 
    foregroundText: light, 
    backgroundColorWin: '', 
    backgroundColor: {a: 255, r: 255, g: 255, b: 255}
    })n

removeSecondaryTile(tileId)

Unpins secondary tile from the start menu.
Example:

pwa.removeSecondaryTile(12345)

checkForDarkTheme()

Returns true or false if system theme is dark
Example:

let isDarkTheme = pwa.checkForDarkTheme();

changeAppTitleBarColor(colorOptions)

Options group includes backgroundColor, foregroundColor, buttonBackgroundColor, buttonForegroundColor, buttonHoverBackgroundColor, buttonHoverForegroundColor, buttonPressedBackgroundColor, buttonPressedForegroundColor, inactiveBackgroundColor, inactiveForegroundColor, buttonInactiveBackgroundColor, buttonInactiveForegroundColor.
All use {a,r,g,b} settings that accept 0-255 decimal or 0x## hexadecimal

Example:

pwa.changeAppTitleBarColor({
    backgroundColor: {a: 255,r: 100,g: 200,b: 225},
    foregroundColor: {a: 255,r: 125,g: 225,b: 250},
    inactiveBackgroundColor: {a: 100,r: 100,g: 200,b: 225},
    inactiveForegroundColor: {a: 100,r: 125,g: 225,b: 250}  
})

toggleCompactOverlayMode()

toggle window between default and shrunken overlay
Example:

pwa.toggleCompactOverlayMode()

addTimelineActivity(options)

Options group includes id, title, bodytext, imagepath, and activationUri.
Example:

pwa.addTimelineActivity({
    id: 12345,
    title: 'Title!',
    bodytext: 'Information!',
    imagepath: 'Uri',
    activationUri: 'Uri'
})

changeDesktopBackgroundImage(localImagePath)

Change desktop background to provided image
Example:

pwa.changeDesktopBackgroundImage('Uri')