Modules

AssetDB

Functions

_checkIfMountValid(assetdb, fspath)

check and remove unused meta file

_deleteImportedAssets()
_removeUnusedMeta(assetdb, metapath)

check and remove unused meta file

_backupUnusedMeta(assetdb, metapath, force)string

check and backup unused meta file

_backupAsset(assetdb, filePath)

check and backup asset file

_removeUnusedImportFiles()

_removeUnusedImportFiles

_removeUnusedMtimeInfo()

_removeUnusedMtimeInfo

_scan(assetdb, fspath, opts, cb)

task scan

_checkIfReimport(assetdb, fspath, cb)

check if reimport

_initMetas(assetdb, fspath, cb)

precache uuid from meta files, if meta file not exists, create it

_importAsset(assetdb, fspath, cb)

precache uuid from meta files, if meta file not exists, create it

_postImportAsset(assetdb, assetInfo, cb)

Post manipulations of meta files, it may used to create reference between imported assets.

_fillInResults(assetdb, path, meta, results)

Construct results for given meta and fill into the results array

_refresh()

task refresh

_preProcessMoveInput()

callback's parameters: srcPath, destPath, srcpaths, destPaths

_copyFiles()
_generateSubMetaDiff()

For save / saveMeta tasks to generate sub meta diff informations

_deleteAsset()

Delete one asset by fspath

AssetDB

Process: core

AssetDB.init([cb])

Init assetdb, it will scan the mounted directories, and import unimported assets.

Kind: static method of AssetDB

Param Type
[cb] function

Example

Editor.assetdb.init(function (err, results) {
  // assets that imported during init
  results.forEach(function ( result ) {
    // result.uuid
    // result.parentUuid
    // result.url
    // result.path
    // result.type
  });
});

AssetDB.refresh(url, [cb])

Refresh the assets in url, and return the results

Kind: static method of AssetDB

Param Type
url string
[cb] function

Example

Editor.assetdb.refresh('db://assets/foo/bar/', function (err, results) {
  // assets that imported during init
  results.forEach(function ( result ) {
    if ( result.command === 'delete' ) {
      // result.uuid
      // result.url
      // result.path
      // result.type
    } else if ( result.command === 'change' || result.command === 'create' ) {
      // result.uuid
      // result.parentUuid
      // result.url
      // result.path
      // result.type
    } else if ( result.command === 'uuid-change' ) {
      // result.oldUuid
      // result.uuid
      // result.parentUuid
      // result.url
      // result.path
      // result.type
    }
  });
});

AssetDB.deepQuery([cb])

deepQuery

Kind: static method of AssetDB

Param Type
[cb] function

Example

Editor.assetdb.deepQuery(function ( err, results ) {
  results.forEach(function ( result ) {
    // result.name
    // result.extname
    // result.uuid
    // result.type
    // result.isSubAsset
    // result.children - the array of children result
  });
});

AssetDB.queryAssets(pattern, assetTypes, [cb])

queryAssets

Kind: static method of AssetDB

Param Type Description
pattern string The url pattern
assetTypes string | array The asset type(s)
[cb] function The callback function

Example

Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( err, results ) {
  results.forEach(function ( result ) {
    // result.url
    // result.path
    // result.uuid
    // result.type
    // result.isSubAsset
  });
});

AssetDB.queryMetas(pattern, type, [cb])

queryMetas

Kind: static method of AssetDB

Param Type Description
pattern string The url pattern
type string The asset type
[cb] function The callback function

Example:

Editor.assetdb.queryMetas( 'db://assets/**\/*', 'texture', function ( err, results ) {
  results.forEach(function ( meta ) {
    // the meta instance
  });
});

AssetDB.move(srcUrl, destUrl, [cb])

move

Kind: static method of AssetDB

Param Type
srcUrl string
destUrl string
[cb] function

Example

Editor.assetdb.move( 'db://assets/foo/foobar.png', 'db://assets/bar/foobar.png', function ( err, results ) {
  results.forEach(function ( result ) {
    // result.srcPath
    // result.destPath
    // result.uuid
    // result.parentUuid
  });
});

