@perspective-dev/client 5.3.0 → 5.3.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.
@@ -964,12 +964,12 @@ export interface InitOutput {
964
964
  readonly virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
965
965
  readonly virtualserver_handleRequest: (a: number, b: number, c: number) => number;
966
966
  readonly virtualserver_new: (a: number, b: number) => void;
967
- readonly __wasm_bindgen_func_elem_1164: (a: number, b: number) => void;
968
- readonly __wasm_bindgen_func_elem_4285: (a: number, b: number) => void;
969
- readonly __wasm_bindgen_func_elem_12453: (a: number, b: number, c: number, d: number) => void;
970
- readonly __wasm_bindgen_func_elem_4302: (a: number, b: number, c: number) => void;
971
- readonly __wasm_bindgen_func_elem_1899: (a: number, b: number) => number;
972
- readonly __wasm_bindgen_func_elem_1900: (a: number, b: number) => void;
967
+ readonly __wasm_bindgen_func_elem_1178: (a: number, b: number) => void;
968
+ readonly __wasm_bindgen_func_elem_4323: (a: number, b: number) => void;
969
+ readonly __wasm_bindgen_func_elem_12505: (a: number, b: number, c: number, d: number) => void;
970
+ readonly __wasm_bindgen_func_elem_4340: (a: number, b: number, c: number) => void;
971
+ readonly __wasm_bindgen_func_elem_1927: (a: number, b: number) => number;
972
+ readonly __wasm_bindgen_func_elem_1928: (a: number, b: number) => void;
973
973
  readonly __wbindgen_export: (a: number, b: number) => number;
974
974
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
975
975
  readonly __wbindgen_export3: (a: number) => void;
@@ -2017,7 +2017,7 @@ function __wbg_get_imports() {
2017
2017
  const a = state0.a;
2018
2018
  state0.a = 0;
2019
2019
  try {
2020
- return __wasm_bindgen_func_elem_12453(a, state0.b, arg0, arg1);
2020
+ return __wasm_bindgen_func_elem_12505(a, state0.b, arg0, arg1);
2021
2021
  } finally {
2022
2022
  state0.a = a;
2023
2023
  }
@@ -2092,7 +2092,7 @@ function __wbg_get_imports() {
2092
2092
  const ret = Promise.resolve(getObject(arg0));
2093
2093
  return addHeapObject(ret);
2094
2094
  },
2095
- __wbg_run_6b188d9db01ef98f: function() { return handleError(function (arg0, arg1) {
2095
+ __wbg_run_eb9b330adc7bc53c: function() { return handleError(function (arg0, arg1) {
2096
2096
  const ret = getObject(arg0).run(getObject(arg1));
2097
2097
  return addHeapObject(ret);
2098
2098
  }, arguments); },
@@ -2180,17 +2180,17 @@ function __wbg_get_imports() {
2180
2180
  },
2181
2181
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2182
2182
  // Cast intrinsic for `Closure(Closure { dtor_idx: 12, function: Function { arguments: [], shim_idx: 32, ret: NamedExternref("Promise<any>"), inner_ret: Some(NamedExternref("Promise<any>")) }, mutable: false }) -> Externref`.
2183
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1164, __wasm_bindgen_func_elem_1899);
2183
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1178, __wasm_bindgen_func_elem_1927);
2184
2184
  return addHeapObject(ret);
2185
2185
  },
2186
2186
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2187
2187
  // Cast intrinsic for `Closure(Closure { dtor_idx: 12, function: Function { arguments: [], shim_idx: 33, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
2188
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1164, __wasm_bindgen_func_elem_1900);
2188
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1178, __wasm_bindgen_func_elem_1928);
2189
2189
  return addHeapObject(ret);
2190
2190
  },
2191
2191
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2192
2192
  // Cast intrinsic for `Closure(Closure { dtor_idx: 591, function: Function { arguments: [Externref], shim_idx: 592, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2193
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4285, __wasm_bindgen_func_elem_4302);
2193
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4323, __wasm_bindgen_func_elem_4340);
2194
2194
  return addHeapObject(ret);
2195
2195
  },
2196
2196
  __wbindgen_cast_0000000000000004: function(arg0) {
@@ -2267,21 +2267,21 @@ function __wbg_get_imports() {
2267
2267
  };
2268
2268
  }
2269
2269
 
2270
- function __wasm_bindgen_func_elem_1900(arg0, arg1) {
2271
- wasm.__wasm_bindgen_func_elem_1900(arg0, arg1);
2270
+ function __wasm_bindgen_func_elem_1928(arg0, arg1) {
2271
+ wasm.__wasm_bindgen_func_elem_1928(arg0, arg1);
2272
2272
  }
2273
2273
 
2274
- function __wasm_bindgen_func_elem_1899(arg0, arg1) {
2275
- const ret = wasm.__wasm_bindgen_func_elem_1899(arg0, arg1);
2274
+ function __wasm_bindgen_func_elem_1927(arg0, arg1) {
2275
+ const ret = wasm.__wasm_bindgen_func_elem_1927(arg0, arg1);
2276
2276
  return takeObject(ret);
2277
2277
  }
2278
2278
 
2279
- function __wasm_bindgen_func_elem_4302(arg0, arg1, arg2) {
2280
- wasm.__wasm_bindgen_func_elem_4302(arg0, arg1, addHeapObject(arg2));
2279
+ function __wasm_bindgen_func_elem_4340(arg0, arg1, arg2) {
2280
+ wasm.__wasm_bindgen_func_elem_4340(arg0, arg1, addHeapObject(arg2));
2281
2281
  }
2282
2282
 
2283
- function __wasm_bindgen_func_elem_12453(arg0, arg1, arg2, arg3) {
2284
- wasm.__wasm_bindgen_func_elem_12453(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2283
+ function __wasm_bindgen_func_elem_12505(arg0, arg1, arg2, arg3) {
2284
+ wasm.__wasm_bindgen_func_elem_12505(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2285
2285
  }
2286
2286
 
2287
2287
  const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
Binary file
@@ -93,12 +93,12 @@ export const virtualdataslice_setIntegerCol: (a: number, b: number, c: number, d
93
93
  export const virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
94
94
  export const virtualserver_handleRequest: (a: number, b: number, c: number) => number;
95
95
  export const virtualserver_new: (a: number, b: number) => void;
96
- export const __wasm_bindgen_func_elem_1164: (a: number, b: number) => void;
97
- export const __wasm_bindgen_func_elem_4285: (a: number, b: number) => void;
98
- export const __wasm_bindgen_func_elem_12453: (a: number, b: number, c: number, d: number) => void;
99
- export const __wasm_bindgen_func_elem_4302: (a: number, b: number, c: number) => void;
100
- export const __wasm_bindgen_func_elem_1899: (a: number, b: number) => number;
101
- export const __wasm_bindgen_func_elem_1900: (a: number, b: number) => void;
96
+ export const __wasm_bindgen_func_elem_1178: (a: number, b: number) => void;
97
+ export const __wasm_bindgen_func_elem_4323: (a: number, b: number) => void;
98
+ export const __wasm_bindgen_func_elem_12505: (a: number, b: number, c: number, d: number) => void;
99
+ export const __wasm_bindgen_func_elem_4340: (a: number, b: number, c: number) => void;
100
+ export const __wasm_bindgen_func_elem_1927: (a: number, b: number) => number;
101
+ export const __wasm_bindgen_func_elem_1928: (a: number, b: number) => void;
102
102
  export const __wbindgen_export: (a: number, b: number) => number;
103
103
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
104
104
  export const __wbindgen_export3: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perspective-dev/client",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Client for Perspective, a high-performance WASM engine with reactive Tables, Views, and joins.",
5
5
  "keywords": [
6
6
  "perspective",
@@ -14,7 +14,9 @@ use std::io::Cursor;
14
14
 
15
15
  use arrow_array::cast::AsArray;
16
16
  use arrow_array::types::*;
17
- use arrow_array::{Array as _, ArrowPrimitiveType, DictionaryArray, PrimitiveArray, StringArray};
17
+ use arrow_array::{
18
+ Array as _, ArrayRef, ArrowPrimitiveType, DictionaryArray, PrimitiveArray, StringArray,
19
+ };
18
20
  use arrow_ipc::reader::StreamReader;
19
21
  use arrow_schema::{DataType, TimeUnit};
20
22
  use js_sys::{Array, Function, JsString, Uint8Array};
@@ -74,6 +76,33 @@ fn zero_invalid_slots<T: ArrowPrimitiveType>(arr: &PrimitiveArray<T>) {
74
76
  }
75
77
  }
76
78
 
79
+ /// Emit a sub-32-bit integer column as an `Int32Array`. Every Arrow
80
+ /// integer width the engine emits below 32 bits (`i8`/`u8`/`i16`/`u16`)
81
+ /// widens losslessly, so consumers see ONE integer representation
82
+ /// regardless of the column's storage width — and, like `Int32`, one
83
+ /// the `float32` flag never narrows. Needs a copy; `Box<[i32]>` gives
84
+ /// the stable data pointer the zero-copy `view` requires, exactly as
85
+ /// the `f32`/`f64` conversion buffers do.
86
+ fn set_widened_i32<T>(
87
+ col: &ArrayRef,
88
+ col_idx: usize,
89
+ js_values: &Array,
90
+ js_dicts: &Array,
91
+ storage: &mut Vec<Box<[i32]>>,
92
+ ) where
93
+ T: ArrowPrimitiveType,
94
+ T::Native: Into<i32>,
95
+ {
96
+ let typed = col.as_primitive::<T>();
97
+ zero_invalid_slots(typed);
98
+ let vals: Box<[i32]> = typed.values().iter().map(|&v| v.into()).collect();
99
+
100
+ let arr = unsafe { js_sys::Int32Array::view(&vals) };
101
+ storage.push(vals);
102
+ js_values.set(col_idx as u32, arr.into());
103
+ js_dicts.set(col_idx as u32, JsValue::NULL);
104
+ }
105
+
77
106
  /// Decode an Arrow IPC batch and call `callback` once with all columns.
78
107
  ///
79
108
  /// Callback signature:
@@ -108,12 +137,14 @@ pub(crate) async fn decode_and_call(
108
137
  let js_validities = Array::new_with_length(num_cols as u32);
109
138
  let js_dicts = Array::new_with_length(num_cols as u32);
110
139
 
111
- // Storage for type-conversion buffers (Int64/Date32/Timestamp and
112
- // `float32` narrowing). These MUST outlive the callback because
113
- // `js_sys::*Array::view()` creates zero-copy views into their heap
114
- // memory. Using `Box<[T]>` (rather than `Vec<T>`) yields a stable
115
- // data pointer that won't move when the outer Vec grows, so a view
116
- // created before the push stays valid.
140
+ // Storage for type-conversion buffers (narrow-int/bool widening,
141
+ // Int64/UInt64/Date32/Timestamp and `float32` narrowing). These
142
+ // MUST outlive the callback because `js_sys::*Array::view()`
143
+ // creates zero-copy views into their heap memory. Using `Box<[T]>`
144
+ // (rather than `Vec<T>`) yields a stable data pointer that won't
145
+ // move when the outer Vec grows, so a view created before the push
146
+ // stays valid.
147
+ let mut i32_storage: Vec<Box<[i32]>> = Vec::new();
117
148
  let mut f32_storage: Vec<Box<[f32]>> = Vec::new();
118
149
  let mut f64_storage: Vec<Box<[f64]>> = Vec::new();
119
150
 
@@ -133,6 +164,24 @@ pub(crate) async fn decode_and_call(
133
164
  js_names.set(col_idx as u32, JsString::from(field.name().as_str()).into());
134
165
 
135
166
  match col.data_type() {
167
+ DataType::Int8 => {
168
+ set_widened_i32::<Int8Type>(col, col_idx, &js_values, &js_dicts, &mut i32_storage);
169
+ },
170
+ DataType::UInt8 => {
171
+ set_widened_i32::<UInt8Type>(col, col_idx, &js_values, &js_dicts, &mut i32_storage);
172
+ },
173
+ DataType::Int16 => {
174
+ set_widened_i32::<Int16Type>(col, col_idx, &js_values, &js_dicts, &mut i32_storage);
175
+ },
176
+ DataType::UInt16 => {
177
+ set_widened_i32::<UInt16Type>(
178
+ col,
179
+ col_idx,
180
+ &js_values,
181
+ &js_dicts,
182
+ &mut i32_storage,
183
+ );
184
+ },
136
185
  DataType::UInt32 => {
137
186
  let typed = col.as_primitive::<UInt32Type>();
138
187
  zero_invalid_slots(typed);
@@ -218,6 +267,46 @@ pub(crate) async fn decode_and_call(
218
267
 
219
268
  js_dicts.set(col_idx as u32, JsValue::NULL);
220
269
  },
270
+ // Neither `u64` nor `i64` fits `Int32Array`, so both widen
271
+ // to float (narrowed by `float32` like the other float
272
+ // columns) and lose exactness past 2^53. `UInt64` is not an
273
+ // exotic case: `get_simple_accumulator_type` promotes EVERY
274
+ // unsigned width to `DTYPE_UINT64`, so the `sum` of any
275
+ // unsigned column in a `group_by` view lands here.
276
+ DataType::UInt64 => {
277
+ let typed = col.as_primitive::<UInt64Type>();
278
+ zero_invalid_slots(typed);
279
+ if float32 {
280
+ let vals: Box<[f32]> = typed.values().iter().map(|&v| v as f32).collect();
281
+
282
+ let arr = unsafe { js_sys::Float32Array::view(&vals) };
283
+ f32_storage.push(vals);
284
+ js_values.set(col_idx as u32, arr.into());
285
+ } else {
286
+ let vals: Box<[f64]> = typed.values().iter().map(|&v| v as f64).collect();
287
+
288
+ let arr = unsafe { js_sys::Float64Array::view(&vals) };
289
+ f64_storage.push(vals);
290
+ js_values.set(col_idx as u32, arr.into());
291
+ }
292
+
293
+ js_dicts.set(col_idx as u32, JsValue::NULL);
294
+ },
295
+ DataType::Boolean => {
296
+ // Bit-packed, so `zero_invalid_slots` (a `PrimitiveArray`
297
+ // memory rewrite) cannot apply — the `is_valid` test
298
+ // below enforces the same "invalid slots read 0"
299
+ // contract while materializing.
300
+ let typed = col.as_boolean();
301
+ let vals: Box<[i32]> = (0..typed.len())
302
+ .map(|i| i32::from(typed.is_valid(i) && typed.value(i)))
303
+ .collect();
304
+
305
+ let arr = unsafe { js_sys::Int32Array::view(&vals) };
306
+ i32_storage.push(vals);
307
+ js_values.set(col_idx as u32, arr.into());
308
+ js_dicts.set(col_idx as u32, JsValue::NULL);
309
+ },
221
310
  DataType::Dictionary(..) => {
222
311
  let dict = col
223
312
  .as_any()
@@ -279,9 +368,9 @@ pub(crate) async fn decode_and_call(
279
368
  )?;
280
369
 
281
370
  // If the callback returned a Promise, await it before releasing the
282
- // batch — zero-copy TypedArray views into `batch`/`f32_storage`/
283
- // `f64_storage` must remain valid for the full lifetime of the
284
- // awaited work.
371
+ // batch — zero-copy TypedArray views into `batch` and the
372
+ // `i32`/`f32`/`f64` conversion buffers must remain valid for the
373
+ // full lifetime of the awaited work.
285
374
  if ret.is_instance_of::<js_sys::Promise>() {
286
375
  let promise: js_sys::Promise = ret.unchecked_into();
287
376
  wasm_bindgen_futures::JsFuture::from(promise).await?;
@@ -289,6 +378,7 @@ pub(crate) async fn decode_and_call(
289
378
 
290
379
  // Keep storage alive until after the callback (and its awaited
291
380
  // promise, if any) returns.
381
+ drop(i32_storage);
292
382
  drop(f32_storage);
293
383
  drop(f64_storage);
294
384