@seelen-ui/lib 2.4.6 → 2.4.8
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/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +23 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.js +51 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts +35 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_common32.js +192 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts +2 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.js +26 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts +61 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/ascii85.js +152 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts +40 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base32.js +87 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts +40 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base58.js +131 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +40 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/base64.js +82 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +39 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.js +87 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts +98 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/mod.js +99 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts +120 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.10/varint.js +205 -0
- package/esm/gen/types/AppExtraFlag.d.ts +6 -5
- package/esm/gen/types/AppExtraFlag.d.ts.map +1 -1
- package/esm/gen/types/AppExtraFlag.js +6 -5
- package/esm/gen/types/FancyToolbarSettings.d.ts +0 -8
- package/esm/gen/types/FancyToolbarSettings.d.ts.map +1 -1
- package/esm/gen/types/FocusedApp.d.ts +6 -0
- package/esm/gen/types/FocusedApp.d.ts.map +1 -1
- package/esm/gen/types/SeelenCommandArgument.d.ts +4 -3
- package/esm/gen/types/SeelenCommandArgument.d.ts.map +1 -1
- package/esm/gen/types/SeelenCommandReturn.d.ts +4 -2
- package/esm/gen/types/SeelenCommandReturn.d.ts.map +1 -1
- package/esm/gen/types/SeelenEventPayload.d.ts +0 -4
- package/esm/gen/types/SeelenEventPayload.d.ts.map +1 -1
- package/esm/gen/types/mod.d.ts +0 -1
- package/esm/gen/types/mod.d.ts.map +1 -1
- package/esm/gen/types/mod.js +0 -1
- package/esm/src/constants/mod.d.ts +194 -196
- package/esm/src/constants/mod.d.ts.map +1 -1
- package/esm/src/constants/mod.js +52 -61
- package/esm/src/handlers/commands.d.ts +2 -1
- package/esm/src/handlers/commands.d.ts.map +1 -1
- package/esm/src/handlers/commands.js +2 -1
- package/esm/src/handlers/events.d.ts +0 -2
- package/esm/src/handlers/events.d.ts.map +1 -1
- package/esm/src/handlers/events.js +0 -2
- package/esm/src/state/widget/mod.js +1 -1
- package/package.json +7 -6
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts +23 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.js +57 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts +35 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_common32.js +198 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts +2 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/_validate_binary_like.js +29 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts +61 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/ascii85.js +156 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts +40 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base32.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base32.js +91 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts +40 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base58.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base58.js +135 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts +40 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/base64.js +86 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts +39 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/hex.js +91 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts +98 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/mod.js +115 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts +120 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/varint.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.10/varint.js +211 -0
- package/script/gen/types/AppExtraFlag.d.ts +6 -5
- package/script/gen/types/AppExtraFlag.d.ts.map +1 -1
- package/script/gen/types/AppExtraFlag.js +6 -5
- package/script/gen/types/FancyToolbarSettings.d.ts +0 -8
- package/script/gen/types/FancyToolbarSettings.d.ts.map +1 -1
- package/script/gen/types/FocusedApp.d.ts +6 -0
- package/script/gen/types/FocusedApp.d.ts.map +1 -1
- package/script/gen/types/SeelenCommandArgument.d.ts +4 -3
- package/script/gen/types/SeelenCommandArgument.d.ts.map +1 -1
- package/script/gen/types/SeelenCommandReturn.d.ts +4 -2
- package/script/gen/types/SeelenCommandReturn.d.ts.map +1 -1
- package/script/gen/types/SeelenEventPayload.d.ts +0 -4
- package/script/gen/types/SeelenEventPayload.d.ts.map +1 -1
- package/script/gen/types/mod.d.ts +0 -1
- package/script/gen/types/mod.d.ts.map +1 -1
- package/script/gen/types/mod.js +0 -1
- package/script/src/constants/mod.d.ts +194 -196
- package/script/src/constants/mod.d.ts.map +1 -1
- package/script/src/constants/mod.js +52 -61
- package/script/src/handlers/commands.d.ts +2 -1
- package/script/src/handlers/commands.d.ts.map +1 -1
- package/script/src/handlers/commands.js +2 -1
- package/script/src/handlers/events.d.ts +0 -2
- package/script/src/handlers/events.d.ts.map +1 -1
- package/script/src/handlers/events.js +0 -2
- package/script/src/re-exports/tauri.js +17 -7
- package/script/src/state/widget/mod.js +19 -9
- package/esm/gen/types/SeelenCommandTranslateTextArgs.d.ts +0 -6
- package/esm/gen/types/SeelenCommandTranslateTextArgs.d.ts.map +0 -1
- package/esm/gen/types/SeelenCommandTranslateTextArgs.js +0 -2
- package/script/gen/types/SeelenCommandTranslateTextArgs.d.ts +0 -6
- package/script/gen/types/SeelenCommandTranslateTextArgs.d.ts.map +0 -1
- package/script/gen/types/SeelenCommandTranslateTextArgs.js +0 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// Copyright (c) 2014 Jameson Little. MIT License.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
/**
|
|
5
|
+
* Utilities for
|
|
6
|
+
* {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6 | base32}
|
|
7
|
+
* encoding and decoding.
|
|
8
|
+
*
|
|
9
|
+
* Modified from {@link https://github.com/beatgammit/base64-js}.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { encodeBase32, decodeBase32 } from "@std/encoding/base32";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
*
|
|
15
|
+
* assertEquals(encodeBase32("foobar"), "MZXW6YTBOI======");
|
|
16
|
+
*
|
|
17
|
+
* assertEquals(
|
|
18
|
+
* decodeBase32("MZXW6YTBOI======"),
|
|
19
|
+
* new TextEncoder().encode("foobar")
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import { calcSizeBase32, decode, encode } from "./_common32.js";
|
|
26
|
+
import { detach } from "./_common_detach.js";
|
|
27
|
+
const padding = "=".charCodeAt(0);
|
|
28
|
+
const alphabet = new TextEncoder()
|
|
29
|
+
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
|
|
30
|
+
const rAlphabet = new Uint8Array(128).fill(32); //alphabet.length
|
|
31
|
+
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
32
|
+
/**
|
|
33
|
+
* Converts data into a base32-encoded string.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
|
|
36
|
+
*
|
|
37
|
+
* @param data The data to encode.
|
|
38
|
+
* @returns The base32-encoded string.
|
|
39
|
+
*
|
|
40
|
+
* @example Usage
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { encodeBase32 } from "@std/encoding/base32";
|
|
43
|
+
* import { assertEquals } from "@std/assert";
|
|
44
|
+
*
|
|
45
|
+
* assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function encodeBase32(data) {
|
|
49
|
+
if (typeof data === "string") {
|
|
50
|
+
data = new TextEncoder().encode(data);
|
|
51
|
+
}
|
|
52
|
+
else if (data instanceof ArrayBuffer)
|
|
53
|
+
data = new Uint8Array(data).slice();
|
|
54
|
+
else
|
|
55
|
+
data = data.slice();
|
|
56
|
+
const [output, i] = detach(data, calcSizeBase32(data.length));
|
|
57
|
+
encode(output, i, 0, alphabet, padding);
|
|
58
|
+
return new TextDecoder().decode(output);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Decodes a base32-encoded string.
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
|
|
64
|
+
*
|
|
65
|
+
* @param b32 The base32-encoded string to decode.
|
|
66
|
+
* @returns The decoded data.
|
|
67
|
+
*
|
|
68
|
+
* @example Usage
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { decodeBase32 } from "@std/encoding/base32";
|
|
71
|
+
* import { assertEquals } from "@std/assert";
|
|
72
|
+
*
|
|
73
|
+
* assertEquals(
|
|
74
|
+
* decodeBase32("GZRTMMDDGA======"),
|
|
75
|
+
* new TextEncoder().encode("6c60c0"),
|
|
76
|
+
* );
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export function decodeBase32(b32) {
|
|
80
|
+
const output = new TextEncoder().encode(b32);
|
|
81
|
+
if (output.length % 8) {
|
|
82
|
+
throw new TypeError(`Invalid base32 string: length (${output.length}) must be a multiple of 8`);
|
|
83
|
+
}
|
|
84
|
+
// deno-lint-ignore no-explicit-any
|
|
85
|
+
return new Uint8Array(output.buffer
|
|
86
|
+
.transfer(decode(output, 0, 0, rAlphabet, padding)));
|
|
87
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
/**
|
|
4
|
+
* Utilities for
|
|
5
|
+
* {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03 | base58}
|
|
6
|
+
* encoding and decoding.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { encodeBase58, decodeBase58 } from "@std/encoding/base58";
|
|
10
|
+
* import { assertEquals } from "@std/assert";
|
|
11
|
+
*
|
|
12
|
+
* const hello = new TextEncoder().encode("Hello World!");
|
|
13
|
+
*
|
|
14
|
+
* assertEquals(encodeBase58(hello), "2NEpo7TZRRrLZSi2U");
|
|
15
|
+
*
|
|
16
|
+
* assertEquals(decodeBase58("2NEpo7TZRRrLZSi2U"), hello);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { validateBinaryLike } from "./_validate_binary_like.js";
|
|
22
|
+
// deno-fmt-ignore
|
|
23
|
+
const mapBase58 = {
|
|
24
|
+
"1": 0, "2": 1, "3": 2, "4": 3, "5": 4, "6": 5, "7": 6, "8": 7, "9": 8, A: 9,
|
|
25
|
+
B: 10, C: 11, D: 12, E: 13, F: 14, G: 15, H: 16, J: 17, K: 18, L: 19, M: 20,
|
|
26
|
+
N: 21, P: 22, Q: 23, R: 24, S: 25, T: 26, U: 27, V: 28, W: 29, X: 30, Y: 31,
|
|
27
|
+
Z: 32, a: 33, b: 34, c: 35, d: 36, e: 37, f: 38, g: 39, h: 40, i: 41, j: 42,
|
|
28
|
+
k: 43, m: 44, n: 45, o: 46, p: 47, q: 48, r: 49, s: 50, t: 51, u: 52, v: 53,
|
|
29
|
+
w: 54, x: 55, y: 56, z: 57
|
|
30
|
+
};
|
|
31
|
+
const base58alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split("");
|
|
32
|
+
/**
|
|
33
|
+
* Converts data into a base58-encoded string.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-3}
|
|
36
|
+
*
|
|
37
|
+
* @param data The data to encode.
|
|
38
|
+
* @returns The base58-encoded string.
|
|
39
|
+
*
|
|
40
|
+
* @example Usage
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { encodeBase58 } from "@std/encoding/base58";
|
|
43
|
+
* import { assertEquals } from "@std/assert";
|
|
44
|
+
*
|
|
45
|
+
* assertEquals(encodeBase58("Hello World!"), "2NEpo7TZRRrLZSi2U");
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function encodeBase58(data) {
|
|
49
|
+
const uint8tData = validateBinaryLike(data);
|
|
50
|
+
let length = 0;
|
|
51
|
+
let zeroes = 0;
|
|
52
|
+
// Counting leading zeroes
|
|
53
|
+
let index = 0;
|
|
54
|
+
while (uint8tData[index] === 0) {
|
|
55
|
+
zeroes++;
|
|
56
|
+
index++;
|
|
57
|
+
}
|
|
58
|
+
const notZeroUint8Data = uint8tData.slice(index);
|
|
59
|
+
const size = Math.round((uint8tData.length * 138) / 100 + 1);
|
|
60
|
+
const b58Encoding = [];
|
|
61
|
+
notZeroUint8Data.forEach((byte) => {
|
|
62
|
+
let i = 0;
|
|
63
|
+
let carry = byte;
|
|
64
|
+
for (let reverseIterator = size - 1; (carry > 0 || i < length) && reverseIterator !== -1; reverseIterator--, i++) {
|
|
65
|
+
carry += (b58Encoding[reverseIterator] ?? 0) * 256;
|
|
66
|
+
b58Encoding[reverseIterator] = Math.round(carry % 58);
|
|
67
|
+
carry = Math.floor(carry / 58);
|
|
68
|
+
}
|
|
69
|
+
length = i;
|
|
70
|
+
});
|
|
71
|
+
const strResult = Array.from({
|
|
72
|
+
length: b58Encoding.length + zeroes,
|
|
73
|
+
});
|
|
74
|
+
if (zeroes > 0) {
|
|
75
|
+
strResult.fill("1", 0, zeroes);
|
|
76
|
+
}
|
|
77
|
+
b58Encoding.forEach((byteValue) => strResult.push(base58alphabet[byteValue]));
|
|
78
|
+
return strResult.join("");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Decodes a base58-encoded string.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-4}
|
|
84
|
+
*
|
|
85
|
+
* @param b58 The base58-encoded string to decode.
|
|
86
|
+
* @returns The decoded data.
|
|
87
|
+
*
|
|
88
|
+
* @example Usage
|
|
89
|
+
* ```ts
|
|
90
|
+
* import { decodeBase58 } from "@std/encoding/base58";
|
|
91
|
+
* import { assertEquals } from "@std/assert";
|
|
92
|
+
*
|
|
93
|
+
* assertEquals(
|
|
94
|
+
* decodeBase58("2NEpo7TZRRrLZSi2U"),
|
|
95
|
+
* new TextEncoder().encode("Hello World!")
|
|
96
|
+
* );
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export function decodeBase58(b58) {
|
|
100
|
+
const splitInput = b58.trim().split("");
|
|
101
|
+
let length = 0;
|
|
102
|
+
let ones = 0;
|
|
103
|
+
// Counting leading ones
|
|
104
|
+
let index = 0;
|
|
105
|
+
while (splitInput[index] === "1") {
|
|
106
|
+
ones++;
|
|
107
|
+
index++;
|
|
108
|
+
}
|
|
109
|
+
const notZeroData = splitInput.slice(index);
|
|
110
|
+
const size = Math.round((b58.length * 733) / 1000 + 1);
|
|
111
|
+
const output = [];
|
|
112
|
+
notZeroData.forEach((char, idx) => {
|
|
113
|
+
let carry = mapBase58[char];
|
|
114
|
+
let i = 0;
|
|
115
|
+
if (carry === undefined) {
|
|
116
|
+
throw new TypeError(`Invalid base58 char at index ${idx} with value ${char}`);
|
|
117
|
+
}
|
|
118
|
+
for (let reverseIterator = size - 1; (carry > 0 || i < length) && reverseIterator !== -1; reverseIterator--, i++) {
|
|
119
|
+
carry += 58 * (output[reverseIterator] ?? 0);
|
|
120
|
+
output[reverseIterator] = Math.round(carry % 256);
|
|
121
|
+
carry = Math.floor(carry / 256);
|
|
122
|
+
}
|
|
123
|
+
length = i;
|
|
124
|
+
});
|
|
125
|
+
const validOutput = output.filter((item) => item !== undefined);
|
|
126
|
+
if (ones > 0) {
|
|
127
|
+
const onesResult = Array.from({ length: ones }).fill(0, 0, ones);
|
|
128
|
+
return new Uint8Array([...onesResult, ...validOutput]);
|
|
129
|
+
}
|
|
130
|
+
return new Uint8Array(validOutput);
|
|
131
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
+
export type { Uint8Array_ };
|
|
3
|
+
/**
|
|
4
|
+
* Converts data into a base64-encoded string.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
7
|
+
*
|
|
8
|
+
* @param data The data to encode.
|
|
9
|
+
* @returns The base64-encoded string.
|
|
10
|
+
*
|
|
11
|
+
* @example Usage
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { encodeBase64 } from "@std/encoding/base64";
|
|
14
|
+
* import { assertEquals } from "@std/assert";
|
|
15
|
+
*
|
|
16
|
+
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Decodes a base64-encoded string.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
24
|
+
*
|
|
25
|
+
* @param b64 The base64-encoded string to decode.
|
|
26
|
+
* @returns The decoded data.
|
|
27
|
+
*
|
|
28
|
+
* @example Usage
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { decodeBase64 } from "@std/encoding/base64";
|
|
31
|
+
* import { assertEquals } from "@std/assert";
|
|
32
|
+
*
|
|
33
|
+
* assertEquals(
|
|
34
|
+
* decodeBase64("Zm9vYmFy"),
|
|
35
|
+
* new TextEncoder().encode("foobar")
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function decodeBase64(b64: string): Uint8Array_;
|
|
40
|
+
//# sourceMappingURL=base64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/base64.ts"],"names":[],"mappings":"AA0BA,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,CAKrD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
/**
|
|
4
|
+
* Utilities for
|
|
5
|
+
* {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4 | base64}
|
|
6
|
+
* encoding and decoding.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import {
|
|
10
|
+
* encodeBase64,
|
|
11
|
+
* decodeBase64,
|
|
12
|
+
* } from "@std/encoding/base64";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
*
|
|
15
|
+
* const foobar = new TextEncoder().encode("foobar");
|
|
16
|
+
*
|
|
17
|
+
* assertEquals(encodeBase64(foobar), "Zm9vYmFy");
|
|
18
|
+
* assertEquals(decodeBase64("Zm9vYmFy"), foobar);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import { calcSizeBase64, decode, encode } from "./_common64.js";
|
|
24
|
+
import { detach } from "./_common_detach.js";
|
|
25
|
+
const padding = "=".charCodeAt(0);
|
|
26
|
+
const alphabet = new TextEncoder()
|
|
27
|
+
.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
|
28
|
+
const rAlphabet = new Uint8Array(128).fill(64); // alphabet.length
|
|
29
|
+
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
30
|
+
/**
|
|
31
|
+
* Converts data into a base64-encoded string.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
34
|
+
*
|
|
35
|
+
* @param data The data to encode.
|
|
36
|
+
* @returns The base64-encoded string.
|
|
37
|
+
*
|
|
38
|
+
* @example Usage
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { encodeBase64 } from "@std/encoding/base64";
|
|
41
|
+
* import { assertEquals } from "@std/assert";
|
|
42
|
+
*
|
|
43
|
+
* assertEquals(encodeBase64("foobar"), "Zm9vYmFy");
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function encodeBase64(data) {
|
|
47
|
+
if (typeof data === "string") {
|
|
48
|
+
data = new TextEncoder().encode(data);
|
|
49
|
+
}
|
|
50
|
+
else if (data instanceof ArrayBuffer)
|
|
51
|
+
data = new Uint8Array(data).slice();
|
|
52
|
+
else
|
|
53
|
+
data = data.slice();
|
|
54
|
+
const [output, i] = detach(data, calcSizeBase64(data.length));
|
|
55
|
+
encode(output, i, 0, alphabet, padding);
|
|
56
|
+
return new TextDecoder().decode(output);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Decodes a base64-encoded string.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4}
|
|
62
|
+
*
|
|
63
|
+
* @param b64 The base64-encoded string to decode.
|
|
64
|
+
* @returns The decoded data.
|
|
65
|
+
*
|
|
66
|
+
* @example Usage
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { decodeBase64 } from "@std/encoding/base64";
|
|
69
|
+
* import { assertEquals } from "@std/assert";
|
|
70
|
+
*
|
|
71
|
+
* assertEquals(
|
|
72
|
+
* decodeBase64("Zm9vYmFy"),
|
|
73
|
+
* new TextEncoder().encode("foobar")
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export function decodeBase64(b64) {
|
|
78
|
+
const output = new TextEncoder().encode(b64);
|
|
79
|
+
// deno-lint-ignore no-explicit-any
|
|
80
|
+
return new Uint8Array(output.buffer
|
|
81
|
+
.transfer(decode(output, 0, 0, rAlphabet, padding)));
|
|
82
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
+
export type { Uint8Array_ };
|
|
3
|
+
/**
|
|
4
|
+
* Converts data into a hex-encoded string.
|
|
5
|
+
*
|
|
6
|
+
* @param src The data to encode.
|
|
7
|
+
*
|
|
8
|
+
* @returns The hex-encoded string.
|
|
9
|
+
*
|
|
10
|
+
* @example Usage
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { encodeHex } from "@std/encoding/hex";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
*
|
|
15
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function encodeHex(src: string | Uint8Array | ArrayBuffer): string;
|
|
19
|
+
/**
|
|
20
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
21
|
+
* thrown.
|
|
22
|
+
*
|
|
23
|
+
* @param src The hex-encoded string to decode.
|
|
24
|
+
*
|
|
25
|
+
* @returns The decoded data.
|
|
26
|
+
*
|
|
27
|
+
* @example Usage
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { decodeHex } from "@std/encoding/hex";
|
|
30
|
+
* import { assertEquals } from "@std/assert";
|
|
31
|
+
*
|
|
32
|
+
* assertEquals(
|
|
33
|
+
* decodeHex("616263"),
|
|
34
|
+
* new TextEncoder().encode("abc"),
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeHex(src: string): Uint8Array_;
|
|
39
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/hex.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AAU5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAWxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAKlD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright 2009 The Go Authors. All rights reserved.
|
|
2
|
+
// https://github.com/golang/go/blob/master/LICENSE
|
|
3
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
/**
|
|
6
|
+
* Port of the Go
|
|
7
|
+
* {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
|
|
8
|
+
* library.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {
|
|
12
|
+
* decodeHex,
|
|
13
|
+
* encodeHex,
|
|
14
|
+
* } from "@std/encoding/hex";
|
|
15
|
+
* import { assertEquals } from "@std/assert";
|
|
16
|
+
*
|
|
17
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
18
|
+
*
|
|
19
|
+
* assertEquals(
|
|
20
|
+
* decodeHex("616263"),
|
|
21
|
+
* new TextEncoder().encode("abc"),
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
import { calcSizeHex, decode, encode } from "./_common16.js";
|
|
28
|
+
import { detach } from "./_common_detach.js";
|
|
29
|
+
const alphabet = new TextEncoder()
|
|
30
|
+
.encode("0123456789abcdef");
|
|
31
|
+
const rAlphabet = new Uint8Array(128).fill(16); // alphabet.length
|
|
32
|
+
alphabet.forEach((byte, i) => rAlphabet[byte] = i);
|
|
33
|
+
new TextEncoder()
|
|
34
|
+
.encode("ABCDEF")
|
|
35
|
+
.forEach((byte, i) => rAlphabet[byte] = i + 10);
|
|
36
|
+
/**
|
|
37
|
+
* Converts data into a hex-encoded string.
|
|
38
|
+
*
|
|
39
|
+
* @param src The data to encode.
|
|
40
|
+
*
|
|
41
|
+
* @returns The hex-encoded string.
|
|
42
|
+
*
|
|
43
|
+
* @example Usage
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { encodeHex } from "@std/encoding/hex";
|
|
46
|
+
* import { assertEquals } from "@std/assert";
|
|
47
|
+
*
|
|
48
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function encodeHex(src) {
|
|
52
|
+
if (typeof src === "string") {
|
|
53
|
+
src = new TextEncoder().encode(src);
|
|
54
|
+
}
|
|
55
|
+
else if (src instanceof ArrayBuffer)
|
|
56
|
+
src = new Uint8Array(src).slice();
|
|
57
|
+
else
|
|
58
|
+
src = src.slice();
|
|
59
|
+
const [output, i] = detach(src, calcSizeHex(src.length));
|
|
60
|
+
encode(output, i, 0, alphabet);
|
|
61
|
+
return new TextDecoder().decode(output);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
65
|
+
* thrown.
|
|
66
|
+
*
|
|
67
|
+
* @param src The hex-encoded string to decode.
|
|
68
|
+
*
|
|
69
|
+
* @returns The decoded data.
|
|
70
|
+
*
|
|
71
|
+
* @example Usage
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { decodeHex } from "@std/encoding/hex";
|
|
74
|
+
* import { assertEquals } from "@std/assert";
|
|
75
|
+
*
|
|
76
|
+
* assertEquals(
|
|
77
|
+
* decodeHex("616263"),
|
|
78
|
+
* new TextEncoder().encode("abc"),
|
|
79
|
+
* );
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function decodeHex(src) {
|
|
83
|
+
const output = new TextEncoder().encode(src);
|
|
84
|
+
// deno-lint-ignore no-explicit-any
|
|
85
|
+
return new Uint8Array(output.buffer
|
|
86
|
+
.transfer(decode(output, 0, 0, rAlphabet)));
|
|
87
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for encoding and decoding common formats like hex, base64, and varint.
|
|
3
|
+
*
|
|
4
|
+
* ## Basic Usage
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { encodeBase64, decodeBase64 } from "@std/encoding";
|
|
8
|
+
* import { assertEquals } from "@std/assert";
|
|
9
|
+
*
|
|
10
|
+
* const foobar = new TextEncoder().encode("foobar");
|
|
11
|
+
* assertEquals(encodeBase64(foobar), "Zm9vYmFy");
|
|
12
|
+
* assertEquals(decodeBase64("Zm9vYmFy"), foobar);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* ## Various Encoding Formats
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import {
|
|
19
|
+
* encodeHex,
|
|
20
|
+
* encodeBase32,
|
|
21
|
+
* encodeBase58,
|
|
22
|
+
* encodeBase64,
|
|
23
|
+
* encodeAscii85,
|
|
24
|
+
* decodeHex,
|
|
25
|
+
* decodeBase32,
|
|
26
|
+
* decodeBase58,
|
|
27
|
+
* decodeBase64,
|
|
28
|
+
* decodeAscii85,
|
|
29
|
+
* } from "@std/encoding";
|
|
30
|
+
* import { assertEquals } from "@std/assert";
|
|
31
|
+
*
|
|
32
|
+
* // Many different encodings for different character sets
|
|
33
|
+
* assertEquals(encodeHex("Hello world!"), "48656c6c6f20776f726c6421");
|
|
34
|
+
* assertEquals(encodeBase32("Hello world!"), "JBSWY3DPEB3W64TMMQQQ====");
|
|
35
|
+
* assertEquals(encodeBase58("Hello world!"), "2NEpo7TZRhna7vSvL");
|
|
36
|
+
* assertEquals(encodeBase64("Hello world!"), "SGVsbG8gd29ybGQh");
|
|
37
|
+
* assertEquals(encodeAscii85("Hello world!"), "87cURD]j7BEbo80");
|
|
38
|
+
*
|
|
39
|
+
* // Decoding
|
|
40
|
+
* assertEquals(new TextDecoder().decode(decodeHex("48656c6c6f20776f726c6421")), "Hello world!");
|
|
41
|
+
* assertEquals(new TextDecoder().decode(decodeBase32("JBSWY3DPEB3W64TMMQQQ====")), "Hello world!");
|
|
42
|
+
* assertEquals(new TextDecoder().decode(decodeBase58("2NEpo7TZRhna7vSvL")), "Hello world!");
|
|
43
|
+
* assertEquals(new TextDecoder().decode(decodeBase64("SGVsbG8gd29ybGQh")), "Hello world!");
|
|
44
|
+
* assertEquals(new TextDecoder().decode(decodeAscii85("87cURD]j7BEbo80")), "Hello world!");
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## URL-Safe Base64
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { encodeBase64, encodeBase64Url } from "@std/encoding";
|
|
51
|
+
* import { assertEquals } from "@std/assert";
|
|
52
|
+
*
|
|
53
|
+
* assertEquals(encodeBase64("ice creams"), "aWNlIGNyZWFtcw=="); // Not url-safe because of `=`
|
|
54
|
+
* assertEquals(encodeBase64Url("ice creams"), "aWNlIGNyZWFtcw"); // URL-safe!
|
|
55
|
+
*
|
|
56
|
+
* // Base64Url replaces + with - and / with _
|
|
57
|
+
* assertEquals(encodeBase64("subjects?"), "c3ViamVjdHM/"); // slash is not URL-safe
|
|
58
|
+
* assertEquals(encodeBase64Url("subjects?"), "c3ViamVjdHM_"); // _ is URL-safe
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ## Binary Data Encoding
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { encodeHex, encodeBase64 } from "@std/encoding";
|
|
65
|
+
* import { assertEquals } from "@std/assert";
|
|
66
|
+
*
|
|
67
|
+
* // Working with binary data
|
|
68
|
+
* const binaryData = new Uint8Array([0xDE, 0xAD, 0xBE, 0xEF]);
|
|
69
|
+
* assertEquals(encodeHex(binaryData), "deadbeef");
|
|
70
|
+
* assertEquals(encodeBase64(binaryData), "3q2+7w==");
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* ## Varint Encoding
|
|
74
|
+
*
|
|
75
|
+
* Learn more from the [protobuf Varint encoding docs](https://protobuf.dev/programming-guides/encoding/#varints).
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { encodeVarint, decodeVarint } from "@std/encoding";
|
|
79
|
+
* import { assertEquals } from "@std/assert";
|
|
80
|
+
*
|
|
81
|
+
* // Varint encoding support
|
|
82
|
+
* assertEquals(encodeVarint(9601n), [new Uint8Array([129, 75]), 2]);
|
|
83
|
+
*
|
|
84
|
+
* // Decode a varint
|
|
85
|
+
* const bytes = new Uint8Array([129, 75]);
|
|
86
|
+
* assertEquals(decodeVarint(bytes), [9601n, 2]);
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @module
|
|
90
|
+
*/
|
|
91
|
+
export * from "./ascii85.js";
|
|
92
|
+
export * from "./base32.js";
|
|
93
|
+
export * from "./base58.js";
|
|
94
|
+
export * from "./base64.js";
|
|
95
|
+
export * from "./base64url.js";
|
|
96
|
+
export * from "./hex.js";
|
|
97
|
+
export * from "./varint.js";
|
|
98
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.10/mod.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|