@holo-js/adapter-nuxt 0.3.0 → 0.3.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.d.mts +19 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +131 -6
- package/dist/runtime/server/routes/realtime-mutation.post.d.ts +0 -0
- package/dist/runtime/server/routes/realtime-mutation.post.js +9 -0
- package/dist/runtime/server/routes/realtime-query.post.d.ts +0 -0
- package/dist/runtime/server/routes/realtime-query.post.js +9 -0
- package/dist/runtime/server/routes/realtime-request.d.ts +0 -0
- package/dist/runtime/server/routes/realtime-request.js +14 -0
- package/package.json +14 -14
package/dist/module.d.mts
CHANGED
|
@@ -66,6 +66,17 @@ interface NuxtOptionsWithNitro {
|
|
|
66
66
|
nitro: {
|
|
67
67
|
storage: Record<string, unknown>;
|
|
68
68
|
errorHandler?: string | string[];
|
|
69
|
+
externals?: {
|
|
70
|
+
external?: unknown[];
|
|
71
|
+
inline?: unknown[];
|
|
72
|
+
trace?: boolean;
|
|
73
|
+
traceInclude?: string[];
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
rollupConfig?: {
|
|
77
|
+
preserveSymlinks?: boolean;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
};
|
|
69
80
|
virtual?: Record<string, () => string>;
|
|
70
81
|
experimental?: {
|
|
71
82
|
asyncContext?: boolean;
|
|
@@ -99,6 +110,10 @@ interface NuxtOptionsWithNitro {
|
|
|
99
110
|
_holoTypesRegistered?: boolean;
|
|
100
111
|
}
|
|
101
112
|
declare function hasProjectPackage(rootDir: string, packageName: string, resolvePackage?: (packageName: string) => string): boolean;
|
|
113
|
+
declare function resolveProjectPackageEntry(rootDir: string, packageName: string, resolvePackage?: (packageName: string) => string): string | undefined;
|
|
114
|
+
declare function resolveProjectPackageTraceEntry(rootDir: string, packageName: string): string | undefined;
|
|
115
|
+
declare function isProjectPackageLinked(rootDir: string, packageRootName: string): boolean;
|
|
116
|
+
declare function addNitroRuntimeTraceIncludes(opts: NuxtOptionsWithNitro, rootDir: string, pluginPackages?: readonly string[], resolvePackage?: (rootDir: string, packageName: string) => string | undefined): void;
|
|
102
117
|
declare function resolveClientOptimizeDeps(rootDir: string): string[];
|
|
103
118
|
declare function addViteOptimizeDeps(opts: NuxtOptionsWithNitro, deps: readonly string[]): void;
|
|
104
119
|
declare function isRealtimeDefinitionModule(_rootDir: string, id: string): boolean;
|
|
@@ -131,6 +146,7 @@ declare const moduleInternals: {
|
|
|
131
146
|
addViteOptimizeDeps: typeof addViteOptimizeDeps;
|
|
132
147
|
addVitePlugin: typeof addVitePlugin;
|
|
133
148
|
addNitroErrorHandler: typeof addNitroErrorHandler;
|
|
149
|
+
addNitroRuntimeTraceIncludes: typeof addNitroRuntimeTraceIncludes;
|
|
134
150
|
createRealtimeDefinitionVitePlugin: typeof createRealtimeDefinitionVitePlugin;
|
|
135
151
|
existsFile: typeof existsFile;
|
|
136
152
|
hasProjectPackage: typeof hasProjectPackage;
|
|
@@ -141,6 +157,9 @@ declare const moduleInternals: {
|
|
|
141
157
|
finalizeStorageSetup: typeof finalizeStorageSetup;
|
|
142
158
|
resolveStorageSetup: typeof resolveStorageSetup;
|
|
143
159
|
isModuleResolutionFailure: typeof isModuleResolutionFailure;
|
|
160
|
+
resolveProjectPackageEntry: typeof resolveProjectPackageEntry;
|
|
161
|
+
resolveProjectPackageTraceEntry: typeof resolveProjectPackageTraceEntry;
|
|
162
|
+
isProjectPackageLinked: typeof isProjectPackageLinked;
|
|
144
163
|
isRealtimeDefinitionModule: typeof isRealtimeDefinitionModule;
|
|
145
164
|
resolveClientOptimizeDeps: typeof resolveClientOptimizeDeps;
|
|
146
165
|
resolveExistingRealtimeDefinitionFile: typeof resolveExistingRealtimeDefinitionFile;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
1
|
+
import { lstatSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { readdir, mkdir, writeFile, access } from 'node:fs/promises';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { resolve, extname, relative, basename, dirname } from 'node:path';
|
|
@@ -27,6 +27,68 @@ const CLIENT_OPTIMIZE_DEPS = [
|
|
|
27
27
|
include: `${HOLO_PACKAGE_SCOPE}validation > valibot`
|
|
28
28
|
}
|
|
29
29
|
];
|
|
30
|
+
const NITRO_RUNTIME_TRACE_IMPORTS = [
|
|
31
|
+
"@holo-js/auth-clerk",
|
|
32
|
+
"@holo-js/auth-social",
|
|
33
|
+
"@holo-js/auth-workos",
|
|
34
|
+
"@holo-js/authorization",
|
|
35
|
+
"@holo-js/broadcast",
|
|
36
|
+
"@holo-js/cache",
|
|
37
|
+
"@holo-js/cache-db",
|
|
38
|
+
"@holo-js/cache-redis",
|
|
39
|
+
"@holo-js/db-mysql",
|
|
40
|
+
"@holo-js/db-postgres",
|
|
41
|
+
"@holo-js/db-sqlite",
|
|
42
|
+
"@holo-js/events",
|
|
43
|
+
"@holo-js/mail",
|
|
44
|
+
"@holo-js/media",
|
|
45
|
+
"@holo-js/notifications",
|
|
46
|
+
"@holo-js/queue",
|
|
47
|
+
"@holo-js/queue-db",
|
|
48
|
+
"@holo-js/queue-redis",
|
|
49
|
+
"@holo-js/security",
|
|
50
|
+
"@holo-js/security/drivers/redis-adapter",
|
|
51
|
+
"@holo-js/session",
|
|
52
|
+
"@holo-js/session/drivers/redis-adapter",
|
|
53
|
+
"@holo-js/storage",
|
|
54
|
+
"@holo-js/storage/runtime",
|
|
55
|
+
"@holo-js/storage-s3"
|
|
56
|
+
];
|
|
57
|
+
const NITRO_RUNTIME_EXTERNALS = [
|
|
58
|
+
"@holo-js/auth",
|
|
59
|
+
"@holo-js/auth-clerk",
|
|
60
|
+
"@holo-js/auth-social",
|
|
61
|
+
"@holo-js/auth-workos",
|
|
62
|
+
"@holo-js/authorization",
|
|
63
|
+
"@holo-js/broadcast",
|
|
64
|
+
"@holo-js/cache",
|
|
65
|
+
"@holo-js/cache-db",
|
|
66
|
+
"@holo-js/cache-redis",
|
|
67
|
+
"@holo-js/config",
|
|
68
|
+
"@holo-js/core",
|
|
69
|
+
"@holo-js/db",
|
|
70
|
+
"@holo-js/db-mysql",
|
|
71
|
+
"@holo-js/db-postgres",
|
|
72
|
+
"@holo-js/db-sqlite",
|
|
73
|
+
"@holo-js/events",
|
|
74
|
+
"@holo-js/kernel",
|
|
75
|
+
"@holo-js/mail",
|
|
76
|
+
"@holo-js/media",
|
|
77
|
+
"@holo-js/notifications",
|
|
78
|
+
"@holo-js/queue",
|
|
79
|
+
"@holo-js/queue-db",
|
|
80
|
+
"@holo-js/queue-redis",
|
|
81
|
+
"@holo-js/realtime",
|
|
82
|
+
"@holo-js/security",
|
|
83
|
+
"@holo-js/session",
|
|
84
|
+
"@holo-js/storage",
|
|
85
|
+
"@holo-js/storage-s3",
|
|
86
|
+
"@holo-js/validation"
|
|
87
|
+
];
|
|
88
|
+
const NITRO_RUNTIME_INLINE_IMPORTS = [
|
|
89
|
+
"@holo-js/auth/nuxt",
|
|
90
|
+
"@holo-js/auth/nuxt/server"
|
|
91
|
+
];
|
|
30
92
|
function escapeRegExp(value) {
|
|
31
93
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
32
94
|
}
|
|
@@ -58,16 +120,58 @@ function isModuleResolutionFailure(error) {
|
|
|
58
120
|
return "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND");
|
|
59
121
|
}
|
|
60
122
|
function hasProjectPackage(rootDir, packageName, resolvePackage = createRequire(resolve(rootDir, "package.json")).resolve) {
|
|
123
|
+
return typeof resolveProjectPackageEntry(rootDir, packageName, resolvePackage) === "string";
|
|
124
|
+
}
|
|
125
|
+
function resolveProjectPackageEntry(rootDir, packageName, resolvePackage = createRequire(resolve(rootDir, "package.json")).resolve) {
|
|
61
126
|
try {
|
|
62
|
-
resolvePackage(packageName);
|
|
63
|
-
return true;
|
|
127
|
+
return resolvePackage(packageName);
|
|
64
128
|
} catch (error) {
|
|
65
129
|
if (isModuleResolutionFailure(error)) {
|
|
66
|
-
return
|
|
130
|
+
return void 0;
|
|
67
131
|
}
|
|
68
132
|
throw error;
|
|
69
133
|
}
|
|
70
134
|
}
|
|
135
|
+
function resolveProjectPackageTraceEntry(rootDir, packageName) {
|
|
136
|
+
const packageSegments = packageName.split("/");
|
|
137
|
+
const packageRootName = packageName.startsWith("@") ? packageSegments.slice(0, 2).join("/") : packageSegments[0];
|
|
138
|
+
if (!packageRootName) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
if (isProjectPackageLinked(rootDir, packageRootName)) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
return resolveProjectPackageEntry(rootDir, packageName);
|
|
145
|
+
}
|
|
146
|
+
function isProjectPackageLinked(rootDir, packageRootName) {
|
|
147
|
+
const projectPackageRoot = resolve(rootDir, "node_modules", packageRootName);
|
|
148
|
+
return lstatSync(projectPackageRoot, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
149
|
+
}
|
|
150
|
+
function addNitroRuntimeTraceIncludes(opts, rootDir, pluginPackages = [], resolvePackage = resolveProjectPackageTraceEntry) {
|
|
151
|
+
const externals = opts.nitro.externals ?? {};
|
|
152
|
+
const external = new Set(externals.external ?? []);
|
|
153
|
+
const inline = new Set(externals.inline ?? []);
|
|
154
|
+
const traceInclude = new Set(externals.traceInclude ?? []);
|
|
155
|
+
for (const specifier of NITRO_RUNTIME_EXTERNALS) {
|
|
156
|
+
external.add(specifier);
|
|
157
|
+
}
|
|
158
|
+
for (const specifier of NITRO_RUNTIME_INLINE_IMPORTS) {
|
|
159
|
+
inline.add(specifier);
|
|
160
|
+
}
|
|
161
|
+
for (const specifier of [...NITRO_RUNTIME_TRACE_IMPORTS, ...pluginPackages]) {
|
|
162
|
+
const packageEntry = resolvePackage(rootDir, specifier);
|
|
163
|
+
if (packageEntry) {
|
|
164
|
+
traceInclude.add(packageEntry);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
opts.nitro.externals = {
|
|
168
|
+
...externals,
|
|
169
|
+
external: [...external],
|
|
170
|
+
inline: [...inline],
|
|
171
|
+
trace: isProjectPackageLinked(rootDir, "@holo-js/core") ? false : externals.trace,
|
|
172
|
+
traceInclude: [...traceInclude]
|
|
173
|
+
};
|
|
174
|
+
}
|
|
71
175
|
function resolveClientOptimizeDeps(rootDir) {
|
|
72
176
|
const projectRequire = createRequire(resolve(rootDir, "package.json"));
|
|
73
177
|
const deps = [];
|
|
@@ -303,6 +407,13 @@ const module$1 = defineNuxtModule({
|
|
|
303
407
|
const s3Driver = resolver.resolve("./runtime/drivers/s3.js");
|
|
304
408
|
opts.nitro = opts.nitro || { storage: {} };
|
|
305
409
|
opts.nitro.storage = opts.nitro.storage || {};
|
|
410
|
+
if (isProjectPackageLinked(rootDir, "@holo-js/core")) {
|
|
411
|
+
opts.nitro.rollupConfig = {
|
|
412
|
+
...opts.nitro.rollupConfig,
|
|
413
|
+
preserveSymlinks: true
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
addNitroRuntimeTraceIncludes(opts, rootDir, loaded.app.plugins);
|
|
306
417
|
addNitroErrorHandler(opts, resolver.resolve("./runtime/server/error"));
|
|
307
418
|
opts.nitro.experimental = {
|
|
308
419
|
...opts.nitro.experimental || {},
|
|
@@ -374,14 +485,24 @@ const module$1 = defineNuxtModule({
|
|
|
374
485
|
src: resolver.resolve("./runtime/plugins/realtime"),
|
|
375
486
|
mode: "all"
|
|
376
487
|
});
|
|
488
|
+
addServerHandler({
|
|
489
|
+
route: "/holo/realtime/query",
|
|
490
|
+
handler: resolver.resolve("./runtime/server/routes/realtime-query.post")
|
|
491
|
+
});
|
|
492
|
+
addServerHandler({
|
|
493
|
+
route: "/holo/realtime/mutation",
|
|
494
|
+
handler: resolver.resolve("./runtime/server/routes/realtime-mutation.post")
|
|
495
|
+
});
|
|
377
496
|
opts._holoRealtimeRouteRegistered = true;
|
|
378
497
|
}
|
|
379
498
|
if (storageModule && normalizedStorage && (!opts.nitro.storage || Object.keys(opts.nitro.storage).every((key) => !key.startsWith("holo:")))) {
|
|
380
499
|
storageModule.applyNitroStorageConfig(opts, normalizedStorage, s3Driver);
|
|
381
500
|
}
|
|
382
501
|
const runtimePath = resolver.resolve("./runtime");
|
|
383
|
-
|
|
384
|
-
opts.build.transpile.
|
|
502
|
+
for (const packageName of [runtimePath, "@holo-js/auth"]) {
|
|
503
|
+
if (!opts.build.transpile.includes(packageName)) {
|
|
504
|
+
opts.build.transpile.push(packageName);
|
|
505
|
+
}
|
|
385
506
|
}
|
|
386
507
|
if (storageModule && !opts._holoStorageFinalizeRegistered) {
|
|
387
508
|
opts._holoStorageFinalizeRegistered = true;
|
|
@@ -407,6 +528,7 @@ const moduleInternals = {
|
|
|
407
528
|
addViteOptimizeDeps,
|
|
408
529
|
addVitePlugin,
|
|
409
530
|
addNitroErrorHandler,
|
|
531
|
+
addNitroRuntimeTraceIncludes,
|
|
410
532
|
createRealtimeDefinitionVitePlugin,
|
|
411
533
|
existsFile,
|
|
412
534
|
hasProjectPackage,
|
|
@@ -417,6 +539,9 @@ const moduleInternals = {
|
|
|
417
539
|
finalizeStorageSetup,
|
|
418
540
|
resolveStorageSetup,
|
|
419
541
|
isModuleResolutionFailure,
|
|
542
|
+
resolveProjectPackageEntry,
|
|
543
|
+
resolveProjectPackageTraceEntry,
|
|
544
|
+
isProjectPackageLinked,
|
|
420
545
|
isRealtimeDefinitionModule,
|
|
421
546
|
resolveClientOptimizeDeps,
|
|
422
547
|
resolveExistingRealtimeDefinitionFile,
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { handleRealtimeMutationRequest } from "@holo-js/realtime/server";
|
|
4
|
+
import { createRealtimeRequest } from "./realtime-request.js";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
return await handleRealtimeMutationRequest(await createRealtimeRequest(event), {
|
|
7
|
+
projectRoot: useRuntimeConfig().holo.projectRoot ?? process.cwd()
|
|
8
|
+
});
|
|
9
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { handleRealtimeQueryRequest } from "@holo-js/realtime/server";
|
|
4
|
+
import { createRealtimeRequest } from "./realtime-request.js";
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
return await handleRealtimeQueryRequest(await createRealtimeRequest(event), {
|
|
7
|
+
projectRoot: useRuntimeConfig().holo.projectRoot ?? process.cwd()
|
|
8
|
+
});
|
|
9
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getHeaders, getRequestURL, readRawBody } from "h3";
|
|
2
|
+
export async function createRealtimeRequest(event) {
|
|
3
|
+
const headers = new Headers();
|
|
4
|
+
for (const [key, value] of Object.entries(getHeaders(event))) {
|
|
5
|
+
if (typeof value === "string") {
|
|
6
|
+
headers.set(key, value);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return new Request(getRequestURL(event), {
|
|
10
|
+
body: await readRawBody(event),
|
|
11
|
+
headers,
|
|
12
|
+
method: event.method
|
|
13
|
+
});
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/adapter-nuxt",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Holo-JS Framework - Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
"test": "vitest --run"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@holo-js/adapter-shared": "^0.3.
|
|
41
|
+
"@holo-js/adapter-shared": "^0.3.2",
|
|
42
42
|
"@nuxt/kit": "^4.4.4",
|
|
43
|
-
"@holo-js/config": "^0.3.
|
|
44
|
-
"@holo-js/core": "^0.3.
|
|
45
|
-
"@holo-js/db": "^0.3.
|
|
46
|
-
"@holo-js/validation": "^0.3.
|
|
43
|
+
"@holo-js/config": "^0.3.2",
|
|
44
|
+
"@holo-js/core": "^0.3.2",
|
|
45
|
+
"@holo-js/db": "^0.3.2",
|
|
46
|
+
"@holo-js/validation": "^0.3.2",
|
|
47
47
|
"h3": "^1.15.11"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@holo-js/broadcast": "^0.3.
|
|
51
|
-
"@holo-js/forms": "^0.3.
|
|
52
|
-
"@holo-js/realtime": "^0.3.
|
|
53
|
-
"@holo-js/storage": "^0.3.
|
|
54
|
-
"@holo-js/storage-s3": "^0.3.
|
|
50
|
+
"@holo-js/broadcast": "^0.3.2",
|
|
51
|
+
"@holo-js/forms": "^0.3.2",
|
|
52
|
+
"@holo-js/realtime": "^0.3.2",
|
|
53
|
+
"@holo-js/storage": "^0.3.2",
|
|
54
|
+
"@holo-js/storage-s3": "^0.3.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@holo-js/broadcast": {
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@holo-js/broadcast": "^0.3.
|
|
75
|
-
"@holo-js/realtime": "^0.3.
|
|
76
|
-
"@holo-js/storage-s3": "^0.3.
|
|
74
|
+
"@holo-js/broadcast": "^0.3.2",
|
|
75
|
+
"@holo-js/realtime": "^0.3.2",
|
|
76
|
+
"@holo-js/storage-s3": "^0.3.2",
|
|
77
77
|
"@nuxt/module-builder": "^1.0.2",
|
|
78
78
|
"@types/node": "^22.10.2",
|
|
79
79
|
"nuxt": "^4.4.4",
|