From c73049d3edf267aed147735a5d9789ef53866baf Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 9 Jun 2023 03:17:53 +0300 Subject: [PATCH 1/4] fix: remove tsconfig symlink (#429) * fix: remove tsconfig symlink * one more tsconfig --- plugins/authenticator/tsconfig.json | 5 ++++- plugins/autostart/tsconfig.json | 5 ++++- plugins/fs/tsconfig.json | 5 ++++- plugins/log/tsconfig.json | 5 ++++- plugins/positioner/tsconfig.json | 5 ++++- plugins/sql/tsconfig.json | 5 ++++- plugins/store/tsconfig.json | 5 ++++- plugins/stronghold/tsconfig.json | 5 ++++- plugins/upload/guest-js/index.ts | 1 - plugins/upload/src/api-iife.js | 2 +- plugins/upload/tsconfig.json | 5 ++++- plugins/websocket/tsconfig.json | 5 ++++- plugins/window-state/tsconfig.json | 5 ++++- shared/template/tsconfig.json | 5 ++++- 14 files changed, 49 insertions(+), 14 deletions(-) diff --git a/plugins/authenticator/tsconfig.json b/plugins/authenticator/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/authenticator/tsconfig.json +++ b/plugins/authenticator/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/autostart/tsconfig.json b/plugins/autostart/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/autostart/tsconfig.json +++ b/plugins/autostart/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/fs/tsconfig.json b/plugins/fs/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/fs/tsconfig.json +++ b/plugins/fs/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/log/tsconfig.json b/plugins/log/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/log/tsconfig.json +++ b/plugins/log/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/positioner/tsconfig.json b/plugins/positioner/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/positioner/tsconfig.json +++ b/plugins/positioner/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/sql/tsconfig.json b/plugins/sql/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/sql/tsconfig.json +++ b/plugins/sql/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/store/tsconfig.json b/plugins/store/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/store/tsconfig.json +++ b/plugins/store/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/stronghold/tsconfig.json b/plugins/stronghold/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/stronghold/tsconfig.json +++ b/plugins/stronghold/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index d220af04..29c25a98 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -63,5 +63,4 @@ async function download( }); } -export default upload; export { download, upload }; diff --git a/plugins/upload/src/api-iife.js b/plugins/upload/src/api-iife.js index b42588ae..210ee0d9 100644 --- a/plugins/upload/src/api-iife.js +++ b/plugins/upload/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_UPLOAD__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),o=(e,n,r,o)=>(t(e,n,"write to private field"),o?o.call(e,r):n.set(e,r),r);function a(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>l,PluginListener:()=>s,addPluginListener:()=>d,convertFileSrc:()=>u,invoke:()=>c,transformCallback:()=>a});var i,l=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,i,(()=>{})),this.id=a((e=>{r(this,i).call(this,e)}))}set onmessage(e){o(this,i,e)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var s=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,n,t){let r=new l;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new s(e,n,r.id)))}async function c(e,n={}){return new Promise(((t,r)=>{let o=a((e=>{t(e),Reflect.deleteProperty(window,`_${i}`)}),!0),i=a((e=>{r(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:i,...n})}))}function u(e,n="asset"){let t=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${n}.localhost/${t}`:`${n}://localhost/${t}`}async function _(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new l;null!=t&&(i.onmessage=t),await c("plugin:upload|upload",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})}return e.default=_,e.download=async function(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new l;null!=t&&(i.onmessage=t),await c("plugin:upload|download",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})},e.upload=_,Object.defineProperty(e,"__esModule",{value:!0}),e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} +if("__TAURI__"in window){var __TAURI_UPLOAD__=function(e){"use strict";var n=Object.defineProperty,t=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},r=(e,n,r)=>(t(e,n,"read from private field"),r?r.call(e):n.get(e)),o=(e,n,r,o)=>(t(e,n,"write to private field"),o?o.call(e,r):n.set(e,r),r);function a(e,n=!1){let t=window.crypto.getRandomValues(new Uint32Array(1))[0],r=`_${t}`;return Object.defineProperty(window,r,{value:t=>(n&&Reflect.deleteProperty(window,r),e?.(t)),writable:!1,configurable:!0}),t}((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>l,addPluginListener:()=>d,convertFileSrc:()=>u,invoke:()=>c,transformCallback:()=>a});var i,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)})(this,i,(()=>{})),this.id=a((e=>{r(this,i).call(this,e)}))}set onmessage(e){o(this,i,e)}get onmessage(){return r(this,i)}toJSON(){return`__CHANNEL__:${this.id}`}};i=new WeakMap;var l=class{constructor(e,n,t){this.plugin=e,this.event=n,this.channelId=t}async unregister(){return c(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function d(e,n,t){let r=new s;return r.onmessage=t,c(`plugin:${e}|register_listener`,{event:n,handler:r}).then((()=>new l(e,n,r.id)))}async function c(e,n={}){return new Promise(((t,r)=>{let o=a((e=>{t(e),Reflect.deleteProperty(window,`_${i}`)}),!0),i=a((e=>{r(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:i,...n})}))}function u(e,n="asset"){let t=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?`https://${n}.localhost/${t}`:`${n}://localhost/${t}`}return e.download=async function(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new s;null!=t&&(i.onmessage=t),await c("plugin:upload|download",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})},e.upload=async function(e,n,t,r){const o=new Uint32Array(1);window.crypto.getRandomValues(o);const a=o[0],i=new s;null!=t&&(i.onmessage=t),await c("plugin:upload|upload",{id:a,url:e,filePath:n,headers:null!=r?r:{},onProgress:i})},e}({});Object.defineProperty(window.__TAURI__,"upload",{value:__TAURI_UPLOAD__})} diff --git a/plugins/upload/tsconfig.json b/plugins/upload/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/upload/tsconfig.json +++ b/plugins/upload/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/websocket/tsconfig.json b/plugins/websocket/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/websocket/tsconfig.json +++ b/plugins/websocket/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/window-state/tsconfig.json b/plugins/window-state/tsconfig.json index 7cd38da8..5098169a 120000 --- a/plugins/window-state/tsconfig.json +++ b/plugins/window-state/tsconfig.json @@ -1 +1,4 @@ -../../shared/tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/shared/template/tsconfig.json b/shared/template/tsconfig.json index 4ec6ff6a..5098169a 120000 --- a/shared/template/tsconfig.json +++ b/shared/template/tsconfig.json @@ -1 +1,4 @@ -../tsconfig.json \ No newline at end of file +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} From 84b3612393e3d0d4faeebe1e61cb7d7973556503 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 13 Jun 2023 23:30:39 +0300 Subject: [PATCH 2/4] fix(window-state): port fixes from v1 (#436) * fix(window-state): correctly set decoration state if no saved state exists, fixes #421 (#424) * fix(window-state): propagate promise (#435) closes #432 * fix(window-state): manual default implentation (#425) * fix(window-state): manual default implentation, closes #421 * Update lib.rs * change file * generated files * fix symlinks? --------- Co-authored-by: Fabian-Lars --- .changes/window-state-decorated.md | 5 +++++ .changes/window-state-promise.md | 5 +++++ plugins/authenticator/tsconfig.json | 0 plugins/autostart/tsconfig.json | 0 plugins/fs/tsconfig.json | 0 plugins/log/tsconfig.json | 0 plugins/positioner/tsconfig.json | 0 plugins/sql/tsconfig.json | 0 plugins/store/tsconfig.json | 0 plugins/stronghold/tsconfig.json | 0 plugins/upload/tsconfig.json | 0 plugins/websocket/tsconfig.json | 0 plugins/window-state/guest-js/index.ts | 14 ++++++++------ plugins/window-state/src/api-iife.js | 2 +- plugins/window-state/src/lib.rs | 19 +++++++++++++++++-- plugins/window-state/tsconfig.json | 0 16 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .changes/window-state-decorated.md create mode 100644 .changes/window-state-promise.md mode change 120000 => 100644 plugins/authenticator/tsconfig.json mode change 120000 => 100644 plugins/autostart/tsconfig.json mode change 120000 => 100644 plugins/fs/tsconfig.json mode change 120000 => 100644 plugins/log/tsconfig.json mode change 120000 => 100644 plugins/positioner/tsconfig.json mode change 120000 => 100644 plugins/sql/tsconfig.json mode change 120000 => 100644 plugins/store/tsconfig.json mode change 120000 => 100644 plugins/stronghold/tsconfig.json mode change 120000 => 100644 plugins/upload/tsconfig.json mode change 120000 => 100644 plugins/websocket/tsconfig.json mode change 120000 => 100644 plugins/window-state/tsconfig.json diff --git a/.changes/window-state-decorated.md b/.changes/window-state-decorated.md new file mode 100644 index 00000000..191ec5c2 --- /dev/null +++ b/.changes/window-state-decorated.md @@ -0,0 +1,5 @@ +--- +"window-state": "patch" +--- + +Correctly set decoration state if no saved state xists diff --git a/.changes/window-state-promise.md b/.changes/window-state-promise.md new file mode 100644 index 00000000..f97c43df --- /dev/null +++ b/.changes/window-state-promise.md @@ -0,0 +1,5 @@ +--- +"window-state-js": "patch" +--- + +Correctly propagate the promise inside `saveWindowState`, `restoreState` and `restoreStateCurrent` so callers can choose to `await` them. diff --git a/plugins/authenticator/tsconfig.json b/plugins/authenticator/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/authenticator/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/authenticator/tsconfig.json b/plugins/authenticator/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/authenticator/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/autostart/tsconfig.json b/plugins/autostart/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/autostart/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/autostart/tsconfig.json b/plugins/autostart/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/autostart/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/fs/tsconfig.json b/plugins/fs/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/fs/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/fs/tsconfig.json b/plugins/fs/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/fs/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/log/tsconfig.json b/plugins/log/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/log/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/log/tsconfig.json b/plugins/log/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/log/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/positioner/tsconfig.json b/plugins/positioner/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/positioner/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/positioner/tsconfig.json b/plugins/positioner/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/positioner/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/sql/tsconfig.json b/plugins/sql/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/sql/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/sql/tsconfig.json b/plugins/sql/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/sql/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/store/tsconfig.json b/plugins/store/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/store/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/store/tsconfig.json b/plugins/store/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/store/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/stronghold/tsconfig.json b/plugins/stronghold/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/stronghold/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/stronghold/tsconfig.json b/plugins/stronghold/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/stronghold/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/upload/tsconfig.json b/plugins/upload/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/upload/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/upload/tsconfig.json b/plugins/upload/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/upload/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/websocket/tsconfig.json b/plugins/websocket/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/websocket/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/websocket/tsconfig.json b/plugins/websocket/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/websocket/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} diff --git a/plugins/window-state/guest-js/index.ts b/plugins/window-state/guest-js/index.ts index 706e3cbf..31d88f9a 100644 --- a/plugins/window-state/guest-js/index.ts +++ b/plugins/window-state/guest-js/index.ts @@ -34,15 +34,17 @@ export enum StateFlags { /** * Save the state of all open windows to disk. */ -async function saveWindowState(flags: StateFlags) { - window.__TAURI_INVOKE__("plugin:window-state|save_window_state", { flags }); +async function saveWindowState(flags: StateFlags): Promise { + return window.__TAURI_INVOKE__("plugin:window-state|save_window_state", { + flags, + }); } /** * Restore the state for the specified window from disk. */ -async function restoreState(label: string, flags: StateFlags) { - window.__TAURI_INVOKE__("plugin:window-state|restore_state", { +async function restoreState(label: string, flags: StateFlags): Promise { + return window.__TAURI_INVOKE__("plugin:window-state|restore_state", { label, flags, }); @@ -51,8 +53,8 @@ async function restoreState(label: string, flags: StateFlags) { /** * Restore the state for the current window from disk. */ -async function restoreStateCurrent(flags: StateFlags) { - restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags); +async function restoreStateCurrent(flags: StateFlags): Promise { + return restoreState(window.__TAURI_METADATA__.__currentWindow.label, flags); } export { restoreState, restoreStateCurrent, saveWindowState }; diff --git a/plugins/window-state/src/api-iife.js b/plugins/window-state/src/api-iife.js index 86c310f8..3ded95ac 100644 --- a/plugins/window-state/src/api-iife.js +++ b/plugins/window-state/src/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_WINDOWSTATE__=function(_){"use strict";var t;async function e(_,t){window.__TAURI_INVOKE__("plugin:window-state|restore_state",{label:_,flags:t})}return _.StateFlags=void 0,(t=_.StateFlags||(_.StateFlags={}))[t.SIZE=1]="SIZE",t[t.POSITION=2]="POSITION",t[t.MAXIMIZED=4]="MAXIMIZED",t[t.VISIBLE=8]="VISIBLE",t[t.DECORATIONS=16]="DECORATIONS",t[t.FULLSCREEN=32]="FULLSCREEN",t[t.ALL=63]="ALL",_.restoreState=e,_.restoreStateCurrent=async function(_){e(window.__TAURI_METADATA__.__currentWindow.label,_)},_.saveWindowState=async function(_){window.__TAURI_INVOKE__("plugin:window-state|save_window_state",{flags:_})},_}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_WINDOWSTATE__})} +if("__TAURI__"in window){var __TAURI_WINDOWSTATE__=function(t){"use strict";var _;async function e(t,_){return window.__TAURI_INVOKE__("plugin:window-state|restore_state",{label:t,flags:_})}return t.StateFlags=void 0,(_=t.StateFlags||(t.StateFlags={}))[_.SIZE=1]="SIZE",_[_.POSITION=2]="POSITION",_[_.MAXIMIZED=4]="MAXIMIZED",_[_.VISIBLE=8]="VISIBLE",_[_.DECORATIONS=16]="DECORATIONS",_[_.FULLSCREEN=32]="FULLSCREEN",_[_.ALL=63]="ALL",t.restoreState=e,t.restoreStateCurrent=async function(t){return e(window.__TAURI_METADATA__.__currentWindow.label,t)},t.saveWindowState=async function(t){return window.__TAURI_INVOKE__("plugin:window-state|save_window_state",{flags:t})},t}({});Object.defineProperty(window.__TAURI__,"windowState",{value:__TAURI_WINDOWSTATE__})} diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index 28e00b35..fa88be3b 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -55,7 +55,7 @@ impl Default for StateFlags { } } -#[derive(Debug, Default, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq)] struct WindowState { width: f64, height: f64, @@ -67,6 +67,21 @@ struct WindowState { fullscreen: bool, } +impl Default for WindowState { + fn default() -> Self { + Self { + width: Default::default(), + height: Default::default(), + x: Default::default(), + y: Default::default(), + maximized: Default::default(), + visible: true, + decorated: true, + fullscreen: Default::default(), + } + } +} + struct WindowStateCache(Arc>>); pub trait AppHandleExt { /// Saves all open windows state to disk @@ -177,7 +192,7 @@ impl WindowExt for Window { } if flags.contains(StateFlags::DECORATIONS) { - metadata.visible = self.is_visible()?; + metadata.decorated = self.is_decorated()?; } if flags.contains(StateFlags::FULLSCREEN) { diff --git a/plugins/window-state/tsconfig.json b/plugins/window-state/tsconfig.json deleted file mode 120000 index 5098169a..00000000 --- a/plugins/window-state/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/plugins/window-state/tsconfig.json b/plugins/window-state/tsconfig.json new file mode 100644 index 00000000..5098169a --- /dev/null +++ b/plugins/window-state/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["guest-js/*.ts"] +} From 9359b5b138a2aa03ff824474849ddb2c8df3f685 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Fri, 16 Jun 2023 08:05:55 -0700 Subject: [PATCH 3/4] fix(examples): adjust layout for iOS (#439) --- examples/api/index.html | 5 ++++- examples/api/src/App.svelte | 2 +- examples/api/src/app.css | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/api/index.html b/examples/api/index.html index 3b39b0f6..81b6f92e 100644 --- a/examples/api/index.html +++ b/examples/api/index.html @@ -2,7 +2,10 @@ - + Svelte + Vite App diff --git a/examples/api/src/App.svelte b/examples/api/src/App.svelte index 1b3c9b71..dd0df993 100644 --- a/examples/api/src/App.svelte +++ b/examples/api/src/App.svelte @@ -354,7 +354,7 @@