/** * Class for resolve root and asset paths. * @class PathUtils * @memberof jibo.utils */ /** * The token separating asset packs. * @name jibo.utils.PathUtils.ASSET_TOKEN * @type {String} * @private * @readOnly */ /** * Traverses up the directories until the first folder with a `package.json` file. * This also works for requests with asset-pack, e.g., "core://resources/fonts.css". * @method jibo.utils.PathUtils.findRoot * @param {String} [start] The starting directory, empty uses current working directory. * @return {String} The root directory which contains `package.json`. */ /** * Get a project name. Useful for figuring out the asset pack. * @method jibo.utils.PathUtils.getProjectName * @param {String} dir The directory. Should contain `package.json`. * @return {String} The name in the `package.json`. */ /** * Basic check to see if a URI is a URL. * @method jibo.utils.PathUtils.isURL * @param {String} uri String path to test. * @return {Boolean} `true` if URI is a URL. */ /** * Basic check to see if a URI is an image. * @method jibo.utils.PathUtils.isImage * @param {String} uri String path to test. * @return {Boolean} `true` if URI contains an image extension. */ /** * Set the default path for behaviors, rules, animations, etc. * @method jibo.utils.PathUtils.setDefaultPath * @param {String} parentDir The parent directory. * @param {String} fileName The file name. * @return {String} asset URI to load. */ /** * Get the asset pack from the file request, if available. * @method jibo.utils.PathUtils.getAssetPack * @param {String} fileName The file name. * @return {String} The asset pack name, otherwise returns ''. */ /** * Get an asset pack URI. * @method jibo.utils.PathUtils.getAssetUri * @param {String} fileName The file name to load, can be `asset-pack://etc`. * @param {String} assetPack The current asset pack to load within. * @param {string} [resourceRoot] The root of the skill to get the asset from (defaults to current skill). * @return {String} The result URI. */ /** * Get asset source from filename and asset pack. * @method jibo.utils.PathUtils.getAudioUri * @param {String} fileName The file name to load, can be `asset-pack://etc`. * @param {String} currentAssetPack The current asset pack to load within. * @param {String} [resourceRoot] The root to the skill. * @return {String} The result URI. */ /** * Get asset source from filename and asset pack. * @method jibo.utils.PathUtils.getTimelineUri * @param {String} fileName The file name to load, can be `asset-pack://etc`. * @param {String} currentAssetPack The current asset pack to load within. * @param {String} [resourceRoot] The root to the skill. * @return {String} The result URI. */ /** * Get the URI for an animation referenced from within another animation's reference layer. * In the case of asset pack references, we resolve it relative to the asset pack's "animations" directory. * Otherwise it's a relative reference, relative to the referencing animation file's directory. * @method jibo.utils.PathUtils.getAnimationUri * @param fileName * @param currentAssetPack * @param resourceRoot * @returns {string} */ /** * Modified from [https://github.com/sindresorhus/resolve-from](https://github.com/sindresorhus/resolve-from). Return the path to the * module's `package.json`, not the module directory. * @method jibo.utils.PathUtils.resolve * @param {String} moduleId The module to resolve path to. * @param {String} [fromPath=process.cwd()] Resolve path from * @return {String} The resolved file path. */ /** * Return the root path of the asset pack from the asset filename, if available. * @method jibo.utils.PathUtils.resolveAssetPack * @param {String} assetPack The assetPack name name. * @return {String} Full path to the root directory. */