Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pwabuilder/pwainstall

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pwabuilder/pwainstall - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

package.json
{
"name": "@pwabuilder/pwainstall",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/pwa-install.js",

@@ -41,3 +41,4 @@ # pwa-install

| ------------------- | ------------------- | ------------------------------------------------- | --------- | --------------- |
| `showeligible` | `showeligible` | Will only show install button if user is eligible | `boolean` | `false` |
| `showopen` | `showopen` | Will always show the install button | `boolean` | `false` |
| `usecustom` | `usecustom` | Hides default button | `boolean` | `false` |
| `manifestpath` | `manifestpath` | path to your web manifest | `string` | `manifest.json` |

@@ -48,3 +49,3 @@ | `featuresheader` | `featuresheader` | Controls the text of the features header | `string` | `Key Features` |

| `cancelbuttontext` | `cancelbuttontext` | Controls the text of the cancel button | `string` | `Cancel` |
| `iosinstallinfotext`| `iosinstallinfotext`| Controls the iOS installation info text | `string` | `Tap the share button and then 'Add to Homescreen'` |
| `iosinstallinfotext`| `iosinstallinfotext`| Controls the iOS installation info text | `string` | `Tap the share button and then 'Add to Homescreen'` |

@@ -51,0 +52,0 @@ ### Methods

@@ -8,3 +8,2 @@ import {

@property() deferredprompt: any;
@property() manifestpath: string = "manifest.json";

@@ -16,6 +15,7 @@ @property() iconpath: string;

@property({ type: Boolean }) showopen: boolean;
@property({ type: Boolean }) showEligible: boolean;
@property({ type: Boolean }) isSupportingBrowser: boolean;
@property({ type: Boolean }) isIOS: boolean;
@property({ type: Boolean }) installed: boolean;
@property({ type: Boolean }) hasprompt: boolean = false;
@property({ type: Boolean }) usecustom: boolean = false;

@@ -29,2 +29,4 @@ @property() explainer: string = "This app can be installed on your PC or mobile device. This will allow this web app to look and behave like any other installed up. You will find it in your app lists and be able to pin it to your home screen, start menus or task bars. This installed web app will also be able to safely interact with other apps and your operating system. "

@property() deferredprompt: any;
static get styles() {

@@ -510,2 +512,14 @@ return css`

connectedCallback() {
super.connectedCallback();
window.addEventListener('beforeinstallprompt', (event) => this.handleInstallPromptEvent(event));
document.onkeyup = (e) => {
if (e.key === "Escape") {
this.cancel();
}
}
}
async firstUpdated(): Promise<void> {

@@ -520,23 +534,11 @@ if (this.manifestpath) {

}
}
if (this.showEligible) {
this.showopen = false;
}
handleInstallPromptEvent(event) {
console.log(event);
this.deferredprompt = event;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
console.log(e);
// Stash the event so it can be triggered later.
this.deferredprompt = e;
this.hasprompt = true;
this.showopen = true;
});
document.onkeyup = (e) => {
if (e.key === "Escape") {
this.cancel();
}
}
event.preventDefault();
}

@@ -625,8 +627,7 @@

shouldShowInstall(): boolean {
const eligibleUser = this.showEligible && this.deferredprompt || this.isSupportingBrowser && this.deferredprompt;
const eligibleUser = !this.usecustom && this.isSupportingBrowser && this.hasprompt === true;
console.log('this.deferredprompt', this.deferredprompt);
console.log('this.showEligible', this.showEligible);
console.log('this.isSupportingBrowser', this.isSupportingBrowser);
return eligibleUser;
// return this.showopen || eligibleUser;
// return eligibleUser;
return this.showopen || eligibleUser;
}

@@ -687,3 +688,3 @@

return html`
${this.installed !== true && this.shouldShowInstall() || this.shouldShowInstall() && this.showEligible && this.showopen ? html`<button id="openButton" @click="${() => this.openPrompt()}">
${!this.usecustom && this.showopen || this.shouldShowInstall() && this.installed !== true ? html`<button id="openButton" @click="${() => this.openPrompt()}">
<slot>

@@ -690,0 +691,0 @@ ${this.installbuttontext}

@@ -74,3 +74,5 @@ import { expect, elementUpdated, html, fixture } from '@open-wc/testing';

it('shouldShowInstall should return true if showopen is true', async () => {
// will be undefined in the test environment as there is no manifest / sw
// we never want to show the install button if the app cant be installed
it('shouldShowInstall should still return undefined even if showopen is true', async () => {
const el = await fixture('<pwa-install showopen></pwa-install>');

@@ -81,6 +83,8 @@

expect(testResult).to.be.true;
expect(testResult).to.be.undefined;
});
it('shouldShowInstall should return true if showeligible is on', async () => {
// will be undefined in the test environment as there is no manifest / sw
// we never want to show the install button if the app cant be installed
it('shouldShowInstall should return undefined even if showeligible is on', async () => {
// this should be undefined because install is eligible in this case

@@ -92,3 +96,3 @@ const el = await fixture('<pwa-install showeligible></pwa-install>');

expect(testResult).to.be.true;
expect(testResult).to.be.undefined;
});

@@ -95,0 +99,0 @@

@@ -17,3 +17,2 @@ // This is the service worker with the Cache-first network

caches.open(CACHE).then(function (cache) {
console.log("[PWA Builder] Caching pages during install", cache);
})

@@ -31,3 +30,2 @@ );

self.addEventListener("fetch", function (event) {
console.log(event);

@@ -37,7 +35,5 @@ });

function fromCache(request) {
console.log(request);
}
function updateCache(request, response) {
console.log(request, response);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc