wick-charts 0.3.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +545 -0
  3. package/dist/axis.d.ts +21 -0
  4. package/dist/axis.js +44 -0
  5. package/dist/dataSource.d.ts +24 -0
  6. package/dist/dataSource.js +1 -0
  7. package/dist/hitTest.d.ts +31 -0
  8. package/dist/hitTest.js +46 -0
  9. package/dist/hybridScale.d.ts +25 -0
  10. package/dist/hybridScale.js +41 -0
  11. package/dist/index.d.ts +225 -0
  12. package/dist/index.js +715 -0
  13. package/dist/mergeSeries.d.ts +14 -0
  14. package/dist/mergeSeries.js +21 -0
  15. package/dist/plugins/types.d.ts +140 -0
  16. package/dist/plugins/types.js +1 -0
  17. package/dist/priceAxis.d.ts +7 -0
  18. package/dist/priceAxis.js +49 -0
  19. package/dist/priceRange.d.ts +12 -0
  20. package/dist/priceRange.js +16 -0
  21. package/dist/renderer.d.ts +79 -0
  22. package/dist/renderer.js +318 -0
  23. package/dist/scale.d.ts +20 -0
  24. package/dist/scale.js +29 -0
  25. package/dist/series/candlestick.d.ts +20 -0
  26. package/dist/series/candlestick.js +88 -0
  27. package/dist/series/registry.d.ts +13 -0
  28. package/dist/series/registry.js +30 -0
  29. package/dist/series/types.d.ts +56 -0
  30. package/dist/series/types.js +1 -0
  31. package/dist/testHelpers.d.ts +38 -0
  32. package/dist/testHelpers.js +50 -0
  33. package/dist/time.d.ts +6 -0
  34. package/dist/time.js +58 -0
  35. package/dist/types.d.ts +151 -0
  36. package/dist/types.js +1 -0
  37. package/dist/viewport.d.ts +52 -0
  38. package/dist/viewport.js +87 -0
  39. package/dist/wasm.d.ts +29 -0
  40. package/dist/wasm.js +35 -0
  41. package/dist/wasmImporter.d.ts +6 -0
  42. package/dist/wasmImporter.js +7 -0
  43. package/package.json +39 -0
  44. package/wasm-pkg/package.json +21 -0
  45. package/wasm-pkg/wickchart_core.d.ts +59 -0
  46. package/wasm-pkg/wickchart_core.js +227 -0
  47. package/wasm-pkg/wickchart_core_bg.wasm +0 -0
  48. package/wasm-pkg/wickchart_core_bg.wasm.d.ts +11 -0
