@lunora/nuxt 1.0.0-alpha.41 → 1.0.0-alpha.43

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.js CHANGED
@@ -1,72 +1 @@
1
- import { existsSync } from 'node:fs';
2
- import { join, resolve, dirname } from 'node:path';
3
- import { defineNuxtModule, createResolver, addServerHandler, useLogger } from '@nuxt/kit';
4
-
5
- const resolveTildePath = (specifier, rootDirectory, sourceDirectory) => {
6
- if (specifier.startsWith("~~/")) {
7
- return join(rootDirectory, specifier.slice(3));
8
- }
9
- if (specifier.startsWith("~/")) {
10
- return join(sourceDirectory, specifier.slice(2));
11
- }
12
- if (specifier.startsWith("./") || specifier.startsWith("../")) {
13
- return join(rootDirectory, specifier);
14
- }
15
- return specifier;
16
- };
17
-
18
- const JS_EXTENSION_SUFFIX = /\.js$/;
19
- const lunoraTsSourceResolver = (rootDirectory) => {
20
- const lunoraDirectory = join(rootDirectory, "lunora");
21
- return {
22
- name: "lunora:nitro-ts-source-resolve",
23
- resolveId: {
24
- handler(source, importer) {
25
- if (!source.endsWith(".js")) {
26
- return void 0;
27
- }
28
- let absolute;
29
- if (source.startsWith("#lunora/")) {
30
- absolute = join(lunoraDirectory, source.slice("#lunora/".length));
31
- } else if (source.startsWith(".") && importer !== void 0) {
32
- absolute = resolve(dirname(importer), source);
33
- }
34
- if (absolute === void 0) {
35
- return void 0;
36
- }
37
- const tsSource = absolute.replace(JS_EXTENSION_SUFFIX, ".ts");
38
- return existsSync(tsSource) ? tsSource : void 0;
39
- },
40
- order: "pre"
41
- }
42
- };
43
- };
44
- const lunoraNuxtModule = defineNuxtModule({
45
- defaults: {
46
- appEntry: "~/lunora/server",
47
- prefix: "/_lunora"
48
- },
49
- meta: {
50
- configKey: "lunora",
51
- name: "@lunora/nuxt"
52
- },
53
- setup(options, nuxt) {
54
- const resolver = createResolver(import.meta.url);
55
- nuxt.options.alias["#lunora/app"] = resolveTildePath(options.appEntry, nuxt.options.rootDir, nuxt.options.srcDir);
56
- nuxt.hook("nitro:config", (nitroConfig) => {
57
- const plugins = [...nitroConfig.rollupConfig?.plugins ?? [], lunoraTsSourceResolver(nuxt.options.rootDir)];
58
- nitroConfig.rollupConfig = { ...nitroConfig.rollupConfig, plugins };
59
- });
60
- addServerHandler({
61
- handler: resolver.resolve("./runtime/server/lunora"),
62
- route: `${options.prefix}/**`
63
- });
64
- if (!existsSync(join(nuxt.options.rootDir, "worker.ts"))) {
65
- useLogger("@lunora/nuxt").warn(
66
- 'missing worker.ts at the project root — add a wrapper that re-exports Nitro\'s handler and `ShardDO` (`export { default } from "./.output/server/index.mjs"; export { ShardDO } from "./lunora/server";`) and point wrangler\'s `main` at it, so the SHARD Durable Object is exported from the deployed worker.'
67
- );
68
- }
69
- }
70
- });
71
-
72
- export { lunoraNuxtModule as default };
1
+ import{existsSync as i}from"node:fs";import{join as n,resolve as l,dirname as p}from"node:path";import{defineNuxtModule as u,createResolver as d,addServerHandler as m,useLogger as f}from"@nuxt/kit";const c=(r,o,e)=>r.startsWith("~~/")?n(o,r.slice(3)):r.startsWith("~/")?n(e,r.slice(2)):r.startsWith("./")||r.startsWith("../")?n(o,r):r,h=/\.js$/,v=r=>{const o=n(r,"lunora");return{name:"lunora:nitro-ts-source-resolve",resolveId:{handler(e,t){if(!e.endsWith(".js"))return;let s;if(e.startsWith("#lunora/")?s=n(o,e.slice(8)):e.startsWith(".")&&t!==void 0&&(s=l(p(t),e)),s===void 0)return;const a=s.replace(h,".ts");return i(a)?a:void 0},order:"pre"}}},W=u({defaults:{appEntry:"~/lunora/server",prefix:"/_lunora"},meta:{configKey:"lunora",name:"@lunora/nuxt"},setup(r,o){const e=d(import.meta.url);o.options.alias["#lunora/app"]=c(r.appEntry,o.options.rootDir,o.options.srcDir),o.hook("nitro:config",t=>{const s=[...t.rollupConfig?.plugins??[],v(o.options.rootDir)];t.rollupConfig={...t.rollupConfig,plugins:s}}),m({handler:e.resolve("./runtime/server/lunora"),route:`${r.prefix}/**`}),i(n(o.options.rootDir,"worker.ts"))||f("@lunora/nuxt").warn('missing worker.ts at the project root — add a wrapper that re-exports Nitro\'s handler and `ShardDO` (`export { default } from "./.output/server/index.mjs"; export { ShardDO } from "./lunora/server";`) and point wrangler\'s `main` at it, so the SHARD Durable Object is exported from the deployed worker.')}});export{W 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.40"
4
+ "version": "1.0.0-alpha.42"
5
5
  }
