@@ -157,7 +157,7 @@ Phoenix.app = {
157
157
* double clicking a file in file explorer in os, the handler will be called with the command line args with the
158
158
* file that was double-clicked (or folder using open with) in os file explorer/cli.
159
159
* @param {function(cliArgs, cwd) } handlerFn - the handler function will receive two args on callback, the cliArgs
160
- * of the other phoenix process that was invoked to open the file and its current working dir.
160
+ * of the other phoenix process that was invoked to open the file and its current working dir. cwd may be null
161
161
* @return {* }
162
162
*/
163
163
setSingleInstanceCLIArgsHandler : function ( handlerFn ) {
@@ -171,10 +171,25 @@ Phoenix.app = {
171
171
window . __TAURI__ . event . listen ( "single-instance" , ( { payload} ) => {
172
172
handlerFn ( payload . args , payload . cwd ) ;
173
173
} ) ;
174
+ window . __TAURI__ . tauri . invoke ( "get_mac_deep_link_requests" ) . then ( filesURLList => {
175
+ if ( ! filesURLList . length ) {
176
+ return ;
177
+ }
178
+ // this is special handling for open with to work from mac finder. Mac will raise and event which will
179
+ // be buffered in the shell till the app reads the opened file list. Once read, the file list will be
180
+ // emptied in shell and no other instances will get the data, so we have to process it here.
181
+ const platformSimulatedArgs = [ "macOSBootTimeDeepLink" ] ;
182
+ for ( const fileURL of filesURLList ) {
183
+ platformSimulatedArgs . push ( fileURL . replace ( "file://" , "" ) ) ;
184
+ }
185
+ handlerFn ( platformSimulatedArgs , "" ) ;
186
+ } ) ;
174
187
window . __TAURI__ . event . listen ( "scheme-request-received" , ( receivedEvent ) => {
175
188
// this is for mac-os open with processing from finder.
176
- console . error ( "Macos not handled" , receivedEvent ) ;
177
- alert ( JSON . stringify ( receivedEvent ) ) ;
189
+ console . log ( "Macos received Event from OS:" , receivedEvent ) ;
190
+ const fileURL = receivedEvent . payload ;
191
+ window . __TAURI__ . tauri . invoke ( "get_mac_deep_link_requests" ) ; // this will clear the cached queue in shell
192
+ handlerFn ( [ "macOSEvent" , fileURL . replace ( "file://" , "" ) ] , "" ) ;
178
193
} ) ;
179
194
}
180
195
} ,
0 commit comments