AssetDB.delete(urls, [cb])

delete

Kind: static method of AssetDB

Param Type
urls array
[cb] function

Example

Editor.assetdb.delete( [ 'db://assets/foo/bar.png', 'db://assets/foo/bar.plist' ], function ( err, results ) {
  results.forEach(function ( result ) {
    // result.srcPath
    // result.destPath
    // result.uuid
    // result.parentUuid
  });
});

AssetDB.create(url, data, [cb])

Create asset at url with data

Kind: static method of AssetDB

Param Type
url string
data string
[cb] function

Example

Editor.assetdb.create( 'db://assets/foo/bar.js', data, function ( err, results ) {
  results.forEach(function ( result ) {
    // result.uuid
    // result.parentUuid
    // result.url
    // result.path
    // result.type
  });
});

AssetDB.saveExists(url, data, [cb])

Save data to the exists asset at url

Kind: static method of AssetDB

Param Type
url string
data string
[cb] function

Example

Editor.assetdb.saveExists( 'db://assets/foo/bar.js', data, function ( err, meta ) {
  // do something
});

AssetDB.import(rawfiles, url, [cb])

Import raw files to url

Kind: static method of AssetDB

Param Type
rawfiles array
url string
[cb] function

Example

Editor.assetdb.import( ['/User/user/foo.js', '/User/user/bar.js'], 'db://assets/foobar', function ( err, results ) {
  results.forEach(function ( result ) {
    // result.uuid
    // result.parentUuid
    // result.url
    // result.path
    // result.type
  });
});

AssetDB.saveMeta(uuid, jsonString, [cb])

Overwrite the meta by loading it through uuid

Kind: static method of AssetDB

Param Type
uuid string
jsonString string
[cb] function

Example

Editor.assetdb.saveMeta( uuid, jsonString, function ( err, meta ) {
  // do something
});

AssetDB.exchangeUuid(urlA, urlB, [cb])

Exchange uuid for two assets

Kind: static method of AssetDB

Param Type
urlA string
urlB string
[cb] function

AssetDB.clearImports(url, [cb])

Clear imports

Kind: static method of AssetDB

Param Type
url string
[cb] function

Example

Editor.assetdb.clearImports( 'db://assets/foo/bar.js', function ( err, results ) {
  results.forEach(function ( result ) {
    // result.uuid
    // result.url
    // result.path
    // result.type
  });
});

AssetDB.register(extname, folder, metaCtor)

Register meta type

Kind: static method of AssetDB

Param Type Description
extname string
folder boolean Whether it's a folder type
metaCtor object

Example

Editor.assetdb.register( '.png', false, PngMeta );

AssetDB.unregister(metaCtor)

Unregister meta type

Kind: static method of AssetDB

Param Type
metaCtor object

Example

Editor.assetdb.unregister( PngMeta );

AssetDB.getRelativePath(fspath) ⇒ string

Get the relative path from mount path to the asset by fspath

Kind: static method of AssetDB
Returns: string - the relative path from mount path to the asset

Param Type
fspath string

AssetDB.getAssetBackupPath(filePath)

get the backup file path of asset file

Kind: static method of AssetDB

Param Type Description
filePath string asset file path

AssetDB.setEventCallback(cb)

set the event callback for assets events

Kind: static method of AssetDB

Param Type Description
cb object The callback for assets events.

Example

Editor.assetdb.setEventCallback((event, params) => {
   // do something for the event
})

AssetDB~urlToUuid(url) ⇒ string

Return uuid by url. if uuid not found, it will return null.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~fspathToUuid(fspath) ⇒ string

Return uuid by file path. if uuid not found, it will return null.

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~uuidToFspath(uuid) ⇒ string

Return file path by uuid. if file path not found, it will return null.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~uuidToUrl(uuid) ⇒ string

Return url by uuid. if url not found, it will return null.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~fspathToUrl(fspath) ⇒ string