@@ -1,15 +1 @@
1
- import '@lunora/runtime';
2
-
3
- const resolveCloudflare = (event) => {
4
- const fromContext = event.context?.cloudflare;
5
- if (fromContext?.env) {
6
- return { ctx: fromContext.context ?? fromContext.ctx, env: fromContext.env };
7
- }
8
- const fromRuntime = event.req?.runtime?.cloudflare;
9
- if (fromRuntime?.env) {
10
- return { ctx: fromRuntime.ctx ?? fromRuntime.context, env: fromRuntime.env };
11
- }
12
- return {};
13
- };
14
-
15
- export { resolveCloudflare };
1
+ import"@lunora/runtime";const c=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{c as resolveCloudflare};
@@ -1,3 +1 @@
1
- const resolveWebRequest = (h3, event) => typeof h3.toWebRequest === "function" ? h3.toWebRequest(event) : event.req;
2
-
3
- export { resolveWebRequest };
1
+ const o=(e,t)=>typeof e.toWebRequest=="function"?e.toWebRequest(t):t.req;export{o as resolveWebRequest};
@@ -1,19 +1 @@
1
- import { NOOP_EXECUTION_CONTEXT } from '@lunora/runtime';
2
- export { NOOP_EXECUTION_CONTEXT } from '@lunora/runtime';
3
-
4
- const delegateToLunora = async (worker, request, env, context) => {
5
- if (!env) {
6
- return Response.json(
7
- {
8
- error: {
9
- code: "LUNORA_RUNTIME_UNAVAILABLE",
10
- 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`)."
11
- }
12
- },
13
- { status: 500 }
14
- );
15
- }
16
- return worker.fetch(request, env, context ?? NOOP_EXECUTION_CONTEXT);
17
- };
18
-
19
- export { delegateToLunora };
1
+ import{NOOP_EXECUTION_CONTEXT as n}from"@lunora/runtime";import{NOOP_EXECUTION_CONTEXT as l}from"@lunora/runtime";const u=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,u as delegateToLunora};
@@ -1,13 +1 @@
1
- import * as h3 from 'h3';
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
-
7
- const lunoraEventHandler = h3.defineEventHandler(async (event) => {
8
- const { ctx, env } = resolveCloudflare(event);
9
- const request = resolveWebRequest(h3, event);
10
- return delegateToLunora(lunoraApp, request, env, ctx);
11
- });
12
-
13
- export { lunoraEventHandler as default };
1
+ import*as r from"h3";import s from"#lunora/app";import{resolveCloudflare as m}from"../cloudflare.js";import{resolveWebRequest as n}from"../h3-request.js";import{delegateToLunora as f}from"../handler.js";const d=r.defineEventHandler(async o=>{const{ctx:e,env:t}=m(o),a=n(r,o);return f(s,a,t,e)});export{d as default};
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- export { createServerClient, deserializePreloaded, getServerSession, preloadQuery, preloadedQueryResult, serializePreloaded } from '@lunora/client/ssr';
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.41",
3
+ "version": "1.0.0-alpha.43",
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",
@@ -51,8 +51,8 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@lunora/client": "1.0.0-alpha.27",
55
- "@lunora/runtime": "1.0.0-alpha.36",
54
+ "@lunora/client": "1.0.0-alpha.29",
55
+ "@lunora/runtime": "1.0.0-alpha.38",
56
56
  "@nuxt/kit": "^4.4.8"
57
57
  },
58
58
  "peerDependencies": {