Skip to content

Commit

Permalink
chore: merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Clovis committed Jan 13, 2025
2 parents 4f10d75 + 2a85c9e commit bee828a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions elk/components/modal/DurationPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ watchEffect(() => {
const duration
= days.value * 24 * 60 * 60
+ hours.value * 60 * 60
+ minutes.value * 60
+ hours.value * 60 * 60
+ minutes.value * 60
if (duration <= 0) {
isValid.value = false
Expand Down
2 changes: 1 addition & 1 deletion elk/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"devDependencies": {
"@nuxt-themes/docus": "^1.15.1",
"nuxt": "^3.14.1592"
"nuxt": "^3.15.1"
}
}
2 changes: 1 addition & 1 deletion elk/modules/pwa/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function createI18n(): Promise<RequiredWebManifestEntry> {
id: '/',
start_url: '/',
orientation: 'natural',
display: 'standalone',
display: 'fullscreen',
display_override: ['window-controls-overlay'],
categories: ['social', 'social networking', 'news'],
icons: [
Expand Down
27 changes: 18 additions & 9 deletions elk/modules/pwa/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Buffer } from 'node:buffer'
import type { Plugin } from 'vite'
import type { VitePluginPWAAPI } from 'vite-plugin-pwa'
import type { ManifestOptions, VitePluginPWAAPI } from 'vite-plugin-pwa'
import type { VitePWANuxtOptions } from './types'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { dirname } from 'node:path'
Expand All @@ -13,6 +13,15 @@ import { createI18n, type LocalizedWebManifest, pwaLocales } from './i18n'

export * from './types'

interface PwaDevIcon {
src: string
type: string
}

interface ResolvedPwaDevIcon extends PwaDevIcon {
data: Promise<Buffer>
}

export default defineNuxtModule<VitePWANuxtOptions>({
meta: {
name: 'elk-pwa',
Expand All @@ -29,7 +38,7 @@ export default defineNuxtModule<VitePWANuxtOptions>({
const resolveVitePluginPWAAPI = (): VitePluginPWAAPI | undefined => {
return vitePwaClientPlugin?.api
}

let webmanifests: any | undefined
nuxt.options.appConfig = nuxt.options.appConfig || {}
nuxt.options.appConfig.pwaEnabled = !options.disable

Expand Down Expand Up @@ -70,11 +79,10 @@ export default defineNuxtModule<VitePWANuxtOptions>({
if (plugin)
throw new Error('Remove vite-plugin-pwa plugin from Vite Plugins entry in Nuxt config file!')

const webmanifest = await createI18n()
webmanifests = await createI18n()
const generateManifest = () => {
return JSON.stringify(webmanifest)
return JSON.stringify(webmanifests)
}

if (isClient) {
viteInlineConfig.plugins.push({
name: 'elk:pwa:locales:build',
Expand All @@ -98,7 +106,7 @@ export default defineNuxtModule<VitePWANuxtOptions>({
return next()

const match = url.match(localeMatcher)
const entry = match && webmanifest!
const entry = match && webmanifests
if (entry) {
res.statusCode = 200
res.setHeader('Content-Type', 'application/manifest+json')
Expand All @@ -107,7 +115,8 @@ export default defineNuxtModule<VitePWANuxtOptions>({
res.end()
return
}
res.end()

return next()
})
},
})
Expand All @@ -120,7 +129,7 @@ export default defineNuxtModule<VitePWANuxtOptions>({
})

if (nuxt.options.dev) {
const webManifesturl = `${nuxt.options.app.baseURL}${options.devOptions?.webManifestUrl ?? options.manifestFilename ?? 'manifest.webmanifest'}`
const webManifest = `${nuxt.options.app.baseURL}${options.devOptions?.webManifestUrl ?? options.manifestFilename ?? 'manifest.webmanifest'}`
const devSw = `${nuxt.options.app.baseURL}dev-sw.js?dev-sw`
const workbox = `${nuxt.options.app.baseURL}workbox-`
// @ts-expect-error just ignore
Expand All @@ -131,7 +140,7 @@ export default defineNuxtModule<VitePWANuxtOptions>({
if (isServer)
return

viteServer.middlewares.stack.push({ route: webManifesturl, handle: emptyHandle })
viteServer.middlewares.stack.push({ route: webManifest, handle: emptyHandle })
viteServer.middlewares.stack.push({ route: devSw, handle: emptyHandle })
})

Expand Down

0 comments on commit bee828a

Please sign in to comment.