create-nowaki 0.18.2 → 0.19.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nowaki",
3
- "version": "0.18.2",
3
+ "version": "0.19.0",
4
4
  "description": "Scaffold a new Nowaki app",
5
5
  "license": "MIT",
6
6
  "author": "Tettu0530",
@@ -26,6 +26,14 @@ After an edit or a failing request, check `recent_errors` first.
26
26
  ```
27
27
  routes/ file-based routes (pages + API). _layout.tsx, _middleware.ts,
28
28
  _404.tsx, _500.tsx, [slug].tsx, api/*.ts
29
+ (name)/ = route group: no URL segment, its own _layout /
30
+ _middleware for the files inside it (group middleware skips 404s)
31
+ @name/ = parallel route slot: the parent dir's _layout gets
32
+ `slots.name` (the @name file matching the URL, else
33
+ @name/default.tsx, else null). @name/(.)photo/[id].tsx =
34
+ intercepting route: client navigation to /photo/1 shows it in
35
+ the slot (a modal); a reload renders routes/photo/[id].tsx.
36
+ Close it with history.back()
29
37
  islands/ interactive components — THE ONLY things that ship JS and hydrate
30
38
  components/ shared server components (no client JS)
31
39
  lib/ shared server code
@@ -141,6 +149,11 @@ nowaki.config.mjs plugins (optional)
141
149
  Use `nowaki start` or a deploy adapter output in production.
142
150
  - **Secrets stay server-side.** Only `PUBLIC_*` (and `MODE`) reach the browser. Copy
143
151
  `.env.example` to `.env` and keep database URLs, API keys, and tokens unprefixed.
152
+ To validate them, declare them in `env.ts` at the app root with `defineEnv({ server,
153
+ public })` from `@nowaki-dev/runtime/env` and a Standard Schema per variable; the
154
+ build fails on a missing or invalid one. Read server values with
155
+ `import { env } from "@nowaki-dev/runtime/env/server"` in loaders, actions, and server
156
+ functions (never in islands: that fails the build).
144
157
  - **Server functions and API routes are public endpoints.** Validate and bound every
145
158
  argument; authorize with `getContext()` (cookies/headers) before mutating data.
146
159
  Use `serverFn(schema, impl)` for `"use server"` exports that take arguments (see
@@ -1,5 +1,8 @@
1
1
  // Nowaki ambient types, so editors understand CSS / asset / virtual-module imports.
2
2
  // No need to edit (it only teaches the type checker the framework's import conventions).
3
+ // Keep this file free of top-level import / export. Either one makes it a module, and then the
4
+ // `declare module "*..."` wildcards below stop being ambient declarations. The preact JSX
5
+ // additions (client:* directives) need a module, so they are in nowaki-jsx.d.ts.
3
6
 
4
7
  declare module "*.module.css" {
5
8
  const classes: Record<string, string>;
@@ -46,36 +49,27 @@ declare module "*.mdx" {
46
49
  export default MDXContent;
47
50
  }
48
51
 
52
+ // Markdoc (@nowaki-dev/markdoc): the default export renders the file; `frontmatter` is its
53
+ // frontmatter and `headings` lists its headings.
54
+ declare module "*.mdoc" {
55
+ export const frontmatter: Record<string, any>;
56
+ export const headings: { depth: number; text: string; id: string }[];
57
+ const MarkdocContent: () => import("preact").JSX.Element;
58
+ export default MarkdocContent;
59
+ }
60
+
49
61
  // Plugin virtual modules (resolveId/load in nowaki.config). Any export is allowed.
50
62
  declare module "virtual:*";
51
63
 
52
- // Extends preact's JSX.IntrinsicAttributes so client:* directives can go on any component.
53
- // This import makes the file a module, so the global types below are exposed via declare global.
54
- import "preact";
55
- declare module "preact" {
56
- namespace JSX {
57
- interface IntrinsicAttributes {
58
- /** Hydrate on page load (default). */
59
- "client:load"?: boolean;
60
- /** Hydrate when idle, via requestIdleCallback. */
61
- "client:idle"?: boolean;
62
- /** Hydrate once visible, via IntersectionObserver. */
63
- "client:visible"?: boolean;
64
- /** Hydrate when the media query matches. e.g. client:media="(min-width: 768px)" */
65
- "client:media"?: string;
66
- /** Skip SSR and render on the client only (for islands using browser-only APIs). */
67
- "client:only"?: boolean;
68
- }
69
- }
64
+ // import.meta.env (PUBLIC_*, MODE and BASE_URL are inlined at build time). These are global
65
+ // because this file is not a module. `nowaki typegen` adds the types of env.ts's public values
66
+ // in .nowaki/types.d.ts.
67
+ interface ImportMetaEnv {
68
+ readonly MODE: string;
69
+ /** nowaki.config `basePath` with a trailing slash ("/app/"), or "/". */
70
+ readonly BASE_URL: string;
71
+ readonly [key: `PUBLIC_${string}`]: string | undefined;
70
72
  }
71
-
72
- declare global {
73
- // import.meta.env (PUBLIC_* and MODE are inlined at build time).
74
- interface ImportMetaEnv {
75
- readonly MODE: string;
76
- readonly [key: `PUBLIC_${string}`]: string | undefined;
77
- }
78
- interface ImportMeta {
79
- readonly env: ImportMetaEnv;
80
- }
73
+ interface ImportMeta {
74
+ readonly env: ImportMetaEnv;
81
75
  }
@@ -0,0 +1,22 @@
1
+ // Nowaki's additions to preact's JSX types. No need to edit.
2
+ // Extends preact's JSX.IntrinsicAttributes so client:* directives can go on any component.
3
+ // The import makes this file a module, which a `declare module "preact"` augmentation needs.
4
+ // The ambient asset declarations are in nowaki-env.d.ts, which must not be a module.
5
+ import "preact";
6
+
7
+ declare module "preact" {
8
+ namespace JSX {
9
+ interface IntrinsicAttributes {
10
+ /** Hydrate on page load (default). */
11
+ "client:load"?: boolean;
12
+ /** Hydrate when idle, via requestIdleCallback. */
13
+ "client:idle"?: boolean;
14
+ /** Hydrate once visible, via IntersectionObserver. */
15
+ "client:visible"?: boolean;
16
+ /** Hydrate when the media query matches. e.g. client:media="(min-width: 768px)" */
17
+ "client:media"?: string;
18
+ /** Skip SSR and render on the client only (for islands using browser-only APIs). */
19
+ "client:only"?: boolean;
20
+ }
21
+ }
22
+ }
@@ -9,11 +9,11 @@
9
9
  "prerender": "nowaki prerender"
10
10
  },
11
11
  "dependencies": {
12
- "@nowaki-dev/runtime": "^0.16.2",
12
+ "@nowaki-dev/runtime": "^0.17.0",
13
13
  "preact": "^11.1.1",
14
14
  "preact-render-to-string": "^6.8.2"
15
15
  },
16
16
  "devDependencies": {
17
- "nowaki": "^0.17.2"
17
+ "nowaki": "^0.18.0"
18
18
  }
19
19
  }
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "include": [
25
25
  "nowaki-env.d.ts",
26
+ "nowaki-jsx.d.ts",
26
27
  ".nowaki/types.d.ts",
27
28
  "nowaki.config.*",
28
29
  "routes",