@lunora/nuxt 0.0.1 → 1.0.0-alpha.2
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 +105 -0
- package/README.md +78 -43
- package/__assets__/package-og.svg +14 -0
- package/dist/module.d.mts +9 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +29 -0
- package/dist/runtime/cloudflare.d.ts +0 -0
- package/dist/runtime/cloudflare.js +12 -0
- package/dist/runtime/handler.d.ts +0 -0
- package/dist/runtime/handler.js +21 -0
- package/dist/runtime/server/lunora.d.ts +0 -0
- package/dist/runtime/server/lunora.js +9 -0
- package/dist/server.d.mts +1 -0
- package/dist/server.mjs +1 -0
- package/dist/types.d.mts +7 -0
- package/package.json +69 -7
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 anolilab and contributors
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or service
|
|
34
|
+
that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software that
|
|
39
|
+
exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee using
|
|
52
|
+
the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to the
|
|
59
|
+
infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN
|
|
79
|
+
IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following will
|
|
93
|
+
apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,45 +1,80 @@
|
|
|
1
1
|
# @lunora/nuxt
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
3
|
+
A **Nuxt module** that runs Lunora and Nuxt as a **single Cloudflare Worker**.
|
|
4
|
+
|
|
5
|
+
Instead of Lunora owning the Cloudflare worker entry (the two-worker split), it
|
|
6
|
+
is mounted _inside_ Nitro: the module registers a server route at `/_lunora/**`
|
|
7
|
+
that forwards every Lunora RPC, WebSocket upgrade, and admin request to your
|
|
8
|
+
Lunora app in-process. One `wrangler.jsonc`, one deploy, a same-origin client.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @lunora/nuxt
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// nuxt.config.ts
|
|
20
|
+
export default defineNuxtConfig({
|
|
21
|
+
modules: ["@lunora/nuxt"],
|
|
22
|
+
nitro: { preset: "cloudflare_module" },
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Add `exports.cloudflare.ts` to the project root so the `ShardDO` Durable Object
|
|
27
|
+
class is exported from the emitted worker entry:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// exports.cloudflare.ts
|
|
31
|
+
export { ShardDO } from "./lunora/server";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`lunora/server.ts` is your built Lunora app (`defineApp().build()`) — its default
|
|
35
|
+
export is the worker (a `fetch` entrypoint), and it re-exports `ShardDO`. The
|
|
36
|
+
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`).
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
| Option | Default | Description |
|
|
43
|
+
| ---------- | ----------------- | --------------------------------------------------------- |
|
|
44
|
+
| `appEntry` | `~/lunora/server` | Module specifier of the Lunora app entry (`#lunora/app`). |
|
|
45
|
+
| `prefix` | `/_lunora` | URL prefix the Lunora realtime plane is mounted at. |
|
|
46
|
+
|
|
47
|
+
## How it works
|
|
48
|
+
|
|
49
|
+
- **The route** (`addServerHandler` at `prefix/**`): reconstructs a Web `Request`
|
|
50
|
+
from the H3 event, resolves the Cloudflare `env`/`ExecutionContext` off it
|
|
51
|
+
(tolerating both `event.context.cloudflare` and `event.req.runtime.cloudflare`),
|
|
52
|
+
and forwards to your app's `fetch`. A missing Cloudflare runtime answers a clear 500.
|
|
53
|
+
- **`#lunora/app` alias**: points the route's worker import at your app entry,
|
|
54
|
+
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).
|
|
57
|
+
|
|
58
|
+
## Verify before deploy
|
|
59
|
+
|
|
60
|
+
Single-worker composition rides on two Nitro behaviours that vary across versions
|
|
61
|
+
— verify them on your pinned toolchain:
|
|
62
|
+
|
|
63
|
+
1. **WebSocket upgrade pass-through.** The live feed needs Nitro to return your
|
|
64
|
+
Lunora app's `101 Switching Protocols` response (carrying its Cloudflare
|
|
65
|
+
`webSocket`) untouched. RPC (plain JSON) works regardless; if live
|
|
66
|
+
subscriptions never connect while RPC does, Nitro is normalising the upgrade
|
|
67
|
+
response and `/_lunora/ws` needs a deploy-boundary handoff instead of the H3
|
|
68
|
+
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.
|
|
74
|
+
|
|
75
|
+
## Server data-loading
|
|
76
|
+
|
|
77
|
+
`@lunora/nuxt/server` re-exports the framework-neutral SSR helpers
|
|
78
|
+
(`createServerClient`, `preloadQuery`, …) from `@lunora/client/ssr` for the
|
|
79
|
+
reactive-loader handoff. Safe to import from a Nitro server route (no WebSocket,
|
|
80
|
+
no browser globals).
|