Skip to content

Commit 1fb5ba0

Browse files
committed
Add release code.
1 parent cdbf4c3 commit 1fb5ba0

6 files changed

Lines changed: 412 additions & 1 deletion

File tree

docs/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274

275275
<!-- Note the usage of `type=module` here as this is an ES6 module -->
276276
<script type="module">
277-
import init, { greet, analyze_gpx, analyze_tcx, analyze_fit, export_data, merge } from '../../activity-analyzer/pkg/activity_analyzer.js';
277+
import init, { greet, analyze_gpx, analyze_tcx, analyze_fit, export_data, merge } from '../pkg/activity_analyzer.js';
278278

279279
async function run() {
280280
await init();

docs/pkg/activity_analyzer.d.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
*/
5+
export function greet(): void;
6+
/**
7+
* @param {string} s
8+
*/
9+
export function set_world_data(s: string): void;
10+
/**
11+
* @param {string} s
12+
*/
13+
export function set_us_data(s: string): void;
14+
/**
15+
* @param {string} s
16+
* @returns {string}
17+
*/
18+
export function analyze_gpx(s: string): string;
19+
/**
20+
* @param {string} s
21+
* @returns {string}
22+
*/
23+
export function analyze_tcx(s: string): string;
24+
/**
25+
* @param {Uint8Array} s
26+
* @returns {string}
27+
*/
28+
export function analyze_fit(s: Uint8Array): string;
29+
/**
30+
* @param {string} format
31+
* @param {number} split_start
32+
* @param {number} split_end
33+
* @returns {string}
34+
*/
35+
export function export_data(format: string, split_start: number, split_end: number): string;
36+
/**
37+
* @param {string} format
38+
* @returns {string}
39+
*/
40+
export function merge(format: string): string;
41+
42+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
43+
44+
export interface InitOutput {
45+
readonly memory: WebAssembly.Memory;
46+
readonly greet: () => void;
47+
readonly set_world_data: (a: number, b: number) => void;
48+
readonly set_us_data: (a: number, b: number) => void;
49+
readonly analyze_gpx: (a: number, b: number, c: number) => void;
50+
readonly analyze_tcx: (a: number, b: number, c: number) => void;
51+
readonly analyze_fit: (a: number, b: number, c: number) => void;
52+
readonly export_data: (a: number, b: number, c: number, d: number, e: number) => void;
53+
readonly merge: (a: number, b: number, c: number) => void;
54+
readonly __wbindgen_malloc: (a: number) => number;
55+
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
56+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
57+
readonly __wbindgen_free: (a: number, b: number) => void;
58+
}
59+
60+
/**
61+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
62+
* for everything else, calls `WebAssembly.instantiate` directly.
63+
*
64+
* @param {InitInput | Promise<InitInput>} module_or_path
65+
*
66+
* @returns {Promise<InitOutput>}
67+
*/
68+
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;

docs/pkg/activity_analyzer.js

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
2+
let wasm;
3+
4+
const heap = new Array(32).fill(undefined);
5+
6+
heap.push(undefined, null, true, false);
7+
8+
function getObject(idx) { return heap[idx]; }
9+
10+
let heap_next = heap.length;
11+
12+
function dropObject(idx) {
13+
if (idx < 36) return;
14+
heap[idx] = heap_next;
15+
heap_next = idx;
16+
}
17+
18+
function takeObject(idx) {
19+
const ret = getObject(idx);
20+
dropObject(idx);
21+
return ret;
22+
}
23+
24+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
25+
26+
cachedTextDecoder.decode();
27+
28+
let cachegetUint8Memory0 = null;
29+
function getUint8Memory0() {
30+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
31+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
32+
}
33+
return cachegetUint8Memory0;
34+
}
35+
36+
function getStringFromWasm0(ptr, len) {
37+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
38+
}
39+
/**
40+
*/
41+
export function greet() {
42+
wasm.greet();
43+
}
44+
45+
let WASM_VECTOR_LEN = 0;
46+
47+
let cachedTextEncoder = new TextEncoder('utf-8');
48+
49+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
50+
? function (arg, view) {
51+
return cachedTextEncoder.encodeInto(arg, view);
52+
}
53+
: function (arg, view) {
54+
const buf = cachedTextEncoder.encode(arg);
55+
view.set(buf);
56+
return {
57+
read: arg.length,
58+
written: buf.length
59+
};
60+
});
61+
62+
function passStringToWasm0(arg, malloc, realloc) {
63+
64+
if (realloc === undefined) {
65+
const buf = cachedTextEncoder.encode(arg);
66+
const ptr = malloc(buf.length);
67+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
68+
WASM_VECTOR_LEN = buf.length;
69+
return ptr;
70+
}
71+
72+
let len = arg.length;
73+
let ptr = malloc(len);
74+
75+
const mem = getUint8Memory0();
76+
77+
let offset = 0;
78+
79+
for (; offset < len; offset++) {
80+
const code = arg.charCodeAt(offset);
81+
if (code > 0x7F) break;
82+
mem[ptr + offset] = code;
83+
}
84+
85+
if (offset !== len) {
86+
if (offset !== 0) {
87+
arg = arg.slice(offset);
88+
}
89+
ptr = realloc(ptr, len, len = offset + arg.length * 3);
90+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
91+
const ret = encodeString(arg, view);
92+
93+
offset += ret.written;
94+
}
95+
96+
WASM_VECTOR_LEN = offset;
97+
return ptr;
98+
}
99+
/**
100+
* @param {string} s
101+
*/
102+
export function set_world_data(s) {
103+
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
104+
var len0 = WASM_VECTOR_LEN;
105+
wasm.set_world_data(ptr0, len0);
106+
}
107+
108+
/**
109+
* @param {string} s
110+
*/
111+
export function set_us_data(s) {
112+
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113+
var len0 = WASM_VECTOR_LEN;
114+
wasm.set_us_data(ptr0, len0);
115+
}
116+
117+
let cachegetInt32Memory0 = null;
118+
function getInt32Memory0() {
119+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
120+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
121+
}
122+
return cachegetInt32Memory0;
123+
}
124+
/**
125+
* @param {string} s
126+
* @returns {string}
127+
*/
128+
export function analyze_gpx(s) {
129+
try {
130+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
131+
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132+
var len0 = WASM_VECTOR_LEN;
133+
wasm.analyze_gpx(retptr, ptr0, len0);
134+
var r0 = getInt32Memory0()[retptr / 4 + 0];
135+
var r1 = getInt32Memory0()[retptr / 4 + 1];
136+
return getStringFromWasm0(r0, r1);
137+
} finally {
138+
wasm.__wbindgen_add_to_stack_pointer(16);
139+
wasm.__wbindgen_free(r0, r1);
140+
}
141+
}
142+
143+
/**
144+
* @param {string} s
145+
* @returns {string}
146+
*/
147+
export function analyze_tcx(s) {
148+
try {
149+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
150+
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
151+
var len0 = WASM_VECTOR_LEN;
152+
wasm.analyze_tcx(retptr, ptr0, len0);
153+
var r0 = getInt32Memory0()[retptr / 4 + 0];
154+
var r1 = getInt32Memory0()[retptr / 4 + 1];
155+
return getStringFromWasm0(r0, r1);
156+
} finally {
157+
wasm.__wbindgen_add_to_stack_pointer(16);
158+
wasm.__wbindgen_free(r0, r1);
159+
}
160+
}
161+
162+
function passArray8ToWasm0(arg, malloc) {
163+
const ptr = malloc(arg.length * 1);
164+
getUint8Memory0().set(arg, ptr / 1);
165+
WASM_VECTOR_LEN = arg.length;
166+
return ptr;
167+
}
168+
/**
169+
* @param {Uint8Array} s
170+
* @returns {string}
171+
*/
172+
export function analyze_fit(s) {
173+
try {
174+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
175+
var ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
176+
var len0 = WASM_VECTOR_LEN;
177+
wasm.analyze_fit(retptr, ptr0, len0);
178+
var r0 = getInt32Memory0()[retptr / 4 + 0];
179+
var r1 = getInt32Memory0()[retptr / 4 + 1];
180+
return getStringFromWasm0(r0, r1);
181+
} finally {
182+
wasm.__wbindgen_add_to_stack_pointer(16);
183+
wasm.__wbindgen_free(r0, r1);
184+
}
185+
}
186+
187+
/**
188+
* @param {string} format
189+
* @param {number} split_start
190+
* @param {number} split_end
191+
* @returns {string}
192+
*/
193+
export function export_data(format, split_start, split_end) {
194+
try {
195+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
196+
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197+
var len0 = WASM_VECTOR_LEN;
198+
wasm.export_data(retptr, ptr0, len0, split_start, split_end);
199+
var r0 = getInt32Memory0()[retptr / 4 + 0];
200+
var r1 = getInt32Memory0()[retptr / 4 + 1];
201+
return getStringFromWasm0(r0, r1);
202+
} finally {
203+
wasm.__wbindgen_add_to_stack_pointer(16);
204+
wasm.__wbindgen_free(r0, r1);
205+
}
206+
}
207+
208+
/**
209+
* @param {string} format
210+
* @returns {string}
211+
*/
212+
export function merge(format) {
213+
try {
214+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
215+
var ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216+
var len0 = WASM_VECTOR_LEN;
217+
wasm.merge(retptr, ptr0, len0);
218+
var r0 = getInt32Memory0()[retptr / 4 + 0];
219+
var r1 = getInt32Memory0()[retptr / 4 + 1];
220+
return getStringFromWasm0(r0, r1);
221+
} finally {
222+
wasm.__wbindgen_add_to_stack_pointer(16);
223+
wasm.__wbindgen_free(r0, r1);
224+
}
225+
}
226+
227+
function addHeapObject(obj) {
228+
if (heap_next === heap.length) heap.push(heap.length + 1);
229+
const idx = heap_next;
230+
heap_next = heap[idx];
231+
232+
heap[idx] = obj;
233+
return idx;
234+
}
235+
236+
async function load(module, imports) {
237+
if (typeof Response === 'function' && module instanceof Response) {
238+
if (typeof WebAssembly.instantiateStreaming === 'function') {
239+
try {
240+
return await WebAssembly.instantiateStreaming(module, imports);
241+
242+
} catch (e) {
243+
if (module.headers.get('Content-Type') != 'application/wasm') {
244+
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);
245+
246+
} else {
247+
throw e;
248+
}
249+
}
250+
}
251+
252+
const bytes = await module.arrayBuffer();
253+
return await WebAssembly.instantiate(bytes, imports);
254+
255+
} else {
256+
const instance = await WebAssembly.instantiate(module, imports);
257+
258+
if (instance instanceof WebAssembly.Instance) {
259+
return { instance, module };
260+
261+
} else {
262+
return instance;
263+
}
264+
}
265+
}
266+
267+
async function init(input) {
268+
if (typeof input === 'undefined') {
269+
input = new URL('activity_analyzer_bg.wasm', import.meta.url);
270+
}
271+
const imports = {};
272+
imports.wbg = {};
273+
imports.wbg.__wbg_alert_4694f216c27a99a5 = function(arg0, arg1) {
274+
alert(getStringFromWasm0(arg0, arg1));
275+
};
276+
imports.wbg.__wbg_new_59cb74e423758ede = function() {
277+
var ret = new Error();
278+
return addHeapObject(ret);
279+
};
280+
imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) {
281+
var ret = getObject(arg1).stack;
282+
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283+
var len0 = WASM_VECTOR_LEN;
284+
getInt32Memory0()[arg0 / 4 + 1] = len0;
285+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
286+
};
287+
imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) {
288+
try {
289+
console.error(getStringFromWasm0(arg0, arg1));
290+
} finally {
291+
wasm.__wbindgen_free(arg0, arg1);
292+
}
293+
};
294+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
295+
takeObject(arg0);
296+
};
297+
298+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
299+
input = fetch(input);
300+
}
301+
302+
303+
304+
const { instance, module } = await load(await input, imports);
305+
306+
wasm = instance.exports;
307+
init.__wbindgen_wasm_module = module;
308+
309+
return wasm;
310+
}
311+
312+
export default init;
313+

docs/pkg/activity_analyzer_bg.wasm

546 KB
Binary file not shown.

0 commit comments

Comments
 (0)