feat: Add Be and tbd skill, also added Roadmap file

This commit is contained in:
2026-05-10 16:32:12 -04:00
parent 3500ade13f
commit 0bb8885802
29587 changed files with 10611695 additions and 0 deletions

View File

@@ -0,0 +1,213 @@
/**
* Internal class to represent a cached item
* Saves a reference to the original URL request
* and the content.
* @private
* @class CacheItem
* @memberof jibo.loader
* @param {String} request Full path requested
* @param {any} content Result of the load.
*/
/**
* Set of tokens referencing this asset.
* @name jibo.loader.CacheItem#tokens
* @type {Set<AssetToken>}
*/
/**
* Name and cache of items loaded from this item, so that they can be unloaded with it.
* @name jibo.loader.CacheItem#subAssets
* @type {AssetToken[]}
*/
/**
* The cached content.
* @name jibo.loader.CacheItem#content
* @type {any}
*/
/**
* Callbacks for completion of a pending load.
* @name jibo.loader.CacheItem#pendingCallbacks
* @type {Function[]}
*/
/**
* If the content variable contains an error rather than an actual result.
* @name jibo.loader.CacheItem#contentIsError
* @type {boolean}
*/
/**
* If the item load is currently in progress.
* @name jibo.loader.CacheItem#isPending
* @type {boolean}
* @readOnly
*/
/**
* Adds a callback to be called when the load completes.
* @method jibo.loader.CacheItem#addPending
* @param {jibo.loader.AssetToken} token Token attached to this callback
* @param {Function} callback Callback for when the load completes.
*/
/**
* Removes a pending callback.
* @method jibo.loader.CacheItem#removePending
* @param {Function} token Token of a pending asset load to remove.
*/
/**
* Adds the loaded content and any subAssets loaded during the load.
* @method jibo.loader.CacheItem#completeLoad
*/
/**
* Destroy the content, don't use after this.
* @method jibo.loader.CacheItem#destroy
* @param {jibo.loader.AssetCache} cache The main asset cache so that sub assets can be unloaded.
*/
/**
* Internal class to represent a specific cache that items are loaded into. This allows for easier
* unloading of a whole group of items.
* @private
* @class NamedCache
* @memberof jibo.loader
* @param {String} name Name of the cache.
*/
/**
* The name of the cache.
* @type {String}
* @name jibo.loader.NamedCache#name
*/
/**
* A map of asset ids to asset keys.
* @type {Object}
* @name jibo.loader.NamedCache#idMap
*/
/**
* The set of loads attached to this cache.
* @type {Object}
* @name jibo.loader.NamedCache#tokens
*/
/**
* Marks an item as loaded one time within this cache.
* @method jibo.loader.NamedCache#load
* @param {jibo.loader.AssetToken} token Shorthand id that the item was loaded under.
*/
/**
* Removes one loaded mark for an item within this cache.
* @method jibo.loader.NamedCache#unload
* @param {jibo.loader.AssetToken} token Token by which
*/
/**
* Manages a cache for assets.
* @class AssetCache
* @memberof jibo.loader
* @private
*/
/**
* The cache containing assets.
* @type {Object}
* @name jibo.loader.AssetCache#_cache
*/
/**
* A map of the current named caches
* @type {Object}
* @name jibo.loader.AssetCache#_cachesMap
*/
/**
* A reference to the owning asset manager.
* @type {jibo.loader.AssetManager}
* @name jibo.loader.AssetCache#_manager
*/
/**
* Add a named cache to load items with.
* @method jibo.loader.AssetCache#addCache
* @param {String} id The cache id to add.
*/
/**
* Retrieves a single asset from the cache.
* @method jibo.loader.AssetCache#read
* @param {String} id The asset to get. If no cacheId, then this must be the unique id (usually the absolute source path).
* @param {String} [cacheId] Cache ID to specify.
* @return {any} Result or null, if no asset
*/
/**
* Dermines if a single asset from the cache is loaded or not.
* @method jibo.loader.AssetCache#isLoaded
* @param {String} id The asset to get. If no cacheId, then this must be the unique id (usually the absolute source path).
* @param {String} [cacheId] Cache ID to specify.
* @return {boolean} If the item is fully loaded
*/
/**
* Determines if a single asset from the cache has been loaded, but was a failure to load.
* @method jibo.loader.AssetCache#wasError
* @param {String} id The asset to get. If no cacheId, then this must be the unique id (usually the absolute source path).
* @param {String} [cacheId] Cache ID to specify.
* @return {boolean} If the item is fully loaded but was an error
*/
/**
* Prepares a single asset in the cache to have content written later.
* @method jibo.loader.AssetCache#prepare
* @param {string} key Unique key that the asset will be stored under.
* @param {string} cacheName Name of the named cache that the asset will be stored under.
* @param {string} id Id that the asset will be stored in the named cache under.
* @returns {jibo.loader.AssetToken} A unique token representing this load of the asset. Use this to unload the asset later.
*/
/**
* Prepares a single asset in the cache to have content written later.
* @method jibo.loader.AssetCache#addPending
* @param {AssetToken} token The AssetResult type object from the AssetLoad.
* @param {Function} callback Callback to call when the asset has been loaded.
* @returns {boolean} true if this was the first pending callback added, false if it was already pending
*/
/**
* Removes a callback from a pending item.
* @method jibo.loader.AssetCache#cancelPending
* @param {jibo.loader.AssetToken} token The token that was created when the asset began loading.
*/
/**
* Adds loaded content to an item in the cache, and tells it to call pending callbacks.
* @method jibo.loader.AssetCache#completePending
* @param {any} err A load error.
* @param {AssetResult} result The AssetResult type object from the AssetLoad.
*/
/**
* Removes a single asset from the cache.
* @method jibo.loader.AssetCache#delete
* @param {Object|String} assetOrId The asset to remove, or id of asset.
* @param {String} cacheId Cache to specify
*/
/**
* Removes all assets from the cache.
* @method jibo.loader.AssetCache#empty
* @param {string} [cacheId] The optional cache
*/
/**
* Destroys the cache. Don't use after this.
* @method jibo.loader.AssetCache#destroy
*/