@@ -0,0 +1,87 @@
1
+ const MIN_VISIBLE_COUNT = 5;
2
+ const MIN_VALUE_SCALE_FACTOR = 0.5;
3
+ const MAX_VALUE_SCALE_FACTOR = 8;
4
+ function clamp(value, min, max) {
5
+ return Math.min(max, Math.max(min, value));
6
+ }
7
+ /**
8
+ * Pure pan/zoom/value-scale state — no DOM, no canvas. `WickChart` owns
9
+ * translating pixel deltas (drag distance, wheel delta) into calls here;
10
+ * this class only owns the resulting numbers, which keeps it unit-testable
11
+ * without a canvas. Generic across series types: "value" here is whatever
12
+ * the active `SeriesDefinition.getValueRange` returns for the y-axis —
13
+ * price for candlesticks, but no different in kind for a future line or
14
+ * bar series's own value domain.
15
+ */
16
+ export class Viewport {
17
+ constructor(totalCount, visibleCount) {
18
+ /** 1 = auto-fit value range. >1 widens it (the series looks
19
+ * shorter/compressed). <1 narrows it (the series looks taller), clamped
20
+ * so real data never clips off-screen. Sign of drag->factor mapping
21
+ * lives in WickChart, not here. */
22
+ this.valueScaleFactor = 1;
23
+ /** Manually-set value range from a vertical drag or value-axis scale.
24
+ * `null` until the user first touches the value axis — while `null` the
25
+ * renderer auto-fits (see `SeriesDefinition.getValueRange`) using
26
+ * `valueScaleFactor` alone. Once set, auto-fit stops applying: the user
27
+ * has taken explicit control of the axis, so the chart stops
28
+ * recentering it under them. */
29
+ this.valueRangeOverride = null;
30
+ this.visibleCount = clamp(visibleCount ?? totalCount, MIN_VISIBLE_COUNT, Math.max(totalCount, MIN_VISIBLE_COUNT));
31
+ this.startIndex = clamp(totalCount - this.visibleCount, 0, Math.max(0, totalCount - this.visibleCount));
32
+ }
33
+ get endIndex() {
34
+ return this.startIndex + this.visibleCount;
35
+ }
36
+ /** Shifts the visible window. Positive `deltaPoints` moves forward in
37
+ * time (later points come into view on the right). Clamped so the
38
+ * window never leaves [0, totalCount] — no overscroll past the data. */
39
+ pan(deltaPoints, totalCount) {
40
+ const maxStart = Math.max(0, totalCount - this.visibleCount);
41
+ this.startIndex = clamp(this.startIndex + deltaPoints, 0, maxStart);
42
+ }
43
+ /** Scales the visible window by `factor` (>1 zooms out, <1 zooms in),
44
+ * keeping the point at `anchorIndex` under the same relative position —
45
+ * the standard "zoom toward the cursor" feel. */
46
+ zoom(factor, anchorIndex, totalCount) {
47
+ const newVisibleCount = clamp(this.visibleCount * factor, MIN_VISIBLE_COUNT, totalCount);
48
+ const anchorRatio = this.visibleCount === 0 ? 0.5 : (anchorIndex - this.startIndex) / this.visibleCount;
49
+ this.visibleCount = newVisibleCount;
50
+ const maxStart = Math.max(0, totalCount - this.visibleCount);
51
+ this.startIndex = clamp(anchorIndex - anchorRatio * newVisibleCount, 0, maxStart);
52
+ }
53
+ /** Multiplies the value-scale factor, clamped to a sane range so the
54
+ * value axis can't be dragged into showing nothing or clipping data.
55
+ * Only affects the auto-fit path — a no-op once `valueRangeOverride` is
56
+ * set, at which point `scaleValueRange` takes over. */
57
+ scaleValue(factor) {
58
+ this.valueScaleFactor = clamp(this.valueScaleFactor * factor, MIN_VALUE_SCALE_FACTOR, MAX_VALUE_SCALE_FACTOR);
59
+ }
60
+ /** Switches the value axis to manual mode, pinned at `range`. Call once,
61
+ * lazily, the first time the user drags vertically — see `WickChart`. */
62
+ setValueRangeOverride(range) {
63
+ this.valueRangeOverride = range;
64
+ }
65
+ /** Shifts the manual value range by an absolute amount (same units as
66
+ * the plotted value). No-op until `setValueRangeOverride` has been
67
+ * called at least once — there is nothing to shift relative to
68
+ * otherwise. */
69
+ panValueRange(deltaAbsolute) {
70
+ if (!this.valueRangeOverride)
71
+ return;
72
+ this.valueRangeOverride = {
73
+ min: this.valueRangeOverride.min + deltaAbsolute,
74
+ max: this.valueRangeOverride.max + deltaAbsolute,
75
+ };
76
+ }
77
+ /** Scales the manual value range around its own center. No-op until
78
+ * `setValueRangeOverride` has been called at least once. */
79
+ scaleValueRange(factor) {
80
+ if (!this.valueRangeOverride)
81
+ return;
82
+ const { min, max } = this.valueRangeOverride;
83
+ const mid = (min + max) / 2;
84
+ const halfSpan = ((max - min) / 2) * factor;
85
+ this.valueRangeOverride = { min: mid - halfSpan, max: mid + halfSpan };
86
+ }
87
+ }
package/dist/wasm.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ /** Shape of the compiled wickchart-core WASM module as exposed by its
2
+ * wasm-bindgen bindings: a `default` init function plus the same `Scale`
3
+ * class the Rust crate defines. */
4
+ export interface WasmModule {
5
+ default: (input?: unknown) => Promise<unknown>;
6
+ Scale: new (domainMin: number, domainMax: number, rangeMin: number, rangeMax: number) => {
7
+ map(value: number): number;
8
+ map_many(values: Float64Array): Float64Array;
9
+ free(): void;
10
+ };
11
+ }
12
+ export type WasmImporter = () => Promise<WasmModule>;
13
+ /**
14
+ * Kicks off loading and initializing the compiled WASM module in the
15
+ * background. Never throws — an environment without WASM support, a
16
+ * blocked fetch, or any other failure just means every caller keeps using
17
+ * the JS fallback instead. Safe to call repeatedly: the in-flight or
18
+ * already-resolved promise is reused rather than re-fetching.
19
+ */
20
+ export declare function loadWasm(importer: WasmImporter): Promise<WasmModule | null>;
21
+ /** Synchronous read of whatever `loadWasm` has resolved so far — `null`
22
+ * both before loading finishes and if it failed. Callers on a synchronous
23
+ * hot path (the renderer can't `await` mid-frame) read this instead of
24
+ * awaiting `loadWasm` directly. */
25
+ export declare function getCachedWasmModule(): WasmModule | null;
26
+ /** Test-only escape hatch: clears the module-level cache so each test can
27
+ * exercise `loadWasm` from a clean slate instead of sharing one promise
28
+ * across the whole suite. */
29
+ export declare function resetWasmForTesting(): void;
package/dist/wasm.js ADDED
@@ -0,0 +1,35 @@
1
+ let modulePromise = null;
2
+ let cached = null;
3
+ /**
4
+ * Kicks off loading and initializing the compiled WASM module in the
5
+ * background. Never throws — an environment without WASM support, a
6
+ * blocked fetch, or any other failure just means every caller keeps using
7
+ * the JS fallback instead. Safe to call repeatedly: the in-flight or
8
+ * already-resolved promise is reused rather than re-fetching.
9
+ */
10
+ export function loadWasm(importer) {
11
+ if (!modulePromise) {
12
+ modulePromise = importer()
13
+ .then(async (mod) => {
14
+ await mod.default();
15
+ cached = mod;
16
+ return mod;
17
+ })
18
+ .catch(() => null);
19
+ }
20
+ return modulePromise;
21
+ }
22
+ /** Synchronous read of whatever `loadWasm` has resolved so far — `null`
23
+ * both before loading finishes and if it failed. Callers on a synchronous
24
+ * hot path (the renderer can't `await` mid-frame) read this instead of
25
+ * awaiting `loadWasm` directly. */
26
+ export function getCachedWasmModule() {
27
+ return cached;
28
+ }
29
+ /** Test-only escape hatch: clears the module-level cache so each test can
30
+ * exercise `loadWasm` from a clean slate instead of sharing one promise
31
+ * across the whole suite. */
32
+ export function resetWasmForTesting() {
33
+ modulePromise = null;
34
+ cached = null;
35
+ }
@@ -0,0 +1,6 @@
1
+ import type { WasmModule } from './wasm.js';
2
+ /** The real dynamic import of the wasm-pack build output — kept as a
3
+ * one-line seam so `loadWasm` (see wasm.ts) can be unit tested with a fake
4
+ * importer instead of needing an actual `.wasm` binary in the test run.
5
+ * Regenerate the target with `pnpm build:wasm`. */
6
+ export declare function importRealWasm(): Promise<WasmModule>;
@@ -0,0 +1,7 @@
1
+ /** The real dynamic import of the wasm-pack build output — kept as a
2
+ * one-line seam so `loadWasm` (see wasm.ts) can be unit tested with a fake
3
+ * importer instead of needing an actual `.wasm` binary in the test run.
4
+ * Regenerate the target with `pnpm build:wasm`. */
5
+ export function importRealWasm() {
6
+ return import('../wasm-pkg/wickchart_core.js');
7
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "wick-charts",
3
+ "version": "0.3.0",
4
+ "description": "An open-source financial charting library — WASM (Rust) for compute, Canvas2D for rendering.",
5
+ "license": "MIT",
6
+ "author": "eatnows",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/eatnows/wick-charts.git"
10
+ },
11
+ "homepage": "https://github.com/eatnows/wick-charts#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/eatnows/wick-charts/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "files": [
19
+ "dist",
20
+ "wasm-pkg",
21
+ "LICENSE",
22
+ "README.md"
23
+ ],
24
+ "scripts": {
25
+ "clean": "rm -rf dist",
26
+ "build": "pnpm clean && tsc -p tsconfig.json",
27
+ "build:wasm": "wasm-pack build crates/wickchart-core --target web --out-dir ../../wasm-pkg --out-name wickchart_core",
28
+ "demo": "pnpm build:wasm && pnpm build && python3 -m http.server 4173",
29
+ "test": "vitest run",
30
+ "test:rust": "cargo test",
31
+ "check:rust": "cargo check --target wasm32-unknown-unknown -p wickchart-core",
32
+ "prepublishOnly": "pnpm build:wasm && pnpm build && pnpm test"
33
+ },
34
+ "devDependencies": {
35
+ "jsdom": "^30.0.1",
36
+ "typescript": "^5.6.0",
37
+ "vitest": "^2.1.0"
38
+ }
39
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "wickchart-core",
3
+ "type": "module",
4
+ "description": "WASM compute core for wick-charts — domain-to-pixel coordinate scaling, compiled to run at native speed in the browser.",
5
+ "version": "0.1.0",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/eatnows/wick-charts"
10
+ },
11
+ "files": [
12
+ "wickchart_core_bg.wasm",
13
+ "wickchart_core.js",
14
+ "wickchart_core.d.ts"
15
+ ],
16
+ "main": "wickchart_core.js",
17
+ "types": "wickchart_core.d.ts",
18
+ "sideEffects": [
19
+ "./snippets/*"
20
+ ]
21
+ }
@@ -0,0 +1,59 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Linear mapping from a data domain (e.g. price min/max) to a pixel range
6
+ * (e.g. canvas top/bottom). Every plotted point on every frame goes through
7
+ * this — the classic case where avoiding per-call JS overhead across
8
+ * thousands of points actually shows up in a profile.
9
+ */
10
+ export class Scale {
11
+ free(): void;
12
+ [Symbol.dispose](): void;
13
+ /**
14
+ * Maps a single value from the data domain into the pixel range.
15
+ */
16
+ map(value: number): number;
17
+ /**
18
+ * Maps a whole series in one call, avoiding per-point JS↔WASM boundary
19
+ * crossings. `values` and the returned buffer are both flat f64 arrays.
20
+ */
21
+ map_many(values: Float64Array): Float64Array;
22
+ constructor(domain_min: number, domain_max: number, range_min: number, range_max: number);
23
+ }
24
+
25
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
26
+
27
+ export interface InitOutput {
28
+ readonly memory: WebAssembly.Memory;
29
+ readonly __wbg_scale_free: (a: number, b: number) => void;
30
+ readonly scale_map: (a: number, b: number) => number;
31
+ readonly scale_map_many: (a: number, b: number, c: number) => [number, number];
32
+ readonly scale_new: (a: number, b: number, c: number, d: number) => number;
33
+ readonly __wbindgen_externrefs: WebAssembly.Table;
34
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
35
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
36
+ readonly __wbindgen_start: () => void;
37
+ }
38
+
39
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
40
+
41
+ /**
42
+ * Instantiates the given `module`, which can either be bytes or
43
+ * a precompiled `WebAssembly.Module`.
44
+ *
45
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
46
+ *
47
+ * @returns {InitOutput}
48
+ */
49
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
50
+
51
+ /**
52
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
53
+ * for everything else, calls `WebAssembly.instantiate` directly.
54
+ *
55
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
56
+ *
57
+ * @returns {Promise<InitOutput>}
58
+ */
59
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,227 @@
1
+ /* @ts-self-types="./wickchart_core.d.ts" */
2
+
3
+ /**
4
+ * Linear mapping from a data domain (e.g. price min/max) to a pixel range
5
+ * (e.g. canvas top/bottom). Every plotted point on every frame goes through
6
+ * this — the classic case where avoiding per-call JS overhead across
7
+ * thousands of points actually shows up in a profile.
8
+ */
9
+ export class Scale {
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ ScaleFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_scale_free(ptr, 0);
19
+ }
20
+ /**
21
+ * Maps a single value from the data domain into the pixel range.
22
+ * @param {number} value
23
+ * @returns {number}
24
+ */
25
+ map(value) {
26
+ const ret = wasm.scale_map(this.__wbg_ptr, value);
27
+ return ret;
28
+ }
29
+ /**
30
+ * Maps a whole series in one call, avoiding per-point JS↔WASM boundary
31
+ * crossings. `values` and the returned buffer are both flat f64 arrays.
32
+ * @param {Float64Array} values
33
+ * @returns {Float64Array}
34
+ */
35
+ map_many(values) {
36
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
37
+ const len0 = WASM_VECTOR_LEN;
38
+ const ret = wasm.scale_map_many(this.__wbg_ptr, ptr0, len0);
39
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
40
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
41
+ return v2;
42
+ }
43
+ /**
44
+ * @param {number} domain_min
45
+ * @param {number} domain_max
46
+ * @param {number} range_min
47
+ * @param {number} range_max
48
+ */
49
+ constructor(domain_min, domain_max, range_min, range_max) {
50
+ const ret = wasm.scale_new(domain_min, domain_max, range_min, range_max);
51
+ this.__wbg_ptr = ret;
52
+ ScaleFinalization.register(this, this.__wbg_ptr, this);
53
+ return this;
54
+ }
55
+ }
56
+ if (Symbol.dispose) Scale.prototype[Symbol.dispose] = Scale.prototype.free;
57
+ function __wbg_get_imports() {
58
+ const import0 = {
59
+ __proto__: null,
60
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
61
+ throw new Error(getStringFromWasm0(arg0, arg1));
62
+ },
63
+ __wbindgen_init_externref_table: function() {
64
+ const table = wasm.__wbindgen_externrefs;
65
+ const offset = table.grow(4);
66
+ table.set(0, undefined);
67
+ table.set(offset + 0, undefined);
68
+ table.set(offset + 1, null);
69
+ table.set(offset + 2, true);
70
+ table.set(offset + 3, false);
71
+ },
72
+ };
73
+ return {
74
+ __proto__: null,
75
+ "./wickchart_core_bg.js": import0,
76
+ };
77
+ }
78
+
79
+ const ScaleFinalization = (typeof FinalizationRegistry === 'undefined')
80
+ ? { register: () => {}, unregister: () => {} }
81
+ : new FinalizationRegistry(ptr => wasm.__wbg_scale_free(ptr, 1));
82
+
83
+ function getArrayF64FromWasm0(ptr, len) {
84
+ ptr = ptr >>> 0;
85
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
86
+ }
87
+
88
+ let cachedFloat64ArrayMemory0 = null;
89
+ function getFloat64ArrayMemory0() {
90
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
91
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
92
+ }
93
+ return cachedFloat64ArrayMemory0;
94
+ }
95
+
96
+ function getStringFromWasm0(ptr, len) {
97
+ return decodeText(ptr >>> 0, len);
98
+ }
99
+
100
+ let cachedUint8ArrayMemory0 = null;
101
+ function getUint8ArrayMemory0() {
102
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
103
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
104
+ }
105
+ return cachedUint8ArrayMemory0;
106
+ }
107
+
108
+ function passArrayF64ToWasm0(arg, malloc) {
109
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
110
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
111
+ WASM_VECTOR_LEN = arg.length;
112
+ return ptr;
113
+ }
114
+
115
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
116
+ cachedTextDecoder.decode();
117
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
118
+ let numBytesDecoded = 0;
119
+ function decodeText(ptr, len) {
120
+ numBytesDecoded += len;
121
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
122
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
123
+ cachedTextDecoder.decode();
124
+ numBytesDecoded = len;
125
+ }
126
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
127
+ }
128
+
129
+ let WASM_VECTOR_LEN = 0;
130
+
131
+ let wasmModule, wasmInstance, wasm;
132
+ function __wbg_finalize_init(instance, module) {
133
+ wasmInstance = instance;
134
+ wasm = instance.exports;
135
+ wasmModule = module;
136
+ cachedFloat64ArrayMemory0 = null;
137
+ cachedUint8ArrayMemory0 = null;
138
+ wasm.__wbindgen_start();
139
+ return wasm;
140
+ }
141
+
142
+ async function __wbg_load(module, imports) {
143
+ if (typeof Response === 'function' && module instanceof Response) {
144
+ if (!module.ok) {
145
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
146
+ }
147
+
148
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
149
+ try {
150
+ return await WebAssembly.instantiateStreaming(module, imports);
151
+ } catch (e) {
152
+ const validResponse = expectedResponseType(module.type);
153
+
154
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
155
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
156
+
157
+ } else { throw e; }
158
+ }
159
+ }
160
+
161
+ const bytes = await module.arrayBuffer();
162
+ return await WebAssembly.instantiate(bytes, imports);
163
+ } else {
164
+ const instance = await WebAssembly.instantiate(module, imports);
165
+
166
+ if (instance instanceof WebAssembly.Instance) {
167
+ return { instance, module };
168
+ } else {
169
+ return instance;
170
+ }
171
+ }
172
+
173
+ function expectedResponseType(type) {
174
+ switch (type) {
175
+ case 'basic': case 'cors': case 'default': return true;
176
+ }
177
+ return false;
178
+ }
179
+ }
180
+
181
+ function initSync(module) {
182
+ if (wasm !== undefined) return wasm;
183
+
184
+
185
+ if (module !== undefined) {
186
+ if (Object.getPrototypeOf(module) === Object.prototype) {
187
+ ({module} = module)
188
+ } else {
189
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
190
+ }
191
+ }
192
+
193
+ const imports = __wbg_get_imports();
194
+ if (!(module instanceof WebAssembly.Module)) {
195
+ module = new WebAssembly.Module(module);
196
+ }
197
+ const instance = new WebAssembly.Instance(module, imports);
198
+ return __wbg_finalize_init(instance, module);
199
+ }
200
+
201
+ async function __wbg_init(module_or_path) {
202
+ if (wasm !== undefined) return wasm;
203
+
204
+
205
+ if (module_or_path !== undefined) {
206
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
207
+ ({module_or_path} = module_or_path)
208
+ } else {
209
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
210
+ }
211
+ }
212
+
213
+ if (module_or_path === undefined) {
214
+ module_or_path = new URL('wickchart_core_bg.wasm', import.meta.url);
215
+ }
216
+ const imports = __wbg_get_imports();
217
+
218
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
219
+ module_or_path = fetch(module_or_path);
220
+ }
221
+
222
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
223
+
224
+ return __wbg_finalize_init(instance, module);
225
+ }
226
+
227
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,11 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_scale_free: (a: number, b: number) => void;
5
+ export const scale_map: (a: number, b: number) => number;
6
+ export const scale_map_many: (a: number, b: number, c: number) => [number, number];
7
+ export const scale_new: (a: number, b: number, c: number, d: number) => number;
8
+ export const __wbindgen_externrefs: WebAssembly.Table;
9
+ export const __wbindgen_malloc: (a: number, b: number) => number;
10
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
11
+ export const __wbindgen_start: () => void;