@lunora/nuxt 1.0.0-alpha.3 → 1.0.0-alpha.31

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,14 +59,23 @@ 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`
@@ -52,8 +97,8 @@ option, default `~/lunora/server`) and serves it at the `/_lunora/**` route
52
97
  and forwards to your app's `fetch`. A missing Cloudflare runtime answers a clear 500.
53
98
  - **`#lunora/app` alias**: points the route's worker import at your app entry,
54
99
  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).
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`.
57
102
 
58
103
  ## Verify before deploy
59
104
 
@@ -66,11 +111,12 @@ Single-worker composition rides on two Nitro behaviours that vary across version
66
111
  subscriptions never connect while RPC does, Nitro is normalising the upgrade
67
112
  response and `/_lunora/ws` needs a deploy-boundary handoff instead of the H3
68
113
  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.
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.
74
120
 
75
121
  ## Server data-loading
76
122
 
@@ -78,3 +124,64 @@ Single-worker composition rides on two Nitro behaviours that vary across version
78
124
  (`createServerClient`, `preloadQuery`, …) from `@lunora/client/ssr` for the
79
125
  reactive-loader handoff. Safe to import from a Nitro server route (no WebSocket,
80
126
  no browser globals).
127
+
128
+ ## Feature flags
129
+
130
+ `@lunora/nuxt` ships no flag composable — Nuxt _is_ Vue, so read `ctx.flags`
131
+ server-side (a Nitro route, a function, or a reactive loader) and pass the
132
+ resolved value down, or call `useFlag` / `useFlags` from
133
+ [`@lunora/vue`](https://www.npmjs.com/package/@lunora/vue) directly in a
134
+ component for live updates over the WebSocket. Requires
135
+ [`@lunora/flags`](https://www.npmjs.com/package/@lunora/flags) wired in
136
+ `lunora/flags.ts`.
137
+
138
+ ```vue
139
+ <script setup lang="ts">
140
+ import { useFlag } from "@lunora/vue";
141
+
142
+ // Live over the Lunora WS — holds `false` until the server resolves it.
143
+ const newHero = useFlag("homepage-hero", false);
144
+ </script>
145
+
146
+ <template>
147
+ <NewHero v-if="newHero" />
148
+ <ClassicHero v-else />
149
+ </template>
150
+ ```
151
+
152
+ ## Supported Node.js Versions
153
+
154
+ Libraries in this ecosystem make the best effort to track [Node.js' release schedule](https://github.com/nodejs/release#release-schedule).
155
+ 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).
156
+
157
+ ## Contributing
158
+
159
+ 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.
160
+
161
+ > **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.
162
+
163
+ ## Credits
164
+
165
+ - [Daniel Bannert](https://github.com/prisis)
166
+ - [All Contributors](https://github.com/anolilab/lunora/graphs/contributors)
167
+
168
+ ## Made with ❤️ at Anolilab
169
+
170
+ 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!
171
+
172
+ ## License
173
+
174
+ The Lunora nuxt package is open-sourced software licensed under the [FSL-1.1-Apache-2.0][license].
175
+
176
+ <!-- badges -->
177
+
178
+ [license-badge]: https://img.shields.io/badge/license-FSL--1.1--Apache--2.0-blue.svg?style=for-the-badge
179
+ [license]: https://github.com/anolilab/lunora/blob/alpha/LICENSE.md
180
+ [npm-version-badge]: https://img.shields.io/npm/v/@lunora/nuxt?style=for-the-badge
181
+ [npm-version]: https://www.npmjs.com/package/@lunora/nuxt
182
+ [npm-downloads-badge]: https://img.shields.io/npm/dm/@lunora/nuxt?style=for-the-badge
183
+ [npm-downloads]: https://www.npmjs.com/package/@lunora/nuxt
184
+ [prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
185
+ [prs-welcome]: https://github.com/anolilab/lunora/blob/alpha/.github/CONTRIBUTING.md
186
+ [typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
187
+ [typescript-url]: https://www.typescriptlang.org/