@synnaxlabs/x 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +18 -0
- package/.turbo/turbo-build.log +16 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +4 -0
- package/README.md +44 -0
- package/dist/binary/encoder.d.ts +59 -0
- package/dist/binary/encoder.spec.d.ts +1 -0
- package/dist/binary/index.d.ts +1 -0
- package/dist/case.d.ts +5 -0
- package/dist/change/change.d.ts +32 -0
- package/dist/change/index.d.ts +1 -0
- package/dist/clamp.d.ts +1 -0
- package/dist/compare/compare.d.ts +39 -0
- package/dist/compare/index.d.ts +1 -0
- package/dist/debounce.d.ts +2 -0
- package/dist/deep/copy.d.ts +1 -0
- package/dist/deep/delete.d.ts +2 -0
- package/dist/deep/delete.spec.d.ts +1 -0
- package/dist/deep/equal.d.ts +8 -0
- package/dist/deep/equal.spec.d.ts +1 -0
- package/dist/deep/external.d.ts +7 -0
- package/dist/deep/index.d.ts +1 -0
- package/dist/deep/key.d.ts +30 -0
- package/dist/deep/memo.d.ts +1 -0
- package/dist/deep/merge.d.ts +2 -0
- package/dist/deep/merge.spec.d.ts +1 -0
- package/dist/deep/partial.d.ts +3 -0
- package/dist/destructor.d.ts +1 -0
- package/dist/identity.d.ts +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/join.d.ts +1 -0
- package/dist/kv/index.d.ts +1 -0
- package/dist/kv/types.d.ts +32 -0
- package/dist/mock/MockGLBufferController.d.ts +20 -0
- package/dist/mock/index.d.ts +1 -0
- package/dist/observe/index.d.ts +1 -0
- package/dist/observe/observe.d.ts +11 -0
- package/dist/optional.d.ts +1 -0
- package/dist/primitive.d.ts +8 -0
- package/dist/record.d.ts +14 -0
- package/dist/renderable.d.ts +4 -0
- package/dist/runtime/detect.d.ts +9 -0
- package/dist/runtime/external.d.ts +2 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/os.d.ts +9 -0
- package/dist/search.d.ts +15 -0
- package/dist/spatial/base.d.ts +102 -0
- package/dist/spatial/bounds.d.ts +31 -0
- package/dist/spatial/bounds.spec.d.ts +1 -0
- package/dist/spatial/box.d.ts +265 -0
- package/dist/spatial/box.spec.d.ts +1 -0
- package/dist/spatial/dimensions.d.ts +59 -0
- package/dist/spatial/dimensions.spec.d.ts +1 -0
- package/dist/spatial/direction.d.ts +10 -0
- package/dist/spatial/direction.spec.d.ts +1 -0
- package/dist/spatial/external.d.ts +8 -0
- package/dist/spatial/index.d.ts +1 -0
- package/dist/spatial/location.d.ts +52 -0
- package/dist/spatial/location.spec.d.ts +1 -0
- package/dist/spatial/position.d.ts +2 -0
- package/dist/spatial/scale.d.ts +241 -0
- package/dist/spatial/scale.spec.d.ts +1 -0
- package/dist/spatial/spatial.d.ts +1 -0
- package/dist/spatial/xy.d.ts +116 -0
- package/dist/spatial/xy.spec.d.ts +1 -0
- package/dist/telem/encode.d.ts +1 -0
- package/dist/telem/generate.d.ts +2 -0
- package/dist/telem/gl.d.ts +11 -0
- package/dist/telem/index.d.ts +3 -0
- package/dist/telem/series.d.ts +104 -0
- package/dist/telem/series.spec.d.ts +1 -0
- package/dist/telem/telem.d.ts +633 -0
- package/dist/telem/telem.spec.d.ts +1 -0
- package/dist/toArray.d.ts +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/unique.d.ts +1 -0
- package/dist/url/index.d.ts +1 -0
- package/dist/url/url.d.ts +46 -0
- package/dist/url/url.spec.d.ts +1 -0
- package/dist/worker/worker.d.ts +32 -0
- package/dist/worker/worker.spec.d.ts +1 -0
- package/dist/x.cjs.js +9046 -0
- package/dist/x.cjs.js.map +1 -0
- package/dist/x.es.js +9047 -0
- package/dist/x.es.js.map +1 -0
- package/package.json +42 -0
- package/src/binary/encoder.spec.ts +31 -0
- package/src/binary/encoder.ts +118 -0
- package/src/binary/index.ts +10 -0
- package/src/case.ts +31 -0
- package/src/change/change.ts +31 -0
- package/src/change/index.ts +10 -0
- package/src/clamp.ts +14 -0
- package/src/compare/compare.ts +116 -0
- package/src/compare/index.ts +10 -0
- package/src/debounce.ts +45 -0
- package/src/deep/copy.ts +13 -0
- package/src/deep/delete.spec.ts +36 -0
- package/src/deep/delete.ts +27 -0
- package/src/deep/equal.spec.ts +82 -0
- package/src/deep/equal.ts +65 -0
- package/src/deep/external.ts +15 -0
- package/src/deep/index.ts +10 -0
- package/src/deep/key.ts +46 -0
- package/src/deep/merge.spec.ts +63 -0
- package/src/deep/merge.ts +41 -0
- package/src/deep/partial.ts +14 -0
- package/src/destructor.ts +10 -0
- package/src/identity.ts +14 -0
- package/src/index.ts +34 -0
- package/src/join.ts +14 -0
- package/src/kv/index.ts +10 -0
- package/src/kv/types.ts +52 -0
- package/src/mock/MockGLBufferController.ts +70 -0
- package/src/mock/index.ts +10 -0
- package/src/observe/index.ts +10 -0
- package/src/observe/observe.ts +33 -0
- package/src/optional.ts +10 -0
- package/src/primitive.ts +46 -0
- package/src/record.ts +45 -0
- package/src/renderable.ts +20 -0
- package/src/runtime/detect.ts +34 -0
- package/src/runtime/external.ts +11 -0
- package/src/runtime/index.ts +10 -0
- package/src/runtime/os.ts +38 -0
- package/src/search.ts +40 -0
- package/src/spatial/base.ts +80 -0
- package/src/spatial/bounds.spec.ts +99 -0
- package/src/spatial/bounds.ts +80 -0
- package/src/spatial/box.spec.ts +137 -0
- package/src/spatial/box.ts +326 -0
- package/src/spatial/dimensions.spec.ts +47 -0
- package/src/spatial/dimensions.ts +64 -0
- package/src/spatial/direction.spec.ts +25 -0
- package/src/spatial/direction.ts +47 -0
- package/src/spatial/external.ts +17 -0
- package/src/spatial/index.ts +10 -0
- package/src/spatial/location.spec.ts +24 -0
- package/src/spatial/location.ts +124 -0
- package/src/spatial/position.ts +26 -0
- package/src/spatial/scale.spec.ts +74 -0
- package/src/spatial/scale.ts +351 -0
- package/src/spatial/spatial.ts +17 -0
- package/src/spatial/xy.spec.ts +68 -0
- package/src/spatial/xy.ts +164 -0
- package/src/telem/encode.ts +22 -0
- package/src/telem/generate.ts +19 -0
- package/src/telem/gl.ts +22 -0
- package/src/telem/index.ts +12 -0
- package/src/telem/series.spec.ts +289 -0
- package/src/telem/series.ts +449 -0
- package/src/telem/telem.spec.ts +302 -0
- package/src/telem/telem.ts +1237 -0
- package/src/toArray.ts +11 -0
- package/src/transform.ts +10 -0
- package/src/unique.ts +10 -0
- package/src/url/index.ts +10 -0
- package/src/url/url.spec.ts +47 -0
- package/src/url/url.ts +113 -0
- package/src/worker/worker.spec.ts +41 -0
- package/src/worker/worker.ts +86 -0
- package/tsconfig.json +7 -0
- package/tsconfig.vite.json +4 -0
- package/vite.config.ts +23 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Synnax Labs, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this software is governed by the Business Source License included in the file
|
|
5
|
+
* licenses/BSL.txt.
|
|
6
|
+
*
|
|
7
|
+
* As of the Change Date specified in that file, in accordance with the Business Source
|
|
8
|
+
* License, use of this software will be governed by the Apache License, Version 2.0,
|
|
9
|
+
* included in the file licenses/APL.txt.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
root: true,
|
|
14
|
+
extends: ["synnaxlabs"],
|
|
15
|
+
parserOptions: {
|
|
16
|
+
project: "./tsconfig.json",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
> @synnaxlabs/x@0.7.0 build /Users/emilianobonilla/Desktop/synnaxlabs/synnax/x/ts
|
|
3
|
+
> vite build
|
|
4
|
+
|
|
5
|
+
vite v5.0.10 building for production...
|
|
6
|
+
transforming...
|
|
7
|
+
✓ 112 modules transformed.
|
|
8
|
+
rendering chunks...
|
|
9
|
+
|
|
10
|
+
[vite:dts] Start generate declaration files...
|
|
11
|
+
computing gzip size...
|
|
12
|
+
dist/x.es.js 282.61 kB │ gzip: 52.80 kB │ map: 575.28 kB
|
|
13
|
+
[vite:dts] Declaration files built in 1170ms.
|
|
14
|
+
|
|
15
|
+
dist/x.cjs.js 283.44 kB │ gzip: 52.94 kB │ map: 575.40 kB
|
|
16
|
+
✓ built in 1.57s
|
package/LICENSE
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Source code in this repository is licensed under the Business Source License 1.1 (BSL).
|
|
2
|
+
A copy of the license can be found in the licenses/BSL.txt file. Source code in a given
|
|
3
|
+
file is licensed under the BSL and the copyright belongs to Synnax Labs, Inc. unless
|
|
4
|
+
otherwise noted at the beginning of the file.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Typescript X - Common Utilities for the Synnax Codebase
|
|
2
|
+
|
|
3
|
+
This directory contains the source for the `@synnaxlabs/x` package, which contains
|
|
4
|
+
common utilities dependend on by other packages in the Synnax codebase.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
With NPM:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install @synnaxlabs/x
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With Yarn:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
yarn add @synnaxlabs/x
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With PNPM:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @synnaxlabs/x
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Running the test suite
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm test
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Building the package
|
|
33
|
+
|
|
34
|
+
From the root directory of the synnax repository, run:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pnpm build:x
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ZodSchema, type z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* CustomTypeEncoder is an interface for a class that needs to transform its
|
|
4
|
+
* value before encoding.
|
|
5
|
+
*/
|
|
6
|
+
interface CustomTypeEncoder {
|
|
7
|
+
/** The Class the custom encoder is set for */
|
|
8
|
+
Class: Function;
|
|
9
|
+
/**
|
|
10
|
+
* The function that transforms the value before encoding;
|
|
11
|
+
*
|
|
12
|
+
* @param instance - The instance of the class to transform.
|
|
13
|
+
* @returns The transformed value.
|
|
14
|
+
*/
|
|
15
|
+
write: <P>(instance: P) => unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* EncoderDecoder is an entity that encodes and decodes messages to and from a
|
|
19
|
+
* binary format.
|
|
20
|
+
*/
|
|
21
|
+
export interface EncoderDecoder {
|
|
22
|
+
/** The HTTP content type of the encoder */
|
|
23
|
+
contentType: string;
|
|
24
|
+
/**
|
|
25
|
+
* Encodes the given payload into a binary representation.
|
|
26
|
+
*
|
|
27
|
+
* @param payload - The payload to encode.
|
|
28
|
+
* @returns An ArrayBuffer containing the encoded payload.
|
|
29
|
+
*/
|
|
30
|
+
encode: (payload: unknown) => ArrayBuffer;
|
|
31
|
+
/**
|
|
32
|
+
* Decodes the given binary representation into a type checked payload.
|
|
33
|
+
*
|
|
34
|
+
* @param data - The data to decode.
|
|
35
|
+
* @param schema - The schema to decode the data with.
|
|
36
|
+
*/
|
|
37
|
+
decode: <P>(data: Uint8Array | ArrayBuffer, schema?: ZodSchema<P>) => P;
|
|
38
|
+
}
|
|
39
|
+
interface StaticEncoderDecoder {
|
|
40
|
+
registerCustomType: (encoder: CustomTypeEncoder) => void;
|
|
41
|
+
}
|
|
42
|
+
/** MsgpackEncoderDecoder is a msgpack implementation of EncoderDecoder. */
|
|
43
|
+
export declare class MsgpackEncoderDecoder implements EncoderDecoder {
|
|
44
|
+
contentType: string;
|
|
45
|
+
encode(payload: unknown): ArrayBuffer;
|
|
46
|
+
decode<P extends z.ZodTypeAny>(data: Uint8Array | ArrayBuffer, schema?: P): z.output<P>;
|
|
47
|
+
static registerCustomType(encoder: CustomTypeEncoder): void;
|
|
48
|
+
}
|
|
49
|
+
/** JSONEncoderDecoder is a JSON implementation of EncoderDecoder. */
|
|
50
|
+
export declare class JSONEncoderDecoder implements EncoderDecoder {
|
|
51
|
+
contentType: string;
|
|
52
|
+
encode(payload: unknown): ArrayBuffer;
|
|
53
|
+
decode<P extends z.ZodTypeAny>(data: Uint8Array | ArrayBuffer, schema?: P): z.output<P>;
|
|
54
|
+
static registerCustomType(): void;
|
|
55
|
+
}
|
|
56
|
+
export declare const ENCODERS: EncoderDecoder[];
|
|
57
|
+
export declare const ENCODER_CLASSES: StaticEncoderDecoder[];
|
|
58
|
+
export declare const registerCustomTypeEncoder: (encoder: CustomTypeEncoder) => void;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as binary from '../binary/encoder';
|
package/dist/case.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type Variant = "set" | "delete";
|
|
3
|
+
export declare const Z: <V extends z.ZodTypeAny>(value: V) => z.ZodObject<{
|
|
4
|
+
variant: z.ZodEnum<["set", "delete"]>;
|
|
5
|
+
key: z.ZodString;
|
|
6
|
+
value: V;
|
|
7
|
+
}, "strip", z.ZodTypeAny, { [k_1 in keyof z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
8
|
+
variant: z.ZodEnum<["set", "delete"]>;
|
|
9
|
+
key: z.ZodString;
|
|
10
|
+
value: V;
|
|
11
|
+
}>, "key" | "variant" | (undefined extends V["_output"] ? never : "value")>]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
12
|
+
variant: z.ZodEnum<["set", "delete"]>;
|
|
13
|
+
key: z.ZodString;
|
|
14
|
+
value: V;
|
|
15
|
+
}>, "key" | "variant" | (undefined extends V["_output"] ? never : "value")>[k_1]; }, { [k_2 in keyof z.baseObjectInputType<{
|
|
16
|
+
variant: z.ZodEnum<["set", "delete"]>;
|
|
17
|
+
key: z.ZodString;
|
|
18
|
+
value: V;
|
|
19
|
+
}>]: z.baseObjectInputType<{
|
|
20
|
+
variant: z.ZodEnum<["set", "delete"]>;
|
|
21
|
+
key: z.ZodString;
|
|
22
|
+
value: V;
|
|
23
|
+
}>[k_2]; }>;
|
|
24
|
+
export type Change<K, V> = {
|
|
25
|
+
variant: "set";
|
|
26
|
+
key: K;
|
|
27
|
+
value: V;
|
|
28
|
+
} | {
|
|
29
|
+
variant: "delete";
|
|
30
|
+
key: K;
|
|
31
|
+
value?: V;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as change from '../change/change';
|
package/dist/clamp.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clamp: (value: number, min?: number, max?: number) => number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Primitive, type PrimitiveRecord } from '../primitive';
|
|
2
|
+
import { type spatial } from '../spatial';
|
|
3
|
+
export type CompareF<T> = (a: T, b: T) => number;
|
|
4
|
+
/**
|
|
5
|
+
* Creates the appropriate compare function for sorting the given
|
|
6
|
+
* primitive type.
|
|
7
|
+
*
|
|
8
|
+
* @param v The primitive value to create a compare function for.
|
|
9
|
+
* This is used to determine the type of comparison to perform.
|
|
10
|
+
* @param reverse Whether to reverse the sort order.
|
|
11
|
+
*/
|
|
12
|
+
export declare const newF: <T extends Primitive>(v: T, reverse?: boolean) => CompareF<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a compare function that compares the field of the given object.
|
|
15
|
+
*
|
|
16
|
+
* @param key The key of the field to compare.
|
|
17
|
+
* @param value The object to compare the field of. This is used to determine the type of
|
|
18
|
+
* comparison to perform.
|
|
19
|
+
* @param reverse Whether to reverse the sort order.
|
|
20
|
+
*/
|
|
21
|
+
export declare const newFieldF: <T extends PrimitiveRecord>(key: keyof T, value: T, reverse?: boolean) => CompareF<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Compares the two primitive arrays.
|
|
24
|
+
* @param a The first array to compare.
|
|
25
|
+
* @param b The second array to compare.
|
|
26
|
+
* @returns The array with the greater length if the array lengths are not equal. If the
|
|
27
|
+
* arrays are the same length, returns 0 if all elements are equal, otherwise returns -1.
|
|
28
|
+
*/
|
|
29
|
+
export declare const primitiveArrays: <T extends Primitive>(a: readonly T[] | T[], b: readonly T[] | T[]) => number;
|
|
30
|
+
export declare const unorderedPrimitiveArrays: <T extends Primitive>(a: readonly T[] | T[], b: readonly T[] | T[]) => number;
|
|
31
|
+
export declare const order: (a: spatial.Order, b: spatial.Order) => number;
|
|
32
|
+
/** @returns the reverse of the given compare function. */
|
|
33
|
+
export declare const reverseF: <T>(f: CompareF<T>) => CompareF<T>;
|
|
34
|
+
/** The equal return value of a compare function. */
|
|
35
|
+
export declare const EQUAL = 0;
|
|
36
|
+
/** The less than return value of a compare function. */
|
|
37
|
+
export declare const LESS_THAN = -1;
|
|
38
|
+
/** The greater than return value of a compare function. */
|
|
39
|
+
export declare const GREATER_THAN = 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as compare from '../compare/compare';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const copy: <T extends Partial<Record<keyof T, unknown>>>(obj: T) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UnknownRecord } from '../record';
|
|
2
|
+
import { Primitive } from '../primitive';
|
|
3
|
+
type DeepEqualBaseRecord = UnknownRecord | {
|
|
4
|
+
equals?: (other: any) => boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const equal: <T extends DeepEqualBaseRecord | DeepEqualBaseRecord[] | Primitive[]>(a: T, b: T) => boolean;
|
|
7
|
+
export declare const partialEqual: <T extends Partial<Record<keyof T, unknown>>>(base: T, partial: Partial<T>) => boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as deep from '../deep/external';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Join } from '../join';
|
|
2
|
+
type Prev = [
|
|
3
|
+
never,
|
|
4
|
+
0,
|
|
5
|
+
1,
|
|
6
|
+
2,
|
|
7
|
+
3,
|
|
8
|
+
4,
|
|
9
|
+
5,
|
|
10
|
+
6,
|
|
11
|
+
7,
|
|
12
|
+
8,
|
|
13
|
+
9,
|
|
14
|
+
10,
|
|
15
|
+
11,
|
|
16
|
+
12,
|
|
17
|
+
13,
|
|
18
|
+
14,
|
|
19
|
+
15,
|
|
20
|
+
16,
|
|
21
|
+
17,
|
|
22
|
+
18,
|
|
23
|
+
19,
|
|
24
|
+
20,
|
|
25
|
+
...Array<0>
|
|
26
|
+
];
|
|
27
|
+
export type Key<T, D extends number = 5> = [D] extends [never] ? never : T extends object ? {
|
|
28
|
+
[K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Key<T[K], Prev[D]>> : never;
|
|
29
|
+
}[keyof T] : "";
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const memo: <F extends (...args: any[]) => any>(func: F) => F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Destructor = () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isObject: <T extends Partial<Record<import('./record').Key, unknown>> = Partial<Record<import('./record').Key, unknown>>>(item?: unknown) => item is T;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from './telem';
|
|
2
|
+
export * from './primitive';
|
|
3
|
+
export * from './record';
|
|
4
|
+
export * from './renderable';
|
|
5
|
+
export * from './optional';
|
|
6
|
+
export * from './identity';
|
|
7
|
+
export * from './runtime';
|
|
8
|
+
export * from './deep';
|
|
9
|
+
export * from './debounce';
|
|
10
|
+
export * from './clamp';
|
|
11
|
+
export * from './compare';
|
|
12
|
+
export * from './runtime';
|
|
13
|
+
export * from './unique';
|
|
14
|
+
export * from './kv';
|
|
15
|
+
export * from './spatial';
|
|
16
|
+
export * from './url';
|
|
17
|
+
export * from './toArray';
|
|
18
|
+
export * from './case';
|
|
19
|
+
export * from './search';
|
|
20
|
+
export * from './destructor';
|
|
21
|
+
export * from './worker/worker';
|
|
22
|
+
export * from './transform';
|
|
23
|
+
export * from './binary';
|
|
24
|
+
export * from './observe';
|
|
25
|
+
export * from './change';
|
package/dist/join.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${"" extends P ? "" : "."}${P}` : never : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as kv from '../kv/types';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface KV<K = string, V = string, WK = K, WV = V, D = K> extends Reader<K, V>, Writer<WK, WV>, Deleter<D> {
|
|
2
|
+
}
|
|
3
|
+
export interface Reader<K = string, V = string> {
|
|
4
|
+
/** @returns the value for a given key, or null if the key is not present. */
|
|
5
|
+
get: (key: K) => V | null;
|
|
6
|
+
}
|
|
7
|
+
export interface Writer<K = string, V = string> {
|
|
8
|
+
/** Sets a key-value pair in the store. */
|
|
9
|
+
set: (key: K, value: V) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface Deleter<K = string> {
|
|
12
|
+
/** Deletes a key-value pair from the store. */
|
|
13
|
+
delete: (key: K) => void;
|
|
14
|
+
}
|
|
15
|
+
/** A read-writable key-value store. */
|
|
16
|
+
export interface Async<K = string, V = string, WK = K, WV = V, D = K> extends AsyncReader<K, V>, AsyncWriter<WK, WV>, AsyncDeleter<D> {
|
|
17
|
+
}
|
|
18
|
+
/** A readable key-value store. */
|
|
19
|
+
export interface AsyncReader<K = string, V = string> {
|
|
20
|
+
/** Get the value for a given key. */
|
|
21
|
+
get: (key: K) => Promise<V | null>;
|
|
22
|
+
}
|
|
23
|
+
/** A writable key-value store. */
|
|
24
|
+
export interface AsyncWriter<K = string, V = string> {
|
|
25
|
+
/** Sets a key-value pair in the store. The value must be serializable. */
|
|
26
|
+
set: (key: K, value: V) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/** A key-value store that can delete key-value pairs. */
|
|
29
|
+
export interface AsyncDeleter<K = string> {
|
|
30
|
+
/** Deletes a key-value pair from the store. */
|
|
31
|
+
delete: (key: K) => Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Mock } from "vitest";
|
|
2
|
+
import { GLBufferController } from '../telem/gl';
|
|
3
|
+
export declare class MockGLBufferController implements GLBufferController {
|
|
4
|
+
ARRAY_BUFFER: number;
|
|
5
|
+
STATIC_DRAW: number;
|
|
6
|
+
DYNAMIC_DRAW: number;
|
|
7
|
+
targets: Record<number, number>;
|
|
8
|
+
counter: number;
|
|
9
|
+
buffers: Record<number, ArrayBuffer>;
|
|
10
|
+
createBufferMock: Mock<[], WebGLBuffer | null>;
|
|
11
|
+
bufferDataMock: Mock<[number, ArrayBufferLike | number, number]>;
|
|
12
|
+
bufferSubDataMock: Mock<[number, number, ArrayBufferLike]>;
|
|
13
|
+
bindBufferMock: Mock<[number, WebGLBuffer | null]>;
|
|
14
|
+
deleteBufferMock: Mock<[WebGLBuffer | null]>;
|
|
15
|
+
deleteBuffer(buffer: WebGLBuffer | null): void;
|
|
16
|
+
createBuffer(): WebGLBuffer | null;
|
|
17
|
+
bufferData(target: number, dataOrSize: ArrayBufferLike | number, usage: number): void;
|
|
18
|
+
bindBuffer(target: number, buffer: WebGLBuffer | null): void;
|
|
19
|
+
bufferSubData(target: number, offset: number, data: ArrayBufferLike): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../mock/MockGLBufferController';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as observe from '../observe/observe';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Destructor } from '../destructor';
|
|
2
|
+
export type Handler<T> = (value: T) => void;
|
|
3
|
+
export interface Observable<T> {
|
|
4
|
+
onChange: (handler: Handler<T>) => Destructor;
|
|
5
|
+
}
|
|
6
|
+
export declare class Observer<T> implements Observable<T> {
|
|
7
|
+
private readonly handlers;
|
|
8
|
+
constructor();
|
|
9
|
+
onChange(handler: Handler<T>): Destructor;
|
|
10
|
+
notify(value: T): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Key } from './record';
|
|
2
|
+
export type Primitive = string | number | bigint | boolean | Stringer | null | undefined;
|
|
3
|
+
export interface Stringer {
|
|
4
|
+
toString: () => string;
|
|
5
|
+
}
|
|
6
|
+
export declare const isStringer: (value: unknown) => boolean;
|
|
7
|
+
export type PrimitiveRecord = Record<Key, Primitive>;
|
|
8
|
+
export declare const primitiveIsZero: (value: Primitive) => boolean;
|
package/dist/record.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type RenderableValue } from './renderable';
|
|
3
|
+
export type Key = string | number | symbol;
|
|
4
|
+
export type KeyedRecord<K extends Key = Key, E extends Record<string, unknown> = Record<string, unknown>> = {
|
|
5
|
+
key: K;
|
|
6
|
+
} & Partial<Record<keyof E, unknown>>;
|
|
7
|
+
export type UnknownRecord<E extends Record<Key, unknown> = Record<Key, unknown>> = Partial<Record<keyof E, unknown>>;
|
|
8
|
+
export type RenderableRecord<E extends Record<string, RenderableValue> = Record<string, RenderableValue>> = E;
|
|
9
|
+
export type KeyedRenderableRecord<K extends Key = Key, E extends Record<string, RenderableValue> = Record<string, RenderableValue>> = KeyedRecord<K, E> & Omit<RenderableRecord<E>, "key">;
|
|
10
|
+
export declare const unknownRecordZ: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
11
|
+
export type Entries<T> = {
|
|
12
|
+
[K in keyof T]: [K, T[K]];
|
|
13
|
+
}[keyof T][];
|
|
14
|
+
export declare const getEntries: <T extends Record<Key, unknown>>(obj: T) => Entries<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** JavaScript runtime environments. */
|
|
2
|
+
export type Runtime = "browser" | "node" | "webworker";
|
|
3
|
+
/**
|
|
4
|
+
* Does best effort detection of the runtime environment.
|
|
5
|
+
*
|
|
6
|
+
* @returns The runtime environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const detect: () => Runtime;
|
|
9
|
+
export declare const RUNTIME: Runtime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as runtime from '../runtime/external';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const OPERATING_SYSTEMS: readonly ["MacOS", "Windows", "Linux", "Docker"];
|
|
3
|
+
export declare const osZ: z.ZodEnum<["MacOS", "Windows", "Linux", "Docker"]>;
|
|
4
|
+
export type OS = (typeof OPERATING_SYSTEMS)[number];
|
|
5
|
+
export interface GetOSProps {
|
|
6
|
+
force?: OS;
|
|
7
|
+
default?: OS;
|
|
8
|
+
}
|
|
9
|
+
export declare const getOS: (props?: GetOSProps) => OS | undefined;
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CompareF } from './compare/compare';
|
|
2
|
+
import { type Key, type KeyedRecord } from './record';
|
|
3
|
+
export declare const Search: {
|
|
4
|
+
binary: <T>(arr: T[], target: T, compare: CompareF<T>) => number;
|
|
5
|
+
};
|
|
6
|
+
export interface TermSearcher<T, K extends Key, E extends KeyedRecord<K, E>> {
|
|
7
|
+
search: (term: T) => E[];
|
|
8
|
+
retrieve: (keys: K[]) => E[];
|
|
9
|
+
page: (offset: number, limit: number) => E[];
|
|
10
|
+
}
|
|
11
|
+
export interface AsyncTermSearcher<T, K extends Key, E extends KeyedRecord<K, E>> {
|
|
12
|
+
search: (term: T) => Promise<E[]>;
|
|
13
|
+
retrieve: (keys: K[]) => Promise<E[]>;
|
|
14
|
+
page: (offset: number, limit: number) => Promise<E[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const numberCouple: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
3
|
+
export type NumberCouple = z.infer<typeof numberCouple>;
|
|
4
|
+
export declare const dimensions: z.ZodObject<{
|
|
5
|
+
width: z.ZodNumber;
|
|
6
|
+
height: z.ZodNumber;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}, {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}>;
|
|
14
|
+
export type Dimensions = z.infer<typeof dimensions>;
|
|
15
|
+
export declare const signedDimensions: z.ZodObject<{
|
|
16
|
+
signedWidth: z.ZodNumber;
|
|
17
|
+
signedHeight: z.ZodNumber;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
signedWidth: number;
|
|
20
|
+
signedHeight: number;
|
|
21
|
+
}, {
|
|
22
|
+
signedWidth: number;
|
|
23
|
+
signedHeight: number;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const DIMENSIONS: readonly ["width", "height"];
|
|
26
|
+
export declare const dimension: z.ZodEnum<["width", "height"]>;
|
|
27
|
+
export type Dimension = (typeof DIMENSIONS)[number];
|
|
28
|
+
export declare const ALIGNMENTS: readonly ["start", "center", "end"];
|
|
29
|
+
export declare const SIGNED_DIMENSIONS: readonly ["signedWidth", "signedHeight"];
|
|
30
|
+
export declare const signedDimension: z.ZodEnum<["signedWidth", "signedHeight"]>;
|
|
31
|
+
export type SignedDimension = (typeof SIGNED_DIMENSIONS)[number];
|
|
32
|
+
export declare const xy: z.ZodObject<{
|
|
33
|
+
x: z.ZodNumber;
|
|
34
|
+
y: z.ZodNumber;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}, {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}>;
|
|
42
|
+
export type XY = z.infer<typeof xy>;
|
|
43
|
+
export declare const clientXY: z.ZodObject<{
|
|
44
|
+
clientX: z.ZodNumber;
|
|
45
|
+
clientY: z.ZodNumber;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
clientX: number;
|
|
48
|
+
clientY: number;
|
|
49
|
+
}, {
|
|
50
|
+
clientX: number;
|
|
51
|
+
clientY: number;
|
|
52
|
+
}>;
|
|
53
|
+
export type ClientXY = z.infer<typeof clientXY>;
|
|
54
|
+
export declare const DIRECTIONS: readonly ["x", "y"];
|
|
55
|
+
export declare const direction: z.ZodEnum<["x", "y"]>;
|
|
56
|
+
export type Direction = z.infer<typeof direction>;
|
|
57
|
+
export declare const OUTER_LOCATIONS: readonly ["top", "right", "bottom", "left"];
|
|
58
|
+
export declare const outerLocation: z.ZodEnum<["top", "right", "bottom", "left"]>;
|
|
59
|
+
export type OuterLocation = (typeof OUTER_LOCATIONS)[number];
|
|
60
|
+
export declare const X_LOCATIONS: readonly ["left", "right"];
|
|
61
|
+
export declare const xLocation: z.ZodEnum<["left", "right"]>;
|
|
62
|
+
export type XLocation = (typeof X_LOCATIONS)[number];
|
|
63
|
+
export declare const Y_LOCATIONS: readonly ["top", "bottom"];
|
|
64
|
+
export declare const yLocation: z.ZodEnum<["top", "bottom"]>;
|
|
65
|
+
export type YLocation = (typeof Y_LOCATIONS)[number];
|
|
66
|
+
export declare const CENTER_LOCATIONS: readonly ["center"];
|
|
67
|
+
export declare const centerlocation: z.ZodEnum<["center"]>;
|
|
68
|
+
export type CenterLocation = (typeof CENTER_LOCATIONS)[number];
|
|
69
|
+
export declare const LOCATIONS: readonly ["top", "right", "bottom", "left", "center"];
|
|
70
|
+
export declare const location: z.ZodEnum<["top", "right", "bottom", "left", "center"]>;
|
|
71
|
+
export type Location = z.infer<typeof location>;
|
|
72
|
+
export declare const alignment: z.ZodEnum<["start", "center", "end"]>;
|
|
73
|
+
export type Alignment = (typeof ALIGNMENTS)[number];
|
|
74
|
+
export declare const ORDERS: readonly ["first", "last"];
|
|
75
|
+
export declare const order: z.ZodEnum<["first", "last"]>;
|
|
76
|
+
export type Order = (typeof ORDERS)[number];
|
|
77
|
+
export declare const bounds: z.ZodObject<{
|
|
78
|
+
lower: z.ZodNumber;
|
|
79
|
+
upper: z.ZodNumber;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
lower: number;
|
|
82
|
+
upper: number;
|
|
83
|
+
}, {
|
|
84
|
+
lower: number;
|
|
85
|
+
upper: number;
|
|
86
|
+
}>;
|
|
87
|
+
export type Bounds = z.infer<typeof bounds>;
|
|
88
|
+
export declare const crudeBounds: z.ZodUnion<[z.ZodObject<{
|
|
89
|
+
lower: z.ZodNumber;
|
|
90
|
+
upper: z.ZodNumber;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
lower: number;
|
|
93
|
+
upper: number;
|
|
94
|
+
}, {
|
|
95
|
+
lower: number;
|
|
96
|
+
upper: number;
|
|
97
|
+
}>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
98
|
+
export type CrudeBounds = z.infer<typeof crudeBounds>;
|
|
99
|
+
export declare const crudeDirection: z.ZodUnion<[z.ZodEnum<["x", "y"]>, z.ZodEnum<["top", "right", "bottom", "left", "center"]>]>;
|
|
100
|
+
export type CrudeDirection = z.infer<typeof crudeDirection>;
|
|
101
|
+
export declare const crudeLocation: z.ZodUnion<[z.ZodEnum<["x", "y"]>, z.ZodEnum<["top", "right", "bottom", "left", "center"]>, z.ZodType<String, z.ZodTypeDef, String>]>;
|
|
102
|
+
export type CrudeLocation = z.infer<typeof crudeLocation>;
|