@beatzball/create-litro 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # create-litro
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - bfd8f9a: Fix fullstack recipe: add `base: '/_litro/'` to `vite.config.ts` and extend `LitroPage` in `[slug].ts`
8
+
9
+ Without `base: '/_litro/'`, Vite's compiled modulepreload URL resolver emits paths like `/assets/chunk.js` instead of `/_litro/assets/chunk.js`. These requests hit the Nitro catch-all page handler and return HTML, causing a MIME type error that leaves dynamic routes (e.g. `/blog/hello-world`) stuck on "Loading…".
10
+
11
+ Also fixes `pages/blog/[slug].ts` to extend `LitroPage` (not `LitElement`) and implement `fetchData()`, so client-side SPA navigation to different slugs correctly updates `serverData`.
12
+
13
+ ## 0.1.2
14
+
15
+ ### Patch Changes
16
+
17
+ - 19f4909: Fix recipe templates using unscoped `litro/runtime/...` imports instead of `@beatzball/litro/runtime/...`, and bump `nitropack` devDependency to `^2.13.1`.
18
+
3
19
  ## 0.1.1
4
20
 
5
21
  ### Patch Changes
@@ -2,8 +2,8 @@
2
2
  import '@lit-labs/ssr-client/lit-element-hydrate-support.js';
3
3
 
4
4
  // Client runtime: router outlet and link custom elements.
5
- import 'litro/runtime/LitroOutlet.js';
6
- import 'litro/runtime/LitroLink.js';
5
+ import '@beatzball/litro/runtime/LitroOutlet.js';
6
+ import '@beatzball/litro/runtime/LitroLink.js';
7
7
 
8
8
  // Routes generated by the page scanner before each vite build.
9
9
  import { routes } from './routes.generated.js';
@@ -19,7 +19,7 @@
19
19
  "h3": "^1.13.0"
20
20
  },
21
21
  "devDependencies": {
22
- "nitropack": "^2.10.4",
22
+ "nitropack": "^2.13.1",
23
23
  "vite": "^5.4.11",
24
24
  "typescript": "^5.7.3"
25
25
  }
@@ -2,8 +2,8 @@
2
2
  import '@lit-labs/ssr-client/lit-element-hydrate-support.js';
3
3
 
4
4
  // Client runtime: router outlet and link custom elements.
5
- import 'litro/runtime/LitroOutlet.js';
6
- import 'litro/runtime/LitroLink.js';
5
+ import '@beatzball/litro/runtime/LitroOutlet.js';
6
+ import '@beatzball/litro/runtime/LitroLink.js';
7
7
 
8
8
  // Routes generated by the page scanner before each vite build.
9
9
  // routes.generated.ts lives at the project root (not in dist/) so Vite's
@@ -19,7 +19,7 @@
19
19
  "h3": "^1.13.0"
20
20
  },
21
21
  "devDependencies": {
22
- "nitropack": "^2.10.4",
22
+ "nitropack": "^2.13.1",
23
23
  "vite": "^5.4.11",
24
24
  "typescript": "^5.7.3"
25
25
  }
@@ -1,6 +1,8 @@
1
- import { LitElement, html } from 'lit';
1
+ import { html } from 'lit';
2
2
  import { customElement, state } from 'lit/decorators.js';
3
+ import { LitroPage } from '@beatzball/litro/runtime';
3
4
  import { definePageData } from '@beatzball/litro';
5
+ import type { LitroLocation } from '@beatzball/litro-router';
4
6
 
