From 8e76718e7b8253fbb1ce506cb9d6ed9bb7f5fa54 Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Thu, 13 Jun 2024 22:00:53 +0100 Subject: [PATCH] fix various small issues --- package.json | 1 + src-tauri/gen/schemas/windows-schema.json | 445 ++++++++++------------ src/components/DragAndDrop.vue | 8 +- src/components/FileTree.vue | 4 +- src/stores/main.ts | 8 +- yarn.lock | 40 +- 6 files changed, 237 insertions(+), 269 deletions(-) diff --git a/package.json b/package.json index f5b7f15..b2a4e45 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@tauri-apps/api": "^2.0.0-beta.13", + "@tauri-apps/plugin-dialog": "^2.0.0-beta.5", "@tauri-apps/plugin-os": "^2.0.0-beta.5", "pinia": "^2.1.7", "vue": "^3.3.4" diff --git a/src-tauri/gen/schemas/windows-schema.json b/src-tauri/gen/schemas/windows-schema.json index 3f7e295..9972cd6 100644 --- a/src-tauri/gen/schemas/windows-schema.json +++ b/src-tauri/gen/schemas/windows-schema.json @@ -11,6 +11,13 @@ } ] }, + { + "description": "A list of capabilities.", + "type": "array", + "items": { + "$ref": "#/definitions/Capability" + } + }, { "description": "A list of capabilities.", "type": "object", @@ -34,8 +41,7 @@ "type": "object", "required": [ "identifier", - "permissions", - "windows" + "permissions" ], "properties": { "identifier": { @@ -86,14 +92,10 @@ }, "platforms": { "description": "Target platforms this capability applies. By default all platforms are affected by this capability.", - "default": [ - "linux", - "macOS", - "windows", - "android", - "iOS" + "type": [ + "array", + "null" ], - "type": "array", "items": { "$ref": "#/definitions/Target" } @@ -108,7 +110,7 @@ ], "properties": { "urls": { - "description": "Remote domains this capability refers to. Can use glob patterns.", + "description": "Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/).\n\n# Examples\n\n- \"https://*.mydomain.dev\": allows subdomains of mydomain.dev - \"https://mydomain.dev/api/*\": allows any subpath of mydomain.dev/api", "type": "array", "items": { "type": "string" @@ -130,146 +132,39 @@ { "description": "Reference a permission or permission set by identifier and extends its scope.", "type": "object", - "oneOf": [ - { - "type": "object", - "required": [ - "identifier" - ], - "properties": { - "identifier": { - "oneOf": [ - { - "description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-execute" - ] - }, - { - "description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-kill" - ] - }, - { - "description": "shell:allow-open -> Enables the open command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-open" - ] - }, - { - "description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-stdin-write" - ] - }, - { - "description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-execute" - ] - }, - { - "description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-kill" - ] - }, - { - "description": "shell:deny-open -> Denies the open command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-open" - ] - }, - { - "description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-stdin-write" - ] - } - ] - }, - "allow": { - "items": { - "title": "Entry", - "description": "A command allowed to be executed by the webview API.", - "type": "object", - "required": [ - "args", - "command", - "name", - "sidecar" - ], - "properties": { - "args": { - "description": "The allowed arguments for the command execution.", - "allOf": [ - { - "$ref": "#/definitions/ShellAllowedArgs" - } - ] - }, - "command": { - "description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.", - "type": "string" - }, - "name": { - "description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.", - "type": "string" - }, - "sidecar": { - "description": "If this command is a sidecar command.", - "type": "boolean" - } - } - } - }, - "deny": { - "items": { - "title": "Entry", - "description": "A command allowed to be executed by the webview API.", - "type": "object", - "required": [ - "args", - "command", - "name", - "sidecar" - ], - "properties": { - "args": { - "description": "The allowed arguments for the command execution.", - "allOf": [ - { - "$ref": "#/definitions/ShellAllowedArgs" - } - ] - }, - "command": { - "description": "The command name. It can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.", - "type": "string" - }, - "name": { - "description": "The name for this allowed shell command configuration.\n\nThis name will be used inside of the webview API to call this command along with any specified arguments.", - "type": "string" - }, - "sidecar": { - "description": "If this command is a sidecar command.", - "type": "boolean" - } - } - } + "required": [ + "identifier" + ], + "properties": { + "identifier": { + "description": "Identifier of the permission or permission set.", + "allOf": [ + { + "$ref": "#/definitions/Identifier" } + ] + }, + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" } } - ] + } } ] }, @@ -352,6 +247,12 @@ "app:deny-version" ] }, + { + "type": "string", + "enum": [ + "dialog:default" + ] + }, { "description": "dialog:allow-ask -> Enables the ask command without any pre-configured scope.", "type": "string", @@ -485,6 +386,83 @@ "event:deny-unlisten" ] }, + { + "description": "image:default -> Default permissions for the plugin.", + "type": "string", + "enum": [ + "image:default" + ] + }, + { + "description": "image:allow-from-bytes -> Enables the from_bytes command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:allow-from-bytes" + ] + }, + { + "description": "image:allow-from-path -> Enables the from_path command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:allow-from-path" + ] + }, + { + "description": "image:allow-new -> Enables the new command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:allow-new" + ] + }, + { + "description": "image:allow-rgba -> Enables the rgba command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:allow-rgba" + ] + }, + { + "description": "image:allow-size -> Enables the size command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:allow-size" + ] + }, + { + "description": "image:deny-from-bytes -> Denies the from_bytes command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:deny-from-bytes" + ] + }, + { + "description": "image:deny-from-path -> Denies the from_path command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:deny-from-path" + ] + }, + { + "description": "image:deny-new -> Denies the new command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:deny-new" + ] + }, + { + "description": "image:deny-rgba -> Denies the rgba command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:deny-rgba" + ] + }, + { + "description": "image:deny-size -> Denies the size command without any pre-configured scope.", + "type": "string", + "enum": [ + "image:deny-size" + ] + }, { "description": "menu:default -> Default permissions for the plugin.", "type": "string", @@ -800,6 +778,12 @@ "menu:deny-text" ] }, + { + "type": "string", + "enum": [ + "os:default" + ] + }, { "description": "os:allow-arch -> Enables the arch command without any pre-configured scope.", "type": "string", @@ -1053,73 +1037,31 @@ ] }, { - "description": "shell:allow-execute -> Enables the execute command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-execute" - ] - }, - { - "description": "shell:allow-kill -> Enables the kill command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-kill" - ] - }, - { - "description": "shell:allow-open -> Enables the open command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-open" - ] - }, - { - "description": "shell:allow-stdin-write -> Enables the stdin_write command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:allow-stdin-write" - ] - }, - { - "description": "shell:deny-execute -> Denies the execute command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-execute" - ] - }, - { - "description": "shell:deny-kill -> Denies the kill command without any pre-configured scope.", - "type": "string", - "enum": [ - "shell:deny-kill" - ] - }, - { - "description": "shell:deny-open -> Denies the open command without any pre-configured scope.", + "description": "tray:default -> Default permissions for the plugin.", "type": "string", "enum": [ - "shell:deny-open" + "tray:default" ] }, { - "description": "shell:deny-stdin-write -> Denies the stdin_write command without any pre-configured scope.", + "description": "tray:allow-get-by-id -> Enables the get_by_id command without any pre-configured scope.", "type": "string", "enum": [ - "shell:deny-stdin-write" + "tray:allow-get-by-id" ] }, { - "description": "tray:default -> Default permissions for the plugin.", + "description": "tray:allow-new -> Enables the new command without any pre-configured scope.", "type": "string", "enum": [ - "tray:default" + "tray:allow-new" ] }, { - "description": "tray:allow-new -> Enables the new command without any pre-configured scope.", + "description": "tray:allow-remove-by-id -> Enables the remove_by_id command without any pre-configured scope.", "type": "string", "enum": [ - "tray:allow-new" + "tray:allow-remove-by-id" ] }, { @@ -1178,6 +1120,13 @@ "tray:allow-set-visible" ] }, + { + "description": "tray:deny-get-by-id -> Denies the get_by_id command without any pre-configured scope.", + "type": "string", + "enum": [ + "tray:deny-get-by-id" + ] + }, { "description": "tray:deny-new -> Denies the new command without any pre-configured scope.", "type": "string", @@ -1185,6 +1134,13 @@ "tray:deny-new" ] }, + { + "description": "tray:deny-remove-by-id -> Denies the remove_by_id command without any pre-configured scope.", + "type": "string", + "enum": [ + "tray:deny-remove-by-id" + ] + }, { "description": "tray:deny-set-icon -> Denies the set_icon command without any pre-configured scope.", "type": "string", @@ -1304,6 +1260,13 @@ "webview:allow-set-webview-size" ] }, + { + "description": "webview:allow-set-webview-zoom -> Enables the set_webview_zoom command without any pre-configured scope.", + "type": "string", + "enum": [ + "webview:allow-set-webview-zoom" + ] + }, { "description": "webview:allow-webview-close -> Enables the webview_close command without any pre-configured scope.", "type": "string", @@ -1381,6 +1344,13 @@ "webview:deny-set-webview-size" ] }, + { + "description": "webview:deny-set-webview-zoom -> Denies the set_webview_zoom command without any pre-configured scope.", + "type": "string", + "enum": [ + "webview:deny-set-webview-zoom" + ] + }, { "description": "webview:deny-webview-close -> Denies the webview_close command without any pre-configured scope.", "type": "string", @@ -1444,6 +1414,13 @@ "window:allow-current-monitor" ] }, + { + "description": "window:allow-cursor-position -> Enables the cursor_position command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:allow-cursor-position" + ] + }, { "description": "window:allow-destroy -> Enables the destroy command without any pre-configured scope.", "type": "string", @@ -1563,6 +1540,13 @@ "window:allow-minimize" ] }, + { + "description": "window:allow-monitor-from-point -> Enables the monitor_from_point command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:allow-monitor-from-point" + ] + }, { "description": "window:allow-outer-position -> Enables the outer_position command without any pre-configured scope.", "type": "string", @@ -1794,6 +1778,13 @@ "window:allow-start-dragging" ] }, + { + "description": "window:allow-start-resize-dragging -> Enables the start_resize_dragging command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:allow-start-resize-dragging" + ] + }, { "description": "window:allow-theme -> Enables the theme command without any pre-configured scope.", "type": "string", @@ -1864,6 +1855,13 @@ "window:deny-current-monitor" ] }, + { + "description": "window:deny-cursor-position -> Denies the cursor_position command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:deny-cursor-position" + ] + }, { "description": "window:deny-destroy -> Denies the destroy command without any pre-configured scope.", "type": "string", @@ -1983,6 +1981,13 @@ "window:deny-minimize" ] }, + { + "description": "window:deny-monitor-from-point -> Denies the monitor_from_point command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:deny-monitor-from-point" + ] + }, { "description": "window:deny-outer-position -> Denies the outer_position command without any pre-configured scope.", "type": "string", @@ -2214,6 +2219,13 @@ "window:deny-start-dragging" ] }, + { + "description": "window:deny-start-resize-dragging -> Denies the start_resize_dragging command without any pre-configured scope.", + "type": "string", + "enum": [ + "window:deny-start-resize-dragging" + ] + }, { "description": "window:deny-theme -> Denies the theme command without any pre-configured scope.", "type": "string", @@ -2344,45 +2356,6 @@ ] } ] - }, - "ShellAllowedArg": { - "description": "A command argument allowed to be executed by the webview API.", - "anyOf": [ - { - "description": "A non-configurable argument that is passed to the command in the order it was specified.", - "type": "string" - }, - { - "description": "A variable that is set while calling the command from the webview API.", - "type": "object", - "required": [ - "validator" - ], - "properties": { - "validator": { - "description": "[regex] validator to require passed values to conform to an expected input.\n\nThis will require the argument value passed to this variable to match the `validator` regex before it will be executed.\n\n[regex]: https://docs.rs/regex/latest/regex/#syntax", - "type": "string" - } - }, - "additionalProperties": false - } - ] - }, - "ShellAllowedArgs": { - "description": "A set of command arguments allowed to be executed by the webview API.\n\nA value of `true` will allow any arguments to be passed to the command. `false` will disable all arguments. A list of [`ShellAllowedArg`] will set those arguments as the only valid arguments to be passed to the attached command configuration.", - "anyOf": [ - { - "description": "Use a simple boolean to allow all or disable all arguments to this command configuration.", - "type": "boolean" - }, - { - "description": "A specific set of [`ShellAllowedArg`] that are valid to call for the command configuration.", - "type": "array", - "items": { - "$ref": "#/definitions/ShellAllowedArg" - } - } - ] } } } \ No newline at end of file diff --git a/src/components/DragAndDrop.vue b/src/components/DragAndDrop.vue index a0663f4..eb63aba 100644 --- a/src/components/DragAndDrop.vue +++ b/src/components/DragAndDrop.vue @@ -7,15 +7,15 @@ const mainStore = useStore(); let fileHover = ref(false); -const unlisten = getCurrent().onFileDropEvent(event => { - if (event.payload.type === 'hover') { +const unlisten = getCurrent().onDragDropEvent(event => { + if (event.payload.type === 'dragged') { fileHover.value = event.payload.paths.length == 1 && event.payload.paths[0].endsWith('.vpk'); - } else if (event.payload.type === 'drop') { + } else if (event.payload.type === 'dropped') { fileHover.value = false; if (event.payload.paths.length == 1 && event.payload.paths[0].endsWith('.vpk')) { mainStore.loadFromPath(event.payload.paths[0]); } - } else { + } else if (event.payload.type === 'cancelled') { fileHover.value = false; } }); diff --git a/src/components/FileTree.vue b/src/components/FileTree.vue index 45e2140..c6997b3 100644 --- a/src/components/FileTree.vue +++ b/src/components/FileTree.vue @@ -42,7 +42,9 @@ async function selectFile(path: string) { selectedEntry.value = await invoke('get_file_entry', { path }); } -async function previewFile(path: string) { +async function previewFile(path: string | null) { + if (path == null) return; + previewPath.value = path; if (!path.includes('/')) { diff --git a/src/stores/main.ts b/src/stores/main.ts index 188d2a8..695a4b4 100644 --- a/src/stores/main.ts +++ b/src/stores/main.ts @@ -122,7 +122,9 @@ export const useStore = defineStore('main', () => { } } - async function extractDir(dir: string) { + async function extractDir(dir: string | null) { + if (!dir) return; + let res = await open({ title: 'Select a output directory', directory: true, multiple: false }) if (res !== null && typeof res == 'string') { extractElapsedTime.value = 0; @@ -158,7 +160,9 @@ export const useStore = defineStore('main', () => { } } - async function extractFile(filePath: string) { + async function extractFile(filePath: string | null) { + if (!filePath) return; + let res = await open({ title: 'Select a output directory', directory: true, multiple: false }) if (res !== null && typeof res == 'string') { if (!filePath.includes('/')) { diff --git a/yarn.lock b/yarn.lock index ee4dc08..b1cecf2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -192,15 +192,10 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.12.0.tgz#9ffdf9ed133a7464f4ae187eb9e1294413fab235" integrity sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg== -"@tauri-apps/api@2.0.0-beta.2": - version "2.0.0-beta.2" - resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-beta.2.tgz#adec036f5ece03b88f59fdb7fa18e315c77d0738" - integrity sha512-4r1r6kgttzIWxJ3HxkZQH+b7EiUtKhdUCPbi0KSalD+2T3j6klw+v8VyxhKwEdjM/eo60NE+J33v1E/Urq8puw== - -"@tauri-apps/api@^2.0.0-beta.3": - version "2.0.0-beta.3" - resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-beta.3.tgz#aae36cae870d342bdf40b1301d270a10bbf758ce" - integrity sha512-gDSJzKpBs6efXw2ZWqjl9QVNImY5GR5qygXqB7JK4y7prcQInxnTj2ARFR0vD4wuzkrUHGrlIKraiJJPHWJ9vg== +"@tauri-apps/api@2.0.0-beta.13", "@tauri-apps/api@^2.0.0-beta.13": + version "2.0.0-beta.13" + resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-beta.13.tgz#53ec5117d042d560615afec2d38a6d38ee20ff22" + integrity sha512-Np1opKANzRMF3lgJ9gDquBCB9SxlE2lRmNpVx1+L6RyzAmigkuh0ZulT5jMnDA3JLsuSDU135r/s4t/Pmx4atg== "@tauri-apps/cli-darwin-arm64@2.0.0-beta.6": version "2.0.0-beta.6" @@ -268,26 +263,19 @@ "@tauri-apps/cli-win32-ia32-msvc" "2.0.0-beta.6" "@tauri-apps/cli-win32-x64-msvc" "2.0.0-beta.6" -"@tauri-apps/plugin-dialog@^2.0.0-beta.1": - version "2.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-dialog/-/plugin-dialog-2.0.0-beta.1.tgz#d02e39368fa0a069826b438dd729edb57bc316ff" - integrity sha512-nVZv2m67NaEU05SRbe59heFaZ5wlew9pgd/oi2yL8yUM+46abo9prky/eyXb1HzF8n66yRSaSkNcX1GZou5pNQ== - dependencies: - "@tauri-apps/api" "2.0.0-beta.2" - -"@tauri-apps/plugin-os@^2.0.0-beta.1": - version "2.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-os/-/plugin-os-2.0.0-beta.1.tgz#70e3fd5b50859138b81dba1d999a067246fda2d8" - integrity sha512-fQ0rPJjuAppOtRlBULIn7vc9oNgP8aIi58Q48HvrIZ2ndysxEEO5TW4hkFCU+BXB/b6Y24lwhLBiC8kCzUcLew== +"@tauri-apps/plugin-dialog@^2.0.0-beta.5": + version "2.0.0-beta.5" + resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-dialog/-/plugin-dialog-2.0.0-beta.5.tgz#1ad9592d554bd5a4b4d41a9f4aa6e01aa33a9f6a" + integrity sha512-jkaBCsx2v6WB6sB77fTMCeijuvT3FlzwschiHnPlD7aU6CHvQgRlpCv/FttPdTq4ih2t6MIlM4oX85hNYgfs6w== dependencies: - "@tauri-apps/api" "2.0.0-beta.2" + "@tauri-apps/api" "2.0.0-beta.13" -"@tauri-apps/plugin-shell@^2.0.0-beta.1": - version "2.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-shell/-/plugin-shell-2.0.0-beta.1.tgz#e22b3c3ee8ca30c241467fe947a82ef5d229374d" - integrity sha512-yMf9CMHCRkGnx0pv420MptEeUdk+bVrXyM5zwFisy75GBhXgvEEtSjAkubTsC0jkzLfn4EInizaW2GER9ub7cQ== +"@tauri-apps/plugin-os@^2.0.0-beta.5": + version "2.0.0-beta.5" + resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-os/-/plugin-os-2.0.0-beta.5.tgz#7b3b066796e37f073925afb6cb0ddb9cdab0f7d9" + integrity sha512-Qfs/clZ9R05J+OVOGkko+9OaYaL+xJaGICeQ1G5CnLFpUdTfMV10D+1nBBauxDdiLU4ay5I0iprJ5aG5GJBunQ== dependencies: - "@tauri-apps/api" "2.0.0-beta.2" + "@tauri-apps/api" "2.0.0-beta.13" "@types/estree@1.0.5": version "1.0.5"