@perspective-dev/client 5.5.0 → 5.5.1

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.
@@ -19,9 +19,10 @@ export type TypedArrayWindow = {
19
19
  */
20
20
  formatted?: boolean;
21
21
  /**
22
- * Only impacts [`View::to_arrow`]
22
+ * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
23
+ * (uncompressed when omitted).
23
24
  */
24
- compression?: string;
25
+ compression?: "lz4" | "zstd";
25
26
  /**
26
27
  * When `true`, group-by columns use legacy `"colname (Group by N)"`
27
28
  * naming. When `false`, they use `__ROW_PATH_N__` naming consistent
@@ -16,9 +16,10 @@ export type ViewWindow = {
16
16
  */
17
17
  formatted?: boolean;
18
18
  /**
19
- * Only impacts [`View::to_arrow`]
19
+ * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
20
+ * (uncompressed when omitted).
20
21
  */
21
- compression?: string;
22
+ compression?: "lz4" | "zstd";
22
23
  /**
23
24
  * When `true`, group-by columns use legacy `"colname (Group by N)"`
24
25
  * naming. When `false`, they use `__ROW_PATH_N__` naming consistent
@@ -8,6 +8,7 @@ export interface DiskBridgeHelpers {
8
8
  readCString: (p: number | bigint) => string;
9
9
  }
10
10
  export interface CompileOptions {
11
+ env?: Record<string, string | undefined>;
11
12
  make_disk_bridge?: (helpers: DiskBridgeHelpers) => {
12
13
  store(namePtr: number | bigint, dataPtr: number | bigint, len: number): number;
13
14
  load(namePtr: number | bigint, dataPtr: number | bigint, len: number): number;
@@ -827,6 +827,17 @@ export class View {
827
827
  set_depth(depth: number): Promise<void>;
828
828
  /**
829
829
  * Serializes a [`View`] to the Apache Arrow data format.
830
+ *
831
+ * # Arguments
832
+ *
833
+ * - `window` - a [`ViewWindow`]; its `compression` key selects Arrow IPC
834
+ * body compression, `"lz4"` or `"zstd"` (uncompressed when omitted).
835
+ *
836
+ * # JavaScript Examples
837
+ *
838
+ * ```javascript
839
+ * const arrow = await view.to_arrow({ compression: "zstd" });
840
+ * ```
830
841
  */
831
842
  to_arrow(window?: ViewWindow | null): Promise<ArrayBuffer>;
832
843
  /**
@@ -1397,6 +1397,17 @@ export class View {
1397
1397
  }
1398
1398
  /**
1399
1399
  * Serializes a [`View`] to the Apache Arrow data format.
1400
+ *
1401
+ * # Arguments
1402
+ *
1403
+ * - `window` - a [`ViewWindow`]; its `compression` key selects Arrow IPC
1404
+ * body compression, `"lz4"` or `"zstd"` (uncompressed when omitted).
1405
+ *
1406
+ * # JavaScript Examples
1407
+ *
1408
+ * ```javascript
1409
+ * const arrow = await view.to_arrow({ compression: "zstd" });
1410
+ * ```
1400
1411
  * @param {ViewWindow | null} [window]
1401
1412
  * @returns {Promise<ArrayBuffer>}
1402
1413
  */
@@ -2127,7 +2138,7 @@ function __wbg_get_imports() {
2127
2138
  const ret = Promise.resolve(getObject(arg0));
2128
2139
  return addHeapObject(ret);
2129
2140
  },
2130
- __wbg_run_26ff8525c6787d9c: function() { return handleError(function (arg0, arg1) {
2141
+ __wbg_run_556972011e45ec00: function() { return handleError(function (arg0, arg1) {
2131
2142
  const ret = getObject(arg0).run(getObject(arg1));
2132
2143
  return addHeapObject(ret);
2133
2144
  }, arguments); },
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perspective-dev/client",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "Client for Perspective, a high-performance WASM engine with reactive Tables, Views, and joins.",
5
5
  "keywords": [
6
6
  "perspective",
@@ -66,13 +66,13 @@
66
66
  "pro_self_extracting_wasm": "0.0.9",
67
67
  "stoppable": "=1.1.0",
68
68
  "ws": "^8.17.0",
69
- "@perspective-dev/server": "^5.5.0"
69
+ "@perspective-dev/server": "^5.5.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@clickhouse/client-web": "^1.12.0",
73
73
  "@duckdb/duckdb-wasm": "1.33.1-dev18.0",
74
- "@playwright/experimental-ct-react": "=1.58.0",
75
- "@playwright/test": "=1.58.0",
74
+ "@playwright/experimental-ct-react": "=1.62.0",
75
+ "@playwright/test": "=1.62.0",
76
76
  "@types/node": ">=22",
77
77
  "@types/ws": ">=8",
78
78
  "@types/stoppable": ">=1",
@@ -84,9 +84,9 @@
84
84
  "typescript": ">=5 <6",
85
85
  "web-worker": "1.4.1",
86
86
  "zx": ">=8 <9",
87
- "@perspective-dev/esbuild-plugin": "^5.5.0",
88
- "@perspective-dev/metadata": "^5.5.0",
89
- "@perspective-dev/test": "^5.5.0"
87
+ "@perspective-dev/esbuild-plugin": "^5.5.1",
88
+ "@perspective-dev/metadata": "^5.5.1",
89
+ "@perspective-dev/test": "^5.5.1"
90
90
  },
91
91
  "scripts": {
92
92
  "build": "node ./build.mjs",
package/src/rust/view.rs CHANGED
@@ -195,6 +195,17 @@ impl View {
195
195
  }
196
196
 
197
197
  /// Serializes a [`View`] to the Apache Arrow data format.
198
+ ///
199
+ /// # Arguments
200
+ ///
201
+ /// - `window` - a [`ViewWindow`]; its `compression` key selects Arrow IPC
202
+ /// body compression, `"lz4"` or `"zstd"` (uncompressed when omitted).
203
+ ///
204
+ /// # JavaScript Examples
205
+ ///
206
+ /// ```javascript
207
+ /// const arrow = await view.to_arrow({ compression: "zstd" });
208
+ /// ```
198
209
  #[wasm_bindgen]
199
210
  pub async fn to_arrow(&self, window: Option<JsViewWindow>) -> ApiResult<ArrayBuffer> {
200
211
  let window = window.into_serde_ext::<Option<ViewWindow>>()?;
@@ -181,6 +181,7 @@ async function compile_server_module(wasm_path: string) {
181
181
  const bytes = await load_wasm_stage_0(buffer.buffer as ArrayBuffer);
182
182
  return await compile_perspective(bytes.buffer as ArrayBuffer, {
183
183
  make_disk_bridge: make_node_disk_bridge,
184
+ env: process.env,
184
185
  });
185
186
  }
186
187
 
@@ -15,9 +15,10 @@ float32: boolean, start_row?: number, start_col?: number, end_row?: number, end_
15
15
  */
16
16
  formatted?: boolean,
17
17
  /**
18
- * Only impacts [`View::to_arrow`]
18
+ * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
19
+ * (uncompressed when omitted).
19
20
  */
20
- compression?: string,
21
+ compression?: "lz4" | "zstd",
21
22
  /**
22
23
  * When `true`, group-by columns use legacy `"colname (Group by N)"`
23
24
  * naming. When `false`, they use `__ROW_PATH_N__` naming consistent
@@ -12,9 +12,10 @@ export type ViewWindow = { start_row?: number, start_col?: number, end_row?: num
12
12
  */
13
13
  formatted?: boolean,
14
14
  /**
15
- * Only impacts [`View::to_arrow`]
15
+ * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
16
+ * (uncompressed when omitted).
16
17
  */
17
- compression?: string,
18
+ compression?: "lz4" | "zstd",
18
19
  /**
19
20
  * When `true`, group-by columns use legacy `"colname (Group by N)"`
20
21
  * naming. When `false`, they use `__ROW_PATH_N__` naming consistent
@@ -24,6 +24,8 @@ export interface DiskBridgeHelpers {
24
24
  }
25
25
 
26
26
  export interface CompileOptions {
27
+ env?: Record<string, string | undefined>;
28
+
27
29
  make_disk_bridge?: (helpers: DiskBridgeHelpers) => {
28
30
  store(
29
31
  namePtr: number | bigint,
@@ -49,6 +51,7 @@ export async function compile_perspective(
49
51
  return x;
50
52
  },
51
53
  make_disk_bridge: opts?.make_disk_bridge,
54
+ env: opts?.env,
52
55
  instantiateWasm: async (
53
56
  imports: any,
54
57
  receive: (_: WebAssembly.Instance) => void,
@@ -71,6 +71,10 @@ export default async function (obj: any) {
71
71
  // receives a resolved file name string (from `victim_fname`).
72
72
  const disk_helpers = { heap, toAddr, readCString };
73
73
 
74
+ const environ_entries: Uint8Array[] = Object.entries(obj.env ?? {})
75
+ .filter(([, value]) => typeof value === "string")
76
+ .map(([key, value]) => new TextEncoder().encode(`${key}=${value}\0`));
77
+
74
78
  function makeOpfsBridge() {
75
79
  async function opfsOpenFile(name: string, create: boolean) {
76
80
  const parts = name.split("/").filter((s) => s.length > 0);
@@ -281,10 +285,51 @@ export default async function (obj: any) {
281
285
  console.error("abort");
282
286
  }
283
287
  },
284
- environ_get(...args: any[]) {
288
+ environ_get(environ: number | bigint, environ_buf: number | bigint) {
289
+ const view = new DataView(wasm_memory.buffer);
290
+ let entry = toAddr(environ);
291
+ let cursor = toAddr(environ_buf);
292
+ for (const bytes of environ_entries) {
293
+ if (is_memory64) {
294
+ view.setBigUint64(entry, BigInt(cursor), true);
295
+ entry += 8;
296
+ } else {
297
+ view.setUint32(entry, cursor, true);
298
+ entry += 4;
299
+ }
300
+
301
+ heap().set(bytes, cursor);
302
+ cursor += bytes.length;
303
+ }
304
+
285
305
  return 0;
286
306
  },
287
- environ_sizes_get(...args: any[]) {
307
+ environ_sizes_get(
308
+ environ_count: number | bigint,
309
+ environ_buf_size: number | bigint,
310
+ ) {
311
+ const view = new DataView(wasm_memory.buffer);
312
+ const total = environ_entries.reduce((n, x) => n + x.length, 0);
313
+ if (is_memory64) {
314
+ view.setBigUint64(
315
+ toAddr(environ_count),
316
+ BigInt(environ_entries.length),
317
+ true,
318
+ );
319
+ view.setBigUint64(
320
+ toAddr(environ_buf_size),
321
+ BigInt(total),
322
+ true,
323
+ );
324
+ } else {
325
+ view.setUint32(
326
+ toAddr(environ_count),
327
+ environ_entries.length,
328
+ true,
329
+ );
330
+ view.setUint32(toAddr(environ_buf_size), total, true);
331
+ }
332
+
288
333
  return 0;
289
334
  },
290
335
  fd_close(...args: any[]) {
@@ -392,8 +437,9 @@ export default async function (obj: any) {
392
437
  }
393
438
  const n = Number(mod.psp_residency_prepare(server));
394
439
  for (let i = 0; i < n; i++) {
440
+ const index = is_memory64 ? BigInt(i) : i;
395
441
  const fname = readCString(
396
- mod.psp_residency_victim_fname(server, i),
442
+ mod.psp_residency_victim_fname(server, index),
397
443
  );
398
444
  if (fname) {
399
445
  await disk.ensureOpen(fname);