create-nowaki 0.12.0 → 0.13.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.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Scaffold a new Nowaki app",
5
5
  "license": "MIT",
6
6
  "author": "VorEdge <dev@voredge.com>",
@@ -71,6 +71,17 @@ nowaki.config.mjs plugins (optional)
71
71
  return <button onClick={() => setN(n + 1)}>count: {n}</button>;
72
72
  }
73
73
  ```
74
+ **Lazy hydration** (Astro-style `client:*` directives) controls *when* an
75
+ island hydrates — add a directive where you use it:
76
+ ```tsx
77
+ <Counter client:load /> // default — hydrate on load
78
+ <Counter client:idle /> // hydrate on requestIdleCallback
79
+ <Counter client:visible /> // hydrate when scrolled into view
80
+ <Chart client:media="(min-width: 768px)" /> // hydrate when the query matches
81
+ <Map client:only /> // skip SSR, render only on the client
82
+ ```
83
+ Prefer `client:visible` / `client:idle` for below-the-fold or non-critical
84
+ islands to cut work on first load. The directives are typed (no prop leaks).
74
85
  7. **Server functions** — a module with a top-of-file `"use server"` directive
75
86
  becomes RPC; the client gets a tiny fetch proxy, the implementation stays on
76
87
  the server. Validate arguments; read auth via `getContext()`:
@@ -91,6 +102,15 @@ nowaki.config.mjs plugins (optional)
91
102
  `error.tsx`, mark the message element `data-nowaki-error` and the retry button
92
103
  `data-nowaki-reset`. Visited pages are kept in a ~30s Router Cache, so
93
104
  back/forward is instant. These are server components, not islands.
105
+ 10. **Typed navigation** — `dev`/`build` generate `.nowaki/types.d.ts` from your
106
+ routes (run `nowaki typegen` to refresh manually). Build links type-safely
107
+ from `@nowaki-dev/runtime/navigation`:
108
+ ```tsx
109
+ import { route, Link } from "@nowaki-dev/runtime/navigation";
110
+ <Link href="/about">About</Link> // static path, checked
111
+ <a href={route("/blog/[slug]", { slug })}>Post</a> // dynamic, params typed
112
+ ```
113
+ Unknown paths, missing params, and wrong param keys are compile errors.
94
114
 
95
115
  ## Don't
96
116
 
@@ -1,6 +1,8 @@
1
1
  node_modules/
2
2
  dist/
3
3
  .cache/
4
+ .nowaki/
5
+ .vercel/
4
6
 
5
7
  # env (keep secrets out of git; only PUBLIC_* reaches the client)
6
8
  .env
@@ -32,11 +32,34 @@ declare module "*.pdf" { const url: string; export default url; }
32
32
  // プラグインの仮想モジュール(nowaki.config の resolveId/load)。任意の export を許す。
33
33
  declare module "virtual:*";
34
34
 
35
- // import.meta.env(PUBLIC_* MODE がビルド時に inline される)。
36
- interface ImportMetaEnv {
37
- readonly MODE: string;
38
- readonly [key: `PUBLIC_${string}`]: string | undefined;
35
+ // 遅延ハイドレーション指令(Astro 互換の client:*)を任意のコンポーネントに付けられるよう、
36
+ // preact の JSX.IntrinsicAttributes を拡張する。<Counter client:visible /> 等が型チェックを通る。
37
+ // (この import で本ファイルはモジュールになる=下のグローバル型は declare global で公開する。)
38
+ import "preact";
39
+ declare module "preact" {
40
+ namespace JSX {
41
+ interface IntrinsicAttributes {
42
+ /** ページ読み込み時にハイドレート(既定)。 */
43
+ "client:load"?: boolean;
44
+ /** requestIdleCallback でアイドル時にハイドレート。 */
45
+ "client:idle"?: boolean;
46
+ /** IntersectionObserver で可視になったらハイドレート。 */
47
+ "client:visible"?: boolean;
48
+ /** 指定メディアクエリが一致したらハイドレート。例: client:media="(min-width: 768px)" */
49
+ "client:media"?: string;
50
+ /** SSR せず、クライアントだけで描画(ブラウザ専用 API を使う島向け)。 */
51
+ "client:only"?: boolean;
52
+ }
53
+ }
39
54
  }
40
- interface ImportMeta {
41
- readonly env: ImportMetaEnv;
55
+
56
+ declare global {
57
+ // import.meta.env(PUBLIC_* と MODE がビルド時に inline される)。
58
+ interface ImportMetaEnv {
59
+ readonly MODE: string;
60
+ readonly [key: `PUBLIC_${string}`]: string | undefined;
61
+ }
62
+ interface ImportMeta {
63
+ readonly env: ImportMetaEnv;
64
+ }
42
65
  }
@@ -9,11 +9,11 @@
9
9
  "prerender": "nowaki prerender"
10
10
  },
11
11
  "dependencies": {
12
- "@nowaki-dev/runtime": "^0.10.0",
12
+ "@nowaki-dev/runtime": "^0.11.0",
13
13
  "preact": "^10.25.4",
14
14
  "preact-render-to-string": "^6.5.13"
15
15
  },
16
16
  "devDependencies": {
17
- "nowaki": "^0.11.0"
17
+ "nowaki": "^0.12.0"
18
18
  }
19
19
  }
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "include": [
25
25
  "nowaki-env.d.ts",
26
+ ".nowaki/types.d.ts",
26
27
  "nowaki.config.*",
27
28
  "routes",
28
29
  "islands",