@geektech/tsone 0.2.1 → 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 +24 -10
- package/README.md +26 -10
- package/dist/core/reactive/scheduler.d.ts +32 -0
- package/dist/core/reactive.d.ts +12 -0
- package/dist/dom/index.d.ts +1 -1
- package/dist/dom/index.js +2 -2179
- package/dist/dom/index.js.map +3 -3
- package/dist/index-939sv8vt.js +26 -0
- package/dist/{index-ffzday7h.js.map → index-939sv8vt.js.map} +2 -2
- package/dist/index-p55hs6x8.js +12 -0
- package/dist/{index-1x4ectvr.js.map → index-p55hs6x8.js.map} +7 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -267
- package/dist/index.js.map +3 -3
- package/dist/router/index.js +2 -16
- package/dist/router/index.js.map +1 -1
- package/dist/style/index.js +2 -9
- package/dist/style/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-1x4ectvr.js +0 -2453
- package/dist/index-ffzday7h.js +0 -91
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.
|
|
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
|
|
|
@@ -142,14 +143,15 @@ export default defineConfig({
|
|
|
142
143
|
(`index.html`、`about.html`、`docs/guide.html`),资源 URL 相对各文档。
|
|
143
144
|
|
|
144
145
|
```text
|
|
146
|
+
tsone create
|
|
145
147
|
tsone dev [--host <host>] [--port <port>] [--no-watch]
|
|
146
148
|
tsone build [--out-dir <path>]
|
|
147
149
|
```
|
|
148
150
|
|
|
149
|
-
`dev` 接受主机、端口覆盖和 `--no-watch`;`build`
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
`create` 不接受任何选项。`dev` 接受主机、端口覆盖和 `--no-watch`;`build` 只
|
|
152
|
+
接受输出目录覆盖;`--port 3000` 和 `--port=3000` 两种形式均可。`tsone dev`
|
|
153
|
+
默认监听项目文件,文件变化时通过 `/__tsone/reload` 通知浏览器刷新。构建输出
|
|
154
|
+
必须是项目根目录内部的安全子目录。
|
|
153
155
|
|
|
154
156
|
编程式工具 API 来自 `@geektech/tsone-cli`,而不是框架主入口。该包导出
|
|
155
157
|
`defineConfig`、`resolveConfig`、`startDevServer` 与 `build`。调用方负责开发
|
|
@@ -229,7 +231,7 @@ bun run dev:admin
|
|
|
229
231
|
文档站点使用 typed content registry:中文内容维护在
|
|
230
232
|
`packages/tsone/docs/app/content/zh/`,英文内容维护在
|
|
231
233
|
`packages/tsone/docs/app/content/en/`,中英文逻辑路由必须一致。
|
|
232
|
-
中英文 catalog 当前各包含
|
|
234
|
+
中英文 catalog 当前各包含 15 条逻辑路由;新增或删除路由时必须同步修改两边。
|
|
233
235
|
|
|
234
236
|
内容链接保持 locale-neutral,不要手写 `/en/`。中文公开路由不带前缀,英文公开
|
|
235
237
|
路由使用 `/en/`。浏览器语言检测仅在 `/` 生效;手动选择优先并持久化,后续访问
|
|
@@ -243,6 +245,17 @@ bun run docs:build
|
|
|
243
245
|
|
|
244
246
|
构建遇到缺失、多余、重复、空内容或混用语言的页面时会严格失败。
|
|
245
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
|
+
|
|
246
259
|
基础 HTML 文档壳也可以放进 `createApp` 配置里生成。默认会输出 `#app`
|
|
247
260
|
挂载节点;需要自定义挂载点时再传 `rootElement`。`body` 需要自定义时传入组件
|
|
248
261
|
或 VNode,不传 HTML 字符串。
|
|
@@ -302,7 +315,8 @@ const html = app.renderHtmlDocument({
|
|
|
302
315
|
- `effect()` / `stop()`
|
|
303
316
|
- `computed()`
|
|
304
317
|
- `ref()` / `isRef()` / `unref()`
|
|
305
|
-
- `
|
|
318
|
+
- `nextTick()` / `flushSync()`
|
|
319
|
+
- `version`,当前为 `0.3.0`
|
|
306
320
|
|
|
307
321
|
## 渲染、通信与表单
|
|
308
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.
|
|
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
|
|
|
@@ -153,15 +155,16 @@ emits one HTML document per page (`index.html`, `about.html`,
|
|
|
153
155
|
`docs/guide.html`) with page-relative asset URLs.
|
|
154
156
|
|
|
155
157
|
```text
|
|
158
|
+
tsone create
|
|
156
159
|
tsone dev [--host <host>] [--port <port>] [--no-watch]
|
|
157
160
|
tsone build [--out-dir <path>]
|
|
158
161
|
```
|
|
159
162
|
|
|
160
|
-
`dev` accepts host/port overrides and `--no-watch`;
|
|
161
|
-
output-directory override; both `--port 3000` and
|
|
162
|
-
valid. `tsone dev` watches the project by default and
|
|
163
|
-
reload over `/__tsone/reload` when a watched file changes.
|
|
164
|
-
remain a safe child directory inside the project root.
|
|
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.
|
|
165
168
|
|
|
166
169
|
Programmatic tooling is imported from `@geektech/tsone-cli`, not from the
|
|
167
170
|
framework root. It exports `defineConfig`, `resolveConfig`, `startDevServer`,
|
|
@@ -249,7 +252,7 @@ content lives in `packages/tsone/docs/app/content/zh/`, while English content
|
|
|
249
252
|
lives in `packages/tsone/docs/app/content/en/`. Every logical route must exist
|
|
250
253
|
in both directories.
|
|
251
254
|
|
|
252
|
-
Chinese and English catalogs each contain exactly
|
|
255
|
+
Chinese and English catalogs each contain exactly 15 logical routes. Add or
|
|
253
256
|
remove a route in both catalogs in the same change.
|
|
254
257
|
|
|
255
258
|
Content links stay locale-neutral: never write `/en/` manually. Chinese public
|
|
@@ -266,6 +269,18 @@ bun run docs:build
|
|
|
266
269
|
The build fails strictly for missing, extra, duplicate, empty, or
|
|
267
270
|
mixed-language pages.
|
|
268
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
|
+
|
|
269
284
|
The base HTML document shell can also be generated from `createApp`. It emits a
|
|
270
285
|
`#app` mount node by default; pass `rootElement` only to use a different target.
|
|
271
286
|
When a custom `body` is needed, pass a component or VNode rather than an HTML
|
|
@@ -325,7 +340,8 @@ The main `@geektech/tsone` entry point exports:
|
|
|
325
340
|
- `effect()` / `stop()`
|
|
326
341
|
- `computed()`
|
|
327
342
|
- `ref()` / `isRef()` / `unref()`
|
|
328
|
-
- `
|
|
343
|
+
- `nextTick()` / `flushSync()`
|
|
344
|
+
- `version`, currently `0.3.0`
|
|
329
345
|
|
|
330
346
|
## Rendering, Communication, and Forms
|
|
331
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;
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -448,7 +448,7 @@ export declare class Storage {
|
|
|
448
448
|
clear(): void;
|
|
449
449
|
}
|
|
450
450
|
export declare class Navigator {
|
|
451
|
-
readonly userAgent = "TSone/0.
|
|
451
|
+
readonly userAgent = "TSone/0.3.0";
|
|
452
452
|
readonly platform = "TSone";
|
|
453
453
|
readonly language = "zh-CN";
|
|
454
454
|
readonly languages: string[];
|