mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +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';
|
||||
|
||||
const API_VERSION = 1;
|
||||
|
||||
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) => {
|
||||
if (event.data !== 'READY?') {
|
||||
return;
|
||||
}
|
||||
event.stopImmediatePropagation();
|
||||
self.parent.postMessage({ type: 'READY', version: API_VERSION }, '*');
|
||||
self.parent.postMessage({ type: 'READY', version: MAJOR_VERSION }, '*');
|
||||
});
|
||||
expose(new API(app), self.parent);
|
||||
}
|
||||
|
||||
@@ -70,8 +70,10 @@ export default class App extends Component<Props, State> {
|
||||
});
|
||||
|
||||
window.addEventListener('popstate', this.onPopState);
|
||||
/* webpackChunkName: "client-api" */
|
||||
import('./client-api').then(m => m.exposeAPI(this));
|
||||
import(
|
||||
/* webpackChunkName: "client-api" */
|
||||
'./client-api',
|
||||
).then(m => m.exposeAPI(this));
|
||||
}
|
||||
|
||||
@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 MAJOR_VERSION: string;
|
||||
|
||||
declare var ga: {
|
||||
(...args: any[]): void;
|
||||
|
||||
@@ -263,6 +263,7 @@ module.exports = async function (_, env) {
|
||||
// Inline constants during build, so they can be folded by UglifyJS.
|
||||
new webpack.DefinePlugin({
|
||||
VERSION: JSON.stringify(VERSION),
|
||||
MAJOR_VERSION: JSON.stringify(VERSION.split(".")[0]),
|
||||
// We set node.process=false later in this config.
|
||||
// Here we make sure if (process && process.foo) still works:
|
||||
process: '{}'
|
||||
|
||||
Reference in New Issue
Block a user