View File

@@ -0,0 +1,304 @@
/**
* Class that represents a single multi load.
* @class AssetLoad
* @memberof jibo.loader
*/
/**
* Debugging Keep track of how many we've created
* @type {int}
* @name jibo.loader.AssetLoad.ID
* @static
* @private
*/
/**
* @constructor
* @param {jibo.loader.AssetManager} manager Reference to the manager.
* @private
*/
/**
* Reference to the Task Manager.
* @type {jibo.loader.AssetManager}
* @name jibo.loader.AssetLoad#manager
* @private
*/
/**
* How to display the results, either as single (0), map (1) or list (2).
* @type {int}
* @name jibo.loader.AssetLoad#mode
* @default 1
* @private
*/
/**
* The maximum number of loads, 0 for no max limit (all at once)
* @type {Number}
* @name jibo.loader.AssetLoad#maxLoads
* @readOnly
* @private
*/
/**
* Name of cache to apply to all items in the load
* @type {String}
* @name jibo.loader.AssetLoad#cacheAll
* @default null
* @private
*/
/**
* `true` if we load all the resources remotely.
* @type {Boolean}
* @name jibo.loader.AssetLoad#remoteAll
* @default false
* @private
*/
/**
* Number of milliseconds to timeout all remote requests
* @type {Number}
* @name jibo.loader.AssetLoad#timeoutAll
* @default 0
* @private
*/
/**
* Items that have already been loaded and added to the cache. Stored for removal
* if the load is canceled before completion, as well accessing by the code that initiated
* the load.
* @type {jibo.loader.AssetToken[]}
* @name jibo.loader.AssetLoad#loadedTokens
* @private
*/
/**
* The list of tasks to load.
* @type {Array<jibo.loader.Task>}
* @name jibo.loader.AssetLoad#tasks
* @private
*/
/**
* The results to return when we're done.
* @type {Array|Object}
* @name jibo.loader.AssetLoad#results
*/
/**
* `true` if the load is currently running.
* @type {Boolean}
* @name jibo.loader.AssetLoad#running
* @default false
*/
/**
* The total number of assets loaded.
* @type {int}
* @name jibo.loader.AssetLoad#numLoaded
* @default 0
* @readOnly
* @private
*/
/**
* The current number of .
* @type {int}
* @name jibo.loader.AssetLoad#numLoading
* @default 0
* @readOnly
* @private
*/
/**
* The total number of assets.
* @type {int}
* @name jibo.loader.AssetLoad#total
* @default 0
* @readOnly
* @private
*/
/**
* When an asset is finished.
* @event jibo.loader.AssetLoad#taskDone
* @param {*} result The loader result.
* @param {object} originalAsset The original load asset.
* @param {jibo.loader.AssetLoad} load This loader to add additional assets to.
*/
/**
* When all assets have been completely loaded.
* @event jibo.loader.AssetLoad#complete
* @param {Array|Object} results The results of load.
*/
/**
* Checks how many assets have finished loading.
* @event jibo.loader.AssetLoad#progress
* @param {number} percentage The amount loaded from 0 to 1.
*/
/**
* List of AssetToken objects for all loads that will be or have been performed.
* @type {jibo.loader.AssetToken[]}
* @name jibo.loader.AssetLoad#tokens
*/
/**
* Debugging purposes.
* @method jibo.loader.AssetLoad#toString
* @return {String}
* @private
*/
/**
* Initializes the Load.
* @method jibo.loader.AssetLoad#setup
* @param {object|array} assets The collection of assets to load.
* @param {object} [options] The loading options.
* @param {Number} [options.maxLoads=4] `0` to start all load requests at once, any other to limit.
* @param {Boolean} [options.autoStart=true] `true` to start running automatically.
* @param {Boolean|String} [options.cacheAll=false] `true` to cache all load results, `false` to allow assets to cache themselves.
* @param {Boolean|String} [options.remoteAll=false] `true` to make all requests remote, `false` to allow assets to remote themselves.
* @private
*/
/**
* Cancel the load progress.
* @method jibo.loader.AssetLoad#cancel
*/
/**
* Cancel the load progress.
* @method jibo.loader.AssetLoad#cancelToken
* @private
*/
/**
* Starts the load process.
* @method jibo.loader.AssetLoad#start
*/
/**
* Sets back to the original state.
* @method jibo.loader.AssetLoad#reset
* @private
*/
/**
* Adds loads to an ongoing load. Call this during callbacks/events for individual task
* completion.
* @method jibo.loader.AssetLoad#addAssets
* @param {Object|Array} assets The assets to load.
* @return {jibo.loader.AssetToken[]} The asset tokens of the newly added assets (if they are cached).
*/
/**
* Creates a list of tasks from assets.
* @method jibo.loader.AssetLoad#addTasks
* @private
* @param {Object|Array} assets The assets to load.
* @param {jibo.loader.AssetToken[]} [tokenOut] An array to add new asset tokens to.
*/
/**
* Converts assets into object defaults.
* @method jibo.loader.AssetLoad#applyDefaults
* @private
* @static
* @param {*} asset The function to convert.
* @return {Object} The object asset to use.
*/
/**
* Loads a single asset.
* @method jibo.loader.AssetLoad#addTask
* @private
* @param {Object} asset The asset to load.
* Can either be an object, URL/path, or async function.
* @return {Task} New task instance.
*/
/**
* Gets the Task definition for an asset.
* @method jibo.loader.AssetLoad#getTaskByAsset
* @private
* @static
* @param {Object} asset The asset to check.
* @return {Function} The Task class.
*/
/**
* Runs the next task that's waiting.
* @method jibo.loader.AssetLoad#nextTask
* @private
*/
/**
* Handler when a task has completed.
* @method jibo.loader.AssetLoad#taskDone
* @private
* @param {Task} task Reference to original task.
* @param {Error} err The error thrown by load.
* @param {*} [result] The result of load.
*/
/**
* Gets an empty assets collection.
* @method jibo.loader.AssetLoad#getAssetsContainer
* @private
* @param {int} mode The mode.
* @return {Array|Object|null} Empty container for assets.
*/
/**
* Destroys this and discards.
* @private
* @method jibo.loader.AssetLoad#destroy
*/
/**
* The result is a single result.
* @property {int} jibo.loader.AssetLoad.SINGLE_MODE
* @private
* @final
* @static
* @default 0
*/
/**
* The result is a map of result objects.
* @property {int} jibo.loader.AssetLoad.MAP_MODE
* @private
* @final
* @static
* @default 1
*/
/**
* The result is an array of result objects.
* @property {int} jibo.loader.AssetLoad.LIST_MODE
* @private
* @final
* @static
* @default 2
*/
/**
* Checks if an object is a String type.
* @method jibo.loader.AssetLoad.isString
* @private
* @param {*} obj The object to check.
* @return {Boolean} `true` if object is a String, `false` otherwise.
*/
/**
* Checks if an object is a function type.
* @method jibo.loader.AssetLoad.isFunction
* @private
* @param {*} obj The object to check.
* @return {Boolean} `true` if object is a function, `false` otherwise.
*/