5
7
  export interface PostData {
6
8
  slug: string;
@@ -24,9 +26,19 @@ export async function generateRoutes(): Promise<string[]> {
24
26
  }
25
27
 
26
28
  @customElement('page-blog-slug')
27
- export class BlogPostPage extends LitElement {
29
+ export class BlogPostPage extends LitroPage {
28
30
  @state() declare serverData: PostData | null;
29
31
 
32
+ // Called by LitroRouter on client-side navigation to fetch data for the new slug.
33
+ override async fetchData(location: LitroLocation): Promise<PostData> {
34
+ const slug = location.params['slug'] ?? '';
35
+ return {
36
+ slug,
37
+ title: `Post: ${slug}`,
38
+ content: `This is the content for the "${slug}" post.`,
39
+ };
40
+ }
41
+
30
42
  render() {
31
43
  return html`
32
44
  <article>
@@ -1,6 +1,15 @@
1
1
  import { defineConfig } from 'vite';
2
2
 
3
3
  export default defineConfig({
4
+ // base must match publicAssets.baseURL in nitro.config.ts ('/_litro/').
5
+ // Vite embeds the base into the compiled preload URL resolver so that
6
+ // modulepreload hints resolve to /_litro/assets/... instead of /assets/...
7
+ // Without this, preload requests hit the catch-all page handler and return
8
+ // HTML, causing a MIME type error for module scripts.
9
+ base: '/_litro/',
10
+ resolve: {
11
+ conditions: ['source', 'browser', 'module', 'import', 'default'],
12
+ },
4
13
  build: {
5
14
  outDir: 'dist/client',
6
15
  rollupOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beatzball/create-litro",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Create a new Litro app",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -2,8 +2,8 @@
2
2
  import '@lit-labs/ssr-client/lit-element-hydrate-support.js';
3
3
 
4
4
  // Client runtime: router outlet and link custom elements.
5
- import 'litro/runtime/LitroOutlet.js';
6
- import 'litro/runtime/LitroLink.js';
5
+ import '@beatzball/litro/runtime/LitroOutlet.js';
6
+ import '@beatzball/litro/runtime/LitroLink.js';
7
7
 
8
8
  // Routes generated by the page scanner before each vite build.
9
9
  import { routes } from './routes.generated.js';
@@ -19,7 +19,7 @@
19
19
  "h3": "^1.13.0"
20
20
  },
21
21
  "devDependencies": {
22
- "nitropack": "^2.10.4",
22
+ "nitropack": "^2.13.1",
23
23
  "vite": "^5.4.11",
24
24
  "typescript": "^5.7.3"
25
25
  }
@@ -2,8 +2,8 @@
2
2
  import '@lit-labs/ssr-client/lit-element-hydrate-support.js';
3
3
 
4
4
  // Client runtime: router outlet and link custom elements.
5
- import 'litro/runtime/LitroOutlet.js';
6
- import 'litro/runtime/LitroLink.js';
5
+ import '@beatzball/litro/runtime/LitroOutlet.js';
6
+ import '@beatzball/litro/runtime/LitroLink.js';
7
7
 
8
8
  // Routes generated by the page scanner before each vite build.
9
9
  // routes.generated.ts lives at the project root (not in dist/) so Vite's
@@ -19,7 +19,7 @@
19
19
  "h3": "^1.13.0"
20
20
  },
21
21
  "devDependencies": {
22
- "nitropack": "^2.10.4",
22
+ "nitropack": "^2.13.1",
23
23
  "vite": "^5.4.11",
24
24
  "typescript": "^5.7.3"
25
25
  }
@@ -1,6 +1,8 @@
1
- import { LitElement, html } from 'lit';
1
+ import { html } from 'lit';
2
2
  import { customElement, state } from 'lit/decorators.js';
3
+ import { LitroPage } from '@beatzball/litro/runtime';
3
4
  import { definePageData } from '@beatzball/litro';
5
+ import type { LitroLocation } from '@beatzball/litro-router';
4
6
 
5
7
  export interface PostData {
6
8
  slug: string;
@@ -24,9 +26,19 @@ export async function generateRoutes(): Promise<string[]> {
24
26
  }
25
27
 
26
28
  @customElement('page-blog-slug')
27
- export class BlogPostPage extends LitElement {
29
+ export class BlogPostPage extends LitroPage {
28
30
  @state() declare serverData: PostData | null;
29
31
 
32
+ // Called by LitroRouter on client-side navigation to fetch data for the new slug.
33
+ override async fetchData(location: LitroLocation): Promise<PostData> {
34
+ const slug = location.params['slug'] ?? '';
35
+ return {
36
+ slug,
37
+ title: `Post: ${slug}`,
38
+ content: `This is the content for the "${slug}" post.`,
39
+ };
40
+ }
41
+
30
42
  render() {
31
43
  return html`
32
44
  <article>
@@ -1,6 +1,15 @@
1
1
  import { defineConfig } from 'vite';
2
2
 
3
3
  export default defineConfig({
4
+ // base must match publicAssets.baseURL in nitro.config.ts ('/_litro/').
5
+ // Vite embeds the base into the compiled preload URL resolver so that
6
+ // modulepreload hints resolve to /_litro/assets/... instead of /assets/...
7
+ // Without this, preload requests hit the catch-all page handler and return
8
+ // HTML, causing a MIME type error for module scripts.
9
+ base: '/_litro/',
10
+ resolve: {
11
+ conditions: ['source', 'browser', 'module', 'import', 'default'],
12
+ },
4
13
  build: {
5
14
  outDir: 'dist/client',
6
15
  rollupOptions: {