@vite-pwa/nuxt-core 0.0.0 โ 2.0.1
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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/config.d.mts +5 -0
- package/dist/config.mjs +5 -0
- package/dist/context-types.d.mts +2 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +17 -0
- package/dist/shared-types.d.mts +2 -0
- package/dist/types-CZVs9I9K.d.mts +142 -0
- package/dist/types.d.mts +2 -0
- package/package.json +40 -7
- package/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
<p align='center'>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vite-pwa/.github/main/nuxt-core-hero-dark.svg" />
|
|
4
|
+
<img src="https://raw.githubusercontent.com/vite-pwa/.github/main/nuxt-core-hero.svg" alt="@vite-pwa/nuxt - Nuxt PWA Core Utilities logo">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
<h1 align='center'>
|
|
9
|
+
Nuxt PWA Core Utilities
|
|
10
|
+
</h1>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
Internal package used by <a href='https://github.com/vite-pwa/nuxt' target="_blank" rel="noopener noreferrer">@vite-pwa/nuxt</a>. Install `@vite-pwa/nuxt` instead.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align='center'>
|
|
17
|
+
<a href='https://npmx.dev/package/@vite-pwa/nuxt-core' target="_blank" rel="noopener noreferrer">
|
|
18
|
+
<img src='https://img.shields.io/npm/v/@vite-pwa/nuxt-core?color=33A6B8&label=' alt="NPM version">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://npmx.dev/package/@vite-pwa/nuxt-core" target="_blank" rel="noopener noreferrer">
|
|
21
|
+
<img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@vite-pwa/nuxt-core?color=476582&label=">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://unplugin-pwa.netlify.app/frameworks/nuxt" target="__blank">
|
|
24
|
+
<img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
|
|
25
|
+
</a>
|
|
26
|
+
<br>
|
|
27
|
+
<a href="https://github.com/vite-pwa/nuxt" target="__blank">
|
|
28
|
+
<img alt="GitHub stars" src="https://img.shields.io/github/stars/vite-pwa/nuxt?style=social">
|
|
29
|
+
</a>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<br>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
|
36
|
+
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg' alt="Anthony Fu SVG sponsors image"/>
|
|
37
|
+
</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
## ๐ Features
|
|
41
|
+
|
|
42
|
+
- ๐ [**Documentation & guides**](https://unplugin-pwa.netlify.app/)
|
|
43
|
+
- ๐ **Zero-Config**: sensible built-in default configs for common use cases
|
|
44
|
+
- ๐ฉ **Extensible**: expose the full ability to customize the behavior of the plugin
|
|
45
|
+
- ๐ฆพ **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
|
|
46
|
+
- ๐ **Offline Support**: generate service worker with offline support (via Workbox)
|
|
47
|
+
- โก **Fully tree shakable**: client virtual modules are strictly optimized for Dead Code Elimination.
|
|
48
|
+
- ๐ **Web Manifest**: auto-inject Web App Manifest and PWA assets seamlessly.
|
|
49
|
+
- ๐ฌ **Prompt for new content**: built-in support for Vanilla JavaScript, Vue 3, React, Svelte, SolidJS and Preact
|
|
50
|
+
- โ๏ธ **Stale-while-revalidate**: automatic reload when new content is available
|
|
51
|
+
- โจ **Static assets handling**: configure static assets for offline support
|
|
52
|
+
- ๐ **Development Support**: debug your custom service worker logic as you develop your application
|
|
53
|
+
- ๐ **Inspector**: visually inspect your resolved configuration, web manifest and service worker during development, via middleware or [DevFrame](https://github.com/devframes/devframe)
|
|
54
|
+
- ๐งฉ **Modular**: use the ready-to-use plugins or compose your own integration from the building blocks in `@unplugin-pwa/core` and `@unplugin-pwa/vite`
|
|
55
|
+
- ๐ฆ **Universal Bundlers**: native integration with Vite, Rolldown, Webpack (WIP), Rspack (WIP), and Rsbuild (WIP).
|
|
56
|
+
- ๐ ๏ธ **Meta-Frameworks**: seamless integration with [รฎles](https://github.com/ElMassimo/iles), [SvelteKit](https://github.com/sveltejs/kit), [VitePress](https://github.com/vuejs/vitepress), [Astro](https://github.com/withastro/astro), [Nuxt 3/4/5](https://github.com/nuxt/nuxt), [React Router](https://github.com/remix-run/react-router/), [TanStack](https://github.com/TanStack) and [Next](https://github.com/vercel/next.js/) (WIP).
|
|
57
|
+
- ๐ฅ **PWA Assets Generator**: generate all the PWA assets from a single command and a single source image
|
|
58
|
+
- ๐ **PWA Assets Integration**: serving, generating and injecting PWA Assets on the fly in your application
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
[MIT](https://github.com/vite-pwa/nuxt/blob/main/LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { r as PwaOptions } from "./types-CZVs9I9K.mjs";
|
|
2
|
+
import { VitePWAStrategy } from "@unplugin-pwa/core";
|
|
3
|
+
import { SWType } from "@vite-pwa/workbox-build/types";
|
|
4
|
+
export type NuxtExternalPWAOptions<UserStrategy extends VitePWAStrategy, T extends SWType> = Omit<PwaOptions<UserStrategy, T>, 'cwd' | 'path' | 'mergeOptions' | 'builder'>;
|
|
5
|
+
export declare function definePwaConfig<UserStrategy extends VitePWAStrategy, T extends SWType>(config: Partial<NuxtExternalPWAOptions<UserStrategy, T>>): Partial<NuxtExternalPWAOptions<UserStrategy, T>>;
|
package/dist/config.mjs
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { i as NuxtPWAContext } from "./types-CZVs9I9K.mjs";
|
|
2
|
+
import { VitePWAStrategy } from "@unplugin-pwa/core";
|
|
3
|
+
import { SWType } from "@vite-pwa/workbox-build/types";
|
|
4
|
+
import { Nuxt } from "@nuxt/schema";
|
|
5
|
+
import { Bundler } from "@unplugin-pwa/core/context-types";
|
|
6
|
+
export declare function loadPwaConfiguration<B extends Bundler, UserStrategy extends VitePWAStrategy, T extends SWType, NPWAC extends NuxtPWAContext<B, UserStrategy, T>>(ctx: NPWAC, nuxt: Nuxt): Promise<void>;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { resolvePwaConfiguration } from "@unplugin-pwa/core/config";
|
|
3
|
+
// src/index.ts
|
|
4
|
+
async function loadPwaConfiguration(ctx, nuxt) {
|
|
5
|
+
ctx.resolvedOptions = await resolvePwaConfiguration(ctx.consumerOptions, {
|
|
6
|
+
isDev: nuxt.options.dev,
|
|
7
|
+
isWrongInjectManifest: (swSrc) => {
|
|
8
|
+
const file = path.resolve(nuxt.options.rootDir, swSrc);
|
|
9
|
+
return !ctx.nuxt.publicDirs.some((dir) => isInsideDirectory(file, dir));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function isInsideDirectory(file, dir) {
|
|
14
|
+
const relative = path.relative(dir, file);
|
|
15
|
+
return !!relative && relative.split(/[\\/]/)[0] !== ".." && !path.isAbsolute(relative);
|
|
16
|
+
}
|
|
17
|
+
export { loadPwaConfiguration };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { VitePWAOptions, VitePWAStrategy } from "@unplugin-pwa/core";
|
|
2
|
+
import { SWType } from "@vite-pwa/workbox-build/types";
|
|
3
|
+
import { Nuxt } from "@nuxt/schema";
|
|
4
|
+
import { Bundler, PWAPluginContext } from "@unplugin-pwa/core/context-types";
|
|
5
|
+
interface NitroPWAOptions {
|
|
6
|
+
routeRules: Record<string, Record<string, any>>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Module path resolver, compatible with the one returned by `createResolver` from `@nuxt/kit`.
|
|
10
|
+
*/
|
|
11
|
+
interface NuxtPWAModuleResolver {
|
|
12
|
+
resolve: (...path: string[]) => string;
|
|
13
|
+
resolvePath: (path: string, options?: {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
alias?: Record<string, string>;
|
|
16
|
+
extensions?: string[];
|
|
17
|
+
}) => Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
interface PWAPluginContextOptions {
|
|
20
|
+
nuxtVersion: string;
|
|
21
|
+
nitroPWAOptions: NitroPWAOptions;
|
|
22
|
+
publicDirs: string[];
|
|
23
|
+
buildAssetsDir: string;
|
|
24
|
+
enableGlobPatterns?: boolean;
|
|
25
|
+
appManifestFolder?: string;
|
|
26
|
+
client: Required<ClientOptions>;
|
|
27
|
+
/**
|
|
28
|
+
* Called at `nitro:init` hook if builder requires adding some custom PWA options.
|
|
29
|
+
*/
|
|
30
|
+
preparePwaConfiguration?: () => Promise<void> | void;
|
|
31
|
+
/**
|
|
32
|
+
* Configure builder specific options, called at `build:before` hook.
|
|
33
|
+
*/
|
|
34
|
+
prepareNuxtOptions: () => Promise<void> | void;
|
|
35
|
+
/**
|
|
36
|
+
* The resolver using the module path.
|
|
37
|
+
*/
|
|
38
|
+
moduleResolver: NuxtPWAModuleResolver;
|
|
39
|
+
experimental?: PwaOptions<any, any>['experimental'];
|
|
40
|
+
/**
|
|
41
|
+
* Should add nitro route rules for the web manifest?.
|
|
42
|
+
*/
|
|
43
|
+
registerWebManifestInRouteRules?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Writes the plugin to disk: defaults to false (debug).
|
|
46
|
+
*/
|
|
47
|
+
writePlugin?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface NuxtPWAContext<B extends Bundler, UserStrategy extends VitePWAStrategy, T extends SWType> extends PWAPluginContext<B, UserStrategy, T> {
|
|
50
|
+
nuxt: PWAPluginContextOptions;
|
|
51
|
+
}
|
|
52
|
+
interface NuxtPWAContextBuilder {
|
|
53
|
+
build: <B extends Bundler, UserStrategy extends VitePWAStrategy, T extends SWType, PWAContext extends NuxtPWAContext<B, UserStrategy, T>>(nuxtVersion: string, buildAssetsDir: string, options: PwaOptions<UserStrategy, T>, nuxt: Nuxt, moduleResolver: NuxtPWAModuleResolver) => Promise<PWAContext>;
|
|
54
|
+
}
|
|
55
|
+
interface ClientOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Expose the plugin?.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
registerPlugin?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Registers a periodic sync for updates interval: value in seconds.
|
|
64
|
+
*/
|
|
65
|
+
periodicSyncForUpdates?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Will prevent showing native PWA install prompt.
|
|
68
|
+
*
|
|
69
|
+
* When set to true or non-empty string, the native PWA install prompt will be prevented.
|
|
70
|
+
*
|
|
71
|
+
* When set to a string, it will be used as the key in `localStorage` to prevent showing the native PWA install prompt widget.
|
|
72
|
+
*
|
|
73
|
+
* When set to true, the key used will be `vite-pwa:hide-install`.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
installPrompt?: boolean | string;
|
|
78
|
+
}
|
|
79
|
+
interface PwaOptions<UserStrategy extends VitePWAStrategy, T extends SWType> extends VitePWAOptions<UserStrategy, T> {
|
|
80
|
+
builder?: NuxtPWAContextBuilder;
|
|
81
|
+
/**
|
|
82
|
+
* Experimental features.
|
|
83
|
+
*/
|
|
84
|
+
experimental?: {
|
|
85
|
+
/**
|
|
86
|
+
* NOTE: this option will be ignored if using `build-sw` or `inject-manifest` strategies or when Nuxt experimental payload
|
|
87
|
+
* extraction is disabled.
|
|
88
|
+
*
|
|
89
|
+
* Enable custom runtime caching to resolve the payload.json requests with query parameters when offline:
|
|
90
|
+
* - Nuxt SSG will generate a payload.json file and will fetch it with a query parameter.
|
|
91
|
+
* - The service worker cannot resolve the payload.json request with query parameters, and you won't get the payload when offline.
|
|
92
|
+
*
|
|
93
|
+
* Enabling this option will add a custom runtime caching handler to the service worker to resolve the payload files
|
|
94
|
+
* with query parameters when offline: the runtime caching handler will redirect to the payload.json file without
|
|
95
|
+
* query parameters when the original request fails.
|
|
96
|
+
*
|
|
97
|
+
* The new `@vite-pwa/workbox-build` allows `urlManipulation` option for `precacheAndRoute` when using `generate-sw` strategy.
|
|
98
|
+
*
|
|
99
|
+
* If you're using `build-sw` or `inject-manifest` strategy, you can fix the issue in your custom service worker adding the
|
|
100
|
+
* following `urlManipulation` callback to the `precacheAndRouter` call:
|
|
101
|
+
* ```ts
|
|
102
|
+
* // self.__WB_MANIFEST is the default injection point
|
|
103
|
+
* precacheAndRoute(
|
|
104
|
+
* self.__WB_MANIFEST,
|
|
105
|
+
* {
|
|
106
|
+
* urlManipulation: ({ url }) => {
|
|
107
|
+
* const urls: URL[] = []
|
|
108
|
+
* if (url.pathname.endsWith('_payload.json')) {
|
|
109
|
+
* const newUrl = new URL(url.href)
|
|
110
|
+
* newUrl.search = ''
|
|
111
|
+
* urls.push(newUrl)
|
|
112
|
+
* }
|
|
113
|
+
* return urls
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
* )
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
enableGenerateSWPayloadQueryParams?: true;
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated use `enableGenerateSWPayloadQueryParams` instead.
|
|
122
|
+
*/
|
|
123
|
+
enableWorkboxPayloadQueryParams?: true;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Should add nitro route rules for the web manifest?.
|
|
127
|
+
*
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
registerWebManifestInRouteRules?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Writes the plugin to disk.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
writePlugin?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Options for plugin.
|
|
139
|
+
*/
|
|
140
|
+
client?: ClientOptions;
|
|
141
|
+
}
|
|
142
|
+
export { NitroPWAOptions as a, NuxtPWAContext as i, NuxtPWAContextBuilder as n, NuxtPWAModuleResolver as o, PwaOptions as r, PWAPluginContextOptions as s, ClientOptions as t };
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-pwa/nuxt-core",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "Nuxt PWA types and external configuration",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
10
7
|
"license": "MIT",
|
|
8
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
11
9
|
"homepage": "https://github.com/vite-pwa/nuxt#readme",
|
|
12
10
|
"repository": {
|
|
13
11
|
"type": "git",
|
|
@@ -21,5 +19,40 @@
|
|
|
21
19
|
"workbox",
|
|
22
20
|
"unplugin-pwa",
|
|
23
21
|
"configuration"
|
|
24
|
-
]
|
|
25
|
-
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./dist/index.mjs",
|
|
26
|
+
"./config": "./dist/config.mjs",
|
|
27
|
+
"./context-types": {
|
|
28
|
+
"types": "./dist/context-types.d.mts"
|
|
29
|
+
},
|
|
30
|
+
"./shared-types": {
|
|
31
|
+
"types": "./dist/shared-types.d.mts"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"types": "./dist/types.d.mts"
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"types": "./dist/index.d.mts",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@unplugin-pwa/core": "^0.0.6",
|
|
44
|
+
"@vite-pwa/workbox-build": "^8.0.15"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@nuxt/schema": "^4.6.4",
|
|
48
|
+
"rolldown": "~1.2.18"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsdown",
|
|
56
|
+
"test:typecheck": "tsc --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|