initial commit
This commit is contained in:
commit
c3e5b84282
54 changed files with 2009 additions and 0 deletions
30
dist/mocks.js
vendored
Normal file
30
dist/mocks.js
vendored
Normal 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
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue