@nuxt/bridge-edge 3.5.0-29142082.f9326ec → 3.6.0-29254309.9051103

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.
@@ -7,7 +7,7 @@ import { genObjectFromRawEntries, genDynamicImport } from 'knitwork';
7
7
  import fse from 'fs-extra';
8
8
  import { debounce } from 'perfect-debounce';
9
9
  import { isIgnored, logger } from '@nuxt/kit';
10
- import { g as generateDevSSRManifest, i as isCSS, h as hashId, u as uniq } from '../shared/bridge-edge.DRPBE2e8.mjs';
10
+ import { g as generateDevSSRManifest, i as isCSS, h as hashId, u as uniq } from '../shared/bridge-edge.DfLAC_Lt.mjs';
11
11
  import { c as createIsExternal } from './vite.mjs';
12
12
  import 'h3';
13
13
  import 'node-fetch';
@@ -3,7 +3,7 @@ import hash from 'hash-sum';
3
3
  import { resolve } from 'pathe';
4
4
  import { genObjectFromRawEntries, genImport } from 'knitwork';
5
5
 
6
- const version = "3.5.0-29142082.f9326ec";
6
+ const version = "3.6.0-29254309.9051103";
7
7
 
8
8
  const middlewareTemplate = {
9
9
  filename: "middleware.js",
@@ -2,11 +2,11 @@ import { normalize, resolve, isAbsolute, join } from 'pathe';
2
2
  import { logger, isIgnored } from '@nuxt/kit';
3
3
  import { resolve as resolve$1, findExports, sanitizeFilePath } from 'mlly';
4
4
  import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo';
5
- import { d as distDir, t as transpile, i as isCSS, p as prepareManifests, a as pkgDir } from '../shared/bridge-edge.DRPBE2e8.mjs';
5
+ import { d as distDir, t as transpile, i as isCSS, p as prepareManifests, a as pkgDir } from '../shared/bridge-edge.DfLAC_Lt.mjs';
6
6
  import createVuePlugin from '@vitejs/plugin-vue2';
7
7
  import { getPort } from 'get-port-please';
8
8
  import { toNodeListener, createApp, defineEventHandler, defineLazyEventHandler, eventHandler, createError } from 'h3';
9
- import defu, { defu as defu$1 } from 'defu';
9
+ import { defu } from 'defu';
10
10
  import { pathToFileURL } from 'node:url';
11
11
  import { ViteNodeServer } from 'vite-node/server';
12
12
  import fse from 'fs-extra';
@@ -594,7 +594,7 @@ function resolveCSSOptions(nuxt) {
594
594
  plugins: []
595
595
  }
596
596
  };
