@dargmuesli/nuxt-vio 20.1.5 → 21.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/components/vio/button/VioButtonShare.vue +9 -5
- package/app/composables/dateTime.ts +42 -8
- package/nuxt.config.ts +12 -6
- package/package.json +4 -6
- package/server/utils/constants.ts +1 -3
- package/server/utils/site.ts +1 -1
- package/shared/utils/constants.ts +2 -2
- package/shared/utils/nuxt.ts +4 -5
- package/node.ts +0 -2
- package/shared/utils/text.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span v-if="url" class="flex items-center gap-2">
|
|
3
3
|
<slot />
|
|
4
|
-
<VioButtonColored :aria-label="t('share')" @click="
|
|
4
|
+
<VioButtonColored :aria-label="t('share')" @click="copy2(url)">
|
|
5
5
|
<template #prefix>
|
|
6
6
|
<VioIconShare />
|
|
7
7
|
</template>
|
|
@@ -19,17 +19,21 @@ interface Props {
|
|
|
19
19
|
withDefaults(defineProps<Props>(), {})
|
|
20
20
|
|
|
21
21
|
const { t } = useI18n()
|
|
22
|
+
const { copy } = useCopy()
|
|
23
|
+
const alertError = useAlertError()
|
|
22
24
|
|
|
23
25
|
// methods
|
|
24
|
-
const
|
|
26
|
+
const copy2 = async (string: string) => {
|
|
25
27
|
if (typeof window === 'undefined') return
|
|
26
28
|
|
|
27
29
|
try {
|
|
28
|
-
await
|
|
30
|
+
await copy(string)
|
|
29
31
|
toast.success(t('donationUrlCopySuccess'))
|
|
30
32
|
} catch (error: unknown) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
alertError({
|
|
34
|
+
...(error instanceof Error ? { error } : {}),
|
|
35
|
+
messageI18n: t('donationUrlCopyError'),
|
|
36
|
+
})
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
</script>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useNow as useNowVueUse, syncRef } from '@vueuse/core'
|
|
2
|
+
|
|
1
3
|
export const useTimeZone = () =>
|
|
2
4
|
useNuxtApp().ssrContext?.event.context.$timeZone ||
|
|
3
5
|
useCookie(TIMEZONE_COOKIE_NAME, {
|
|
@@ -9,15 +11,47 @@ export const useTimeZone = () =>
|
|
|
9
11
|
? Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
10
12
|
: undefined)
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
// TODO: evaluate custom scheduler (https://github.com/vueuse/vueuse/pull/5129)
|
|
15
|
+
export const useNow = (options?: { live?: boolean }) => {
|
|
16
|
+
const { live = true } = options || {}
|
|
17
|
+
|
|
18
|
+
const nowState = useState(STATE_KEY_NOW, () => new Date())
|
|
19
|
+
|
|
20
|
+
if (live) {
|
|
21
|
+
const now = useNowVueUse()
|
|
22
|
+
syncRef(now, nowState, { direction: 'ltr', immediate: false })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return nowState
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// TODO: import from vueuse once reactive locale can be passed in (no issue or PR created yet)
|
|
29
|
+
export const useTimeAgoIntl = (options: {
|
|
30
|
+
live?: boolean
|
|
31
|
+
to: MaybeRef<Date>
|
|
32
|
+
}) => {
|
|
33
|
+
const { live = true, to } = options
|
|
34
|
+
|
|
35
|
+
const { locale } = useI18n({ useScope: 'global' })
|
|
36
|
+
const now = useNow({ live })
|
|
37
|
+
|
|
38
|
+
const formatter = computed(
|
|
39
|
+
() =>
|
|
40
|
+
new Intl.RelativeTimeFormat(locale.value, {
|
|
41
|
+
numeric: 'auto',
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const toAsRef = toRef(to)
|
|
46
|
+
const fromTo = computed(() =>
|
|
47
|
+
getFromTo(now.value, toAsRef.value, formatter.value),
|
|
48
|
+
)
|
|
13
49
|
|
|
14
|
-
|
|
15
|
-
const { locale } = useI18n()
|
|
16
|
-
const now = useNow()
|
|
50
|
+
const fromToState = useState(STATE_KEY_FROM_TO, () => fromTo)
|
|
17
51
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
52
|
+
if (live) {
|
|
53
|
+
syncRef(fromTo, fromToState, { direction: 'ltr', immediate: false })
|
|
54
|
+
}
|
|
21
55
|
|
|
22
|
-
return
|
|
56
|
+
return fromToState
|
|
23
57
|
}
|
package/nuxt.config.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url'
|
|
2
|
-
import { dirname, join } from 'node:path'
|
|
3
|
-
|
|
4
1
|
import tailwindcss from '@tailwindcss/vite'
|
|
2
|
+
import { createResolver } from 'nuxt/kit'
|
|
5
3
|
import { defu } from 'defu'
|
|
6
4
|
|
|
7
5
|
import {
|
|
@@ -13,7 +11,7 @@ import {
|
|
|
13
11
|
} from './shared/utils/constants'
|
|
14
12
|
import { VIO_NUXT_BASE_CONFIG } from './shared/utils/nuxt'
|
|
15
13
|
|
|
16
|
-
const
|
|
14
|
+
const { resolve } = createResolver(import.meta.url)
|
|
17
15
|
|
|
18
16
|
export default defineNuxtConfig(
|
|
19
17
|
defu(
|
|
@@ -29,7 +27,7 @@ export default defineNuxtConfig(
|
|
|
29
27
|
},
|
|
30
28
|
},
|
|
31
29
|
compatibilityDate: '2024-04-03',
|
|
32
|
-
...(process.env.
|
|
30
|
+
...(process.env.NUXT_PUBLIC_I18N_BASE_URL
|
|
33
31
|
? {}
|
|
34
32
|
: {
|
|
35
33
|
devServer: {
|
|
@@ -114,6 +112,13 @@ export default defineNuxtConfig(
|
|
|
114
112
|
},
|
|
115
113
|
typescript: {
|
|
116
114
|
tsConfig: {
|
|
115
|
+
nodeTsConfig: {
|
|
116
|
+
include: [
|
|
117
|
+
resolve('../.config'),
|
|
118
|
+
resolve('../node'),
|
|
119
|
+
// resolve('../sentry.server.config.ts'),
|
|
120
|
+
],
|
|
121
|
+
},
|
|
117
122
|
vueCompilerOptions: {
|
|
118
123
|
htmlAttributes: [], // https://github.com/johnsoncodehk/volar/issues/1970#issuecomment-1276994634
|
|
119
124
|
},
|
|
@@ -273,13 +278,14 @@ export default defineNuxtConfig(
|
|
|
273
278
|
},
|
|
274
279
|
shadcn: {
|
|
275
280
|
prefix: '',
|
|
276
|
-
componentDir:
|
|
281
|
+
componentDir: resolve('./app/components/scn'),
|
|
277
282
|
},
|
|
278
283
|
site: {
|
|
279
284
|
url: SITE_URL,
|
|
280
285
|
},
|
|
281
286
|
sitemap: {
|
|
282
287
|
credits: false,
|
|
288
|
+
zeroRuntime: true,
|
|
283
289
|
},
|
|
284
290
|
|
|
285
291
|
// environments
|
package/package.json
CHANGED
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@vuelidate/validators": "2.0.4",
|
|
24
24
|
"@vueuse/core": "14.1.0",
|
|
25
25
|
"class-variance-authority": "0.7.1",
|
|
26
|
-
"clipboardy": "5.0.2",
|
|
27
26
|
"clsx": "2.1.1",
|
|
28
27
|
"eslint": "9.39.2",
|
|
29
28
|
"eslint-config-prettier": "10.1.8",
|
|
@@ -95,9 +94,8 @@
|
|
|
95
94
|
},
|
|
96
95
|
"scripts": {
|
|
97
96
|
"build": "pnpm run build:node",
|
|
98
|
-
"build:node": "nuxt build playground",
|
|
99
|
-
"build:static": "nuxt generate playground",
|
|
100
|
-
"build:static:test": "SITE_URL=https://localhost:3002 pnpm run build:static",
|
|
97
|
+
"build:node": "NUXT_PUBLIC_I18N_BASE_URL=https://localhost:3001 nuxt build playground",
|
|
98
|
+
"build:static": "NUXT_PUBLIC_I18N_BASE_URL=https://localhost:3002 nuxt generate playground",
|
|
101
99
|
"dev": "pnpm run start:dev",
|
|
102
100
|
"generate": "pnpm run build:static",
|
|
103
101
|
"lint": "pnpm run lint:js && pnpm run lint:ts && pnpm run lint:style",
|
|
@@ -110,9 +108,9 @@
|
|
|
110
108
|
"preview": "nuxt preview playground",
|
|
111
109
|
"start": "pnpm run start:node",
|
|
112
110
|
"start:dev": "nuxt dev playground",
|
|
113
|
-
"start:node": "node
|
|
111
|
+
"start:node": "node scripts/server.mjs",
|
|
114
112
|
"start:static": "serve playground/.output/public --ssl-cert ./.config/certificates/ssl.crt --ssl-key ./.config/certificates/ssl.key"
|
|
115
113
|
},
|
|
116
114
|
"type": "module",
|
|
117
|
-
"version": "
|
|
115
|
+
"version": "21.0.0-beta.2"
|
|
118
116
|
}
|
package/server/utils/site.ts
CHANGED
|
@@ -5,8 +5,7 @@ import { defu } from 'defu'
|
|
|
5
5
|
export const VIO_SITE_NAME = 'Vio'
|
|
6
6
|
|
|
7
7
|
export const SITE_URL =
|
|
8
|
-
process.env.
|
|
9
|
-
process.env.NUXT_PUBLIC_SITE_URL ||
|
|
8
|
+
process.env.NUXT_PUBLIC_I18N_BASE_URL ||
|
|
10
9
|
`https://${process.env.HOST || 'localhost'}:${process.env.PORT || '3000'}`
|
|
11
10
|
export const CACHE_VERSION = 'zeMtipb6C9'
|
|
12
11
|
export const COOKIE_CONTROL_CONSENT_COOKIE_NAME =
|
|
@@ -157,6 +156,7 @@ export const POLYFILLS = [
|
|
|
157
156
|
export const REGEX_UUID =
|
|
158
157
|
/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
|
|
159
158
|
export const STATE_KEY_NOW = 'dateTimeNow'
|
|
159
|
+
export const STATE_KEY_FROM_TO = 'dateTimeFromTo'
|
|
160
160
|
export const TESTING_COOKIE_NAME = 'vio_is-testing'
|
|
161
161
|
export const TIMEZONE_COOKIE_NAME = [COOKIE_PREFIX, 'tz'].join(COOKIE_SEPARATOR)
|
|
162
162
|
export const TIMEZONE_HEADER_KEY = `X-${VIO_SITE_NAME}-Timezone`
|
package/shared/utils/nuxt.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { defineNuxtConfig } from 'nuxt/config'
|
|
2
2
|
|
|
3
|
+
import { IS_IN_FRONTEND_DEVELOPMENT } from '../../node'
|
|
3
4
|
import { I18N_MODULE_CONFIG } from './constants'
|
|
4
5
|
|
|
5
6
|
export const VIO_NUXT_BASE_CONFIG = ({
|
|
@@ -20,11 +21,9 @@ export const VIO_NUXT_BASE_CONFIG = ({
|
|
|
20
21
|
vio: {
|
|
21
22
|
...(stagingHost
|
|
22
23
|
? {
|
|
23
|
-
stagingHost:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
? stagingHost
|
|
27
|
-
: undefined,
|
|
24
|
+
stagingHost: IS_IN_FRONTEND_DEVELOPMENT
|
|
25
|
+
? stagingHost
|
|
26
|
+
: undefined,
|
|
28
27
|
}
|
|
29
28
|
: {}),
|
|
30
29
|
},
|
package/node.ts
DELETED
package/shared/utils/text.ts
DELETED