@goxjs/goxjs 0.3.0 → 0.4.1

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
@@ -77,13 +77,66 @@ render(
77
77
  > `<Show when={x} fallback={f}>…</Show>` → `<view show={x} fallback={f}>…</view>`。
78
78
  > `gx/view` 现在只导出 `Switch` / `Match`。
79
79
 
80
- GUI 示例(仓库 `testdata/` 下有 30+ 个可直接运行的演示):
80
+ GUI 示例(仓库 `testdata/` 下有 35+ 个可直接运行的演示):
81
81
 
82
82
  ```bash
83
83
  goxjs testdata/view_demo2.js # 列表复用 / 条件保活 / 多分支
84
84
  goxjs testdata/model_demo.js # 八类受控组件的双向绑定
85
+ goxjs testdata/router_demo.js # 路由表 / 参数匹配 / 三级守卫 / 懒加载
85
86
  ```
86
87
 
88
+ ## 路由与屏幕(`gx/router` / `gx/screen`)
89
+
90
+ **0.4.0 新增模块**:路由不用再自己手写 signal 切页了 ——
91
+
92
+ ```jsx
93
+ import { h, render } from "gx/gfx";
94
+ import { createRouter, RouterView, RouterLink } from "gx/router";
95
+
96
+ function HomePage() { return <text font={15}>home</text>; }
97
+ function ListPage() { return <text font={15}>list</text>; }
98
+ function DetailPage(props) { return <text font={15}>{"detail id=" + props.param.id}</text>; }
99
+
100
+ const router = createRouter({
101
+ routes: [
102
+ { path: "/", name: "home", component: HomePage },
103
+ { path: "/list", name: "list", component: ListPage, keepAlive: true },
104
+ { path: "/detail/:id", name: "detail", component: DetailPage },
105
+ { path: "*", name: "nf", component: HomePage },
106
+ ],
107
+ initial: "/",
108
+ });
109
+
110
+ render(
111
+ <window title="app" width={480} height={360}>
112
+ <column gap={8} padding={12}>
113
+ <text font={12}>{() => "route: " + router.currentRoute().path}</text>
114
+ <row gap={10}>
115
+ <RouterLink to="/list"><text font={13}>列表</text></RouterLink>
116
+ <RouterLink to={{ name: "detail", params: { id: 7 } }}><text font={13}>详情</text></RouterLink>
117
+ </row>
118
+ <RouterView />
119
+ </column>
120
+ </window>
121
+ );
122
+ ```
123
+
124
+ 开箱就有:`:param` / `:param?` / `*` 匹配(优先级不依赖声明序)、三级守卫
125
+ (`beforeEach` / `beforeEnter` / `beforeRouteLeave` …,可返回 Promise 做异步)、`push` 返回
126
+ Promise(`{ok:false, reason}` 表达被拦截)、`Alt+←` / `Alt+→` 后退前进、`lazy(() => import(…))`
127
+ 懒加载、**两档状态保留**(路由记录 `keepAlive: true` 保住整棵子树;`useRouteState()` 存住值)、
128
+ 多窗口独立导航栈与 `sync()` 同步组(mirror / share / follow)。
129
+
130
+ `gx/screen` 提供显示器枚举、窗口所在屏、折叠姿态上报;**半折时 `RouterView` 自动变双栏**
131
+ (左栏历史的上一条,通常是列表)。
132
+
133
+ > 三处与浏览器路由的刻意差异:**没有 URL,也没有 history 模式**(桌面应用没有地址栏,"历史"
134
+ > 是内存里的一个栈);`to` 一律按**绝对路径**解析;正则路径约束 / `alias` / 相对路径不做,
135
+ > 参数校验写在 `beforeEnter`。Windows / X11 没有折叠姿态查询 API —— 框架只提供 `reportPosture()`
136
+ > 通道而不猜姿态,没人上报就恒为平展屏。
137
+ >
138
+ > 完整手册:[`docs/gui-router.md`](https://github.com/14752222/Gox/blob/main/docs/gui-router.md)。
139
+
87
140
  完整文档与语言示例见 [GitHub 仓库](https://github.com/14752222/Gox)。
88
141
 
89
142
  ## License
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goxjs/goxjs",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Gox — 用 Go 从零实现的 JavaScript 运行时(lexer → parser → 字节码 VM),单二进制零外部依赖",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,7 +8,8 @@
8
8
  "url": "git+https://github.com/14752222/Gox.git"
9
9
  },
10
10
  "bin": {
11
- "goxjs": "bin/gox.js"
11
+ "goxjs": "bin/gox.js",
12
+ "gox": "bin/gox.js"
12
13
  },
13
14
  "files": [
14
15
  "bin/gox.js",