glotto 2.9.0 → 3.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 (138) hide show
  1. package/README.md +86 -55
  2. package/esm/cli.js +47 -39
  3. package/esm/deno.d.ts +0 -1
  4. package/esm/deno.js +1 -2
  5. package/esm/src/contants.d.ts +2 -2
  6. package/esm/src/contants.d.ts.map +1 -1
  7. package/esm/src/contants.js +22 -12
  8. package/esm/src/file.d.ts +2 -7
  9. package/esm/src/file.d.ts.map +1 -1
  10. package/esm/src/file.js +1 -108
  11. package/esm/src/providers/anthropic.d.ts +6 -11
  12. package/esm/src/providers/anthropic.d.ts.map +1 -1
  13. package/esm/src/providers/anthropic.js +14 -108
  14. package/esm/src/providers/gemini.d.ts +6 -11
  15. package/esm/src/providers/gemini.d.ts.map +1 -1
  16. package/esm/src/providers/gemini.js +13 -114
  17. package/esm/src/providers/openai.d.ts +6 -11
  18. package/esm/src/providers/openai.d.ts.map +1 -1
  19. package/esm/src/providers/openai.js +10 -109
  20. package/esm/src/translator.d.ts +8 -0
  21. package/esm/src/translator.d.ts.map +1 -0
  22. package/esm/src/translator.js +200 -0
  23. package/esm/src/types.d.ts +28 -11
  24. package/esm/src/types.d.ts.map +1 -1
  25. package/esm/src/utilites.d.ts +0 -6
  26. package/esm/src/utilites.d.ts.map +1 -1
  27. package/esm/src/utilites.js +18 -132
  28. package/package.json +1 -1
  29. package/script/cli.js +45 -37
  30. package/script/deno.d.ts +0 -1
  31. package/script/deno.js +1 -2
  32. package/script/src/contants.d.ts +2 -2
  33. package/script/src/contants.d.ts.map +1 -1
  34. package/script/src/contants.js +23 -13
  35. package/script/src/file.d.ts +2 -7
  36. package/script/src/file.d.ts.map +1 -1
  37. package/script/src/file.js +2 -114
  38. package/script/src/providers/anthropic.d.ts +6 -11
  39. package/script/src/providers/anthropic.d.ts.map +1 -1
  40. package/script/src/providers/anthropic.js +13 -107
  41. package/script/src/providers/gemini.d.ts +6 -11
  42. package/script/src/providers/gemini.d.ts.map +1 -1
  43. package/script/src/providers/gemini.js +12 -113
  44. package/script/src/providers/openai.d.ts +6 -11
  45. package/script/src/providers/openai.d.ts.map +1 -1
  46. package/script/src/providers/openai.js +9 -108
  47. package/script/src/translator.d.ts +8 -0
  48. package/script/src/translator.d.ts.map +1 -0
  49. package/script/src/translator.js +209 -0
  50. package/script/src/types.d.ts +28 -11
  51. package/script/src/types.d.ts.map +1 -1
  52. package/script/src/utilites.d.ts +0 -6
  53. package/script/src/utilites.d.ts.map +1 -1
  54. package/script/src/utilites.js +19 -136
  55. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
  56. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
  57. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -51
  58. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts +0 -35
  59. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts.map +0 -1
  60. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.js +0 -192
  61. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +0 -35
  62. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +0 -1
  63. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common64.js +0 -113
  64. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
  65. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
  66. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -13
  67. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
  68. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
  69. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -2
  70. package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts +0 -2
  71. package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts.map +0 -1
  72. package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.js +0 -26
  73. package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts +0 -61
  74. package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts.map +0 -1
  75. package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.js +0 -152
  76. package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts +0 -40
  77. package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts.map +0 -1
  78. package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.js +0 -87
  79. package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts +0 -40
  80. package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts.map +0 -1
  81. package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.js +0 -131
  82. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +0 -40
  83. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +0 -1
  84. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.js +0 -82
  85. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64url.d.ts +0 -40
  86. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64url.d.ts.map +0 -1
  87. package/esm/deps/jsr.io/@std/encoding/1.0.10/base64url.js +0 -72
  88. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
  89. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
  90. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -87
  91. package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts +0 -98
  92. package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts.map +0 -1
  93. package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.js +0 -99
  94. package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts +0 -120
  95. package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts.map +0 -1
  96. package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.js +0 -205
  97. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +0 -23
  98. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +0 -1
  99. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.js +0 -57
  100. package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts +0 -35
  101. package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts.map +0 -1
  102. package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.js +0 -198
  103. package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts +0 -35
  104. package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.d.ts.map +0 -1
  105. package/script/deps/jsr.io/@std/encoding/1.0.10/_common64.js +0 -119
  106. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts +0 -4
  107. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +0 -1
  108. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.js +0 -16
  109. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts +0 -9
  110. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +0 -1
  111. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.js +0 -3
  112. package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts +0 -2
  113. package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts.map +0 -1
  114. package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.js +0 -29
  115. package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts +0 -61
  116. package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts.map +0 -1
  117. package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.js +0 -156
  118. package/script/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts +0 -40
  119. package/script/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts.map +0 -1
  120. package/script/deps/jsr.io/@std/encoding/1.0.10/base32.js +0 -91
  121. package/script/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts +0 -40
  122. package/script/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts.map +0 -1
  123. package/script/deps/jsr.io/@std/encoding/1.0.10/base58.js +0 -135
  124. package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +0 -40
  125. package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +0 -1
  126. package/script/deps/jsr.io/@std/encoding/1.0.10/base64.js +0 -86
  127. package/script/deps/jsr.io/@std/encoding/1.0.10/base64url.d.ts +0 -40
  128. package/script/deps/jsr.io/@std/encoding/1.0.10/base64url.d.ts.map +0 -1
  129. package/script/deps/jsr.io/@std/encoding/1.0.10/base64url.js +0 -76
  130. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +0 -39
  131. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +0 -1
  132. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.js +0 -91
  133. package/script/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts +0 -98
  134. package/script/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts.map +0 -1
  135. package/script/deps/jsr.io/@std/encoding/1.0.10/mod.js +0 -115
  136. package/script/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts +0 -120
  137. package/script/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts.map +0 -1
  138. package/script/deps/jsr.io/@std/encoding/1.0.10/varint.js +0 -211
