@qorejs/qore 0.7.0 → 0.7.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.
Files changed (2) hide show
  1. package/README.md +49 -48
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Qore
2
2
 
3
- Qore 的灵魂只有四个字:`流式响应`。
3
+ Qore is a streaming-response framework where `stream = signal`.
4
4
 
5
- 它不是把数据当快照,而是把数据当河流。token 一段一段地到来,UI 就应该一段一段地响应,不需要手动拼字符串,不需要到处补 `loading`,也不需要把 partial render 当成特例处理。
5
+ Instead of treating data as a snapshot, Qore treats it like a river. Tokens arrive piece by piece, and the UI should respond piece by piece too. No manual string accumulation. No scattered loading state. No partial rendering workaround layered on top of a snapshot-first mental model.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,9 +16,10 @@ npm i @qorejs/qore
16
16
 
17
17
  ## Core Idea
18
18
 
19
- `stream` 是数据流动的方式,`signal` UI 响应变化的方式。
19
+ `stream` is how data flows.
20
+ `signal` is how the UI reacts.
20
21
 
21
- Qore 里,这两者是同一个 primitive 的两面:
22
+ In Qore, they are two sides of the same primitive:
22
23
 
23
24
  ```js
24
25
  import { createOpenAI, h, stream, text } from '@qorejs/qore';
@@ -29,18 +30,18 @@ const answer = stream(openai.chat('hello'));
29
30
  return h('div', {}, text(() => answer()));
30
31
  ```
31
32
 
32
- 这里的 `answer` 同时是:
33
+ Here, `answer` is all of the following at once:
33
34
 
34
- - 一个只读 `signal`,`answer()` 拿到当前累积值
35
- - 一个 `AsyncIterable`,可以继续 `for await...of`
36
- - 一个带生命周期的流状态,支持 `status()`、`streaming()`、`error()`、`chunks()`
35
+ - A read-only `signal`, so `answer()` returns the current accumulated value
36
+ - An `AsyncIterable`, so you can still use `for await...of`
37
+ - A lifecycle-aware streaming state, with `status()`, `streaming()`, `error()`, and `chunks()`
37
38
 
38
39
  ## Why Qore
39
40
 
40
- - React stream 当成特殊情况,需要额外心智去补
41
- - SolidJS signal 很强,但没有原生 stream primitive
42
- - Vue ref 很顺手,但 stream 依旧是外置概念
43
- - Qore 直接把 `stream = signal` 做成核心 API
41
+ - React treats streaming as a special case that needs extra machinery
42
+ - SolidJS has excellent signals, but no native stream primitive
43
+ - Vue has ergonomic refs, but stream handling still lives outside the core model
44
+ - Qore makes `stream = signal` the core API from the start
44
45
 
45
46
  ## Quick Start
46
47
 
@@ -48,15 +49,15 @@ return h('div', {}, text(() => answer()));
48
49
  import { h, mount, stream, text } from '@qorejs/qore';
49
50
 
50
51
  const answer = stream(async function* () {
51
- yield '';
52
- yield '';
53
- yield '响应';
52
+ yield 'stream';
53
+ yield ' = ';
54
+ yield 'signal';
54
55
  }());
55
56
 
56
57
  mount('#app', () => h('div', { className: 'answer' }, text(() => answer())));
57
58
  ```
58
59
 
59
- 上面这个例子只会更新那一个 text node,不会 whole tree 重绘。
60
+ This updates only the text node that depends on the stream. It does not re-render the whole tree.
60
61
 
61
62
  ## Providers
62
63
 
@@ -88,7 +89,7 @@ const answer = stream(anthropic.chat('Why should stream be signal?'));
88
89
 
89
90
  ### `createSSEAdapter(options?)`
90
91
 
91
- 如果你的后端本来就已经在吐 SSE,Qore 也可以直接把它收编进同一个 story:
92
+ If your backend already streams `text/event-stream`, Qore can adopt it directly:
92
93
 
93
94
  ```js
94
95
  import { createSSEAdapter, stream } from '@qorejs/qore';
