dist/globals/ember-data.prod.js in ember-data-source-2.15.0.beta.3 vs dist/globals/ember-data.prod.js in ember-data-source-2.15.0.beta.4
- old
+ new
@@ -4,18 +4,20 @@
/*!
* @overview Ember Data
* @copyright Copyright 2011-2017 Tilde Inc. and contributors.
* Portions Copyright 2011 LivingSocial Inc.
* @license Licensed under MIT license (see license.js)
- * @version 2.15.0-beta.3
+ * @version 2.15.0-beta.4
*/
var loader, define, requireModule, require, requirejs;
(function (global) {
'use strict';
+ var heimdall = global.heimdall;
+
function dict() {
var obj = Object.create(null);
obj['__'] = undefined;
delete obj['__'];
return obj;
@@ -28,13 +30,13 @@
requireModule: requireModule,
require: require,
requirejs: requirejs
};
- requirejs = require = requireModule = function (id) {
+ requirejs = require = requireModule = function (name) {
var pending = [];
- var mod = findModule(id, '(require)', pending);
+ var mod = findModule(name, '(require)', pending);
for (var i = pending.length - 1; i >= 0; i--) {
pending[i].exports();
}
@@ -53,29 +55,36 @@
global[newName] = global[oldName];
global[oldName] = oldGlobals[oldName];
}
}
}
- },
- // Option to enable or disable the generation of default exports
- makeDefaultExport: true
+ }
};
+ var _isArray;
+ if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ _isArray = Array.isArray;
+ }
+
var registry = dict();
var seen = dict();
var uuid = 0;
function unsupportedModule(length) {
- throw new Error('an unsupported module was defined, expected `define(id, deps, module)` instead got: `' + length + '` arguments to define`');
+ throw new Error('an unsupported module was defined, expected `define(name, deps, module)` instead got: `' + length + '` arguments to define`');
}
var defaultDeps = ['require', 'exports', 'module'];
- function Module(id, deps, callback, alias) {
- this.uuid = uuid++;
- this.id = id;
+ function Module(name, deps, callback, alias) {
+ this.id = uuid++;
+ this.name = name;
this.deps = !deps.length && callback.length ? defaultDeps : deps;
this.module = { exports: {} };
this.callback = callback;
this.hasExportsAsDep = false;
this.isAlias = alias;
@@ -105,27 +114,23 @@
// circular dependency so we must return our (partial) exports.
if (this.state === 'finalized' || this.state === 'reifying') {
return this.module.exports;
}
-
if (loader.wrapModules) {
- this.callback = loader.wrapModules(this.id, this.callback);
+ this.callback = loader.wrapModules(this.name, this.callback);
}
this.reify();
var result = this.callback.apply(this, this.reified);
- this.reified.length = 0;
this.state = 'finalized';
if (!(this.hasExportsAsDep && result === undefined)) {
this.module.exports = result;
}
- if (loader.makeDefaultExport) {
- this.makeDefaultExport();
- }
+ this.makeDefaultExport();
return this.module.exports;
};
Module.prototype.unsee = function () {
this.state = 'new';
@@ -174,118 +179,93 @@
} else if (dep === 'require') {
entry.exports = this.makeRequire();
} else if (dep === 'module') {
entry.exports = this.module;
} else {
- entry.module = findModule(resolve(dep, this.id), this.id, pending);
+ entry.module = findModule(resolve(dep, this.name), this.name, pending);
}
}
};
Module.prototype.makeRequire = function () {
- var id = this.id;
+ var name = this.name;
var r = function (dep) {
- return require(resolve(dep, id));
+ return require(resolve(dep, name));
};
r['default'] = r;
- r.moduleId = id;
r.has = function (dep) {
- return has(resolve(dep, id));
+ return has(resolve(dep, name));
};
return r;
};
- define = function (id, deps, callback) {
- var module = registry[id];
+ define = function (name, deps, callback) {
+ var module = registry[name];
- // If a module for this id has already been defined and is in any state
+ // If a module for this name has already been defined and is in any state
// other than `new` (meaning it has been or is currently being required),
// then we return early to avoid redefinition.
if (module && module.state !== 'new') {
return;
}
if (arguments.length < 2) {
unsupportedModule(arguments.length);
}
- if (!Array.isArray(deps)) {
+ if (!_isArray(deps)) {
callback = deps;
deps = [];
}
if (callback instanceof Alias) {
- registry[id] = new Module(callback.id, deps, callback, true);
+ registry[name] = new Module(callback.name, deps, callback, true);
} else {
- registry[id] = new Module(id, deps, callback, false);
+ registry[name] = new Module(name, deps, callback, false);
}
};
- define.exports = function (name, defaultExport) {
- var module = registry[name];
-
- // If a module for this name has already been defined and is in any state
- // other than `new` (meaning it has been or is currently being required),
- // then we return early to avoid redefinition.
- if (module && module.state !== 'new') {
- return;
- }
-
- module = new Module(name, [], noop, null);
- module.module.exports = defaultExport;
- module.state = 'finalized';
- registry[name] = module;
-
- return module;
- };
-
- function noop() {}
// we don't support all of AMD
// define.amd = {};
- function Alias(id) {
- this.id = id;
+ function Alias(path) {
+ this.name = path;
}
- define.alias = function (id, target) {
- if (arguments.length === 2) {
- return define(target, new Alias(id));
- }
-
- return new Alias(id);
+ define.alias = function (path) {
+ return new Alias(path);
};
- function missingModule(id, referrer) {
- throw new Error('Could not find module `' + id + '` imported from `' + referrer + '`');
+ function missingModule(name, referrer) {
+ throw new Error('Could not find module `' + name + '` imported from `' + referrer + '`');
}
- function findModule(id, referrer, pending) {
- var mod = registry[id] || registry[id + '/index'];
+ function findModule(name, referrer, pending) {
+ var mod = registry[name] || registry[name + '/index'];
while (mod && mod.isAlias) {
- mod = registry[mod.id];
+ mod = registry[mod.name];
}
if (!mod) {
- missingModule(id, referrer);
+ missingModule(name, referrer);
}
if (pending && mod.state !== 'pending' && mod.state !== 'finalized') {
mod.findDeps(pending);
pending.push(mod);
}
return mod;
}
- function resolve(child, id) {
+ function resolve(child, name) {
if (child.charAt(0) !== '.') {
return child;
}
-
var parts = child.split('/');
- var nameParts = id.split('/');
+ var nameParts = name.split('/');
var parentBase = nameParts.slice(0, -1);
for (var i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
@@ -302,18 +282,18 @@
}
return parentBase.join('/');
}
- function has(id) {
- return !!(registry[id] || registry[id + '/index']);
+ function has(name) {
+ return !!(registry[name] || registry[name + '/index']);
}
requirejs.entries = requirejs._eak_seen = registry;
requirejs.has = has;
- requirejs.unsee = function (id) {
- findModule(id, '(unsee)', false).unsee();
+ requirejs.unsee = function (moduleName) {
+ findModule(moduleName, '(unsee)', false).unsee();
};
requirejs.clear = function () {
requirejs.entries = requirejs._eak_seen = registry = dict();
seen = dict();
@@ -328,16 +308,13 @@
require('foo/bar');
}
});
define('foo/baz', [], define.alias('foo'));
define('foo/quz', define.alias('foo'));
- define.alias('foo', 'foo/qux');
define('foo/bar', ['foo', './quz', './baz', './asdf', './bar', '../foo'], function () {});
define('foo/main', ['foo/bar'], function () {});
- define.exports('foo/exports', {});
- require('foo/exports');
require('foo/main');
require.unsee('foo/bar');
requirejs.clear();
@@ -3064,19 +3041,37 @@
if (this._scheduledDestroy === null) {
this._scheduledDestroy = run.schedule('destroy', this, '_checkForOrphanedInternalModels');
}
};
+ InternalModel.prototype.hasScheduledDestroy = function hasScheduledDestroy() {
+ return !!this._scheduledDestroy;
+ };
+
InternalModel.prototype.cancelDestroy = function cancelDestroy() {
(false && _ember.default.assert('You cannot cancel the destruction of an InternalModel once it has already been destroyed', !this.isDestroyed));
this._isDematerializing = false;
run.cancel(this._scheduledDestroy);
this._scheduledDestroy = null;
};
+ InternalModel.prototype.destroySync = function destroySync() {
+ if (this._isDematerializing) {
+ this.cancelDestroy();
+ }
+ this._checkForOrphanedInternalModels();
+ if (this.isDestroyed || this.isDestroying) {
+ return;
+ }
+
+ // just in-case we are not one of the orphaned, we should still
+ // still destroy ourselves
+ this.destroy();
+ };
+
InternalModel.prototype._checkForOrphanedInternalModels = function _checkForOrphanedInternalModels() {
this._isDematerializing = false;
this._scheduledDestroy = null;
if (this.isDestroyed) {
return;
@@ -8408,16 +8403,17 @@
var inverseRelationshipData = {
data: {
id: id,
type: modelName
}
+ };
- // start flushing this individual payload. The logic is the same whether
- // it's for the left hand side of the relationship or the right hand side,
- // except the role of primary and inverse idToPayloads is reversed
- //
- };var previousPayload = void 0;
+ // start flushing this individual payload. The logic is the same whether
+ // it's for the left hand side of the relationship or the right hand side,
+ // except the role of primary and inverse idToPayloads is reversed
+ //
+ var previousPayload = void 0;
var idToPayloads = void 0;
var inverseIdToPayloads = void 0;
var inverseIsMany = void 0;
if (this._isLHS(modelName, relationshipName)) {
previousPayload = this._lhsPayloads[id];
@@ -9637,20 +9633,23 @@
}
this.willSync = true;
this.store._updateRelationshipState(this);
};
- Relationship.prototype.updateLink = function updateLink(link) {
+ Relationship.prototype.updateLink = function updateLink(link, initial) {
(false && _ember.default.warn('You pushed a record of type \'' + this.internalModel.modelName + '\' with a relationship \'' + this.key + '\' configured as \'async: false\'. You\'ve included a link but no primary data, this may be an error in your payload.', this.isAsync || this.hasData, {
id: 'ds.store.push-link-for-sync-relationship'
}));
(false && _ember.default.assert('You have pushed a record of type \'' + this.internalModel.modelName + '\' with \'' + this.key + '\' as a link, but the value of that link is not a string.', typeof link === 'string' || link === null));
this.link = link;
this.linkPromise = null;
- this.internalModel.notifyPropertyChange(this.key);
+
+ if (!initial) {
+ this.internalModel.notifyPropertyChange(this.key);
+ }
};
Relationship.prototype.findLink = function findLink() {
if (this.linkPromise) {
return this.linkPromise;
@@ -11099,19 +11098,20 @@
},
_internalModelForId: function (modelName, id) {
var trueId = (0, _coerceId.default)(id);
var internalModel = this._internalModelsFor(modelName).get(trueId);
- if (!internalModel) {
- internalModel = this._buildInternalModel(modelName, trueId);
+ if (internalModel) {
+ if (internalModel.hasScheduledDestroy()) {
+ internalModel.destroySync();
+ return this._buildInternalModel(modelName, trueId);
+ } else {
+ return internalModel;
+ }
} else {
- // if we already have an internalModel, we need to ensure any async teardown is cancelled
- // since we want it again.
- internalModel.cancelDestroy();
+ return this._buildInternalModel(modelName, trueId);
}
-
- return internalModel;
},
_internalModelDidReceiveRelationshipData: function (modelName, id, relationshipData) {
this._relationshipsPayloads.push(modelName, id, relationshipData);
},
_internalModelDestroyed: function (internalModel) {
@@ -12405,20 +12405,28 @@
*/
_buildInternalModel: function (modelName, id, data) {
(false && _ember.default.assert('You can no longer pass a modelClass as the first argument to store._buildInternalModel. Pass modelName instead.', typeof modelName === 'string'));
- var recordMap = this._internalModelsFor(modelName);
+ var internalModels = this._internalModelsFor(modelName);
+ var existingInternalModel = internalModels.get(id);
- (false && _ember.default.assert('The id ' + id + ' has already been used with another record for modelClass \'' + modelName + '\'.', !id || !recordMap.get(id)));
+ if (existingInternalModel && existingInternalModel.hasScheduledDestroy()) {
+ // unloadRecord is async, if one attempts to unload + then sync create,
+ // we must ensure the unload is complete before starting the create
+ existingInternalModel.destroySync();
+ existingInternalModel = null;
+ }
+ (false && _ember.default.assert('The id ' + id + ' has already been used with another record for modelClass \'' + modelName + '\'.', !existingInternalModel));
+
// lookupFactory should really return an object that creates
// instances with the injections applied
var internalModel = new _internalModel5.default(modelName, id, this, data);
- recordMap.add(internalModel, id);
+ internalModels.add(internalModel, id);
return internalModel;
},
buildInternalModel: function (modelName, id, data) {
(false && !(false) && _ember.default.deprecate('buildInternalModel was documented as private and will be removed in the next version of Ember Data.', false, { id: 'ember-data.buildInternalModel', until: '2.17.0' }));
@@ -12707,11 +12715,11 @@
var relationshipRequiresNotification = relationships.has(relationshipName) || isInverseRelationshipInitialized(store, internalModel, data, relationshipName, modelNameToInverseMap);
if (relationshipRequiresNotification) {
var relationshipData = data.relationships[relationshipName];
- relationships.get(relationshipName).push(relationshipData);
+ relationships.get(relationshipName).push(relationshipData, false);
}
// in debug, assert payload validity eagerly
if (false) {
var relationshipMeta = get(internalModel.type, 'relationshipsByName').get(relationshipName);
@@ -18403,10 +18411,10 @@
});
define("ember-data/version", ["exports"], function (exports) {
"use strict";
exports.__esModule = true;
- exports.default = "2.15.0-beta.3";
+ exports.default = "2.15.0-beta.4";
});
define("ember-inflector", ["module", "exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (module, exports, _ember, _system) {
"use strict";
exports.__esModule = true;