597
- const plugins = defu$1(nuxt.options.build.postcss.plugins, {
597
+ const plugins = defu(nuxt.options.build.postcss.plugins, {
598
598
  // https://github.com/postcss/postcss-import
599
599
  "postcss-import": {
600
600
  resolve: createResolver({
package/dist/module.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import '@nuxt/kit';
2
2
  import 'h3';
3
- export { m as default } from './shared/bridge-edge.DRPBE2e8.mjs';
3
+ export { m as default } from './shared/bridge-edge.DfLAC_Lt.mjs';
4
4
  import 'fs';
5
5
  import 'url';
6
6
  import 'node-fetch';
@@ -24,10 +24,10 @@ export interface AsyncDataOptions<ResT, DataT = ResT, PickKeys extends KeysOf<Da
24
24
  default?: () => DefaultT | Ref<DefaultT>;
25
25
  /**
26
26
  * Provide a function which returns cached data.
27
- * A `null` or `undefined` return value will trigger a fetch.
27
+ * A `undefined` return value will trigger a fetch.
28
28
  * Default is `key => nuxt.isHydrating ? nuxt.payload.data[key] : nuxt.static.data[key]` which only caches data when payloadExtraction is enabled.
29
29
  */
30
- getCachedData?: (key: string, nuxtApp: NuxtAppCompat) => DataT;
30
+ getCachedData?: (key: string, nuxtApp: NuxtAppCompat) => NoInfer<DataT> | undefined;
31
31
  /**
32
32
  * A function that can be used to alter handler function result after resolving
33
33
  */
@@ -1,7 +1,7 @@
1
1
  import { ref, watch, getCurrentScope, onScopeDispose, customRef, nextTick } from "vue";
2
2
  import { parse, serialize } from "cookie-es";
3
3
  import { deleteCookie, getCookie, getRequestHeader, setCookie } from "h3";
4
- import destr from "destr";
4
+ import { destr } from "destr";
5
5
  import { isEqual } from "ohash/utils";
6
6
  import { klona } from "klona";
7
7
  import { useNuxtApp } from "../nuxt.mjs";
@@ -22,6 +22,7 @@ export function useCookie(name, _opts) {
22
22
  delay = opts.expires.getTime() - Date.now();
23
23
  }
24
24
  const hasExpired = delay !== void 0 && delay <= 0;
25
+ const shouldSetInitialClientCookie = process.client && (hasExpired || cookies[name] === void 0 || cookies[name] === null);
25
26
  const cookieValue = klona(hasExpired ? void 0 : cookies[name] ?? opts.default?.());
26
27
  const cookie = process.client && delay && !hasExpired ? cookieRef(cookieValue, delay, opts.watch && opts.watch !== "shallow") : ref(cookieValue);
27
28
  if (process.dev && hasExpired) {
@@ -35,9 +36,11 @@ export function useCookie(name, _opts) {
35
36
  }
36
37
  } catch {
37
38
  }
38
- const callback = () => {
39
- if (opts.readonly || isEqual(cookie.value, cookies[name])) {
40
- return;
39
+ const callback = (force = false) => {
40
+ if (!force) {
41
+ if (opts.readonly || isEqual(cookie.value, cookies[name])) {
42
+ return;
43
+ }
41
44
  }
42
45
  writeClientCookie(name, cookie.value, opts);
43
46
  channel?.postMessage(opts.encode(cookie.value));
@@ -70,8 +73,9 @@ export function useCookie(name, _opts) {
70
73
  },
71
74
  { deep: opts.watch !== "shallow" }
72
75
  );
73
- } else {
74
- callback();
76
+ }
77
+ if (shouldSetInitialClientCookie) {
78
+ callback(shouldSetInitialClientCookie);
75
79
  }
76
80
  } else if (process.server) {
77
81
  const nuxtApp = useNuxtApp();
@@ -79,6 +83,16 @@ export function useCookie(name, _opts) {
79
83
  if (opts.readonly || isEqual(cookie.value, cookies[name])) {
80
84
  return;
81
85
  }
86
+ nuxtApp._cookies = nuxtApp._cookies || {};
87
+ if (name in nuxtApp._cookies) {
88
+ if (isEqual(cookie.value, nuxtApp._cookies[name])) {
89
+ return;
90
+ }
91
+ if (process.dev) {
92
+ console.warn(`[nuxt] cookie \`${name}\` was previously set to \`${opts.encode(nuxtApp._cookies[name])}\` and is being overridden to \`${opts.encode(cookie.value)}\`. This may cause unexpected issues.`);
93
+ }
94
+ }
95
+ nuxtApp._cookies[name] = cookie.value;
82
96
  writeServerCookie(useRequestEvent(nuxtApp), name, cookie.value, opts);
83
97
  };
84
98
  const unhook = nuxtApp.hooks.hookOnce("app:rendered", writeFinalCookieValue);
@@ -6,3 +6,4 @@ export { useLazyFetch } from './fetch';
6
6
  export * from './router';
7
7
  export { useRequestHeaders, useRequestEvent } from './ssr';
8
8
  export * from './state';
9
+ export { useRuntimeHook } from './runtime-hook';
@@ -6,3 +6,4 @@ export { useLazyFetch } from "./fetch.mjs";
6
6
  export * from "./router.mjs";
7
7
  export { useRequestHeaders, useRequestEvent } from "./ssr.mjs";
8
8
  export * from "./state.mjs";
9
+ export { useRuntimeHook } from "./runtime-hook.mjs";
@@ -0,0 +1,8 @@
1
+ import type { HookCallback } from 'hookable';
2
+ import type { RuntimeNuxtHooks } from '@nuxt/bridge-schema';
3
+ /**
4
+ * Registers a runtime hook in a Nuxt application and ensures it is properly disposed of when the scope is destroyed.
5
+ * @param name - The name of the hook to register.
6
+ * @param fn - The callback function to be executed when the hook is triggered.
7
+ */
8
+ export declare function useRuntimeHook<THookName extends keyof RuntimeNuxtHooks>(name: THookName, fn: RuntimeNuxtHooks[THookName] extends HookCallback ? RuntimeNuxtHooks[THookName] : never): void;
@@ -0,0 +1,7 @@
1
+ import { onScopeDispose } from "vue";
2
+ import { useNuxtApp } from "../nuxt.mjs";
3
+ export function useRuntimeHook(name, fn) {
4
+ const nuxtApp = useNuxtApp();
5
+ const unregister = nuxtApp.hook(name, fn);
6
+ onScopeDispose(unregister);
7
+ }
@@ -1130,6 +1130,10 @@ const granularAppPresets = [
1130
1130
  {
1131
1131
  imports: ["useAsyncData", "useFetch", "useHydration"],
1132
1132
  from: "#app/mocks"
1133
+ },
1134
+ {
1135
+ imports: ["useRuntimeHook"],
1136
+ from: "#app/composables/runtime-hook"
1133
1137
  }
1134
1138
  ];
1135
1139
  const vueKeys = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/bridge-edge",
3
- "version": "3.5.0-29142082.f9326ec",
3
+ "version": "3.6.0-29254309.9051103",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/bridge.git"
@@ -21,30 +21,30 @@
21
21
  "dependencies": {
22
22
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
23
23
  "@babel/plugin-proposal-optional-chaining": "^7.21.0",
24
- "@babel/plugin-transform-typescript": "^7.27.1",
25
- "@nuxt/bridge-schema": "npm:@nuxt/bridge-schema-edge@3.5.0-29142082.f9326ec",
24
+ "@babel/plugin-transform-typescript": "^7.28.0",
25
+ "@nuxt/bridge-schema": "npm:@nuxt/bridge-schema-edge@3.6.0-29254309.9051103",
26
26
  "@nuxt/devalue": "^2.0.2",
27
- "@nuxt/kit": "3.17.4",
28
- "@nuxt/schema": "3.17.4",
27
+ "@nuxt/kit": "3.18.1",
28
+ "@nuxt/schema": "3.18.1",
29
29
  "@nuxt/ui-templates": "^1.3.4",
30
30
  "@rollup/plugin-replace": "^6.0.2",
31
31
  "@unhead/ssr": "^1.11.20",
32
32
  "@unhead/vue": "^1.11.20",
33
- "@vitejs/plugin-legacy": "^6.1.1",
33
+ "@vitejs/plugin-legacy": "^7.2.1",
34
34
  "@vitejs/plugin-vue2": "^2.3.3",
35
- "acorn": "^8.14.1",
35
+ "acorn": "^8.15.0",
36
36
  "cookie-es": "^2.0.0",
37
37
  "defu": "^6.1.4",
38
38
  "destr": "^2.0.5",
39
- "enhanced-resolve": "^5.18.1",
39
+ "enhanced-resolve": "^5.18.3",
40
40
  "esbuild-loader": "^4.3.0",
41
41
  "escape-string-regexp": "^5.0.0",
42
42
  "estree-walker": "^3.0.3",
43
- "exsolve": "^1.0.5",
43
+ "exsolve": "^1.0.7",
44
44
  "externality": "^1.0.2",
45
45
  "fs-extra": "^10.1.0",
46
- "get-port-please": "^3.1.2",
47
- "h3": "~1.14.0",
46
+ "get-port-please": "^3.2.0",
47
+ "h3": "~1.15.4",
48
48
  "hash-sum": "^2.0.0",
49
49
  "hookable": "5.5.3",
50
50
  "klona": "^2.0.6",
@@ -52,43 +52,43 @@
52
52
  "magic-string": "^0.30.17",
53
53
  "mlly": "^1.7.4",
54
54
  "mocked-exports": "^0.1.1",
55
- "nitropack": "^2.11.12",
55
+ "nitropack": "^2.12.4",
56
56
  "node-fetch": "^3.3.2",
57
- "nypm": "^0.6.0",
57
+ "nypm": "^0.6.1",
58
58
  "ofetch": "^1.4.1",
59
59
  "ohash": "^2.0.11",
60
60
  "pathe": "^2.0.3",
61
61
  "perfect-debounce": "^1.0.0",
62
- "pkg-types": "^2.1.0",
62
+ "pkg-types": "^2.2.0",
63
63
  "postcss-import-resolver": "^2.0.0",
64
64
  "scule": "^1.3.0",
65
65
  "std-env": "^3.9.0",
66
- "terser": "^5.40.0",
66
+ "terser": "^5.43.1",
67
67
  "ufo": "^1.6.1",
68
- "unimport": "^5.0.1",
68
+ "unimport": "^5.2.0",
69
69
  "unplugin": "^1.16.1",
70
70
  "untyped": "^2.0.0",
71
- "vite": "~6.3.5",
72
- "vite-node": "^3.1.4",
73
- "vue-bundle-renderer": "^2.1.1"
71
+ "vite": "~7.1.1",
72
+ "vite-node": "^3.2.4",
73
+ "vue-bundle-renderer": "^2.1.2"
74
74
  },
75
75
  "devDependencies": {
76
- "@babel/core": "^7.27.3",
77
- "@types/estree": "^1.0.7",
76
+ "@babel/core": "^7.28.0",
77
+ "@types/estree": "^1.0.8",
78
78
  "@types/fs-extra": "^9.0.13",
79
79
  "@types/hash-sum": "^1.0.2",
80
80
  "@types/webpack": "^4.41.40",
81
81
  "@vue/compiler-sfc": "^2.7.16",
82
- "@vue/reactivity": "^3.5.16",
83
- "rollup": "^4.41.1",
84
- "unbuild": "3.5.0",
82
+ "@vue/reactivity": "^3.5.18",
83
+ "rollup": "^4.46.2",
84
+ "unbuild": "3.6.0",
85
85
  "vue": "^2.7.16",
86
86
  "vue-meta": "^2.4.0",
87
87
  "vue-router": "^3.6.5",
88
88
  "zhead": "^2.2.4"
89
89
  },
90
90
  "engines": {
91
- "node": "^18.20.5 || ^20.0.0 || >=22.0.0"
91
+ "node": "^20.19.0 || >=22.12.0"
92
92
  },
93
93
  "_name": "@nuxt/bridge",
94
94
  "scripts": {