@vite-pwa/nuxt 0.10.4 → 0.10.6
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.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { eventHandler } from 'h3';
|
|
4
|
+
|
|
5
|
+
function dev(swMap, resolvedSwMapFile, worboxMap, buildDir, baseURL) {
|
|
6
|
+
return eventHandler(async (event) => {
|
|
7
|
+
const url = event.path;
|
|
8
|
+
if (!url)
|
|
9
|
+
return;
|
|
10
|
+
const file = url === swMap ? resolvedSwMapFile : url.startsWith(worboxMap) && url.endsWith(".js.map") ? join(
|
|
11
|
+
buildDir,
|
|
12
|
+
"dev-sw-dist",
|
|
13
|
+
url.slice(baseURL.length)
|
|
14
|
+
) : void 0;
|
|
15
|
+
if (file) {
|
|
16
|
+
try {
|
|
17
|
+
await waitFor(() => fs.existsSync(file));
|
|
18
|
+
const map = fs.readFileSync(file, "utf-8");
|
|
19
|
+
event.headers.set("Content-Type", "application/json");
|
|
20
|
+
event.headers.set("Cache-Control", "public, max-age=0, must-revalidate");
|
|
21
|
+
event.headers.set("Content-Length", `${map.length}`);
|
|
22
|
+
event.node.res.end(map);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function waitFor(method, retries = 5) {
|
|
29
|
+
if (method())
|
|
30
|
+
return;
|
|
31
|
+
if (retries === 0)
|
|
32
|
+
throw new Error("Timeout in waitFor");
|
|
33
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
34
|
+
return waitFor(method, retries - 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { dev };
|
|
@@ -3,7 +3,7 @@ import { resolve, relative, basename } from 'node:path';
|
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { instructions } from '@vite-pwa/assets-generator/api/instructions';
|
|
5
5
|
import { loadConfig } from '@vite-pwa/assets-generator/config';
|
|
6
|
-
import { p as pwaIcons, g as generatePwaImageType } from '../shared/nuxt.
|
|
6
|
+
import { p as pwaIcons, g as generatePwaImageType } from '../shared/nuxt.56487db8.mjs';
|
|
7
7
|
import '@nuxt/kit';
|
|
8
8
|
import 'vite-plugin-pwa';
|
|
9
9
|
import 'node:crypto';
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addPluginTemplate, addTypeTemplate, addImports, createResolver, getNuxtVersion, addPlugin, addComponent, extendWebpackConfig, defineNuxtModule } from '@nuxt/kit';
|
|
1
|
+
import { addPluginTemplate, addTypeTemplate, addImports, createResolver, getNuxtVersion, addPlugin, addComponent, extendWebpackConfig, addDevServerHandler, defineNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { lstat, writeFile, mkdir } from 'node:fs/promises';
|
|
4
4
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
@@ -6,7 +6,7 @@ import { createHash } from 'node:crypto';
|
|
|
6
6
|
import { createReadStream } from 'node:fs';
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
|
|
9
|
-
const version = "0.10.
|
|
9
|
+
const version = "0.10.6";
|
|
10
10
|
|
|
11
11
|
function configurePWAOptions(nuxt3_8, options, nuxt, nitroConfig) {
|
|
12
12
|
if (!options.outDir) {
|
|
@@ -521,6 +521,25 @@ export const periodicSyncForUpdates = ${typeof client.periodicSyncForUpdates ===
|
|
|
521
521
|
viteServer.middlewares.stack.push({ route: suppressWarnings, handle: emptyHandle });
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
|
+
const { sourcemap = nuxt.options.sourcemap.client === true } = options.workbox ?? {};
|
|
525
|
+
if (sourcemap) {
|
|
526
|
+
const swMap = `${nuxt.options.app.baseURL}${options.filename ?? "sw.js"}.map`;
|
|
527
|
+
const resolvedSwMapFile = join(nuxt.options.buildDir, "dev-sw-dist", swMap);
|
|
528
|
+
const worboxMap = `${nuxt.options.app.baseURL}workbox-`;
|
|
529
|
+
addDevServerHandler({
|
|
530
|
+
route: "",
|
|
531
|
+
handler: await import('h3').then(({ defineLazyEventHandler }) => defineLazyEventHandler(async () => {
|
|
532
|
+
const { dev } = await import('../chunks/dev.mjs');
|
|
533
|
+
return dev(
|
|
534
|
+
swMap,
|
|
535
|
+
resolvedSwMapFile,
|
|
536
|
+
worboxMap,
|
|
537
|
+
nuxt.options.buildDir,
|
|
538
|
+
nuxt.options.app.baseURL
|
|
539
|
+
);
|
|
540
|
+
}))
|
|
541
|
+
});
|
|
542
|
+
}
|
|
524
543
|
}
|
|
525
544
|
} else {
|
|
526
545
|
if (!options.disable && options.registerWebManifestInRouteRules) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-pwa/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
5
|
-
"packageManager": "pnpm@9.
|
|
4
|
+
"version": "0.10.6",
|
|
5
|
+
"packageManager": "pnpm@9.12.3",
|
|
6
6
|
"description": "Zero-config PWA for Nuxt 3",
|
|
7
7
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dev:preview:generate": "nr dev:generate && serve playground/dist",
|
|
50
50
|
"release": "bumpp && npm publish",
|
|
51
51
|
"lint": "eslint .",
|
|
52
|
-
"lint
|
|
52
|
+
"lint:fix": "nr lint --fix",
|
|
53
53
|
"test:build:serve": "PORT=4173 node playground/.output/server/index.mjs",
|
|
54
54
|
"test:generate:serve": "PORT=4173 serve playground/dist",
|
|
55
55
|
"test:build": "nr dev:build && NUXT_ECOSYSTEM_CI=true TEST_BUILD=true vitest run && TEST_BUILD=true playwright test",
|
|
@@ -60,11 +60,19 @@
|
|
|
60
60
|
"test": "nr test:build && nr test:generate",
|
|
61
61
|
"test:with-build": "nr dev:prepare && nr prepack && nr test"
|
|
62
62
|
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@vite-pwa/assets-generator": "^0.2.6"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@vite-pwa/assets-generator": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
63
71
|
"dependencies": {
|
|
64
72
|
"@nuxt/kit": "^3.9.0",
|
|
65
73
|
"pathe": "^1.1.1",
|
|
66
74
|
"ufo": "^1.3.2",
|
|
67
|
-
"vite-plugin-pwa": ">=0.20.
|
|
75
|
+
"vite-plugin-pwa": ">=0.20.5 <1"
|
|
68
76
|
},
|
|
69
77
|
"devDependencies": {
|
|
70
78
|
"@antfu/eslint-config": "^0.43.1",
|
|
@@ -88,20 +96,13 @@
|
|
|
88
96
|
"resolutions": {
|
|
89
97
|
"@nuxt/kit": "^3.10.1"
|
|
90
98
|
},
|
|
91
|
-
"peerDependencies": {
|
|
92
|
-
"@vite-pwa/assets-generator": "^0.2.6"
|
|
93
|
-
},
|
|
94
|
-
"peerDependenciesMeta": {
|
|
95
|
-
"@vite-pwa/assets-generator": {
|
|
96
|
-
"optional": true
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
99
|
"build": {
|
|
100
100
|
"externals": [
|
|
101
101
|
"node:child_process",
|
|
102
102
|
"node:fs",
|
|
103
103
|
"consola",
|
|
104
104
|
"esbuild",
|
|
105
|
+
"h3",
|
|
105
106
|
"pathe",
|
|
106
107
|
"rollup",
|
|
107
108
|
"ufo",
|