Return url by file path. if file path not found, it will return null.

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~urlToFspath(url) ⇒ string

Return file path by url. if url not found, it will return null.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~exists(url) ⇒ string

Check existance by url.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~existsByUuid(uuid) ⇒ string

Check existance by uuid.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~existsByPath(fspath) ⇒ string

Check existance by path.

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~isSubAsset(url) ⇒ boolean

Check whether asset for a given url is a sub asset.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~isSubAssetByUuid(uuid) ⇒ boolean

Check whether asset for a given uuid is a sub asset.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~isSubAssetByPath(fspath) ⇒ boolean

Check whether asset for a given path is a sub asset.

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~containsSubAssets(url) ⇒ boolean

Check whether asset contains sub assets for a given url.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~containsSubAssetsByUuid(uuid) ⇒ boolean

Check whether asset contains sub assets for a given uuid.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~containsSubAssetsByPath(path) ⇒ boolean

Check whether asset contains sub assets for a given path.

Kind: inner method of AssetDB

Param Type
path string

AssetDB~assetInfo(url) ⇒ object

Return asset info by a given url.

Kind: inner method of AssetDB
Returns: object - - { uuid, path, url, type, isSubAsset }

Param Type
url string

AssetDB~assetInfoByUuid(uuid) ⇒ object

Return asset info by a given uuid.

Kind: inner method of AssetDB
Returns: object - - { uuid, path, url, type, isSubAsset }

Param Type
uuid string

AssetDB~assetInfoByPath(fspath) ⇒ object

Return asset info by a given file path.

Kind: inner method of AssetDB
Returns: object - - { uuid, path, url, type, isSubAsset }

Param Type
fspath string

AssetDB~subAssetInfos(url) ⇒ array

Return all sub assets info by url if the url contains sub assets.

Kind: inner method of AssetDB
Returns: array - - [{ uuid, path, url, type, isSubAsset }]

Param Type
url string

AssetDB~subAssetInfosByUuid(uuid) ⇒ array

Return all sub assets info by uuid if the uuid contains sub assets.

Kind: inner method of AssetDB
Returns: array - - [{ uuid, path, url, type, isSubAsset }]

Param Type
uuid string

AssetDB~subAssetInfosByPath(fspath) ⇒ array

Return all sub assets info by path if the path contains sub assets.

Kind: inner method of AssetDB
Returns: array - - [{ uuid, path, url, type, isSubAsset }]

Param Type
fspath string

AssetDB~loadMeta(url) ⇒ object

Return meta instance by a given url.

Kind: inner method of AssetDB

Param Type
url string

AssetDB~loadMetaByUuid(uuid) ⇒ object

Return meta instance by a given uuid.

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~loadMetaByPath(fspath) ⇒ object

Return meta instance by a given path.

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~isMount(url) ⇒ boolean

Return whether a given url is reference to a mount

Kind: inner method of AssetDB

Param Type
url string

AssetDB~isMountByPath(fspath) ⇒ boolean

Return whether a given path is reference to a mount

Kind: inner method of AssetDB

Param Type
fspath string

AssetDB~isMountByUuid(uuid) ⇒ boolean

Return whether a given uuid is reference to a mount

Kind: inner method of AssetDB

Param Type
uuid string

AssetDB~mountInfo(url) ⇒ object

Return mount info by url

Kind: inner method of AssetDB
Returns: object - - { path, name, type }

Param Type
url string

AssetDB~mountInfoByUuid(uuid) ⇒ object

Return mount info by uuid

Kind: inner method of AssetDB
Returns: object - - { path, name, type }

Param Type
uuid string

AssetDB~mountInfoByPath(fspath) ⇒ object

Return mount info by path

Kind: inner method of AssetDB
Returns: object - - { path, name, type }

Param Type
fspath string

AssetDB~mount(path, mountPath, opts, [cb])

mount a directory to assetdb, and give it a name. if you don't provide a name, it will mount to root.

Kind: inner method of AssetDB

