Compare commits

...

27 Commits

Author SHA1 Message Date
Jake Archibald
57418034c4 1.11.2 2020-07-07 16:08:26 +01:00
Jake Archibald
3892490023 Update size report branch 2020-07-07 16:08:13 +01:00
Anton
5bedff583b Update privacy link (#771)
The link doesn't work, as the default branch has been renamed
2020-07-07 16:06:33 +01:00
Jake Archibald
d94835402f 1.11.1 2020-07-02 14:29:00 +01:00
Jake Archibald
b7e45ab843 Bringing live back in sync 2020-07-02 14:28:40 +01:00
Leo Postovoit
8313246fd1 Fix typo for "spatial" (#768) 2020-07-02 14:25:51 +01:00
Surma
2b3cafb1f4 1.11.0 2020-06-24 16:22:06 +01:00
Surma
d52698f005 Merge remote-tracking branch 'origin/dev' into live 2020-06-24 16:21:49 +01:00
Surma
6ad28c0b5c Merge pull request #765 from petele/dimension 2020-06-24 16:15:16 +01:00
Surma
c76dabf063 Merge branch 'dev' into dimension 2020-06-24 16:12:59 +01:00
Surma
e6d8bac9c5 Merge pull request #764 from petele/install-prompt 2020-06-24 16:12:48 +01:00
Jake Archibald
42e43730c8 Naming changes 2020-06-24 15:16:38 +01:00
Jake Archibald
5c17fba349 Minor tweaks 2020-06-24 15:12:48 +01:00
Pete LePage
85eb94b725 Set the dimension value 2020-06-24 09:54:54 -04:00
Pete LePage
4fa73be842 Apply suggestions from code review
Co-authored-by: Surma <surma@surma.dev>
2020-06-24 09:40:56 -04:00
Surma
7c89d09139 Add missing prop to navigator 2020-06-24 14:08:52 +01:00
Pete LePage
079e56f1e1 Use a dimension to note how the user opened squoosh 2020-06-23 16:34:47 -04:00
Pete LePage
6065ceabfe update readme 2020-06-23 16:16:32 -04:00
Pete LePage
265e6db2bd Adds install button to Squoosh 2020-06-23 16:10:40 -04:00
Ingvar Stepanyan
eeb3d3562a 1.10.3 2020-04-22 17:35:39 +01:00
Ingvar Stepanyan
2d73c24e09 Merge remote-tracking branch 'origin/master' into live 2020-04-22 17:34:10 +01:00
Surma
f4a16022ef 1.10.2 2020-04-16 20:07:42 +01:00
Surma
12153c72dc Merge remote-tracking branch 'origin/master' into live 2020-04-16 20:07:08 +01:00
Surma
62c53c9fed 1.10.1 2020-04-16 11:52:59 +01:00
Surma
53a38b2ba1 Merge remote-tracking branch 'origin/master' into live 2020-04-16 11:52:34 +01:00
Surma
22b7e36c01 1.10.0 2020-04-14 13:29:05 +01:00
Surma
a0e6a377cd Merge remote-tracking branch 'origin/master' into live 2020-04-14 13:28:27 +01:00
10 changed files with 145 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ Google Analytics is used to record the following:
* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631). * [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
* Before and after image size once an image is downloaded. These values are rounded to the nearest * Before and after image size once an image is downloaded. These values are rounded to the nearest
kilobyte. kilobyte.
* If install is available, when Squoosh is installed, and what method was used to install Squoosh.
Image compression is handled locally; no additional data is sent to the server. Image compression is handled locally; no additional data is sent to the server.

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "squoosh", "name": "squoosh",
"version": "1.9.1", "version": "1.11.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "squoosh", "name": "squoosh",
"version": "1.9.1", "version": "1.11.2",
"license": "apache-2.0", "license": "apache-2.0",
"scripts": { "scripts": {
"start": "webpack-dev-server --host 0.0.0.0 --hot", "start": "webpack-dev-server --host 0.0.0.0 --hot",

View File

@@ -3,7 +3,7 @@ const escapeRE = require("escape-string-regexp");
module.exports = { module.exports = {
repo: "GoogleChromeLabs/squoosh", repo: "GoogleChromeLabs/squoosh",
path: "build/**/!(*.map)", path: "build/**/!(*.map)",
branch: "master", branch: "dev",
findRenamed(path, newPaths) { findRenamed(path, newPaths) {
const nameParts = /^(.+\.)[a-f0-9]+(\..+)$/.exec(path); const nameParts = /^(.+\.)[a-f0-9]+(\..+)$/.exec(path);
if (!nameParts) return; if (!nameParts) return;

View File

@@ -270,7 +270,7 @@ export default class WebPEncoderOptions extends Component<Props, State> {
value={options.sns_strength} value={options.sns_strength}
onInput={this.onChange} onInput={this.onChange}
> >
Spacial noise shaping: Spatial noise shaping:
</Range> </Range>
</div> </div>
<label class={style.optionTextFirst}> <label class={style.optionTextFirst}>

View File

@@ -41,17 +41,31 @@ const demos = [
}, },
]; ];
const installButtonSource = 'introInstallButton';
interface Props { interface Props {
onFile: (file: File | Fileish) => void; onFile: (file: File | Fileish) => void;
showSnack: SnackBarElement['showSnackbar']; showSnack: SnackBarElement['showSnackbar'];
} }
interface State { interface State {
fetchingDemoIndex?: number; fetchingDemoIndex?: number;
beforeInstallEvent?: BeforeInstallPromptEvent;
} }
export default class Intro extends Component<Props, State> { export default class Intro extends Component<Props, State> {
state: State = {}; state: State = {};
private fileInput?: HTMLInputElement; private fileInput?: HTMLInputElement;
private installingViaButton = false;
constructor() {
super();
// Listen for beforeinstallprompt events, indicating Squoosh is installable.
window.addEventListener('beforeinstallprompt', this.onBeforeInstallPromptEvent);
// Listen for the appinstalled event, indicating Squoosh has been installed.
window.addEventListener('appinstalled', this.onAppInstalled);
}
@bind @bind
private resetFileInput() { private resetFileInput() {
@@ -90,7 +104,52 @@ export default class Intro extends Component<Props, State> {
} }
} }
render({ }: Props, { fetchingDemoIndex }: State) { @bind
private onBeforeInstallPromptEvent(event: BeforeInstallPromptEvent) {
// Don't show the mini-infobar on mobile
event.preventDefault();
// Save the beforeinstallprompt event so it can be called later.
this.setState({ beforeInstallEvent: event });
// Log the event.
ga('send', 'event', 'pwa-install', 'available');
}
@bind
private async onInstallClick(event: Event) {
// Get the deferred beforeinstallprompt event
const beforeInstallEvent = this.state.beforeInstallEvent;
// If there's no deferred prompt, bail.
if (!beforeInstallEvent) return;
this.installingViaButton = true;
// Show the browser install prompt
beforeInstallEvent.prompt();
// Wait for the user to accept or dismiss the install prompt
const { outcome } = await beforeInstallEvent.userChoice;
ga('send', 'event', 'pwa-install', installButtonSource, outcome);
// If the prompt was dismissed, we aren't going to install via the button.
if (outcome === 'dismissed') {
this.installingViaButton = false;
}
}
@bind
private onAppInstalled() {
// Try to get the install, if it's not set, use 'browser'
const source = this.installingViaButton ? installButtonSource : 'browser';
ga('send', 'event', 'pwa-install', 'installed', source);
this.installingViaButton = false;
// We don't need the install button, if it's shown
this.setState({ beforeInstallEvent: undefined });
}
render({ }: Props, { fetchingDemoIndex, beforeInstallEvent }: State) {
return ( return (
<div class={style.intro}> <div class={style.intro}>
<div> <div>
@@ -120,7 +179,7 @@ export default class Intro extends Component<Props, State> {
<img class={style.demoIcon} src={demo.iconUrl} alt="" decoding="async" /> <img class={style.demoIcon} src={demo.iconUrl} alt="" decoding="async" />
{fetchingDemoIndex === i && {fetchingDemoIndex === i &&
<div class={style.demoLoading}> <div class={style.demoLoading}>
<loading-spinner class={style.demoLoadingSpinner}/> <loading-spinner class={style.demoLoadingSpinner} />
</div> </div>
} }
</div> </div>
@@ -132,11 +191,20 @@ export default class Intro extends Component<Props, State> {
)} )}
</ul> </ul>
</div> </div>
{beforeInstallEvent &&
<button
type="button"
class={style.installButton}
onClick={this.onInstallClick}
>
Install
</button>
}
<ul class={style.relatedLinks}> <ul class={style.relatedLinks}>
<li><a href="https://github.com/GoogleChromeLabs/squoosh/">View the code</a></li> <li><a href="https://github.com/GoogleChromeLabs/squoosh/">View the code</a></li>
<li><a href="https://github.com/GoogleChromeLabs/squoosh/issues">Report a bug</a></li> <li><a href="https://github.com/GoogleChromeLabs/squoosh/issues">Report a bug</a></li>
<li> <li>
<a href="https://github.com/GoogleChromeLabs/squoosh/blob/master/README.md#privacy"> <a href="https://github.com/GoogleChromeLabs/squoosh/blob/dev/README.md#privacy">
Privacy Privacy
</a> </a>
</li> </li>

32
src/components/intro/missing-types.d.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* The BeforeInstallPromptEvent is fired at the Window.onbeforeinstallprompt handler
* before a user is prompted to "install" a web site to a home screen on mobile.
*/
interface BeforeInstallPromptEvent extends Event {
/**
* Returns an array of DOMString items containing the platforms on which the event was dispatched.
* This is provided for user agents that want to present a choice of versions to the user such as,
* for example, "web" or "play" which would allow the user to chose between a web version or
* an Android version.
*/
readonly platforms: Array<string>;
/**
* Returns a Promise that resolves to a DOMString containing either "accepted" or "dismissed".
*/
readonly userChoice: Promise<{
outcome: 'accepted' | 'dismissed',
platform: string
}>;
/**
* Allows a developer to show the install prompt at a time of their own choosing.
* This method returns a Promise.
*/
prompt(): Promise<void>;
}
interface WindowEventMap {
"beforeinstallprompt": BeforeInstallPromptEvent;
}

View File

@@ -170,6 +170,30 @@
--color: #fff; --color: #fff;
} }
.install-button {
composes: unbutton from '../../lib/util.scss';
&:hover,
&:focus {
background: #f5f5f5;
}
background: #fff;
border: 1px solid #e8e8e8;
padding: 14px;
font-size: 1.3rem;
position: absolute;
top: 1rem;
right: 1rem;
animation: fade-in .3s ease-in-out;
}
@keyframes fade-in {
from { opacity: 0; }
}
.related-links { .related-links {
display: flex; display: flex;
padding: 0; padding: 0;

View File

@@ -13,11 +13,19 @@ if (!('customElements' in self)) {
} }
if (typeof PRERENDER === 'undefined') { if (typeof PRERENDER === 'undefined') {
// Determine the current display mode.
let displayMode = 'browser';
const mqStandAlone = '(display-mode: standalone)';
if (navigator.standalone || window.matchMedia(mqStandAlone).matches) {
displayMode = 'standalone';
}
// Setup analytics
window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args)); window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args));
ga('create', 'UA-128752250-1', 'auto'); ga('create', 'UA-128752250-1', 'auto');
ga('set', 'transport', 'beacon'); ga('set', 'transport', 'beacon');
ga('set', 'dimension1', displayMode);
ga('send', 'pageview'); ga('send', 'pageview');
// Load the GA script // Load the GA script
const s = document.createElement('script'); const s = document.createElement('script');
s.src = 'https://www.google-analytics.com/analytics.js'; s.src = 'https://www.google-analytics.com/analytics.js';
document.head!.appendChild(s); document.head!.appendChild(s);

View File

@@ -39,3 +39,7 @@ declare var ga: {
(...args: any[]): void; (...args: any[]): void;
q: any[]; q: any[];
}; };
interface Navigator {
readonly standalone: boolean;
}