mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
* feat(init): added EditorPanel with prettier, copy and settings support * chore(static): ignore static * feat: added navigator * feat: * feat(settings): added sessionStorage support for settings * feat(message): add messaging support in editors * feat(preview): added support for preview panel * fix(settings): use localstorage for settings instead of session storage * feat: * feat(css-to-js): implemented React section * feat(schema): add json to schema conversions * feat(others): implemented xml, yaml and markdown conversions * feat(babel): added flow to typescript converter * feat(graphql): implemented graphql to typescript * feat(graphql): added some transformations * fix: add support for different default value in one language * feat(graphql): added components, resolver signatures and mongodb * feat: * scala case class * fix(memory): worker-loader patch applied to fix memory overflow crash * feat: added json schema to typescript * icon: <GraphQLIcon />, * feat(navigator): shorter naming and new categories * route fixes * navigator * perf(workers): create separate file and remove fallback * fix(navigator): completed * build(snack): * fixes * fixes * fix(safari): * added json-to-mobx-state tree * fix(native): snacksession * fixes * added logo * navigator * fixes * custom header * fixes * refactor(settings): move settings to left side * feat: set up redirects * feat(seo): added title and description * feat(error): added custom error page * ga-script * feat: * fixes * fixe * fixes * fixes * fix:
45 lines
731 B
TypeScript
45 lines
731 B
TypeScript
import SVGO from "svgo";
|
|
|
|
const _self: any = self;
|
|
|
|
interface Data {
|
|
payload: Payload;
|
|
id: string;
|
|
}
|
|
|
|
interface Payload {
|
|
value: string;
|
|
settings: any;
|
|
}
|
|
|
|
_self.onmessage = ({ data: { id, payload } }: { data: Data }) => {
|
|
delete payload.settings.optimizeSvg;
|
|
|
|
const plugins = Object.keys(payload.settings).filter(
|
|
key => payload.settings[key]
|
|
);
|
|
|
|
try {
|
|
const svgo = new SVGO({
|
|
full: true,
|
|
// @ts-ignore
|
|
plugins
|
|
});
|
|
|
|
svgo.optimize(payload.value).then(result => {
|
|
_self.postMessage({
|
|
id,
|
|
payload: result.data
|
|
});
|
|
});
|
|
} catch (e) {
|
|
if (IS_DEV) {
|
|
console.error(e);
|
|
}
|
|
_self.postMessage({
|
|
id,
|
|
err: e.message
|
|
});
|
|
}
|
|
};
|