@latticexyz/utils 2.0.0-alpha.1.21 → 2.0.0-alpha.1.211
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/dist/index.js +2 -995
- package/dist/index.js.map +1 -1
- package/package.json +20 -33
- package/src/CoordMap.spec.ts +57 -0
- package/src/CoordMap.ts +106 -0
- package/src/VoxelCoordMap.ts +76 -0
- package/src/area.ts +15 -0
- package/{dist/arrays.d.ts → src/arrays.ts} +8 -2
- package/src/bytes.spec.ts +77 -0
- package/src/bytes.ts +85 -0
- package/src/console.ts +62 -0
- package/src/cubic.spec.ts +14 -0
- package/src/cubic.ts +109 -0
- package/src/deferred.ts +14 -0
- package/src/distance.ts +11 -0
- package/src/enums.ts +13 -0
- package/src/eth.ts +42 -0
- package/src/guards.ts +10 -0
- package/src/hash.ts +20 -0
- package/{dist/index.d.ts → src/index.ts} +13 -1
- package/src/iterable.spec.ts +56 -0
- package/src/iterable.ts +59 -0
- package/{dist/math.d.ts → src/math.ts} +4 -1
- package/src/mobx.ts +26 -0
- package/src/objects.ts +16 -0
- package/src/pack.spec.ts +37 -0
- package/src/pack.ts +61 -0
- package/src/promise.ts +46 -0
- package/src/proxy.spec.ts +186 -0
- package/src/proxy.ts +101 -0
- package/{dist/random.d.ts → src/random.ts} +7 -2
- package/src/rx.spec.ts +45 -0
- package/src/rx.ts +124 -0
- package/src/sleep.ts +3 -0
- package/src/types.ts +48 -0
- package/src/uuid.ts +70 -0
- package/src/v2/TableId.ts +49 -0
- package/src/v2/arrayToHex.ts +3 -0
- package/src/v2/bytesToString.ts +1 -0
- package/src/v2/getTableIds.ts +10 -0
- package/src/v2/hexToArray.ts +12 -0
- package/{dist/v2/index.d.ts → src/v2/index.ts} +3 -1
- package/src/v2/isDefined.ts +3 -0
- package/src/v2/isHex.ts +6 -0
- package/src/v2/isNotNull.ts +3 -0
- package/src/v2/stringToBytes.ts +9 -0
- package/src/worker.ts +16 -0
- package/dist/CoordMap.d.ts +0 -26
- package/dist/VoxelCoordMap.d.ts +0 -23
- package/dist/area.d.ts +0 -3
- package/dist/bytes.d.ts +0 -10
- package/dist/console.d.ts +0 -52
- package/dist/cubic.d.ts +0 -32
- package/dist/deferred.d.ts +0 -5
- package/dist/distance.d.ts +0 -8
- package/dist/enums.d.ts +0 -5
- package/dist/eth.d.ts +0 -22
- package/dist/guards.d.ts +0 -3
- package/dist/hash.d.ts +0 -8
- package/dist/iterable.d.ts +0 -10
- package/dist/mobx.d.ts +0 -6
- package/dist/objects.d.ts +0 -11
- package/dist/pack.d.ts +0 -16
- package/dist/promise.d.ts +0 -4
- package/dist/proxy.d.ts +0 -8
- package/dist/rx.d.ts +0 -30
- package/dist/sleep.d.ts +0 -1
- package/dist/types.d.ts +0 -40
- package/dist/uuid.d.ts +0 -19
- package/dist/v2/TableId.d.ts +0 -10
- package/dist/v2/arrayToHex.d.ts +0 -1
- package/dist/v2/bytesToString.d.ts +0 -1
- package/dist/v2/hexToArray.d.ts +0 -1
- package/dist/v2/isDefined.d.ts +0 -1
- package/dist/v2/isHex.d.ts +0 -1
- package/dist/v2/stringToBytes16.d.ts +0 -1
- package/dist/worker.d.ts +0 -6
package/src/uuid.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID.core.js - UUID.js for Minimalists
|
|
3
|
+
*
|
|
4
|
+
* @file
|
|
5
|
+
* @author LiosK
|
|
6
|
+
* @version v4.2.0
|
|
7
|
+
* @license Apache License 2.0: Copyright (c) 2010-2018 LiosK
|
|
8
|
+
* @url https://github.com/LiosK/UUID.js/blob/master/src/uuid.core.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @class
|
|
13
|
+
* @classdesc {@link UUID} object.
|
|
14
|
+
* @hideconstructor
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Core Component {{{
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generates a version 4 UUID as a hexadecimal string.
|
|
21
|
+
* @returns {string} Hexadecimal UUID string.
|
|
22
|
+
*/
|
|
23
|
+
export const uuid = function () {
|
|
24
|
+
const rand = _getRandomInt,
|
|
25
|
+
hex = _hexAligner;
|
|
26
|
+
return (
|
|
27
|
+
hex(rand(32), 8) + // time_low
|
|
28
|
+
"-" +
|
|
29
|
+
hex(rand(16), 4) + // time_mid
|
|
30
|
+
"-" +
|
|
31
|
+
hex(0x4000 | rand(12), 4) + // time_hi_and_version
|
|
32
|
+
"-" +
|
|
33
|
+
hex(0x8000 | rand(14), 4) + // clock_seq_hi_and_reserved clock_seq_low
|
|
34
|
+
"-" +
|
|
35
|
+
hex(rand(48), 12)
|
|
36
|
+
); // node
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns an unsigned x-bit random integer.
|
|
41
|
+
* @private
|
|
42
|
+
* @param {number} x Unsigned integer ranging from 0 to 53, inclusive.
|
|
43
|
+
* @returns {number} Unsigned x-bit random integer (0 <= f(x) < 2^x).
|
|
44
|
+
*/
|
|
45
|
+
const _getRandomInt = function (x: number) {
|
|
46
|
+
if (x < 0 || x > 53) {
|
|
47
|
+
return NaN;
|
|
48
|
+
}
|
|
49
|
+
const n = 0 | (Math.random() * 0x40000000); // 1 << 30
|
|
50
|
+
return x > 30 ? n + (0 | (Math.random() * (1 << (x - 30)))) * 0x40000000 : n >>> (30 - x);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts an integer to a zero-filled hexadecimal string.
|
|
55
|
+
* @private
|
|
56
|
+
* @param {number} num
|
|
57
|
+
* @param {number} length
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
const _hexAligner = function (num: number, length: number) {
|
|
61
|
+
let str = num.toString(16),
|
|
62
|
+
i = length - str.length,
|
|
63
|
+
z = "0";
|
|
64
|
+
for (; i > 0; i >>>= 1, z += z) {
|
|
65
|
+
if (i & 1) {
|
|
66
|
+
str = z + str;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return str;
|
|
70
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { arrayToHex } from "./arrayToHex";
|
|
2
|
+
import { bytesToString } from "./bytesToString";
|
|
3
|
+
import { hexToArray } from "./hexToArray";
|
|
4
|
+
import { stringToBytes16 } from "./stringToBytes";
|
|
5
|
+
|
|
6
|
+
export class TableId {
|
|
7
|
+
namespace: string;
|
|
8
|
+
name: string;
|
|
9
|
+
|
|
10
|
+
constructor(namespace: string, name: string) {
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.name = name;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
toString() {
|
|
16
|
+
return `TableId<${this.namespace || "[empty]"}:${this.name || "[empty]"}>`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toHexString() {
|
|
20
|
+
return TableId.toHexString(this.namespace, this.name);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static toHexString(namespace: string, name: string) {
|
|
24
|
+
const tableId = new Uint8Array(32);
|
|
25
|
+
tableId.set(stringToBytes16(namespace), 0);
|
|
26
|
+
tableId.set(stringToBytes16(name), 16);
|
|
27
|
+
return arrayToHex(tableId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static fromHexString(tableId: string) {
|
|
31
|
+
return TableId.fromBytes32(hexToArray(tableId));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromBytes32(tableId: Uint8Array) {
|
|
35
|
+
const tableIdBytes = new Uint8Array(32);
|
|
36
|
+
tableIdBytes.set(tableId);
|
|
37
|
+
const namespace = bytesToString(tableIdBytes.slice(0, 16)).replace(/\0+$/, "");
|
|
38
|
+
const name = bytesToString(tableIdBytes.slice(16, 32)).replace(/\0+$/, "");
|
|
39
|
+
return new TableId(namespace, name);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @deprecated Don't use this! This is a temporary hack for v2<>v1 compatibility until we can write v2 client libraries. This is here so it stays close to the formatting of `toString()` above. */
|
|
43
|
+
static parse(tableIdString: string) {
|
|
44
|
+
const match = tableIdString.match(/^TableId<(.+?):(.+?)>$/);
|
|
45
|
+
if (!match) return null;
|
|
46
|
+
const [, namespace, name] = match;
|
|
47
|
+
return new TableId(namespace === "[empty]" ? "" : namespace, name === "[empty]" ? "" : name);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const bytesToString = (bytes: Uint8Array): string => [...bytes].map((x) => String.fromCharCode(x)).join("");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TableId } from "./TableId";
|
|
2
|
+
|
|
3
|
+
const STORE_SELECTOR_MAX_LENGTH = 16;
|
|
4
|
+
|
|
5
|
+
export function getTableIds(config: { namespace: string; tables: { [key: string]: unknown } }) {
|
|
6
|
+
return Object.keys(config.tables).map(
|
|
7
|
+
(table) =>
|
|
8
|
+
new TableId(config.namespace.slice(0, STORE_SELECTOR_MAX_LENGTH), table.slice(0, STORE_SELECTOR_MAX_LENGTH))
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isHex } from "./isHex";
|
|
2
|
+
|
|
3
|
+
// TODO: migrate to viem's toBytes(hex)
|
|
4
|
+
export const hexToArray = (hex: string): Uint8Array => {
|
|
5
|
+
if (!isHex(hex)) {
|
|
6
|
+
console.error("Invalid hex string", hex);
|
|
7
|
+
throw new Error("Invalid hex string");
|
|
8
|
+
}
|
|
9
|
+
const bytes = hex.match(/[\da-f]{2}/gi);
|
|
10
|
+
if (!bytes) return new Uint8Array([]);
|
|
11
|
+
return new Uint8Array(bytes.map((byte) => parseInt(byte, 16)));
|
|
12
|
+
};
|
|
@@ -2,6 +2,8 @@ export * from "./arrayToHex";
|
|
|
2
2
|
export * from "./bytesToString";
|
|
3
3
|
export * from "./hexToArray";
|
|
4
4
|
export * from "./isDefined";
|
|
5
|
+
export * from "./isNotNull";
|
|
5
6
|
export * from "./isHex";
|
|
6
|
-
export * from "./
|
|
7
|
+
export * from "./stringToBytes";
|
|
7
8
|
export * from "./TableId";
|
|
9
|
+
export * from "./getTableIds";
|
package/src/v2/isHex.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// TODO: migrate to viem's isHex()
|
|
2
|
+
// Note that this assumes hex pairs, but viem does not. We'll need to be careful migrating.
|
|
3
|
+
// Padding an odd-length hex sounds scary (based on how Solidity left/right aligns numbers vs bytes/strings).
|
|
4
|
+
export function isHex(hex: string): boolean {
|
|
5
|
+
return /^(0x)?([\da-f]{2})*$/i.test(hex);
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const stringToBytes16 = (str: string): Uint8Array => {
|
|
2
|
+
if (str.length > 16) throw new Error("string too long");
|
|
3
|
+
return new Uint8Array(16).map((v, i) => str.charCodeAt(i));
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const stringToBytes32 = (str: string): Uint8Array => {
|
|
7
|
+
if (str.length > 32) throw new Error("string too long");
|
|
8
|
+
return new Uint8Array(32).map((v, i) => str.charCodeAt(i));
|
|
9
|
+
};
|
package/src/worker.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fromEvent, map, Observable } from "rxjs";
|
|
2
|
+
|
|
3
|
+
export interface DoWork<In, Out> {
|
|
4
|
+
work(input$: Observable<In>): Observable<Out>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function fromWorker<I, O>(worker: Worker, input$: Observable<I>): Observable<O> {
|
|
8
|
+
input$.subscribe((event) => worker.postMessage(event));
|
|
9
|
+
return fromEvent<MessageEvent<O>>(worker, "message").pipe(map((e) => e.data));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function runWorker<I, O>(worker: DoWork<I, O>) {
|
|
13
|
+
const input$ = fromEvent<MessageEvent<I>>(self, "message");
|
|
14
|
+
const output$ = worker.work(input$.pipe(map((event) => event.data)));
|
|
15
|
+
output$.subscribe((event) => self.postMessage(event));
|
|
16
|
+
}
|
package/dist/CoordMap.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Coord } from "./types";
|
|
2
|
-
export declare function subtract(from: CoordMap<boolean>, subtract: CoordMap<boolean>): CoordMap<boolean>;
|
|
3
|
-
export declare function coordToKey(coord: Coord): number;
|
|
4
|
-
export declare function keyToCoord(key: number): Coord;
|
|
5
|
-
export declare class CoordMap<T> {
|
|
6
|
-
map: Map<number, T>;
|
|
7
|
-
defaultValue?: T;
|
|
8
|
-
constructor(props?: {
|
|
9
|
-
defaultValue?: T;
|
|
10
|
-
});
|
|
11
|
-
static from<T>(coordMapLike: {
|
|
12
|
-
map: Map<number, T>;
|
|
13
|
-
defaultValue?: T;
|
|
14
|
-
}): CoordMap<T>;
|
|
15
|
-
set(coord: Coord, value: T): Map<number, T>;
|
|
16
|
-
get(coord: Coord): T | undefined;
|
|
17
|
-
keys(): IterableIterator<number>;
|
|
18
|
-
coords(): IterableIterator<Coord>;
|
|
19
|
-
entries(): IterableIterator<[number, T]>;
|
|
20
|
-
toArray(): [Coord, T][];
|
|
21
|
-
values(): IterableIterator<T>;
|
|
22
|
-
delete(coord: Coord): boolean;
|
|
23
|
-
has(coord: Coord): boolean;
|
|
24
|
-
clear(): void;
|
|
25
|
-
get size(): number;
|
|
26
|
-
}
|
package/dist/VoxelCoordMap.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { VoxelCoord } from "./types";
|
|
2
|
-
export declare class VoxelCoordMap<T> {
|
|
3
|
-
map: Map<string, T>;
|
|
4
|
-
defaultValue?: T;
|
|
5
|
-
constructor(props?: {
|
|
6
|
-
defaultValue?: T;
|
|
7
|
-
});
|
|
8
|
-
static from<T>(coordMapLike: {
|
|
9
|
-
map: Map<string, T>;
|
|
10
|
-
defaultValue?: T;
|
|
11
|
-
}): VoxelCoordMap<T>;
|
|
12
|
-
set(coord: VoxelCoord, value: T): Map<string, T>;
|
|
13
|
-
get(coord: VoxelCoord): T | undefined;
|
|
14
|
-
keys(): IterableIterator<string>;
|
|
15
|
-
coords(): IterableIterator<VoxelCoord>;
|
|
16
|
-
entries(): IterableIterator<[string, T]>;
|
|
17
|
-
toArray(): [VoxelCoord, T][];
|
|
18
|
-
values(): IterableIterator<T>;
|
|
19
|
-
delete(coord: VoxelCoord): boolean;
|
|
20
|
-
has(coord: VoxelCoord): boolean;
|
|
21
|
-
clear(): void;
|
|
22
|
-
get size(): number;
|
|
23
|
-
}
|
package/dist/area.d.ts
DELETED
package/dist/bytes.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function formatHex(hex: string): string;
|
|
2
|
-
export declare function hexStringToUint8Array(hexString: string): Uint8Array;
|
|
3
|
-
export declare function Uint8ArrayToHexString(data: Uint8Array): string;
|
|
4
|
-
export declare function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array;
|
|
5
|
-
export declare function splitUint8Arrays(data: Uint8Array, byteLengths: number[]): Uint8Array[];
|
|
6
|
-
export declare function Int32ArrayToUint8Array(input: number[]): Uint8Array;
|
|
7
|
-
export declare function Uint8ArrayToInt32Array(input: Uint8Array): number[];
|
|
8
|
-
export declare function ethAddressToUint8Array(address: string): Uint8Array;
|
|
9
|
-
export declare function createToInt(size: number): (value: number) => number;
|
|
10
|
-
export declare const toInt32: (value: number) => number;
|
package/dist/console.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
export declare function enableLogger(): {
|
|
4
|
-
log: (...logs: string[]) => void;
|
|
5
|
-
logWithTopic: (topic: string, ...logs: string[]) => void;
|
|
6
|
-
enableFilters: () => void;
|
|
7
|
-
disableFilters: () => void;
|
|
8
|
-
addTopic: (topic: string) => void;
|
|
9
|
-
removeTopic: (topic: string) => void;
|
|
10
|
-
resetTopics: () => void;
|
|
11
|
-
assert(condition?: boolean | undefined, ...data: any[]): void;
|
|
12
|
-
assert(value: any, message?: string | undefined, ...optionalParams: any[]): void;
|
|
13
|
-
clear(): void;
|
|
14
|
-
clear(): void;
|
|
15
|
-
count(label?: string | undefined): void;
|
|
16
|
-
count(label?: string | undefined): void;
|
|
17
|
-
countReset(label?: string | undefined): void;
|
|
18
|
-
countReset(label?: string | undefined): void;
|
|
19
|
-
debug(...data: any[]): void;
|
|
20
|
-
debug(message?: any, ...optionalParams: any[]): void;
|
|
21
|
-
dir(item?: any, options?: any): void;
|
|
22
|
-
dir(obj: any, options?: import("util").InspectOptions | undefined): void;
|
|
23
|
-
dirxml(...data: any[]): void;
|
|
24
|
-
dirxml(...data: any[]): void;
|
|
25
|
-
error(...data: any[]): void;
|
|
26
|
-
error(message?: any, ...optionalParams: any[]): void;
|
|
27
|
-
group(...data: any[]): void;
|
|
28
|
-
group(...label: any[]): void;
|
|
29
|
-
groupCollapsed(...data: any[]): void;
|
|
30
|
-
groupCollapsed(...label: any[]): void;
|
|
31
|
-
groupEnd(): void;
|
|
32
|
-
groupEnd(): void;
|
|
33
|
-
info(...data: any[]): void;
|
|
34
|
-
info(message?: any, ...optionalParams: any[]): void;
|
|
35
|
-
table(tabularData?: any, properties?: string[] | undefined): void;
|
|
36
|
-
table(tabularData: any, properties?: readonly string[] | undefined): void;
|
|
37
|
-
time(label?: string | undefined): void;
|
|
38
|
-
time(label?: string | undefined): void;
|
|
39
|
-
timeEnd(label?: string | undefined): void;
|
|
40
|
-
timeEnd(label?: string | undefined): void;
|
|
41
|
-
timeLog(label?: string | undefined, ...data: any[]): void;
|
|
42
|
-
timeLog(label?: string | undefined, ...data: any[]): void;
|
|
43
|
-
timeStamp(label?: string | undefined): void;
|
|
44
|
-
timeStamp(label?: string | undefined): void;
|
|
45
|
-
trace(...data: any[]): void;
|
|
46
|
-
trace(message?: any, ...optionalParams: any[]): void;
|
|
47
|
-
warn(...data: any[]): void;
|
|
48
|
-
warn(message?: any, ...optionalParams: any[]): void;
|
|
49
|
-
Console: console.ConsoleConstructor;
|
|
50
|
-
profile(label?: string | undefined): void;
|
|
51
|
-
profileEnd(label?: string | undefined): void;
|
|
52
|
-
};
|
package/dist/cubic.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export declare function randomize(seed: number, x: number, y: number): number;
|
|
2
|
-
export declare function tile(coordinate: number, period: number): number;
|
|
3
|
-
export declare function interpolate(a: number, b: number, c: number, d: number, x: number, s: number, scale: number): number;
|
|
4
|
-
/**
|
|
5
|
-
* Config a cubic noise.
|
|
6
|
-
* @param {Number} seed A seed in the range [0, 1].
|
|
7
|
-
* @param {Number} [periodX] The number of units after which the x coordinate repeats.
|
|
8
|
-
* @param {Number} [periodY] The number of units after which the y coordinate repeats.
|
|
9
|
-
* @returns {Object} A configuration object used by noise functions.
|
|
10
|
-
*/
|
|
11
|
-
export declare function cubicNoiseConfig(seed: number, octave: number, scale: number, periodX?: number, periodY?: number): {
|
|
12
|
-
seed: number;
|
|
13
|
-
periodX: number;
|
|
14
|
-
periodY: number;
|
|
15
|
-
octave: number;
|
|
16
|
-
scale: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Sample 1D cubic noise.
|
|
20
|
-
* @param {Object} config A valid noise configuration.
|
|
21
|
-
* @param {Number} x The X position to sample at.
|
|
22
|
-
* @returns {Number} A noise value in the range [0, 1].
|
|
23
|
-
*/
|
|
24
|
-
export declare function cubicNoiseSample1(config: ReturnType<typeof cubicNoiseConfig>, x: number): number;
|
|
25
|
-
/**
|
|
26
|
-
* Sample 2D cubic noise.
|
|
27
|
-
* @param {Object} config A valid noise configuration.
|
|
28
|
-
* @param {Number} x The X position to sample at.
|
|
29
|
-
* @param {Number} y The Y position to sample at.
|
|
30
|
-
* @returns {Number} A noise value in the range [0, 1].
|
|
31
|
-
*/
|
|
32
|
-
export declare function cubicNoiseSample2({ octave, periodX, periodY, seed, scale }: ReturnType<typeof cubicNoiseConfig>, x: number, y: number): number;
|
package/dist/deferred.d.ts
DELETED
package/dist/distance.d.ts
DELETED
package/dist/enums.d.ts
DELETED
package/dist/eth.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pads start of a hex string with 0 to create a bit string of the given length
|
|
3
|
-
* @param input Hex string
|
|
4
|
-
* @param bits Number of bits in the output hex string
|
|
5
|
-
* @returns Hex string of specified length
|
|
6
|
-
*/
|
|
7
|
-
export declare function padToBitLength(input: string, bits: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* Pads start of a hex string with 0 to create a 160 bit hex string
|
|
10
|
-
* which can be used as an Ethereum address
|
|
11
|
-
* @param input Hex string
|
|
12
|
-
* @returns 160 bit hex string
|
|
13
|
-
*/
|
|
14
|
-
export declare function toEthAddress(input: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Pads start of a hex string with 0 to create a 256bit hex string
|
|
17
|
-
* which can be used as an Ethereum address
|
|
18
|
-
* @param input Hex string
|
|
19
|
-
* @returns 256 bit hex string
|
|
20
|
-
*/
|
|
21
|
-
export declare function to256BitString(input: string): string;
|
|
22
|
-
export declare function extractEncodedArguments(input: string): string;
|
package/dist/guards.d.ts
DELETED
package/dist/hash.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Coord } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Compute keccak256 hash from given string and remove padding from the resulting hex string
|
|
4
|
-
* @param data String to be hashed
|
|
5
|
-
* @returns Hash of the given string as hex string without padding
|
|
6
|
-
*/
|
|
7
|
-
export declare function keccak256(data: string): string;
|
|
8
|
-
export declare function keccak256Coord(coord: Coord): string;
|
package/dist/iterable.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function makeIterable<T>(iterator: Iterator<T>): IterableIterator<T>;
|
|
2
|
-
export declare function concatIterators<T>(first: Iterator<T>, second?: Iterator<T>): IterableIterator<T>;
|
|
3
|
-
export declare function mergeIterators<A, B>(iteratorA: Iterator<A>, iteratorB: Iterator<B>): IterableIterator<[A, B]>;
|
|
4
|
-
export declare function transformIterator<A, B>(iterator: Iterator<A>, transform: (value: A) => B): IterableIterator<B>;
|
|
5
|
-
/**
|
|
6
|
-
* Turns an array into an iterator. NOTE: an iterator can only be iterated once.
|
|
7
|
-
* @param array Array to be turned into an iterator
|
|
8
|
-
* @returns Iterator to iterate through the array
|
|
9
|
-
*/
|
|
10
|
-
export declare function arrayToIterator<T>(array: T[]): IterableIterator<T>;
|
package/dist/mobx.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IComputedValue, IObservableValue } from "mobx";
|
|
2
|
-
/**
|
|
3
|
-
* @param comp Computed/Observable value that is either defined or undefined
|
|
4
|
-
* @returns promise that resolves with the first truthy computed value
|
|
5
|
-
*/
|
|
6
|
-
export declare function awaitValue<T>(comp: IComputedValue<T | undefined> | IObservableValue<T | undefined>): Promise<T>;
|
package/dist/objects.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility function to map a source object to an object with the same keys but mapped values
|
|
3
|
-
* @param source Source object to be mapped
|
|
4
|
-
* @param valueMap Mapping values of the source object to values of the target object
|
|
5
|
-
* @returns An object with the same keys as the source object but mapped values
|
|
6
|
-
*/
|
|
7
|
-
export declare function mapObject<S extends {
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}, T extends {
|
|
10
|
-
[key in keyof S]: unknown;
|
|
11
|
-
}>(source: S, valueMap: (value: S[keyof S], key: keyof S) => T[keyof S]): T;
|
package/dist/pack.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Packs two unsigned integers in one 32 bit unsigned integer
|
|
3
|
-
* @param numbers Unsigned integers to be packed in 32 bit integer
|
|
4
|
-
* @param bitsPerNumber Bits for each number
|
|
5
|
-
* @returns Packed 32 bit unsigned integer
|
|
6
|
-
*/
|
|
7
|
-
export declare function pack(numbers: number[], bitsPerNumber: number[]): number;
|
|
8
|
-
/**
|
|
9
|
-
* Unpacks a packed 32 bit unsigned integer into the original unsigned integers
|
|
10
|
-
* @param packed Packed 32 bit unsigned integer
|
|
11
|
-
* @param bitsPerNumber Bits for each unsigned integer
|
|
12
|
-
* @returns Array of unpacked unsignd integers
|
|
13
|
-
*/
|
|
14
|
-
export declare function unpack(packed: number, bitsPerNumber: number[]): number[];
|
|
15
|
-
export declare function packTuple(numbers: [number, number]): number;
|
|
16
|
-
export declare function unpackTuple(packed: number): [number, number];
|
package/dist/promise.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const range: (total?: number, step?: number, from?: number) => Generator<number, void, unknown>;
|
|
2
|
-
export declare function rejectAfter<T>(ms: number, msg: string): Promise<T>;
|
|
3
|
-
export declare const timeoutAfter: <T>(promise: Promise<T>, ms: number, timeoutMsg: string) => Promise<T>;
|
|
4
|
-
export declare const callWithRetry: <T>(fn: (...args: any[]) => Promise<T>, args?: any[], maxRetries?: number, retryInterval?: number) => Promise<T>;
|
package/dist/proxy.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IComputedValue, IObservableValue } from "mobx";
|
|
2
|
-
import { Cached } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Caches any function calls to the target until the target is ready.
|
|
5
|
-
* @param target T extends Cachable
|
|
6
|
-
* @returns Cached<T>
|
|
7
|
-
*/
|
|
8
|
-
export declare function cacheUntilReady<T extends Record<string, any>>(target: IObservableValue<T | undefined> | IComputedValue<T | undefined>): Cached<T>;
|
package/dist/rx.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Observable, OperatorFunction } from "rxjs";
|
|
2
|
-
import { IComputedValue, IObservableValue } from "mobx";
|
|
3
|
-
export declare function filterNullish<T>(): OperatorFunction<T, NonNullable<T>>;
|
|
4
|
-
export declare function awaitPromise<T extends Promise<unknown>>(): OperatorFunction<T, Awaited<T>>;
|
|
5
|
-
/**
|
|
6
|
-
* RxJS operator to stretch out an event stream by a given delay per event
|
|
7
|
-
* @param spacingDelayMs Delay between each event in ms
|
|
8
|
-
* @returns stream of events with at least spacingDelayMs spaceing between event
|
|
9
|
-
*/
|
|
10
|
-
export declare function stretch<T>(spacingDelayMs: number): import("rxjs").UnaryFunction<Observable<T>, Observable<T>>;
|
|
11
|
-
export declare function observableToComputed<T>(obs: IObservableValue<T>): IComputedValue<T>;
|
|
12
|
-
export declare function computedToStream<T>(comp: IComputedValue<T> | IObservableValue<T>): Observable<T>;
|
|
13
|
-
export declare function observableToStream<T>(obs: T): Observable<T>;
|
|
14
|
-
export declare function streamToComputed<T>(stream$: Observable<T>): IComputedValue<T | undefined>;
|
|
15
|
-
export declare function streamToDefinedComputed<T>(stream$: Observable<T>): Promise<IComputedValue<T>>;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param stream$ RxJS observable to check for the given value
|
|
19
|
-
* @param predicate Predicate to check
|
|
20
|
-
* @returns A promise that resolves with the requested value once the predicate is true
|
|
21
|
-
*/
|
|
22
|
-
export declare function awaitStreamValue<T>(stream$: Observable<T>, predicate?: (value: T) => boolean): Promise<T>;
|
|
23
|
-
/**
|
|
24
|
-
* Turns a stream into an updating object for easy access outside of rxjs
|
|
25
|
-
* @param stream$ Stream to turn into a wrapped value
|
|
26
|
-
* @returns Object with `current` key corresponding to last stream value
|
|
27
|
-
*/
|
|
28
|
-
export declare function streamToWrappedValue<T>(stream$: Observable<T>): Promise<{
|
|
29
|
-
current: T;
|
|
30
|
-
}>;
|
package/dist/sleep.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sleep<T>(timeout: number, returns?: T): Promise<T>;
|
package/dist/types.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { enableLogger } from "./console";
|
|
2
|
-
export type Func<A extends any[], R> = (...args: A) => R;
|
|
3
|
-
export type AsyncFunc<A extends any[], R> = R extends Promise<unknown> ? (...args: A) => R : (...args: A) => Promise<R>;
|
|
4
|
-
export type CachedValue<V, Proxied extends boolean> = Proxied extends true ? V extends Func<infer A, infer B> ? AsyncFunc<A, B> : V extends Record<string, any> ? Cached<V> & {
|
|
5
|
-
proxied: true;
|
|
6
|
-
} : {
|
|
7
|
-
proxied: true;
|
|
8
|
-
} : V extends Func<infer A, infer B> ? Func<A, B> : V extends Record<string, any> ? V : V & {
|
|
9
|
-
proxied: false;
|
|
10
|
-
};
|
|
11
|
-
export type Cached<C> = ({
|
|
12
|
-
proxied: false;
|
|
13
|
-
} & {
|
|
14
|
-
[key in keyof C]: CachedValue<C[key], false>;
|
|
15
|
-
}) | ({
|
|
16
|
-
proxied: true;
|
|
17
|
-
} & {
|
|
18
|
-
[key in keyof C]: CachedValue<C[key], true>;
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use Awaited<T> instead
|
|
22
|
-
*/
|
|
23
|
-
export type PromiseValue<T> = Awaited<T>;
|
|
24
|
-
export type ValueOf<T extends object> = T[keyof T];
|
|
25
|
-
export type Area = {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
width: number;
|
|
29
|
-
height: number;
|
|
30
|
-
};
|
|
31
|
-
export type Coord = {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
};
|
|
35
|
-
export type VoxelCoord = {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
z: number;
|
|
39
|
-
};
|
|
40
|
-
export type Logger = ReturnType<typeof enableLogger>;
|
package/dist/uuid.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UUID.core.js - UUID.js for Minimalists
|
|
3
|
-
*
|
|
4
|
-
* @file
|
|
5
|
-
* @author LiosK
|
|
6
|
-
* @version v4.2.0
|
|
7
|
-
* @license Apache License 2.0: Copyright (c) 2010-2018 LiosK
|
|
8
|
-
* @url https://github.com/LiosK/UUID.js/blob/master/src/uuid.core.js
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @class
|
|
12
|
-
* @classdesc {@link UUID} object.
|
|
13
|
-
* @hideconstructor
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Generates a version 4 UUID as a hexadecimal string.
|
|
17
|
-
* @returns {string} Hexadecimal UUID string.
|
|
18
|
-
*/
|
|
19
|
-
export declare const uuid: () => string;
|
package/dist/v2/TableId.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class TableId {
|
|
2
|
-
namespace: string;
|
|
3
|
-
name: string;
|
|
4
|
-
constructor(namespace: string, name: string);
|
|
5
|
-
toString(): string;
|
|
6
|
-
toHexString(): `0x${string}`;
|
|
7
|
-
static toHexString(namespace: string, name: string): `0x${string}`;
|
|
8
|
-
static fromHexString(tableId: string): TableId;
|
|
9
|
-
static fromBytes32(tableId: Uint8Array): TableId;
|
|
10
|
-
}
|
package/dist/v2/arrayToHex.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const arrayToHex: (array: Uint8Array | ArrayBuffer) => `0x${string}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const bytesToString: (bytes: Uint8Array) => string;
|
package/dist/v2/hexToArray.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const hexToArray: (hex: string) => Uint8Array;
|
package/dist/v2/isDefined.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDefined<T>(argument: T | undefined): argument is T;
|
package/dist/v2/isHex.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isHex(hex: string): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stringToBytes16: (str: string) => Uint8Array;
|
package/dist/worker.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
export interface DoWork<In, Out> {
|
|
3
|
-
work(input$: Observable<In>): Observable<Out>;
|
|
4
|
-
}
|
|
5
|
-
export declare function fromWorker<I, O>(worker: Worker, input$: Observable<I>): Observable<O>;
|
|
6
|
-
export declare function runWorker<I, O>(worker: DoWork<I, O>): void;
|