@@ -113,25 +114,25 @@ const provider = createSSEAdapter({
113
114
  const answer = stream(provider.chat('hello'));
114
115
  ```
115
116
 
116
- 这让 `stream(provider.chat(...))` 不再绑定某一家 SDK,而是成为一个通用入口。
117
+ That makes `stream(provider.chat(...))` a general entry point instead of something tied to a single SDK.
117
118
 
118
119
  ## API Shape
119
120
 
120
121
  ### `stream(source, options?)`
121
122
 
122
- 默认把 chunk 累积成文本 signal
123
+ By default, `stream(...)` accumulates chunks into a text signal:
123
124
 
124
125
  ```js
125
126
  const answer = stream(openai.chat('hello'));
126
127
 
127
- answer(); // 当前文本
128
+ answer(); // current text
128
129
  answer.status(); // idle | pending | streaming | completed | error | aborted
129
130
  answer.streaming(); // boolean
130
- answer.chunks(); // 原始 chunk 列表
131
- await answer.ready; // 等待结束
131
+ answer.chunks(); // raw chunks
132
+ await answer.ready; // wait for completion
132
133
  ```
133
134
 
134
- 如果你需要结构化流:
135
+ If you need structured streams:
135
136
 
136
137
  ```js
137
138
  const events = stream.list(eventSource);
@@ -148,17 +149,17 @@ const answer = stream.withBackpressure(openai.chat('hello'), {
148
149
  });
149
150
  ```
150
151
 
151
- backpressure 现在不只是“睡一下”:
152
+ Backpressure is not just a delay wrapper:
152
153
 
153
- - `interval`:chunk 进入 signal / UI 之间的最小间隔
154
- - `buffer`:在 UI 前面最多允许排队多少个 chunk
155
- - `overflow`:缓冲区满了以后怎么办,可选 `wait` / `drop-oldest` / `drop-newest` / `error`
154
+ - `interval`: the minimum spacing between chunk delivery into the signal and UI
155
+ - `buffer`: the maximum number of queued chunks before the UI catches up
156
+ - `overflow`: what to do when the buffer is full: `wait`, `drop-oldest`, `drop-newest`, or `error`
156
157
 
157
- 你还可以直接观察压力状态:
158
+ You can also observe stream pressure directly:
158
159
 
159
160
  ```js
160
- answer.buffered(); // 当前还有多少 chunk 在排队
161
- answer.dropped(); // overflow 策略被丢掉了多少 chunk
161
+ answer.buffered(); // how many chunks are queued right now
162
+ answer.dropped(); // how many chunks were dropped by the overflow policy
162
163
  ```
163
164
 
164
165
  ### `signal`, `computed`, `effect`
@@ -172,13 +173,13 @@ const length = computed(() => answer().length);
172
173
 
173
174
  ### `response`
174
175
 
175
- `response` 仍然保留,但它更像底层状态机 escape hatch,适合复杂 reducer 或自定义聚合。
176
+ `response` still exists, but it is closer to a lower-level state machine escape hatch for custom reducers and aggregators.
176
177
 
177
- 如果你的目标是“把流直接接进 UI”,优先使用 `stream(...)`。
178
+ If your goal is to pipe a stream directly into the UI, prefer `stream(...)`.
178
179
 
179
180
  ## Demos
180
181
 
181
- 仓库里带了完整 landing page focused demo
182
+ The repository includes a landing page and a focused streaming demo:
182
183
 
183
184
  - [Landing Page Source](https://github.com/qorejs/qore/blob/main/index.html)
184
185
  - [Homepage Logic](https://github.com/qorejs/qore/blob/main/examples/showcase.js)
@@ -187,7 +188,7 @@ const length = computed(() => answer().length);
187
188
  - [Focused Chat Logic](https://github.com/qorejs/qore/blob/main/examples/qore-chat.js)
188
189
  - [React Compare](https://github.com/qorejs/qore/blob/main/examples/react-chat.jsx)
189
190
 
190
- 本地预览:
191
+ For a local preview:
191
192
 
192
193
  ```bash
193
194
  git clone git@github.com:qorejs/qore.git
@@ -195,19 +196,19 @@ cd qore
195
196
  python3 -m http.server 4173
196
197
  ```
197
198
 
198
- 然后打开 [http://127.0.0.1:4173/](http://127.0.0.1:4173/)
199
+ Then open [http://127.0.0.1:4173/](http://127.0.0.1:4173/).
199
200
 
200
201
  ## Package Boundary
201
202
 
202
- Qore 核心包不内置 Button、Dialog、Tabs 这类 UI primitives
203
+ Qore does not ship a built-in catalog of buttons, dialogs, tabs, or other UI primitives.
203
204
 
204
- 核心包只做三件事:
205
+ The core package does only three things:
205
206
 
206
- - 让流进入状态
207
- - 让状态进入 UI
208
- - 让整个过程保持细粒度响应
207
+ - Move streams into state
208
+ - Move state into the UI
209
+ - Keep the whole process finely reactive
209
210
 
210
- 一切不服务于 `流式响应` 的东西,都应该放到实验层或者外围仓库。
211
+ Anything that does not serve `streaming response` belongs in an experimental layer or a separate package.
211
212
 
212
213
  ## Testing
213
214
 
@@ -215,14 +216,14 @@ Qore 核心包不内置 Button、Dialog、Tabs 这类 UI primitives。
215
216
  npm test
216
217
  ```
217
218
 
218
- 当前测试覆盖了:
219
+ The current test suite covers:
219
220
 
220
- - signal / computed / effect
221
- - stream = signal 的核心行为
222
- - response async iterable 的兼容
223
- - OpenAI / Anthropic / generic SSE adapters
221
+ - `signal`, `computed`, and `effect`
222
+ - The core `stream = signal` behavior
223
+ - `response` interoperability with async iterables
224
+ - OpenAI, Anthropic, and generic SSE adapters
224
225
 
225
226
  ## Roadmap
226
227
 
227
- - 围绕服务端流式渲染收敛 hydration 模型
228
- - 做公开 benchmark,把 Qore React/Vercel AI SDK 的差异变成可重复的数据
228
+ - Tighten the hydration model around server-streamed rendering
229
+ - Publish repeatable benchmarks that compare Qore with React and the Vercel AI SDK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qorejs/qore",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Qore is a streaming-response framework where stream becomes signal.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",