mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
Keep track of app_instance_id
s
This commit is contained in:
parent
c21c16026b
commit
25eea41f60
@ -112,10 +112,11 @@ window.puter = (function() {
|
||||
// The default APIOrigin is https://api.puter.com. However, if the URL contains a `puter.api_origin` query parameter,
|
||||
// then that value is used as the APIOrigin. If the URL contains a `puter.domain` query parameter, then the APIOrigin
|
||||
// is constructed as `https://api.<puter.domain>`.
|
||||
// This should only be done when the SDK is running in 'app' mode.
|
||||
this.APIOrigin = this.defaultAPIOrigin;
|
||||
if(URLParams.has('puter.api_origin')){
|
||||
if(URLParams.has('puter.api_origin') && this.env === 'app'){
|
||||
this.APIOrigin = decodeURIComponent(URLParams.get('puter.api_origin'));
|
||||
}else if(URLParams.has('puter.domain')){
|
||||
}else if(URLParams.has('puter.domain') && this.env === 'app'){
|
||||
this.APIOrigin = 'https://api.' + URLParams.get('puter.domain');
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,10 @@ window.addEventListener('message', async (event) => {
|
||||
|
||||
// `appInstanceID` is required
|
||||
if(!event.data.appInstanceID){
|
||||
console.log(`appInstanceID is needed`);
|
||||
console.error(`appInstanceID is needed`);
|
||||
return;
|
||||
}else if(!window.app_instance_ids.has(event.data.appInstanceID)){
|
||||
console.error(`appInstanceID is invalid`);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,7 +168,6 @@ window.addEventListener('message', async (event) => {
|
||||
center: event.data.options.center,
|
||||
show_in_taskbar: event.data.options.show_in_taskbar,
|
||||
iframe_srcdoc: event.data.options.content,
|
||||
iframe_url: event.data.options.url,
|
||||
parent_uuid: event.data.appInstanceID,
|
||||
})
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ window.window_nav_history = {};
|
||||
window.window_nav_history_current_position = {};
|
||||
window.progress_tracker = [];
|
||||
window.upload_item_global_id = 0;
|
||||
window.app_instance_ids = new Set();
|
||||
|
||||
window.download_progress = [];
|
||||
window.download_item_global_id = 0;
|
||||
|
@ -1762,6 +1762,10 @@ window.launch_app = async (options)=>{
|
||||
// ...and finally append utm_source=puter.com to the URL
|
||||
iframe_url.searchParams.append('utm_source', 'puter.com');
|
||||
|
||||
// register app_instance_uid
|
||||
window.app_instance_ids.add(uuid);
|
||||
|
||||
// open window
|
||||
el_win = UIWindow({
|
||||
element_uuid: uuid,
|
||||
title: title,
|
||||
|
Loading…
Reference in New Issue
Block a user