forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
1 lines (1 loc) · 1.96 KB
/
Copy pathmain.js
File metadata and controls
1 lines (1 loc) · 1.96 KB
1
define(function(require,exports,module){const serverSync=require("./serverSync"),newProject=require("./new-project"),defaultProjects=require("./default-projects"),AppInit=require("utils/AppInit"),Strings=require("strings"),Dialogs=require("widgets/Dialogs"),NotificationUI=require("widgets/NotificationUI"),DefaultDialogs=require("widgets/DefaultDialogs"),PERSIST_STORAGE_DIALOG_DELAY_SECS=6e4;function _showUnSupportedBrowserDialogue(){if(Phoenix.browser.isMobile||Phoenix.browser.isTablet)Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR,Strings.UNSUPPORTED_BROWSER_MOBILE_TITLE,Strings.UNSUPPORTED_BROWSER_MOBILE);else if(Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR,Strings.UNSUPPORTED_BROWSER_TITLE,Strings.UNSUPPORTED_BROWSER_MESSAGE),!("serviceWorker"in navigator))throw new Error("Service worker is not supported by the browser. Phcode cannot continue.")}function _detectUnSupportedBrowser(){Phoenix.isTestWindow||(Phoenix.isSupportedBrowser||_showUnSupportedBrowserDialogue(),(Phoenix.browser.desktop.isSafari||Phoenix.browser.mobile.isIos)&&NotificationUI.createToastFromTemplate(Strings.ATTENTION_SAFARI_USERS,Strings.ATTENTION_SAFARI_USERS_MESSAGE,{dismissOnClick:!1,toastStyle:NotificationUI.NOTIFICATION_STYLES_CSS_CLASS.DANGER}))}async function _persistBrowserStorage(){if(navigator.storage&&navigator.storage.persist){let isPersisted=await navigator.storage.persisted();console.log(`Browser Persisted storage granted?: ${isPersisted}`),setTimeout(async()=>{isPersisted||(console.log("Browser Persisted storage requesting"),isPersisted=await navigator.storage.persist(),console.log(`Browser Persisted storage granted?: ${isPersisted}`))},PERSIST_STORAGE_DIALOG_DELAY_SECS)}else Phoenix.isNativeApp||(console.error("Browser does not support storage persistence APIs"),_showUnSupportedBrowserDialogue())}AppInit.appReady(function(){Phoenix.isSpecRunnerWindow||(serverSync.init(),defaultProjects.init(),newProject.init(),_detectUnSupportedBrowser(),_persistBrowserStorage())})});