Modules

Functions

AssetDB

Process: core

AssetDB.init([cb])

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

Kind: static method of AssetDB

ParamType
[cb]function

Example

  1. Editor.assetdb.init(function (err, results) {
  2. // assets that imported during init
  3. results.forEach(function ( result ) {
  4. // result.uuid
  5. // result.parentUuid
  6. // result.url
  7. // result.path
  8. // result.type
  9. });
  10. });

AssetDB.refresh(url, [cb])

Refresh the assets in url, and return the results

Kind: static method of AssetDB

ParamType
urlstring
[cb]function

Example

  1. Editor.assetdb.refresh('db://assets/foo/bar/', function (err, results) {
  2. // assets that imported during init
  3. results.forEach(function ( result ) {
  4. if ( result.command === 'delete' ) {
  5. // result.uuid
  6. // result.url
  7. // result.path
  8. // result.type
  9. } else if ( result.command === 'change' || result.command === 'create' ) {
  10. // result.uuid
  11. // result.parentUuid
  12. // result.url
  13. // result.path
  14. // result.type
  15. } else if ( result.command === 'uuid-change' ) {
  16. // result.oldUuid
  17. // result.uuid
  18. // result.parentUuid
  19. // result.url
  20. // result.path
  21. // result.type
  22. }
  23. });
  24. });

AssetDB.deepQuery([cb])

deepQuery

Kind: static method of AssetDB

ParamType
[cb]function

Example

  1. Editor.assetdb.deepQuery(function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.name
  4. // result.extname
  5. // result.uuid
  6. // result.type
  7. // result.isSubAsset
  8. // result.children - the array of children result
  9. });
  10. });

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

queryAssets

Kind: static method of AssetDB

ParamTypeDescription
patternstringThe url pattern
assetTypesstring \arrayThe asset type(s)
[cb]functionThe callback function

Example

  1. Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.url
  4. // result.path
  5. // result.uuid
  6. // result.type
  7. // result.isSubAsset
  8. });
  9. });

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

queryMetas

Kind: static method of AssetDB

ParamTypeDescription
patternstringThe url pattern
typestringThe asset type
[cb]functionThe callback function

Example

  1. Editor.assetdb.queryAssets( 'db://assets/**\/*', 'texture', function ( err, results ) {
  2. results.forEach(function ( meta ) {
  3. // the meta instance
  4. });
  5. });

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

move

Kind: static method of AssetDB

ParamType
srcUrlstring
destUrlstring
[cb]function

Example

  1. Editor.assetdb.move( 'db://assets/foo/foobar.png', 'db://assets/bar/foobar.png', function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.srcPath
  4. // result.destPath
  5. // result.uuid
  6. // result.parentUuid
  7. });
  8. });

AssetDB.delete(urls, [cb])

delete

Kind: static method of AssetDB

ParamType
urlsarray
[cb]function

Example

  1. Editor.assetdb.delete( [ 'db://assets/foo/bar.png', 'db://assets/foo/bar.plist' ], function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.srcPath
  4. // result.destPath
  5. // result.uuid
  6. // result.parentUuid
  7. });
  8. });

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

Create asset at url with data

Kind: static method of AssetDB

ParamType
urlstring
datastring
[cb]function

Example

  1. Editor.assetdb.create( 'db://assets/foo/bar.js', data, function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.uuid
  4. // result.parentUuid
  5. // result.url
  6. // result.path
  7. // result.type
  8. });
  9. });

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

Save data to the exists asset at url

Kind: static method of AssetDB

ParamType
urlstring
datastring
[cb]function

Example

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

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

Import raw files to url

Kind: static method of AssetDB

ParamType
rawfilesarray
urlstring
[cb]function

Example

  1. Editor.assetdb.import( ['/User/user/foo.js', '/User/user/bar.js'], 'db://assets/foobar', function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.uuid
  4. // result.parentUuid
  5. // result.url
  6. // result.path
  7. // result.type
  8. });
  9. });

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

Overwrite the meta by loading it through uuid

Kind: static method of AssetDB

ParamType
uuidstring
jsonStringstring
[cb]function

Example

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

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

Exchange uuid for two assets

Kind: static method of AssetDB

ParamType
urlAstring
urlBstring
[cb]function

AssetDB.clearImports(url, [cb])

Clear imports

Kind: static method of AssetDB

ParamType
urlstring
[cb]function

Example

  1. Editor.assetdb.clearImports( 'db://assets/foo/bar.js', function ( err, results ) {
  2. results.forEach(function ( result ) {
  3. // result.uuid
  4. // result.url
  5. // result.path
  6. // result.type
  7. });
  8. });

AssetDB.register(extname, folder, metaCtor)

Register meta type

Kind: static method of AssetDB

ParamTypeDescription
extnamestring
folderbooleanWhether it's a folder type
metaCtorobject

Example

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

AssetDB.unregister(metaCtor)

Unregister meta type

Kind: static method of AssetDB

ParamType
metaCtorobject

Example

  1. Editor.assetdb.unregister( PngMeta );

AssetDB.getRelativePath(fspath) ⇒ string

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

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

ParamType
fspathstring

AssetDB.getAssetBackupPath(filePath)

get the backup file path of asset file

Kind: static method of AssetDB

ParamTypeDescription
filePathstringasset file path

AssetDB.setEventCallback(cb)

set the event callback for assets events

Kind: static method of AssetDB

ParamTypeDescription
cbobjectThe callback for assets events.

Example

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

AssetDB~urlToUuid(url) ⇒ string

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

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~fspathToUuid(fspath) ⇒ string

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

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~uuidToFspath(uuid) ⇒ string

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

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~uuidToUrl(uuid) ⇒ string

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

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~fspathToUrl(fspath) ⇒ string

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

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~urlToFspath(url) ⇒ string

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

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~exists(url) ⇒ string

