@qorejs/qore 1.0.6 → 2.0.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.
Files changed (46) hide show
  1. package/MIGRATION.md +124 -0
  2. package/README.md +70 -40
  3. package/README.zh-CN.md +24 -12
  4. package/dist/src/core/response-types.d.ts +6 -2
  5. package/dist/src/core/response-types.d.ts.map +1 -1
  6. package/dist/src/core/stream-types.d.ts +18 -2
  7. package/dist/src/core/stream-types.d.ts.map +1 -1
  8. package/dist/src/core/stream.d.ts +1 -1
  9. package/dist/src/core/stream.d.ts.map +1 -1
  10. package/dist/src/core/stream.js +123 -9
  11. package/dist/src/core/stream.js.map +1 -1
  12. package/dist/src/dom.d.ts +6 -0
  13. package/dist/src/dom.d.ts.map +1 -0
  14. package/dist/src/dom.js +5 -0
  15. package/dist/src/dom.js.map +1 -0
  16. package/dist/src/index.d.ts +3 -18
  17. package/dist/src/index.d.ts.map +1 -1
  18. package/dist/src/index.js +0 -12
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/providers.d.ts +8 -0
  21. package/dist/src/providers.d.ts.map +1 -0
  22. package/dist/src/providers.js +8 -0
  23. package/dist/src/providers.js.map +1 -0
  24. package/dist/src/react.d.ts +63 -0
  25. package/dist/src/react.d.ts.map +1 -0
  26. package/dist/src/react.js +123 -0
  27. package/dist/src/react.js.map +1 -0
  28. package/dist/src/server.d.ts +3 -0
  29. package/dist/src/server.d.ts.map +1 -0
  30. package/dist/src/server.js +3 -0
  31. package/dist/src/server.js.map +1 -0
  32. package/dist/src/shared/utils.d.ts +2 -1
  33. package/dist/src/shared/utils.d.ts.map +1 -1
  34. package/dist/src/shared/utils.js.map +1 -1
  35. package/dist/src/signals.d.ts +4 -0
  36. package/dist/src/signals.d.ts.map +1 -0
  37. package/dist/src/signals.js +3 -0
  38. package/dist/src/signals.js.map +1 -0
  39. package/docs/api.md +42 -7
  40. package/docs/architecture.md +36 -34
  41. package/docs/comparisons.md +23 -20
  42. package/docs/concepts.md +6 -14
  43. package/docs/providers.md +19 -1
  44. package/docs/react.md +23 -7
  45. package/docs/runtime.md +49 -0
  46. package/package.json +35 -4
package/MIGRATION.md ADDED
@@ -0,0 +1,124 @@
1
+ # Qore Migration Notes
2
+
3
+ ## `1.x` -> `2.0.0`
4
+
5
+ Qore 2 narrows the default entrypoint to the stream runtime. This is a breaking
6
+ import-path change; stream accumulation and lifecycle behavior are preserved.
7
+
8
+ ```ts
9
+ // 1.x
10
+ import { stream, signal, h, mount, createOpenAI, createSSEResponse } from '@qorejs/qore';
11
+
12
+ // 2.x
13
+ import { stream } from '@qorejs/qore';
14
+ import { signal } from '@qorejs/qore/signals';
15
+ import { h, mount } from '@qorejs/qore/dom';
16
+ import { createOpenAI } from '@qorejs/qore/providers';
17
+ import { createSSEResponse } from '@qorejs/qore/server';
18
+ ```
19
+
20
+ | Previous root exports | New import |
21
+ | --- | --- |
22
+ | `signal`, `computed`, `effect`, `batch`, `untrack`, `isSignal`, `createRoot`, `onCleanup`; `Signal`, `ComputedSignal`, effect types | `@qorejs/qore/signals` |
23
+ | `h`, `text`, `fragment`, `dynamic`, `show`, `list`, `mount`, `renderResponse`, `createApp`, DOM guards and DOM types | `@qorejs/qore/dom` |
24
+ | All vendor/generic provider factories, metadata helpers and provider types | `@qorejs/qore/providers` |
25
+ | `createSSEResponse`, `CreateSSEResponseOptions`, `SSEFrame` | `@qorejs/qore/server` |
26
+ | Stream/response APIs, inspection, `ReadonlySignal`, `SubscribeOptions`, shared utilities | remain at `@qorejs/qore` |
27
+
28
+ React hooks now ship in the same package:
29
+
30
+ ```tsx
31
+ import { useQoreStream, useQoreSignalSelector } from '@qorejs/qore/react';
32
+ ```
33
+
34
+ Install React 18.2+ in React applications. React is an optional peer and is not
35
+ required when using only the core, DOM, signals, providers or server entrypoints.
36
+ The separate `@qorejs/react` package is not required. If migrating repository-local
37
+ usage of that unpublished package, replace its imports with `@qorejs/qore/react`.
38
+
39
+ Use your host framework's lifecycle to unsubscribe observers and abort streams
40
+ owned by the component. The managed React hook does this automatically. Observing
41
+ an externally owned stream with the snapshot hook does not abort it on unmount.
42
+
43
+ The internal signal engine and optional DOM behavior are retained. This release
44
+ does not remove the underlying reactive implementation, add Qore DOM SSR/hydration,
45
+ or change total history retention. `maxItems` bounds collection values only.
46
+
47
+
48
+ This document tracks the public migration surface for `@qorejs/qore`.
49
+
50
+ ## `0.7.x` -> `0.8.x`
51
+
52
+ ### Runtime and Packaging
53
+
54
+ - The package is now TypeScript-first in `src/` and publishes compiled output from `dist/src`.
55
+ - The public DOM aliases were normalized around standard DOM types while keeping legacy `Global*` aliases available.
56
+ - The release pipeline now treats package smoke, browser regression, and dist-sync checks as release gates.
57
+
58
+ ### Stream Runtime
59
+
60
+ - `QoreStream` lifecycle state is exposed through read-only signals.
61
+ - `status`, `error`, `chunks`, `startedAt`, and `finishedAt` should now be treated as immutable views.
62
+ - If user code was mutating these fields directly, it must move to runtime APIs like `abort()` or a new stream instance.
63
+
64
+ ### Scheduling
65
+
66
+ - `effect(...)` scheduling is now an explicit part of the runtime surface.
67
+ - Supported scheduler modes:
68
+ - `sync`
69
+ - `microtask`
70
+ - `raf`
71
+ - custom scheduler function
72
+
73
+ ## `0.8.x` -> `0.9.0`
74
+
75
+ ### New Stable Runtime Surface
76
+
77
+ The following public APIs were added and are intended to remain on the stable track:
78
+
79
+ - `createRoot(...)`
80
+ - `onCleanup(...)`
81
+ - `createSSEResponse(...)`
82
+ - `collectProviderMetadata(...)`
83
+ - `mergeProviderMetadata(...)`
84
+ - `extractOpenAIMetadata(...)`
85
+ - `extractAnthropicMetadata(...)`
86
+ - `extractOpenRouterMetadata(...)`
87
+ - `extractDeepSeekMetadata(...)`
88
+ - `extractOllamaMetadata(...)`
89
+
90
+ ### Stream Composition
91
+
92
+ Qore now exposes a broader orchestration layer:
93
+
94
+ - `stream.merge(...)`
95
+ - `stream.concat(...)`
96
+ - `stream.pipe(...)`
97
+ - `stream.race(...)`
98
+ - `stream.retryable(...)`
99
+ - `stream.switchMap(...)`
100
+
101
+ If earlier code implemented these patterns manually around `for await...of` loops, it can usually simplify into the built-in stream helpers.
102
+
103
+ ### Browser Boundary
104
+
105
+ The DOM layer is explicitly browser-only in the `0.9.x` line.
106
+
107
+ - `signal`, `stream`, providers, and server helpers work in Node and the browser
108
+ - `h`, `text`, `dynamic`, `list`, `mount`, and `createApp(...).mount(...)` require a browser-like `document`
109
+ - `assertCanUseDOM(...)` and `canUseDOM()` are the supported guards for branching
110
+
111
+ ### SSR and Hydration
112
+
113
+ There is no stable SSR or hydration support in `0.9.x`.
114
+
115
+ If an integration previously assumed partial SSR support, it should treat that assumption as unsupported and move DOM entrypoints behind a browser/runtime guard.
116
+
117
+ ## `1.0.0-rc`
118
+
119
+ Expected RC rules:
120
+
121
+ - no casual public API additions
122
+ - no silent semantics changes in stream lifecycle behavior
123
+ - no ambiguous SSR or hydration claims
124
+ - any public API surface change must update the frozen API snapshot and release notes intentionally
package/README.md CHANGED
@@ -20,42 +20,45 @@ npm i @qorejs/qore
20
20
  ## 30-Second Demo
21
21
 
22
22
  ```js
23
- import { createSSEResponse, h, mount, stream, text } from '@qorejs/qore';
24
-
25
- // Server: expose your provider as SSE.
26
- export function handler() {
27
- return createSSEResponse(async function* () {
28
- yield 'stream';
29
- yield ' = ';
30
- yield 'signal';
31
- }());
32
- }
23
+ import { stream } from '@qorejs/qore';
33
24
 
34
- // Browser: consume the stream as one reactive value.
35
- const answer = stream(fetch('/api/chat').then((response) => response.body));
25
+ const answer = stream(['stream', ' = ', 'signal']);
26
+ const unsubscribe = answer.subscribe((value) => console.log(value));
36
27
 
37
- mount('#app', () =>
38
- h('main', {}, text(() => answer()))
39
- );
28
+ await answer.ready;
29
+ console.log(answer(), answer.status());
30
+ unsubscribe();
40
31
  ```
41
32
 
42
- `answer` is a readonly signal and an async iterable. The UI reads `answer()`, and Qore updates only the DOM node that depends on it.
33
+ `answer` is a readonly signal and an async iterable. Use `answer()` or
34
+ `answer.peek()` to read its current value, and `answer.subscribe(...)` to observe
35
+ updates. Your UI framework owns rendering and component lifecycle.
43
36
 
44
- ## Why Qore
37
+ ## Package Entrypoints
45
38
 
46
- React/Vercel AI SDK:
39
+ Qore 2 separates the stream runtime from optional integrations. These are explicit
40
+ subpath imports within one versioned package; importing the core does not load
41
+ React, the DOM renderer, or provider adapters.
47
42
 
48
- ```text
49
- Token -> Hook state -> Component render -> Reconcile
50
- ```
43
+ | Import | Purpose |
44
+ | --- | --- |
45
+ | `@qorejs/qore` | streams, response lifecycle, readonly contracts, inspection |
46
+ | `@qorejs/qore/react` | React hooks; requires React 18.2+ |
47
+ | `@qorejs/qore/dom` | optional standalone browser renderer |
48
+ | `@qorejs/qore/signals` | optional mutable signals, effects and ownership scopes |
49
+ | `@qorejs/qore/providers` | provider protocol adapters for trusted runtimes |
50
+ | `@qorejs/qore/server` | server-side SSE response helper |
51
51
 
52
- Qore:
52
+ Upgrading from 1.x requires moving imports: see [migration notes](./MIGRATION.md).
53
+ The internal reactive engine remains shared with the optional integrations; this
54
+ release narrows the public core without rewriting stream scheduling semantics.
53
55
 
54
- ```text
55
- Token -> Stream signal -> Text node
56
- ```
56
+ ## Why Qore
57
57
 
58
- That is the core difference. Qore is not trying to be another AI SDK. It is the runtime layer that makes streamed data reactive.
58
+ Qore brings accumulation, events, cancellation, errors and backpressure into one
59
+ stream lifecycle. Existing frameworks can consume that state through their own
60
+ renderers. React subscriptions still render React components; direct text-node
61
+ updates apply specifically to the optional DOM renderer.
59
62
 
60
63
  ## Event Streams
61
64
 
@@ -69,22 +72,49 @@ const text = events.select('text', {
69
72
  reduce: (current, event) => current + event.text
70
73
  });
71
74
  const tools = events.select('tool_call');
72
- const status = events.select('status');
75
+ const status = events.select('status', { maxItems: 20 });
73
76
  const diff = events.select('diff');
74
77
  ```
75
78
 
76
- Each selected stream is still a signal and an async iterable. A timeline can render every event, while a markdown pane can bind only to `text()`. The runnable shape is captured in [`examples/agent-event-stream.ts`](./examples/agent-event-stream.ts).
79
+ Each selected stream is still a signal and an async iterable. A timeline can render every event, while a markdown pane can bind only to `text()`. Use `maxItems` on the full timeline or selected timelines when an agent can run for minutes. The runnable shape is captured in [`examples/agent-event-stream.ts`](./examples/agent-event-stream.ts), with focused examples for [`streaming-markdown-diff`](./examples/streaming-markdown-diff.ts) and [`server-sse-to-qore-client`](./examples/server-sse-to-qore-client.ts).
77
80
 
81
+ ## Structured Output
78
82
 
79
- ## React Adapter
83
+ Structured AI output should also flow through the same runtime path:
84
+
85
+ ```ts
86
+ const result = stream.json<{ title: string; items: string[] }>(provider.chat(prompt));
87
+
88
+ result(); // null until valid JSON is available, then the parsed object
89
+ ```
80
90
 
81
- Qore can be used inside React without replacing your UI stack. The release-ready adapter lives in [`packages/react`](./packages/react) and subscribes to Qore streams through React's external store contract, so the stream remains the source of truth while React renders the view.
91
+ For line-delimited event streams, use the same idea per line:
92
+
93
+ ```ts
94
+ const events = stream.ndjson<{ type: string; value: unknown }>(fetch('/api/events').then((r) => r.body));
95
+
96
+ events(); // accumulated structured events
97
+ ```
98
+
99
+ Use `validate` when you want a typed guard before publishing parsed output into UI state. Invalid JSON or NDJSON fails through the normal stream lifecycle instead of becoming hidden glue code.
100
+
101
+ For long-running feeds, bound only the signal window while keeping the stream lifecycle and async iteration intact:
102
+
103
+ ```ts
104
+ const timeline = stream.ndjson(agent.events(), { maxItems: 200 });
105
+ ```
106
+
107
+
108
+ ## React Adapter
82
109
 
83
- > Status: `@qorejs/react` is release-ready in this repository, but npm publishing is still waiting on `@qorejs/react` package access for the `@qorejs` scope. The adapter smoke test passes; the package will be announced as published only after npm accepts it.
110
+ The React adapter ships at `@qorejs/qore/react` in the core package. Install
111
+ React in your application; it is an optional peer dependency for Qore. The adapter
112
+ uses React's external store contract and owns cancellation on unmount or dependency
113
+ changes. The separate `@qorejs/react` package is not required.
84
114
 
85
115
  ```tsx