Param Type Description
path string file system path
mountPath string the mount path (relative path)
opts object options
opts.hide object if the mount hide in assets browser
opts.virtual object if this is a virtual mount point
opts.icon object icon for the mount
[cb] function a callback function

Example

Editor.assetdb.mount('path/to/mount', 'assets', function (err) {
  // mounted, do something ...
});

AssetDB~attachMountPath(mountPath, [cb])

attach the specified mount path

Kind: inner method of AssetDB

Param Type Description
mountPath string the mount path (relative path)
[cb] function a callback function

Example

Editor.assetdb.attachMountPath('assets', function (err, results) {
  // mount path attached, do something ...
  // results are the assets created
});

AssetDB~unattachMountPath(mountPath, [cb])

unattach the specified mount path

Kind: inner method of AssetDB

Param Type Description
mountPath string the mount path (relative path)
[cb] function a callback function

Example

Editor.assetdb.unattachMountPath('assets', function (err, results) {
  // mount path unattached, do something ...
  // results are the assets deleted
});

AssetDB~unmount(mountPath, [cb])

Unmount by name

Kind: inner method of AssetDB

Param Type Description
mountPath string the mount path
[cb] function

Example

Editor.assetdb.unmount('assets', function (err) {
  // unmounted, do something ...
});

_checkIfMountValid(assetdb, fspath)

check and remove unused meta file

Kind: global function

Param Type Description
assetdb object asset database
fspath string meta file path

_deleteImportedAssets()

Kind: global function

_removeUnusedMeta(assetdb, metapath)

check and remove unused meta file

Kind: global function

Param Type Description
assetdb object asset database
metapath string meta file path

_backupUnusedMeta(assetdb, metapath, force) ⇒ string

check and backup unused meta file

Kind: global function
Returns: string - The relative path of the meta file. If not backed up, return null

Param Type Description
assetdb object asset database
metapath string meta file path
force boolean skip the check process and force do backup, default is false

_backupAsset(assetdb, filePath)

check and backup asset file

Kind: global function

Param Type Description
assetdb object asset database
filePath string asset file path

_removeUnusedImportFiles()

_removeUnusedImportFiles

Kind: global function

_removeUnusedMtimeInfo()

_removeUnusedMtimeInfo

Kind: global function

_scan(assetdb, fspath, opts, cb)

task scan

Kind: global function

Param Type Description
assetdb object asset database
fspath string file system path
opts object options
opts.remove-unused-meta object indicate if remove unused meta file
opts.filter-meta object if results need filter .meta file
cb function

_checkIfReimport(assetdb, fspath, cb)

check if reimport

Kind: global function

Param Type Description
assetdb object asset database
fspath string file system path
cb function

_initMetas(assetdb, fspath, cb)

precache uuid from meta files, if meta file not exists, create it

Kind: global function

Param Type Description
assetdb object asset database
fspath string file system path
cb function

_importAsset(assetdb, fspath, cb)

precache uuid from meta files, if meta file not exists, create it

Kind: global function

Param Type Description
assetdb object asset database
fspath string file system path
cb function

_postImportAsset(assetdb, assetInfo, cb)

Post manipulations of meta files, it may used to create reference between imported assets.

Kind: global function

Param Type Description
assetdb object asset database
assetInfo object Asset info object including file system path and other informations.
cb function

_fillInResults(assetdb, path, meta, results)

Construct results for given meta and fill into the results array

Kind: global function

Param Type Description
assetdb object asset database
path string file system path for asset
meta AssetMeta Meta object
results Array The results array to fill

_refresh()

task refresh

Kind: global function

_preProcessMoveInput()

callback's parameters: srcPath, destPath, srcpaths, destPaths

Kind: global function

_copyFiles()

Kind: global function

_generateSubMetaDiff()

For save / saveMeta tasks to generate sub meta diff informations

Kind: global function

_deleteAsset()

Delete one asset by fspath

Kind: global function

条与 "" 相匹配的结果

    没有与 "" 匹配的结果