@lunora/astro 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 +6 -0
- package/README.md +33 -4
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +95 -56
- package/dist/index.d.ts +95 -56
- package/dist/index.mjs +1 -2
- package/dist/packem_shared/lunora-DnV2_atg.mjs +6 -0
- package/dist/server.mjs +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/lunora-DCkPGEVa.mjs +0 -15
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
|
@@ -70,7 +70,7 @@ export default defineConfig({
|
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
|
-
// src/
|
|
73
|
+
// src/server.ts — the composed worker's `export default`.
|
|
74
74
|
import { handle } from "@astrojs/cloudflare/handler";
|
|
75
75
|
import { withLunora } from "@lunora/astro";
|
|
76
76
|
|
|
@@ -81,7 +81,7 @@ export default withLunora(
|
|
|
81
81
|
);
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Set `"main": "src/
|
|
84
|
+
Set `"main": "src/server.ts"` in `wrangler.jsonc` so wrangler bundles this entry. `withLunora` reserves `/_lunora/rpc`, `/_lunora/ws`, and `/_lunora/admin/*` for the realtime plane; every other request falls through to Astro's SSR handler. An Astro render that throws is contained at the seam as a plain 500 — it can't take down realtime.
|
|
85
85
|
|
|
86
86
|
Reactivity comes from the island adapter you hydrate with, not from this package. Preload a query in `.astro` frontmatter or a server endpoint with `@lunora/astro/server`, then hand the token to that adapter's `hydratePreloaded`:
|
|
87
87
|
|
|
@@ -91,11 +91,40 @@ Reactivity comes from the island adapter you hydrate with, not from this package
|
|
|
91
91
|
import { createServerClient, preloadQuery, serializePreloaded } from "@lunora/astro/server";
|
|
92
92
|
import { api } from "../lunora/_generated/api";
|
|
93
93
|
|
|
94
|
-
const client = createServerClient({ url: Astro.url.origin
|
|
94
|
+
const client = createServerClient({ url: Astro.url.origin });
|
|
95
95
|
const preloaded = await preloadQuery(client, api.messages.list, {});
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
-
<
|
|
98
|
+
<script id="preloaded" type="application/json" set:html={serializePreloaded(preloaded)}></script>
|
|
99
|
+
<my-island></my-island>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The island has to pick the token up explicitly — no adapter discovers `#preloaded` on its own:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { hydratePreloaded } from "@lunora/react";
|
|
106
|
+
import { deserializePreloaded } from "@lunora/astro/server";
|
|
107
|
+
|
|
108
|
+
const preloaded = deserializePreloaded(document.querySelector("#preloaded")!.textContent!);
|
|
109
|
+
const initial = hydratePreloaded(preloaded); // seeds the first paint, then goes live
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Feature flags
|
|
113
|
+
|
|
114
|
+
`@lunora/astro` ships no flag hook — like every other surface, flags follow the same server/island split. Read `ctx.flags` server-side (a server endpoint, a function, or the same `.astro` frontmatter) and hand the resolved value to the island, or call `useFlag` inside the island itself via the adapter you hydrate with (`@lunora/react`, `@lunora/vue`, …). Requires [`@lunora/flags`](https://www.npmjs.com/package/@lunora/flags) wired in `lunora/flags.ts`.
|
|
115
|
+
|
|
116
|
+
```astro
|
|
117
|
+
---
|
|
118
|
+
// src/pages/index.astro — resolve the flag once, server-side
|
|
119
|
+
import { createServerClient, preloadQuery, preloadedQueryResult } from "@lunora/astro/server";
|
|
120
|
+
import { api } from "../lunora/_generated/api";
|
|
121
|
+
|
|
122
|
+
const client = createServerClient({ url: Astro.url.origin });
|
|
123
|
+
const preloaded = await preloadQuery(client, api.homepage.heroFlag, {}); // a query that returns ctx.flags.boolean(...)
|
|
124
|
+
const newHero = preloadedQueryResult(preloaded);
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
{newHero ? <NewHero client:load /> : <ClassicHero client:load />}
|
|
99
128
|
```
|
|
100
129
|
|
|
101
130
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/frameworks/bring-your-framework)**.
|