@nuxt/bridge-edge 3.0.0-27414150.3589a2d → 3.0.0-27415326.3c563fa
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/chunks/module.mjs +6 -2
- package/dist/chunks/module2.mjs +1 -1
- package/dist/chunks/vite.mjs +1 -1
- package/dist/runtime/app.d.ts +7 -0
- package/dist/runtime/app.mjs +9 -5
- package/dist/runtime/app.plugin.d.mts +1 -1
- package/dist/runtime/app.plugin.mjs +29 -2
- package/dist/runtime/capi.legacy.d.mts +1 -1
- package/dist/runtime/composables.d.ts +13 -1
- package/dist/runtime/composables.mjs +85 -21
- package/dist/runtime/meta/lib/vueuse-head.plugin.mjs +3 -4
- package/package.json +5 -5
package/dist/chunks/module.mjs
CHANGED
|
@@ -880,7 +880,7 @@ export default () => {};`;
|
|
|
880
880
|
addDeclarationTemplates(ctx);
|
|
881
881
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
882
882
|
references.push({ path: resolve(nuxt.options.buildDir, "types/auto-imports.d.ts") });
|
|
883
|
-
references.push({ path: resolve(nuxt.options.buildDir, "
|
|
883
|
+
references.push({ path: resolve(nuxt.options.buildDir, "imports.d.ts") });
|
|
884
884
|
});
|
|
885
885
|
nuxt.hook("builder:watch", async (_, path) => {
|
|
886
886
|
const _resolved = resolve(nuxt.options.srcDir, path);
|
|
@@ -907,7 +907,7 @@ function addDeclarationTemplates(ctx) {
|
|
|
907
907
|
return path;
|
|
908
908
|
};
|
|
909
909
|
addTemplate({
|
|
910
|
-
filename: "
|
|
910
|
+
filename: "imports.d.ts",
|
|
911
911
|
getContents: () => toExports(ctx.autoImports)
|
|
912
912
|
});
|
|
913
913
|
addTemplate({
|
|
@@ -943,6 +943,10 @@ async function setupAutoImports() {
|
|
|
943
943
|
}
|
|
944
944
|
autoImports2.push({ name: "useRouter", as: "useRouter", from: "#app" });
|
|
945
945
|
autoImports2.push({ name: "useRoute", as: "useRoute", from: "#app" });
|
|
946
|
+
autoImports2.push({ name: "addRouteMiddleware", as: "addRouteMiddleware", from: "#app" });
|
|
947
|
+
autoImports2.push({ name: "navigateTo", as: "navigateTo", from: "#app" });
|
|
948
|
+
autoImports2.push({ name: "abortNavigation", as: "abortNavigation", from: "#app" });
|
|
949
|
+
autoImports2.push({ name: "defineNuxtRouteMiddleware", as: "defineNuxtRouteMiddleware", from: "#app" });
|
|
946
950
|
autoImports2.push({ name: "useNuxt2Meta", as: "useNuxt2Meta", from: "#app" });
|
|
947
951
|
});
|
|
948
952
|
await installModule(autoImports);
|
package/dist/chunks/module2.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import hash from 'hash-sum';
|
|
|
4
4
|
import { resolve } from 'pathe';
|
|
5
5
|
import { genImport, genObjectFromRawEntries } from 'knitwork';
|
|
6
6
|
|
|
7
|
-
const version = "3.0.0-
|
|
7
|
+
const version = "3.0.0-27415326.3c563fa";
|
|
8
8
|
|
|
9
9
|
const middlewareTemplate = {
|
|
10
10
|
filename: "middleware.js",
|
package/dist/chunks/vite.mjs
CHANGED
|
@@ -208,7 +208,7 @@ async function transformRequest(opts, id) {
|
|
|
208
208
|
}
|
|
209
209
|
const withoutVersionQuery = id.replace(/\?v=\w+$/, "");
|
|
210
210
|
if (await isExternal(opts, withoutVersionQuery)) {
|
|
211
|
-
const path = builtinModules.includes(withoutVersionQuery.split("node:").pop()) ? withoutVersionQuery : pathToFileURL(withoutVersionQuery);
|
|
211
|
+
const path = builtinModules.includes(withoutVersionQuery.split("node:").pop()) ? withoutVersionQuery : pathToFileURL(withoutVersionQuery).href;
|
|
212
212
|
return {
|
|
213
213
|
code: `(global, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => ${genDynamicImport(path, { wrapper: false })}.then(r => { exports.default = r.default; ssrExportAll(r) }).catch(e => { console.error(e); throw new Error(${JSON.stringify(`[vite dev] Error loading external "${id}".`)}) })`,
|
|
214
214
|
deps: [],
|
package/dist/runtime/app.d.ts
CHANGED
|
@@ -40,5 +40,12 @@ export interface Context {
|
|
|
40
40
|
$_nuxtApp: NuxtAppCompat;
|
|
41
41
|
}
|
|
42
42
|
export declare const setNuxtAppInstance: (nuxt: NuxtAppCompat | null) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Ensures that the setup function passed in has access to the Nuxt instance via `useNuxt`.
|
|
45
|
+
*
|
|
46
|
+
* @param nuxt A Nuxt instance
|
|
47
|
+
* @param setup The function to call
|
|
48
|
+
*/
|
|
49
|
+
export declare function callWithNuxt<T extends (...args: any[]) => any>(nuxt: NuxtAppCompat, setup: T, args?: Parameters<T>): ReturnType<T>;
|
|
43
50
|
export declare function defineNuxtPlugin(plugin: (nuxtApp: NuxtAppCompat) => void): (ctx: Context) => void;
|
|
44
51
|
export declare const useNuxtApp: () => NuxtAppCompat;
|
package/dist/runtime/app.mjs
CHANGED
|
@@ -6,12 +6,16 @@ let currentNuxtAppInstance;
|
|
|
6
6
|
export const setNuxtAppInstance = (nuxt) => {
|
|
7
7
|
currentNuxtAppInstance = nuxt;
|
|
8
8
|
};
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export function callWithNuxt(nuxt, setup, args) {
|
|
10
|
+
setNuxtAppInstance(nuxt);
|
|
11
|
+
const p = args ? setup(...args) : setup();
|
|
12
|
+
if (process.server) {
|
|
13
13
|
setNuxtAppInstance(null);
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
|
+
return p;
|
|
16
|
+
}
|
|
17
|
+
export function defineNuxtPlugin(plugin) {
|
|
18
|
+
return (ctx) => callWithNuxt(ctx.$_nuxtApp, plugin, [ctx.$_nuxtApp]);
|
|
15
19
|
}
|
|
16
20
|
export const useNuxtApp = () => {
|
|
17
21
|
const vm = getCurrentInstance();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function _default(ctx: any, inject: any): void
|
|
1
|
+
declare function _default(ctx: any, inject: any): Promise<void>;
|
|
2
2
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Vue from 'vue'
|
|
2
2
|
import { createHooks } from 'hookable'
|
|
3
|
-
import { setNuxtAppInstance } from '#app'
|
|
3
|
+
import { callWithNuxt, setNuxtAppInstance } from '#app'
|
|
4
4
|
|
|
5
5
|
// Reshape payload to match key `useLazyAsyncData` expects
|
|
6
6
|
function proxiedState (state) {
|
|
@@ -19,7 +19,7 @@ function proxiedState (state) {
|
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export default (ctx, inject) => {
|
|
22
|
+
export default async (ctx, inject) => {
|
|
23
23
|
const nuxtApp = {
|
|
24
24
|
vueApp: {
|
|
25
25
|
component: Vue.component.bind(Vue),
|
|
@@ -48,6 +48,27 @@ export default (ctx, inject) => {
|
|
|
48
48
|
nuxtApp.hook = nuxtApp.hooks.hook
|
|
49
49
|
nuxtApp.callHook = nuxtApp.hooks.callHook
|
|
50
50
|
|
|
51
|
+
const middleware = await import('#build/middleware').then(r => r.default)
|
|
52
|
+
nuxtApp._middleware = nuxtApp._middleware || {
|
|
53
|
+
global: [],
|
|
54
|
+
named: middleware
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ctx.app.router.beforeEach(async (to, from, next) => {
|
|
58
|
+
nuxtApp._processingMiddleware = true
|
|
59
|
+
|
|
60
|
+
for (const middleware of nuxtApp._middleware.global) {
|
|
61
|
+
const result = await callWithNuxt(nuxtApp, middleware, [to, from])
|
|
62
|
+
if (result || result === false) { return next(result) }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
next()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
ctx.app.router.afterEach(() => {
|
|
69
|
+
delete nuxtApp._processingMiddleware
|
|
70
|
+
})
|
|
71
|
+
|
|
51
72
|
if (!Array.isArray(ctx.app.created)) {
|
|
52
73
|
ctx.app.created = [ctx.app.created].filter(Boolean)
|
|
53
74
|
}
|
|
@@ -77,5 +98,11 @@ export default (ctx, inject) => {
|
|
|
77
98
|
|
|
78
99
|
setNuxtAppInstance(proxiedApp)
|
|
79
100
|
|
|
101
|
+
if (process.client) {
|
|
102
|
+
window.onNuxtReady(() => {
|
|
103
|
+
nuxtApp.hooks.callHook('app:mounted', nuxtApp.vueApp)
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
inject('_nuxtApp', proxiedApp)
|
|
81
108
|
}
|
|
@@ -24,7 +24,7 @@ export function useContext(): {
|
|
|
24
24
|
$root: import("vue").default;
|
|
25
25
|
$children: import("vue").default[];
|
|
26
26
|
$refs: {
|
|
27
|
-
[key: string]: import("vue").default | Element |
|
|
27
|
+
[key: string]: Element | import("vue").default | (Element | import("vue").default)[];
|
|
28
28
|
};
|
|
29
29
|
$slots: {
|
|
30
30
|
[key: string]: import("vue").VNode[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Ref } from '@vue/composition-api';
|
|
2
2
|
import type { MetaInfo } from 'vue-meta';
|
|
3
3
|
import type VueRouter from 'vue-router';
|
|
4
|
-
import type { Route } from 'vue-router';
|
|
4
|
+
import type { Location, Route } from 'vue-router';
|
|
5
5
|
import type { RuntimeConfig } from '@nuxt/schema';
|
|
6
6
|
export { useLazyAsyncData } from './asyncData';
|
|
7
7
|
export { useLazyFetch } from './fetch';
|
|
@@ -19,3 +19,15 @@ declare type Reffed<T extends Record<string, any>> = {
|
|
|
19
19
|
[P in keyof T]: T[P] extends Array<infer A> ? Ref<Array<Reffed<A>>> | Array<Reffed<A>> : T[P] extends Record<string, any> ? Reffed<T[P]> | Ref<Reffed<T[P]>> : T[P] | Ref<T[P]>;
|
|
20
20
|
};
|
|
21
21
|
export declare const useNuxt2Meta: (metaOptions: Reffed<MetaInfo> | (() => Reffed<MetaInfo>)) => void;
|
|
22
|
+
export interface AddRouteMiddlewareOptions {
|
|
23
|
+
global?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const addRouteMiddleware: (name: string, middleware: any, options?: AddRouteMiddlewareOptions) => void;
|
|
26
|
+
export declare const navigateTo: (to: Route) => Route | Promise<Route>;
|
|
27
|
+
/** This will abort navigation within a Nuxt route middleware handler. */
|
|
28
|
+
export declare const abortNavigation: (err?: Error | string) => boolean;
|
|
29
|
+
declare type RouteMiddlewareReturn = void | Error | string | Location | boolean;
|
|
30
|
+
export interface RouteMiddleware {
|
|
31
|
+
(to: Route, from: Route): RouteMiddlewareReturn | Promise<RouteMiddlewareReturn>;
|
|
32
|
+
}
|
|
33
|
+
export declare const defineNuxtRouteMiddleware: (middleware: RouteMiddleware) => RouteMiddleware;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getCurrentInstance, onBeforeUnmount, isRef, watch, reactive, toRef, isReactive, set } from "@vue/composition-api";
|
|
2
|
+
import defu from "defu";
|
|
2
3
|
import { useNuxtApp } from "./app.mjs";
|
|
3
4
|
export { useLazyAsyncData } from "./asyncData.mjs";
|
|
4
5
|
export { useLazyFetch } from "./fetch.mjs";
|
|
@@ -65,30 +66,93 @@ function unwrap(value) {
|
|
|
65
66
|
}
|
|
66
67
|
return value;
|
|
67
68
|
}
|
|
69
|
+
function metaInfoFromOptions(metaOptions) {
|
|
70
|
+
return metaOptions instanceof Function ? metaOptions : () => metaOptions;
|
|
71
|
+
}
|
|
68
72
|
export const useNuxt2Meta = (metaOptions) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
let vm = null;
|
|
74
|
+
try {
|
|
75
|
+
vm = getCurrentInstance().proxy;
|
|
76
|
+
const meta = vm.$meta();
|
|
77
|
+
const $root = vm.$root;
|
|
78
|
+
if (!vm._vueMeta) {
|
|
79
|
+
vm._vueMeta = true;
|
|
80
|
+
let parent = vm.$parent;
|
|
81
|
+
while (parent && parent !== $root) {
|
|
82
|
+
if (parent._vueMeta === void 0) {
|
|
83
|
+
parent._vueMeta = false;
|
|
84
|
+
}
|
|
85
|
+
parent = parent.$parent;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
vm.$options.head = vm.$options.head || {};
|
|
89
|
+
const unwatch = watch(metaInfoFromOptions(metaOptions), (metaInfo) => {
|
|
90
|
+
vm.$metaInfo = {
|
|
91
|
+
...vm.$metaInfo || {},
|
|
92
|
+
...unwrap(metaInfo)
|
|
93
|
+
};
|
|
94
|
+
if (process.client) {
|
|
95
|
+
meta.refresh();
|
|
78
96
|
}
|
|
79
|
-
|
|
97
|
+
}, { immediate: true, deep: true });
|
|
98
|
+
onBeforeUnmount(unwatch);
|
|
99
|
+
} catch {
|
|
100
|
+
const app = useNuxtApp().nuxt2Context.app;
|
|
101
|
+
if (typeof app.head === "function") {
|
|
102
|
+
const originalHead = app.head;
|
|
103
|
+
app.head = function() {
|
|
104
|
+
const head = originalHead.call(this) || {};
|
|
105
|
+
return defu(unwrap(metaInfoFromOptions(metaOptions)), head);
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
app.head = defu(unwrap(metaInfoFromOptions(metaOptions)), app.head);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function convertToLegacyMiddleware(middleware) {
|
|
113
|
+
return async (ctx) => {
|
|
114
|
+
const result = await middleware(ctx.route, ctx.from);
|
|
115
|
+
if (result instanceof Error) {
|
|
116
|
+
return ctx.error(result);
|
|
80
117
|
}
|
|
118
|
+
if (result) {
|
|
119
|
+
return ctx.redirect(result);
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export const addRouteMiddleware = (name, middleware, options = {}) => {
|
|
125
|
+
const nuxtApp = useNuxtApp();
|
|
126
|
+
if (options.global) {
|
|
127
|
+
nuxtApp._middleware.global.push(middleware);
|
|
128
|
+
} else {
|
|
129
|
+
nuxtApp._middleware.named[name] = convertToLegacyMiddleware(middleware);
|
|
81
130
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
...unwrap(metaInfo)
|
|
88
|
-
};
|
|
89
|
-
if (process.client) {
|
|
90
|
-
meta.refresh();
|
|
131
|
+
};
|
|
132
|
+
const isProcessingMiddleware = () => {
|
|
133
|
+
try {
|
|
134
|
+
if (useNuxtApp()._processingMiddleware) {
|
|
135
|
+
return true;
|
|
91
136
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
137
|
+
} catch {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
142
|
+
export const navigateTo = (to) => {
|
|
143
|
+
if (isProcessingMiddleware()) {
|
|
144
|
+
return to;
|
|
145
|
+
}
|
|
146
|
+
const router = process.server ? useRouter() : window.$nuxt.router;
|
|
147
|
+
return router.push(to);
|
|
148
|
+
};
|
|
149
|
+
export const abortNavigation = (err) => {
|
|
150
|
+
if (process.dev && !isProcessingMiddleware()) {
|
|
151
|
+
throw new Error("abortNavigation() is only usable inside a route middleware handler.");
|
|
152
|
+
}
|
|
153
|
+
if (err) {
|
|
154
|
+
throw err instanceof Error ? err : new Error(err);
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
94
157
|
};
|
|
158
|
+
export const defineNuxtRouteMiddleware = (middleware) => middleware;
|
|
@@ -4,22 +4,21 @@ import { defineNuxtPlugin } from "#app";
|
|
|
4
4
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
5
|
const head = createHead();
|
|
6
6
|
nuxtApp.vueApp.use(head);
|
|
7
|
+
nuxtApp.hooks.hookOnce("app:mounted", () => {
|
|
8
|
+
watchEffect(() => head.updateDOM());
|
|
9
|
+
});
|
|
7
10
|
nuxtApp._useMeta = (meta) => {
|
|
8
11
|
const headObj = ref(meta);
|
|
9
12
|
head.addHeadObjs(headObj);
|
|
10
13
|
if (process.server) {
|
|
11
14
|
return;
|
|
12
15
|
}
|
|
13
|
-
watchEffect(() => {
|
|
14
|
-
head.updateDOM();
|
|
15
|
-
});
|
|
16
16
|
const vm = getCurrentInstance();
|
|
17
17
|
if (!vm) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
onBeforeUnmount(() => {
|
|
21
21
|
head.removeHeadObjs(headObj);
|
|
22
|
-
head.updateDOM();
|
|
23
22
|
});
|
|
24
23
|
};
|
|
25
24
|
if (process.server) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/bridge-edge",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-27415326.3c563fa",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
22
22
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
23
23
|
"@babel/plugin-transform-typescript": "^7.16.8",
|
|
24
|
-
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-
|
|
25
|
-
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-
|
|
24
|
+
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27415326.3c563fa",
|
|
25
|
+
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-27415326.3c563fa",
|
|
26
26
|
"@nuxt/postcss8": "^1.1.3",
|
|
27
|
-
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-
|
|
27
|
+
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27415326.3c563fa",
|
|
28
28
|
"@vitejs/plugin-legacy": "^1.6.4",
|
|
29
29
|
"@vue/composition-api": "^1.4.6",
|
|
30
30
|
"@vueuse/head": "^0.7.5",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"mlly": "^0.4.2",
|
|
47
47
|
"murmurhash-es": "^0.1.1",
|
|
48
48
|
"node-fetch": "^3.2.0",
|
|
49
|
-
"nuxi": "npm:nuxi-edge@3.0.0-
|
|
49
|
+
"nuxi": "npm:nuxi-edge@3.0.0-27415326.3c563fa",
|
|
50
50
|
"p-debounce": "^4.0.0",
|
|
51
51
|
"pathe": "^0.2.0",
|
|
52
52
|
"postcss": "^8",
|