@perspective-dev/client 4.5.2 → 5.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/dist/cdn/perspective-server.worker.js +1 -1
- package/dist/cdn/perspective-server.worker.js.map +3 -3
- package/dist/cdn/perspective.js +2 -2
- package/dist/cdn/perspective.js.map +4 -4
- package/dist/esm/perspective.browser.d.ts +50 -1
- package/dist/esm/perspective.inline.js +2 -2
- package/dist/esm/perspective.inline.js.map +4 -4
- package/dist/esm/perspective.js +2 -2
- package/dist/esm/perspective.js.map +4 -4
- package/dist/esm/perspective.node.d.ts +3 -0
- package/dist/esm/perspective.node.js +75 -21
- package/dist/esm/perspective.node.js.map +3 -3
- package/dist/esm/ts-rs/AggSpec.d.ts +8 -0
- package/dist/esm/ts-rs/Features.d.ts +59 -0
- package/dist/esm/ts-rs/ViewConfig.d.ts +2 -0
- package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +9 -0
- package/dist/esm/ts-rs/WindowAggregate.d.ts +1 -0
- package/dist/esm/ts-rs/WindowSort.d.ts +7 -0
- package/dist/esm/ts-rs/WindowSortDir.d.ts +6 -0
- package/dist/esm/ts-rs/WindowSpec.d.ts +46 -0
- package/dist/esm/ts-rs/Windows.d.ts +10 -0
- package/dist/esm/virtual_server.d.ts +8 -34
- package/dist/esm/virtual_servers/clickhouse.js +1 -1
- package/dist/esm/virtual_servers/clickhouse.js.map +3 -3
- package/dist/esm/virtual_servers/duckdb.d.ts +6 -26
- package/dist/esm/virtual_servers/duckdb.js +1 -1
- package/dist/esm/virtual_servers/duckdb.js.map +3 -3
- package/dist/esm/wasm/features.d.ts +4 -0
- package/dist/wasm/perspective-js.d.ts +96 -6
- package/dist/wasm/perspective-js.js +11 -11
- package/dist/wasm/perspective-js.wasm +0 -0
- package/dist/wasm/perspective-js.wasm.d.ts +5 -5
- package/package.json +1 -1
- package/src/rust/lib.rs +6 -0
- package/src/rust/typed_array.rs +88 -54
- package/src/rust/virtual_server.rs +98 -2
- package/src/ts/perspective.browser.ts +176 -20
- package/src/ts/perspective.cdn.ts +11 -5
- package/src/ts/perspective.node.ts +39 -8
- package/src/ts/ts-rs/AggSpec.ts +10 -0
- package/src/ts/ts-rs/Features.ts +54 -0
- package/src/ts/ts-rs/ViewConfig.ts +2 -1
- package/src/ts/ts-rs/ViewConfigUpdate.ts +9 -0
- package/src/ts/ts-rs/WindowAggregate.ts +3 -0
- package/src/ts/ts-rs/WindowSort.ts +9 -0
- package/src/ts/ts-rs/WindowSortDir.ts +8 -0
- package/src/ts/ts-rs/WindowSpec.ts +46 -0
- package/src/ts/ts-rs/Windows.ts +10 -0
- package/src/ts/virtual_server.ts +17 -55
- package/src/ts/virtual_servers/clickhouse.ts +45 -2
- package/src/ts/virtual_servers/duckdb.ts +46 -4
- package/src/ts/wasm/cdn.ts +32 -0
- package/src/ts/wasm/engine.ts +7 -5
- package/src/ts/wasm/features.ts +31 -0
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
import type * as perspective from "@perspective-dev/client";
|
|
25
25
|
import type { ColumnType } from "@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts";
|
|
26
26
|
import type { ViewConfig } from "@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts";
|
|
27
|
+
import type { ViewConfigUpdate } from "@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts";
|
|
27
28
|
import type { ViewWindow } from "@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts";
|
|
29
|
+
import type { WindowAggregate } from "@perspective-dev/client/dist/esm/ts-rs/WindowAggregate.d.ts";
|
|
28
30
|
import type * as clickhouse from "@clickhouse/client-web";
|
|
29
31
|
|
|
30
32
|
const NUMBER_AGGS = [
|
|
@@ -63,6 +65,30 @@ const STRING_AGGS = [
|
|
|
63
65
|
"string_agg",
|
|
64
66
|
];
|
|
65
67
|
|
|
68
|
+
// The window aggregates the SQL translation supports, per source
|
|
69
|
+
// column type (`ema` is recursive - no SQL window equivalent).
|
|
70
|
+
const WINDOW_AGGREGATES: WindowAggregate[] = [
|
|
71
|
+
"sum",
|
|
72
|
+
"avg",
|
|
73
|
+
"count",
|
|
74
|
+
"min",
|
|
75
|
+
"max",
|
|
76
|
+
"stddev",
|
|
77
|
+
"var",
|
|
78
|
+
"lag",
|
|
79
|
+
"lead",
|
|
80
|
+
"diff",
|
|
81
|
+
"rate",
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const WINDOW_AGGREGATES_ANY: WindowAggregate[] = [
|
|
85
|
+
"count",
|
|
86
|
+
"min",
|
|
87
|
+
"max",
|
|
88
|
+
"lag",
|
|
89
|
+
"lead",
|
|
90
|
+
];
|
|
91
|
+
|
|
66
92
|
const FILTER_OPS = [
|
|
67
93
|
"==",
|
|
68
94
|
"!=",
|
|
@@ -214,15 +240,28 @@ export class ClickhouseHandler implements perspective.VirtualServerHandler {
|
|
|
214
240
|
this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({
|
|
215
241
|
create_entity: "VIEW",
|
|
216
242
|
grouping_fn: "GROUPING",
|
|
243
|
+
column_separator: "|",
|
|
217
244
|
});
|
|
218
245
|
}
|
|
219
246
|
|
|
220
|
-
getFeatures() {
|
|
247
|
+
getFeatures(): perspective.Features {
|
|
221
248
|
return {
|
|
222
249
|
group_by: true,
|
|
223
250
|
split_by: false,
|
|
224
251
|
sort: true,
|
|
225
252
|
expressions: true,
|
|
253
|
+
// ClickHouse has no stable `rowid`, so natural-order windows
|
|
254
|
+
// are unsupported.
|
|
255
|
+
unordered: true,
|
|
256
|
+
window_aggregates: {
|
|
257
|
+
// `ema` is recursive and has no SQL window translation.
|
|
258
|
+
integer: WINDOW_AGGREGATES,
|
|
259
|
+
float: WINDOW_AGGREGATES,
|
|
260
|
+
string: WINDOW_AGGREGATES_ANY,
|
|
261
|
+
date: WINDOW_AGGREGATES_ANY,
|
|
262
|
+
datetime: WINDOW_AGGREGATES_ANY,
|
|
263
|
+
boolean: WINDOW_AGGREGATES_ANY,
|
|
264
|
+
},
|
|
226
265
|
group_rollup_mode: ["rollup", "flat", "total"],
|
|
227
266
|
filter_ops: {
|
|
228
267
|
integer: FILTER_OPS,
|
|
@@ -283,7 +322,11 @@ export class ClickhouseHandler implements perspective.VirtualServerHandler {
|
|
|
283
322
|
return Number(results[0]["COUNT()"]);
|
|
284
323
|
}
|
|
285
324
|
|
|
286
|
-
async tableMakeView(
|
|
325
|
+
async tableMakeView(
|
|
326
|
+
tableId: string,
|
|
327
|
+
viewId: string,
|
|
328
|
+
config: ViewConfigUpdate,
|
|
329
|
+
) {
|
|
287
330
|
const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);
|
|
288
331
|
await runQuery(this.db, query, { execute: true });
|
|
289
332
|
}
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
import type * as perspective from "@perspective-dev/client";
|
|
25
25
|
import type { ColumnType } from "@perspective-dev/client/dist/esm/ts-rs/ColumnType.d.ts";
|
|
26
26
|
import type { ViewConfig } from "@perspective-dev/client/dist/esm/ts-rs/ViewConfig.d.ts";
|
|
27
|
+
import type { ViewConfigUpdate } from "@perspective-dev/client/dist/esm/ts-rs/ViewConfigUpdate.d.ts";
|
|
27
28
|
import type { ViewWindow } from "@perspective-dev/client/dist/esm/ts-rs/ViewWindow.d.ts";
|
|
29
|
+
import type { WindowAggregate } from "@perspective-dev/client/dist/esm/ts-rs/WindowAggregate.d.ts";
|
|
30
|
+
import type { Scalar } from "@perspective-dev/client/dist/esm/ts-rs/Scalar.d.ts";
|
|
28
31
|
import type * as duckdb from "@duckdb/duckdb-wasm";
|
|
29
32
|
|
|
30
33
|
const NUMBER_AGGS = [
|
|
@@ -63,6 +66,30 @@ const STRING_AGGS = [
|
|
|
63
66
|
"string_agg",
|
|
64
67
|
];
|
|
65
68
|
|
|
69
|
+
// The window aggregates the SQL translation supports, per source
|
|
70
|
+
// column type (`ema` is recursive - no SQL window equivalent).
|
|
71
|
+
const WINDOW_AGGREGATES: WindowAggregate[] = [
|
|
72
|
+
"sum",
|
|
73
|
+
"avg",
|
|
74
|
+
"count",
|
|
75
|
+
"min",
|
|
76
|
+
"max",
|
|
77
|
+
"stddev",
|
|
78
|
+
"var",
|
|
79
|
+
"lag",
|
|
80
|
+
"lead",
|
|
81
|
+
"diff",
|
|
82
|
+
"rate",
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
const WINDOW_AGGREGATES_ANY: WindowAggregate[] = [
|
|
86
|
+
"count",
|
|
87
|
+
"min",
|
|
88
|
+
"max",
|
|
89
|
+
"lag",
|
|
90
|
+
"lead",
|
|
91
|
+
];
|
|
92
|
+
|
|
66
93
|
const FILTER_OPS = [
|
|
67
94
|
"==",
|
|
68
95
|
"!=",
|
|
@@ -184,15 +211,26 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
184
211
|
}
|
|
185
212
|
|
|
186
213
|
this.db = db;
|
|
187
|
-
this.sqlBuilder = new mod!.GenericSQLVirtualServerModel(
|
|
214
|
+
this.sqlBuilder = new mod!.GenericSQLVirtualServerModel({
|
|
215
|
+
column_separator: "|",
|
|
216
|
+
});
|
|
188
217
|
}
|
|
189
218
|
|
|
190
|
-
getFeatures() {
|
|
219
|
+
getFeatures(): perspective.Features {
|
|
191
220
|
return {
|
|
192
221
|
group_by: true,
|
|
193
222
|
split_by: true,
|
|
194
223
|
sort: true,
|
|
195
224
|
expressions: true,
|
|
225
|
+
window_aggregates: {
|
|
226
|
+
// `ema` is recursive and has no SQL window translation.
|
|
227
|
+
integer: WINDOW_AGGREGATES,
|
|
228
|
+
float: WINDOW_AGGREGATES,
|
|
229
|
+
string: WINDOW_AGGREGATES_ANY,
|
|
230
|
+
date: WINDOW_AGGREGATES_ANY,
|
|
231
|
+
datetime: WINDOW_AGGREGATES_ANY,
|
|
232
|
+
boolean: WINDOW_AGGREGATES_ANY,
|
|
233
|
+
},
|
|
196
234
|
group_rollup_mode: ["rollup", "flat", "total"],
|
|
197
235
|
filter_ops: {
|
|
198
236
|
integer: FILTER_OPS,
|
|
@@ -254,7 +292,11 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
254
292
|
return Number(results[0].toJSON()["count_star()"]);
|
|
255
293
|
}
|
|
256
294
|
|
|
257
|
-
async tableMakeView(
|
|
295
|
+
async tableMakeView(
|
|
296
|
+
tableId: string,
|
|
297
|
+
viewId: string,
|
|
298
|
+
config: ViewConfigUpdate,
|
|
299
|
+
) {
|
|
258
300
|
const query = this.sqlBuilder.tableMakeView(tableId, viewId, config);
|
|
259
301
|
await runQuery(this.db, query);
|
|
260
302
|
}
|
|
@@ -286,7 +328,7 @@ export class DuckDBHandler implements perspective.VirtualServerHandler {
|
|
|
286
328
|
let [min, max] = Object.values(row);
|
|
287
329
|
if (typeof min === "bigint") min = Number(min);
|
|
288
330
|
if (typeof max === "bigint") max = Number(max);
|
|
289
|
-
return { min: min ?? null, max: max ?? null };
|
|
331
|
+
return { min: (min ?? null) as Scalar, max: (max ?? null) as Scalar };
|
|
290
332
|
}
|
|
291
333
|
|
|
292
334
|
async viewGetData(
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the URL of one of `@perspective-dev/server`'s engine WASM binaries
|
|
15
|
+
* relative to the URL of the `@perspective-dev/client` CDN bundle which loads
|
|
16
|
+
* it.
|
|
17
|
+
*/
|
|
18
|
+
export function resolve_server_wasm_url(
|
|
19
|
+
client_url: string,
|
|
20
|
+
filename: string = "perspective-server.wasm",
|
|
21
|
+
): string {
|
|
22
|
+
const rewritten = client_url.replace(
|
|
23
|
+
/\/client(@[^/]+)?\/dist\/cdn\/[^/?#]*([?#].*)?$/,
|
|
24
|
+
(_, tag) => `/server${tag ?? ""}/dist/wasm/${filename}`,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (rewritten !== client_url) {
|
|
28
|
+
return rewritten;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return new URL(`../../../server/dist/wasm/${filename}`, client_url).href;
|
|
32
|
+
}
|
package/src/ts/wasm/engine.ts
CHANGED
|
@@ -211,15 +211,17 @@ async function convert_typed_array_to_pointer(
|
|
|
211
211
|
array: Uint8Array,
|
|
212
212
|
callback: (_: PspPtr) => Promise<PspPtr>,
|
|
213
213
|
): Promise<PspPtr> {
|
|
214
|
+
const is_64 = core._psp_is_memory64();
|
|
214
215
|
const ptr = core._psp_alloc(
|
|
215
|
-
|
|
216
|
+
is_64
|
|
216
217
|
? (BigInt(array.byteLength) as any as number)
|
|
217
218
|
: (array.byteLength as any),
|
|
218
219
|
);
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
const addr = is_64 ? Number(ptr) : Number(ptr) >>> 0;
|
|
222
|
+
core.HEAPU8.set(array, addr);
|
|
223
|
+
const msg = await callback(ptr);
|
|
224
|
+
core._psp_free(ptr);
|
|
223
225
|
return msg;
|
|
224
226
|
}
|
|
225
227
|
|
|
@@ -255,7 +257,7 @@ async function decode_api_responses(
|
|
|
255
257
|
const is_64 = core._psp_is_memory64();
|
|
256
258
|
const response = new DataView(
|
|
257
259
|
core.HEAPU8.buffer,
|
|
258
|
-
Number(ptr) >>> 0,
|
|
260
|
+
is_64 ? Number(ptr) : Number(ptr) >>> 0,
|
|
259
261
|
is_64 ? 12 : 8,
|
|
260
262
|
);
|
|
261
263
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
3
|
+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
4
|
+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
5
|
+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
6
|
+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
7
|
+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
8
|
+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
9
|
+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
10
|
+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
11
|
+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
12
|
+
|
|
13
|
+
// The encoding of `(module (memory i64 1))` — validates only on hosts with
|
|
14
|
+
// WebAssembly Memory64 support (the same probe `wasm-feature-detect` uses).
|
|
15
|
+
const MEMORY64_PROBE = new Uint8Array([
|
|
16
|
+
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x05, 0x03, 0x01, 0x04,
|
|
17
|
+
0x01,
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
let MEMORY64_SUPPORTED: boolean | undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Does this JavaScript host support WebAssembly Memory64 (wasm64)?
|
|
24
|
+
*/
|
|
25
|
+
export function host_supports_memory64(): boolean {
|
|
26
|
+
if (MEMORY64_SUPPORTED === undefined) {
|
|
27
|
+
MEMORY64_SUPPORTED = WebAssembly.validate(MEMORY64_PROBE);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return MEMORY64_SUPPORTED;
|
|
31
|
+
}
|