View File

@@ -0,0 +1,140 @@
/**
* Gets the progress of the load.
* @callback jibo.loader.AssetManager~progressCallback
* @param {Number} progress The amount of tasks loaded from 0 to 1.
*/
/**
* Executes when a load is complete.
* @callback jibo.loader.AssetManager~completeCallback
* @param {Error} error The error, if any, thrown by loading.
* @param {*} result The result of load.
*/
/**
* The collection of current multiloads.
* @type {array<jibo.loader.AssetLoad>}
* @name jibo.loader.AssetManager#loads
* @private
* @readOnly
*/
/**
* The expired loads to reuse.
* @type {array<jibo.loader.AssetLoad>}
* @name jibo.loader.AssetManager#loadPool
* @private
* @readOnly
*/
/**
* The collection of task definitions.
* @type {array}
* @name jibo.loader.AssetManager#taskDefs
* @readOnly
*/
/**
* The cache of assets.
* @type {jibo.loader.AssetCache}
* @name jibo.loader.AssetManager#cache
* @readOnly
* @private
*/
/**
* Resource loader for doing remote requests.
* @type {jibo.loader.RemoteLoader}
* @name jibo.loader.AssetManager#resourceLoader
* @private
*/
/**
* Resource loader for doing filesystem requests.
* @type {jibo.loader.LocalLoader}
* @name jibo.loader.AssetManager#localLoader
* @private
*/
/**
* The maximum number of loads to do at once.
* @type {Number}
* @name jibo.loader.AssetManager#maxDefaultLoads
* @default 4
*/
/**
* Registers new tasks types. These tasks must extend Task.
* @method jibo.loader.AssetManager#register
* @private
* @param {Function|String} TaskClass The class task reference.
* @param {int} [priority=0] The priority. Higher priority tasks
* are tested first. More general tasks should be lower
* and more specific tasks should be higher.
*/
/**
* Loads a bunch of assets. Can only call one load at a time.
* @method jibo.loader.AssetManager#load
* @param {Object|Array} asset The assets to load.
* @param {Object} [options] The loading options.
* @param {jibo.loader.AssetManager~completeCallback} [options.complete] The callback when finished.
* @param {jibo.loader.AssetManager~progressCallback} [options.progress] The callback when loading percentage is updated.
* @param {jibo.loader.Task~completeCallback} [options.taskDone] The callback when finished with each individual task.
* @param {Boolean} [options.autoStart=true] `true` to start running right away.
* @param {Number} [options.maxLoads=4] The maximum number of simultaneous loads, 0 for all.
* @param {Boolean} [options.remoteAll=false] `true` to force remote calls on all assets.
* @param {Number} [options.timeoutAll=false] Number of milliseconds to timeout remote calls.
* @param {Boolean|String} [options.cacheAll=false] `true` to cache all files. String as the cache id.
* @return {jibo.loader.AssetLoad} The reference to the current load.
*/
/**
* Loads the asset file.
* @method jibo.loader.AssetManager#simpleLoad
* @param {String} uri The file to load.
* @param {Function} callback Callback when complete.
* @param {Object} [options]
* @param {Number} [options.timeout] Number of milliseconds to timeout remote load.
* @param {Boolean} [options.remote] `true` to force remote loading, `false` to auto-detect.
*/
/**
* Prepare the URI to be absolute.
* @method jibo.loader.AssetManager#prepare
* @param {String} uri The file to load.
* @param {Boolean} [remote=false] `true` to force remote loading, `false` to auto-detect.
* @return {String} The absolute URL or URI to request.
*/
/**
* Cancel all current loads.
* @method jibo.loader.AssetManager#cancelAll
*/
/**
* Destroys the AssetManager.
* @method jibo.loader.AssetManager#destroy
*/
/**
* Stashes the load for use later.
* @method jibo.loader.AssetManager#cancel
* @param {jibo.loader.AssetLoad} load The load to recycle.
*/
/**
* Gets either a new AssetLoad or a recycled one.
* @method jibo.loader.AssetManager#_getLoad
* @private
* @return {AssetLoad} The load to use.
*/
/**
* Handler when a load is finished.
* @method jibo.loader.AssetManager#_onLoaded
* @private
* @param {jibo.loader.AssetManager~completeCallback} complete The function to call when done.
* @param {AssetLoad} load The current load.
* @param {*} The returned results.
*/

