@perspective-dev/client 4.0.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.md +193 -0
- package/README.md +3 -0
- package/dist/cdn/perspective-server.worker.js +2 -0
- package/dist/cdn/perspective-server.worker.js.map +7 -0
- package/dist/cdn/perspective.js +3 -0
- package/dist/cdn/perspective.js.map +7 -0
- package/dist/esm/perspective-server.worker.d.ts +1 -0
- package/dist/esm/perspective.browser.d.ts +14 -0
- package/dist/esm/perspective.inline.js +3 -0
- package/dist/esm/perspective.inline.js.map +7 -0
- package/dist/esm/perspective.js +3 -0
- package/dist/esm/perspective.js.map +7 -0
- package/dist/esm/perspective.node.d.ts +60 -0
- package/dist/esm/perspective.node.js +2431 -0
- package/dist/esm/perspective.node.js.map +7 -0
- package/dist/esm/ts-rs/Aggregate.d.ts +1 -0
- package/dist/esm/ts-rs/ColumnWindow.d.ts +4 -0
- package/dist/esm/ts-rs/DeleteOptions.d.ts +6 -0
- package/dist/esm/ts-rs/Expressions.d.ts +3 -0
- package/dist/esm/ts-rs/Filter.d.ts +2 -0
- package/dist/esm/ts-rs/FilterReducer.d.ts +1 -0
- package/dist/esm/ts-rs/FilterTerm.d.ts +2 -0
- package/dist/esm/ts-rs/OnUpdateMode.d.ts +9 -0
- package/dist/esm/ts-rs/OnUpdateOptions.d.ts +7 -0
- package/dist/esm/ts-rs/Scalar.d.ts +5 -0
- package/dist/esm/ts-rs/Sort.d.ts +2 -0
- package/dist/esm/ts-rs/SortDir.d.ts +1 -0
- package/dist/esm/ts-rs/SystemInfo.d.ts +40 -0
- package/dist/esm/ts-rs/TableInitOptions.d.ts +22 -0
- package/dist/esm/ts-rs/TableReadFormat.d.ts +7 -0
- package/dist/esm/ts-rs/UpdateOptions.d.ts +8 -0
- package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +90 -0
- package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +4 -0
- package/dist/esm/ts-rs/ViewWindow.d.ts +23 -0
- package/dist/esm/wasm/browser.d.ts +21 -0
- package/dist/esm/wasm/decompress.d.ts +1 -0
- package/dist/esm/wasm/emscripten_api.d.ts +5 -0
- package/dist/esm/wasm/engine.d.ts +40 -0
- package/dist/esm/wasm/perspective-server.poly.d.ts +1 -0
- package/dist/esm/websocket.d.ts +4 -0
- package/dist/wasm/perspective-js.d.ts +712 -0
- package/dist/wasm/perspective-js.js +1934 -0
- package/dist/wasm/perspective-js.wasm +0 -0
- package/dist/wasm/perspective-js.wasm.d.ts +75 -0
- package/package.json +68 -0
- package/src/rust/client.rs +483 -0
- package/src/rust/lib.rs +70 -0
- package/src/rust/table.rs +364 -0
- package/src/rust/table_data.rs +159 -0
- package/src/rust/utils/browser.rs +39 -0
- package/src/rust/utils/console_logger.rs +236 -0
- package/src/rust/utils/errors.rs +288 -0
- package/src/rust/utils/futures.rs +174 -0
- package/src/rust/utils/json.rs +252 -0
- package/src/rust/utils/local_poll_loop.rs +63 -0
- package/src/rust/utils/mod.rs +32 -0
- package/src/rust/utils/serde.rs +46 -0
- package/src/rust/utils/trace_allocator.rs +98 -0
- package/src/rust/view.rs +355 -0
- package/src/ts/perspective-server.worker.ts +54 -0
- package/src/ts/perspective.browser.ts +132 -0
- package/src/ts/perspective.cdn.ts +22 -0
- package/src/ts/perspective.inline.ts +27 -0
- package/src/ts/perspective.node.ts +315 -0
- package/src/ts/ts-rs/Aggregate.ts +3 -0
- package/src/ts/ts-rs/ColumnWindow.ts +3 -0
- package/src/ts/ts-rs/DeleteOptions.ts +6 -0
- package/src/ts/ts-rs/Expressions.ts +3 -0
- package/src/ts/ts-rs/Filter.ts +4 -0
- package/src/ts/ts-rs/FilterReducer.ts +3 -0
- package/src/ts/ts-rs/FilterTerm.ts +4 -0
- package/src/ts/ts-rs/OnUpdateData.ts +8 -0
- package/src/ts/ts-rs/OnUpdateMode.ts +11 -0
- package/src/ts/ts-rs/OnUpdateOptions.ts +7 -0
- package/src/ts/ts-rs/Scalar.ts +7 -0
- package/src/ts/ts-rs/Sort.ts +4 -0
- package/src/ts/ts-rs/SortDir.ts +3 -0
- package/src/ts/ts-rs/SystemInfo.ts +41 -0
- package/src/ts/ts-rs/TableInitOptions.ts +21 -0
- package/src/ts/ts-rs/TableReadFormat.ts +9 -0
- package/src/ts/ts-rs/UpdateOptions.ts +7 -0
- package/src/ts/ts-rs/ViewConfigUpdate.ts +87 -0
- package/src/ts/ts-rs/ViewOnUpdateResp.ts +3 -0
- package/src/ts/ts-rs/ViewWindow.ts +17 -0
- package/src/ts/wasm/browser.ts +123 -0
- package/src/ts/wasm/decompress.ts +64 -0
- package/src/ts/wasm/emscripten_api.ts +63 -0
- package/src/ts/wasm/engine.ts +271 -0
- package/src/ts/wasm/perspective-server.poly.ts +244 -0
- package/src/ts/websocket.ts +95 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Aggregate } from "./Aggregate.js";
|
|
2
|
+
import type { Expressions } from "./Expressions.js";
|
|
3
|
+
import type { Filter } from "./Filter.js";
|
|
4
|
+
import type { FilterReducer } from "./FilterReducer.js";
|
|
5
|
+
import type { Sort } from "./Sort.js";
|
|
6
|
+
export type ViewConfigUpdate = {
|
|
7
|
+
/**
|
|
8
|
+
* A group by _groups_ the dataset by the unique values of each column used
|
|
9
|
+
* as a group by - a close analogue in SQL to the `GROUP BY` statement.
|
|
10
|
+
* The underlying dataset is aggregated to show the values belonging to
|
|
11
|
+
* each group, and a total row is calculated for each group, showing
|
|
12
|
+
* the currently selected aggregated value (e.g. `sum`) of the column.
|
|
13
|
+
* Group by are useful for hierarchies, categorizing data and
|
|
14
|
+
* attributing values, i.e. showing the number of units sold based on
|
|
15
|
+
* State and City. In Perspective, group by are represented as an array
|
|
16
|
+
* of string column names to pivot, are applied in the order provided;
|
|
17
|
+
* For example, a group by of `["State", "City", "Postal Code"]` shows
|
|
18
|
+
* the values for each Postal Code, which are grouped by City,
|
|
19
|
+
* which are in turn grouped by State.
|
|
20
|
+
*/
|
|
21
|
+
group_by?: Array<string>;
|
|
22
|
+
/**
|
|
23
|
+
* A split by _splits_ the dataset by the unique values of each column used
|
|
24
|
+
* as a split by. The underlying dataset is not aggregated, and a new
|
|
25
|
+
* column is created for each unique value of the split by. Each newly
|
|
26
|
+
* created column contains the parts of the dataset that correspond to
|
|
27
|
+
* the column header, i.e. a `View` that has `["State"]` as its split
|
|
28
|
+
* by will have a new column for each state. In Perspective, Split By
|
|
29
|
+
* are represented as an array of string column names to pivot.
|
|
30
|
+
*/
|
|
31
|
+
split_by?: Array<string>;
|
|
32
|
+
/**
|
|
33
|
+
* The `columns` property specifies which columns should be included in the
|
|
34
|
+
* [`crate::View`]'s output. This allows users to show or hide a specific
|
|
35
|
+
* subset of columns, as well as control the order in which columns
|
|
36
|
+
* appear to the user. This is represented in Perspective as an array
|
|
37
|
+
* of string column names.
|
|
38
|
+
*/
|
|
39
|
+
columns?: Array<string | null>;
|
|
40
|
+
/**
|
|
41
|
+
* The `filter` property specifies columns on which the query can be
|
|
42
|
+
* filtered, returning rows that pass the specified filter condition.
|
|
43
|
+
* This is analogous to the `WHERE` clause in SQL. There is no limit on
|
|
44
|
+
* the number of columns where `filter` is applied, but the resulting
|
|
45
|
+
* dataset is one that passes all the filter conditions, i.e. the
|
|
46
|
+
* filters are joined with an `AND` condition.
|
|
47
|
+
*
|
|
48
|
+
* Perspective represents `filter` as an array of arrays, with the values
|
|
49
|
+
* of each inner array being a string column name, a string filter
|
|
50
|
+
* operator, and a filter operand in the type of the column.
|
|
51
|
+
*/
|
|
52
|
+
filter?: Array<Filter>;
|
|
53
|
+
/**
|
|
54
|
+
* The `sort` property specifies columns on which the query should be
|
|
55
|
+
* sorted, analogous to `ORDER BY` in SQL. A column can be sorted
|
|
56
|
+
* regardless of its data type, and sorts can be applied in ascending
|
|
57
|
+
* or descending order. Perspective represents `sort` as an array of
|
|
58
|
+
* arrays, with the values of each inner array being a string column
|
|
59
|
+
* name and a string sort direction. When `column-pivots` are applied,
|
|
60
|
+
* the additional sort directions `"col asc"` and `"col desc"` will
|
|
61
|
+
* determine the order of pivot columns groups.
|
|
62
|
+
*/
|
|
63
|
+
sort?: Array<Sort>;
|
|
64
|
+
/**
|
|
65
|
+
* The `expressions` property specifies _new_ columns in Perspective that
|
|
66
|
+
* are created using existing column values or arbitary scalar values
|
|
67
|
+
* defined within the expression. In `<perspective-viewer>`,
|
|
68
|
+
* expressions are added using the "New Column" button in the side
|
|
69
|
+
* panel.
|
|
70
|
+
*/
|
|
71
|
+
expressions?: Expressions;
|
|
72
|
+
/**
|
|
73
|
+
* Aggregates perform a calculation over an entire column, and are
|
|
74
|
+
* displayed when one or more [Group By](#group-by) are applied to the
|
|
75
|
+
* `View`. Aggregates can be specified by the user, or Perspective will
|
|
76
|
+
* use the following sensible default aggregates based on column type:
|
|
77
|
+
*
|
|
78
|
+
* - "sum" for `integer` and `float` columns
|
|
79
|
+
* - "count" for all other columns
|
|
80
|
+
*
|
|
81
|
+
* Perspective provides a selection of aggregate functions that can be
|
|
82
|
+
* applied to columns in the `View` constructor using a dictionary of
|
|
83
|
+
* column name to aggregate function name.
|
|
84
|
+
*/
|
|
85
|
+
aggregates?: {
|
|
86
|
+
[key in string]?: Aggregate;
|
|
87
|
+
};
|
|
88
|
+
group_by_depth?: number;
|
|
89
|
+
filter_op?: FilterReducer;
|
|
90
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for serializing a window of data from a [`View`].
|
|
3
|
+
*
|
|
4
|
+
* Some fields of [`ViewWindow`] are only applicable to specific methods of
|
|
5
|
+
* [`View`].
|
|
6
|
+
*/
|
|
7
|
+
export type ViewWindow = {
|
|
8
|
+
start_row: number | null;
|
|
9
|
+
start_col: number | null;
|
|
10
|
+
end_row: number | null;
|
|
11
|
+
end_col: number | null;
|
|
12
|
+
id: boolean | null;
|
|
13
|
+
index: boolean | null;
|
|
14
|
+
leaves_only: boolean | null;
|
|
15
|
+
/**
|
|
16
|
+
* Only impacts [`View::to_csv`]
|
|
17
|
+
*/
|
|
18
|
+
formatted: boolean | null;
|
|
19
|
+
/**
|
|
20
|
+
* Only impacts [`View::to_arrow`]
|
|
21
|
+
*/
|
|
22
|
+
compression: string | null;
|
|
23
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as psp from "../../../dist/wasm/perspective-js.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new client connected exclusively to a new Web Worker instance of
|
|
4
|
+
* the Perspective engine.
|
|
5
|
+
* @param module
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function worker(module: Promise<typeof psp>, server_wasm: Promise<WebAssembly.Module>, perspective_wasm_worker: Promise<SharedWorker | ServiceWorker | Worker>): Promise<psp.Client>;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new client connected via WebSocket to a server implemnting the
|
|
11
|
+
* Perspective Protocol.
|
|
12
|
+
* @param module
|
|
13
|
+
* @param url
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function websocket(module: Promise<typeof psp>, url: string | URL): Promise<psp.Client>;
|
|
17
|
+
declare const _default: {
|
|
18
|
+
websocket: typeof websocket;
|
|
19
|
+
worker: typeof worker;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function load_wasm_stage_0(wasm: ArrayBuffer | Response | WebAssembly.Module | (() => Promise<ArrayBuffer>)): Promise<Uint8Array>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type * from "../../../dist/wasm/perspective-js.js";
|
|
2
|
+
import type * as perspective_server_t from "@perspective-dev/server/dist/wasm/perspective-server.js";
|
|
3
|
+
export type PspPtr = BigInt | number;
|
|
4
|
+
export type EmscriptenServer = bigint | number;
|
|
5
|
+
export declare function compile_perspective(wasmBinary: ArrayBuffer): Promise<perspective_server_t.MainModule>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MainModule } from "@perspective-dev/server/dist/wasm/perspective-server.js";
|
|
2
|
+
import type { EmscriptenServer } from "./emscripten_api.ts";
|
|
3
|
+
export type ApiResponse = {
|
|
4
|
+
client_id: number;
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
export interface PerspectiveServerOptions {
|
|
8
|
+
on_poll_request?: (x: PerspectiveServer) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare class PerspectivePollThread {
|
|
11
|
+
private poll_handle?;
|
|
12
|
+
private server;
|
|
13
|
+
constructor(server: PerspectiveServer);
|
|
14
|
+
private set_poll_handle;
|
|
15
|
+
on_poll_request(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class PerspectiveServer {
|
|
18
|
+
clients: Map<number, (buffer: Uint8Array) => Promise<void>>;
|
|
19
|
+
server: EmscriptenServer;
|
|
20
|
+
module: MainModule;
|
|
21
|
+
on_poll_request?: (x: PerspectiveServer) => Promise<void>;
|
|
22
|
+
constructor(module: MainModule, options?: PerspectiveServerOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to create server emitter/receiver pairs
|
|
25
|
+
*/
|
|
26
|
+
make_session(callback: (buffer: Uint8Array) => Promise<void>): PerspectiveSession;
|
|
27
|
+
poll(): Promise<void>;
|
|
28
|
+
delete(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class PerspectiveSession {
|
|
31
|
+
private mod;
|
|
32
|
+
private server;
|
|
33
|
+
private client_id;
|
|
34
|
+
private client_map;
|
|
35
|
+
private on_poll_request?;
|
|
36
|
+
constructor(mod: MainModule, server: EmscriptenServer, client_id: number, client_map: Map<number, (buffer: Uint8Array) => Promise<void>>, on_poll_request?: (() => Promise<void>) | undefined);
|
|
37
|
+
handle_request(view: Uint8Array): Promise<void>;
|
|
38
|
+
private poll;
|
|
39
|
+
close(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (obj: any): Promise<any>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as perspective_client from "../../dist/wasm/perspective-js.js";
|
|
2
|
+
export declare function websocket(WebSocket: typeof window.WebSocket, Client: typeof perspective_client.Client, url: string | URL, options?: {
|
|
3
|
+
maxPayload: number;
|
|
4
|
+
}): Promise<perspective_client.Client>;
|