Commit Graph

20 Commits

Author SHA1 Message Date
Sam Atkins
280479c0c6 chore: Clarify usage of window fields in IPC.js
Resolves these eslint errors:

/puter/src/IPC.js
    53:69  error  'appCallbackFunctions' is not defined                no-undef
    55:9   error  'appCallbackFunctions' is not defined                no-undef
    57:16  error  'appCallbackFunctions' is not defined                no-undef
    81:33  error  'window_for_app_instance' is not defined             no-undef
    84:27  error  'iframe_for_app_instance' is not defined             no-undef
   105:48  error  Empty block statement                                no-empty
   180:18  error  'api_origin' is not defined                          no-undef
   190:44  error  'auth_token' is not defined                          no-undef
   194:21  error  'logout' is not defined                              no-undef
   207:18  error  'api_origin' is not defined                          no-undef
   216:44  error  'auth_token' is not defined                          no-undef
   220:21  error  'logout' is not defined                              no-undef
   239:18  error  'api_origin' is not defined                          no-undef
   248:44  error  'auth_token' is not defined                          no-undef
   252:21  error  'logout' is not defined                              no-undef
   268:13  error  'is_auth' is not defined                             no-undef
   309:13  error  'is_auth' is not defined                             no-undef
   348:27  error  'window_for_app_instance' is not defined             no-undef
   360:27  error  'window_for_app_instance' is not defined             no-undef
   576:35  error  'uuidv4' is not defined                              no-undef
   582:9   error  'launch_app' is not defined                          no-undef
   597:37  error  'appdata_path' is not defined                        no-undef
   629:12  error  'appdata_signatures' is not defined                  no-undef
   633:23  error  'appdata_signatures' is not defined                  no-undef
   638:30  error  'appdata_path' is not defined                        no-undef
   647:25  error  'appdata_signatures' is not defined                  no-undef
   664:29  error  'appdata_signatures' is not defined                  no-undef
   682:13  error  'is_auth' is not defined                             no-undef
   717:13  error  'is_auth' is not defined                             no-undef
   745:13  error  'is_auth' is not defined                             no-undef
   773:13  error  'is_auth' is not defined                             no-undef
   783:22  error  'api_origin' is not defined                          no-undef
   793:48  error  'auth_token' is not defined                          no-undef
   797:25  error  'logout' is not defined                              no-undef
   825:13  error  'is_auth' is not defined                             no-undef
   857:36  error  'operation_id' is not defined                        no-undef
   872:41  error  'auth_token' is not defined                          no-undef
   873:41  error  'api_origin' is not defined                          no-undef
   939:45  error  'item_icon' is not defined                           no-undef
   951:33  error  'sort_items' is not defined                          no-undef
   954:29  error  'show_save_account_notice_if_needed' is not defined  no-undef
   998:38  error  'busy_indicator_hide_delay' is not defined           no-undef
  1004:33  error  'busy_indicator_hide_delay' is not defined           no-undef
  1018:37  error  'pictures_path' is not defined                       no-undef
  1020:37  error  'desktop_path' is not defined                        no-undef
  1022:37  error  'documents_path' is not defined                      no-undef
  1024:37  error  'videos_path' is not defined                         no-undef
  1026:37  error  'audio_path' is not defined                          no-undef
  1028:37  error  'appdata_path' is not defined                        no-undef
  1032:13  error  'is_auth' is not defined                             no-undef
  1044:28  error  'operation_id' is not defined                        no-undef
  1059:33  error  'auth_token' is not defined                          no-undef
  1060:33  error  'api_origin' is not defined                          no-undef
  1145:31  error  'iframe_for_app_instance' is not defined             no-undef
  1163:31  error  'window_for_app_instance' is not defined             no-undef
  1178:36  error  'get_apps' is not defined                            no-undef
  1199:11  error  'window_for_app_instance' is not defined             no-undef
2024-05-02 11:21:50 +01:00
Nariman Jelveh
c4b2d9861f Clean up some of the unnecessary console warnings 2024-04-25 13:11:11 -07:00
Nariman Jelveh
f5f35f2c37 Phase out openItem in IPC
also fix the issue with directories being opened with notepad after setting notepad as default app for files without extensions.
2024-04-24 23:12:57 -07:00
Nariman Jelveh
25eea41f60 Keep track of app_instance_ids 2024-04-24 17:57:30 -07:00
Eric Dubé
331d9e7542
feat: allow apps to add a menubar via puter.js
* Begin work on menubar and dropdowns

