@simtest-js/funnel 1.0.0-beta.10
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/README.md +67 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/wasm/simtest_funnel_wasm.d.ts +17 -0
- package/dist/wasm/simtest_funnel_wasm.js +9 -0
- package/dist/wasm/simtest_funnel_wasm_bg.js +363 -0
- package/dist/wasm/simtest_funnel_wasm_bg.wasm +0 -0
- package/dist/wasm/simtest_funnel_wasm_bg.wasm.d.ts +12 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @simtest-js/funnel
|
|
2
|
+
|
|
3
|
+
TypeScript / JavaScript SDK for the
|
|
4
|
+
[simtest-funnel](https://github.com/Symoptia/simtest-funnel) trajectory
|
|
5
|
+
comparison library. Thin wrapper around the Rust core compiled to
|
|
6
|
+
WebAssembly via `wasm-bindgen`.
|
|
7
|
+
|
|
8
|
+
See the workspace
|
|
9
|
+
[`README.md`](https://github.com/Symoptia/simtest-funnel#differences-from-lbnl-funnel)
|
|
10
|
+
for how this library differs from LBNL Funnel (signed errors,
|
|
11
|
+
`MissingReference` / `MissingTest` statuses, default tolerances).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @simtest-js/funnel
|
|
17
|
+
# or: npm install @simtest-js/funnel
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { compare, Status } from "@simtest-js/funnel";
|
|
24
|
+
|
|
25
|
+
const tRef = Float64Array.from({ length: 101 }, (_, i) => i / 100);
|
|
26
|
+
const yRef = tRef.map((t) => Math.sin(2 * Math.PI * t));
|
|
27
|
+
const yTest = yRef.map((y) => y + 0.01);
|
|
28
|
+
|
|
29
|
+
const result = compare(tRef, yRef, tRef, yTest, {
|
|
30
|
+
tolerances: { atoly: 0.05 },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (result.status === Status.Pass) {
|
|
34
|
+
console.log("inside funnel");
|
|
35
|
+
} else {
|
|
36
|
+
console.log("status:", result.status, "signed errors:", result.errorsY);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`compare()` accepts `ArrayLike<number>` or `Float64Array` inputs and
|
|
41
|
+
returns a `CompareResult` whose `errorsY` array is **signed** — positive
|
|
42
|
+
above the upper bound, negative below the lower bound.
|
|
43
|
+
|
|
44
|
+
## Status codes
|
|
45
|
+
|
|
46
|
+
Mirror `simtest_funnel_core::Status`:
|
|
47
|
+
|
|
48
|
+
| Name | Code |
|
|
49
|
+
|---------------------|-----:|
|
|
50
|
+
| `Pass` | 0 |
|
|
51
|
+
| `Fail` | -1 |
|
|
52
|
+
| `MissingReference` | 1 |
|
|
53
|
+
| `MissingTest` | 2 |
|
|
54
|
+
| `NonMonotonic` | 10 |
|
|
55
|
+
| `LengthMismatch` | 11 |
|
|
56
|
+
| `EmptyRange` | 12 |
|
|
57
|
+
| `BufferTooSmall` | 13 |
|
|
58
|
+
| `InsufficientData` | 14 |
|
|
59
|
+
|
|
60
|
+
## Reference documentation
|
|
61
|
+
|
|
62
|
+
A full `typedoc`-generated API reference is published alongside every
|
|
63
|
+
release. To build it locally:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
make docs-js # writes target/doc/js/index.html
|
|
67
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Tolerances passed to {@link compare}. */
|
|
2
|
+
export interface Tolerances {
|
|
3
|
+
atolx?: number;
|
|
4
|
+
atoly?: number;
|
|
5
|
+
ltolx?: number;
|
|
6
|
+
ltoly?: number;
|
|
7
|
+
rtolx?: number;
|
|
8
|
+
rtoly?: number;
|
|
9
|
+
}
|
|
10
|
+
/** X-range filter. */
|
|
11
|
+
export interface XRange {
|
|
12
|
+
lo: number;
|
|
13
|
+
hi: number;
|
|
14
|
+
}
|
|
15
|
+
/** Options for {@link compare}. */
|
|
16
|
+
export interface Options {
|
|
17
|
+
tolerances?: Tolerances;
|
|
18
|
+
xRange?: XRange;
|
|
19
|
+
}
|
|
20
|
+
/** Status codes (mirror `simtest_funnel_core::Status`). */
|
|
21
|
+
export declare const Status: {
|
|
22
|
+
readonly Pass: 0;
|
|
23
|
+
readonly Fail: -1;
|
|
24
|
+
readonly MissingReference: 1;
|
|
25
|
+
readonly MissingTest: 2;
|
|
26
|
+
readonly NonMonotonic: 10;
|
|
27
|
+
readonly LengthMismatch: 11;
|
|
28
|
+
readonly EmptyRange: 12;
|
|
29
|
+
readonly BufferTooSmall: 13;
|
|
30
|
+
readonly InsufficientData: 14;
|
|
31
|
+
};
|
|
32
|
+
export type StatusCode = (typeof Status)[keyof typeof Status];
|
|
33
|
+
/** Result of {@link compare}. Errors are signed. */
|
|
34
|
+
export interface CompareResult {
|
|
35
|
+
status: StatusCode;
|
|
36
|
+
lowerX: Float64Array;
|
|
37
|
+
lowerY: Float64Array;
|
|
38
|
+
upperX: Float64Array;
|
|
39
|
+
upperY: Float64Array;
|
|
40
|
+
errorsX: Float64Array;
|
|
41
|
+
errorsY: Float64Array;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Compare a test trajectory against a reference. Errors are signed
|
|
45
|
+
* (positive above upper, negative below lower).
|
|
46
|
+
*/
|
|
47
|
+
export declare function compare(referenceX: ArrayLike<number> | Float64Array, referenceY: ArrayLike<number> | Float64Array, testX: ArrayLike<number> | Float64Array, testY: ArrayLike<number> | Float64Array, options?: Options): CompareResult;
|
|
48
|
+
/** Returns the default options. */
|
|
49
|
+
export declare function defaultOptions(): Options;
|
|
50
|
+
/** Returns the core crate version. */
|
|
51
|
+
export declare function version(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Plot interface shared with Plotly.js. We declare only the minimal
|
|
54
|
+
* surface we need so that users can bring their own Plotly build
|
|
55
|
+
* (peer dependency).
|
|
56
|
+
*/
|
|
57
|
+
export interface PlotlyLike {
|
|
58
|
+
newPlot(el: HTMLElement, data: unknown[], layout?: unknown, config?: unknown): Promise<unknown>;
|
|
59
|
+
}
|
|
60
|
+
/** Trace inputs to {@link createFunnelPlot}. */
|
|
61
|
+
export interface CreateFunnelPlotInputs {
|
|
62
|
+
reference: {
|
|
63
|
+
x: ArrayLike<number>;
|
|
64
|
+
y: ArrayLike<number>;
|
|
65
|
+
name?: string;
|
|
66
|
+
};
|
|
67
|
+
test: {
|
|
68
|
+
x: ArrayLike<number>;
|
|
69
|
+
y: ArrayLike<number>;
|
|
70
|
+
name?: string;
|
|
71
|
+
};
|
|
72
|
+
result: CompareResult;
|
|
73
|
+
}
|
|
74
|
+
/** Render a funnel plot into `el`. */
|
|
75
|
+
export declare function createFunnelPlot(plotly: PlotlyLike, el: HTMLElement, inputs: CreateFunnelPlotInputs, layout?: Record<string, unknown>): Promise<unknown>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as wasm from './wasm/simtest_funnel_wasm.js';
|
|
2
|
+
/** Status codes (mirror `simtest_funnel_core::Status`). */
|
|
3
|
+
export const Status = {
|
|
4
|
+
Pass: 0,
|
|
5
|
+
Fail: -1,
|
|
6
|
+
MissingReference: 1,
|
|
7
|
+
MissingTest: 2,
|
|
8
|
+
NonMonotonic: 10,
|
|
9
|
+
LengthMismatch: 11,
|
|
10
|
+
EmptyRange: 12,
|
|
11
|
+
BufferTooSmall: 13,
|
|
12
|
+
InsufficientData: 14,
|
|
13
|
+
};
|
|
14
|
+
function toF64(v) {
|
|
15
|
+
return v instanceof Float64Array
|
|
16
|
+
? v
|
|
17
|
+
: Float64Array.from(v);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compare a test trajectory against a reference. Errors are signed
|
|
21
|
+
* (positive above upper, negative below lower).
|
|
22
|
+
*/
|
|
23
|
+
export function compare(referenceX, referenceY, testX, testY, options) {
|
|
24
|
+
const raw = wasm.compare(toF64(referenceX), toF64(referenceY), toF64(testX), toF64(testY),
|
|
25
|
+
// biome-ignore lint/suspicious/noExplicitAny: WASM glue returns `any`
|
|
26
|
+
(options ?? null));
|
|
27
|
+
const r = raw;
|
|
28
|
+
return {
|
|
29
|
+
status: r.status,
|
|
30
|
+
lowerX: Float64Array.from(r.lowerX),
|
|
31
|
+
lowerY: Float64Array.from(r.lowerY),
|
|
32
|
+
upperX: Float64Array.from(r.upperX),
|
|
33
|
+
upperY: Float64Array.from(r.upperY),
|
|
34
|
+
errorsX: Float64Array.from(r.errorsX),
|
|
35
|
+
errorsY: Float64Array.from(r.errorsY),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Returns the default options. */
|
|
39
|
+
export function defaultOptions() {
|
|
40
|
+
return wasm.defaultOptions();
|
|
41
|
+
}
|
|
42
|
+
/** Returns the core crate version. */
|
|
43
|
+
export function version() {
|
|
44
|
+
return wasm.version();
|
|
45
|
+
}
|
|
46
|
+
/** Render a funnel plot into `el`. */
|
|
47
|
+
export async function createFunnelPlot(plotly, el, inputs, layout) {
|
|
48
|
+
const traces = [
|
|
49
|
+
{
|
|
50
|
+
x: Array.from(inputs.reference.x),
|
|
51
|
+
y: Array.from(inputs.reference.y),
|
|
52
|
+
name: inputs.reference.name ?? 'reference',
|
|
53
|
+
mode: 'lines',
|
|
54
|
+
type: 'scatter',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
x: Array.from(inputs.test.x),
|
|
58
|
+
y: Array.from(inputs.test.y),
|
|
59
|
+
name: inputs.test.name ?? 'test',
|
|
60
|
+
mode: 'lines',
|
|
61
|
+
type: 'scatter',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
x: Array.from(inputs.result.lowerX),
|
|
65
|
+
y: Array.from(inputs.result.lowerY),
|
|
66
|
+
name: 'lower bound',
|
|
67
|
+
mode: 'lines',
|
|
68
|
+
line: { dash: 'dot' },
|
|
69
|
+
type: 'scatter',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
x: Array.from(inputs.result.upperX),
|
|
73
|
+
y: Array.from(inputs.result.upperY),
|
|
74
|
+
name: 'upper bound',
|
|
75
|
+
mode: 'lines',
|
|
76
|
+
line: { dash: 'dot' },
|
|
77
|
+
type: 'scatter',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
x: Array.from(inputs.result.errorsX),
|
|
81
|
+
y: Array.from(inputs.result.errorsY).map((v) => Math.abs(v)),
|
|
82
|
+
name: 'error',
|
|
83
|
+
mode: 'lines',
|
|
84
|
+
type: 'scatter',
|
|
85
|
+
yaxis: 'y2',
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const finalLayout = {
|
|
89
|
+
title: 'Funnel comparison',
|
|
90
|
+
yaxis: { title: 'value' },
|
|
91
|
+
yaxis2: { title: '|error|', overlaying: 'y', side: 'right' },
|
|
92
|
+
...(layout ?? {}),
|
|
93
|
+
};
|
|
94
|
+
return plotly.newPlot(el, traces, finalLayout);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAC;AAwBtD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;IACR,gBAAgB,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;CACZ,CAAC;AAcX,SAAS,KAAK,CAAC,CAAmC;IAChD,OAAO,CAAC,YAAY,YAAY;QAC9B,CAAC,C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AC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5D,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI;SACZ;KACF,CAAC;IACF,MAAM,WAAW,GAAG;QAClB,KAAK,EAAE,mBAAmB;QAC1B,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QACzB,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC5D,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;KAClB,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Compare `test` against `reference`.
|
|
6
|
+
*/
|
|
7
|
+
export function compare(reference_x: Float64Array, reference_y: Float64Array, test_x: Float64Array, test_y: Float64Array, options: any): any;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns default Options as a JS object.
|
|
11
|
+
*/
|
|
12
|
+
export function defaultOptions(): any;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns the core crate version.
|
|
16
|
+
*/
|
|
17
|
+
export function version(): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./simtest_funnel_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./simtest_funnel_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./simtest_funnel_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
compare, defaultOptions, version
|
|
9
|
+
} from "./simtest_funnel_wasm_bg.js";
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare `test` against `reference`.
|
|
3
|
+
* @param {Float64Array} reference_x
|
|
4
|
+
* @param {Float64Array} reference_y
|
|
5
|
+
* @param {Float64Array} test_x
|
|
6
|
+
* @param {Float64Array} test_y
|
|
7
|
+
* @param {any} options
|
|
8
|
+
* @returns {any}
|
|
9
|
+
*/
|
|
10
|
+
export function compare(reference_x, reference_y, test_x, test_y, options) {
|
|
11
|
+
const ret = wasm.compare(reference_x, reference_y, test_x, test_y, options);
|
|
12
|
+
if (ret[2]) {
|
|
13
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
14
|
+
}
|
|
15
|
+
return takeFromExternrefTable0(ret[0]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns default Options as a JS object.
|
|
20
|
+
* @returns {any}
|
|
21
|
+
*/
|
|
22
|
+
export function defaultOptions() {
|
|
23
|
+
const ret = wasm.defaultOptions();
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the core crate version.
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function version() {
|
|
32
|
+
let deferred1_0;
|
|
33
|
+
let deferred1_1;
|
|
34
|
+
try {
|
|
35
|
+
const ret = wasm.version();
|
|
36
|
+
deferred1_0 = ret[0];
|
|
37
|
+
deferred1_1 = ret[1];
|
|
38
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
39
|
+
} finally {
|
|
40
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
44
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
45
|
+
return ret;
|
|
46
|
+
}
|
|
47
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
48
|
+
const ret = String(arg1);
|
|
49
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
50
|
+
const len1 = WASM_VECTOR_LEN;
|
|
51
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
52
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
53
|
+
}
|
|
54
|
+
export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
|
|
55
|
+
const v = arg0;
|
|
56
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
57
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
58
|
+
}
|
|
59
|
+
export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
|
|
60
|
+
const ret = debugString(arg1);
|
|
61
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
62
|
+
const len1 = WASM_VECTOR_LEN;
|
|
63
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
64
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
65
|
+
}
|
|
66
|
+
export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
|
|
67
|
+
const ret = arg0 in arg1;
|
|
68
|
+
return ret;
|
|
69
|
+
}
|
|
70
|
+
export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
|
|
71
|
+
const ret = arg0 === null;
|
|
72
|
+
return ret;
|
|
73
|
+
}
|
|
74
|
+
export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
|
|
75
|
+
const val = arg0;
|
|
76
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
77
|
+
return ret;
|
|
78
|
+
}
|
|
79
|
+
export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
|
|
80
|
+
const ret = arg0 === undefined;
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
|
|
84
|
+
const ret = arg0 == arg1;
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
|
|
88
|
+
const obj = arg1;
|
|
89
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
90
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
91
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
92
|
+
}
|
|
93
|
+
export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
|
|
94
|
+
const obj = arg1;
|
|
95
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
96
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
97
|
+
var len1 = WASM_VECTOR_LEN;
|
|
98
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
99
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
100
|
+
}
|
|
101
|
+
export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
|
|
102
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
103
|
+
}
|
|
104
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
105
|
+
const ret = arg0[arg1];
|
|
106
|
+
return ret;
|
|
107
|
+
}
|
|
108
|
+
export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
|
|
109
|
+
let result;
|
|
110
|
+
try {
|
|
111
|
+
result = arg0 instanceof ArrayBuffer;
|
|
112
|
+
} catch (_) {
|
|
113
|
+
result = false;
|
|
114
|
+
}
|
|
115
|
+
const ret = result;
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
|
|
119
|
+
let result;
|
|
120
|
+
try {
|
|
121
|
+
result = arg0 instanceof Uint8Array;
|
|
122
|
+
} catch (_) {
|
|
123
|
+
result = false;
|
|
124
|
+
}
|
|
125
|
+
const ret = result;
|
|
126
|
+
return ret;
|
|
127
|
+
}
|
|
128
|
+
export function __wbg_length_9f1775224cf1d815(arg0) {
|
|
129
|
+
const ret = arg0.length;
|
|
130
|
+
return ret;
|
|
131
|
+
}
|
|
132
|
+
export function __wbg_length_d807629e96c741b8(arg0) {
|
|
133
|
+
const ret = arg0.length;
|
|
134
|
+
return ret;
|
|
135
|
+
}
|
|
136
|
+
export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
137
|
+
const ret = new Uint8Array(arg0);
|
|
138
|
+
return ret;
|
|
139
|
+
}
|
|
140
|
+
export function __wbg_new_682678e2f47e32bc() {
|
|
141
|
+
const ret = new Array();
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
export function __wbg_new_aa8d0fa9762c29bd() {
|
|
145
|
+
const ret = new Object();
|
|
146
|
+
return ret;
|
|
147
|
+
}
|
|
148
|
+
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
149
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
150
|
+
}
|
|
151
|
+
export function __wbg_prototypesetcall_c5875dab42ff6b97(arg0, arg1, arg2) {
|
|
152
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
|
|
153
|
+
}
|
|
154
|
+
export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
|
|
155
|
+
arg0[arg1 >>> 0] = arg2;
|
|
156
|
+
}
|
|
157
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
158
|
+
arg0[arg1] = arg2;
|
|
159
|
+
}
|
|
160
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
161
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
162
|
+
const ret = arg0;
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
166
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
167
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
168
|
+
return ret;
|
|
169
|
+
}
|
|
170
|
+
export function __wbindgen_init_externref_table() {
|
|
171
|
+
const table = wasm.__wbindgen_externrefs;
|
|
172
|
+
const offset = table.grow(4);
|
|
173
|
+
table.set(0, undefined);
|
|
174
|
+
table.set(offset + 0, undefined);
|
|
175
|
+
table.set(offset + 1, null);
|
|
176
|
+
table.set(offset + 2, true);
|
|
177
|
+
table.set(offset + 3, false);
|
|
178
|
+
}
|
|
179
|
+
function debugString(val) {
|
|
180
|
+
// primitive types
|
|
181
|
+
const type = typeof val;
|
|
182
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
183
|
+
return `${val}`;
|
|
184
|
+
}
|
|
185
|
+
if (type == 'string') {
|
|
186
|
+
return `"${val}"`;
|
|
187
|
+
}
|
|
188
|
+
if (type == 'symbol') {
|
|
189
|
+
const description = val.description;
|
|
190
|
+
if (description == null) {
|
|
191
|
+
return 'Symbol';
|
|
192
|
+
} else {
|
|
193
|
+
return `Symbol(${description})`;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (type == 'function') {
|
|
197
|
+
const name = val.name;
|
|
198
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
199
|
+
return `Function(${name})`;
|
|
200
|
+
} else {
|
|
201
|
+
return 'Function';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// objects
|
|
205
|
+
if (Array.isArray(val)) {
|
|
206
|
+
const length = val.length;
|
|
207
|
+
let debug = '[';
|
|
208
|
+
if (length > 0) {
|
|
209
|
+
debug += debugString(val[0]);
|
|
210
|
+
}
|
|
211
|
+
for(let i = 1; i < length; i++) {
|
|
212
|
+
debug += ', ' + debugString(val[i]);
|
|
213
|
+
}
|
|
214
|
+
debug += ']';
|
|
215
|
+
return debug;
|
|
216
|
+
}
|
|
217
|
+
// Test for built-in
|
|
218
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
219
|
+
let className;
|
|
220
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
221
|
+
className = builtInMatches[1];
|
|
222
|
+
} else {
|
|
223
|
+
// Failed to match the standard '[object ClassName]'
|
|
224
|
+
return toString.call(val);
|
|
225
|
+
}
|
|
226
|
+
if (className == 'Object') {
|
|
227
|
+
// we're a user defined class or Object
|
|
228
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
229
|
+
// easier than looping through ownProperties of `val`.
|
|
230
|
+
try {
|
|
231
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
232
|
+
} catch (_) {
|
|
233
|
+
return 'Object';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// errors
|
|
237
|
+
if (val instanceof Error) {
|
|
238
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
239
|
+
}
|
|
240
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
241
|
+
return className;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
245
|
+
ptr = ptr >>> 0;
|
|
246
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
250
|
+
ptr = ptr >>> 0;
|
|
251
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let cachedDataViewMemory0 = null;
|
|
255
|
+
function getDataViewMemory0() {
|
|
256
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
257
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
258
|
+
}
|
|
259
|
+
return cachedDataViewMemory0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
263
|
+
function getFloat64ArrayMemory0() {
|
|
264
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
265
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
266
|
+
}
|
|
267
|
+
return cachedFloat64ArrayMemory0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getStringFromWasm0(ptr, len) {
|
|
271
|
+
ptr = ptr >>> 0;
|
|
272
|
+
return decodeText(ptr, len);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let cachedUint8ArrayMemory0 = null;
|
|
276
|
+
function getUint8ArrayMemory0() {
|
|
277
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
278
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
279
|
+
}
|
|
280
|
+
return cachedUint8ArrayMemory0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function isLikeNone(x) {
|
|
284
|
+
return x === undefined || x === null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
288
|
+
if (realloc === undefined) {
|
|
289
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
290
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
291
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
292
|
+
WASM_VECTOR_LEN = buf.length;
|
|
293
|
+
return ptr;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let len = arg.length;
|
|
297
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
298
|
+
|
|
299
|
+
const mem = getUint8ArrayMemory0();
|
|
300
|
+
|
|
301
|
+
let offset = 0;
|
|
302
|
+
|
|
303
|
+
for (; offset < len; offset++) {
|
|
304
|
+
const code = arg.charCodeAt(offset);
|
|
305
|
+
if (code > 0x7F) break;
|
|
306
|
+
mem[ptr + offset] = code;
|
|
307
|
+
}
|
|
308
|
+
if (offset !== len) {
|
|
309
|
+
if (offset !== 0) {
|
|
310
|
+
arg = arg.slice(offset);
|
|
311
|
+
}
|
|
312
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
313
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
314
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
315
|
+
|
|
316
|
+
offset += ret.written;
|
|
317
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
WASM_VECTOR_LEN = offset;
|
|
321
|
+
return ptr;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function takeFromExternrefTable0(idx) {
|
|
325
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
326
|
+
wasm.__externref_table_dealloc(idx);
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
331
|
+
cachedTextDecoder.decode();
|
|
332
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
333
|
+
let numBytesDecoded = 0;
|
|
334
|
+
function decodeText(ptr, len) {
|
|
335
|
+
numBytesDecoded += len;
|
|
336
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
337
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
338
|
+
cachedTextDecoder.decode();
|
|
339
|
+
numBytesDecoded = len;
|
|
340
|
+
}
|
|
341
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const cachedTextEncoder = new TextEncoder();
|
|
345
|
+
|
|
346
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
347
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
348
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
349
|
+
view.set(buf);
|
|
350
|
+
return {
|
|
351
|
+
read: arg.length,
|
|
352
|
+
written: buf.length
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
let WASM_VECTOR_LEN = 0;
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
let wasm;
|
|
361
|
+
export function __wbg_set_wasm(val) {
|
|
362
|
+
wasm = val;
|
|
363
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const compare: (a: any, b: any, c: any, d: any, e: any) => [number, number, number];
|
|
5
|
+
export const defaultOptions: () => any;
|
|
6
|
+
export const version: () => [number, number];
|
|
7
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
10
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
11
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
12
|
+
export const __wbindgen_start: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simtest-js/funnel",
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
|
+
"description": "Trajectory comparison library (WASM + TypeScript)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Symoptia/simtest-funnel.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build:wasm": "wasm-pack build ../../crates/simtest-funnel-wasm --target bundler --out-dir ../../packages/sdk/src/wasm",
|
|
21
|
+
"build:dist": "tsc && cp -r src/wasm dist/wasm && rm -f dist/wasm/.gitignore dist/wasm/package.json",
|
|
22
|
+
"build": "pnpm build:wasm && pnpm build:dist",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"lint": "biome check .",
|
|
25
|
+
"format": "biome format . --write",
|
|
26
|
+
"docs": "typedoc src/index.ts --out ../../target/doc/js"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@biomejs/biome": "^1.7.0",
|
|
30
|
+
"typedoc": "^0.28.0",
|
|
31
|
+
"typescript": "^5.3.0",
|
|
32
|
+
"vite-plugin-wasm": "^3.3.0",
|
|
33
|
+
"vite-plugin-top-level-await": "^1.4.0",
|
|
34
|
+
"vitest": "^1.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|