@lunora/nuxt 1.0.0-alpha.93 → 1.0.0-alpha.95

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.
@@ -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.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "configKey": "lunora",
3
3
  "name": "@lunora/nuxt",
4
- "version": "1.0.0-alpha.92"
4
+ "version": "1.0.0-alpha.94"
5
5
  }
@@ -0,0 +1,36 @@
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. */
4
+ interface CloudflareEventBag {
5
+ context?: ExecutionContextLike;
6
+ ctx?: ExecutionContextLike;
7
+ env?: Record<string, unknown>;
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
+ */
14
+ interface H3EventLike {
15
+ context?: {
16
+ cloudflare?: CloudflareEventBag;
17
+ };
18
+ req?: {
19
+ runtime?: {
20
+ cloudflare?: CloudflareEventBag;
21
+ };
22
+ };
23
+ }
24
+ /** Resolved Cloudflare runtime for one request: the bindings `env` and the optional `ExecutionContext`. */
25
+ interface ResolvedCloudflare {
26
+ ctx?: ExecutionContextLike;
27
+ env?: Record<string, unknown>;
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
+ */
35
+ declare const resolveCloudflare: (event: H3EventLike) => ResolvedCloudflare;
36
+ export { type H3EventLike, type ResolvedCloudflare, resolveCloudflare };
@@ -0,0 +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
+ */
14
+ interface H3RequestNamespace {
15
+ toWebRequest?: unknown;
16
+ }
17
+ declare const resolveWebRequest: (h3: H3RequestNamespace, event: unknown) => Request;
18
+ export { type H3RequestNamespace, resolveWebRequest };
@@ -0,0 +1,19 @@
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
+ */
9
+ interface LunoraWorkerLike {
10
+ fetch: (request: Request, env: unknown, context: ExecutionContextLike) => Promise<Response> | Response;
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
+ */
18
+ declare const delegateToLunora: (worker: LunoraWorkerLike, request: Request, env: Record<string, unknown> | undefined, context?: ExecutionContextLike) => Promise<Response>;
19
+ export { type LunoraWorkerLike, delegateToLunora };
@@ -0,0 +1,92 @@
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 };
@@ -0,0 +1 @@
1
+ import*as e from"h3";import a from"#lunora/app";import{resolveCloudflare as l}from"../cloudflare.mjs";import{resolveWebRequest as m}from"../h3-request.mjs";import{delegateToLunora as s}from"../handler.mjs";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};
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/nuxt",
3
- "version": "1.0.0-alpha.93",
3
+ "version": "1.0.0-alpha.95",
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.js",
37
- "module": "./dist/module.js",
36
+ "main": "./dist/module.mjs",
37
+ "module": "./dist/module.mjs",
38
38
  "types": "./dist/module.d.ts",
39
39
  "exports": {
40
40
  ".": {
41
41
  "types": "./dist/module.d.ts",
42
- "import": "./dist/module.js"
42
+ "import": "./dist/module.mjs"
43
43
  },
44
44
  "./server": {
45
45
  "types": "./dist/server.d.ts",
46
- "import": "./dist/server.js"
46
+ "import": "./dist/server.mjs"
47
47
  },
48
48
  "./package.json": "./package.json"
49
49
  },
@@ -51,8 +51,8 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@lunora/client": "1.0.0-alpha.62",
55
- "@lunora/runtime": "1.0.0-alpha.79",
54
+ "@lunora/client": "1.0.0-alpha.64",
55
+ "@lunora/runtime": "1.0.0-alpha.81",
56
56
  "@nuxt/kit": "^4.5.2"
57
57
  },
58
58
  "peerDependencies": {
@@ -1 +0,0 @@
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};
File without changes
File without changes
File without changes
File without changes
File without changes