Files
Zos/Skills/@be/node_modules/jibo-loader/lib/docs/AssetLoad.js

304 lines
7.9 KiB
JavaScript
Raw Normal View History

/**
* 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.
*/