* Improve menubar

* Fix pointer event behavior

* Fix labels

* Fix active button

* Eliminate flicker

* Update _default.js

---------

Co-authored-by: Nariman Jelveh <n.jelveh@gmail.com>
2024-04-22 20:38:16 -04:00
Sam Atkins
0aa5543397 Let AppConnection know if its target app uses the Puter SDK
Apps are not required to use the Puter SDK. If they don't, then we can
still launch them, close them, and listen to their close event, but are
unable to send messages to them.
2024-04-19 15:52:59 +01:00
Sam Atkins
dfdda4f3b9 Extract some helper functions for accessing a window/iframe by uuid 2024-04-19 15:52:59 +01:00
Sam Atkins
776b6831f3 Fix permission check for closeApp message
Firstly, I was missing an `async` here, which somehow still worked for
me then, but produced errors for me when I tried it today.

Then, actually await the promise.

Finally, actually check the target's parent is us, and not just that it
has the attribute!

I don't know what was going on in my head that day. 🤦‍♂️
2024-04-11 17:21:23 +01:00
Eric Dubé
92dc0a7671
Merge pull request #255 from AtkinsSJ/appconnection-close
Notify apps when a child app closes, and let them close their children manually
2024-04-09 21:31:48 -04:00
Sam Atkins
21c64e827b Add closeApp message
Sending a 'closeApp' message allows an app to close a target app, if it
has permission to do so. Currently, permission is granted if the
requesting app is the parent of the target app, or has godmode set.
2024-04-09 16:09:12 +01:00
Sam Atkins
c69a0abfa9 Extract a window_for_app_instance() helper function 2024-04-09 15:55:14 +01:00
Sam Atkins
068e620249 Add a message broadcasting service
A broadcast is a message sent to every running app that uses Puter.js.
Broadcasts have a name and a data payload, and are sent as a 'broadcast'
message.

Send a broadcast using:
`globalThis.services.get('broadcast').sendBroadcast(...)`

When doing so, you have the option to keep the broadcast message around,
so that it can be sent to any newly-launched apps. Sending another
broadcast with the same name will overwrite the previous one, so you
don't have to worry about flooding a new app with duplicates.
2024-04-09 10:44:51 +01:00
Sam Atkins
725cbf2e20 Add support for launching child apps
Calling `puter.ui.launchApp()` now treats the new app as a child of the
one that launched it.

A child app is given a `puter.parent_instance_id` URL param, containing
its parent's instance ID.

Previously, `launchApp()` would resolve as soon as the app was launched.
This commit changes that, so that it is notified after the child app
sends its READY event to Puter. This means that as soon as `launchApp()`
has completed, the child app is ready to receive messages. The downside
is that launching an app that does not include Puter.js will now not
cause a notification, so `await puter.ui.launchApp()` will not resolve
in that case.
2024-04-06 12:27:36 +01:00
Sam Atkins
c78927d5db Add messageToApp message
This lets apps communicate with each other, via Puter.

We probably want to limit this in some way, but for now, all apps are
allowed to send messages to any other apps.

The message is:
- `targetAppInstanceID`: The instance ID to send the message to
- `targetAppOrigin`: targetOrigin passed to postMessage(), in case we
  want to restrict which URL can receive the message
- `contents`: The message to send to the target
2024-04-05 16:38:12 +01:00
Sondre Njåstad
8e1dbc8189 Fix broken dialogboxes 2024-03-18 21:16:33 +01:00
Sondre Njåstad
592a30ca6d Translation WIP 2024-03-18 21:07:29 +01:00
Nariman Jelveh
a5584317c8 Allow apps to resize/reposition their windows
The resizing and repositioning is safe from abuse in that the window's position and size cannot cause it to escape the viewport. More could be done here, e.g. rate limit resize/repos. I will request rate-limiting in a separate issue.
2024-03-15 16:53:05 -07:00
Nariman Jelveh
e04da6d8b1 fix license formatting
Prefix lines with ' * ' and use the correct repo name.
2024-03-04 13:00:26 -08:00
Nariman Jelveh
17f0709a42 Add license headers
lame but necessary
2024-03-02 19:59:32 -08:00
Nariman Jelveh
fa42b0871e Initial commit 2024-03-02 18:39:14 -08:00