@geektech/tsone 0.1.0 → 0.3.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-zh.md +44 -11
- package/README.md +48 -10
- package/dist/core/reactive/scheduler.d.ts +32 -0
- package/dist/core/reactive.d.ts +12 -0
- package/dist/dom/index.d.ts +534 -0
- package/dist/dom/index.js +4 -0
- package/dist/dom/index.js.map +10 -0
- package/dist/index-939sv8vt.js +26 -0
- package/dist/index-939sv8vt.js.map +11 -0
- package/dist/index-p55hs6x8.js +12 -0
- package/dist/index-p55hs6x8.js.map +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -606
- package/dist/index.js.map +4 -6
- package/dist/router/index.js +2 -16
- package/dist/router/index.js.map +1 -1
- package/dist/style/index.js +2 -11
- package/dist/style/index.js.map +1 -1
- package/package.json +10 -1
- package/dist/index-8wjswsye.js +0 -63
- package/dist/index-8wjswsye.js.map +0 -10
- package/dist/index-vpx80nq5.js +0 -32
- package/dist/index-vpx80nq5.js.map +0 -10
- package/dist/index-wv9gyjqt.js +0 -2112
- package/dist/index-wv9gyjqt.js.map +0 -25
package/README-zh.md
CHANGED
|
@@ -53,7 +53,7 @@ class App extends Component<Record<string, never>, AppState> {
|
|
|
53
53
|
protected initState(): AppState {
|
|
54
54
|
return {
|
|
55
55
|
count: 0,
|
|
56
|
-
version: '0.0
|
|
56
|
+
version: '0.3.0',
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -95,9 +95,10 @@ console.log(status.value);
|
|
|
95
95
|
|
|
96
96
|
## 开发工具
|
|
97
97
|
|
|
98
|
-
独立的 `@geektech/tsone-cli` 包提供 `tsone dev` 与
|
|
99
|
-
`
|
|
100
|
-
`
|
|
98
|
+
独立的 `@geektech/tsone-cli` 包提供 `tsone create`、`tsone dev` 与
|
|
99
|
+
`tsone build`。`tsone create` 会在当前目录脚手架一个基础项目(包含一个展示
|
|
100
|
+
TSone 名称与 GitHub 链接的首页)。CLI 的默认入口为 `src/main.ts`;入口模块必须
|
|
101
|
+
通过 `export const app` 导出应用,并且该值必须提供 `renderHtmlDocument()`。
|
|
101
102
|
|
|
102
103
|
可以在项目根目录创建可选的 `tsone.config.ts`:
|
|
103
104
|
|
|
@@ -121,16 +122,36 @@ export default defineConfig({
|
|
|
121
122
|
```
|
|
122
123
|
|
|
123
124
|
代理也支持字符串简写,例如 `{ '/backend': 'http://localhost:4000' }`。默认值为
|
|
124
|
-
入口 `src/main.ts`、主机 `127.0.0.1`、端口 `52211`、空的 `server.proxy
|
|
125
|
-
|
|
125
|
+
入口 `src/main.ts`、主机 `127.0.0.1`、端口 `52211`、空的 `server.proxy`、输出
|
|
126
|
+
目录 `dist`,且没有额外页面。
|
|
127
|
+
|
|
128
|
+
多页应用可在同一配置文件里把路由映射到页面入口;每个页面入口与根入口一样,
|
|
129
|
+
都要通过 `export const app` 暴露带有 `renderHtmlDocument()` 的应用:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
export default defineConfig({
|
|
133
|
+
entry: 'src/main.ts',
|
|
134
|
+
pages: {
|
|
135
|
+
'/about': 'src/about.ts',
|
|
136
|
+
'/docs/guide': 'src/guide.ts',
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`pages` 的键必须以 `/` 开头并支持嵌套;根路径 `/` 由 `entry` 提供。开发时每个
|
|
142
|
+
页面在其路由下提供服务,`tsone build` 会为每个页面输出一个 HTML 文档
|
|
143
|
+
(`index.html`、`about.html`、`docs/guide.html`),资源 URL 相对各文档。
|
|
126
144
|
|
|
127
145
|
```text
|
|
128
|
-
tsone
|
|
146
|
+
tsone create
|
|
147
|
+
tsone dev [--host <host>] [--port <port>] [--no-watch]
|
|
129
148
|
tsone build [--out-dir <path>]
|
|
130
149
|
```
|
|
131
150
|
|
|
132
|
-
`
|
|
133
|
-
`--port=3000`
|
|
151
|
+
`create` 不接受任何选项。`dev` 接受主机、端口覆盖和 `--no-watch`;`build` 只
|
|
152
|
+
接受输出目录覆盖;`--port 3000` 和 `--port=3000` 两种形式均可。`tsone dev`
|
|
153
|
+
默认监听项目文件,文件变化时通过 `/__tsone/reload` 通知浏览器刷新。构建输出
|
|
154
|
+
必须是项目根目录内部的安全子目录。
|
|
134
155
|
|
|
135
156
|
编程式工具 API 来自 `@geektech/tsone-cli`,而不是框架主入口。该包导出
|
|
136
157
|
`defineConfig`、`resolveConfig`、`startDevServer` 与 `build`。调用方负责开发
|
|
@@ -210,7 +231,7 @@ bun run dev:admin
|
|
|
210
231
|
文档站点使用 typed content registry:中文内容维护在
|
|
211
232
|
`packages/tsone/docs/app/content/zh/`,英文内容维护在
|
|
212
233
|
`packages/tsone/docs/app/content/en/`,中英文逻辑路由必须一致。
|
|
213
|
-
中英文 catalog 当前各包含
|
|
234
|
+
中英文 catalog 当前各包含 15 条逻辑路由;新增或删除路由时必须同步修改两边。
|
|
214
235
|
|
|
215
236
|
内容链接保持 locale-neutral,不要手写 `/en/`。中文公开路由不带前缀,英文公开
|
|
216
237
|
路由使用 `/en/`。浏览器语言检测仅在 `/` 生效;手动选择优先并持久化,后续访问
|
|
@@ -224,6 +245,17 @@ bun run docs:build
|
|
|
224
245
|
|
|
225
246
|
构建遇到缺失、多余、重复、空内容或混用语言的页面时会严格失败。
|
|
226
247
|
|
|
248
|
+
需要把站点托管到某个子路径下(例如 GitHub Pages 项目页
|
|
249
|
+
`https://<owner>.github.io/tsone/`)时,可以用 base path 构建:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
bun run docs:build -- --base=/tsone/
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
也可以通过环境变量 `DOCS_BASE_PATH` 指定。配置 base path 后,产物中的所有
|
|
256
|
+
链接与资源 URL 都会带上该前缀,语言引导脚本会从渲染后的文档读取 base path,
|
|
257
|
+
站点即可在任意子路径下正常工作。
|
|
258
|
+
|
|
227
259
|
基础 HTML 文档壳也可以放进 `createApp` 配置里生成。默认会输出 `#app`
|
|
228
260
|
挂载节点;需要自定义挂载点时再传 `rootElement`。`body` 需要自定义时传入组件
|
|
229
261
|
或 VNode,不传 HTML 字符串。
|
|
@@ -283,7 +315,8 @@ const html = app.renderHtmlDocument({
|
|
|
283
315
|
- `effect()` / `stop()`
|
|
284
316
|
- `computed()`
|
|
285
317
|
- `ref()` / `isRef()` / `unref()`
|
|
286
|
-
- `
|
|
318
|
+
- `nextTick()` / `flushSync()`
|
|
319
|
+
- `version`,当前为 `0.3.0`
|
|
287
320
|
|
|
288
321
|
## 渲染、通信与表单
|
|
289
322
|
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ class App extends Component<Record<string, never>, AppState> {
|
|
|
58
58
|
protected initState(): AppState {
|
|
59
59
|
return {
|
|
60
60
|
count: 0,
|
|
61
|
-
version: '0.0
|
|
61
|
+
version: '0.3.0',
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -101,8 +101,10 @@ need to override the default target.
|
|
|
101
101
|
|
|
102
102
|
## Development Tooling
|
|
103
103
|
|
|
104
|
-
The separate `@geektech/tsone-cli` package provides `tsone
|
|
105
|
-
`tsone build`.
|
|
104
|
+
The separate `@geektech/tsone-cli` package provides `tsone create`, `tsone dev`,
|
|
105
|
+
and `tsone build`. `tsone create` scaffolds a basic project (including a
|
|
106
|
+
homepage showing the TSone name and a GitHub link) into the current directory.
|
|
107
|
+
The CLI's default entry is `src/main.ts`; that module must expose the
|
|
106
108
|
application as `export const app`, and the value must provide
|
|
107
109
|
`renderHtmlDocument()`.
|
|
108
110
|
|
|
@@ -130,16 +132,39 @@ export default defineConfig({
|
|
|
130
132
|
|
|
131
133
|
The string proxy shorthand is also supported, for example
|
|
132
134
|
`{ '/backend': 'http://localhost:4000' }`. Defaults are `src/main.ts`,
|
|
133
|
-
`127.0.0.1`, port `52211`, an empty `server.proxy`, and
|
|
135
|
+
`127.0.0.1`, port `52211`, an empty `server.proxy`, `dist`, and no additional
|
|
136
|
+
pages.
|
|
137
|
+
|
|
138
|
+
Multi-page applications map routes to page entries in the same config file;
|
|
139
|
+
each page entry exposes `app` with `renderHtmlDocument()` exactly like the root
|
|
140
|
+
entry:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
export default defineConfig({
|
|
144
|
+
entry: 'src/main.ts',
|
|
145
|
+
pages: {
|
|
146
|
+
'/about': 'src/about.ts',
|
|
147
|
+
'/docs/guide': 'src/guide.ts',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`pages` keys must start with `/` and may nest; the root `/` is served by
|
|
153
|
+
`entry`. During development each page is served at its route, and `tsone build`
|
|
154
|
+
emits one HTML document per page (`index.html`, `about.html`,
|
|
155
|
+
`docs/guide.html`) with page-relative asset URLs.
|
|
134
156
|
|
|
135
157
|
```text
|
|
136
|
-
tsone
|
|
158
|
+
tsone create
|
|
159
|
+
tsone dev [--host <host>] [--port <port>] [--no-watch]
|
|
137
160
|
tsone build [--out-dir <path>]
|
|
138
161
|
```
|
|
139
162
|
|
|
140
|
-
`dev` accepts host/port overrides and
|
|
141
|
-
override; both `--port 3000` and
|
|
142
|
-
|
|
163
|
+
`create` takes no options. `dev` accepts host/port overrides and `--no-watch`;
|
|
164
|
+
`build` accepts the output-directory override; both `--port 3000` and
|
|
165
|
+
`--port=3000` forms are valid. `tsone dev` watches the project by default and
|
|
166
|
+
notifies browsers to reload over `/__tsone/reload` when a watched file changes.
|
|
167
|
+
Build output must remain a safe child directory inside the project root.
|
|
143
168
|
|
|
144
169
|
Programmatic tooling is imported from `@geektech/tsone-cli`, not from the
|
|
145
170
|
framework root. It exports `defineConfig`, `resolveConfig`, `startDevServer`,
|
|
@@ -227,7 +252,7 @@ content lives in `packages/tsone/docs/app/content/zh/`, while English content
|
|
|
227
252
|
lives in `packages/tsone/docs/app/content/en/`. Every logical route must exist
|
|
228
253
|
in both directories.
|
|
229
254
|
|
|
230
|
-
Chinese and English catalogs each contain exactly
|
|
255
|
+
Chinese and English catalogs each contain exactly 15 logical routes. Add or
|
|
231
256
|
remove a route in both catalogs in the same change.
|
|
232
257
|
|
|
233
258
|
Content links stay locale-neutral: never write `/en/` manually. Chinese public
|
|
@@ -244,6 +269,18 @@ bun run docs:build
|
|
|
244
269
|
The build fails strictly for missing, extra, duplicate, empty, or
|
|
245
270
|
mixed-language pages.
|
|
246
271
|
|
|
272
|
+
To host the site under a sub-path (for example a GitHub Pages project page such
|
|
273
|
+
as `https://<owner>.github.io/tsone/`), build it with a base path:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
bun run docs:build -- --base=/tsone/
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
You can also set the `DOCS_BASE_PATH` environment variable. When a base path is
|
|
280
|
+
configured, every link and asset URL is prefixed with it, and the locale
|
|
281
|
+
bootstrap reads the base path from the rendered document, so the site works
|
|
282
|
+
under any sub-path.
|
|
283
|
+
|
|
247
284
|
The base HTML document shell can also be generated from `createApp`. It emits a
|
|
248
285
|
`#app` mount node by default; pass `rootElement` only to use a different target.
|
|
249
286
|
When a custom `body` is needed, pass a component or VNode rather than an HTML
|
|
@@ -303,7 +340,8 @@ The main `@geektech/tsone` entry point exports:
|
|
|
303
340
|
- `effect()` / `stop()`
|
|
304
341
|
- `computed()`
|
|
305
342
|
- `ref()` / `isRef()` / `unref()`
|
|
306
|
-
- `
|
|
343
|
+
- `nextTick()` / `flushSync()`
|
|
344
|
+
- `version`, currently `0.3.0`
|
|
307
345
|
|
|
308
346
|
## Rendering, Communication, and Forms
|
|
309
347
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactiveEffect } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 响应式 effect 批处理调度器。
|
|
4
|
+
*
|
|
5
|
+
* 同一批同步状态变更(同一个任务内的多次 mutation)只会触发一次 effect
|
|
6
|
+
* 运行:effect 被 enqueue 后去重入队,并在微任务中统一冲刷(flush)。
|
|
7
|
+
* 冲刷期间的重复入队会在同一轮循环中继续处理,直到队列清空。
|
|
8
|
+
*
|
|
9
|
+
* 组件渲染通过该调度器合并更新:连续修改 state 不会逐次重渲染,
|
|
10
|
+
* 与 Vue 微任务调度 / React 自动批处理的语义一致。
|
|
11
|
+
*/
|
|
12
|
+
export declare class ReactiveScheduler {
|
|
13
|
+
private readonly pending;
|
|
14
|
+
private flushing;
|
|
15
|
+
private flushPromise;
|
|
16
|
+
private flushResolve;
|
|
17
|
+
/**
|
|
18
|
+
* 将 effect 加入待冲刷队列(去重)。
|
|
19
|
+
*/
|
|
20
|
+
enqueue(effect: ReactiveEffect): void;
|
|
21
|
+
/**
|
|
22
|
+
* 同步冲刷队列:立即执行所有待运行的 effect。
|
|
23
|
+
* 若当前正处于一次冲刷中(例如在 effect 内部调用),则直接返回,
|
|
24
|
+
* 由正在进行的冲刷循环负责处理新增任务。
|
|
25
|
+
*/
|
|
26
|
+
flush(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 返回一个在待冲刷的 effect 全部执行完成后 resolve 的 Promise。
|
|
29
|
+
* 若当前没有待冲刷任务,立即 resolve。
|
|
30
|
+
*/
|
|
31
|
+
nextTick(): Promise<void>;
|
|
32
|
+
}
|
package/dist/core/reactive.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { ComputedRef, Ref, ReactiveEffect, ReactiveEffectOptions } from './reactive/types';
|
|
2
|
+
import { ReactiveScheduler } from './reactive/scheduler';
|
|
2
3
|
export type { ComputedRef, Ref, ReactiveEffect, ReactiveEffectOptions, } from './reactive/types';
|
|
4
|
+
export declare const reactiveScheduler: ReactiveScheduler;
|
|
5
|
+
/**
|
|
6
|
+
* 等待当前批次的响应式 effect 全部执行完成(通常是组件重渲染)。
|
|
7
|
+
* 修改 state 后需要立即读取 DOM 时使用:await nextTick()。
|
|
8
|
+
*/
|
|
9
|
+
export declare function nextTick(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* 同步冲刷待执行的响应式 effect,立即完成组件重渲染。
|
|
12
|
+
* 一般仅测试或需要同步读 DOM 的场景使用。
|
|
13
|
+
*/
|
|
14
|
+
export declare function flushSync(): void;
|
|
3
15
|
export declare class ReactiveSystem {
|
|
4
16
|
private static instance;
|
|
5
17
|
private activeEffect;
|