@lunora/nuxt 1.0.0-alpha.2 → 1.0.0-alpha.200

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 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
@@ -1,4 +1,38 @@
1
- # @lunora/nuxt
1
+ <!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
2
+
3
+ <a href="https://www.anolilab.com/open-source" align="center">
4
+
5
+ <img src="__assets__/package-og.svg" alt="nuxt" />
6
+
7
+ </a>
8
+
9
+ <h3 align="center">Nuxt module for Lunora — single-worker composition (mounts /_lunora/* into Nitro) plus reactive-loader server helpers</h3>
10
+
11
+ <!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
12
+
13
+ <br />
14
+
15
+ <div align="center">
16
+
17
+ [![typescript-image][typescript-badge]][typescript-url]
18
+ [![FSL-1.1-Apache-2.0 licence][license-badge]][license]
19
+ [![npm version][npm-version-badge]][npm-version]
20
+ [![npm downloads][npm-downloads-badge]][npm-downloads]
21
+ [![PRs Welcome][prs-welcome-badge]][prs-welcome]
22
+
23
+ </div>
24
+
25
+ ---
26
+
27
+ <div align="center">
28
+ <p>
29
+ <sup>
30
+ Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
31
+ </sup>
32
+ </p>
33
+ </div>
34
+
35
+ ---
2
36
 
3
37
  A **Nuxt module** that runs Lunora and Nuxt as a **single Cloudflare Worker**.
4
38
 
@@ -7,6 +41,8 @@ is mounted _inside_ Nitro: the module registers a server route at `/_lunora/**`
7
41
  that forwards every Lunora RPC, WebSocket upgrade, and admin request to your
8
42
  Lunora app in-process. One `wrangler.jsonc`, one deploy, a same-origin client.
9
43
 
44
+ Part of the [Lunora](https://github.com/anolilab/lunora) framework — a type-safe, real-time backend on Cloudflare Workers + Durable Objects with a Vite-first DX.
45
+
10
46
  ## Install
11
47
 
12
48
  ```bash
@@ -23,37 +59,47 @@ export default defineNuxtConfig({
23
59
  });
24
60
  ```
25
61
 
26
- Add `exports.cloudflare.ts` to the project root so the `ShardDO` Durable Object
27
- class is exported from the emitted worker entry:
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:
28
67
 
29
68
  ```ts
30
- // exports.cloudflare.ts
69
+ // worker.ts
70
+ export { default } from "./.output/server/index.mjs";
31
71
  export { ShardDO } from "./lunora/server";
32
72
  ```
33
73
 
74
+ ```jsonc
75
+ // wrangler.jsonc
76
+ { "main": "worker.ts" }
77
+ ```
78
+
34
79
  `lunora/server.ts` is your built Lunora app (`defineApp().build()`) — its default
35
80
  export is the worker (a `fetch` entrypoint), and it re-exports `ShardDO`. The
36
81
  module aliases the `#lunora/app` virtual to it (configurable via the `lunora.appEntry`
37
- option, default `~/lunora/server`) and serves it at the `/_lunora/**` route
38
- (prefix configurable via `lunora.prefix`).
82
+ option, default `~/lunora/server`) and serves it at the `/_lunora/**` route.
39
83
 
40
84
  ## Options
41
85
 
42
86
  | Option | Default | Description |
43
87
  | ---------- | ----------------- | --------------------------------------------------------- |
44
88
  | `appEntry` | `~/lunora/server` | Module specifier of the Lunora app entry (`#lunora/app`). |
45
- | `prefix` | `/_lunora` | URL prefix the Lunora realtime plane is mounted at. |
89
+
90
+ The `/_lunora/**` mount is fixed: the worker routes on those exact paths and the
91
+ generated client calls them.
46
92
 
47
93
  ## How it works
48
94
 
49
- - **The route** (`addServerHandler` at `prefix/**`): reconstructs a Web `Request`
95
+ - **The route** (`addServerHandler` at `/_lunora/**`): reconstructs a Web `Request`
50
96
  from the H3 event, resolves the Cloudflare `env`/`ExecutionContext` off it
51
97
  (tolerating both `event.context.cloudflare` and `event.req.runtime.cloudflare`),
52
98
  and forwards to your app's `fetch`. A missing Cloudflare runtime answers a clear 500.
53
99
  - **`#lunora/app` alias**: points the route's worker import at your app entry,
54
100
  forwarded into the Nitro server bundle via `nuxt.options.alias`.
55
- - **`ShardDO`** rides to the worker entry through your root `exports.cloudflare.ts`
56
- (the `cloudflare_module` preset appends its exports).
101
+ - **`ShardDO`** rides to the deployed worker through your root `worker.ts` wrapper
102
+ (`wrangler.jsonc`'s `main`), which re-exports Nitro's SSR handler and `ShardDO`.
57
103
 
58
104
  ## Verify before deploy
59
105
 
@@ -66,11 +112,12 @@ Single-worker composition rides on two Nitro behaviours that vary across version
66
112
  subscriptions never connect while RPC does, Nitro is normalising the upgrade
67
113
  response and `/_lunora/ws` needs a deploy-boundary handoff instead of the H3
68
114
  route return.
69
- 2. **`exports.cloudflare.ts` hook.** The `cloudflare_module` preset must append
70
- this file's exports onto the worker entry. If `wrangler deploy` fails with
71
- "ShardDO class not exported", your Nitro version may use a different hook
72
- (`nitro.cloudflare.additionalModules`, or a `rollupConfig` output export). The
73
- module `warn()`s when the file is missing but can't verify the hook fires.
115
+ 2. **`worker.ts` wrapper.** `wrangler.jsonc`'s `main` must point at a root
116
+ `worker.ts` that re-exports Nitro's SSR handler _and_ `ShardDO` — Nitro's
117
+ `cloudflare_module` output exports only the SSR handler. If `wrangler deploy`
118
+ fails with "ShardDO class not exported", check that `main` points at the
119
+ wrapper and that it re-exports `ShardDO`. The module `warn()`s when
120
+ `worker.ts` is missing but can't verify wrangler's `main` points at it.
74
121
 
75
122
  ## Server data-loading
76
123
 
@@ -78,3 +125,64 @@ Single-worker composition rides on two Nitro behaviours that vary across version
78
125
  (`createServerClient`, `preloadQuery`, …) from `@lunora/client/ssr` for the
79
126
  reactive-loader handoff. Safe to import from a Nitro server route (no WebSocket,
80
127
  no browser globals).
128
+
129
+ ## Feature flags
130
+
131
+ `@lunora/nuxt` ships no flag composable — Nuxt _is_ Vue, so read `ctx.flags`
132
+ server-side (a Nitro route, a function, or a reactive loader) and pass the
133
+ resolved value down, or call `useFlag` / `useFlags` from
134
+ [`@lunora/vue`](https://www.npmjs.com/package/@lunora/vue) directly in a
135
+ component for live updates over the WebSocket. Requires
136
+ [`@lunora/flags`](https://www.npmjs.com/package/@lunora/flags) wired in
137
+ `lunora/flags.ts`.
138
+
139
+ ```vue
140
+ <script setup lang="ts">
141
+ import { useFlag } from "@lunora/vue";
142
+
143
+ // Live over the Lunora WS — holds `false` until the server resolves it.
144
+ const newHero = useFlag("homepage-hero", false);
145
+ </script>
146
+
147
+ <template>
148
+ <NewHero v-if="newHero" />
149
+ <ClassicHero v-else />
150
+ </template>
151
+ ```
152
+
153
+ ## Supported Node.js Versions
154
+
155
+ Libraries in this ecosystem make the best effort to track [Node.js' release schedule](https://github.com/nodejs/release#release-schedule).
156
+ Here's [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
157
+
158
+ ## Contributing
159
+
160
+ If you would like to help take a look at the [list of issues](https://github.com/anolilab/lunora/issues) and check our [Contributing](https://github.com/anolilab/lunora/blob/alpha/.github/CONTRIBUTING.md) guidelines.
161
+
162
+ > **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
163
+
164
+ ## Credits
165
+
166
+ - [Daniel Bannert](https://github.com/prisis)
167
+ - [All Contributors](https://github.com/anolilab/lunora/graphs/contributors)
168
+
169
+ ## Made with ❤️ at Anolilab
170
+
171
+ This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
172
+
173
+ ## License
174
+
175
+ The Lunora nuxt package is open-sourced software licensed under the [FSL-1.1-Apache-2.0][license].
176
+
177
+ <!-- badges -->
178
+
179
+ [license-badge]: https://img.shields.io/badge/license-FSL--1.1--Apache--2.0-blue.svg?style=for-the-badge
180
+ [license]: https://github.com/anolilab/lunora/blob/alpha/LICENSE.md
181
+ [npm-version-badge]: https://img.shields.io/npm/v/@lunora/nuxt?style=for-the-badge
182
+ [npm-version]: https://www.npmjs.com/package/@lunora/nuxt
183
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@lunora/nuxt?style=for-the-badge
184
+ [npm-downloads]: https://www.npmjs.com/package/@lunora/nuxt
185
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
186
+ [prs-welcome]: https://github.com/anolilab/lunora/blob/alpha/.github/CONTRIBUTING.md
187
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
188
+ [typescript-url]: https://www.typescriptlang.org/