add some documentation to the humble_api in the header. and don’t cache files by default.
- requires implementing buildCacheKey extension point to cache files
| | |
| | | |
| | | bool humble_init(); |
| | | |
| | | /** |
| | | * Trigger a FS.syncfs call on the emscripten Filesystem |
| | | */ |
| | | void humble_sync(); |
| | | |
| | | /** |
| | | * This method is 100% compatible to emscripten_async_wget_data. |
| | | * Except that it can cache the fetched files into IndexedDB and it has 2 extension points |
| | | * one to map the URL/path (e.g. to handle pre-signed GETs against CDNs) |
| | | * another to map the URL path to a cache KEY. (e.g. if using relative allow it to be prefixed by something else |
| | | */ |
| | | void humble_fetch_asset_data(const char* url, void *arg, em_async_wget_onload_func onload, em_arg_callback_func onerror); |
| | | |
| | | #ifdef __cplusplus |
| | |
| | | if (HUMBLE_API.options.buildCacheKey) { |
| | | return HUMBLE_API.options.buildCacheKey.call(HUMBLE_API, path); |
| | | } else { |
| | | return path; |
| | | return null; |
| | | } |
| | | }, |
| | | |
| | | storeToCache: function(path, byteArray, ondone) { |
| | | HUMBLE_API.file_cache[path] = byteArray; |
| | | if (path !== null) { |
| | | HUMBLE_API.file_cache[path] = byteArray; |
| | | } |
| | | ondone(null); |
| | | }, |
| | | fetchFromCache: function(path, ondone, onfail) { |
| | | if (path in HUMBLE_API.file_cache) { |
| | | if (path !== null && path in HUMBLE_API.file_cache) { |
| | | ondone(HUMBLE_API.file_cache[path]); |
| | | } else { |
| | | // NULL for file not cached. Error object otherwise |