@lunora/nuxt 1.0.0-alpha.21 → 1.0.0-alpha.23

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.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "configKey": "lunora",
3
3
  "name": "@lunora/nuxt",
4
- "version": "1.0.0-alpha.20",
4
+ "version": "1.0.0-alpha.22",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,7 +1,42 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { join, resolve, dirname } from 'node:path';
3
3
  import { defineNuxtModule, createResolver, addServerHandler, useLogger } from '@nuxt/kit';
4
4
 
5
+ const JS_EXTENSION_SUFFIX = /\.js$/;
6
+ const resolveTildePath = (specifier, rootDirectory, sourceDirectory) => {
7
+ if (specifier.startsWith("~~/")) {
8
+ return join(rootDirectory, specifier.slice(3));
9
+ }
10
+ if (specifier.startsWith("~/")) {
11
+ return join(sourceDirectory, specifier.slice(2));
12
+ }
13
+ return specifier;
14
+ };
15
+ const lunoraTsSourceResolver = (rootDirectory) => {
16
+ const lunoraDirectory = join(rootDirectory, "lunora");
17
+ return {
18
+ name: "lunora:nitro-ts-source-resolve",
19
+ resolveId: {
20
+ handler(source, importer) {
21
+ if (!source.endsWith(".js")) {
22
+ return void 0;
23
+ }
24
+ let absolute;
25
+ if (source.startsWith("#lunora/")) {
26
+ absolute = join(lunoraDirectory, source.slice("#lunora/".length));
27
+ } else if (source.startsWith(".") && importer !== void 0) {
28
+ absolute = resolve(dirname(importer), source);
29
+ }
30
+ if (absolute === void 0) {
31
+ return void 0;
32
+ }
33
+ const tsSource = absolute.replace(JS_EXTENSION_SUFFIX, ".ts");
34
+ return existsSync(tsSource) ? tsSource : void 0;
35
+ },
36
+ order: "pre"
37
+ }
38
+ };
39
+ };
5
40
  const module$1 = defineNuxtModule({
6
41
  defaults: {
7
42
  appEntry: "~/lunora/server",
@@ -13,14 +48,18 @@ const module$1 = defineNuxtModule({
13
48
  },
14
49
  setup(options, nuxt) {
15
50
  const resolver = createResolver(import.meta.url);
16
- nuxt.options.alias["#lunora/app"] = options.appEntry;
51
+ nuxt.options.alias["#lunora/app"] = resolveTildePath(options.appEntry, nuxt.options.rootDir, nuxt.options.srcDir);
52
+ nuxt.hook("nitro:config", (nitroConfig) => {
53
+ const plugins = [...nitroConfig.rollupConfig?.plugins ?? [], lunoraTsSourceResolver(nuxt.options.rootDir)];
54
+ nitroConfig.rollupConfig = { ...nitroConfig.rollupConfig, plugins };
55
+ });
17
56
  addServerHandler({
18
57
  handler: resolver.resolve("./runtime/server/lunora"),
19
58
  route: `${options.prefix}/**`
20
59
  });
21
- if (!existsSync(join(nuxt.options.rootDir, "exports.cloudflare.ts"))) {
60
+ if (!existsSync(join(nuxt.options.rootDir, "worker.ts"))) {
22
61
  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.'
62
+ 'missing worker.ts at the project root \u2014 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.'
24
63
  );
25
64
  }
26
65
  }
@@ -1,4 +1,4 @@
1
- import type { ExecutionContextLike } from "../../../../shared/execution-context.js";
1
+ import type { ExecutionContextLike } from "@lunora/runtime";
2
2
  interface CloudflareEventBag {
3
3
  context?: ExecutionContextLike;
4
4
  ctx?: ExecutionContextLike;
@@ -21,4 +21,4 @@ interface ResolvedCloudflare {
21
21
  declare const resolveCloudflare: (event: H3EventLike) => ResolvedCloudflare;
22
22
  export type { H3EventLike, ResolvedCloudflare };
23
23
  export { resolveCloudflare };
24
- export { type ExecutionContextLike } from "../../../../shared/execution-context.js";
24
+ export { type ExecutionContextLike } from "@lunora/runtime";
@@ -1,8 +1,8 @@
1
- import type { ExecutionContextLike } from "../../../../shared/execution-context.js";
1
+ import type { ExecutionContextLike } from "@lunora/runtime";
2
2
  interface LunoraWorkerLike {
3
3
  fetch: (request: Request, env: unknown, context: ExecutionContextLike) => Promise<Response> | Response;
4
4
  }
5
5
  declare const delegateToLunora: (worker: LunoraWorkerLike, request: Request, env: Record<string, unknown> | undefined, context?: ExecutionContextLike) => Promise<Response>;
6
6
  export type { LunoraWorkerLike };
7
7
  export { delegateToLunora };
8
- export { NOOP_EXECUTION_CONTEXT } from "../../../../shared/execution-context.js";
8
+ export { NOOP_EXECUTION_CONTEXT } from "@lunora/runtime";
@@ -1,4 +1,4 @@
1
- import { NOOP_EXECUTION_CONTEXT } from "../../../../shared/execution-context";
1
+ import { NOOP_EXECUTION_CONTEXT } from "@lunora/runtime";
2
2
  const delegateToLunora = async (worker, request, env, context) => {
3
3
  if (!env) {
4
4
  return Response.json(
@@ -14,4 +14,4 @@ const delegateToLunora = async (worker, request, env, context) => {
14
14
  return worker.fetch(request, env, context ?? NOOP_EXECUTION_CONTEXT);
15
15
  };
16
16
  export { delegateToLunora };
17
- export { NOOP_EXECUTION_CONTEXT } from "../../../../shared/execution-context";
17
+ export { NOOP_EXECUTION_CONTEXT } from "@lunora/runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/nuxt",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.23",
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",
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@lunora/client": "1.0.0-alpha.19",
55
+ "@lunora/runtime": "1.0.0-alpha.20",
55
56
  "@nuxt/kit": "^4.4.8"
56
57
  },
57
58
  "peerDependencies": {