@soundscript/cli-linux-arm64 0.1.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/LICENSE +15 -0
- package/README.md +3 -0
- package/bin/soundscript +0 -0
- package/package.json +26 -0
- package/src/bundled/sound-libs/lib.decorators.d.ts +385 -0
- package/src/bundled/sound-libs/lib.decorators.legacy.d.ts +22 -0
- package/src/bundled/sound-libs/lib.dom.asynciterable.d.ts +42 -0
- package/src/bundled/sound-libs/lib.dom.d.ts +39440 -0
- package/src/bundled/sound-libs/lib.es2015.collection.d.ts +149 -0
- package/src/bundled/sound-libs/lib.es2015.core.d.ts +657 -0
- package/src/bundled/sound-libs/lib.es2015.d.ts +28 -0
- package/src/bundled/sound-libs/lib.es2015.generator.d.ts +77 -0
- package/src/bundled/sound-libs/lib.es2015.iterable.d.ts +616 -0
- package/src/bundled/sound-libs/lib.es2015.promise.d.ts +80 -0
- package/src/bundled/sound-libs/lib.es2015.proxy.d.ts +128 -0
- package/src/bundled/sound-libs/lib.es2015.reflect.d.ts +144 -0
- package/src/bundled/sound-libs/lib.es2015.symbol.d.ts +46 -0
- package/src/bundled/sound-libs/lib.es2015.symbol.wellknown.d.ts +170 -0
- package/src/bundled/sound-libs/lib.es2016.array.include.d.ts +116 -0
- package/src/bundled/sound-libs/lib.es2016.d.ts +21 -0
- package/src/bundled/sound-libs/lib.es2017.arraybuffer.d.ts +21 -0
- package/src/bundled/sound-libs/lib.es2017.d.ts +26 -0
- package/src/bundled/sound-libs/lib.es2017.date.d.ts +31 -0
- package/src/bundled/sound-libs/lib.es2017.object.d.ts +49 -0
- package/src/bundled/sound-libs/lib.es2017.string.d.ts +45 -0
- package/src/bundled/sound-libs/lib.es2017.typedarrays.d.ts +53 -0
- package/src/bundled/sound-libs/lib.es2018.asyncgenerator.d.ts +77 -0
- package/src/bundled/sound-libs/lib.es2018.asynciterable.d.ts +57 -0
- package/src/bundled/sound-libs/lib.es2018.d.ts +24 -0
- package/src/bundled/sound-libs/lib.es2018.promise.d.ts +30 -0
- package/src/bundled/sound-libs/lib.es2018.regexp.d.ts +37 -0
- package/src/bundled/sound-libs/lib.es2019.array.d.ts +79 -0
- package/src/bundled/sound-libs/lib.es2019.d.ts +24 -0
- package/src/bundled/sound-libs/lib.es2019.object.d.ts +47 -0
- package/src/bundled/sound-libs/lib.es2019.string.d.ts +37 -0
- package/src/bundled/sound-libs/lib.es2019.symbol.d.ts +24 -0
- package/src/bundled/sound-libs/lib.es2020.bigint.d.ts +765 -0
- package/src/bundled/sound-libs/lib.es2020.d.ts +27 -0
- package/src/bundled/sound-libs/lib.es2020.date.d.ts +42 -0
- package/src/bundled/sound-libs/lib.es2020.number.d.ts +28 -0
- package/src/bundled/sound-libs/lib.es2020.promise.d.ts +49 -0
- package/src/bundled/sound-libs/lib.es2020.string.d.ts +44 -0
- package/src/bundled/sound-libs/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/src/bundled/sound-libs/lib.es2021.d.ts +23 -0
- package/src/bundled/sound-libs/lib.es2021.promise.d.ts +48 -0
- package/src/bundled/sound-libs/lib.es2021.string.d.ts +33 -0
- package/src/bundled/sound-libs/lib.es2021.weakref.d.ts +78 -0
- package/src/bundled/sound-libs/lib.es2022.array.d.ts +121 -0
- package/src/bundled/sound-libs/lib.es2022.d.ts +25 -0
- package/src/bundled/sound-libs/lib.es2022.error.d.ts +75 -0
- package/src/bundled/sound-libs/lib.es2022.object.d.ts +26 -0
- package/src/bundled/sound-libs/lib.es2022.regexp.d.ts +39 -0
- package/src/bundled/sound-libs/lib.es2022.string.d.ts +25 -0
- package/src/bundled/sound-libs/lib.es2023.array.d.ts +924 -0
- package/src/bundled/sound-libs/lib.es2023.collection.d.ts +21 -0
- package/src/bundled/sound-libs/lib.es2023.d.ts +22 -0
- package/src/bundled/sound-libs/lib.es2024.arraybuffer.d.ts +65 -0
- package/src/bundled/sound-libs/lib.es2024.collection.d.ts +29 -0
- package/src/bundled/sound-libs/lib.es2024.d.ts +26 -0
- package/src/bundled/sound-libs/lib.es2024.object.d.ts +33 -0
- package/src/bundled/sound-libs/lib.es2024.promise.d.ts +35 -0
- package/src/bundled/sound-libs/lib.es2024.regexp.d.ts +25 -0
- package/src/bundled/sound-libs/lib.es2024.string.d.ts +29 -0
- package/src/bundled/sound-libs/lib.es5.d.ts +4924 -0
- package/src/stdlib/async.d.ts +81 -0
- package/src/stdlib/codec.d.ts +31 -0
- package/src/stdlib/compare.d.ts +28 -0
- package/src/stdlib/component.d.ts +40 -0
- package/src/stdlib/css.d.ts +16 -0
- package/src/stdlib/debug.d.ts +2 -0
- package/src/stdlib/decode.d.ts +84 -0
- package/src/stdlib/derive.d.ts +6 -0
- package/src/stdlib/encode.d.ts +98 -0
- package/src/stdlib/failures.d.ts +23 -0
- package/src/stdlib/graphql.d.ts +16 -0
- package/src/stdlib/hash.d.ts +34 -0
- package/src/stdlib/hkt.d.ts +40 -0
- package/src/stdlib/index.d.ts +9 -0
- package/src/stdlib/json.d.ts +98 -0
- package/src/stdlib/match.d.ts +11 -0
- package/src/stdlib/numerics.d.ts +45 -0
- package/src/stdlib/result.d.ts +52 -0
- package/src/stdlib/sql.d.ts +22 -0
- package/src/stdlib/thunk.d.ts +2 -0
- package/src/stdlib/typeclasses.d.ts +57 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Bind, Kind2, TypeLambda } from 'sts:hkt';
|
|
2
|
+
import { Failure } from 'sts:failures';
|
|
3
|
+
import type { Result } from 'sts:result';
|
|
4
|
+
import type { Applicative, AsyncMonad, Functor, Monad } from 'sts:typeclasses';
|
|
5
|
+
|
|
6
|
+
export interface AbortSignalLike {
|
|
7
|
+
readonly aborted: boolean;
|
|
8
|
+
readonly reason?: unknown;
|
|
9
|
+
addEventListener(
|
|
10
|
+
type: 'abort',
|
|
11
|
+
listener: () => void,
|
|
12
|
+
options?: boolean | { once?: boolean },
|
|
13
|
+
): void;
|
|
14
|
+
removeEventListener(type: 'abort', listener: () => void, options?: boolean): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Task<T, E = Error> = (signal?: AbortSignalLike) => Promise<Result<T, E>>;
|
|
18
|
+
|
|
19
|
+
export interface TaskF extends TypeLambda {
|
|
20
|
+
readonly type: Task<this['Args'][1], this['Args'][0]>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PromiseF extends TypeLambda {
|
|
24
|
+
readonly type: Promise<this['Args'][0]>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type TaskKind<E, T> = Kind2<TaskF, E, T>;
|
|
28
|
+
export type PromiseKind<T> = Promise<T>;
|
|
29
|
+
|
|
30
|
+
export class TimeoutFailure extends Failure {
|
|
31
|
+
readonly ms: number;
|
|
32
|
+
constructor(ms: number, cause?: unknown);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function succeed<T>(value: T): Task<T, never>;
|
|
36
|
+
export function fail<E>(error: E): Task<never, E>;
|
|
37
|
+
export function fromResult<T, E>(result: Result<T, E>): Task<T, E>;
|
|
38
|
+
export function fromPromise<T>(fn: (signal?: AbortSignalLike) => Promise<T>): Task<T, Error>;
|
|
39
|
+
export function fromPromise<T, E>(
|
|
40
|
+
fn: (signal?: AbortSignalLike) => Promise<T>,
|
|
41
|
+
mapError: (error: Error) => E,
|
|
42
|
+
): Task<T, E>;
|
|
43
|
+
export function map<A, B, E>(
|
|
44
|
+
task: Task<A, E>,
|
|
45
|
+
project: (value: A) => B,
|
|
46
|
+
): Task<B, E>;
|
|
47
|
+
export function mapError<A, E1, E2>(
|
|
48
|
+
task: Task<A, E1>,
|
|
49
|
+
project: (error: E1) => E2,
|
|
50
|
+
): Task<A, E2 | Error>;
|
|
51
|
+
export function flatMap<A, B, E1, E2>(
|
|
52
|
+
task: Task<A, E1>,
|
|
53
|
+
project: (value: A) => Task<B, E2>,
|
|
54
|
+
): Task<B, E1 | E2>;
|
|
55
|
+
export function recover<A, B, E>(
|
|
56
|
+
task: Task<A, E>,
|
|
57
|
+
project: (error: E) => B | PromiseLike<B>,
|
|
58
|
+
): Task<A | B, Error>;
|
|
59
|
+
export function tap<A, E>(
|
|
60
|
+
task: Task<A, E>,
|
|
61
|
+
effect: (value: A) => unknown | PromiseLike<unknown>,
|
|
62
|
+
): Task<A, E | Error>;
|
|
63
|
+
export function tapError<A, E>(
|
|
64
|
+
task: Task<A, E>,
|
|
65
|
+
effect: (error: E) => unknown | PromiseLike<unknown>,
|
|
66
|
+
): Task<A, E | Error>;
|
|
67
|
+
export function parallel<T, E>(tasks: readonly Task<T, E>[]): Task<readonly T[], E>;
|
|
68
|
+
export function race<T, E>(
|
|
69
|
+
tasks: readonly [Task<T, E>, ...Task<T, E>[]],
|
|
70
|
+
): Task<T, E>;
|
|
71
|
+
export function timeout<T, E>(task: Task<T, E>, ms: number): Task<T, E | TimeoutFailure>;
|
|
72
|
+
|
|
73
|
+
export function taskFunctor<E>(): Functor<Bind<TaskF, [E]>>;
|
|
74
|
+
export function taskApplicative<E>(): Applicative<Bind<TaskF, [E]>>;
|
|
75
|
+
export function taskMonad<E>(): Monad<Bind<TaskF, [E]>>;
|
|
76
|
+
export function taskAsyncMonad<E>(): AsyncMonad<Bind<TaskF, [E]>>;
|
|
77
|
+
|
|
78
|
+
export const promiseFunctor: Functor<PromiseF>;
|
|
79
|
+
export const promiseApplicative: Applicative<PromiseF>;
|
|
80
|
+
export const promiseMonad: Monad<PromiseF>;
|
|
81
|
+
export const promiseAsyncMonad: AsyncMonad<PromiseF>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Bind, TypeLambda } from 'sts:hkt';
|
|
2
|
+
import { type DecodeFailure, type Decoder } from 'sts:decode';
|
|
3
|
+
import { contramap, type EncodeFailure, type Encoder } from 'sts:encode';
|
|
4
|
+
import type { Invariant } from 'sts:typeclasses';
|
|
5
|
+
|
|
6
|
+
export { booleanEncoder, contramap, numberEncoder, stringEncoder } from 'sts:encode';
|
|
7
|
+
export type { EncodeFailure, Encoder } from 'sts:encode';
|
|
8
|
+
|
|
9
|
+
export interface Codec<T, TEncoded = unknown, DE = DecodeFailure, EE = EncodeFailure>
|
|
10
|
+
extends Decoder<T, DE>, Encoder<T, TEncoded, EE> {}
|
|
11
|
+
|
|
12
|
+
export interface CodecF extends TypeLambda {
|
|
13
|
+
readonly type: Codec<this['Args'][3], this['Args'][2], this['Args'][1], this['Args'][0]>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function codec<T, TEncoded, DE, EE>(
|
|
17
|
+
decoder: Decoder<T, DE>,
|
|
18
|
+
encoder: Encoder<T, TEncoded, EE>,
|
|
19
|
+
): Codec<T, TEncoded, DE, EE>;
|
|
20
|
+
export function imap<A, B, TEncoded, DE, EE>(
|
|
21
|
+
base: Codec<A, TEncoded, DE, EE>,
|
|
22
|
+
decodeMap: (value: A) => B,
|
|
23
|
+
encodeMap: (value: B) => A,
|
|
24
|
+
): Codec<B, TEncoded, DE, EE>;
|
|
25
|
+
export function codecInvariant<TEncoded, DE = DecodeFailure, EE = EncodeFailure>(): Invariant<
|
|
26
|
+
Bind<Bind<Bind<CodecF, [EE]>, [DE]>, [TEncoded]>
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
export const stringCodec: Codec<string, string>;
|
|
30
|
+
export const numberCodec: Codec<number, number>;
|
|
31
|
+
export const booleanCodec: Codec<boolean, boolean>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Option, Result } from 'sts:result';
|
|
2
|
+
|
|
3
|
+
export type Ordering = -1 | 0 | 1;
|
|
4
|
+
|
|
5
|
+
export interface Eq<T> {
|
|
6
|
+
equals(left: T, right: T): boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Order<T> extends Eq<T> {
|
|
10
|
+
compare(left: T, right: T): Ordering;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type EqValue<TEq> = TEq extends Eq<infer TValue> ? TValue : never;
|
|
14
|
+
|
|
15
|
+
export const stringEq: Eq<string>;
|
|
16
|
+
export const numberEq: Eq<number>;
|
|
17
|
+
export const booleanEq: Eq<boolean>;
|
|
18
|
+
export const bigintEq: Eq<bigint>;
|
|
19
|
+
export function lazyEq<T>(getEq: () => Eq<T>): Eq<T>;
|
|
20
|
+
export function arrayEq<T>(itemEq: Eq<T>): Eq<readonly T[]>;
|
|
21
|
+
export function tupleEq<const TEqs extends readonly Eq<unknown>[]>(
|
|
22
|
+
...elements: TEqs
|
|
23
|
+
): Eq<{ readonly [K in keyof TEqs]: EqValue<TEqs[K]> }>;
|
|
24
|
+
export function optionEq<T>(itemEq: Eq<T>): Eq<Option<T>>;
|
|
25
|
+
export function resultEq<T, E>(okEq: Eq<T>, errEq: Eq<E>): Eq<Result<T, E>>;
|
|
26
|
+
export function fromCompare<T>(compare: (left: T, right: T) => number): Order<T>;
|
|
27
|
+
export function reverse<T>(order: Order<T>): Order<T>;
|
|
28
|
+
export function thenBy<T>(primary: Order<T>, secondary: Order<T>): Order<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface ComponentContextKey<T> {
|
|
2
|
+
readonly __ss_component_context_key: symbol;
|
|
3
|
+
readonly __ss_component_context_type__?: (_value: T) => T;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ComponentEvent<Detail = unknown, Target = unknown> {
|
|
7
|
+
readonly currentTarget: Target;
|
|
8
|
+
readonly detail: Detail;
|
|
9
|
+
readonly target: Target;
|
|
10
|
+
readonly type: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function state<T>(value: T): T;
|
|
14
|
+
export function awaited<T, PendingResult, FulfilledResult, RejectedResult = never>(
|
|
15
|
+
promise: PromiseLike<T>,
|
|
16
|
+
pending: PendingResult | (() => PendingResult),
|
|
17
|
+
fulfilled: (value: T) => FulfilledResult,
|
|
18
|
+
rejected?: (error: unknown) => RejectedResult,
|
|
19
|
+
): PendingResult | FulfilledResult | RejectedResult;
|
|
20
|
+
export function boundary<RenderResult, FallbackResult>(
|
|
21
|
+
render: () => RenderResult,
|
|
22
|
+
fallback: (error: unknown) => FallbackResult,
|
|
23
|
+
): RenderResult | FallbackResult;
|
|
24
|
+
export function context<T>(): ComponentContextKey<T>;
|
|
25
|
+
export function dispatch<T = undefined>(type: string, detail?: T): void;
|
|
26
|
+
export function derived<T>(compute: () => T): T;
|
|
27
|
+
export function effect<T>(callback: () => T): T;
|
|
28
|
+
export function onMount<T>(callback: () => T): T;
|
|
29
|
+
export function prop<T = never>(): T;
|
|
30
|
+
export function prop<T>(value: T): T;
|
|
31
|
+
export function provide<T, R>(context: ComponentContextKey<T>, value: T, content: R): R;
|
|
32
|
+
export function provide<T, R>(
|
|
33
|
+
context: ComponentContextKey<T>,
|
|
34
|
+
value: T,
|
|
35
|
+
content: () => R,
|
|
36
|
+
): R;
|
|
37
|
+
export function useContext<T>(value: ComponentContextKey<T>): T;
|
|
38
|
+
export function useStore<T>(value: T): T;
|
|
39
|
+
export function component<T>(value: T): T;
|
|
40
|
+
export function store<T>(value: T): T;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface CssRawFragment {
|
|
2
|
+
readonly __cssKind: 'raw';
|
|
3
|
+
readonly text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface CssTemplate {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly values: readonly unknown[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CssTag {
|
|
12
|
+
(strings: TemplateStringsArray, ...values: readonly unknown[]): CssTemplate;
|
|
13
|
+
raw(text: string): CssRawFragment;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const css: CssTag;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type ErrorFrame, Failure } from 'sts:failures';
|
|
2
|
+
import type { Option, Result } from 'sts:result';
|
|
3
|
+
|
|
4
|
+
export type DecodePathSegment = string | number;
|
|
5
|
+
export type DecodePath = readonly DecodePathSegment[];
|
|
6
|
+
|
|
7
|
+
export class DecodeFailure extends Failure {
|
|
8
|
+
readonly path: DecodePath;
|
|
9
|
+
constructor(
|
|
10
|
+
message?: string,
|
|
11
|
+
options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
path?: DecodePath;
|
|
14
|
+
trace?: readonly ErrorFrame[];
|
|
15
|
+
},
|
|
16
|
+
);
|
|
17
|
+
at(segment: DecodePathSegment): this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Decoder<T, E = DecodeFailure> {
|
|
21
|
+
decode(value: unknown): Result<T, E>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface OptionalDecoder<T, E = DecodeFailure> extends Decoder<T | undefined, E> {
|
|
25
|
+
readonly __soundscriptOptional: true;
|
|
26
|
+
readonly inner: Decoder<T, E>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type DecoderValue<TDecoder> = TDecoder extends Decoder<infer TValue, unknown> ? TValue : never;
|
|
30
|
+
type DecoderError<TDecoder> = TDecoder extends Decoder<unknown, infer E> ? E : never;
|
|
31
|
+
type ObjectShape = Record<string, Decoder<unknown, unknown>>;
|
|
32
|
+
type TupleShape = readonly Decoder<unknown, unknown>[];
|
|
33
|
+
|
|
34
|
+
export const string: Decoder<string>;
|
|
35
|
+
export const number: Decoder<number>;
|
|
36
|
+
export const boolean: Decoder<boolean>;
|
|
37
|
+
export const bigint: Decoder<bigint>;
|
|
38
|
+
export function lazy<T, E>(getDecoder: () => Decoder<T, E>): Decoder<T, E>;
|
|
39
|
+
|
|
40
|
+
export function optional<T, E>(decoder: Decoder<T, E>): OptionalDecoder<T, E>;
|
|
41
|
+
export function literal<const T extends string | number | boolean | null>(value: T): Decoder<T>;
|
|
42
|
+
export function array<T, E>(item: Decoder<T, E>): Decoder<readonly T[], E | DecodeFailure>;
|
|
43
|
+
export function tuple<const TElements extends TupleShape>(
|
|
44
|
+
...elements: TElements
|
|
45
|
+
): Decoder<
|
|
46
|
+
{ readonly [K in keyof TElements]: DecoderValue<TElements[K]> },
|
|
47
|
+
DecoderError<TElements[number]> | DecodeFailure
|
|
48
|
+
>;
|
|
49
|
+
export function option<T, E>(item: Decoder<T, E>): Decoder<Option<T>, E | DecodeFailure>;
|
|
50
|
+
export function result<T, EValue, EDecodeValue, EDecodeError>(
|
|
51
|
+
okDecoder: Decoder<T, EDecodeValue>,
|
|
52
|
+
errDecoder: Decoder<EValue, EDecodeError>,
|
|
53
|
+
): Decoder<Result<T, EValue>, EDecodeValue | EDecodeError | DecodeFailure>;
|
|
54
|
+
export function object<TShape extends ObjectShape>(
|
|
55
|
+
shape: TShape,
|
|
56
|
+
): Decoder<
|
|
57
|
+
{ readonly [K in keyof TShape]: DecoderValue<TShape[K]> },
|
|
58
|
+
DecoderError<TShape[keyof TShape]> | DecodeFailure
|
|
59
|
+
>;
|
|
60
|
+
export function field<K extends string, T, E>(
|
|
61
|
+
key: K,
|
|
62
|
+
decoder: Decoder<T, E>,
|
|
63
|
+
): Decoder<T, E | DecodeFailure>;
|
|
64
|
+
export function optionalField<K extends string, T, E>(
|
|
65
|
+
key: K,
|
|
66
|
+
decoder: Decoder<T, E>,
|
|
67
|
+
): Decoder<T | undefined, E | DecodeFailure>;
|
|
68
|
+
export function union<A, B, ELeft, ERight>(
|
|
69
|
+
left: Decoder<A, ELeft>,
|
|
70
|
+
right: Decoder<B, ERight>,
|
|
71
|
+
): Decoder<A | B, ELeft | ERight | DecodeFailure>;
|
|
72
|
+
export function map<A, B, E>(
|
|
73
|
+
decoder: Decoder<A, E>,
|
|
74
|
+
project: (value: A) => B,
|
|
75
|
+
): Decoder<B, E>;
|
|
76
|
+
export function andThen<A, B, E>(
|
|
77
|
+
decoder: Decoder<A, E>,
|
|
78
|
+
project: (value: A) => Decoder<B, E>,
|
|
79
|
+
): Decoder<B, E>;
|
|
80
|
+
export function refine<A, B extends A, E>(
|
|
81
|
+
decoder: Decoder<A, E>,
|
|
82
|
+
predicate: (value: A) => value is B,
|
|
83
|
+
message: string,
|
|
84
|
+
): Decoder<B, E | DecodeFailure>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Bind, Kind3, TypeLambda } from 'sts:hkt';
|
|
2
|
+
import { Failure } from 'sts:failures';
|
|
3
|
+
import type { Option, Result } from 'sts:result';
|
|
4
|
+
import type { Contravariant } from 'sts:typeclasses';
|
|
5
|
+
|
|
6
|
+
export class EncodeFailure extends Failure {
|
|
7
|
+
constructor(message?: string, cause?: unknown);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Encoder<T, TEncoded = unknown, E = EncodeFailure> {
|
|
11
|
+
encode(value: T): Result<TEncoded, E>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface OptionalEncoder<T, TEncoded = T, E = EncodeFailure>
|
|
15
|
+
extends Encoder<T | undefined, TEncoded | undefined, E> {
|
|
16
|
+
readonly __soundscriptOptional: true;
|
|
17
|
+
readonly inner: Encoder<T, TEncoded, E>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type EncoderInput<TEncoder> = TEncoder extends Encoder<infer TValue, unknown, unknown> ? TValue
|
|
21
|
+
: never;
|
|
22
|
+
type EncoderOutput<TEncoder> = TEncoder extends Encoder<unknown, infer TEncoded, unknown>
|
|
23
|
+
? TEncoded
|
|
24
|
+
: never;
|
|
25
|
+
type EncoderError<TEncoder> = TEncoder extends Encoder<unknown, unknown, infer E> ? E : never;
|
|
26
|
+
type ObjectShape = Record<string, Encoder<unknown, unknown, unknown>>;
|
|
27
|
+
type TupleShape = readonly Encoder<unknown, unknown, unknown>[];
|
|
28
|
+
|
|
29
|
+
export interface EncoderF extends TypeLambda {
|
|
30
|
+
readonly type: Encoder<this['Args'][2], this['Args'][1], this['Args'][0]>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type EncoderKind<E, TEncoded, T> = Kind3<EncoderF, E, TEncoded, T>;
|
|
34
|
+
|
|
35
|
+
export function fromEncode<T, TEncoded, E>(
|
|
36
|
+
encode: (value: T) => Result<TEncoded, E>,
|
|
37
|
+
): Encoder<T, TEncoded, E>;
|
|
38
|
+
export function contramap<A, B, TEncoded, E>(
|
|
39
|
+
encoder: Encoder<A, TEncoded, E>,
|
|
40
|
+
project: (value: B) => A,
|
|
41
|
+
): Encoder<B, TEncoded, E>;
|
|
42
|
+
export function encoderContravariant<TEncoded, E = EncodeFailure>(): Contravariant<
|
|
43
|
+
Bind<Bind<EncoderF, [E]>, [TEncoded]>
|
|
44
|
+
>;
|
|
45
|
+
|
|
46
|
+
export const stringEncoder: Encoder<string, string>;
|
|
47
|
+
export const numberEncoder: Encoder<number, number>;
|
|
48
|
+
export const booleanEncoder: Encoder<boolean, boolean>;
|
|
49
|
+
export const bigintEncoder: Encoder<bigint, bigint>;
|
|
50
|
+
|
|
51
|
+
export function optional<T, TEncoded, E>(
|
|
52
|
+
encoder: Encoder<T, TEncoded, E>,
|
|
53
|
+
): OptionalEncoder<T, TEncoded, E>;
|
|
54
|
+
export function lazy<T, TEncoded, E>(
|
|
55
|
+
getEncoder: () => Encoder<T, TEncoded, E>,
|
|
56
|
+
): Encoder<T, TEncoded, E>;
|
|
57
|
+
export function nullable<T, TEncoded, E>(
|
|
58
|
+
encoder: Encoder<T, TEncoded, E>,
|
|
59
|
+
): Encoder<T | null, TEncoded | null, E>;
|
|
60
|
+
export function literal<const T extends string | number | boolean | null>(value: T): Encoder<T, T>;
|
|
61
|
+
export function array<T, TEncoded, E>(
|
|
62
|
+
item: Encoder<T, TEncoded, E>,
|
|
63
|
+
): Encoder<readonly T[], readonly TEncoded[], E | EncodeFailure>;
|
|
64
|
+
export function tuple<const TElements extends TupleShape>(
|
|
65
|
+
...elements: TElements
|
|
66
|
+
): Encoder<
|
|
67
|
+
{ readonly [K in keyof TElements]: EncoderInput<TElements[K]> },
|
|
68
|
+
{ readonly [K in keyof TElements]: EncoderOutput<TElements[K]> },
|
|
69
|
+
EncoderError<TElements[number]>
|
|
70
|
+
>;
|
|
71
|
+
export function option<T, TEncoded, E>(
|
|
72
|
+
item: Encoder<T, TEncoded, E>,
|
|
73
|
+
): Encoder<
|
|
74
|
+
Option<T>,
|
|
75
|
+
{ readonly error?: undefined; readonly tag: 'err' } | {
|
|
76
|
+
readonly tag: 'ok';
|
|
77
|
+
readonly value: TEncoded;
|
|
78
|
+
},
|
|
79
|
+
E
|
|
80
|
+
>;
|
|
81
|
+
export function result<T, EValue, TEncoded, EEncoded, EOk, EErr>(
|
|
82
|
+
okEncoder: Encoder<T, TEncoded, EOk>,
|
|
83
|
+
errEncoder: Encoder<EValue, EEncoded, EErr>,
|
|
84
|
+
): Encoder<
|
|
85
|
+
Result<T, EValue>,
|
|
86
|
+
{ readonly tag: 'ok'; readonly value: TEncoded } | {
|
|
87
|
+
readonly error: EEncoded;
|
|
88
|
+
readonly tag: 'err';
|
|
89
|
+
},
|
|
90
|
+
EOk | EErr
|
|
91
|
+
>;
|
|
92
|
+
export function object<TShape extends ObjectShape>(
|
|
93
|
+
shape: TShape,
|
|
94
|
+
): Encoder<
|
|
95
|
+
{ readonly [K in keyof TShape]: EncoderInput<TShape[K]> },
|
|
96
|
+
{ readonly [K in keyof TShape]: EncoderOutput<TShape[K]> },
|
|
97
|
+
EncoderError<TShape[keyof TShape]> | EncodeFailure
|
|
98
|
+
>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ErrorFrame = {
|
|
2
|
+
readonly column: number;
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly fn?: string;
|
|
5
|
+
readonly line: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class Failure {
|
|
9
|
+
readonly cause?: unknown;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly trace: readonly ErrorFrame[];
|
|
13
|
+
constructor(
|
|
14
|
+
message?: string,
|
|
15
|
+
options?: {
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
trace?: readonly ErrorFrame[];
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
withFrame(frame: ErrorFrame): this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function normalizeThrown(value: unknown): Error;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface GraphqlRawFragment {
|
|
2
|
+
readonly __graphqlKind: 'raw';
|
|
3
|
+
readonly text: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface GraphqlQuery {
|
|
7
|
+
readonly query: string;
|
|
8
|
+
readonly values: readonly unknown[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface GraphqlTag {
|
|
12
|
+
(strings: TemplateStringsArray, ...values: readonly unknown[]): GraphqlQuery;
|
|
13
|
+
raw(text: string): GraphqlRawFragment;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const graphql: GraphqlTag;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Eq } from 'sts:compare';
|
|
2
|
+
import type { Option, Result } from 'sts:result';
|
|
3
|
+
|
|
4
|
+
export type HashCode = number;
|
|
5
|
+
|
|
6
|
+
export interface Hash<T> {
|
|
7
|
+
hash(value: T): HashCode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HashEq<T> extends Hash<T>, Eq<T> {}
|
|
11
|
+
|
|
12
|
+
type HashEqValue<THashEq> = THashEq extends HashEq<infer TValue> ? TValue : never;
|
|
13
|
+
|
|
14
|
+
export function fromHashEq<T>(
|
|
15
|
+
hash: (value: T) => HashCode,
|
|
16
|
+
equals: (left: T, right: T) => boolean,
|
|
17
|
+
): HashEq<T>;
|
|
18
|
+
export function contramap<A, B>(
|
|
19
|
+
hashEq: HashEq<A>,
|
|
20
|
+
project: (value: B) => A,
|
|
21
|
+
): HashEq<B>;
|
|
22
|
+
export function lazyHashEq<T>(getHashEq: () => HashEq<T>): HashEq<T>;
|
|
23
|
+
export function arrayHash<T>(itemHash: HashEq<T>): HashEq<readonly T[]>;
|
|
24
|
+
export function tupleHash<const THashEqs extends readonly HashEq<unknown>[]>(
|
|
25
|
+
...elements: THashEqs
|
|
26
|
+
): HashEq<{ readonly [K in keyof THashEqs]: HashEqValue<THashEqs[K]> }>;
|
|
27
|
+
export function optionHash<T>(itemHash: HashEq<T>): HashEq<Option<T>>;
|
|
28
|
+
export function resultHash<T, E>(okHash: HashEq<T>, errHash: HashEq<E>): HashEq<Result<T, E>>;
|
|
29
|
+
|
|
30
|
+
export const stringHash: HashEq<string>;
|
|
31
|
+
export const numberHash: HashEq<number>;
|
|
32
|
+
export const booleanHash: HashEq<boolean>;
|
|
33
|
+
export const bigintHash: HashEq<bigint>;
|
|
34
|
+
export function combineHashes(...hashes: readonly HashCode[]): HashCode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface TypeLambda {
|
|
2
|
+
readonly Args: readonly unknown[];
|
|
3
|
+
readonly type: unknown;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type Apply<F extends TypeLambda, Args extends readonly unknown[]> = F extends {
|
|
7
|
+
readonly __target: infer Target extends TypeLambda;
|
|
8
|
+
readonly __prefix: infer Prefix extends readonly unknown[];
|
|
9
|
+
} ? Apply<Target, [...Prefix, ...Args]>
|
|
10
|
+
: (F & { readonly Args: Args })['type'];
|
|
11
|
+
|
|
12
|
+
export type Bind<F extends TypeLambda, Prefix extends readonly unknown[]> = TypeLambda & {
|
|
13
|
+
readonly __target: F;
|
|
14
|
+
readonly __prefix: Prefix;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type Kind<F extends TypeLambda, A> = Apply<F, [A]>;
|
|
18
|
+
export type Kind2<F extends TypeLambda, A, B> = Apply<F, [A, B]>;
|
|
19
|
+
export type Kind3<F extends TypeLambda, A, B, C> = Apply<F, [A, B, C]>;
|
|
20
|
+
|
|
21
|
+
export type MonadTypeLambda<M extends { readonly __type_lambda?: TypeLambda }> = M extends {
|
|
22
|
+
readonly __type_lambda?: infer F extends TypeLambda;
|
|
23
|
+
} ? F
|
|
24
|
+
: never;
|
|
25
|
+
export type BoundEffect<F extends TypeLambda, A = unknown> = Kind<F, A>;
|
|
26
|
+
export type BoundValue<F extends TypeLambda, Value> = Value extends BoundEffect<F, infer A> ? A
|
|
27
|
+
: never;
|
|
28
|
+
export type Binder<F extends TypeLambda> = <A>(value: BoundEffect<F, A>) => A;
|
|
29
|
+
|
|
30
|
+
export type {
|
|
31
|
+
Applicative,
|
|
32
|
+
AsyncMonad,
|
|
33
|
+
Contravariant,
|
|
34
|
+
Functor,
|
|
35
|
+
Invariant,
|
|
36
|
+
Monad,
|
|
37
|
+
} from 'sts:typeclasses';
|
|
38
|
+
export { Do, monadGen } from 'sts:typeclasses';
|
|
39
|
+
|
|
40
|
+
export const hkt: unknown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Err, None, Ok, Option, Result, Some } from 'sts:result';
|
|
2
|
+
|
|
3
|
+
export { err, isErr, isNone, isOk, isSome, none, ok, some, Try } from 'sts:result';
|
|
4
|
+
export { Match, where } from 'sts:match';
|
|
5
|
+
export { Failure } from 'sts:failures';
|
|
6
|
+
|
|
7
|
+
export function Defer(cleanup: () => unknown): never;
|
|
8
|
+
export function todo(message?: string): never;
|
|
9
|
+
export function unreachable(message?: string): never;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Failure } from 'sts:failures';
|
|
2
|
+
import type { Decoder } from 'sts:decode';
|
|
3
|
+
import type { Encoder } from 'sts:encode';
|
|
4
|
+
import type { Result } from 'sts:result';
|
|
5
|
+
|
|
6
|
+
export type JsonArray = JsonValue[];
|
|
7
|
+
export type JsonObject = {
|
|
8
|
+
[key: string]: JsonValue;
|
|
9
|
+
};
|
|
10
|
+
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
11
|
+
type LosslessJsonArray = LosslessJsonValue[];
|
|
12
|
+
type LosslessJsonObject = {
|
|
13
|
+
[key: string]: LosslessJsonValue;
|
|
14
|
+
};
|
|
15
|
+
export type LosslessJsonValue =
|
|
16
|
+
| string
|
|
17
|
+
| number
|
|
18
|
+
| bigint
|
|
19
|
+
| boolean
|
|
20
|
+
| null
|
|
21
|
+
| LosslessJsonObject
|
|
22
|
+
| LosslessJsonArray;
|
|
23
|
+
|
|
24
|
+
export type JsonLikeArray = JsonLikeValue[];
|
|
25
|
+
export type JsonLikeObject = {
|
|
26
|
+
[key: string]: JsonLikeValue;
|
|
27
|
+
};
|
|
28
|
+
export type JsonLikeValue =
|
|
29
|
+
| string
|
|
30
|
+
| number
|
|
31
|
+
| boolean
|
|
32
|
+
| bigint
|
|
33
|
+
| null
|
|
34
|
+
| undefined
|
|
35
|
+
| JsonLikeObject
|
|
36
|
+
| JsonLikeArray;
|
|
37
|
+
|
|
38
|
+
export interface JsonParseOptions {
|
|
39
|
+
int64?: 'default' | 'lossless';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type JsonStringifyBigintMode = 'number' | 'reject' | 'string';
|
|
43
|
+
|
|
44
|
+
export interface JsonStringifyOptions {
|
|
45
|
+
int64?: 'default' | 'string' | 'lossless';
|
|
46
|
+
readonly bigint?: JsonStringifyBigintMode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class JsonParseFailure extends Failure {
|
|
50
|
+
constructor(cause?: unknown);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class JsonStringifyFailure extends Failure {
|
|
54
|
+
constructor(cause?: unknown);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function parseJson(text: string): Result<JsonValue, JsonParseFailure>;
|
|
58
|
+
export function parseJson(
|
|
59
|
+
text: string,
|
|
60
|
+
options: JsonParseOptions & { int64: 'lossless' },
|
|
61
|
+
): Result<LosslessJsonValue, JsonParseFailure>;
|
|
62
|
+
export function parseJson(
|
|
63
|
+
text: string,
|
|
64
|
+
options?: JsonParseOptions,
|
|
65
|
+
): Result<JsonValue | LosslessJsonValue, JsonParseFailure>;
|
|
66
|
+
export function stringifyJson(value: JsonValue): Result<string, JsonStringifyFailure>;
|
|
67
|
+
export function stringifyJson(
|
|
68
|
+
value: LosslessJsonValue,
|
|
69
|
+
options: JsonStringifyOptions & { int64: 'string' | 'lossless' },
|
|
70
|
+
): Result<string, JsonStringifyFailure>;
|
|
71
|
+
export function stringifyJson(
|
|
72
|
+
value: JsonValue | LosslessJsonValue,
|
|
73
|
+
options?: JsonStringifyOptions,
|
|
74
|
+
): Result<string, JsonStringifyFailure>;
|
|
75
|
+
export function parseAndDecode<T, E>(
|
|
76
|
+
text: string,
|
|
77
|
+
decoder: Decoder<T, E>,
|
|
78
|
+
): Result<T, JsonParseFailure | E>;
|
|
79
|
+
export function encodeAndStringify<T, E>(
|
|
80
|
+
value: T,
|
|
81
|
+
encoder: Encoder<T, JsonValue, E>,
|
|
82
|
+
): Result<string, E | JsonStringifyFailure>;
|
|
83
|
+
export function isJsonValue(value: unknown): value is JsonValue;
|
|
84
|
+
export function parseJsonLike(text: string): Result<JsonLikeValue, JsonParseFailure>;
|
|
85
|
+
export function stringifyJsonLike(
|
|
86
|
+
value: JsonLikeValue,
|
|
87
|
+
options?: JsonStringifyOptions,
|
|
88
|
+
): Result<string, JsonStringifyFailure>;
|
|
89
|
+
export function decodeJson<T, E>(
|
|
90
|
+
text: string,
|
|
91
|
+
decoder: Decoder<T, E>,
|
|
92
|
+
): Result<T, E | JsonParseFailure>;
|
|
93
|
+
export function encodeJson<T, E>(
|
|
94
|
+
value: T,
|
|
95
|
+
encoder: Encoder<T, JsonLikeValue, E>,
|
|
96
|
+
options?: JsonStringifyOptions,
|
|
97
|
+
): Result<string, E | JsonStringifyFailure>;
|
|
98
|
+
export function isJsonLikeValue(value: unknown): value is JsonLikeValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type MatchArm<TValue = unknown, TResult = unknown> = (value: TValue) => TResult;
|
|
2
|
+
|
|
3
|
+
export function where<TValue, TResult>(
|
|
4
|
+
arm: (value: TValue) => TResult,
|
|
5
|
+
predicate: (value: TValue) => unknown,
|
|
6
|
+
): (value: TValue) => TResult;
|
|
7
|
+
|
|
8
|
+
export function Match<TArm extends MatchArm<any, any>>(
|
|
9
|
+
value: unknown,
|
|
10
|
+
arms: readonly [TArm, ...TArm[]],
|
|
11
|
+
): ReturnType<TArm>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type NumberLike = number;
|
|
2
|
+
export type BigintLike = bigint;
|
|
3
|
+
export type Numeric = NumberLike | BigintLike;
|
|
4
|
+
export type __soundscript_builtin_bigint = bigint;
|
|
5
|
+
export type f64 = number;
|
|
6
|
+
export type f32 = number & { readonly __soundscript_builtin_f32_brand: 'f32' };
|
|
7
|
+
export type i8 = number & { readonly __soundscript_builtin_i8_brand: 'i8' };
|
|
8
|
+
export type i16 = number & { readonly __soundscript_builtin_i16_brand: 'i16' };
|
|
9
|
+
export type i32 = number & { readonly __soundscript_builtin_i32_brand: 'i32' };
|
|
10
|
+
export type i64 = bigint & { readonly __soundscript_builtin_i64_brand: 'i64' };
|
|
11
|
+
export type u8 = number & { readonly __soundscript_builtin_u8_brand: 'u8' };
|
|
12
|
+
export type u16 = number & { readonly __soundscript_builtin_u16_brand: 'u16' };
|
|
13
|
+
export type u32 = number & { readonly __soundscript_builtin_u32_brand: 'u32' };
|
|
14
|
+
export type u64 = bigint & { readonly __soundscript_builtin_u64_brand: 'u64' };
|
|
15
|
+
type integral_number = number & {
|
|
16
|
+
readonly __soundscript_builtin_int_refinement_brand: 'Int';
|
|
17
|
+
};
|
|
18
|
+
export type Int = integral_number | i8 | i16 | i32 | i64 | u8 | u16 | u32 | u64 | bigint;
|
|
19
|
+
export type Float = number & {
|
|
20
|
+
readonly __soundscript_builtin_float_refinement_brand: 'Float';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function isInt(value: Numeric): value is Int;
|
|
24
|
+
export function isFloat(value: Numeric): value is Float;
|
|
25
|
+
export function equals(left: Numeric, right: Numeric): boolean;
|
|
26
|
+
export function fitsF32(value: Numeric): value is f32;
|
|
27
|
+
export function fitsI8(value: Numeric): value is i8;
|
|
28
|
+
export function fitsI16(value: Numeric): value is i16;
|
|
29
|
+
export function fitsI32(value: Numeric): value is i32;
|
|
30
|
+
export function fitsI64(value: Numeric): value is i64;
|
|
31
|
+
export function fitsU8(value: Numeric): value is u8;
|
|
32
|
+
export function fitsU16(value: Numeric): value is u16;
|
|
33
|
+
export function fitsU32(value: Numeric): value is u32;
|
|
34
|
+
export function fitsU64(value: Numeric): value is u64;
|
|
35
|
+
|
|
36
|
+
export function __numericWasmLeaf<T>(value: unknown): T;
|
|
37
|
+
export function F32(value: number): f32;
|
|
38
|
+
export function I8(value: number): i8;
|
|
39
|
+
export function I16(value: number): i16;
|
|
40
|
+
export function I32(value: number): i32;
|
|
41
|
+
export function I64(value: number | bigint): i64;
|
|
42
|
+
export function U8(value: number): u8;
|
|
43
|
+
export function U16(value: number): u16;
|
|
44
|
+
export function U32(value: number): u32;
|
|
45
|
+
export function U64(value: number | bigint): u64;
|