@minjun0219/mdwire 0.1.9 → 0.1.11

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `renderWithReport` 의 결과.
2
+ * The result of `renderWithReport`.
3
3
  */
4
4
  export class Rendered {
5
5
  static __wrap(ptr) {
@@ -19,7 +19,7 @@ export class Rendered {
19
19
  wasm.__wbg_rendered_free(ptr, 0);
20
20
  }
21
21
  /**
22
- * 조각들. 한도를 넘지 않았으면 하나다.
22
+ * The parts. Just one if the text fit within the limit.
23
23
  * @returns {string[]}
24
24
  */
25
25
  get parts() {
@@ -36,7 +36,7 @@ export class Rendered {
36
36
  }
37
37
  }
38
38
  /**
39
- * 정규화가 고친 것.
39
+ * What normalization repaired.
40
40
  * @returns {Repairs}
41
41
  */
42
42
  get repairs() {
@@ -47,7 +47,7 @@ export class Rendered {
47
47
  if (Symbol.dispose) Rendered.prototype[Symbol.dispose] = Rendered.prototype.free;
48
48
 
49
49
  /**
50
- * 정규화가 고친 것과 채널에 맞춰 바꾼 것의 개수.
50
+ * Counts of what normalization repaired and what was changed to fit the channel.
51
51
  */
52
52
  export class Repairs {
53
53
  static __wrap(ptr) {
@@ -67,7 +67,7 @@ export class Repairs {
67
67
  wasm.__wbg_repairs_free(ptr, 0);
68
68
  }
69
69
  /**
70
- * 블록이 끝나도록 안 닫혀서 닫아 준 강조.
70
+ * Emphasis left open at the end of a block, closed for you.
71
71
  * @returns {number}
72
72
  */
73
73
  get closedEmphasis() {
@@ -75,7 +75,7 @@ export class Repairs {
75
75
  return ret >>> 0;
76
76
  }
77
77
  /**
78
- * 문서 끝까지 안 닫혀서 닫아 준 코드펜스.
78
+ * Code fences left open at the end of the document, closed for you.
79
79
  * @returns {number}
80
80
  */
81
81
  get closedFence() {
@@ -83,7 +83,7 @@ export class Repairs {
83
83
  return ret >>> 0;
84
84
  }
85
85
  /**
86
- * 다른 표기로 바꿔 쓴 강조 마커와 `<url|텍스트>` 링크.
86
+ * Emphasis markers and `<url|text>` links rewritten in a different notation.
87
87
  * @returns {number}
88
88
  */
89
89
  get convertedMarker() {
@@ -91,7 +91,7 @@ export class Repairs {
91
91
  return ret >>> 0;
92
92
  }
93
93
  /**
94
- * 짝 잃은 채 버린 `**`.
94
+ * Unmatched `**` markers that were dropped.
95
95
  * @returns {number}
96
96
  */
97
97
  get droppedMarker() {
@@ -99,7 +99,7 @@ export class Repairs {
99
99
  return ret >>> 0;
100
100
  }
101
101
  /**
102
- * 채널이 구문으로 읽을 글자를 탈출한 수(GitHub 의 `\~`·`\<`·`\*`).
102
+ * Characters escaped because the channel would read them as syntax (GitHub's `\~`, `\<`, `\*`).
103
103
  * @returns {number}
104
104
  */
105
105
  get escapedChar() {
@@ -107,7 +107,7 @@ export class Repairs {
107
107
  return ret >>> 0;
108
108
  }
109
109
  /**
110
- * 짝이 없어 글자로 되돌린 백틱 런.
110
+ * Unmatched backtick runs, turned back into literal text.
111
111
  * @returns {number}
112
112
  */
113
113
  get revertedCodeSpan() {
@@ -115,7 +115,7 @@ export class Repairs {
115
115
  return ret >>> 0;
116
116
  }
117
117
  /**
118
- * 다른 기호로 바꿔 쓴 목록 불릿.
118
+ * List bullets rewritten with a different symbol.
119
119
  * @returns {number}
120
120
  */
121
121
  get rewrittenBullet() {
@@ -123,7 +123,7 @@ export class Repairs {
123
123
  return ret >>> 0;
124
124
  }
125
125
  /**
126
- * 원문과 다른 모양으로 다시 쓴 표.
126
+ * Tables rewritten in a different shape from the source.
127
127
  * @returns {number}
128
128
  */
129
129
  get rewrittenTable() {
@@ -131,7 +131,7 @@ export class Repairs {
131
131
  return ret >>> 0;
132
132
  }
133
133
  /**
134
- * 벗긴 원문 HTML(태그·주석·줄바꿈으로 바꾼 `<br>`).
134
+ * Raw HTML stripped from the source (tags, comments, and `<br>` turned into line breaks).
135
135
  * @returns {number}
136
136
  */
137
137
  get strippedHtml() {
@@ -139,7 +139,7 @@ export class Repairs {
139
139
  return ret >>> 0;
140
140
  }
141
141
  /**
142
- * 마커 대신 태그로 낸 강조(GitHub 의 `<strong>`).
142
+ * Emphasis emitted differently because the channel would not read the marker in that position (GitHub's `<strong>`, Slack's U+2060).
143
143
  * @returns {number}
144
144
  */
145
145
  get tagEmphasis() {
@@ -147,70 +147,70 @@ export class Repairs {
147
147
  return ret >>> 0;
148
148
  }
149
149
  /**
150
- * 블록이 끝나도록 안 닫혀서 닫아 준 강조.
150
+ * Emphasis left open at the end of a block, closed for you.
151
151
  * @param {number} arg0
152
152
  */
153
153
  set closedEmphasis(arg0) {
154
154
  wasm.__wbg_set_repairs_closedEmphasis(this.__wbg_ptr, arg0);
155
155
  }
156
156
  /**
157
- * 문서 끝까지 안 닫혀서 닫아 준 코드펜스.
157
+ * Code fences left open at the end of the document, closed for you.
158
158
  * @param {number} arg0
159
159
  */
160
160
  set closedFence(arg0) {
161
161
  wasm.__wbg_set_repairs_closedFence(this.__wbg_ptr, arg0);
162
162
  }
163
163
  /**
164
- * 다른 표기로 바꿔 쓴 강조 마커와 `<url|텍스트>` 링크.
164
+ * Emphasis markers and `<url|text>` links rewritten in a different notation.
165
165
  * @param {number} arg0
166
166
  */
167
167
  set convertedMarker(arg0) {
168
168
  wasm.__wbg_set_repairs_convertedMarker(this.__wbg_ptr, arg0);
169
169
  }
170
170
  /**
171
- * 짝 잃은 채 버린 `**`.
171
+ * Unmatched `**` markers that were dropped.
172
172
  * @param {number} arg0
173
173
  */
174
174
  set droppedMarker(arg0) {
175
175
  wasm.__wbg_set_repairs_droppedMarker(this.__wbg_ptr, arg0);
176
176
  }
177
177
  /**
178
- * 채널이 구문으로 읽을 글자를 탈출한 수(GitHub 의 `\~`·`\<`·`\*`).
178
+ * Characters escaped because the channel would read them as syntax (GitHub's `\~`, `\<`, `\*`).
179
179
  * @param {number} arg0
180
180
  */
181
181
  set escapedChar(arg0) {
182
182
  wasm.__wbg_set_repairs_escapedChar(this.__wbg_ptr, arg0);
183
183
  }
184
184
  /**
185
- * 짝이 없어 글자로 되돌린 백틱 런.
185
+ * Unmatched backtick runs, turned back into literal text.
186
186
  * @param {number} arg0
187
187
  */
188
188
  set revertedCodeSpan(arg0) {
189
189
  wasm.__wbg_set_repairs_revertedCodeSpan(this.__wbg_ptr, arg0);
190
190
  }
191
191
  /**
192
- * 다른 기호로 바꿔 쓴 목록 불릿.
192
+ * List bullets rewritten with a different symbol.
193
193
  * @param {number} arg0
194
194
  */
195
195
  set rewrittenBullet(arg0) {
196
196
  wasm.__wbg_set_repairs_rewrittenBullet(this.__wbg_ptr, arg0);
197
197
  }
198
198
  /**
199
- * 원문과 다른 모양으로 다시 쓴 표.
199
+ * Tables rewritten in a different shape from the source.
200
200
  * @param {number} arg0
201
201
  */
202
202
  set rewrittenTable(arg0) {
203
203
  wasm.__wbg_set_repairs_rewrittenTable(this.__wbg_ptr, arg0);
204
204
  }
205
205
  /**
206
- * 벗긴 원문 HTML(태그·주석·줄바꿈으로 바꾼 `<br>`).
206
+ * Raw HTML stripped from the source (tags, comments, and `<br>` turned into line breaks).
207
207
  * @param {number} arg0
208
208
  */
209
209
  set strippedHtml(arg0) {
210
210
  wasm.__wbg_set_repairs_strippedHtml(this.__wbg_ptr, arg0);
211
211
  }
212
212
  /**
213
- * 마커 대신 태그로 낸 강조(GitHub 의 `<strong>`).
213
+ * Emphasis emitted differently because the channel would not read the marker in that position (GitHub's `<strong>`, Slack's U+2060).
214
214
  * @param {number} arg0
215
215
  */
216
216
  set tagEmphasis(arg0) {
@@ -220,10 +220,11 @@ export class Repairs {
220
220
  if (Symbol.dispose) Repairs.prototype[Symbol.dispose] = Repairs.prototype.free;
221
221
 
222
222
  /**
223
- * 스트리밍 변환기.
223
+ * Streaming converter.
224
224
  *
225
- * 조각을 넣으면 지금 안전하게 내보낼 수 있는 만큼만 돌려준다. 경계에 걸린 마크업은
226
- * 안에 남는다 — 토큰이 흘러들어오는 대로 화면에 붙이는 쪽이 이것 때문에 쓴다.
225
+ * Push a chunk and it returns only what is safe to emit now. Markup cut off at the
226
+ * chunk boundary stays inside. This is what you want when appending tokens to the
227
+ * screen as they arrive.
227
228
  */
228
229
  export class Streamer {
229
230
  __destroy_into_raw() {
@@ -237,14 +238,15 @@ export class Streamer {
237
238
  wasm.__wbg_streamer_free(ptr, 0);
238
239
  }
239
240
  /**
240
- * **지금까지 받은 것을 그대로 보내려면 이걸 뒤에 붙인다.**
241
+ * **To send what you have received so far as is, append this after it.**
241
242
  *
242
- * 상태는 건드리지 않으므로 붙인 뒤에도 스트리밍은 이어진다. 누적본 자체에는
243
- * 넣지 말고, 보내기 직전에만 붙인다. 토큰이 오는 대로 메시지를 편집하는 쪽이 쓴다.
243
+ * It does not touch the state, so streaming continues afterwards. Do not add it
244
+ * to the accumulated output itself; append it only right before sending. Use it
245
+ * when editing a message as tokens arrive.
244
246
  *
245
247
  * ```js
246
248
  * acc += s.push(chunk);
247
- * await edit(acc + s.closeOpen()); // 누적본은 그대로 둔다
249
+ * await edit(acc + s.closeOpen()); // leave acc unchanged
248
250
  * ```
249
251
  * @returns {string}
250
252
  */
@@ -265,7 +267,7 @@ export class Streamer {
265
267
  }
266
268
  }
267
269
  /**
268
- * 입력이 끝났다. 남은 것을 내보내고 열린 마크업을 닫는다.
270
+ * Input has ended. Emits what is left and closes open markup.
269
271
  * @returns {string}
270
272
  */
271
273
  finish() {
@@ -308,15 +310,16 @@ export class Streamer {
308
310
  }
309
311
  }
310
312
  /**
311
- * **지금 입력이 끝났다면 확정분 뒤에 붙을 꼬리.** `closeOpen` 과 같은 자리에 들어가지만
312
- * 붙들고 있던 것(열린 강조, 표 행, 코드 스팬)까지 그린다. 누적본을 통째로 다시 그리는 쪽의
313
- * 기본값이다. 추측이라 뒤 조각이 모양을 바꿀 수 있다 — 끝난 뒤 `revised()` 로 본다.
313
+ * **The tail that would follow the final output if input ended now.** It goes in the
314
+ * same place as `closeOpen`, but also draws what is being held back (open emphasis,
315
+ * table rows, code spans). This is the default when you redraw the whole message.
316
+ * It is a guess, so later chunks may change the shape. Check `revised()` after the end.
314
317
  *
315
318
  * ```js
316
319
  * acc += s.push(chunk);
317
- * await edit(acc + s.preview()); // 화면을 그릴 때만 부른다(열린 블록만큼 든다)
320
+ * await edit(acc + s.preview()); // call only when drawing (costs as much as the open block)
318
321
  * acc += s.finish();
319
- * if (s.revised()) await edit(acc); // 마지막 화면이 곧 완성본이면 건너뛴다
322
+ * if (s.revised()) await edit(acc); // skip if the last screen already is the final output
320
323
  * ```
321
324
  * @returns {string}
322
325
  */
@@ -359,7 +362,7 @@ export class Streamer {
359
362
  }
360
363
  }
361
364
  /**
362
- * 지금까지 정규화가 고친 것. `finish` 뒤에 보면 문서 전체의 값이다.
365
+ * What normalization has repaired so far. After `finish`, this covers the whole document.
363
366
  * @returns {Repairs}
364
367
  */
365
368
  repairs() {
@@ -367,7 +370,7 @@ export class Streamer {
367
370
  return Repairs.__wrap(ret);
368
371
  }
369
372
  /**
370
- * 완성본이 마지막 `preview()` 와 다른가 — `finish` 뒤에 본다.
373
+ * Whether the final output differs from the last `preview()`. Check it after `finish`.
371
374
  * @returns {boolean}
372
375
  */
373
376
  revised() {
@@ -378,7 +381,7 @@ export class Streamer {
378
381
  if (Symbol.dispose) Streamer.prototype[Symbol.dispose] = Streamer.prototype.free;
379
382
 
380
383
  /**
381
- * 채널의 길이 한도(문자 수). 조각을 직접 다루려는 호출자를 위해 열어 둔다.
384
+ * The channel's length limit (in characters). Exposed for callers that handle parts themselves.
382
385
  * @param {string} channel
383
386
  * @returns {number}
384
387
  */
@@ -401,7 +404,7 @@ export function limit(channel) {
401
404
  }
402
405
 
403
406
  /**
404
- * 완성된 문서를 변환한다. 한도를 넘으면 조각 배열로 돌아온다.
407
+ * Converts a complete document. Returns an array of parts; it has more than one when the text exceeds the limit.
405
408
  * @param {string} input
406
409
  * @param {string} channel
407
410
  * @param {RenderOptions | null} [options]
@@ -431,8 +434,8 @@ export function render(input, channel, options) {
431
434
  }
432
435
 
433
436
  /**
434
- * [`render`] 에 **정규화가 고친 것**을 같이 돌려준다. 모델이 얼마나 자주 서식을 깨는지
435
- * 로그로 남기려는 쪽이 쓴다.
437
+ * Like [`render`], but also returns **what normalization repaired**. Use it to log
438
+ * how often the model breaks formatting.
436
439
  * @param {string} input
437
440
  * @param {string} channel
438
441
  * @param {RenderOptions | null} [options]
@@ -472,37 +475,30 @@ export function __wbg___wbindgen_string_get_92ab86bb19cbc12f(arg0, arg1) {
472
475
  export function __wbg___wbindgen_throw_5d9e815e6fdf150f(arg0, arg1) {
473
476
  throw new Error(getStringFromWasm0(arg0, arg1));
474
477
  }
475
- export function __wbg_from_6a18a824ab73bfc5(arg0, arg1) {
476
- const ret = getObject(arg1).from;
477
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
478
- var len1 = WASM_VECTOR_LEN;
479
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
480
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
481
- }
482
- export function __wbg_html_a628fe022a5daeaf(arg0) {
478
+ export function __wbg_html_89b49615556b2850(arg0) {
483
479
  const ret = getObject(arg0).html;
484
480
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
485
481
  }
486
- export function __wbg_images_ff5cc833afad2dcf(arg0, arg1) {
482
+ export function __wbg_images_fc88426d1f55bdfc(arg0, arg1) {
487
483
  const ret = getObject(arg1).images;
488
484
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
489
485
  var len1 = WASM_VECTOR_LEN;
490
486
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
491
487
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
492
488
  }
493
- export function __wbg_limit_cce570f9381001ea(arg0, arg1) {
489
+ export function __wbg_limit_d1453e73fbf788db(arg0, arg1) {
494
490
  const ret = getObject(arg1).limit;
495
491
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
496
492
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
497
493
  }
498
- export function __wbg_lineBreaks_aa928a165d0a7659(arg0, arg1) {
494
+ export function __wbg_lineBreaks_8b98689e9716a2c8(arg0, arg1) {
499
495
  const ret = getObject(arg1).lineBreaks;
500
496
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
501
497
  var len1 = WASM_VECTOR_LEN;
502
498
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
503
499
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
504
500
  }
505
- export function __wbg_schemes_429ccca2fff29ed9(arg0, arg1) {
501
+ export function __wbg_schemes_8e39175723a07726(arg0, arg1) {
506
502
  const ret = getObject(arg1).schemes;
507
503
  var ptr1 = isLikeNone(ret) ? 0 : passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
508
504
  var len1 = WASM_VECTOR_LEN;
Binary file
package/js/events.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- /** mdwire html 출력에 나오는 태그. */
1
+ /** Tags that appear in mdwire's html output. */
2
2
  export type MdTag =
3
3
  | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "ul" | "ol" | "li" | "blockquote" | "pre" | "code"
4
4
  | "strong" | "em" | "del" | "a" | "table" | "thead" | "tbody" | "tr" | "th" | "td" | "hr" | "br"
5
5
  | "sub" | "sup" | "b" | "i" | "u" | "s" | "strike" | "span" | "small" | "mark" | "kbd" | "ins" | "img";
6
6
 
7
7
  /**
8
- * 이벤트 하나. 속성은 코어가 내는 것만 담긴다 —
9
- * `a` 의 `href`, `code` 의 `class`(`language-…`), `th`·`td` 의 `style`(`text-align:…`), `ol` 의 `start`.
8
+ * A single event. Attributes hold only what the core emits:
9
+ * `href` on `a`, `class` on `code` (`language-…`), `style` on `th` and `td` (`text-align:…`), `start` on `ol`.
10
10
  */
11
11
  export type MdEvent =
12
12
  | { type: "open"; tag: MdTag; attrs: Record<string, string> }
13
13
  | { type: "close"; tag: MdTag }
14
14
  | { type: "void"; tag: "br" | "hr" }
15
- /** 이미지는 `html.images: "load"` 일 때만 나온다. `src`·`alt` 를 담는다. */
15
+ /** Images appear only with `html.images: "load"`. Holds `src` and `alt`. */
16
16
  | { type: "void"; tag: "img"; attrs: Record<string, string> }
17
17
  | { type: "text"; text: string };
18
18
 
19
- /** html 채널 출력(또는 스트리밍 누적본 + `closeOpen()`)을 이벤트 배열로 푼다. */
19
+ /** Parses html channel output (or the accumulated stream output + `closeOpen()`) into an array of events. */
20
20
  export function toEvents(html: string): MdEvent[];
package/js/events.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // mdwire 의 html 채널 출력을 이벤트 열로 푼다.
2
2
  //
3
- // **mdwire 가 낸 HTML 만 읽는다.** 코어가 글자를 전부 escape 하고 태그를 고정된 집합으로만
3
+ // **mdwire 가 낸 HTML 만 읽는다.** 코어가 글자를 전부 이스케이프하고 태그를 고정된 집합으로만
4
4
  // 내므로(SPEC 4절) 여기서 필요한 것은 작은 토크나이저 하나다. 남이 쓴 HTML 을 넣으면 모르는
5
5
  // 태그는 글자로 돌려준다 — 이 모듈은 새니타이저가 아니다. 안전 판단은 코어 한 곳에 있다.
6
6
 
@@ -18,8 +18,8 @@ const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"' };
18
18
  const decode = (s) => s.replace(/&(amp|lt|gt|quot);/g, (_, n) => ENTITIES[n]);
19
19
 
20
20
  /**
21
- * html 채널 출력을 이벤트 배열로 바꾼다.
22
- * @param {string} html `render(text, "html")` 의 결과, 또는 스트리밍 누적본 + `closeOpen()`.
21
+ * Converts html channel output into an array of events.
22
+ * @param {string} html The result of `render(text, "html")`, or the accumulated stream output + `closeOpen()`.
23
23
  * @returns {import("./events.d.ts").MdEvent[]}
24
24
  */
25
25
  export function toEvents(html) {
package/js/react.d.ts CHANGED
@@ -2,35 +2,32 @@ import type { ElementType, ReactElement, ReactNode } from "react";
2
2
  import type { MdTag } from "./events.js";
3
3
  import type { RenderOptions } from "@minjun0219/mdwire";
4
4
 
5
- /** 태그별로 갈아 끼울 컴포넌트 — 예: `{ a: MyLink, code: CodeBlock }`. 받는 props 는 그 태그의 것이다. */
5
+ /** Components that replace individual tags, e.g. `{ a: MyLink, code: CodeBlock }`. Each receives that tag's props. */
6
6
  export type MdComponents = Partial<Record<MdTag, ElementType>>;
7
7
 
8
8
  export interface MarkdownProps {
9
- /** 에이전트가 쓴 마크다운(완성된 글). 스트리밍은 `Streamer` + `toElements` 로 — 누적본을 매번 넘기면 처음부터 다시 변환한다. */
9
+ /** Markdown written by the agent (complete text). For streaming, use `Streamer` + `toElements`; passing the accumulated output each time reconverts it from scratch. */
10
10
  text: string;
11
- /** 입력 표기. 슬랙 레거시 mrkdwn 이면 "slack-mrkdwn". */
12
- from?: "markdown" | "slack-mrkdwn";
13
11
  components?: MdComponents;
14
- /** 코어에 넘길 옵션 — `html` 정책(줄바꿈·이미지·스킴)이 여기 든다. `from` 은 위 것이 이긴다. */
12
+ /** Options passed to the core. The `html` policy (line breaks, images, schemes) goes here. */
15
13
  options?: RenderOptions;
16
14
  }
17
15
 
18
- /** 마크다운을 React 요소로 그린다. innerHTML 을 쓰지 않는다. */
16
+ /** Renders markdown as React elements. Does not use innerHTML. */
19
17
  export function Markdown(props: MarkdownProps): ReactElement;
20
18
 
21
19
  export interface MarkdownStreamOptions {
22
- from?: "markdown" | "slack-mrkdwn";
23
20
  components?: MdComponents;
24
21
  options?: RenderOptions;
25
- /** 붙든 것(열린 강조·표 행·코드 스팬)도 먼저 그린다. 기본 `true`. `false` 면 확정된 것만. */
22
+ /** Also draw what is held back (open emphasis, table rows, code spans) ahead of time. Default `true`. With `false`, only final output is shown. */
26
23
  eager?: boolean;
27
- /** 끝났을 때. `revised` 는 완성본이 마지막 화면과 다른가 — 거짓이면 훅은 다시 그리지 않는다. */
24
+ /** Called when done. `revised` tells whether the final output differs from the last screen; if false, the hook does not redraw. */
28
25
  onSettled?: (html: string, revised: boolean) => void;
29
26
  }
30
27
 
31
28
  /**
32
- * 스트리밍용 훅 — 토큰마다 `push`, 끝나면 `finish`. 기본은 붙든 것도 먼저 그린다(`eager`).
33
- * `onSettled` 말고는 처음 한 번만 읽는다.
29
+ * Hook for streaming: call `push` for each token and `finish` at the end. By default it also draws what is held back (`eager`).
30
+ * Options other than `onSettled` are read only once, on first render.
34
31
  */
35
32
  export function useMarkdownStream(opts?: MarkdownStreamOptions): {
36
33
  elements: ReactElement;
@@ -38,6 +35,6 @@ export function useMarkdownStream(opts?: MarkdownStreamOptions): {
38
35
  finish(): void;
39
36
  };
40
37
 
41
- /** html 채널 출력(스트리밍이면 누적본 + `preview()` 또는 `closeOpen()`)을 React 노드로 바꾼다. */
42
- /** `schemes` 는 코어에 준 `options.html.schemes` 와 같게 준다. 기본 `["http", "https", "mailto"]`. */
38
+ /** Converts html channel output (when streaming, the accumulated output + `preview()` or `closeOpen()`) into React nodes. */
39
+ /** Pass the same `schemes` you gave the core as `options.html.schemes`. Default `["http", "https", "mailto"]`. */
43
40
  export function toElements(html: string, components?: MdComponents, schemes?: string[]): ReactNode[];
package/js/react.js CHANGED
@@ -40,11 +40,11 @@ function propsOf(tag, attrs, key, schemes) {
40
40
  }
41
41
 
42
42
  /**
43
- * html 채널 출력을 React 노드 배열로 바꾼다. 스트리밍 누적본을 직접 다루는 쪽이 쓴다 —
44
- * `toElements(acc + streamer.closeOpen())`.
43
+ * Converts html channel output into an array of React nodes. Use it when you handle the
44
+ * accumulated stream output yourself: `toElements(acc + streamer.closeOpen())`.
45
45
  * @param {string} html
46
- * @param {Partial<Record<string, import("react").ElementType>>} [components] 태그별로 갈아 끼울 컴포넌트.
47
- * @param {string[]} [schemes] 링크·이미지로 받는 스킴. 코어에 준 `options.html.schemes` 와 같게.
46
+ * @param {Partial<Record<string, import("react").ElementType>>} [components] Components that replace individual tags.
47
+ * @param {string[]} [schemes] Schemes allowed for links and images. Same as the `options.html.schemes` given to the core.
48
48
  */
49
49
  export function toElements(html, components = {}, schemes = DEFAULT_SCHEMES) {
50
50
  const root = { tag: null, children: [] };
@@ -84,36 +84,41 @@ export function toElements(html, components = {}, schemes = DEFAULT_SCHEMES) {
84
84
  }
85
85
 
86
86
  /**
87
- * 에이전트 마크다운을 그린다 — 완성된 글용. 스트리밍 중인 누적본을 토큰마다 넘기면 매번
88
- * 처음부터 다시 변환해 전체 비용이 제곱으로 늘고, 반쪽 마커(`**굵`, 여는 백틱, `##`)가 잠깐 글자로
89
- * 보였다가 사라진다. 스트리밍은 [`useMarkdownStream`].
87
+ * Renders agent markdown, for complete text. If you pass the accumulated stream on every token,
88
+ * it reconverts from scratch each time, so total cost grows quadratically, and half-written markers
89
+ * (`**bo`, an opening backtick, `##`) briefly show up as text and then vanish. For streaming, use [`useMarkdownStream`].
90
90
  * @param {import("./react.d.ts").MarkdownProps} props
91
91
  */
92
- export function Markdown({ text, from, components, options }) {
93
- const opts = { ...options, ...(from ? { from } : {}) };
94
- const html = render(text, "html", opts).join("");
95
- return createElement(Fragment, null, ...toElements(html, components, opts.html?.schemes ?? DEFAULT_SCHEMES));
92
+ export function Markdown({ text, components, options }) {
93
+ const html = render(text, "html", options).join("");
94
+ return createElement(Fragment, null, ...toElements(html, components, options?.html?.schemes ?? DEFAULT_SCHEMES));
96
95
  }
97
96
 
98
97
  /**
99
- * 스트리밍용 훅. 토큰이 오는 대로 `push(chunk)`, 끝나면 `finish()`.
98
+ * Hook for streaming. Call `push(chunk)` as tokens arrive and `finish()` at the end.
100
99
  *
101
- * 기본(`eager: true`)은 **붙든 것도 먼저 그린다** — 열린 강조는 닫아서, 표는 지금까지 온 행으로,
102
- * 코드 스팬은 닫아서(`Streamer.preview()`). 추측이라 뒤 토큰이 모양을 바꿀 수 있지만 완성본은
103
- * 일괄 변환과 같다. `eager: false` 면 확정된 것만 보인다(append-only, SPEC 8.2) — 짝이 안 맞은
104
- * 강조·판정 전 접두사는 확정될 때 나온다.
100
+ * By default (`eager: true`) it **also draws what is held back**: open emphasis closed, tables with
101
+ * the rows received so far, code spans closed (`Streamer.preview()`). This is a guess, so later tokens
102
+ * may change the shape, but the final output matches a one-shot conversion. With `eager: false`, only
103
+ * final output is shown (append-only, SPEC 8.2): unmatched emphasis and prefixes not yet decided
104
+ * appear once they become final.
105
105
  *
106
- * 끝나면 `onSettled(html, revised)` — `revised` 는 완성본이 마지막으로 **화면에 그려진** 것과
107
- * 다른가다. 같으면 훅은 다시 그리지 않는다.
106
+ * At the end it calls `onSettled(html, revised)`. `revised` tells whether the final output differs
107
+ * from what was last **drawn on screen**. If they match, the hook does not redraw.
108
108
  * @param {import("./react.d.ts").MarkdownStreamOptions} [opts]
109
109
  */
110
- export function useMarkdownStream({ from, components, options, eager = true, onSettled } = {}) {
110
+ export function useMarkdownStream({ components, options, eager = true, onSettled } = {}) {
111
111
  const ref = useRef(null);
112
112
  const init = useRef(null);
113
113
  const [, rerender] = useReducer((n) => n + 1, 0);
114
114
  if (init.current === null) {
115
- const o = { ...options, ...(from ? { from } : {}) };
116
- init.current = () => ({ streamer: new Streamer("html", o), acc: "", done: false, eager, schemes: o.html?.schemes ?? DEFAULT_SCHEMES });
115
+ init.current = () => ({
116
+ streamer: new Streamer("html", options),
117
+ acc: "",
118
+ done: false,
119
+ eager,
120
+ schemes: options?.html?.schemes ?? DEFAULT_SCHEMES,
121
+ });
117
122
  }
118
123
  // 해제됐으면 다시 만든다 — StrictMode 개발 모드는 이펙트를 붙였다 떼었다 다시 붙여서, 정리
119
124
  // 함수가 스트리머를 먼저 해제한다(토큰이 오기 전이라 잃는 것은 없다).