fix: opt in to `import.meta.*` properties (#364)
This commit is contained in:
parent
2191f46214
commit
d9996e0d9d
|
|
@ -144,7 +144,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
showUploadModal: {
|
showUploadModal: {
|
||||||
handler (val) {
|
handler (val) {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
document.removeEventListener('paste', this.onUploadPasteEvent)
|
document.removeEventListener('paste', this.onUploadPasteEvent)
|
||||||
if (this.showUploadModal) {
|
if (this.showUploadModal) {
|
||||||
document.addEventListener('paste', this.onUploadPasteEvent)
|
document.addEventListener('paste', this.onUploadPasteEvent)
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,13 @@ const closeOnEscape = (e) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
document.addEventListener('keydown', closeOnEscape)
|
document.addEventListener('keydown', closeOnEscape)
|
||||||
initMotions()
|
initMotions()
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
document.removeEventListener('keydown', closeOnEscape)
|
document.removeEventListener('keydown', closeOnEscape)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
openChangelog() {
|
openChangelog() {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
window.Featurebase('manually_open_changelog_popup')
|
window.Featurebase('manually_open_changelog_popup')
|
||||||
},
|
},
|
||||||
async logout() {
|
async logout() {
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isEmbedPopup () {
|
isEmbedPopup () {
|
||||||
return process.client && window.location.href.includes('popup=true')
|
return import.meta.client && window.location.href.includes('popup=true')
|
||||||
},
|
},
|
||||||
theme () {
|
theme () {
|
||||||
return this.themes[this.themes.hasOwnProperty(this.form.theme) ? this.form.theme : 'default']
|
return this.themes[this.themes.hasOwnProperty(this.form.theme) ? this.form.theme : 'default']
|
||||||
|
|
@ -161,7 +161,7 @@ export default {
|
||||||
return this.$route.name === 'forms-slug'
|
return this.$route.name === 'forms-slug'
|
||||||
},
|
},
|
||||||
isHideTitle () {
|
isHideTitle () {
|
||||||
return this.form.hide_title || (process.client && window.location.href.includes('hide_title=true'))
|
return this.form.hide_title || (import.meta.client && window.location.href.includes('hide_title=true'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ export default {
|
||||||
|
|
||||||
mounted () {
|
mounted () {
|
||||||
this.initForm()
|
this.initForm()
|
||||||
if (process.client && window.location.href.includes('auto_submit=true')) {
|
if (import.meta.client && window.location.href.includes('auto_submit=true')) {
|
||||||
this.isAutoSubmit = true
|
this.isAutoSubmit = true
|
||||||
this.submitForm()
|
this.submitForm()
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +279,7 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.form.use_captcha && process.client) {
|
if (this.form.use_captcha && import.meta.client) {
|
||||||
this.dataForm['h-captcha-response'] = document.getElementsByName('h-captcha-response')[0].value
|
this.dataForm['h-captcha-response'] = document.getElementsByName('h-captcha-response')[0].value
|
||||||
this.$refs.hcaptcha.reset()
|
this.$refs.hcaptcha.reset()
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to error
|
// Scroll to error
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
const elements = document.getElementsByClassName('has-error')
|
const elements = document.getElementsByClassName('has-error')
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
window.scroll({
|
window.scroll({
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
|
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
copy(props.content)
|
copy(props.content)
|
||||||
if(props.isDraft){
|
if(props.isDraft){
|
||||||
useAlert().warning('Copied! But other people won\'t be able to see the form since it\'s currently in draft mode')
|
useAlert().warning('Copied! But other people won\'t be able to see the form since it\'s currently in draft mode')
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
parentPage() {
|
parentPage() {
|
||||||
if (process.server) {
|
if (import.meta.server) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return window
|
return window
|
||||||
|
|
@ -261,7 +261,7 @@ export default {
|
||||||
this.properties = columns
|
this.properties = columns
|
||||||
},
|
},
|
||||||
onChangeDisplayColumns() {
|
onChangeDisplayColumns() {
|
||||||
if (!process.client) return
|
if (!import.meta.client) return
|
||||||
window.localStorage.setItem('display-columns-formid-' + this.form.id, JSON.stringify(this.displayColumns))
|
window.localStorage.setItem('display-columns-formid-' + this.form.id, JSON.stringify(this.displayColumns))
|
||||||
this.properties = clonedeep(this.form.properties).concat(this.removed_properties).filter((field) => {
|
this.properties = clonedeep(this.form.properties).concat(this.removed_properties).filter((field) => {
|
||||||
return this.displayColumns[field.id] === true
|
return this.displayColumns[field.id] === true
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ const preFillUrl = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
copy(preFillUrl.value)
|
copy(preFillUrl.value)
|
||||||
useAlert().success('Copied!')
|
useAlert().success('Copied!')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
mouseDownHandler(e) {
|
mouseDownHandler(e) {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
// Get the current mouse position
|
// Get the current mouse position
|
||||||
this.x = e.clientX
|
this.x = e.clientX
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,12 +150,12 @@ const onClose = () => {
|
||||||
showEmbedFormAsPopupModal.value = false
|
showEmbedFormAsPopupModal.value = false
|
||||||
}
|
}
|
||||||
const copyToClipboard = () => {
|
const copyToClipboard = () => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
copy(embedPopupCode.value)
|
copy(embedPopupCode.value)
|
||||||
useAlert().success('Copied!')
|
useAlert().success('Copied!')
|
||||||
}
|
}
|
||||||
const removePreview = () => {
|
const removePreview = () => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
const oldP = document.head.querySelector('#nf-popup-preview')
|
const oldP = document.head.querySelector('#nf-popup-preview')
|
||||||
if (oldP) {
|
if (oldP) {
|
||||||
oldP.remove()
|
oldP.remove()
|
||||||
|
|
@ -166,7 +166,7 @@ const removePreview = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const previewPopup = (nfData) => {
|
const previewPopup = (nfData) => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
if (!showEmbedFormAsPopupModal.value) {
|
if (!showEmbedFormAsPopupModal.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
loadScript () {
|
loadScript () {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script')
|
||||||
script.setAttribute('src', 'https://testimonial.to/js/iframeResizer.min.js')
|
script.setAttribute('src', 'https://testimonial.to/js/iframeResizer.min.js')
|
||||||
document.head.appendChild(script)
|
document.head.appendChild(script)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const loadScript = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const setupForUser = () => {
|
const setupForUser = () => {
|
||||||
if (process.server || !user.value || !featureBaseOrganization ||isImpersonating.value) return
|
if (import.meta.server || !user.value || !featureBaseOrganization ||isImpersonating.value) return
|
||||||
window.Featurebase(
|
window.Featurebase(
|
||||||
"identify",
|
"identify",
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +49,7 @@ const setupForUser = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
|
|
||||||
// Setup base
|
// Setup base
|
||||||
if (!window.hasOwnProperty('Featurebase') || typeof window.Featurebase !== "function") {
|
if (!window.hasOwnProperty('Featurebase') || typeof window.Featurebase !== "function") {
|
||||||
|
|
@ -64,7 +64,7 @@ onMounted(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(user, (val) => {
|
watch(user, (val) => {
|
||||||
if (process.server || !val) return
|
if (import.meta.server || !val) return
|
||||||
|
|
||||||
loadScript()
|
loadScript()
|
||||||
setupForUser()
|
setupForUser()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const pendingSubmission = (form) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const set = (value) => {
|
const set = (value) => {
|
||||||
if (process.server || !enabled.value) return
|
if (import.meta.server || !enabled.value) return
|
||||||
useStorage(formPendingSubmissionKey.value).value = value === null ? value : JSON.stringify(value)
|
useStorage(formPendingSubmissionKey.value).value = value === null ? value : JSON.stringify(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ export const pendingSubmission = (form) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const get = (defaultValue = {}) => {
|
const get = (defaultValue = {}) => {
|
||||||
if (process.server || !enabled.value) return
|
if (import.meta.server || !enabled.value) return
|
||||||
const pendingSubmission = useStorage(formPendingSubmissionKey.value).value
|
const pendingSubmission = useStorage(formPendingSubmissionKey.value).value
|
||||||
return pendingSubmission ? JSON.parse(pendingSubmission) : defaultValue
|
return pendingSubmission ? JSON.parse(pendingSubmission) : defaultValue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
export const useCrisp = () => {
|
export const useCrisp = () => {
|
||||||
|
|
||||||
let crisp = process.client ? window.Crisp : null
|
let crisp = import.meta.client ? window.Crisp : null
|
||||||
|
|
||||||
function openChat() {
|
function openChat() {
|
||||||
if (!crisp) return
|
if (!crisp) return
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
export const useIsIframe = () => {
|
export const useIsIframe = () => {
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
return window.location !== window.parent.location || window.frameElement
|
return window.location !== window.parent.location || window.frameElement
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export function getOpnRequestsOptions(request, opts) {
|
||||||
opts.headers = {accept: 'application/json', ...opts.headers}
|
opts.headers = {accept: 'application/json', ...opts.headers}
|
||||||
|
|
||||||
// Authenticate requests coming from the server
|
// Authenticate requests coming from the server
|
||||||
if (process.server && config.apiSecret) {
|
if (import.meta.server && config.apiSecret) {
|
||||||
opts.headers['x-api-secret'] = config.apiSecret
|
opts.headers['x-api-secret'] = config.apiSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
let darkModeNodeParent = process.client ? document.body : null
|
let darkModeNodeParent = import.meta.client ? document.body : null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle form public pages dark mode and transparent mode
|
* Handle form public pages dark mode and transparent mode
|
||||||
*/
|
*/
|
||||||
export function handleDarkMode (darkMode, elem = null) {
|
export function handleDarkMode (darkMode, elem = null) {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
|
|
||||||
darkModeNodeParent = elem ?? document.body
|
darkModeNodeParent = elem ?? document.body
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ export function handleDarkMode (darkMode, elem = null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function darkModeEnabled() {
|
export function darkModeEnabled() {
|
||||||
if (process.server) return false
|
if (import.meta.server) return false
|
||||||
return computed(() => document.body.classList.contains('dark'))
|
return computed(() => document.body.classList.contains('dark'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ function handleDarkModeToggle (enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function disableDarkMode () {
|
export function disableDarkMode () {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
const body = document.body
|
const body = document.body
|
||||||
body.classList.remove('dark')
|
body.classList.remove('dark')
|
||||||
// Remove event listener
|
// Remove event listener
|
||||||
|
|
@ -44,7 +44,7 @@ export function disableDarkMode () {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleTransparentMode (transparentModeEnabled) {
|
export function handleTransparentMode (transparentModeEnabled) {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
if (!useIsIframe() || !transparentModeEnabled) return
|
if (!useIsIframe() || !transparentModeEnabled) return
|
||||||
|
|
||||||
const app = document.getElementById('app')
|
const app = document.getElementById('app')
|
||||||
|
|
@ -54,7 +54,7 @@ export function handleTransparentMode (transparentModeEnabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function focusOnFirstFormElement() {
|
export function focusOnFirstFormElement() {
|
||||||
if (process.server) return
|
if (import.meta.server) return
|
||||||
for (const ele of document.querySelectorAll('input,button,textarea,[role="button"]')) {
|
for (const ele of document.querySelectorAll('input,button,textarea,[role="button"]')) {
|
||||||
if (ele.offsetWidth !== 0 || ele.offsetHeight !== 0) {
|
if (ele.offsetWidth !== 0 || ele.offsetHeight !== 0) {
|
||||||
ele.focus()
|
ele.focus()
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ export const appUrl = (path = '/') => {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export const getHost = function () {
|
export const getHost = function () {
|
||||||
if (process.server) {
|
if (import.meta.server) {
|
||||||
return getDomain(useNuxtApp().ssrContext?.event.context.siteConfigNitroOrigin) || useNuxtApp().ssrContext?.event.node.req.headers.host
|
return getDomain(useNuxtApp().ssrContext?.event.context.siteConfigNitroOrigin) || useNuxtApp().ssrContext?.event.node.req.headers.host
|
||||||
} else {
|
} else {
|
||||||
return window.location.host
|
return window.location.host
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
export default defineNuxtRouteMiddleware((to, from) => {
|
export default defineNuxtRouteMiddleware((to, from) => {
|
||||||
if (process.client) return
|
if (import.meta.client) return
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
if (to.fullPath.startsWith('/api')) {
|
if (to.fullPath.startsWith('/api')) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
const customDomainHeaderValue = useRequestHeaders()[customDomainHeaderName]
|
const customDomainHeaderValue = useRequestHeaders()[customDomainHeaderName]
|
||||||
if (process.server && (!customDomainHeaderValue || customDomainHeaderValue !== getDomain(getHost()))) {
|
if (import.meta.server && (!customDomainHeaderValue || customDomainHeaderValue !== getDomain(getHost()))) {
|
||||||
return redirectToMainDomain( {
|
return redirectToMainDomain( {
|
||||||
reason: 'header_mismatch',
|
reason: 'header_mismatch',
|
||||||
customDomainHeaderValue: customDomainHeaderValue,
|
customDomainHeaderValue: customDomainHeaderValue,
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ onBeforeRouteLeave((to, from, next) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
window.onbeforeunload = () => {
|
window.onbeforeunload = () => {
|
||||||
if (isDirty()) {
|
if (isDirty()) {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ onMounted(() => {
|
||||||
handleDarkMode(form.value?.dark_mode)
|
handleDarkMode(form.value?.dark_mode)
|
||||||
handleTransparentMode(form.value?.transparent_background)
|
handleTransparentMode(form.value?.transparent_background)
|
||||||
|
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
if (form.value.custom_code) {
|
if (form.value.custom_code) {
|
||||||
const scriptEl = document.createRange().createContextualFragment(form.value.custom_code)
|
const scriptEl = document.createRange().createContextualFragment(form.value.custom_code)
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ watch(() => workspace, () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
window.onbeforeunload = () => {
|
window.onbeforeunload = () => {
|
||||||
if (isDirty()) {
|
if (isDirty()) {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import * as Sentry from "@sentry/vue";
|
||||||
|
|
||||||
function getSentryIntegrations() {
|
function getSentryIntegrations() {
|
||||||
// don't load on server
|
// don't load on server
|
||||||
if (!process.client) return [];
|
if (!import.meta.client) return [];
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const browserTracing = new Sentry.BrowserTracing({
|
const browserTracing = new Sentry.BrowserTracing({
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export const useAuthStore = defineStore('auth', {
|
||||||
},
|
},
|
||||||
|
|
||||||
setCookie(name, value) {
|
setCookie(name, value) {
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
useCookie(name).value = value
|
useCookie(name).value = value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue