nuxt-skew-protection 0.2.3 → 0.3.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.md CHANGED
@@ -1,51 +1,5 @@
1
- Dual License
1
+ ## License
2
2
 
3
- This software is available under two different licenses:
3
+ Nuxt Skew Protection requires a [Nuxt SEO Pro license](https://nuxtseo.com/pricing) for all use, including development and production environments.
4
4
 
5
- 1. MIT License (for open source and non-commercial projects)
6
- 2. Commercial License (for commercial projects)
7
-
8
- ---
9
-
10
- ## MIT License (Open Source & Non-Commercial Use)
11
-
12
- Copyright (c) 2025 Harlan Wilton
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- This license applies only to:
22
- - Open source projects with source code publicly available under an OSI-approved license
23
- - Non-commercial projects (personal projects, educational use, non-profit organizations)
24
-
25
- The above copyright notice and this permission notice shall be included in all
26
- copies or substantial portions of the Software.
27
-
28
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
- SOFTWARE.
35
-
36
- ---
37
-
38
- ## Commercial License
39
-
40
- If you want to use this software for commercial projects, you must obtain a
41
- Nuxt SEO Pro license.
42
-
43
- Commercial use includes:
44
- - Use in commercial products or services
45
- - Use in projects generating revenue
46
- - Use in closed-source commercial applications
47
-
48
- For commercial licensing, please visit: https://nuxtseo.com/pricing
49
-
50
- With a Nuxt SEO Pro license, your source code remains proprietary and you are
51
- not required to open source your application.
5
+ Your source code remains proprietary - no open-source requirements.
package/README.md CHANGED
@@ -2,40 +2,28 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
- [![License][license-src]][license-href]
6
5
  [![Nuxt][nuxt-src]][nuxt-href]
7
6
 
8
- <p align="center">
9
- <table>
10
- <tbody>
11
- <td align="center">
12
- <sub>Made possible by my <a href="https://github.com/sponsors/harlan-zw">Sponsor Program 💖</a><br> Follow me <a href="https://twitter.com/harlan_zw">@harlan_zw</a> 🐦 • Join <a href="https://discord.gg/275MBUBvgP">Discord</a> for help</sub><br>
13
- </td>
14
- </tbody>
15
- </table>
16
- </p>
7
+ > Solve Nuxt version skew with persistent assets and instant updates.
17
8
 
18
9
  ## Why Nuxt Skew Protection?
19
10
 
20
- Congrats on shipping that latest release! Unfortunately, many of your users are going to be using the previous version of your app
21
- for hours to days afterwards until they refresh.
22
-
23
- Finally fixed that SEO issue? Great, but crawlers will often hit your site and request build chunks that no longer exist, leading
24
- to 500 errors and broken indexes.
11
+ **Version skew** is a mismatch between your deployed build and the chunks running in user browsers and crawler sessions. It can lead to several issues:
25
12
 
26
- You've just been "skewed"! Skew is the version difference between what your users are running and what is currently deployed.
13
+ - 🕷️ **Crawlers 404 on stale chunks** - Googlebot requests `_nuxt/builds/abc123.js` which no longer exists post-deploy, logging 500s and potentially impacting indexing
14
+ - 💥 **ChunkLoadError in production** - Users mid-session get `Failed to fetch dynamically imported module` when navigating to routes with invalidated chunks
15
+ - 🔄 **Delayed rollout** - Your latest release sits unloaded until users hard refresh, sometimes hours or days later
27
16
 
28
- While Nuxt helps us by hard-reloading on navigation when it detects a new release, it's often not enough to ensure a smooth experience for all users
29
- and crawlers. Just check out one of Nuxt's top commented [issues](https://github.com/nuxt/nuxt/issues/29624).
17
+ Nuxt's built-in behavior (hard-reload when a new deployment is detected) helps, but in many cases it's [not enough](https://github.com/nuxt/nuxt/issues/29624).
30
18
 
31
- Nuxt Skew Protection aims to solve skews by providing better UX on top of app updates as well as long-lived build assets to avoid breaking crawlers and old sessions.
19
+ Nuxt Skew Protection solves this with proactive update prompts and persistent build assets across deploys.
32
20
 
33
21
  ## Features
34
22
 
35
- - ⚡ **Instantly Adopted Releases** - Zero-config Real-time notifications to users when a new version is deployed.
36
- - 🎯 **Intelligent User Notifications** - Avoid spamming your users by only sending update notifications when their chunks are outdated. No annoying popups for unrelated updates.
37
- - 📦 **Long-lived Build Assets** - Avoid breaking crawlers or old sessions with previous build assets remain accessible.
38
- - 🎨 **Headless UI** - Ship it quicker with a headless notification component that works perfectly with Nuxt UI.
23
+ - 🕷️ **Persistent Build Assets** - Previous build artifacts remain accessible, so crawlers and stale sessions never hit dead ends.
24
+ - ⚡ **Instant Update Prompts** - Zero-config real-time notifications on deploy. Users adopt your latest build immediately.
25
+ - 🎯 **Chunk-Aware Targeting** - Notifications fire only when the user's loaded chunks are invalidated. No noise for unrelated updates.
26
+ - 🎨 **Headless UI** - Drop-in notification component with first-class Nuxt UI support.
39
27
 
40
28
  ## Installation
41
29
 
@@ -45,8 +33,6 @@ Install `nuxt-skew-protection` dependency to your project:
45
33
  npx nuxi@latest module add nuxt-skew-protection
46
34
  ```
47
35
 
48
- Nuxt Skew Protection is a [Nuxt SEO Pro](https://nuxtseo.com/pricing) module, **please see the [licensing](#license) for commercial use**.
49
-
50
36
  ## Documentation
51
37
 
52
38
  [📖 Read the full documentation](https://nuxtseo.com/skew-protection) for more information.
@@ -61,22 +47,7 @@ Nuxt Skew Protection is a [Nuxt SEO Pro](https://nuxtseo.com/pricing) module, **
61
47
 
62
48
  ## License
63
49
 
64
- #### Commercial License
65
-
66
- Nuxt Skew Protection requires a paid license when using it for commercial projects. With this license, your source code remains proprietary.
67
-
68
- See the [Nuxt SEO Pro](https://nuxtseo.com/pricing) to purchase or contact me at harlan@harlanzw.com.
69
-
70
- Commercial use includes:
71
- - Use in commercial products or services
72
- - Use in projects generating revenue
73
- - Use in closed-source commercial applications
74
-
75
- #### Open Source & Non-Commercial License
76
-
77
- If you are creating an open source project or using this for non-commercial purposes (personal projects, educational use, non-profit organizations), you may use this project under the terms of the MIT License.
78
-
79
- See [LICENSE](https://github.com/harlan-zw/nuxt-skew-protection/blob/main/LICENSE) for full details.
50
+ Nuxt Skew Protection requires a [Nuxt SEO Pro license](https://nuxtseo.com/pro), see [LICENSE](https://github.com/harlan-zw/nuxt-skew-protection/blob/main/LICENSE) for full details.
80
51
 
81
52
  <!-- Badges -->
82
53
  [npm-version-src]: https://img.shields.io/npm/v/nuxt-skew-protection/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
@@ -85,8 +56,5 @@ See [LICENSE](https://github.com/harlan-zw/nuxt-skew-protection/blob/main/LICENS
85
56
  [npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-skew-protection.svg?style=flat&colorA=18181B&colorB=28CF8D
86
57
  [npm-downloads-href]: https://npmjs.com/package/nuxt-skew-protection
87
58
 
88
- [license-src]: https://img.shields.io/github/license/harlan-zw/nuxt-skew-protection.svg?style=flat&colorA=18181B&colorB=28CF8D
89
- [license-href]: https://github.com/harlan-zw/nuxt-skew-protection/blob/main/LICENSE.md
90
-
91
- [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
59
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt
92
60
  [nuxt-href]: https://nuxt.com
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { CookieSerializeOptions } from 'cookie-es';
3
- import { NuxtSkewProtectionRuntimeConfig } from '/home/runner/work/nuxt-skew-protection/nuxt-skew-protection/dist/runtime/types.js';
3
+ import { NuxtSkewProtectionRuntimeConfig } from '../dist/runtime/types.js';
4
4
 
5
5
  interface ModuleOptions {
6
6
  /**
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "skewProtection",
7
- "version": "0.2.3",
7
+ "version": "0.3.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import { writeFileSync, unlinkSync, existsSync, readFileSync, promises } from 'node:fs';
2
- import { useNuxt, tryUseNuxt, useLogger, defineNuxtModule, createResolver, addTypeTemplate, addComponent, addImports, addPlugin, addServerHandler } from '@nuxt/kit';
2
+ import { useNuxt, tryUseNuxt, useLogger, defineNuxtModule, createResolver, hasNuxtModule, addTypeTemplate, addComponent, addImports, addPlugin, addServerHandler } from '@nuxt/kit';
3
+ import { colors } from 'consola/utils';
4
+ import { readPackageJSON } from 'pkg-types';
3
5
  import { provider, env } from 'std-env';
4
6
  import { join } from 'node:path';
5
7
  import { tmpdir } from 'node:os';
6
8
  import { x } from 'tinyexec';
7
9
  import { defineDriver, createStorage } from 'unstorage';
8
- import { colors } from 'consola/utils';
9
10
  import { join as join$1, dirname } from 'pathe';
10
11
 
11
12
  function isStaticPreset(nuxt = useNuxt()) {
@@ -45,11 +46,13 @@ function resolveNitroPreset(nitroConfig) {
45
46
  const logger = useLogger("nuxt-skew-protection");
46
47
 
47
48
  const cloudflareKVWranglerDriver = defineDriver((opts) => {
48
- const { namespaceId, local = false } = opts;
49
+ const { namespaceId, local = false, base = "" } = opts;
49
50
  if (!namespaceId) {
50
51
  throw new Error("[cloudflare-kv-wrangler] namespaceId is required");
51
52
  }
52
53
  const locationFlag = local ? "--local" : "--remote";
54
+ const prefixKey = (key) => base ? `${base}${key}` : key;
55
+ const unprefixKey = (key) => base && key.startsWith(base) ? key.slice(base.length) : key;
53
56
  async function execWrangler(command, throwOnError = true) {
54
57
  const result = await x("sh", ["-c", `npx ${command}`]);
55
58
  if (throwOnError && result.exitCode !== 0) {
@@ -66,108 +69,53 @@ stderr: ${result.stderr}`
66
69
  name: "cloudflare-kv-wrangler",
67
70
  options: opts,
68
71
  async hasItem(key) {
69
- const result = await execWrangler(`wrangler kv key get "${key}" --namespace-id="${namespaceId}" ${locationFlag}`, false);
72
+ const prefixedKey = prefixKey(key);
73
+ const result = await execWrangler(`wrangler kv key get "${prefixedKey}" --namespace-id="${namespaceId}" ${locationFlag}`, false);
70
74
  return result.exitCode === 0;
71
75
  },
72
76
  async getItem(key) {
73
- const result = await execWrangler(`wrangler kv key get "${key}" --namespace-id="${namespaceId}" ${locationFlag}`, false);
77
+ const prefixedKey = prefixKey(key);
78
+ const result = await execWrangler(`wrangler kv key get "${prefixedKey}" --namespace-id="${namespaceId}" ${locationFlag}`, false);
74
79
  if (result.exitCode !== 0) {
75
80
  return null;
76
81
  }
77
82
  return JSON.parse(result.stdout);
78
83
  },
79
84
  async getItemRaw(key) {
80
- const result = await execWrangler(`wrangler kv key get "${key}" --namespace-id="${namespaceId}" ${locationFlag}`);
85
+ const prefixedKey = prefixKey(key);
86
+ const result = await execWrangler(`wrangler kv key get "${prefixedKey}" --namespace-id="${namespaceId}" ${locationFlag}`);
81
87
  return Buffer.from(result.stdout, "utf-8");
82
88
  },
83
89
  async setItem(key, value) {
90
+ const prefixedKey = prefixKey(key);
84
91
  const tmpFile = join(tmpdir(), `kv-${Date.now()}-${Math.random().toString(36).substring(7)}.json`);
85
92
  writeFileSync(tmpFile, JSON.stringify(value));
86
93
  try {
87
- await execWrangler(`wrangler kv key put "${key}" --path="${tmpFile}" --namespace-id="${namespaceId}" ${locationFlag}`);
94
+ await execWrangler(`wrangler kv key put "${prefixedKey}" --path="${tmpFile}" --namespace-id="${namespaceId}" ${locationFlag}`);
88
95
  } finally {
89
96
  unlinkSync(tmpFile);
90
97
  }
91
98
  },
92
99
  async setItemRaw(key, value) {
100
+ const prefixedKey = prefixKey(key);
93
101
  const tmpFile = join(tmpdir(), `kv-${Date.now()}.bin`);
94
102
  writeFileSync(tmpFile, value);
95
- await execWrangler(`wrangler kv key put "${key}" --path="${tmpFile}" --namespace-id="${namespaceId}" ${locationFlag}`);
103
+ await execWrangler(`wrangler kv key put "${prefixedKey}" --path="${tmpFile}" --namespace-id="${namespaceId}" ${locationFlag}`);
96
104
  unlinkSync(tmpFile);
97
105
  },
98
106
  async removeItem(key) {
99
- await execWrangler(`wrangler kv key delete "${key}" --namespace-id="${namespaceId}" ${locationFlag}`);
107
+ const prefixedKey = prefixKey(key);
108
+ await execWrangler(`wrangler kv key delete "${prefixedKey}" --namespace-id="${namespaceId}" ${locationFlag}`);
100
109
  },
101
- async getKeys(base) {
102
- const prefix = base ? `--prefix="${base}"` : "";
110
+ async getKeys(basePrefix) {
111
+ const fullPrefix = base ? basePrefix ? `${base}${basePrefix}` : base : basePrefix;
112
+ const prefix = fullPrefix ? `--prefix="${fullPrefix}"` : "";
103
113
  const result = await execWrangler(`wrangler kv key list ${prefix} --namespace-id="${namespaceId}" ${locationFlag}`);
104
114
  const keys = JSON.parse(result.stdout);
105
- return keys.map((k) => k.name);
115
+ return keys.map((k) => unprefixKey(k.name));
106
116
  },
107
- async clear(base) {
108
- const keys = await driver.getKeys(base);
109
- for (const key of keys) {
110
- await driver.removeItem(key);
111
- }
112
- },
113
- async dispose() {
114
- }
115
- };
116
- return driver;
117
- });
118
-
119
- const vercelKVCLIDriver = defineDriver((opts) => {
120
- const { storeName, teamId } = opts;
121
- if (!storeName) {
122
- throw new Error("[vercel-kv-cli] storeName is required");
123
- }
124
- function buildCommand(subcommand) {
125
- const teamFlag = teamId ? `--team ${teamId}` : "";
126
- return `vercel kv ${subcommand} ${storeName} ${teamFlag}`.trim();
127
- }
128
- async function execVercelKV(subcommand) {
129
- const command = buildCommand(subcommand);
130
- const result = await x("sh", ["-c", command], {
131
- throwOnError: true
132
- });
133
- return result.stdout.trim();
134
- }
135
- const driver = {
136
- name: "vercel-kv-cli",
137
- options: opts,
138
- async hasItem(key) {
139
- const result = await execVercelKV(`get "${key}"`);
140
- return !!result;
141
- },
142
- async getItem(key) {
143
- const result = await execVercelKV(`get "${key}"`);
144
- return JSON.parse(result);
145
- },
146
- async getItemRaw(key) {
147
- const result = await execVercelKV(`get "${key}"`);
148
- return Buffer.from(result, "utf-8");
149
- },
150
- async setItem(key, value) {
151
- const jsonValue = JSON.stringify(value);
152
- const escapedValue = jsonValue.replace(/"/g, '\\"');
153
- await execVercelKV(`set "${key}" "${escapedValue}"`);
154
- },
155
- async setItemRaw(key, value) {
156
- const base64Value = Buffer.from(value).toString("base64");
157
- const escapedValue = base64Value.replace(/"/g, '\\"');
158
- await execVercelKV(`set "${key}" "${escapedValue}"`);
159
- },
160
- async removeItem(key) {
161
- await execVercelKV(`del "${key}"`);
162
- },
163
- async getKeys(base) {
164
- const pattern = base ? `"${base}*"` : '"*"';
165
- const result = await execVercelKV(`keys ${pattern}`);
166
- const keys = JSON.parse(result);
167
- return Array.isArray(keys) ? keys : [];
168
- },
169
- async clear(base) {
170
- const keys = await driver.getKeys(base);
117
+ async clear(basePrefix) {
118
+ const keys = await driver.getKeys(basePrefix);
171
119
  for (const key of keys) {
172
120
  await driver.removeItem(key);
173
121
  }
@@ -180,41 +128,58 @@ const vercelKVCLIDriver = defineDriver((opts) => {
180
128
 
181
129
  async function detectCloudflareKVNamespace() {
182
130
  const nuxt = useNuxt();
183
- const rootDir = nuxt.options.rootDir || process.cwd();
184
- const wranglerPath = join(rootDir, "wrangler.toml");
185
- if (!existsSync(wranglerPath)) {
186
- return null;
131
+ const kvNamespaces = nuxt.options.nitro?.cloudflare?.wrangler?.kv_namespaces;
132
+ if (kvNamespaces?.length) {
133
+ const skewNamespace = kvNamespaces.find((ns) => ns?.binding === "SKEW_PROTECTION");
134
+ if (skewNamespace?.id) {
135
+ return skewNamespace.id;
136
+ }
137
+ if (kvNamespaces[0]?.id) {
138
+ return kvNamespaces[0].id;
139
+ }
187
140
  }
188
- try {
189
- const content = readFileSync(wranglerPath, "utf-8");
190
- const kvNamespaceMatch = content.match(/\[\[kv_namespaces\]\][^[]*?id\s*=\s*"([^"]+)"/);
191
- if (kvNamespaceMatch?.[1]) {
192
- return kvNamespaceMatch[1];
141
+ const rootDir = nuxt.options.rootDir || process.cwd();
142
+ const possiblePaths = [
143
+ join(rootDir, "wrangler.toml"),
144
+ join(rootDir, "app", "wrangler.toml")
145
+ ];
146
+ for (const wranglerPath of possiblePaths) {
147
+ if (!existsSync(wranglerPath)) {
148
+ continue;
149
+ }
150
+ try {
151
+ const content = readFileSync(wranglerPath, "utf-8");
152
+ const skewMatch = content.match(/\[\[kv_namespaces\]\][^[]*?binding\s*=\s*"SKEW_PROTECTION"[^[]*?id\s*=\s*"([^"]+)"/);
153
+ if (skewMatch?.[1]) {
154
+ return skewMatch[1];
155
+ }
156
+ const kvNamespaceMatch = content.match(/\[\[kv_namespaces\]\][^[]*?id\s*=\s*"([^"]+)"/);
157
+ if (kvNamespaceMatch?.[1]) {
158
+ return kvNamespaceMatch[1];
159
+ }
160
+ } catch {
193
161
  }
194
- return null;
195
- } catch {
196
- return null;
197
162
  }
163
+ return null;
198
164
  }
199
165
  async function resolveBuildTimeDriver(storage) {
200
- const { driver, ...driverOptions } = storage;
166
+ const { driver, base, ...driverOptions } = storage;
201
167
  switch (driver) {
202
168
  case "cloudflare-kv-binding": {
203
169
  let namespaceId = storage.namespaceId;
204
170
  if (!namespaceId) {
205
171
  namespaceId = await detectCloudflareKVNamespace();
206
172
  }
173
+ const kvBase = base?.includes("/") ? "skew-protection:" : base || "skew-protection:";
207
174
  return cloudflareKVWranglerDriver({
208
175
  namespaceId,
176
+ base: kvBase,
209
177
  ...driverOptions
210
178
  });
211
179
  }
212
- case "vercel-kv": {
213
- return vercelKVCLIDriver(driverOptions);
214
- }
215
180
  }
216
181
  const lazyDriver = await import(`unstorage/drivers/${storage.driver}`).then((m) => m.default);
217
- return lazyDriver(driverOptions);
182
+ return lazyDriver({ base, ...driverOptions });
218
183
  }
219
184
 
220
185
  function extractFileId(assetPath) {
@@ -226,7 +191,7 @@ function extractFileId(assetPath) {
226
191
  }
227
192
  function calculateDeletedChunks(currentAssets, previousAssets) {
228
193
  const currentSet = new Set(currentAssets);
229
- return previousAssets.filter((asset) => !currentSet.has(asset));
194
+ return previousAssets.filter((asset) => !currentSet.has(asset)).filter((asset) => asset.endsWith(".js"));
230
195
  }
231
196
  function getPreviousVersion(manifest, currentVersionId) {
232
197
  const sortedVersions = Object.entries(manifest.versions).map(([id, data]) => ({ id, timestamp: new Date(data.timestamp).getTime() })).sort((a, b) => b.timestamp - a.timestamp);
@@ -381,9 +346,7 @@ function createAssetManager(options) {
381
346
  if (assetData) {
382
347
  const storageKey = `${buildId}/${asset}`;
383
348
  await storage.setItemRaw(storageKey, assetData).catch((error) => {
384
- if (options.debug) {
385
- logger.warn(`Failed to store ${storageKey}:`, error);
386
- }
349
+ logger.error(`Failed to store ${storageKey}:`, error?.message || error);
387
350
  });
388
351
  if (fileId && fileIdToVersion[fileId] && fileIdToVersion[fileId] !== buildId) {
389
352
  const previousVersionId = fileIdToVersion[fileId];
@@ -561,7 +524,7 @@ function createAssetManager(options) {
561
524
  };
562
525
  }
563
526
 
564
- const module = defineNuxtModule({
527
+ const module$1 = defineNuxtModule({
565
528
  meta: {
566
529
  name: "nuxt-skew-protection",
567
530
  compatibility: {
@@ -588,6 +551,7 @@ const module = defineNuxtModule({
588
551
  },
589
552
  async setup(options, nuxt) {
590
553
  const resolver = createResolver(import.meta.url);
554
+ const { version } = await readPackageJSON(resolver.resolve("../package.json"));
591
555
  logger.level = options.debug || nuxt.options.debug ? 4 : 3;
592
556
  if (options.enabled === false) {
593
557
  logger.debug("The module is disabled, skipping setup.");
@@ -599,6 +563,12 @@ const module = defineNuxtModule({
599
563
  debug: options.debug
600
564
  };
601
565
  const nitroPreset = resolveNitroPreset(nuxt.options.nitro);
566
+ const isNuxtHub = hasNuxtModule("@nuxthub/core");
567
+ if (isNuxtHub && options.storage?.driver === "cloudflare-kv-binding" && !options.storage.namespaceId) {
568
+ logger.error("NuxtHub detected with cloudflare-kv-binding driver but no namespaceId configured.");
569
+ logger.info("Learn more: https://nuxtseo.com/docs/skew-protection/guides/cloudflare");
570
+ throw new Error("namespaceId required for cloudflare-kv-binding driver with NuxtHub");
571
+ }
602
572
  addTypeTemplate({
603
573
  filename: "types/nuxt-skew-protection.d.ts",
604
574
  getContents: () => {
@@ -711,8 +681,16 @@ export {}
711
681
  });
712
682
  const assets = await assetManager.getAssetsFromBuild(outputDir);
713
683
  const { isExistingVersion } = await assetManager.updateVersionsManifest(buildId, assets);
714
- logger.log(`Storing ${assets.length} assets in storage...`);
715
- await assetManager.storeAssetsInStorage(buildId, outputDir, assets);
684
+ logger.log(colors.cyan(`Initialising Nuxt Skew Protection v${version}...`));
685
+ const storageInfo = options.storage.base ? `${colors.green(options.storage.driver)} ${colors.gray(`(${options.storage.base})`)}` : colors.green(options.storage.driver);
686
+ logger.log(` Database: ${storageInfo}`);
687
+ logger.log(` Storing ${colors.yellow(assets.length.toString())} assets in storage...`);
688
+ await assetManager.storeAssetsInStorage(buildId, outputDir, assets).then(() => {
689
+ logger.success(` \u2713 Successfully stored ${assets.length} assets`);
690
+ }).catch((error) => {
691
+ logger.error(` \u2717 Failed to store assets:`, error instanceof Error ? error.message : error);
692
+ throw error;
693
+ });
716
694
  const existingVersions = await assetManager.listExistingVersions();
717
695
  const versionCount = existingVersions.filter((v) => v.id !== buildId).length;
718
696
  if (versionCount > 0) {
@@ -773,4 +751,4 @@ export {}
773
751
  }
774
752
  });
775
753
 
776
- export { module as default };
754
+ export { module$1 as default };
@@ -5,7 +5,7 @@ interface Props {
5
5
  */
6
6
  forceOpen?: boolean;
7
7
  }
8
- declare var __VLS_7: {
8
+ declare var __VLS_8: {
9
9
  version: any;
10
10
  isCurrentChunksOutdated: any;
11
11
  dismiss: any;
@@ -16,7 +16,7 @@ declare var __VLS_7: {
16
16
  isAppOutdated: any;
17
17
  };
18
18
  type __VLS_Slots = {} & {
19
- default?: (props: typeof __VLS_7) => any;
19
+ default?: (props: typeof __VLS_8) => any;
20
20
  };
21
21
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
22
  dismiss: () => any;
@@ -5,7 +5,7 @@ interface Props {
5
5
  */
6
6
  forceOpen?: boolean;
7
7
  }
8
- declare var __VLS_7: {
8
+ declare var __VLS_8: {
9
9
  version: any;
10
10
  isCurrentChunksOutdated: any;
11
11
  dismiss: any;
@@ -16,7 +16,7 @@ declare var __VLS_7: {
16
16
  isAppOutdated: any;
17
17
  };
18
18
  type __VLS_Slots = {} & {
19
- default?: (props: typeof __VLS_7) => any;
19
+ default?: (props: typeof __VLS_8) => any;
20
20
  };
21
21
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
22
  dismiss: () => any;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nuxt-skew-protection",
3
3
  "type": "module",
4
- "version": "0.2.3",
5
- "description": "Instantly adopted Nuxt releases with long-lived build assets.",
4
+ "version": "0.3.1",
5
+ "description": "Solve Nuxt version skews with persistent assets and instant updates.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
8
8
  "email": "harlan@harlanzw.com",
@@ -29,56 +29,56 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@nuxt/kit": "^4.1.3",
33
- "@nuxtjs/robots": "^5.5.5",
34
- "@vueuse/core": "^13.9.0",
32
+ "@nuxt/kit": "^4.2.1",
33
+ "@nuxtjs/robots": "^5.6.0",
34
+ "@vueuse/core": "^14.1.0",
35
35
  "consola": "^3.4.2",
36
36
  "cookie-es": "^2.0.0",
37
37
  "defu": "^6.1.4",
38
- "nuxt-site-config": "^3.2.9",
38
+ "nuxt-site-config": "^3.2.11",
39
39
  "pathe": "^2.0.3",
40
40
  "pkg-types": "^2.3.0",
41
- "std-env": "^3.9.0",
42
- "tinyexec": "^1.0.1",
41
+ "std-env": "^3.10.0",
42
+ "tinyexec": "^1.0.2",
43
43
  "ufo": "^1.6.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@antfu/eslint-config": "^5.4.1",
46
+ "@antfu/eslint-config": "^6.2.0",
47
47
  "@arethetypeswrong/cli": "^0.18.2",
48
- "@nuxt/content": "^3.7.1",
49
- "@nuxt/devtools-ui-kit": "^2.6.5",
48
+ "@nuxt/content": "^3.8.2",
49
+ "@nuxt/devtools-ui-kit": "^3.1.1",
50
50
  "@nuxt/module-builder": "^1.0.2",
51
- "@nuxt/test-utils": "^3.19.2",
52
- "@nuxt/ui": "^4.0.1",
53
- "@nuxtjs/color-mode": "^3.5.2",
51
+ "@nuxt/test-utils": "^3.20.1",
52
+ "@nuxt/ui": "^4.2.1",
53
+ "@nuxtjs/color-mode": "^4.0.0",
54
54
  "@nuxtjs/eslint-config-typescript": "^12.1.0",
55
- "@nuxtjs/i18n": "^10.1.0",
55
+ "@nuxtjs/i18n": "^10.2.1",
56
56
  "@types/ioredis": "^5.0.0",
57
57
  "@types/ws": "^8.18.1",
58
- "@unocss/nuxt": "^66.5.2",
59
- "@unocss/preset-icons": "^66.5.2",
60
- "@unocss/preset-uno": "^66.5.2",
61
- "@unocss/runtime": "^66.5.2",
62
- "@vueuse/nuxt": "^13.9.0",
63
- "better-sqlite3": "^12.4.1",
64
- "bumpp": "^10.3.1",
65
- "eslint": "^9.37.0",
66
- "eventsource": "^4.0.0",
67
- "execa": "^9.6.0",
68
- "firebase-functions": "^6.5.0",
69
- "happy-dom": "^19.0.2",
70
- "ioredis": "^5.8.1",
71
- "nuxt": "^4.1.3",
72
- "playwright-core": "^1.56.0",
73
- "tsx": "^4.20.6",
58
+ "@unocss/nuxt": "66.5.10-beta.1",
59
+ "@unocss/preset-icons": "66.5.10-beta.1",
60
+ "@unocss/preset-uno": "66.5.10-beta.1",
61
+ "@unocss/runtime": "66.5.10-beta.1",
62
+ "@vueuse/nuxt": "^14.1.0",
63
+ "better-sqlite3": "^12.5.0",
64
+ "bumpp": "^10.3.2",
65
+ "eslint": "^9.39.1",
66
+ "eventsource": "^4.1.0",
67
+ "execa": "^9.6.1",
68
+ "firebase-functions": "^7.0.0",
69
+ "happy-dom": "^20.0.11",
70
+ "ioredis": "^5.8.2",
71
+ "nuxt": "^4.2.1",
72
+ "playwright-core": "^1.57.0",
73
+ "tsx": "^4.21.0",
74
74
  "typescript": "^5.9.3",
75
- "unocss": "^66.5.2",
76
- "unstorage": "^1.17.1",
77
- "vitest": "^3.2.4",
78
- "vue": "^3.5.22",
79
- "vue-router": "^4.5.1",
80
- "vue-tsc": "^3.1.1",
81
- "wrangler": "^4.42.1",
75
+ "unocss": "66.5.10-beta.1",
76
+ "unstorage": "^1.17.3",
77
+ "vitest": "^4.0.14",
78
+ "vue": "^3.5.25",
79
+ "vue-router": "^4.6.3",
80
+ "vue-tsc": "^3.1.5",
81
+ "wrangler": "^4.51.0",
82
82
  "ws": "^8.18.3"
83
83
  },
84
84
  "resolutions": {