Skip to content

Commit

Permalink
chore: remove references to unused __TAURI_INTERNALS__.metadata (#11369)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Oct 15, 2024
1 parent 25cc565 commit 2e88633
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changes/remove-unused-metadata-references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/api": patch:changes
"tauri": patch:changes
---

Remove references to no longer used `__TAURI_INTERNALS__.metadata.windows` and `__TAURI_INTERNALS__.metadata.webviews`.
2 changes: 1 addition & 1 deletion crates/tauri/scripts/bundle.global.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions crates/tauri/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,6 @@ impl<R: Runtime> AppManager<R> {
#[cfg(desktop)]
pub(crate) fn on_webview_close(&self, label: &str) {
self.webview.webviews_lock().remove(label);

if let Ok(webview_labels_array) = serde_json::to_string(&self.webview.labels()) {
let _ = self.webview.eval_script_all(format!(
r#"(function () {{ const metadata = window.__TAURI_INTERNALS__.metadata; if (metadata != null) {{ metadata.webviews = {webview_labels_array}.map(function (label) {{ return {{ label: label }} }}) }} }})()"#,
));
}
}

pub fn windows(&self) -> HashMap<String, Window<R>> {
Expand Down
10 changes: 9 additions & 1 deletion packages/api/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ export default [
'@typescript-eslint/default-param-last': 'off',
'@typescript-eslint/strict-boolean-expressions': 0,
'no-return-await': 'warn',
'@typescript-eslint/return-await': 'off'
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
]
}
}
]
2 changes: 0 additions & 2 deletions packages/api/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ declare global {
options?: InvokeOptions
}) => void
metadata: {
windows: WindowDef[]
currentWindow: WindowDef
webviews: WebviewDef[]
currentWebview: WebviewDef
}
plugins: {
Expand Down
8 changes: 1 addition & 7 deletions packages/api/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,16 @@ export function mockIPC(
* ```
*
* @param current Label of window this JavaScript context is running in.
* @param additionalWindows Label of additional windows the app has.
*
* @since 1.0.0
*/
export function mockWindows(
current: string,
...additionalWindows: string[]
..._additionalWindows: string[]
): void {
mockInternals()
window.__TAURI_INTERNALS__.metadata = {
windows: [current, ...additionalWindows].map((label) => ({ label })),
currentWindow: { label: current },
webviews: [current, ...additionalWindows].map((label) => ({
windowLabel: label,
label
})),
currentWebview: { windowLabel: current, label: current }
}
}
Expand Down

0 comments on commit 2e88633

Please sign in to comment.