Fix build version of the project because of web workers
This commit is contained in:
parent
2945febd91
commit
c7bc77b08f
4 changed files with 4 additions and 5 deletions
|
@ -3,7 +3,6 @@ import { IConfiguration } from '../../Interfaces/IConfiguration';
|
|||
import { getCircularReplacer } from '../../utils/saveload';
|
||||
import { ID } from '../SVG/SVG';
|
||||
import { IEditorState } from '../../Interfaces/IEditorState';
|
||||
import Worker from '../../workers/worker?worker';
|
||||
|
||||
export function SaveEditorAsJSON(
|
||||
history: IHistoryState[],
|
||||
|
@ -21,7 +20,7 @@ export function SaveEditorAsJSON(
|
|||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
if (window.Worker) {
|
||||
// use webworker for the stringify to avoid freezing
|
||||
const myWorker = new Worker();
|
||||
const myWorker = new Worker('workers/worker.js');
|
||||
myWorker.postMessage({ editorState, spaces });
|
||||
myWorker.onmessage = (event) => {
|
||||
const data = event.data;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
onmessage = (e) => {
|
||||
const data = JSON.stringify(e.data.editorState, getCircularReplacer(), e.data.spaces);
|
||||
postMessage(data);
|
||||
};
|
||||
|
||||
const getCircularReplacer = () => {
|
||||
const seen = new WeakSet();
|
||||
return (key, value) => {
|
||||
if (key === 'parent') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'SelectedContainer') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return;
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue