@windborne/grapher 1.0.11 → 1.0.13

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.
@@ -0,0 +1,305 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ function getArrayU8FromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
19
+ }
20
+
21
+ let WASM_VECTOR_LEN = 0;
22
+
23
+ const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
24
+
25
+ let cachedTextEncoder = new lTextEncoder('utf-8');
26
+
27
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
28
+ ? function (arg, view) {
29
+ return cachedTextEncoder.encodeInto(arg, view);
30
+ }
31
+ : function (arg, view) {
32
+ const buf = cachedTextEncoder.encode(arg);
33
+ view.set(buf);
34
+ return {
35
+ read: arg.length,
36
+ written: buf.length
37
+ };
38
+ });
39
+
40
+ function passStringToWasm0(arg, malloc, realloc) {
41
+
42
+ if (realloc === undefined) {
43
+ const buf = cachedTextEncoder.encode(arg);
44
+ const ptr = malloc(buf.length, 1) >>> 0;
45
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
46
+ WASM_VECTOR_LEN = buf.length;
47
+ return ptr;
48
+ }
49
+
50
+ let len = arg.length;
51
+ let ptr = malloc(len, 1) >>> 0;
52
+
53
+ const mem = getUint8ArrayMemory0();
54
+
55
+ let offset = 0;
56
+
57
+ for (; offset < len; offset++) {
58
+ const code = arg.charCodeAt(offset);
59
+ if (code > 0x7F) break;
60
+ mem[ptr + offset] = code;
61
+ }
62
+
63
+ if (offset !== len) {
64
+ if (offset !== 0) {
65
+ arg = arg.slice(offset);
66
+ }
67
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
68
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
69
+ const ret = encodeString(arg, view);
70
+
71
+ offset += ret.written;
72
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
73
+ }
74
+
75
+ WASM_VECTOR_LEN = offset;
76
+ return ptr;
77
+ }
78
+
79
+ function isLikeNone(x) {
80
+ return x === undefined || x === null;
81
+ }
82
+
83
+ let cachedDataViewMemory0 = null;
84
+
85
+ function getDataViewMemory0() {
86
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
87
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
88
+ }
89
+ return cachedDataViewMemory0;
90
+ }
91
+
92
+ const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
93
+
94
+ let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
95
+
96
+ cachedTextDecoder.decode();
97
+
98
+ function getStringFromWasm0(ptr, len) {
99
+ ptr = ptr >>> 0;
100
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
101
+ }
102
+
103
+ let cachedFloat64ArrayMemory0 = null;
104
+
105
+ function getFloat64ArrayMemory0() {
106
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
107
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
108
+ }
109
+ return cachedFloat64ArrayMemory0;
110
+ }
111
+
112
+ function passArrayF64ToWasm0(arg, malloc) {
113
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
114
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
115
+ WASM_VECTOR_LEN = arg.length;
116
+ return ptr;
117
+ }
118
+
119
+ function passArray8ToWasm0(arg, malloc) {
120
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
121
+ getUint8ArrayMemory0().set(arg, ptr / 1);
122
+ WASM_VECTOR_LEN = arg.length;
123
+ return ptr;
124
+ }
125
+ /**
126
+ * @param {number} length
127
+ * @param {Float64Array} data
128
+ * @param {Uint8Array} data_null_mask
129
+ * @param {any} params
130
+ * @param {Uint8Array} null_mask
131
+ * @param {Float64Array} y_values
132
+ * @param {Float64Array} min_y_values
133
+ * @param {Float64Array} max_y_values
134
+ */
135
+ export function selected_space_to_render_space(length, data, data_null_mask, params, null_mask, y_values, min_y_values, max_y_values) {
136
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
137
+ const len0 = WASM_VECTOR_LEN;
138
+ const ptr1 = passArray8ToWasm0(data_null_mask, wasm.__wbindgen_malloc);
139
+ const len1 = WASM_VECTOR_LEN;
140
+ var ptr2 = passArray8ToWasm0(null_mask, wasm.__wbindgen_malloc);
141
+ var len2 = WASM_VECTOR_LEN;
142
+ var ptr3 = passArrayF64ToWasm0(y_values, wasm.__wbindgen_malloc);
143
+ var len3 = WASM_VECTOR_LEN;
144
+ var ptr4 = passArrayF64ToWasm0(min_y_values, wasm.__wbindgen_malloc);
145
+ var len4 = WASM_VECTOR_LEN;
146
+ var ptr5 = passArrayF64ToWasm0(max_y_values, wasm.__wbindgen_malloc);
147
+ var len5 = WASM_VECTOR_LEN;
148
+ wasm.selected_space_to_render_space(length, ptr0, len0, ptr1, len1, params, ptr2, len2, null_mask, ptr3, len3, y_values, ptr4, len4, min_y_values, ptr5, len5, max_y_values);
149
+ }
150
+
151
+ let cachedFloat32ArrayMemory0 = null;
152
+
153
+ function getFloat32ArrayMemory0() {
154
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
155
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
156
+ }
157
+ return cachedFloat32ArrayMemory0;
158
+ }
159
+
160
+ function passArrayF32ToWasm0(arg, malloc) {
161
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
162
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
163
+ WASM_VECTOR_LEN = arg.length;
164
+ return ptr;
165
+ }
166
+
167
+ let cachedUint32ArrayMemory0 = null;
168
+
169
+ function getUint32ArrayMemory0() {
170
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
171
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
172
+ }
173
+ return cachedUint32ArrayMemory0;
174
+ }
175
+
176
+ function passArray32ToWasm0(arg, malloc) {
177
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
178
+ getUint32ArrayMemory0().set(arg, ptr / 4);
179
+ WASM_VECTOR_LEN = arg.length;
180
+ return ptr;
181
+ }
182
+ /**
183
+ * @param {number} dpi_increase
184
+ * @param {Uint8Array} null_mask
185
+ * @param {Float64Array} y_values
186
+ * @param {Float64Array} min_y_values
187
+ * @param {Float64Array} max_y_values
188
+ * @param {Float32Array} positions
189
+ * @param {Float32Array} prev_positions
190
+ * @param {Float32Array} vertices
191
+ * @param {Uint32Array} indices
192
+ * @param {boolean} dashed
193
+ * @param {number} dash0
194
+ * @param {number} dash1
195
+ */
196
+ export function extract_vertices(dpi_increase, null_mask, y_values, min_y_values, max_y_values, positions, prev_positions, vertices, indices, dashed, dash0, dash1) {
197
+ const ptr0 = passArray8ToWasm0(null_mask, wasm.__wbindgen_malloc);
198
+ const len0 = WASM_VECTOR_LEN;
199
+ const ptr1 = passArrayF64ToWasm0(y_values, wasm.__wbindgen_malloc);
200
+ const len1 = WASM_VECTOR_LEN;
201
+ const ptr2 = passArrayF64ToWasm0(min_y_values, wasm.__wbindgen_malloc);
202
+ const len2 = WASM_VECTOR_LEN;
203
+ const ptr3 = passArrayF64ToWasm0(max_y_values, wasm.__wbindgen_malloc);
204
+ const len3 = WASM_VECTOR_LEN;
205
+ var ptr4 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
206
+ var len4 = WASM_VECTOR_LEN;
207
+ var ptr5 = passArrayF32ToWasm0(prev_positions, wasm.__wbindgen_malloc);
208
+ var len5 = WASM_VECTOR_LEN;
209
+ var ptr6 = passArrayF32ToWasm0(vertices, wasm.__wbindgen_malloc);
210
+ var len6 = WASM_VECTOR_LEN;
211
+ var ptr7 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
212
+ var len7 = WASM_VECTOR_LEN;
213
+ wasm.extract_vertices(dpi_increase, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, positions, ptr5, len5, prev_positions, ptr6, len6, vertices, ptr7, len7, indices, dashed, dash0, dash1);
214
+ }
215
+
216
+ /**
217
+ * @param {Uint8Array} null_mask
218
+ * @param {Float64Array} y_values
219
+ * @param {Float64Array} min_y_values
220
+ * @param {Float64Array} max_y_values
221
+ * @param {boolean} dashed
222
+ * @param {number} dash0
223
+ * @param {number} dash1
224
+ * @returns {number}
225
+ */
226
+ export function get_point_number(null_mask, y_values, min_y_values, max_y_values, dashed, dash0, dash1) {
227
+ const ptr0 = passArray8ToWasm0(null_mask, wasm.__wbindgen_malloc);
228
+ const len0 = WASM_VECTOR_LEN;
229
+ const ptr1 = passArrayF64ToWasm0(y_values, wasm.__wbindgen_malloc);
230
+ const len1 = WASM_VECTOR_LEN;
231
+ const ptr2 = passArrayF64ToWasm0(min_y_values, wasm.__wbindgen_malloc);
232
+ const len2 = WASM_VECTOR_LEN;
233
+ const ptr3 = passArrayF64ToWasm0(max_y_values, wasm.__wbindgen_malloc);
234
+ const len3 = WASM_VECTOR_LEN;
235
+ const ret = wasm.get_point_number(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, dashed, dash0, dash1);
236
+ return ret;
237
+ }
238
+
239
+ export function main_js() {
240
+ wasm.main_js();
241
+ }
242
+
243
+ export function __wbg_maxx_a3b1e1c3299e47bf(arg0) {
244
+ const ret = arg0.maxX;
245
+ return ret;
246
+ };
247
+
248
+ export function __wbg_maxy_007b81ea99058122(arg0) {
249
+ const ret = arg0.maxY;
250
+ return ret;
251
+ };
252
+
253
+ export function __wbg_minx_e03d57649d81fc8f(arg0) {
254
+ const ret = arg0.minX;
255
+ return ret;
256
+ };
257
+
258
+ export function __wbg_miny_46aab5af597882a7(arg0) {
259
+ const ret = arg0.minY;
260
+ return ret;
261
+ };
262
+
263
+ export function __wbg_renderheight_d030fe5a23b4c32b(arg0) {
264
+ const ret = arg0.renderHeight;
265
+ return ret;
266
+ };
267
+
268
+ export function __wbg_renderwidth_8685762ee304f2a7(arg0) {
269
+ const ret = arg0.renderWidth;
270
+ return ret;
271
+ };
272
+
273
+ export function __wbg_scale_d705e0de44ed2361(arg0) {
274
+ const ret = arg0.scale;
275
+ return ret;
276
+ };
277
+
278
+ export function __wbindgen_copy_to_typed_array(arg0, arg1, arg2) {
279
+ new Uint8Array(arg2.buffer, arg2.byteOffset, arg2.byteLength).set(getArrayU8FromWasm0(arg0, arg1));
280
+ };
281
+
282
+ export function __wbindgen_init_externref_table() {
283
+ const table = wasm.__wbindgen_export_0;
284
+ const offset = table.grow(4);
285
+ table.set(0, undefined);
286
+ table.set(offset + 0, undefined);
287
+ table.set(offset + 1, null);
288
+ table.set(offset + 2, true);
289
+ table.set(offset + 3, false);
290
+ ;
291
+ };
292
+
293
+ export function __wbindgen_string_get(arg0, arg1) {
294
+ const obj = arg1;
295
+ const ret = typeof(obj) === 'string' ? obj : undefined;
296
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
297
+ var len1 = WASM_VECTOR_LEN;
298
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
299
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
300
+ };
301
+
302
+ export function __wbindgen_throw(arg0, arg1) {
303
+ throw new Error(getStringFromWasm0(arg0, arg1));
304
+ };
305
+
Binary file
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "grapher-rs",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "Kai Marshland <kaimarshland@gmail.com>"
5
6
  ],
6
7
  "version": "0.1.0",
7
8
  "files": [
8
9
  "index_bg.wasm",
9
- "index.js",
10
- "index_bg.js"
10
+ "index.js"
11
11
  ],
12
- "module": "index.js",
13
- "sideEffects": false
12
+ "main": "index.js",
13
+ "sideEffects": [
14
+ "./snippets/*"
15
+ ]
14
16
  }
@@ -0,0 +1,10 @@
1
+ let rustApiModule;
2
+ export const RustAPIPromise = import('../rust/pkg/index.js').then((module) => {
3
+ return module.default().then(() => {
4
+ rustApiModule = module;
5
+ });
6
+ });
7
+
8
+ export default function RustAPI() {
9
+ return rustApiModule;
10
+ }
@@ -1,8 +1,6 @@
1
1
  import scaleBounds from '../../renderer/scale_bounds';
2
- let RustAPI;
3
- import('../../rust/pkg/index.js').then((module) => {
4
- RustAPI = module;
5
- });
2
+ import RustAPI from '../rust_api';
3
+
6
4
 
7
5
  function selectedSpaceToRenderSpaceInPlace({ data, renderWidth, renderHeight, minX, maxX, minY, maxY, scale }, { nullMask, yValues, minYValues, maxYValues }) {
8
6
  let i = 0;
@@ -120,7 +118,7 @@ export default function selectedSpaceToRenderSpace({ data, swap, renderWidth, re
120
118
 
121
119
  let dataF64, dataNullMask;
122
120
 
123
- if (RustAPI) {
121
+ if (RustAPI()) {
124
122
  let copyIndexStart = 0;
125
123
 
126
124
  const hasSwap = swap && swap.dataNullMask && swap.dataF64;
@@ -154,7 +152,7 @@ export default function selectedSpaceToRenderSpace({ data, swap, renderWidth, re
154
152
  dataNullMask[i] = 0;
155
153
  }
156
154
  }
157
- RustAPI.selected_space_to_render_space(data.length, dataF64, dataNullMask, inParams, nullMask, yValues, minYValues, maxYValues);
155
+ RustAPI().selected_space_to_render_space(data.length, dataF64, dataNullMask, inParams, nullMask, yValues, minYValues, maxYValues);
158
156
  } else {
159
157
  selectedSpaceToRenderSpaceInPlace(inParams, { nullMask, yValues, minYValues, maxYValues });
160
158
  }
@@ -18,10 +18,7 @@ import {averageLoopTimes} from './average_loop_times';
18
18
  import condenseDataSpace from './space_conversions/condense_data_space.js';
19
19
  import calculateAnnotationsState from './calculate_annotations_state.js';
20
20
  import {selectedSpaceToBackgroundSpace} from './space_conversions/selected_space_to_background_space.js';
21
- let RustAPI;
22
- const RustAPIPromise = import('../rust/pkg/index.js').then((module) => {
23
- RustAPI = module;
24
- });
21
+ import RustAPI, {RustAPIPromise} from './rust_api';
25
22
 
26
23
  export default class StateController extends Eventable {
27
24
 
@@ -625,7 +622,7 @@ export default class StateController extends Eventable {
625
622
  singleSeries.simpleDataSliceStart = simpleData.length;
626
623
  singleSeries.dataBounds = calculateDataBounds(singleSeries.inDataSpace);
627
624
  if (singleSeries.rendering === 'bar') {
628
- singleSeries.dataBounds = expandBounds(singleSeries.dataBounds, { extendXForNBars: singleSeries.inDataSpace.length });
625
+ singleSeries.dataBounds = expandBounds(singleSeries.dataBounds, { extendXForNBars: singleSeries.inDataSpace.length, expandYWith: singleSeries.expandYWith });
629
626
  }
630
627
 
631
628
  dataBoundsList.push(singleSeries.dataBounds);
@@ -712,7 +709,7 @@ export default class StateController extends Eventable {
712
709
 
713
710
  let newDataBounds = calculateDataBounds(newDataInDataSpace);
714
711
  if (singleSeries.rendering === 'bar') {
715
- newDataBounds = expandBounds(newDataBounds, { extendXForNBars: singleSeries.inDataSpace.length });
712
+ newDataBounds = expandBounds(newDataBounds, { extendXForNBars: singleSeries.inDataSpace.length, expandYWith: singleSeries.expandYWith });
716
713
  }
717
714
 
718
715
  singleSeries.dataBounds = mergeBounds([singleSeries.dataBounds, newDataBounds]);
@@ -97,7 +97,7 @@ module.exports = {
97
97
  new WasmPackPlugin({
98
98
  crateDirectory: path.resolve(__dirname, 'src', 'rust'),
99
99
  outDir: path.resolve(__dirname, 'src', 'rust', 'pkg'),
100
- extraArgs: '--no-typescript',
100
+ extraArgs: '--no-typescript --target web',
101
101
  forceMode: 'production'
102
102
  }),
103
103
  ...pages.map((page) => new HtmlWebpackPlugin({
@@ -53,7 +53,7 @@ module.exports = {
53
53
  new WasmPackPlugin({
54
54
  crateDirectory: path.resolve(__dirname, 'src', 'rust'),
55
55
  outDir: path.resolve(__dirname, 'src', 'rust', 'pkg'),
56
- extraArgs: '--no-typescript',
56
+ extraArgs: '--no-typescript --target web',
57
57
  forceMode: 'production'
58
58
  })
59
59
  ]
Binary file
@@ -1,42 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {number} length
5
- * @param {Float64Array} data
6
- * @param {Uint8Array} data_null_mask
7
- * @param {any} params
8
- * @param {Uint8Array} null_mask
9
- * @param {Float64Array} y_values
10
- * @param {Float64Array} min_y_values
11
- * @param {Float64Array} max_y_values
12
- */
13
- export function selected_space_to_render_space(length: number, data: Float64Array, data_null_mask: Uint8Array, params: any, null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array): void;
14
- /**
15
- * @param {number} dpi_increase
16
- * @param {Uint8Array} null_mask
17
- * @param {Float64Array} y_values
18
- * @param {Float64Array} min_y_values
19
- * @param {Float64Array} max_y_values
20
- * @param {Float32Array} positions
21
- * @param {Float32Array} prev_positions
22
- * @param {Float32Array} vertices
23
- * @param {Uint32Array} indices
24
- * @param {boolean} dashed
25
- * @param {number} dash0
26
- * @param {number} dash1
27
- */
28
- export function extract_vertices(dpi_increase: number, null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array, positions: Float32Array, prev_positions: Float32Array, vertices: Float32Array, indices: Uint32Array, dashed: boolean, dash0: number, dash1: number): void;
29
- /**
30
- */
31
- export function main_js(): void;
32
- /**
33
- * @param {Uint8Array} null_mask
34
- * @param {Float64Array} y_values
35
- * @param {Float64Array} min_y_values
36
- * @param {Float64Array} max_y_values
37
- * @param {boolean} dashed
38
- * @param {number} dash0
39
- * @param {number} dash1
40
- * @returns {number}
41
- */
42
- export function get_point_number(null_mask: Uint8Array, y_values: Float64Array, min_y_values: Float64Array, max_y_values: Float64Array, dashed: boolean, dash0: number, dash1: number): number;