86
116
  import { stream } from '@qorejs/qore';
87
- import { useQoreStream } from '@qorejs/react';
117
+ import { useQoreStream } from '@qorejs/qore/react';
88
118
 
89
119
  function Answer({ prompt }) {
90
120
  const answer = useQoreStream(
@@ -101,7 +131,7 @@ See [React Adapter](./docs/react.md) for lifecycle, status, abort, and signal su
101
131
 
102
132
  ## Provider Safety
103
133
 
104
- Provider adapters are intended for server-side or trusted runtimes. Do not put `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or any vendor secret in browser code. For browsers, expose your own SSE or NDJSON endpoint and stream that endpoint into Qore.
134
+ Provider adapters are intended for server-side or trusted runtimes. Do not put `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or any vendor secret in browser code. For browsers, expose your own SSE or NDJSON endpoint and stream that endpoint into Qore. See [`examples/server-sse-to-qore-client.ts`](./examples/server-sse-to-qore-client.ts) for the recommended boundary.
105
135
 
106
136
  ## Inspect Streams
107
137
 
@@ -139,14 +169,14 @@ The inspector is zero-dependency and built on the same `__QORE_DEVTOOLS__` hook
139
169
  | --- | --- | --- |
140
170
  | Node runtime | Supported | `Node >= 18` |
141
171
  | Browser runtime | Supported | DOM entrypoints require `document` |
142
- | Reactive core | Supported | `signal`, `computed`, `effect`, `batch`, `createRoot`, `onCleanup` |
143
- | Stream runtime | Supported | backpressure, retry, orchestration, async iteration, abort, and DevTools hooks |
144
- | Provider adapters | Supported | OpenAI, Anthropic, OpenRouter, DeepSeek, Ollama, generic SSE, generic line-stream |
145
- | Browser DOM layer | Supported | `h`, `text`, `dynamic`, `list`, `mount`, `createApp(...).mount(...)` |
146
- | React adapter | Release-ready | `packages/react` bridges Qore streams through `useSyncExternalStore`; npm publishing is waiting on scope access |
172
+ | Optional signals | `@qorejs/qore/signals` | `signal`, `computed`, `effect`, `batch`, `createRoot`, `onCleanup` |
173
+ | Stream runtime | Supported | backpressure, bounded collections, retry, orchestration, structured JSON/NDJSON, async iteration, abort, and DevTools hooks |
174
+ | Provider adapters | `@qorejs/qore/providers` | OpenAI, Anthropic, OpenRouter, DeepSeek, Ollama, generic SSE, generic line-stream |
175
+ | Browser DOM layer | `@qorejs/qore/dom` | `h`, `text`, `dynamic`, `list`, `mount`, `createApp(...).mount(...)` |
176
+ | React adapter | `@qorejs/qore/react` | cached external-store snapshots; React owns rendering |
147
177
  | Published package maps | Supported | JavaScript source maps and declaration maps ship in `dist/src` |
148
- | SSR | Not supported | explicit browser-only DOM boundary in `1.0.x` |
149
- | Hydration | Not supported | deferred until a fully proven implementation exists |
178
+ | SSR | Host framework | React hooks supply server snapshots; the optional DOM renderer is browser-only |
179
+ | Hydration | Host framework | no Qore DOM hydration implementation |
150
180
 
151
181
  ## Provider Support Matrix
152
182
 
package/README.zh-CN.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Qore
2
2
 
3
- Qore 是一个面向 AI 原生界面的 reactive stream runtime
4
-
5
- 它的核心原语是 `stream = signal`:异步流本身也是一条只读 signal,所以 token、tool event、状态、markdown 片段和 diff 都可以直接进入 UI 状态。
3
+ Qore 是面向 AI 原生界面的 reactive stream runtime。核心原语是 `stream = signal`:
4
+ 同一条流提供当前值、订阅、异步迭代,以及完成、错误和取消状态。
6
5
 
7
6
  ## 安装
8
7
 
@@ -13,17 +12,30 @@ npm i @qorejs/qore
13
12
  ## 最小示例
14
13
 
15
14
  ```js
16
- import { h, mount, stream, text } from '@qorejs/qore';
17
-
18
- const answer = stream(model.chat('hello'));
15
+ import { stream } from '@qorejs/qore';
19
16
 
20
- mount('#app', () =>
21
- h('main', {}, text(() => answer()))
22
- );
17
+ const answer = stream(['你好', ',Qore']);
18
+ const unsubscribe = answer.subscribe(console.log);
19
+ await answer.ready;
20
+ unsubscribe();
23
21
  ```
24
22
 
25
- `answer()` 返回当前累积内容。UI 会随着 stream 更新,且只更新读取这条 signal 的节点。
23
+ ## 2.0 的边界
24
+
25
+ 默认入口只提供流运行时。应用继续使用原有框架的组件、渲染和生命周期。
26
+
27
+ | 入口 | 用途 |
28
+ | --- | --- |
29
+ | `@qorejs/qore` | 流、响应生命周期、只读状态契约、检查工具 |
30
+ | `@qorejs/qore/react` | React hooks,需应用安装 React 18.2+ |
31
+ | `@qorejs/qore/dom` | 可选的独立页面 DOM 渲染器 |
32
+ | `@qorejs/qore/signals` | 可选的 signal、computed、effect 等工具 |
33
+ | `@qorejs/qore/providers` | Provider 协议适配 |
34
+ | `@qorejs/qore/server` | 服务端 SSE 输出 |
26
35
 
27
- ## 文档
36
+ 这些是同一个 npm 包的独立子入口。只导入核心不会加载 React、DOM 层或 Provider。
37
+ 内部响应式引擎仍然保留并共享,流的行为未在这次拆分中重写。
38
+ React 适配器仍通过 React 渲染组件;直接更新文本节点是可选 DOM 层的行为。
28
39
 
29
- README 以英文为主。中文文档入口在官网 `/zh/`。
40
+ 1.x 升级需要调整导入路径,详见 [迁移说明](./MIGRATION.md)。
41
+ 完整 API 和示例见 [英文 README](./README.md) 与 [React 文档](./docs/react.md)。
@@ -6,8 +6,12 @@ export type GlobalAbortSignal = typeof globalThis extends {
6
6
  } ? T extends {
7
7
  prototype: infer P;
8
8
  } ? P : unknown : {
9
- aborted: boolean;
10
- reason?: unknown;
9
+ readonly aborted: boolean;
10
+ readonly reason?: unknown;
11
+ addEventListener(type: 'abort', listener: () => void, options?: {
12
+ once?: boolean;
13
+ }): void;
14
+ removeEventListener(type: 'abort', listener: () => void): void;
11
15
  };
12
16
  export interface ResponseSnapshot<TChunk = unknown, TValue = unknown> {
13
17
  status: ResponseStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"response-types.d.ts","sourceRoot":"","sources":["../../../src/core/response-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;AAClG,MAAM,MAAM,iBAAiB,GAAG,OA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MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,GAAG,CACD,QAAQ,EAAE,CAAC,OAAO,EAAE,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,EACrF,OAAO,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GACnC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvG,QAAQ,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtG,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5E"}
@@ -30,8 +30,21 @@ export type StreamEventType<TEvent extends StreamEventBase> = TEvent['type'] & s
30
30
  export type StreamEventOf<TEvent extends StreamEventBase, TType extends StreamEventType<TEvent>> = Extract<TEvent, {
31
31
  type: TType;
32
32
  }>;
33
- export type StreamEventOptions<TEvent extends StreamEventBase> = Omit<StreamOptions<TEvent, TEvent[]>, 'seed' | 'reduce'>;
33
+ export type StreamEventOptions<TEvent extends StreamEventBase> = Omit<StreamCollectionOptions<TEvent>, 'seed' | 'reduce'>;
34
+ export interface StreamCollectionOptions<TChunk> extends StreamOptions<TChunk, TChunk[]> {
35
+ maxItems?: number;
36
+ }
37
+ export interface StructuredStreamOptions<TValue> extends Omit<StreamOptions<TValue, TValue | null>, 'seed' | 'reduce'> {
38
+ seed?: TValue | null;
39
+ parse?: (text: string) => TValue;
40
+ validate?: (value: unknown) => value is TValue;
41
+ }
42
+ export interface StructuredLineStreamOptions<TValue> extends Omit<StreamCollectionOptions<TValue>, 'reduce'> {
43
+ parse?: (text: string) => TValue;
44
+ validate?: (value: unknown) => value is TValue;
45
+ }
34
46
  export type StreamSelectOptions<TEvent extends StreamEventBase, TValue> = StreamOptions<TEvent, TValue>;
47
+ export type StreamSelectCollectionOptions<TEvent extends StreamEventBase> = StreamCollectionOptions<TEvent>;
35
48
  export interface RetryableStreamOptions<TChunk = unknown, TValue = string> extends StreamOptions<TChunk, TValue> {
36
49
  maxRetries?: number;
37
50
  backoff?: RetryBackoff;
@@ -69,6 +82,7 @@ export interface QoreStream<TChunk = unknown, TValue = string> extends ReadonlyS
69
82
  }
70
83
  export interface QoreEventStream<TEvent extends StreamEventBase = StreamEventBase> extends QoreStream<TEvent, TEvent[]> {
71
84
  select<TType extends StreamEventType<TEvent>>(type: TType): QoreStream<StreamEventOf<TEvent, TType>, Array<StreamEventOf<TEvent, TType>>>;
85
+ select<TType extends StreamEventType<TEvent>>(type: TType, options: StreamSelectCollectionOptions<StreamEventOf<TEvent, TType>>): QoreStream<StreamEventOf<TEvent, TType>, Array<StreamEventOf<TEvent, TType>>>;
72
86
  select<TType extends StreamEventType<TEvent>, TValue>(type: TType, options: StreamSelectOptions<StreamEventOf<TEvent, TType>, TValue>): QoreStream<StreamEventOf<TEvent, TType>, TValue>;
73
87
  }
74
88
  export interface StreamFactory {
@@ -78,8 +92,10 @@ export interface StreamFactory {
78
92
  delay?: number;
79
93
  }): QoreStream<TChunk, TValue>;
80
94
  text<TChunk = unknown>(sourceOrSetup: StreamInput<TChunk, string>, options?: StreamOptions<TChunk, string>): QoreStream<TChunk, string>;
81
- list<TChunk>(sourceOrSetup: StreamInput<TChunk, TChunk[]>, options?: StreamOptions<TChunk, TChunk[]>): QoreStream<TChunk, TChunk[]>;
95
+ list<TChunk>(sourceOrSetup: StreamInput<TChunk, TChunk[]>, options?: StreamCollectionOptions<TChunk>): QoreStream<TChunk, TChunk[]>;
82
96
  latest<TChunk>(sourceOrSetup: StreamInput<TChunk, TChunk | null>, options?: StreamOptions<TChunk, TChunk | null>): QoreStream<TChunk, TChunk | null>;
97
+ json<TValue = unknown>(source: SourceLike<string>, options?: StructuredStreamOptions<TValue>): QoreStream<TValue, TValue | null>;
98
+ ndjson<TValue = unknown>(source: SourceLike<string>, options?: StructuredLineStreamOptions<TValue>): QoreStream<TValue, TValue[]>;
83
99
  events<TEvent extends StreamEventBase>(sourceOrSetup: StreamInput<TEvent, TEvent[]>, options?: StreamEventOptions<TEvent>): QoreEventStream<TEvent>;
84
100
  withBackpressure<TChunk = unknown, TValue = string>(sourceOrSetup: StreamInput<TChunk, TValue>, backpressure: number | BackpressureOptions, options?: StreamOptions<TChunk, TValue>): QoreStream<TChunk, TValue>;
85
101
  paced<TChunk = unknown, TValue = string>(sourceOrSetup: StreamInput<TChunk, TValue>, interval: number, options?: StreamOptions<TChunk, TValue>): QoreStream<TChunk, TValue>;
@@ -1 +1 @@
1
- {"version":3,"file":"stream-types.d.ts","sourceRoot":"","sources":["../../../src/core/stream-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,UAAU,EACX,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,OA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AE,MAAM,CAAC,GACtC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,MAAM,EACzC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,OAAO,CAAC,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,MAAM,EACjD,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC1E,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,MAAM,mBAAmB,CAAC,MAAM,EAAE,MAAM,IAAI,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -7,6 +7,6 @@ export declare function from<TChunk, TValue = string>(source: SourceLike<TChunk>
7
7
  export declare function mapStream<TInput, TOutput, TValue = string>(source: SourceLike<TInput>, mapper: (chunk: TInput, index: number) => MaybePromise<TOutput>, options?: StreamOptions<TOutput, TValue>): QoreStream<TOutput, TValue>;
8
8
  export declare function scanStream<TInput, TOutput>(source: SourceLike<TInput>, reducer: (currentValue: TOutput, chunk: TInput, index: number) => MaybePromise<TOutput>, seed: TOutput, options?: Omit<StreamOptions<TOutput, TOutput>, 'seed' | 'reduce'>): QoreStream<TOutput, TOutput>;
9
9
  export { createStream } from './stream-runtime.js';
10
- export type { BackpressureOptions, QoreEventStream, QoreStream, RetryBackoff, RetryableStreamOptions, StreamController, StreamEventBase, StreamEventOf, StreamEventOptions, StreamEventType, StreamFactory, StreamInput, StreamOptions, StreamSelectOptions, StreamSetup } from './stream-types.js';
10
+ export type { BackpressureOptions, QoreEventStream, QoreStream, RetryBackoff, RetryableStreamOptions, StreamCollectionOptions, StreamController, StreamEventBase, StreamEventOf, StreamEventOptions, StreamEventType, StreamFactory, StreamInput, StreamOptions, StreamSelectCollectionOptions, StreamSelectOptions, StreamSetup, StructuredLineStreamOptions, StructuredStreamOptions } from './stream-types.js';
11
11
  export { toAsyncIterable } from './iterable.js';
12
12
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/core/stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAGV,UAAU,EAOV,aAAa,EAIb,aAAa,EACd,MAAM,mBAAmB,CAAC;AA0Q3B,eAAO,MAAM,MAAM,eAAgB,CAAC;AA0EpC,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAC1C,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,OAAO,GAAE,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAgB5B;AAGD,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EACxD,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,OAAO,CAAC,EAC/D,OAAO,GAAE,aAAa,CAAC,OAAO,EAAE,MAAM,CAAM,GAC3C,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAa7B;AAGD,wBAAgB,UAAU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EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EACxD,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,OAAO,CAAC,EAC/D,OAAO,GAAE,aAAa,CAAC,OAAO,EAAE,MAAM,CAAM,GAC3C,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAa7B;AAGD,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EACxC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,OAAO,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,OAAO,CAAC,EACvF,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAM,GACrE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAmB9B;AAGD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,WAAW,EACX,aAAa,EACb,6BAA6B,EAC7B,mBAAmB,EACnB,WAAW,EACX,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -18,9 +18,9 @@ streamFactory.text = (sourceOrSetup, options = {}) => createStream(sourceOrSetup
18
18
  });
19
19
  // Convenience constructor for streams that accumulate every chunk into an array.
20
20
  streamFactory.list = (sourceOrSetup, options = {}) => createStream(sourceOrSetup, {
21
- seed: [],
22
- reduce: (currentValue, chunk) => [...currentValue, chunk],
23
- ...options
21
+ ...options,
22
+ seed: trimCollection(options.seed ?? [], options.maxItems),
23
+ reduce: createCollectionReducer(options)
24
24
  });
25
25
  // Convenience constructor for streams that only expose the latest chunk as current value.
26
26
  streamFactory.latest = (sourceOrSetup, options = {}) => createStream(sourceOrSetup, {
@@ -28,10 +28,84 @@ streamFactory.latest = (sourceOrSetup, options = {}) => createStream(sourceOrSet
28
28
  reduce: (_, chunk) => chunk,
29
29
  ...options
30
30
  });
31
+ streamFactory.json = (source, options = {}) => {
32
+ const { seed = null, parse = JSON.parse, validate, ...streamOptions } = options;
33
+ return createStream(async (controller) => {
34
+ let buffer = '';
35
+ let parsedOnce = false;
36
+ let lastParsedText = '';
37
+ let lastParseError = null;
38
+ for await (const chunk of toAsyncIterable(source)) {
39
+ if (controller.signal.aborted) {
40
+ break;
41
+ }
42
+ buffer += chunk;
43
+ const candidateText = buffer.trim();
44
+ try {
45
+ const parsed = parseStructuredValue(candidateText, parse, validate);
46
+ parsedOnce = true;
47
+ lastParseError = null;
48
+ if (candidateText !== lastParsedText) {
49
+ lastParsedText = candidateText;
50
+ await controller.push(parsed);
51
+ }
52
+ }
53
+ catch (error) {
54
+ lastParseError = error;
55
+ }
56
+ }
57
+ if (!controller.signal.aborted && (!parsedOnce || lastParseError !== null)) {
58
+ throw lastParseError instanceof Error
59
+ ? lastParseError
60
+ : new SyntaxError('Structured stream did not produce valid JSON.');
61
+ }
62
+ }, {
63
+ seed,
64
+ reduce: (_, chunk) => chunk,
65
+ ...streamOptions
66
+ });
67
+ };
68
+ streamFactory.ndjson = (source, options = {}) => {
69
+ const { seed = [], parse = JSON.parse, validate, maxItems, ...streamOptions } = options;
70
+ const collectionOptions = maxItems === undefined
71
+ ? { ...streamOptions, seed }
72
+ : { ...streamOptions, seed, maxItems };
73
+ return createStream(async (controller) => {
74
+ let buffer = '';
75
+ const publishLine = async (line) => {
76
+ const text = line.trim();
77
+ if (text.length === 0) {
78
+ return;
79
+ }
80
+ await controller.push(parseStructuredValue(text, parse, validate));
81
+ };
82
+ for await (const chunk of toAsyncIterable(source)) {
83
+ if (controller.signal.aborted) {
84
+ break;
85
+ }
86
+ buffer += chunk;
87
+ const lines = buffer.split(/\r?\n/);
88
+ buffer = lines.pop() ?? '';
89
+ for (const line of lines) {
90
+ if (controller.signal.aborted) {
91
+ break;
92
+ }
93
+ await publishLine(line);
94
+ }
95
+ }
96
+ if (!controller.signal.aborted) {
97
+ await publishLine(buffer);
98
+ }
99
+ }, {
100
+ ...streamOptions,
101
+ seed: trimCollection(seed, maxItems),
102
+ reduce: createCollectionReducer(collectionOptions)
103
+ });
104
+ };
31
105
  streamFactory.events = (sourceOrSetup, options = {}) => attachEventSelectors(createStream(sourceOrSetup, {
106
+ ...options,
32
107
  seed: [],
33
- reduce: (currentValue, chunk) => [...currentValue, chunk],
34
- ...options
108
+ reduce: createCollectionReducer(options)
35
109
  }));
36
110
  // Attach backpressure behavior without changing the reducer semantics.
37
111
  streamFactory.withBackpressure = (sourceOrSetup, backpressure, options = {}) => createStream(sourceOrSetup, {
@@ -180,10 +254,13 @@ function attachEventSelectors(events) {
180
254
  eventStream.select = function select(type, options) {
181
255
  let seen = 0;
182
256
  let drain = Promise.resolve();
183
- const selectedOptions = options ?? {
184
- seed: [],
185
- reduce: (currentValue, chunk) => [...currentValue, chunk]
186
- };
257
+ const selectedOptions = isCollectionSelectOptions(options)
258
+ ? {
259
+ ...options,
260
+ seed: trimCollection(options?.seed ?? [], options?.maxItems),
261
+ reduce: createCollectionReducer(options ?? {})
262
+ }
263
+ : options;
187
264
  return createStream(async (controller) => {
188
265
  const emitFrom = async (chunks) => {
189
266
  while (seen < chunks.length && !controller.signal.aborted) {
@@ -214,6 +291,9 @@ function attachEventSelectors(events) {
214
291
  };
215
292
  return eventStream;
216
293
  }
294
+ function isCollectionSelectOptions(options) {
295
+ return options === undefined || Array.isArray(options.seed) || 'maxItems' in options;
296
+ }
217
297
  async function resolveRetryDelay(backoff, retry, error) {
218
298
  if (typeof backoff === 'function') {
219
299
  return Math.max(0, await backoff(retry, error));
@@ -227,6 +307,40 @@ async function resolveRetryDelay(backoff, retry, error) {
227
307
  }
228
308
  return Math.max(0, backoff);
229
309
  }
310
+ function parseStructuredValue(text, parse, validate) {
311
+ const parsed = parse(text);
312
+ if (validate && !validate(parsed)) {
313
+ throw new TypeError('Structured stream value failed validation.');
314
+ }
315
+ return parsed;
316
+ }
317
+ function createCollectionReducer(options) {
318
+ return (currentValue, chunk, index) => {
319
+ const nextValue = options.reduce
320
+ ? options.reduce(currentValue, chunk, index)
321
+ : [...currentValue, chunk];
322
+ return trimCollection(nextValue, options.maxItems);
323
+ };
324
+ }
325
+ function trimCollection(items, maxItems) {
326
+ const normalizedMaxItems = normalizeMaxItems(maxItems);
327
+ if (normalizedMaxItems === null || items.length <= normalizedMaxItems) {
328
+ return items;
329
+ }
330
+ if (normalizedMaxItems === 0) {
331
+ return [];
332
+ }
333
+ return items.slice(items.length - normalizedMaxItems);
334
+ }
335
+ function normalizeMaxItems(maxItems) {
336
+ if (maxItems === undefined) {
337
+ return null;
338
+ }
339
+ if (!Number.isFinite(maxItems)) {
340
+ return null;
341
+ }
342
+ return Math.max(0, Math.floor(maxItems));
343
+ }
230
344
  // Turn any iterable or async iterable into a stream, optionally adding source delay.
231
345
  export function from(source, options = {}) {
232
346
  const { delay = 0, ...streamOptions } = options;