ranuts 0.4.0-alpha.5 → 0.4.1-alpha.2

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 (44) hide show
  1. package/CLAUDE.md +180 -32
  2. package/README.md +2 -0
  3. package/README.zh-CN.md +2 -0
  4. package/dist/{color-DPV7TsVU.js → color-BTvZUuf-.js} +1 -1
  5. package/dist/i18n-DW21b_DJ.js +1 -0
  6. package/dist/index.js +1 -1
  7. package/dist/src/conversation/engine.d.ts +109 -0
  8. package/dist/src/conversation/index.d.ts +12 -0
  9. package/dist/src/conversation/index.js +1 -0
  10. package/dist/src/conversation/types.d.ts +99 -0
  11. package/dist/src/node/index.js +1 -1
  12. package/dist/src/stream/accumulator.d.ts +51 -0
  13. package/dist/src/stream/budget.d.ts +89 -0
  14. package/dist/src/stream/index.d.ts +25 -0
  15. package/dist/src/stream/index.js +1 -0
  16. package/dist/src/stream/sse.d.ts +51 -0
  17. package/dist/src/stream/types.d.ts +106 -0
  18. package/dist/src/utils/binary.d.ts +33 -0
  19. package/dist/src/utils/canvas.d.ts +1 -0
  20. package/dist/src/utils/device.d.ts +8 -0
  21. package/dist/src/utils/diff.d.ts +51 -0
  22. package/dist/src/utils/i18n/index.js +1 -1
  23. package/dist/src/utils/index.d.ts +12 -7
  24. package/dist/src/utils/index.js +1 -1
  25. package/dist/src/utils/number.d.ts +20 -0
  26. package/dist/src/utils/placement.d.ts +42 -5
  27. package/dist/src/utils/scroll.d.ts +93 -0
  28. package/dist/src/utils/secure.d.ts +58 -0
  29. package/dist/src/utils/str.d.ts +75 -0
  30. package/dist/test/budget.test.d.ts +1 -0
  31. package/dist/test/conversation.test.d.ts +1 -0
  32. package/dist/test/diff.test.d.ts +1 -0
  33. package/dist/test/formatBytes.test.d.ts +1 -0
  34. package/dist/test/scroll.test.d.ts +1 -0
  35. package/dist/test/stream.test.d.ts +1 -0
  36. package/dist/test/utils/secure.test.d.ts +1 -0
  37. package/dist/test/utils/text-boundary.test.d.ts +1 -0
  38. package/dist/umd/index.umd.cjs +1 -1
  39. package/dist/umd/utils/utils.umd.cjs +1 -1
  40. package/dist/utils-B4FnyUzW.js +1 -0
  41. package/docs/API.md +94 -6
  42. package/package.json +11 -2
  43. package/dist/i18n-Bq-f7htr.js +0 -1
  44. package/dist/utils-BSvtPyGl.js +0 -1
@@ -13,6 +13,17 @@ export declare const strParse: (str?: string, sep?: string | RegExp, eq?: string
13
13
  */
14
14
  export declare const clearBr: (str?: string) => string;
15
15
  export declare const isString: (obj: unknown) => boolean;
16
+ /**
17
+ * @description: A short random-ish string prefixed with the current timestamp.
18
+ *
19
+ * **Not cryptographically secure** — it draws from `Math.random()`, whose output is
20
+ * predictable from previous values. Good for a DOM id, a message correlation key or a cache
21
+ * buster; never for a token, code or anything an attacker benefits from guessing. Use
22
+ * `secureRandomString` / `secureToken` for those.
23
+ *
24
+ * @param {number} len characters of randomness after the timestamp
25
+ * @return {string}
26
+ */
16
27
  export declare function randomString(len?: number): string;
17
28
  interface ClearStrOption {
18
29
  urlencoded?: boolean;
@@ -102,6 +113,15 @@ export declare const transformText: (content: string | ArrayBuffer) => Transform
102
113
  * @returns The MD5 hash as a hexadecimal string
103
114
  */
104
115
  export declare const md5: (str: string) => string;
116
+ /**
117
+ * @description: A short random-ish base-36 string.
118
+ *
119
+ * **Not cryptographically secure** — `Math.random()` based, like `randomString`. Use
120
+ * `secureRandomString` / `secureToken` when the value must be unguessable.
121
+ *
122
+ * @param {number} len
123
+ * @return {string}
124
+ */
105
125
  export declare const getRandomString: (len?: number) => string;
106
126
  type FileChunk = {
107
127
  name: string;
@@ -260,4 +280,59 @@ export declare const MessageCodec: {
260
280
  */
261
281
  decodeFileChunked(chunks: FileChunk[]): Promise<File>;
262
282
  };
283
+ /**
284
+ * @description: Cut text to `max` characters and mark that it was cut.
285
+ *
286
+ * Different from `truncate`, which is for display: that one keeps a head and a tail around an
287
+ * ellipsis so a path or a name stays recognisable. This one is for text about to cross a
288
+ * boundary — a log line into a database row, tool output into a message, a field into a
289
+ * fixed-size frame — where the job is to respect a hard ceiling and leave evidence that
290
+ * something was dropped. Silent truncation is the failure this prevents: a reader who cannot
291
+ * tell a short answer from a cut-off one will trust the cut-off one.
292
+ *
293
+ * @param {string} text
294
+ * @param {number} max maximum characters to keep, before the marker
295
+ * @param {string} marker appended when anything was dropped
296
+ * @return {string}
297
+ */
298
+ export declare const truncateWithMarker: (text: string, max: number, marker?: string) => string;
299
+ /**
300
+ * @description: Wrap text in a Markdown code fence long enough to survive backticks inside it.
301
+ *
302
+ * A fixed ``` fence breaks the moment the body contains one — the block ends early and the
303
+ * rest of the document renders as prose, which is exactly what happens when you paste a
304
+ * Markdown snippet or a transcript into a report. CommonMark closes a fence only on a run at
305
+ * least as long as the opening one, so the fix is to measure the longest run in the body and
306
+ * open with one backtick more.
307
+ *
308
+ * @param {string} body
309
+ * @param {string} lang info string for the opening fence
310
+ * @return {string}
311
+ */
312
+ export declare const fenceCode: (body: string, lang?: string) => string;
313
+ /**
314
+ * @description: Reduce text to a lowercase `a-z0-9-` slug, safe as a filename on every
315
+ * filesystem and as a URL segment.
316
+ *
317
+ * Non-ASCII is dropped rather than transliterated: a guess at romanisation is wrong often
318
+ * enough that an empty slug — which the caller can detect and replace — beats a confidently
319
+ * mangled one. Callers that need CJK titles preserved should keep the original alongside.
320
+ *
321
+ * @param {string} text
322
+ * @param {number} maxLength longest slug to return; trailing dashes are trimmed after cutting
323
+ * @return {string} the slug, or `''` when nothing survived
324
+ */
325
+ export declare const slugify: (text: string, maxLength?: number) => string;
326
+ /**
327
+ * @description: Escape one CSV field: doubles any quote and wraps the value when it contains
328
+ * a comma, a quote or a newline (RFC 4180).
329
+ *
330
+ * A leading `=`, `+`, `-` or `@` is also prefixed with a quote, because spreadsheet software
331
+ * treats those as formulas — the "CSV injection" that turns an exported username into a
332
+ * command when someone opens the file.
333
+ *
334
+ * @param {string | number} value
335
+ * @return {string}
336
+ */
337
+ export declare const csvEscape: (value: string | number) => string;
263
338
  export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};