chore: CDN related changes (#23882)

Co-authored-by: Satish Gandham <hello@satishgandham.com>
This commit is contained in:
Satish Gandham 2023-06-02 11:38:45 +05:30 committed by GitHub
parent 54a62ea99a
commit 1ea35a6c04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 32 deletions

View File

@ -15,6 +15,37 @@
transition: all ease-in 0.3s;
}
</style>
<script>
// '' (empty strings), 'false' are falsy
// could return either boolean or string based on value
const parseConfig = (config) => {
if (config.indexOf("__") === 0 || config.indexOf("$") === 0 || config.indexOf("%") === 0)
return "";
const result = config.trim();
if (result.toLowerCase() === "false" || result === "") {
return false;
} else if (result.toLowerCase() === "true") {
return true;
}
return result;
};
const CLOUD_HOSTING = parseConfig("__APPSMITH_CLOUD_HOSTING__");
const ZIPY_KEY = parseConfig("__APPSMITH_ZIPY_SDK_KEY__");
if (CLOUD_HOSTING && ZIPY_KEY) {
const script = document.createElement('script');
script.crossOrigin = "anonymous";
script.defer = true;
script.src = "https://cdn.zipy.ai/sdk/v1.0/zipy.min.umd.js";
script.onload = () => {
window.zipy && window.zipy.init(ZIPY_KEY);
}
const head = document.getElementsByTagName('head')[0];
head && head.appendChild(script);
}
</script>
<%=
(function () {
// This code emits additional `link rel="preload"` tags for edit.html and view.html.
@ -49,35 +80,6 @@
})()
%>
<script>
// '' (empty strings), 'false' are falsy
// could return either boolean or string based on value
const parseConfig = (config) => {
if (config.indexOf("__") === 0 || config.indexOf("$") === 0 || config.indexOf("%") === 0)
return "";
const result = config.trim();
if (result.toLowerCase() === "false" || result === "") {
return false;
} else if (result.toLowerCase() === "true") {
return true;
}
return result;
}
const CLOUD_HOSTING = parseConfig("__APPSMITH_CLOUD_HOSTING__");
const ZIPY_KEY = parseConfig("__APPSMITH_ZIPY_SDK_KEY__");
if (CLOUD_HOSTING && ZIPY_KEY) {
const script = document.createElement('script');
script.crossOrigin = "anonymous";
script.defer = true;
script.src = "https://cdn.zipy.ai/sdk/v1.0/zipy.min.umd.js";
script.onload = () => {
window.zipy && window.zipy.init(ZIPY_KEY);
}
const head = document.getElementsByTagName('head')[0];
head && head.appendChild(script);
}
// This function is triggered on load of google apis javascript library
// Even though the script is loaded asynchronously, in case of firefox run on windows
// The gapi script is getting loaded even before the last script of index.html
@ -221,4 +223,4 @@
</script>
</body>
</html>
</html>

View File

@ -19,9 +19,10 @@ import GlobalStyles from "globalStyles";
// enable autofreeze only in development
import { setAutoFreeze } from "immer";
import AppErrorBoundary from "./AppErrorBoundry";
const shouldAutoFreeze = process.env.NODE_ENV === "development";
setAutoFreeze(shouldAutoFreeze);
const shouldAutoFreeze = process.env.NODE_ENV === "development";
setAutoFreeze(shouldAutoFreeze);
runSagaMiddleware();
appInitializer();