@skmtc/core 0.0.245 → 0.0.247

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 (81) hide show
  1. package/esm/context/CoreContext.d.ts +1 -1
  2. package/esm/context/CoreContext.d.ts.map +1 -1
  3. package/esm/context/CoreContext.js +2 -2
  4. package/esm/context/RenderContext.d.ts +4 -3
  5. package/esm/context/RenderContext.d.ts.map +1 -1
  6. package/esm/context/RenderContext.js +8 -34
  7. package/esm/context/types.d.ts +1 -0
  8. package/esm/context/types.d.ts.map +1 -1
  9. package/esm/generate/generate.d.ts +2 -1
  10. package/esm/generate/generate.d.ts.map +1 -1
  11. package/esm/generate/generate.js +2 -2
  12. package/esm/server/createServer.d.ts.map +1 -1
  13. package/esm/server/createServer.js +3 -2
  14. package/package.json +1 -2
  15. package/script/context/CoreContext.d.ts +1 -1
  16. package/script/context/CoreContext.d.ts.map +1 -1
  17. package/script/context/CoreContext.js +2 -2
  18. package/script/context/RenderContext.d.ts +4 -3
  19. package/script/context/RenderContext.d.ts.map +1 -1
  20. package/script/context/RenderContext.js +11 -37
  21. package/script/context/types.d.ts +1 -0
  22. package/script/context/types.d.ts.map +1 -1
  23. package/script/generate/generate.d.ts +2 -1
  24. package/script/generate/generate.d.ts.map +1 -1
  25. package/script/generate/generate.js +2 -2
  26. package/script/server/createServer.d.ts.map +1 -1
  27. package/script/server/createServer.js +3 -2
  28. package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts +0 -2
  29. package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts.map +0 -1
  30. package/esm/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.js +0 -26
  31. package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts +0 -59
  32. package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts.map +0 -1
  33. package/esm/deps/jsr.io/@std/encoding/1.0.1/ascii85.js +0 -152
  34. package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts +0 -38
  35. package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts.map +0 -1
  36. package/esm/deps/jsr.io/@std/encoding/1.0.1/base32.js +0 -224
  37. package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts +0 -38
  38. package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts.map +0 -1
  39. package/esm/deps/jsr.io/@std/encoding/1.0.1/base58.js +0 -131
  40. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts +0 -38
  41. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts.map +0 -1
  42. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64.js +0 -163
  43. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts +0 -38
  44. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts.map +0 -1
  45. package/esm/deps/jsr.io/@std/encoding/1.0.1/base64url.js +0 -81
  46. package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts +0 -37
  47. package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts.map +0 -1
  48. package/esm/deps/jsr.io/@std/encoding/1.0.1/hex.js +0 -109
  49. package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts +0 -22
  50. package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts.map +0 -1
  51. package/esm/deps/jsr.io/@std/encoding/1.0.1/mod.js +0 -22
  52. package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts +0 -118
  53. package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts.map +0 -1
  54. package/esm/deps/jsr.io/@std/encoding/1.0.1/varint.js +0 -206
  55. package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts +0 -2
  56. package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.d.ts.map +0 -1
  57. package/script/deps/jsr.io/@std/encoding/1.0.1/_validate_binary_like.js +0 -29
  58. package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts +0 -59
  59. package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.d.ts.map +0 -1
  60. package/script/deps/jsr.io/@std/encoding/1.0.1/ascii85.js +0 -156
  61. package/script/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts +0 -38
  62. package/script/deps/jsr.io/@std/encoding/1.0.1/base32.d.ts.map +0 -1
  63. package/script/deps/jsr.io/@std/encoding/1.0.1/base32.js +0 -228
  64. package/script/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts +0 -38
  65. package/script/deps/jsr.io/@std/encoding/1.0.1/base58.d.ts.map +0 -1
  66. package/script/deps/jsr.io/@std/encoding/1.0.1/base58.js +0 -135
  67. package/script/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts +0 -38
  68. package/script/deps/jsr.io/@std/encoding/1.0.1/base64.d.ts.map +0 -1
  69. package/script/deps/jsr.io/@std/encoding/1.0.1/base64.js +0 -167
  70. package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts +0 -38
  71. package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.d.ts.map +0 -1
  72. package/script/deps/jsr.io/@std/encoding/1.0.1/base64url.js +0 -108
  73. package/script/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts +0 -37
  74. package/script/deps/jsr.io/@std/encoding/1.0.1/hex.d.ts.map +0 -1
  75. package/script/deps/jsr.io/@std/encoding/1.0.1/hex.js +0 -113
  76. package/script/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts +0 -22
  77. package/script/deps/jsr.io/@std/encoding/1.0.1/mod.d.ts.map +0 -1
  78. package/script/deps/jsr.io/@std/encoding/1.0.1/mod.js +0 -38
  79. package/script/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts +0 -118
  80. package/script/deps/jsr.io/@std/encoding/1.0.1/varint.d.ts.map +0 -1
  81. package/script/deps/jsr.io/@std/encoding/1.0.1/varint.js +0 -212
