@mirascript/mirascript 0.1.4 → 0.1.6
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/{chunk-RYSPVMVZ.js → chunk-OU3K5EYB.js} +26 -5
- package/dist/chunk-OU3K5EYB.js.map +6 -0
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/index.js +25 -16
- package/dist/cli/index.js.map +2 -2
- package/dist/cli/print.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/subtle.js +1 -1
- package/dist/vm/lib/_helpers.d.ts +1 -1
- package/dist/vm/lib/_helpers.d.ts.map +1 -1
- package/dist/vm/lib/global/bit.d.ts +7 -8
- package/dist/vm/lib/global/bit.d.ts.map +1 -1
- package/dist/vm/lib/global/debug.d.ts +6 -3
- package/dist/vm/lib/global/debug.d.ts.map +1 -1
- package/dist/vm/lib/global/json.d.ts +2 -3
- package/dist/vm/lib/global/json.d.ts.map +1 -1
- package/dist/vm/lib/global/math-additional.d.ts +1 -2
- package/dist/vm/lib/global/math-additional.d.ts.map +1 -1
- package/dist/vm/lib/global/math-arr.d.ts +5 -6
- package/dist/vm/lib/global/math-arr.d.ts.map +1 -1
- package/dist/vm/lib/global/math-unary.d.ts +26 -27
- package/dist/vm/lib/global/math-unary.d.ts.map +1 -1
- package/dist/vm/lib/global/math.d.ts +3 -4
- package/dist/vm/lib/global/math.d.ts.map +1 -1
- package/dist/vm/lib/global/mod/matrix.d.ts +13 -14
- package/dist/vm/lib/global/mod/matrix.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/all-any.d.ts +2 -3
- package/dist/vm/lib/global/sequence/all-any.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/entries.d.ts +4 -5
- package/dist/vm/lib/global/sequence/entries.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/find.d.ts +2 -3
- package/dist/vm/lib/global/sequence/find.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/flatten.d.ts +1 -2
- package/dist/vm/lib/global/sequence/flatten.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/len.d.ts +1 -2
- package/dist/vm/lib/global/sequence/len.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/map-filter.d.ts +3 -4
- package/dist/vm/lib/global/sequence/map-filter.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/repeat.d.ts +1 -2
- package/dist/vm/lib/global/sequence/repeat.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/reverse.d.ts +1 -2
- package/dist/vm/lib/global/sequence/reverse.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/sort.d.ts +2 -3
- package/dist/vm/lib/global/sequence/sort.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/with.d.ts +1 -2
- package/dist/vm/lib/global/sequence/with.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/zip.d.ts +1 -2
- package/dist/vm/lib/global/sequence/zip.d.ts.map +1 -1
- package/dist/vm/lib/global/string.d.ts +10 -11
- package/dist/vm/lib/global/string.d.ts.map +1 -1
- package/dist/vm/lib/global/time.d.ts +4 -5
- package/dist/vm/lib/global/time.d.ts.map +1 -1
- package/dist/vm/lib/global/to-primitive.d.ts +4 -5
- package/dist/vm/lib/global/to-primitive.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/cli/execute.ts +8 -5
- package/src/cli/print.ts +35 -23
- package/src/vm/lib/_helpers.ts +8 -3
- package/src/vm/lib/global/debug.ts +24 -3
- package/dist/chunk-RYSPVMVZ.js.map +0 -6
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import type { VmAny } from '../../index.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const cbrt: VmLib<(x: VmAny) => number>;
|
|
2
|
+
export declare const trunc: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const floor: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
|
+
export declare const ceil: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
5
|
+
export declare const round: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
6
|
+
export declare const sign: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
7
|
+
export declare const abs: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
8
|
+
export declare const acos: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
9
|
+
export declare const acosh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
10
|
+
export declare const asin: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
11
|
+
export declare const asinh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
12
|
+
export declare const atan: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
13
|
+
export declare const atanh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
14
|
+
export declare const cos: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
15
|
+
export declare const cosh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
16
|
+
export declare const sin: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
17
|
+
export declare const sinh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
18
|
+
export declare const tan: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
19
|
+
export declare const tanh: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
20
|
+
export declare const exp: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
21
|
+
export declare const expm1: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
22
|
+
export declare const log: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
23
|
+
export declare const log10: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
24
|
+
export declare const log1p: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
25
|
+
export declare const log2: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
26
|
+
export declare const sqrt: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
27
|
+
export declare const cbrt: ((x: VmAny) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
29
28
|
//# sourceMappingURL=math-unary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-unary.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math-unary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"math-unary.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math-unary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAY5C,eAAO,MAAM,KAAK,OAP4B,KAAK,KAAK,MAAM,kEAY5D,CAAC;AACH,eAAO,MAAM,KAAK,OAb4B,KAAK,KAAK,MAAM,kEAkB5D,CAAC;AACH,eAAO,MAAM,IAAI,OAnB6B,KAAK,KAAK,MAAM,kEAwB5D,CAAC;AACH,eAAO,MAAM,KAAK,OAzB4B,KAAK,KAAK,MAAM,kEA8B5D,CAAC;AACH,eAAO,MAAM,IAAI,OA/B6B,KAAK,KAAK,MAAM,kEAoC5D,CAAC;AACH,eAAO,MAAM,GAAG,OArC8B,KAAK,KAAK,MAAM,kEA0C5D,CAAC;AAEH,eAAO,MAAM,IAAI,OA5C6B,KAAK,KAAK,MAAM,kEAiD5D,CAAC;AACH,eAAO,MAAM,KAAK,OAlD4B,KAAK,KAAK,MAAM,kEAuD5D,CAAC;AACH,eAAO,MAAM,IAAI,OAxD6B,KAAK,KAAK,MAAM,kEA6D5D,CAAC;AACH,eAAO,MAAM,KAAK,OA9D4B,KAAK,KAAK,MAAM,kEAmE5D,CAAC;AACH,eAAO,MAAM,IAAI,OApE6B,KAAK,KAAK,MAAM,kEAyE5D,CAAC;AACH,eAAO,MAAM,KAAK,OA1E4B,KAAK,KAAK,MAAM,kEA+E5D,CAAC;AACH,eAAO,MAAM,GAAG,OAhF8B,KAAK,KAAK,MAAM,kEAqF5D,CAAC;AACH,eAAO,MAAM,IAAI,OAtF6B,KAAK,KAAK,MAAM,kEA2F5D,CAAC;AACH,eAAO,MAAM,GAAG,OA5F8B,KAAK,KAAK,MAAM,kEAiG5D,CAAC;AACH,eAAO,MAAM,IAAI,OAlG6B,KAAK,KAAK,MAAM,kEAuG5D,CAAC;AACH,eAAO,MAAM,GAAG,OAxG8B,KAAK,KAAK,MAAM,kEA6G5D,CAAC;AACH,eAAO,MAAM,IAAI,OA9G6B,KAAK,KAAK,MAAM,kEAmH5D,CAAC;AAEH,eAAO,MAAM,GAAG,OArH8B,KAAK,KAAK,MAAM,kEA0H5D,CAAC;AACH,eAAO,MAAM,KAAK,OA3H4B,KAAK,KAAK,MAAM,kEAgI5D,CAAC;AACH,eAAO,MAAM,GAAG,OAjI8B,KAAK,KAAK,MAAM,kEAsI5D,CAAC;AACH,eAAO,MAAM,KAAK,OAvI4B,KAAK,KAAK,MAAM,kEA4I5D,CAAC;AACH,eAAO,MAAM,KAAK,OA7I4B,KAAK,KAAK,MAAM,kEAkJ5D,CAAC;AACH,eAAO,MAAM,IAAI,OAnJ6B,KAAK,KAAK,MAAM,kEAwJ5D,CAAC;AAEH,eAAO,MAAM,IAAI,OA1J6B,KAAK,KAAK,MAAM,kEA+J5D,CAAC;AACH,eAAO,MAAM,IAAI,OAhK6B,KAAK,KAAK,MAAM,kEAqK5D,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const random: VmLib<() => number>;
|
|
1
|
+
export declare const atan2: ((x: import("../../index.js").VmValue | undefined, y: import("../../index.js").VmValue | undefined) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
2
|
+
export declare const pow: ((x: import("../../index.js").VmValue | undefined, y: import("../../index.js").VmValue | undefined) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const random: (() => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
5
4
|
export * from './math-arr.js';
|
|
6
5
|
export * from './math-const.js';
|
|
7
6
|
export * from './math-unary.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/math.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,iLAKhB,CAAC;AACH,eAAO,MAAM,GAAG,iLAKd,CAAC;AACH,eAAO,MAAM,MAAM,iFAKjB,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { type VmArray, type VmConst, type VmValue } from '../../../types/index.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const diagonal: VmLib<(x: VmValue | undefined, k?: VmValue | undefined) => VmConst[]>;
|
|
2
|
+
export declare const size: ((matrix: VmValue | undefined) => [] | [number, number] | [number]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const transpose: ((matrix: VmValue | undefined) => string | number | boolean | import("../../../types/index.js").VmRecord | VmArray | import("../../../types/function.js").VmFunction | import("../../../types/module.js").VmModule<Record<string, VmValue>> | import("../../../types/extern.js").VmExtern<object> | null) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
|
+
export declare const entrywise: ((a: VmValue | undefined, b: VmValue | undefined, f: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
5
|
+
export declare const add: ((a: VmValue | undefined, b: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
6
|
+
export declare const subtract: ((a: VmValue | undefined, b: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
7
|
+
export declare const entrywise_multiply: ((a: VmValue | undefined, b: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
8
|
+
export declare const entrywise_divide: ((a: VmValue | undefined, b: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
9
|
+
export declare const multiply: ((a: VmValue | undefined, b: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
10
|
+
export declare const invert: ((a: VmValue | undefined) => VmConst) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
11
|
+
export declare const zeros: ((...size: readonly (VmValue | undefined)[]) => VmArray) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
12
|
+
export declare const ones: ((...size: readonly (VmValue | undefined)[]) => VmArray) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
13
|
+
export declare const identity: ((...size: readonly (VmValue | undefined)[]) => number[][]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
14
|
+
export declare const diagonal: ((x: VmValue | undefined, k?: VmValue | undefined) => VmConst[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
16
15
|
//# sourceMappingURL=matrix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/mod/matrix.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoC,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/mod/matrix.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoC,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAqCrH,eAAO,MAAM,IAAI,yIAYhB,CAAC;AAEF,eAAO,MAAM,SAAS,+WA0BrB,CAAC;AA8HF,eAAO,MAAM,SAAS,2JAmBrB,CAAC;AAEF,eAAO,MAAM,GAAG,mIAaf,CAAC;AAEF,eAAO,MAAM,QAAQ,mIAapB,CAAC;AAEF,eAAO,MAAM,kBAAkB,mIAa9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,mIAa5B,CAAC;AAEF,eAAO,MAAM,QAAQ,mIAiEpB,CAAC;AAEF,eAAO,MAAM,MAAM,2GAsHlB,CAAC;AAkBF,eAAO,MAAM,KAAK,8HAMhB,CAAC;AAEH,eAAO,MAAM,IAAI,8HAMf,CAAC;AAEH,eAAO,MAAM,QAAQ,iIA0BpB,CAAC;AAEF,eAAO,MAAM,QAAQ,sIA4CpB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const any: VmLib<(data: import("../../../types/index.js").VmValue | undefined, predicate: import("../../../types/index.js").VmValue | undefined) => boolean>;
|
|
1
|
+
export declare const all: ((data: import("../../../types/index.js").VmValue | undefined, predicate: import("../../../types/index.js").VmValue | undefined) => boolean) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
2
|
+
export declare const any: ((data: import("../../../types/index.js").VmValue | undefined, predicate: import("../../../types/index.js").VmValue | undefined) => boolean) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
3
|
//# sourceMappingURL=all-any.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-any.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/all-any.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"all-any.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/all-any.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG,kNAgCf,CAAC;AAEF,eAAO,MAAM,GAAG,kNAgCf,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type VmConst } from '../../../types/index.js';
|
|
2
|
-
import
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const entries: VmLib<(data: import("../../../types/index.js").VmValue | undefined) => {
|
|
2
|
+
export declare const keys: ((data: import("../../../types/index.js").VmValue | undefined) => string[] | number[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const values: ((data: import("../../../types/index.js").VmValue | undefined) => import("../../../types/index.js").VmArray) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
|
+
export declare const entries: ((data: import("../../../types/index.js").VmValue | undefined) => {
|
|
6
5
|
0: number;
|
|
7
6
|
1: VmConst;
|
|
8
7
|
}[] | {
|
|
9
8
|
0: string;
|
|
10
9
|
1: string | number | boolean | import("../../../types/index.js").VmRecord | import("../../../types/index.js").VmArray | null;
|
|
11
|
-
}[]>;
|
|
10
|
+
}[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
12
11
|
//# sourceMappingURL=entries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAI9E,eAAO,MAAM,IAAI,4JAuBhB,CAAC;AAEF,eAAO,MAAM,MAAM,kLAelB,CAAC;AAEF,eAAO,MAAM,OAAO;OAIc,MAAM;OAAK,OAAO;;;;wEAgBnD,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type VmValue } from '../../../types/index.js';
|
|
2
|
-
|
|
3
|
-
export declare const find: VmLib<(data: VmValue | undefined, predicate: VmValue | undefined) => {
|
|
2
|
+
export declare const find: ((data: VmValue | undefined, predicate: VmValue | undefined) => {
|
|
4
3
|
0: number;
|
|
5
4
|
1: string | number | boolean | import("../../../types/index.js").VmRecord | import("../../../types/index.js").VmArray | null;
|
|
6
5
|
} | {
|
|
7
6
|
0: string;
|
|
8
7
|
1: string | number | boolean | import("../../../types/index.js").VmRecord | import("../../../types/index.js").VmArray | null;
|
|
9
|
-
} | null>;
|
|
8
|
+
} | null) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
10
9
|
//# sourceMappingURL=find.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/find.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA2B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/find.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA2B,MAAM,yBAAyB,CAAC;AAGhF,eAAO,MAAM,IAAI;;;;;;6EA4ChB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const flatten: VmLib<(data: import("../../../index.js").VmValue | undefined, depth?: import("../../../index.js").VmValue | undefined) => (string | number | boolean | import("../../../index.js").VmRecord | import("../../../index.js").VmArray | null | undefined)[]>;
|
|
1
|
+
export declare const flatten: ((data: import("../../../index.js").VmValue | undefined, depth?: import("../../../index.js").VmValue | undefined) => (string | number | boolean | import("../../../index.js").VmRecord | import("../../../index.js").VmArray | null | undefined)[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
2
|
//# sourceMappingURL=flatten.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/flatten.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/flatten.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,yTAYnB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const len: VmLib<(arr: import("../../../index.js").VmValue | undefined) => number>;
|
|
1
|
+
export declare const len: ((arr: import("../../../index.js").VmValue | undefined) => number) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
2
|
//# sourceMappingURL=len.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"len.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/len.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"len.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/len.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,wIAYf,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type VmValue } from '../../../types/index.js';
|
|
2
|
-
import { VmLib } from '../../_helpers.js';
|
|
3
2
|
export * from './with.js';
|
|
4
3
|
export * from './entries.js';
|
|
5
4
|
export * from './len.js';
|
|
6
|
-
export declare const map:
|
|
7
|
-
export declare const filter:
|
|
8
|
-
export declare const filter_map:
|
|
5
|
+
export declare const map: ((data: VmValue | undefined, f: VmValue | undefined) => VmValue) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
6
|
+
export declare const filter: ((data: VmValue | undefined, predicate: VmValue | undefined) => VmValue) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
7
|
+
export declare const filter_map: ((data: VmValue | undefined, f: VmValue | undefined) => VmValue) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
9
8
|
//# sourceMappingURL=map-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-filter.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/map-filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"map-filter.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/map-filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG9E,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AAkBzB,eAAO,MAAM,GAAG,sIAef,CAAC;AAEF,eAAO,MAAM,MAAM,8IAmBlB,CAAC;AAEF,eAAO,MAAM,UAAU,sIAmBtB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { VmConst } from '../../../types/index.js';
|
|
2
|
-
import
|
|
3
|
-
export declare const repeat: VmLib<(data: import("../../../types/index.js").VmValue | undefined, times: import("../../../types/index.js").VmValue | undefined) => VmConst[]>;
|
|
2
|
+
export declare const repeat: ((data: import("../../../types/index.js").VmValue | undefined, times: import("../../../types/index.js").VmValue | undefined) => VmConst[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
3
|
//# sourceMappingURL=repeat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeat.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/repeat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"repeat.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/repeat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,eAAO,MAAM,MAAM,gNAuBlB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const reverse: VmLib<(arr: import("../../../index.js").VmValue | undefined) => (import("../../../index.js").VmConst | undefined)[]>;
|
|
1
|
+
export declare const reverse: ((arr: import("../../../index.js").VmValue | undefined) => (import("../../../index.js").VmConst | undefined)[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
2
|
//# sourceMappingURL=reverse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/reverse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/reverse.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,qLAcnB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VmConst, VmValue } from '../../../types/index.js';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const sort_by: VmLib<(data: VmValue | undefined, key_fn: VmValue | undefined, comparator: VmValue | undefined) => VmConst[]>;
|
|
2
|
+
export declare const sort: ((data: VmValue | undefined, comparator: VmValue | undefined) => VmConst[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const sort_by: ((data: VmValue | undefined, key_fn: VmValue | undefined, comparator: VmValue | undefined) => VmConst[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
5
4
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/sort.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/sort.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AA4BvE,eAAO,MAAM,IAAI,iJAwBhB,CAAC;AAEF,eAAO,MAAM,OAAO,8KAgCnB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type VmArray, type VmValue } from '../../../types/index.js';
|
|
2
|
-
import
|
|
3
|
-
declare const _with: VmLib<(data: VmValue | undefined, ...entries: (VmValue | undefined)[]) => import("../../../types/index.js").VmRecord | VmArray>;
|
|
2
|
+
declare const _with: ((data: VmValue | undefined, ...entries: (VmValue | undefined)[]) => import("../../../types/index.js").VmRecord | VmArray) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
3
|
export { _with as 'with' };
|
|
5
4
|
//# sourceMappingURL=with.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/with.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,KAAK,OAAO,EAEZ,KAAK,OAAO,EACf,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"with.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/with.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,KAAK,OAAO,EAEZ,KAAK,OAAO,EACf,MAAM,yBAAyB,CAAC;AA+DjC,QAAA,MAAM,KAAK,gMA8DV,CAAC;AACF,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type VmConst } from '../../../types/index.js';
|
|
2
|
-
import
|
|
3
|
-
export declare const zip: VmLib<(data: import("../../../types/index.js").VmValue | undefined) => Record<string | number, VmConst>[]>;
|
|
2
|
+
export declare const zip: ((data: import("../../../types/index.js").VmValue | undefined) => Record<string | number, VmConst>[]) & import("../../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
3
|
//# sourceMappingURL=zip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/zip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,OAAO,EAAgB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../../../../src/vm/lib/global/sequence/zip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,OAAO,EAAgB,MAAM,yBAAyB,CAAC;AAIhF,eAAO,MAAM,GAAG,2KAiCf,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const join: VmLib<(arr: import("../../index.js").VmValue | undefined, separator?: import("../../index.js").VmValue | undefined) => string>;
|
|
1
|
+
export declare const chars: ((str: import("../../index.js").VmValue | undefined) => string[]) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
2
|
+
export declare const starts_with: ((str: import("../../index.js").VmValue | undefined, search: import("../../index.js").VmValue | undefined) => boolean) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const ends_with: ((str: import("../../index.js").VmValue | undefined, search: import("../../index.js").VmValue | undefined) => boolean) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
|
+
export declare const contains: ((str: import("../../index.js").VmValue | undefined, search: import("../../index.js").VmValue | undefined) => boolean) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
5
|
+
export declare const trim_start: ((str: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
6
|
+
export declare const trim_end: ((str: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
7
|
+
export declare const trim: ((str: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
8
|
+
export declare const replace: ((str: import("../../index.js").VmValue | undefined, search: import("../../index.js").VmValue | undefined, replacement?: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
9
|
+
export declare const split: ((str: import("../../index.js").VmValue | undefined, separator?: import("../../index.js").VmValue | undefined) => string[]) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
10
|
+
export declare const join: ((arr: import("../../index.js").VmValue | undefined, separator?: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
12
11
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/string.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/string.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,oIAYjB,CAAC;AAEF,eAAO,MAAM,WAAW,yLAavB,CAAC;AACF,eAAO,MAAM,SAAS,yLAarB,CAAC;AAEF,eAAO,MAAM,QAAQ,yLAapB,CAAC;AAEF,eAAO,MAAM,UAAU,kIAYtB,CAAC;AAEF,eAAO,MAAM,QAAQ,kIAYpB,CAAC;AAEF,eAAO,MAAM,IAAI,kIAYhB,CAAC;AAEF,eAAO,MAAM,OAAO,oPAanB,CAAC;AAEF,eAAO,MAAM,KAAK,8LAejB,CAAC;AAEF,eAAO,MAAM,IAAI,4LAahB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const to_datetime: VmLib<(datetime: import("../../index.js").VmValue | undefined, offset: import("../../index.js").VmValue | undefined) => {
|
|
1
|
+
export declare const to_timestamp: ((datetime: import("../../index.js").VmValue | undefined) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
2
|
+
export declare const to_datetime: ((datetime: import("../../index.js").VmValue | undefined, offset: import("../../index.js").VmValue | undefined) => {
|
|
4
3
|
year: number;
|
|
5
4
|
month: number;
|
|
6
5
|
day: number;
|
|
@@ -10,6 +9,6 @@ export declare const to_datetime: VmLib<(datetime: import("../../index.js").VmVa
|
|
|
10
9
|
millisecond: number;
|
|
11
10
|
dayOfWeek: number;
|
|
12
11
|
offset: number;
|
|
13
|
-
} | null>;
|
|
14
|
-
export declare const to_iso8601:
|
|
12
|
+
} | null) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
13
|
+
export declare const to_iso8601: ((datetime: import("../../index.js").VmValue | undefined) => string | null) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
15
14
|
//# sourceMappingURL=time.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/time.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,uIAqBxB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;0EA8BvB,CAAC;AAEF,eAAO,MAAM,UAAU,8IAatB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const format: VmLib<(data: import("../../index.js").VmValue | undefined, format: import("../../index.js").VmValue | undefined) => string>;
|
|
1
|
+
export declare const to_string: ((data: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
2
|
+
export declare const to_number: ((data: import("../../index.js").VmValue | undefined) => number) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
3
|
+
export declare const to_boolean: ((data: import("../../index.js").VmValue | undefined) => boolean) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
4
|
+
export declare const format: ((data: import("../../index.js").VmValue | undefined, format: import("../../index.js").VmValue | undefined) => string) & import("../_helpers.js").VmLibOption & Record<string, unknown>;
|
|
6
5
|
//# sourceMappingURL=to-primitive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-primitive.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/to-primitive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-primitive.d.ts","sourceRoot":"","sources":["../../../../src/vm/lib/global/to-primitive.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,mIAYrB,CAAC;AAEF,eAAO,MAAM,SAAS,mIAYrB,CAAC;AAEF,eAAO,MAAM,UAAU,oIAYtB,CAAC;AAEF,eAAO,MAAM,MAAM,yLAYlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirascript/mirascript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "An expression based scripting language.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
"commander": "^14.0.2",
|
|
37
37
|
"js-base64": "^3.7.8",
|
|
38
38
|
"source-map-js": "^1.2.1",
|
|
39
|
-
"
|
|
40
|
-
"@mirascript/napi": "~0.1.
|
|
39
|
+
"supports-color": "^10.2.2",
|
|
40
|
+
"@mirascript/napi": "~0.1.6",
|
|
41
|
+
"@mirascript/wasm": "~0.1.6"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/node": "^24.10.0",
|
package/src/cli/execute.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import styles from 'ansi-styles';
|
|
3
|
+
import supportsColor from 'supports-color';
|
|
3
4
|
import { compile } from '../index.js';
|
|
4
5
|
import { createVmContext, VmFunction, type VmValue } from '../vm/index.js';
|
|
5
6
|
import { debug_print } from '../vm/lib/global/debug.js';
|
|
@@ -17,10 +18,7 @@ export async function execute(
|
|
|
17
18
|
const r = f(
|
|
18
19
|
createVmContext({
|
|
19
20
|
debug_print: VmFunction((...values) => {
|
|
20
|
-
console.log(
|
|
21
|
-
'\u001B[46;30m MiraScript \u001B[0m',
|
|
22
|
-
...values.map((v) => (typeof v == 'string' ? v : print(v))),
|
|
23
|
-
);
|
|
21
|
+
console.log(...debug_print.prefix, ...values.map((v) => (typeof v == 'string' ? v : print(v))));
|
|
24
22
|
}, debug_print),
|
|
25
23
|
...variables,
|
|
26
24
|
}),
|
|
@@ -31,7 +29,12 @@ export async function execute(
|
|
|
31
29
|
console.log(print(r));
|
|
32
30
|
}
|
|
33
31
|
} catch (ex) {
|
|
34
|
-
|
|
32
|
+
const { stack } = ex as Error;
|
|
33
|
+
if (supportsColor.stderr) {
|
|
34
|
+
console.error(styles.red.open + stack + styles.red.close);
|
|
35
|
+
} else {
|
|
36
|
+
console.error(stack);
|
|
37
|
+
}
|
|
35
38
|
process.exitCode = 2;
|
|
36
39
|
}
|
|
37
40
|
}
|
package/src/cli/print.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styles from 'ansi-styles';
|
|
2
|
+
import supportsColor from 'supports-color';
|
|
2
3
|
import {
|
|
3
4
|
serialize,
|
|
4
5
|
serializeNumber,
|
|
@@ -9,36 +10,47 @@ import {
|
|
|
9
10
|
} from '../subtle.js';
|
|
10
11
|
import type { VmAny, VmRecord } from '../vm/index.js';
|
|
11
12
|
|
|
13
|
+
const noColor = !supportsColor.stdout;
|
|
14
|
+
|
|
12
15
|
const options: Partial<SerializeOptions> = {
|
|
13
16
|
maxDepth: 3,
|
|
14
|
-
serializeNil: () => styles.gray.open + serializeNil() + styles.gray.close,
|
|
15
|
-
serializeBoolean: (v) => styles.blue.open + serializeBoolean(v) + styles.blue.close,
|
|
16
|
-
serializeNumber: (v) => styles.yellow.open + serializeNumber(v) + styles.yellow.close,
|
|
17
|
-
serializeStringQuote:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
serializeNil: noColor ? undefined : () => styles.gray.open + serializeNil() + styles.gray.close,
|
|
18
|
+
serializeBoolean: noColor ? undefined : (v) => styles.blue.open + serializeBoolean(v) + styles.blue.close,
|
|
19
|
+
serializeNumber: noColor ? undefined : (v) => styles.yellow.open + serializeNumber(v) + styles.yellow.close,
|
|
20
|
+
serializeStringQuote: noColor
|
|
21
|
+
? undefined
|
|
22
|
+
: (v, open) => {
|
|
23
|
+
const q = styles.dim.open + v + styles.dim.close;
|
|
24
|
+
if (open) {
|
|
25
|
+
return styles.green.open + q;
|
|
26
|
+
} else {
|
|
27
|
+
return q + styles.green.close;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
serializeStringEscape: noColor ? undefined : (v) => styles.bold.open + v + styles.bold.close,
|
|
31
|
+
serializePropName: noColor ? undefined : (v) => styles.whiteBright.open + String(v) + styles.whiteBright.close,
|
|
32
|
+
serializeFunction: noColor
|
|
33
|
+
? operations.$ToString
|
|
34
|
+
: (v) => styles.cyan.open + operations.$ToString(v) + styles.cyan.close,
|
|
35
|
+
serializeModule: noColor
|
|
36
|
+
? (v, depth, options) => {
|
|
37
|
+
return operations.$ToString(v) + ' ' + options.serializeRecord(v.value as VmRecord, depth, options);
|
|
38
|
+
}
|
|
39
|
+
: (v, depth, options) => {
|
|
40
|
+
return (
|
|
41
|
+
styles.magenta.open +
|
|
42
|
+
operations.$ToString(v) +
|
|
43
|
+
styles.magenta.close +
|
|
44
|
+
' ' +
|
|
45
|
+
options.serializeRecord(v.value as VmRecord, depth, options)
|
|
46
|
+
);
|
|
47
|
+
},
|
|
37
48
|
};
|
|
38
49
|
|
|
39
50
|
/** 序列化值 */
|
|
40
51
|
export function print(value: VmAny, depth = 3): string {
|
|
41
52
|
if (value === undefined) {
|
|
53
|
+
if (noColor) return '<uninitialized>';
|
|
42
54
|
return styles.gray.open + '<uninitialized>' + styles.gray.close;
|
|
43
55
|
}
|
|
44
56
|
return serialize(value, { ...options, maxDepth: depth });
|
package/src/vm/lib/_helpers.ts
CHANGED
|
@@ -191,17 +191,22 @@ export type VmLibOption = Pick<
|
|
|
191
191
|
export type VmLib<T extends VmFunctionLike = VmFunctionLike> = T & VmLibOption;
|
|
192
192
|
|
|
193
193
|
/** 创建库函数 */
|
|
194
|
-
export function VmLib<T extends VmFunctionLike
|
|
194
|
+
export function VmLib<T extends VmFunctionLike, P extends Record<string, unknown>>(
|
|
195
|
+
fn: T,
|
|
196
|
+
option: VmLibOption,
|
|
197
|
+
properties?: P,
|
|
198
|
+
): VmLib<T> & P {
|
|
195
199
|
/* c8 ignore next 2 */
|
|
196
200
|
if (typeof fn != 'function') throw new TypeError('Invalid function');
|
|
197
201
|
if (isVmFunction(fn)) throw new TypeError('Cannot create VmLib from a VmFunction');
|
|
198
202
|
|
|
199
|
-
const ret = fn as T & VmLibOption as Writable<VmLibOption>;
|
|
203
|
+
const ret = fn as T & VmLibOption & P as Writable<T & VmLibOption & P>;
|
|
204
|
+
Object.assign(ret, properties);
|
|
200
205
|
ret.params = option.params;
|
|
201
206
|
ret.paramsType = option.paramsType;
|
|
202
207
|
ret.returns = option.returns;
|
|
203
208
|
ret.returnsType = option.returnsType;
|
|
204
209
|
ret.summary = option.summary;
|
|
205
210
|
ret.examples = option.examples;
|
|
206
|
-
return ret as T & VmLibOption;
|
|
211
|
+
return ret as T & VmLibOption & P;
|
|
207
212
|
}
|