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.
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:
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}
})
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
Unpins secondary tile from the start menu.
Example:
pwa.removeSecondaryTile(12345)
Returns true or false if system theme is dark
Example:
let isDarkTheme = pwa.checkForDarkTheme();
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}
})
toggle window between default and shrunken overlay
Example:
pwa.toggleCompactOverlayMode()
Options group includes id, title, bodytext, imagepath, and activationUri.
Example:
pwa.addTimelineActivity({
id: 12345,
title: 'Title!',
bodytext: 'Information!',
imagepath: 'Uri',
activationUri: 'Uri'
})
Change desktop background to provided image
Example:
pwa.changeDesktopBackgroundImage('Uri')