@@ -1,59 +0,0 @@
1
- /**
2
- * Supported ascii85 standards for {@linkcode EncodeAscii85Options} and
3
- * {@linkcode DecodeAscii85Options}.
4
- */
5
- export type Ascii85Standard = "Adobe" | "btoa" | "RFC 1924" | "Z85";
6
- /** Options for {@linkcode encodeAscii85}. */
7
- export interface EncodeAscii85Options {
8
- /**
9
- * Character set and delimiter (if supported and used).
10
- *
11
- * @default {"Adobe"}
12
- */
13
- standard?: Ascii85Standard;
14
- /**
15
- * Whether to use a delimiter (if supported).
16
- *
17
- * @default {false}
18
- */
19
- delimiter?: boolean;
20
- }
21
- /**
22
- * Converts data into an ascii85-encoded string.
23
- *
24
- * @param data The data to encode.
25
- * @param options Options for encoding.
26
- *
27
- * @returns The ascii85-encoded string.
28
- *
29
- * @example Usage
30
- * ```ts
31
- * import { encodeAscii85 } from "@std/encoding/ascii85";
32
- * import { assertEquals } from "@std/assert";
33
- *
34
- * assertEquals(encodeAscii85("Hello world!"), "87cURD]j7BEbo80");
35
- * ```
36
- */
37
- export declare function encodeAscii85(data: ArrayBuffer | Uint8Array | string, options?: EncodeAscii85Options): string;
38
- /** Options for {@linkcode decodeAscii85}. */
39
- export type DecodeAscii85Options = Omit<EncodeAscii85Options, "delimiter">;
40
- /**
41
- * Decodes a ascii85-encoded string.
42
- *
43
- * @param ascii85 The ascii85-encoded string to decode.
44
- * @param options Options for decoding.
45
- * @returns The decoded data.
46
- *
47
- * @example Usage
48
- * ```ts
49
- * import { decodeAscii85 } from "@std/encoding/ascii85";
50
- * import { assertEquals } from "@std/assert";
51
- *
52
- * assertEquals(
53
- * decodeAscii85("87cURD]j7BEbo80"),
54
- * new TextEncoder().encode("Hello world!"),
55
- * );
56
- * ```
57
- */
58
- export declare function decodeAscii85(ascii85: string, options?: DecodeAscii85Options): Uint8Array;
59
- //# 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.1/ascii85.ts"],"names":[],"mappings":"AAyBA;;;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,UAAU,CA4CZ"}
@@ -1,152 +0,0 @@
1
- // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Utilities for working with {@link https://en.wikipedia.org/wiki/Ascii85 | ascii85} encoding.
5
- *
6
- * ## Specifying a standard and delimiter
7
- *
8
- * By default, all functions are using the most popular Adobe version of ascii85
9
- * and not adding any delimiter. However, there are three more standards
10
- * supported - btoa (different delimiter and additional compression of 4 bytes
11
- * equal to 32), {@link https://rfc.zeromq.org/spec/32/ | Z85} and
12
- * {@link https://www.rfc-editor.org/rfc/rfc1924.html | RFC 1924}. It's possible to use a
13
- * different encoding by specifying it in `options` object as a second parameter.
14
- *
15
- * Similarly, it's possible to make `encode` add a delimiter (`<~` and `~>` for
16
- * Adobe, `xbtoa Begin` and `xbtoa End` with newlines between the delimiters and
17
- * encoded data for btoa. Checksums for btoa are not supported. Delimiters are not
18
- * supported by other encodings.)
19
- *
20
- * @module
21
- */
22
- import { validateBinaryLike } from "./_validate_binary_like.js";
23
- const rfc1924 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
24
- const Z85 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#";
25
- /**
26
- * Converts data into an ascii85-encoded string.
27
- *
28
- * @param data The data to encode.
29
- * @param options Options for encoding.
30
- *
31
- * @returns The ascii85-encoded string.
32
- *
33
- * @example Usage
34
- * ```ts
35
- * import { encodeAscii85 } from "@std/encoding/ascii85";
36
- * import { assertEquals } from "@std/assert";
37
- *
38
- * assertEquals(encodeAscii85("Hello world!"), "87cURD]j7BEbo80");
39
- * ```
40
- */
41
- export function encodeAscii85(data, options = {}) {
42
- let uint8 = validateBinaryLike(data);
43
- const { standard = "Adobe" } = options;
44
- let output = [];
45
- let v;
46
- let n = 0;
47
- let difference = 0;
48
- if (uint8.length % 4 !== 0) {
49
- const tmp = uint8;
50
- difference = 4 - (tmp.length % 4);
51
- uint8 = new Uint8Array(tmp.length + difference);
52
- uint8.set(tmp);
53
- }
54
- const view = new DataView(uint8.buffer, uint8.byteOffset, uint8.byteLength);
55
- for (let i = 0; i < uint8.length; i += 4) {
56
- v = view.getUint32(i);
57
- // Adobe and btoa standards compress 4 zeroes to single "z" character
58
- if ((standard === "Adobe" || standard === "btoa") &&
59
- v === 0 &&
60
- i < uint8.length - difference - 3) {
61
- output[n++] = "z";
62
- continue;
63
- }
64
- // btoa compresses 4 spaces - that is, bytes equal to 32 - into single "y" character
65
- if (standard === "btoa" && v === 538976288) {
66
- output[n++] = "y";
67
- continue;
68
- }
69
- for (let j = 4; j >= 0; j--) {
70
- output[n + j] = String.fromCharCode((v % 85) + 33);
71
- v = Math.trunc(v / 85);
72
- }
73
- n += 5;
74
- }
75
- switch (standard) {
76
- case "Adobe":
77
- if (options?.delimiter) {
78
- return `<~${output.slice(0, output.length - difference).join("")}~>`;
79
- }
80
- break;
81
- case "btoa":
82
- if (options?.delimiter) {
83
- return `xbtoa Begin\n${output
84
- .slice(0, output.length - difference)
85
- .join("")}\nxbtoa End`;
86
- }
87
- break;
88
- case "RFC 1924":
89
- output = output.map((val) => rfc1924[val.charCodeAt(0) - 33]);
90
- break;
91
- case "Z85":
92
- output = output.map((val) => Z85[val.charCodeAt(0) - 33]);
93
- break;
94
- }
95
- return output.slice(0, output.length - difference).join("");
96
- }
97
- /**
98
- * Decodes a ascii85-encoded string.
99
- *
100
- * @param ascii85 The ascii85-encoded string to decode.
101
- * @param options Options for decoding.
102
- * @returns The decoded data.
103
- *
104
- * @example Usage
105
- * ```ts
106
- * import { decodeAscii85 } from "@std/encoding/ascii85";
107
- * import { assertEquals } from "@std/assert";
108
- *
109
- * assertEquals(
110
- * decodeAscii85("87cURD]j7BEbo80"),
111
- * new TextEncoder().encode("Hello world!"),
112
- * );
113
- * ```
114
- */
115
- export function decodeAscii85(ascii85, options = {}) {
116
- const { standard = "Adobe" } = options;
117
- // translate all encodings to most basic adobe/btoa one and decompress some special characters ("z" and "y")
118
- switch (standard) {
119
- case "Adobe":
120
- ascii85 = ascii85.replaceAll(/(<~|~>)/g, "").replaceAll("z", "!!!!!");
121
- break;
122
- case "btoa":
123
- ascii85 = ascii85
124
- .replaceAll(/(xbtoa Begin|xbtoa End|\n)/g, "")
125
- .replaceAll("z", "!!!!!")
126
- .replaceAll("y", "+<VdL");
127
- break;
128
- case "RFC 1924":
129
- ascii85 = ascii85.replaceAll(/./g, (match) => String.fromCharCode(rfc1924.indexOf(match) + 33));
130
- break;
131
- case "Z85":
132
- ascii85 = ascii85.replaceAll(/./g, (match) => String.fromCharCode(Z85.indexOf(match) + 33));
133
- break;
134
- }
135
- // remove all invalid characters
136
- ascii85 = ascii85.replaceAll(/[^!-u]/g, "");
137
- const len = ascii85.length;
138
- const output = new Uint8Array(len + 4 - (len % 4));
139
- const view = new DataView(output.buffer);
140
- let v = 0;
141
- let n = 0;
142
- let max = 0;
143
- for (let i = 0; i < len;) {
144
- for (max += 5; i < max; i++) {
145
- v = v * 85 + (i < len ? ascii85.charCodeAt(i) : 117) - 33;
146
- }
147
- view.setUint32(n, v);
148
- v = 0;
149
- n += 4;
150
- }
151
- return output.slice(0, Math.trunc(len * 0.8));
152
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Decodes a base32-encoded string.
3
- *
4
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
5
- *
6
- * @param b32 The base32-encoded string to decode.
7
- * @returns The decoded data.
8
- *
9
- * @example Usage
10
- * ```ts
11
- * import { decodeBase32 } from "@std/encoding/base32";
12
- * import { assertEquals } from "@std/assert";
13
- *
14
- * assertEquals(
15
- * decodeBase32("GZRTMMDDGA======"),
16
- * new TextEncoder().encode("6c60c0"),
17
- * );
18
- * ```
19
- */
20
- export declare function decodeBase32(b32: string): Uint8Array;
21
- /**
22
- * Converts data into a base32-encoded string.
23
- *
24
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
25
- *
26
- * @param data The data to encode.
27
- * @returns The base32-encoded string.
28
- *
29
- * @example Usage
30
- * ```ts
31
- * import { encodeBase32 } from "@std/encoding/base32";
32
- * import { assertEquals } from "@std/assert";
33
- *
34
- * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
35
- * ```
36
- */
37
- export declare function encodeBase32(data: ArrayBuffer | Uint8Array | string): string;
38
- //# 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.1/base32.ts"],"names":[],"mappings":"AA6DA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAkEpD;AAwBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CA6D5E"}
@@ -1,224 +0,0 @@
1
- // Copyright 2018-2024 the Deno authors. All rights reserved. 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 { validateBinaryLike } from "./_validate_binary_like.js";
26
- const lookup = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split("");
27
- const revLookup = [];
28
- lookup.forEach((c, i) => revLookup[c.charCodeAt(0)] = i);
29
- const placeHolderPadLookup = [0, 1, , 2, 3, , 4];
30
- function getPadLength(placeHoldersLen) {
31
- const maybeLen = placeHolderPadLookup[placeHoldersLen];
32
- if (typeof maybeLen !== "number") {
33
- throw new Error("Invalid pad length");
34
- }
35
- return maybeLen;
36
- }
37
- function getLens(b32) {
38
- const len = b32.length;
39
- if (len % 8 > 0) {
40
- throw new Error("Invalid string. Length must be a multiple of 8");
41
- }
42
- let validLen = b32.indexOf("=");
43
- if (validLen === -1)
44
- validLen = len;
45
- const placeHoldersLen = validLen === len ? 0 : 8 - (validLen % 8);
46
- return [validLen, placeHoldersLen];
47
- }
48
- function getByteLength(validLen, placeHoldersLen) {
49
- return ((validLen + placeHoldersLen) * 5) / 8 - getPadLength(placeHoldersLen);
50
- }
51
- /**
52
- * Decodes a base32-encoded string.
53
- *
54
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
55
- *
56
- * @param b32 The base32-encoded string to decode.
57
- * @returns The decoded data.
58
- *
59
- * @example Usage
60
- * ```ts
61
- * import { decodeBase32 } from "@std/encoding/base32";
62
- * import { assertEquals } from "@std/assert";
63
- *
64
- * assertEquals(
65
- * decodeBase32("GZRTMMDDGA======"),
66
- * new TextEncoder().encode("6c60c0"),
67
- * );
68
- * ```
69
- */
70
- export function decodeBase32(b32) {
71
- let tmp;
72
- const [validLen, placeHoldersLen] = getLens(b32);
73
- const arr = new Uint8Array(getByteLength(validLen, placeHoldersLen));
74
- let curByte = 0;
75
- // if there are placeholders, only get up to the last complete 8 chars
76
- const len = placeHoldersLen > 0 ? validLen - 8 : validLen;
77
- let i;
78
- for (i = 0; i < len; i += 8) {
79
- tmp = (revLookup[b32.charCodeAt(i)] << 20) |
80
- (revLookup[b32.charCodeAt(i + 1)] << 15) |
81
- (revLookup[b32.charCodeAt(i + 2)] << 10) |
82
- (revLookup[b32.charCodeAt(i + 3)] << 5) |
83
- revLookup[b32.charCodeAt(i + 4)];
84
- arr[curByte++] = (tmp >> 17) & 0xff;
85
- arr[curByte++] = (tmp >> 9) & 0xff;
86
- arr[curByte++] = (tmp >> 1) & 0xff;
87
- tmp = ((tmp & 1) << 15) |
88
- (revLookup[b32.charCodeAt(i + 5)] << 10) |
89
- (revLookup[b32.charCodeAt(i + 6)] << 5) |
90
- revLookup[b32.charCodeAt(i + 7)];
91
- arr[curByte++] = (tmp >> 8) & 0xff;
92
- arr[curByte++] = tmp & 0xff;
93
- }
94
- if (placeHoldersLen === 1) {
95
- tmp = (revLookup[b32.charCodeAt(i)] << 20) |
96
- (revLookup[b32.charCodeAt(i + 1)] << 15) |
97
- (revLookup[b32.charCodeAt(i + 2)] << 10) |
98
- (revLookup[b32.charCodeAt(i + 3)] << 5) |
99
- revLookup[b32.charCodeAt(i + 4)];
100
- arr[curByte++] = (tmp >> 17) & 0xff;
101
- arr[curByte++] = (tmp >> 9) & 0xff;
102
- arr[curByte++] = (tmp >> 1) & 0xff;
103
- tmp = ((tmp & 1) << 7) |
104
- (revLookup[b32.charCodeAt(i + 5)] << 2) |
105
- (revLookup[b32.charCodeAt(i + 6)] >> 3);
106
- arr[curByte++] = tmp & 0xff;
107
- }
108
- else if (placeHoldersLen === 3) {
109
- tmp = (revLookup[b32.charCodeAt(i)] << 19) |
110
- (revLookup[b32.charCodeAt(i + 1)] << 14) |
111
- (revLookup[b32.charCodeAt(i + 2)] << 9) |
112
- (revLookup[b32.charCodeAt(i + 3)] << 4) |
113
- (revLookup[b32.charCodeAt(i + 4)] >> 1);
114
- arr[curByte++] = (tmp >> 16) & 0xff;
115
- arr[curByte++] = (tmp >> 8) & 0xff;
116
- arr[curByte++] = tmp & 0xff;
117
- }
118
- else if (placeHoldersLen === 4) {
119
- tmp = (revLookup[b32.charCodeAt(i)] << 11) |
120
- (revLookup[b32.charCodeAt(i + 1)] << 6) |
121
- (revLookup[b32.charCodeAt(i + 2)] << 1) |
122
- (revLookup[b32.charCodeAt(i + 3)] >> 4);
123
- arr[curByte++] = (tmp >> 8) & 0xff;
124
- arr[curByte++] = tmp & 0xff;
125
- }
126
- else if (placeHoldersLen === 6) {
127
- tmp = (revLookup[b32.charCodeAt(i)] << 3) |
128
- (revLookup[b32.charCodeAt(i + 1)] >> 2);
129
- arr[curByte++] = tmp & 0xff;
130
- }
131
- return arr;
132
- }
133
- function encodeChunk(uint8, start, end) {
134
- let tmp;
135
- const output = [];
136
- for (let i = start; i < end; i += 5) {
137
- tmp = ((uint8[i] << 16) & 0xff0000) |
138
- ((uint8[i + 1] << 8) & 0xff00) |
139
- (uint8[i + 2] & 0xff);
140
- output.push(lookup[(tmp >> 19) & 0x1f]);
141
- output.push(lookup[(tmp >> 14) & 0x1f]);
142
- output.push(lookup[(tmp >> 9) & 0x1f]);
143
- output.push(lookup[(tmp >> 4) & 0x1f]);
144
- tmp = ((tmp & 0xf) << 16) |
145
- ((uint8[i + 3] << 8) & 0xff00) |
146
- (uint8[i + 4] & 0xff);
147
- output.push(lookup[(tmp >> 15) & 0x1f]);
148
- output.push(lookup[(tmp >> 10) & 0x1f]);
149
- output.push(lookup[(tmp >> 5) & 0x1f]);
150
- output.push(lookup[tmp & 0x1f]);
151
- }
152
- return output.join("");
153
- }
154
- /**
155
- * Converts data into a base32-encoded string.
156
- *
157
- * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-6}
158
- *
159
- * @param data The data to encode.
160
- * @returns The base32-encoded string.
161
- *
162
- * @example Usage
163
- * ```ts
164
- * import { encodeBase32 } from "@std/encoding/base32";
165
- * import { assertEquals } from "@std/assert";
166
- *
167
- * assertEquals(encodeBase32("6c60c0"), "GZRTMMDDGA======");
168
- * ```
169
- */
170
- export function encodeBase32(data) {
171
- const uint8 = validateBinaryLike(data);
172
- let tmp;
173
- const len = uint8.length;
174
- const extraBytes = len % 5;
175
- const parts = [];
176
- const maxChunkLength = 16385; // must be multiple of 5
177
- const len2 = len - extraBytes;
178
- // go through the array every 5 bytes, we'll deal with trailing stuff later
179
- for (let i = 0; i < len2; i += maxChunkLength) {
180
- parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
181
- }
182
- // pad the end with zeros, but make sure to not forget the extra bytes
183
- if (extraBytes === 4) {
184
- tmp = ((uint8[len2] & 0xff) << 16) |
185
- ((uint8[len2 + 1] & 0xff) << 8) |
186
- (uint8[len2 + 2] & 0xff);
187
- parts.push(lookup[(tmp >> 19) & 0x1f]);
188
- parts.push(lookup[(tmp >> 14) & 0x1f]);
189
- parts.push(lookup[(tmp >> 9) & 0x1f]);
190
- parts.push(lookup[(tmp >> 4) & 0x1f]);
191
- tmp = ((tmp & 0xf) << 11) | (uint8[len2 + 3] << 3);
192
- parts.push(lookup[(tmp >> 10) & 0x1f]);
193
- parts.push(lookup[(tmp >> 5) & 0x1f]);
194
- parts.push(lookup[tmp & 0x1f]);
195
- parts.push("=");
196
- }
197
- else if (extraBytes === 3) {
198
- tmp = ((uint8[len2] & 0xff) << 17) |
199
- ((uint8[len2 + 1] & 0xff) << 9) |
200
- ((uint8[len2 + 2] & 0xff) << 1);
201
- parts.push(lookup[(tmp >> 20) & 0x1f]);
202
- parts.push(lookup[(tmp >> 15) & 0x1f]);
203
- parts.push(lookup[(tmp >> 10) & 0x1f]);
204
- parts.push(lookup[(tmp >> 5) & 0x1f]);
205
- parts.push(lookup[tmp & 0x1f]);
206
- parts.push("===");
207
- }
208
- else if (extraBytes === 2) {
209
- tmp = ((uint8[len2] & 0xff) << 12) |
210
- ((uint8[len2 + 1] & 0xff) << 4);
211
- parts.push(lookup[(tmp >> 15) & 0x1f]);
212
- parts.push(lookup[(tmp >> 10) & 0x1f]);
213
- parts.push(lookup[(tmp >> 5) & 0x1f]);
214
- parts.push(lookup[tmp & 0x1f]);
215
- parts.push("====");
216
- }
217
- else if (extraBytes === 1) {
218
- tmp = (uint8[len2] & 0xff) << 2;
219
- parts.push(lookup[(tmp >> 5) & 0x1f]);
220
- parts.push(lookup[tmp & 0x1f]);
221
- parts.push("======");
222
- }
223
- return parts.join("");
224
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Converts data into a base58-encoded string.
3
- *
4
- * @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-3}
5
- *
6
- * @param data The data to encode.
7
- * @returns The base58-encoded string.
8
- *
9
- * @example Usage
10
- * ```ts
11
- * import { encodeBase58 } from "@std/encoding/base58";
12
- * import { assertEquals } from "@std/assert";
13
- *
14
- * assertEquals(encodeBase58("Hello World!"), "2NEpo7TZRRrLZSi2U");
15
- * ```
16
- */
17
- export declare function encodeBase58(data: ArrayBuffer | Uint8Array | string): string;
18
- /**
19
- * Decodes a base58-encoded string.
20
- *
21
- * @see {@link https://datatracker.ietf.org/doc/html/draft-msporny-base58-03#section-4}
22
- *
23
- * @param b58 The base58-encoded string to decode.
24
- * @returns The decoded data.
25
- *
26
- * @example Usage
27
- * ```ts
28
- * import { decodeBase58 } from "@std/encoding/base58";
29
- * import { assertEquals } from "@std/assert";
30
- *
31
- * assertEquals(
32
- * decodeBase58("2NEpo7TZRRrLZSi2U"),
33
- * new TextEncoder().encode("Hello World!")
34
- * );
35
- * ```
36
- */
37
- export declare function decodeBase58(b58: string): Uint8Array;
38
- //# 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.1/base58.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;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,UAAU,CAkDpD"}
@@ -1,131 +0,0 @@
1
- // Copyright 2018-2024 the Deno authors. All rights reserved. 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
- }