View File

@@ -0,0 +1,58 @@
/**
* Class that represents a loaded or loading item, enabling strict unloading policies.
* @class AssetToken
* @memberof jibo.loader
*/
/**
* Name of the named cache that this load was attached to.
* @type {string}
* @name jibo.loader.AssetToken#cache
* @readonly
*/
/**
* Unique id within the named cache that this load was attached to.
* @type {string}
* @name jibo.loader.AssetToken#id
* @readonly
*/
/**
* Globally unique key used to cache this load.
* @type {string}
* @name jibo.loader.AssetToken#key
* @readonly
*/
/**
* The AssetCache that this token will use to unload a loaded asset.
* @private
*/
/**
* The loader that this token will use to cancel a load.
* @private
*/
/**
* If this token is valid. Tokens that have been unloaded are invalid.
* @type {boolean}
* @name jibo.loader.AssetToken#isValid
* @readonly
*/
/**
* @private
*/
/**
* Cancels any ongoing load (if still being loaded) and removes this load from the cache.
* @method jibo.loader.AssetToken#unload
*/
/**
* Alias for unload()
* @method jibo.loader.AssetToken#cancel
* @see jibo.loader.AssetToken#unload
*/

View File

@@ -0,0 +1,11 @@
/**
* Utility function for loading.
* @class AssetUtils
* @memberof jibo.loader
*/
/**
* Checks if the object is plain literal.
* @method jibo.loader.AssetUtils.isPlain
* @return {Boolean} `true` if it's a plain object.
*/