@@ -1,119 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.rAlphabet = exports.alphabet = exports.padding = void 0;
5
- exports.calcSizeBase64 = calcSizeBase64;
6
- exports.encode = encode;
7
- exports.decode = decode;
8
- exports.padding = "=".charCodeAt(0);
9
- exports.alphabet = {
10
- base64: new TextEncoder()
11
- .encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),
12
- base64url: new TextEncoder()
13
- .encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),
14
- };
15
- exports.rAlphabet = {
16
- base64: new Uint8Array(128).fill(64), // alphabet.base64.length
17
- base64url: new Uint8Array(128).fill(64),
18
- };
19
- exports.alphabet.base64
20
- .forEach((byte, i) => exports.rAlphabet.base64[byte] = i);
21
- exports.alphabet.base64url
22
- .forEach((byte, i) => exports.rAlphabet.base64url[byte] = i);
23
- /**
24
- * Calculate the output size needed to encode a given input size for
25
- * {@linkcode encodeIntoBase64}.
26
- *
27
- * @param originalSize The size of the input buffer.
28
- * @returns The size of the output buffer.
29
- *
30
- * @example Basic Usage
31
- * ```ts
32
- * import { assertEquals } from "@std/assert";
33
- * import { calcSizeBase64 } from "@std/encoding/unstable-base64";
34
- *
35
- * assertEquals(calcSizeBase64(1), 4);
36
- * ```
37
- */
38
- function calcSizeBase64(originalSize) {
39
- return ((originalSize + 2) / 3 | 0) * 4;
40
- }
41
- function encode(buffer, i, o, alphabet, padding) {
42
- i += 2;
43
- for (; i < buffer.length; i += 3) {
44
- const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8) | buffer[i];
45
- buffer[o++] = alphabet[x >> 18];
46
- buffer[o++] = alphabet[x >> 12 & 0x3F];
47
- buffer[o++] = alphabet[x >> 6 & 0x3F];
48
- buffer[o++] = alphabet[x & 0x3F];
49
- }
50
- switch (i) {
51
- case buffer.length + 1: {
52
- const x = buffer[i - 2] << 16;
53
- buffer[o++] = alphabet[x >> 18];
54
- buffer[o++] = alphabet[x >> 12 & 0x3F];
55
- buffer[o++] = padding;
56
- buffer[o++] = padding;
57
- break;
58
- }
59
- case buffer.length: {
60
- const x = (buffer[i - 2] << 16) | (buffer[i - 1] << 8);
61
- buffer[o++] = alphabet[x >> 18];
62
- buffer[o++] = alphabet[x >> 12 & 0x3F];
63
- buffer[o++] = alphabet[x >> 6 & 0x3F];
64
- buffer[o++] = padding;
65
- break;
66
- }
67
- }
68
- return o;
69
- }
70
- function decode(buffer, i, o, alphabet, padding) {
71
- for (let x = buffer.length - 2; x < buffer.length; ++x) {
72
- if (buffer[x] === padding) {
73
- for (let y = x + 1; y < buffer.length; ++y) {
74
- if (buffer[y] !== padding) {
75
- throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(buffer[y])})`);
76
- }
77
- }
78
- buffer = buffer.subarray(0, x);
79
- break;
80
- }
81
- }
82
- if ((buffer.length - o) % 4 === 1) {
83
- throw new RangeError(`Cannot decode input as base64: Length (${buffer.length - o}), excluding padding, must not have a remainder of 1 when divided by 4`);
84
- }
85
- i += 3;
86
- for (; i < buffer.length; i += 4) {
87
- const x = (getByte(buffer[i - 3], alphabet) << 18) |
88
- (getByte(buffer[i - 2], alphabet) << 12) |
89
- (getByte(buffer[i - 1], alphabet) << 6) |
90
- getByte(buffer[i], alphabet);
91
- buffer[o++] = x >> 16;
92
- buffer[o++] = x >> 8 & 0xFF;
93
- buffer[o++] = x & 0xFF;
94
- }
95
- switch (i) {
96
- case buffer.length + 1: {
97
- const x = (getByte(buffer[i - 3], alphabet) << 18) |
98
- (getByte(buffer[i - 2], alphabet) << 12);
99
- buffer[o++] = x >> 16;
100
- break;
101
- }
102
- case buffer.length: {
103
- const x = (getByte(buffer[i - 3], alphabet) << 18) |
104
- (getByte(buffer[i - 2], alphabet) << 12) |
105
- (getByte(buffer[i - 1], alphabet) << 6);
106
- buffer[o++] = x >> 16;
107
- buffer[o++] = x >> 8 & 0xFF;
108
- break;
109
- }
110
- }
111
- return o;
112
- }
113
- function getByte(char, alphabet) {
114
- const byte = alphabet[char] ?? 64;
115
- if (byte === 64) { // alphabet.Base64.length
116
- throw new TypeError(`Cannot decode input as base64: Invalid character (${String.fromCharCode(char)})`);
117
- }
118
- return byte;
119
- }
@@ -1,4 +0,0 @@
1
- import type { Uint8Array_ } from "./_types.js";
2
- export type { Uint8Array_ };
3
- export declare function detach(buffer: Uint8Array_, maxSize: number): [Uint8Array_, number];
4
- //# sourceMappingURL=_common_detach.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_common_detach.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_common_detach.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,wBAAgB,MAAM,CACpB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,GACd,CAAC,WAAW,EAAE,MAAM,CAAC,CAWvB"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.detach = detach;
5
- function detach(buffer, maxSize) {
6
- const originalSize = buffer.length;
7
- if (buffer.byteOffset) {
8
- const b = new Uint8Array(buffer.buffer);
9
- b.set(buffer);
10
- buffer = b.subarray(0, originalSize);
11
- }
12
- // deno-lint-ignore no-explicit-any
13
- buffer = new Uint8Array(buffer.buffer.transfer(maxSize));
14
- buffer.set(buffer.subarray(0, originalSize), maxSize - originalSize);
15
- return [buffer, maxSize - originalSize];
16
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Proxy type of {@code Uint8Array<ArrayBuffer} or {@code Uint8Array} in TypeScript 5.7 or below respectively.
3
- *
4
- * This type is internal utility type and should not be used directly.
5
- *
6
- * @internal @private
7
- */
8
- export type Uint8Array_ = ReturnType<Uint8Array["slice"]>;
9
- //# sourceMappingURL=_types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_types.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export declare function validateBinaryLike(source: unknown): Uint8Array;
2
- //# sourceMappingURL=_validate_binary_like.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_validate_binary_like.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.ts"],"names":[],"mappings":"AAeA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAa9D"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.validateBinaryLike = validateBinaryLike;
5
- const encoder = new TextEncoder();
6
- function getTypeName(value) {
7
- const type = typeof value;
8
- if (type !== "object") {
9
- return type;
10
- }
11
- else if (value === null) {
12
- return "null";
13
- }
14
- else {
15
- return value?.constructor?.name ?? "object";
16
- }
17
- }
18
- function validateBinaryLike(source) {
19
- if (typeof source === "string") {
20
- return encoder.encode(source);
21
- }
22
- else if (source instanceof Uint8Array) {
23
- return source;
24
- }
25
- else if (source instanceof ArrayBuffer) {
26
- return new Uint8Array(source);
27
- }
28
- throw new TypeError(`Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${getTypeName(source)}`);
29
- }
@@ -1,61 +0,0 @@
1
- import type { Uint8Array_ } from "./_types.js";
2
- export type { Uint8Array_ };
3
- /**
4
- * Supported ascii85 standards for {@linkcode EncodeAscii85Options} and
5
- * {@linkcode DecodeAscii85Options}.
6
- */
7
- export type Ascii85Standard = "Adobe" | "btoa" | "RFC 1924" | "Z85";
8
- /** Options for {@linkcode encodeAscii85}. */
9
- export interface EncodeAscii85Options {
10
- /**
11
- * Character set and delimiter (if supported and used).
12
- *
13
- * @default {"Adobe"}
14
- */
15
- standard?: Ascii85Standard;
16
- /**
17
- * Whether to use a delimiter (if supported).
18
- *
19
- * @default {false}
20
- */
21
- delimiter?: boolean;
22
- }
23
- /**
24
- * Converts data into an ascii85-encoded string.
25
- *
26
- * @param data The data to encode.
27
- * @param options Options for encoding.
28
- *
29
- * @returns The ascii85-encoded string.
30
- *
31
- * @example Usage
32
- * ```ts
33
- * import { encodeAscii85 } from "@std/encoding/ascii85";
34
- * import { assertEquals } from "@std/assert";
35
- *
36
- * assertEquals(encodeAscii85("Hello world!"), "87cURD]j7BEbo80");
37
- * ```
38
- */
39
- export declare function encodeAscii85(data: ArrayBuffer | Uint8Array | string, options?: EncodeAscii85Options): string;
40
- /** Options for {@linkcode decodeAscii85}. */
41
- export type DecodeAscii85Options = Omit<EncodeAscii85Options, "delimiter">;
42
- /**
43
- * Decodes a ascii85-encoded string.
44
- *
45
- * @param ascii85 The ascii85-encoded string to decode.
46
- * @param options Options for decoding.
47
- * @returns The decoded data.
48
- *
49
- * @example Usage
50
- * ```ts
51
- * import { decodeAscii85 } from "@std/encoding/ascii85";
52
- * import { assertEquals } from "@std/assert";
53
- *
54
- * assertEquals(
55
- * decodeAscii85("87cURD]j7BEbo80"),
56
- * new TextEncoder().encode("Hello world!"),
57
- * );
58
- * ```
59
- */
60
- export declare function decodeAscii85(ascii85: string, options?: DecodeAscii85Options): Uint8Array_;
61
- //# sourceMappingURL=ascii85.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ascii85.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/ascii85.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAwB5B;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAEpE,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAOD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,EACvC,OAAO,GAAE,oBAAyB,GACjC,MAAM,CA6DR;AAED,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,oBAAyB,GACjC,WAAW,CA4Cb"}
@@ -1,156 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- // This module is browser compatible.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.encodeAscii85 = encodeAscii85;
6
- exports.decodeAscii85 = decodeAscii85;
7
- /**
8
- * Utilities for working with {@link https://en.wikipedia.org/wiki/Ascii85 | ascii85} encoding.
9
- *
10
- * ## Specifying a standard and delimiter
11
- *
12
- * By default, all functions are using the most popular Adobe version of ascii85
13
- * and not adding any delimiter. However, there are three more standards
14
- * supported - btoa (different delimiter and additional compression of 4 bytes
15
- * equal to 32), {@link https://rfc.zeromq.org/spec/32/ | Z85} and
16
- * {@link https://www.rfc-editor.org/rfc/rfc1924.html | RFC 1924}. It's possible to use a
17
- * different encoding by specifying it in `options` object as a second parameter.
18
- *
19
- * Similarly, it's possible to make `encode` add a delimiter (`<~` and `~>` for
20
- * Adobe, `xbtoa Begin` and `xbtoa End` with newlines between the delimiters and
21
- * encoded data for btoa. Checksums for btoa are not supported. Delimiters are not
22
- * supported by other encodings.)
23
- *
24
- * @module
25
- */
26
- const _validate_binary_like_js_1 = require("./_validate_binary_like.js");
27
- const rfc1924 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
28
- const Z85 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#";
29
- /**
30
- * Converts data into an ascii85-encoded string.
31
- *
32
- * @param data The data to encode.
33
- * @param options Options for encoding.
34
- *
35
- * @returns The ascii85-encoded string.
36
- *
37
- * @example Usage
38
- * ```ts
39
- * import { encodeAscii85 } from "@std/encoding/ascii85";
40
- * import { assertEquals } from "@std/assert";
41
- *
42
- * assertEquals(encodeAscii85("Hello world!"), "87cURD]j7BEbo80");
43
- * ```
44
- */
45
- function encodeAscii85(data, options = {}) {
46
- let uint8 = (0, _validate_binary_like_js_1.validateBinaryLike)(data);
47
- const { standard = "Adobe" } = options;
48
- let output = [];
49
- let v;
50
- let n = 0;
51
- let difference = 0;
52
- if (uint8.length % 4 !== 0) {
53
- const tmp = uint8;
54
- difference = 4 - (tmp.length % 4);
55
- uint8 = new Uint8Array(tmp.length + difference);
56
- uint8.set(tmp);
57
- }
58
- const view = new DataView(uint8.buffer, uint8.byteOffset, uint8.byteLength);
59
- for (let i = 0; i < uint8.length; i += 4) {
60
- v = view.getUint32(i);
61
- // Adobe and btoa standards compress 4 zeroes to single "z" character
62
- if ((standard === "Adobe" || standard === "btoa") &&
63
- v === 0 &&
64
- i < uint8.length - difference - 3) {
65
- output[n++] = "z";
66
- continue;
67
- }
68
- // btoa compresses 4 spaces - that is, bytes equal to 32 - into single "y" character
69
- if (standard === "btoa" && v === 538976288) {
70
- output[n++] = "y";
71
- continue;
72
- }
73
- for (let j = 4; j >= 0; j--) {
74
- output[n + j] = String.fromCharCode((v % 85) + 33);
75
- v = Math.trunc(v / 85);
76
- }
77
- n += 5;
78
- }
79
- switch (standard) {
80
- case "Adobe":
81
- if (options?.delimiter) {
82
- return `<~${output.slice(0, output.length - difference).join("")}~>`;
83
- }
84
- break;
85
- case "btoa":
86
- if (options?.delimiter) {
87
- return `xbtoa Begin\n${output
88
- .slice(0, output.length - difference)
89
- .join("")}\nxbtoa End`;
90
- }
91
- break;
92
- case "RFC 1924":
93
- output = output.map((val) => rfc1924[val.charCodeAt(0) - 33]);
94
- break;
95
- case "Z85":
96
- output = output.map((val) => Z85[val.charCodeAt(0) - 33]);
97
- break;
98
- }
99
- return output.slice(0, output.length - difference).join("");
100
- }
101
- /**
102
- * Decodes a ascii85-encoded string.
103
- *
104
- * @param ascii85 The ascii85-encoded string to decode.
105
- * @param options Options for decoding.
106
- * @returns The decoded data.
107
- *
108
- * @example Usage
109
- * ```ts
110
- * import { decodeAscii85 } from "@std/encoding/ascii85";
111
- * import { assertEquals } from "@std/assert";
112
- *
113
- * assertEquals(
114
- * decodeAscii85("87cURD]j7BEbo80"),
115
- * new TextEncoder().encode("Hello world!"),
116
- * );
117
- * ```
118
- */
119
- function decodeAscii85(ascii85, options = {}) {
120
- const { standard = "Adobe" } = options;
121
- // translate all encodings to most basic adobe/btoa one and decompress some special characters ("z" and "y")
122
- switch (standard) {
123
- case "Adobe":
124
- ascii85 = ascii85.replaceAll(/(<~|~>)/g, "").replaceAll("z", "!!!!!");
125
- break;
126
- case "btoa":
127
- ascii85 = ascii85
128
- .replaceAll(/(xbtoa Begin|xbtoa End|\n)/g, "")
129
- .replaceAll("z", "!!!!!")
130
- .replaceAll("y", "+<VdL");
131
- break;
132
- case "RFC 1924":
133
- ascii85 = ascii85.replaceAll(/./g, (match) => String.fromCharCode(rfc1924.indexOf(match) + 33));
134
- break;
135
- case "Z85":
136
- ascii85 = ascii85.replaceAll(/./g, (match) => String.fromCharCode(Z85.indexOf(match) + 33));
137
- break;
138
- }
139
- // remove all invalid characters
140
- ascii85 = ascii85.replaceAll(/[^!-u]/g, "");
141
- const len = ascii85.length;
142
- const output = new Uint8Array(len + 4 - (len % 4));
143
- const view = new DataView(output.buffer);
144
- let v = 0;
145
- let n = 0;
146
- let max = 0;
147
- for (let i = 0; i < len;) {
148
- for (max += 5; i < max; i++) {
149
- v = v * 85 + (i < len ? ascii85.charCodeAt(i) : 117) - 33;
150
- }
151
- view.setUint32(n, v);
152
- v = 0;
153
- n += 4;
154
- }
155
- return output.slice(0, Math.trunc(len * 0.8));
156
- }
@@ -1,40 +0,0 @@
1
- import type { Uint8Array_ } from "./_types.js";
2
- export type { Uint8Array_ };
3
- /**
4
- * Converts data into a base32-encoded string.
5
- *
6
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
7
- *
8
- * @param data The data to encode.
9
- * @returns The base32-encoded string.
10
- *
11
- * @example Usage
12
- * ```ts
13
- * import { encodeBase32 } from "@std/encoding/base32";
14
- * import { assertEquals } from "@std/assert";
15
- *
16
- * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
17
- * ```
18
- */
19
- export declare function encodeBase32(data: ArrayBuffer | Uint8Array | string): string;
20
- /**
21
- * Decodes a base32-encoded string.
22
- *
23
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
24
- *
25
- * @param b32 The base32-encoded string to decode.
26
- * @returns The decoded data.
27
- *
28
- * @example Usage
29
- * ```ts
30
- * import { decodeBase32 } from "@std/encoding/base32";
31
- * import { assertEquals } from "@std/assert";
32
- *
33
- * assertEquals(
34
- * decodeBase32("GZRTMMDDGA======"),
35
- * new TextEncoder().encode("6c60c0"),
36
- * );
37
- * ```
38
- */
39
- export declare function decodeBase32(b32: string): Uint8Array_;
40
- //# sourceMappingURL=base32.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base32.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/base32.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAQ5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAW5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAUrD"}
@@ -1,91 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2025 the Deno authors. MIT license.
3
- // Copyright (c) 2014 Jameson Little. MIT License.
4
- // This module is browser compatible.
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.encodeBase32 = encodeBase32;
7
- exports.decodeBase32 = decodeBase32;
8
- /**
9
- * Utilities for
10
- * {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6 | base32}
11
- * encoding and decoding.
12
- *
13
- * Modified from {@link https://github.com/beatgammit/base64-js}.
14
- *
15
- * ```ts
16
- * import { encodeBase32, decodeBase32 } from "@std/encoding/base32";
17
- * import { assertEquals } from "@std/assert";
18
- *
19
- * assertEquals(encodeBase32("foobar"), "MZXW6YTBOI======");
20
- *
21
- * assertEquals(
22
- * decodeBase32("MZXW6YTBOI======"),
23
- * new TextEncoder().encode("foobar")
24
- * );
25
- * ```
26
- *
27
- * @module
28
- */
29
- const _common32_js_1 = require("./_common32.js");
30
- const _common_detach_js_1 = require("./_common_detach.js");
31
- const padding = "=".charCodeAt(0);
32
- const alphabet = new TextEncoder()
33
- .encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
34
- const rAlphabet = new Uint8Array(128).fill(32); //alphabet.length
35
- alphabet.forEach((byte, i) => rAlphabet[byte] = i);
36
- /**
37
- * Converts data into a base32-encoded string.
38
- *
39
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
40
- *
41
- * @param data The data to encode.
42
- * @returns The base32-encoded string.
43
- *
44
- * @example Usage
45
- * ```ts
46
- * import { encodeBase32 } from "@std/encoding/base32";
47
- * import { assertEquals } from "@std/assert";
48
- *
49
- * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
50
- * ```
51
- */
52
- function encodeBase32(data) {
53
- if (typeof data === "string") {
54
- data = new TextEncoder().encode(data);
55
- }
56
- else if (data instanceof ArrayBuffer)
57
- data = new Uint8Array(data).slice();
58
- else
59
- data = data.slice();
60
- const [output, i] = (0, _common_detach_js_1.detach)(data, (0, _common32_js_1.calcSizeBase32)(data.length));
61
- (0, _common32_js_1.encode)(output, i, 0, alphabet, padding);
62
- return new TextDecoder().decode(output);
63
- }
64
- /**
65
- * Decodes a base32-encoded string.
66
- *
67
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
68
- *
69
- * @param b32 The base32-encoded string to decode.
70
- * @returns The decoded data.
71
- *
72
- * @example Usage
73
- * ```ts
74
- * import { decodeBase32 } from "@std/encoding/base32";
75
- * import { assertEquals } from "@std/assert";
76
- *
77
- * assertEquals(
78
- * decodeBase32("GZRTMMDDGA======"),
79
- * new TextEncoder().encode("6c60c0"),
80
- * );
81
- * ```
82
- */
83
- function decodeBase32(b32) {
84
- const output = new TextEncoder().encode(b32);
85
- if (output.length % 8) {
86
- throw new TypeError(`Invalid base32 string: length (${output.length}) must be a multiple of 8`);
87
- }
88
- // deno-lint-ignore no-explicit-any
89
- return new Uint8Array(output.buffer
90
- .transfer((0, _common32_js_1.decode)(output, 0, 0, rAlphabet, padding)));
91
- }
@@ -1,40 +0,0 @@
1
- import type { Uint8Array_ } from "./_types.js";
2
- export type { Uint8Array_ };
3
- /**
4
- * Converts data into a base58-encoded string.
5
- *
6
- * @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-3}
7
- *
8
- * @param data The data to encode.
9
- * @returns The base58-encoded string.
10
- *
11
- * @example Usage
12
- * ```ts
13
- * import { encodeBase58 } from "@std/encoding/base58";
14
- * import { assertEquals } from "@std/assert";
15
- *
16
- * assertEquals(encodeBase58("Hello World!"), "2NEpo7TZRRrLZSi2U");
17
- * ```
18
- */
19
- export declare function encodeBase58(data: ArrayBuffer | Uint8Array | string): string;
20
- /**
21
- * Decodes a base58-encoded string.
22
- *
23
- * @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-4}
24
- *
25
- * @param b58 The base58-encoded string to decode.
26
- * @returns The decoded data.
27
- *
28
- * @example Usage
29
- * ```ts
30
- * import { decodeBase58 } from "@std/encoding/base58";
31
- * import { assertEquals } from "@std/assert";
32
- *
33
- * assertEquals(
34
- * decodeBase58("2NEpo7TZRRrLZSi2U"),
35
- * new TextEncoder().encode("Hello World!")
36
- * );
37
- * ```
38
- */
39
- export declare function decodeBase58(b58: string): Uint8Array_;
40
- //# sourceMappingURL=base58.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/base58.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAe5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAgD5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAkDrD"}