nuxt-skew-protection 0.4.0 → 0.4.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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=4.0.0"
5
5
  },
6
6
  "configKey": "skewProtection",
7
- "version": "0.4.0",
7
+ "version": "0.4.2",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -6,7 +6,6 @@ import { readPackageJSON } from 'pkg-types';
6
6
  import * as p from '@clack/prompts';
7
7
  import { $fetch } from 'ofetch';
8
8
  import { isTest, isCI, provider, env } from 'std-env';
9
- import { isSkewAdapter } from '../dist/runtime/adapters/types.js';
10
9
  import { join } from 'node:path';
11
10
  import { tmpdir } from 'node:os';
12
11
  import { x } from 'tinyexec';
@@ -239,6 +238,10 @@ async function resolveBuildTimeDriver(storage) {
239
238
  return lazyDriver({ base, ...driverOptions });
240
239
  }
241
240
 
241
+ function isSkewAdapter(value) {
242
+ return typeof value === "object" && value !== null && "name" in value && "subscribe" in value && "broadcast" in value && typeof value.subscribe === "function" && typeof value.broadcast === "function";
243
+ }
244
+
242
245
  async function processBatch(items, batchSize, processor) {
243
246
  const results = [];
244
247
  for (let i = 0; i < items.length; i += batchSize) {
@@ -1,4 +1,4 @@
1
- import { defineAdapter } from "../types.js";
1
+ import { defineAdapter } from "../../../utils";
2
2
  import { ablyConfigSchema } from "./types.js";
3
3
  export { ablyConfigSchema } from "./types.js";
4
4
  export const ablyAdapter = defineAdapter({
@@ -1,5 +1,5 @@
1
1
  import { Rest } from "ably";
2
- import { defineNodeBroadcast } from "../types.js";
2
+ import { defineNodeBroadcast } from "../../../utils";
3
3
  export const broadcast = defineNodeBroadcast(async (config, version) => {
4
4
  const ably = new Rest({ key: config.key });
5
5
  const channelName = config.channel || "skew-protection";
@@ -1,5 +1,5 @@
1
1
  import { onNuxtReady } from "nuxt/app";
2
- import { defineWebSubscribe } from "../types.js";
2
+ import { defineWebSubscribe } from "../../../utils";
3
3
  export const subscribe = defineWebSubscribe((config, onMessage) => {
4
4
  let cleanup;
5
5
  onNuxtReady(async () => {
@@ -1,4 +1,4 @@
1
+ export { isSkewAdapter } from '../../utils.js';
1
2
  export type { AblyAdapterConfig } from './ably/types.js';
2
3
  export type { PusherAdapterConfig } from './pusher/types.js';
3
4
  export type { SkewAdapter, SkewAdapterFactory } from './types.js';
4
- export { isSkewAdapter } from './types.js';
@@ -1 +1 @@
1
- export { isSkewAdapter } from "./types.js";
1
+ export { isSkewAdapter } from "../../utils";
@@ -1,4 +1,4 @@
1
- import { defineAdapter } from "../types.js";
1
+ import { defineAdapter } from "../../../utils";
2
2
  import { pusherConfigSchema } from "./types.js";
3
3
  export { pusherConfigSchema } from "./types.js";
4
4
  export const pusherAdapter = defineAdapter({
@@ -1,5 +1,5 @@
1
1
  import { createHash, createHmac } from "node:crypto";
2
- import { defineNodeBroadcast } from "../types.js";
2
+ import { defineNodeBroadcast } from "../../../utils";
3
3
  export const broadcast = defineNodeBroadcast(async (config, version) => {
4
4
  const channelName = config.channel || "skew-protection";
5
5
  const eventName = config.event || "VersionUpdated";
@@ -1,5 +1,5 @@
1
1
  import { onNuxtReady } from "nuxt/app";
2
- import { defineWebSubscribe } from "../types.js";
2
+ import { defineWebSubscribe } from "../../../utils";
3
3
  export const subscribe = defineWebSubscribe((config, onMessage) => {
4
4
  let cleanup;
5
5
  onNuxtReady(async () => {
@@ -13,11 +13,7 @@ export interface DefineAdapterOptions<T> {
13
13
  name: string;
14
14
  schema: z.ZodType<T>;
15
15
  }
16
- export declare function defineAdapter<T>(options: DefineAdapterOptions<T>): SkewAdapterFactory<T>;
17
16
  export type BroadcastFn<T> = (config: T, version: string) => Promise<void>;
18
- export declare const defineNodeBroadcast: <T>(broadcast: BroadcastFn<T>) => BroadcastFn<T>;
19
17
  export type SubscribeFn<T> = (config: T, onMessage: (msg: {
20
18
  version: string;
21
19
  }) => void) => () => void;
22
- export declare const defineWebSubscribe: <T>(subscribe: SubscribeFn<T>) => SubscribeFn<T>;
23
- export declare function isSkewAdapter(value: unknown): value is SkewAdapter;
@@ -1,18 +0,0 @@
1
- export function defineAdapter(options) {
2
- return (config) => ({
3
- name: options.name,
4
- config,
5
- schema: options.schema,
6
- subscribe: () => {
7
- throw new Error(`${options.name}.subscribe() - use web build`);
8
- },
9
- broadcast: () => {
10
- throw new Error(`${options.name}.broadcast() - use node build`);
11
- }
12
- });
13
- }
14
- export const defineNodeBroadcast = (broadcast) => broadcast;
15
- export const defineWebSubscribe = (subscribe) => subscribe;
16
- export function isSkewAdapter(value) {
17
- return typeof value === "object" && value !== null && "name" in value && "subscribe" in value && "broadcast" in value && typeof value.subscribe === "function" && typeof value.broadcast === "function";
18
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-skew-protection",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "description": "Solve Nuxt version skews with persistent assets and instant updates.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -50,12 +50,11 @@
50
50
  "dependencies": {
51
51
  "@clack/prompts": "^0.11.0",
52
52
  "@nuxt/kit": "^4.2.2",
53
- "@nuxtjs/robots": "^5.6.3",
54
53
  "@vueuse/core": "^14.1.0",
55
54
  "consola": "^3.4.2",
56
55
  "cookie-es": "^2.0.0",
57
56
  "defu": "^6.1.4",
58
- "nuxt-site-config": "^3.2.11",
57
+ "nuxt-site-config": "^3.2.12",
59
58
  "ofetch": "^1.5.1",
60
59
  "pathe": "^2.0.3",
61
60
  "pkg-types": "^2.3.0",
@@ -100,9 +99,9 @@
100
99
  "unocss": "66.5.10",
101
100
  "vitest": "^4.0.15",
102
101
  "vue": "^3.5.25",
103
- "vue-router": "^4.6.3",
102
+ "vue-router": "^4.6.4",
104
103
  "vue-tsc": "^3.1.8",
105
- "wrangler": "^4.53.0",
104
+ "wrangler": "^4.54.0",
106
105
  "ws": "^8.18.3"
107
106
  },
108
107
  "resolutions": {