@perspective-dev/client 5.4.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.
@@ -1400,6 +1400,17 @@ var View = class _View {
1400
1400
  }
1401
1401
  /**
1402
1402
  * Serializes a [`View`] to the Apache Arrow data format.
1403
+ *
1404
+ * # Arguments
1405
+ *
1406
+ * - `window` - a [`ViewWindow`]; its `compression` key selects Arrow IPC
1407
+ * body compression, `"lz4"` or `"zstd"` (uncompressed when omitted).
1408
+ *
1409
+ * # JavaScript Examples
1410
+ *
1411
+ * ```javascript
1412
+ * const arrow = await view.to_arrow({ compression: "zstd" });
1413
+ * ```
1403
1414
  * @param {ViewWindow | null} [window]
1404
1415
  * @returns {Promise<ArrayBuffer>}
1405
1416
  */
@@ -2150,7 +2161,7 @@ function __wbg_get_imports() {
2150
2161
  const ret = Promise.resolve(getObject(arg0));
2151
2162
  return addHeapObject(ret);
2152
2163
  },
2153
- __wbg_run_a7d22113de2ff7d8: function() {
2164
+ __wbg_run_556972011e45ec00: function() {
2154
2165
  return handleError(function(arg0, arg1) {
2155
2166
  const ret = getObject(arg0).run(getObject(arg1));
2156
2167
  return addHeapObject(ret);
@@ -2962,6 +2973,7 @@ async function perspective_server_poly_default(obj) {
2962
2973
  return UTF8Decoder.decode(h.subarray(addr, end));
2963
2974
  }
2964
2975
  const disk_helpers = { heap: heap2, toAddr, readCString };
2976
+ const environ_entries = Object.entries(obj.env ?? {}).filter(([, value]) => typeof value === "string").map(([key, value]) => new TextEncoder().encode(`${key}=${value}\0`));
2965
2977
  function makeOpfsBridge() {
2966
2978
  async function opfsOpenFile(name, create) {
2967
2979
  const parts = name.split("/").filter((s) => s.length > 0);
@@ -3124,10 +3136,45 @@ async function perspective_server_poly_default(obj) {
3124
3136
  console.error("abort");
3125
3137
  }
3126
3138
  },
3127
- environ_get(...args) {
3139
+ environ_get(environ, environ_buf) {
3140
+ const view = new DataView(wasm_memory.buffer);
3141
+ let entry = toAddr(environ);
3142
+ let cursor = toAddr(environ_buf);
3143
+ for (const bytes of environ_entries) {
3144
+ if (is_memory64) {
3145
+ view.setBigUint64(entry, BigInt(cursor), true);
3146
+ entry += 8;
3147
+ } else {
3148
+ view.setUint32(entry, cursor, true);
3149
+ entry += 4;
3150
+ }
3151
+ heap2().set(bytes, cursor);
3152
+ cursor += bytes.length;
3153
+ }
3128
3154
  return 0;
3129
3155
  },
3130
- environ_sizes_get(...args) {
3156
+ environ_sizes_get(environ_count, environ_buf_size) {
3157
+ const view = new DataView(wasm_memory.buffer);
3158
+ const total = environ_entries.reduce((n, x2) => n + x2.length, 0);
3159
+ if (is_memory64) {
3160
+ view.setBigUint64(
3161
+ toAddr(environ_count),
3162
+ BigInt(environ_entries.length),
3163
+ true
3164
+ );
3165
+ view.setBigUint64(
3166
+ toAddr(environ_buf_size),
3167
+ BigInt(total),
3168
+ true
3169
+ );
3170
+ } else {
3171
+ view.setUint32(
3172
+ toAddr(environ_count),
3173
+ environ_entries.length,
3174
+ true
3175
+ );
3176
+ view.setUint32(toAddr(environ_buf_size), total, true);
3177
+ }
3131
3178
  return 0;
3132
3179
  },
3133
3180
  fd_close(...args) {
@@ -3209,8 +3256,9 @@ async function perspective_server_poly_default(obj) {
3209
3256
  }
3210
3257
  const n = Number(mod.psp_residency_prepare(server));
3211
3258
  for (let i = 0; i < n; i++) {
3259
+ const index = is_memory64 ? BigInt(i) : i;
3212
3260
  const fname = readCString(
3213
- mod.psp_residency_victim_fname(server, i)
3261
+ mod.psp_residency_victim_fname(server, index)
3214
3262
  );
3215
3263
  if (fname) {
3216
3264
  await disk.ensureOpen(fname);
@@ -3235,6 +3283,7 @@ async function compile_perspective(wasmBinary, opts) {
3235
3283
  return x;
3236
3284
  },
3237
3285
  make_disk_bridge: opts?.make_disk_bridge,
3286
+ env: opts?.env,
3238
3287
  instantiateWasm: async (imports, receive) => {
3239
3288
  imports["env"] = {
3240
3289
  ...imports["env"],
@@ -3456,7 +3505,8 @@ async function compile_server_module(wasm_path) {
3456
3505
  const buffer = await fs.readFile(wasm_path);
3457
3506
  const bytes = await load_wasm_stage_0(buffer.buffer);
3458
3507
  return await compile_perspective(bytes.buffer, {
3459
- make_disk_bridge: make_node_disk_bridge
3508
+ make_disk_bridge: make_node_disk_bridge,
3509
+ env: process.env
3460
3510
  });
3461
3511
  }
3462
3512
  async function load_server_module() {