mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 10:09:45 +00:00
Use MAJOR_VERSION from package.json
This commit is contained in:
@@ -3,16 +3,14 @@ import { SideEvent, SideEventType } from '../compress/index';
|
|||||||
|
|
||||||
import { expose } from 'comlink';
|
import { expose } from 'comlink';
|
||||||
|
|
||||||
const API_VERSION = 1;
|
|
||||||
|
|
||||||
export function exposeAPI(app: App) {
|
export function exposeAPI(app: App) {
|
||||||
self.parent.postMessage({ type: 'READY', version: API_VERSION }, '*');
|
self.parent.postMessage({ type: 'READY', version: MAJOR_VERSION }, '*');
|
||||||
self.addEventListener('message', (event: MessageEvent) => {
|
self.addEventListener('message', (event: MessageEvent) => {
|
||||||
if (event.data !== 'READY?') {
|
if (event.data !== 'READY?') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
self.parent.postMessage({ type: 'READY', version: API_VERSION }, '*');
|
self.parent.postMessage({ type: 'READY', version: MAJOR_VERSION }, '*');
|
||||||
});
|
});
|
||||||
expose(new API(app), self.parent);
|
expose(new API(app), self.parent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ export default class App extends Component<Props, State> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('popstate', this.onPopState);
|
window.addEventListener('popstate', this.onPopState);
|
||||||
/* webpackChunkName: "client-api" */
|
import(
|
||||||
import('./client-api').then(m => m.exposeAPI(this));
|
/* webpackChunkName: "client-api" */
|
||||||
|
'./client-api',
|
||||||
|
).then(m => m.exposeAPI(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind openFile(file: File | Fileish) {
|
@bind openFile(file: File | Fileish) {
|
||||||
|
|||||||
1
src/missing-types.d.ts
vendored
1
src/missing-types.d.ts
vendored
@@ -34,6 +34,7 @@ declare module 'url-loader!*' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare var VERSION: string;
|
declare var VERSION: string;
|
||||||
|
declare var MAJOR_VERSION: string;
|
||||||
|
|
||||||
declare var ga: {
|
declare var ga: {
|
||||||
(...args: any[]): void;
|
(...args: any[]): void;
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ module.exports = async function (_, env) {
|
|||||||
// Inline constants during build, so they can be folded by UglifyJS.
|
// Inline constants during build, so they can be folded by UglifyJS.
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
VERSION: JSON.stringify(VERSION),
|
VERSION: JSON.stringify(VERSION),
|
||||||
|
MAJOR_VERSION: JSON.stringify(VERSION.split(".")[0]),
|
||||||
// We set node.process=false later in this config.
|
// We set node.process=false later in this config.
|
||||||
// Here we make sure if (process && process.foo) still works:
|
// Here we make sure if (process && process.foo) still works:
|
||||||
process: '{}'
|
process: '{}'
|
||||||
|
|||||||
Reference in New Issue
Block a user