ai 6.0.206 → 6.0.208
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/CHANGELOG.md +20 -0
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +2 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -1
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/36-transcription.mdx +28 -25
- package/package.json +3 -3
- package/src/generate-text/stream-text.ts +3 -1
- package/src/util/download/download.ts +4 -0
- package/src/util/fix-json.ts +30 -1
package/src/util/fix-json.ts
CHANGED
|
@@ -3,6 +3,7 @@ type State =
|
|
|
3
3
|
| 'FINISH'
|
|
4
4
|
| 'INSIDE_STRING'
|
|
5
5
|
| 'INSIDE_STRING_ESCAPE'
|
|
6
|
+
| 'INSIDE_STRING_UNICODE_ESCAPE'
|
|
6
7
|
| 'INSIDE_LITERAL'
|
|
7
8
|
| 'INSIDE_NUMBER'
|
|
8
9
|
| 'INSIDE_OBJECT_START'
|
|
@@ -28,6 +29,15 @@ export function fixJson(input: string): string {
|
|
|
28
29
|
const stack: State[] = ['ROOT'];
|
|
29
30
|
let lastValidIndex = -1;
|
|
30
31
|
let literalStart: number | null = null;
|
|
32
|
+
let unicodeEscapeDigits = 0;
|
|
33
|
+
|
|
34
|
+
function isHexDigit(char: string) {
|
|
35
|
+
return (
|
|
36
|
+
(char >= '0' && char <= '9') ||
|
|
37
|
+
(char >= 'A' && char <= 'F') ||
|
|
38
|
+
(char >= 'a' && char <= 'f')
|
|
39
|
+
);
|
|
40
|
+
}
|
|
31
41
|
|
|
32
42
|
function processValueStart(char: string, i: number, swapState: State) {
|
|
33
43
|
{
|
|
@@ -260,7 +270,26 @@ export function fixJson(input: string): string {
|
|
|
260
270
|
|
|
261
271
|
case 'INSIDE_STRING_ESCAPE': {
|
|
262
272
|
stack.pop();
|
|
263
|
-
|
|
273
|
+
|
|
274
|
+
if (char === 'u') {
|
|
275
|
+
unicodeEscapeDigits = 0;
|
|
276
|
+
stack.push('INSIDE_STRING_UNICODE_ESCAPE');
|
|
277
|
+
} else {
|
|
278
|
+
lastValidIndex = i;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
case 'INSIDE_STRING_UNICODE_ESCAPE': {
|
|
285
|
+
if (isHexDigit(char)) {
|
|
286
|
+
unicodeEscapeDigits++;
|
|
287
|
+
|
|
288
|
+
if (unicodeEscapeDigits === 4) {
|
|
289
|
+
stack.pop();
|
|
290
|
+
lastValidIndex = i;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
264
293
|
|
|
265
294
|
break;
|
|
266
295
|
}
|