Check existance by url.

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~existsByUuid(uuid) ⇒ string

Check existance by uuid.

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~existsByPath(fspath) ⇒ string

Check existance by path.

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~isSubAsset(url) ⇒ boolean

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

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~isSubAssetByUuid(uuid) ⇒ boolean

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

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~isSubAssetByPath(fspath) ⇒ boolean

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

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~containsSubAssets(url) ⇒ boolean

Check whether asset contains sub assets for a given url.

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~containsSubAssetsByUuid(uuid) ⇒ boolean

Check whether asset contains sub assets for a given uuid.

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~containsSubAssetsByPath(path) ⇒ boolean

Check whether asset contains sub assets for a given path.

Kind: inner method of AssetDB

ParamType
pathstring

AssetDB~assetInfo(url) ⇒ object

Return asset info by a given url.

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

ParamType
urlstring

AssetDB~assetInfoByUuid(uuid) ⇒ object

Return asset info by a given uuid.

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

ParamType
uuidstring

AssetDB~assetInfoByPath(fspath) ⇒ object

Return asset info by a given file path.

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

ParamType
fspathstring

AssetDB~subAssetInfos(url) ⇒ array

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

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

ParamType
urlstring

AssetDB~subAssetInfosByUuid(uuid) ⇒ array

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

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

ParamType
uuidstring

AssetDB~subAssetInfosByPath(fspath) ⇒ array

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

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

ParamType
fspathstring

AssetDB~loadMeta(url) ⇒ object

Return meta instance by a given url.

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~loadMetaByUuid(uuid) ⇒ object

Return meta instance by a given uuid.

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~loadMetaByPath(fspath) ⇒ object

Return meta instance by a given path.

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~isMount(url) ⇒ boolean

Return whether a given url is reference to a mount

Kind: inner method of AssetDB

ParamType
urlstring

AssetDB~isMountByPath(fspath) ⇒ boolean

Return whether a given path is reference to a mount

Kind: inner method of AssetDB

ParamType
fspathstring

AssetDB~isMountByUuid(uuid) ⇒ boolean

Return whether a given uuid is reference to a mount

Kind: inner method of AssetDB

ParamType
uuidstring

AssetDB~mountInfo(url) ⇒ object

Return mount info by url

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

ParamType
urlstring

AssetDB~mountInfoByUuid(uuid) ⇒ object

Return mount info by uuid

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

ParamType
uuidstring

AssetDB~mountInfoByPath(fspath) ⇒ object

Return mount info by path

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

ParamType
fspathstring

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

ParamTypeDescription
pathstringfile system path
mountPathstringthe mount path (relative path)
optsobjectoptions
opts.hideobjectif the mount hide in assets browser
opts.virtualobjectif this is a virtual mount point
opts.iconobjecticon for the mount
[cb]functiona callback function

Example

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

AssetDB~attachMountPath(mountPath, [cb])

attach the specified mount path

Kind: inner method of AssetDB

ParamTypeDescription
mountPathstringthe mount path (relative path)
[cb]functiona callback function

Example

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

AssetDB~unattachMountPath(mountPath, [cb])

unattach the specified mount path

Kind: inner method of AssetDB

ParamTypeDescription
mountPathstringthe mount path (relative path)
[cb]functiona callback function

Example

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

AssetDB~unmount(mountPath, [cb])

Unmount by name

Kind: inner method of AssetDB

ParamTypeDescription
mountPathstringthe mount path
[cb]function

Example

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

_checkIfMountValid(assetdb, fspath)

check and remove unused meta file

Kind: global function

ParamTypeDescription
assetdbobjectasset database
fspathstringmeta file path

_deleteImportedAssets()

Kind: global function

_removeUnusedMeta(assetdb, metapath)

check and remove unused meta file

Kind: global function

ParamTypeDescription
assetdbobjectasset database
metapathstringmeta file path

_backupUnusedMeta(assetdb, metapath, force) ⇒ string

check and backup unused meta file

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

ParamTypeDescription
assetdbobjectasset database
metapathstringmeta file path
forcebooleanskip the check process and force do backup, default is false

_backupAsset(assetdb, filePath)

check and backup asset file

Kind: global function

ParamTypeDescription
assetdbobjectasset database
filePathstringasset file path

_removeUnusedImportFiles()

_removeUnusedImportFiles

Kind: global function

_removeUnusedMtimeInfo()

_removeUnusedMtimeInfo

Kind: global function

_scan(assetdb, fspath, opts, cb)

task scan

Kind: global function

ParamTypeDescription
assetdbobjectasset database
fspathstringfile system path
optsobjectoptions
opts.remove-unused-metaobjectindicate if remove unused meta file
opts.filter-metaobjectif results need filter .meta file
cbfunction

_checkIfReimport(assetdb, fspath, cb)

check if reimport

Kind: global function

ParamTypeDescription
assetdbobjectasset database
fspathstringfile system path
cbfunction

_initMetas(assetdb, fspath, cb)

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

Kind: global function

ParamTypeDescription
assetdbobjectasset database
fspathstringfile system path
cbfunction

_importAsset(assetdb, fspath, cb)

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

Kind: global function

ParamTypeDescription
assetdbobjectasset database
fspathstringfile system path
cbfunction

_postImportAsset(assetdb, assetInfo, cb)

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

Kind: global function

ParamTypeDescription
assetdbobjectasset database
assetInfoobjectAsset info object including file system path and other informations.
cbfunction

_fillInResults(assetdb, path, meta, results)

Construct results for given meta and fill into the results array

Kind: global function

ParamTypeDescription
assetdbobjectasset database
pathstringfile system path for asset
metaAssetMetaMeta object
resultsArrayThe 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