refactor code out to make the HUMBLE CLOUD to simply be CLOUDFS and (eventually) more general
2 files renamed
3 files modified
1 files added
| | |
| | | NO_EXIT_RUNTIME=1 |
| | | EXPORTED_FUNCTIONS="['_main','_test_list_files']" |
| | | JS_LIBS |
| | | ${CMAKE_CURRENT_SOURCE_DIR}/library/humble_cloud.js |
| | | ${CMAKE_CURRENT_SOURCE_DIR}/library/library_cloudfs.js |
| | | ${CMAKE_CURRENT_SOURCE_DIR}/library/library_humble.js |
| | | ) |
| | | |
| File was renamed from client/library/humble_cloud.h |
| | |
| | | extern "C" { |
| | | #endif |
| | | |
| | | bool humble_cloud_init(); |
| | | bool humble_init(); |
| | | |
| | | void humble_cloud_sync(); |
| | | void humble_sync(); |
| | | |
| | | #ifdef __cplusplus |
| | | }; |
| File was renamed from client/library/humble_cloud.js |
| | |
| | | var LibraryHUMBLE_CLOUD = { |
| | | $HUMBLE_CLOUD__deps: ['$FS', '$MEMFS', '$PATH'], |
| | | $HUMBLE_CLOUD: { |
| | | var LibraryCLOUDFS = { |
| | | $CLOUDFS__deps: ['$FS', '$MEMFS', '$PATH'], |
| | | $CLOUDFS: { |
| | | applicationToken: '__NOTOKEN__', |
| | | remoteAPIEndpoint: 'http://asmjs.brigadoon.outoforder.cc/cloud', |
| | | |
| | |
| | | window.HB_mount = mount; |
| | | console.log("Syncing", mount, populate); |
| | | // re-use IDBFS.getLocalSet for now |
| | | HUMBLE_CLOUD.getLocalSet(mount, function(err, local) { |
| | | CLOUDFS.getLocalSet(mount, function(err, local) { |
| | | if (err) return callback(err); |
| | | |
| | | HUMBLE_CLOUD.getRemoteSet(mount, function(err, remote) { |
| | | CLOUDFS.getRemoteSet(mount, function(err, remote) { |
| | | if (err) return callback(err); |
| | | |
| | | var src = populate ? remote : local; |
| | |
| | | |
| | | console.log('source', src); |
| | | console.log('destination', dst); |
| | | |
| | | // say we completed (for now) |
| | | callback(null); |
| | | }); |
| | | }); |
| | | }, |
| | |
| | | return callback(null, { type: 'local', entries: entries }); |
| | | }, |
| | | getRemoteSet: function(mount, callback) { |
| | | var url = HUMBLE_CLOUD.remoteAPIEndpoint + '/storage/files'; |
| | | HUMBLE_CLOUD.xhrLoad(url, function(data) { |
| | | var url = CLOUDFS.remoteAPIEndpoint + '/storage/files'; |
| | | CLOUDFS.xhrLoad(url, function(data) { |
| | | var entries = {}, |
| | | toAbsolute = function(p) { return PATH.join2(mount.mountpoint, p); }; |
| | | json = JSON.parse(data); |
| | |
| | | } |
| | | var p = toAbsolute(f.path); |
| | | entries[p] = { |
| | | url: (f.url.substr(0, 1) == '/') ? HUMBLE_CLOUD.remoteAPIEndpoint + f.url : f.url, |
| | | url: (f.url.substr(0, 1) == '/') ? CLOUDFS.remoteAPIEndpoint + f.url : f.url, |
| | | path: f.path.trim('/'), |
| | | timestamp: timestamp, |
| | | size: f.size |
| | |
| | | callback(e || new Error('failed request')); |
| | | }); |
| | | } |
| | | }, |
| | | humble_cloud_init: function() { |
| | | // Dummy function to pull in the rest of the functions |
| | | }, |
| | | humble_cloud_sync: function() { |
| | | FS.syncfs(function(err) { |
| | | console.log('File Sync'); |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | autoAddDeps(LibraryHUMBLE_CLOUD, '$HUMBLE_CLOUD'); |
| | | mergeInto(LibraryManager.library, LibraryHUMBLE_CLOUD); |
| | | autoAddDeps(LibraryCLOUDFS, '$CLOUDFS'); |
| | | mergeInto(LibraryManager.library, LibraryCLOUDFS); |
| New file |
| | |
| | | var LibraryHUMBLE = { |
| | | humble_init: function() { |
| | | // Dummy function to pull in the rest of the functions |
| | | }, |
| | | humble_sync__deps: ['$FS'], |
| | | humble_sync: function() { |
| | | FS.syncfs(function (err) { |
| | | console.log('File Sync'); |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | autoAddDeps(LibraryHUMBLE, '$CLOUDFS'); |
| | | mergeInto(LibraryManager.library, LibraryHUMBLE); |
| | |
| | | |
| | | #include <emscripten/emscripten.h> |
| | | |
| | | #include "humble_cloud.h" |
| | | #include "humble_api.h" |
| | | |
| | | #include <dirent.h> |
| | | |
| | |
| | | { |
| | | std::cout << "Welcome Main\n"; |
| | | // call dummy function to init cloud |
| | | humble_cloud_init(); |
| | | humble_init(); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | </div> |
| | | <textarea id="output" rows="8"></textarea> |
| | | |
| | | <script type='text/javascript' src="humble_cloud.js"></script> |
| | | <script type='text/javascript'> |
| | | var statusElement = document.getElementById('status'); |
| | | var progressElement = document.getElementById('progress'); |
| | |
| | | }; |
| | | }; |
| | | Module['preRun'].push(function() { |
| | | addRunDependency('HUMBLE_CLOUD_setup'); |
| | | addRunDependency('CLOUDFS_setup'); |
| | | FS.createFolder('/', 'user_data', true, true); |
| | | FS.mount(IDBFS, {}, '/user_data'); |
| | | |
| | | FS.createFolder('/', 'user_cloud', true, true); |
| | | FS.mount(HUMBLE_CLOUD, { |
| | | endpoint: 'http://someawesomeserver/', |
| | | applicationtoken: 'deadbeef' |
| | | FS.mount(CLOUDFS, { |
| | | // a list of regexes or string prefixes to synchronize |
| | | sync: [ |
| | | ], |
| | | // which provider engine to use.. (looks for an object of that name in the global window object) |
| | | provider: 'HUMBLE_BUNDLE_PROVIDER', |
| | | // configuration sent to the provider |
| | | cloud: { |
| | | applicationtoken: 'deadbeef' |
| | | } |
| | | }, '/user_cloud'); |
| | | |
| | | FS.syncfs(true, function(err) { |
| | | if(err) console.log('ERROR!', err); |
| | | console.log('finished syncing.. YEAH!!!'); |
| | | removeRunDependency('HUMBLE_CLOUD_setup'); |
| | | removeRunDependency('CLOUDFS_setup'); |
| | | }); |
| | | }); |
| | | var test_functions = {}; |