initial commit

This commit is contained in:
Jonas Kruckenberg 2022-11-01 15:19:25 +01:00
commit c3e5b84282
54 changed files with 2009 additions and 0 deletions

30
dist/mocks.js vendored Normal file
View file

@ -0,0 +1,30 @@
// tauri/tooling/api/src/mocks.ts
function mockIPC(cb) {
window.__TAURI_IPC__ = async ({
cmd,
callback,
error,
...args
}) => {
try {
window[`_${callback}`](await cb(cmd, args));
} catch (err) {
window[`_${error}`](err);
}
};
}
function mockWindows(current, ...additionalWindows) {
window.__TAURI_METADATA__ = {
__windows: [current, ...additionalWindows].map((label) => ({ label })),
__currentWindow: { label: current }
};
}
function clearMocks() {
delete window.__TAURI_IPC__;
delete window.__TAURI_METADATA__;
}
export {
clearMocks,
mockIPC,
mockWindows
};