@holo-js/adapter-nuxt 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/.holo-build-fingerprint +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -2
- package/dist/runtime/composables/index.d.ts +8 -0
- package/dist/runtime/composables/index.js +6 -9
- package/dist/runtime/nitro-runtime.d.ts +0 -0
- package/dist/runtime/nitro-runtime.js +9 -0
- package/dist/runtime/plugins/init.js +3 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8f7f9b7bfee9b0a0904d07c909766727fc45d706a012f1ead2158695cf3ac531
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -176,8 +176,12 @@ function resolveProjectPackageTraceEntry(rootDir, packageName) {
|
|
|
176
176
|
return resolveProjectPackageEntry(rootDir, packageName);
|
|
177
177
|
}
|
|
178
178
|
function isProjectPackageLinked(rootDir, packageRootName) {
|
|
179
|
-
const
|
|
180
|
-
|
|
179
|
+
const projectRequire = createRequire(resolve(rootDir, "package.json"));
|
|
180
|
+
for (const nodeModulesPath of projectRequire.resolve.paths(packageRootName) ?? []) {
|
|
181
|
+
const packageStats = lstatSync(resolve(nodeModulesPath, packageRootName), { throwIfNoEntry: false });
|
|
182
|
+
if (packageStats) return packageStats.isSymbolicLink();
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
181
185
|
}
|
|
182
186
|
function addNitroRuntimeTraceIncludes(opts, rootDir, pluginPackages = [], resolvePackage = resolveProjectPackageTraceEntry) {
|
|
183
187
|
const externals = opts.nitro.externals ?? {};
|
|
@@ -33,6 +33,14 @@ export declare function configureHoloRuntimeConfig(config: {
|
|
|
33
33
|
}
|
|
34
34
|
}): void
|
|
35
35
|
export declare function resetHoloRuntimeConfig(): void
|
|
36
|
+
export type NuxtRuntime = {
|
|
37
|
+
readonly useEvent: () => NuxtAuthRequestEvent | undefined
|
|
38
|
+
readonly createAuthorizationError: (decision: {
|
|
39
|
+
readonly message?: string
|
|
40
|
+
readonly status: 200 | 403 | 404
|
|
41
|
+
}) => Error
|
|
42
|
+
}
|
|
43
|
+
export declare function configureNuxtRuntime(runtime: NuxtRuntime): void
|
|
36
44
|
export type NuxtAuthRequestEvent = {
|
|
37
45
|
readonly headers?: Pick<Headers, 'get'>
|
|
38
46
|
readonly request?: {
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
initializeHoloAdapterProject
|
|
6
6
|
} from "@holo-js/core";
|
|
7
7
|
import { createCookieWriteUnavailableError } from "@holo-js/kernel";
|
|
8
|
+
import { getNuxtRuntime } from "../nitro-runtime.js";
|
|
9
|
+
export { configureNuxtRuntime } from "../nitro-runtime.js";
|
|
8
10
|
export function configureHoloRuntimeConfig(config) {
|
|
9
11
|
const runtimeGlobals = globalThis;
|
|
10
12
|
runtimeGlobals.__holoRuntimeConfig = config;
|
|
@@ -26,10 +28,6 @@ function getRuntimeConfig() {
|
|
|
26
28
|
function resolveRuntimeProjectRoot(config) {
|
|
27
29
|
return config.holo.projectRoot?.trim() || process.cwd();
|
|
28
30
|
}
|
|
29
|
-
async function resolveNitroEvent() {
|
|
30
|
-
const { useEvent } = await import("#imports");
|
|
31
|
-
return useEvent();
|
|
32
|
-
}
|
|
33
31
|
export function createNuxtAuthRequestAccessors(requestEvent) {
|
|
34
32
|
function safeDecode(value) {
|
|
35
33
|
try {
|
|
@@ -39,7 +37,7 @@ export function createNuxtAuthRequestAccessors(requestEvent) {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
async function readHeader(name) {
|
|
42
|
-
const event = requestEvent ??
|
|
40
|
+
const event = requestEvent ?? getNuxtRuntime().useEvent();
|
|
43
41
|
if (!event) {
|
|
44
42
|
return void 0;
|
|
45
43
|
}
|
|
@@ -81,7 +79,7 @@ export function createNuxtAuthRequestAccessors(requestEvent) {
|
|
|
81
79
|
return void 0;
|
|
82
80
|
}
|
|
83
81
|
async function resolveResponse() {
|
|
84
|
-
const event = requestEvent ??
|
|
82
|
+
const event = requestEvent ?? getNuxtRuntime().useEvent();
|
|
85
83
|
return event?.node?.res;
|
|
86
84
|
}
|
|
87
85
|
async function appendCookie(cookie) {
|
|
@@ -113,7 +111,7 @@ export function createNuxtAuthRequestAccessors(requestEvent) {
|
|
|
113
111
|
await appendCookie(cookie);
|
|
114
112
|
};
|
|
115
113
|
const redirectResponse = async (url, status) => {
|
|
116
|
-
const event = requestEvent ??
|
|
114
|
+
const event = requestEvent ?? getNuxtRuntime().useEvent();
|
|
117
115
|
const response = event?.node?.res;
|
|
118
116
|
if (!response) {
|
|
119
117
|
throw new TypeError("Holo Nuxt auth redirect requires an active Nitro event.");
|
|
@@ -139,12 +137,11 @@ export async function runWithNuxtRequest(event, callback) {
|
|
|
139
137
|
export const holo = createHoloProjectAccessors(async () => {
|
|
140
138
|
const config = getRuntimeConfig();
|
|
141
139
|
const authRequest = createNuxtAuthRequestAccessors();
|
|
142
|
-
const { createNuxtAuthorizationError } = await import("../authorization-error.js");
|
|
143
140
|
const project = await initializeHoloAdapterProject(resolveRuntimeProjectRoot(config), {
|
|
144
141
|
processEnv: process.env,
|
|
145
142
|
authRequest,
|
|
146
143
|
authorizationError: {
|
|
147
|
-
createError:
|
|
144
|
+
createError: getNuxtRuntime().createAuthorizationError
|
|
148
145
|
}
|
|
149
146
|
});
|
|
150
147
|
const runtimeGlobals = globalThis;
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function configureNuxtRuntime(runtime) {
|
|
2
|
+
const globals = globalThis;
|
|
3
|
+
globals.__holoNuxtRuntime = runtime;
|
|
4
|
+
}
|
|
5
|
+
export function getNuxtRuntime() {
|
|
6
|
+
const runtime = globalThis.__holoNuxtRuntime;
|
|
7
|
+
if (!runtime) throw new TypeError("Holo Nuxt runtime is not configured.");
|
|
8
|
+
return runtime;
|
|
9
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createNuxtAuthRequestAccessors,
|
|
3
|
-
configureHoloRuntimeConfig
|
|
3
|
+
configureHoloRuntimeConfig,
|
|
4
|
+
configureNuxtRuntime
|
|
4
5
|
} from "../composables/index.js";
|
|
5
6
|
import { createNuxtAuthorizationError } from "../authorization-error.js";
|
|
6
7
|
import { connectionAddress } from "../server/connection-address.js";
|
|
@@ -10,6 +11,7 @@ import { captureErrorReporter } from "@holo-js/kernel/error-reporting";
|
|
|
10
11
|
import { defineNitroPlugin, useEvent, useRuntimeConfig } from "#imports";
|
|
11
12
|
export default defineNitroPlugin((nitroApp) => {
|
|
12
13
|
const config = useRuntimeConfig();
|
|
14
|
+
configureNuxtRuntime({ useEvent, createAuthorizationError: createNuxtAuthorizationError });
|
|
13
15
|
configureHoloRuntimeConfig(config);
|
|
14
16
|
requestUrlInternals.provideConnectionAddress(() => connectionAddress(useEvent().node.req.socket));
|
|
15
17
|
const project = initializeHoloAdapterProject(config.holo.projectRoot?.trim() || process.cwd(), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/adapter-nuxt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Holo-JS Framework - Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"test": "vitest --run"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@holo-js/adapter-shared": "^0.4.
|
|
47
|
+
"@holo-js/adapter-shared": "^0.4.2",
|
|
48
48
|
"@nuxt/kit": "^4.6.2",
|
|
49
|
-
"@holo-js/config": "^0.4.
|
|
50
|
-
"@holo-js/core": "^0.4.
|
|
51
|
-
"@holo-js/db": "^0.4.
|
|
52
|
-
"@holo-js/kernel": "^0.4.
|
|
53
|
-
"@holo-js/validation": "^0.4.
|
|
49
|
+
"@holo-js/config": "^0.4.2",
|
|
50
|
+
"@holo-js/core": "^0.4.2",
|
|
51
|
+
"@holo-js/db": "^0.4.2",
|
|
52
|
+
"@holo-js/kernel": "^0.4.2",
|
|
53
|
+
"@holo-js/validation": "^0.4.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"nuxt": "^4.6.2",
|
|
57
57
|
"vue": "^3.5.13",
|
|
58
|
-
"@holo-js/broadcast": "^0.4.
|
|
59
|
-
"@holo-js/forms": "^0.4.
|
|
60
|
-
"@holo-js/realtime": "^0.4.
|
|
61
|
-
"@holo-js/storage": "^0.4.
|
|
62
|
-
"@holo-js/storage-s3": "^0.4.
|
|
58
|
+
"@holo-js/broadcast": "^0.4.2",
|
|
59
|
+
"@holo-js/forms": "^0.4.2",
|
|
60
|
+
"@holo-js/realtime": "^0.4.2",
|
|
61
|
+
"@holo-js/storage": "^0.4.2",
|
|
62
|
+
"@holo-js/storage-s3": "^0.4.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"@holo-js/broadcast": {
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"vue": "^3.5.13",
|
|
83
|
-
"@holo-js/broadcast": "^0.4.
|
|
84
|
-
"@holo-js/realtime": "^0.4.
|
|
85
|
-
"@holo-js/storage-s3": "^0.4.
|
|
83
|
+
"@holo-js/broadcast": "^0.4.2",
|
|
84
|
+
"@holo-js/realtime": "^0.4.2",
|
|
85
|
+
"@holo-js/storage-s3": "^0.4.2",
|
|
86
86
|
"@nuxt/module-builder": "^1.0.2",
|
|
87
87
|
"@types/node": "^22.20.5",
|
|
88
88
|
"nuxt": "^4.6.2",
|