@perspective-dev/client 4.4.1 → 4.5.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 +2 -2
- package/dist/cdn/perspective.js +2 -2
- package/dist/cdn/perspective.js.map +3 -3
- package/dist/esm/perspective.browser.d.ts +19 -0
- package/dist/esm/perspective.inline.js +2 -2
- package/dist/esm/perspective.inline.js.map +3 -3
- package/dist/esm/perspective.js +2 -2
- package/dist/esm/perspective.js.map +3 -3
- package/dist/esm/perspective.node.d.ts +12 -0
- package/dist/esm/perspective.node.js +160 -15
- package/dist/esm/perspective.node.js.map +2 -2
- package/dist/esm/ts-rs/TypedArrayWindow.d.ts +31 -0
- package/dist/esm/ts-rs/ViewWindow.d.ts +6 -0
- package/dist/esm/virtual_servers/duckdb.js +1 -1
- package/dist/esm/virtual_servers/duckdb.js.map +2 -2
- package/dist/wasm/perspective-js.d.ts +51 -5
- package/dist/wasm/perspective-js.js +167 -14
- package/dist/wasm/perspective-js.wasm +0 -0
- package/dist/wasm/perspective-js.wasm.d.ts +8 -5
- package/package.json +27 -3
- package/src/rust/client.rs +28 -0
- package/src/rust/lib.rs +4 -0
- package/src/rust/typed_array.rs +243 -0
- package/src/rust/view.rs +38 -0
- package/src/rust/virtual_server.rs +4 -4
- package/src/ts/perspective.browser.ts +89 -7
- package/src/ts/perspective.node.ts +15 -1
- package/src/ts/ts-rs/TypedArrayWindow.ts +26 -0
- package/src/ts/ts-rs/ViewWindow.ts +7 -1
- package/src/ts/virtual_servers/duckdb.ts +4 -0
- package/src/ts/wasm/engine.ts +2 -2
- package/src/ts/wasm/perspective-server.poly.ts +1 -1
|
@@ -20,6 +20,18 @@ export declare function make_client(send_request: (buffer: Uint8Array) => Promis
|
|
|
20
20
|
export declare function cwd_static_file_handler(request: http.IncomingMessage, response: http.ServerResponse<http.IncomingMessage>, assets?: string[], { debug }?: {
|
|
21
21
|
debug?: boolean | undefined;
|
|
22
22
|
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* A simple Node `http`-based WebSocket adapter that exposes a
|
|
25
|
+
* `PerspectiveServer` over the wire.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
*
|
|
29
|
+
* **Security.** `WebSocketServer` is a reference integration with no
|
|
30
|
+
* authentication, authorization, origin enforcement, or rate limiting, and
|
|
31
|
+
* is not safe to expose to untrusted networks — see
|
|
32
|
+
* [`SECURITY.md`](https://github.com/perspective-dev/perspective/blob/master/SECURITY.md)
|
|
33
|
+
* for the full threat model.
|
|
34
|
+
*/
|
|
23
35
|
export declare class WebSocketServer {
|
|
24
36
|
_server: http.Server | any;
|
|
25
37
|
_wss: HttpWebSocketServer;
|
|
@@ -64,6 +64,36 @@ var Client = class _Client {
|
|
|
64
64
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Unsafely gets a [`View`] by raw ID, useful for JavaScript multi-threaded
|
|
69
|
+
* (via Web Worker) context where a standard `View` cannot otherwise be
|
|
70
|
+
* shared because its wrapper is not serializable.
|
|
71
|
+
*
|
|
72
|
+
* # Safety
|
|
73
|
+
*
|
|
74
|
+
* This method is unsafe because the lifetime of a [`View`] is bound to
|
|
75
|
+
* the [`Client`] which created it.
|
|
76
|
+
*
|
|
77
|
+
* The caller must guarantee that `entity_id` corresponds to a live
|
|
78
|
+
* [`crate::View`] on the connected server (obtained from another
|
|
79
|
+
* [`Client`]'s [`crate::View::get_name`] and forwarded across the
|
|
80
|
+
* serialization boundary).
|
|
81
|
+
*
|
|
82
|
+
* # JavaScript Examples
|
|
83
|
+
*
|
|
84
|
+
* ```javascript
|
|
85
|
+
* const view = client.__unsafe_open_view(name_from_main_thread);
|
|
86
|
+
* const cols = await view.to_columns();
|
|
87
|
+
* ```
|
|
88
|
+
* @param {string} entity_id
|
|
89
|
+
* @returns {View}
|
|
90
|
+
*/
|
|
91
|
+
__unsafe_open_view(entity_id) {
|
|
92
|
+
const ptr0 = passStringToWasm0(entity_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
93
|
+
const len0 = WASM_VECTOR_LEN;
|
|
94
|
+
const ret = wasm.client___unsafe_open_view(this.__wbg_ptr, ptr0, len0);
|
|
95
|
+
return View.__wrap(ret);
|
|
96
|
+
}
|
|
67
97
|
/**
|
|
68
98
|
* Retrieves the names of all tables that this client has access to.
|
|
69
99
|
*
|
|
@@ -1085,6 +1115,24 @@ var View = class _View {
|
|
|
1085
1115
|
const ret = wasm.view___get_model(this.__wbg_ptr);
|
|
1086
1116
|
return _View.__wrap(ret);
|
|
1087
1117
|
}
|
|
1118
|
+
/**
|
|
1119
|
+
* @returns {string}
|
|
1120
|
+
*/
|
|
1121
|
+
__unsafe_get_name() {
|
|
1122
|
+
try {
|
|
1123
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1124
|
+
wasm.view___unsafe_get_name(retptr, this.__wbg_ptr);
|
|
1125
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1126
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1127
|
+
var v1 = getCachedStringFromWasm0(r0, r1);
|
|
1128
|
+
if (r0 !== 0) {
|
|
1129
|
+
wasm.__wbindgen_export4(r0, r1, 1);
|
|
1130
|
+
}
|
|
1131
|
+
return v1;
|
|
1132
|
+
} finally {
|
|
1133
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1088
1136
|
/**
|
|
1089
1137
|
* Collapses the `group_by` row at `row_index`.
|
|
1090
1138
|
* @param {number} row_index
|
|
@@ -1371,6 +1419,29 @@ var View = class _View {
|
|
|
1371
1419
|
const ret = wasm.view_to_ndjson(this.__wbg_ptr, isLikeNone(window2) ? 0 : addHeapObject(window2));
|
|
1372
1420
|
return takeObject(ret);
|
|
1373
1421
|
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Fetches columns from the [`View`] in Arrow format, decodes them, and
|
|
1424
|
+
* passes typed array views to `callback`. All arrays are only valid for
|
|
1425
|
+
* the duration of the callback — if `callback` returns a `Promise`, it
|
|
1426
|
+
* is awaited before the backing Arrow buffer is released, so async
|
|
1427
|
+
* callbacks may use the views for the full duration of the awaited
|
|
1428
|
+
* work (e.g. across an `await requestAnimationFrame`-backed promise).
|
|
1429
|
+
*
|
|
1430
|
+
* # Arguments
|
|
1431
|
+
*
|
|
1432
|
+
* - `window` - Optional [`TypedArrayWindow`] controlling row/column
|
|
1433
|
+
* windowing and output options (e.g., `float32` mode).
|
|
1434
|
+
* - `callback` - A JS function called with `(names: string[], values:
|
|
1435
|
+
* TypedArray[], validities: (Uint8Array|null)[], dictionaries:
|
|
1436
|
+
* (string[]|null)[]) => void | Promise<void>`.
|
|
1437
|
+
* @param {TypedArrayWindow | null | undefined} window
|
|
1438
|
+
* @param {Function} callback
|
|
1439
|
+
* @returns {Promise<void>}
|
|
1440
|
+
*/
|
|
1441
|
+
with_typed_arrays(window2, callback) {
|
|
1442
|
+
const ret = wasm.view_with_typed_arrays(this.__wbg_ptr, isLikeNone(window2) ? 0 : addHeapObject(window2), addHeapObject(callback));
|
|
1443
|
+
return takeObject(ret);
|
|
1444
|
+
}
|
|
1374
1445
|
};
|
|
1375
1446
|
if (Symbol.dispose) View.prototype[Symbol.dispose] = View.prototype.free;
|
|
1376
1447
|
var VirtualDataSlice = class _VirtualDataSlice {
|
|
@@ -1708,6 +1779,12 @@ function __wbg_get_imports() {
|
|
|
1708
1779
|
return addHeapObject(ret);
|
|
1709
1780
|
}, arguments);
|
|
1710
1781
|
},
|
|
1782
|
+
__wbg_call_41bedb84c3e5c0c9: function() {
|
|
1783
|
+
return handleError(function(arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
1784
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4), getObject(arg5));
|
|
1785
|
+
return addHeapObject(ret);
|
|
1786
|
+
}, arguments);
|
|
1787
|
+
},
|
|
1711
1788
|
__wbg_call_4708e0c13bdc8e95: function() {
|
|
1712
1789
|
return handleError(function(arg0, arg1, arg2) {
|
|
1713
1790
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
@@ -1948,7 +2025,7 @@ function __wbg_get_imports() {
|
|
|
1948
2025
|
const a = state0.a;
|
|
1949
2026
|
state0.a = 0;
|
|
1950
2027
|
try {
|
|
1951
|
-
return
|
|
2028
|
+
return __wasm_bindgen_func_elem_11006(a, state0.b, arg02, arg12);
|
|
1952
2029
|
} finally {
|
|
1953
2030
|
state0.a = a;
|
|
1954
2031
|
}
|
|
@@ -1976,6 +2053,10 @@ function __wbg_get_imports() {
|
|
|
1976
2053
|
const ret = new Function(v0);
|
|
1977
2054
|
return addHeapObject(ret);
|
|
1978
2055
|
},
|
|
2056
|
+
__wbg_new_with_length_1763c527b2923202: function(arg0) {
|
|
2057
|
+
const ret = new Array(arg0 >>> 0);
|
|
2058
|
+
return addHeapObject(ret);
|
|
2059
|
+
},
|
|
1979
2060
|
__wbg_next_3482f54c49e8af19: function() {
|
|
1980
2061
|
return handleError(function(arg0) {
|
|
1981
2062
|
const ret = getObject(arg0).next();
|
|
@@ -2108,11 +2189,11 @@ function __wbg_get_imports() {
|
|
|
2108
2189
|
console.warn(getObject(arg0));
|
|
2109
2190
|
},
|
|
2110
2191
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2111
|
-
const ret = makeClosure(arg0, arg1, wasm.
|
|
2192
|
+
const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_860, __wasm_bindgen_func_elem_1768);
|
|
2112
2193
|
return addHeapObject(ret);
|
|
2113
2194
|
},
|
|
2114
2195
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2115
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
2196
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4015, __wasm_bindgen_func_elem_4032);
|
|
2116
2197
|
return addHeapObject(ret);
|
|
2117
2198
|
},
|
|
2118
2199
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -2129,20 +2210,36 @@ function __wbg_get_imports() {
|
|
|
2129
2210
|
return addHeapObject(ret);
|
|
2130
2211
|
},
|
|
2131
2212
|
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
|
|
2213
|
+
const ret = getArrayF32FromWasm0(arg0, arg1);
|
|
2214
|
+
return addHeapObject(ret);
|
|
2215
|
+
},
|
|
2216
|
+
__wbindgen_cast_0000000000000007: function(arg0, arg1) {
|
|
2217
|
+
const ret = getArrayF64FromWasm0(arg0, arg1);
|
|
2218
|
+
return addHeapObject(ret);
|
|
2219
|
+
},
|
|
2220
|
+
__wbindgen_cast_0000000000000008: function(arg0, arg1) {
|
|
2221
|
+
const ret = getArrayI32FromWasm0(arg0, arg1);
|
|
2222
|
+
return addHeapObject(ret);
|
|
2223
|
+
},
|
|
2224
|
+
__wbindgen_cast_0000000000000009: function(arg0, arg1) {
|
|
2225
|
+
const ret = getArrayU32FromWasm0(arg0, arg1);
|
|
2226
|
+
return addHeapObject(ret);
|
|
2227
|
+
},
|
|
2228
|
+
__wbindgen_cast_000000000000000a: function(arg0, arg1) {
|
|
2132
2229
|
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
2133
2230
|
return addHeapObject(ret);
|
|
2134
2231
|
},
|
|
2135
|
-
|
|
2232
|
+
__wbindgen_cast_000000000000000b: function(arg0) {
|
|
2136
2233
|
const ret = BigInt.asUintN(64, arg0);
|
|
2137
2234
|
return addHeapObject(ret);
|
|
2138
2235
|
},
|
|
2139
|
-
|
|
2236
|
+
__wbindgen_cast_000000000000000c: function(arg0, arg1) {
|
|
2140
2237
|
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
|
2141
2238
|
wasm.__wbindgen_export4(arg0, arg1 * 4, 4);
|
|
2142
2239
|
const ret = v0;
|
|
2143
2240
|
return addHeapObject(ret);
|
|
2144
2241
|
},
|
|
2145
|
-
|
|
2242
|
+
__wbindgen_cast_000000000000000d: function(arg0, arg1) {
|
|
2146
2243
|
var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
|
|
2147
2244
|
wasm.__wbindgen_export4(arg0, arg1 * 1, 1);
|
|
2148
2245
|
const ret = v0;
|
|
@@ -2161,15 +2258,15 @@ function __wbg_get_imports() {
|
|
|
2161
2258
|
"./perspective-js.wasm_bg.js": import0
|
|
2162
2259
|
};
|
|
2163
2260
|
}
|
|
2164
|
-
function
|
|
2165
|
-
const ret = wasm.
|
|
2261
|
+
function __wasm_bindgen_func_elem_1768(arg0, arg1) {
|
|
2262
|
+
const ret = wasm.__wasm_bindgen_func_elem_1768(arg0, arg1);
|
|
2166
2263
|
return takeObject(ret);
|
|
2167
2264
|
}
|
|
2168
|
-
function
|
|
2169
|
-
wasm.
|
|
2265
|
+
function __wasm_bindgen_func_elem_4032(arg0, arg1, arg2) {
|
|
2266
|
+
wasm.__wasm_bindgen_func_elem_4032(arg0, arg1, addHeapObject(arg2));
|
|
2170
2267
|
}
|
|
2171
|
-
function
|
|
2172
|
-
wasm.
|
|
2268
|
+
function __wasm_bindgen_func_elem_11006(arg0, arg1, arg2, arg3) {
|
|
2269
|
+
wasm.__wasm_bindgen_func_elem_11006(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
2173
2270
|
}
|
|
2174
2271
|
var ClientFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
2175
2272
|
}, unregister: () => {
|
|
@@ -2273,6 +2370,18 @@ function dropObject(idx) {
|
|
|
2273
2370
|
heap[idx] = heap_next;
|
|
2274
2371
|
heap_next = idx;
|
|
2275
2372
|
}
|
|
2373
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
2374
|
+
ptr = ptr >>> 0;
|
|
2375
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
2376
|
+
}
|
|
2377
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
2378
|
+
ptr = ptr >>> 0;
|
|
2379
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
2380
|
+
}
|
|
2381
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
2382
|
+
ptr = ptr >>> 0;
|
|
2383
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
2384
|
+
}
|
|
2276
2385
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
2277
2386
|
ptr = ptr >>> 0;
|
|
2278
2387
|
const mem = getDataViewMemory0();
|
|
@@ -2282,6 +2391,10 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
2282
2391
|
}
|
|
2283
2392
|
return result;
|
|
2284
2393
|
}
|
|
2394
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
2395
|
+
ptr = ptr >>> 0;
|
|
2396
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
2397
|
+
}
|
|
2285
2398
|
function getArrayU8FromWasm0(ptr, len) {
|
|
2286
2399
|
ptr = ptr >>> 0;
|
|
2287
2400
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -2300,10 +2413,38 @@ function getDataViewMemory0() {
|
|
|
2300
2413
|
}
|
|
2301
2414
|
return cachedDataViewMemory0;
|
|
2302
2415
|
}
|
|
2416
|
+
var cachedFloat32ArrayMemory0 = null;
|
|
2417
|
+
function getFloat32ArrayMemory0() {
|
|
2418
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
2419
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
2420
|
+
}
|
|
2421
|
+
return cachedFloat32ArrayMemory0;
|
|
2422
|
+
}
|
|
2423
|
+
var cachedFloat64ArrayMemory0 = null;
|
|
2424
|
+
function getFloat64ArrayMemory0() {
|
|
2425
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
2426
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
2427
|
+
}
|
|
2428
|
+
return cachedFloat64ArrayMemory0;
|
|
2429
|
+
}
|
|
2430
|
+
var cachedInt32ArrayMemory0 = null;
|
|
2431
|
+
function getInt32ArrayMemory0() {
|
|
2432
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
2433
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
2434
|
+
}
|
|
2435
|
+
return cachedInt32ArrayMemory0;
|
|
2436
|
+
}
|
|
2303
2437
|
function getStringFromWasm0(ptr, len) {
|
|
2304
2438
|
ptr = ptr >>> 0;
|
|
2305
2439
|
return decodeText(ptr, len);
|
|
2306
2440
|
}
|
|
2441
|
+
var cachedUint32ArrayMemory0 = null;
|
|
2442
|
+
function getUint32ArrayMemory0() {
|
|
2443
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
2444
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
2445
|
+
}
|
|
2446
|
+
return cachedUint32ArrayMemory0;
|
|
2447
|
+
}
|
|
2307
2448
|
var cachedUint8ArrayMemory0 = null;
|
|
2308
2449
|
function getUint8ArrayMemory0() {
|
|
2309
2450
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
@@ -2433,6 +2574,10 @@ function __wbg_finalize_init(instance, module) {
|
|
|
2433
2574
|
wasm = instance.exports;
|
|
2434
2575
|
wasmModule = module;
|
|
2435
2576
|
cachedDataViewMemory0 = null;
|
|
2577
|
+
cachedFloat32ArrayMemory0 = null;
|
|
2578
|
+
cachedFloat64ArrayMemory0 = null;
|
|
2579
|
+
cachedInt32ArrayMemory0 = null;
|
|
2580
|
+
cachedUint32ArrayMemory0 = null;
|
|
2436
2581
|
cachedUint8ArrayMemory0 = null;
|
|
2437
2582
|
return wasm;
|
|
2438
2583
|
}
|
|
@@ -2640,8 +2785,8 @@ async function decode_api_responses(core, ptr, callback) {
|
|
|
2640
2785
|
messages.getInt32(i * 16 + 8, true),
|
|
2641
2786
|
messages.getInt32(i * 16 + 12, true)
|
|
2642
2787
|
] : [
|
|
2643
|
-
messages.
|
|
2644
|
-
messages.
|
|
2788
|
+
messages.getUint32(i * 12, true),
|
|
2789
|
+
messages.getUint32(i * 12 + 4, true),
|
|
2645
2790
|
messages.getInt32(i * 12 + 8, true)
|
|
2646
2791
|
];
|
|
2647
2792
|
const data = new Uint8Array(
|
|
@@ -3017,7 +3162,7 @@ var CONTENT_TYPES = {
|
|
|
3017
3162
|
".wasm": "application/wasm",
|
|
3018
3163
|
".svg": "image/svg+xml"
|
|
3019
3164
|
};
|
|
3020
|
-
async function cwd_static_file_handler(request, response, assets = ["./"], { debug =
|
|
3165
|
+
async function cwd_static_file_handler(request, response, assets = ["./"], { debug = false } = {}) {
|
|
3021
3166
|
let url2 = request.url?.split(/[\?\#]/)[0].replace(/@[\^~]?\d+.[\d\*]*.[\d\*]*/, "") || "/";
|
|
3022
3167
|
if (url2 === "/") {
|
|
3023
3168
|
url2 = "/index.html";
|