create-murasaki 0.4.0 → 0.7.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-murasaki",
3
- "version": "0.4.0",
3
+ "version": "0.7.0",
4
4
  "description": "Scaffolder for Murasaki apps. Run with `npm create murasaki@latest`.",
5
5
  "keywords": [
6
6
  "murasaki",
@@ -7,7 +7,7 @@
7
7
  "dev": "murasaki dev"
8
8
  },
9
9
  "dependencies": {
10
- "murasaki": "^0.4.0"
10
+ "murasaki": "^0.7.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "typescript": "^5.7.0"
@@ -1,11 +1,17 @@
1
1
  // src/app/page.tsx — the "/" route.
2
2
  //
3
- // Demonstrates client-side hooks (useState) and the native bridge
4
- // (useNotification / useClipboard / useShell) from murasaki/jsx/dom.
3
+ // Demonstrates hooks from murasaki/jsx/dom:
4
+ // useState — re-render on state change
5
+ // useNotification — OS notification banner
6
+ // useClipboard — read/write system clipboard
7
+ // useShell — open URL in default browser
8
+ // useDialog + useFs — file picker + read
5
9
 
6
10
  import { Link } from 'murasaki'
7
11
  import {
8
12
  useClipboard,
13
+ useDialog,
14
+ useFs,
9
15
  useNotification,
10
16
  useShell,
11
17
  useState,
@@ -13,9 +19,21 @@ import {
13
19
 
14
20
  export default function HomePage() {
15
21
  const [count, setCount] = useState(0)
22
+ const [filePath, setFilePath] = useState('')
23
+
16
24
  const notify = useNotification()
17
25
  const clipboard = useClipboard()
18
26
  const shell = useShell()
27
+ const dialog = useDialog()
28
+ const fs = useFs()
29
+
30
+ async function pickFile() {
31
+ const paths = await dialog.openFile({ title: 'Pick a file' })
32
+ if (paths.length === 0) return
33
+ setFilePath(paths[0])
34
+ const text = await fs.readFile(paths[0])
35
+ notify({ title: 'File loaded', body: `${text.length} chars from ${paths[0]}` })
36
+ }
19
37
 
20
38
  return (
21
39
  <main>
@@ -38,15 +56,18 @@ export default function HomePage() {
38
56
  <button onClick={() => notify({ title: 'Hello', body: `Count: ${count}` })}>
39
57
  🔔 Notify
40
58
  </button>
41
- <button onClick={() => clipboard.write(`Count: ${count}`)}>
42
- 📋 Copy to clipboard
43
- </button>
59
+ <button onClick={() => clipboard.write(`Count: ${count}`)}>📋 Copy</button>
60
+ <button onClick={pickFile}>📂 Pick file</button>
44
61
  <button onClick={() => shell.openExternal('https://github.com/murasakijs/murasaki')}>
45
- 🔗 Open repo
62
+ 🔗 Repo
46
63
  </button>
47
64
  </div>
48
65
 
49
- <p className="hint">Edit this file — the window reloads instantly.</p>
66
+ {filePath && (
67
+ <p className="hint">
68
+ Last picked: <code>{filePath}</code>
69
+ </p>
70
+ )}
50
71
 
51
72
  <nav className="links">
52
73
  <Link href="/about">About →</Link>