View File

@@ -0,0 +1,367 @@
/**
* Adds all assets to a skill,
* including custom ones from your file system
* that are not included in the template skill by default.
* Assets can include images, sounds, code, data, and other files.
*
* @example <caption> <h4>Loading a Single File </h4></caption>
* const jibo = require('jibo');
* jibo.loader.load('config.json', function(err, config) {
* // config is the parsed JSON object
* });
* // this is the same as:
* jibo.loader.load({ src: 'config.json' }, function(err, config) {
* // config is the parsed JSON object
* });
*
* @example <caption><h4>Loading Multiple Files</h4></caption>
* const jibo = require('jibo');
* const assets = [
* "logo.png",
* "header.jpg"
* ];
* jibo.loader.load(assets, function(err, results) {
* // results is an Array of HTMLImageElements
* });
* const jibo = require('jibo');
* const assets = [
* { id:'logo', src: "logo.png" },
* { id: 'header', src: "header.jpg" }
* ];
* jibo.loader.load(assets, function(err, results) {
* // results is an Object with keys 'logo' and 'header'
* // the values are both HTMLImageElements
* });
*
* @example <caption><h4>Caching Assets</h4>
* In order to cache elements, each asset must have an id field,
* which is the name of the element accessible from the loader's cache.</caption>
* const jibo = require('jibo');
* const assets = [
* { id:'logo', src: "logo.png", cache: true },
* { id: 'header', src: "header.jpg", cache: true }
* ];
* jibo.loader.load(assets, function() {
* jibo.loader.cached('logo'); // contains HTMLImageElement
* jibo.loader.cached('header'); // contains HTMLImageElement
* });
*
* @example <caption><h4>Options for Multiple Loading</h4></caption>
* jibo.loader.load(assets, {
* complete: function(err, results){}, // when completed
* progress: function(progress){}, // percentage of total load progress
* taskDone: function(err, result){}, // called when a task is complete
* cacheAll: false, // cache all assets
* startAll: true // start all file requests at once
* });
*
* @example <caption> <h4>Return Types</h4></caption>
* | Extension | Result Type |
* | ------------------------ | -------------------------- |
* | png, jpg, gif, bmp, webp | `HTMLImageElement` |
* | html | `HTMLDocument` |
* | css | `HTMLStyleElement` |
* | mp3, oga, ogg, wav, m4a | `ArrayBuffer` |
* | svg, xml | `Document` |
* | webm, ogm, m4v, mp4 | `Buffer` |
* | txt | `String` |
* | json | `JSON` |
* | js | return of `module.exports` |
*
* @example <caption><h4>General Asset</h4>
* An asset can be represented as a String (path to load) or Object.
* The asset Object contains several optional keys and a required src key.</caption>
* {
* src: "file.txt", // path to file
* cache: false, // save to cache
* id: "file-ref", // cache key
* complete: function(result){}, // returns
* }
*
* @example <caption> <h4>Color-Alpha Asset </h4>
* The Color-Alpha asset can be used to load an image and apply a color.
* Can be useful for compressing large spritesheets as JPGs and applying a simple alpha channel from a PNG.
* </caption>
* {
* src: "color.jpg", // path to file
* alpha: "color-alpha.png", // alpha
* complete: function(err, img){}, // returns HTMLImageElement
* }
*
* @example <caption><h4>Texture Asset </h4>
* By default, loading images returns an HTMLImageElement.
* To return a PIXI.Texture object, you can used the Texture Asset.
* Notice the required field type.</caption>
* {
* src: "logo.png",
* type: "texture", // required
* upload: false, // upload to GPU when finished downloading
* complete: function(err, texture){} // returns PIXI.Texture object
* }
*
* @example <caption><h4>Keys Asset </h4>
* Preload a keys file and any assets (sounds or timelines) that it uses.</caption>
* {
* src: "my-animation.keys",
* type: "keys", // required
* root: "/path/to/the/project-or-assetpack", // Can be used with PathUtils.getAssetUri
* complete: function(err, animation){} // returns jibo.rendering.animation.KeysAnimation object
* }
*
* @example <caption><h4>Timeline Asset</h4>
* Preload a PixiAnimate animation.
* Will preload any assets used by the timeline (shapes & images). </caption>
* {
* src: "my-animation.js",
* type: "timeline", // required
* complete: function(err, timeline){} // returns jibo.rendering.animation.Timeline object
* }
*
* @example <caption><h4>Sound Asset </h4>
* Sounds can be loaded automatically and added to jibo.sound.
* If no ID is specified, the basename of the file is used as the sound alias.
* In the example below, the alias would be "music",
* and the sound could be played by calling jibo.sound.play("music").
* </caption>
* {
* src: "music.mp3",
* type: "sound", // required
* block: false, // allow only playing at once
* volume: 1, // from 0 to 1
* panning: 0, // from -1 (left) to 1 (right)
* loop: false, // allow looping
* autoPlay: false, // play when finished
* complete: function(err, sound){} // returns jibo.sound.Sound object
* }
*
* @example <caption><h4>Function Asset</h4>
* A function can be used as an asset like any other.
* This requires done to be called. Optionally a result can be passed as the
* first argument to done and this will be used as the cached result.
* </caption>
* function(err, done)
* {
* // do some async things here
* done();
* }
*
* @example <caption><h4>Unloading</h4></caption>
* const assets = [
* { id:'logo', src: "logo.png", cache: 'myCache' },
* { id: 'header', src: "header.jpg", cache: 'myCache' }
* ];
* jibo.loader.unload(assets);
* jibo.loader.unload(['logo', 'header'], 'myCache'); // alternatively, remove by IDs
* jibo.loader.unloadAll(); // remove all assets
*
* @example <caption><h4>Custom Task </h4>
* When assets are loaded by the loader module, they are converted into asynchronous Tasks.
* Custom tasks can be registered with the loader module to provide
* convenience creating complex types of objects. Here's an example:</caption>
* // Must extend the Task class
* class SpritesheetTask extends jibo.loader.Task {
* // A test method is required to test if an asset can use this task
* static test(asset) {
* return asset.image && asset.data;
* }
* // constructor takes the assetManager and asset as arguments
* constructor(manager, asset) {
* super(manager, asset, asset.image);
* this.image = asset.image;
* this.data = asset.data;
* }
* // entry point for starting async task, callback takes one argument
* // for the object we're returning
* start(callback) {
* const assets = {
* _image: this.image,
* _data: this.data
* }
* // base Task class has load and simpleLoad methods
* this.load(assets, (err, results) => {
* if (err) return callback(err);
* callback(null, new Spritesheet(results._image, results._data));
* });
* }
* }
*
* // Register with the loader module
* jibo.loader.register(SpritesheetTask, 50);
* // Note 50 is the priority, all built-in tasks are < 50, higher priority tasks
* // are tested before lower (more generalized) tasks
*
* @example <caption><h4>Custom Task Usage</h4></caption>
* const asset = {
* image: "spritesheet.png",
* data: "spritesheet_atlas.json"
* };
* jibo.loader.load(asset, function(err, spritesheet) {
* // spritesheet should be a Spritesheet object
* });
*
* @namespace jibo.loader
*/
/**
* Instance of the asset manager.
* @name jibo.loader#assetManager
* @type {jibo.loader.AssetManager}
* @private
*/
/**
* Handles any errors coming from the manager.
* @method jibo.loader#register
* @param {Function} TaskDefinition The class definition for a loader task.
* @param {int} [priority=0] The priority of the task. Higher priority tasks
* are run first and therefore should be more specific
* types of tasks. Lower priority tasks are more generalized.
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Performs simple load of a single file.
* @method jibo.loader#load
* @param {String} source The file to load.
* @param {jibo.loader.AssetManager~completeCallback} complete The completed callback with a single
* parameters result object.
* @param {jibo.loader.AssetManager~progressCallback} [progress=null] Callback percentage updates.
* @param {String} [cache=null] A cache id to save to the asset cache after load.
* @param {Object} [data] Optional data to pass along
* @param {Boolean} [remote=false] `true` to force remote download.
* @param {Number} [timeout=0] Number of milliseconds to timeout remote load.
* @param {String} [format] Force a format type, either:
* "image", "json", "xml", "css", "js", "svg", "text", or "html"
*/
/**
* Loads a single custom asset with options.
* @method jibo.loader#load
* @param {Object} asset The single asset resource to load, properties
* will depend on the type of asset loading.
* @param {jibo.loader.AssetManager~completeCallback} [asset.complete=null] Callback when finished.
* @param {String} [asset.id=null] The ID to attach to this asset.
* @param {String} [asset.cache=null] A cache id if the result should be cached for later.
* @param {Boolean} [asset.remote=false] `true` if the src should be loaded of http(s), `false` to auto-determine.
* @param {String} [asset.format] Force a format type, either:
* "image", "json", "xml", "css", "js", "svg", "text", or "html"
* @param {Number} [asset.timeout=0] Number of milliseconds to timeout remote load.
* @param {jibo.loader.AssetManager~completeCallback} [complete] The completed callback with a single
* parameters which is a result object. Will
* only use if `asset.complete` is undefined.
*/
/**
* Loads a single file with options.
* @method jibo.loader#load
* @param {Object} asset The file resource to load.
* @param {String} asset.src The file to load.
* @param {String} [asset.cache=null] A cache id if the result should be cached for later.
* If string, then the name of the cache to use.
* @param {Boolean} [asset.remote=false] `true` if the src should be loaded of http(s), `false` to auto-determine.
* @param {String} [asset.format] Force a format type, either:
* "image", "json", "xml", "css", "js", "svg", "text", or "html"
* @param {Number} [asset.timeout=0] Number of milliseconds to timeout remote load.
* @param {jibo.loader.AssetManager~completeCallback} [asset.complete=null] Callback when finished.
* @param {jibo.loader.AssetManager~completeCallback} [complete] The completed callback with a single
* parameter which is a result object. Will
* only use if `asset.complete` is undefined.
*/
/**
* Loads a map of multiple assets and return mapped result objects.
* @method jibo.loader#load
* @param {Object} assets Load a map of assets.
* @param {jibo.loader.AssetManager~completeCallback|object} [options] Callback where the only parameter is the
* map of the results by ID, or the collection of load options.
* @param {jibo.loader.AssetManager~completeCallback} [options.complete=null] The complete callback if using load options.
* @param {jibo.loader.Task~completeCallback} [options.taskDone=null] The callback when a single item is finished.
* @param {jibo.loader.AssetManager~progressCallback} [options.progress=null] Callback percentage updates.
* @param {Boolean} [options.cacheAll=false] `true` if tasks should be cached.
* @param {Number} [options.maxLoads=4] The maximum number of simultaneous loads, 0 to start all.
* @param {Boolean} [options.remoteAll=false] `true` to force remote calls on all assets.
* @param {Number} [options.timeoutAll=0] Number of milliseconds to timeout remote calls.
*/
/**
* Loads a list of multiple assets and return array of result objects.
* @method jibo.loader#load
* @param {Array} assets The list of assets.
* If each object has a `id` the result will be a mapped object.
* @param {function|object} [options] Callback where the only parameter is the
* collection or map of the results, or the collection of load options.
* @param {jibo.loader.AssetManager~completeCallback} [options.complete=null] The complete callback if using load options.
* @param {jibo.loader.Task~completeCallback} [options.taskDone=null] The callback when a single item is finished.
* @param {jibo.loader.AssetManager~progressCallback} [options.progress=null] Callback percentage updates.
* @param {Boolean} [options.cacheAll=false] `true` if tasks should be cached.
* @param {Number} [options.maxLoads=4] The maximum number of simultaneous loads, 0 to start all.
* @param {Boolean} [options.remoteAll=false] `true` to force remote calls on all assets.
* @param {Number} [options.timeoutAll=0] Number of milliseconds to timeout remote calls.
*/
/**
* Sets the base path to prepend to all loads.
* @name jibo.loader#basePath
* @type {String}
*/
/**
* Sets the base URL to prepend to all remote loads.
* @name jibo.loader#baseUrl
* @type {String}
*/
/**
* Unloads an asset or list of assets.
* @method jibo.loader#unload
* @param {jibo.loader.AssetToken|jibo.loader.AssetToken[]} assets The collection of asset ids or
* single asset id.
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Unloads all assets from the assets cache.
* @method jibo.loader#unloadAll
* @param {String} [cacheId] The specific cache to unload. Uses active cache if empty.
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Cancels all the current loads.
* @method jibo.loader#cancelAll
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Adds a new custom cache. This "bucket" can be unloaded later. If the cache already exists,
* nothing happens.
* @method jibo.loader#addCache
* @param {String} cacheId The unique ID for cache.
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Set or get the currently active cache.
* @name jibo.loader#activeCache
* @type {String}
*/
/**
* Set or get the default number of max simultaneous loads.
* @name jibo.loader#maxDefaultLoads
* @type {Number}
*/
/**
* Unloads all assets from the assets cache.
* @method jibo.loader#deleteCache
* @return {jibo.loader} The loader namespace for chaining.
*/
/**
* Gets an asset from the cache by ID
* @method jibo.loader#cached
* @param {String} id The asset to fetch.
* @param {String} cacheId The cache to grab asset from, uses the active cache if empty.
* @return {any|null} The cached object or null if empty.
*/