@crossberryweb/mozhi 3.7.0 → 3.9.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/README.md CHANGED
@@ -22,6 +22,32 @@ always in sync: same version, same flags, same exit codes.
22
22
  end-of-life notice. The interpreter itself is a fully static native binary —
23
23
  Node.js only runs the tiny launcher shim.
24
24
 
25
+ ## New in 3.9.0
26
+
27
+ - `mz install <name>` falls back to NxMirror when a name is absent from the
28
+ existing registry. Use `mz install nx:<name>[@version]` explicitly.
29
+ - The interpreter imports manifest-based packages directly from `nx_modules/`,
30
+ including sibling dependencies installed by `nxc install`.
31
+ - `[build] mode = "native"`, `output`, and `release` configure numeric
32
+ machine-code builds. This requires a separately installed `mozhi-fast`
33
+ Rust compiler and a host C compiler; those tools are **not bundled** in
34
+ this npm package. Set `MOZHI_FAST_BIN` or put `mozhi-fast` on PATH.
35
+ - `mz pkg build/publish --native` can include an optional manifest-declared
36
+ executable alongside importable source. Installation never builds or
37
+ executes downloaded tools automatically.
38
+
39
+ Native compilation supports numeric functions/control flow and literal
40
+ printing, not imports, web modules or the full dynamic type system. It uses
41
+ C `double`; it does not guarantee exact 64-bit integers or a fixed runtime.
42
+ Executables are host-specific, and source remains required for package
43
+ imports. See [native build documentation](https://github.com/crossberry-in/mozhi/blob/main/docs/BUILD.md).
44
+
45
+ The npm build includes the app scaffold's nested templates and icon assets.
46
+ Both bundled interpreters report 3.9.0 and are statically linked Linux
47
+ executables for x86-64 and ARM64. These builds do not include OpenSSL;
48
+ the interpreter's native HTTPS client needs an OpenSSL-enabled build.
49
+ Node.js package-manager HTTPS requests are unaffected.
50
+
25
51
  ## Package manager (v3.3.0)
26
52
 
27
53
  The launcher now includes a package manager — no interpreter required:
@@ -55,6 +81,25 @@ mz pkg new mytool
55
81
 
56
82
  Full guide: https://crossberry-in.github.io/mozhi-doc/packages.html
57
83
 
84
+ ## Apps (v3.8.0)
85
+
86
+ The launcher also implements the **app platform** — write app code in
87
+ `.mz`, build a `.pkg` release, install it, open it in a full window
88
+ (like Kotlin → APK, with Mozhi's own tools):
89
+
90
+ ```bash
91
+ mz app new counter --id in.crossberry.counter --label Counter
92
+ mz app build counter # → dist/counter-0.1.0.pkg
93
+ mz app install counter/dist/counter-0.1.0.pkg # → ~/.mozhi/apps/<id>/
94
+ mz app list # launcher entries
95
+ mz app open in.crossberry.counter # full app window
96
+ mz app home # launcher home screen
97
+ mz app uninstall in.crossberry.counter
98
+ ```
99
+
100
+ Full guide: **docs/APPS.md** in the repository (honest scope included:
101
+ the window is the app's own web UI today; the `.pkg` is not an APK).
102
+
58
103
  ## What you get (v3.3.0)
59
104
 
60
105
  - **Precise error diagnostics**: every error carries a stable code
Binary file
Binary file
package/bin/mozhi.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * natively by this launcher (lib/) without starting the interpreter —
17
17
  * see `mz help pkg`.
18
18
  *
19
- * Bundled official release binaries (v3.6.0 line, static builds with
19
+ * Bundled official release binaries (v3.9.0 line, static builds with
20
20
  * SQLite and the RFC 6234 SHA sources vendored):
21
21
  * bin/mozhi-linux-x86_64
22
22
  * bin/mozhi-linux-arm64
@@ -52,7 +52,7 @@ if (nodeMajor < 22) {
52
52
 
53
53
  /* ---------------- package manager commands (no interpreter) --------- */
54
54
 
55
- const PKG_COMMANDS = new Set(['install', 'add', 'uninstall', 'remove', 'list', 'ls', 'search', 'pkg', 'package']);
55
+ const PKG_COMMANDS = new Set(['install', 'add', 'uninstall', 'remove', 'list', 'ls', 'search', 'pkg', 'package', 'app', 'apps']);
56
56
 
57
57
  const argv = process.argv.slice(2);
58
58
 
@@ -74,7 +74,7 @@ if (argv.length && PKG_COMMANDS.has(argv[0])) {
74
74
 
75
75
  if (!fs.existsSync(bin)) {
76
76
  console.error('[mozhi] No bundled interpreter for ' + process.platform + '-' + process.arch + '.');
77
- console.error('[mozhi] This package ships official v3.6.0 binaries for:');
77
+ console.error('[mozhi] This package ships official v3.9.0 binaries for:');
78
78
  console.error('[mozhi] linux-x86_64, linux-arm64 (fully static — works on glibc, Alpine, Termux)');
79
79
  console.error('[mozhi] For macOS, Windows and other platforms use the installer:');
80
80
  console.error('[mozhi] curl -fsSL https://github.com/crossberry-in/mozhi-doc/raw/main/install.sh | bash');
@@ -1,6 +1,2 @@
1
- dbb0c6a28587c0574a230b2bea5d037b6c64152d02feba91d1fc125bf251e11c mozhi-interpreter-alpine-arm64
2
- fd3f4558821648c3ebc6f71d4c0d354e4f3de99ca6417d8466aac6aceb18890f mozhi-interpreter-alpine-x86_64
3
- a15b858168d21a5b459e264cd904f490fd54cae6ca077d9522d95db1136d7885 mozhi-interpreter-linux-arm64
4
- 3d903735c716bebfdba950fe6f345a8729b8f3749276cd90c4d38d71eb4ee1fb mozhi-interpreter-linux-x86_64
5
- eb1f7fd7d32b71657ee7001cd42c84f82064734f4c3c7aec6cee836f190f5274 mozhi-interpreter-macos-arm64
6
- a4a31288b0dc624cd80904fa1748f2c73832055f647760e3cbeb9e5ea840b445 mozhi-interpreter-macos-x86_64
1
+ e0577576809a48135c1943f4a4f32ec8c3e07d91059152df6589e6c4058629f0 bin/mozhi-linux-x86_64
2
+ 6d0bae7a08ebac44b234a145523abef21231a678ad1aa5b462b4a8eade73be89 bin/mozhi-linux-arm64
@@ -0,0 +1,32 @@
1
+ # {{label}}
2
+
3
+ A [Mozhi](https://github.com/crossberry-in/mozhi) app — written in `.mz`,
4
+ released as a `.pkg`, installed into the launcher, opened in a full window.
5
+
6
+ ## Files
7
+
8
+ | File | Purpose |
9
+ | --- | --- |
10
+ | `mozhi.toml` | Project config + `[app]` identity (id, icon, window kind) |
11
+ | `main.mz` | App entry: routes + UI data (Mozhi web platform) |
12
+ | `src/logic.mz` | Pure logic, imported as a relative package module |
13
+ | `views/index.html` | The full-window UI template |
14
+ | `public/` | Styles + client script served statically |
15
+ | `public/icon.png` | Launcher logo (served at /icon.png) |
16
+ | `tests/app.test.mz` | Unit tests (`mozhi test`) |
17
+
18
+ ## Lifecycle
19
+
20
+ ```sh
21
+ mozhi dev # 1. develop (live reload)
22
+ mozhi test # 2. test
23
+ mz app build # 3. release: dist/{{name}}-0.1.0.pkg
24
+ mz app install dist/{{name}}-0.1.0.pkg
25
+ mz app list # 4. launcher entry visible
26
+ mz app open {{id}} # 5. opens the full app window
27
+ mz app home # or pick it from the home screen
28
+ ```
29
+
30
+ The `.pkg` is Mozhi's app package (a zip with the manifest, bundled entry,
31
+ views, assets and a SHA-256 manifest) — the same role an APK plays for
32
+ Android, not an APK itself. See docs/APPS.md in the Mozhi repository.
@@ -0,0 +1,33 @@
1
+ # {{label}} — app entry.
2
+ #
3
+ # The UI is served by Mozhi's native web platform: the window you get from
4
+ # `mz app open` renders views/index.html with data produced by this module.
5
+ # Pure logic lives in src/logic.mz — imported as a relative project module
6
+ # (`import logic` brings its functions into scope) — so it can be
7
+ # unit-tested without starting the server.
8
+
9
+ import web
10
+ import logic
11
+
12
+ let app = web.create()
13
+
14
+ app.static("public")
15
+ app.views("views")
16
+
17
+ app.get("/", fn(req, res) {
18
+ return res.render("index.html", {
19
+ label: "{{label}}",
20
+ version: "0.1.0",
21
+ count: value()
22
+ })
23
+ })
24
+
25
+ app.post("/api/tap", fn(req, res) {
26
+ return res.json({ count: tap() })
27
+ })
28
+
29
+ app.post("/api/reset", fn(req, res) {
30
+ return res.json({ count: reset() })
31
+ })
32
+
33
+ app.listen("127.0.0.1", {{port}})
@@ -0,0 +1,29 @@
1
+ # {{label}} — a Mozhi app.
2
+ #
3
+ # Lifecycle (the same shape as Kotlin -> APK on Android):
4
+ # mz app build -> dist/{{name}}-<version>.pkg release package
5
+ # mz app install -> ~/.mozhi/apps/{{id}}/ launcher entry
6
+ # mz app home -> launcher home screen
7
+ # mz app open -> opens the app in its full window
8
+ # mozhi dev -> develop locally with live reload
9
+ #
10
+ # [project] is the standard Mozhi project config (mozhi build / dev / serve
11
+ # all work in this directory). [app] is the app-platform identity: it is
12
+ # what the launcher shows and what `mz app install` registers.
13
+
14
+ [project]
15
+ name = "{{name}}"
16
+ version = "0.1.0"
17
+ entry = "main.mz"
18
+ description = "{{label}} — a Mozhi app"
19
+
20
+ [app]
21
+ id = "{{id}}" # reverse-DNS id, unique on the device
22
+ icon = "public/icon.png" # launcher logo (PNG)
23
+ window = "full" # the app opens in its own full window
24
+ kind = "web" # web = served UI (browser window today; the same
25
+ # .pkg drives the native launcher on NoxOS v0.4)
26
+
27
+ [server]
28
+ host = "127.0.0.1"
29
+ port = {{port}}
@@ -0,0 +1,19 @@
1
+ // {{label}} — tap handling.
2
+ // State lives in the Mozhi backend (lib/logic.mz); this window only
3
+ // renders what the app returns. On NoxOS v0.4 the same endpoints are
4
+ // driven by the native touch surface.
5
+ 'use strict';
6
+
7
+ const countEl = document.getElementById('count');
8
+
9
+ document.getElementById('tap').addEventListener('click', async () => {
10
+ const r = await fetch('/api/tap', { method: 'POST' });
11
+ const data = await r.json();
12
+ countEl.textContent = data.count;
13
+ });
14
+
15
+ document.getElementById('reset').addEventListener('click', async () => {
16
+ const r = await fetch('/api/reset', { method: 'POST' });
17
+ const data = await r.json();
18
+ countEl.textContent = data.count;
19
+ });
Binary file
@@ -0,0 +1,106 @@
1
+ /* {{label}} — full-window app styles (dark, touch-first).
2
+ * The app owns the whole window: 100dvh layout, no page scroll,
3
+ * safe-area aware title bar like a native mobile app shell. */
4
+
5
+ * { box-sizing: border-box; margin: 0; }
6
+
7
+ html, body { height: 100%; }
8
+
9
+ body {
10
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
11
+ background: linear-gradient(180deg, #0b1220 0%, #12233a 100%);
12
+ color: #e6f7ff;
13
+ overflow: hidden;
14
+ -webkit-user-select: none;
15
+ user-select: none;
16
+ }
17
+
18
+ .app {
19
+ min-height: 100dvh;
20
+ display: flex;
21
+ flex-direction: column;
22
+ }
23
+
24
+ .titlebar {
25
+ display: flex;
26
+ align-items: center;
27
+ gap: 12px;
28
+ padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
29
+ border-bottom: 1px solid #1e2f47;
30
+ background: rgba(10, 16, 28, 0.55);
31
+ }
32
+
33
+ .logo {
34
+ width: 40px;
35
+ height: 40px;
36
+ border-radius: 10px;
37
+ }
38
+
39
+ .titles h1 {
40
+ font-size: 18px;
41
+ font-weight: 600;
42
+ letter-spacing: 0.2px;
43
+ }
44
+
45
+ .version {
46
+ font-size: 12px;
47
+ color: #7fa3c0;
48
+ }
49
+
50
+ .stage {
51
+ flex: 1;
52
+ display: flex;
53
+ flex-direction: column;
54
+ align-items: center;
55
+ justify-content: center;
56
+ gap: 10px;
57
+ padding: 24px;
58
+ }
59
+
60
+ .count {
61
+ font-size: 108px;
62
+ font-weight: 700;
63
+ font-variant-numeric: tabular-nums;
64
+ line-height: 1;
65
+ }
66
+
67
+ .hint {
68
+ color: #7fa3c0;
69
+ font-size: 14px;
70
+ text-transform: uppercase;
71
+ letter-spacing: 3px;
72
+ margin-bottom: 18px;
73
+ }
74
+
75
+ .tap {
76
+ width: 240px;
77
+ padding: 18px 0;
78
+ font-size: 20px;
79
+ font-weight: 700;
80
+ color: #06222a;
81
+ background: linear-gradient(180deg, #2adcf0, #14b8c8);
82
+ border: 0;
83
+ border-radius: 18px;
84
+ cursor: pointer;
85
+ touch-action: manipulation;
86
+ box-shadow: 0 10px 30px rgba(34, 211, 238, 0.25);
87
+ }
88
+
89
+ .tap:active { transform: scale(0.97); }
90
+
91
+ .ghost {
92
+ margin-top: 6px;
93
+ padding: 10px 22px;
94
+ font-size: 14px;
95
+ color: #9cc2dd;
96
+ background: transparent;
97
+ border: 1px solid #2a4060;
98
+ border-radius: 12px;
99
+ cursor: pointer;
100
+ }
101
+
102
+ .note {
103
+ margin-top: 28px;
104
+ color: #51708c;
105
+ font-size: 12px;
106
+ }
@@ -0,0 +1,22 @@
1
+ # Pure app logic for {{label}} — no I/O, no server.
2
+ #
3
+ # Imported by main.mz as a relative project module (`import logic`,
4
+ # resolved from src/). Keeping logic here — instead of inside route
5
+ # handlers — means tests can import the same module directly:
6
+ # see tests/app.test.mz.
7
+
8
+ let state = { count: 0 }
9
+
10
+ fn tap() {
11
+ state.count = state.count + 1
12
+ return state.count
13
+ }
14
+
15
+ fn reset() {
16
+ state.count = 0
17
+ return state.count
18
+ }
19
+
20
+ fn value() {
21
+ return state.count
22
+ }
@@ -0,0 +1,13 @@
1
+ # {{label}} unit tests — run with: mozhi test
2
+ #
3
+ # Imports the pure logic module directly (relative package import), so
4
+ # no server is started during testing.
5
+
6
+ import l from "../src/logic.mz"
7
+
8
+ assert_eq(l.value(), 0, "starts at zero")
9
+ assert_eq(l.tap(), 1, "first tap returns 1")
10
+ assert_eq(l.tap(), 2, "second tap returns 2")
11
+ assert_eq(l.value(), 2, "value matches taps")
12
+ assert_eq(l.reset(), 0, "reset returns to zero")
13
+ assert_eq(l.value(), 0, "value is zero after reset")
@@ -0,0 +1,29 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
+ <title>{{ label }}</title>
7
+ <link rel="icon" href="/icon.png">
8
+ <link rel="stylesheet" href="/style.css">
9
+ </head>
10
+ <body>
11
+ <main class="app">
12
+ <header class="titlebar">
13
+ <img class="logo" src="/icon.png" alt="app logo">
14
+ <div class="titles">
15
+ <h1>{{ label }}</h1>
16
+ <span class="version">v{{ version }}</span>
17
+ </div>
18
+ </header>
19
+ <section class="stage">
20
+ <div class="count" id="count">{{ count }}</div>
21
+ <div class="hint">taps</div>
22
+ <button class="tap" id="tap" type="button">Tap me</button>
23
+ <button class="ghost" id="reset" type="button">Reset</button>
24
+ <p class="note">.mz &rarr; build &rarr; .pkg &rarr; install &rarr; full window</p>
25
+ </section>
26
+ </main>
27
+ <script src="/app.js"></script>
28
+ </body>
29
+ </html>