UNPKG

@awayjs/core

Version:
111 lines (110 loc) 3.6 kB
import { __extends } from "tslib"; import { AbstractMethodError } from '../errors/AbstractMethodError'; import { AssetEvent } from '../events/AssetEvent'; import { EventDispatcher } from '../events/EventDispatcher'; import { UUID } from './UUID'; var AssetBase = /** @class */ (function (_super) { __extends(AssetBase, _super); function AssetBase() { var _this = _super.call(this) || this; _this._abstractions = {}; _this.id = UUID.Next(); return _this; } Object.defineProperty(AssetBase.prototype, "adaptee", { get: function () { return this; }, enumerable: false, configurable: true }); Object.defineProperty(AssetBase.prototype, "adapter", { /** * adapter is used to provide MovieClip to scripts taken from different platforms * setter typically managed by factory. getter defaults to AwayJS class */ get: function () { return this._adapter || this; }, set: function (value) { this._adapter = value; }, enumerable: false, configurable: true }); Object.defineProperty(AssetBase.prototype, "assetType", { /** * */ get: function () { return AssetBase.assetType; }, enumerable: false, configurable: true }); Object.defineProperty(AssetBase.prototype, "name", { get: function () { return this._name; }, set: function (val) { var prev = this._name; this._name = val; if (this._name == null) this._name = 'null'; this.dispatchEvent(new AssetEvent(AssetEvent.RENAME, this, prev)); }, enumerable: false, configurable: true }); /** * */ AssetBase.prototype.invalidate = function () { for (var key in this._abstractions) this._abstractions[key].onInvalidate(); }; AssetBase.prototype.addAbstraction = function (abstraction) { this._abstractions[abstraction.id] = abstraction; }; AssetBase.prototype.removeAbstraction = function (abstraction) { delete this._abstractions[abstraction.id]; }; /** * @inheritDoc */ AssetBase.prototype.dispose = function () { throw new AbstractMethodError(); }; AssetBase.prototype.clone = function () { throw new AbstractMethodError(); }; AssetBase.prototype.clear = function () { for (var key in this._abstractions) this._abstractions[key].onClear(); }; Object.defineProperty(AssetBase.prototype, "assetNamespace", { get: function () { return this._namespace; }, set: function (value) { this._namespace = value ? value : AssetBase.DEFAULT_NAMESPACE; }, enumerable: false, configurable: true }); AssetBase.prototype.assetPathEquals = function (name, ns) { return (this._name == name && (!ns || this._namespace == ns)); }; AssetBase.prototype.isAsset = function (assetClass) { return this.assetType == assetClass.assetType; }; AssetBase.prototype.resetAssetPath = function (name, ns) { if (ns === void 0) { ns = null; } this._name = name ? name : 'null'; this._namespace = ns ? ns : AssetBase.DEFAULT_NAMESPACE; }; AssetBase.assetType = '[asset Asset]'; AssetBase.DEFAULT_NAMESPACE = 'default'; return AssetBase; }(EventDispatcher)); export { AssetBase };