@lunora/nuxt 1.0.0-alpha.9 → 1.0.0-alpha.90
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/LICENSE.md +6 -0
- package/README.md +20 -10
- package/dist/module.d.ts +36 -0
- package/dist/module.js +1 -0
- package/dist/module.json +2 -6
- package/dist/runtime/cloudflare.d.ts +28 -16
- package/dist/runtime/cloudflare.js +1 -12
- package/dist/runtime/h3-request.d.ts +15 -3
- package/dist/runtime/h3-request.js +1 -2
- package/dist/runtime/handler.d.ts +16 -5
- package/dist/runtime/handler.js +1 -17
- package/dist/runtime/server/lunora.d.ts +92 -3
- package/dist/runtime/server/lunora.js +1 -10
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/package.json +13 -12
- package/dist/module.d.mts +0 -9
- package/dist/module.mjs +0 -29
- package/dist/server.d.mts +0 -1
- package/dist/server.mjs +0 -1
- package/dist/types.d.mts +0 -7
package/LICENSE.md
CHANGED
|
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
|
|
|
103
103
|
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
104
|
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
105
|
specific language governing permissions and limitations under the License.
|
|
106
|
+
|
|
107
|
+
<!-- DEPENDENCIES -->
|
|
108
|
+
<!-- /DEPENDENCIES -->
|
|
109
|
+
|
|
110
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
111
|
+
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -59,14 +59,23 @@ export default defineNuxtConfig({
|
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Add `
|
|
63
|
-
class is exported from the
|
|
62
|
+
Add a `worker.ts` wrapper at the project root and point `wrangler.jsonc`'s `main`
|
|
63
|
+
at it, so the `ShardDO` Durable Object class is exported from the deployed worker.
|
|
64
|
+
Nitro's `cloudflare_module` output exports only the SSR handler, so `main` must
|
|
65
|
+
point at the wrapper — not the raw `.output/server/index.mjs` — or `wrangler deploy`
|
|
66
|
+
fails on the missing DO class:
|
|
64
67
|
|
|
65
68
|
```ts
|
|
66
|
-
//
|
|
69
|
+
// worker.ts
|
|
70
|
+
export { default } from "./.output/server/index.mjs";
|
|
67
71
|
export { ShardDO } from "./lunora/server";
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
```jsonc
|
|
75
|
+
// wrangler.jsonc
|
|
76
|
+
{ "main": "worker.ts" }
|
|
77
|
+
```
|
|
78
|
+
|
|
70
79
|
`lunora/server.ts` is your built Lunora app (`defineApp().build()`) — its default
|
|
71
80
|
export is the worker (a `fetch` entrypoint), and it re-exports `ShardDO`. The
|
|
72
81
|
module aliases the `#lunora/app` virtual to it (configurable via the `lunora.appEntry`
|
|
@@ -88,8 +97,8 @@ option, default `~/lunora/server`) and serves it at the `/_lunora/**` route
|
|
|
88
97
|
and forwards to your app's `fetch`. A missing Cloudflare runtime answers a clear 500.
|
|
89
98
|
- **`#lunora/app` alias**: points the route's worker import at your app entry,
|
|
90
99
|
forwarded into the Nitro server bundle via `nuxt.options.alias`.
|
|
91
|
-
- **`ShardDO`** rides to the worker
|
|
92
|
-
(
|
|
100
|
+
- **`ShardDO`** rides to the deployed worker through your root `worker.ts` wrapper
|
|
101
|
+
(`wrangler.jsonc`'s `main`), which re-exports Nitro's SSR handler and `ShardDO`.
|
|
93
102
|
|
|
94
103
|
## Verify before deploy
|
|
95
104
|
|
|
@@ -102,11 +111,12 @@ Single-worker composition rides on two Nitro behaviours that vary across version
|
|
|
102
111
|
subscriptions never connect while RPC does, Nitro is normalising the upgrade
|
|
103
112
|
response and `/_lunora/ws` needs a deploy-boundary handoff instead of the H3
|
|
104
113
|
route return.
|
|
105
|
-
2. **`
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
module `warn()`s when
|
|
114
|
+
2. **`worker.ts` wrapper.** `wrangler.jsonc`'s `main` must point at a root
|
|
115
|
+
`worker.ts` that re-exports Nitro's SSR handler _and_ `ShardDO` — Nitro's
|
|
116
|
+
`cloudflare_module` output exports only the SSR handler. If `wrangler deploy`
|
|
117
|
+
fails with "ShardDO class not exported", check that `main` points at the
|
|
118
|
+
wrapper and that it re-exports `ShardDO`. The module `warn()`s when
|
|
119
|
+
`worker.ts` is missing but can't verify wrangler's `main` points at it.
|
|
110
120
|
|
|
111
121
|
## Server data-loading
|
|
112
122
|
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
|
+
/**
|
|
3
|
+
* Check that `worker.ts` at the project root actually re-exports `ShardDO` —
|
|
4
|
+
* not just that the file exists. Extracted from `setup()` so it is testable
|
|
5
|
+
* without booting Nuxt (`defineNuxtModule`'s `setup` needs full Nuxt Kit
|
|
6
|
+
* scaffolding to invoke; this plain function does not).
|
|
7
|
+
*
|
|
8
|
+
* All three outcomes — missing file, unreadable file, present-but-no-`ShardDO`-
|
|
9
|
+
* export — WARN and return; none of them throws. Matches the module's existing
|
|
10
|
+
* stance ("we can't write the user's file, so warn... rather than fail an
|
|
11
|
+
* otherwise-valid build") and the `@lunora/astro` precedent this mirrors.
|
|
12
|
+
*/
|
|
13
|
+
declare const checkWorkerEntry: (rootDirectory: string, warn: (message: string) => void) => void;
|
|
14
|
+
/** Options for the `@lunora/nuxt` module (configurable under the `lunora` key in `nuxt.config`). */
|
|
15
|
+
interface ModuleOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Module specifier of the Lunora app entry — its default export is the built
|
|
18
|
+
* worker (`defineApp().build()` / `createWorker(...)`) and it re-exports
|
|
19
|
+
* `ShardDO`. Aliased to the `#lunora/app` virtual the server route imports.
|
|
20
|
+
*/
|
|
21
|
+
appEntry: string;
|
|
22
|
+
/** URL prefix Lunora realtime is mounted at. */
|
|
23
|
+
prefix: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Return type of `defineNuxtModule<ModuleOptions>({...})` — the value overload of
|
|
27
|
+
* `defineNuxtModule` (the one taking a definition), extracted structurally so the
|
|
28
|
+
* default export has a locally-nameable type under `isolatedDeclarations` without
|
|
29
|
+
* importing `NuxtModule` from `@nuxt/schema` (not a resolvable dependency here).
|
|
30
|
+
*/
|
|
31
|
+
type LunoraNuxtModule = typeof defineNuxtModule<ModuleOptions> extends {
|
|
32
|
+
(definition: infer _Definition): infer Result;
|
|
33
|
+
(): unknown;
|
|
34
|
+
} ? Result : never;
|
|
35
|
+
declare const lunoraNuxtModule: LunoraNuxtModule;
|
|
36
|
+
export { ModuleOptions, checkWorkerEntry, lunoraNuxtModule as default };
|
package/dist/module.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as i,readFileSync as u}from"node:fs";import{join as s,resolve as d,dirname as p}from"node:path";import{defineNuxtModule as h,createResolver as c,addServerHandler as f,useLogger as m}from"@nuxt/kit";const S=(r,t,o)=>r.startsWith("~~/")?s(t,r.slice(3)):r.startsWith("~/")?s(o,r.slice(2)):r.startsWith("./")||r.startsWith("../")?s(t,r):r,v=/\.js$/,D=r=>{const t=s(r,"lunora");return{name:"lunora:nitro-ts-source-resolve",resolveId:{handler(o,e){if(!o.endsWith(".js"))return;let n;if(o.startsWith("#lunora/")?n=s(t,o.slice(8)):o.startsWith(".")&&e!==void 0&&(n=d(p(e),o)),n===void 0)return;const a=n.replace(v,".ts");return i(a)?a:void 0},order:"pre"}}},l='export { default } from "./.output/server/index.mjs"; export { ShardDO } from "./lunora/server";',E=/\bexport\b/u,R=/\bShardDO\b/u,g=/\bexport\s*\*\s*from\s*["'][^"']*lunora[^"']*["']/u,x=r=>E.test(r)?R.test(r)||g.test(r):!1,O=(r,t)=>{const o=s(r,"worker.ts");if(!i(o)){t(`missing worker.ts at the project root — add a wrapper that re-exports Nitro's handler and \`ShardDO\` (\`${l}\`) and point wrangler's \`main\` at it, so the SHARD Durable Object is exported from the deployed worker.`);return}let e;try{e=u(o,"utf8")}catch(n){const a=n instanceof Error?n.message:String(n);t(`could not read worker.ts at the project root (${a}) — skipping the \`ShardDO\` export check.`);return}x(e)||t(`worker.ts at the project root does not appear to export \`ShardDO\` — add \`export { ShardDO } from "./lunora/server";\` (e.g. \`${l}\`) and point wrangler's \`main\` at it, so the SHARD Durable Object is exported from the deployed worker.`)},N=h({defaults:{appEntry:"~/lunora/server",prefix:"/_lunora"},meta:{configKey:"lunora",name:"@lunora/nuxt"},setup(r,t){const o=c(import.meta.url);t.options.alias["#lunora/app"]=S(r.appEntry,t.options.rootDir,t.options.srcDir),t.hook("nitro:config",e=>{const n=[...e.rollupConfig?.plugins??[],D(t.options.rootDir)];e.rollupConfig={...e.rollupConfig,plugins:n}}),f({handler:o.resolve("./runtime/server/lunora"),route:`${r.prefix}/**`}),O(t.options.rootDir,e=>{m("@lunora/nuxt").warn(e)})}});export{O as checkWorkerEntry,N as default};
|
package/dist/module.json
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExecutionContextLike } from '@lunora/runtime';
|
|
2
|
+
export type { ExecutionContextLike } from '@lunora/runtime';
|
|
3
|
+
/** The `{ env, context|ctx }` payload Nitro attaches for the Cloudflare runtime. */
|
|
2
4
|
interface CloudflareEventBag {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
context?: ExecutionContextLike;
|
|
6
|
+
ctx?: ExecutionContextLike;
|
|
7
|
+
env?: Record<string, unknown>;
|
|
6
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Structural view of the bits of an H3 event the resolver reads. Both legacy
|
|
11
|
+
* (`context.cloudflare`) and current (`req.runtime.cloudflare`) shapes are
|
|
12
|
+
* optional so a real H3 `H3Event` is assignable here.
|
|
13
|
+
*/
|
|
7
14
|
interface H3EventLike {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
+
context?: {
|
|
16
|
+
cloudflare?: CloudflareEventBag;
|
|
17
|
+
};
|
|
18
|
+
req?: {
|
|
19
|
+
runtime?: {
|
|
20
|
+
cloudflare?: CloudflareEventBag;
|
|
15
21
|
};
|
|
22
|
+
};
|
|
16
23
|
}
|
|
24
|
+
/** Resolved Cloudflare runtime for one request: the bindings `env` and the optional `ExecutionContext`. */
|
|
17
25
|
interface ResolvedCloudflare {
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
ctx?: ExecutionContextLike;
|
|
27
|
+
env?: Record<string, unknown>;
|
|
20
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Pull the Cloudflare `env` + `ExecutionContext` off a Nitro/H3 event, checking
|
|
31
|
+
* the legacy `event.context.cloudflare` shape first (present under
|
|
32
|
+
* `nitro-cloudflare-dev` in dev) and the newer `event.req.runtime.cloudflare`
|
|
33
|
+
* shape second. Returns `{}` when neither is present.
|
|
34
|
+
*/
|
|
21
35
|
declare const resolveCloudflare: (event: H3EventLike) => ResolvedCloudflare;
|
|
22
|
-
export type
|
|
23
|
-
export { resolveCloudflare };
|
|
24
|
-
export { type ExecutionContextLike } from "../../../../shared/execution-context.js";
|
|
36
|
+
export { type H3EventLike, type ResolvedCloudflare, resolveCloudflare };
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const fromContext = event.context?.cloudflare;
|
|
3
|
-
if (fromContext?.env) {
|
|
4
|
-
return { ctx: fromContext.context ?? fromContext.ctx, env: fromContext.env };
|
|
5
|
-
}
|
|
6
|
-
const fromRuntime = event.req?.runtime?.cloudflare;
|
|
7
|
-
if (fromRuntime?.env) {
|
|
8
|
-
return { ctx: fromRuntime.ctx ?? fromRuntime.context, env: fromRuntime.env };
|
|
9
|
-
}
|
|
10
|
-
return {};
|
|
11
|
-
};
|
|
12
|
-
export { resolveCloudflare };
|
|
1
|
+
const r=n=>{const e=n.context?.cloudflare;if(e?.env)return{ctx:e.context??e.ctx,env:e.env};const t=n.req?.runtime?.cloudflare;return t?.env?{ctx:t.ctx??t.context,env:t.env}:{}};export{r as resolveCloudflare};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the inbound web `Request` from an H3 event across the h3 v1 → v2 break.
|
|
3
|
+
*
|
|
4
|
+
* v1 exposes `toWebRequest(event)`; the v2 web-standards rewrite removed it and
|
|
5
|
+
* carries the web `Request` directly as `event.req`. The `@lunora/nuxt` peer is
|
|
6
|
+
* `h3: "^1.15.0"` (v1 — what Nuxt 4 / Nitro 2 run today); the v2 `event.req`
|
|
7
|
+
* branch is forward-compat for when a stable h3 v2 ships and the peer widens. We
|
|
8
|
+
* feature-detect `toWebRequest` at runtime rather than importing it statically —
|
|
9
|
+
* a named `import { toWebRequest }` would throw at module-eval under v2 (missing export).
|
|
10
|
+
*
|
|
11
|
+
* Kept as a pure helper (the `h3` namespace + event in, a `Request` out) so both
|
|
12
|
+
* branches are unit-tested without booting Nitro or installing a second h3 major.
|
|
13
|
+
*/
|
|
1
14
|
interface H3RequestNamespace {
|
|
2
|
-
|
|
15
|
+
toWebRequest?: unknown;
|
|
3
16
|
}
|
|
4
17
|
declare const resolveWebRequest: (h3: H3RequestNamespace, event: unknown) => Request;
|
|
5
|
-
export type
|
|
6
|
-
export { resolveWebRequest };
|
|
18
|
+
export { type H3RequestNamespace, resolveWebRequest };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
export { resolveWebRequest };
|
|
1
|
+
const o=(e,t)=>typeof e.toWebRequest=="function"?e.toWebRequest(t):t.req;export{o as resolveWebRequest};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExecutionContextLike } from '@lunora/runtime';
|
|
2
|
+
export { NOOP_EXECUTION_CONTEXT } from '@lunora/runtime';
|
|
3
|
+
/**
|
|
4
|
+
* Structural view of the Lunora worker the route delegates to — just the
|
|
5
|
+
* `fetch` entrypoint. Both `createWorker(...)` and the generated
|
|
6
|
+
* `defineApp().build()` app satisfy it (a `ComposedApp` is a superset). Declared
|
|
7
|
+
* locally so `@lunora/nuxt` doesn't hard-depend on `@lunora/runtime`'s worker type.
|
|
8
|
+
*/
|
|
2
9
|
interface LunoraWorkerLike {
|
|
3
|
-
|
|
10
|
+
fetch: (request: Request, env: unknown, context: ExecutionContextLike) => Promise<Response> | Response;
|
|
4
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Forward one inbound request to the Lunora worker. `env` must be the Cloudflare
|
|
14
|
+
* bindings (carrying the `SHARD` Durable Object namespace); when it is missing
|
|
15
|
+
* the Cloudflare runtime wasn't available (e.g. a non-CF preview), so we answer
|
|
16
|
+
* a clear 500 rather than handing the worker an `undefined` env.
|
|
17
|
+
*/
|
|
5
18
|
declare const delegateToLunora: (worker: LunoraWorkerLike, request: Request, env: Record<string, unknown> | undefined, context?: ExecutionContextLike) => Promise<Response>;
|
|
6
|
-
export type
|
|
7
|
-
export { delegateToLunora };
|
|
8
|
-
export { NOOP_EXECUTION_CONTEXT } from "../../../../shared/execution-context.js";
|
|
19
|
+
export { type LunoraWorkerLike, delegateToLunora };
|
package/dist/runtime/handler.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const delegateToLunora = async (worker, request, env, context) => {
|
|
3
|
-
if (!env) {
|
|
4
|
-
return Response.json(
|
|
5
|
-
{
|
|
6
|
-
error: {
|
|
7
|
-
code: "LUNORA_RUNTIME_UNAVAILABLE",
|
|
8
|
-
message: "Lunora could not read the Cloudflare bindings from the request. The `/_lunora/**` route only works on the Cloudflare Workers runtime (deployed, or `nuxt dev` with `nitro-cloudflare-dev`)."
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
{ status: 500 }
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
return worker.fetch(request, env, context ?? NOOP_EXECUTION_CONTEXT);
|
|
15
|
-
};
|
|
16
|
-
export { delegateToLunora };
|
|
17
|
-
export { NOOP_EXECUTION_CONTEXT } from "../../../../shared/execution-context";
|
|
1
|
+
import{NOOP_EXECUTION_CONTEXT as n}from"@lunora/runtime";import{NOOP_EXECUTION_CONTEXT as l}from"@lunora/runtime";const s=async(o,r,e,t)=>e?o.fetch(r,e,t??n):Response.json({error:{code:"LUNORA_RUNTIME_UNAVAILABLE",message:"Lunora could not read the Cloudflare bindings from the request. The `/_lunora/**` route only works on the Cloudflare Workers runtime (deployed, or `nuxt dev` with `nitro-cloudflare-dev`)."}},{status:500});export{l as NOOP_EXECUTION_CONTEXT,s as delegateToLunora};
|
|
@@ -1,3 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { QueryObject } from 'ufo';
|
|
2
|
+
import { Hooks } from 'crossws';
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
+
interface NodeEventContext {
|
|
5
|
+
req: IncomingMessage & {
|
|
6
|
+
originalUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
res: ServerResponse;
|
|
9
|
+
}
|
|
10
|
+
interface WebEventContext {
|
|
11
|
+
request?: Request;
|
|
12
|
+
url?: URL;
|
|
13
|
+
}
|
|
14
|
+
declare class H3Event<_RequestT extends EventHandlerRequest = EventHandlerRequest> implements Pick<FetchEvent, "respondWith"> {
|
|
15
|
+
"__is_event__": boolean;
|
|
16
|
+
node: NodeEventContext;
|
|
17
|
+
web?: WebEventContext;
|
|
18
|
+
context: H3EventContext;
|
|
19
|
+
_method?: HTTPMethod;
|
|
20
|
+
_path?: string;
|
|
21
|
+
_headers?: Headers;
|
|
22
|
+
_requestBody?: BodyInit;
|
|
23
|
+
_handled: boolean;
|
|
24
|
+
_onBeforeResponseCalled: boolean | undefined;
|
|
25
|
+
_onAfterResponseCalled: boolean | undefined;
|
|
26
|
+
constructor(req: IncomingMessage, res: ServerResponse);
|
|
27
|
+
get method(): HTTPMethod;
|
|
28
|
+
get path(): string;
|
|
29
|
+
get headers(): Headers;
|
|
30
|
+
get handled(): boolean;
|
|
31
|
+
respondWith(response: Response | PromiseLike<Response>): Promise<void>;
|
|
32
|
+
toString(): string;
|
|
33
|
+
toJSON(): string;
|
|
34
|
+
/** @deprecated Please use `event.node.req` instead. */
|
|
35
|
+
get req(): IncomingMessage & {
|
|
36
|
+
originalUrl?: string;
|
|
37
|
+
};
|
|
38
|
+
/** @deprecated Please use `event.node.res` instead. */
|
|
39
|
+
get res(): ServerResponse<IncomingMessage>;
|
|
40
|
+
}
|
|
41
|
+
type SessionDataT = Record<string, any>;
|
|
42
|
+
type SessionData<T extends SessionDataT = SessionDataT> = T;
|
|
43
|
+
declare const getSessionPromise: unique symbol;
|
|
44
|
+
interface Session<T extends SessionDataT = SessionDataT> {
|
|
45
|
+
id: string;
|
|
46
|
+
createdAt: number;
|
|
47
|
+
data: SessionData<T>;
|
|
48
|
+
[getSessionPromise]?: Promise<Session<T>>;
|
|
49
|
+
}
|
|
50
|
+
type RouterMethod = Lowercase<HTTPMethod>;
|
|
51
|
+
interface RouteNode {
|
|
52
|
+
handlers: Partial<Record<RouterMethod | "all", EventHandler>>;
|
|
53
|
+
path: string;
|
|
54
|
+
}
|
|
55
|
+
type HTTPMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE";
|
|
56
|
+
interface H3EventContext extends Record<string, any> {
|
|
57
|
+
params?: Record<string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* Matched router Node
|
|
60
|
+
*
|
|
61
|
+
* @experimental The object structure may change in non-major version.
|
|
62
|
+
*/
|
|
63
|
+
matchedRoute?: RouteNode;
|
|
64
|
+
sessions?: Record<string, Session>;
|
|
65
|
+
clientAddress?: string;
|
|
66
|
+
}
|
|
67
|
+
type EventHandlerResponse<T = any> = T | Promise<T>;
|
|
68
|
+
interface EventHandlerRequest {
|
|
69
|
+
body?: any;
|
|
70
|
+
query?: QueryObject;
|
|
71
|
+
routerParams?: Record<string, string>;
|
|
72
|
+
}
|
|
73
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
74
|
+
type EventHandlerResolver = (path: string) => MaybePromise<undefined | {
|
|
75
|
+
route?: string;
|
|
76
|
+
handler: EventHandler;
|
|
77
|
+
}>;
|
|
78
|
+
interface EventHandler<Request extends EventHandlerRequest = EventHandlerRequest, Response extends EventHandlerResponse = EventHandlerResponse> {
|
|
79
|
+
__is_handler__?: true;
|
|
80
|
+
__resolve__?: EventHandlerResolver;
|
|
81
|
+
__websocket__?: Partial<Hooks>;
|
|
82
|
+
(event: H3Event<Request>): Response;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Forward `/_lunora/**` to the Lunora worker. We reconstruct a Web `Request`
|
|
86
|
+
* from the H3 event (Lunora speaks the Web Fetch contract — RPC bodies and the
|
|
87
|
+
* WebSocket `Upgrade` handshake), resolve the Cloudflare `env`/`ExecutionContext`
|
|
88
|
+
* off the event, and return the worker's `Response` verbatim (H3 streams it,
|
|
89
|
+
* including a `101 Switching Protocols` upgrade with its `webSocket`).
|
|
90
|
+
*/
|
|
91
|
+
declare const lunoraEventHandler: EventHandler;
|
|
92
|
+
export { lunoraEventHandler as default };
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import lunoraApp from "#lunora/app";
|
|
3
|
-
import { resolveCloudflare } from "../cloudflare.js";
|
|
4
|
-
import { resolveWebRequest } from "../h3-request.js";
|
|
5
|
-
import { delegateToLunora } from "../handler.js";
|
|
6
|
-
export default h3.defineEventHandler(async (event) => {
|
|
7
|
-
const { ctx, env } = resolveCloudflare(event);
|
|
8
|
-
const request = resolveWebRequest(h3, event);
|
|
9
|
-
return delegateToLunora(lunoraApp, request, env, ctx);
|
|
10
|
-
});
|
|
1
|
+
import*as e from"h3";import a from"#lunora/app";import{resolveCloudflare as l}from"../cloudflare.js";import{resolveWebRequest as m}from"../h3-request.js";import{delegateToLunora as s}from"../handler.js";const i=e.defineEventHandler(async r=>{const{ctx:o,env:t}=l(r),n=m(e,r);return s(a,n,t,o)});export{i as default};
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type ArgsOf, type AuthLike, type FunctionReference, type HeadersSource, type Preloaded, type ReturnOf, type ServerClientOptions, type ServerSession, createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createServerClient as d,deserializePreloaded as l,getServerSession as a,preloadQuery as o,preloadedQueryResult as i,serializePreloaded as s}from"@lunora/client/ssr";export{d as createServerClient,l as deserializePreloaded,a as getServerSession,o as preloadQuery,i as preloadedQueryResult,s as serializePreloaded};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/nuxt",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.90",
|
|
4
4
|
"description": "Nuxt module for Lunora — single-worker composition (mounts /_lunora/* into Nitro) plus reactive-loader server helpers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
],
|
|
34
34
|
"type": "module",
|
|
35
35
|
"sideEffects": false,
|
|
36
|
-
"main": "./dist/module.
|
|
37
|
-
"module": "./dist/module.
|
|
38
|
-
"types": "./dist/
|
|
36
|
+
"main": "./dist/module.js",
|
|
37
|
+
"module": "./dist/module.js",
|
|
38
|
+
"types": "./dist/module.d.ts",
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
|
-
"types": "./dist/
|
|
42
|
-
"import": "./dist/module.
|
|
41
|
+
"types": "./dist/module.d.ts",
|
|
42
|
+
"import": "./dist/module.js"
|
|
43
43
|
},
|
|
44
44
|
"./server": {
|
|
45
|
-
"types": "./dist/server.d.
|
|
46
|
-
"import": "./dist/server.
|
|
45
|
+
"types": "./dist/server.d.ts",
|
|
46
|
+
"import": "./dist/server.js"
|
|
47
47
|
},
|
|
48
48
|
"./package.json": "./package.json"
|
|
49
49
|
},
|
|
@@ -51,12 +51,13 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@lunora/client": "1.0.0-alpha.
|
|
55
|
-
"@
|
|
54
|
+
"@lunora/client": "1.0.0-alpha.60",
|
|
55
|
+
"@lunora/runtime": "1.0.0-alpha.77",
|
|
56
|
+
"@nuxt/kit": "^4.5.2"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
|
-
"h3": "^1.
|
|
59
|
-
"nuxt": "^4.0.
|
|
59
|
+
"h3": "^1.15.0",
|
|
60
|
+
"nuxt": "^4.0.3"
|
|
60
61
|
},
|
|
61
62
|
"peerDependenciesMeta": {
|
|
62
63
|
"h3": {
|
package/dist/module.d.mts
DELETED
package/dist/module.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { defineNuxtModule, createResolver, addServerHandler, useLogger } from '@nuxt/kit';
|
|
4
|
-
|
|
5
|
-
const module$1 = defineNuxtModule({
|
|
6
|
-
defaults: {
|
|
7
|
-
appEntry: "~/lunora/server",
|
|
8
|
-
prefix: "/_lunora"
|
|
9
|
-
},
|
|
10
|
-
meta: {
|
|
11
|
-
configKey: "lunora",
|
|
12
|
-
name: "@lunora/nuxt"
|
|
13
|
-
},
|
|
14
|
-
setup(options, nuxt) {
|
|
15
|
-
const resolver = createResolver(import.meta.url);
|
|
16
|
-
nuxt.options.alias["#lunora/app"] = options.appEntry;
|
|
17
|
-
addServerHandler({
|
|
18
|
-
handler: resolver.resolve("./runtime/server/lunora"),
|
|
19
|
-
route: `${options.prefix}/**`
|
|
20
|
-
});
|
|
21
|
-
if (!existsSync(join(nuxt.options.rootDir, "exports.cloudflare.ts"))) {
|
|
22
|
-
useLogger("@lunora/nuxt").warn(
|
|
23
|
-
'missing exports.cloudflare.ts at the project root \u2014 add `export { ShardDO } from "./lunora/server";` so the SHARD Durable Object is exported from the worker.'
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export { module$1 as default };
|
package/dist/server.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ArgsOf, AuthLike, FunctionReference, HeadersSource, Preloaded, ReturnOf, ServerClientOptions, ServerSession, createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
|
package/dist/server.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
|
package/dist/types.d.mts
DELETED