mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-24 17:43:45 +03:00
55933 lines
2.0 MiB
55933 lines
2.0 MiB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var core = require('../core');
|
|
var microtask = require('../microtask');
|
|
var browserPatch = require('../patch/browser');
|
|
var es6Promise = require('es6-promise');
|
|
|
|
if (global.Zone) {
|
|
console.warn('Zone already exported on window the object!');
|
|
}
|
|
|
|
global.Zone = microtask.addMicrotaskSupport(core.Zone);
|
|
global.zone = new global.Zone();
|
|
|
|
// Monkey patch the Promise implementation to add support for microtasks
|
|
global.Promise = es6Promise.Promise;
|
|
|
|
browserPatch.apply();
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../core":2,"../microtask":4,"../patch/browser":5,"es6-promise":17}],2:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var keys = require('./keys');
|
|
|
|
function Zone(parentZone, data) {
|
|
var zone = (arguments.length) ? Object.create(parentZone) : this;
|
|
|
|
zone.parent = parentZone || null;
|
|
|
|
Object.keys(data || {}).forEach(function(property) {
|
|
|
|
var _property = property.substr(1);
|
|
|
|
// augment the new zone with a hook decorates the parent's hook
|
|
if (property[0] === '$') {
|
|
zone[_property] = data[property](parentZone[_property] || function () {});
|
|
|
|
// augment the new zone with a hook that runs after the parent's hook
|
|
} else if (property[0] === '+') {
|
|
if (parentZone[_property]) {
|
|
zone[_property] = function () {
|
|
var result = parentZone[_property].apply(this, arguments);
|
|
data[property].apply(this, arguments);
|
|
return result;
|
|
};
|
|
} else {
|
|
zone[_property] = data[property];
|
|
}
|
|
|
|
// augment the new zone with a hook that runs before the parent's hook
|
|
} else if (property[0] === '-') {
|
|
if (parentZone[_property]) {
|
|
zone[_property] = function () {
|
|
data[property].apply(this, arguments);
|
|
return parentZone[_property].apply(this, arguments);
|
|
};
|
|
} else {
|
|
zone[_property] = data[property];
|
|
}
|
|
|
|
// set the new zone's hook (replacing the parent zone's)
|
|
} else {
|
|
zone[property] = (typeof data[property] === 'object') ?
|
|
JSON.parse(JSON.stringify(data[property])) :
|
|
data[property];
|
|
}
|
|
});
|
|
|
|
zone.$id = Zone.nextId++;
|
|
|
|
return zone;
|
|
}
|
|
|
|
Zone.prototype = {
|
|
constructor: Zone,
|
|
|
|
fork: function (locals) {
|
|
this.onZoneCreated();
|
|
return new Zone(this, locals);
|
|
},
|
|
|
|
bind: function (fn, skipEnqueue) {
|
|
if (typeof fn !== 'function') {
|
|
throw new Error('Expecting function got: ' + fn);
|
|
}
|
|
skipEnqueue || this.enqueueTask(fn);
|
|
var zone = this.isRootZone() ? this : this.fork();
|
|
return function zoneBoundFn() {
|
|
return zone.run(fn, this, arguments);
|
|
};
|
|
},
|
|
|
|
bindOnce: function (fn) {
|
|
var boundZone = this;
|
|
return this.bind(function () {
|
|
var result = fn.apply(this, arguments);
|
|
boundZone.dequeueTask(fn);
|
|
return result;
|
|
});
|
|
},
|
|
|
|
isRootZone: function() {
|
|
return this.parent === null;
|
|
},
|
|
|
|
run: function run (fn, applyTo, applyWith) {
|
|
applyWith = applyWith || [];
|
|
|
|
var oldZone = global.zone;
|
|
|
|
// MAKE THIS ZONE THE CURRENT ZONE
|
|
global.zone = this;
|
|
|
|
try {
|
|
this.beforeTask();
|
|
return fn.apply(applyTo, applyWith);
|
|
} catch (e) {
|
|
if (this.onError) {
|
|
this.onError(e);
|
|
} else {
|
|
throw e;
|
|
}
|
|
} finally {
|
|
this.afterTask();
|
|
// REVERT THE CURRENT ZONE BACK TO THE ORIGINAL ZONE
|
|
global.zone = oldZone;
|
|
}
|
|
},
|
|
|
|
// onError is used to override error handling.
|
|
// When a custom error handler is provided, it should most probably rethrow the exception
|
|
// not to break the expected control flow:
|
|
//
|
|
// `promise.then(fnThatThrows).catch(fn);`
|
|
//
|
|
// When this code is executed in a zone with a custom onError handler that doesn't rethrow, the
|
|
// `.catch()` branch will not be taken as the `fnThatThrows` exception will be swallowed by the
|
|
// handler.
|
|
onError: null,
|
|
beforeTask: function () {},
|
|
onZoneCreated: function () {},
|
|
afterTask: function () {},
|
|
enqueueTask: function () {},
|
|
dequeueTask: function () {},
|
|
addEventListener: function () {
|
|
return this[keys.common.addEventListener].apply(this, arguments);
|
|
},
|
|
removeEventListener: function () {
|
|
return this[keys.common.removeEventListener].apply(this, arguments);
|
|
}
|
|
};
|
|
|
|
// Root zone ID === 1
|
|
Zone.nextId = 1;
|
|
|
|
Zone.bindPromiseFn = require('./patch/promise').bindPromiseFn;
|
|
|
|
module.exports = {
|
|
Zone: Zone
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./keys":3,"./patch/promise":12}],3:[function(require,module,exports){
|
|
/**
|
|
* Creates keys for `private` properties on exposed objects to minimize interactions with other codebases.
|
|
*/
|
|
|
|
function create(name) {
|
|
// `Symbol` implementation is broken in Chrome 39.0.2171, do not use them even if they are available
|
|
return '_zone$' + name;
|
|
}
|
|
|
|
var commonKeys = {
|
|
addEventListener: create('addEventListener'),
|
|
removeEventListener: create('removeEventListener')
|
|
};
|
|
|
|
module.exports = {
|
|
create: create,
|
|
common: commonKeys
|
|
};
|
|
|
|
},{}],4:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
// TODO(vicb): Create a benchmark for the different methods & the usage of the queue
|
|
// see https://github.com/angular/zone.js/issues/97
|
|
|
|
// It is required to initialize hasNativePromise before requiring es6-promise otherwise es6-promise would
|
|
// overwrite the native Promise implementation on v8 and the check would always return false.
|
|
// see https://github.com/jakearchibald/es6-promise/issues/140
|
|
var hasNativePromise = typeof Promise !== "undefined" &&
|
|
Promise.toString().indexOf("[native code]") !== -1;
|
|
|
|
var isFirefox = global.navigator &&
|
|
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
|
|
var resolvedPromise;
|
|
|
|
// TODO(vicb): remove '!isFirefox' when the bug gets fixed:
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
|
|
if (hasNativePromise && !isFirefox) {
|
|
// When available use a native Promise to schedule microtasks.
|
|
// When not available, es6-promise fallback will be used
|
|
resolvedPromise = Promise.resolve();
|
|
}
|
|
|
|
var es6Promise = require('es6-promise').Promise;
|
|
|
|
if (resolvedPromise) {
|
|
es6Promise._setScheduler(function(fn) {
|
|
resolvedPromise.then(fn);
|
|
});
|
|
}
|
|
|
|
// es6-promise asap should schedule microtasks via zone.scheduleMicrotask so that any
|
|
// user defined hooks are triggered
|
|
es6Promise._setAsap(function(fn, arg) {
|
|
global.zone.scheduleMicrotask(function() {
|
|
fn(arg);
|
|
});
|
|
});
|
|
|
|
// The default implementation of scheduleMicrotask use the original es6-promise implementation
|
|
// to schedule a microtask
|
|
function scheduleMicrotask(fn) {
|
|
es6Promise._asap(this.bind(fn));
|
|
}
|
|
|
|
function addMicrotaskSupport(zoneClass) {
|
|
zoneClass.prototype.scheduleMicrotask = scheduleMicrotask;
|
|
return zoneClass;
|
|
}
|
|
|
|
module.exports = {
|
|
addMicrotaskSupport: addMicrotaskSupport
|
|
};
|
|
|
|
|
|
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"es6-promise":17}],5:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var fnPatch = require('./functions');
|
|
var promisePatch = require('./promise');
|
|
var mutationObserverPatch = require('./mutation-observer');
|
|
var definePropertyPatch = require('./define-property');
|
|
var registerElementPatch = require('./register-element');
|
|
var webSocketPatch = require('./websocket');
|
|
var eventTargetPatch = require('./event-target');
|
|
var propertyDescriptorPatch = require('./property-descriptor');
|
|
var geolocationPatch = require('./geolocation');
|
|
var fileReaderPatch = require('./file-reader');
|
|
|
|
function apply() {
|
|
fnPatch.patchSetClearFunction(global, [
|
|
'timeout',
|
|
'interval',
|
|
'immediate'
|
|
]);
|
|
|
|
fnPatch.patchRequestAnimationFrame(global, [
|
|
'requestAnimationFrame',
|
|
'mozRequestAnimationFrame',
|
|
'webkitRequestAnimationFrame'
|
|
]);
|
|
|
|
fnPatch.patchFunction(global, [
|
|
'alert',
|
|
'prompt'
|
|
]);
|
|
|
|
eventTargetPatch.apply();
|
|
|
|
propertyDescriptorPatch.apply();
|
|
|
|
promisePatch.apply();
|
|
|
|
mutationObserverPatch.patchClass('MutationObserver');
|
|
mutationObserverPatch.patchClass('WebKitMutationObserver');
|
|
|
|
definePropertyPatch.apply();
|
|
|
|
registerElementPatch.apply();
|
|
|
|
geolocationPatch.apply();
|
|
|
|
fileReaderPatch.apply();
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./define-property":6,"./event-target":7,"./file-reader":8,"./functions":9,"./geolocation":10,"./mutation-observer":11,"./promise":12,"./property-descriptor":13,"./register-element":14,"./websocket":15}],6:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var keys = require('../keys');
|
|
|
|
// might need similar for object.freeze
|
|
// i regret nothing
|
|
|
|
var _defineProperty = Object.defineProperty;
|
|
var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
var _create = Object.create;
|
|
var unconfigurablesKey = keys.create('unconfigurables');
|
|
|
|
function apply() {
|
|
Object.defineProperty = function (obj, prop, desc) {
|
|
if (isUnconfigurable(obj, prop)) {
|
|
throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj);
|
|
}
|
|
if (prop !== 'prototype') {
|
|
desc = rewriteDescriptor(obj, prop, desc);
|
|
}
|
|
return _defineProperty(obj, prop, desc);
|
|
};
|
|
|
|
Object.defineProperties = function (obj, props) {
|
|
Object.keys(props).forEach(function (prop) {
|
|
Object.defineProperty(obj, prop, props[prop]);
|
|
});
|
|
return obj;
|
|
};
|
|
|
|
Object.create = function (obj, proto) {
|
|
if (typeof proto === 'object') {
|
|
Object.keys(proto).forEach(function (prop) {
|
|
proto[prop] = rewriteDescriptor(obj, prop, proto[prop]);
|
|
});
|
|
}
|
|
return _create(obj, proto);
|
|
};
|
|
|
|
Object.getOwnPropertyDescriptor = function (obj, prop) {
|
|
var desc = _getOwnPropertyDescriptor(obj, prop);
|
|
if (isUnconfigurable(obj, prop)) {
|
|
desc.configurable = false;
|
|
}
|
|
return desc;
|
|
};
|
|
};
|
|
|
|
function _redefineProperty(obj, prop, desc) {
|
|
desc = rewriteDescriptor(obj, prop, desc);
|
|
return _defineProperty(obj, prop, desc);
|
|
};
|
|
|
|
function isUnconfigurable (obj, prop) {
|
|
return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop];
|
|
}
|
|
|
|
function rewriteDescriptor (obj, prop, desc) {
|
|
desc.configurable = true;
|
|
if (!desc.configurable) {
|
|
if (!obj[unconfigurablesKey]) {
|
|
_defineProperty(obj, unconfigurablesKey, { writable: true, value: {} });
|
|
}
|
|
obj[unconfigurablesKey][prop] = true;
|
|
}
|
|
return desc;
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply,
|
|
_redefineProperty: _redefineProperty
|
|
};
|
|
|
|
|
|
|
|
},{"../keys":3}],7:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
function apply() {
|
|
// patched properties depend on addEventListener, so this needs to come first
|
|
if (global.EventTarget) {
|
|
utils.patchEventTargetMethods(global.EventTarget.prototype);
|
|
|
|
// Note: EventTarget is not available in all browsers,
|
|
// if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget
|
|
} else {
|
|
var apis = [
|
|
'ApplicationCache',
|
|
'EventSource',
|
|
'FileReader',
|
|
'InputMethodContext',
|
|
'MediaController',
|
|
'MessagePort',
|
|
'Node',
|
|
'Performance',
|
|
'SVGElementInstance',
|
|
'SharedWorker',
|
|
'TextTrack',
|
|
'TextTrackCue',
|
|
'TextTrackList',
|
|
'WebKitNamedFlow',
|
|
'Worker',
|
|
'WorkerGlobalScope',
|
|
'XMLHttpRequest',
|
|
'XMLHttpRequestEventTarget',
|
|
'XMLHttpRequestUpload'
|
|
];
|
|
|
|
apis.forEach(function(api) {
|
|
var proto = global[api] && global[api].prototype;
|
|
|
|
// Some browsers e.g. Android 4.3's don't actually implement
|
|
// the EventTarget methods for all of these e.g. FileReader.
|
|
// In this case, there is nothing to patch.
|
|
if (proto && proto.addEventListener) {
|
|
utils.patchEventTargetMethods(proto);
|
|
}
|
|
});
|
|
|
|
// Patch the methods on `window` instead of `Window.prototype`
|
|
// `Window` is not accessible on Android 4.3
|
|
if (typeof(window) !== 'undefined') {
|
|
utils.patchEventTargetMethods(window);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16}],8:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
function apply() {
|
|
utils.patchClass('FileReader');
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
},{"../utils":16}],9:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
function patchSetClearFunction(obj, fnNames) {
|
|
fnNames.map(function (name) {
|
|
return name[0].toUpperCase() + name.substr(1);
|
|
}).forEach(function (name) {
|
|
var setName = 'set' + name;
|
|
var delegate = obj[setName];
|
|
|
|
if (delegate) {
|
|
var clearName = 'clear' + name;
|
|
var ids = {};
|
|
|
|
var bindArgs = setName === 'setInterval' ? utils.bindArguments : utils.bindArgumentsOnce;
|
|
|
|
global.zone[setName] = function (fn) {
|
|
var id, fnRef = fn;
|
|
arguments[0] = function () {
|
|
delete ids[id];
|
|
return fnRef.apply(this, arguments);
|
|
};
|
|
var args = bindArgs(arguments);
|
|
id = delegate.apply(obj, args);
|
|
ids[id] = true;
|
|
return id;
|
|
};
|
|
|
|
obj[setName] = function () {
|
|
return global.zone[setName].apply(this, arguments);
|
|
};
|
|
|
|
var clearDelegate = obj[clearName];
|
|
|
|
global.zone[clearName] = function (id) {
|
|
if (ids[id]) {
|
|
delete ids[id];
|
|
global.zone.dequeueTask();
|
|
}
|
|
return clearDelegate.apply(this, arguments);
|
|
};
|
|
|
|
obj[clearName] = function () {
|
|
return global.zone[clearName].apply(this, arguments);
|
|
};
|
|
}
|
|
});
|
|
};
|
|
|
|
|
|
/**
|
|
* requestAnimationFrame is typically recursively called from within the callback function
|
|
* that it executes. To handle this case, only fork a zone if this is executed
|
|
* within the root zone.
|
|
*/
|
|
function patchRequestAnimationFrame(obj, fnNames) {
|
|
fnNames.forEach(function (name) {
|
|
var delegate = obj[name];
|
|
if (delegate) {
|
|
global.zone[name] = function (fn) {
|
|
var callZone = global.zone.isRootZone() ? global.zone.fork() : global.zone;
|
|
if (fn) {
|
|
arguments[0] = function () {
|
|
return callZone.run(fn, this, arguments);
|
|
};
|
|
}
|
|
return delegate.apply(obj, arguments);
|
|
};
|
|
|
|
obj[name] = function () {
|
|
return global.zone[name].apply(this, arguments);
|
|
};
|
|
}
|
|
});
|
|
};
|
|
|
|
function patchSetFunction(obj, fnNames) {
|
|
fnNames.forEach(function (name) {
|
|
var delegate = obj[name];
|
|
|
|
if (delegate) {
|
|
global.zone[name] = function (fn) {
|
|
arguments[0] = function () {
|
|
return fn.apply(this, arguments);
|
|
};
|
|
var args = utils.bindArgumentsOnce(arguments);
|
|
return delegate.apply(obj, args);
|
|
};
|
|
|
|
obj[name] = function () {
|
|
return zone[name].apply(this, arguments);
|
|
};
|
|
}
|
|
});
|
|
};
|
|
|
|
function patchFunction(obj, fnNames) {
|
|
fnNames.forEach(function (name) {
|
|
var delegate = obj[name];
|
|
global.zone[name] = function () {
|
|
return delegate.apply(obj, arguments);
|
|
};
|
|
|
|
obj[name] = function () {
|
|
return global.zone[name].apply(this, arguments);
|
|
};
|
|
});
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
patchSetClearFunction: patchSetClearFunction,
|
|
patchSetFunction: patchSetFunction,
|
|
patchRequestAnimationFrame: patchRequestAnimationFrame,
|
|
patchFunction: patchFunction
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16}],10:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
function apply() {
|
|
if (global.navigator && global.navigator.geolocation) {
|
|
utils.patchPrototype(global.navigator.geolocation, [
|
|
'getCurrentPosition',
|
|
'watchPosition'
|
|
]);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
}
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16}],11:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var keys = require('../keys');
|
|
|
|
var originalInstanceKey = keys.create('originalInstance');
|
|
var creationZoneKey = keys.create('creationZone');
|
|
var isActiveKey = keys.create('isActive');
|
|
|
|
// wrap some native API on `window`
|
|
function patchClass(className) {
|
|
var OriginalClass = global[className];
|
|
if (!OriginalClass) return;
|
|
|
|
global[className] = function (fn) {
|
|
this[originalInstanceKey] = new OriginalClass(global.zone.bind(fn, true));
|
|
// Remember where the class was instantiate to execute the enqueueTask and dequeueTask hooks
|
|
this[creationZoneKey] = global.zone;
|
|
};
|
|
|
|
var instance = new OriginalClass(function () {});
|
|
|
|
global[className].prototype.disconnect = function () {
|
|
var result = this[originalInstanceKey].disconnect.apply(this[originalInstanceKey], arguments);
|
|
if (this[isActiveKey]) {
|
|
this[creationZoneKey].dequeueTask();
|
|
this[isActiveKey] = false;
|
|
}
|
|
return result;
|
|
};
|
|
|
|
global[className].prototype.observe = function () {
|
|
if (!this[isActiveKey]) {
|
|
this[creationZoneKey].enqueueTask();
|
|
this[isActiveKey] = true;
|
|
}
|
|
return this[originalInstanceKey].observe.apply(this[originalInstanceKey], arguments);
|
|
};
|
|
|
|
var prop;
|
|
for (prop in instance) {
|
|
(function (prop) {
|
|
if (typeof global[className].prototype !== 'undefined') {
|
|
return;
|
|
}
|
|
if (typeof instance[prop] === 'function') {
|
|
global[className].prototype[prop] = function () {
|
|
return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
|
|
};
|
|
} else {
|
|
Object.defineProperty(global[className].prototype, prop, {
|
|
set: function (fn) {
|
|
if (typeof fn === 'function') {
|
|
this[originalInstanceKey][prop] = global.zone.bind(fn);
|
|
} else {
|
|
this[originalInstanceKey][prop] = fn;
|
|
}
|
|
},
|
|
get: function () {
|
|
return this[originalInstanceKey][prop];
|
|
}
|
|
});
|
|
}
|
|
}(prop));
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
patchClass: patchClass
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../keys":3}],12:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
/*
|
|
* Patches a function that returns a Promise-like instance.
|
|
*
|
|
* This function must be used when either:
|
|
* - Native Promises are not available,
|
|
* - The function returns a Promise-like object.
|
|
*
|
|
* This is required because zones rely on a Promise monkey patch that could not be applied when
|
|
* Promise is not natively available or when the returned object is not an instance of Promise.
|
|
*
|
|
* Note that calling `bindPromiseFn` on a function that returns a native Promise will also work
|
|
* with minimal overhead.
|
|
*
|
|
* ```
|
|
* var boundFunction = bindPromiseFn(FunctionReturningAPromise);
|
|
*
|
|
* boundFunction.then(successHandler, errorHandler);
|
|
* ```
|
|
*/
|
|
var bindPromiseFn;
|
|
|
|
if (global.Promise) {
|
|
bindPromiseFn = function (delegate) {
|
|
return function() {
|
|
var delegatePromise = delegate.apply(this, arguments);
|
|
|
|
// if the delegate returned an instance of Promise, forward it.
|
|
if (delegatePromise instanceof Promise) {
|
|
return delegatePromise;
|
|
}
|
|
|
|
// Otherwise wrap the Promise-like in a global Promise
|
|
return new Promise(function(resolve, reject) {
|
|
delegatePromise.then(resolve, reject);
|
|
});
|
|
};
|
|
};
|
|
} else {
|
|
bindPromiseFn = function (delegate) {
|
|
return function () {
|
|
return _patchThenable(delegate.apply(this, arguments));
|
|
};
|
|
};
|
|
}
|
|
|
|
|
|
function _patchPromiseFnsOnObject(objectPath, fnNames) {
|
|
var obj = global;
|
|
|
|
var exists = objectPath.every(function (segment) {
|
|
obj = obj[segment];
|
|
return obj;
|
|
});
|
|
|
|
if (!exists) {
|
|
return;
|
|
}
|
|
|
|
fnNames.forEach(function (name) {
|
|
var fn = obj[name];
|
|
if (fn) {
|
|
obj[name] = bindPromiseFn(fn);
|
|
}
|
|
});
|
|
}
|
|
|
|
function _patchThenable(thenable) {
|
|
var then = thenable.then;
|
|
thenable.then = function () {
|
|
var args = utils.bindArguments(arguments);
|
|
var nextThenable = then.apply(thenable, args);
|
|
return _patchThenable(nextThenable);
|
|
};
|
|
|
|
var ocatch = thenable.catch;
|
|
thenable.catch = function () {
|
|
var args = utils.bindArguments(arguments);
|
|
var nextThenable = ocatch.apply(thenable, args);
|
|
return _patchThenable(nextThenable);
|
|
};
|
|
|
|
return thenable;
|
|
}
|
|
|
|
|
|
function apply() {
|
|
// Patch .then() and .catch() on native Promises to execute callbacks in the zone where
|
|
// those functions are called.
|
|
if (global.Promise) {
|
|
utils.patchPrototype(Promise.prototype, [
|
|
'then',
|
|
'catch'
|
|
]);
|
|
|
|
// Patch browser APIs that return a Promise
|
|
var patchFns = [
|
|
// fetch
|
|
[[], ['fetch']],
|
|
[['Response', 'prototype'], ['arrayBuffer', 'blob', 'json', 'text']]
|
|
];
|
|
|
|
patchFns.forEach(function(objPathAndFns) {
|
|
_patchPromiseFnsOnObject(objPathAndFns[0], objPathAndFns[1]);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply,
|
|
bindPromiseFn: bindPromiseFn
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16}],13:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var webSocketPatch = require('./websocket');
|
|
var utils = require('../utils');
|
|
var keys = require('../keys');
|
|
|
|
var eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'.split(' ');
|
|
|
|
function apply() {
|
|
if (utils.isWebWorker()){
|
|
// on WebWorker so don't apply patch
|
|
return;
|
|
}
|
|
|
|
var supportsWebSocket = typeof WebSocket !== 'undefined';
|
|
if (canPatchViaPropertyDescriptor()) {
|
|
// for browsers that we can patch the descriptor: Chrome & Firefox
|
|
var onEventNames = eventNames.map(function (property) {
|
|
return 'on' + property;
|
|
});
|
|
utils.patchProperties(HTMLElement.prototype, onEventNames);
|
|
utils.patchProperties(XMLHttpRequest.prototype);
|
|
if (supportsWebSocket) {
|
|
utils.patchProperties(WebSocket.prototype);
|
|
}
|
|
} else {
|
|
// Safari, Android browsers (Jelly Bean)
|
|
patchViaCapturingAllTheEvents();
|
|
utils.patchClass('XMLHttpRequest');
|
|
if (supportsWebSocket) {
|
|
webSocketPatch.apply();
|
|
}
|
|
}
|
|
}
|
|
|
|
function canPatchViaPropertyDescriptor() {
|
|
if (!Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') {
|
|
// WebKit https://bugs.webkit.org/show_bug.cgi?id=134364
|
|
// IDL interface attributes are not configurable
|
|
var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick');
|
|
if (desc && !desc.configurable) return false;
|
|
}
|
|
|
|
Object.defineProperty(HTMLElement.prototype, 'onclick', {
|
|
get: function () {
|
|
return true;
|
|
}
|
|
});
|
|
var elt = document.createElement('div');
|
|
var result = !!elt.onclick;
|
|
Object.defineProperty(HTMLElement.prototype, 'onclick', {});
|
|
return result;
|
|
};
|
|
|
|
var unboundKey = keys.create('unbound');
|
|
|
|
// Whenever any event fires, we check the event target and all parents
|
|
// for `onwhatever` properties and replace them with zone-bound functions
|
|
// - Chrome (for now)
|
|
function patchViaCapturingAllTheEvents() {
|
|
eventNames.forEach(function (property) {
|
|
var onproperty = 'on' + property;
|
|
document.addEventListener(property, function (event) {
|
|
var elt = event.target, bound;
|
|
while (elt) {
|
|
if (elt[onproperty] && !elt[onproperty][unboundKey]) {
|
|
bound = global.zone.bind(elt[onproperty]);
|
|
bound[unboundKey] = elt[onproperty];
|
|
elt[onproperty] = bound;
|
|
}
|
|
elt = elt.parentElement;
|
|
}
|
|
}, true);
|
|
});
|
|
};
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../keys":3,"../utils":16,"./websocket":15}],14:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var _redefineProperty = require('./define-property')._redefineProperty;
|
|
var utils = require("../utils");
|
|
|
|
function apply() {
|
|
if (utils.isWebWorker() || !('registerElement' in global.document)) {
|
|
return;
|
|
}
|
|
|
|
var _registerElement = document.registerElement;
|
|
var callbacks = [
|
|
'createdCallback',
|
|
'attachedCallback',
|
|
'detachedCallback',
|
|
'attributeChangedCallback'
|
|
];
|
|
|
|
document.registerElement = function (name, opts) {
|
|
if (opts && opts.prototype) {
|
|
callbacks.forEach(function (callback) {
|
|
if (opts.prototype.hasOwnProperty(callback)) {
|
|
var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback);
|
|
if (descriptor && descriptor.value) {
|
|
descriptor.value = global.zone.bind(descriptor.value);
|
|
_redefineProperty(opts.prototype, callback, descriptor);
|
|
} else {
|
|
opts.prototype[callback] = global.zone.bind(opts.prototype[callback]);
|
|
}
|
|
} else if (opts.prototype[callback]) {
|
|
opts.prototype[callback] = global.zone.bind(opts.prototype[callback]);
|
|
}
|
|
});
|
|
}
|
|
|
|
return _registerElement.apply(document, [name, opts]);
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16,"./define-property":6}],15:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var utils = require('../utils');
|
|
|
|
// we have to patch the instance since the proto is non-configurable
|
|
function apply() {
|
|
var WS = global.WebSocket;
|
|
utils.patchEventTargetMethods(WS.prototype);
|
|
global.WebSocket = function(a, b) {
|
|
var socket = arguments.length > 1 ? new WS(a, b) : new WS(a);
|
|
var proxySocket;
|
|
|
|
// Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance
|
|
var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage');
|
|
if (onmessageDesc && onmessageDesc.configurable === false) {
|
|
proxySocket = Object.create(socket);
|
|
['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function(propName) {
|
|
proxySocket[propName] = function() {
|
|
return socket[propName].apply(socket, arguments);
|
|
};
|
|
});
|
|
} else {
|
|
// we can patch the real socket
|
|
proxySocket = socket;
|
|
}
|
|
|
|
utils.patchProperties(proxySocket, ['onclose', 'onerror', 'onmessage', 'onopen']);
|
|
|
|
return proxySocket;
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
apply: apply
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../utils":16}],16:[function(require,module,exports){
|
|
(function (global){
|
|
'use strict';
|
|
|
|
var keys = require('./keys');
|
|
|
|
function bindArguments(args) {
|
|
for (var i = args.length - 1; i >= 0; i--) {
|
|
if (typeof args[i] === 'function') {
|
|
args[i] = global.zone.bind(args[i]);
|
|
}
|
|
}
|
|
return args;
|
|
};
|
|
|
|
function bindArgumentsOnce(args) {
|
|
for (var i = args.length - 1; i >= 0; i--) {
|
|
if (typeof args[i] === 'function') {
|
|
args[i] = global.zone.bindOnce(args[i]);
|
|
}
|
|
}
|
|
return args;
|
|
};
|
|
|
|
function patchPrototype(obj, fnNames) {
|
|
fnNames.forEach(function (name) {
|
|
var delegate = obj[name];
|
|
if (delegate) {
|
|
obj[name] = function () {
|
|
return delegate.apply(this, bindArguments(arguments));
|
|
};
|
|
}
|
|
});
|
|
};
|
|
|
|
function isWebWorker() {
|
|
return (typeof document === "undefined");
|
|
}
|
|
|
|
function patchProperty(obj, prop) {
|
|
var desc = Object.getOwnPropertyDescriptor(obj, prop) || {
|
|
enumerable: true,
|
|
configurable: true
|
|
};
|
|
|
|
// A property descriptor cannot have getter/setter and be writable
|
|
// deleting the writable and value properties avoids this error:
|
|
//
|
|
// TypeError: property descriptors must not specify a value or be writable when a
|
|
// getter or setter has been specified
|
|
delete desc.writable;
|
|
delete desc.value;
|
|
|
|
// substr(2) cuz 'onclick' -> 'click', etc
|
|
var eventName = prop.substr(2);
|
|
var _prop = '_' + prop;
|
|
|
|
desc.set = function (fn) {
|
|
if (this[_prop]) {
|
|
this.removeEventListener(eventName, this[_prop]);
|
|
}
|
|
|
|
if (typeof fn === 'function') {
|
|
this[_prop] = fn;
|
|
this.addEventListener(eventName, fn, false);
|
|
} else {
|
|
this[_prop] = null;
|
|
}
|
|
};
|
|
|
|
desc.get = function () {
|
|
return this[_prop];
|
|
};
|
|
|
|
Object.defineProperty(obj, prop, desc);
|
|
};
|
|
|
|
function patchProperties(obj, properties) {
|
|
(properties || (function () {
|
|
var props = [];
|
|
for (var prop in obj) {
|
|
props.push(prop);
|
|
}
|
|
return props;
|
|
}()).
|
|
filter(function (propertyName) {
|
|
return propertyName.substr(0,2) === 'on';
|
|
})).
|
|
forEach(function (eventName) {
|
|
patchProperty(obj, eventName);
|
|
});
|
|
};
|
|
|
|
var originalFnKey = keys.create('originalFn');
|
|
var boundFnsKey = keys.create('boundFns');
|
|
|
|
function patchEventTargetMethods(obj) {
|
|
// This is required for the addEventListener hook on the root zone.
|
|
obj[keys.common.addEventListener] = obj.addEventListener;
|
|
obj.addEventListener = function (eventName, handler, useCapturing) {
|
|
//Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
|
|
if (handler && handler.toString() !== "[object FunctionWrapper]") {
|
|
var eventType = eventName + (useCapturing ? '$capturing' : '$bubbling');
|
|
var fn;
|
|
if (handler.handleEvent) {
|
|
// Have to pass in 'handler' reference as an argument here, otherwise it gets clobbered in
|
|
// IE9 by the arguments[1] assignment at end of this function.
|
|
fn = (function(handler) {
|
|
return function() {
|
|
handler.handleEvent.apply(handler, arguments);
|
|
};
|
|
})(handler);
|
|
} else {
|
|
fn = handler;
|
|
}
|
|
|
|
handler[originalFnKey] = fn;
|
|
handler[boundFnsKey] = handler[boundFnsKey] || {};
|
|
handler[boundFnsKey][eventType] = handler[boundFnsKey][eventType] || zone.bind(fn);
|
|
arguments[1] = handler[boundFnsKey][eventType];
|
|
}
|
|
|
|
// - Inside a Web Worker, `this` is undefined, the context is `global` (= `self`)
|
|
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined
|
|
// see https://github.com/angular/zone.js/issues/190
|
|
var target = this || global;
|
|
return global.zone.addEventListener.apply(target, arguments);
|
|
};
|
|
|
|
// This is required for the removeEventListener hook on the root zone.
|
|
obj[keys.common.removeEventListener] = obj.removeEventListener;
|
|
obj.removeEventListener = function (eventName, handler, useCapturing) {
|
|
var eventType = eventName + (useCapturing ? '$capturing' : '$bubbling');
|
|
if (handler && handler[boundFnsKey] && handler[boundFnsKey][eventType]) {
|
|
var _bound = handler[boundFnsKey];
|
|
arguments[1] = _bound[eventType];
|
|
delete _bound[eventType];
|
|
global.zone.dequeueTask(handler[originalFnKey]);
|
|
}
|
|
|
|
// - Inside a Web Worker, `this` is undefined, the context is `global`
|
|
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined
|
|
// see https://github.com/angular/zone.js/issues/190
|
|
var target = this || global;
|
|
var result = global.zone.removeEventListener.apply(target, arguments);
|
|
return result;
|
|
};
|
|
};
|
|
|
|
var originalInstanceKey = keys.create('originalInstance');
|
|
|
|
// wrap some native API on `window`
|
|
function patchClass(className) {
|
|
var OriginalClass = global[className];
|
|
if (!OriginalClass) return;
|
|
|
|
global[className] = function () {
|
|
var a = bindArguments(arguments);
|
|
switch (a.length) {
|
|
case 0: this[originalInstanceKey] = new OriginalClass(); break;
|
|
case 1: this[originalInstanceKey] = new OriginalClass(a[0]); break;
|
|
case 2: this[originalInstanceKey] = new OriginalClass(a[0], a[1]); break;
|
|
case 3: this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); break;
|
|
case 4: this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); break;
|
|
default: throw new Error('what are you even doing?');
|
|
}
|
|
};
|
|
|
|
var instance = new OriginalClass();
|
|
|
|
var prop;
|
|
for (prop in instance) {
|
|
(function (prop) {
|
|
if (typeof instance[prop] === 'function') {
|
|
global[className].prototype[prop] = function () {
|
|
return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
|
|
};
|
|
} else {
|
|
Object.defineProperty(global[className].prototype, prop, {
|
|
set: function (fn) {
|
|
if (typeof fn === 'function') {
|
|
this[originalInstanceKey][prop] = global.zone.bind(fn);
|
|
} else {
|
|
this[originalInstanceKey][prop] = fn;
|
|
}
|
|
},
|
|
get: function () {
|
|
return this[originalInstanceKey][prop];
|
|
}
|
|
});
|
|
}
|
|
}(prop));
|
|
}
|
|
|
|
for (prop in OriginalClass) {
|
|
if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) {
|
|
global[className][prop] = OriginalClass[prop];
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
bindArguments: bindArguments,
|
|
bindArgumentsOnce: bindArgumentsOnce,
|
|
patchPrototype: patchPrototype,
|
|
patchProperty: patchProperty,
|
|
patchProperties: patchProperties,
|
|
patchEventTargetMethods: patchEventTargetMethods,
|
|
patchClass: patchClass,
|
|
isWebWorker: isWebWorker
|
|
};
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"./keys":3}],17:[function(require,module,exports){
|
|
(function (process,global){
|
|
/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
|
|
* @version 3.0.2
|
|
*/
|
|
|
|
(function() {
|
|
"use strict";
|
|
function lib$es6$promise$utils$$objectOrFunction(x) {
|
|
return typeof x === 'function' || (typeof x === 'object' && x !== null);
|
|
}
|
|
|
|
function lib$es6$promise$utils$$isFunction(x) {
|
|
return typeof x === 'function';
|
|
}
|
|
|
|
function lib$es6$promise$utils$$isMaybeThenable(x) {
|
|
return typeof x === 'object' && x !== null;
|
|
}
|
|
|
|
var lib$es6$promise$utils$$_isArray;
|
|
if (!Array.isArray) {
|
|
lib$es6$promise$utils$$_isArray = function (x) {
|
|
return Object.prototype.toString.call(x) === '[object Array]';
|
|
};
|
|
} else {
|
|
lib$es6$promise$utils$$_isArray = Array.isArray;
|
|
}
|
|
|
|
var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
|
|
var lib$es6$promise$asap$$len = 0;
|
|
var lib$es6$promise$asap$$toString = {}.toString;
|
|
var lib$es6$promise$asap$$vertxNext;
|
|
var lib$es6$promise$asap$$customSchedulerFn;
|
|
|
|
var lib$es6$promise$asap$$asap = function asap(callback, arg) {
|
|
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
|
|
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
|
|
lib$es6$promise$asap$$len += 2;
|
|
if (lib$es6$promise$asap$$len === 2) {
|
|
// If len is 2, that means that we need to schedule an async flush.
|
|
// If additional callbacks are queued before the queue is flushed, they
|
|
// will be processed by this flush that we are scheduling.
|
|
if (lib$es6$promise$asap$$customSchedulerFn) {
|
|
lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
|
|
} else {
|
|
lib$es6$promise$asap$$scheduleFlush();
|
|
}
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$asap$$setScheduler(scheduleFn) {
|
|
lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
|
|
}
|
|
|
|
function lib$es6$promise$asap$$setAsap(asapFn) {
|
|
lib$es6$promise$asap$$asap = asapFn;
|
|
}
|
|
|
|
var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
|
|
var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
|
|
var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
|
|
var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
|
|
|
|
// test for web worker but not in IE10
|
|
var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
|
|
typeof importScripts !== 'undefined' &&
|
|
typeof MessageChannel !== 'undefined';
|
|
|
|
// node
|
|
function lib$es6$promise$asap$$useNextTick() {
|
|
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
|
|
// see https://github.com/cujojs/when/issues/410 for details
|
|
return function() {
|
|
process.nextTick(lib$es6$promise$asap$$flush);
|
|
};
|
|
}
|
|
|
|
// vertx
|
|
function lib$es6$promise$asap$$useVertxTimer() {
|
|
return function() {
|
|
lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
|
|
};
|
|
}
|
|
|
|
function lib$es6$promise$asap$$useMutationObserver() {
|
|
var iterations = 0;
|
|
var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
|
|
var node = document.createTextNode('');
|
|
observer.observe(node, { characterData: true });
|
|
|
|
return function() {
|
|
node.data = (iterations = ++iterations % 2);
|
|
};
|
|
}
|
|
|
|
// web worker
|
|
function lib$es6$promise$asap$$useMessageChannel() {
|
|
var channel = new MessageChannel();
|
|
channel.port1.onmessage = lib$es6$promise$asap$$flush;
|
|
return function () {
|
|
channel.port2.postMessage(0);
|
|
};
|
|
}
|
|
|
|
function lib$es6$promise$asap$$useSetTimeout() {
|
|
return function() {
|
|
setTimeout(lib$es6$promise$asap$$flush, 1);
|
|
};
|
|
}
|
|
|
|
var lib$es6$promise$asap$$queue = new Array(1000);
|
|
function lib$es6$promise$asap$$flush() {
|
|
for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
|
|
var callback = lib$es6$promise$asap$$queue[i];
|
|
var arg = lib$es6$promise$asap$$queue[i+1];
|
|
|
|
callback(arg);
|
|
|
|
lib$es6$promise$asap$$queue[i] = undefined;
|
|
lib$es6$promise$asap$$queue[i+1] = undefined;
|
|
}
|
|
|
|
lib$es6$promise$asap$$len = 0;
|
|
}
|
|
|
|
function lib$es6$promise$asap$$attemptVertx() {
|
|
try {
|
|
var r = require;
|
|
var vertx = r('vertx');
|
|
lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
|
|
return lib$es6$promise$asap$$useVertxTimer();
|
|
} catch(e) {
|
|
return lib$es6$promise$asap$$useSetTimeout();
|
|
}
|
|
}
|
|
|
|
var lib$es6$promise$asap$$scheduleFlush;
|
|
// Decide what async method to use to triggering processing of queued callbacks:
|
|
if (lib$es6$promise$asap$$isNode) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
|
|
} else if (lib$es6$promise$asap$$BrowserMutationObserver) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
|
|
} else if (lib$es6$promise$asap$$isWorker) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
|
|
} else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
|
|
} else {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$noop() {}
|
|
|
|
var lib$es6$promise$$internal$$PENDING = void 0;
|
|
var lib$es6$promise$$internal$$FULFILLED = 1;
|
|
var lib$es6$promise$$internal$$REJECTED = 2;
|
|
|
|
var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
|
|
|
|
function lib$es6$promise$$internal$$selfFulfillment() {
|
|
return new TypeError("You cannot resolve a promise with itself");
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$cannotReturnOwn() {
|
|
return new TypeError('A promises callback cannot return that same promise.');
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$getThen(promise) {
|
|
try {
|
|
return promise.then;
|
|
} catch(error) {
|
|
lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
|
|
return lib$es6$promise$$internal$$GET_THEN_ERROR;
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
|
|
try {
|
|
then.call(value, fulfillmentHandler, rejectionHandler);
|
|
} catch(e) {
|
|
return e;
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
|
|
lib$es6$promise$asap$$asap(function(promise) {
|
|
var sealed = false;
|
|
var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
|
|
if (sealed) { return; }
|
|
sealed = true;
|
|
if (thenable !== value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
}
|
|
}, function(reason) {
|
|
if (sealed) { return; }
|
|
sealed = true;
|
|
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
}, 'Settle: ' + (promise._label || ' unknown promise'));
|
|
|
|
if (!sealed && error) {
|
|
sealed = true;
|
|
lib$es6$promise$$internal$$reject(promise, error);
|
|
}
|
|
}, promise);
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
|
|
if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
|
|
lib$es6$promise$$internal$$fulfill(promise, thenable._result);
|
|
} else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, thenable._result);
|
|
} else {
|
|
lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}, function(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
});
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
|
|
if (maybeThenable.constructor === promise.constructor) {
|
|
lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
|
|
} else {
|
|
var then = lib$es6$promise$$internal$$getThen(maybeThenable);
|
|
|
|
if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
|
|
} else if (then === undefined) {
|
|
lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
|
|
} else if (lib$es6$promise$utils$$isFunction(then)) {
|
|
lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
|
|
}
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$resolve(promise, value) {
|
|
if (promise === value) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
|
|
} else if (lib$es6$promise$utils$$objectOrFunction(value)) {
|
|
lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$publishRejection(promise) {
|
|
if (promise._onerror) {
|
|
promise._onerror(promise._result);
|
|
}
|
|
|
|
lib$es6$promise$$internal$$publish(promise);
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$fulfill(promise, value) {
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
|
|
|
|
promise._result = value;
|
|
promise._state = lib$es6$promise$$internal$$FULFILLED;
|
|
|
|
if (promise._subscribers.length !== 0) {
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$reject(promise, reason) {
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
|
|
promise._state = lib$es6$promise$$internal$$REJECTED;
|
|
promise._result = reason;
|
|
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
|
|
var subscribers = parent._subscribers;
|
|
var length = subscribers.length;
|
|
|
|
parent._onerror = null;
|
|
|
|
subscribers[length] = child;
|
|
subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
|
|
subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
|
|
|
|
if (length === 0 && parent._state) {
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$publish(promise) {
|
|
var subscribers = promise._subscribers;
|
|
var settled = promise._state;
|
|
|
|
if (subscribers.length === 0) { return; }
|
|
|
|
var child, callback, detail = promise._result;
|
|
|
|
for (var i = 0; i < subscribers.length; i += 3) {
|
|
child = subscribers[i];
|
|
callback = subscribers[i + settled];
|
|
|
|
if (child) {
|
|
lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
|
|
} else {
|
|
callback(detail);
|
|
}
|
|
}
|
|
|
|
promise._subscribers.length = 0;
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$ErrorObject() {
|
|
this.error = null;
|
|
}
|
|
|
|
var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
|
|
|
|
function lib$es6$promise$$internal$$tryCatch(callback, detail) {
|
|
try {
|
|
return callback(detail);
|
|
} catch(e) {
|
|
lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
|
|
return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
|
|
var hasCallback = lib$es6$promise$utils$$isFunction(callback),
|
|
value, error, succeeded, failed;
|
|
|
|
if (hasCallback) {
|
|
value = lib$es6$promise$$internal$$tryCatch(callback, detail);
|
|
|
|
if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
|
|
failed = true;
|
|
error = value.error;
|
|
value = null;
|
|
} else {
|
|
succeeded = true;
|
|
}
|
|
|
|
if (promise === value) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
|
|
return;
|
|
}
|
|
|
|
} else {
|
|
value = detail;
|
|
succeeded = true;
|
|
}
|
|
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) {
|
|
// noop
|
|
} else if (hasCallback && succeeded) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
} else if (failed) {
|
|
lib$es6$promise$$internal$$reject(promise, error);
|
|
} else if (settled === lib$es6$promise$$internal$$FULFILLED) {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
} else if (settled === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, value);
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
|
|
try {
|
|
resolver(function resolvePromise(value){
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}, function rejectPromise(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
});
|
|
} catch(e) {
|
|
lib$es6$promise$$internal$$reject(promise, e);
|
|
}
|
|
}
|
|
|
|
function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
|
|
var enumerator = this;
|
|
|
|
enumerator._instanceConstructor = Constructor;
|
|
enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
|
|
if (enumerator._validateInput(input)) {
|
|
enumerator._input = input;
|
|
enumerator.length = input.length;
|
|
enumerator._remaining = input.length;
|
|
|
|
enumerator._init();
|
|
|
|
if (enumerator.length === 0) {
|
|
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
|
|
} else {
|
|
enumerator.length = enumerator.length || 0;
|
|
enumerator._enumerate();
|
|
if (enumerator._remaining === 0) {
|
|
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
|
|
}
|
|
}
|
|
} else {
|
|
lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
|
|
}
|
|
}
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
|
|
return lib$es6$promise$utils$$isArray(input);
|
|
};
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
|
|
return new Error('Array Methods must be provided an Array');
|
|
};
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
|
|
this._result = new Array(this.length);
|
|
};
|
|
|
|
var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
|
|
var enumerator = this;
|
|
|
|
var length = enumerator.length;
|
|
var promise = enumerator.promise;
|
|
var input = enumerator._input;
|
|
|
|
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
|
|
enumerator._eachEntry(input[i], i);
|
|
}
|
|
};
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
|
|
var enumerator = this;
|
|
var c = enumerator._instanceConstructor;
|
|
|
|
if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
|
|
if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
|
|
entry._onerror = null;
|
|
enumerator._settledAt(entry._state, i, entry._result);
|
|
} else {
|
|
enumerator._willSettleAt(c.resolve(entry), i);
|
|
}
|
|
} else {
|
|
enumerator._remaining--;
|
|
enumerator._result[i] = entry;
|
|
}
|
|
};
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
|
|
var enumerator = this;
|
|
var promise = enumerator.promise;
|
|
|
|
if (promise._state === lib$es6$promise$$internal$$PENDING) {
|
|
enumerator._remaining--;
|
|
|
|
if (state === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, value);
|
|
} else {
|
|
enumerator._result[i] = value;
|
|
}
|
|
}
|
|
|
|
if (enumerator._remaining === 0) {
|
|
lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
|
|
}
|
|
};
|
|
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
|
|
var enumerator = this;
|
|
|
|
lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
|
|
enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
|
|
}, function(reason) {
|
|
enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
|
|
});
|
|
};
|
|
function lib$es6$promise$promise$all$$all(entries) {
|
|
return new lib$es6$promise$enumerator$$default(this, entries).promise;
|
|
}
|
|
var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
|
|
function lib$es6$promise$promise$race$$race(entries) {
|
|
/*jshint validthis:true */
|
|
var Constructor = this;
|
|
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
|
|
if (!lib$es6$promise$utils$$isArray(entries)) {
|
|
lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
|
|
return promise;
|
|
}
|
|
|
|
var length = entries.length;
|
|
|
|
function onFulfillment(value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}
|
|
|
|
function onRejection(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
}
|
|
|
|
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
|
|
lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
|
|
}
|
|
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
|
|
function lib$es6$promise$promise$resolve$$resolve(object) {
|
|
/*jshint validthis:true */
|
|
var Constructor = this;
|
|
|
|
if (object && typeof object === 'object' && object.constructor === Constructor) {
|
|
return object;
|
|
}
|
|
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
lib$es6$promise$$internal$$resolve(promise, object);
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
|
|
function lib$es6$promise$promise$reject$$reject(reason) {
|
|
/*jshint validthis:true */
|
|
var Constructor = this;
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
|
|
|
|
var lib$es6$promise$promise$$counter = 0;
|
|
|
|
function lib$es6$promise$promise$$needsResolver() {
|
|
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
|
|
}
|
|
|
|
function lib$es6$promise$promise$$needsNew() {
|
|
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
|
|
}
|
|
|
|
var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
|
|
/**
|
|
Promise objects represent the eventual result of an asynchronous operation. The
|
|
primary way of interacting with a promise is through its `then` method, which
|
|
registers callbacks to receive either a promise's eventual value or the reason
|
|
why the promise cannot be fulfilled.
|
|
|
|
Terminology
|
|
-----------
|
|
|
|
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
|
|
- `thenable` is an object or function that defines a `then` method.
|
|
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
|
|
- `exception` is a value that is thrown using the throw statement.
|
|
- `reason` is a value that indicates why a promise was rejected.
|
|
- `settled` the final resting state of a promise, fulfilled or rejected.
|
|
|
|
A promise can be in one of three states: pending, fulfilled, or rejected.
|
|
|
|
Promises that are fulfilled have a fulfillment value and are in the fulfilled
|
|
state. Promises that are rejected have a rejection reason and are in the
|
|
rejected state. A fulfillment value is never a thenable.
|
|
|
|
Promises can also be said to *resolve* a value. If this value is also a
|
|
promise, then the original promise's settled state will match the value's
|
|
settled state. So a promise that *resolves* a promise that rejects will
|
|
itself reject, and a promise that *resolves* a promise that fulfills will
|
|
itself fulfill.
|
|
|
|
|
|
Basic Usage:
|
|
------------
|
|
|
|
```js
|
|
var promise = new Promise(function(resolve, reject) {
|
|
// on success
|
|
resolve(value);
|
|
|
|
// on failure
|
|
reject(reason);
|
|
});
|
|
|
|
promise.then(function(value) {
|
|
// on fulfillment
|
|
}, function(reason) {
|
|
// on rejection
|
|
});
|
|
```
|
|
|
|
Advanced Usage:
|
|
---------------
|
|
|
|
Promises shine when abstracting away asynchronous interactions such as
|
|
`XMLHttpRequest`s.
|
|
|
|
```js
|
|
function getJSON(url) {
|
|
return new Promise(function(resolve, reject){
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open('GET', url);
|
|
xhr.onreadystatechange = handler;
|
|
xhr.responseType = 'json';
|
|
xhr.setRequestHeader('Accept', 'application/json');
|
|
xhr.send();
|
|
|
|
function handler() {
|
|
if (this.readyState === this.DONE) {
|
|
if (this.status === 200) {
|
|
resolve(this.response);
|
|
} else {
|
|
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
|
|
}
|
|
}
|
|
};
|
|
});
|
|
}
|
|
|
|
getJSON('/posts.json').then(function(json) {
|
|
// on fulfillment
|
|
}, function(reason) {
|
|
// on rejection
|
|
});
|
|
```
|
|
|
|
Unlike callbacks, promises are great composable primitives.
|
|
|
|
```js
|
|
Promise.all([
|
|
getJSON('/posts'),
|
|
getJSON('/comments')
|
|
]).then(function(values){
|
|
values[0] // => postsJSON
|
|
values[1] // => commentsJSON
|
|
|
|
return values;
|
|
});
|
|
```
|
|
|
|
@class Promise
|
|
@param {function} resolver
|
|
Useful for tooling.
|
|
@constructor
|
|
*/
|
|
function lib$es6$promise$promise$$Promise(resolver) {
|
|
this._id = lib$es6$promise$promise$$counter++;
|
|
this._state = undefined;
|
|
this._result = undefined;
|
|
this._subscribers = [];
|
|
|
|
if (lib$es6$promise$$internal$$noop !== resolver) {
|
|
if (!lib$es6$promise$utils$$isFunction(resolver)) {
|
|
lib$es6$promise$promise$$needsResolver();
|
|
}
|
|
|
|
if (!(this instanceof lib$es6$promise$promise$$Promise)) {
|
|
lib$es6$promise$promise$$needsNew();
|
|
}
|
|
|
|
lib$es6$promise$$internal$$initializePromise(this, resolver);
|
|
}
|
|
}
|
|
|
|
lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
|
|
lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
|
|
lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
|
|
lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
|
|
lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
|
|
lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
|
|
lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
|
|
|
|
lib$es6$promise$promise$$Promise.prototype = {
|
|
constructor: lib$es6$promise$promise$$Promise,
|
|
|
|
/**
|
|
The primary way of interacting with a promise is through its `then` method,
|
|
which registers callbacks to receive either a promise's eventual value or the
|
|
reason why the promise cannot be fulfilled.
|
|
|
|
```js
|
|
findUser().then(function(user){
|
|
// user is available
|
|
}, function(reason){
|
|
// user is unavailable, and you are given the reason why
|
|
});
|
|
```
|
|
|
|
Chaining
|
|
--------
|
|
|
|
The return value of `then` is itself a promise. This second, 'downstream'
|
|
promise is resolved with the return value of the first promise's fulfillment
|
|
or rejection handler, or rejected if the handler throws an exception.
|
|
|
|
```js
|
|
findUser().then(function (user) {
|
|
return user.name;
|
|
}, function (reason) {
|
|
return 'default name';
|
|
}).then(function (userName) {
|
|
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
|
|
// will be `'default name'`
|
|
});
|
|
|
|
findUser().then(function (user) {
|
|
throw new Error('Found user, but still unhappy');
|
|
}, function (reason) {
|
|
throw new Error('`findUser` rejected and we're unhappy');
|
|
}).then(function (value) {
|
|
// never reached
|
|
}, function (reason) {
|
|
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
|
|
// If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
|
|
});
|
|
```
|
|
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
|
|
|
|
```js
|
|
findUser().then(function (user) {
|
|
throw new PedagogicalException('Upstream error');
|
|
}).then(function (value) {
|
|
// never reached
|
|
}).then(function (value) {
|
|
// never reached
|
|
}, function (reason) {
|
|
// The `PedgagocialException` is propagated all the way down to here
|
|
});
|
|
```
|
|
|
|
Assimilation
|
|
------------
|
|
|
|
Sometimes the value you want to propagate to a downstream promise can only be
|
|
retrieved asynchronously. This can be achieved by returning a promise in the
|
|
fulfillment or rejection handler. The downstream promise will then be pending
|
|
until the returned promise is settled. This is called *assimilation*.
|
|
|
|
```js
|
|
findUser().then(function (user) {
|
|
return findCommentsByAuthor(user);
|
|
}).then(function (comments) {
|
|
// The user's comments are now available
|
|
});
|
|
```
|
|
|
|
If the assimliated promise rejects, then the downstream promise will also reject.
|
|
|
|
```js
|
|
findUser().then(function (user) {
|
|
return findCommentsByAuthor(user);
|
|
}).then(function (comments) {
|
|
// If `findCommentsByAuthor` fulfills, we'll have the value here
|
|
}, function (reason) {
|
|
// If `findCommentsByAuthor` rejects, we'll have the reason here
|
|
});
|
|
```
|
|
|
|
Simple Example
|
|
--------------
|
|
|
|
Synchronous Example
|
|
|
|
```javascript
|
|
var result;
|
|
|
|
try {
|
|
result = findResult();
|
|
// success
|
|
} catch(reason) {
|
|
// failure
|
|
}
|
|
```
|
|
|
|
Errback Example
|
|
|
|
```js
|
|
findResult(function(result, err){
|
|
if (err) {
|
|
// failure
|
|
} else {
|
|
// success
|
|
}
|
|
});
|
|
```
|
|
|
|
Promise Example;
|
|
|
|
```javascript
|
|
findResult().then(function(result){
|
|
// success
|
|
}, function(reason){
|
|
// failure
|
|
});
|
|
```
|
|
|
|
Advanced Example
|
|
--------------
|
|
|
|
Synchronous Example
|
|
|
|
```javascript
|
|
var author, books;
|
|
|
|
try {
|
|
author = findAuthor();
|
|
books = findBooksByAuthor(author);
|
|
// success
|
|
} catch(reason) {
|
|
// failure
|
|
}
|
|
```
|
|
|
|
Errback Example
|
|
|
|
```js
|
|
|
|
function foundBooks(books) {
|
|
|
|
}
|
|
|
|
function failure(reason) {
|
|
|
|
}
|
|
|
|
findAuthor(function(author, err){
|
|
if (err) {
|
|
failure(err);
|
|
// failure
|
|
} else {
|
|
try {
|
|
findBoooksByAuthor(author, function(books, err) {
|
|
if (err) {
|
|
failure(err);
|
|
} else {
|
|
try {
|
|
foundBooks(books);
|
|
} catch(reason) {
|
|
failure(reason);
|
|
}
|
|
}
|
|
});
|
|
} catch(error) {
|
|
failure(err);
|
|
}
|
|
// success
|
|
}
|
|
});
|
|
```
|
|
|
|
Promise Example;
|
|
|
|
```javascript
|
|
findAuthor().
|
|
then(findBooksByAuthor).
|
|
then(function(books){
|
|
// found books
|
|
}).catch(function(reason){
|
|
// something went wrong
|
|
});
|
|
```
|
|
|
|
@method then
|
|
@param {Function} onFulfilled
|
|
@param {Function} onRejected
|
|
Useful for tooling.
|
|
@return {Promise}
|
|
*/
|
|
then: function(onFulfillment, onRejection) {
|
|
var parent = this;
|
|
var state = parent._state;
|
|
|
|
if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
|
|
return this;
|
|
}
|
|
|
|
var child = new this.constructor(lib$es6$promise$$internal$$noop);
|
|
var result = parent._result;
|
|
|
|
if (state) {
|
|
var callback = arguments[state - 1];
|
|
lib$es6$promise$asap$$asap(function(){
|
|
lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
|
|
});
|
|
} else {
|
|
lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
|
|
}
|
|
|
|
return child;
|
|
},
|
|
|
|
/**
|
|
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
|
|
as the catch block of a try/catch statement.
|
|
|
|
```js
|
|
function findAuthor(){
|
|
throw new Error('couldn't find that author');
|
|
}
|
|
|
|
// synchronous
|
|
try {
|
|
findAuthor();
|
|
} catch(reason) {
|
|
// something went wrong
|
|
}
|
|
|
|
// async with promises
|
|
findAuthor().catch(function(reason){
|
|
// something went wrong
|
|
});
|
|
```
|
|
|
|
@method catch
|
|
@param {Function} onRejection
|
|
Useful for tooling.
|
|
@return {Promise}
|
|
*/
|
|
'catch': function(onRejection) {
|
|
return this.then(null, onRejection);
|
|
}
|
|
};
|
|
function lib$es6$promise$polyfill$$polyfill() {
|
|
var local;
|
|
|
|
if (typeof global !== 'undefined') {
|
|
local = global;
|
|
} else if (typeof self !== 'undefined') {
|
|
local = self;
|
|
} else {
|
|
try {
|
|
local = Function('return this')();
|
|
} catch (e) {
|
|
throw new Error('polyfill failed because global object is unavailable in this environment');
|
|
}
|
|
}
|
|
|
|
var P = local.Promise;
|
|
|
|
if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
|
|
return;
|
|
}
|
|
|
|
local.Promise = lib$es6$promise$promise$$default;
|
|
}
|
|
var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
|
|
|
|
var lib$es6$promise$umd$$ES6Promise = {
|
|
'Promise': lib$es6$promise$promise$$default,
|
|
'polyfill': lib$es6$promise$polyfill$$default
|
|
};
|
|
|
|
/* global define:true module:true window: true */
|
|
if (typeof define === 'function' && define['amd']) {
|
|
define(function() { return lib$es6$promise$umd$$ES6Promise; });
|
|
} else if (typeof module !== 'undefined' && module['exports']) {
|
|
module['exports'] = lib$es6$promise$umd$$ES6Promise;
|
|
} else if (typeof this !== 'undefined') {
|
|
this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
|
|
}
|
|
|
|
lib$es6$promise$polyfill$$default();
|
|
}).call(this);
|
|
|
|
|
|
}).call(this,{},typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{}]},{},[1]);
|
|
|
|
/*! *****************************************************************************
|
|
Copyright (C) Microsoft. All rights reserved.
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
this file except in compliance with the License. You may obtain a copy of the
|
|
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
and limitations under the License.
|
|
***************************************************************************** */
|
|
var Reflect;
|
|
(function (Reflect) {
|
|
"use strict";
|
|
// Load global or shim versions of Map, Set, and WeakMap
|
|
var functionPrototype = Object.getPrototypeOf(Function);
|
|
var _Map = typeof Map === "function" ? Map : CreateMapPolyfill();
|
|
var _Set = typeof Set === "function" ? Set : CreateSetPolyfill();
|
|
var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
|
|
// [[Metadata]] internal slot
|
|
var __Metadata__ = new _WeakMap();
|
|
/**
|
|
* Applies a set of decorators to a property of a target object.
|
|
* @param decorators An array of decorators.
|
|
* @param target The target object.
|
|
* @param targetKey (Optional) The property key to decorate.
|
|
* @param targetDescriptor (Optional) The property descriptor for the target key
|
|
* @remarks Decorators are applied in reverse order.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* C = Reflect.decorate(decoratorsArray, C);
|
|
*
|
|
* // property (on constructor)
|
|
* Reflect.decorate(decoratorsArray, C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* Reflect.decorate(decoratorsArray, C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* Object.defineProperty(C, "staticMethod",
|
|
* Reflect.decorate(decoratorsArray, C, "staticMethod",
|
|
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
|
|
*
|
|
* // method (on prototype)
|
|
* Object.defineProperty(C.prototype, "method",
|
|
* Reflect.decorate(decoratorsArray, C.prototype, "method",
|
|
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
|
*
|
|
*/
|
|
function decorate(decorators, target, targetKey, targetDescriptor) {
|
|
if (!IsUndefined(targetDescriptor)) {
|
|
if (!IsArray(decorators)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (IsUndefined(targetKey)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsObject(targetDescriptor)) {
|
|
throw new TypeError();
|
|
}
|
|
targetKey = ToPropertyKey(targetKey);
|
|
return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor);
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
if (!IsArray(decorators)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
targetKey = ToPropertyKey(targetKey);
|
|
return DecoratePropertyWithoutDescriptor(decorators, target, targetKey);
|
|
}
|
|
else {
|
|
if (!IsArray(decorators)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsConstructor(target)) {
|
|
throw new TypeError();
|
|
}
|
|
return DecorateConstructor(decorators, target);
|
|
}
|
|
}
|
|
Reflect.decorate = decorate;
|
|
/**
|
|
* A default metadata decorator factory that can be used on a class, class member, or parameter.
|
|
* @param metadataKey The key for the metadata entry.
|
|
* @param metadataValue The value for the metadata entry.
|
|
* @returns A decorator function.
|
|
* @remarks
|
|
* If `metadataKey` is already defined for the target and target key, the
|
|
* metadataValue for that key will be overwritten.
|
|
* @example
|
|
*
|
|
* // constructor
|
|
* @Reflect.metadata(key, value)
|
|
* class C {
|
|
* }
|
|
*
|
|
* // property (on constructor, TypeScript only)
|
|
* class C {
|
|
* @Reflect.metadata(key, value)
|
|
* static staticProperty;
|
|
* }
|
|
*
|
|
* // property (on prototype, TypeScript only)
|
|
* class C {
|
|
* @Reflect.metadata(key, value)
|
|
* property;
|
|
* }
|
|
*
|
|
* // method (on constructor)
|
|
* class C {
|
|
* @Reflect.metadata(key, value)
|
|
* static staticMethod() { }
|
|
* }
|
|
*
|
|
* // method (on prototype)
|
|
* class C {
|
|
* @Reflect.metadata(key, value)
|
|
* method() { }
|
|
* }
|
|
*
|
|
*/
|
|
function metadata(metadataKey, metadataValue) {
|
|
function decorator(target, targetKey) {
|
|
if (!IsUndefined(targetKey)) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
targetKey = ToPropertyKey(targetKey);
|
|
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
|
}
|
|
else {
|
|
if (!IsConstructor(target)) {
|
|
throw new TypeError();
|
|
}
|
|
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, /*targetKey*/ undefined);
|
|
}
|
|
}
|
|
return decorator;
|
|
}
|
|
Reflect.metadata = metadata;
|
|
/**
|
|
* Define a unique metadata entry on the target.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param metadataValue A value that contains attached metadata.
|
|
* @param target The target object on which to define metadata.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* Reflect.defineMetadata("custom:annotation", options, C);
|
|
*
|
|
* // property (on constructor)
|
|
* Reflect.defineMetadata("custom:annotation", options, C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* Reflect.defineMetadata("custom:annotation", options, C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "method");
|
|
*
|
|
* // decorator factory as metadata-producing annotation.
|
|
* function MyAnnotation(options): Decorator {
|
|
* return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
|
* }
|
|
*
|
|
*/
|
|
function defineMetadata(metadataKey, metadataValue, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
|
}
|
|
Reflect.defineMetadata = defineMetadata;
|
|
/**
|
|
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.hasMetadata("custom:annotation", C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
|
|
*
|
|
*/
|
|
function hasMetadata(metadataKey, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryHasMetadata(metadataKey, target, targetKey);
|
|
}
|
|
Reflect.hasMetadata = hasMetadata;
|
|
/**
|
|
* Gets a value indicating whether the target object has the provided metadata key defined.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.hasOwnMetadata("custom:annotation", C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
|
|
*
|
|
*/
|
|
function hasOwnMetadata(metadataKey, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryHasOwnMetadata(metadataKey, target, targetKey);
|
|
}
|
|
Reflect.hasOwnMetadata = hasOwnMetadata;
|
|
/**
|
|
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.getMetadata("custom:annotation", C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
|
|
*
|
|
*/
|
|
function getMetadata(metadataKey, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryGetMetadata(metadataKey, target, targetKey);
|
|
}
|
|
Reflect.getMetadata = getMetadata;
|
|
/**
|
|
* Gets the metadata value for the provided metadata key on the target object.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.getOwnMetadata("custom:annotation", C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
|
|
*
|
|
*/
|
|
function getOwnMetadata(metadataKey, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryGetOwnMetadata(metadataKey, target, targetKey);
|
|
}
|
|
Reflect.getOwnMetadata = getOwnMetadata;
|
|
/**
|
|
* Gets the metadata keys defined on the target object or its prototype chain.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns An array of unique metadata keys.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.getMetadataKeys(C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.getMetadataKeys(C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.getMetadataKeys(C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.getMetadataKeys(C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.getMetadataKeys(C.prototype, "method");
|
|
*
|
|
*/
|
|
function getMetadataKeys(target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryMetadataKeys(target, targetKey);
|
|
}
|
|
Reflect.getMetadataKeys = getMetadataKeys;
|
|
/**
|
|
* Gets the unique metadata keys defined on the target object.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns An array of unique metadata keys.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.getOwnMetadataKeys(C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.getOwnMetadataKeys(C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.getOwnMetadataKeys(C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.getOwnMetadataKeys(C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.getOwnMetadataKeys(C.prototype, "method");
|
|
*
|
|
*/
|
|
function getOwnMetadataKeys(target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
return OrdinaryOwnMetadataKeys(target, targetKey);
|
|
}
|
|
Reflect.getOwnMetadataKeys = getOwnMetadataKeys;
|
|
/**
|
|
* Deletes the metadata entry from the target object with the provided key.
|
|
* @param metadataKey A key used to store and retrieve metadata.
|
|
* @param target The target object on which the metadata is defined.
|
|
* @param targetKey (Optional) The property key for the target.
|
|
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
|
* @example
|
|
*
|
|
* class C {
|
|
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
|
* // static staticProperty;
|
|
* // property;
|
|
*
|
|
* constructor(p) { }
|
|
* static staticMethod(p) { }
|
|
* method(p) { }
|
|
* }
|
|
*
|
|
* // constructor
|
|
* result = Reflect.deleteMetadata("custom:annotation", C);
|
|
*
|
|
* // property (on constructor)
|
|
* result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
|
|
*
|
|
* // property (on prototype)
|
|
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
|
|
*
|
|
* // method (on constructor)
|
|
* result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
|
|
*
|
|
* // method (on prototype)
|
|
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
|
|
*
|
|
*/
|
|
function deleteMetadata(metadataKey, target, targetKey) {
|
|
if (!IsObject(target)) {
|
|
throw new TypeError();
|
|
}
|
|
else if (!IsUndefined(targetKey)) {
|
|
targetKey = ToPropertyKey(targetKey);
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
|
|
var metadataMap = GetOrCreateMetadataMap(target, targetKey, /*create*/ false);
|
|
if (IsUndefined(metadataMap)) {
|
|
return false;
|
|
}
|
|
if (!metadataMap.delete(metadataKey)) {
|
|
return false;
|
|
}
|
|
if (metadataMap.size > 0) {
|
|
return true;
|
|
}
|
|
var targetMetadata = __Metadata__.get(target);
|
|
targetMetadata.delete(targetKey);
|
|
if (targetMetadata.size > 0) {
|
|
return true;
|
|
}
|
|
__Metadata__.delete(target);
|
|
return true;
|
|
}
|
|
Reflect.deleteMetadata = deleteMetadata;
|
|
function DecorateConstructor(decorators, target) {
|
|
for (var i = decorators.length - 1; i >= 0; --i) {
|
|
var decorator = decorators[i];
|
|
var decorated = decorator(target);
|
|
if (!IsUndefined(decorated)) {
|
|
if (!IsConstructor(decorated)) {
|
|
throw new TypeError();
|
|
}
|
|
target = decorated;
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
function DecoratePropertyWithDescriptor(decorators, target, propertyKey, descriptor) {
|
|
for (var i = decorators.length - 1; i >= 0; --i) {
|
|
var decorator = decorators[i];
|
|
var decorated = decorator(target, propertyKey, descriptor);
|
|
if (!IsUndefined(decorated)) {
|
|
if (!IsObject(decorated)) {
|
|
throw new TypeError();
|
|
}
|
|
descriptor = decorated;
|
|
}
|
|
}
|
|
return descriptor;
|
|
}
|
|
function DecoratePropertyWithoutDescriptor(decorators, target, propertyKey) {
|
|
for (var i = decorators.length - 1; i >= 0; --i) {
|
|
var decorator = decorators[i];
|
|
decorator(target, propertyKey);
|
|
}
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
|
|
function GetOrCreateMetadataMap(target, targetKey, create) {
|
|
var targetMetadata = __Metadata__.get(target);
|
|
if (!targetMetadata) {
|
|
if (!create) {
|
|
return undefined;
|
|
}
|
|
targetMetadata = new _Map();
|
|
__Metadata__.set(target, targetMetadata);
|
|
}
|
|
var keyMetadata = targetMetadata.get(targetKey);
|
|
if (!keyMetadata) {
|
|
if (!create) {
|
|
return undefined;
|
|
}
|
|
keyMetadata = new _Map();
|
|
targetMetadata.set(targetKey, keyMetadata);
|
|
}
|
|
return keyMetadata;
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
|
|
function OrdinaryHasMetadata(MetadataKey, O, P) {
|
|
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
|
if (hasOwn) {
|
|
return true;
|
|
}
|
|
var parent = GetPrototypeOf(O);
|
|
if (parent !== null) {
|
|
return OrdinaryHasMetadata(MetadataKey, parent, P);
|
|
}
|
|
return false;
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
|
|
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
|
|
var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);
|
|
if (metadataMap === undefined) {
|
|
return false;
|
|
}
|
|
return Boolean(metadataMap.has(MetadataKey));
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
|
|
function OrdinaryGetMetadata(MetadataKey, O, P) {
|
|
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
|
if (hasOwn) {
|
|
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
|
|
}
|
|
var parent = GetPrototypeOf(O);
|
|
if (parent !== null) {
|
|
return OrdinaryGetMetadata(MetadataKey, parent, P);
|
|
}
|
|
return undefined;
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
|
|
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
|
|
var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ false);
|
|
if (metadataMap === undefined) {
|
|
return undefined;
|
|
}
|
|
return metadataMap.get(MetadataKey);
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
|
|
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
|
|
var metadataMap = GetOrCreateMetadataMap(O, P, /*create*/ true);
|
|
metadataMap.set(MetadataKey, MetadataValue);
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
|
|
function OrdinaryMetadataKeys(O, P) {
|
|
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
|
|
var parent = GetPrototypeOf(O);
|
|
if (parent === null) {
|
|
return ownKeys;
|
|
}
|
|
var parentKeys = OrdinaryMetadataKeys(parent, P);
|
|
if (parentKeys.length <= 0) {
|
|
return ownKeys;
|
|
}
|
|
if (ownKeys.length <= 0) {
|
|
return parentKeys;
|
|
}
|
|
var set = new _Set();
|
|
var keys = [];
|
|
for (var _i = 0; _i < ownKeys.length; _i++) {
|
|
var key = ownKeys[_i];
|
|
var hasKey = set.has(key);
|
|
if (!hasKey) {
|
|
set.add(key);
|
|
keys.push(key);
|
|
}
|
|
}
|
|
for (var _a = 0; _a < parentKeys.length; _a++) {
|
|
var key = parentKeys[_a];
|
|
var hasKey = set.has(key);
|
|
if (!hasKey) {
|
|
set.add(key);
|
|
keys.push(key);
|
|
}
|
|
}
|
|
return keys;
|
|
}
|
|
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
|
|
function OrdinaryOwnMetadataKeys(target, targetKey) {
|
|
var metadataMap = GetOrCreateMetadataMap(target, targetKey, /*create*/ false);
|
|
var keys = [];
|
|
if (metadataMap) {
|
|
metadataMap.forEach(function (_, key) { return keys.push(key); });
|
|
}
|
|
return keys;
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-undefined-type
|
|
function IsUndefined(x) {
|
|
return x === undefined;
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
|
|
function IsArray(x) {
|
|
return Array.isArray(x);
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type
|
|
function IsObject(x) {
|
|
return typeof x === "object" ? x !== null : typeof x === "function";
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
|
|
function IsConstructor(x) {
|
|
return typeof x === "function";
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-symbol-type
|
|
function IsSymbol(x) {
|
|
return typeof x === "symbol";
|
|
}
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
|
|
function ToPropertyKey(value) {
|
|
if (IsSymbol(value)) {
|
|
return value;
|
|
}
|
|
return String(value);
|
|
}
|
|
function GetPrototypeOf(O) {
|
|
var proto = Object.getPrototypeOf(O);
|
|
if (typeof O !== "function" || O === functionPrototype) {
|
|
return proto;
|
|
}
|
|
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
|
// Try to determine the superclass constructor. Compatible implementations
|
|
// must either set __proto__ on a subclass constructor to the superclass constructor,
|
|
// or ensure each class has a valid `constructor` property on its prototype that
|
|
// points back to the constructor.
|
|
// If this is not the same as Function.[[Prototype]], then this is definately inherited.
|
|
// This is the case when in ES6 or when using __proto__ in a compatible browser.
|
|
if (proto !== functionPrototype) {
|
|
return proto;
|
|
}
|
|
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
|
|
var prototype = O.prototype;
|
|
var prototypeProto = Object.getPrototypeOf(prototype);
|
|
if (prototypeProto == null || prototypeProto === Object.prototype) {
|
|
return proto;
|
|
}
|
|
// if the constructor was not a function, then we cannot determine the heritage.
|
|
var constructor = prototypeProto.constructor;
|
|
if (typeof constructor !== "function") {
|
|
return proto;
|
|
}
|
|
// if we have some kind of self-reference, then we cannot determine the heritage.
|
|
if (constructor === O) {
|
|
return proto;
|
|
}
|
|
// we have a pretty good guess at the heritage.
|
|
return constructor;
|
|
}
|
|
// naive Map shim
|
|
function CreateMapPolyfill() {
|
|
var cacheSentinel = {};
|
|
function Map() {
|
|
this._keys = [];
|
|
this._values = [];
|
|
this._cache = cacheSentinel;
|
|
}
|
|
Map.prototype = {
|
|
get size() {
|
|
return this._keys.length;
|
|
},
|
|
has: function (key) {
|
|
if (key === this._cache) {
|
|
return true;
|
|
}
|
|
if (this._find(key) >= 0) {
|
|
this._cache = key;
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
get: function (key) {
|
|
var index = this._find(key);
|
|
if (index >= 0) {
|
|
this._cache = key;
|
|
return this._values[index];
|
|
}
|
|
return undefined;
|
|
},
|
|
set: function (key, value) {
|
|
this.delete(key);
|
|
this._keys.push(key);
|
|
this._values.push(value);
|
|
this._cache = key;
|
|
return this;
|
|
},
|
|
delete: function (key) {
|
|
var index = this._find(key);
|
|
if (index >= 0) {
|
|
this._keys.splice(index, 1);
|
|
this._values.splice(index, 1);
|
|
this._cache = cacheSentinel;
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
clear: function () {
|
|
this._keys.length = 0;
|
|
this._values.length = 0;
|
|
this._cache = cacheSentinel;
|
|
},
|
|
forEach: function (callback, thisArg) {
|
|
var size = this.size;
|
|
for (var i = 0; i < size; ++i) {
|
|
var key = this._keys[i];
|
|
var value = this._values[i];
|
|
this._cache = key;
|
|
callback.call(this, value, key, this);
|
|
}
|
|
},
|
|
_find: function (key) {
|
|
var keys = this._keys;
|
|
var size = keys.length;
|
|
for (var i = 0; i < size; ++i) {
|
|
if (keys[i] === key) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
};
|
|
return Map;
|
|
}
|
|
// naive Set shim
|
|
function CreateSetPolyfill() {
|
|
var cacheSentinel = {};
|
|
function Set() {
|
|
this._map = new _Map();
|
|
}
|
|
Set.prototype = {
|
|
get size() {
|
|
return this._map.length;
|
|
},
|
|
has: function (value) {
|
|
return this._map.has(value);
|
|
},
|
|
add: function (value) {
|
|
this._map.set(value, value);
|
|
return this;
|
|
},
|
|
delete: function (value) {
|
|
return this._map.delete(value);
|
|
},
|
|
clear: function () {
|
|
this._map.clear();
|
|
},
|
|
forEach: function (callback, thisArg) {
|
|
this._map.forEach(callback, thisArg);
|
|
}
|
|
};
|
|
return Set;
|
|
}
|
|
// naive WeakMap shim
|
|
function CreateWeakMapPolyfill() {
|
|
var UUID_SIZE = 16;
|
|
var isNode = typeof global !== "undefined" && Object.prototype.toString.call(global.process) === '[object process]';
|
|
var nodeCrypto = isNode && require("crypto");
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var keys = {};
|
|
var rootKey = CreateUniqueKey();
|
|
function WeakMap() {
|
|
this._key = CreateUniqueKey();
|
|
}
|
|
WeakMap.prototype = {
|
|
has: function (target) {
|
|
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
|
|
if (table) {
|
|
return this._key in table;
|
|
}
|
|
return false;
|
|
},
|
|
get: function (target) {
|
|
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
|
|
if (table) {
|
|
return table[this._key];
|
|
}
|
|
return undefined;
|
|
},
|
|
set: function (target, value) {
|
|
var table = GetOrCreateWeakMapTable(target, /*create*/ true);
|
|
table[this._key] = value;
|
|
return this;
|
|
},
|
|
delete: function (target) {
|
|
var table = GetOrCreateWeakMapTable(target, /*create*/ false);
|
|
if (table && this._key in table) {
|
|
return delete table[this._key];
|
|
}
|
|
return false;
|
|
},
|
|
clear: function () {
|
|
// NOTE: not a real clear, just makes the previous data unreachable
|
|
this._key = CreateUniqueKey();
|
|
}
|
|
};
|
|
function FillRandomBytes(buffer, size) {
|
|
for (var i = 0; i < size; ++i) {
|
|
buffer[i] = Math.random() * 255 | 0;
|
|
}
|
|
}
|
|
function GenRandomBytes(size) {
|
|
if (nodeCrypto) {
|
|
var data = nodeCrypto.randomBytes(size);
|
|
return data;
|
|
}
|
|
else if (typeof Uint8Array === "function") {
|
|
var data = new Uint8Array(size);
|
|
if (typeof crypto !== "undefined") {
|
|
crypto.getRandomValues(data);
|
|
}
|
|
else if (typeof msCrypto !== "undefined") {
|
|
msCrypto.getRandomValues(data);
|
|
}
|
|
else {
|
|
FillRandomBytes(data, size);
|
|
}
|
|
return data;
|
|
}
|
|
else {
|
|
var data = new Array(size);
|
|
FillRandomBytes(data, size);
|
|
return data;
|
|
}
|
|
}
|
|
function CreateUUID() {
|
|
var data = GenRandomBytes(UUID_SIZE);
|
|
// mark as random - RFC 4122 § 4.4
|
|
data[6] = data[6] & 0x4f | 0x40;
|
|
data[8] = data[8] & 0xbf | 0x80;
|
|
var result = "";
|
|
for (var offset = 0; offset < UUID_SIZE; ++offset) {
|
|
var byte = data[offset];
|
|
if (offset === 4 || offset === 6 || offset === 8) {
|
|
result += "-";
|
|
}
|
|
if (byte < 16) {
|
|
result += "0";
|
|
}
|
|
result += byte.toString(16).toLowerCase();
|
|
}
|
|
return result;
|
|
}
|
|
function CreateUniqueKey() {
|
|
var key;
|
|
do {
|
|
key = "@@WeakMap@@" + CreateUUID();
|
|
} while (hasOwn.call(keys, key));
|
|
keys[key] = true;
|
|
return key;
|
|
}
|
|
function GetOrCreateWeakMapTable(target, create) {
|
|
if (!hasOwn.call(target, rootKey)) {
|
|
if (!create) {
|
|
return undefined;
|
|
}
|
|
Object.defineProperty(target, rootKey, { value: Object.create(null) });
|
|
}
|
|
return target[rootKey];
|
|
}
|
|
return WeakMap;
|
|
}
|
|
// hook global Reflect
|
|
(function (__global) {
|
|
if (typeof __global.Reflect !== "undefined") {
|
|
if (__global.Reflect !== Reflect) {
|
|
for (var p in Reflect) {
|
|
__global.Reflect[p] = Reflect[p];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
__global.Reflect = Reflect;
|
|
}
|
|
})(typeof window !== "undefined" ? window :
|
|
typeof WorkerGlobalScope !== "undefined" ? self :
|
|
typeof global !== "undefined" ? global :
|
|
Function("return this;")());
|
|
})(Reflect || (Reflect = {}));
|
|
|
|
"format amd";
|
|
(function(global) {
|
|
|
|
var defined = {};
|
|
|
|
// indexOf polyfill for IE8
|
|
var indexOf = Array.prototype.indexOf || function(item) {
|
|
for (var i = 0, l = this.length; i < l; i++)
|
|
if (this[i] === item)
|
|
return i;
|
|
return -1;
|
|
}
|
|
|
|
var getOwnPropertyDescriptor = true;
|
|
try {
|
|
Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
|
|
}
|
|
catch(e) {
|
|
getOwnPropertyDescriptor = false;
|
|
}
|
|
|
|
var defineProperty;
|
|
(function () {
|
|
try {
|
|
if (!!Object.defineProperty({}, 'a', {}))
|
|
defineProperty = Object.defineProperty;
|
|
}
|
|
catch (e) {
|
|
defineProperty = function(obj, prop, opt) {
|
|
try {
|
|
obj[prop] = opt.value || opt.get.call(obj);
|
|
}
|
|
catch(e) {}
|
|
}
|
|
}
|
|
})();
|
|
|
|
function register(name, deps, declare) {
|
|
if (arguments.length === 4)
|
|
return registerDynamic.apply(this, arguments);
|
|
doRegister(name, {
|
|
declarative: true,
|
|
deps: deps,
|
|
declare: declare
|
|
});
|
|
}
|
|
|
|
function registerDynamic(name, deps, executingRequire, execute) {
|
|
doRegister(name, {
|
|
declarative: false,
|
|
deps: deps,
|
|
executingRequire: executingRequire,
|
|
execute: execute
|
|
});
|
|
}
|
|
|
|
function doRegister(name, entry) {
|
|
entry.name = name;
|
|
|
|
// we never overwrite an existing define
|
|
if (!(name in defined))
|
|
defined[name] = entry;
|
|
|
|
// we have to normalize dependencies
|
|
// (assume dependencies are normalized for now)
|
|
// entry.normalizedDeps = entry.deps.map(normalize);
|
|
entry.normalizedDeps = entry.deps;
|
|
}
|
|
|
|
|
|
function buildGroups(entry, groups) {
|
|
groups[entry.groupIndex] = groups[entry.groupIndex] || [];
|
|
|
|
if (indexOf.call(groups[entry.groupIndex], entry) != -1)
|
|
return;
|
|
|
|
groups[entry.groupIndex].push(entry);
|
|
|
|
for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
|
|
var depName = entry.normalizedDeps[i];
|
|
var depEntry = defined[depName];
|
|
|
|
// not in the registry means already linked / ES6
|
|
if (!depEntry || depEntry.evaluated)
|
|
continue;
|
|
|
|
// now we know the entry is in our unlinked linkage group
|
|
var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
|
|
|
|
// the group index of an entry is always the maximum
|
|
if (depEntry.groupIndex === undefined || depEntry.groupIndex < depGroupIndex) {
|
|
|
|
// if already in a group, remove from the old group
|
|
if (depEntry.groupIndex !== undefined) {
|
|
groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
|
|
|
|
// if the old group is empty, then we have a mixed depndency cycle
|
|
if (groups[depEntry.groupIndex].length == 0)
|
|
throw new TypeError("Mixed dependency cycle detected");
|
|
}
|
|
|
|
depEntry.groupIndex = depGroupIndex;
|
|
}
|
|
|
|
buildGroups(depEntry, groups);
|
|
}
|
|
}
|
|
|
|
function link(name) {
|
|
var startEntry = defined[name];
|
|
|
|
startEntry.groupIndex = 0;
|
|
|
|
var groups = [];
|
|
|
|
buildGroups(startEntry, groups);
|
|
|
|
var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
|
|
for (var i = groups.length - 1; i >= 0; i--) {
|
|
var group = groups[i];
|
|
for (var j = 0; j < group.length; j++) {
|
|
var entry = group[j];
|
|
|
|
// link each group
|
|
if (curGroupDeclarative)
|
|
linkDeclarativeModule(entry);
|
|
else
|
|
linkDynamicModule(entry);
|
|
}
|
|
curGroupDeclarative = !curGroupDeclarative;
|
|
}
|
|
}
|
|
|
|
// module binding records
|
|
var moduleRecords = {};
|
|
function getOrCreateModuleRecord(name) {
|
|
return moduleRecords[name] || (moduleRecords[name] = {
|
|
name: name,
|
|
dependencies: [],
|
|
exports: {}, // start from an empty module and extend
|
|
importers: []
|
|
})
|
|
}
|
|
|
|
function linkDeclarativeModule(entry) {
|
|
// only link if already not already started linking (stops at circular)
|
|
if (entry.module)
|
|
return;
|
|
|
|
var module = entry.module = getOrCreateModuleRecord(entry.name);
|
|
var exports = entry.module.exports;
|
|
|
|
var declaration = entry.declare.call(global, function(name, value) {
|
|
module.locked = true;
|
|
|
|
if (typeof name == 'object') {
|
|
for (var p in name)
|
|
exports[p] = name[p];
|
|
}
|
|
else {
|
|
exports[name] = value;
|
|
}
|
|
|
|
for (var i = 0, l = module.importers.length; i < l; i++) {
|
|
var importerModule = module.importers[i];
|
|
if (!importerModule.locked) {
|
|
for (var j = 0; j < importerModule.dependencies.length; ++j) {
|
|
if (importerModule.dependencies[j] === module) {
|
|
importerModule.setters[j](exports);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.locked = false;
|
|
return value;
|
|
}, entry.name);
|
|
|
|
module.setters = declaration.setters;
|
|
module.execute = declaration.execute;
|
|
|
|
// now link all the module dependencies
|
|
for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
|
|
var depName = entry.normalizedDeps[i];
|
|
var depEntry = defined[depName];
|
|
var depModule = moduleRecords[depName];
|
|
|
|
// work out how to set depExports based on scenarios...
|
|
var depExports;
|
|
|
|
if (depModule) {
|
|
depExports = depModule.exports;
|
|
}
|
|
else if (depEntry && !depEntry.declarative) {
|
|
depExports = depEntry.esModule;
|
|
}
|
|
// in the module registry
|
|
else if (!depEntry) {
|
|
depExports = load(depName);
|
|
}
|
|
// we have an entry -> link
|
|
else {
|
|
linkDeclarativeModule(depEntry);
|
|
depModule = depEntry.module;
|
|
depExports = depModule.exports;
|
|
}
|
|
|
|
// only declarative modules have dynamic bindings
|
|
if (depModule && depModule.importers) {
|
|
depModule.importers.push(module);
|
|
module.dependencies.push(depModule);
|
|
}
|
|
else
|
|
module.dependencies.push(null);
|
|
|
|
// run the setter for this dependency
|
|
if (module.setters[i])
|
|
module.setters[i](depExports);
|
|
}
|
|
}
|
|
|
|
// An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
|
|
function getModule(name) {
|
|
var exports;
|
|
var entry = defined[name];
|
|
|
|
if (!entry) {
|
|
exports = load(name);
|
|
if (!exports)
|
|
throw new Error("Unable to load dependency " + name + ".");
|
|
}
|
|
|
|
else {
|
|
if (entry.declarative)
|
|
ensureEvaluated(name, []);
|
|
|
|
else if (!entry.evaluated)
|
|
linkDynamicModule(entry);
|
|
|
|
exports = entry.module.exports;
|
|
}
|
|
|
|
if ((!entry || entry.declarative) && exports && exports.__useDefault)
|
|
return exports['default'];
|
|
|
|
return exports;
|
|
}
|
|
|
|
function linkDynamicModule(entry) {
|
|
if (entry.module)
|
|
return;
|
|
|
|
var exports = {};
|
|
|
|
var module = entry.module = { exports: exports, id: entry.name };
|
|
|
|
// AMD requires execute the tree first
|
|
if (!entry.executingRequire) {
|
|
for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
|
|
var depName = entry.normalizedDeps[i];
|
|
var depEntry = defined[depName];
|
|
if (depEntry)
|
|
linkDynamicModule(depEntry);
|
|
}
|
|
}
|
|
|
|
// now execute
|
|
entry.evaluated = true;
|
|
var output = entry.execute.call(global, function(name) {
|
|
for (var i = 0, l = entry.deps.length; i < l; i++) {
|
|
if (entry.deps[i] != name)
|
|
continue;
|
|
return getModule(entry.normalizedDeps[i]);
|
|
}
|
|
throw new TypeError('Module ' + name + ' not declared as a dependency.');
|
|
}, exports, module);
|
|
|
|
if (output)
|
|
module.exports = output;
|
|
|
|
// create the esModule object, which allows ES6 named imports of dynamics
|
|
exports = module.exports;
|
|
|
|
if (exports && exports.__esModule) {
|
|
entry.esModule = exports;
|
|
}
|
|
else {
|
|
entry.esModule = {};
|
|
|
|
// don't trigger getters/setters in environments that support them
|
|
if ((typeof exports == 'object' || typeof exports == 'function') && exports !== global) {
|
|
if (getOwnPropertyDescriptor) {
|
|
var d;
|
|
for (var p in exports)
|
|
if (d = Object.getOwnPropertyDescriptor(exports, p))
|
|
defineProperty(entry.esModule, p, d);
|
|
}
|
|
else {
|
|
var hasOwnProperty = exports && exports.hasOwnProperty;
|
|
for (var p in exports) {
|
|
if (!hasOwnProperty || exports.hasOwnProperty(p))
|
|
entry.esModule[p] = exports[p];
|
|
}
|
|
}
|
|
}
|
|
entry.esModule['default'] = exports;
|
|
defineProperty(entry.esModule, '__useDefault', {
|
|
value: true
|
|
});
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Given a module, and the list of modules for this current branch,
|
|
* ensure that each of the dependencies of this module is evaluated
|
|
* (unless one is a circular dependency already in the list of seen
|
|
* modules, in which case we execute it)
|
|
*
|
|
* Then we evaluate the module itself depth-first left to right
|
|
* execution to match ES6 modules
|
|
*/
|
|
function ensureEvaluated(moduleName, seen) {
|
|
var entry = defined[moduleName];
|
|
|
|
// if already seen, that means it's an already-evaluated non circular dependency
|
|
if (!entry || entry.evaluated || !entry.declarative)
|
|
return;
|
|
|
|
// this only applies to declarative modules which late-execute
|
|
|
|
seen.push(moduleName);
|
|
|
|
for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
|
|
var depName = entry.normalizedDeps[i];
|
|
if (indexOf.call(seen, depName) == -1) {
|
|
if (!defined[depName])
|
|
load(depName);
|
|
else
|
|
ensureEvaluated(depName, seen);
|
|
}
|
|
}
|
|
|
|
if (entry.evaluated)
|
|
return;
|
|
|
|
entry.evaluated = true;
|
|
entry.module.execute.call(global);
|
|
}
|
|
|
|
// magical execution function
|
|
var modules = {};
|
|
function load(name) {
|
|
if (modules[name])
|
|
return modules[name];
|
|
|
|
// node core modules
|
|
if (name.substr(0, 6) == '@node/')
|
|
return require(name.substr(6));
|
|
|
|
var entry = defined[name];
|
|
|
|
// first we check if this module has already been defined in the registry
|
|
if (!entry)
|
|
throw "Module " + name + " not present.";
|
|
|
|
// recursively ensure that the module and all its
|
|
// dependencies are linked (with dependency group handling)
|
|
link(name);
|
|
|
|
// now handle dependency execution in correct order
|
|
ensureEvaluated(name, []);
|
|
|
|
// remove from the registry
|
|
defined[name] = undefined;
|
|
|
|
// exported modules get __esModule defined for interop
|
|
if (entry.declarative)
|
|
defineProperty(entry.module.exports, '__esModule', { value: true });
|
|
|
|
// return the defined module object
|
|
return modules[name] = entry.declarative ? entry.module.exports : entry.esModule;
|
|
};
|
|
|
|
return function(mains, depNames, declare) {
|
|
return function(formatDetect) {
|
|
formatDetect(function(deps) {
|
|
var System = {
|
|
_nodeRequire: typeof require != 'undefined' && require.resolve && typeof process != 'undefined' && require,
|
|
register: register,
|
|
registerDynamic: registerDynamic,
|
|
get: load,
|
|
set: function(name, module) {
|
|
modules[name] = module;
|
|
},
|
|
newModule: function(module) {
|
|
return module;
|
|
}
|
|
};
|
|
System.set('@empty', {});
|
|
|
|
// register external dependencies
|
|
for (var i = 0; i < depNames.length; i++) (function(depName, dep) {
|
|
if (dep && dep.__esModule)
|
|
System.register(depName, [], function(_export) {
|
|
return {
|
|
setters: [],
|
|
execute: function() {
|
|
for (var p in dep)
|
|
if (p != '__esModule' && !(typeof p == 'object' && p + '' == 'Module'))
|
|
_export(p, dep[p]);
|
|
}
|
|
};
|
|
});
|
|
else
|
|
System.registerDynamic(depName, [], false, function() {
|
|
return dep;
|
|
});
|
|
})(depNames[i], arguments[i]);
|
|
|
|
// register modules in this bundle
|
|
declare(System);
|
|
|
|
// load mains
|
|
var firstLoad = load(mains[0]);
|
|
if (mains.length > 1)
|
|
for (var i = 1; i < mains.length; i++)
|
|
load(mains[i]);
|
|
|
|
if (firstLoad.__useDefault)
|
|
return firstLoad['default'];
|
|
else
|
|
return firstLoad;
|
|
});
|
|
};
|
|
};
|
|
|
|
})(typeof self != 'undefined' ? self : global)
|
|
/* (['mainModule'], ['external-dep'], function($__System) {
|
|
System.register(...);
|
|
})
|
|
(function(factory) {
|
|
if (typeof define && define.amd)
|
|
define(['external-dep'], factory);
|
|
// etc UMD / module pattern
|
|
})*/
|
|
|
|
(["1"], [], function($__System) {
|
|
|
|
(function() {
|
|
var loader = $__System;
|
|
|
|
if (typeof window != 'undefined' && typeof document != 'undefined' && window.location)
|
|
var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
|
|
|
|
loader.set('@@cjs-helpers', loader.newModule({
|
|
getPathVars: function(moduleId) {
|
|
// remove any plugin syntax
|
|
var pluginIndex = moduleId.lastIndexOf('!');
|
|
var filename;
|
|
if (pluginIndex != -1)
|
|
filename = moduleId.substr(0, pluginIndex);
|
|
else
|
|
filename = moduleId;
|
|
|
|
var dirname = filename.split('/');
|
|
dirname.pop();
|
|
dirname = dirname.join('/');
|
|
|
|
if (filename.substr(0, 8) == 'file:///') {
|
|
filename = filename.substr(7);
|
|
dirname = dirname.substr(7);
|
|
|
|
// on windows remove leading '/'
|
|
if (isWindows) {
|
|
filename = filename.substr(1);
|
|
dirname = dirname.substr(1);
|
|
}
|
|
}
|
|
else if (windowOrigin && filename.substr(0, windowOrigin.length) === windowOrigin) {
|
|
filename = filename.substr(windowOrigin.length);
|
|
dirname = dirname.substr(windowOrigin.length);
|
|
}
|
|
|
|
return {
|
|
filename: filename,
|
|
dirname: dirname
|
|
};
|
|
}
|
|
}));
|
|
})();
|
|
|
|
$__System.register('2', ['3', '4', '5', '6', '7'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, ApiInfo;
|
|
|
|
return {
|
|
setters: [function (_5) {
|
|
RedocComponent = _5.RedocComponent;
|
|
BaseComponent = _5.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
ApiInfo = (function (_BaseComponent) {
|
|
_inherits(ApiInfo, _BaseComponent);
|
|
|
|
function ApiInfo(schemaMgr) {
|
|
_classCallCheck(this, _ApiInfo);
|
|
|
|
_get(Object.getPrototypeOf(_ApiInfo.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(ApiInfo, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = this.componentSchema.info;
|
|
}
|
|
}]);
|
|
|
|
var _ApiInfo = ApiInfo;
|
|
ApiInfo = RedocComponent({
|
|
selector: 'api-info',
|
|
styles: ['\n .api-info-header {\n color: #00329F; }\n '],
|
|
template: '\n <h1 class="api-info-header">{{data.title}} ({{data.version}})</h1>\n <p *ngIf="data.description" innerHtml="{{data.description | marked}}"> </p>\n <p>\n <!-- TODO: create separate components for contact and license ? -->\n <span *ngIf="data.contact"> Contact:\n <a *ngIf="data.contact.url" href="{{data.contact.url}}">\n {{data.contact.name || data.contact.url}}</a>\n <a *ngIf="data.contact.email" href="mailto:{{data.contact.email}}">\n {{data.contact.email}}</a>\n </span>\n <span *ngIf="data.license"> License:\n <a *ngIf="data.license.url" href="{{data.license.url}}"> {{data.license.name}} </a>\n <span *ngIf="!data.license.url"> {{data.license.name}} </span>\n </span>\n </p>\n '
|
|
})(ApiInfo) || ApiInfo;
|
|
return ApiInfo;
|
|
})(BaseComponent);
|
|
|
|
_export('default', ApiInfo);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('8', ['3', '4', '5', '6', '7'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, ApiInfo;
|
|
|
|
return {
|
|
setters: [function (_5) {
|
|
RedocComponent = _5.RedocComponent;
|
|
BaseComponent = _5.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
ApiInfo = (function (_BaseComponent) {
|
|
_inherits(ApiInfo, _BaseComponent);
|
|
|
|
function ApiInfo(schemaMgr) {
|
|
_classCallCheck(this, _ApiInfo);
|
|
|
|
_get(Object.getPrototypeOf(_ApiInfo.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(ApiInfo, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = {};
|
|
var logoInfo = this.componentSchema.info['x-logo'];
|
|
if (!logoInfo) return;
|
|
this.data.imgUrl = logoInfo.url;
|
|
this.data.bgColor = logoInfo.backgroundColor || 'transparent';
|
|
}
|
|
}]);
|
|
|
|
var _ApiInfo = ApiInfo;
|
|
ApiInfo = RedocComponent({
|
|
selector: 'api-logo',
|
|
styles: ['\n img {\n max-height: 150px;\n width: auto;\n display: inline-block;\n max-width: 100%;\n padding: 0 5px;\n box-sizing: border-box; }\n '],
|
|
template: '\n <img *ngIf="data.imgUrl" [attr.src]="data.imgUrl" [ngStyle]="{\'background-color\': data.bgColor}">\n '
|
|
})(ApiInfo) || ApiInfo;
|
|
return ApiInfo;
|
|
})(BaseComponent);
|
|
|
|
_export('default', ApiInfo);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('9', ['3', '4', '5', '6', '7', 'a'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, JsonSchema, ParamsList;
|
|
|
|
return {
|
|
setters: [function (_5) {
|
|
RedocComponent = _5.RedocComponent;
|
|
BaseComponent = _5.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_a) {
|
|
JsonSchema = _a['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
ParamsList = (function (_BaseComponent) {
|
|
_inherits(ParamsList, _BaseComponent);
|
|
|
|
function ParamsList(schemaMgr) {
|
|
_classCallCheck(this, _ParamsList);
|
|
|
|
_get(Object.getPrototypeOf(_ParamsList.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(ParamsList, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = {};
|
|
var params = this.schemaMgr.getMethodParams(this.pointer, true);
|
|
this.sortParams(params);
|
|
|
|
// temporary handle body param
|
|
if (params.length && params[params.length - 1]['in'] === 'body') {
|
|
var bodyParam = params.pop();
|
|
bodyParam.pointer = bodyParam._pointer;
|
|
this.data.bodyParam = bodyParam;
|
|
}
|
|
|
|
this.data.noParams = !(params.length || this.data.bodyParam);
|
|
this.data.params = params;
|
|
}
|
|
}, {
|
|
key: 'sortParams',
|
|
value: function sortParams(params) {
|
|
var sortOrder = {
|
|
'path': 0,
|
|
'query': 10,
|
|
'formData': 20,
|
|
'header': 40,
|
|
'body': 50
|
|
};
|
|
|
|
params.sort(function (a, b) {
|
|
return sortOrder[a['in']] - sortOrder[b['in']];
|
|
});
|
|
}
|
|
}]);
|
|
|
|
var _ParamsList = ParamsList;
|
|
ParamsList = RedocComponent({
|
|
selector: 'params-list',
|
|
template: '\n <h2 class="param-list-header" *ngIf="data.params.length"> Parameters </h2>\n <div class="params-wrap">\n <div *ngFor="#param of data.params" class="param">\n <div class="param-name">\n <span> {{param.name}} </span>\n </div>\n <div class="param-info">\n <div>\n <span class="param-type" [ngClass]="param.type">{{param.type}}</span>\n <span *ngIf="param.required" class="param-required">Required</span>\n </div>\n <div class="param-description" innerHtml="{{param.description | marked}}"></div>\n </div>\n </div>\n </div>\n\n <div *ngIf="data.bodyParam">\n <h2 class="param-list-header" *ngIf="data.bodyParam"> Request Body </h2>\n\n <div class="body-param-description" innerHtml="{{data.bodyParam.description | marked}}"></div>\n <div>\n <json-schema pointer="{{data.bodyParam.pointer}}/schema">\n </json-schema>\n </div>\n </div>\n ',
|
|
styles: ['\n .param-list-header {\n border-bottom: 1px solid #999;\n font-size: 18px;\n padding: 0.2em 0;\n margin: 0.5em 0;\n color: #253137; }\n\n .param-schema {\n padding-left: 12.5px;\n border-left: 1px solid #7D97CE; }\n\n .param-wrap {\n position: relative; }\n\n .param-schema:before {\n content: "";\n position: absolute;\n left: 13.5px;\n top: 20px;\n bottom: 0;\n border-left: 1px solid #7D97CE; }\n\n .param-name {\n font-size: 14px;\n padding: 10px 25px 10px 0;\n font-weight: bold;\n box-sizing: border-box;\n line-height: 20px;\n border-left: 1px solid #7D97CE;\n white-space: nowrap;\n position: relative; }\n .param-name > span {\n vertical-align: middle; }\n\n .param-info {\n width: 100%;\n padding: 10px 0;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc; }\n\n .param {\n display: flex; }\n\n .param-required {\n color: red;\n font-weight: bold;\n font-size: 12px;\n line-height: 20px;\n vertical-align: middle; }\n\n .param-type {\n text-transform: capitalize;\n color: #999;\n font-size: 12px;\n line-height: 20px;\n vertical-align: middle;\n font-weight: bold; }\n\n .param-type-trivial {\n margin: 10px 10px 0;\n display: inline-block; }\n\n /* tree */\n .param-name > span:before {\n content: "";\n display: inline-block;\n width: 7px;\n height: 7px;\n background-color: #7D97CE;\n margin: 0 10px;\n vertical-align: middle; }\n\n .param-name > span:after {\n content: "";\n position: absolute;\n border-top: 1px solid #7D97CE;\n width: 10px;\n left: 0;\n top: 20px; }\n\n .param-wrap:first-of-type .param-name:before {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n top: 0;\n border-left: 1px solid white;\n height: 20px; }\n\n .param-wrap:last-of-type > .param > .param-name:after {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n border-left: 1px solid white;\n top: 21px;\n background-color: white;\n bottom: 0; }\n\n .param-wrap:last-of-type > .param-schema {\n border-left-color: transparent; }\n\n .param-schema .param-wrap:first-of-type .param-name:before {\n display: none !important; }\n\n /* styles for array-schema for array */\n .params-wrap.params-array:before, .params-wrap.params-array:after {\n display: block;\n font-weight: bold;\n color: #999;\n font-size: 12px;\n line-height: 1.5; }\n\n .params-wrap.params-array:after {\n content: "]"; }\n\n .params-wrap.params-array:before {\n content: "Array ["; }\n\n .params-wrap.params-array {\n padding-left: 10px; }\n\n .param-schema.param-array:before {\n bottom: 9px;\n width: 10px;\n border-left-style: dashed;\n border-bottom: 1px dashed #7D97CE; }\n\n .params-wrap.params-array > .param-wrap:first-of-type > .param > .param-name:after {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n top: 0;\n border-left: 1px solid white;\n height: 20px; }\n\n .params-wrap {\n display: table; }\n\n .param-name {\n display: table-cell;\n vertical-align: top; }\n\n .param-info {\n display: table-cell; }\n\n .param {\n display: table-row; }\n\n .param:first-of-type .param-name:before {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n top: 0;\n border-left: 1px solid white;\n height: 20px; }\n\n .param:last-of-type .param-name:after {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n border-left: 1px solid white;\n top: 21px;\n background-color: white;\n bottom: 0; }\n '],
|
|
directives: [JsonSchema]
|
|
})(ParamsList) || ParamsList;
|
|
return ParamsList;
|
|
})(BaseComponent);
|
|
|
|
_export('default', ParamsList);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('b', ['3', '4', '5', '6', '7', '9', 'c', 'd', 'e', 'f'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, ParamsList, JsonPointer, ResponsesList, ResponsesSamples, SchemaSample, Method;
|
|
|
|
return {
|
|
setters: [function (_5) {
|
|
RedocComponent = _5.RedocComponent;
|
|
BaseComponent = _5.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_6) {
|
|
ParamsList = _6['default'];
|
|
}, function (_c) {
|
|
JsonPointer = _c.JsonPointer;
|
|
}, function (_d) {
|
|
ResponsesList = _d['default'];
|
|
}, function (_e) {
|
|
ResponsesSamples = _e['default'];
|
|
}, function (_f) {
|
|
SchemaSample = _f['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
Method = (function (_BaseComponent) {
|
|
_inherits(Method, _BaseComponent);
|
|
|
|
function Method(schemaMgr) {
|
|
_classCallCheck(this, _Method);
|
|
|
|
_get(Object.getPrototypeOf(_Method.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(Method, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = {};
|
|
this.data.apiUrl = this.schemaMgr.apiUrl;
|
|
this.data.httpMethod = JsonPointer.baseName(this.pointer);
|
|
this.data.path = JsonPointer.baseName(this.pointer, 2);
|
|
this.data.methodInfo = this.componentSchema;
|
|
this.data.methodInfo.tags = this.filterMainTags(this.data.methodInfo.tags);
|
|
this.data.bodyParam = this.findBodyParam();
|
|
}
|
|
}, {
|
|
key: 'filterMainTags',
|
|
value: function filterMainTags(tags) {
|
|
var tagsMap = this.schemaMgr.getTagsMap();
|
|
return tags.filter(function (tag) {
|
|
return tagsMap[tag] && tagsMap[tag]['x-traitTag'];
|
|
});
|
|
}
|
|
}, {
|
|
key: 'findBodyParam',
|
|
value: function findBodyParam() {
|
|
var pathParams = this.schemaMgr.getMethodParams(this.pointer, true);
|
|
var bodyParam = pathParams.find(function (param) {
|
|
return param['in'] === 'body';
|
|
});
|
|
return bodyParam;
|
|
}
|
|
}]);
|
|
|
|
var _Method = Method;
|
|
Method = RedocComponent({
|
|
selector: 'method',
|
|
template: '\n <div class="method">\n <div class="method-content">\n <h2 class="method-header sharable-header">\n <a class="share-link" href="#{{tag}}{{pointer}}"></a>{{data.methodInfo.summary}}\n </h2>\n <h3 class="method-endpoint">\n <span class="http-method" [ngClass]="data.httpMethod">{{data.httpMethod}}</span>\n <span class="api-url">{{data.apiUrl}}</span> <span class="path">{{data.path}}</span>\n </h3>\n <div class="method-tags" *ngIf="data.methodInfo.tags.length">\n <a *ngFor="#tag of data.methodInfo.tags" attr.href="#{{tag}}"> {{tag}} </a>\n </div>\n <p *ngIf="data.methodInfo.description" class="method-description"\n innerHtml="{{data.methodInfo.description | marked}}">\n </p>\n <params-list pointer="{{pointer}}/parameters"> </params-list>\n <responses-list pointer="{{pointer}}/responses"> </responses-list>\n </div>\n <div class="method-samples">\n <div *ngIf="data.bodyParam">\n <header> Body sample </header>\n <schema-sample pointer="{{data.bodyParam._pointer}}/schema"> </schema-sample>\n </div>\n <div>\n <responses-samples pointer="{{pointer}}/responses"> </responses-samples>\n </div>\n </div>\n <div>\n ',
|
|
styles: ['\n .share-link {\n cursor: pointer;\n margin-left: -15px;\n padding: 0;\n line-height: 1;\n width: 15px;\n display: inline-block; }\n\n .share-link:before {\n content: "";\n width: 15px;\n height: 15px;\n background-size: contain;\n background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMCIgeT0iMCIgd2lkdGg9IjUxMiIgaGVpZ2h0PSI1MTIiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBmaWxsPSIjMDEwMTAxIiBkPSJNNDU5LjcgMjMzLjRsLTkwLjUgOTAuNWMtNTAgNTAtMTMxIDUwLTE4MSAwIC03LjktNy44LTE0LTE2LjctMTkuNC0yNS44bDQyLjEtNDIuMWMyLTIgNC41LTMuMiA2LjgtNC41IDIuOSA5LjkgOCAxOS4zIDE1LjggMjcuMiAyNSAyNSA2NS42IDI0LjkgOTAuNSAwbDkwLjUtOTAuNWMyNS0yNSAyNS02NS42IDAtOTAuNSAtMjQuOS0yNS02NS41LTI1LTkwLjUgMGwtMzIuMiAzMi4yYy0yNi4xLTEwLjItNTQuMi0xMi45LTgxLjYtOC45bDY4LjYtNjguNmM1MC01MCAxMzEtNTAgMTgxIDBDNTA5LjYgMTAyLjMgNTA5LjYgMTgzLjQgNDU5LjcgMjMzLjR6TTIyMC4zIDM4Mi4ybC0zMi4yIDMyLjJjLTI1IDI0LjktNjUuNiAyNC45LTkwLjUgMCAtMjUtMjUtMjUtNjUuNiAwLTkwLjVsOTAuNS05MC41YzI1LTI1IDY1LjUtMjUgOTAuNSAwIDcuOCA3LjggMTIuOSAxNy4yIDE1LjggMjcuMSAyLjQtMS40IDQuOC0yLjUgNi44LTQuNWw0Mi4xLTQyYy01LjQtOS4yLTExLjYtMTgtMTkuNC0yNS44IC01MC01MC0xMzEtNTAtMTgxIDBsLTkwLjUgOTAuNWMtNTAgNTAtNTAgMTMxIDAgMTgxIDUwIDUwIDEzMSA1MCAxODEgMGw2OC42LTY4LjZDMjc0LjYgMzk1LjEgMjQ2LjQgMzkyLjMgMjIwLjMgMzgyLjJ6Ii8+PC9zdmc+Cg==");\n opacity: 0.5;\n visibility: hidden;\n display: inline-block;\n vertical-align: middle; }\n\n .sharable-header:hover .share-link:before, .share-link:hover:before {\n visibility: visible; }\n\n responses-list, params-list {\n display: block; }\n\n .method-header {\n font-size: 25px;\n font-weight: 200;\n color: #253137; }\n\n .method-endpoint {\n margin: 0;\n font-weight: 200;\n font-size: 0; }\n\n .method-endpoint > span {\n padding-top: 3px;\n padding-bottom: 3px;\n vertical-align: middle;\n font-size: 14px; }\n\n .api-url {\n color: #999;\n margin-left: 10px; }\n\n .path {\n font-family: monospace;\n font-weight: bold;\n color: #00329F; }\n\n .method-tags {\n margin-top: 20px; }\n\n .method-tags a {\n font-size: 16px;\n color: #999;\n display: inline-block;\n padding: 0 0.5em;\n text-decoration: none; }\n\n .method-tags a:before {\n content: \'#\';\n margin-right: -0.4em; }\n\n .method-tags a:first-of-type {\n padding: 0; }\n\n .method-content, .method-samples {\n display: block;\n box-sizing: border-box;\n float: left; }\n\n .method-content {\n width: 60%;\n padding: 0 20px; }\n\n .method-samples {\n color: #CFD2D3;\n width: 40%;\n padding: 10px 20px; }\n\n responses-samples {\n display: block; }\n\n .method-samples header {\n font-size: 16px;\n margin: 5px 0;\n color: #8A9094;\n text-transform: uppercase; }\n\n .method-samples schema-sample {\n display: block; }\n\n .method:after {\n content: "";\n display: table;\n clear: both; }\n\n .method-description {\n padding: 30px 0; }\n\n .http-method {\n color: white;\n background-color: #1976D3;\n padding: 3px 10px;\n text-transform: uppercase; }\n\n .http-method.delete {\n background-color: red; }\n\n .http-method.post {\n background-color: #00329F; }\n\n .http-method.patch {\n background-color: orange; }\n\n .http-method.put {\n background-color: crimson; }\n\n .http-method.options {\n background-color: black; }\n\n .http-method.head {\n background-color: darkkhaki; }\n '],
|
|
directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample],
|
|
inputs: ['tag']
|
|
})(Method) || Method;
|
|
return Method;
|
|
})(BaseComponent);
|
|
|
|
_export('default', Method);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('10', ['3', '4', '5', '6', '7', '11', '12', 'b'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, _slicedToArray, _Array$from, Method, MethodsList;
|
|
|
|
return {
|
|
setters: [function (_7) {
|
|
RedocComponent = _7.RedocComponent;
|
|
BaseComponent = _7.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_5) {
|
|
_slicedToArray = _5['default'];
|
|
}, function (_6) {
|
|
_Array$from = _6['default'];
|
|
}, function (_b) {
|
|
Method = _b['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
MethodsList = (function (_BaseComponent) {
|
|
_inherits(MethodsList, _BaseComponent);
|
|
|
|
function MethodsList(schemaMgr) {
|
|
_classCallCheck(this, _MethodsList);
|
|
|
|
_get(Object.getPrototypeOf(_MethodsList.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(MethodsList, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = {};
|
|
// follow SwaggerUI behavior for cases when one method has more than one tag:
|
|
// duplicate methods
|
|
|
|
var menuStructure = this.schemaMgr.buildMenuTree();
|
|
var tags = _Array$from(menuStructure.entries()).map(function (entry) {
|
|
var _entry = _slicedToArray(entry, 2);
|
|
|
|
var tag = _entry[0];
|
|
var _entry$1 = _entry[1];
|
|
var description = _entry$1.description;
|
|
var methods = _entry$1.methods;
|
|
|
|
// inject tag name into method info
|
|
methods = methods || [];
|
|
methods.forEach(function (method) {
|
|
method.tag = tag;
|
|
});
|
|
return {
|
|
name: tag,
|
|
description: description,
|
|
methods: methods
|
|
};
|
|
});
|
|
this.data.tags = tags;
|
|
// TODO: check $ref field
|
|
}
|
|
}]);
|
|
|
|
var _MethodsList = MethodsList;
|
|
MethodsList = RedocComponent({
|
|
selector: 'methods-list',
|
|
template: '\n <div class="methods">\n <div class="tag" *ngFor="#tag of data.tags">\n <div class="tag-info" [attr.tag]="tag.name">\n <h1 class="sharable-header"> <a class="share-link" href="#{{tag.name}}"></a>{{tag.name}} </h1>\n <p *ngIf="tag.description" innerHtml="{{ tag.description | marked }}"> </p>\n </div>\n <method *ngFor="#method of tag.methods" [pointer]="method.pointer" [attr.pointer]="method.pointer"\n [attr.tag]="method.tag" [tag]="method.tag"></method>\n </div>\n </div>\n ',
|
|
styles: ['\n .share-link {\n cursor: pointer;\n margin-left: -15px;\n padding: 0;\n line-height: 1;\n width: 15px;\n display: inline-block; }\n\n .share-link:before {\n content: "";\n width: 15px;\n height: 15px;\n background-size: contain;\n background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMCIgeT0iMCIgd2lkdGg9IjUxMiIgaGVpZ2h0PSI1MTIiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBmaWxsPSIjMDEwMTAxIiBkPSJNNDU5LjcgMjMzLjRsLTkwLjUgOTAuNWMtNTAgNTAtMTMxIDUwLTE4MSAwIC03LjktNy44LTE0LTE2LjctMTkuNC0yNS44bDQyLjEtNDIuMWMyLTIgNC41LTMuMiA2LjgtNC41IDIuOSA5LjkgOCAxOS4zIDE1LjggMjcuMiAyNSAyNSA2NS42IDI0LjkgOTAuNSAwbDkwLjUtOTAuNWMyNS0yNSAyNS02NS42IDAtOTAuNSAtMjQuOS0yNS02NS41LTI1LTkwLjUgMGwtMzIuMiAzMi4yYy0yNi4xLTEwLjItNTQuMi0xMi45LTgxLjYtOC45bDY4LjYtNjguNmM1MC01MCAxMzEtNTAgMTgxIDBDNTA5LjYgMTAyLjMgNTA5LjYgMTgzLjQgNDU5LjcgMjMzLjR6TTIyMC4zIDM4Mi4ybC0zMi4yIDMyLjJjLTI1IDI0LjktNjUuNiAyNC45LTkwLjUgMCAtMjUtMjUtMjUtNjUuNiAwLTkwLjVsOTAuNS05MC41YzI1LTI1IDY1LjUtMjUgOTAuNSAwIDcuOCA3LjggMTIuOSAxNy4yIDE1LjggMjcuMSAyLjQtMS40IDQuOC0yLjUgNi44LTQuNWw0Mi4xLTQyYy01LjQtOS4yLTExLjYtMTgtMTkuNC0yNS44IC01MC01MC0xMzEtNTAtMTgxIDBsLTkwLjUgOTAuNWMtNTAgNTAtNTAgMTMxIDAgMTgxIDUwIDUwIDEzMSA1MCAxODEgMGw2OC42LTY4LjZDMjc0LjYgMzk1LjEgMjQ2LjQgMzkyLjMgMjIwLjMgMzgyLjJ6Ii8+PC9zdmc+Cg==");\n opacity: 0.5;\n visibility: hidden;\n display: inline-block;\n vertical-align: middle; }\n\n .sharable-header:hover .share-link:before, .share-link:hover:before {\n visibility: visible; }\n\n method {\n padding-bottom: 100px;\n display: block;\n border-bottom: 2px solid rgba(127, 127, 127, 0.25); }\n\n .tag-info {\n padding: 0 20px;\n box-sizing: border-box;\n background-color: white; }\n\n .tag-info:after, .tag-info:before {\n content: "";\n display: table; }\n\n .tag-info h1 {\n color: #00329F;\n text-transform: capitalize;\n font-weight: bold; }\n\n .methods {\n display: block;\n position: relative; }\n\n .methods:before {\n content: "";\n background: #263238;\n height: 100%;\n width: 40%;\n top: 0;\n right: 0;\n position: absolute;\n z-index: -1; }\n '],
|
|
directives: [Method]
|
|
})(MethodsList) || MethodsList;
|
|
return MethodsList;
|
|
})(BaseComponent);
|
|
|
|
_export('default', MethodsList);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('13', ['6', '7', '14', '15'], function (_export) {
|
|
var _createClass, _classCallCheck, Component, View, OnInit, OnDestroy, ElementRef, BrowserDomAdapter, StickySidebar;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_3) {
|
|
Component = _3.Component;
|
|
View = _3.View;
|
|
OnInit = _3.OnInit;
|
|
OnDestroy = _3.OnDestroy;
|
|
ElementRef = _3.ElementRef;
|
|
}, function (_4) {
|
|
BrowserDomAdapter = _4.BrowserDomAdapter;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
StickySidebar = (function () {
|
|
function StickySidebar(elementRef, adapter) {
|
|
_classCallCheck(this, _StickySidebar);
|
|
|
|
this.element = elementRef.nativeElement;
|
|
this.adapter = adapter;
|
|
|
|
// initial styling
|
|
this.adapter.setStyle(this.element, 'position', 'absolute');
|
|
this.adapter.setStyle(this.element, 'top', '0');
|
|
this.adapter.setStyle(this.element, 'bottom', '0');
|
|
this.adapter.setStyle(this.element, 'max-height', '100%');
|
|
}
|
|
|
|
_createClass(StickySidebar, [{
|
|
key: 'bind',
|
|
value: function bind() {
|
|
var _this = this;
|
|
|
|
this.cancelScrollBinding = this.adapter.onAndCancel(this.scrollParent, 'scroll', function () {
|
|
_this.updatePosition();
|
|
});
|
|
this.updatePosition();
|
|
}
|
|
}, {
|
|
key: 'unbind',
|
|
value: function unbind() {
|
|
this.cancelScrollBinding && this.cancelScrollBinding();
|
|
}
|
|
}, {
|
|
key: 'updatePosition',
|
|
value: function updatePosition() {
|
|
if (this.scrollY + this.scrollYOffset() >= this.redocEl.offsetTop) {
|
|
this.stick();
|
|
} else {
|
|
this.unstick();
|
|
}
|
|
}
|
|
}, {
|
|
key: 'stick',
|
|
value: function stick() {
|
|
this.adapter.setStyle(this.element, 'position', 'fixed');
|
|
this.adapter.setStyle(this.element, 'top', this.scrollYOffset());
|
|
}
|
|
}, {
|
|
key: 'unstick',
|
|
value: function unstick() {
|
|
this.adapter.setStyle(this.element, 'position', 'absolute');
|
|
this.adapter.setStyle(this.element, 'top', 0);
|
|
}
|
|
}, {
|
|
key: 'ngOnInit',
|
|
value: function ngOnInit() {
|
|
this.redocEl = this.element.offsetParent;
|
|
this.bind();
|
|
}
|
|
}, {
|
|
key: 'ngOnDestroy',
|
|
value: function ngOnDestroy() {
|
|
this.unbind();
|
|
}
|
|
}, {
|
|
key: 'scrollY',
|
|
get: function get() {
|
|
return this.scrollParent.scrollY || this.scrollParent.scrollTop || 0;
|
|
}
|
|
}]);
|
|
|
|
var _StickySidebar = StickySidebar;
|
|
StickySidebar = View({
|
|
template: '\n <div class="sticky-sidebar">\n <ng-content></ng-content>\n </div>\n ',
|
|
lifecycle: [OnInit, OnDestroy]
|
|
})(StickySidebar) || StickySidebar;
|
|
StickySidebar = Component({
|
|
selector: 'sticky-sidebar',
|
|
inputs: ['scrollParent', 'scrollYOffset']
|
|
})(StickySidebar) || StickySidebar;
|
|
return StickySidebar;
|
|
})();
|
|
|
|
_export('default', StickySidebar);
|
|
|
|
StickySidebar.parameters = [[ElementRef], [BrowserDomAdapter]];
|
|
}
|
|
};
|
|
});
|
|
$__System.register('16', ['6', '7', '17'], function (_export) {
|
|
var _createClass, _classCallCheck, _Object$assign, options, OptionsManager;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_3) {
|
|
_Object$assign = _3['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
options = {
|
|
scrollYOffset: 0
|
|
};
|
|
|
|
_export('options', options);
|
|
|
|
// singleton
|
|
|
|
OptionsManager = (function () {
|
|
function OptionsManager() {
|
|
_classCallCheck(this, OptionsManager);
|
|
|
|
if (OptionsManager.prototype._instance) {
|
|
return OptionsManager.prototype._instance;
|
|
}
|
|
|
|
OptionsManager.prototype._instance = this;
|
|
|
|
this._defaults = {
|
|
scrollYOffset: 0
|
|
};
|
|
|
|
this._options = {};
|
|
}
|
|
|
|
_createClass(OptionsManager, [{
|
|
key: 'options',
|
|
get: function get() {
|
|
return this._options;
|
|
},
|
|
set: function set(opts) {
|
|
this._options = _Object$assign({}, this._defaults, opts);
|
|
}
|
|
}]);
|
|
|
|
return OptionsManager;
|
|
})();
|
|
|
|
_export('default', OptionsManager);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("18", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
;
|
|
(function() {
|
|
var parents = function(node, ps) {
|
|
if (node.parentNode === null) {
|
|
return ps;
|
|
}
|
|
return parents(node.parentNode, ps.concat([node]));
|
|
};
|
|
var style = function(node, prop) {
|
|
return getComputedStyle(node, null).getPropertyValue(prop);
|
|
};
|
|
var overflow = function(node) {
|
|
return style(node, "overflow") + style(node, "overflow-y") + style(node, "overflow-x");
|
|
};
|
|
var scroll = function(node) {
|
|
return (/(auto|scroll)/).test(overflow(node));
|
|
};
|
|
var scrollParent = function(node) {
|
|
if (!(node instanceof HTMLElement)) {
|
|
return;
|
|
}
|
|
var ps = parents(node.parentNode, []);
|
|
for (var i = 0; i < ps.length; i += 1) {
|
|
if (scroll(ps[i])) {
|
|
return ps[i];
|
|
}
|
|
}
|
|
return window;
|
|
};
|
|
if (typeof module === "object" && module !== null) {
|
|
module.exports = scrollParent;
|
|
} else {
|
|
window.Scrollparent = scrollParent;
|
|
}
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("19", ["18"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('18');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('1a', ['2', '3', '4', '5', '6', '7', '8', '10', '12', '13', '14', '15', '16', '17', '19', '20', '1e', '1f', '1b', '1c', '1d'], function (_export) {
|
|
var ApiInfo, RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, ApiLogo, MethodsList, _Array$from, StickySidebar, ChangeDetectionStrategy, ElementRef, BrowserDomAdapter, bootstrap, OptionsManager, _Object$assign, detectScollParent, isFunction, _Set, _Promise, SchemaManager, SideMenu, redocEvents, optionNames, Redoc;
|
|
|
|
return {
|
|
setters: [function (_8) {
|
|
ApiInfo = _8['default'];
|
|
}, function (_7) {
|
|
RedocComponent = _7.RedocComponent;
|
|
BaseComponent = _7.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_9) {
|
|
ApiLogo = _9['default'];
|
|
}, function (_10) {
|
|
MethodsList = _10['default'];
|
|
}, function (_6) {
|
|
_Array$from = _6['default'];
|
|
}, function (_11) {
|
|
StickySidebar = _11['default'];
|
|
}, function (_13) {
|
|
ChangeDetectionStrategy = _13.ChangeDetectionStrategy;
|
|
ElementRef = _13.ElementRef;
|
|
}, function (_14) {
|
|
BrowserDomAdapter = _14.BrowserDomAdapter;
|
|
bootstrap = _14.bootstrap;
|
|
}, function (_12) {
|
|
OptionsManager = _12['default'];
|
|
}, function (_5) {
|
|
_Object$assign = _5['default'];
|
|
}, function (_15) {
|
|
detectScollParent = _15['default'];
|
|
}, function (_16) {
|
|
isFunction = _16.isFunction;
|
|
}, function (_e) {
|
|
_Set = _e['default'];
|
|
}, function (_f) {
|
|
_Promise = _f['default'];
|
|
}, function (_b) {
|
|
SchemaManager = _b['default'];
|
|
}, function (_c) {
|
|
SideMenu = _c['default'];
|
|
}, function (_d) {
|
|
redocEvents = _d.redocEvents;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
optionNames = new _Set(['scrollYOffset']);
|
|
|
|
Redoc = (function (_BaseComponent) {
|
|
_inherits(Redoc, _BaseComponent);
|
|
|
|
function Redoc(schemaMgr, optionsMgr, elementRef, dom) {
|
|
_classCallCheck(this, _Redoc);
|
|
|
|
_get(Object.getPrototypeOf(_Redoc.prototype), 'constructor', this).call(this, schemaMgr);
|
|
this.element = elementRef.nativeElement;
|
|
|
|
this.dom = dom;
|
|
var el = this.element;
|
|
|
|
//parse options (top level component doesn't support inputs)
|
|
this.scrollParent = detectScollParent(el);
|
|
this.parseOptions();
|
|
this.options = _Object$assign({}, optionsMgr.options, this.options);
|
|
this.normalizeOptions();
|
|
}
|
|
|
|
_createClass(Redoc, [{
|
|
key: 'parseOptions',
|
|
value: function parseOptions() {
|
|
var _this = this;
|
|
|
|
var attributesMap = this.dom.attributeMap(this.element);
|
|
this.options = {};
|
|
_Array$from(attributesMap.keys())
|
|
//camelCasify
|
|
.map(function (k) {
|
|
return {
|
|
attrName: k,
|
|
name: k.replace(/-(.)/g, function (m, $1) {
|
|
return $1.toUpperCase();
|
|
})
|
|
};
|
|
}).filter(function (option) {
|
|
return optionNames.has(option.name);
|
|
}).forEach(function (option) {
|
|
_this.options[option.name] = attributesMap.get(option.attrName);
|
|
});
|
|
}
|
|
}, {
|
|
key: 'normalizeOptions',
|
|
value: function normalizeOptions() {
|
|
var _this2 = this;
|
|
|
|
// modify scrollYOffset to always be a function
|
|
if (!isFunction(this.options.scrollYOffset)) {
|
|
if (isFinite(this.options.scrollYOffset)) {
|
|
(function () {
|
|
// if number specified create function that returns this value
|
|
var numberOffset = parseFloat(_this2.options.scrollYOffset);
|
|
_this2.options.scrollYOffset = function () {
|
|
return numberOffset;
|
|
};
|
|
})();
|
|
} else {
|
|
(function () {
|
|
// if selector or node function that returns bottom offset of this node
|
|
var el = _this2.options.scrollYOffset;
|
|
if (!(el instanceof Node)) {
|
|
el = _this2.dom.query(el);
|
|
}
|
|
if (!el) {
|
|
_this2.options.scrollYOffset = function () {
|
|
return 0;
|
|
};
|
|
} else {
|
|
_this2.options.scrollYOffset = function () {
|
|
return el.offsetTop + el.offsetHeight;
|
|
};
|
|
}
|
|
})();
|
|
}
|
|
}
|
|
}
|
|
}], [{
|
|
key: 'init',
|
|
value: function init(schemaUrl, options) {
|
|
var promise = new _Promise(function (resolve, reject) {
|
|
|
|
SchemaManager.instance().load(schemaUrl).then(function () {
|
|
new OptionsManager().options = options;
|
|
return bootstrap(Redoc);
|
|
}).then(function () {
|
|
redocEvents.bootstrapped.next();
|
|
console.log('ReDoc bootstrapped!');
|
|
resolve();
|
|
}, function (error) {
|
|
console.log(error);
|
|
reject();
|
|
});
|
|
});
|
|
return promise;
|
|
}
|
|
}]);
|
|
|
|
var _Redoc = Redoc;
|
|
Redoc = RedocComponent({
|
|
selector: 'redoc',
|
|
providers: [SchemaManager, BrowserDomAdapter, OptionsManager],
|
|
template: '\n <div class="redoc-wrap">\n <sticky-sidebar [scrollParent]="scrollParent" [scrollYOffset]="options.scrollYOffset">\n <api-logo> </api-logo>\n <side-menu> </side-menu>\n </sticky-sidebar>\n <div id="api-content">\n <api-info> </api-info>\n <methods-list> </methods-list>\n <footer>\n <div class="powered-by-badge">\n <a href="https://github.com/Rebilly/ReDoc" title="Swagger-generated API Reference Documentation" target="_blank">\n Powered by <strong>ReDoc</strong>\n </a>\n </div>\n </footer>\n </div>\n </div>\n ',
|
|
styles: ['\n .redoc-wrap {\n position: relative; }\n\n side-menu {\n display: block;\n box-sizing: border-box; }\n\n methods-list {\n display: block;\n overflow: hidden; }\n\n api-info, .side-bar {\n display: block;\n padding: 10px 0; }\n\n api-info {\n padding: 10px 20px; }\n\n api-logo {\n display: block;\n text-align: center; }\n\n sticky-sidebar {\n width: 260px;\n overflow-y: auto;\n overflow-x: hidden;\n background-color: #FAFAFA; }\n\n #api-content {\n margin-left: 260px; }\n\n footer {\n text-align: right;\n padding: 10px;\n font-size: 15px; }\n footer a {\n color: #999;\n text-decoration: none; }\n footer strong {\n font-size: 18px;\n color: #00329F; }\n '],
|
|
directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar],
|
|
changeDetection: ChangeDetectionStrategy.Default
|
|
})(Redoc) || Redoc;
|
|
return Redoc;
|
|
})(BaseComponent);
|
|
|
|
_export('default', Redoc);
|
|
|
|
Redoc.parameters = Redoc.parameters.concat([[OptionsManager], [ElementRef], [BrowserDomAdapter]]);
|
|
|
|
// this doesn't work in side-menu.js because of some circular references issue
|
|
SideMenu.parameters = SideMenu.parameters.concat([[Redoc]]);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('21', ['6', '7', '14', '22'], function (_export) {
|
|
var _createClass, _classCallCheck, Component, View, EventEmitter, CORE_DIRECTIVES, Zippy;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_3) {
|
|
Component = _3.Component;
|
|
View = _3.View;
|
|
EventEmitter = _3.EventEmitter;
|
|
}, function (_4) {
|
|
CORE_DIRECTIVES = _4.CORE_DIRECTIVES;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
Zippy = (function () {
|
|
function Zippy() {
|
|
_classCallCheck(this, _Zippy);
|
|
|
|
this.type = 'general';
|
|
this.visible = false;
|
|
this.empty = false;
|
|
this.open = new EventEmitter();
|
|
this.close = new EventEmitter();
|
|
}
|
|
|
|
_createClass(Zippy, [{
|
|
key: 'toggle',
|
|
value: function toggle() {
|
|
this.visible = !this.visible;
|
|
if (this.empty) return;
|
|
this.visible ? this.open.next() : this.close.next();
|
|
}
|
|
}]);
|
|
|
|
var _Zippy = Zippy;
|
|
Zippy = View({
|
|
template: '\n <div class="zippy zippy-{{type}}" [ngClass]="{\'zippy-empty\': empty}">\n <div class="zippy-title" (click)="toggle()">\n <span class="zippy-indicator">{{ visible ? \'▾\' : \'▸\' }}</span>\n {{title}}\n </div>\n <div class="zippy-content" [ngClass]="{\'zippy-hidden\': !visible}">\n <ng-content></ng-content>\n </div>\n </div>\n ',
|
|
styles: ['\n .zippy-title {\n padding: 10px;\n margin: 2px 0;\n line-height: 1.5em;\n background-color: #f2f2f2;\n cursor: pointer; }\n .zippy-success > .zippy-title {\n color: #09AC1C;\n background-color: #E1F5E3; }\n .zippy-error > .zippy-title {\n color: #E54541;\n background-color: #FBE7E7; }\n .zippy-redirect > .zippy-title {\n color: #AC7C09;\n background-color: #F5F0E1; }\n .zippy-info > .zippy-title {\n color: #096DAC;\n background-color: #E1EFF5; }\n\n span.zippy-indicator {\n font-size: 1.5em;\n line-height: 1;\n margin-right: 0.2em;\n vertical-align: text-bottom; }\n\n .zippy-content {\n padding: 15px 0; }\n\n .zippy-empty .zippy-title {\n cursor: default; }\n\n .zippy-empty .zippy-indicator {\n display: none; }\n\n .zippy-empty .zippy-content {\n display: none; }\n\n .zippy-hidden {\n visibility: hidden;\n height: 0;\n padding: 0; }\n '],
|
|
directives: [CORE_DIRECTIVES]
|
|
})(Zippy) || Zippy;
|
|
Zippy = Component({
|
|
selector: 'zippy',
|
|
events: ['open', 'close'],
|
|
inputs: ['title', 'visible', 'type', 'empty']
|
|
})(Zippy) || Zippy;
|
|
return Zippy;
|
|
})();
|
|
|
|
_export('default', Zippy);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('d', ['3', '4', '5', '6', '7', '21', '23', '24', 'c', 'a'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, Zippy, statusCodeType, _Object$keys, JsonPointer, JsonSchema, ResponsesList;
|
|
|
|
function isNumeric(n) {
|
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
|
}
|
|
|
|
return {
|
|
setters: [function (_6) {
|
|
RedocComponent = _6.RedocComponent;
|
|
BaseComponent = _6.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_7) {
|
|
Zippy = _7['default'];
|
|
}, function (_8) {
|
|
statusCodeType = _8.statusCodeType;
|
|
}, function (_5) {
|
|
_Object$keys = _5['default'];
|
|
}, function (_c) {
|
|
JsonPointer = _c['default'];
|
|
}, function (_a) {
|
|
JsonSchema = _a['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
ResponsesList = (function (_BaseComponent) {
|
|
_inherits(ResponsesList, _BaseComponent);
|
|
|
|
function ResponsesList(schemaMgr) {
|
|
_classCallCheck(this, _ResponsesList);
|
|
|
|
_get(Object.getPrototypeOf(_ResponsesList.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(ResponsesList, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
var _this = this;
|
|
|
|
this.data = {};
|
|
this.data.responses = [];
|
|
|
|
var responses = this.componentSchema;
|
|
if (!responses) return;
|
|
|
|
responses = _Object$keys(responses).filter(function (respCode) {
|
|
// only response-codes and "default"
|
|
return isNumeric(respCode) || respCode === 'default';
|
|
}).map(function (respCode) {
|
|
var resp = responses[respCode];
|
|
resp.pointer = JsonPointer.join(_this.pointer, respCode);
|
|
if (resp.$ref) {
|
|
var ref = resp.$ref;
|
|
resp = _this.schemaMgr.byPointer(resp.$ref);
|
|
resp.pointer = ref;
|
|
}
|
|
|
|
resp.code = respCode;
|
|
resp.type = statusCodeType(resp.code);
|
|
if (resp.headers) {
|
|
resp.headers = _Object$keys(resp.headers).map(function (k) {
|
|
var respInfo = resp.headers[k];
|
|
respInfo.name = k;
|
|
return respInfo;
|
|
});
|
|
}
|
|
resp.extendable = resp.headers || resp.length;
|
|
return resp;
|
|
});
|
|
this.data.responses = responses;
|
|
}
|
|
}]);
|
|
|
|
var _ResponsesList = ResponsesList;
|
|
ResponsesList = RedocComponent({
|
|
selector: 'responses-list',
|
|
template: '\n <h2 class="responses-list-header" *ngIf="data.responses.length"> Responses </h2>\n <zippy *ngFor="#response of data.responses" title="{{response.code}} {{response.description}}"\n [type]="response.type" [empty]="!response.schema">\n <div *ngIf="response.headers" class="response-headers">\n <header>\n Headers\n </header>\n <div class="header" *ngFor="#header of response.headers">\n <div class="header-name"> {{header.name}} </div>\n <div class="header-type"> {{header.type}} </div>\n <div class="header-description" innerHtml="{{header.description | marked}}"> </div>\n </div>\n </div>\n <header>\n Response schema\n </header>\n <json-schema *ngIf="response.schema" class="schema type" pointer="{{response.pointer}}/schema">\n </json-schema>\n </zippy>\n ',
|
|
styles: ['\n .responses-list-header {\n font-size: 18px;\n padding: 0.2em 0;\n margin: 0.5em 0;\n color: #253137; }\n\n .header-name {\n font-weight: bold;\n display: inline-block; }\n\n .header-type {\n display: inline-block;\n font-weight: bold;\n color: #999; }\n\n header {\n font-size: 14px;\n font-weight: bold;\n text-transform: uppercase;\n margin-bottom: 15px; }\n\n .header {\n margin-bottom: 10px; }\n '],
|
|
directives: [JsonSchema, Zippy]
|
|
})(ResponsesList) || ResponsesList;
|
|
return ResponsesList;
|
|
})(BaseComponent);
|
|
|
|
_export('default', ResponsesList);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('25', ['6', '7', '14', '22'], function (_export) {
|
|
var _createClass, _classCallCheck, Component, View, CORE_DIRECTIVES, Tabs, Tab;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_3) {
|
|
Component = _3.Component;
|
|
View = _3.View;
|
|
}, function (_4) {
|
|
CORE_DIRECTIVES = _4.CORE_DIRECTIVES;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
Tabs = (function () {
|
|
function Tabs() {
|
|
_classCallCheck(this, _Tabs);
|
|
|
|
this.tabs = [];
|
|
}
|
|
|
|
_createClass(Tabs, [{
|
|
key: 'selectTab',
|
|
value: function selectTab(tab) {
|
|
this.tabs.forEach(function (tab) {
|
|
tab.active = false;
|
|
});
|
|
tab.active = true;
|
|
}
|
|
}, {
|
|
key: 'addTab',
|
|
value: function addTab(tab) {
|
|
if (this.tabs.length === 0) {
|
|
tab.active = true;
|
|
}
|
|
this.tabs.push(tab);
|
|
}
|
|
}]);
|
|
|
|
var _Tabs = Tabs;
|
|
Tabs = View({
|
|
template: '\n <ul>\n <li *ngFor="#tab of tabs" [ngClass]="{active: tab.active}" (click)="selectTab(tab)"\n class="tab-{{tab.tabStatus}}"> {{tab.tabTitle}}\n </li>\n </ul>\n <ng-content></ng-content>\n ',
|
|
directives: [CORE_DIRECTIVES],
|
|
styles: ['\n ul {\n display: block;\n margin: 0;\n padding: 10px 0px 0 0; }\n\n li {\n font-size: 13px;\n list-style: none;\n margin: 2px 0;\n padding: 2px 5px;\n display: inline-block;\n cursor: pointer;\n color: #8A9094;\n line-height: 1.25;\n color: #8A9094; }\n\n li.active {\n background-color: white;\n color: #666; }\n\n .tab-success:before, .tab-error:before, .tab-redirect:before, .tab-info:before {\n content: "";\n display: inline-block;\n vertical-align: middle;\n height: 6px;\n width: 6px;\n border-radius: 50%; }\n\n .tab-success:before {\n box-shadow: 0 0 3px 0 #00aa11;\n background-color: #00aa11; }\n\n .tab-error:before {\n box-shadow: 0 0 3px 0 #E53935;\n background-color: #E53935; }\n\n .tab-redirect:before {\n box-shadow: 0 0 3px 0 #F88F00;\n background-color: #F88F00; }\n\n .tab-info:before {\n box-shadow: 0 0 3px 0 #66C2FF;\n background-color: #66C2FF; }\n ']
|
|
})(Tabs) || Tabs;
|
|
Tabs = Component({
|
|
selector: 'tabs'
|
|
})(Tabs) || Tabs;
|
|
return Tabs;
|
|
})();
|
|
|
|
_export('Tabs', Tabs);
|
|
|
|
Tab = (function () {
|
|
function Tab(tabs) {
|
|
_classCallCheck(this, _Tab);
|
|
|
|
this.active = false;
|
|
tabs.addTab(this);
|
|
}
|
|
|
|
var _Tab = Tab;
|
|
Tab = View({
|
|
template: '\n <div class="tab-wrap" [hidden]="!active">\n <ng-content></ng-content>\n </div>\n '
|
|
})(Tab) || Tab;
|
|
Tab = Component({
|
|
selector: 'tab',
|
|
inputs: ['tabTitle', 'tabStatus']
|
|
})(Tab) || Tab;
|
|
return Tab;
|
|
})();
|
|
|
|
_export('Tab', Tab);
|
|
|
|
Tab.parameters = [[Tabs]];
|
|
}
|
|
};
|
|
});
|
|
$__System.register('23', [], function (_export) {
|
|
'use strict';
|
|
|
|
_export('statusCodeType', statusCodeType);
|
|
|
|
function statusCodeType(statusCode) {
|
|
if (statusCode < 100 || statusCode > 599) {
|
|
throw new Error('invalid HTTP code');
|
|
}
|
|
var res = 'success';
|
|
if (statusCode >= 300 && statusCode < 400) {
|
|
res = 'redirect';
|
|
} else if (statusCode >= 400) {
|
|
res = 'error';
|
|
} else if (statusCode < 200) {
|
|
res = 'info';
|
|
}
|
|
return res;
|
|
}
|
|
|
|
return {
|
|
setters: [],
|
|
execute: function () {}
|
|
};
|
|
});
|
|
$__System.register('e', ['3', '4', '5', '6', '7', '23', '24', '25', 'c', 'f'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, statusCodeType, _Object$keys, Tabs, Tab, JsonPointer, SchemaSample, ResponsesSamples;
|
|
|
|
function isNumeric(n) {
|
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
|
}
|
|
|
|
function hasExample(response) {
|
|
return response.examples && response.examples['application/json'] || response.schema;
|
|
}
|
|
|
|
return {
|
|
setters: [function (_6) {
|
|
RedocComponent = _6.RedocComponent;
|
|
BaseComponent = _6.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_8) {
|
|
statusCodeType = _8.statusCodeType;
|
|
}, function (_5) {
|
|
_Object$keys = _5['default'];
|
|
}, function (_7) {
|
|
Tabs = _7.Tabs;
|
|
Tab = _7.Tab;
|
|
}, function (_c) {
|
|
JsonPointer = _c['default'];
|
|
}, function (_f) {
|
|
SchemaSample = _f['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
ResponsesSamples = (function (_BaseComponent) {
|
|
_inherits(ResponsesSamples, _BaseComponent);
|
|
|
|
function ResponsesSamples(schemaMgr) {
|
|
_classCallCheck(this, _ResponsesSamples);
|
|
|
|
_get(Object.getPrototypeOf(_ResponsesSamples.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(ResponsesSamples, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
var _this = this;
|
|
|
|
this.data = {};
|
|
this.data.responses = [];
|
|
|
|
var responses = this.componentSchema;
|
|
if (!responses) return;
|
|
|
|
responses = _Object$keys(responses).filter(function (respCode) {
|
|
// only response-codes and "default"
|
|
return isNumeric(respCode) || respCode === 'default';
|
|
}).map(function (respCode) {
|
|
var resp = responses[respCode];
|
|
resp.pointer = JsonPointer.join(_this.pointer, respCode);
|
|
if (resp.$ref) {
|
|
var ref = resp.$ref;
|
|
resp = _this.schemaMgr.byPointer(resp.$ref);
|
|
resp.pointer = ref;
|
|
}
|
|
|
|
resp.code = respCode;
|
|
resp.type = statusCodeType(resp.code);
|
|
return resp;
|
|
}).filter(function (response) {
|
|
return hasExample(response);
|
|
});
|
|
this.data.responses = responses;
|
|
}
|
|
}]);
|
|
|
|
var _ResponsesSamples = ResponsesSamples;
|
|
ResponsesSamples = RedocComponent({
|
|
selector: 'responses-samples',
|
|
template: '\n <header *ngIf="data.responses.length"> Responses samples </header>\n <tabs *ngIf="data.responses.length">\n <tab *ngFor="#response of data.responses" tabTitle="{{response.code}} {{response.description}}"\n [tabStatus]="response.type">\n <schema-sample [pointer]="response.pointer"></schema-sample>\n </tab>\n </tabs>\n ',
|
|
styles: ['\n tab, tabs {\n display: block; }\n\n schema-sample {\n display: block; }\n\n header {\n font-size: 16px;\n margin: 5px 0;\n color: #8A9094;\n text-transform: uppercase; }\n '],
|
|
directives: [SchemaSample, Tabs, Tab]
|
|
})(ResponsesSamples) || ResponsesSamples;
|
|
return ResponsesSamples;
|
|
})(BaseComponent);
|
|
|
|
_export('default', ResponsesSamples);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("26", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var typesInstantiator = {
|
|
'string': '',
|
|
'number': 0,
|
|
'integer': 0,
|
|
'null': null,
|
|
'boolean': false,
|
|
'object': {}
|
|
};
|
|
function isPrimitive(obj) {
|
|
var type = obj.type;
|
|
return typesInstantiator[type] !== undefined;
|
|
}
|
|
function instantiatePrimitive(val) {
|
|
var type = val.type;
|
|
if (val.default) {
|
|
return val.default;
|
|
}
|
|
return typesInstantiator[type];
|
|
}
|
|
function instantiate(schema) {
|
|
function visit(obj, name, data) {
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
var i;
|
|
var type = obj.type;
|
|
if (type === 'object' && obj.properties) {
|
|
data[name] = data[name] || {};
|
|
for (var property in obj.properties) {
|
|
if (obj.properties.hasOwnProperty(property)) {
|
|
visit(obj.properties[property], property, data[name]);
|
|
}
|
|
}
|
|
} else if (obj.allOf) {
|
|
for (i = 0; i < obj.allOf.length; i++) {
|
|
visit(obj.allOf[i], name, data);
|
|
}
|
|
} else if (type === 'array') {
|
|
data[name] = [];
|
|
var len = 1;
|
|
if (obj.minItems || obj.minItems === 0) {
|
|
len = obj.minItems;
|
|
}
|
|
for (i = 0; i < len; i++) {
|
|
visit(obj.items, i, data[name]);
|
|
}
|
|
} else if (isPrimitive(obj)) {
|
|
data[name] = instantiatePrimitive(obj);
|
|
}
|
|
}
|
|
var data = {};
|
|
visit(schema, 'kek', data);
|
|
return data['kek'];
|
|
}
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = {instantiate: instantiate};
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("27", ["26"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('26');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("28", ["27"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('27');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('f', ['3', '4', '5', '6', '7', '28'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, SchemaSampler, SchemaSample;
|
|
|
|
return {
|
|
setters: [function (_5) {
|
|
RedocComponent = _5.RedocComponent;
|
|
BaseComponent = _5.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_6) {
|
|
SchemaSampler = _6['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
SchemaSample = (function (_BaseComponent) {
|
|
_inherits(SchemaSample, _BaseComponent);
|
|
|
|
function SchemaSample(schemaMgr) {
|
|
_classCallCheck(this, _SchemaSample);
|
|
|
|
_get(Object.getPrototypeOf(_SchemaSample.prototype), 'constructor', this).call(this, schemaMgr);
|
|
}
|
|
|
|
_createClass(SchemaSample, [{
|
|
key: 'init',
|
|
value: function init() {
|
|
this.data = {};
|
|
|
|
// sometimes for some reason this method is called without resolved pointer
|
|
// TODO: fix it and remove the following workaround
|
|
if (!this.componentSchema || !this.pointer) {
|
|
return;
|
|
}
|
|
var base = {};
|
|
var sample = undefined;
|
|
|
|
// got pointer not directly to the schema but e.g. to response obj
|
|
if (this.componentSchema.schema) {
|
|
base = this.componentSchema;
|
|
this.componentSchema = this.componentSchema.schema;
|
|
}
|
|
|
|
if (base.examples && base.examples['application/json']) {
|
|
sample = base.examples['application/json'];
|
|
} else {
|
|
this.dereference(this.componentSchema);
|
|
sample = SchemaSampler.instantiate(this.componentSchema);
|
|
}
|
|
|
|
this.data.sample = sample;
|
|
}
|
|
}]);
|
|
|
|
var _SchemaSample = SchemaSample;
|
|
SchemaSample = RedocComponent({
|
|
selector: 'schema-sample',
|
|
template: '\n <div class="snippet">\n <!-- in case sample is not available for some reason -->\n <pre *ngIf="data.sample == null"> Sample unavailable </pre>\n <pre>{{data.sample | json}}</pre>\n </div>\n ',
|
|
styles: ['\n pre {\n background-color: transparent;\n padding: 0;\n }\n ']
|
|
})(SchemaSample) || SchemaSample;
|
|
return SchemaSample;
|
|
})(BaseComponent);
|
|
|
|
_export('default', SchemaSample);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("29", ["2a", "2b", "2c", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var classof = $__require('2a'),
|
|
ITERATOR = $__require('2b')('iterator'),
|
|
Iterators = $__require('2c');
|
|
module.exports = $__require('2d').isIterable = function(it) {
|
|
var O = Object(it);
|
|
return O[ITERATOR] !== undefined || '@@iterator' in O || Iterators.hasOwnProperty(classof(O));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2e", ["2f", "30", "29"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('2f');
|
|
$__require('30');
|
|
module.exports = $__require('29');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("31", ["2e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('2e'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11", ["32", "31"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var _getIterator = $__require('32')["default"];
|
|
var _isIterable = $__require('31')["default"];
|
|
exports["default"] = (function() {
|
|
function sliceIterator(arr, i) {
|
|
var _arr = [];
|
|
var _n = true;
|
|
var _d = false;
|
|
var _e = undefined;
|
|
try {
|
|
for (var _i = _getIterator(arr),
|
|
_s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
_arr.push(_s.value);
|
|
if (i && _arr.length === i)
|
|
break;
|
|
}
|
|
} catch (err) {
|
|
_d = true;
|
|
_e = err;
|
|
} finally {
|
|
try {
|
|
if (!_n && _i["return"])
|
|
_i["return"]();
|
|
} finally {
|
|
if (_d)
|
|
throw _e;
|
|
}
|
|
}
|
|
return _arr;
|
|
}
|
|
return function(arr, i) {
|
|
if (Array.isArray(arr)) {
|
|
return arr;
|
|
} else if (_isIterable(Object(arr))) {
|
|
return sliceIterator(arr, i);
|
|
} else {
|
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
}
|
|
};
|
|
})();
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('1d', ['14'], function (_export) {
|
|
'use strict';
|
|
|
|
var EventEmitter, bootsrEmmiter, redocEvents;
|
|
return {
|
|
setters: [function (_) {
|
|
EventEmitter = _.EventEmitter;
|
|
}],
|
|
execute: function () {
|
|
bootsrEmmiter = new EventEmitter();
|
|
redocEvents = {
|
|
bootstrapped: bootsrEmmiter
|
|
};
|
|
|
|
_export('redocEvents', redocEvents);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("33", ["20", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var AngularEntrypoint = (function() {
|
|
function AngularEntrypoint(name) {
|
|
this.name = name;
|
|
}
|
|
AngularEntrypoint = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], AngularEntrypoint);
|
|
return AngularEntrypoint;
|
|
})();
|
|
exports.AngularEntrypoint = AngularEntrypoint;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("35", ["36", "20", "37", "38", "39", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var dom_adapter_1 = $__require('36');
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var event_manager_1 = $__require('38');
|
|
var di_1 = $__require('39');
|
|
var modifierKeys = ['alt', 'control', 'meta', 'shift'];
|
|
var modifierKeyGetters = {
|
|
'alt': function(event) {
|
|
return event.altKey;
|
|
},
|
|
'control': function(event) {
|
|
return event.ctrlKey;
|
|
},
|
|
'meta': function(event) {
|
|
return event.metaKey;
|
|
},
|
|
'shift': function(event) {
|
|
return event.shiftKey;
|
|
}
|
|
};
|
|
var KeyEventsPlugin = (function(_super) {
|
|
__extends(KeyEventsPlugin, _super);
|
|
function KeyEventsPlugin() {
|
|
_super.call(this);
|
|
}
|
|
KeyEventsPlugin.prototype.supports = function(eventName) {
|
|
return lang_1.isPresent(KeyEventsPlugin.parseEventName(eventName));
|
|
};
|
|
KeyEventsPlugin.prototype.addEventListener = function(element, eventName, handler) {
|
|
var parsedEvent = KeyEventsPlugin.parseEventName(eventName);
|
|
var outsideHandler = KeyEventsPlugin.eventCallback(element, collection_1.StringMapWrapper.get(parsedEvent, 'fullKey'), handler, this.manager.getZone());
|
|
this.manager.getZone().runOutsideAngular(function() {
|
|
dom_adapter_1.DOM.on(element, collection_1.StringMapWrapper.get(parsedEvent, 'domEventName'), outsideHandler);
|
|
});
|
|
};
|
|
KeyEventsPlugin.parseEventName = function(eventName) {
|
|
var parts = eventName.toLowerCase().split('.');
|
|
var domEventName = parts.shift();
|
|
if ((parts.length === 0) || !(lang_1.StringWrapper.equals(domEventName, 'keydown') || lang_1.StringWrapper.equals(domEventName, 'keyup'))) {
|
|
return null;
|
|
}
|
|
var key = KeyEventsPlugin._normalizeKey(parts.pop());
|
|
var fullKey = '';
|
|
modifierKeys.forEach(function(modifierName) {
|
|
if (collection_1.ListWrapper.contains(parts, modifierName)) {
|
|
collection_1.ListWrapper.remove(parts, modifierName);
|
|
fullKey += modifierName + '.';
|
|
}
|
|
});
|
|
fullKey += key;
|
|
if (parts.length != 0 || key.length === 0) {
|
|
return null;
|
|
}
|
|
var result = collection_1.StringMapWrapper.create();
|
|
collection_1.StringMapWrapper.set(result, 'domEventName', domEventName);
|
|
collection_1.StringMapWrapper.set(result, 'fullKey', fullKey);
|
|
return result;
|
|
};
|
|
KeyEventsPlugin.getEventFullKey = function(event) {
|
|
var fullKey = '';
|
|
var key = dom_adapter_1.DOM.getEventKey(event);
|
|
key = key.toLowerCase();
|
|
if (lang_1.StringWrapper.equals(key, ' ')) {
|
|
key = 'space';
|
|
} else if (lang_1.StringWrapper.equals(key, '.')) {
|
|
key = 'dot';
|
|
}
|
|
modifierKeys.forEach(function(modifierName) {
|
|
if (modifierName != key) {
|
|
var modifierGetter = collection_1.StringMapWrapper.get(modifierKeyGetters, modifierName);
|
|
if (modifierGetter(event)) {
|
|
fullKey += modifierName + '.';
|
|
}
|
|
}
|
|
});
|
|
fullKey += key;
|
|
return fullKey;
|
|
};
|
|
KeyEventsPlugin.eventCallback = function(element, fullKey, handler, zone) {
|
|
return function(event) {
|
|
if (lang_1.StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
|
|
zone.run(function() {
|
|
return handler(event);
|
|
});
|
|
}
|
|
};
|
|
};
|
|
KeyEventsPlugin._normalizeKey = function(keyName) {
|
|
switch (keyName) {
|
|
case 'esc':
|
|
return 'escape';
|
|
default:
|
|
return keyName;
|
|
}
|
|
};
|
|
KeyEventsPlugin = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], KeyEventsPlugin);
|
|
return KeyEventsPlugin;
|
|
})(event_manager_1.EventManagerPlugin);
|
|
exports.KeyEventsPlugin = KeyEventsPlugin;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3a", ["38", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var event_manager_1 = $__require('38');
|
|
var collection_1 = $__require('37');
|
|
var _eventNames = {
|
|
'pan': true,
|
|
'panstart': true,
|
|
'panmove': true,
|
|
'panend': true,
|
|
'pancancel': true,
|
|
'panleft': true,
|
|
'panright': true,
|
|
'panup': true,
|
|
'pandown': true,
|
|
'pinch': true,
|
|
'pinchstart': true,
|
|
'pinchmove': true,
|
|
'pinchend': true,
|
|
'pinchcancel': true,
|
|
'pinchin': true,
|
|
'pinchout': true,
|
|
'press': true,
|
|
'pressup': true,
|
|
'rotate': true,
|
|
'rotatestart': true,
|
|
'rotatemove': true,
|
|
'rotateend': true,
|
|
'rotatecancel': true,
|
|
'swipe': true,
|
|
'swipeleft': true,
|
|
'swiperight': true,
|
|
'swipeup': true,
|
|
'swipedown': true,
|
|
'tap': true
|
|
};
|
|
var HammerGesturesPluginCommon = (function(_super) {
|
|
__extends(HammerGesturesPluginCommon, _super);
|
|
function HammerGesturesPluginCommon() {
|
|
_super.call(this);
|
|
}
|
|
HammerGesturesPluginCommon.prototype.supports = function(eventName) {
|
|
eventName = eventName.toLowerCase();
|
|
return collection_1.StringMapWrapper.contains(_eventNames, eventName);
|
|
};
|
|
return HammerGesturesPluginCommon;
|
|
})(event_manager_1.EventManagerPlugin);
|
|
exports.HammerGesturesPluginCommon = HammerGesturesPluginCommon;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3b", ["3a", "20", "3c", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var hammer_common_1 = $__require('3a');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var di_1 = $__require('39');
|
|
var HammerGesturesPlugin = (function(_super) {
|
|
__extends(HammerGesturesPlugin, _super);
|
|
function HammerGesturesPlugin() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
HammerGesturesPlugin.prototype.supports = function(eventName) {
|
|
if (!_super.prototype.supports.call(this, eventName))
|
|
return false;
|
|
if (!lang_1.isPresent(window['Hammer'])) {
|
|
throw new exceptions_1.BaseException("Hammer.js is not loaded, can not bind " + eventName + " event");
|
|
}
|
|
return true;
|
|
};
|
|
HammerGesturesPlugin.prototype.addEventListener = function(element, eventName, handler) {
|
|
var zone = this.manager.getZone();
|
|
eventName = eventName.toLowerCase();
|
|
zone.runOutsideAngular(function() {
|
|
var mc = new Hammer(element);
|
|
mc.get('pinch').set({enable: true});
|
|
mc.get('rotate').set({enable: true});
|
|
mc.on(eventName, function(eventObj) {
|
|
zone.run(function() {
|
|
handler(eventObj);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
HammerGesturesPlugin = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], HammerGesturesPlugin);
|
|
return HammerGesturesPlugin;
|
|
})(hammer_common_1.HammerGesturesPluginCommon);
|
|
exports.HammerGesturesPlugin = HammerGesturesPlugin;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3d", ["37", "20", "36", "3e"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var dom_adapter_1 = $__require('36');
|
|
var xhr_impl_1 = $__require('3e');
|
|
var GenericBrowserDomAdapter = (function(_super) {
|
|
__extends(GenericBrowserDomAdapter, _super);
|
|
function GenericBrowserDomAdapter() {
|
|
var _this = this;
|
|
_super.call(this);
|
|
this._animationPrefix = null;
|
|
this._transitionEnd = null;
|
|
try {
|
|
var element = this.createElement('div', this.defaultDoc());
|
|
if (lang_1.isPresent(this.getStyle(element, 'animationName'))) {
|
|
this._animationPrefix = '';
|
|
} else {
|
|
var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
|
|
for (var i = 0; i < domPrefixes.length; i++) {
|
|
if (lang_1.isPresent(this.getStyle(element, domPrefixes[i] + 'AnimationName'))) {
|
|
this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
var transEndEventNames = {
|
|
WebkitTransition: 'webkitTransitionEnd',
|
|
MozTransition: 'transitionend',
|
|
OTransition: 'oTransitionEnd otransitionend',
|
|
transition: 'transitionend'
|
|
};
|
|
collection_1.StringMapWrapper.forEach(transEndEventNames, function(value, key) {
|
|
if (lang_1.isPresent(_this.getStyle(element, key))) {
|
|
_this._transitionEnd = value;
|
|
}
|
|
});
|
|
} catch (e) {
|
|
this._animationPrefix = null;
|
|
this._transitionEnd = null;
|
|
}
|
|
}
|
|
GenericBrowserDomAdapter.prototype.getXHR = function() {
|
|
return xhr_impl_1.XHRImpl;
|
|
};
|
|
GenericBrowserDomAdapter.prototype.getDistributedNodes = function(el) {
|
|
return el.getDistributedNodes();
|
|
};
|
|
GenericBrowserDomAdapter.prototype.resolveAndSetHref = function(el, baseUrl, href) {
|
|
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
|
};
|
|
GenericBrowserDomAdapter.prototype.supportsDOMEvents = function() {
|
|
return true;
|
|
};
|
|
GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = function() {
|
|
return lang_1.isFunction(this.defaultDoc().body.createShadowRoot);
|
|
};
|
|
GenericBrowserDomAdapter.prototype.getAnimationPrefix = function() {
|
|
return lang_1.isPresent(this._animationPrefix) ? this._animationPrefix : "";
|
|
};
|
|
GenericBrowserDomAdapter.prototype.getTransitionEnd = function() {
|
|
return lang_1.isPresent(this._transitionEnd) ? this._transitionEnd : "";
|
|
};
|
|
GenericBrowserDomAdapter.prototype.supportsAnimation = function() {
|
|
return lang_1.isPresent(this._animationPrefix) && lang_1.isPresent(this._transitionEnd);
|
|
};
|
|
return GenericBrowserDomAdapter;
|
|
})(dom_adapter_1.DomAdapter);
|
|
exports.GenericBrowserDomAdapter = GenericBrowserDomAdapter;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3f", ["37", "20", "36", "3d"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var dom_adapter_1 = $__require('36');
|
|
var generic_browser_adapter_1 = $__require('3d');
|
|
var _attrToPropMap = {
|
|
'class': 'className',
|
|
'innerHtml': 'innerHTML',
|
|
'readonly': 'readOnly',
|
|
'tabindex': 'tabIndex'
|
|
};
|
|
var DOM_KEY_LOCATION_NUMPAD = 3;
|
|
var _keyMap = {
|
|
'\b': 'Backspace',
|
|
'\t': 'Tab',
|
|
'\x7F': 'Delete',
|
|
'\x1B': 'Escape',
|
|
'Del': 'Delete',
|
|
'Esc': 'Escape',
|
|
'Left': 'ArrowLeft',
|
|
'Right': 'ArrowRight',
|
|
'Up': 'ArrowUp',
|
|
'Down': 'ArrowDown',
|
|
'Menu': 'ContextMenu',
|
|
'Scroll': 'ScrollLock',
|
|
'Win': 'OS'
|
|
};
|
|
var _chromeNumKeyPadMap = {
|
|
'A': '1',
|
|
'B': '2',
|
|
'C': '3',
|
|
'D': '4',
|
|
'E': '5',
|
|
'F': '6',
|
|
'G': '7',
|
|
'H': '8',
|
|
'I': '9',
|
|
'J': '*',
|
|
'K': '+',
|
|
'M': '-',
|
|
'N': '.',
|
|
'O': '/',
|
|
'\x60': '0',
|
|
'\x90': 'NumLock'
|
|
};
|
|
var BrowserDomAdapter = (function(_super) {
|
|
__extends(BrowserDomAdapter, _super);
|
|
function BrowserDomAdapter() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
BrowserDomAdapter.prototype.parse = function(templateHtml) {
|
|
throw new Error("parse not implemented");
|
|
};
|
|
BrowserDomAdapter.makeCurrent = function() {
|
|
dom_adapter_1.setRootDomAdapter(new BrowserDomAdapter());
|
|
};
|
|
BrowserDomAdapter.prototype.hasProperty = function(element, name) {
|
|
return name in element;
|
|
};
|
|
BrowserDomAdapter.prototype.setProperty = function(el, name, value) {
|
|
el[name] = value;
|
|
};
|
|
BrowserDomAdapter.prototype.getProperty = function(el, name) {
|
|
return el[name];
|
|
};
|
|
BrowserDomAdapter.prototype.invoke = function(el, methodName, args) {
|
|
el[methodName].apply(el, args);
|
|
};
|
|
BrowserDomAdapter.prototype.logError = function(error) {
|
|
if (window.console.error) {
|
|
window.console.error(error);
|
|
} else {
|
|
window.console.log(error);
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.log = function(error) {
|
|
window.console.log(error);
|
|
};
|
|
BrowserDomAdapter.prototype.logGroup = function(error) {
|
|
if (window.console.group) {
|
|
window.console.group(error);
|
|
this.logError(error);
|
|
} else {
|
|
window.console.log(error);
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.logGroupEnd = function() {
|
|
if (window.console.groupEnd) {
|
|
window.console.groupEnd();
|
|
}
|
|
};
|
|
Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
|
|
get: function() {
|
|
return _attrToPropMap;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
BrowserDomAdapter.prototype.query = function(selector) {
|
|
return document.querySelector(selector);
|
|
};
|
|
BrowserDomAdapter.prototype.querySelector = function(el, selector) {
|
|
return el.querySelector(selector);
|
|
};
|
|
BrowserDomAdapter.prototype.querySelectorAll = function(el, selector) {
|
|
return el.querySelectorAll(selector);
|
|
};
|
|
BrowserDomAdapter.prototype.on = function(el, evt, listener) {
|
|
el.addEventListener(evt, listener, false);
|
|
};
|
|
BrowserDomAdapter.prototype.onAndCancel = function(el, evt, listener) {
|
|
el.addEventListener(evt, listener, false);
|
|
return function() {
|
|
el.removeEventListener(evt, listener, false);
|
|
};
|
|
};
|
|
BrowserDomAdapter.prototype.dispatchEvent = function(el, evt) {
|
|
el.dispatchEvent(evt);
|
|
};
|
|
BrowserDomAdapter.prototype.createMouseEvent = function(eventType) {
|
|
var evt = document.createEvent('MouseEvent');
|
|
evt.initEvent(eventType, true, true);
|
|
return evt;
|
|
};
|
|
BrowserDomAdapter.prototype.createEvent = function(eventType) {
|
|
var evt = document.createEvent('Event');
|
|
evt.initEvent(eventType, true, true);
|
|
return evt;
|
|
};
|
|
BrowserDomAdapter.prototype.preventDefault = function(evt) {
|
|
evt.preventDefault();
|
|
evt.returnValue = false;
|
|
};
|
|
BrowserDomAdapter.prototype.isPrevented = function(evt) {
|
|
return evt.defaultPrevented || lang_1.isPresent(evt.returnValue) && !evt.returnValue;
|
|
};
|
|
BrowserDomAdapter.prototype.getInnerHTML = function(el) {
|
|
return el.innerHTML;
|
|
};
|
|
BrowserDomAdapter.prototype.getOuterHTML = function(el) {
|
|
return el.outerHTML;
|
|
};
|
|
BrowserDomAdapter.prototype.nodeName = function(node) {
|
|
return node.nodeName;
|
|
};
|
|
BrowserDomAdapter.prototype.nodeValue = function(node) {
|
|
return node.nodeValue;
|
|
};
|
|
BrowserDomAdapter.prototype.type = function(node) {
|
|
return node.type;
|
|
};
|
|
BrowserDomAdapter.prototype.content = function(node) {
|
|
if (this.hasProperty(node, "content")) {
|
|
return node.content;
|
|
} else {
|
|
return node;
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.firstChild = function(el) {
|
|
return el.firstChild;
|
|
};
|
|
BrowserDomAdapter.prototype.nextSibling = function(el) {
|
|
return el.nextSibling;
|
|
};
|
|
BrowserDomAdapter.prototype.parentElement = function(el) {
|
|
return el.parentNode;
|
|
};
|
|
BrowserDomAdapter.prototype.childNodes = function(el) {
|
|
return el.childNodes;
|
|
};
|
|
BrowserDomAdapter.prototype.childNodesAsList = function(el) {
|
|
var childNodes = el.childNodes;
|
|
var res = collection_1.ListWrapper.createFixedSize(childNodes.length);
|
|
for (var i = 0; i < childNodes.length; i++) {
|
|
res[i] = childNodes[i];
|
|
}
|
|
return res;
|
|
};
|
|
BrowserDomAdapter.prototype.clearNodes = function(el) {
|
|
while (el.firstChild) {
|
|
el.removeChild(el.firstChild);
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.appendChild = function(el, node) {
|
|
el.appendChild(node);
|
|
};
|
|
BrowserDomAdapter.prototype.removeChild = function(el, node) {
|
|
el.removeChild(node);
|
|
};
|
|
BrowserDomAdapter.prototype.replaceChild = function(el, newChild, oldChild) {
|
|
el.replaceChild(newChild, oldChild);
|
|
};
|
|
BrowserDomAdapter.prototype.remove = function(node) {
|
|
if (node.parentNode) {
|
|
node.parentNode.removeChild(node);
|
|
}
|
|
return node;
|
|
};
|
|
BrowserDomAdapter.prototype.insertBefore = function(el, node) {
|
|
el.parentNode.insertBefore(node, el);
|
|
};
|
|
BrowserDomAdapter.prototype.insertAllBefore = function(el, nodes) {
|
|
nodes.forEach(function(n) {
|
|
return el.parentNode.insertBefore(n, el);
|
|
});
|
|
};
|
|
BrowserDomAdapter.prototype.insertAfter = function(el, node) {
|
|
el.parentNode.insertBefore(node, el.nextSibling);
|
|
};
|
|
BrowserDomAdapter.prototype.setInnerHTML = function(el, value) {
|
|
el.innerHTML = value;
|
|
};
|
|
BrowserDomAdapter.prototype.getText = function(el) {
|
|
return el.textContent;
|
|
};
|
|
BrowserDomAdapter.prototype.setText = function(el, value) {
|
|
el.textContent = value;
|
|
};
|
|
BrowserDomAdapter.prototype.getValue = function(el) {
|
|
return el.value;
|
|
};
|
|
BrowserDomAdapter.prototype.setValue = function(el, value) {
|
|
el.value = value;
|
|
};
|
|
BrowserDomAdapter.prototype.getChecked = function(el) {
|
|
return el.checked;
|
|
};
|
|
BrowserDomAdapter.prototype.setChecked = function(el, value) {
|
|
el.checked = value;
|
|
};
|
|
BrowserDomAdapter.prototype.createComment = function(text) {
|
|
return document.createComment(text);
|
|
};
|
|
BrowserDomAdapter.prototype.createTemplate = function(html) {
|
|
var t = document.createElement('template');
|
|
t.innerHTML = html;
|
|
return t;
|
|
};
|
|
BrowserDomAdapter.prototype.createElement = function(tagName, doc) {
|
|
if (doc === void 0) {
|
|
doc = document;
|
|
}
|
|
return doc.createElement(tagName);
|
|
};
|
|
BrowserDomAdapter.prototype.createElementNS = function(ns, tagName, doc) {
|
|
if (doc === void 0) {
|
|
doc = document;
|
|
}
|
|
return doc.createElementNS(ns, tagName);
|
|
};
|
|
BrowserDomAdapter.prototype.createTextNode = function(text, doc) {
|
|
if (doc === void 0) {
|
|
doc = document;
|
|
}
|
|
return doc.createTextNode(text);
|
|
};
|
|
BrowserDomAdapter.prototype.createScriptTag = function(attrName, attrValue, doc) {
|
|
if (doc === void 0) {
|
|
doc = document;
|
|
}
|
|
var el = doc.createElement('SCRIPT');
|
|
el.setAttribute(attrName, attrValue);
|
|
return el;
|
|
};
|
|
BrowserDomAdapter.prototype.createStyleElement = function(css, doc) {
|
|
if (doc === void 0) {
|
|
doc = document;
|
|
}
|
|
var style = doc.createElement('style');
|
|
this.appendChild(style, this.createTextNode(css));
|
|
return style;
|
|
};
|
|
BrowserDomAdapter.prototype.createShadowRoot = function(el) {
|
|
return el.createShadowRoot();
|
|
};
|
|
BrowserDomAdapter.prototype.getShadowRoot = function(el) {
|
|
return el.shadowRoot;
|
|
};
|
|
BrowserDomAdapter.prototype.getHost = function(el) {
|
|
return el.host;
|
|
};
|
|
BrowserDomAdapter.prototype.clone = function(node) {
|
|
return node.cloneNode(true);
|
|
};
|
|
BrowserDomAdapter.prototype.getElementsByClassName = function(element, name) {
|
|
return element.getElementsByClassName(name);
|
|
};
|
|
BrowserDomAdapter.prototype.getElementsByTagName = function(element, name) {
|
|
return element.getElementsByTagName(name);
|
|
};
|
|
BrowserDomAdapter.prototype.classList = function(element) {
|
|
return Array.prototype.slice.call(element.classList, 0);
|
|
};
|
|
BrowserDomAdapter.prototype.addClass = function(element, className) {
|
|
element.classList.add(className);
|
|
};
|
|
BrowserDomAdapter.prototype.removeClass = function(element, className) {
|
|
element.classList.remove(className);
|
|
};
|
|
BrowserDomAdapter.prototype.hasClass = function(element, className) {
|
|
return element.classList.contains(className);
|
|
};
|
|
BrowserDomAdapter.prototype.setStyle = function(element, styleName, styleValue) {
|
|
element.style[styleName] = styleValue;
|
|
};
|
|
BrowserDomAdapter.prototype.removeStyle = function(element, stylename) {
|
|
element.style[stylename] = null;
|
|
};
|
|
BrowserDomAdapter.prototype.getStyle = function(element, stylename) {
|
|
return element.style[stylename];
|
|
};
|
|
BrowserDomAdapter.prototype.hasStyle = function(element, styleName, styleValue) {
|
|
if (styleValue === void 0) {
|
|
styleValue = null;
|
|
}
|
|
var value = this.getStyle(element, styleName) || '';
|
|
return styleValue ? value == styleValue : value.length > 0;
|
|
};
|
|
BrowserDomAdapter.prototype.tagName = function(element) {
|
|
return element.tagName;
|
|
};
|
|
BrowserDomAdapter.prototype.attributeMap = function(element) {
|
|
var res = new Map();
|
|
var elAttrs = element.attributes;
|
|
for (var i = 0; i < elAttrs.length; i++) {
|
|
var attrib = elAttrs[i];
|
|
res.set(attrib.name, attrib.value);
|
|
}
|
|
return res;
|
|
};
|
|
BrowserDomAdapter.prototype.hasAttribute = function(element, attribute) {
|
|
return element.hasAttribute(attribute);
|
|
};
|
|
BrowserDomAdapter.prototype.getAttribute = function(element, attribute) {
|
|
return element.getAttribute(attribute);
|
|
};
|
|
BrowserDomAdapter.prototype.setAttribute = function(element, name, value) {
|
|
element.setAttribute(name, value);
|
|
};
|
|
BrowserDomAdapter.prototype.setAttributeNS = function(element, ns, name, value) {
|
|
element.setAttributeNS(ns, name, value);
|
|
};
|
|
BrowserDomAdapter.prototype.removeAttribute = function(element, attribute) {
|
|
element.removeAttribute(attribute);
|
|
};
|
|
BrowserDomAdapter.prototype.templateAwareRoot = function(el) {
|
|
return this.isTemplateElement(el) ? this.content(el) : el;
|
|
};
|
|
BrowserDomAdapter.prototype.createHtmlDocument = function() {
|
|
return document.implementation.createHTMLDocument('fakeTitle');
|
|
};
|
|
BrowserDomAdapter.prototype.defaultDoc = function() {
|
|
return document;
|
|
};
|
|
BrowserDomAdapter.prototype.getBoundingClientRect = function(el) {
|
|
try {
|
|
return el.getBoundingClientRect();
|
|
} catch (e) {
|
|
return {
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
width: 0,
|
|
height: 0
|
|
};
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.getTitle = function() {
|
|
return document.title;
|
|
};
|
|
BrowserDomAdapter.prototype.setTitle = function(newTitle) {
|
|
document.title = newTitle || '';
|
|
};
|
|
BrowserDomAdapter.prototype.elementMatches = function(n, selector) {
|
|
var matches = false;
|
|
if (n instanceof HTMLElement) {
|
|
if (n.matches) {
|
|
matches = n.matches(selector);
|
|
} else if (n.msMatchesSelector) {
|
|
matches = n.msMatchesSelector(selector);
|
|
} else if (n.webkitMatchesSelector) {
|
|
matches = n.webkitMatchesSelector(selector);
|
|
}
|
|
}
|
|
return matches;
|
|
};
|
|
BrowserDomAdapter.prototype.isTemplateElement = function(el) {
|
|
return el instanceof HTMLElement && el.nodeName == "TEMPLATE";
|
|
};
|
|
BrowserDomAdapter.prototype.isTextNode = function(node) {
|
|
return node.nodeType === Node.TEXT_NODE;
|
|
};
|
|
BrowserDomAdapter.prototype.isCommentNode = function(node) {
|
|
return node.nodeType === Node.COMMENT_NODE;
|
|
};
|
|
BrowserDomAdapter.prototype.isElementNode = function(node) {
|
|
return node.nodeType === Node.ELEMENT_NODE;
|
|
};
|
|
BrowserDomAdapter.prototype.hasShadowRoot = function(node) {
|
|
return node instanceof HTMLElement && lang_1.isPresent(node.shadowRoot);
|
|
};
|
|
BrowserDomAdapter.prototype.isShadowRoot = function(node) {
|
|
return node instanceof DocumentFragment;
|
|
};
|
|
BrowserDomAdapter.prototype.importIntoDoc = function(node) {
|
|
var toImport = node;
|
|
if (this.isTemplateElement(node)) {
|
|
toImport = this.content(node);
|
|
}
|
|
return document.importNode(toImport, true);
|
|
};
|
|
BrowserDomAdapter.prototype.adoptNode = function(node) {
|
|
return document.adoptNode(node);
|
|
};
|
|
BrowserDomAdapter.prototype.getHref = function(el) {
|
|
return el.href;
|
|
};
|
|
BrowserDomAdapter.prototype.getEventKey = function(event) {
|
|
var key = event.key;
|
|
if (lang_1.isBlank(key)) {
|
|
key = event.keyIdentifier;
|
|
if (lang_1.isBlank(key)) {
|
|
return 'Unidentified';
|
|
}
|
|
if (key.startsWith('U+')) {
|
|
key = String.fromCharCode(parseInt(key.substring(2), 16));
|
|
if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
|
|
key = _chromeNumKeyPadMap[key];
|
|
}
|
|
}
|
|
}
|
|
if (_keyMap.hasOwnProperty(key)) {
|
|
key = _keyMap[key];
|
|
}
|
|
return key;
|
|
};
|
|
BrowserDomAdapter.prototype.getGlobalEventTarget = function(target) {
|
|
if (target == "window") {
|
|
return window;
|
|
} else if (target == "document") {
|
|
return document;
|
|
} else if (target == "body") {
|
|
return document.body;
|
|
}
|
|
};
|
|
BrowserDomAdapter.prototype.getHistory = function() {
|
|
return window.history;
|
|
};
|
|
BrowserDomAdapter.prototype.getLocation = function() {
|
|
return window.location;
|
|
};
|
|
BrowserDomAdapter.prototype.getBaseHref = function() {
|
|
var href = getBaseElementHref();
|
|
if (lang_1.isBlank(href)) {
|
|
return null;
|
|
}
|
|
return relativePath(href);
|
|
};
|
|
BrowserDomAdapter.prototype.resetBaseElement = function() {
|
|
baseElement = null;
|
|
};
|
|
BrowserDomAdapter.prototype.getUserAgent = function() {
|
|
return window.navigator.userAgent;
|
|
};
|
|
BrowserDomAdapter.prototype.setData = function(element, name, value) {
|
|
this.setAttribute(element, 'data-' + name, value);
|
|
};
|
|
BrowserDomAdapter.prototype.getData = function(element, name) {
|
|
return this.getAttribute(element, 'data-' + name);
|
|
};
|
|
BrowserDomAdapter.prototype.getComputedStyle = function(element) {
|
|
return getComputedStyle(element);
|
|
};
|
|
BrowserDomAdapter.prototype.setGlobalVar = function(path, value) {
|
|
lang_1.setValueOnPath(lang_1.global, path, value);
|
|
};
|
|
BrowserDomAdapter.prototype.requestAnimationFrame = function(callback) {
|
|
return window.requestAnimationFrame(callback);
|
|
};
|
|
BrowserDomAdapter.prototype.cancelAnimationFrame = function(id) {
|
|
window.cancelAnimationFrame(id);
|
|
};
|
|
BrowserDomAdapter.prototype.performanceNow = function() {
|
|
if (lang_1.isPresent(window.performance) && lang_1.isPresent(window.performance.now)) {
|
|
return window.performance.now();
|
|
} else {
|
|
return lang_1.DateWrapper.toMillis(lang_1.DateWrapper.now());
|
|
}
|
|
};
|
|
return BrowserDomAdapter;
|
|
})(generic_browser_adapter_1.GenericBrowserDomAdapter);
|
|
exports.BrowserDomAdapter = BrowserDomAdapter;
|
|
var baseElement = null;
|
|
function getBaseElementHref() {
|
|
if (lang_1.isBlank(baseElement)) {
|
|
baseElement = document.querySelector('base');
|
|
if (lang_1.isBlank(baseElement)) {
|
|
return null;
|
|
}
|
|
}
|
|
return baseElement.getAttribute('href');
|
|
}
|
|
var urlParsingNode = null;
|
|
function relativePath(url) {
|
|
if (lang_1.isBlank(urlParsingNode)) {
|
|
urlParsingNode = document.createElement("a");
|
|
}
|
|
urlParsingNode.setAttribute('href', url);
|
|
return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname : '/' + urlParsingNode.pathname;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("40", ["20", "36", "14"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var dom_adapter_1 = $__require('36');
|
|
var core_1 = $__require('14');
|
|
var PublicTestability = (function() {
|
|
function PublicTestability(testability) {
|
|
this._testability = testability;
|
|
}
|
|
PublicTestability.prototype.isStable = function() {
|
|
return this._testability.isStable();
|
|
};
|
|
PublicTestability.prototype.whenStable = function(callback) {
|
|
this._testability.whenStable(callback);
|
|
};
|
|
PublicTestability.prototype.findBindings = function(using, provider, exactMatch) {
|
|
return this.findProviders(using, provider, exactMatch);
|
|
};
|
|
PublicTestability.prototype.findProviders = function(using, provider, exactMatch) {
|
|
return this._testability.findBindings(using, provider, exactMatch);
|
|
};
|
|
return PublicTestability;
|
|
})();
|
|
var BrowserGetTestability = (function() {
|
|
function BrowserGetTestability() {}
|
|
BrowserGetTestability.init = function() {
|
|
core_1.setTestabilityGetter(new BrowserGetTestability());
|
|
};
|
|
BrowserGetTestability.prototype.addToWindow = function(registry) {
|
|
lang_1.global.getAngularTestability = function(elem, findInAncestors) {
|
|
if (findInAncestors === void 0) {
|
|
findInAncestors = true;
|
|
}
|
|
var testability = registry.findTestabilityInTree(elem, findInAncestors);
|
|
if (testability == null) {
|
|
throw new Error('Could not find testability for element.');
|
|
}
|
|
return new PublicTestability(testability);
|
|
};
|
|
lang_1.global.getAllAngularTestabilities = function() {
|
|
var testabilities = registry.getAllTestabilities();
|
|
return testabilities.map(function(testability) {
|
|
return new PublicTestability(testability);
|
|
});
|
|
};
|
|
};
|
|
BrowserGetTestability.prototype.findTestabilityInTree = function(registry, elem, findInAncestors) {
|
|
if (elem == null) {
|
|
return null;
|
|
}
|
|
var t = registry.getTestability(elem);
|
|
if (lang_1.isPresent(t)) {
|
|
return t;
|
|
} else if (!findInAncestors) {
|
|
return null;
|
|
}
|
|
if (dom_adapter_1.DOM.isShadowRoot(elem)) {
|
|
return this.findTestabilityInTree(registry, dom_adapter_1.DOM.getHost(elem), true);
|
|
}
|
|
return this.findTestabilityInTree(registry, dom_adapter_1.DOM.parentElement(elem), true);
|
|
};
|
|
return BrowserGetTestability;
|
|
})();
|
|
exports.BrowserGetTestability = BrowserGetTestability;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("41", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function wtfInit() {}
|
|
exports.wtfInit = wtfInit;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("42", ["36"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var dom_adapter_1 = $__require('36');
|
|
var Title = (function() {
|
|
function Title() {}
|
|
Title.prototype.getTitle = function() {
|
|
return dom_adapter_1.DOM.getTitle();
|
|
};
|
|
Title.prototype.setTitle = function(newTitle) {
|
|
dom_adapter_1.DOM.setTitle(newTitle);
|
|
};
|
|
return Title;
|
|
})();
|
|
exports.Title = Title;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("43", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var CssAnimationOptions = (function() {
|
|
function CssAnimationOptions() {
|
|
this.classesToAdd = [];
|
|
this.classesToRemove = [];
|
|
this.animationClasses = [];
|
|
}
|
|
return CssAnimationOptions;
|
|
})();
|
|
exports.CssAnimationOptions = CssAnimationOptions;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("44", ["20", "45", "46", "37", "36"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var math_1 = $__require('45');
|
|
var util_1 = $__require('46');
|
|
var collection_1 = $__require('37');
|
|
var dom_adapter_1 = $__require('36');
|
|
var Animation = (function() {
|
|
function Animation(element, data, browserDetails) {
|
|
var _this = this;
|
|
this.element = element;
|
|
this.data = data;
|
|
this.browserDetails = browserDetails;
|
|
this.callbacks = [];
|
|
this.eventClearFunctions = [];
|
|
this.completed = false;
|
|
this._stringPrefix = '';
|
|
this.startTime = lang_1.DateWrapper.toMillis(lang_1.DateWrapper.now());
|
|
this._stringPrefix = dom_adapter_1.DOM.getAnimationPrefix();
|
|
this.setup();
|
|
this.wait(function(timestamp) {
|
|
return _this.start();
|
|
});
|
|
}
|
|
Object.defineProperty(Animation.prototype, "totalTime", {
|
|
get: function() {
|
|
var delay = this.computedDelay != null ? this.computedDelay : 0;
|
|
var duration = this.computedDuration != null ? this.computedDuration : 0;
|
|
return delay + duration;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Animation.prototype.wait = function(callback) {
|
|
this.browserDetails.raf(callback, 2);
|
|
};
|
|
Animation.prototype.setup = function() {
|
|
if (this.data.fromStyles != null)
|
|
this.applyStyles(this.data.fromStyles);
|
|
if (this.data.duration != null)
|
|
this.applyStyles({'transitionDuration': this.data.duration.toString() + 'ms'});
|
|
if (this.data.delay != null)
|
|
this.applyStyles({'transitionDelay': this.data.delay.toString() + 'ms'});
|
|
};
|
|
Animation.prototype.start = function() {
|
|
this.addClasses(this.data.classesToAdd);
|
|
this.addClasses(this.data.animationClasses);
|
|
this.removeClasses(this.data.classesToRemove);
|
|
if (this.data.toStyles != null)
|
|
this.applyStyles(this.data.toStyles);
|
|
var computedStyles = dom_adapter_1.DOM.getComputedStyle(this.element);
|
|
this.computedDelay = math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-delay')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-delay')));
|
|
this.computedDuration = math_1.Math.max(this.parseDurationString(computedStyles.getPropertyValue(this._stringPrefix + 'transition-duration')), this.parseDurationString(this.element.style.getPropertyValue(this._stringPrefix + 'transition-duration')));
|
|
this.addEvents();
|
|
};
|
|
Animation.prototype.applyStyles = function(styles) {
|
|
var _this = this;
|
|
collection_1.StringMapWrapper.forEach(styles, function(value, key) {
|
|
var dashCaseKey = util_1.camelCaseToDashCase(key);
|
|
if (lang_1.isPresent(dom_adapter_1.DOM.getStyle(_this.element, dashCaseKey))) {
|
|
dom_adapter_1.DOM.setStyle(_this.element, dashCaseKey, value.toString());
|
|
} else {
|
|
dom_adapter_1.DOM.setStyle(_this.element, _this._stringPrefix + dashCaseKey, value.toString());
|
|
}
|
|
});
|
|
};
|
|
Animation.prototype.addClasses = function(classes) {
|
|
for (var i = 0,
|
|
len = classes.length; i < len; i++)
|
|
dom_adapter_1.DOM.addClass(this.element, classes[i]);
|
|
};
|
|
Animation.prototype.removeClasses = function(classes) {
|
|
for (var i = 0,
|
|
len = classes.length; i < len; i++)
|
|
dom_adapter_1.DOM.removeClass(this.element, classes[i]);
|
|
};
|
|
Animation.prototype.addEvents = function() {
|
|
var _this = this;
|
|
if (this.totalTime > 0) {
|
|
this.eventClearFunctions.push(dom_adapter_1.DOM.onAndCancel(this.element, dom_adapter_1.DOM.getTransitionEnd(), function(event) {
|
|
return _this.handleAnimationEvent(event);
|
|
}));
|
|
} else {
|
|
this.handleAnimationCompleted();
|
|
}
|
|
};
|
|
Animation.prototype.handleAnimationEvent = function(event) {
|
|
var elapsedTime = math_1.Math.round(event.elapsedTime * 1000);
|
|
if (!this.browserDetails.elapsedTimeIncludesDelay)
|
|
elapsedTime += this.computedDelay;
|
|
event.stopPropagation();
|
|
if (elapsedTime >= this.totalTime)
|
|
this.handleAnimationCompleted();
|
|
};
|
|
Animation.prototype.handleAnimationCompleted = function() {
|
|
this.removeClasses(this.data.animationClasses);
|
|
this.callbacks.forEach(function(callback) {
|
|
return callback();
|
|
});
|
|
this.callbacks = [];
|
|
this.eventClearFunctions.forEach(function(fn) {
|
|
return fn();
|
|
});
|
|
this.eventClearFunctions = [];
|
|
this.completed = true;
|
|
};
|
|
Animation.prototype.onComplete = function(callback) {
|
|
if (this.completed) {
|
|
callback();
|
|
} else {
|
|
this.callbacks.push(callback);
|
|
}
|
|
return this;
|
|
};
|
|
Animation.prototype.parseDurationString = function(duration) {
|
|
var maxValue = 0;
|
|
if (duration == null || duration.length < 2) {
|
|
return maxValue;
|
|
} else if (duration.substring(duration.length - 2) == 'ms') {
|
|
var value = lang_1.NumberWrapper.parseInt(this.stripLetters(duration), 10);
|
|
if (value > maxValue)
|
|
maxValue = value;
|
|
} else if (duration.substring(duration.length - 1) == 's') {
|
|
var ms = lang_1.NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000;
|
|
var value = math_1.Math.floor(ms);
|
|
if (value > maxValue)
|
|
maxValue = value;
|
|
}
|
|
return maxValue;
|
|
};
|
|
Animation.prototype.stripLetters = function(str) {
|
|
return lang_1.StringWrapper.replaceAll(str, lang_1.RegExpWrapper.create('[^0-9]+$', ''), '');
|
|
};
|
|
return Animation;
|
|
})();
|
|
exports.Animation = Animation;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("47", ["43", "44"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var css_animation_options_1 = $__require('43');
|
|
var animation_1 = $__require('44');
|
|
var CssAnimationBuilder = (function() {
|
|
function CssAnimationBuilder(browserDetails) {
|
|
this.browserDetails = browserDetails;
|
|
this.data = new css_animation_options_1.CssAnimationOptions();
|
|
}
|
|
CssAnimationBuilder.prototype.addAnimationClass = function(className) {
|
|
this.data.animationClasses.push(className);
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.addClass = function(className) {
|
|
this.data.classesToAdd.push(className);
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.removeClass = function(className) {
|
|
this.data.classesToRemove.push(className);
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.setDuration = function(duration) {
|
|
this.data.duration = duration;
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.setDelay = function(delay) {
|
|
this.data.delay = delay;
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.setStyles = function(from, to) {
|
|
return this.setFromStyles(from).setToStyles(to);
|
|
};
|
|
CssAnimationBuilder.prototype.setFromStyles = function(from) {
|
|
this.data.fromStyles = from;
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.setToStyles = function(to) {
|
|
this.data.toStyles = to;
|
|
return this;
|
|
};
|
|
CssAnimationBuilder.prototype.start = function(element) {
|
|
return new animation_1.Animation(element, this.data, this.browserDetails);
|
|
};
|
|
return CssAnimationBuilder;
|
|
})();
|
|
exports.CssAnimationBuilder = CssAnimationBuilder;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("45", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.Math = lang_1.global.Math;
|
|
exports.NaN = typeof exports.NaN;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("48", ["39", "45", "36"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var math_1 = $__require('45');
|
|
var dom_adapter_1 = $__require('36');
|
|
var BrowserDetails = (function() {
|
|
function BrowserDetails() {
|
|
this.elapsedTimeIncludesDelay = false;
|
|
this.doesElapsedTimeIncludesDelay();
|
|
}
|
|
BrowserDetails.prototype.doesElapsedTimeIncludesDelay = function() {
|
|
var _this = this;
|
|
var div = dom_adapter_1.DOM.createElement('div');
|
|
dom_adapter_1.DOM.setAttribute(div, 'style', "position: absolute; top: -9999px; left: -9999px; width: 1px;\n height: 1px; transition: all 1ms linear 1ms;");
|
|
this.raf(function(timestamp) {
|
|
dom_adapter_1.DOM.on(div, 'transitionend', function(event) {
|
|
var elapsed = math_1.Math.round(event.elapsedTime * 1000);
|
|
_this.elapsedTimeIncludesDelay = elapsed == 2;
|
|
dom_adapter_1.DOM.remove(div);
|
|
});
|
|
dom_adapter_1.DOM.setStyle(div, 'width', '2px');
|
|
}, 2);
|
|
};
|
|
BrowserDetails.prototype.raf = function(callback, frames) {
|
|
if (frames === void 0) {
|
|
frames = 1;
|
|
}
|
|
var queue = new RafQueue(callback, frames);
|
|
return function() {
|
|
return queue.cancel();
|
|
};
|
|
};
|
|
BrowserDetails = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], BrowserDetails);
|
|
return BrowserDetails;
|
|
})();
|
|
exports.BrowserDetails = BrowserDetails;
|
|
var RafQueue = (function() {
|
|
function RafQueue(callback, frames) {
|
|
this.callback = callback;
|
|
this.frames = frames;
|
|
this._raf();
|
|
}
|
|
RafQueue.prototype._raf = function() {
|
|
var _this = this;
|
|
this.currentFrameId = dom_adapter_1.DOM.requestAnimationFrame(function(timestamp) {
|
|
return _this._nextFrame(timestamp);
|
|
});
|
|
};
|
|
RafQueue.prototype._nextFrame = function(timestamp) {
|
|
this.frames--;
|
|
if (this.frames > 0) {
|
|
this._raf();
|
|
} else {
|
|
this.callback(timestamp);
|
|
}
|
|
};
|
|
RafQueue.prototype.cancel = function() {
|
|
dom_adapter_1.DOM.cancelAnimationFrame(this.currentFrameId);
|
|
this.currentFrameId = null;
|
|
};
|
|
return RafQueue;
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("49", ["39", "47", "48"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var css_animation_builder_1 = $__require('47');
|
|
var browser_details_1 = $__require('48');
|
|
var AnimationBuilder = (function() {
|
|
function AnimationBuilder(browserDetails) {
|
|
this.browserDetails = browserDetails;
|
|
}
|
|
AnimationBuilder.prototype.css = function() {
|
|
return new css_animation_builder_1.CssAnimationBuilder(this.browserDetails);
|
|
};
|
|
AnimationBuilder = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [browser_details_1.BrowserDetails])], AnimationBuilder);
|
|
return AnimationBuilder;
|
|
})();
|
|
exports.AnimationBuilder = AnimationBuilder;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("46", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
var DASH_CASE_REGEXP = /-([a-z])/g;
|
|
function camelCaseToDashCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function(m) {
|
|
return '-' + m[1].toLowerCase();
|
|
});
|
|
}
|
|
exports.camelCaseToDashCase = camelCaseToDashCase;
|
|
function dashCaseToCamelCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function(m) {
|
|
return m[1].toUpperCase();
|
|
});
|
|
}
|
|
exports.dashCaseToCamelCase = dashCaseToCamelCase;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4a", ["39", "49", "20", "3c", "4b", "4c", "14", "38", "4d", "4e", "4f", "50", "36", "46"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var di_1 = $__require('39');
|
|
var animation_builder_1 = $__require('49');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var shared_styles_host_1 = $__require('4b');
|
|
var profile_1 = $__require('4c');
|
|
var core_1 = $__require('14');
|
|
var event_manager_1 = $__require('38');
|
|
var dom_tokens_1 = $__require('4d');
|
|
var view_factory_1 = $__require('4e');
|
|
var view_1 = $__require('4f');
|
|
var metadata_1 = $__require('50');
|
|
var dom_adapter_1 = $__require('36');
|
|
var util_1 = $__require('46');
|
|
var NAMESPACE_URIS = lang_1.CONST_EXPR({
|
|
'xlink': 'http://www.w3.org/1999/xlink',
|
|
'svg': 'http://www.w3.org/2000/svg'
|
|
});
|
|
var TEMPLATE_COMMENT_TEXT = 'template bindings={}';
|
|
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;
|
|
var DomRenderer = (function(_super) {
|
|
__extends(DomRenderer, _super);
|
|
function DomRenderer() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
DomRenderer.prototype.getNativeElementSync = function(location) {
|
|
return resolveInternalDomView(location.renderView).boundElements[location.boundElementIndex];
|
|
};
|
|
DomRenderer.prototype.getRootNodes = function(fragment) {
|
|
return resolveInternalDomFragment(fragment);
|
|
};
|
|
DomRenderer.prototype.attachFragmentAfterFragment = function(previousFragmentRef, fragmentRef) {
|
|
var previousFragmentNodes = resolveInternalDomFragment(previousFragmentRef);
|
|
if (previousFragmentNodes.length > 0) {
|
|
var sibling = previousFragmentNodes[previousFragmentNodes.length - 1];
|
|
var nodes = resolveInternalDomFragment(fragmentRef);
|
|
moveNodesAfterSibling(sibling, nodes);
|
|
this.animateNodesEnter(nodes);
|
|
}
|
|
};
|
|
DomRenderer.prototype.animateNodesEnter = function(nodes) {
|
|
for (var i = 0; i < nodes.length; i++)
|
|
this.animateNodeEnter(nodes[i]);
|
|
};
|
|
DomRenderer.prototype.attachFragmentAfterElement = function(elementRef, fragmentRef) {
|
|
var parentView = resolveInternalDomView(elementRef.renderView);
|
|
var element = parentView.boundElements[elementRef.boundElementIndex];
|
|
var nodes = resolveInternalDomFragment(fragmentRef);
|
|
moveNodesAfterSibling(element, nodes);
|
|
this.animateNodesEnter(nodes);
|
|
};
|
|
DomRenderer.prototype.hydrateView = function(viewRef) {
|
|
resolveInternalDomView(viewRef).hydrate();
|
|
};
|
|
DomRenderer.prototype.dehydrateView = function(viewRef) {
|
|
resolveInternalDomView(viewRef).dehydrate();
|
|
};
|
|
DomRenderer.prototype.createTemplateAnchor = function(attrNameAndValues) {
|
|
return dom_adapter_1.DOM.createComment(TEMPLATE_COMMENT_TEXT);
|
|
};
|
|
DomRenderer.prototype.createText = function(value) {
|
|
return dom_adapter_1.DOM.createTextNode(lang_1.isPresent(value) ? value : '');
|
|
};
|
|
DomRenderer.prototype.appendChild = function(parent, child) {
|
|
dom_adapter_1.DOM.appendChild(parent, child);
|
|
};
|
|
DomRenderer.prototype.setElementProperty = function(location, propertyName, propertyValue) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
dom_adapter_1.DOM.setProperty(view.boundElements[location.boundElementIndex], propertyName, propertyValue);
|
|
};
|
|
DomRenderer.prototype.setElementAttribute = function(location, attributeName, attributeValue) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
var element = view.boundElements[location.boundElementIndex];
|
|
if (lang_1.isPresent(attributeValue)) {
|
|
dom_adapter_1.DOM.setAttribute(element, attributeName, lang_1.stringify(attributeValue));
|
|
} else {
|
|
dom_adapter_1.DOM.removeAttribute(element, attributeName);
|
|
}
|
|
};
|
|
DomRenderer.prototype.setBindingDebugInfo = function(location, propertyName, propertyValue) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
var element = view.boundElements[location.boundElementIndex];
|
|
var dashCasedPropertyName = util_1.camelCaseToDashCase(propertyName);
|
|
if (dom_adapter_1.DOM.isCommentNode(element)) {
|
|
var existingBindings = lang_1.RegExpWrapper.firstMatch(TEMPLATE_BINDINGS_EXP, lang_1.StringWrapper.replaceAll(dom_adapter_1.DOM.getText(element), /\n/g, ''));
|
|
var parsedBindings = lang_1.Json.parse(existingBindings[1]);
|
|
parsedBindings[dashCasedPropertyName] = propertyValue;
|
|
dom_adapter_1.DOM.setText(element, lang_1.StringWrapper.replace(TEMPLATE_COMMENT_TEXT, '{}', lang_1.Json.stringify(parsedBindings)));
|
|
} else {
|
|
this.setElementAttribute(location, propertyName, propertyValue);
|
|
}
|
|
};
|
|
DomRenderer.prototype.setElementClass = function(location, className, isAdd) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
var element = view.boundElements[location.boundElementIndex];
|
|
if (isAdd) {
|
|
dom_adapter_1.DOM.addClass(element, className);
|
|
} else {
|
|
dom_adapter_1.DOM.removeClass(element, className);
|
|
}
|
|
};
|
|
DomRenderer.prototype.setElementStyle = function(location, styleName, styleValue) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
var element = view.boundElements[location.boundElementIndex];
|
|
if (lang_1.isPresent(styleValue)) {
|
|
dom_adapter_1.DOM.setStyle(element, styleName, lang_1.stringify(styleValue));
|
|
} else {
|
|
dom_adapter_1.DOM.removeStyle(element, styleName);
|
|
}
|
|
};
|
|
DomRenderer.prototype.invokeElementMethod = function(location, methodName, args) {
|
|
var view = resolveInternalDomView(location.renderView);
|
|
var element = view.boundElements[location.boundElementIndex];
|
|
dom_adapter_1.DOM.invoke(element, methodName, args);
|
|
};
|
|
DomRenderer.prototype.setText = function(viewRef, textNodeIndex, text) {
|
|
var view = resolveInternalDomView(viewRef);
|
|
dom_adapter_1.DOM.setText(view.boundTextNodes[textNodeIndex], text);
|
|
};
|
|
DomRenderer.prototype.setEventDispatcher = function(viewRef, dispatcher) {
|
|
resolveInternalDomView(viewRef).setEventDispatcher(dispatcher);
|
|
};
|
|
return DomRenderer;
|
|
})(core_1.Renderer);
|
|
exports.DomRenderer = DomRenderer;
|
|
var DomRenderer_ = (function(_super) {
|
|
__extends(DomRenderer_, _super);
|
|
function DomRenderer_(_eventManager, _domSharedStylesHost, _animate, document) {
|
|
_super.call(this);
|
|
this._eventManager = _eventManager;
|
|
this._domSharedStylesHost = _domSharedStylesHost;
|
|
this._animate = _animate;
|
|
this._componentTpls = new Map();
|
|
this._createRootHostViewScope = profile_1.wtfCreateScope('DomRenderer#createRootHostView()');
|
|
this._createViewScope = profile_1.wtfCreateScope('DomRenderer#createView()');
|
|
this._detachFragmentScope = profile_1.wtfCreateScope('DomRenderer#detachFragment()');
|
|
this._document = document;
|
|
}
|
|
DomRenderer_.prototype.registerComponentTemplate = function(template) {
|
|
this._componentTpls.set(template.id, template);
|
|
if (template.encapsulation !== metadata_1.ViewEncapsulation.Native) {
|
|
var encapsulatedStyles = view_factory_1.encapsulateStyles(template);
|
|
this._domSharedStylesHost.addStyles(encapsulatedStyles);
|
|
}
|
|
};
|
|
DomRenderer_.prototype.createProtoView = function(componentTemplateId, cmds) {
|
|
return new view_1.DefaultProtoViewRef(this._componentTpls.get(componentTemplateId), cmds);
|
|
};
|
|
DomRenderer_.prototype.resolveComponentTemplate = function(templateId) {
|
|
return this._componentTpls.get(templateId);
|
|
};
|
|
DomRenderer_.prototype.createRootHostView = function(hostProtoViewRef, fragmentCount, hostElementSelector) {
|
|
var s = this._createRootHostViewScope();
|
|
var element = dom_adapter_1.DOM.querySelector(this._document, hostElementSelector);
|
|
if (lang_1.isBlank(element)) {
|
|
profile_1.wtfLeave(s);
|
|
throw new exceptions_1.BaseException("The selector \"" + hostElementSelector + "\" did not match any elements");
|
|
}
|
|
return profile_1.wtfLeave(s, this._createView(hostProtoViewRef, element));
|
|
};
|
|
DomRenderer_.prototype.createView = function(protoViewRef, fragmentCount) {
|
|
var s = this._createViewScope();
|
|
return profile_1.wtfLeave(s, this._createView(protoViewRef, null));
|
|
};
|
|
DomRenderer_.prototype._createView = function(protoViewRef, inplaceElement) {
|
|
var dpvr = protoViewRef;
|
|
var view = view_factory_1.createRenderView(dpvr.template, dpvr.cmds, inplaceElement, this);
|
|
var sdRoots = view.nativeShadowRoots;
|
|
for (var i = 0; i < sdRoots.length; i++) {
|
|
this._domSharedStylesHost.addHost(sdRoots[i]);
|
|
}
|
|
return new core_1.RenderViewWithFragments(view, view.fragments);
|
|
};
|
|
DomRenderer_.prototype.destroyView = function(viewRef) {
|
|
var view = viewRef;
|
|
var sdRoots = view.nativeShadowRoots;
|
|
for (var i = 0; i < sdRoots.length; i++) {
|
|
this._domSharedStylesHost.removeHost(sdRoots[i]);
|
|
}
|
|
};
|
|
DomRenderer_.prototype.animateNodeEnter = function(node) {
|
|
if (dom_adapter_1.DOM.isElementNode(node) && dom_adapter_1.DOM.hasClass(node, 'ng-animate')) {
|
|
dom_adapter_1.DOM.addClass(node, 'ng-enter');
|
|
this._animate.css().addAnimationClass('ng-enter-active').start(node).onComplete(function() {
|
|
dom_adapter_1.DOM.removeClass(node, 'ng-enter');
|
|
});
|
|
}
|
|
};
|
|
DomRenderer_.prototype.animateNodeLeave = function(node) {
|
|
if (dom_adapter_1.DOM.isElementNode(node) && dom_adapter_1.DOM.hasClass(node, 'ng-animate')) {
|
|
dom_adapter_1.DOM.addClass(node, 'ng-leave');
|
|
this._animate.css().addAnimationClass('ng-leave-active').start(node).onComplete(function() {
|
|
dom_adapter_1.DOM.removeClass(node, 'ng-leave');
|
|
dom_adapter_1.DOM.remove(node);
|
|
});
|
|
} else {
|
|
dom_adapter_1.DOM.remove(node);
|
|
}
|
|
};
|
|
DomRenderer_.prototype.detachFragment = function(fragmentRef) {
|
|
var s = this._detachFragmentScope();
|
|
var fragmentNodes = resolveInternalDomFragment(fragmentRef);
|
|
for (var i = 0; i < fragmentNodes.length; i++) {
|
|
this.animateNodeLeave(fragmentNodes[i]);
|
|
}
|
|
profile_1.wtfLeave(s);
|
|
};
|
|
DomRenderer_.prototype.createElement = function(name, attrNameAndValues) {
|
|
var nsAndName = splitNamespace(name);
|
|
var el = lang_1.isPresent(nsAndName[0]) ? dom_adapter_1.DOM.createElementNS(NAMESPACE_URIS[nsAndName[0]], nsAndName[1]) : dom_adapter_1.DOM.createElement(nsAndName[1]);
|
|
this._setAttributes(el, attrNameAndValues);
|
|
return el;
|
|
};
|
|
DomRenderer_.prototype.mergeElement = function(existing, attrNameAndValues) {
|
|
dom_adapter_1.DOM.clearNodes(existing);
|
|
this._setAttributes(existing, attrNameAndValues);
|
|
};
|
|
DomRenderer_.prototype._setAttributes = function(node, attrNameAndValues) {
|
|
for (var attrIdx = 0; attrIdx < attrNameAndValues.length; attrIdx += 2) {
|
|
var attrNs;
|
|
var attrName = attrNameAndValues[attrIdx];
|
|
var nsAndName = splitNamespace(attrName);
|
|
if (lang_1.isPresent(nsAndName[0])) {
|
|
attrName = nsAndName[0] + ':' + nsAndName[1];
|
|
attrNs = NAMESPACE_URIS[nsAndName[0]];
|
|
}
|
|
var attrValue = attrNameAndValues[attrIdx + 1];
|
|
if (lang_1.isPresent(attrNs)) {
|
|
dom_adapter_1.DOM.setAttributeNS(node, attrNs, attrName, attrValue);
|
|
} else {
|
|
dom_adapter_1.DOM.setAttribute(node, nsAndName[1], attrValue);
|
|
}
|
|
}
|
|
};
|
|
DomRenderer_.prototype.createRootContentInsertionPoint = function() {
|
|
return dom_adapter_1.DOM.createComment('root-content-insertion-point');
|
|
};
|
|
DomRenderer_.prototype.createShadowRoot = function(host, templateId) {
|
|
var sr = dom_adapter_1.DOM.createShadowRoot(host);
|
|
var tpl = this._componentTpls.get(templateId);
|
|
for (var i = 0; i < tpl.styles.length; i++) {
|
|
dom_adapter_1.DOM.appendChild(sr, dom_adapter_1.DOM.createStyleElement(tpl.styles[i]));
|
|
}
|
|
return sr;
|
|
};
|
|
DomRenderer_.prototype.on = function(element, eventName, callback) {
|
|
this._eventManager.addEventListener(element, eventName, decoratePreventDefault(callback));
|
|
};
|
|
DomRenderer_.prototype.globalOn = function(target, eventName, callback) {
|
|
return this._eventManager.addGlobalEventListener(target, eventName, decoratePreventDefault(callback));
|
|
};
|
|
DomRenderer_ = __decorate([di_1.Injectable(), __param(3, di_1.Inject(dom_tokens_1.DOCUMENT)), __metadata('design:paramtypes', [event_manager_1.EventManager, shared_styles_host_1.DomSharedStylesHost, animation_builder_1.AnimationBuilder, Object])], DomRenderer_);
|
|
return DomRenderer_;
|
|
})(DomRenderer);
|
|
exports.DomRenderer_ = DomRenderer_;
|
|
function resolveInternalDomView(viewRef) {
|
|
return viewRef;
|
|
}
|
|
function resolveInternalDomFragment(fragmentRef) {
|
|
return fragmentRef.nodes;
|
|
}
|
|
function moveNodesAfterSibling(sibling, nodes) {
|
|
var parent = dom_adapter_1.DOM.parentElement(sibling);
|
|
if (nodes.length > 0 && lang_1.isPresent(parent)) {
|
|
var nextSibling = dom_adapter_1.DOM.nextSibling(sibling);
|
|
if (lang_1.isPresent(nextSibling)) {
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
dom_adapter_1.DOM.insertBefore(nextSibling, nodes[i]);
|
|
}
|
|
} else {
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
dom_adapter_1.DOM.appendChild(parent, nodes[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function decoratePreventDefault(eventHandler) {
|
|
return function(event) {
|
|
var allowDefaultBehavior = eventHandler(event);
|
|
if (!allowDefaultBehavior) {
|
|
dom_adapter_1.DOM.preventDefault(event);
|
|
}
|
|
};
|
|
}
|
|
var NS_PREFIX_RE = /^@([^:]+):(.+)/g;
|
|
function splitNamespace(name) {
|
|
if (name[0] != '@') {
|
|
return [null, name];
|
|
}
|
|
var match = lang_1.RegExpWrapper.firstMatch(NS_PREFIX_RE, name);
|
|
return [match[1], match[2]];
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4d", ["39", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
exports.DOCUMENT = lang_1.CONST_EXPR(new di_1.OpaqueToken('DocumentToken'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4b", ["36", "39", "37", "4d"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var dom_adapter_1 = $__require('36');
|
|
var di_1 = $__require('39');
|
|
var collection_1 = $__require('37');
|
|
var dom_tokens_1 = $__require('4d');
|
|
var SharedStylesHost = (function() {
|
|
function SharedStylesHost() {
|
|
this._styles = [];
|
|
this._stylesSet = new Set();
|
|
}
|
|
SharedStylesHost.prototype.addStyles = function(styles) {
|
|
var _this = this;
|
|
var additions = [];
|
|
styles.forEach(function(style) {
|
|
if (!collection_1.SetWrapper.has(_this._stylesSet, style)) {
|
|
_this._stylesSet.add(style);
|
|
_this._styles.push(style);
|
|
additions.push(style);
|
|
}
|
|
});
|
|
this.onStylesAdded(additions);
|
|
};
|
|
SharedStylesHost.prototype.onStylesAdded = function(additions) {};
|
|
SharedStylesHost.prototype.getAllStyles = function() {
|
|
return this._styles;
|
|
};
|
|
SharedStylesHost = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], SharedStylesHost);
|
|
return SharedStylesHost;
|
|
})();
|
|
exports.SharedStylesHost = SharedStylesHost;
|
|
var DomSharedStylesHost = (function(_super) {
|
|
__extends(DomSharedStylesHost, _super);
|
|
function DomSharedStylesHost(doc) {
|
|
_super.call(this);
|
|
this._hostNodes = new Set();
|
|
this._hostNodes.add(doc.head);
|
|
}
|
|
DomSharedStylesHost.prototype._addStylesToHost = function(styles, host) {
|
|
for (var i = 0; i < styles.length; i++) {
|
|
var style = styles[i];
|
|
dom_adapter_1.DOM.appendChild(host, dom_adapter_1.DOM.createStyleElement(style));
|
|
}
|
|
};
|
|
DomSharedStylesHost.prototype.addHost = function(hostNode) {
|
|
this._addStylesToHost(this._styles, hostNode);
|
|
this._hostNodes.add(hostNode);
|
|
};
|
|
DomSharedStylesHost.prototype.removeHost = function(hostNode) {
|
|
collection_1.SetWrapper.delete(this._hostNodes, hostNode);
|
|
};
|
|
DomSharedStylesHost.prototype.onStylesAdded = function(additions) {
|
|
var _this = this;
|
|
this._hostNodes.forEach(function(hostNode) {
|
|
_this._addStylesToHost(additions, hostNode);
|
|
});
|
|
};
|
|
DomSharedStylesHost = __decorate([di_1.Injectable(), __param(0, di_1.Inject(dom_tokens_1.DOCUMENT)), __metadata('design:paramtypes', [Object])], DomSharedStylesHost);
|
|
return DomSharedStylesHost;
|
|
})(SharedStylesHost);
|
|
exports.DomSharedStylesHost = DomSharedStylesHost;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("51", ["36", "14", "38"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var dom_adapter_1 = $__require('36');
|
|
var core_1 = $__require('14');
|
|
var event_manager_1 = $__require('38');
|
|
var DomEventsPlugin = (function(_super) {
|
|
__extends(DomEventsPlugin, _super);
|
|
function DomEventsPlugin() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
DomEventsPlugin.prototype.supports = function(eventName) {
|
|
return true;
|
|
};
|
|
DomEventsPlugin.prototype.addEventListener = function(element, eventName, handler) {
|
|
var zone = this.manager.getZone();
|
|
var outsideHandler = function(event) {
|
|
return zone.run(function() {
|
|
return handler(event);
|
|
});
|
|
};
|
|
this.manager.getZone().runOutsideAngular(function() {
|
|
dom_adapter_1.DOM.on(element, eventName, outsideHandler);
|
|
});
|
|
};
|
|
DomEventsPlugin.prototype.addGlobalEventListener = function(target, eventName, handler) {
|
|
var element = dom_adapter_1.DOM.getGlobalEventTarget(target);
|
|
var zone = this.manager.getZone();
|
|
var outsideHandler = function(event) {
|
|
return zone.run(function() {
|
|
return handler(event);
|
|
});
|
|
};
|
|
return this.manager.getZone().runOutsideAngular(function() {
|
|
return dom_adapter_1.DOM.onAndCancel(element, eventName, outsideHandler);
|
|
});
|
|
};
|
|
DomEventsPlugin = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], DomEventsPlugin);
|
|
return DomEventsPlugin;
|
|
})(event_manager_1.EventManagerPlugin);
|
|
exports.DomEventsPlugin = DomEventsPlugin;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("38", ["20", "3c", "39", "52", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var di_1 = $__require('39');
|
|
var ng_zone_1 = $__require('52');
|
|
var collection_1 = $__require('37');
|
|
exports.EVENT_MANAGER_PLUGINS = lang_1.CONST_EXPR(new di_1.OpaqueToken("EventManagerPlugins"));
|
|
var EventManager = (function() {
|
|
function EventManager(plugins, _zone) {
|
|
var _this = this;
|
|
this._zone = _zone;
|
|
plugins.forEach(function(p) {
|
|
return p.manager = _this;
|
|
});
|
|
this._plugins = collection_1.ListWrapper.reversed(plugins);
|
|
}
|
|
EventManager.prototype.addEventListener = function(element, eventName, handler) {
|
|
var plugin = this._findPluginFor(eventName);
|
|
plugin.addEventListener(element, eventName, handler);
|
|
};
|
|
EventManager.prototype.addGlobalEventListener = function(target, eventName, handler) {
|
|
var plugin = this._findPluginFor(eventName);
|
|
return plugin.addGlobalEventListener(target, eventName, handler);
|
|
};
|
|
EventManager.prototype.getZone = function() {
|
|
return this._zone;
|
|
};
|
|
EventManager.prototype._findPluginFor = function(eventName) {
|
|
var plugins = this._plugins;
|
|
for (var i = 0; i < plugins.length; i++) {
|
|
var plugin = plugins[i];
|
|
if (plugin.supports(eventName)) {
|
|
return plugin;
|
|
}
|
|
}
|
|
throw new exceptions_1.BaseException("No event manager plugin found for event " + eventName);
|
|
};
|
|
EventManager = __decorate([di_1.Injectable(), __param(0, di_1.Inject(exports.EVENT_MANAGER_PLUGINS)), __metadata('design:paramtypes', [Array, ng_zone_1.NgZone])], EventManager);
|
|
return EventManager;
|
|
})();
|
|
exports.EventManager = EventManager;
|
|
var EventManagerPlugin = (function() {
|
|
function EventManagerPlugin() {}
|
|
EventManagerPlugin.prototype.supports = function(eventName) {
|
|
return false;
|
|
};
|
|
EventManagerPlugin.prototype.addEventListener = function(element, eventName, handler) {
|
|
throw "not implemented";
|
|
};
|
|
EventManagerPlugin.prototype.addGlobalEventListener = function(element, eventName, handler) {
|
|
throw "not implemented";
|
|
};
|
|
return EventManagerPlugin;
|
|
})();
|
|
exports.EventManagerPlugin = EventManagerPlugin;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("53", ["20", "36"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var dom_adapter_1 = $__require('36');
|
|
var By = (function() {
|
|
function By() {}
|
|
By.all = function() {
|
|
return function(debugElement) {
|
|
return true;
|
|
};
|
|
};
|
|
By.css = function(selector) {
|
|
return function(debugElement) {
|
|
return lang_1.isPresent(debugElement.nativeElement) ? dom_adapter_1.DOM.elementMatches(debugElement.nativeElement, selector) : false;
|
|
};
|
|
};
|
|
By.directive = function(type) {
|
|
return function(debugElement) {
|
|
return debugElement.hasDirective(type);
|
|
};
|
|
};
|
|
return By;
|
|
})();
|
|
exports.By = By;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("54", ["20", "37", "39", "55", "36", "56", "57"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var di_1 = $__require('39');
|
|
var view_listener_1 = $__require('55');
|
|
var dom_adapter_1 = $__require('36');
|
|
var api_1 = $__require('56');
|
|
var debug_element_1 = $__require('57');
|
|
var NG_ID_PROPERTY = 'ngid';
|
|
var INSPECT_GLOBAL_NAME = 'ng.probe';
|
|
var NG_ID_SEPARATOR = '#';
|
|
var _allIdsByView = new collection_1.Map();
|
|
var _allViewsById = new collection_1.Map();
|
|
var _nextId = 0;
|
|
function _setElementId(element, indices) {
|
|
if (lang_1.isPresent(element) && dom_adapter_1.DOM.isElementNode(element)) {
|
|
dom_adapter_1.DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
|
|
}
|
|
}
|
|
function _getElementId(element) {
|
|
var elId = dom_adapter_1.DOM.getData(element, NG_ID_PROPERTY);
|
|
if (lang_1.isPresent(elId)) {
|
|
return elId.split(NG_ID_SEPARATOR).map(function(partStr) {
|
|
return lang_1.NumberWrapper.parseInt(partStr, 10);
|
|
});
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function inspectNativeElement(element) {
|
|
var elId = _getElementId(element);
|
|
if (lang_1.isPresent(elId)) {
|
|
var view = _allViewsById.get(elId[0]);
|
|
if (lang_1.isPresent(view)) {
|
|
return new debug_element_1.DebugElement_(view, elId[1]);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
exports.inspectNativeElement = inspectNativeElement;
|
|
var DebugElementViewListener = (function() {
|
|
function DebugElementViewListener(_renderer) {
|
|
this._renderer = _renderer;
|
|
dom_adapter_1.DOM.setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
|
|
}
|
|
DebugElementViewListener.prototype.onViewCreated = function(view) {
|
|
var viewId = _nextId++;
|
|
_allViewsById.set(viewId, view);
|
|
_allIdsByView.set(view, viewId);
|
|
for (var i = 0; i < view.elementRefs.length; i++) {
|
|
var el = view.elementRefs[i];
|
|
_setElementId(this._renderer.getNativeElementSync(el), [viewId, i]);
|
|
}
|
|
};
|
|
DebugElementViewListener.prototype.onViewDestroyed = function(view) {
|
|
var viewId = _allIdsByView.get(view);
|
|
_allIdsByView.delete(view);
|
|
_allViewsById.delete(viewId);
|
|
};
|
|
DebugElementViewListener = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [api_1.Renderer])], DebugElementViewListener);
|
|
return DebugElementViewListener;
|
|
})();
|
|
exports.DebugElementViewListener = DebugElementViewListener;
|
|
exports.ELEMENT_PROBE_PROVIDERS = lang_1.CONST_EXPR([DebugElementViewListener, lang_1.CONST_EXPR(new di_1.Provider(view_listener_1.AppViewListener, {useExisting: DebugElementViewListener}))]);
|
|
exports.ELEMENT_PROBE_BINDINGS = exports.ELEMENT_PROBE_PROVIDERS;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("58", ["36", "4a", "4d", "4b", "51", "38", "53", "54"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
var dom_adapter_1 = $__require('36');
|
|
exports.DOM = dom_adapter_1.DOM;
|
|
exports.setRootDomAdapter = dom_adapter_1.setRootDomAdapter;
|
|
exports.DomAdapter = dom_adapter_1.DomAdapter;
|
|
var dom_renderer_1 = $__require('4a');
|
|
exports.DomRenderer = dom_renderer_1.DomRenderer;
|
|
var dom_tokens_1 = $__require('4d');
|
|
exports.DOCUMENT = dom_tokens_1.DOCUMENT;
|
|
var shared_styles_host_1 = $__require('4b');
|
|
exports.SharedStylesHost = shared_styles_host_1.SharedStylesHost;
|
|
exports.DomSharedStylesHost = shared_styles_host_1.DomSharedStylesHost;
|
|
var dom_events_1 = $__require('51');
|
|
exports.DomEventsPlugin = dom_events_1.DomEventsPlugin;
|
|
var event_manager_1 = $__require('38');
|
|
exports.EVENT_MANAGER_PLUGINS = event_manager_1.EVENT_MANAGER_PLUGINS;
|
|
exports.EventManager = event_manager_1.EventManager;
|
|
exports.EventManagerPlugin = event_manager_1.EventManagerPlugin;
|
|
__export($__require('53'));
|
|
__export($__require('54'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("59", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var win = window;
|
|
exports.window = win;
|
|
exports.document = window.document;
|
|
exports.location = window.location;
|
|
exports.gc = window['gc'] ? function() {
|
|
return window['gc']();
|
|
} : function() {
|
|
return null;
|
|
};
|
|
exports.performance = window['performance'] ? window['performance'] : null;
|
|
exports.Event = window['Event'];
|
|
exports.MouseEvent = window['MouseEvent'];
|
|
exports.KeyboardEvent = window['KeyboardEvent'];
|
|
exports.EventTarget = window['EventTarget'];
|
|
exports.History = window['History'];
|
|
exports.Location = window['Location'];
|
|
exports.EventListener = window['EventListener'];
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5a", ["5b", "20", "59", "36"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var application_ref_1 = $__require('5b');
|
|
var lang_1 = $__require('20');
|
|
var browser_1 = $__require('59');
|
|
var dom_adapter_1 = $__require('36');
|
|
var AngularTools = (function() {
|
|
function AngularTools(ref) {
|
|
this.profiler = new AngularProfiler(ref);
|
|
}
|
|
return AngularTools;
|
|
})();
|
|
exports.AngularTools = AngularTools;
|
|
var AngularProfiler = (function() {
|
|
function AngularProfiler(ref) {
|
|
this.appRef = ref.injector.get(application_ref_1.ApplicationRef);
|
|
}
|
|
AngularProfiler.prototype.timeChangeDetection = function(config) {
|
|
var record = lang_1.isPresent(config) && config['record'];
|
|
var profileName = 'Change Detection';
|
|
var isProfilerAvailable = lang_1.isPresent(browser_1.window.console.profile);
|
|
if (record && isProfilerAvailable) {
|
|
browser_1.window.console.profile(profileName);
|
|
}
|
|
var start = dom_adapter_1.DOM.performanceNow();
|
|
var numTicks = 0;
|
|
while (numTicks < 5 || (dom_adapter_1.DOM.performanceNow() - start) < 500) {
|
|
this.appRef.tick();
|
|
numTicks++;
|
|
}
|
|
var end = dom_adapter_1.DOM.performanceNow();
|
|
if (record && isProfilerAvailable) {
|
|
browser_1.window.console.profileEnd(profileName);
|
|
}
|
|
var msPerTick = (end - start) / numTicks;
|
|
browser_1.window.console.log("ran " + numTicks + " change detection cycles");
|
|
browser_1.window.console.log(lang_1.NumberWrapper.toFixed(msPerTick, 2) + " ms per check");
|
|
};
|
|
return AngularProfiler;
|
|
})();
|
|
exports.AngularProfiler = AngularProfiler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5c", ["20", "5a"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var common_tools_1 = $__require('5a');
|
|
var context = lang_1.global;
|
|
function enableDebugTools(ref) {
|
|
context.ng = new common_tools_1.AngularTools(ref);
|
|
}
|
|
exports.enableDebugTools = enableDebugTools;
|
|
function disableDebugTools() {
|
|
delete context.ng;
|
|
}
|
|
exports.disableDebugTools = disableDebugTools;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5d", ["20", "39", "14", "22", "5e", "36", "51", "35", "3b", "4d", "4a", "4b", "48", "49", "3f", "40", "41", "38", "42", "58", "5c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var core_1 = $__require('14');
|
|
var common_1 = $__require('22');
|
|
var testability_1 = $__require('5e');
|
|
var dom_adapter_1 = $__require('36');
|
|
var dom_events_1 = $__require('51');
|
|
var key_events_1 = $__require('35');
|
|
var hammer_gestures_1 = $__require('3b');
|
|
var dom_tokens_1 = $__require('4d');
|
|
var dom_renderer_1 = $__require('4a');
|
|
var shared_styles_host_1 = $__require('4b');
|
|
var shared_styles_host_2 = $__require('4b');
|
|
var browser_details_1 = $__require('48');
|
|
var animation_builder_1 = $__require('49');
|
|
var browser_adapter_1 = $__require('3f');
|
|
var testability_2 = $__require('40');
|
|
var wtf_init_1 = $__require('41');
|
|
var event_manager_1 = $__require('38');
|
|
var dom_tokens_2 = $__require('4d');
|
|
exports.DOCUMENT = dom_tokens_2.DOCUMENT;
|
|
var title_1 = $__require('42');
|
|
exports.Title = title_1.Title;
|
|
var common_dom_1 = $__require('58');
|
|
exports.DebugElementViewListener = common_dom_1.DebugElementViewListener;
|
|
exports.ELEMENT_PROBE_PROVIDERS = common_dom_1.ELEMENT_PROBE_PROVIDERS;
|
|
exports.ELEMENT_PROBE_BINDINGS = common_dom_1.ELEMENT_PROBE_BINDINGS;
|
|
exports.inspectNativeElement = common_dom_1.inspectNativeElement;
|
|
exports.By = common_dom_1.By;
|
|
var browser_adapter_2 = $__require('3f');
|
|
exports.BrowserDomAdapter = browser_adapter_2.BrowserDomAdapter;
|
|
var tools_1 = $__require('5c');
|
|
exports.enableDebugTools = tools_1.enableDebugTools;
|
|
exports.disableDebugTools = tools_1.disableDebugTools;
|
|
exports.BROWSER_PROVIDERS = lang_1.CONST_EXPR([core_1.PLATFORM_COMMON_PROVIDERS, new di_1.Provider(core_1.PLATFORM_INITIALIZER, {
|
|
useValue: initDomAdapter,
|
|
multi: true
|
|
})]);
|
|
function _exceptionHandler() {
|
|
return new core_1.ExceptionHandler(dom_adapter_1.DOM, !lang_1.IS_DART);
|
|
}
|
|
function _document() {
|
|
return dom_adapter_1.DOM.defaultDoc();
|
|
}
|
|
exports.BROWSER_APP_COMMON_PROVIDERS = lang_1.CONST_EXPR([core_1.APPLICATION_COMMON_PROVIDERS, common_1.FORM_PROVIDERS, new di_1.Provider(core_1.PLATFORM_PIPES, {
|
|
useValue: common_1.COMMON_PIPES,
|
|
multi: true
|
|
}), new di_1.Provider(core_1.PLATFORM_DIRECTIVES, {
|
|
useValue: common_1.COMMON_DIRECTIVES,
|
|
multi: true
|
|
}), new di_1.Provider(core_1.ExceptionHandler, {
|
|
useFactory: _exceptionHandler,
|
|
deps: []
|
|
}), new di_1.Provider(dom_tokens_1.DOCUMENT, {
|
|
useFactory: _document,
|
|
deps: []
|
|
}), new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, {
|
|
useClass: dom_events_1.DomEventsPlugin,
|
|
multi: true
|
|
}), new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, {
|
|
useClass: key_events_1.KeyEventsPlugin,
|
|
multi: true
|
|
}), new di_1.Provider(event_manager_1.EVENT_MANAGER_PLUGINS, {
|
|
useClass: hammer_gestures_1.HammerGesturesPlugin,
|
|
multi: true
|
|
}), new di_1.Provider(dom_renderer_1.DomRenderer, {useClass: dom_renderer_1.DomRenderer_}), new di_1.Provider(core_1.Renderer, {useExisting: dom_renderer_1.DomRenderer}), new di_1.Provider(shared_styles_host_2.SharedStylesHost, {useExisting: shared_styles_host_1.DomSharedStylesHost}), shared_styles_host_1.DomSharedStylesHost, testability_1.Testability, browser_details_1.BrowserDetails, animation_builder_1.AnimationBuilder, event_manager_1.EventManager]);
|
|
function initDomAdapter() {
|
|
browser_adapter_1.BrowserDomAdapter.makeCurrent();
|
|
wtf_init_1.wtfInit();
|
|
testability_2.BrowserGetTestability.init();
|
|
}
|
|
exports.initDomAdapter = initDomAdapter;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5f", ["60", "61", "62", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var compiler_1 = $__require('60');
|
|
var proto_view_factory_1 = $__require('61');
|
|
var template_compiler_1 = $__require('62');
|
|
var di_1 = $__require('39');
|
|
var RuntimeCompiler = (function(_super) {
|
|
__extends(RuntimeCompiler, _super);
|
|
function RuntimeCompiler() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
return RuntimeCompiler;
|
|
})(compiler_1.Compiler);
|
|
exports.RuntimeCompiler = RuntimeCompiler;
|
|
var RuntimeCompiler_ = (function(_super) {
|
|
__extends(RuntimeCompiler_, _super);
|
|
function RuntimeCompiler_(_protoViewFactory, _templateCompiler) {
|
|
_super.call(this, _protoViewFactory);
|
|
this._templateCompiler = _templateCompiler;
|
|
}
|
|
RuntimeCompiler_.prototype.compileInHost = function(componentType) {
|
|
var _this = this;
|
|
return this._templateCompiler.compileHostComponentRuntime(componentType).then(function(compiledHostTemplate) {
|
|
return compiler_1.internalCreateProtoView(_this, compiledHostTemplate);
|
|
});
|
|
};
|
|
RuntimeCompiler_.prototype.clearCache = function() {
|
|
_super.prototype.clearCache.call(this);
|
|
this._templateCompiler.clearCache();
|
|
};
|
|
RuntimeCompiler_ = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [proto_view_factory_1.ProtoViewFactory, template_compiler_1.TemplateCompiler])], RuntimeCompiler_);
|
|
return RuntimeCompiler_;
|
|
})(compiler_1.Compiler_);
|
|
exports.RuntimeCompiler_ = RuntimeCompiler_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("62", ["20", "3c", "37", "63", "64", "65", "39", "66", "67", "68", "69", "6a", "6b", "6c", "6d"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var async_1 = $__require('63');
|
|
var template_commands_1 = $__require('64');
|
|
var directive_metadata_1 = $__require('65');
|
|
var di_1 = $__require('39');
|
|
var source_module_1 = $__require('66');
|
|
var change_detector_compiler_1 = $__require('67');
|
|
var style_compiler_1 = $__require('68');
|
|
var command_compiler_1 = $__require('69');
|
|
var template_parser_1 = $__require('6a');
|
|
var template_normalizer_1 = $__require('6b');
|
|
var runtime_metadata_1 = $__require('6c');
|
|
var command_compiler_2 = $__require('69');
|
|
var util_1 = $__require('6d');
|
|
var TemplateCompiler = (function() {
|
|
function TemplateCompiler(_runtimeMetadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _commandCompiler, _cdCompiler) {
|
|
this._runtimeMetadataResolver = _runtimeMetadataResolver;
|
|
this._templateNormalizer = _templateNormalizer;
|
|
this._templateParser = _templateParser;
|
|
this._styleCompiler = _styleCompiler;
|
|
this._commandCompiler = _commandCompiler;
|
|
this._cdCompiler = _cdCompiler;
|
|
this._hostCacheKeys = new Map();
|
|
this._compiledTemplateCache = new Map();
|
|
this._compiledTemplateDone = new Map();
|
|
this._nextTemplateId = 0;
|
|
}
|
|
TemplateCompiler.prototype.normalizeDirectiveMetadata = function(directive) {
|
|
if (!directive.isComponent) {
|
|
return async_1.PromiseWrapper.resolve(directive);
|
|
}
|
|
return this._templateNormalizer.normalizeTemplate(directive.type, directive.template).then(function(normalizedTemplate) {
|
|
return new directive_metadata_1.CompileDirectiveMetadata({
|
|
type: directive.type,
|
|
isComponent: directive.isComponent,
|
|
dynamicLoadable: directive.dynamicLoadable,
|
|
selector: directive.selector,
|
|
exportAs: directive.exportAs,
|
|
changeDetection: directive.changeDetection,
|
|
inputs: directive.inputs,
|
|
outputs: directive.outputs,
|
|
hostListeners: directive.hostListeners,
|
|
hostProperties: directive.hostProperties,
|
|
hostAttributes: directive.hostAttributes,
|
|
lifecycleHooks: directive.lifecycleHooks,
|
|
template: normalizedTemplate
|
|
});
|
|
});
|
|
};
|
|
TemplateCompiler.prototype.compileHostComponentRuntime = function(type) {
|
|
var hostCacheKey = this._hostCacheKeys.get(type);
|
|
if (lang_1.isBlank(hostCacheKey)) {
|
|
hostCacheKey = new Object();
|
|
this._hostCacheKeys.set(type, hostCacheKey);
|
|
var compMeta = this._runtimeMetadataResolver.getMetadata(type);
|
|
assertComponent(compMeta);
|
|
var hostMeta = directive_metadata_1.createHostComponentMeta(compMeta.type, compMeta.selector);
|
|
this._compileComponentRuntime(hostCacheKey, hostMeta, [compMeta], new Set());
|
|
}
|
|
return this._compiledTemplateDone.get(hostCacheKey).then(function(compiledTemplate) {
|
|
return new template_commands_1.CompiledHostTemplate(compiledTemplate);
|
|
});
|
|
};
|
|
TemplateCompiler.prototype.clearCache = function() {
|
|
this._hostCacheKeys.clear();
|
|
this._styleCompiler.clearCache();
|
|
this._compiledTemplateCache.clear();
|
|
this._compiledTemplateDone.clear();
|
|
};
|
|
TemplateCompiler.prototype._compileComponentRuntime = function(cacheKey, compMeta, viewDirectives, compilingComponentCacheKeys) {
|
|
var _this = this;
|
|
var uniqViewDirectives = removeDuplicates(viewDirectives);
|
|
var compiledTemplate = this._compiledTemplateCache.get(cacheKey);
|
|
var done = this._compiledTemplateDone.get(cacheKey);
|
|
if (lang_1.isBlank(compiledTemplate)) {
|
|
var styles = [];
|
|
var changeDetectorFactory;
|
|
var commands = [];
|
|
var templateId = lang_1.stringify(compMeta.type.runtime) + "Template" + this._nextTemplateId++;
|
|
compiledTemplate = new template_commands_1.CompiledComponentTemplate(templateId, function(dispatcher) {
|
|
return changeDetectorFactory(dispatcher);
|
|
}, commands, styles);
|
|
this._compiledTemplateCache.set(cacheKey, compiledTemplate);
|
|
compilingComponentCacheKeys.add(cacheKey);
|
|
done = async_1.PromiseWrapper.all([this._styleCompiler.compileComponentRuntime(compMeta.template)].concat(uniqViewDirectives.map(function(dirMeta) {
|
|
return _this.normalizeDirectiveMetadata(dirMeta);
|
|
}))).then(function(stylesAndNormalizedViewDirMetas) {
|
|
var childPromises = [];
|
|
var normalizedViewDirMetas = stylesAndNormalizedViewDirMetas.slice(1);
|
|
var parsedTemplate = _this._templateParser.parse(compMeta.template.template, normalizedViewDirMetas, compMeta.type.name);
|
|
var changeDetectorFactories = _this._cdCompiler.compileComponentRuntime(compMeta.type, compMeta.changeDetection, parsedTemplate);
|
|
changeDetectorFactory = changeDetectorFactories[0];
|
|
var tmpStyles = stylesAndNormalizedViewDirMetas[0];
|
|
tmpStyles.forEach(function(style) {
|
|
return styles.push(style);
|
|
});
|
|
var tmpCommands = _this._compileCommandsRuntime(compMeta, parsedTemplate, changeDetectorFactories, compilingComponentCacheKeys, childPromises);
|
|
tmpCommands.forEach(function(cmd) {
|
|
return commands.push(cmd);
|
|
});
|
|
return async_1.PromiseWrapper.all(childPromises);
|
|
}).then(function(_) {
|
|
collection_1.SetWrapper.delete(compilingComponentCacheKeys, cacheKey);
|
|
return compiledTemplate;
|
|
});
|
|
this._compiledTemplateDone.set(cacheKey, done);
|
|
}
|
|
return compiledTemplate;
|
|
};
|
|
TemplateCompiler.prototype._compileCommandsRuntime = function(compMeta, parsedTemplate, changeDetectorFactories, compilingComponentCacheKeys, childPromises) {
|
|
var _this = this;
|
|
var cmds = this._commandCompiler.compileComponentRuntime(compMeta, parsedTemplate, changeDetectorFactories, function(childComponentDir) {
|
|
var childCacheKey = childComponentDir.type.runtime;
|
|
var childViewDirectives = _this._runtimeMetadataResolver.getViewDirectivesMetadata(childComponentDir.type.runtime);
|
|
var childIsRecursive = collection_1.SetWrapper.has(compilingComponentCacheKeys, childCacheKey);
|
|
var childTemplate = _this._compileComponentRuntime(childCacheKey, childComponentDir, childViewDirectives, compilingComponentCacheKeys);
|
|
if (!childIsRecursive) {
|
|
childPromises.push(_this._compiledTemplateDone.get(childCacheKey));
|
|
}
|
|
return function() {
|
|
return childTemplate;
|
|
};
|
|
});
|
|
cmds.forEach(function(cmd) {
|
|
if (cmd instanceof template_commands_1.BeginComponentCmd) {
|
|
cmd.templateGetter();
|
|
}
|
|
});
|
|
return cmds;
|
|
};
|
|
TemplateCompiler.prototype.compileTemplatesCodeGen = function(components) {
|
|
var _this = this;
|
|
if (components.length === 0) {
|
|
throw new exceptions_1.BaseException('No components given');
|
|
}
|
|
var declarations = [];
|
|
var templateArguments = [];
|
|
var componentMetas = [];
|
|
components.forEach(function(componentWithDirs) {
|
|
var compMeta = componentWithDirs.component;
|
|
assertComponent(compMeta);
|
|
componentMetas.push(compMeta);
|
|
_this._processTemplateCodeGen(compMeta, componentWithDirs.directives, declarations, templateArguments);
|
|
if (compMeta.dynamicLoadable) {
|
|
var hostMeta = directive_metadata_1.createHostComponentMeta(compMeta.type, compMeta.selector);
|
|
componentMetas.push(hostMeta);
|
|
_this._processTemplateCodeGen(hostMeta, [compMeta], declarations, templateArguments);
|
|
}
|
|
});
|
|
collection_1.ListWrapper.forEachWithIndex(componentMetas, function(compMeta, index) {
|
|
var templateId = compMeta.type.moduleUrl + "|" + compMeta.type.name;
|
|
var constructionKeyword = lang_1.IS_DART ? 'const' : 'new';
|
|
var compiledTemplateExpr = constructionKeyword + " " + command_compiler_2.TEMPLATE_COMMANDS_MODULE_REF + "CompiledComponentTemplate('" + templateId + "'," + templateArguments[index].join(',') + ")";
|
|
var variableValueExpr;
|
|
if (compMeta.type.isHost) {
|
|
variableValueExpr = constructionKeyword + " " + command_compiler_2.TEMPLATE_COMMANDS_MODULE_REF + "CompiledHostTemplate(" + compiledTemplateExpr + ")";
|
|
} else {
|
|
variableValueExpr = compiledTemplateExpr;
|
|
}
|
|
var varName = templateVariableName(compMeta.type);
|
|
declarations.push("" + util_1.codeGenExportVariable(varName) + variableValueExpr + ";");
|
|
declarations.push(util_1.codeGenValueFn([], varName, templateGetterName(compMeta.type)) + ";");
|
|
});
|
|
var moduleUrl = components[0].component.type.moduleUrl;
|
|
return new source_module_1.SourceModule("" + templateModuleUrl(moduleUrl), declarations.join('\n'));
|
|
};
|
|
TemplateCompiler.prototype.compileStylesheetCodeGen = function(stylesheetUrl, cssText) {
|
|
return this._styleCompiler.compileStylesheetCodeGen(stylesheetUrl, cssText);
|
|
};
|
|
TemplateCompiler.prototype._processTemplateCodeGen = function(compMeta, directives, targetDeclarations, targetTemplateArguments) {
|
|
var uniqueDirectives = removeDuplicates(directives);
|
|
var styleExpr = this._styleCompiler.compileComponentCodeGen(compMeta.template);
|
|
var parsedTemplate = this._templateParser.parse(compMeta.template.template, uniqueDirectives, compMeta.type.name);
|
|
var changeDetectorsExprs = this._cdCompiler.compileComponentCodeGen(compMeta.type, compMeta.changeDetection, parsedTemplate);
|
|
var commandsExpr = this._commandCompiler.compileComponentCodeGen(compMeta, parsedTemplate, changeDetectorsExprs.expressions, codeGenComponentTemplateFactory);
|
|
addAll(styleExpr.declarations, targetDeclarations);
|
|
addAll(changeDetectorsExprs.declarations, targetDeclarations);
|
|
addAll(commandsExpr.declarations, targetDeclarations);
|
|
targetTemplateArguments.push([changeDetectorsExprs.expressions[0], commandsExpr.expression, styleExpr.expression]);
|
|
};
|
|
TemplateCompiler = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [runtime_metadata_1.RuntimeMetadataResolver, template_normalizer_1.TemplateNormalizer, template_parser_1.TemplateParser, style_compiler_1.StyleCompiler, command_compiler_1.CommandCompiler, change_detector_compiler_1.ChangeDetectionCompiler])], TemplateCompiler);
|
|
return TemplateCompiler;
|
|
})();
|
|
exports.TemplateCompiler = TemplateCompiler;
|
|
var NormalizedComponentWithViewDirectives = (function() {
|
|
function NormalizedComponentWithViewDirectives(component, directives) {
|
|
this.component = component;
|
|
this.directives = directives;
|
|
}
|
|
return NormalizedComponentWithViewDirectives;
|
|
})();
|
|
exports.NormalizedComponentWithViewDirectives = NormalizedComponentWithViewDirectives;
|
|
function assertComponent(meta) {
|
|
if (!meta.isComponent) {
|
|
throw new exceptions_1.BaseException("Could not compile '" + meta.type.name + "' because it is not a component.");
|
|
}
|
|
}
|
|
function templateVariableName(type) {
|
|
return type.name + "Template";
|
|
}
|
|
function templateGetterName(type) {
|
|
return templateVariableName(type) + "Getter";
|
|
}
|
|
function templateModuleUrl(moduleUrl) {
|
|
var urlWithoutSuffix = moduleUrl.substring(0, moduleUrl.length - util_1.MODULE_SUFFIX.length);
|
|
return urlWithoutSuffix + ".template" + util_1.MODULE_SUFFIX;
|
|
}
|
|
function addAll(source, target) {
|
|
for (var i = 0; i < source.length; i++) {
|
|
target.push(source[i]);
|
|
}
|
|
}
|
|
function codeGenComponentTemplateFactory(nestedCompType) {
|
|
return "" + source_module_1.moduleRef(templateModuleUrl(nestedCompType.type.moduleUrl)) + templateGetterName(nestedCompType.type);
|
|
}
|
|
function removeDuplicates(items) {
|
|
var res = [];
|
|
items.forEach(function(item) {
|
|
var hasMatch = res.filter(function(r) {
|
|
return r.type.name == item.type.name && r.type.moduleUrl == item.type.moduleUrl && r.type.runtime == item.type.runtime;
|
|
}).length > 0;
|
|
if (!hasMatch) {
|
|
res.push(item);
|
|
}
|
|
});
|
|
return res;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6a", ["37", "20", "14", "3c", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "6d", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var lang_2 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var change_detection_1 = $__require('6e');
|
|
var html_parser_1 = $__require('6f');
|
|
var html_tags_1 = $__require('70');
|
|
var parse_util_1 = $__require('71');
|
|
var template_ast_1 = $__require('72');
|
|
var selector_1 = $__require('73');
|
|
var element_schema_registry_1 = $__require('74');
|
|
var template_preparser_1 = $__require('75');
|
|
var style_url_resolver_1 = $__require('76');
|
|
var html_ast_1 = $__require('77');
|
|
var util_1 = $__require('6d');
|
|
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
|
|
var TEMPLATE_ELEMENT = 'template';
|
|
var TEMPLATE_ATTR = 'template';
|
|
var TEMPLATE_ATTR_PREFIX = '*';
|
|
var CLASS_ATTR = 'class';
|
|
var PROPERTY_PARTS_SEPARATOR = '.';
|
|
var ATTRIBUTE_PREFIX = 'attr';
|
|
var CLASS_PREFIX = 'class';
|
|
var STYLE_PREFIX = 'style';
|
|
var TEXT_CSS_SELECTOR = selector_1.CssSelector.parse('*')[0];
|
|
exports.TEMPLATE_TRANSFORMS = lang_2.CONST_EXPR(new core_1.OpaqueToken('TemplateTransforms'));
|
|
var TemplateParseError = (function(_super) {
|
|
__extends(TemplateParseError, _super);
|
|
function TemplateParseError(message, location) {
|
|
_super.call(this, location, message);
|
|
}
|
|
return TemplateParseError;
|
|
})(parse_util_1.ParseError);
|
|
exports.TemplateParseError = TemplateParseError;
|
|
var TemplateParser = (function() {
|
|
function TemplateParser(_exprParser, _schemaRegistry, _htmlParser, transforms) {
|
|
this._exprParser = _exprParser;
|
|
this._schemaRegistry = _schemaRegistry;
|
|
this._htmlParser = _htmlParser;
|
|
this.transforms = transforms;
|
|
}
|
|
TemplateParser.prototype.parse = function(template, directives, templateUrl) {
|
|
var parseVisitor = new TemplateParseVisitor(directives, this._exprParser, this._schemaRegistry);
|
|
var htmlAstWithErrors = this._htmlParser.parse(template, templateUrl);
|
|
var result = html_ast_1.htmlVisitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_COMPONENT);
|
|
var errors = htmlAstWithErrors.errors.concat(parseVisitor.errors);
|
|
if (errors.length > 0) {
|
|
var errorString = errors.join('\n');
|
|
throw new exceptions_1.BaseException("Template parse errors:\n" + errorString);
|
|
}
|
|
if (lang_1.isPresent(this.transforms)) {
|
|
this.transforms.forEach(function(transform) {
|
|
result = template_ast_1.templateVisitAll(transform, result);
|
|
});
|
|
}
|
|
return result;
|
|
};
|
|
TemplateParser = __decorate([core_1.Injectable(), __param(3, core_1.Optional()), __param(3, core_1.Inject(exports.TEMPLATE_TRANSFORMS)), __metadata('design:paramtypes', [change_detection_1.Parser, element_schema_registry_1.ElementSchemaRegistry, html_parser_1.HtmlParser, Array])], TemplateParser);
|
|
return TemplateParser;
|
|
})();
|
|
exports.TemplateParser = TemplateParser;
|
|
var TemplateParseVisitor = (function() {
|
|
function TemplateParseVisitor(directives, _exprParser, _schemaRegistry) {
|
|
var _this = this;
|
|
this._exprParser = _exprParser;
|
|
this._schemaRegistry = _schemaRegistry;
|
|
this.errors = [];
|
|
this.directivesIndex = new Map();
|
|
this.ngContentCount = 0;
|
|
this.selectorMatcher = new selector_1.SelectorMatcher();
|
|
collection_1.ListWrapper.forEachWithIndex(directives, function(directive, index) {
|
|
var selector = selector_1.CssSelector.parse(directive.selector);
|
|
_this.selectorMatcher.addSelectables(selector, directive);
|
|
_this.directivesIndex.set(directive, index);
|
|
});
|
|
}
|
|
TemplateParseVisitor.prototype._reportError = function(message, sourceSpan) {
|
|
this.errors.push(new TemplateParseError(message, sourceSpan.start));
|
|
};
|
|
TemplateParseVisitor.prototype._parseInterpolation = function(value, sourceSpan) {
|
|
var sourceInfo = sourceSpan.start.toString();
|
|
try {
|
|
return this._exprParser.parseInterpolation(value, sourceInfo);
|
|
} catch (e) {
|
|
this._reportError("" + e, sourceSpan);
|
|
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._parseAction = function(value, sourceSpan) {
|
|
var sourceInfo = sourceSpan.start.toString();
|
|
try {
|
|
return this._exprParser.parseAction(value, sourceInfo);
|
|
} catch (e) {
|
|
this._reportError("" + e, sourceSpan);
|
|
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._parseBinding = function(value, sourceSpan) {
|
|
var sourceInfo = sourceSpan.start.toString();
|
|
try {
|
|
return this._exprParser.parseBinding(value, sourceInfo);
|
|
} catch (e) {
|
|
this._reportError("" + e, sourceSpan);
|
|
return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._parseTemplateBindings = function(value, sourceSpan) {
|
|
var sourceInfo = sourceSpan.start.toString();
|
|
try {
|
|
return this._exprParser.parseTemplateBindings(value, sourceInfo);
|
|
} catch (e) {
|
|
this._reportError("" + e, sourceSpan);
|
|
return [];
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype.visitText = function(ast, component) {
|
|
var ngContentIndex = component.findNgContentIndex(TEXT_CSS_SELECTOR);
|
|
var expr = this._parseInterpolation(ast.value, ast.sourceSpan);
|
|
if (lang_1.isPresent(expr)) {
|
|
return new template_ast_1.BoundTextAst(expr, ngContentIndex, ast.sourceSpan);
|
|
} else {
|
|
return new template_ast_1.TextAst(ast.value, ngContentIndex, ast.sourceSpan);
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype.visitAttr = function(ast, contex) {
|
|
return new template_ast_1.AttrAst(ast.name, ast.value, ast.sourceSpan);
|
|
};
|
|
TemplateParseVisitor.prototype.visitElement = function(element, component) {
|
|
var _this = this;
|
|
var nodeName = element.name;
|
|
var preparsedElement = template_preparser_1.preparseElement(element);
|
|
if (preparsedElement.type === template_preparser_1.PreparsedElementType.SCRIPT || preparsedElement.type === template_preparser_1.PreparsedElementType.STYLE) {
|
|
return null;
|
|
}
|
|
if (preparsedElement.type === template_preparser_1.PreparsedElementType.STYLESHEET && style_url_resolver_1.isStyleUrlResolvable(preparsedElement.hrefAttr)) {
|
|
return null;
|
|
}
|
|
var matchableAttrs = [];
|
|
var elementOrDirectiveProps = [];
|
|
var vars = [];
|
|
var events = [];
|
|
var templateElementOrDirectiveProps = [];
|
|
var templateVars = [];
|
|
var templateMatchableAttrs = [];
|
|
var hasInlineTemplates = false;
|
|
var attrs = [];
|
|
element.attrs.forEach(function(attr) {
|
|
matchableAttrs.push([attr.name, attr.value]);
|
|
var hasBinding = _this._parseAttr(attr, matchableAttrs, elementOrDirectiveProps, events, vars);
|
|
var hasTemplateBinding = _this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateVars);
|
|
if (!hasBinding && !hasTemplateBinding) {
|
|
attrs.push(_this.visitAttr(attr, null));
|
|
}
|
|
if (hasTemplateBinding) {
|
|
hasInlineTemplates = true;
|
|
}
|
|
});
|
|
var lcElName = html_tags_1.splitNsName(nodeName.toLowerCase())[1];
|
|
var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
|
|
var elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
|
|
var directives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, elementCssSelector), elementOrDirectiveProps, isTemplateElement ? [] : vars, element.sourceSpan);
|
|
var elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, directives);
|
|
var children = html_ast_1.htmlVisitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, Component.create(directives));
|
|
var elementNgContentIndex = hasInlineTemplates ? null : component.findNgContentIndex(elementCssSelector);
|
|
var parsedElement;
|
|
if (preparsedElement.type === template_preparser_1.PreparsedElementType.NG_CONTENT) {
|
|
if (lang_1.isPresent(element.children) && element.children.length > 0) {
|
|
this._reportError("<ng-content> element cannot have content. <ng-content> must be immediately followed by </ng-content>", element.sourceSpan);
|
|
}
|
|
parsedElement = new template_ast_1.NgContentAst(this.ngContentCount++, elementNgContentIndex, element.sourceSpan);
|
|
} else if (isTemplateElement) {
|
|
this._assertAllEventsPublishedByDirectives(directives, events);
|
|
this._assertNoComponentsNorElementBindingsOnTemplate(directives, elementProps, element.sourceSpan);
|
|
parsedElement = new template_ast_1.EmbeddedTemplateAst(attrs, events, vars, directives, children, elementNgContentIndex, element.sourceSpan);
|
|
} else {
|
|
this._assertOnlyOneComponent(directives, element.sourceSpan);
|
|
var elementExportAsVars = vars.filter(function(varAst) {
|
|
return varAst.value.length === 0;
|
|
});
|
|
parsedElement = new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, directives, children, elementNgContentIndex, element.sourceSpan);
|
|
}
|
|
if (hasInlineTemplates) {
|
|
var templateCssSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
|
|
var templateDirectives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, templateCssSelector), templateElementOrDirectiveProps, [], element.sourceSpan);
|
|
var templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateDirectives);
|
|
this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectives, templateElementProps, element.sourceSpan);
|
|
parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], templateVars, templateDirectives, [parsedElement], component.findNgContentIndex(templateCssSelector), element.sourceSpan);
|
|
}
|
|
return parsedElement;
|
|
};
|
|
TemplateParseVisitor.prototype._parseInlineTemplateBinding = function(attr, targetMatchableAttrs, targetProps, targetVars) {
|
|
var templateBindingsSource = null;
|
|
if (attr.name == TEMPLATE_ATTR) {
|
|
templateBindingsSource = attr.value;
|
|
} else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) {
|
|
var key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length);
|
|
templateBindingsSource = (attr.value.length == 0) ? key : key + ' ' + attr.value;
|
|
}
|
|
if (lang_1.isPresent(templateBindingsSource)) {
|
|
var bindings = this._parseTemplateBindings(templateBindingsSource, attr.sourceSpan);
|
|
for (var i = 0; i < bindings.length; i++) {
|
|
var binding = bindings[i];
|
|
if (binding.keyIsVar) {
|
|
targetVars.push(new template_ast_1.VariableAst(binding.key, binding.name, attr.sourceSpan));
|
|
targetMatchableAttrs.push([binding.key, binding.name]);
|
|
} else if (lang_1.isPresent(binding.expression)) {
|
|
this._parsePropertyAst(binding.key, binding.expression, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
} else {
|
|
targetMatchableAttrs.push([binding.key, '']);
|
|
this._parseLiteralAttr(binding.key, null, attr.sourceSpan, targetProps);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
TemplateParseVisitor.prototype._parseAttr = function(attr, targetMatchableAttrs, targetProps, targetEvents, targetVars) {
|
|
var attrName = this._normalizeAttributeName(attr.name);
|
|
var attrValue = attr.value;
|
|
var bindParts = lang_1.RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
|
|
var hasBinding = false;
|
|
if (lang_1.isPresent(bindParts)) {
|
|
hasBinding = true;
|
|
if (lang_1.isPresent(bindParts[1])) {
|
|
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
} else if (lang_1.isPresent(bindParts[2])) {
|
|
var identifier = bindParts[5];
|
|
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
|
|
} else if (lang_1.isPresent(bindParts[3])) {
|
|
this._parseEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
|
|
} else if (lang_1.isPresent(bindParts[4])) {
|
|
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
this._parseAssignmentEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
|
|
} else if (lang_1.isPresent(bindParts[6])) {
|
|
this._parseProperty(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
this._parseAssignmentEvent(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
|
|
} else if (lang_1.isPresent(bindParts[7])) {
|
|
this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
} else if (lang_1.isPresent(bindParts[8])) {
|
|
this._parseEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
|
|
}
|
|
} else {
|
|
hasBinding = this._parsePropertyInterpolation(attrName, attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
|
|
}
|
|
if (!hasBinding) {
|
|
this._parseLiteralAttr(attrName, attrValue, attr.sourceSpan, targetProps);
|
|
}
|
|
return hasBinding;
|
|
};
|
|
TemplateParseVisitor.prototype._normalizeAttributeName = function(attrName) {
|
|
return attrName.toLowerCase().startsWith('data-') ? attrName.substring(5) : attrName;
|
|
};
|
|
TemplateParseVisitor.prototype._parseVariable = function(identifier, value, sourceSpan, targetVars) {
|
|
if (identifier.indexOf('-') > -1) {
|
|
this._reportError("\"-\" is not allowed in variable names", sourceSpan);
|
|
}
|
|
targetVars.push(new template_ast_1.VariableAst(identifier, value, sourceSpan));
|
|
};
|
|
TemplateParseVisitor.prototype._parseProperty = function(name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
|
|
this._parsePropertyAst(name, this._parseBinding(expression, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
|
|
};
|
|
TemplateParseVisitor.prototype._parsePropertyInterpolation = function(name, value, sourceSpan, targetMatchableAttrs, targetProps) {
|
|
var expr = this._parseInterpolation(value, sourceSpan);
|
|
if (lang_1.isPresent(expr)) {
|
|
this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
TemplateParseVisitor.prototype._parsePropertyAst = function(name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
|
|
targetMatchableAttrs.push([name, ast.source]);
|
|
targetProps.push(new BoundElementOrDirectiveProperty(name, ast, false, sourceSpan));
|
|
};
|
|
TemplateParseVisitor.prototype._parseAssignmentEvent = function(name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
|
|
this._parseEvent(name + "Change", expression + "=$event", sourceSpan, targetMatchableAttrs, targetEvents);
|
|
};
|
|
TemplateParseVisitor.prototype._parseEvent = function(name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
|
|
var parts = util_1.splitAtColon(name, [null, name]);
|
|
var target = parts[0];
|
|
var eventName = parts[1];
|
|
targetEvents.push(new template_ast_1.BoundEventAst(eventName, target, this._parseAction(expression, sourceSpan), sourceSpan));
|
|
};
|
|
TemplateParseVisitor.prototype._parseLiteralAttr = function(name, value, sourceSpan, targetProps) {
|
|
targetProps.push(new BoundElementOrDirectiveProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), true, sourceSpan));
|
|
};
|
|
TemplateParseVisitor.prototype._parseDirectives = function(selectorMatcher, elementCssSelector) {
|
|
var _this = this;
|
|
var directives = [];
|
|
selectorMatcher.match(elementCssSelector, function(selector, directive) {
|
|
directives.push(directive);
|
|
});
|
|
collection_1.ListWrapper.sort(directives, function(dir1, dir2) {
|
|
var dir1Comp = dir1.isComponent;
|
|
var dir2Comp = dir2.isComponent;
|
|
if (dir1Comp && !dir2Comp) {
|
|
return -1;
|
|
} else if (!dir1Comp && dir2Comp) {
|
|
return 1;
|
|
} else {
|
|
return _this.directivesIndex.get(dir1) - _this.directivesIndex.get(dir2);
|
|
}
|
|
});
|
|
return directives;
|
|
};
|
|
TemplateParseVisitor.prototype._createDirectiveAsts = function(elementName, directives, props, possibleExportAsVars, sourceSpan) {
|
|
var _this = this;
|
|
var matchedVariables = new Set();
|
|
var directiveAsts = directives.map(function(directive) {
|
|
var hostProperties = [];
|
|
var hostEvents = [];
|
|
var directiveProperties = [];
|
|
_this._createDirectiveHostPropertyAsts(elementName, directive.hostProperties, sourceSpan, hostProperties);
|
|
_this._createDirectiveHostEventAsts(directive.hostListeners, sourceSpan, hostEvents);
|
|
_this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties);
|
|
var exportAsVars = [];
|
|
possibleExportAsVars.forEach(function(varAst) {
|
|
if ((varAst.value.length === 0 && directive.isComponent) || (directive.exportAs == varAst.value)) {
|
|
exportAsVars.push(varAst);
|
|
matchedVariables.add(varAst.name);
|
|
}
|
|
});
|
|
return new template_ast_1.DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, exportAsVars, sourceSpan);
|
|
});
|
|
possibleExportAsVars.forEach(function(varAst) {
|
|
if (varAst.value.length > 0 && !collection_1.SetWrapper.has(matchedVariables, varAst.name)) {
|
|
_this._reportError("There is no directive with \"exportAs\" set to \"" + varAst.value + "\"", varAst.sourceSpan);
|
|
}
|
|
});
|
|
return directiveAsts;
|
|
};
|
|
TemplateParseVisitor.prototype._createDirectiveHostPropertyAsts = function(elementName, hostProps, sourceSpan, targetPropertyAsts) {
|
|
var _this = this;
|
|
if (lang_1.isPresent(hostProps)) {
|
|
collection_1.StringMapWrapper.forEach(hostProps, function(expression, propName) {
|
|
var exprAst = _this._parseBinding(expression, sourceSpan);
|
|
targetPropertyAsts.push(_this._createElementPropertyAst(elementName, propName, exprAst, sourceSpan));
|
|
});
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._createDirectiveHostEventAsts = function(hostListeners, sourceSpan, targetEventAsts) {
|
|
var _this = this;
|
|
if (lang_1.isPresent(hostListeners)) {
|
|
collection_1.StringMapWrapper.forEach(hostListeners, function(expression, propName) {
|
|
_this._parseEvent(propName, expression, sourceSpan, [], targetEventAsts);
|
|
});
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._createDirectivePropertyAsts = function(directiveProperties, boundProps, targetBoundDirectiveProps) {
|
|
if (lang_1.isPresent(directiveProperties)) {
|
|
var boundPropsByName = new Map();
|
|
boundProps.forEach(function(boundProp) {
|
|
var prevValue = boundPropsByName.get(boundProp.name);
|
|
if (lang_1.isBlank(prevValue) || prevValue.isLiteral) {
|
|
boundPropsByName.set(boundProp.name, boundProp);
|
|
}
|
|
});
|
|
collection_1.StringMapWrapper.forEach(directiveProperties, function(elProp, dirProp) {
|
|
var boundProp = boundPropsByName.get(elProp);
|
|
if (lang_1.isPresent(boundProp)) {
|
|
targetBoundDirectiveProps.push(new template_ast_1.BoundDirectivePropertyAst(dirProp, boundProp.name, boundProp.expression, boundProp.sourceSpan));
|
|
}
|
|
});
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._createElementPropertyAsts = function(elementName, props, directives) {
|
|
var _this = this;
|
|
var boundElementProps = [];
|
|
var boundDirectivePropsIndex = new Map();
|
|
directives.forEach(function(directive) {
|
|
directive.inputs.forEach(function(prop) {
|
|
boundDirectivePropsIndex.set(prop.templateName, prop);
|
|
});
|
|
});
|
|
props.forEach(function(prop) {
|
|
if (!prop.isLiteral && lang_1.isBlank(boundDirectivePropsIndex.get(prop.name))) {
|
|
boundElementProps.push(_this._createElementPropertyAst(elementName, prop.name, prop.expression, prop.sourceSpan));
|
|
}
|
|
});
|
|
return boundElementProps;
|
|
};
|
|
TemplateParseVisitor.prototype._createElementPropertyAst = function(elementName, name, ast, sourceSpan) {
|
|
var unit = null;
|
|
var bindingType;
|
|
var boundPropertyName;
|
|
var parts = name.split(PROPERTY_PARTS_SEPARATOR);
|
|
if (parts.length === 1) {
|
|
boundPropertyName = this._schemaRegistry.getMappedPropName(parts[0]);
|
|
bindingType = template_ast_1.PropertyBindingType.Property;
|
|
if (!this._schemaRegistry.hasProperty(elementName, boundPropertyName)) {
|
|
this._reportError("Can't bind to '" + boundPropertyName + "' since it isn't a known native property", sourceSpan);
|
|
}
|
|
} else {
|
|
if (parts[0] == ATTRIBUTE_PREFIX) {
|
|
boundPropertyName = parts[1];
|
|
bindingType = template_ast_1.PropertyBindingType.Attribute;
|
|
} else if (parts[0] == CLASS_PREFIX) {
|
|
boundPropertyName = parts[1];
|
|
bindingType = template_ast_1.PropertyBindingType.Class;
|
|
} else if (parts[0] == STYLE_PREFIX) {
|
|
unit = parts.length > 2 ? parts[2] : null;
|
|
boundPropertyName = parts[1];
|
|
bindingType = template_ast_1.PropertyBindingType.Style;
|
|
} else {
|
|
this._reportError("Invalid property name '" + name + "'", sourceSpan);
|
|
bindingType = null;
|
|
}
|
|
}
|
|
return new template_ast_1.BoundElementPropertyAst(boundPropertyName, bindingType, ast, unit, sourceSpan);
|
|
};
|
|
TemplateParseVisitor.prototype._findComponentDirectiveNames = function(directives) {
|
|
var componentTypeNames = [];
|
|
directives.forEach(function(directive) {
|
|
var typeName = directive.directive.type.name;
|
|
if (directive.directive.isComponent) {
|
|
componentTypeNames.push(typeName);
|
|
}
|
|
});
|
|
return componentTypeNames;
|
|
};
|
|
TemplateParseVisitor.prototype._assertOnlyOneComponent = function(directives, sourceSpan) {
|
|
var componentTypeNames = this._findComponentDirectiveNames(directives);
|
|
if (componentTypeNames.length > 1) {
|
|
this._reportError("More than one component: " + componentTypeNames.join(','), sourceSpan);
|
|
}
|
|
};
|
|
TemplateParseVisitor.prototype._assertNoComponentsNorElementBindingsOnTemplate = function(directives, elementProps, sourceSpan) {
|
|
var _this = this;
|
|
var componentTypeNames = this._findComponentDirectiveNames(directives);
|
|
if (componentTypeNames.length > 0) {
|
|
this._reportError("Components on an embedded template: " + componentTypeNames.join(','), sourceSpan);
|
|
}
|
|
elementProps.forEach(function(prop) {
|
|
_this._reportError("Property binding " + prop.name + " not used by any directive on an embedded template", sourceSpan);
|
|
});
|
|
};
|
|
TemplateParseVisitor.prototype._assertAllEventsPublishedByDirectives = function(directives, events) {
|
|
var _this = this;
|
|
var allDirectiveEvents = new Set();
|
|
directives.forEach(function(directive) {
|
|
collection_1.StringMapWrapper.forEach(directive.directive.outputs, function(eventName, _) {
|
|
allDirectiveEvents.add(eventName);
|
|
});
|
|
});
|
|
events.forEach(function(event) {
|
|
if (lang_1.isPresent(event.target) || !collection_1.SetWrapper.has(allDirectiveEvents, event.name)) {
|
|
_this._reportError("Event binding " + event.fullName + " not emitted by any directive on an embedded template", event.sourceSpan);
|
|
}
|
|
});
|
|
};
|
|
return TemplateParseVisitor;
|
|
})();
|
|
var NonBindableVisitor = (function() {
|
|
function NonBindableVisitor() {}
|
|
NonBindableVisitor.prototype.visitElement = function(ast, component) {
|
|
var preparsedElement = template_preparser_1.preparseElement(ast);
|
|
if (preparsedElement.type === template_preparser_1.PreparsedElementType.SCRIPT || preparsedElement.type === template_preparser_1.PreparsedElementType.STYLE || preparsedElement.type === template_preparser_1.PreparsedElementType.STYLESHEET) {
|
|
return null;
|
|
}
|
|
var attrNameAndValues = ast.attrs.map(function(attrAst) {
|
|
return [attrAst.name, attrAst.value];
|
|
});
|
|
var selector = createElementCssSelector(ast.name, attrNameAndValues);
|
|
var ngContentIndex = component.findNgContentIndex(selector);
|
|
var children = html_ast_1.htmlVisitAll(this, ast.children, EMPTY_COMPONENT);
|
|
return new template_ast_1.ElementAst(ast.name, html_ast_1.htmlVisitAll(this, ast.attrs), [], [], [], [], children, ngContentIndex, ast.sourceSpan);
|
|
};
|
|
NonBindableVisitor.prototype.visitAttr = function(ast, context) {
|
|
return new template_ast_1.AttrAst(ast.name, ast.value, ast.sourceSpan);
|
|
};
|
|
NonBindableVisitor.prototype.visitText = function(ast, component) {
|
|
var ngContentIndex = component.findNgContentIndex(TEXT_CSS_SELECTOR);
|
|
return new template_ast_1.TextAst(ast.value, ngContentIndex, ast.sourceSpan);
|
|
};
|
|
return NonBindableVisitor;
|
|
})();
|
|
var BoundElementOrDirectiveProperty = (function() {
|
|
function BoundElementOrDirectiveProperty(name, expression, isLiteral, sourceSpan) {
|
|
this.name = name;
|
|
this.expression = expression;
|
|
this.isLiteral = isLiteral;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
return BoundElementOrDirectiveProperty;
|
|
})();
|
|
function splitClasses(classAttrValue) {
|
|
return lang_1.StringWrapper.split(classAttrValue.trim(), /\s+/g);
|
|
}
|
|
exports.splitClasses = splitClasses;
|
|
var Component = (function() {
|
|
function Component(ngContentIndexMatcher, wildcardNgContentIndex) {
|
|
this.ngContentIndexMatcher = ngContentIndexMatcher;
|
|
this.wildcardNgContentIndex = wildcardNgContentIndex;
|
|
}
|
|
Component.create = function(directives) {
|
|
if (directives.length === 0 || !directives[0].directive.isComponent) {
|
|
return EMPTY_COMPONENT;
|
|
}
|
|
var matcher = new selector_1.SelectorMatcher();
|
|
var ngContentSelectors = directives[0].directive.template.ngContentSelectors;
|
|
var wildcardNgContentIndex = null;
|
|
for (var i = 0; i < ngContentSelectors.length; i++) {
|
|
var selector = ngContentSelectors[i];
|
|
if (lang_1.StringWrapper.equals(selector, '*')) {
|
|
wildcardNgContentIndex = i;
|
|
} else {
|
|
matcher.addSelectables(selector_1.CssSelector.parse(ngContentSelectors[i]), i);
|
|
}
|
|
}
|
|
return new Component(matcher, wildcardNgContentIndex);
|
|
};
|
|
Component.prototype.findNgContentIndex = function(selector) {
|
|
var ngContentIndices = [];
|
|
this.ngContentIndexMatcher.match(selector, function(selector, ngContentIndex) {
|
|
ngContentIndices.push(ngContentIndex);
|
|
});
|
|
collection_1.ListWrapper.sort(ngContentIndices);
|
|
if (lang_1.isPresent(this.wildcardNgContentIndex)) {
|
|
ngContentIndices.push(this.wildcardNgContentIndex);
|
|
}
|
|
return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
|
|
};
|
|
return Component;
|
|
})();
|
|
function createElementCssSelector(elementName, matchableAttrs) {
|
|
var cssSelector = new selector_1.CssSelector();
|
|
var elNameNoNs = html_tags_1.splitNsName(elementName)[1];
|
|
cssSelector.setElement(elNameNoNs);
|
|
for (var i = 0; i < matchableAttrs.length; i++) {
|
|
var attrName = matchableAttrs[i][0];
|
|
var attrNameNoNs = html_tags_1.splitNsName(attrName)[1];
|
|
var attrValue = matchableAttrs[i][1];
|
|
cssSelector.addAttribute(attrNameNoNs, attrValue);
|
|
if (attrName.toLowerCase() == CLASS_ATTR) {
|
|
var classes = splitClasses(attrValue);
|
|
classes.forEach(function(className) {
|
|
return cssSelector.addClassName(className);
|
|
});
|
|
}
|
|
}
|
|
return cssSelector;
|
|
}
|
|
var EMPTY_COMPONENT = new Component(new selector_1.SelectorMatcher(), null);
|
|
var NON_BINDABLE_VISITOR = new NonBindableVisitor();
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("77", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var HtmlTextAst = (function() {
|
|
function HtmlTextAst(value, sourceSpan) {
|
|
this.value = value;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
HtmlTextAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitText(this, context);
|
|
};
|
|
return HtmlTextAst;
|
|
})();
|
|
exports.HtmlTextAst = HtmlTextAst;
|
|
var HtmlAttrAst = (function() {
|
|
function HtmlAttrAst(name, value, sourceSpan) {
|
|
this.name = name;
|
|
this.value = value;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
HtmlAttrAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitAttr(this, context);
|
|
};
|
|
return HtmlAttrAst;
|
|
})();
|
|
exports.HtmlAttrAst = HtmlAttrAst;
|
|
var HtmlElementAst = (function() {
|
|
function HtmlElementAst(name, attrs, children, sourceSpan) {
|
|
this.name = name;
|
|
this.attrs = attrs;
|
|
this.children = children;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
HtmlElementAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitElement(this, context);
|
|
};
|
|
return HtmlElementAst;
|
|
})();
|
|
exports.HtmlElementAst = HtmlElementAst;
|
|
function htmlVisitAll(visitor, asts, context) {
|
|
if (context === void 0) {
|
|
context = null;
|
|
}
|
|
var result = [];
|
|
asts.forEach(function(ast) {
|
|
var astResult = ast.visit(visitor, context);
|
|
if (lang_1.isPresent(astResult)) {
|
|
result.push(astResult);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
exports.htmlVisitAll = htmlVisitAll;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("78", ["20", "37", "71", "70", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var parse_util_1 = $__require('71');
|
|
var html_tags_1 = $__require('70');
|
|
(function(HtmlTokenType) {
|
|
HtmlTokenType[HtmlTokenType["TAG_OPEN_START"] = 0] = "TAG_OPEN_START";
|
|
HtmlTokenType[HtmlTokenType["TAG_OPEN_END"] = 1] = "TAG_OPEN_END";
|
|
HtmlTokenType[HtmlTokenType["TAG_OPEN_END_VOID"] = 2] = "TAG_OPEN_END_VOID";
|
|
HtmlTokenType[HtmlTokenType["TAG_CLOSE"] = 3] = "TAG_CLOSE";
|
|
HtmlTokenType[HtmlTokenType["TEXT"] = 4] = "TEXT";
|
|
HtmlTokenType[HtmlTokenType["ESCAPABLE_RAW_TEXT"] = 5] = "ESCAPABLE_RAW_TEXT";
|
|
HtmlTokenType[HtmlTokenType["RAW_TEXT"] = 6] = "RAW_TEXT";
|
|
HtmlTokenType[HtmlTokenType["COMMENT_START"] = 7] = "COMMENT_START";
|
|
HtmlTokenType[HtmlTokenType["COMMENT_END"] = 8] = "COMMENT_END";
|
|
HtmlTokenType[HtmlTokenType["CDATA_START"] = 9] = "CDATA_START";
|
|
HtmlTokenType[HtmlTokenType["CDATA_END"] = 10] = "CDATA_END";
|
|
HtmlTokenType[HtmlTokenType["ATTR_NAME"] = 11] = "ATTR_NAME";
|
|
HtmlTokenType[HtmlTokenType["ATTR_VALUE"] = 12] = "ATTR_VALUE";
|
|
HtmlTokenType[HtmlTokenType["DOC_TYPE"] = 13] = "DOC_TYPE";
|
|
HtmlTokenType[HtmlTokenType["EOF"] = 14] = "EOF";
|
|
})(exports.HtmlTokenType || (exports.HtmlTokenType = {}));
|
|
var HtmlTokenType = exports.HtmlTokenType;
|
|
var HtmlToken = (function() {
|
|
function HtmlToken(type, parts, sourceSpan) {
|
|
this.type = type;
|
|
this.parts = parts;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
return HtmlToken;
|
|
})();
|
|
exports.HtmlToken = HtmlToken;
|
|
var HtmlTokenError = (function(_super) {
|
|
__extends(HtmlTokenError, _super);
|
|
function HtmlTokenError(errorMsg, tokenType, location) {
|
|
_super.call(this, location, errorMsg);
|
|
this.tokenType = tokenType;
|
|
}
|
|
return HtmlTokenError;
|
|
})(parse_util_1.ParseError);
|
|
exports.HtmlTokenError = HtmlTokenError;
|
|
var HtmlTokenizeResult = (function() {
|
|
function HtmlTokenizeResult(tokens, errors) {
|
|
this.tokens = tokens;
|
|
this.errors = errors;
|
|
}
|
|
return HtmlTokenizeResult;
|
|
})();
|
|
exports.HtmlTokenizeResult = HtmlTokenizeResult;
|
|
function tokenizeHtml(sourceContent, sourceUrl) {
|
|
return new _HtmlTokenizer(new parse_util_1.ParseSourceFile(sourceContent, sourceUrl)).tokenize();
|
|
}
|
|
exports.tokenizeHtml = tokenizeHtml;
|
|
var $EOF = 0;
|
|
var $TAB = 9;
|
|
var $LF = 10;
|
|
var $FF = 12;
|
|
var $CR = 13;
|
|
var $SPACE = 32;
|
|
var $BANG = 33;
|
|
var $DQ = 34;
|
|
var $HASH = 35;
|
|
var $$ = 36;
|
|
var $AMPERSAND = 38;
|
|
var $SQ = 39;
|
|
var $MINUS = 45;
|
|
var $SLASH = 47;
|
|
var $0 = 48;
|
|
var $SEMICOLON = 59;
|
|
var $9 = 57;
|
|
var $COLON = 58;
|
|
var $LT = 60;
|
|
var $EQ = 61;
|
|
var $GT = 62;
|
|
var $QUESTION = 63;
|
|
var $A = 65;
|
|
var $Z = 90;
|
|
var $LBRACKET = 91;
|
|
var $RBRACKET = 93;
|
|
var $a = 97;
|
|
var $f = 102;
|
|
var $z = 122;
|
|
var $x = 120;
|
|
var $NBSP = 160;
|
|
var CR_OR_CRLF_REGEXP = /\r\n?/g;
|
|
function unexpectedCharacterErrorMsg(charCode) {
|
|
var char = charCode === $EOF ? 'EOF' : lang_1.StringWrapper.fromCharCode(charCode);
|
|
return "Unexpected character \"" + char + "\"";
|
|
}
|
|
function unknownEntityErrorMsg(entitySrc) {
|
|
return "Unknown entity \"" + entitySrc + "\" - use the \"&#<decimal>;\" or \"&#x<hex>;\" syntax";
|
|
}
|
|
var ControlFlowError = (function() {
|
|
function ControlFlowError(error) {
|
|
this.error = error;
|
|
}
|
|
return ControlFlowError;
|
|
})();
|
|
var _HtmlTokenizer = (function() {
|
|
function _HtmlTokenizer(file) {
|
|
this.file = file;
|
|
this.peek = -1;
|
|
this.index = -1;
|
|
this.line = 0;
|
|
this.column = -1;
|
|
this.tokens = [];
|
|
this.errors = [];
|
|
this.input = file.content;
|
|
this.inputLowercase = file.content.toLowerCase();
|
|
this.length = file.content.length;
|
|
this._advance();
|
|
}
|
|
_HtmlTokenizer.prototype._processCarriageReturns = function(content) {
|
|
return lang_1.StringWrapper.replaceAll(content, CR_OR_CRLF_REGEXP, '\n');
|
|
};
|
|
_HtmlTokenizer.prototype.tokenize = function() {
|
|
while (this.peek !== $EOF) {
|
|
var start = this._getLocation();
|
|
try {
|
|
if (this._attemptChar($LT)) {
|
|
if (this._attemptChar($BANG)) {
|
|
if (this._attemptChar($LBRACKET)) {
|
|
this._consumeCdata(start);
|
|
} else if (this._attemptChar($MINUS)) {
|
|
this._consumeComment(start);
|
|
} else {
|
|
this._consumeDocType(start);
|
|
}
|
|
} else if (this._attemptChar($SLASH)) {
|
|
this._consumeTagClose(start);
|
|
} else {
|
|
this._consumeTagOpen(start);
|
|
}
|
|
} else {
|
|
this._consumeText();
|
|
}
|
|
} catch (e) {
|
|
if (e instanceof ControlFlowError) {
|
|
this.errors.push(e.error);
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
this._beginToken(HtmlTokenType.EOF);
|
|
this._endToken([]);
|
|
return new HtmlTokenizeResult(mergeTextTokens(this.tokens), this.errors);
|
|
};
|
|
_HtmlTokenizer.prototype._getLocation = function() {
|
|
return new parse_util_1.ParseLocation(this.file, this.index, this.line, this.column);
|
|
};
|
|
_HtmlTokenizer.prototype._beginToken = function(type, start) {
|
|
if (start === void 0) {
|
|
start = null;
|
|
}
|
|
if (lang_1.isBlank(start)) {
|
|
start = this._getLocation();
|
|
}
|
|
this.currentTokenStart = start;
|
|
this.currentTokenType = type;
|
|
};
|
|
_HtmlTokenizer.prototype._endToken = function(parts, end) {
|
|
if (end === void 0) {
|
|
end = null;
|
|
}
|
|
if (lang_1.isBlank(end)) {
|
|
end = this._getLocation();
|
|
}
|
|
var token = new HtmlToken(this.currentTokenType, parts, new parse_util_1.ParseSourceSpan(this.currentTokenStart, end));
|
|
this.tokens.push(token);
|
|
this.currentTokenStart = null;
|
|
this.currentTokenType = null;
|
|
return token;
|
|
};
|
|
_HtmlTokenizer.prototype._createError = function(msg, position) {
|
|
var error = new HtmlTokenError(msg, this.currentTokenType, position);
|
|
this.currentTokenStart = null;
|
|
this.currentTokenType = null;
|
|
return new ControlFlowError(error);
|
|
};
|
|
_HtmlTokenizer.prototype._advance = function() {
|
|
if (this.index >= this.length) {
|
|
throw this._createError(unexpectedCharacterErrorMsg($EOF), this._getLocation());
|
|
}
|
|
if (this.peek === $LF) {
|
|
this.line++;
|
|
this.column = 0;
|
|
} else if (this.peek !== $LF && this.peek !== $CR) {
|
|
this.column++;
|
|
}
|
|
this.index++;
|
|
this.peek = this.index >= this.length ? $EOF : lang_1.StringWrapper.charCodeAt(this.inputLowercase, this.index);
|
|
};
|
|
_HtmlTokenizer.prototype._attemptChar = function(charCode) {
|
|
if (this.peek === charCode) {
|
|
this._advance();
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
_HtmlTokenizer.prototype._requireChar = function(charCode) {
|
|
var location = this._getLocation();
|
|
if (!this._attemptChar(charCode)) {
|
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), location);
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._attemptChars = function(chars) {
|
|
for (var i = 0; i < chars.length; i++) {
|
|
if (!this._attemptChar(lang_1.StringWrapper.charCodeAt(chars, i))) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
_HtmlTokenizer.prototype._requireChars = function(chars) {
|
|
var location = this._getLocation();
|
|
if (!this._attemptChars(chars)) {
|
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), location);
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._attemptUntilFn = function(predicate) {
|
|
while (!predicate(this.peek)) {
|
|
this._advance();
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._requireUntilFn = function(predicate, len) {
|
|
var start = this._getLocation();
|
|
this._attemptUntilFn(predicate);
|
|
if (this.index - start.offset < len) {
|
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), start);
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._attemptUntilChar = function(char) {
|
|
while (this.peek !== char) {
|
|
this._advance();
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._readChar = function(decodeEntities) {
|
|
if (decodeEntities && this.peek === $AMPERSAND) {
|
|
return this._decodeEntity();
|
|
} else {
|
|
var index = this.index;
|
|
this._advance();
|
|
return this.input[index];
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._decodeEntity = function() {
|
|
var start = this._getLocation();
|
|
this._advance();
|
|
if (this._attemptChar($HASH)) {
|
|
var isHex = this._attemptChar($x);
|
|
var numberStart = this._getLocation().offset;
|
|
this._attemptUntilFn(isDigitEntityEnd);
|
|
if (this.peek != $SEMICOLON) {
|
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), this._getLocation());
|
|
}
|
|
this._advance();
|
|
var strNum = this.input.substring(numberStart, this.index - 1);
|
|
try {
|
|
var charCode = lang_1.NumberWrapper.parseInt(strNum, isHex ? 16 : 10);
|
|
return lang_1.StringWrapper.fromCharCode(charCode);
|
|
} catch (e) {
|
|
var entity = this.input.substring(start.offset + 1, this.index - 1);
|
|
throw this._createError(unknownEntityErrorMsg(entity), start);
|
|
}
|
|
} else {
|
|
var startPosition = this._savePosition();
|
|
this._attemptUntilFn(isNamedEntityEnd);
|
|
if (this.peek != $SEMICOLON) {
|
|
this._restorePosition(startPosition);
|
|
return '&';
|
|
}
|
|
this._advance();
|
|
var name_1 = this.input.substring(start.offset + 1, this.index - 1);
|
|
var char = html_tags_1.NAMED_ENTITIES[name_1];
|
|
if (lang_1.isBlank(char)) {
|
|
throw this._createError(unknownEntityErrorMsg(name_1), start);
|
|
}
|
|
return char;
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._consumeRawText = function(decodeEntities, firstCharOfEnd, attemptEndRest) {
|
|
var tagCloseStart;
|
|
var textStart = this._getLocation();
|
|
this._beginToken(decodeEntities ? HtmlTokenType.ESCAPABLE_RAW_TEXT : HtmlTokenType.RAW_TEXT, textStart);
|
|
var parts = [];
|
|
while (true) {
|
|
tagCloseStart = this._getLocation();
|
|
if (this._attemptChar(firstCharOfEnd) && attemptEndRest()) {
|
|
break;
|
|
}
|
|
if (this.index > tagCloseStart.offset) {
|
|
parts.push(this.input.substring(tagCloseStart.offset, this.index));
|
|
}
|
|
while (this.peek !== firstCharOfEnd) {
|
|
parts.push(this._readChar(decodeEntities));
|
|
}
|
|
}
|
|
return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeComment = function(start) {
|
|
var _this = this;
|
|
this._beginToken(HtmlTokenType.COMMENT_START, start);
|
|
this._requireChar($MINUS);
|
|
this._endToken([]);
|
|
var textToken = this._consumeRawText(false, $MINUS, function() {
|
|
return _this._attemptChars('->');
|
|
});
|
|
this._beginToken(HtmlTokenType.COMMENT_END, textToken.sourceSpan.end);
|
|
this._endToken([]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeCdata = function(start) {
|
|
var _this = this;
|
|
this._beginToken(HtmlTokenType.CDATA_START, start);
|
|
this._requireChars('cdata[');
|
|
this._endToken([]);
|
|
var textToken = this._consumeRawText(false, $RBRACKET, function() {
|
|
return _this._attemptChars(']>');
|
|
});
|
|
this._beginToken(HtmlTokenType.CDATA_END, textToken.sourceSpan.end);
|
|
this._endToken([]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeDocType = function(start) {
|
|
this._beginToken(HtmlTokenType.DOC_TYPE, start);
|
|
this._attemptUntilChar($GT);
|
|
this._advance();
|
|
this._endToken([this.input.substring(start.offset + 2, this.index - 1)]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumePrefixAndName = function() {
|
|
var nameOrPrefixStart = this.index;
|
|
var prefix = null;
|
|
while (this.peek !== $COLON && !isPrefixEnd(this.peek)) {
|
|
this._advance();
|
|
}
|
|
var nameStart;
|
|
if (this.peek === $COLON) {
|
|
this._advance();
|
|
prefix = this.input.substring(nameOrPrefixStart, this.index - 1);
|
|
nameStart = this.index;
|
|
} else {
|
|
nameStart = nameOrPrefixStart;
|
|
}
|
|
this._requireUntilFn(isNameEnd, this.index === nameStart ? 1 : 0);
|
|
var name = this.input.substring(nameStart, this.index);
|
|
return [prefix, name];
|
|
};
|
|
_HtmlTokenizer.prototype._consumeTagOpen = function(start) {
|
|
var savedPos = this._savePosition();
|
|
var lowercaseTagName;
|
|
try {
|
|
if (!isAsciiLetter(this.peek)) {
|
|
throw this._createError(unexpectedCharacterErrorMsg(this.peek), this._getLocation());
|
|
}
|
|
var nameStart = this.index;
|
|
this._consumeTagOpenStart(start);
|
|
lowercaseTagName = this.inputLowercase.substring(nameStart, this.index);
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
while (this.peek !== $SLASH && this.peek !== $GT) {
|
|
this._consumeAttributeName();
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
if (this._attemptChar($EQ)) {
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
this._consumeAttributeValue();
|
|
}
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
}
|
|
this._consumeTagOpenEnd();
|
|
} catch (e) {
|
|
if (e instanceof ControlFlowError) {
|
|
this._restorePosition(savedPos);
|
|
this._beginToken(HtmlTokenType.TEXT, start);
|
|
this._endToken(['<']);
|
|
return;
|
|
}
|
|
throw e;
|
|
}
|
|
var contentTokenType = html_tags_1.getHtmlTagDefinition(lowercaseTagName).contentType;
|
|
if (contentTokenType === html_tags_1.HtmlTagContentType.RAW_TEXT) {
|
|
this._consumeRawTextWithTagClose(lowercaseTagName, false);
|
|
} else if (contentTokenType === html_tags_1.HtmlTagContentType.ESCAPABLE_RAW_TEXT) {
|
|
this._consumeRawTextWithTagClose(lowercaseTagName, true);
|
|
}
|
|
};
|
|
_HtmlTokenizer.prototype._consumeRawTextWithTagClose = function(lowercaseTagName, decodeEntities) {
|
|
var _this = this;
|
|
var textToken = this._consumeRawText(decodeEntities, $LT, function() {
|
|
if (!_this._attemptChar($SLASH))
|
|
return false;
|
|
_this._attemptUntilFn(isNotWhitespace);
|
|
if (!_this._attemptChars(lowercaseTagName))
|
|
return false;
|
|
_this._attemptUntilFn(isNotWhitespace);
|
|
if (!_this._attemptChar($GT))
|
|
return false;
|
|
return true;
|
|
});
|
|
this._beginToken(HtmlTokenType.TAG_CLOSE, textToken.sourceSpan.end);
|
|
this._endToken([null, lowercaseTagName]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeTagOpenStart = function(start) {
|
|
this._beginToken(HtmlTokenType.TAG_OPEN_START, start);
|
|
var parts = this._consumePrefixAndName();
|
|
this._endToken(parts);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeAttributeName = function() {
|
|
this._beginToken(HtmlTokenType.ATTR_NAME);
|
|
var prefixAndName = this._consumePrefixAndName();
|
|
this._endToken(prefixAndName);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeAttributeValue = function() {
|
|
this._beginToken(HtmlTokenType.ATTR_VALUE);
|
|
var value;
|
|
if (this.peek === $SQ || this.peek === $DQ) {
|
|
var quoteChar = this.peek;
|
|
this._advance();
|
|
var parts = [];
|
|
while (this.peek !== quoteChar) {
|
|
parts.push(this._readChar(true));
|
|
}
|
|
value = parts.join('');
|
|
this._advance();
|
|
} else {
|
|
var valueStart = this.index;
|
|
this._requireUntilFn(isNameEnd, 1);
|
|
value = this.input.substring(valueStart, this.index);
|
|
}
|
|
this._endToken([this._processCarriageReturns(value)]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeTagOpenEnd = function() {
|
|
var tokenType = this._attemptChar($SLASH) ? HtmlTokenType.TAG_OPEN_END_VOID : HtmlTokenType.TAG_OPEN_END;
|
|
this._beginToken(tokenType);
|
|
this._requireChar($GT);
|
|
this._endToken([]);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeTagClose = function(start) {
|
|
this._beginToken(HtmlTokenType.TAG_CLOSE, start);
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
var prefixAndName;
|
|
prefixAndName = this._consumePrefixAndName();
|
|
this._attemptUntilFn(isNotWhitespace);
|
|
this._requireChar($GT);
|
|
this._endToken(prefixAndName);
|
|
};
|
|
_HtmlTokenizer.prototype._consumeText = function() {
|
|
var start = this._getLocation();
|
|
this._beginToken(HtmlTokenType.TEXT, start);
|
|
var parts = [this._readChar(true)];
|
|
while (!isTextEnd(this.peek)) {
|
|
parts.push(this._readChar(true));
|
|
}
|
|
this._endToken([this._processCarriageReturns(parts.join(''))]);
|
|
};
|
|
_HtmlTokenizer.prototype._savePosition = function() {
|
|
return [this.peek, this.index, this.column, this.line, this.tokens.length];
|
|
};
|
|
_HtmlTokenizer.prototype._restorePosition = function(position) {
|
|
this.peek = position[0];
|
|
this.index = position[1];
|
|
this.column = position[2];
|
|
this.line = position[3];
|
|
var nbTokens = position[4];
|
|
if (nbTokens < this.tokens.length) {
|
|
this.tokens = collection_1.ListWrapper.slice(this.tokens, 0, nbTokens);
|
|
}
|
|
};
|
|
return _HtmlTokenizer;
|
|
})();
|
|
function isNotWhitespace(code) {
|
|
return !isWhitespace(code) || code === $EOF;
|
|
}
|
|
function isWhitespace(code) {
|
|
return (code >= $TAB && code <= $SPACE) || (code === $NBSP);
|
|
}
|
|
function isNameEnd(code) {
|
|
return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ || code === $EQ;
|
|
}
|
|
function isPrefixEnd(code) {
|
|
return (code < $a || $z < code) && (code < $A || $Z < code) && (code < $0 || code > $9);
|
|
}
|
|
function isDigitEntityEnd(code) {
|
|
return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
|
|
}
|
|
function isNamedEntityEnd(code) {
|
|
return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
|
|
}
|
|
function isTextEnd(code) {
|
|
return code === $LT || code === $EOF;
|
|
}
|
|
function isAsciiLetter(code) {
|
|
return code >= $a && code <= $z;
|
|
}
|
|
function isAsciiHexDigit(code) {
|
|
return code >= $a && code <= $f || code >= $0 && code <= $9;
|
|
}
|
|
function mergeTextTokens(srcTokens) {
|
|
var dstTokens = [];
|
|
var lastDstToken;
|
|
for (var i = 0; i < srcTokens.length; i++) {
|
|
var token = srcTokens[i];
|
|
if (lang_1.isPresent(lastDstToken) && lastDstToken.type == HtmlTokenType.TEXT && token.type == HtmlTokenType.TEXT) {
|
|
lastDstToken.parts[0] += token.parts[0];
|
|
lastDstToken.sourceSpan.end = token.sourceSpan.end;
|
|
} else {
|
|
lastDstToken = token;
|
|
dstTokens.push(lastDstToken);
|
|
}
|
|
}
|
|
return dstTokens;
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("71", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ParseLocation = (function() {
|
|
function ParseLocation(file, offset, line, col) {
|
|
this.file = file;
|
|
this.offset = offset;
|
|
this.line = line;
|
|
this.col = col;
|
|
}
|
|
ParseLocation.prototype.toString = function() {
|
|
return this.file.url + "@" + this.line + ":" + this.col;
|
|
};
|
|
return ParseLocation;
|
|
})();
|
|
exports.ParseLocation = ParseLocation;
|
|
var ParseSourceFile = (function() {
|
|
function ParseSourceFile(content, url) {
|
|
this.content = content;
|
|
this.url = url;
|
|
}
|
|
return ParseSourceFile;
|
|
})();
|
|
exports.ParseSourceFile = ParseSourceFile;
|
|
var ParseError = (function() {
|
|
function ParseError(location, msg) {
|
|
this.location = location;
|
|
this.msg = msg;
|
|
}
|
|
ParseError.prototype.toString = function() {
|
|
var source = this.location.file.content;
|
|
var ctxStart = this.location.offset;
|
|
if (ctxStart > source.length - 1) {
|
|
ctxStart = source.length - 1;
|
|
}
|
|
var ctxEnd = ctxStart;
|
|
var ctxLen = 0;
|
|
var ctxLines = 0;
|
|
while (ctxLen < 100 && ctxStart > 0) {
|
|
ctxStart--;
|
|
ctxLen++;
|
|
if (source[ctxStart] == "\n") {
|
|
if (++ctxLines == 3) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
ctxLen = 0;
|
|
ctxLines = 0;
|
|
while (ctxLen < 100 && ctxEnd < source.length - 1) {
|
|
ctxEnd++;
|
|
ctxLen++;
|
|
if (source[ctxEnd] == "\n") {
|
|
if (++ctxLines == 3) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
var context = source.substring(ctxStart, this.location.offset) + '[ERROR ->]' + source.substring(this.location.offset, ctxEnd + 1);
|
|
return this.msg + " (\"" + context + "\"): " + this.location;
|
|
};
|
|
return ParseError;
|
|
})();
|
|
exports.ParseError = ParseError;
|
|
var ParseSourceSpan = (function() {
|
|
function ParseSourceSpan(start, end) {
|
|
this.start = start;
|
|
this.end = end;
|
|
}
|
|
ParseSourceSpan.prototype.toString = function() {
|
|
return this.start.file.content.substring(this.start.offset, this.end.offset);
|
|
};
|
|
return ParseSourceSpan;
|
|
})();
|
|
exports.ParseSourceSpan = ParseSourceSpan;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6f", ["20", "37", "77", "39", "78", "71", "70"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var html_ast_1 = $__require('77');
|
|
var di_1 = $__require('39');
|
|
var html_lexer_1 = $__require('78');
|
|
var parse_util_1 = $__require('71');
|
|
var html_tags_1 = $__require('70');
|
|
var HtmlTreeError = (function(_super) {
|
|
__extends(HtmlTreeError, _super);
|
|
function HtmlTreeError(elementName, location, msg) {
|
|
_super.call(this, location, msg);
|
|
this.elementName = elementName;
|
|
}
|
|
HtmlTreeError.create = function(elementName, location, msg) {
|
|
return new HtmlTreeError(elementName, location, msg);
|
|
};
|
|
return HtmlTreeError;
|
|
})(parse_util_1.ParseError);
|
|
exports.HtmlTreeError = HtmlTreeError;
|
|
var HtmlParseTreeResult = (function() {
|
|
function HtmlParseTreeResult(rootNodes, errors) {
|
|
this.rootNodes = rootNodes;
|
|
this.errors = errors;
|
|
}
|
|
return HtmlParseTreeResult;
|
|
})();
|
|
exports.HtmlParseTreeResult = HtmlParseTreeResult;
|
|
var HtmlParser = (function() {
|
|
function HtmlParser() {}
|
|
HtmlParser.prototype.parse = function(sourceContent, sourceUrl) {
|
|
var tokensAndErrors = html_lexer_1.tokenizeHtml(sourceContent, sourceUrl);
|
|
var treeAndErrors = new TreeBuilder(tokensAndErrors.tokens).build();
|
|
return new HtmlParseTreeResult(treeAndErrors.rootNodes, tokensAndErrors.errors.concat(treeAndErrors.errors));
|
|
};
|
|
HtmlParser = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], HtmlParser);
|
|
return HtmlParser;
|
|
})();
|
|
exports.HtmlParser = HtmlParser;
|
|
var TreeBuilder = (function() {
|
|
function TreeBuilder(tokens) {
|
|
this.tokens = tokens;
|
|
this.index = -1;
|
|
this.rootNodes = [];
|
|
this.errors = [];
|
|
this.elementStack = [];
|
|
this._advance();
|
|
}
|
|
TreeBuilder.prototype.build = function() {
|
|
while (this.peek.type !== html_lexer_1.HtmlTokenType.EOF) {
|
|
if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_START) {
|
|
this._consumeStartTag(this._advance());
|
|
} else if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_CLOSE) {
|
|
this._consumeEndTag(this._advance());
|
|
} else if (this.peek.type === html_lexer_1.HtmlTokenType.CDATA_START) {
|
|
this._closeVoidElement();
|
|
this._consumeCdata(this._advance());
|
|
} else if (this.peek.type === html_lexer_1.HtmlTokenType.COMMENT_START) {
|
|
this._closeVoidElement();
|
|
this._consumeComment(this._advance());
|
|
} else if (this.peek.type === html_lexer_1.HtmlTokenType.TEXT || this.peek.type === html_lexer_1.HtmlTokenType.RAW_TEXT || this.peek.type === html_lexer_1.HtmlTokenType.ESCAPABLE_RAW_TEXT) {
|
|
this._closeVoidElement();
|
|
this._consumeText(this._advance());
|
|
} else {
|
|
this._advance();
|
|
}
|
|
}
|
|
return new HtmlParseTreeResult(this.rootNodes, this.errors);
|
|
};
|
|
TreeBuilder.prototype._advance = function() {
|
|
var prev = this.peek;
|
|
if (this.index < this.tokens.length - 1) {
|
|
this.index++;
|
|
}
|
|
this.peek = this.tokens[this.index];
|
|
return prev;
|
|
};
|
|
TreeBuilder.prototype._advanceIf = function(type) {
|
|
if (this.peek.type === type) {
|
|
return this._advance();
|
|
}
|
|
return null;
|
|
};
|
|
TreeBuilder.prototype._consumeCdata = function(startToken) {
|
|
this._consumeText(this._advance());
|
|
this._advanceIf(html_lexer_1.HtmlTokenType.CDATA_END);
|
|
};
|
|
TreeBuilder.prototype._consumeComment = function(startToken) {
|
|
this._advanceIf(html_lexer_1.HtmlTokenType.RAW_TEXT);
|
|
this._advanceIf(html_lexer_1.HtmlTokenType.COMMENT_END);
|
|
};
|
|
TreeBuilder.prototype._consumeText = function(token) {
|
|
var text = token.parts[0];
|
|
if (text.length > 0 && text[0] == '\n') {
|
|
var parent_1 = this._getParentElement();
|
|
if (lang_1.isPresent(parent_1) && parent_1.children.length == 0 && html_tags_1.getHtmlTagDefinition(parent_1.name).ignoreFirstLf) {
|
|
text = text.substring(1);
|
|
}
|
|
}
|
|
if (text.length > 0) {
|
|
this._addToParent(new html_ast_1.HtmlTextAst(text, token.sourceSpan));
|
|
}
|
|
};
|
|
TreeBuilder.prototype._closeVoidElement = function() {
|
|
if (this.elementStack.length > 0) {
|
|
var el = collection_1.ListWrapper.last(this.elementStack);
|
|
if (html_tags_1.getHtmlTagDefinition(el.name).isVoid) {
|
|
this.elementStack.pop();
|
|
}
|
|
}
|
|
};
|
|
TreeBuilder.prototype._consumeStartTag = function(startTagToken) {
|
|
var prefix = startTagToken.parts[0];
|
|
var name = startTagToken.parts[1];
|
|
var attrs = [];
|
|
while (this.peek.type === html_lexer_1.HtmlTokenType.ATTR_NAME) {
|
|
attrs.push(this._consumeAttr(this._advance()));
|
|
}
|
|
var fullName = getElementFullName(prefix, name, this._getParentElement());
|
|
var selfClosing = false;
|
|
if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_END_VOID) {
|
|
this._advance();
|
|
selfClosing = true;
|
|
if (html_tags_1.getNsPrefix(fullName) == null && !html_tags_1.getHtmlTagDefinition(fullName).isVoid) {
|
|
this.errors.push(HtmlTreeError.create(fullName, startTagToken.sourceSpan.start, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
|
|
}
|
|
} else if (this.peek.type === html_lexer_1.HtmlTokenType.TAG_OPEN_END) {
|
|
this._advance();
|
|
selfClosing = false;
|
|
}
|
|
var end = this.peek.sourceSpan.start;
|
|
var el = new html_ast_1.HtmlElementAst(fullName, attrs, [], new parse_util_1.ParseSourceSpan(startTagToken.sourceSpan.start, end));
|
|
this._pushElement(el);
|
|
if (selfClosing) {
|
|
this._popElement(fullName);
|
|
}
|
|
};
|
|
TreeBuilder.prototype._pushElement = function(el) {
|
|
if (this.elementStack.length > 0) {
|
|
var parentEl = collection_1.ListWrapper.last(this.elementStack);
|
|
if (html_tags_1.getHtmlTagDefinition(parentEl.name).isClosedByChild(el.name)) {
|
|
this.elementStack.pop();
|
|
}
|
|
}
|
|
var tagDef = html_tags_1.getHtmlTagDefinition(el.name);
|
|
var parentEl = this._getParentElement();
|
|
if (tagDef.requireExtraParent(lang_1.isPresent(parentEl) ? parentEl.name : null)) {
|
|
var newParent = new html_ast_1.HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan);
|
|
this._addToParent(newParent);
|
|
this.elementStack.push(newParent);
|
|
this.elementStack.push(el);
|
|
} else {
|
|
this._addToParent(el);
|
|
this.elementStack.push(el);
|
|
}
|
|
};
|
|
TreeBuilder.prototype._consumeEndTag = function(endTagToken) {
|
|
var fullName = getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
|
|
if (html_tags_1.getHtmlTagDefinition(fullName).isVoid) {
|
|
this.errors.push(HtmlTreeError.create(fullName, endTagToken.sourceSpan.start, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
|
|
} else if (!this._popElement(fullName)) {
|
|
this.errors.push(HtmlTreeError.create(fullName, endTagToken.sourceSpan.start, "Unexpected closing tag \"" + endTagToken.parts[1] + "\""));
|
|
}
|
|
};
|
|
TreeBuilder.prototype._popElement = function(fullName) {
|
|
for (var stackIndex = this.elementStack.length - 1; stackIndex >= 0; stackIndex--) {
|
|
var el = this.elementStack[stackIndex];
|
|
if (el.name == fullName) {
|
|
collection_1.ListWrapper.splice(this.elementStack, stackIndex, this.elementStack.length - stackIndex);
|
|
return true;
|
|
}
|
|
if (!html_tags_1.getHtmlTagDefinition(el.name).closedByParent) {
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
TreeBuilder.prototype._consumeAttr = function(attrName) {
|
|
var fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
|
|
var end = attrName.sourceSpan.end;
|
|
var value = '';
|
|
if (this.peek.type === html_lexer_1.HtmlTokenType.ATTR_VALUE) {
|
|
var valueToken = this._advance();
|
|
value = valueToken.parts[0];
|
|
end = valueToken.sourceSpan.end;
|
|
}
|
|
return new html_ast_1.HtmlAttrAst(fullName, value, new parse_util_1.ParseSourceSpan(attrName.sourceSpan.start, end));
|
|
};
|
|
TreeBuilder.prototype._getParentElement = function() {
|
|
return this.elementStack.length > 0 ? collection_1.ListWrapper.last(this.elementStack) : null;
|
|
};
|
|
TreeBuilder.prototype._addToParent = function(node) {
|
|
var parent = this._getParentElement();
|
|
if (lang_1.isPresent(parent)) {
|
|
parent.children.push(node);
|
|
} else {
|
|
this.rootNodes.push(node);
|
|
}
|
|
};
|
|
return TreeBuilder;
|
|
})();
|
|
function mergeNsAndName(prefix, localName) {
|
|
return lang_1.isPresent(prefix) ? "@" + prefix + ":" + localName : localName;
|
|
}
|
|
function getElementFullName(prefix, localName, parentElement) {
|
|
if (lang_1.isBlank(prefix)) {
|
|
prefix = html_tags_1.getHtmlTagDefinition(localName).implicitNamespacePrefix;
|
|
if (lang_1.isBlank(prefix) && lang_1.isPresent(parentElement)) {
|
|
prefix = html_tags_1.getNsPrefix(parentElement.name);
|
|
}
|
|
}
|
|
return mergeNsAndName(prefix, localName);
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("75", ["20", "70"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var html_tags_1 = $__require('70');
|
|
var NG_CONTENT_SELECT_ATTR = 'select';
|
|
var NG_CONTENT_ELEMENT = 'ng-content';
|
|
var LINK_ELEMENT = 'link';
|
|
var LINK_STYLE_REL_ATTR = 'rel';
|
|
var LINK_STYLE_HREF_ATTR = 'href';
|
|
var LINK_STYLE_REL_VALUE = 'stylesheet';
|
|
var STYLE_ELEMENT = 'style';
|
|
var SCRIPT_ELEMENT = 'script';
|
|
var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
|
|
function preparseElement(ast) {
|
|
var selectAttr = null;
|
|
var hrefAttr = null;
|
|
var relAttr = null;
|
|
var nonBindable = false;
|
|
ast.attrs.forEach(function(attr) {
|
|
var lcAttrName = attr.name.toLowerCase();
|
|
if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
|
|
selectAttr = attr.value;
|
|
} else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
|
|
hrefAttr = attr.value;
|
|
} else if (lcAttrName == LINK_STYLE_REL_ATTR) {
|
|
relAttr = attr.value;
|
|
} else if (attr.name == NG_NON_BINDABLE_ATTR) {
|
|
nonBindable = true;
|
|
}
|
|
});
|
|
selectAttr = normalizeNgContentSelect(selectAttr);
|
|
var nodeName = ast.name.toLowerCase();
|
|
var type = PreparsedElementType.OTHER;
|
|
if (html_tags_1.splitNsName(nodeName)[1] == NG_CONTENT_ELEMENT) {
|
|
type = PreparsedElementType.NG_CONTENT;
|
|
} else if (nodeName == STYLE_ELEMENT) {
|
|
type = PreparsedElementType.STYLE;
|
|
} else if (nodeName == SCRIPT_ELEMENT) {
|
|
type = PreparsedElementType.SCRIPT;
|
|
} else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
|
|
type = PreparsedElementType.STYLESHEET;
|
|
}
|
|
return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable);
|
|
}
|
|
exports.preparseElement = preparseElement;
|
|
(function(PreparsedElementType) {
|
|
PreparsedElementType[PreparsedElementType["NG_CONTENT"] = 0] = "NG_CONTENT";
|
|
PreparsedElementType[PreparsedElementType["STYLE"] = 1] = "STYLE";
|
|
PreparsedElementType[PreparsedElementType["STYLESHEET"] = 2] = "STYLESHEET";
|
|
PreparsedElementType[PreparsedElementType["SCRIPT"] = 3] = "SCRIPT";
|
|
PreparsedElementType[PreparsedElementType["OTHER"] = 4] = "OTHER";
|
|
})(exports.PreparsedElementType || (exports.PreparsedElementType = {}));
|
|
var PreparsedElementType = exports.PreparsedElementType;
|
|
var PreparsedElement = (function() {
|
|
function PreparsedElement(type, selectAttr, hrefAttr, nonBindable) {
|
|
this.type = type;
|
|
this.selectAttr = selectAttr;
|
|
this.hrefAttr = hrefAttr;
|
|
this.nonBindable = nonBindable;
|
|
}
|
|
return PreparsedElement;
|
|
})();
|
|
exports.PreparsedElement = PreparsedElement;
|
|
function normalizeNgContentSelect(selectAttr) {
|
|
if (lang_1.isBlank(selectAttr) || selectAttr.length === 0) {
|
|
return '*';
|
|
}
|
|
return selectAttr;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6b", ["65", "20", "3c", "63", "79", "7a", "76", "39", "7b", "77", "6f", "75"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var directive_metadata_1 = $__require('65');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var async_1 = $__require('63');
|
|
var xhr_1 = $__require('79');
|
|
var url_resolver_1 = $__require('7a');
|
|
var style_url_resolver_1 = $__require('76');
|
|
var di_1 = $__require('39');
|
|
var view_1 = $__require('7b');
|
|
var html_ast_1 = $__require('77');
|
|
var html_parser_1 = $__require('6f');
|
|
var template_preparser_1 = $__require('75');
|
|
var TemplateNormalizer = (function() {
|
|
function TemplateNormalizer(_xhr, _urlResolver, _htmlParser) {
|
|
this._xhr = _xhr;
|
|
this._urlResolver = _urlResolver;
|
|
this._htmlParser = _htmlParser;
|
|
}
|
|
TemplateNormalizer.prototype.normalizeTemplate = function(directiveType, template) {
|
|
var _this = this;
|
|
if (lang_1.isPresent(template.template)) {
|
|
return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
|
|
} else if (lang_1.isPresent(template.templateUrl)) {
|
|
var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
|
|
return this._xhr.get(sourceAbsUrl).then(function(templateContent) {
|
|
return _this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl);
|
|
});
|
|
} else {
|
|
throw new exceptions_1.BaseException("No template specified for component " + directiveType.name);
|
|
}
|
|
};
|
|
TemplateNormalizer.prototype.normalizeLoadedTemplate = function(directiveType, templateMeta, template, templateAbsUrl) {
|
|
var _this = this;
|
|
var rootNodesAndErrors = this._htmlParser.parse(template, directiveType.name);
|
|
if (rootNodesAndErrors.errors.length > 0) {
|
|
var errorString = rootNodesAndErrors.errors.join('\n');
|
|
throw new exceptions_1.BaseException("Template parse errors:\n" + errorString);
|
|
}
|
|
var visitor = new TemplatePreparseVisitor();
|
|
html_ast_1.htmlVisitAll(visitor, rootNodesAndErrors.rootNodes);
|
|
var allStyles = templateMeta.styles.concat(visitor.styles);
|
|
var allStyleAbsUrls = visitor.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable).map(function(url) {
|
|
return _this._urlResolver.resolve(templateAbsUrl, url);
|
|
}).concat(templateMeta.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable).map(function(url) {
|
|
return _this._urlResolver.resolve(directiveType.moduleUrl, url);
|
|
}));
|
|
var allResolvedStyles = allStyles.map(function(style) {
|
|
var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, templateAbsUrl, style);
|
|
styleWithImports.styleUrls.forEach(function(styleUrl) {
|
|
return allStyleAbsUrls.push(styleUrl);
|
|
});
|
|
return styleWithImports.style;
|
|
});
|
|
var encapsulation = templateMeta.encapsulation;
|
|
if (encapsulation === view_1.ViewEncapsulation.Emulated && allResolvedStyles.length === 0 && allStyleAbsUrls.length === 0) {
|
|
encapsulation = view_1.ViewEncapsulation.None;
|
|
}
|
|
return new directive_metadata_1.CompileTemplateMetadata({
|
|
encapsulation: encapsulation,
|
|
template: template,
|
|
templateUrl: templateAbsUrl,
|
|
styles: allResolvedStyles,
|
|
styleUrls: allStyleAbsUrls,
|
|
ngContentSelectors: visitor.ngContentSelectors
|
|
});
|
|
};
|
|
TemplateNormalizer = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [xhr_1.XHR, url_resolver_1.UrlResolver, html_parser_1.HtmlParser])], TemplateNormalizer);
|
|
return TemplateNormalizer;
|
|
})();
|
|
exports.TemplateNormalizer = TemplateNormalizer;
|
|
var TemplatePreparseVisitor = (function() {
|
|
function TemplatePreparseVisitor() {
|
|
this.ngContentSelectors = [];
|
|
this.styles = [];
|
|
this.styleUrls = [];
|
|
this.ngNonBindableStackCount = 0;
|
|
}
|
|
TemplatePreparseVisitor.prototype.visitElement = function(ast, context) {
|
|
var preparsedElement = template_preparser_1.preparseElement(ast);
|
|
switch (preparsedElement.type) {
|
|
case template_preparser_1.PreparsedElementType.NG_CONTENT:
|
|
if (this.ngNonBindableStackCount === 0) {
|
|
this.ngContentSelectors.push(preparsedElement.selectAttr);
|
|
}
|
|
break;
|
|
case template_preparser_1.PreparsedElementType.STYLE:
|
|
var textContent = '';
|
|
ast.children.forEach(function(child) {
|
|
if (child instanceof html_ast_1.HtmlTextAst) {
|
|
textContent += child.value;
|
|
}
|
|
});
|
|
this.styles.push(textContent);
|
|
break;
|
|
case template_preparser_1.PreparsedElementType.STYLESHEET:
|
|
this.styleUrls.push(preparsedElement.hrefAttr);
|
|
break;
|
|
}
|
|
if (preparsedElement.nonBindable) {
|
|
this.ngNonBindableStackCount++;
|
|
}
|
|
html_ast_1.htmlVisitAll(this, ast.children);
|
|
if (preparsedElement.nonBindable) {
|
|
this.ngNonBindableStackCount--;
|
|
}
|
|
return null;
|
|
};
|
|
TemplatePreparseVisitor.prototype.visitAttr = function(ast, context) {
|
|
return null;
|
|
};
|
|
TemplatePreparseVisitor.prototype.visitText = function(ast, context) {
|
|
return null;
|
|
};
|
|
return TemplatePreparseVisitor;
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("73", ["37", "20", "3c", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var _EMPTY_ATTR_VALUE = '';
|
|
var _SELECTOR_REGEXP = lang_1.RegExpWrapper.create('(\\:not\\()|' + '([-\\w]+)|' + '(?:\\.([-\\w]+))|' + '(?:\\[([-\\w*]+)(?:=([^\\]]*))?\\])|' + '(\\))|' + '(\\s*,\\s*)');
|
|
var CssSelector = (function() {
|
|
function CssSelector() {
|
|
this.element = null;
|
|
this.classNames = [];
|
|
this.attrs = [];
|
|
this.notSelectors = [];
|
|
}
|
|
CssSelector.parse = function(selector) {
|
|
var results = [];
|
|
var _addResult = function(res, cssSel) {
|
|
if (cssSel.notSelectors.length > 0 && lang_1.isBlank(cssSel.element) && collection_1.ListWrapper.isEmpty(cssSel.classNames) && collection_1.ListWrapper.isEmpty(cssSel.attrs)) {
|
|
cssSel.element = "*";
|
|
}
|
|
res.push(cssSel);
|
|
};
|
|
var cssSelector = new CssSelector();
|
|
var matcher = lang_1.RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
|
|
var match;
|
|
var current = cssSelector;
|
|
var inNot = false;
|
|
while (lang_1.isPresent(match = lang_1.RegExpMatcherWrapper.next(matcher))) {
|
|
if (lang_1.isPresent(match[1])) {
|
|
if (inNot) {
|
|
throw new exceptions_1.BaseException('Nesting :not is not allowed in a selector');
|
|
}
|
|
inNot = true;
|
|
current = new CssSelector();
|
|
cssSelector.notSelectors.push(current);
|
|
}
|
|
if (lang_1.isPresent(match[2])) {
|
|
current.setElement(match[2]);
|
|
}
|
|
if (lang_1.isPresent(match[3])) {
|
|
current.addClassName(match[3]);
|
|
}
|
|
if (lang_1.isPresent(match[4])) {
|
|
current.addAttribute(match[4], match[5]);
|
|
}
|
|
if (lang_1.isPresent(match[6])) {
|
|
inNot = false;
|
|
current = cssSelector;
|
|
}
|
|
if (lang_1.isPresent(match[7])) {
|
|
if (inNot) {
|
|
throw new exceptions_1.BaseException('Multiple selectors in :not are not supported');
|
|
}
|
|
_addResult(results, cssSelector);
|
|
cssSelector = current = new CssSelector();
|
|
}
|
|
}
|
|
_addResult(results, cssSelector);
|
|
return results;
|
|
};
|
|
CssSelector.prototype.isElementSelector = function() {
|
|
return lang_1.isPresent(this.element) && collection_1.ListWrapper.isEmpty(this.classNames) && collection_1.ListWrapper.isEmpty(this.attrs) && this.notSelectors.length === 0;
|
|
};
|
|
CssSelector.prototype.setElement = function(element) {
|
|
if (element === void 0) {
|
|
element = null;
|
|
}
|
|
this.element = element;
|
|
};
|
|
CssSelector.prototype.getMatchingElementTemplate = function() {
|
|
var tagName = lang_1.isPresent(this.element) ? this.element : 'div';
|
|
var classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
|
|
var attrs = '';
|
|
for (var i = 0; i < this.attrs.length; i += 2) {
|
|
var attrName = this.attrs[i];
|
|
var attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
|
|
attrs += " " + attrName + attrValue;
|
|
}
|
|
return "<" + tagName + classAttr + attrs + "></" + tagName + ">";
|
|
};
|
|
CssSelector.prototype.addAttribute = function(name, value) {
|
|
if (value === void 0) {
|
|
value = _EMPTY_ATTR_VALUE;
|
|
}
|
|
this.attrs.push(name);
|
|
if (lang_1.isPresent(value)) {
|
|
value = value.toLowerCase();
|
|
} else {
|
|
value = _EMPTY_ATTR_VALUE;
|
|
}
|
|
this.attrs.push(value);
|
|
};
|
|
CssSelector.prototype.addClassName = function(name) {
|
|
this.classNames.push(name.toLowerCase());
|
|
};
|
|
CssSelector.prototype.toString = function() {
|
|
var res = '';
|
|
if (lang_1.isPresent(this.element)) {
|
|
res += this.element;
|
|
}
|
|
if (lang_1.isPresent(this.classNames)) {
|
|
for (var i = 0; i < this.classNames.length; i++) {
|
|
res += '.' + this.classNames[i];
|
|
}
|
|
}
|
|
if (lang_1.isPresent(this.attrs)) {
|
|
for (var i = 0; i < this.attrs.length; ) {
|
|
var attrName = this.attrs[i++];
|
|
var attrValue = this.attrs[i++];
|
|
res += '[' + attrName;
|
|
if (attrValue.length > 0) {
|
|
res += '=' + attrValue;
|
|
}
|
|
res += ']';
|
|
}
|
|
}
|
|
this.notSelectors.forEach(function(notSelector) {
|
|
return res += ":not(" + notSelector + ")";
|
|
});
|
|
return res;
|
|
};
|
|
return CssSelector;
|
|
})();
|
|
exports.CssSelector = CssSelector;
|
|
var SelectorMatcher = (function() {
|
|
function SelectorMatcher() {
|
|
this._elementMap = new collection_1.Map();
|
|
this._elementPartialMap = new collection_1.Map();
|
|
this._classMap = new collection_1.Map();
|
|
this._classPartialMap = new collection_1.Map();
|
|
this._attrValueMap = new collection_1.Map();
|
|
this._attrValuePartialMap = new collection_1.Map();
|
|
this._listContexts = [];
|
|
}
|
|
SelectorMatcher.createNotMatcher = function(notSelectors) {
|
|
var notMatcher = new SelectorMatcher();
|
|
notMatcher.addSelectables(notSelectors, null);
|
|
return notMatcher;
|
|
};
|
|
SelectorMatcher.prototype.addSelectables = function(cssSelectors, callbackCtxt) {
|
|
var listContext = null;
|
|
if (cssSelectors.length > 1) {
|
|
listContext = new SelectorListContext(cssSelectors);
|
|
this._listContexts.push(listContext);
|
|
}
|
|
for (var i = 0; i < cssSelectors.length; i++) {
|
|
this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
|
|
}
|
|
};
|
|
SelectorMatcher.prototype._addSelectable = function(cssSelector, callbackCtxt, listContext) {
|
|
var matcher = this;
|
|
var element = cssSelector.element;
|
|
var classNames = cssSelector.classNames;
|
|
var attrs = cssSelector.attrs;
|
|
var selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
|
|
if (lang_1.isPresent(element)) {
|
|
var isTerminal = attrs.length === 0 && classNames.length === 0;
|
|
if (isTerminal) {
|
|
this._addTerminal(matcher._elementMap, element, selectable);
|
|
} else {
|
|
matcher = this._addPartial(matcher._elementPartialMap, element);
|
|
}
|
|
}
|
|
if (lang_1.isPresent(classNames)) {
|
|
for (var index = 0; index < classNames.length; index++) {
|
|
var isTerminal = attrs.length === 0 && index === classNames.length - 1;
|
|
var className = classNames[index];
|
|
if (isTerminal) {
|
|
this._addTerminal(matcher._classMap, className, selectable);
|
|
} else {
|
|
matcher = this._addPartial(matcher._classPartialMap, className);
|
|
}
|
|
}
|
|
}
|
|
if (lang_1.isPresent(attrs)) {
|
|
for (var index = 0; index < attrs.length; ) {
|
|
var isTerminal = index === attrs.length - 2;
|
|
var attrName = attrs[index++];
|
|
var attrValue = attrs[index++];
|
|
if (isTerminal) {
|
|
var terminalMap = matcher._attrValueMap;
|
|
var terminalValuesMap = terminalMap.get(attrName);
|
|
if (lang_1.isBlank(terminalValuesMap)) {
|
|
terminalValuesMap = new collection_1.Map();
|
|
terminalMap.set(attrName, terminalValuesMap);
|
|
}
|
|
this._addTerminal(terminalValuesMap, attrValue, selectable);
|
|
} else {
|
|
var parttialMap = matcher._attrValuePartialMap;
|
|
var partialValuesMap = parttialMap.get(attrName);
|
|
if (lang_1.isBlank(partialValuesMap)) {
|
|
partialValuesMap = new collection_1.Map();
|
|
parttialMap.set(attrName, partialValuesMap);
|
|
}
|
|
matcher = this._addPartial(partialValuesMap, attrValue);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
SelectorMatcher.prototype._addTerminal = function(map, name, selectable) {
|
|
var terminalList = map.get(name);
|
|
if (lang_1.isBlank(terminalList)) {
|
|
terminalList = [];
|
|
map.set(name, terminalList);
|
|
}
|
|
terminalList.push(selectable);
|
|
};
|
|
SelectorMatcher.prototype._addPartial = function(map, name) {
|
|
var matcher = map.get(name);
|
|
if (lang_1.isBlank(matcher)) {
|
|
matcher = new SelectorMatcher();
|
|
map.set(name, matcher);
|
|
}
|
|
return matcher;
|
|
};
|
|
SelectorMatcher.prototype.match = function(cssSelector, matchedCallback) {
|
|
var result = false;
|
|
var element = cssSelector.element;
|
|
var classNames = cssSelector.classNames;
|
|
var attrs = cssSelector.attrs;
|
|
for (var i = 0; i < this._listContexts.length; i++) {
|
|
this._listContexts[i].alreadyMatched = false;
|
|
}
|
|
result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
|
|
result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) || result;
|
|
if (lang_1.isPresent(classNames)) {
|
|
for (var index = 0; index < classNames.length; index++) {
|
|
var className = classNames[index];
|
|
result = this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
|
|
result = this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) || result;
|
|
}
|
|
}
|
|
if (lang_1.isPresent(attrs)) {
|
|
for (var index = 0; index < attrs.length; ) {
|
|
var attrName = attrs[index++];
|
|
var attrValue = attrs[index++];
|
|
var terminalValuesMap = this._attrValueMap.get(attrName);
|
|
if (!lang_1.StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
|
|
result = this._matchTerminal(terminalValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) || result;
|
|
}
|
|
result = this._matchTerminal(terminalValuesMap, attrValue, cssSelector, matchedCallback) || result;
|
|
var partialValuesMap = this._attrValuePartialMap.get(attrName);
|
|
if (!lang_1.StringWrapper.equals(attrValue, _EMPTY_ATTR_VALUE)) {
|
|
result = this._matchPartial(partialValuesMap, _EMPTY_ATTR_VALUE, cssSelector, matchedCallback) || result;
|
|
}
|
|
result = this._matchPartial(partialValuesMap, attrValue, cssSelector, matchedCallback) || result;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
SelectorMatcher.prototype._matchTerminal = function(map, name, cssSelector, matchedCallback) {
|
|
if (lang_1.isBlank(map) || lang_1.isBlank(name)) {
|
|
return false;
|
|
}
|
|
var selectables = map.get(name);
|
|
var starSelectables = map.get("*");
|
|
if (lang_1.isPresent(starSelectables)) {
|
|
selectables = selectables.concat(starSelectables);
|
|
}
|
|
if (lang_1.isBlank(selectables)) {
|
|
return false;
|
|
}
|
|
var selectable;
|
|
var result = false;
|
|
for (var index = 0; index < selectables.length; index++) {
|
|
selectable = selectables[index];
|
|
result = selectable.finalize(cssSelector, matchedCallback) || result;
|
|
}
|
|
return result;
|
|
};
|
|
SelectorMatcher.prototype._matchPartial = function(map, name, cssSelector, matchedCallback) {
|
|
if (lang_1.isBlank(map) || lang_1.isBlank(name)) {
|
|
return false;
|
|
}
|
|
var nestedSelector = map.get(name);
|
|
if (lang_1.isBlank(nestedSelector)) {
|
|
return false;
|
|
}
|
|
return nestedSelector.match(cssSelector, matchedCallback);
|
|
};
|
|
return SelectorMatcher;
|
|
})();
|
|
exports.SelectorMatcher = SelectorMatcher;
|
|
var SelectorListContext = (function() {
|
|
function SelectorListContext(selectors) {
|
|
this.selectors = selectors;
|
|
this.alreadyMatched = false;
|
|
}
|
|
return SelectorListContext;
|
|
})();
|
|
exports.SelectorListContext = SelectorListContext;
|
|
var SelectorContext = (function() {
|
|
function SelectorContext(selector, cbContext, listContext) {
|
|
this.selector = selector;
|
|
this.cbContext = cbContext;
|
|
this.listContext = listContext;
|
|
this.notSelectors = selector.notSelectors;
|
|
}
|
|
SelectorContext.prototype.finalize = function(cssSelector, callback) {
|
|
var result = true;
|
|
if (this.notSelectors.length > 0 && (lang_1.isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
|
|
var notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
|
|
result = !notMatcher.match(cssSelector, null);
|
|
}
|
|
if (result && lang_1.isPresent(callback) && (lang_1.isBlank(this.listContext) || !this.listContext.alreadyMatched)) {
|
|
if (lang_1.isPresent(this.listContext)) {
|
|
this.listContext.alreadyMatched = true;
|
|
}
|
|
callback(this.selector, this.cbContext);
|
|
}
|
|
return result;
|
|
};
|
|
return SelectorContext;
|
|
})();
|
|
exports.SelectorContext = SelectorContext;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("65", ["20", "37", "6e", "7b", "73", "6d", "7c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var change_detection_1 = $__require('6e');
|
|
var view_1 = $__require('7b');
|
|
var selector_1 = $__require('73');
|
|
var util_1 = $__require('6d');
|
|
var interfaces_1 = $__require('7c');
|
|
var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))$/g;
|
|
var CompileTypeMetadata = (function() {
|
|
function CompileTypeMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
runtime = _b.runtime,
|
|
name = _b.name,
|
|
moduleUrl = _b.moduleUrl,
|
|
isHost = _b.isHost;
|
|
this.runtime = runtime;
|
|
this.name = name;
|
|
this.moduleUrl = moduleUrl;
|
|
this.isHost = lang_1.normalizeBool(isHost);
|
|
}
|
|
CompileTypeMetadata.fromJson = function(data) {
|
|
return new CompileTypeMetadata({
|
|
name: data['name'],
|
|
moduleUrl: data['moduleUrl'],
|
|
isHost: data['isHost']
|
|
});
|
|
};
|
|
CompileTypeMetadata.prototype.toJson = function() {
|
|
return {
|
|
'name': this.name,
|
|
'moduleUrl': this.moduleUrl,
|
|
'isHost': this.isHost
|
|
};
|
|
};
|
|
return CompileTypeMetadata;
|
|
})();
|
|
exports.CompileTypeMetadata = CompileTypeMetadata;
|
|
var CompileTemplateMetadata = (function() {
|
|
function CompileTemplateMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
encapsulation = _b.encapsulation,
|
|
template = _b.template,
|
|
templateUrl = _b.templateUrl,
|
|
styles = _b.styles,
|
|
styleUrls = _b.styleUrls,
|
|
ngContentSelectors = _b.ngContentSelectors;
|
|
this.encapsulation = lang_1.isPresent(encapsulation) ? encapsulation : view_1.ViewEncapsulation.Emulated;
|
|
this.template = template;
|
|
this.templateUrl = templateUrl;
|
|
this.styles = lang_1.isPresent(styles) ? styles : [];
|
|
this.styleUrls = lang_1.isPresent(styleUrls) ? styleUrls : [];
|
|
this.ngContentSelectors = lang_1.isPresent(ngContentSelectors) ? ngContentSelectors : [];
|
|
}
|
|
CompileTemplateMetadata.fromJson = function(data) {
|
|
return new CompileTemplateMetadata({
|
|
encapsulation: lang_1.isPresent(data['encapsulation']) ? view_1.VIEW_ENCAPSULATION_VALUES[data['encapsulation']] : data['encapsulation'],
|
|
template: data['template'],
|
|
templateUrl: data['templateUrl'],
|
|
styles: data['styles'],
|
|
styleUrls: data['styleUrls'],
|
|
ngContentSelectors: data['ngContentSelectors']
|
|
});
|
|
};
|
|
CompileTemplateMetadata.prototype.toJson = function() {
|
|
return {
|
|
'encapsulation': lang_1.isPresent(this.encapsulation) ? lang_1.serializeEnum(this.encapsulation) : this.encapsulation,
|
|
'template': this.template,
|
|
'templateUrl': this.templateUrl,
|
|
'styles': this.styles,
|
|
'styleUrls': this.styleUrls,
|
|
'ngContentSelectors': this.ngContentSelectors
|
|
};
|
|
};
|
|
return CompileTemplateMetadata;
|
|
})();
|
|
exports.CompileTemplateMetadata = CompileTemplateMetadata;
|
|
var CompileDirectiveMetadata = (function() {
|
|
function CompileDirectiveMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
type = _b.type,
|
|
isComponent = _b.isComponent,
|
|
dynamicLoadable = _b.dynamicLoadable,
|
|
selector = _b.selector,
|
|
exportAs = _b.exportAs,
|
|
changeDetection = _b.changeDetection,
|
|
inputs = _b.inputs,
|
|
outputs = _b.outputs,
|
|
hostListeners = _b.hostListeners,
|
|
hostProperties = _b.hostProperties,
|
|
hostAttributes = _b.hostAttributes,
|
|
lifecycleHooks = _b.lifecycleHooks,
|
|
template = _b.template;
|
|
this.type = type;
|
|
this.isComponent = isComponent;
|
|
this.dynamicLoadable = dynamicLoadable;
|
|
this.selector = selector;
|
|
this.exportAs = exportAs;
|
|
this.changeDetection = changeDetection;
|
|
this.inputs = inputs;
|
|
this.outputs = outputs;
|
|
this.hostListeners = hostListeners;
|
|
this.hostProperties = hostProperties;
|
|
this.hostAttributes = hostAttributes;
|
|
this.lifecycleHooks = lifecycleHooks;
|
|
this.template = template;
|
|
}
|
|
CompileDirectiveMetadata.create = function(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
type = _b.type,
|
|
isComponent = _b.isComponent,
|
|
dynamicLoadable = _b.dynamicLoadable,
|
|
selector = _b.selector,
|
|
exportAs = _b.exportAs,
|
|
changeDetection = _b.changeDetection,
|
|
inputs = _b.inputs,
|
|
outputs = _b.outputs,
|
|
host = _b.host,
|
|
lifecycleHooks = _b.lifecycleHooks,
|
|
template = _b.template;
|
|
var hostListeners = {};
|
|
var hostProperties = {};
|
|
var hostAttributes = {};
|
|
if (lang_1.isPresent(host)) {
|
|
collection_1.StringMapWrapper.forEach(host, function(value, key) {
|
|
var matches = lang_1.RegExpWrapper.firstMatch(HOST_REG_EXP, key);
|
|
if (lang_1.isBlank(matches)) {
|
|
hostAttributes[key] = value;
|
|
} else if (lang_1.isPresent(matches[1])) {
|
|
hostProperties[matches[1]] = value;
|
|
} else if (lang_1.isPresent(matches[2])) {
|
|
hostListeners[matches[2]] = value;
|
|
}
|
|
});
|
|
}
|
|
var inputsMap = {};
|
|
if (lang_1.isPresent(inputs)) {
|
|
inputs.forEach(function(bindConfig) {
|
|
var parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
|
|
inputsMap[parts[0]] = parts[1];
|
|
});
|
|
}
|
|
var outputsMap = {};
|
|
if (lang_1.isPresent(outputs)) {
|
|
outputs.forEach(function(bindConfig) {
|
|
var parts = util_1.splitAtColon(bindConfig, [bindConfig, bindConfig]);
|
|
outputsMap[parts[0]] = parts[1];
|
|
});
|
|
}
|
|
return new CompileDirectiveMetadata({
|
|
type: type,
|
|
isComponent: lang_1.normalizeBool(isComponent),
|
|
dynamicLoadable: lang_1.normalizeBool(dynamicLoadable),
|
|
selector: selector,
|
|
exportAs: exportAs,
|
|
changeDetection: changeDetection,
|
|
inputs: inputsMap,
|
|
outputs: outputsMap,
|
|
hostListeners: hostListeners,
|
|
hostProperties: hostProperties,
|
|
hostAttributes: hostAttributes,
|
|
lifecycleHooks: lang_1.isPresent(lifecycleHooks) ? lifecycleHooks : [],
|
|
template: template
|
|
});
|
|
};
|
|
CompileDirectiveMetadata.fromJson = function(data) {
|
|
return new CompileDirectiveMetadata({
|
|
isComponent: data['isComponent'],
|
|
dynamicLoadable: data['dynamicLoadable'],
|
|
selector: data['selector'],
|
|
exportAs: data['exportAs'],
|
|
type: lang_1.isPresent(data['type']) ? CompileTypeMetadata.fromJson(data['type']) : data['type'],
|
|
changeDetection: lang_1.isPresent(data['changeDetection']) ? change_detection_1.CHANGE_DETECTION_STRATEGY_VALUES[data['changeDetection']] : data['changeDetection'],
|
|
inputs: data['inputs'],
|
|
outputs: data['outputs'],
|
|
hostListeners: data['hostListeners'],
|
|
hostProperties: data['hostProperties'],
|
|
hostAttributes: data['hostAttributes'],
|
|
lifecycleHooks: data['lifecycleHooks'].map(function(hookValue) {
|
|
return interfaces_1.LIFECYCLE_HOOKS_VALUES[hookValue];
|
|
}),
|
|
template: lang_1.isPresent(data['template']) ? CompileTemplateMetadata.fromJson(data['template']) : data['template']
|
|
});
|
|
};
|
|
CompileDirectiveMetadata.prototype.toJson = function() {
|
|
return {
|
|
'isComponent': this.isComponent,
|
|
'dynamicLoadable': this.dynamicLoadable,
|
|
'selector': this.selector,
|
|
'exportAs': this.exportAs,
|
|
'type': lang_1.isPresent(this.type) ? this.type.toJson() : this.type,
|
|
'changeDetection': lang_1.isPresent(this.changeDetection) ? lang_1.serializeEnum(this.changeDetection) : this.changeDetection,
|
|
'inputs': this.inputs,
|
|
'outputs': this.outputs,
|
|
'hostListeners': this.hostListeners,
|
|
'hostProperties': this.hostProperties,
|
|
'hostAttributes': this.hostAttributes,
|
|
'lifecycleHooks': this.lifecycleHooks.map(function(hook) {
|
|
return lang_1.serializeEnum(hook);
|
|
}),
|
|
'template': lang_1.isPresent(this.template) ? this.template.toJson() : this.template
|
|
};
|
|
};
|
|
return CompileDirectiveMetadata;
|
|
})();
|
|
exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
|
|
function createHostComponentMeta(componentType, componentSelector) {
|
|
var template = selector_1.CssSelector.parse(componentSelector)[0].getMatchingElementTemplate();
|
|
return CompileDirectiveMetadata.create({
|
|
type: new CompileTypeMetadata({
|
|
runtime: Object,
|
|
name: "Host" + componentType.name,
|
|
moduleUrl: componentType.moduleUrl,
|
|
isHost: true
|
|
}),
|
|
template: new CompileTemplateMetadata({
|
|
template: template,
|
|
templateUrl: '',
|
|
styles: [],
|
|
styleUrls: [],
|
|
ngContentSelectors: []
|
|
}),
|
|
changeDetection: change_detection_1.ChangeDetectionStrategy.Default,
|
|
inputs: [],
|
|
outputs: [],
|
|
host: {},
|
|
lifecycleHooks: [],
|
|
isComponent: true,
|
|
dynamicLoadable: false,
|
|
selector: '*'
|
|
});
|
|
}
|
|
exports.createHostComponentMeta = createHostComponentMeta;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6c", ["39", "20", "3c", "65", "7d", "7e", "7f", "80", "7c", "81", "82", "6d", "7a"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var cpl = $__require('65');
|
|
var md = $__require('7d');
|
|
var directive_resolver_1 = $__require('7e');
|
|
var view_resolver_1 = $__require('7f');
|
|
var directive_lifecycle_reflector_1 = $__require('80');
|
|
var interfaces_1 = $__require('7c');
|
|
var reflection_1 = $__require('81');
|
|
var di_2 = $__require('39');
|
|
var platform_directives_and_pipes_1 = $__require('82');
|
|
var util_1 = $__require('6d');
|
|
var url_resolver_1 = $__require('7a');
|
|
var RuntimeMetadataResolver = (function() {
|
|
function RuntimeMetadataResolver(_directiveResolver, _viewResolver, _platformDirectives) {
|
|
this._directiveResolver = _directiveResolver;
|
|
this._viewResolver = _viewResolver;
|
|
this._platformDirectives = _platformDirectives;
|
|
this._cache = new Map();
|
|
}
|
|
RuntimeMetadataResolver.prototype.getMetadata = function(directiveType) {
|
|
var meta = this._cache.get(directiveType);
|
|
if (lang_1.isBlank(meta)) {
|
|
var dirMeta = this._directiveResolver.resolve(directiveType);
|
|
var moduleUrl = null;
|
|
var templateMeta = null;
|
|
var changeDetectionStrategy = null;
|
|
if (dirMeta instanceof md.ComponentMetadata) {
|
|
var cmpMeta = dirMeta;
|
|
moduleUrl = calcModuleUrl(directiveType, cmpMeta);
|
|
var viewMeta = this._viewResolver.resolve(directiveType);
|
|
templateMeta = new cpl.CompileTemplateMetadata({
|
|
encapsulation: viewMeta.encapsulation,
|
|
template: viewMeta.template,
|
|
templateUrl: viewMeta.templateUrl,
|
|
styles: viewMeta.styles,
|
|
styleUrls: viewMeta.styleUrls
|
|
});
|
|
changeDetectionStrategy = cmpMeta.changeDetection;
|
|
}
|
|
meta = cpl.CompileDirectiveMetadata.create({
|
|
selector: dirMeta.selector,
|
|
exportAs: dirMeta.exportAs,
|
|
isComponent: lang_1.isPresent(templateMeta),
|
|
dynamicLoadable: true,
|
|
type: new cpl.CompileTypeMetadata({
|
|
name: lang_1.stringify(directiveType),
|
|
moduleUrl: moduleUrl,
|
|
runtime: directiveType
|
|
}),
|
|
template: templateMeta,
|
|
changeDetection: changeDetectionStrategy,
|
|
inputs: dirMeta.inputs,
|
|
outputs: dirMeta.outputs,
|
|
host: dirMeta.host,
|
|
lifecycleHooks: interfaces_1.LIFECYCLE_HOOKS_VALUES.filter(function(hook) {
|
|
return directive_lifecycle_reflector_1.hasLifecycleHook(hook, directiveType);
|
|
})
|
|
});
|
|
this._cache.set(directiveType, meta);
|
|
}
|
|
return meta;
|
|
};
|
|
RuntimeMetadataResolver.prototype.getViewDirectivesMetadata = function(component) {
|
|
var _this = this;
|
|
var view = this._viewResolver.resolve(component);
|
|
var directives = flattenDirectives(view, this._platformDirectives);
|
|
for (var i = 0; i < directives.length; i++) {
|
|
if (!isValidDirective(directives[i])) {
|
|
throw new exceptions_1.BaseException("Unexpected directive value '" + lang_1.stringify(directives[i]) + "' on the View of component '" + lang_1.stringify(component) + "'");
|
|
}
|
|
}
|
|
return directives.map(function(type) {
|
|
return _this.getMetadata(type);
|
|
});
|
|
};
|
|
RuntimeMetadataResolver = __decorate([di_2.Injectable(), __param(2, di_2.Optional()), __param(2, di_2.Inject(platform_directives_and_pipes_1.PLATFORM_DIRECTIVES)), __metadata('design:paramtypes', [directive_resolver_1.DirectiveResolver, view_resolver_1.ViewResolver, Array])], RuntimeMetadataResolver);
|
|
return RuntimeMetadataResolver;
|
|
})();
|
|
exports.RuntimeMetadataResolver = RuntimeMetadataResolver;
|
|
function flattenDirectives(view, platformDirectives) {
|
|
var directives = [];
|
|
if (lang_1.isPresent(platformDirectives)) {
|
|
flattenArray(platformDirectives, directives);
|
|
}
|
|
if (lang_1.isPresent(view.directives)) {
|
|
flattenArray(view.directives, directives);
|
|
}
|
|
return directives;
|
|
}
|
|
function flattenArray(tree, out) {
|
|
for (var i = 0; i < tree.length; i++) {
|
|
var item = di_1.resolveForwardRef(tree[i]);
|
|
if (lang_1.isArray(item)) {
|
|
flattenArray(item, out);
|
|
} else {
|
|
out.push(item);
|
|
}
|
|
}
|
|
}
|
|
function isValidDirective(value) {
|
|
return lang_1.isPresent(value) && (value instanceof lang_1.Type);
|
|
}
|
|
function calcModuleUrl(type, cmpMetadata) {
|
|
var moduleId = cmpMetadata.moduleId;
|
|
if (lang_1.isPresent(moduleId)) {
|
|
var scheme = url_resolver_1.getUrlScheme(moduleId);
|
|
return lang_1.isPresent(scheme) && scheme.length > 0 ? moduleId : "package:" + moduleId + util_1.MODULE_SUFFIX;
|
|
} else {
|
|
return reflection_1.reflector.importUri(type);
|
|
}
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("83", ["37", "20", "81", "6e", "72", "7c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var reflection_1 = $__require('81');
|
|
var change_detection_1 = $__require('6e');
|
|
var template_ast_1 = $__require('72');
|
|
var interfaces_1 = $__require('7c');
|
|
function createChangeDetectorDefinitions(componentType, componentStrategy, genConfig, parsedTemplate) {
|
|
var pvVisitors = [];
|
|
var visitor = new ProtoViewVisitor(null, pvVisitors, componentStrategy);
|
|
template_ast_1.templateVisitAll(visitor, parsedTemplate);
|
|
return createChangeDefinitions(pvVisitors, componentType, genConfig);
|
|
}
|
|
exports.createChangeDetectorDefinitions = createChangeDetectorDefinitions;
|
|
var ProtoViewVisitor = (function() {
|
|
function ProtoViewVisitor(parent, allVisitors, strategy) {
|
|
this.parent = parent;
|
|
this.allVisitors = allVisitors;
|
|
this.strategy = strategy;
|
|
this.boundTextCount = 0;
|
|
this.boundElementCount = 0;
|
|
this.variableNames = [];
|
|
this.bindingRecords = [];
|
|
this.eventRecords = [];
|
|
this.directiveRecords = [];
|
|
this.viewIndex = allVisitors.length;
|
|
allVisitors.push(this);
|
|
}
|
|
ProtoViewVisitor.prototype.visitEmbeddedTemplate = function(ast, context) {
|
|
this.boundElementCount++;
|
|
template_ast_1.templateVisitAll(this, ast.outputs);
|
|
for (var i = 0; i < ast.directives.length; i++) {
|
|
ast.directives[i].visit(this, i);
|
|
}
|
|
var childVisitor = new ProtoViewVisitor(this, this.allVisitors, change_detection_1.ChangeDetectionStrategy.Default);
|
|
template_ast_1.templateVisitAll(childVisitor, ast.vars);
|
|
template_ast_1.templateVisitAll(childVisitor, ast.children);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitElement = function(ast, context) {
|
|
if (ast.isBound()) {
|
|
this.boundElementCount++;
|
|
}
|
|
template_ast_1.templateVisitAll(this, ast.inputs, null);
|
|
template_ast_1.templateVisitAll(this, ast.outputs);
|
|
template_ast_1.templateVisitAll(this, ast.exportAsVars);
|
|
for (var i = 0; i < ast.directives.length; i++) {
|
|
ast.directives[i].visit(this, i);
|
|
}
|
|
template_ast_1.templateVisitAll(this, ast.children);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitNgContent = function(ast, context) {
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitVariable = function(ast, context) {
|
|
this.variableNames.push(ast.name);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitEvent = function(ast, directiveRecord) {
|
|
var bindingRecord = lang_1.isPresent(directiveRecord) ? change_detection_1.BindingRecord.createForHostEvent(ast.handler, ast.fullName, directiveRecord) : change_detection_1.BindingRecord.createForEvent(ast.handler, ast.fullName, this.boundElementCount - 1);
|
|
this.eventRecords.push(bindingRecord);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitElementProperty = function(ast, directiveRecord) {
|
|
var boundElementIndex = this.boundElementCount - 1;
|
|
var dirIndex = lang_1.isPresent(directiveRecord) ? directiveRecord.directiveIndex : null;
|
|
var bindingRecord;
|
|
if (ast.type === template_ast_1.PropertyBindingType.Property) {
|
|
bindingRecord = lang_1.isPresent(dirIndex) ? change_detection_1.BindingRecord.createForHostProperty(dirIndex, ast.value, ast.name) : change_detection_1.BindingRecord.createForElementProperty(ast.value, boundElementIndex, ast.name);
|
|
} else if (ast.type === template_ast_1.PropertyBindingType.Attribute) {
|
|
bindingRecord = lang_1.isPresent(dirIndex) ? change_detection_1.BindingRecord.createForHostAttribute(dirIndex, ast.value, ast.name) : change_detection_1.BindingRecord.createForElementAttribute(ast.value, boundElementIndex, ast.name);
|
|
} else if (ast.type === template_ast_1.PropertyBindingType.Class) {
|
|
bindingRecord = lang_1.isPresent(dirIndex) ? change_detection_1.BindingRecord.createForHostClass(dirIndex, ast.value, ast.name) : change_detection_1.BindingRecord.createForElementClass(ast.value, boundElementIndex, ast.name);
|
|
} else if (ast.type === template_ast_1.PropertyBindingType.Style) {
|
|
bindingRecord = lang_1.isPresent(dirIndex) ? change_detection_1.BindingRecord.createForHostStyle(dirIndex, ast.value, ast.name, ast.unit) : change_detection_1.BindingRecord.createForElementStyle(ast.value, boundElementIndex, ast.name, ast.unit);
|
|
}
|
|
this.bindingRecords.push(bindingRecord);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitAttr = function(ast, context) {
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitBoundText = function(ast, context) {
|
|
var boundTextIndex = this.boundTextCount++;
|
|
this.bindingRecords.push(change_detection_1.BindingRecord.createForTextNode(ast.value, boundTextIndex));
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitText = function(ast, context) {
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitDirective = function(ast, directiveIndexAsNumber) {
|
|
var directiveIndex = new change_detection_1.DirectiveIndex(this.boundElementCount - 1, directiveIndexAsNumber);
|
|
var directiveMetadata = ast.directive;
|
|
var directiveRecord = new change_detection_1.DirectiveRecord({
|
|
directiveIndex: directiveIndex,
|
|
callAfterContentInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterContentInit) !== -1,
|
|
callAfterContentChecked: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterContentChecked) !== -1,
|
|
callAfterViewInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterViewInit) !== -1,
|
|
callAfterViewChecked: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.AfterViewChecked) !== -1,
|
|
callOnChanges: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.OnChanges) !== -1,
|
|
callDoCheck: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.DoCheck) !== -1,
|
|
callOnInit: directiveMetadata.lifecycleHooks.indexOf(interfaces_1.LifecycleHooks.OnInit) !== -1,
|
|
changeDetection: directiveMetadata.changeDetection
|
|
});
|
|
this.directiveRecords.push(directiveRecord);
|
|
template_ast_1.templateVisitAll(this, ast.inputs, directiveRecord);
|
|
var bindingRecords = this.bindingRecords;
|
|
if (directiveRecord.callOnChanges) {
|
|
bindingRecords.push(change_detection_1.BindingRecord.createDirectiveOnChanges(directiveRecord));
|
|
}
|
|
if (directiveRecord.callOnInit) {
|
|
bindingRecords.push(change_detection_1.BindingRecord.createDirectiveOnInit(directiveRecord));
|
|
}
|
|
if (directiveRecord.callDoCheck) {
|
|
bindingRecords.push(change_detection_1.BindingRecord.createDirectiveDoCheck(directiveRecord));
|
|
}
|
|
template_ast_1.templateVisitAll(this, ast.hostProperties, directiveRecord);
|
|
template_ast_1.templateVisitAll(this, ast.hostEvents, directiveRecord);
|
|
template_ast_1.templateVisitAll(this, ast.exportAsVars);
|
|
return null;
|
|
};
|
|
ProtoViewVisitor.prototype.visitDirectiveProperty = function(ast, directiveRecord) {
|
|
var setter = reflection_1.reflector.setter(ast.directiveName);
|
|
this.bindingRecords.push(change_detection_1.BindingRecord.createForDirective(ast.value, ast.directiveName, setter, directiveRecord));
|
|
return null;
|
|
};
|
|
return ProtoViewVisitor;
|
|
})();
|
|
function createChangeDefinitions(pvVisitors, componentType, genConfig) {
|
|
var pvVariableNames = _collectNestedProtoViewsVariableNames(pvVisitors);
|
|
return pvVisitors.map(function(pvVisitor) {
|
|
var id = componentType.name + "_" + pvVisitor.viewIndex;
|
|
return new change_detection_1.ChangeDetectorDefinition(id, pvVisitor.strategy, pvVariableNames[pvVisitor.viewIndex], pvVisitor.bindingRecords, pvVisitor.eventRecords, pvVisitor.directiveRecords, genConfig);
|
|
});
|
|
}
|
|
function _collectNestedProtoViewsVariableNames(pvVisitors) {
|
|
var nestedPvVariableNames = collection_1.ListWrapper.createFixedSize(pvVisitors.length);
|
|
pvVisitors.forEach(function(pv) {
|
|
var parentVariableNames = lang_1.isPresent(pv.parent) ? nestedPvVariableNames[pv.parent.viewIndex] : [];
|
|
nestedPvVariableNames[pv.viewIndex] = parentVariableNames.concat(pv.variableNames);
|
|
});
|
|
return nestedPvVariableNames;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("84", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Codegen = (function() {
|
|
function Codegen(moduleAlias) {}
|
|
Codegen.prototype.generate = function(typeName, changeDetectorTypeName, def) {
|
|
throw "Not implemented in JS";
|
|
};
|
|
Codegen.prototype.toString = function() {
|
|
throw "Not implemented in JS";
|
|
};
|
|
return Codegen;
|
|
})();
|
|
exports.Codegen = Codegen;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("67", ["66", "85", "83", "20", "6e", "84", "6d", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var source_module_1 = $__require('66');
|
|
var change_detection_jit_generator_1 = $__require('85');
|
|
var change_definition_factory_1 = $__require('83');
|
|
var lang_1 = $__require('20');
|
|
var change_detection_1 = $__require('6e');
|
|
var change_detector_codegen_1 = $__require('84');
|
|
var util_1 = $__require('6d');
|
|
var di_1 = $__require('39');
|
|
var ABSTRACT_CHANGE_DETECTOR = "AbstractChangeDetector";
|
|
var UTIL = "ChangeDetectionUtil";
|
|
var CHANGE_DETECTOR_STATE = "ChangeDetectorState";
|
|
var ABSTRACT_CHANGE_DETECTOR_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/abstract_change_detector" + util_1.MODULE_SUFFIX);
|
|
var UTIL_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/change_detection_util" + util_1.MODULE_SUFFIX);
|
|
var PREGEN_PROTO_CHANGE_DETECTOR_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/pregen_proto_change_detector" + util_1.MODULE_SUFFIX);
|
|
var CONSTANTS_MODULE = source_module_1.moduleRef("package:angular2/src/core/change_detection/constants" + util_1.MODULE_SUFFIX);
|
|
var ChangeDetectionCompiler = (function() {
|
|
function ChangeDetectionCompiler(_genConfig) {
|
|
this._genConfig = _genConfig;
|
|
}
|
|
ChangeDetectionCompiler.prototype.compileComponentRuntime = function(componentType, strategy, parsedTemplate) {
|
|
var _this = this;
|
|
var changeDetectorDefinitions = change_definition_factory_1.createChangeDetectorDefinitions(componentType, strategy, this._genConfig, parsedTemplate);
|
|
return changeDetectorDefinitions.map(function(definition) {
|
|
return _this._createChangeDetectorFactory(definition);
|
|
});
|
|
};
|
|
ChangeDetectionCompiler.prototype._createChangeDetectorFactory = function(definition) {
|
|
if (lang_1.IS_DART || !this._genConfig.useJit) {
|
|
var proto = new change_detection_1.DynamicProtoChangeDetector(definition);
|
|
return function(dispatcher) {
|
|
return proto.instantiate(dispatcher);
|
|
};
|
|
} else {
|
|
return new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, UTIL, ABSTRACT_CHANGE_DETECTOR, CHANGE_DETECTOR_STATE).generate();
|
|
}
|
|
};
|
|
ChangeDetectionCompiler.prototype.compileComponentCodeGen = function(componentType, strategy, parsedTemplate) {
|
|
var changeDetectorDefinitions = change_definition_factory_1.createChangeDetectorDefinitions(componentType, strategy, this._genConfig, parsedTemplate);
|
|
var factories = [];
|
|
var index = 0;
|
|
var sourceParts = changeDetectorDefinitions.map(function(definition) {
|
|
var codegen;
|
|
var sourcePart;
|
|
if (lang_1.IS_DART) {
|
|
codegen = new change_detector_codegen_1.Codegen(PREGEN_PROTO_CHANGE_DETECTOR_MODULE);
|
|
var className = "_" + definition.id;
|
|
var typeRef = (index === 0 && componentType.isHost) ? 'dynamic' : "" + source_module_1.moduleRef(componentType.moduleUrl) + componentType.name;
|
|
codegen.generate(typeRef, className, definition);
|
|
factories.push(className + ".newChangeDetector");
|
|
sourcePart = codegen.toString();
|
|
} else {
|
|
codegen = new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, "" + UTIL_MODULE + UTIL, "" + ABSTRACT_CHANGE_DETECTOR_MODULE + ABSTRACT_CHANGE_DETECTOR, "" + CONSTANTS_MODULE + CHANGE_DETECTOR_STATE);
|
|
factories.push("function(dispatcher) { return new " + codegen.typeName + "(dispatcher); }");
|
|
sourcePart = codegen.generateSource();
|
|
}
|
|
index++;
|
|
return sourcePart;
|
|
});
|
|
return new source_module_1.SourceExpressions(sourceParts, factories);
|
|
};
|
|
ChangeDetectionCompiler = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [change_detection_1.ChangeDetectorGenConfig])], ChangeDetectionCompiler);
|
|
return ChangeDetectionCompiler;
|
|
})();
|
|
exports.ChangeDetectionCompiler = ChangeDetectionCompiler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("86", ["37", "20", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var ShadowCss = (function() {
|
|
function ShadowCss() {
|
|
this.strictStyling = true;
|
|
}
|
|
ShadowCss.prototype.shimCssText = function(cssText, selector, hostSelector) {
|
|
if (hostSelector === void 0) {
|
|
hostSelector = '';
|
|
}
|
|
cssText = stripComments(cssText);
|
|
cssText = this._insertDirectives(cssText);
|
|
return this._scopeCssText(cssText, selector, hostSelector);
|
|
};
|
|
ShadowCss.prototype._insertDirectives = function(cssText) {
|
|
cssText = this._insertPolyfillDirectivesInCssText(cssText);
|
|
return this._insertPolyfillRulesInCssText(cssText);
|
|
};
|
|
ShadowCss.prototype._insertPolyfillDirectivesInCssText = function(cssText) {
|
|
return lang_1.StringWrapper.replaceAllMapped(cssText, _cssContentNextSelectorRe, function(m) {
|
|
return m[1] + '{';
|
|
});
|
|
};
|
|
ShadowCss.prototype._insertPolyfillRulesInCssText = function(cssText) {
|
|
return lang_1.StringWrapper.replaceAllMapped(cssText, _cssContentRuleRe, function(m) {
|
|
var rule = m[0];
|
|
rule = lang_1.StringWrapper.replace(rule, m[1], '');
|
|
rule = lang_1.StringWrapper.replace(rule, m[2], '');
|
|
return m[3] + rule;
|
|
});
|
|
};
|
|
ShadowCss.prototype._scopeCssText = function(cssText, scopeSelector, hostSelector) {
|
|
var unscoped = this._extractUnscopedRulesFromCssText(cssText);
|
|
cssText = this._insertPolyfillHostInCssText(cssText);
|
|
cssText = this._convertColonHost(cssText);
|
|
cssText = this._convertColonHostContext(cssText);
|
|
cssText = this._convertShadowDOMSelectors(cssText);
|
|
if (lang_1.isPresent(scopeSelector)) {
|
|
cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);
|
|
}
|
|
cssText = cssText + '\n' + unscoped;
|
|
return cssText.trim();
|
|
};
|
|
ShadowCss.prototype._extractUnscopedRulesFromCssText = function(cssText) {
|
|
var r = '',
|
|
m;
|
|
var matcher = lang_1.RegExpWrapper.matcher(_cssContentUnscopedRuleRe, cssText);
|
|
while (lang_1.isPresent(m = lang_1.RegExpMatcherWrapper.next(matcher))) {
|
|
var rule = m[0];
|
|
rule = lang_1.StringWrapper.replace(rule, m[2], '');
|
|
rule = lang_1.StringWrapper.replace(rule, m[1], m[3]);
|
|
r += rule + '\n\n';
|
|
}
|
|
return r;
|
|
};
|
|
ShadowCss.prototype._convertColonHost = function(cssText) {
|
|
return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
|
|
};
|
|
ShadowCss.prototype._convertColonHostContext = function(cssText) {
|
|
return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer);
|
|
};
|
|
ShadowCss.prototype._convertColonRule = function(cssText, regExp, partReplacer) {
|
|
return lang_1.StringWrapper.replaceAllMapped(cssText, regExp, function(m) {
|
|
if (lang_1.isPresent(m[2])) {
|
|
var parts = m[2].split(','),
|
|
r = [];
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var p = parts[i];
|
|
if (lang_1.isBlank(p))
|
|
break;
|
|
p = p.trim();
|
|
r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
|
|
}
|
|
return r.join(',');
|
|
} else {
|
|
return _polyfillHostNoCombinator + m[3];
|
|
}
|
|
});
|
|
};
|
|
ShadowCss.prototype._colonHostContextPartReplacer = function(host, part, suffix) {
|
|
if (lang_1.StringWrapper.contains(part, _polyfillHost)) {
|
|
return this._colonHostPartReplacer(host, part, suffix);
|
|
} else {
|
|
return host + part + suffix + ', ' + part + ' ' + host + suffix;
|
|
}
|
|
};
|
|
ShadowCss.prototype._colonHostPartReplacer = function(host, part, suffix) {
|
|
return host + lang_1.StringWrapper.replace(part, _polyfillHost, '') + suffix;
|
|
};
|
|
ShadowCss.prototype._convertShadowDOMSelectors = function(cssText) {
|
|
for (var i = 0; i < _shadowDOMSelectorsRe.length; i++) {
|
|
cssText = lang_1.StringWrapper.replaceAll(cssText, _shadowDOMSelectorsRe[i], ' ');
|
|
}
|
|
return cssText;
|
|
};
|
|
ShadowCss.prototype._scopeSelectors = function(cssText, scopeSelector, hostSelector) {
|
|
var _this = this;
|
|
return processRules(cssText, function(rule) {
|
|
var selector = rule.selector;
|
|
var content = rule.content;
|
|
if (rule.selector[0] != '@' || rule.selector.startsWith('@page')) {
|
|
selector = _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling);
|
|
} else if (rule.selector.startsWith('@media')) {
|
|
content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector);
|
|
}
|
|
return new CssRule(selector, content);
|
|
});
|
|
};
|
|
ShadowCss.prototype._scopeSelector = function(selector, scopeSelector, hostSelector, strict) {
|
|
var r = [],
|
|
parts = selector.split(',');
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var p = parts[i];
|
|
p = p.trim();
|
|
if (this._selectorNeedsScoping(p, scopeSelector)) {
|
|
p = strict && !lang_1.StringWrapper.contains(p, _polyfillHostNoCombinator) ? this._applyStrictSelectorScope(p, scopeSelector) : this._applySelectorScope(p, scopeSelector, hostSelector);
|
|
}
|
|
r.push(p);
|
|
}
|
|
return r.join(', ');
|
|
};
|
|
ShadowCss.prototype._selectorNeedsScoping = function(selector, scopeSelector) {
|
|
var re = this._makeScopeMatcher(scopeSelector);
|
|
return !lang_1.isPresent(lang_1.RegExpWrapper.firstMatch(re, selector));
|
|
};
|
|
ShadowCss.prototype._makeScopeMatcher = function(scopeSelector) {
|
|
var lre = /\[/g;
|
|
var rre = /\]/g;
|
|
scopeSelector = lang_1.StringWrapper.replaceAll(scopeSelector, lre, '\\[');
|
|
scopeSelector = lang_1.StringWrapper.replaceAll(scopeSelector, rre, '\\]');
|
|
return lang_1.RegExpWrapper.create('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
|
|
};
|
|
ShadowCss.prototype._applySelectorScope = function(selector, scopeSelector, hostSelector) {
|
|
return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
|
|
};
|
|
ShadowCss.prototype._applySimpleSelectorScope = function(selector, scopeSelector, hostSelector) {
|
|
if (lang_1.isPresent(lang_1.RegExpWrapper.firstMatch(_polyfillHostRe, selector))) {
|
|
var replaceBy = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector;
|
|
selector = lang_1.StringWrapper.replace(selector, _polyfillHostNoCombinator, replaceBy);
|
|
return lang_1.StringWrapper.replaceAll(selector, _polyfillHostRe, replaceBy + ' ');
|
|
} else {
|
|
return scopeSelector + ' ' + selector;
|
|
}
|
|
};
|
|
ShadowCss.prototype._applyStrictSelectorScope = function(selector, scopeSelector) {
|
|
var isRe = /\[is=([^\]]*)\]/g;
|
|
scopeSelector = lang_1.StringWrapper.replaceAllMapped(scopeSelector, isRe, function(m) {
|
|
return m[1];
|
|
});
|
|
var splits = [' ', '>', '+', '~'],
|
|
scoped = selector,
|
|
attrName = '[' + scopeSelector + ']';
|
|
for (var i = 0; i < splits.length; i++) {
|
|
var sep = splits[i];
|
|
var parts = scoped.split(sep);
|
|
scoped = parts.map(function(p) {
|
|
var t = lang_1.StringWrapper.replaceAll(p.trim(), _polyfillHostRe, '');
|
|
if (t.length > 0 && !collection_1.ListWrapper.contains(splits, t) && !lang_1.StringWrapper.contains(t, attrName)) {
|
|
var re = /([^:]*)(:*)(.*)/g;
|
|
var m = lang_1.RegExpWrapper.firstMatch(re, t);
|
|
if (lang_1.isPresent(m)) {
|
|
p = m[1] + attrName + m[2] + m[3];
|
|
}
|
|
}
|
|
return p;
|
|
}).join(sep);
|
|
}
|
|
return scoped;
|
|
};
|
|
ShadowCss.prototype._insertPolyfillHostInCssText = function(selector) {
|
|
selector = lang_1.StringWrapper.replaceAll(selector, _colonHostContextRe, _polyfillHostContext);
|
|
selector = lang_1.StringWrapper.replaceAll(selector, _colonHostRe, _polyfillHost);
|
|
return selector;
|
|
};
|
|
return ShadowCss;
|
|
})();
|
|
exports.ShadowCss = ShadowCss;
|
|
var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim;
|
|
var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim;
|
|
var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim;
|
|
var _polyfillHost = '-shadowcsshost';
|
|
var _polyfillHostContext = '-shadowcsscontext';
|
|
var _parenSuffix = ')(?:\\((' + '(?:\\([^)(]*\\)|[^)(]*)+?' + ')\\))?([^,{]*)';
|
|
var _cssColonHostRe = lang_1.RegExpWrapper.create('(' + _polyfillHost + _parenSuffix, 'im');
|
|
var _cssColonHostContextRe = lang_1.RegExpWrapper.create('(' + _polyfillHostContext + _parenSuffix, 'im');
|
|
var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
|
|
var _shadowDOMSelectorsRe = [/>>>/g, /::shadow/g, /::content/g, /\/deep\//g, /\/shadow-deep\//g, /\/shadow\//g];
|
|
var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$';
|
|
var _polyfillHostRe = lang_1.RegExpWrapper.create(_polyfillHost, 'im');
|
|
var _colonHostRe = /:host/gim;
|
|
var _colonHostContextRe = /:host-context/gim;
|
|
var _commentRe = /\/\*[\s\S]*?\*\//g;
|
|
function stripComments(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, _commentRe, function(_) {
|
|
return '';
|
|
});
|
|
}
|
|
var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
|
|
var _curlyRe = /([{}])/g;
|
|
var OPEN_CURLY = '{';
|
|
var CLOSE_CURLY = '}';
|
|
var BLOCK_PLACEHOLDER = '%BLOCK%';
|
|
var CssRule = (function() {
|
|
function CssRule(selector, content) {
|
|
this.selector = selector;
|
|
this.content = content;
|
|
}
|
|
return CssRule;
|
|
})();
|
|
exports.CssRule = CssRule;
|
|
function processRules(input, ruleCallback) {
|
|
var inputWithEscapedBlocks = escapeBlocks(input);
|
|
var nextBlockIndex = 0;
|
|
return lang_1.StringWrapper.replaceAllMapped(inputWithEscapedBlocks.escapedString, _ruleRe, function(m) {
|
|
var selector = m[2];
|
|
var content = '';
|
|
var suffix = m[4];
|
|
var contentPrefix = '';
|
|
if (lang_1.isPresent(m[4]) && m[4].startsWith('{' + BLOCK_PLACEHOLDER)) {
|
|
content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
|
|
suffix = m[4].substring(BLOCK_PLACEHOLDER.length + 1);
|
|
contentPrefix = '{';
|
|
}
|
|
var rule = ruleCallback(new CssRule(selector, content));
|
|
return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix;
|
|
});
|
|
}
|
|
exports.processRules = processRules;
|
|
var StringWithEscapedBlocks = (function() {
|
|
function StringWithEscapedBlocks(escapedString, blocks) {
|
|
this.escapedString = escapedString;
|
|
this.blocks = blocks;
|
|
}
|
|
return StringWithEscapedBlocks;
|
|
})();
|
|
function escapeBlocks(input) {
|
|
var inputParts = lang_1.StringWrapper.split(input, _curlyRe);
|
|
var resultParts = [];
|
|
var escapedBlocks = [];
|
|
var bracketCount = 0;
|
|
var currentBlockParts = [];
|
|
for (var partIndex = 0; partIndex < inputParts.length; partIndex++) {
|
|
var part = inputParts[partIndex];
|
|
if (part == CLOSE_CURLY) {
|
|
bracketCount--;
|
|
}
|
|
if (bracketCount > 0) {
|
|
currentBlockParts.push(part);
|
|
} else {
|
|
if (currentBlockParts.length > 0) {
|
|
escapedBlocks.push(currentBlockParts.join(''));
|
|
resultParts.push(BLOCK_PLACEHOLDER);
|
|
currentBlockParts = [];
|
|
}
|
|
resultParts.push(part);
|
|
}
|
|
if (part == OPEN_CURLY) {
|
|
bracketCount++;
|
|
}
|
|
}
|
|
if (currentBlockParts.length > 0) {
|
|
escapedBlocks.push(currentBlockParts.join(''));
|
|
resultParts.push(BLOCK_PLACEHOLDER);
|
|
}
|
|
return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("76", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var StyleWithImports = (function() {
|
|
function StyleWithImports(style, styleUrls) {
|
|
this.style = style;
|
|
this.styleUrls = styleUrls;
|
|
}
|
|
return StyleWithImports;
|
|
})();
|
|
exports.StyleWithImports = StyleWithImports;
|
|
function isStyleUrlResolvable(url) {
|
|
if (lang_1.isBlank(url) || url.length === 0 || url[0] == '/')
|
|
return false;
|
|
var schemeMatch = lang_1.RegExpWrapper.firstMatch(_urlWithSchemaRe, url);
|
|
return lang_1.isBlank(schemeMatch) || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
|
|
}
|
|
exports.isStyleUrlResolvable = isStyleUrlResolvable;
|
|
function extractStyleUrls(resolver, baseUrl, cssText) {
|
|
var foundUrls = [];
|
|
var modifiedCssText = lang_1.StringWrapper.replaceAllMapped(cssText, _cssImportRe, function(m) {
|
|
var url = lang_1.isPresent(m[1]) ? m[1] : m[2];
|
|
if (!isStyleUrlResolvable(url)) {
|
|
return m[0];
|
|
}
|
|
foundUrls.push(resolver.resolve(baseUrl, url));
|
|
return '';
|
|
});
|
|
return new StyleWithImports(modifiedCssText, foundUrls);
|
|
}
|
|
exports.extractStyleUrls = extractStyleUrls;
|
|
var _cssImportRe = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
|
|
var _urlWithSchemaRe = /^([a-zA-Z\-\+\.]+):/g;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4f", ["3c", "37", "20", "56"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var api_1 = $__require('56');
|
|
var DefaultProtoViewRef = (function(_super) {
|
|
__extends(DefaultProtoViewRef, _super);
|
|
function DefaultProtoViewRef(template, cmds) {
|
|
_super.call(this);
|
|
this.template = template;
|
|
this.cmds = cmds;
|
|
}
|
|
return DefaultProtoViewRef;
|
|
})(api_1.RenderProtoViewRef);
|
|
exports.DefaultProtoViewRef = DefaultProtoViewRef;
|
|
var DefaultRenderFragmentRef = (function(_super) {
|
|
__extends(DefaultRenderFragmentRef, _super);
|
|
function DefaultRenderFragmentRef(nodes) {
|
|
_super.call(this);
|
|
this.nodes = nodes;
|
|
}
|
|
return DefaultRenderFragmentRef;
|
|
})(api_1.RenderFragmentRef);
|
|
exports.DefaultRenderFragmentRef = DefaultRenderFragmentRef;
|
|
var DefaultRenderView = (function(_super) {
|
|
__extends(DefaultRenderView, _super);
|
|
function DefaultRenderView(fragments, boundTextNodes, boundElements, nativeShadowRoots, globalEventAdders, rootContentInsertionPoints) {
|
|
_super.call(this);
|
|
this.fragments = fragments;
|
|
this.boundTextNodes = boundTextNodes;
|
|
this.boundElements = boundElements;
|
|
this.nativeShadowRoots = nativeShadowRoots;
|
|
this.globalEventAdders = globalEventAdders;
|
|
this.rootContentInsertionPoints = rootContentInsertionPoints;
|
|
this.hydrated = false;
|
|
this.eventDispatcher = null;
|
|
this.globalEventRemovers = null;
|
|
}
|
|
DefaultRenderView.prototype.hydrate = function() {
|
|
if (this.hydrated)
|
|
throw new exceptions_1.BaseException('The view is already hydrated.');
|
|
this.hydrated = true;
|
|
this.globalEventRemovers = collection_1.ListWrapper.createFixedSize(this.globalEventAdders.length);
|
|
for (var i = 0; i < this.globalEventAdders.length; i++) {
|
|
this.globalEventRemovers[i] = this.globalEventAdders[i]();
|
|
}
|
|
};
|
|
DefaultRenderView.prototype.dehydrate = function() {
|
|
if (!this.hydrated)
|
|
throw new exceptions_1.BaseException('The view is already dehydrated.');
|
|
for (var i = 0; i < this.globalEventRemovers.length; i++) {
|
|
this.globalEventRemovers[i]();
|
|
}
|
|
this.globalEventRemovers = null;
|
|
this.hydrated = false;
|
|
};
|
|
DefaultRenderView.prototype.setEventDispatcher = function(dispatcher) {
|
|
this.eventDispatcher = dispatcher;
|
|
};
|
|
DefaultRenderView.prototype.dispatchRenderEvent = function(boundElementIndex, eventName, event) {
|
|
var allowDefaultBehavior = true;
|
|
if (lang_1.isPresent(this.eventDispatcher)) {
|
|
var locals = new collection_1.Map();
|
|
locals.set('$event', event);
|
|
allowDefaultBehavior = this.eventDispatcher.dispatchRenderEvent(boundElementIndex, eventName, locals);
|
|
}
|
|
return allowDefaultBehavior;
|
|
};
|
|
return DefaultRenderView;
|
|
})(api_1.RenderViewRef);
|
|
exports.DefaultRenderView = DefaultRenderView;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4e", ["20", "4f", "50", "37", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var lang_1 = $__require('20');
|
|
var view_1 = $__require('4f');
|
|
var metadata_1 = $__require('50');
|
|
var collection_1 = $__require('37');
|
|
function encapsulateStyles(componentTemplate) {
|
|
var processedStyles = componentTemplate.styles;
|
|
if (componentTemplate.encapsulation === metadata_1.ViewEncapsulation.Emulated) {
|
|
processedStyles = collection_1.ListWrapper.createFixedSize(componentTemplate.styles.length);
|
|
for (var i = 0; i < componentTemplate.styles.length; i++) {
|
|
processedStyles[i] = lang_1.StringWrapper.replaceAll(componentTemplate.styles[i], COMPONENT_REGEX, componentTemplate.shortId);
|
|
}
|
|
}
|
|
return processedStyles;
|
|
}
|
|
exports.encapsulateStyles = encapsulateStyles;
|
|
function createRenderView(componentTemplate, cmds, inplaceElement, nodeFactory) {
|
|
var view;
|
|
var eventDispatcher = function(boundElementIndex, eventName, event) {
|
|
return view.dispatchRenderEvent(boundElementIndex, eventName, event);
|
|
};
|
|
var context = new BuildContext(eventDispatcher, nodeFactory, inplaceElement);
|
|
context.build(componentTemplate, cmds);
|
|
var fragments = [];
|
|
for (var i = 0; i < context.fragments.length; i++) {
|
|
fragments.push(new view_1.DefaultRenderFragmentRef(context.fragments[i]));
|
|
}
|
|
view = new view_1.DefaultRenderView(fragments, context.boundTextNodes, context.boundElements, context.nativeShadowRoots, context.globalEventAdders, context.rootContentInsertionPoints);
|
|
return view;
|
|
}
|
|
exports.createRenderView = createRenderView;
|
|
var BuildContext = (function() {
|
|
function BuildContext(_eventDispatcher, factory, _inplaceElement) {
|
|
this._eventDispatcher = _eventDispatcher;
|
|
this.factory = factory;
|
|
this._inplaceElement = _inplaceElement;
|
|
this._builders = [];
|
|
this.globalEventAdders = [];
|
|
this.boundElements = [];
|
|
this.boundTextNodes = [];
|
|
this.nativeShadowRoots = [];
|
|
this.fragments = [];
|
|
this.rootContentInsertionPoints = [];
|
|
this.componentCount = 0;
|
|
this.isHost = lang_1.isPresent((_inplaceElement));
|
|
}
|
|
BuildContext.prototype.build = function(template, cmds) {
|
|
this.enqueueRootBuilder(template, cmds);
|
|
this._build(this._builders[0]);
|
|
};
|
|
BuildContext.prototype._build = function(builder) {
|
|
this._builders = [];
|
|
builder.build(this);
|
|
var enqueuedBuilders = this._builders;
|
|
for (var i = 0; i < enqueuedBuilders.length; i++) {
|
|
this._build(enqueuedBuilders[i]);
|
|
}
|
|
};
|
|
BuildContext.prototype.enqueueComponentBuilder = function(component) {
|
|
this.componentCount++;
|
|
this._builders.push(new RenderViewBuilder(component, null, component.template, component.template.commands));
|
|
};
|
|
BuildContext.prototype.enqueueFragmentBuilder = function(parentComponent, parentTemplate, commands) {
|
|
var rootNodes = [];
|
|
this.fragments.push(rootNodes);
|
|
this._builders.push(new RenderViewBuilder(parentComponent, rootNodes, parentTemplate, commands));
|
|
};
|
|
BuildContext.prototype.enqueueRootBuilder = function(template, cmds) {
|
|
var rootNodes = [];
|
|
this.fragments.push(rootNodes);
|
|
this._builders.push(new RenderViewBuilder(null, rootNodes, template, cmds));
|
|
};
|
|
BuildContext.prototype.consumeInplaceElement = function() {
|
|
var result = this._inplaceElement;
|
|
this._inplaceElement = null;
|
|
return result;
|
|
};
|
|
BuildContext.prototype.addEventListener = function(boundElementIndex, target, eventName) {
|
|
if (lang_1.isPresent(target)) {
|
|
var handler = createEventHandler(boundElementIndex, target + ":" + eventName, this._eventDispatcher);
|
|
this.globalEventAdders.push(createGlobalEventAdder(target, eventName, handler, this.factory));
|
|
} else {
|
|
var handler = createEventHandler(boundElementIndex, eventName, this._eventDispatcher);
|
|
this.factory.on(this.boundElements[boundElementIndex], eventName, handler);
|
|
}
|
|
};
|
|
return BuildContext;
|
|
})();
|
|
function createEventHandler(boundElementIndex, eventName, eventDispatcher) {
|
|
return function($event) {
|
|
return eventDispatcher(boundElementIndex, eventName, $event);
|
|
};
|
|
}
|
|
function createGlobalEventAdder(target, eventName, eventHandler, nodeFactory) {
|
|
return function() {
|
|
return nodeFactory.globalOn(target, eventName, eventHandler);
|
|
};
|
|
}
|
|
var RenderViewBuilder = (function() {
|
|
function RenderViewBuilder(parentComponent, fragmentRootNodes, template, cmds) {
|
|
this.parentComponent = parentComponent;
|
|
this.fragmentRootNodes = fragmentRootNodes;
|
|
this.template = template;
|
|
this.cmds = cmds;
|
|
var rootNodesParent = lang_1.isPresent(fragmentRootNodes) ? null : parentComponent.shadowRoot;
|
|
this.parentStack = [rootNodesParent];
|
|
}
|
|
RenderViewBuilder.prototype.build = function(context) {
|
|
var cmds = this.cmds;
|
|
for (var i = 0; i < cmds.length; i++) {
|
|
cmds[i].visit(this, context);
|
|
}
|
|
};
|
|
Object.defineProperty(RenderViewBuilder.prototype, "parent", {
|
|
get: function() {
|
|
return this.parentStack[this.parentStack.length - 1];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
RenderViewBuilder.prototype.visitText = function(cmd, context) {
|
|
var text = context.factory.createText(cmd.value);
|
|
this._addChild(text, cmd.ngContentIndex, context);
|
|
if (cmd.isBound) {
|
|
context.boundTextNodes.push(text);
|
|
}
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitNgContent = function(cmd, context) {
|
|
if (lang_1.isPresent(this.parentComponent)) {
|
|
if (this.parentComponent.isRoot) {
|
|
var insertionPoint = context.factory.createRootContentInsertionPoint();
|
|
if (this.parent instanceof Component) {
|
|
context.factory.appendChild(this.parent.shadowRoot, insertionPoint);
|
|
} else {
|
|
context.factory.appendChild(this.parent, insertionPoint);
|
|
}
|
|
context.rootContentInsertionPoints.push(insertionPoint);
|
|
} else {
|
|
var projectedNodes = this.parentComponent.project(cmd.index);
|
|
for (var i = 0; i < projectedNodes.length; i++) {
|
|
var node = projectedNodes[i];
|
|
this._addChild(node, cmd.ngContentIndex, context);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitBeginElement = function(cmd, context) {
|
|
this.parentStack.push(this._beginElement(cmd, context, null));
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitEndElement = function(context) {
|
|
this._endElement();
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitBeginComponent = function(cmd, context) {
|
|
var templateId = cmd.templateId;
|
|
var tpl = context.factory.resolveComponentTemplate(templateId);
|
|
var el = this._beginElement(cmd, context, tpl);
|
|
var root = el;
|
|
if (tpl.encapsulation === metadata_1.ViewEncapsulation.Native) {
|
|
root = context.factory.createShadowRoot(el, templateId);
|
|
context.nativeShadowRoots.push(root);
|
|
}
|
|
var isRoot = context.componentCount === 0 && context.isHost;
|
|
var component = new Component(el, root, isRoot, tpl);
|
|
context.enqueueComponentBuilder(component);
|
|
this.parentStack.push(component);
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitEndComponent = function(context) {
|
|
this._endElement();
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype.visitEmbeddedTemplate = function(cmd, context) {
|
|
var el = context.factory.createTemplateAnchor(cmd.attrNameAndValues);
|
|
this._addChild(el, cmd.ngContentIndex, context);
|
|
context.boundElements.push(el);
|
|
if (cmd.isMerged) {
|
|
context.enqueueFragmentBuilder(this.parentComponent, this.template, cmd.children);
|
|
}
|
|
return null;
|
|
};
|
|
RenderViewBuilder.prototype._beginElement = function(cmd, context, componentTemplate) {
|
|
var el = context.consumeInplaceElement();
|
|
var attrNameAndValues = cmd.attrNameAndValues;
|
|
var templateEmulatedEncapsulation = this.template.encapsulation === metadata_1.ViewEncapsulation.Emulated;
|
|
var componentEmulatedEncapsulation = lang_1.isPresent(componentTemplate) && componentTemplate.encapsulation === metadata_1.ViewEncapsulation.Emulated;
|
|
var newAttrLength = attrNameAndValues.length + (templateEmulatedEncapsulation ? 2 : 0) + (componentEmulatedEncapsulation ? 2 : 0);
|
|
if (newAttrLength > attrNameAndValues.length) {
|
|
var newAttrNameAndValues = collection_1.ListWrapper.createFixedSize(newAttrLength);
|
|
var attrIndex;
|
|
for (attrIndex = 0; attrIndex < attrNameAndValues.length; attrIndex++) {
|
|
newAttrNameAndValues[attrIndex] = attrNameAndValues[attrIndex];
|
|
}
|
|
if (templateEmulatedEncapsulation) {
|
|
newAttrNameAndValues[attrIndex++] = _shimContentAttribute(this.template.shortId);
|
|
newAttrNameAndValues[attrIndex++] = '';
|
|
}
|
|
if (componentEmulatedEncapsulation) {
|
|
newAttrNameAndValues[attrIndex++] = _shimHostAttribute(componentTemplate.shortId);
|
|
newAttrNameAndValues[attrIndex++] = '';
|
|
}
|
|
attrNameAndValues = newAttrNameAndValues;
|
|
}
|
|
if (lang_1.isPresent(el)) {
|
|
context.factory.mergeElement(el, attrNameAndValues);
|
|
this.fragmentRootNodes.push(el);
|
|
} else {
|
|
el = context.factory.createElement(cmd.name, attrNameAndValues);
|
|
this._addChild(el, cmd.ngContentIndex, context);
|
|
}
|
|
if (cmd.isBound) {
|
|
var boundElementIndex = context.boundElements.length;
|
|
context.boundElements.push(el);
|
|
for (var i = 0; i < cmd.eventTargetAndNames.length; i += 2) {
|
|
var target = cmd.eventTargetAndNames[i];
|
|
var eventName = cmd.eventTargetAndNames[i + 1];
|
|
context.addEventListener(boundElementIndex, target, eventName);
|
|
}
|
|
}
|
|
return el;
|
|
};
|
|
RenderViewBuilder.prototype._endElement = function() {
|
|
this.parentStack.pop();
|
|
};
|
|
RenderViewBuilder.prototype._addChild = function(node, ngContentIndex, context) {
|
|
var parent = this.parent;
|
|
if (lang_1.isPresent(parent)) {
|
|
if (parent instanceof Component) {
|
|
parent.addContentNode(ngContentIndex, node, context);
|
|
} else {
|
|
context.factory.appendChild(parent, node);
|
|
}
|
|
} else {
|
|
this.fragmentRootNodes.push(node);
|
|
}
|
|
};
|
|
return RenderViewBuilder;
|
|
})();
|
|
var Component = (function() {
|
|
function Component(hostElement, shadowRoot, isRoot, template) {
|
|
this.hostElement = hostElement;
|
|
this.shadowRoot = shadowRoot;
|
|
this.isRoot = isRoot;
|
|
this.template = template;
|
|
this.contentNodesByNgContentIndex = [];
|
|
}
|
|
Component.prototype.addContentNode = function(ngContentIndex, node, context) {
|
|
if (lang_1.isBlank(ngContentIndex)) {
|
|
if (this.template.encapsulation === metadata_1.ViewEncapsulation.Native) {
|
|
context.factory.appendChild(this.hostElement, node);
|
|
}
|
|
} else {
|
|
while (this.contentNodesByNgContentIndex.length <= ngContentIndex) {
|
|
this.contentNodesByNgContentIndex.push([]);
|
|
}
|
|
this.contentNodesByNgContentIndex[ngContentIndex].push(node);
|
|
}
|
|
};
|
|
Component.prototype.project = function(ngContentIndex) {
|
|
return ngContentIndex < this.contentNodesByNgContentIndex.length ? this.contentNodesByNgContentIndex[ngContentIndex] : [];
|
|
};
|
|
return Component;
|
|
})();
|
|
var COMPONENT_REGEX = /%COMP%/g;
|
|
exports.COMPONENT_VARIABLE = '%COMP%';
|
|
exports.HOST_ATTR = "_nghost-" + exports.COMPONENT_VARIABLE;
|
|
exports.CONTENT_ATTR = "_ngcontent-" + exports.COMPONENT_VARIABLE;
|
|
function _shimContentAttribute(componentShortId) {
|
|
return lang_1.StringWrapper.replaceAll(exports.CONTENT_ATTR, COMPONENT_REGEX, componentShortId);
|
|
}
|
|
function _shimHostAttribute(componentShortId) {
|
|
return lang_1.StringWrapper.replaceAll(exports.HOST_ATTR, COMPONENT_REGEX, componentShortId);
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("68", ["66", "7b", "79", "20", "63", "86", "7a", "76", "6d", "39", "4e"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var source_module_1 = $__require('66');
|
|
var view_1 = $__require('7b');
|
|
var xhr_1 = $__require('79');
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var shadow_css_1 = $__require('86');
|
|
var url_resolver_1 = $__require('7a');
|
|
var style_url_resolver_1 = $__require('76');
|
|
var util_1 = $__require('6d');
|
|
var di_1 = $__require('39');
|
|
var view_factory_1 = $__require('4e');
|
|
var StyleCompiler = (function() {
|
|
function StyleCompiler(_xhr, _urlResolver) {
|
|
this._xhr = _xhr;
|
|
this._urlResolver = _urlResolver;
|
|
this._styleCache = new Map();
|
|
this._shadowCss = new shadow_css_1.ShadowCss();
|
|
}
|
|
StyleCompiler.prototype.compileComponentRuntime = function(template) {
|
|
var styles = template.styles;
|
|
var styleAbsUrls = template.styleUrls;
|
|
return this._loadStyles(styles, styleAbsUrls, template.encapsulation === view_1.ViewEncapsulation.Emulated);
|
|
};
|
|
StyleCompiler.prototype.compileComponentCodeGen = function(template) {
|
|
var shim = template.encapsulation === view_1.ViewEncapsulation.Emulated;
|
|
return this._styleCodeGen(template.styles, template.styleUrls, shim);
|
|
};
|
|
StyleCompiler.prototype.compileStylesheetCodeGen = function(stylesheetUrl, cssText) {
|
|
var styleWithImports = style_url_resolver_1.extractStyleUrls(this._urlResolver, stylesheetUrl, cssText);
|
|
return [this._styleModule(stylesheetUrl, false, this._styleCodeGen([styleWithImports.style], styleWithImports.styleUrls, false)), this._styleModule(stylesheetUrl, true, this._styleCodeGen([styleWithImports.style], styleWithImports.styleUrls, true))];
|
|
};
|
|
StyleCompiler.prototype.clearCache = function() {
|
|
this._styleCache.clear();
|
|
};
|
|
StyleCompiler.prototype._loadStyles = function(plainStyles, absUrls, encapsulate) {
|
|
var _this = this;
|
|
var promises = absUrls.map(function(absUrl) {
|
|
var cacheKey = "" + absUrl + (encapsulate ? '.shim' : '');
|
|
var result = _this._styleCache.get(cacheKey);
|
|
if (lang_1.isBlank(result)) {
|
|
result = _this._xhr.get(absUrl).then(function(style) {
|
|
var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, absUrl, style);
|
|
return _this._loadStyles([styleWithImports.style], styleWithImports.styleUrls, encapsulate);
|
|
});
|
|
_this._styleCache.set(cacheKey, result);
|
|
}
|
|
return result;
|
|
});
|
|
return async_1.PromiseWrapper.all(promises).then(function(nestedStyles) {
|
|
var result = plainStyles.map(function(plainStyle) {
|
|
return _this._shimIfNeeded(plainStyle, encapsulate);
|
|
});
|
|
nestedStyles.forEach(function(styles) {
|
|
return result.push(styles);
|
|
});
|
|
return result;
|
|
});
|
|
};
|
|
StyleCompiler.prototype._styleCodeGen = function(plainStyles, absUrls, shim) {
|
|
var _this = this;
|
|
var arrayPrefix = lang_1.IS_DART ? "const" : '';
|
|
var styleExpressions = plainStyles.map(function(plainStyle) {
|
|
return util_1.escapeSingleQuoteString(_this._shimIfNeeded(plainStyle, shim));
|
|
});
|
|
for (var i = 0; i < absUrls.length; i++) {
|
|
var moduleUrl = this._createModuleUrl(absUrls[i], shim);
|
|
styleExpressions.push(source_module_1.moduleRef(moduleUrl) + "STYLES");
|
|
}
|
|
var expressionSource = arrayPrefix + " [" + styleExpressions.join(',') + "]";
|
|
return new source_module_1.SourceExpression([], expressionSource);
|
|
};
|
|
StyleCompiler.prototype._styleModule = function(stylesheetUrl, shim, expression) {
|
|
var moduleSource = "\n " + expression.declarations.join('\n') + "\n " + util_1.codeGenExportVariable('STYLES') + expression.expression + ";\n ";
|
|
return new source_module_1.SourceModule(this._createModuleUrl(stylesheetUrl, shim), moduleSource);
|
|
};
|
|
StyleCompiler.prototype._shimIfNeeded = function(style, shim) {
|
|
return shim ? this._shadowCss.shimCssText(style, view_factory_1.CONTENT_ATTR, view_factory_1.HOST_ATTR) : style;
|
|
};
|
|
StyleCompiler.prototype._createModuleUrl = function(stylesheetUrl, shim) {
|
|
return shim ? stylesheetUrl + ".shim" + util_1.MODULE_SUFFIX : "" + stylesheetUrl + util_1.MODULE_SUFFIX;
|
|
};
|
|
StyleCompiler = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [xhr_1.XHR, url_resolver_1.UrlResolver])], StyleCompiler);
|
|
return StyleCompiler;
|
|
})();
|
|
exports.StyleCompiler = StyleCompiler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("72", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var TextAst = (function() {
|
|
function TextAst(value, ngContentIndex, sourceSpan) {
|
|
this.value = value;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
TextAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitText(this, context);
|
|
};
|
|
return TextAst;
|
|
})();
|
|
exports.TextAst = TextAst;
|
|
var BoundTextAst = (function() {
|
|
function BoundTextAst(value, ngContentIndex, sourceSpan) {
|
|
this.value = value;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
BoundTextAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitBoundText(this, context);
|
|
};
|
|
return BoundTextAst;
|
|
})();
|
|
exports.BoundTextAst = BoundTextAst;
|
|
var AttrAst = (function() {
|
|
function AttrAst(name, value, sourceSpan) {
|
|
this.name = name;
|
|
this.value = value;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
AttrAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitAttr(this, context);
|
|
};
|
|
return AttrAst;
|
|
})();
|
|
exports.AttrAst = AttrAst;
|
|
var BoundElementPropertyAst = (function() {
|
|
function BoundElementPropertyAst(name, type, value, unit, sourceSpan) {
|
|
this.name = name;
|
|
this.type = type;
|
|
this.value = value;
|
|
this.unit = unit;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
BoundElementPropertyAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitElementProperty(this, context);
|
|
};
|
|
return BoundElementPropertyAst;
|
|
})();
|
|
exports.BoundElementPropertyAst = BoundElementPropertyAst;
|
|
var BoundEventAst = (function() {
|
|
function BoundEventAst(name, target, handler, sourceSpan) {
|
|
this.name = name;
|
|
this.target = target;
|
|
this.handler = handler;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
BoundEventAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitEvent(this, context);
|
|
};
|
|
Object.defineProperty(BoundEventAst.prototype, "fullName", {
|
|
get: function() {
|
|
if (lang_1.isPresent(this.target)) {
|
|
return this.target + ":" + this.name;
|
|
} else {
|
|
return this.name;
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return BoundEventAst;
|
|
})();
|
|
exports.BoundEventAst = BoundEventAst;
|
|
var VariableAst = (function() {
|
|
function VariableAst(name, value, sourceSpan) {
|
|
this.name = name;
|
|
this.value = value;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
VariableAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitVariable(this, context);
|
|
};
|
|
return VariableAst;
|
|
})();
|
|
exports.VariableAst = VariableAst;
|
|
var ElementAst = (function() {
|
|
function ElementAst(name, attrs, inputs, outputs, exportAsVars, directives, children, ngContentIndex, sourceSpan) {
|
|
this.name = name;
|
|
this.attrs = attrs;
|
|
this.inputs = inputs;
|
|
this.outputs = outputs;
|
|
this.exportAsVars = exportAsVars;
|
|
this.directives = directives;
|
|
this.children = children;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
ElementAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitElement(this, context);
|
|
};
|
|
ElementAst.prototype.isBound = function() {
|
|
return (this.inputs.length > 0 || this.outputs.length > 0 || this.exportAsVars.length > 0 || this.directives.length > 0);
|
|
};
|
|
ElementAst.prototype.getComponent = function() {
|
|
return this.directives.length > 0 && this.directives[0].directive.isComponent ? this.directives[0].directive : null;
|
|
};
|
|
return ElementAst;
|
|
})();
|
|
exports.ElementAst = ElementAst;
|
|
var EmbeddedTemplateAst = (function() {
|
|
function EmbeddedTemplateAst(attrs, outputs, vars, directives, children, ngContentIndex, sourceSpan) {
|
|
this.attrs = attrs;
|
|
this.outputs = outputs;
|
|
this.vars = vars;
|
|
this.directives = directives;
|
|
this.children = children;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
EmbeddedTemplateAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitEmbeddedTemplate(this, context);
|
|
};
|
|
return EmbeddedTemplateAst;
|
|
})();
|
|
exports.EmbeddedTemplateAst = EmbeddedTemplateAst;
|
|
var BoundDirectivePropertyAst = (function() {
|
|
function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
|
|
this.directiveName = directiveName;
|
|
this.templateName = templateName;
|
|
this.value = value;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
BoundDirectivePropertyAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitDirectiveProperty(this, context);
|
|
};
|
|
return BoundDirectivePropertyAst;
|
|
})();
|
|
exports.BoundDirectivePropertyAst = BoundDirectivePropertyAst;
|
|
var DirectiveAst = (function() {
|
|
function DirectiveAst(directive, inputs, hostProperties, hostEvents, exportAsVars, sourceSpan) {
|
|
this.directive = directive;
|
|
this.inputs = inputs;
|
|
this.hostProperties = hostProperties;
|
|
this.hostEvents = hostEvents;
|
|
this.exportAsVars = exportAsVars;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
DirectiveAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitDirective(this, context);
|
|
};
|
|
return DirectiveAst;
|
|
})();
|
|
exports.DirectiveAst = DirectiveAst;
|
|
var NgContentAst = (function() {
|
|
function NgContentAst(index, ngContentIndex, sourceSpan) {
|
|
this.index = index;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.sourceSpan = sourceSpan;
|
|
}
|
|
NgContentAst.prototype.visit = function(visitor, context) {
|
|
return visitor.visitNgContent(this, context);
|
|
};
|
|
return NgContentAst;
|
|
})();
|
|
exports.NgContentAst = NgContentAst;
|
|
(function(PropertyBindingType) {
|
|
PropertyBindingType[PropertyBindingType["Property"] = 0] = "Property";
|
|
PropertyBindingType[PropertyBindingType["Attribute"] = 1] = "Attribute";
|
|
PropertyBindingType[PropertyBindingType["Class"] = 2] = "Class";
|
|
PropertyBindingType[PropertyBindingType["Style"] = 3] = "Style";
|
|
})(exports.PropertyBindingType || (exports.PropertyBindingType = {}));
|
|
var PropertyBindingType = exports.PropertyBindingType;
|
|
function templateVisitAll(visitor, asts, context) {
|
|
if (context === void 0) {
|
|
context = null;
|
|
}
|
|
var result = [];
|
|
asts.forEach(function(ast) {
|
|
var astResult = ast.visit(visitor, context);
|
|
if (lang_1.isPresent(astResult)) {
|
|
result.push(astResult);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
exports.templateVisitAll = templateVisitAll;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("66", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var MODULE_REGEXP = /#MODULE\[([^\]]*)\]/g;
|
|
function moduleRef(moduleUrl) {
|
|
return "#MODULE[" + moduleUrl + "]";
|
|
}
|
|
exports.moduleRef = moduleRef;
|
|
var SourceModule = (function() {
|
|
function SourceModule(moduleUrl, sourceWithModuleRefs) {
|
|
this.moduleUrl = moduleUrl;
|
|
this.sourceWithModuleRefs = sourceWithModuleRefs;
|
|
}
|
|
SourceModule.prototype.getSourceWithImports = function() {
|
|
var _this = this;
|
|
var moduleAliases = {};
|
|
var imports = [];
|
|
var newSource = lang_1.StringWrapper.replaceAllMapped(this.sourceWithModuleRefs, MODULE_REGEXP, function(match) {
|
|
var moduleUrl = match[1];
|
|
var alias = moduleAliases[moduleUrl];
|
|
if (lang_1.isBlank(alias)) {
|
|
if (moduleUrl == _this.moduleUrl) {
|
|
alias = '';
|
|
} else {
|
|
alias = "import" + imports.length;
|
|
imports.push([moduleUrl, alias]);
|
|
}
|
|
moduleAliases[moduleUrl] = alias;
|
|
}
|
|
return alias.length > 0 ? alias + "." : '';
|
|
});
|
|
return new SourceWithImports(newSource, imports);
|
|
};
|
|
return SourceModule;
|
|
})();
|
|
exports.SourceModule = SourceModule;
|
|
var SourceExpression = (function() {
|
|
function SourceExpression(declarations, expression) {
|
|
this.declarations = declarations;
|
|
this.expression = expression;
|
|
}
|
|
return SourceExpression;
|
|
})();
|
|
exports.SourceExpression = SourceExpression;
|
|
var SourceExpressions = (function() {
|
|
function SourceExpressions(declarations, expressions) {
|
|
this.declarations = declarations;
|
|
this.expressions = expressions;
|
|
}
|
|
return SourceExpressions;
|
|
})();
|
|
exports.SourceExpressions = SourceExpressions;
|
|
var SourceWithImports = (function() {
|
|
function SourceWithImports(source, imports) {
|
|
this.source = source;
|
|
this.imports = imports;
|
|
}
|
|
return SourceWithImports;
|
|
})();
|
|
exports.SourceWithImports = SourceWithImports;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6d", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
var DASH_CASE_REGEXP = /-([a-z])/g;
|
|
var SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
|
|
var DOUBLE_QUOTE_ESCAPE_STRING_RE = /"|\\|\n|\r|\$/g;
|
|
exports.MODULE_SUFFIX = lang_1.IS_DART ? '.dart' : '.js';
|
|
function camelCaseToDashCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function(m) {
|
|
return '-' + m[1].toLowerCase();
|
|
});
|
|
}
|
|
exports.camelCaseToDashCase = camelCaseToDashCase;
|
|
function dashCaseToCamelCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function(m) {
|
|
return m[1].toUpperCase();
|
|
});
|
|
}
|
|
exports.dashCaseToCamelCase = dashCaseToCamelCase;
|
|
function escapeSingleQuoteString(input) {
|
|
if (lang_1.isBlank(input)) {
|
|
return null;
|
|
}
|
|
return "'" + escapeString(input, SINGLE_QUOTE_ESCAPE_STRING_RE) + "'";
|
|
}
|
|
exports.escapeSingleQuoteString = escapeSingleQuoteString;
|
|
function escapeDoubleQuoteString(input) {
|
|
if (lang_1.isBlank(input)) {
|
|
return null;
|
|
}
|
|
return "\"" + escapeString(input, DOUBLE_QUOTE_ESCAPE_STRING_RE) + "\"";
|
|
}
|
|
exports.escapeDoubleQuoteString = escapeDoubleQuoteString;
|
|
function escapeString(input, re) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, re, function(match) {
|
|
if (match[0] == '$') {
|
|
return lang_1.IS_DART ? '\\$' : '$';
|
|
} else if (match[0] == '\n') {
|
|
return '\\n';
|
|
} else if (match[0] == '\r') {
|
|
return '\\r';
|
|
} else {
|
|
return "\\" + match[0];
|
|
}
|
|
});
|
|
}
|
|
function codeGenExportVariable(name) {
|
|
if (lang_1.IS_DART) {
|
|
return "const " + name + " = ";
|
|
} else {
|
|
return "var " + name + " = exports['" + name + "'] = ";
|
|
}
|
|
}
|
|
exports.codeGenExportVariable = codeGenExportVariable;
|
|
function codeGenConstConstructorCall(name) {
|
|
if (lang_1.IS_DART) {
|
|
return "const " + name;
|
|
} else {
|
|
return "new " + name;
|
|
}
|
|
}
|
|
exports.codeGenConstConstructorCall = codeGenConstConstructorCall;
|
|
function codeGenValueFn(params, value, fnName) {
|
|
if (fnName === void 0) {
|
|
fnName = '';
|
|
}
|
|
if (lang_1.IS_DART) {
|
|
return fnName + "(" + params.join(',') + ") => " + value;
|
|
} else {
|
|
return "function " + fnName + "(" + params.join(',') + ") { return " + value + "; }";
|
|
}
|
|
}
|
|
exports.codeGenValueFn = codeGenValueFn;
|
|
function codeGenToString(expr) {
|
|
if (lang_1.IS_DART) {
|
|
return "'${" + expr + "}'";
|
|
} else {
|
|
return expr;
|
|
}
|
|
}
|
|
exports.codeGenToString = codeGenToString;
|
|
function splitAtColon(input, defaultValues) {
|
|
var parts = lang_1.StringWrapper.split(input.trim(), /\s*:\s*/g);
|
|
if (parts.length > 1) {
|
|
return parts;
|
|
} else {
|
|
return defaultValues;
|
|
}
|
|
}
|
|
exports.splitAtColon = splitAtColon;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("69", ["20", "37", "64", "72", "66", "6d", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var template_commands_1 = $__require('64');
|
|
var template_ast_1 = $__require('72');
|
|
var source_module_1 = $__require('66');
|
|
var util_1 = $__require('6d');
|
|
var di_1 = $__require('39');
|
|
exports.TEMPLATE_COMMANDS_MODULE_REF = source_module_1.moduleRef("package:angular2/src/core/linker/template_commands" + util_1.MODULE_SUFFIX);
|
|
var IMPLICIT_TEMPLATE_VAR = '\$implicit';
|
|
var CLASS_ATTR = 'class';
|
|
var STYLE_ATTR = 'style';
|
|
var CommandCompiler = (function() {
|
|
function CommandCompiler() {}
|
|
CommandCompiler.prototype.compileComponentRuntime = function(component, template, changeDetectorFactories, componentTemplateFactory) {
|
|
var visitor = new CommandBuilderVisitor(new RuntimeCommandFactory(component, componentTemplateFactory, changeDetectorFactories), 0);
|
|
template_ast_1.templateVisitAll(visitor, template);
|
|
return visitor.result;
|
|
};
|
|
CommandCompiler.prototype.compileComponentCodeGen = function(component, template, changeDetectorFactoryExpressions, componentTemplateFactory) {
|
|
var visitor = new CommandBuilderVisitor(new CodegenCommandFactory(component, componentTemplateFactory, changeDetectorFactoryExpressions), 0);
|
|
template_ast_1.templateVisitAll(visitor, template);
|
|
return new source_module_1.SourceExpression([], codeGenArray(visitor.result));
|
|
};
|
|
CommandCompiler = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], CommandCompiler);
|
|
return CommandCompiler;
|
|
})();
|
|
exports.CommandCompiler = CommandCompiler;
|
|
var RuntimeCommandFactory = (function() {
|
|
function RuntimeCommandFactory(component, componentTemplateFactory, changeDetectorFactories) {
|
|
this.component = component;
|
|
this.componentTemplateFactory = componentTemplateFactory;
|
|
this.changeDetectorFactories = changeDetectorFactories;
|
|
}
|
|
RuntimeCommandFactory.prototype._mapDirectives = function(directives) {
|
|
return directives.map(function(directive) {
|
|
return directive.type.runtime;
|
|
});
|
|
};
|
|
RuntimeCommandFactory.prototype.createText = function(value, isBound, ngContentIndex) {
|
|
return new template_commands_1.TextCmd(value, isBound, ngContentIndex);
|
|
};
|
|
RuntimeCommandFactory.prototype.createNgContent = function(index, ngContentIndex) {
|
|
return new template_commands_1.NgContentCmd(index, ngContentIndex);
|
|
};
|
|
RuntimeCommandFactory.prototype.createBeginElement = function(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
|
|
return new template_commands_1.BeginElementCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, this._mapDirectives(directives), isBound, ngContentIndex);
|
|
};
|
|
RuntimeCommandFactory.prototype.createEndElement = function() {
|
|
return new template_commands_1.EndElementCmd();
|
|
};
|
|
RuntimeCommandFactory.prototype.createBeginComponent = function(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex) {
|
|
var nestedTemplateAccessor = this.componentTemplateFactory(directives[0]);
|
|
return new template_commands_1.BeginComponentCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, this._mapDirectives(directives), encapsulation, ngContentIndex, nestedTemplateAccessor);
|
|
};
|
|
RuntimeCommandFactory.prototype.createEndComponent = function() {
|
|
return new template_commands_1.EndComponentCmd();
|
|
};
|
|
RuntimeCommandFactory.prototype.createEmbeddedTemplate = function(embeddedTemplateIndex, attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, children) {
|
|
return new template_commands_1.EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, this._mapDirectives(directives), isMerged, ngContentIndex, this.changeDetectorFactories[embeddedTemplateIndex], children);
|
|
};
|
|
return RuntimeCommandFactory;
|
|
})();
|
|
var CodegenCommandFactory = (function() {
|
|
function CodegenCommandFactory(component, componentTemplateFactory, changeDetectorFactoryExpressions) {
|
|
this.component = component;
|
|
this.componentTemplateFactory = componentTemplateFactory;
|
|
this.changeDetectorFactoryExpressions = changeDetectorFactoryExpressions;
|
|
}
|
|
CodegenCommandFactory.prototype.createText = function(value, isBound, ngContentIndex) {
|
|
return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'TextCmd') + "(" + util_1.escapeSingleQuoteString(value) + ", " + isBound + ", " + ngContentIndex + ")");
|
|
};
|
|
CodegenCommandFactory.prototype.createNgContent = function(index, ngContentIndex) {
|
|
return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'NgContentCmd') + "(" + index + ", " + ngContentIndex + ")");
|
|
};
|
|
CodegenCommandFactory.prototype.createBeginElement = function(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
|
|
var attrsExpression = codeGenArray(attrNameAndValues);
|
|
return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'BeginElementCmd') + "(" + util_1.escapeSingleQuoteString(name) + ", " + attrsExpression + ", ") + (codeGenArray(eventTargetAndNames) + ", " + codeGenArray(variableNameAndValues) + ", " + codeGenDirectivesArray(directives) + ", " + isBound + ", " + ngContentIndex + ")"));
|
|
};
|
|
CodegenCommandFactory.prototype.createEndElement = function() {
|
|
return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EndElementCmd') + "()");
|
|
};
|
|
CodegenCommandFactory.prototype.createBeginComponent = function(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex) {
|
|
var attrsExpression = codeGenArray(attrNameAndValues);
|
|
return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'BeginComponentCmd') + "(" + util_1.escapeSingleQuoteString(name) + ", " + attrsExpression + ", ") + (codeGenArray(eventTargetAndNames) + ", " + codeGenArray(variableNameAndValues) + ", " + codeGenDirectivesArray(directives) + ", " + codeGenViewEncapsulation(encapsulation) + ", " + ngContentIndex + ", " + this.componentTemplateFactory(directives[0]) + ")"));
|
|
};
|
|
CodegenCommandFactory.prototype.createEndComponent = function() {
|
|
return new Expression(util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EndComponentCmd') + "()");
|
|
};
|
|
CodegenCommandFactory.prototype.createEmbeddedTemplate = function(embeddedTemplateIndex, attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, children) {
|
|
return new Expression((util_1.codeGenConstConstructorCall(exports.TEMPLATE_COMMANDS_MODULE_REF + 'EmbeddedTemplateCmd') + "(" + codeGenArray(attrNameAndValues) + ", " + codeGenArray(variableNameAndValues) + ", ") + (codeGenDirectivesArray(directives) + ", " + isMerged + ", " + ngContentIndex + ", " + this.changeDetectorFactoryExpressions[embeddedTemplateIndex] + ", " + codeGenArray(children) + ")"));
|
|
};
|
|
return CodegenCommandFactory;
|
|
})();
|
|
function visitAndReturnContext(visitor, asts, context) {
|
|
template_ast_1.templateVisitAll(visitor, asts, context);
|
|
return context;
|
|
}
|
|
var CommandBuilderVisitor = (function() {
|
|
function CommandBuilderVisitor(commandFactory, embeddedTemplateIndex) {
|
|
this.commandFactory = commandFactory;
|
|
this.embeddedTemplateIndex = embeddedTemplateIndex;
|
|
this.result = [];
|
|
this.transitiveNgContentCount = 0;
|
|
}
|
|
CommandBuilderVisitor.prototype._readAttrNameAndValues = function(directives, attrAsts) {
|
|
var attrs = keyValueArrayToMap(visitAndReturnContext(this, attrAsts, []));
|
|
directives.forEach(function(directiveMeta) {
|
|
collection_1.StringMapWrapper.forEach(directiveMeta.hostAttributes, function(value, name) {
|
|
var prevValue = attrs[name];
|
|
attrs[name] = lang_1.isPresent(prevValue) ? mergeAttributeValue(name, prevValue, value) : value;
|
|
});
|
|
});
|
|
return mapToKeyValueArray(attrs);
|
|
};
|
|
CommandBuilderVisitor.prototype.visitNgContent = function(ast, context) {
|
|
this.transitiveNgContentCount++;
|
|
this.result.push(this.commandFactory.createNgContent(ast.index, ast.ngContentIndex));
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitEmbeddedTemplate = function(ast, context) {
|
|
var _this = this;
|
|
this.embeddedTemplateIndex++;
|
|
var childVisitor = new CommandBuilderVisitor(this.commandFactory, this.embeddedTemplateIndex);
|
|
template_ast_1.templateVisitAll(childVisitor, ast.children);
|
|
var isMerged = childVisitor.transitiveNgContentCount > 0;
|
|
var variableNameAndValues = [];
|
|
ast.vars.forEach(function(varAst) {
|
|
variableNameAndValues.push(varAst.name);
|
|
variableNameAndValues.push(varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR);
|
|
});
|
|
var directives = [];
|
|
collection_1.ListWrapper.forEachWithIndex(ast.directives, function(directiveAst, index) {
|
|
directiveAst.visit(_this, new DirectiveContext(index, [], [], directives));
|
|
});
|
|
this.result.push(this.commandFactory.createEmbeddedTemplate(this.embeddedTemplateIndex, this._readAttrNameAndValues(directives, ast.attrs), variableNameAndValues, directives, isMerged, ast.ngContentIndex, childVisitor.result));
|
|
this.transitiveNgContentCount += childVisitor.transitiveNgContentCount;
|
|
this.embeddedTemplateIndex = childVisitor.embeddedTemplateIndex;
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitElement = function(ast, context) {
|
|
var _this = this;
|
|
var component = ast.getComponent();
|
|
var eventTargetAndNames = visitAndReturnContext(this, ast.outputs, []);
|
|
var variableNameAndValues = [];
|
|
if (lang_1.isBlank(component)) {
|
|
ast.exportAsVars.forEach(function(varAst) {
|
|
variableNameAndValues.push(varAst.name);
|
|
variableNameAndValues.push(null);
|
|
});
|
|
}
|
|
var directives = [];
|
|
collection_1.ListWrapper.forEachWithIndex(ast.directives, function(directiveAst, index) {
|
|
directiveAst.visit(_this, new DirectiveContext(index, eventTargetAndNames, variableNameAndValues, directives));
|
|
});
|
|
eventTargetAndNames = removeKeyValueArrayDuplicates(eventTargetAndNames);
|
|
var attrNameAndValues = this._readAttrNameAndValues(directives, ast.attrs);
|
|
if (lang_1.isPresent(component)) {
|
|
this.result.push(this.commandFactory.createBeginComponent(ast.name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, component.template.encapsulation, ast.ngContentIndex));
|
|
template_ast_1.templateVisitAll(this, ast.children);
|
|
this.result.push(this.commandFactory.createEndComponent());
|
|
} else {
|
|
this.result.push(this.commandFactory.createBeginElement(ast.name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, ast.isBound(), ast.ngContentIndex));
|
|
template_ast_1.templateVisitAll(this, ast.children);
|
|
this.result.push(this.commandFactory.createEndElement());
|
|
}
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitVariable = function(ast, ctx) {
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitAttr = function(ast, attrNameAndValues) {
|
|
attrNameAndValues.push(ast.name);
|
|
attrNameAndValues.push(ast.value);
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitBoundText = function(ast, context) {
|
|
this.result.push(this.commandFactory.createText(null, true, ast.ngContentIndex));
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitText = function(ast, context) {
|
|
this.result.push(this.commandFactory.createText(ast.value, false, ast.ngContentIndex));
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitDirective = function(ast, ctx) {
|
|
ctx.targetDirectives.push(ast.directive);
|
|
template_ast_1.templateVisitAll(this, ast.hostEvents, ctx.eventTargetAndNames);
|
|
ast.exportAsVars.forEach(function(varAst) {
|
|
ctx.targetVariableNameAndValues.push(varAst.name);
|
|
ctx.targetVariableNameAndValues.push(ctx.index);
|
|
});
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitEvent = function(ast, eventTargetAndNames) {
|
|
eventTargetAndNames.push(ast.target);
|
|
eventTargetAndNames.push(ast.name);
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitDirectiveProperty = function(ast, context) {
|
|
return null;
|
|
};
|
|
CommandBuilderVisitor.prototype.visitElementProperty = function(ast, context) {
|
|
return null;
|
|
};
|
|
return CommandBuilderVisitor;
|
|
})();
|
|
function removeKeyValueArrayDuplicates(keyValueArray) {
|
|
var knownPairs = new Set();
|
|
var resultKeyValueArray = [];
|
|
for (var i = 0; i < keyValueArray.length; i += 2) {
|
|
var key = keyValueArray[i];
|
|
var value = keyValueArray[i + 1];
|
|
var pairId = key + ":" + value;
|
|
if (!collection_1.SetWrapper.has(knownPairs, pairId)) {
|
|
resultKeyValueArray.push(key);
|
|
resultKeyValueArray.push(value);
|
|
knownPairs.add(pairId);
|
|
}
|
|
}
|
|
return resultKeyValueArray;
|
|
}
|
|
function keyValueArrayToMap(keyValueArr) {
|
|
var data = {};
|
|
for (var i = 0; i < keyValueArr.length; i += 2) {
|
|
data[keyValueArr[i]] = keyValueArr[i + 1];
|
|
}
|
|
return data;
|
|
}
|
|
function mapToKeyValueArray(data) {
|
|
var entryArray = [];
|
|
collection_1.StringMapWrapper.forEach(data, function(value, name) {
|
|
entryArray.push([name, value]);
|
|
});
|
|
collection_1.ListWrapper.sort(entryArray, function(entry1, entry2) {
|
|
return lang_1.StringWrapper.compare(entry1[0], entry2[0]);
|
|
});
|
|
var keyValueArray = [];
|
|
entryArray.forEach(function(entry) {
|
|
keyValueArray.push(entry[0]);
|
|
keyValueArray.push(entry[1]);
|
|
});
|
|
return keyValueArray;
|
|
}
|
|
function mergeAttributeValue(attrName, attrValue1, attrValue2) {
|
|
if (attrName == CLASS_ATTR || attrName == STYLE_ATTR) {
|
|
return attrValue1 + " " + attrValue2;
|
|
} else {
|
|
return attrValue2;
|
|
}
|
|
}
|
|
var DirectiveContext = (function() {
|
|
function DirectiveContext(index, eventTargetAndNames, targetVariableNameAndValues, targetDirectives) {
|
|
this.index = index;
|
|
this.eventTargetAndNames = eventTargetAndNames;
|
|
this.targetVariableNameAndValues = targetVariableNameAndValues;
|
|
this.targetDirectives = targetDirectives;
|
|
}
|
|
return DirectiveContext;
|
|
})();
|
|
var Expression = (function() {
|
|
function Expression(value) {
|
|
this.value = value;
|
|
}
|
|
return Expression;
|
|
})();
|
|
function escapeValue(value) {
|
|
if (value instanceof Expression) {
|
|
return value.value;
|
|
} else if (lang_1.isString(value)) {
|
|
return util_1.escapeSingleQuoteString(value);
|
|
} else if (lang_1.isBlank(value)) {
|
|
return 'null';
|
|
} else {
|
|
return "" + value;
|
|
}
|
|
}
|
|
function codeGenArray(data) {
|
|
var base = "[" + data.map(escapeValue).join(',') + "]";
|
|
return lang_1.IS_DART ? "const " + base : base;
|
|
}
|
|
function codeGenDirectivesArray(directives) {
|
|
var expressions = directives.map(function(directiveType) {
|
|
return ("" + source_module_1.moduleRef(directiveType.type.moduleUrl) + directiveType.type.name);
|
|
});
|
|
var base = "[" + expressions.join(',') + "]";
|
|
return lang_1.IS_DART ? "const " + base : base;
|
|
}
|
|
function codeGenViewEncapsulation(value) {
|
|
if (lang_1.IS_DART) {
|
|
return "" + exports.TEMPLATE_COMMANDS_MODULE_REF + value;
|
|
} else {
|
|
return "" + value;
|
|
}
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("36", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.DOM = null;
|
|
function setRootDomAdapter(adapter) {
|
|
if (lang_1.isBlank(exports.DOM)) {
|
|
exports.DOM = adapter;
|
|
}
|
|
}
|
|
exports.setRootDomAdapter = setRootDomAdapter;
|
|
var DomAdapter = (function() {
|
|
function DomAdapter() {}
|
|
return DomAdapter;
|
|
})();
|
|
exports.DomAdapter = DomAdapter;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("70", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.NAMED_ENTITIES = lang_1.CONST_EXPR({
|
|
'Aacute': '\u00C1',
|
|
'aacute': '\u00E1',
|
|
'Acirc': '\u00C2',
|
|
'acirc': '\u00E2',
|
|
'acute': '\u00B4',
|
|
'AElig': '\u00C6',
|
|
'aelig': '\u00E6',
|
|
'Agrave': '\u00C0',
|
|
'agrave': '\u00E0',
|
|
'alefsym': '\u2135',
|
|
'Alpha': '\u0391',
|
|
'alpha': '\u03B1',
|
|
'amp': '&',
|
|
'and': '\u2227',
|
|
'ang': '\u2220',
|
|
'apos': '\u0027',
|
|
'Aring': '\u00C5',
|
|
'aring': '\u00E5',
|
|
'asymp': '\u2248',
|
|
'Atilde': '\u00C3',
|
|
'atilde': '\u00E3',
|
|
'Auml': '\u00C4',
|
|
'auml': '\u00E4',
|
|
'bdquo': '\u201E',
|
|
'Beta': '\u0392',
|
|
'beta': '\u03B2',
|
|
'brvbar': '\u00A6',
|
|
'bull': '\u2022',
|
|
'cap': '\u2229',
|
|
'Ccedil': '\u00C7',
|
|
'ccedil': '\u00E7',
|
|
'cedil': '\u00B8',
|
|
'cent': '\u00A2',
|
|
'Chi': '\u03A7',
|
|
'chi': '\u03C7',
|
|
'circ': '\u02C6',
|
|
'clubs': '\u2663',
|
|
'cong': '\u2245',
|
|
'copy': '\u00A9',
|
|
'crarr': '\u21B5',
|
|
'cup': '\u222A',
|
|
'curren': '\u00A4',
|
|
'dagger': '\u2020',
|
|
'Dagger': '\u2021',
|
|
'darr': '\u2193',
|
|
'dArr': '\u21D3',
|
|
'deg': '\u00B0',
|
|
'Delta': '\u0394',
|
|
'delta': '\u03B4',
|
|
'diams': '\u2666',
|
|
'divide': '\u00F7',
|
|
'Eacute': '\u00C9',
|
|
'eacute': '\u00E9',
|
|
'Ecirc': '\u00CA',
|
|
'ecirc': '\u00EA',
|
|
'Egrave': '\u00C8',
|
|
'egrave': '\u00E8',
|
|
'empty': '\u2205',
|
|
'emsp': '\u2003',
|
|
'ensp': '\u2002',
|
|
'Epsilon': '\u0395',
|
|
'epsilon': '\u03B5',
|
|
'equiv': '\u2261',
|
|
'Eta': '\u0397',
|
|
'eta': '\u03B7',
|
|
'ETH': '\u00D0',
|
|
'eth': '\u00F0',
|
|
'Euml': '\u00CB',
|
|
'euml': '\u00EB',
|
|
'euro': '\u20AC',
|
|
'exist': '\u2203',
|
|
'fnof': '\u0192',
|
|
'forall': '\u2200',
|
|
'frac12': '\u00BD',
|
|
'frac14': '\u00BC',
|
|
'frac34': '\u00BE',
|
|
'frasl': '\u2044',
|
|
'Gamma': '\u0393',
|
|
'gamma': '\u03B3',
|
|
'ge': '\u2265',
|
|
'gt': '>',
|
|
'harr': '\u2194',
|
|
'hArr': '\u21D4',
|
|
'hearts': '\u2665',
|
|
'hellip': '\u2026',
|
|
'Iacute': '\u00CD',
|
|
'iacute': '\u00ED',
|
|
'Icirc': '\u00CE',
|
|
'icirc': '\u00EE',
|
|
'iexcl': '\u00A1',
|
|
'Igrave': '\u00CC',
|
|
'igrave': '\u00EC',
|
|
'image': '\u2111',
|
|
'infin': '\u221E',
|
|
'int': '\u222B',
|
|
'Iota': '\u0399',
|
|
'iota': '\u03B9',
|
|
'iquest': '\u00BF',
|
|
'isin': '\u2208',
|
|
'Iuml': '\u00CF',
|
|
'iuml': '\u00EF',
|
|
'Kappa': '\u039A',
|
|
'kappa': '\u03BA',
|
|
'Lambda': '\u039B',
|
|
'lambda': '\u03BB',
|
|
'lang': '\u27E8',
|
|
'laquo': '\u00AB',
|
|
'larr': '\u2190',
|
|
'lArr': '\u21D0',
|
|
'lceil': '\u2308',
|
|
'ldquo': '\u201C',
|
|
'le': '\u2264',
|
|
'lfloor': '\u230A',
|
|
'lowast': '\u2217',
|
|
'loz': '\u25CA',
|
|
'lrm': '\u200E',
|
|
'lsaquo': '\u2039',
|
|
'lsquo': '\u2018',
|
|
'lt': '<',
|
|
'macr': '\u00AF',
|
|
'mdash': '\u2014',
|
|
'micro': '\u00B5',
|
|
'middot': '\u00B7',
|
|
'minus': '\u2212',
|
|
'Mu': '\u039C',
|
|
'mu': '\u03BC',
|
|
'nabla': '\u2207',
|
|
'nbsp': '\u00A0',
|
|
'ndash': '\u2013',
|
|
'ne': '\u2260',
|
|
'ni': '\u220B',
|
|
'not': '\u00AC',
|
|
'notin': '\u2209',
|
|
'nsub': '\u2284',
|
|
'Ntilde': '\u00D1',
|
|
'ntilde': '\u00F1',
|
|
'Nu': '\u039D',
|
|
'nu': '\u03BD',
|
|
'Oacute': '\u00D3',
|
|
'oacute': '\u00F3',
|
|
'Ocirc': '\u00D4',
|
|
'ocirc': '\u00F4',
|
|
'OElig': '\u0152',
|
|
'oelig': '\u0153',
|
|
'Ograve': '\u00D2',
|
|
'ograve': '\u00F2',
|
|
'oline': '\u203E',
|
|
'Omega': '\u03A9',
|
|
'omega': '\u03C9',
|
|
'Omicron': '\u039F',
|
|
'omicron': '\u03BF',
|
|
'oplus': '\u2295',
|
|
'or': '\u2228',
|
|
'ordf': '\u00AA',
|
|
'ordm': '\u00BA',
|
|
'Oslash': '\u00D8',
|
|
'oslash': '\u00F8',
|
|
'Otilde': '\u00D5',
|
|
'otilde': '\u00F5',
|
|
'otimes': '\u2297',
|
|
'Ouml': '\u00D6',
|
|
'ouml': '\u00F6',
|
|
'para': '\u00B6',
|
|
'permil': '\u2030',
|
|
'perp': '\u22A5',
|
|
'Phi': '\u03A6',
|
|
'phi': '\u03C6',
|
|
'Pi': '\u03A0',
|
|
'pi': '\u03C0',
|
|
'piv': '\u03D6',
|
|
'plusmn': '\u00B1',
|
|
'pound': '\u00A3',
|
|
'prime': '\u2032',
|
|
'Prime': '\u2033',
|
|
'prod': '\u220F',
|
|
'prop': '\u221D',
|
|
'Psi': '\u03A8',
|
|
'psi': '\u03C8',
|
|
'quot': '\u0022',
|
|
'radic': '\u221A',
|
|
'rang': '\u27E9',
|
|
'raquo': '\u00BB',
|
|
'rarr': '\u2192',
|
|
'rArr': '\u21D2',
|
|
'rceil': '\u2309',
|
|
'rdquo': '\u201D',
|
|
'real': '\u211C',
|
|
'reg': '\u00AE',
|
|
'rfloor': '\u230B',
|
|
'Rho': '\u03A1',
|
|
'rho': '\u03C1',
|
|
'rlm': '\u200F',
|
|
'rsaquo': '\u203A',
|
|
'rsquo': '\u2019',
|
|
'sbquo': '\u201A',
|
|
'Scaron': '\u0160',
|
|
'scaron': '\u0161',
|
|
'sdot': '\u22C5',
|
|
'sect': '\u00A7',
|
|
'shy': '\u00AD',
|
|
'Sigma': '\u03A3',
|
|
'sigma': '\u03C3',
|
|
'sigmaf': '\u03C2',
|
|
'sim': '\u223C',
|
|
'spades': '\u2660',
|
|
'sub': '\u2282',
|
|
'sube': '\u2286',
|
|
'sum': '\u2211',
|
|
'sup': '\u2283',
|
|
'sup1': '\u00B9',
|
|
'sup2': '\u00B2',
|
|
'sup3': '\u00B3',
|
|
'supe': '\u2287',
|
|
'szlig': '\u00DF',
|
|
'Tau': '\u03A4',
|
|
'tau': '\u03C4',
|
|
'there4': '\u2234',
|
|
'Theta': '\u0398',
|
|
'theta': '\u03B8',
|
|
'thetasym': '\u03D1',
|
|
'thinsp': '\u2009',
|
|
'THORN': '\u00DE',
|
|
'thorn': '\u00FE',
|
|
'tilde': '\u02DC',
|
|
'times': '\u00D7',
|
|
'trade': '\u2122',
|
|
'Uacute': '\u00DA',
|
|
'uacute': '\u00FA',
|
|
'uarr': '\u2191',
|
|
'uArr': '\u21D1',
|
|
'Ucirc': '\u00DB',
|
|
'ucirc': '\u00FB',
|
|
'Ugrave': '\u00D9',
|
|
'ugrave': '\u00F9',
|
|
'uml': '\u00A8',
|
|
'upsih': '\u03D2',
|
|
'Upsilon': '\u03A5',
|
|
'upsilon': '\u03C5',
|
|
'Uuml': '\u00DC',
|
|
'uuml': '\u00FC',
|
|
'weierp': '\u2118',
|
|
'Xi': '\u039E',
|
|
'xi': '\u03BE',
|
|
'Yacute': '\u00DD',
|
|
'yacute': '\u00FD',
|
|
'yen': '\u00A5',
|
|
'yuml': '\u00FF',
|
|
'Yuml': '\u0178',
|
|
'Zeta': '\u0396',
|
|
'zeta': '\u03B6',
|
|
'zwj': '\u200D',
|
|
'zwnj': '\u200C'
|
|
});
|
|
(function(HtmlTagContentType) {
|
|
HtmlTagContentType[HtmlTagContentType["RAW_TEXT"] = 0] = "RAW_TEXT";
|
|
HtmlTagContentType[HtmlTagContentType["ESCAPABLE_RAW_TEXT"] = 1] = "ESCAPABLE_RAW_TEXT";
|
|
HtmlTagContentType[HtmlTagContentType["PARSABLE_DATA"] = 2] = "PARSABLE_DATA";
|
|
})(exports.HtmlTagContentType || (exports.HtmlTagContentType = {}));
|
|
var HtmlTagContentType = exports.HtmlTagContentType;
|
|
var HtmlTagDefinition = (function() {
|
|
function HtmlTagDefinition(_a) {
|
|
var _this = this;
|
|
var _b = _a === void 0 ? {} : _a,
|
|
closedByChildren = _b.closedByChildren,
|
|
requiredParents = _b.requiredParents,
|
|
implicitNamespacePrefix = _b.implicitNamespacePrefix,
|
|
contentType = _b.contentType,
|
|
closedByParent = _b.closedByParent,
|
|
isVoid = _b.isVoid,
|
|
ignoreFirstLf = _b.ignoreFirstLf;
|
|
this.closedByChildren = {};
|
|
this.closedByParent = false;
|
|
if (lang_1.isPresent(closedByChildren) && closedByChildren.length > 0) {
|
|
closedByChildren.forEach(function(tagName) {
|
|
return _this.closedByChildren[tagName] = true;
|
|
});
|
|
}
|
|
this.isVoid = lang_1.normalizeBool(isVoid);
|
|
this.closedByParent = lang_1.normalizeBool(closedByParent) || this.isVoid;
|
|
if (lang_1.isPresent(requiredParents) && requiredParents.length > 0) {
|
|
this.requiredParents = {};
|
|
this.parentToAdd = requiredParents[0];
|
|
requiredParents.forEach(function(tagName) {
|
|
return _this.requiredParents[tagName] = true;
|
|
});
|
|
}
|
|
this.implicitNamespacePrefix = implicitNamespacePrefix;
|
|
this.contentType = lang_1.isPresent(contentType) ? contentType : HtmlTagContentType.PARSABLE_DATA;
|
|
this.ignoreFirstLf = lang_1.normalizeBool(ignoreFirstLf);
|
|
}
|
|
HtmlTagDefinition.prototype.requireExtraParent = function(currentParent) {
|
|
if (lang_1.isBlank(this.requiredParents)) {
|
|
return false;
|
|
}
|
|
if (lang_1.isBlank(currentParent)) {
|
|
return true;
|
|
}
|
|
var lcParent = currentParent.toLowerCase();
|
|
return this.requiredParents[lcParent] != true && lcParent != 'template';
|
|
};
|
|
HtmlTagDefinition.prototype.isClosedByChild = function(name) {
|
|
return this.isVoid || lang_1.normalizeBool(this.closedByChildren[name.toLowerCase()]);
|
|
};
|
|
return HtmlTagDefinition;
|
|
})();
|
|
exports.HtmlTagDefinition = HtmlTagDefinition;
|
|
var TAG_DEFINITIONS = {
|
|
'area': new HtmlTagDefinition({isVoid: true}),
|
|
'embed': new HtmlTagDefinition({isVoid: true}),
|
|
'link': new HtmlTagDefinition({isVoid: true}),
|
|
'img': new HtmlTagDefinition({isVoid: true}),
|
|
'input': new HtmlTagDefinition({isVoid: true}),
|
|
'param': new HtmlTagDefinition({isVoid: true}),
|
|
'hr': new HtmlTagDefinition({isVoid: true}),
|
|
'br': new HtmlTagDefinition({isVoid: true}),
|
|
'source': new HtmlTagDefinition({isVoid: true}),
|
|
'track': new HtmlTagDefinition({isVoid: true}),
|
|
'wbr': new HtmlTagDefinition({isVoid: true}),
|
|
'p': new HtmlTagDefinition({
|
|
closedByChildren: ['address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'],
|
|
closedByParent: true
|
|
}),
|
|
'thead': new HtmlTagDefinition({closedByChildren: ['tbody', 'tfoot']}),
|
|
'tbody': new HtmlTagDefinition({
|
|
closedByChildren: ['tbody', 'tfoot'],
|
|
closedByParent: true
|
|
}),
|
|
'tfoot': new HtmlTagDefinition({
|
|
closedByChildren: ['tbody'],
|
|
closedByParent: true
|
|
}),
|
|
'tr': new HtmlTagDefinition({
|
|
closedByChildren: ['tr'],
|
|
requiredParents: ['tbody', 'tfoot', 'thead'],
|
|
closedByParent: true
|
|
}),
|
|
'td': new HtmlTagDefinition({
|
|
closedByChildren: ['td', 'th'],
|
|
closedByParent: true
|
|
}),
|
|
'th': new HtmlTagDefinition({
|
|
closedByChildren: ['td', 'th'],
|
|
closedByParent: true
|
|
}),
|
|
'col': new HtmlTagDefinition({
|
|
requiredParents: ['colgroup'],
|
|
isVoid: true
|
|
}),
|
|
'svg': new HtmlTagDefinition({implicitNamespacePrefix: 'svg'}),
|
|
'math': new HtmlTagDefinition({implicitNamespacePrefix: 'math'}),
|
|
'li': new HtmlTagDefinition({
|
|
closedByChildren: ['li'],
|
|
closedByParent: true
|
|
}),
|
|
'dt': new HtmlTagDefinition({closedByChildren: ['dt', 'dd']}),
|
|
'dd': new HtmlTagDefinition({
|
|
closedByChildren: ['dt', 'dd'],
|
|
closedByParent: true
|
|
}),
|
|
'rb': new HtmlTagDefinition({
|
|
closedByChildren: ['rb', 'rt', 'rtc', 'rp'],
|
|
closedByParent: true
|
|
}),
|
|
'rt': new HtmlTagDefinition({
|
|
closedByChildren: ['rb', 'rt', 'rtc', 'rp'],
|
|
closedByParent: true
|
|
}),
|
|
'rtc': new HtmlTagDefinition({
|
|
closedByChildren: ['rb', 'rtc', 'rp'],
|
|
closedByParent: true
|
|
}),
|
|
'rp': new HtmlTagDefinition({
|
|
closedByChildren: ['rb', 'rt', 'rtc', 'rp'],
|
|
closedByParent: true
|
|
}),
|
|
'optgroup': new HtmlTagDefinition({
|
|
closedByChildren: ['optgroup'],
|
|
closedByParent: true
|
|
}),
|
|
'option': new HtmlTagDefinition({
|
|
closedByChildren: ['option', 'optgroup'],
|
|
closedByParent: true
|
|
}),
|
|
'pre': new HtmlTagDefinition({ignoreFirstLf: true}),
|
|
'listing': new HtmlTagDefinition({ignoreFirstLf: true}),
|
|
'style': new HtmlTagDefinition({contentType: HtmlTagContentType.RAW_TEXT}),
|
|
'script': new HtmlTagDefinition({contentType: HtmlTagContentType.RAW_TEXT}),
|
|
'title': new HtmlTagDefinition({contentType: HtmlTagContentType.ESCAPABLE_RAW_TEXT}),
|
|
'textarea': new HtmlTagDefinition({
|
|
contentType: HtmlTagContentType.ESCAPABLE_RAW_TEXT,
|
|
ignoreFirstLf: true
|
|
})
|
|
};
|
|
var DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
|
|
function getHtmlTagDefinition(tagName) {
|
|
var result = TAG_DEFINITIONS[tagName.toLowerCase()];
|
|
return lang_1.isPresent(result) ? result : DEFAULT_TAG_DEFINITION;
|
|
}
|
|
exports.getHtmlTagDefinition = getHtmlTagDefinition;
|
|
var NS_PREFIX_RE = /^@([^:]+):(.+)/g;
|
|
function splitNsName(elementName) {
|
|
if (elementName[0] != '@') {
|
|
return [null, elementName];
|
|
}
|
|
var match = lang_1.RegExpWrapper.firstMatch(NS_PREFIX_RE, elementName);
|
|
return [match[1], match[2]];
|
|
}
|
|
exports.splitNsName = splitNsName;
|
|
function getNsPrefix(elementName) {
|
|
return splitNsName(elementName)[0];
|
|
}
|
|
exports.getNsPrefix = getNsPrefix;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("74", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ElementSchemaRegistry = (function() {
|
|
function ElementSchemaRegistry() {}
|
|
ElementSchemaRegistry.prototype.hasProperty = function(tagName, propName) {
|
|
return true;
|
|
};
|
|
ElementSchemaRegistry.prototype.getMappedPropName = function(propName) {
|
|
return propName;
|
|
};
|
|
return ElementSchemaRegistry;
|
|
})();
|
|
exports.ElementSchemaRegistry = ElementSchemaRegistry;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("87", ["39", "20", "37", "36", "70", "74"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var dom_adapter_1 = $__require('36');
|
|
var html_tags_1 = $__require('70');
|
|
var element_schema_registry_1 = $__require('74');
|
|
var NAMESPACE_URIS = lang_1.CONST_EXPR({
|
|
'xlink': 'http://www.w3.org/1999/xlink',
|
|
'svg': 'http://www.w3.org/2000/svg'
|
|
});
|
|
var DomElementSchemaRegistry = (function(_super) {
|
|
__extends(DomElementSchemaRegistry, _super);
|
|
function DomElementSchemaRegistry() {
|
|
_super.apply(this, arguments);
|
|
this._protoElements = new Map();
|
|
}
|
|
DomElementSchemaRegistry.prototype._getProtoElement = function(tagName) {
|
|
var element = this._protoElements.get(tagName);
|
|
if (lang_1.isBlank(element)) {
|
|
var nsAndName = html_tags_1.splitNsName(tagName);
|
|
element = lang_1.isPresent(nsAndName[0]) ? dom_adapter_1.DOM.createElementNS(NAMESPACE_URIS[nsAndName[0]], nsAndName[1]) : dom_adapter_1.DOM.createElement(nsAndName[1]);
|
|
this._protoElements.set(tagName, element);
|
|
}
|
|
return element;
|
|
};
|
|
DomElementSchemaRegistry.prototype.hasProperty = function(tagName, propName) {
|
|
if (tagName.indexOf('-') !== -1) {
|
|
return true;
|
|
} else {
|
|
var elm = this._getProtoElement(tagName);
|
|
return dom_adapter_1.DOM.hasProperty(elm, propName);
|
|
}
|
|
};
|
|
DomElementSchemaRegistry.prototype.getMappedPropName = function(propName) {
|
|
var mappedPropName = collection_1.StringMapWrapper.get(dom_adapter_1.DOM.attrToPropMap, propName);
|
|
return lang_1.isPresent(mappedPropName) ? mappedPropName : propName;
|
|
};
|
|
DomElementSchemaRegistry = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], DomElementSchemaRegistry);
|
|
return DomElementSchemaRegistry;
|
|
})(element_schema_registry_1.ElementSchemaRegistry);
|
|
exports.DomElementSchemaRegistry = DomElementSchemaRegistry;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7a", ["39", "20", "88"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var application_tokens_1 = $__require('88');
|
|
var di_2 = $__require('39');
|
|
function createWithoutPackagePrefix() {
|
|
return new UrlResolver();
|
|
}
|
|
exports.createWithoutPackagePrefix = createWithoutPackagePrefix;
|
|
exports.DEFAULT_PACKAGE_URL_PROVIDER = new di_2.Provider(application_tokens_1.PACKAGE_ROOT_URL, {useValue: "/"});
|
|
var UrlResolver = (function() {
|
|
function UrlResolver(packagePrefix) {
|
|
if (packagePrefix === void 0) {
|
|
packagePrefix = null;
|
|
}
|
|
if (lang_1.isPresent(packagePrefix)) {
|
|
this._packagePrefix = lang_1.StringWrapper.stripRight(packagePrefix, "/") + "/";
|
|
}
|
|
}
|
|
UrlResolver.prototype.resolve = function(baseUrl, url) {
|
|
var resolvedUrl = url;
|
|
if (lang_1.isPresent(baseUrl) && baseUrl.length > 0) {
|
|
resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
|
|
}
|
|
if (lang_1.isPresent(this._packagePrefix) && getUrlScheme(resolvedUrl) == "package") {
|
|
resolvedUrl = resolvedUrl.replace("package:", this._packagePrefix);
|
|
}
|
|
return resolvedUrl;
|
|
};
|
|
UrlResolver = __decorate([di_1.Injectable(), __param(0, di_1.Inject(application_tokens_1.PACKAGE_ROOT_URL)), __metadata('design:paramtypes', [String])], UrlResolver);
|
|
return UrlResolver;
|
|
})();
|
|
exports.UrlResolver = UrlResolver;
|
|
function getUrlScheme(url) {
|
|
var match = _split(url);
|
|
return (match && match[_ComponentIndex.Scheme]) || "";
|
|
}
|
|
exports.getUrlScheme = getUrlScheme;
|
|
function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
|
|
var out = [];
|
|
if (lang_1.isPresent(opt_scheme)) {
|
|
out.push(opt_scheme + ':');
|
|
}
|
|
if (lang_1.isPresent(opt_domain)) {
|
|
out.push('//');
|
|
if (lang_1.isPresent(opt_userInfo)) {
|
|
out.push(opt_userInfo + '@');
|
|
}
|
|
out.push(opt_domain);
|
|
if (lang_1.isPresent(opt_port)) {
|
|
out.push(':' + opt_port);
|
|
}
|
|
}
|
|
if (lang_1.isPresent(opt_path)) {
|
|
out.push(opt_path);
|
|
}
|
|
if (lang_1.isPresent(opt_queryData)) {
|
|
out.push('?' + opt_queryData);
|
|
}
|
|
if (lang_1.isPresent(opt_fragment)) {
|
|
out.push('#' + opt_fragment);
|
|
}
|
|
return out.join('');
|
|
}
|
|
var _splitRe = lang_1.RegExpWrapper.create('^' + '(?:' + '([^:/?#.]+)' + ':)?' + '(?://' + '(?:([^/?#]*)@)?' + '([\\w\\d\\-\\u0100-\\uffff.%]*)' + '(?::([0-9]+))?' + ')?' + '([^?#]+)?' + '(?:\\?([^#]*))?' + '(?:#(.*))?' + '$');
|
|
var _ComponentIndex;
|
|
(function(_ComponentIndex) {
|
|
_ComponentIndex[_ComponentIndex["Scheme"] = 1] = "Scheme";
|
|
_ComponentIndex[_ComponentIndex["UserInfo"] = 2] = "UserInfo";
|
|
_ComponentIndex[_ComponentIndex["Domain"] = 3] = "Domain";
|
|
_ComponentIndex[_ComponentIndex["Port"] = 4] = "Port";
|
|
_ComponentIndex[_ComponentIndex["Path"] = 5] = "Path";
|
|
_ComponentIndex[_ComponentIndex["QueryData"] = 6] = "QueryData";
|
|
_ComponentIndex[_ComponentIndex["Fragment"] = 7] = "Fragment";
|
|
})(_ComponentIndex || (_ComponentIndex = {}));
|
|
function _split(uri) {
|
|
return lang_1.RegExpWrapper.firstMatch(_splitRe, uri);
|
|
}
|
|
function _removeDotSegments(path) {
|
|
if (path == '/')
|
|
return '/';
|
|
var leadingSlash = path[0] == '/' ? '/' : '';
|
|
var trailingSlash = path[path.length - 1] === '/' ? '/' : '';
|
|
var segments = path.split('/');
|
|
var out = [];
|
|
var up = 0;
|
|
for (var pos = 0; pos < segments.length; pos++) {
|
|
var segment = segments[pos];
|
|
switch (segment) {
|
|
case '':
|
|
case '.':
|
|
break;
|
|
case '..':
|
|
if (out.length > 0) {
|
|
out.pop();
|
|
} else {
|
|
up++;
|
|
}
|
|
break;
|
|
default:
|
|
out.push(segment);
|
|
}
|
|
}
|
|
if (leadingSlash == '') {
|
|
while (up-- > 0) {
|
|
out.unshift('..');
|
|
}
|
|
if (out.length === 0)
|
|
out.push('.');
|
|
}
|
|
return leadingSlash + out.join('/') + trailingSlash;
|
|
}
|
|
function _joinAndCanonicalizePath(parts) {
|
|
var path = parts[_ComponentIndex.Path];
|
|
path = lang_1.isBlank(path) ? '' : _removeDotSegments(path);
|
|
parts[_ComponentIndex.Path] = path;
|
|
return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
|
|
}
|
|
function _resolveUrl(base, url) {
|
|
var parts = _split(encodeURI(url));
|
|
var baseParts = _split(base);
|
|
if (lang_1.isPresent(parts[_ComponentIndex.Scheme])) {
|
|
return _joinAndCanonicalizePath(parts);
|
|
} else {
|
|
parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
|
|
}
|
|
for (var i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
|
|
if (lang_1.isBlank(parts[i])) {
|
|
parts[i] = baseParts[i];
|
|
}
|
|
}
|
|
if (parts[_ComponentIndex.Path][0] == '/') {
|
|
return _joinAndCanonicalizePath(parts);
|
|
}
|
|
var path = baseParts[_ComponentIndex.Path];
|
|
if (lang_1.isBlank(path))
|
|
path = '/';
|
|
var index = path.lastIndexOf('/');
|
|
path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
|
|
parts[_ComponentIndex.Path] = path;
|
|
return _joinAndCanonicalizePath(parts);
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("89", ["5f", "62", "65", "66", "82", "72", "6a", "20", "39", "6f", "6b", "6c", "67", "68", "69", "6e", "60", "74", "87", "7a"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
var runtime_compiler_1 = $__require('5f');
|
|
var template_compiler_1 = $__require('62');
|
|
exports.TemplateCompiler = template_compiler_1.TemplateCompiler;
|
|
var directive_metadata_1 = $__require('65');
|
|
exports.CompileDirectiveMetadata = directive_metadata_1.CompileDirectiveMetadata;
|
|
exports.CompileTypeMetadata = directive_metadata_1.CompileTypeMetadata;
|
|
exports.CompileTemplateMetadata = directive_metadata_1.CompileTemplateMetadata;
|
|
var source_module_1 = $__require('66');
|
|
exports.SourceModule = source_module_1.SourceModule;
|
|
exports.SourceWithImports = source_module_1.SourceWithImports;
|
|
var platform_directives_and_pipes_1 = $__require('82');
|
|
exports.PLATFORM_DIRECTIVES = platform_directives_and_pipes_1.PLATFORM_DIRECTIVES;
|
|
exports.PLATFORM_PIPES = platform_directives_and_pipes_1.PLATFORM_PIPES;
|
|
__export($__require('72'));
|
|
var template_parser_1 = $__require('6a');
|
|
exports.TEMPLATE_TRANSFORMS = template_parser_1.TEMPLATE_TRANSFORMS;
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var template_parser_2 = $__require('6a');
|
|
var html_parser_1 = $__require('6f');
|
|
var template_normalizer_1 = $__require('6b');
|
|
var runtime_metadata_1 = $__require('6c');
|
|
var change_detector_compiler_1 = $__require('67');
|
|
var style_compiler_1 = $__require('68');
|
|
var command_compiler_1 = $__require('69');
|
|
var template_compiler_2 = $__require('62');
|
|
var change_detection_1 = $__require('6e');
|
|
var compiler_1 = $__require('60');
|
|
var runtime_compiler_2 = $__require('5f');
|
|
var element_schema_registry_1 = $__require('74');
|
|
var dom_element_schema_registry_1 = $__require('87');
|
|
var url_resolver_1 = $__require('7a');
|
|
var change_detection_2 = $__require('6e');
|
|
function _createChangeDetectorGenConfig() {
|
|
return new change_detection_1.ChangeDetectorGenConfig(lang_1.assertionsEnabled(), false, true);
|
|
}
|
|
exports.COMPILER_PROVIDERS = lang_1.CONST_EXPR([change_detection_2.Lexer, change_detection_2.Parser, html_parser_1.HtmlParser, template_parser_2.TemplateParser, template_normalizer_1.TemplateNormalizer, runtime_metadata_1.RuntimeMetadataResolver, url_resolver_1.DEFAULT_PACKAGE_URL_PROVIDER, style_compiler_1.StyleCompiler, command_compiler_1.CommandCompiler, change_detector_compiler_1.ChangeDetectionCompiler, new di_1.Provider(change_detection_1.ChangeDetectorGenConfig, {
|
|
useFactory: _createChangeDetectorGenConfig,
|
|
deps: []
|
|
}), template_compiler_2.TemplateCompiler, new di_1.Provider(runtime_compiler_2.RuntimeCompiler, {useClass: runtime_compiler_1.RuntimeCompiler_}), new di_1.Provider(compiler_1.Compiler, {useExisting: runtime_compiler_2.RuntimeCompiler}), dom_element_schema_registry_1.DomElementSchemaRegistry, new di_1.Provider(element_schema_registry_1.ElementSchemaRegistry, {useExisting: dom_element_schema_registry_1.DomElementSchemaRegistry}), url_resolver_1.UrlResolver]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("8a", ["7a", "79", "89"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
__export($__require('7a'));
|
|
__export($__require('79'));
|
|
__export($__require('89'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("79", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var XHR = (function() {
|
|
function XHR() {}
|
|
XHR.prototype.get = function(url) {
|
|
return null;
|
|
};
|
|
return XHR;
|
|
})();
|
|
exports.XHR = XHR;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3e", ["8b", "20", "79"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var promise_1 = $__require('8b');
|
|
var lang_1 = $__require('20');
|
|
var xhr_1 = $__require('79');
|
|
var XHRImpl = (function(_super) {
|
|
__extends(XHRImpl, _super);
|
|
function XHRImpl() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
XHRImpl.prototype.get = function(url) {
|
|
var completer = promise_1.PromiseWrapper.completer();
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', url, true);
|
|
xhr.responseType = 'text';
|
|
xhr.onload = function() {
|
|
var response = lang_1.isPresent(xhr.response) ? xhr.response : xhr.responseText;
|
|
var status = xhr.status === 1223 ? 204 : xhr.status;
|
|
if (status === 0) {
|
|
status = response ? 200 : 0;
|
|
}
|
|
if (200 <= status && status <= 300) {
|
|
completer.resolve(response);
|
|
} else {
|
|
completer.reject("Failed to load " + url, null);
|
|
}
|
|
};
|
|
xhr.onerror = function() {
|
|
completer.reject("Failed to load " + url, null);
|
|
};
|
|
xhr.send();
|
|
return completer.promise;
|
|
};
|
|
return XHRImpl;
|
|
})(xhr_1.XHR);
|
|
exports.XHRImpl = XHRImpl;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15", ["33", "5d", "20", "8a", "14", "8c", "3e", "39", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var angular_entrypoint_1 = $__require('33');
|
|
exports.AngularEntrypoint = angular_entrypoint_1.AngularEntrypoint;
|
|
var browser_common_1 = $__require('5d');
|
|
exports.BROWSER_PROVIDERS = browser_common_1.BROWSER_PROVIDERS;
|
|
exports.ELEMENT_PROBE_BINDINGS = browser_common_1.ELEMENT_PROBE_BINDINGS;
|
|
exports.ELEMENT_PROBE_PROVIDERS = browser_common_1.ELEMENT_PROBE_PROVIDERS;
|
|
exports.inspectNativeElement = browser_common_1.inspectNativeElement;
|
|
exports.BrowserDomAdapter = browser_common_1.BrowserDomAdapter;
|
|
exports.By = browser_common_1.By;
|
|
exports.Title = browser_common_1.Title;
|
|
exports.DOCUMENT = browser_common_1.DOCUMENT;
|
|
exports.enableDebugTools = browser_common_1.enableDebugTools;
|
|
exports.disableDebugTools = browser_common_1.disableDebugTools;
|
|
var lang_1 = $__require('20');
|
|
var browser_common_2 = $__require('5d');
|
|
var compiler_1 = $__require('8a');
|
|
var core_1 = $__require('14');
|
|
var reflection_capabilities_1 = $__require('8c');
|
|
var xhr_impl_1 = $__require('3e');
|
|
var compiler_2 = $__require('8a');
|
|
var di_1 = $__require('39');
|
|
exports.BROWSER_APP_PROVIDERS = lang_1.CONST_EXPR([browser_common_2.BROWSER_APP_COMMON_PROVIDERS, compiler_1.COMPILER_PROVIDERS, new di_1.Provider(compiler_2.XHR, {useClass: xhr_impl_1.XHRImpl})]);
|
|
function bootstrap(appComponentType, customProviders) {
|
|
core_1.reflector.reflectionCapabilities = new reflection_capabilities_1.ReflectionCapabilities();
|
|
var appProviders = lang_1.isPresent(customProviders) ? [exports.BROWSER_APP_PROVIDERS, customProviders] : exports.BROWSER_APP_PROVIDERS;
|
|
return core_1.platform(browser_common_2.BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
|
|
}
|
|
exports.bootstrap = bootstrap;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('1c', ['3', '4', '5', '6', '7', '11', '12', '14', '15', '20', '59', '1d'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, _slicedToArray, _Array$from, NgZone, ChangeDetectionStrategy, BrowserDomAdapter, global, document, redocEvents, CHANGE, INVIEW_POSITION, SideMenu;
|
|
|
|
return {
|
|
setters: [function (_7) {
|
|
RedocComponent = _7.RedocComponent;
|
|
BaseComponent = _7.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_5) {
|
|
_slicedToArray = _5['default'];
|
|
}, function (_6) {
|
|
_Array$from = _6['default'];
|
|
}, function (_8) {
|
|
NgZone = _8.NgZone;
|
|
ChangeDetectionStrategy = _8.ChangeDetectionStrategy;
|
|
}, function (_10) {
|
|
BrowserDomAdapter = _10.BrowserDomAdapter;
|
|
}, function (_11) {
|
|
global = _11.global;
|
|
}, function (_9) {
|
|
document = _9.document;
|
|
}, function (_d) {
|
|
redocEvents = _d.redocEvents;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
CHANGE = {
|
|
NEXT: 1,
|
|
BACK: -1,
|
|
INITIAL: 0
|
|
};
|
|
INVIEW_POSITION = {
|
|
ABOVE: 1,
|
|
BELLOW: -1,
|
|
INVIEW: 0
|
|
};
|
|
|
|
SideMenu = (function (_BaseComponent) {
|
|
_inherits(SideMenu, _BaseComponent);
|
|
|
|
function SideMenu(schemaMgr, adapter, zone, redoc) {
|
|
var _this = this;
|
|
|
|
_classCallCheck(this, _SideMenu);
|
|
|
|
_get(Object.getPrototypeOf(_SideMenu.prototype), 'constructor', this).call(this, schemaMgr);
|
|
this.zone = zone;
|
|
this.adapter = adapter;
|
|
this.redoc = redoc;
|
|
|
|
this.scrollParent = this.redoc.scrollParent;
|
|
|
|
// for some reason constructor is not run inside zone
|
|
// as workaround running it manually
|
|
this.zone.run(function () {
|
|
_this.bindEvents();
|
|
});
|
|
this.activeCatIdx = 0;
|
|
this.activeMethodIdx = -1;
|
|
this.prevOffsetY = null;
|
|
|
|
redocEvents.bootstrapped.subscribe(function () {
|
|
return _this.hashScroll();
|
|
});
|
|
}
|
|
|
|
_createClass(SideMenu, [{
|
|
key: 'scrollY',
|
|
value: function scrollY() {
|
|
return this.scrollParent.scrollY != null ? this.scrollParent.scrollY : this.scrollParent.scrollTop;
|
|
}
|
|
}, {
|
|
key: 'hashScroll',
|
|
value: function hashScroll(evt) {
|
|
var hash = this.adapter.getLocation().hash;
|
|
if (!hash) return;
|
|
|
|
hash = hash.substr(1);
|
|
var tag = hash.split('/')[0];
|
|
var ptr = hash.substr(tag.length);
|
|
var el = this.getMethodEl(ptr, tag);
|
|
if (el) this.scrollTo(el);
|
|
if (evt) evt.preventDefault();
|
|
}
|
|
}, {
|
|
key: 'bindEvents',
|
|
value: function bindEvents() {
|
|
var _this2 = this;
|
|
|
|
this.prevOffsetY = this.scrollY();
|
|
this.scrollYOffset = this.redoc.options.scrollYOffset;
|
|
this._cancel = {};
|
|
this._cancel.scroll = this.adapter.onAndCancel(this.scrollParent, 'scroll', function () {
|
|
_this2.scrollHandler();
|
|
});
|
|
this._cancel.hash = this.adapter.onAndCancel(global, 'hashchange', function (evt) {
|
|
return _this2.hashScroll(evt);
|
|
});
|
|
}
|
|
}, {
|
|
key: 'destroy',
|
|
value: function destroy() {
|
|
this._cancel.scroll();
|
|
this._cancel.hash();
|
|
}
|
|
}, {
|
|
key: 'activateAndScroll',
|
|
value: function activateAndScroll(idx, methodIdx) {
|
|
this.activate(idx, methodIdx);
|
|
this.scrollToActive();
|
|
}
|
|
}, {
|
|
key: 'scrollTo',
|
|
value: function scrollTo(el) {
|
|
// TODO: rewrite this to use offsetTop as more reliable solution
|
|
var subjRect = el.getBoundingClientRect();
|
|
var offset = this.scrollY() + subjRect.top - this.scrollYOffset() + 1;
|
|
if (this.scrollParent.scrollTo) {
|
|
this.scrollParent.scrollTo(0, offset);
|
|
} else {
|
|
this.scrollParent.scrollTop = offset;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'scrollToActive',
|
|
value: function scrollToActive() {
|
|
this.scrollTo(this.getCurrentMethodEl());
|
|
}
|
|
}, {
|
|
key: 'activate',
|
|
value: function activate(catIdx, methodIdx) {
|
|
var menu = this.data.menu;
|
|
menu[this.activeCatIdx].active = false;
|
|
if (menu[this.activeCatIdx].methods.length) {
|
|
if (this.activeMethodIdx >= 0) {
|
|
menu[this.activeCatIdx].methods[this.activeMethodIdx].active = false;
|
|
}
|
|
}
|
|
|
|
this.activeCatIdx = catIdx;
|
|
this.activeMethodIdx = methodIdx;
|
|
menu[catIdx].active = true;
|
|
this.activeMethodPtr = null;
|
|
if (menu[catIdx].methods.length && methodIdx > -1) {
|
|
var currentItem = menu[catIdx].methods[methodIdx];
|
|
currentItem.active = true;
|
|
this.activeMethodPtr = currentItem.pointer;
|
|
}
|
|
}
|
|
}, {
|
|
key: '_calcActiveIndexes',
|
|
value: function _calcActiveIndexes(offset) {
|
|
var menu = this.data.menu;
|
|
var catCount = menu.length;
|
|
var catLength = menu[this.activeCatIdx].methods.length;
|
|
|
|
var resMethodIdx = this.activeMethodIdx + offset;
|
|
var resCatIdx = this.activeCatIdx;
|
|
|
|
if (resMethodIdx > catLength - 1) {
|
|
resCatIdx++;
|
|
resMethodIdx = -1;
|
|
}
|
|
if (resMethodIdx < -1) {
|
|
var prevCatIdx = --resCatIdx;
|
|
catLength = menu[Math.max(prevCatIdx, 0)].methods.length;
|
|
resMethodIdx = catLength - 1;
|
|
}
|
|
if (resCatIdx > catCount - 1) {
|
|
resCatIdx = catCount - 1;
|
|
resMethodIdx = catLength - 1;
|
|
}
|
|
if (resCatIdx < 0) {
|
|
resCatIdx = 0;
|
|
resMethodIdx = 0;
|
|
}
|
|
|
|
return [resCatIdx, resMethodIdx];
|
|
}
|
|
}, {
|
|
key: 'changeActive',
|
|
value: function changeActive() {
|
|
var offset = arguments.length <= 0 || arguments[0] === undefined ? 1 : arguments[0];
|
|
|
|
var _calcActiveIndexes2 = this._calcActiveIndexes(offset);
|
|
|
|
var _calcActiveIndexes22 = _slicedToArray(_calcActiveIndexes2, 2);
|
|
|
|
var catIdx = _calcActiveIndexes22[0];
|
|
var methodIdx = _calcActiveIndexes22[1];
|
|
|
|
this.activate(catIdx, methodIdx);
|
|
return methodIdx === 0 && catIdx === 0;
|
|
}
|
|
}, {
|
|
key: 'getMethodEl',
|
|
value: function getMethodEl(ptr, tag) {
|
|
var selector = ptr ? '[pointer="' + ptr + '"][tag="' + tag + '"]' : '[tag="' + tag + '"]';
|
|
return document.querySelector(selector);
|
|
}
|
|
}, {
|
|
key: 'getCurrentMethodEl',
|
|
value: function getCurrentMethodEl() {
|
|
return this.getMethodEl(this.activeMethodPtr, this.data.menu[this.activeCatIdx].name);
|
|
}
|
|
|
|
/* returns 1 if element if above the view, 0 if in view and -1 below the view */
|
|
}, {
|
|
key: 'getElementInViewPos',
|
|
value: function getElementInViewPos(el) {
|
|
if (Math.floor(el.getBoundingClientRect().top) > this.scrollYOffset()) {
|
|
return INVIEW_POSITION.ABOVE;
|
|
}
|
|
|
|
if (el.getBoundingClientRect().bottom <= this.scrollYOffset()) {
|
|
return INVIEW_POSITION.BELLOW;
|
|
}
|
|
return INVIEW_POSITION.INVIEW;
|
|
}
|
|
}, {
|
|
key: 'scrollHandler',
|
|
value: function scrollHandler() {
|
|
var isScrolledDown = this.scrollY() - this.prevOffsetY > 0;
|
|
this.prevOffsetY = this.scrollY();
|
|
var stable = false;
|
|
while (!stable) {
|
|
var activeMethodHost = this.getCurrentMethodEl();
|
|
if (!activeMethodHost) return;
|
|
var elementInViewPos = this.getElementInViewPos(activeMethodHost);
|
|
if (isScrolledDown && elementInViewPos === INVIEW_POSITION.BELLOW) {
|
|
stable = this.changeActive(CHANGE.NEXT);
|
|
continue;
|
|
}
|
|
if (!isScrolledDown && elementInViewPos === INVIEW_POSITION.ABOVE) {
|
|
stable = this.changeActive(CHANGE.BACK);
|
|
continue;
|
|
}
|
|
stable = true;
|
|
}
|
|
}
|
|
}, {
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
this.data = {};
|
|
this.data.menu = _Array$from(this.schemaMgr.buildMenuTree().entries()).map(function (el) {
|
|
return { name: el[0], description: el[1].description, methods: el[1].methods };
|
|
});
|
|
}
|
|
}, {
|
|
key: 'init',
|
|
value: function init() {
|
|
this.changeActive(CHANGE.INITIAL);
|
|
}
|
|
}]);
|
|
|
|
var _SideMenu = SideMenu;
|
|
SideMenu = RedocComponent({
|
|
selector: 'side-menu',
|
|
template: '\n <h2 class="menu-header"> Api reference </h2>\n <div *ngFor="var cat of data.menu; #idx = index" class="menu-cat">\n\n <label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [ngClass]="{active: cat.active}"> {{cat.name}}</label>\n <ul class="menu-subitems" [ngClass]="{active: cat.active}">\n <li *ngFor="var method of cat.methods; var methIdx = index"\n [ngClass]="{active: method.active}"\n (click)="activateAndScroll(idx, methIdx)">\n {{method.summary}}\n </li>\n </ul>\n\n </div>\n ',
|
|
styles: ['\n .menu-header {\n text-transform: uppercase;\n color: #00329F;\n padding: 0 20px;\n margin: 10px 0;\n font-size: 16px; }\n\n .menu-cat-header {\n font-size: 15px;\n cursor: pointer;\n color: #384248;\n text-transform: uppercase;\n background-color: #FAFAFA;\n display: block;\n padding: 5px 20px; }\n\n .menu-cat:nth-of-type(even) .menu-cat-header {\n background-color: #F0F0F0; }\n\n .menu-subitems {\n margin: 0;\n padding: 0;\n height: 0;\n overflow: hidden; }\n\n .menu-subitems.active {\n height: auto; }\n\n .menu-subitems li {\n list-style: none inside none;\n cursor: pointer;\n padding: 5px 20px;\n padding-left: 40px;\n background-color: #FAFAFA;\n overflow: hidden;\n text-overflow: ellipsis; }\n\n .menu-subitems li:nth-of-type(even) {\n background-color: #F0F0F0; }\n\n .menu-cat:nth-of-type(odd) .menu-subitems li {\n background-color: #F0F0F0; }\n\n .menu-cat:nth-of-type(odd) .menu-subitems li:nth-of-type(even) {\n background-color: #FAFAFA; }\n\n .menu-cat-header.active, .menu-subitems li.active {\n background-color: #E6E6E6 !important;\n font-weight: bold; }\n '],
|
|
changeDetection: ChangeDetectionStrategy.Default
|
|
})(SideMenu) || SideMenu;
|
|
return SideMenu;
|
|
})(BaseComponent);
|
|
|
|
_export('default', SideMenu);
|
|
|
|
SideMenu.parameters = SideMenu.parameters.concat([[BrowserDomAdapter], [NgZone]]);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("8d", ["8e", "8f", "90", "91", "92", "93", "94", "95"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ctx = $__require('8e'),
|
|
$export = $__require('8f'),
|
|
toObject = $__require('90'),
|
|
call = $__require('91'),
|
|
isArrayIter = $__require('92'),
|
|
toLength = $__require('93'),
|
|
getIterFn = $__require('94');
|
|
$export($export.S + $export.F * !$__require('95')(function(iter) {
|
|
Array.from(iter);
|
|
}), 'Array', {from: function from(arrayLike) {
|
|
var O = toObject(arrayLike),
|
|
C = typeof this == 'function' ? this : Array,
|
|
$$ = arguments,
|
|
$$len = $$.length,
|
|
mapfn = $$len > 1 ? $$[1] : undefined,
|
|
mapping = mapfn !== undefined,
|
|
index = 0,
|
|
iterFn = getIterFn(O),
|
|
length,
|
|
result,
|
|
step,
|
|
iterator;
|
|
if (mapping)
|
|
mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2);
|
|
if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
|
|
for (iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++) {
|
|
result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value;
|
|
}
|
|
} else {
|
|
length = toLength(O.length);
|
|
for (result = new C(length); length > index; index++) {
|
|
result[index] = mapping ? mapfn(O[index], index) : O[index];
|
|
}
|
|
}
|
|
result.length = index;
|
|
return result;
|
|
}});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("96", ["30", "8d", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('30');
|
|
$__require('8d');
|
|
module.exports = $__require('2d').Array.from;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12", ["96"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('96'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("97", ["12"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var _Array$from = $__require('12')["default"];
|
|
exports["default"] = function(arr) {
|
|
if (Array.isArray(arr)) {
|
|
for (var i = 0,
|
|
arr2 = Array(arr.length); i < arr.length; i++)
|
|
arr2[i] = arr[i];
|
|
return arr2;
|
|
} else {
|
|
return _Array$from(arr);
|
|
}
|
|
};
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("98", ["99", "90", "9a", "9b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99'),
|
|
toObject = $__require('90'),
|
|
IObject = $__require('9a');
|
|
module.exports = $__require('9b')(function() {
|
|
var a = Object.assign,
|
|
A = {},
|
|
B = {},
|
|
S = Symbol(),
|
|
K = 'abcdefghijklmnopqrst';
|
|
A[S] = 7;
|
|
K.split('').forEach(function(k) {
|
|
B[k] = k;
|
|
});
|
|
return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K;
|
|
}) ? function assign(target, source) {
|
|
var T = toObject(target),
|
|
$$ = arguments,
|
|
$$len = $$.length,
|
|
index = 1,
|
|
getKeys = $.getKeys,
|
|
getSymbols = $.getSymbols,
|
|
isEnum = $.isEnum;
|
|
while ($$len > index) {
|
|
var S = IObject($$[index++]),
|
|
keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S),
|
|
length = keys.length,
|
|
j = 0,
|
|
key;
|
|
while (length > j)
|
|
if (isEnum.call(S, key = keys[j++]))
|
|
T[key] = S[key];
|
|
}
|
|
return T;
|
|
} : Object.assign;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9c", ["8f", "98"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $export = $__require('8f');
|
|
$export($export.S + $export.F, 'Object', {assign: $__require('98')});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9d", ["9c", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('9c');
|
|
module.exports = $__require('2d').Object.assign;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17", ["9d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('9d'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9e", ["20", "63", "14", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var core_1 = $__require('14');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var ObservableStrategy = (function() {
|
|
function ObservableStrategy() {}
|
|
ObservableStrategy.prototype.createSubscription = function(async, updateLatestValue) {
|
|
return async_1.ObservableWrapper.subscribe(async, updateLatestValue, function(e) {
|
|
throw e;
|
|
});
|
|
};
|
|
ObservableStrategy.prototype.dispose = function(subscription) {
|
|
async_1.ObservableWrapper.dispose(subscription);
|
|
};
|
|
ObservableStrategy.prototype.onDestroy = function(subscription) {
|
|
async_1.ObservableWrapper.dispose(subscription);
|
|
};
|
|
return ObservableStrategy;
|
|
})();
|
|
var PromiseStrategy = (function() {
|
|
function PromiseStrategy() {}
|
|
PromiseStrategy.prototype.createSubscription = function(async, updateLatestValue) {
|
|
return async.then(updateLatestValue);
|
|
};
|
|
PromiseStrategy.prototype.dispose = function(subscription) {};
|
|
PromiseStrategy.prototype.onDestroy = function(subscription) {};
|
|
return PromiseStrategy;
|
|
})();
|
|
var _promiseStrategy = new PromiseStrategy();
|
|
var _observableStrategy = new ObservableStrategy();
|
|
var AsyncPipe = (function() {
|
|
function AsyncPipe(_ref) {
|
|
this._latestValue = null;
|
|
this._latestReturnedValue = null;
|
|
this._subscription = null;
|
|
this._obj = null;
|
|
this._strategy = null;
|
|
this._ref = _ref;
|
|
}
|
|
AsyncPipe.prototype.ngOnDestroy = function() {
|
|
if (lang_1.isPresent(this._subscription)) {
|
|
this._dispose();
|
|
}
|
|
};
|
|
AsyncPipe.prototype.transform = function(obj, args) {
|
|
if (lang_1.isBlank(this._obj)) {
|
|
if (lang_1.isPresent(obj)) {
|
|
this._subscribe(obj);
|
|
}
|
|
return this._latestValue;
|
|
}
|
|
if (obj !== this._obj) {
|
|
this._dispose();
|
|
return this.transform(obj);
|
|
}
|
|
if (this._latestValue === this._latestReturnedValue) {
|
|
return this._latestReturnedValue;
|
|
} else {
|
|
this._latestReturnedValue = this._latestValue;
|
|
return core_1.WrappedValue.wrap(this._latestValue);
|
|
}
|
|
};
|
|
AsyncPipe.prototype._subscribe = function(obj) {
|
|
var _this = this;
|
|
this._obj = obj;
|
|
this._strategy = this._selectStrategy(obj);
|
|
this._subscription = this._strategy.createSubscription(obj, function(value) {
|
|
return _this._updateLatestValue(obj, value);
|
|
});
|
|
};
|
|
AsyncPipe.prototype._selectStrategy = function(obj) {
|
|
if (lang_1.isPromise(obj)) {
|
|
return _promiseStrategy;
|
|
} else if (async_1.ObservableWrapper.isObservable(obj)) {
|
|
return _observableStrategy;
|
|
} else {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(AsyncPipe, obj);
|
|
}
|
|
};
|
|
AsyncPipe.prototype._dispose = function() {
|
|
this._strategy.dispose(this._subscription);
|
|
this._latestValue = null;
|
|
this._latestReturnedValue = null;
|
|
this._subscription = null;
|
|
this._obj = null;
|
|
};
|
|
AsyncPipe.prototype._updateLatestValue = function(async, value) {
|
|
if (async === this._obj) {
|
|
this._latestValue = value;
|
|
this._ref.markForCheck();
|
|
}
|
|
};
|
|
AsyncPipe = __decorate([core_1.Pipe({
|
|
name: 'async',
|
|
pure: false
|
|
}), core_1.Injectable(), __metadata('design:paramtypes', [core_1.ChangeDetectorRef])], AsyncPipe);
|
|
return AsyncPipe;
|
|
})();
|
|
exports.AsyncPipe = AsyncPipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a0", ["20", "14", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var UpperCasePipe = (function() {
|
|
function UpperCasePipe() {}
|
|
UpperCasePipe.prototype.transform = function(value, args) {
|
|
if (args === void 0) {
|
|
args = null;
|
|
}
|
|
if (lang_1.isBlank(value))
|
|
return value;
|
|
if (!lang_1.isString(value)) {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(UpperCasePipe, value);
|
|
}
|
|
return value.toUpperCase();
|
|
};
|
|
UpperCasePipe = __decorate([lang_1.CONST(), core_1.Pipe({name: 'uppercase'}), core_1.Injectable(), __metadata('design:paramtypes', [])], UpperCasePipe);
|
|
return UpperCasePipe;
|
|
})();
|
|
exports.UpperCasePipe = UpperCasePipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a1", ["20", "14", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var LowerCasePipe = (function() {
|
|
function LowerCasePipe() {}
|
|
LowerCasePipe.prototype.transform = function(value, args) {
|
|
if (args === void 0) {
|
|
args = null;
|
|
}
|
|
if (lang_1.isBlank(value))
|
|
return value;
|
|
if (!lang_1.isString(value)) {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(LowerCasePipe, value);
|
|
}
|
|
return value.toLowerCase();
|
|
};
|
|
LowerCasePipe = __decorate([lang_1.CONST(), core_1.Pipe({name: 'lowercase'}), core_1.Injectable(), __metadata('design:paramtypes', [])], LowerCasePipe);
|
|
return LowerCasePipe;
|
|
})();
|
|
exports.LowerCasePipe = LowerCasePipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a2", ["20", "14"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var JsonPipe = (function() {
|
|
function JsonPipe() {}
|
|
JsonPipe.prototype.transform = function(value, args) {
|
|
if (args === void 0) {
|
|
args = null;
|
|
}
|
|
return lang_1.Json.stringify(value);
|
|
};
|
|
JsonPipe = __decorate([lang_1.CONST(), core_1.Pipe({
|
|
name: 'json',
|
|
pure: false
|
|
}), core_1.Injectable(), __metadata('design:paramtypes', [])], JsonPipe);
|
|
return JsonPipe;
|
|
})();
|
|
exports.JsonPipe = JsonPipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a3", ["20", "3c", "37", "14", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var core_1 = $__require('14');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var SlicePipe = (function() {
|
|
function SlicePipe() {}
|
|
SlicePipe.prototype.transform = function(value, args) {
|
|
if (args === void 0) {
|
|
args = null;
|
|
}
|
|
if (lang_1.isBlank(args) || args.length == 0) {
|
|
throw new exceptions_1.BaseException('Slice pipe requires one argument');
|
|
}
|
|
if (!this.supports(value)) {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(SlicePipe, value);
|
|
}
|
|
if (lang_1.isBlank(value))
|
|
return value;
|
|
var start = args[0];
|
|
var end = args.length > 1 ? args[1] : null;
|
|
if (lang_1.isString(value)) {
|
|
return lang_1.StringWrapper.slice(value, start, end);
|
|
}
|
|
return collection_1.ListWrapper.slice(value, start, end);
|
|
};
|
|
SlicePipe.prototype.supports = function(obj) {
|
|
return lang_1.isString(obj) || lang_1.isArray(obj);
|
|
};
|
|
SlicePipe = __decorate([core_1.Pipe({
|
|
name: 'slice',
|
|
pure: false
|
|
}), core_1.Injectable(), __metadata('design:paramtypes', [])], SlicePipe);
|
|
return SlicePipe;
|
|
})();
|
|
exports.SlicePipe = SlicePipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a4", ["20", "a5", "14", "37", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var intl_1 = $__require('a5');
|
|
var core_1 = $__require('14');
|
|
var collection_1 = $__require('37');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var defaultLocale = 'en-US';
|
|
var DatePipe = (function() {
|
|
function DatePipe() {}
|
|
DatePipe.prototype.transform = function(value, args) {
|
|
if (lang_1.isBlank(value))
|
|
return null;
|
|
if (!this.supports(value)) {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(DatePipe, value);
|
|
}
|
|
var pattern = lang_1.isPresent(args) && args.length > 0 ? args[0] : 'mediumDate';
|
|
if (lang_1.isNumber(value)) {
|
|
value = lang_1.DateWrapper.fromMillis(value);
|
|
}
|
|
if (collection_1.StringMapWrapper.contains(DatePipe._ALIASES, pattern)) {
|
|
pattern = collection_1.StringMapWrapper.get(DatePipe._ALIASES, pattern);
|
|
}
|
|
return intl_1.DateFormatter.format(value, defaultLocale, pattern);
|
|
};
|
|
DatePipe.prototype.supports = function(obj) {
|
|
return lang_1.isDate(obj) || lang_1.isNumber(obj);
|
|
};
|
|
DatePipe._ALIASES = {
|
|
'medium': 'yMMMdjms',
|
|
'short': 'yMdjm',
|
|
'fullDate': 'yMMMMEEEEd',
|
|
'longDate': 'yMMMMd',
|
|
'mediumDate': 'yMMMd',
|
|
'shortDate': 'yMd',
|
|
'mediumTime': 'jms',
|
|
'shortTime': 'jm'
|
|
};
|
|
DatePipe = __decorate([lang_1.CONST(), core_1.Pipe({
|
|
name: 'date',
|
|
pure: true
|
|
}), core_1.Injectable(), __metadata('design:paramtypes', [])], DatePipe);
|
|
return DatePipe;
|
|
})();
|
|
exports.DatePipe = DatePipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a5", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(NumberFormatStyle) {
|
|
NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
|
|
NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
|
|
NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
|
|
})(exports.NumberFormatStyle || (exports.NumberFormatStyle = {}));
|
|
var NumberFormatStyle = exports.NumberFormatStyle;
|
|
var NumberFormatter = (function() {
|
|
function NumberFormatter() {}
|
|
NumberFormatter.format = function(num, locale, style, _a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
_c = _b.minimumIntegerDigits,
|
|
minimumIntegerDigits = _c === void 0 ? 1 : _c,
|
|
_d = _b.minimumFractionDigits,
|
|
minimumFractionDigits = _d === void 0 ? 0 : _d,
|
|
_e = _b.maximumFractionDigits,
|
|
maximumFractionDigits = _e === void 0 ? 3 : _e,
|
|
currency = _b.currency,
|
|
_f = _b.currencyAsSymbol,
|
|
currencyAsSymbol = _f === void 0 ? false : _f;
|
|
var intlOptions = {
|
|
minimumIntegerDigits: minimumIntegerDigits,
|
|
minimumFractionDigits: minimumFractionDigits,
|
|
maximumFractionDigits: maximumFractionDigits
|
|
};
|
|
intlOptions.style = NumberFormatStyle[style].toLowerCase();
|
|
if (style == NumberFormatStyle.Currency) {
|
|
intlOptions.currency = currency;
|
|
intlOptions.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
|
|
}
|
|
return new Intl.NumberFormat(locale, intlOptions).format(num);
|
|
};
|
|
return NumberFormatter;
|
|
})();
|
|
exports.NumberFormatter = NumberFormatter;
|
|
function digitCondition(len) {
|
|
return len == 2 ? '2-digit' : 'numeric';
|
|
}
|
|
function nameCondition(len) {
|
|
return len < 4 ? 'short' : 'long';
|
|
}
|
|
function extractComponents(pattern) {
|
|
var ret = {};
|
|
var i = 0,
|
|
j;
|
|
while (i < pattern.length) {
|
|
j = i;
|
|
while (j < pattern.length && pattern[j] == pattern[i])
|
|
j++;
|
|
var len = j - i;
|
|
switch (pattern[i]) {
|
|
case 'G':
|
|
ret.era = nameCondition(len);
|
|
break;
|
|
case 'y':
|
|
ret.year = digitCondition(len);
|
|
break;
|
|
case 'M':
|
|
if (len >= 3)
|
|
ret.month = nameCondition(len);
|
|
else
|
|
ret.month = digitCondition(len);
|
|
break;
|
|
case 'd':
|
|
ret.day = digitCondition(len);
|
|
break;
|
|
case 'E':
|
|
ret.weekday = nameCondition(len);
|
|
break;
|
|
case 'j':
|
|
ret.hour = digitCondition(len);
|
|
break;
|
|
case 'h':
|
|
ret.hour = digitCondition(len);
|
|
ret.hour12 = true;
|
|
break;
|
|
case 'H':
|
|
ret.hour = digitCondition(len);
|
|
ret.hour12 = false;
|
|
break;
|
|
case 'm':
|
|
ret.minute = digitCondition(len);
|
|
break;
|
|
case 's':
|
|
ret.second = digitCondition(len);
|
|
break;
|
|
case 'z':
|
|
ret.timeZoneName = 'long';
|
|
break;
|
|
case 'Z':
|
|
ret.timeZoneName = 'short';
|
|
break;
|
|
}
|
|
i = j;
|
|
}
|
|
return ret;
|
|
}
|
|
var dateFormatterCache = new Map();
|
|
var DateFormatter = (function() {
|
|
function DateFormatter() {}
|
|
DateFormatter.format = function(date, locale, pattern) {
|
|
var key = locale + pattern;
|
|
if (dateFormatterCache.has(key)) {
|
|
return dateFormatterCache.get(key).format(date);
|
|
}
|
|
var formatter = new Intl.DateTimeFormat(locale, extractComponents(pattern));
|
|
dateFormatterCache.set(key, formatter);
|
|
return formatter.format(date);
|
|
};
|
|
return DateFormatter;
|
|
})();
|
|
exports.DateFormatter = DateFormatter;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9f", ["20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var InvalidPipeArgumentException = (function(_super) {
|
|
__extends(InvalidPipeArgumentException, _super);
|
|
function InvalidPipeArgumentException(type, value) {
|
|
_super.call(this, "Invalid argument '" + value + "' for pipe '" + lang_1.stringify(type) + "'");
|
|
}
|
|
return InvalidPipeArgumentException;
|
|
})(exceptions_1.BaseException);
|
|
exports.InvalidPipeArgumentException = InvalidPipeArgumentException;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a6", ["20", "3c", "a5", "14", "37", "9f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var intl_1 = $__require('a5');
|
|
var core_1 = $__require('14');
|
|
var collection_1 = $__require('37');
|
|
var invalid_pipe_argument_exception_1 = $__require('9f');
|
|
var defaultLocale = 'en-US';
|
|
var _re = lang_1.RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
|
var NumberPipe = (function() {
|
|
function NumberPipe() {}
|
|
NumberPipe._format = function(value, style, digits, currency, currencyAsSymbol) {
|
|
if (currency === void 0) {
|
|
currency = null;
|
|
}
|
|
if (currencyAsSymbol === void 0) {
|
|
currencyAsSymbol = false;
|
|
}
|
|
if (lang_1.isBlank(value))
|
|
return null;
|
|
if (!lang_1.isNumber(value)) {
|
|
throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(NumberPipe, value);
|
|
}
|
|
var minInt = 1,
|
|
minFraction = 0,
|
|
maxFraction = 3;
|
|
if (lang_1.isPresent(digits)) {
|
|
var parts = lang_1.RegExpWrapper.firstMatch(_re, digits);
|
|
if (lang_1.isBlank(parts)) {
|
|
throw new exceptions_1.BaseException(digits + " is not a valid digit info for number pipes");
|
|
}
|
|
if (lang_1.isPresent(parts[1])) {
|
|
minInt = lang_1.NumberWrapper.parseIntAutoRadix(parts[1]);
|
|
}
|
|
if (lang_1.isPresent(parts[3])) {
|
|
minFraction = lang_1.NumberWrapper.parseIntAutoRadix(parts[3]);
|
|
}
|
|
if (lang_1.isPresent(parts[5])) {
|
|
maxFraction = lang_1.NumberWrapper.parseIntAutoRadix(parts[5]);
|
|
}
|
|
}
|
|
return intl_1.NumberFormatter.format(value, defaultLocale, style, {
|
|
minimumIntegerDigits: minInt,
|
|
minimumFractionDigits: minFraction,
|
|
maximumFractionDigits: maxFraction,
|
|
currency: currency,
|
|
currencyAsSymbol: currencyAsSymbol
|
|
});
|
|
};
|
|
NumberPipe = __decorate([lang_1.CONST(), core_1.Injectable(), __metadata('design:paramtypes', [])], NumberPipe);
|
|
return NumberPipe;
|
|
})();
|
|
exports.NumberPipe = NumberPipe;
|
|
var DecimalPipe = (function(_super) {
|
|
__extends(DecimalPipe, _super);
|
|
function DecimalPipe() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
DecimalPipe.prototype.transform = function(value, args) {
|
|
var digits = collection_1.ListWrapper.first(args);
|
|
return NumberPipe._format(value, intl_1.NumberFormatStyle.Decimal, digits);
|
|
};
|
|
DecimalPipe = __decorate([lang_1.CONST(), core_1.Pipe({name: 'number'}), core_1.Injectable(), __metadata('design:paramtypes', [])], DecimalPipe);
|
|
return DecimalPipe;
|
|
})(NumberPipe);
|
|
exports.DecimalPipe = DecimalPipe;
|
|
var PercentPipe = (function(_super) {
|
|
__extends(PercentPipe, _super);
|
|
function PercentPipe() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
PercentPipe.prototype.transform = function(value, args) {
|
|
var digits = collection_1.ListWrapper.first(args);
|
|
return NumberPipe._format(value, intl_1.NumberFormatStyle.Percent, digits);
|
|
};
|
|
PercentPipe = __decorate([lang_1.CONST(), core_1.Pipe({name: 'percent'}), core_1.Injectable(), __metadata('design:paramtypes', [])], PercentPipe);
|
|
return PercentPipe;
|
|
})(NumberPipe);
|
|
exports.PercentPipe = PercentPipe;
|
|
var CurrencyPipe = (function(_super) {
|
|
__extends(CurrencyPipe, _super);
|
|
function CurrencyPipe() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
CurrencyPipe.prototype.transform = function(value, args) {
|
|
var currencyCode = lang_1.isPresent(args) && args.length > 0 ? args[0] : 'USD';
|
|
var symbolDisplay = lang_1.isPresent(args) && args.length > 1 ? args[1] : false;
|
|
var digits = lang_1.isPresent(args) && args.length > 2 ? args[2] : null;
|
|
return NumberPipe._format(value, intl_1.NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
|
|
};
|
|
CurrencyPipe = __decorate([lang_1.CONST(), core_1.Pipe({name: 'currency'}), core_1.Injectable(), __metadata('design:paramtypes', [])], CurrencyPipe);
|
|
return CurrencyPipe;
|
|
})(NumberPipe);
|
|
exports.CurrencyPipe = CurrencyPipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a7", ["9e", "a0", "a1", "a2", "a3", "a4", "a6", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var async_pipe_1 = $__require('9e');
|
|
var uppercase_pipe_1 = $__require('a0');
|
|
var lowercase_pipe_1 = $__require('a1');
|
|
var json_pipe_1 = $__require('a2');
|
|
var slice_pipe_1 = $__require('a3');
|
|
var date_pipe_1 = $__require('a4');
|
|
var number_pipe_1 = $__require('a6');
|
|
var lang_1 = $__require('20');
|
|
var async_pipe_2 = $__require('9e');
|
|
exports.AsyncPipe = async_pipe_2.AsyncPipe;
|
|
var date_pipe_2 = $__require('a4');
|
|
exports.DatePipe = date_pipe_2.DatePipe;
|
|
var json_pipe_2 = $__require('a2');
|
|
exports.JsonPipe = json_pipe_2.JsonPipe;
|
|
var slice_pipe_2 = $__require('a3');
|
|
exports.SlicePipe = slice_pipe_2.SlicePipe;
|
|
var lowercase_pipe_2 = $__require('a1');
|
|
exports.LowerCasePipe = lowercase_pipe_2.LowerCasePipe;
|
|
var number_pipe_2 = $__require('a6');
|
|
exports.NumberPipe = number_pipe_2.NumberPipe;
|
|
exports.DecimalPipe = number_pipe_2.DecimalPipe;
|
|
exports.PercentPipe = number_pipe_2.PercentPipe;
|
|
exports.CurrencyPipe = number_pipe_2.CurrencyPipe;
|
|
var uppercase_pipe_2 = $__require('a0');
|
|
exports.UpperCasePipe = uppercase_pipe_2.UpperCasePipe;
|
|
exports.COMMON_PIPES = lang_1.CONST_EXPR([async_pipe_1.AsyncPipe, uppercase_pipe_1.UpperCasePipe, lowercase_pipe_1.LowerCasePipe, json_pipe_1.JsonPipe, slice_pipe_1.SlicePipe, number_pipe_1.DecimalPipe, number_pipe_1.PercentPipe, number_pipe_1.CurrencyPipe, date_pipe_1.DatePipe]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a8", ["20", "63", "14", "a9", "aa", "ab", "ac", "ad"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var core_1 = $__require('14');
|
|
var control_container_1 = $__require('a9');
|
|
var ng_control_1 = $__require('aa');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var shared_1 = $__require('ac');
|
|
var validators_1 = $__require('ad');
|
|
var controlNameBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, {useExisting: core_1.forwardRef(function() {
|
|
return NgControlName;
|
|
})}));
|
|
var NgControlName = (function(_super) {
|
|
__extends(NgControlName, _super);
|
|
function NgControlName(_parent, _validators, _asyncValidators, valueAccessors) {
|
|
_super.call(this);
|
|
this._parent = _parent;
|
|
this._validators = _validators;
|
|
this._asyncValidators = _asyncValidators;
|
|
this.update = new async_1.EventEmitter();
|
|
this._added = false;
|
|
this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
|
|
}
|
|
NgControlName.prototype.ngOnChanges = function(changes) {
|
|
if (!this._added) {
|
|
this.formDirective.addControl(this);
|
|
this._added = true;
|
|
}
|
|
if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
|
|
this.viewModel = this.model;
|
|
this.formDirective.updateModel(this, this.model);
|
|
}
|
|
};
|
|
NgControlName.prototype.ngOnDestroy = function() {
|
|
this.formDirective.removeControl(this);
|
|
};
|
|
NgControlName.prototype.viewToModelUpdate = function(newValue) {
|
|
this.viewModel = newValue;
|
|
async_1.ObservableWrapper.callEmit(this.update, newValue);
|
|
};
|
|
Object.defineProperty(NgControlName.prototype, "path", {
|
|
get: function() {
|
|
return shared_1.controlPath(this.name, this._parent);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlName.prototype, "formDirective", {
|
|
get: function() {
|
|
return this._parent.formDirective;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlName.prototype, "validator", {
|
|
get: function() {
|
|
return shared_1.composeValidators(this._validators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlName.prototype, "asyncValidator", {
|
|
get: function() {
|
|
return shared_1.composeAsyncValidators(this._asyncValidators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlName.prototype, "control", {
|
|
get: function() {
|
|
return this.formDirective.getControl(this);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgControlName = __decorate([core_1.Directive({
|
|
selector: '[ngControl]',
|
|
bindings: [controlNameBinding],
|
|
inputs: ['name: ngControl', 'model: ngModel'],
|
|
outputs: ['update: ngModelChange'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Host()), __param(0, core_1.SkipSelf()), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_VALIDATORS)), __param(2, core_1.Optional()), __param(2, core_1.Self()), __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __param(3, core_1.Optional()), __param(3, core_1.Self()), __param(3, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)), __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array, Array])], NgControlName);
|
|
return NgControlName;
|
|
})(ng_control_1.NgControl);
|
|
exports.NgControlName = NgControlName;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ae", ["20", "37", "63", "14", "aa", "ad", "ab", "ac"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var async_1 = $__require('63');
|
|
var core_1 = $__require('14');
|
|
var ng_control_1 = $__require('aa');
|
|
var validators_1 = $__require('ad');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var shared_1 = $__require('ac');
|
|
var formControlBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, {useExisting: core_1.forwardRef(function() {
|
|
return NgFormControl;
|
|
})}));
|
|
var NgFormControl = (function(_super) {
|
|
__extends(NgFormControl, _super);
|
|
function NgFormControl(_validators, _asyncValidators, valueAccessors) {
|
|
_super.call(this);
|
|
this._validators = _validators;
|
|
this._asyncValidators = _asyncValidators;
|
|
this.update = new async_1.EventEmitter();
|
|
this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
|
|
}
|
|
NgFormControl.prototype.ngOnChanges = function(changes) {
|
|
if (this._isControlChanged(changes)) {
|
|
shared_1.setUpControl(this.form, this);
|
|
this.form.updateValueAndValidity({emitEvent: false});
|
|
}
|
|
if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
|
|
this.form.updateValue(this.model);
|
|
this.viewModel = this.model;
|
|
}
|
|
};
|
|
Object.defineProperty(NgFormControl.prototype, "path", {
|
|
get: function() {
|
|
return [];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFormControl.prototype, "validator", {
|
|
get: function() {
|
|
return shared_1.composeValidators(this._validators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFormControl.prototype, "asyncValidator", {
|
|
get: function() {
|
|
return shared_1.composeAsyncValidators(this._asyncValidators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFormControl.prototype, "control", {
|
|
get: function() {
|
|
return this.form;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgFormControl.prototype.viewToModelUpdate = function(newValue) {
|
|
this.viewModel = newValue;
|
|
async_1.ObservableWrapper.callEmit(this.update, newValue);
|
|
};
|
|
NgFormControl.prototype._isControlChanged = function(changes) {
|
|
return collection_1.StringMapWrapper.contains(changes, "form");
|
|
};
|
|
NgFormControl = __decorate([core_1.Directive({
|
|
selector: '[ngFormControl]',
|
|
bindings: [formControlBinding],
|
|
inputs: ['form: ngFormControl', 'model: ngModel'],
|
|
outputs: ['update: ngModelChange'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Optional()), __param(0, core_1.Self()), __param(0, core_1.Inject(validators_1.NG_VALIDATORS)), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __param(2, core_1.Optional()), __param(2, core_1.Self()), __param(2, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)), __metadata('design:paramtypes', [Array, Array, Array])], NgFormControl);
|
|
return NgFormControl;
|
|
})(ng_control_1.NgControl);
|
|
exports.NgFormControl = NgFormControl;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("af", ["20", "63", "14", "ab", "aa", "b0", "ad", "ac"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var core_1 = $__require('14');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var ng_control_1 = $__require('aa');
|
|
var model_1 = $__require('b0');
|
|
var validators_1 = $__require('ad');
|
|
var shared_1 = $__require('ac');
|
|
var formControlBinding = lang_1.CONST_EXPR(new core_1.Provider(ng_control_1.NgControl, {useExisting: core_1.forwardRef(function() {
|
|
return NgModel;
|
|
})}));
|
|
var NgModel = (function(_super) {
|
|
__extends(NgModel, _super);
|
|
function NgModel(_validators, _asyncValidators, valueAccessors) {
|
|
_super.call(this);
|
|
this._validators = _validators;
|
|
this._asyncValidators = _asyncValidators;
|
|
this._control = new model_1.Control();
|
|
this._added = false;
|
|
this.update = new async_1.EventEmitter();
|
|
this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
|
|
}
|
|
NgModel.prototype.ngOnChanges = function(changes) {
|
|
if (!this._added) {
|
|
shared_1.setUpControl(this._control, this);
|
|
this._control.updateValueAndValidity({emitEvent: false});
|
|
this._added = true;
|
|
}
|
|
if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
|
|
this._control.updateValue(this.model);
|
|
this.viewModel = this.model;
|
|
}
|
|
};
|
|
Object.defineProperty(NgModel.prototype, "control", {
|
|
get: function() {
|
|
return this._control;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgModel.prototype, "path", {
|
|
get: function() {
|
|
return [];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgModel.prototype, "validator", {
|
|
get: function() {
|
|
return shared_1.composeValidators(this._validators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgModel.prototype, "asyncValidator", {
|
|
get: function() {
|
|
return shared_1.composeAsyncValidators(this._asyncValidators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgModel.prototype.viewToModelUpdate = function(newValue) {
|
|
this.viewModel = newValue;
|
|
async_1.ObservableWrapper.callEmit(this.update, newValue);
|
|
};
|
|
NgModel = __decorate([core_1.Directive({
|
|
selector: '[ngModel]:not([ngControl]):not([ngFormControl])',
|
|
bindings: [formControlBinding],
|
|
inputs: ['model: ngModel'],
|
|
outputs: ['update: ngModelChange'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Optional()), __param(0, core_1.Self()), __param(0, core_1.Inject(validators_1.NG_VALIDATORS)), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __param(2, core_1.Optional()), __param(2, core_1.Self()), __param(2, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)), __metadata('design:paramtypes', [Array, Array, Array])], NgModel);
|
|
return NgModel;
|
|
})(ng_control_1.NgControl);
|
|
exports.NgModel = NgModel;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b1", ["14", "20", "a9", "ac", "ad"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var control_container_1 = $__require('a9');
|
|
var shared_1 = $__require('ac');
|
|
var validators_1 = $__require('ad');
|
|
var controlGroupProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, {useExisting: core_1.forwardRef(function() {
|
|
return NgControlGroup;
|
|
})}));
|
|
var NgControlGroup = (function(_super) {
|
|
__extends(NgControlGroup, _super);
|
|
function NgControlGroup(parent, _validators, _asyncValidators) {
|
|
_super.call(this);
|
|
this._validators = _validators;
|
|
this._asyncValidators = _asyncValidators;
|
|
this._parent = parent;
|
|
}
|
|
NgControlGroup.prototype.ngOnInit = function() {
|
|
this.formDirective.addControlGroup(this);
|
|
};
|
|
NgControlGroup.prototype.ngOnDestroy = function() {
|
|
this.formDirective.removeControlGroup(this);
|
|
};
|
|
Object.defineProperty(NgControlGroup.prototype, "control", {
|
|
get: function() {
|
|
return this.formDirective.getControlGroup(this);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlGroup.prototype, "path", {
|
|
get: function() {
|
|
return shared_1.controlPath(this.name, this._parent);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlGroup.prototype, "formDirective", {
|
|
get: function() {
|
|
return this._parent.formDirective;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlGroup.prototype, "validator", {
|
|
get: function() {
|
|
return shared_1.composeValidators(this._validators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlGroup.prototype, "asyncValidator", {
|
|
get: function() {
|
|
return shared_1.composeAsyncValidators(this._asyncValidators);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgControlGroup = __decorate([core_1.Directive({
|
|
selector: '[ngControlGroup]',
|
|
providers: [controlGroupProvider],
|
|
inputs: ['name: ngControlGroup'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Host()), __param(0, core_1.SkipSelf()), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_VALIDATORS)), __param(2, core_1.Optional()), __param(2, core_1.Self()), __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array])], NgControlGroup);
|
|
return NgControlGroup;
|
|
})(control_container_1.ControlContainer);
|
|
exports.NgControlGroup = NgControlGroup;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b2", ["20", "37", "63", "14", "a9", "ac", "ad"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var async_1 = $__require('63');
|
|
var core_1 = $__require('14');
|
|
var control_container_1 = $__require('a9');
|
|
var shared_1 = $__require('ac');
|
|
var validators_1 = $__require('ad');
|
|
var formDirectiveProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, {useExisting: core_1.forwardRef(function() {
|
|
return NgFormModel;
|
|
})}));
|
|
var NgFormModel = (function(_super) {
|
|
__extends(NgFormModel, _super);
|
|
function NgFormModel(_validators, _asyncValidators) {
|
|
_super.call(this);
|
|
this._validators = _validators;
|
|
this._asyncValidators = _asyncValidators;
|
|
this.form = null;
|
|
this.directives = [];
|
|
this.ngSubmit = new async_1.EventEmitter();
|
|
}
|
|
NgFormModel.prototype.ngOnChanges = function(changes) {
|
|
if (collection_1.StringMapWrapper.contains(changes, "form")) {
|
|
var sync = shared_1.composeValidators(this._validators);
|
|
this.form.validator = validators_1.Validators.compose([this.form.validator, sync]);
|
|
var async = shared_1.composeAsyncValidators(this._asyncValidators);
|
|
this.form.asyncValidator = validators_1.Validators.composeAsync([this.form.asyncValidator, async]);
|
|
this.form.updateValueAndValidity({
|
|
onlySelf: true,
|
|
emitEvent: false
|
|
});
|
|
}
|
|
this._updateDomValue();
|
|
};
|
|
Object.defineProperty(NgFormModel.prototype, "formDirective", {
|
|
get: function() {
|
|
return this;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFormModel.prototype, "control", {
|
|
get: function() {
|
|
return this.form;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFormModel.prototype, "path", {
|
|
get: function() {
|
|
return [];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgFormModel.prototype.addControl = function(dir) {
|
|
var ctrl = this.form.find(dir.path);
|
|
shared_1.setUpControl(ctrl, dir);
|
|
ctrl.updateValueAndValidity({emitEvent: false});
|
|
this.directives.push(dir);
|
|
};
|
|
NgFormModel.prototype.getControl = function(dir) {
|
|
return this.form.find(dir.path);
|
|
};
|
|
NgFormModel.prototype.removeControl = function(dir) {
|
|
collection_1.ListWrapper.remove(this.directives, dir);
|
|
};
|
|
NgFormModel.prototype.addControlGroup = function(dir) {
|
|
var ctrl = this.form.find(dir.path);
|
|
shared_1.setUpControlGroup(ctrl, dir);
|
|
ctrl.updateValueAndValidity({emitEvent: false});
|
|
};
|
|
NgFormModel.prototype.removeControlGroup = function(dir) {};
|
|
NgFormModel.prototype.getControlGroup = function(dir) {
|
|
return this.form.find(dir.path);
|
|
};
|
|
NgFormModel.prototype.updateModel = function(dir, value) {
|
|
var ctrl = this.form.find(dir.path);
|
|
ctrl.updateValue(value);
|
|
};
|
|
NgFormModel.prototype.onSubmit = function() {
|
|
async_1.ObservableWrapper.callEmit(this.ngSubmit, null);
|
|
return false;
|
|
};
|
|
NgFormModel.prototype._updateDomValue = function() {
|
|
var _this = this;
|
|
this.directives.forEach(function(dir) {
|
|
var ctrl = _this.form.find(dir.path);
|
|
dir.valueAccessor.writeValue(ctrl.value);
|
|
});
|
|
};
|
|
NgFormModel = __decorate([core_1.Directive({
|
|
selector: '[ngFormModel]',
|
|
bindings: [formDirectiveProvider],
|
|
inputs: ['form: ngFormModel'],
|
|
host: {'(submit)': 'onSubmit()'},
|
|
outputs: ['ngSubmit'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Optional()), __param(0, core_1.Self()), __param(0, core_1.Inject(validators_1.NG_VALIDATORS)), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __metadata('design:paramtypes', [Array, Array])], NgFormModel);
|
|
return NgFormModel;
|
|
})(control_container_1.ControlContainer);
|
|
exports.NgFormModel = NgFormModel;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("a9", ["b3"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var abstract_control_directive_1 = $__require('b3');
|
|
var ControlContainer = (function(_super) {
|
|
__extends(ControlContainer, _super);
|
|
function ControlContainer() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(ControlContainer.prototype, "formDirective", {
|
|
get: function() {
|
|
return null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ControlContainer.prototype, "path", {
|
|
get: function() {
|
|
return null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ControlContainer;
|
|
})(abstract_control_directive_1.AbstractControlDirective);
|
|
exports.ControlContainer = ControlContainer;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b4", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function normalizeValidator(validator) {
|
|
if (validator.validate !== undefined) {
|
|
return function(c) {
|
|
return validator.validate(c);
|
|
};
|
|
} else {
|
|
return validator;
|
|
}
|
|
}
|
|
exports.normalizeValidator = normalizeValidator;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ac", ["37", "20", "3c", "ad", "b5", "b6", "b7", "b8", "b4"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var validators_1 = $__require('ad');
|
|
var default_value_accessor_1 = $__require('b5');
|
|
var number_value_accessor_1 = $__require('b6');
|
|
var checkbox_value_accessor_1 = $__require('b7');
|
|
var select_control_value_accessor_1 = $__require('b8');
|
|
var normalize_validator_1 = $__require('b4');
|
|
function controlPath(name, parent) {
|
|
var p = collection_1.ListWrapper.clone(parent.path);
|
|
p.push(name);
|
|
return p;
|
|
}
|
|
exports.controlPath = controlPath;
|
|
function setUpControl(control, dir) {
|
|
if (lang_1.isBlank(control))
|
|
_throwError(dir, "Cannot find control");
|
|
if (lang_1.isBlank(dir.valueAccessor))
|
|
_throwError(dir, "No value accessor for");
|
|
control.validator = validators_1.Validators.compose([control.validator, dir.validator]);
|
|
control.asyncValidator = validators_1.Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
|
|
dir.valueAccessor.writeValue(control.value);
|
|
dir.valueAccessor.registerOnChange(function(newValue) {
|
|
dir.viewToModelUpdate(newValue);
|
|
control.updateValue(newValue, {emitModelToViewChange: false});
|
|
control.markAsDirty();
|
|
});
|
|
control.registerOnChange(function(newValue) {
|
|
return dir.valueAccessor.writeValue(newValue);
|
|
});
|
|
dir.valueAccessor.registerOnTouched(function() {
|
|
return control.markAsTouched();
|
|
});
|
|
}
|
|
exports.setUpControl = setUpControl;
|
|
function setUpControlGroup(control, dir) {
|
|
if (lang_1.isBlank(control))
|
|
_throwError(dir, "Cannot find control");
|
|
control.validator = validators_1.Validators.compose([control.validator, dir.validator]);
|
|
control.asyncValidator = validators_1.Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
|
|
}
|
|
exports.setUpControlGroup = setUpControlGroup;
|
|
function _throwError(dir, message) {
|
|
var path = dir.path.join(" -> ");
|
|
throw new exceptions_1.BaseException(message + " '" + path + "'");
|
|
}
|
|
function composeValidators(validators) {
|
|
return lang_1.isPresent(validators) ? validators_1.Validators.compose(validators.map(normalize_validator_1.normalizeValidator)) : null;
|
|
}
|
|
exports.composeValidators = composeValidators;
|
|
function composeAsyncValidators(validators) {
|
|
return lang_1.isPresent(validators) ? validators_1.Validators.composeAsync(validators.map(normalize_validator_1.normalizeValidator)) : null;
|
|
}
|
|
exports.composeAsyncValidators = composeAsyncValidators;
|
|
function isPropertyUpdated(changes, viewModel) {
|
|
if (!collection_1.StringMapWrapper.contains(changes, "model"))
|
|
return false;
|
|
var change = changes["model"];
|
|
if (change.isFirstChange())
|
|
return true;
|
|
return !lang_1.looseIdentical(viewModel, change.currentValue);
|
|
}
|
|
exports.isPropertyUpdated = isPropertyUpdated;
|
|
function selectValueAccessor(dir, valueAccessors) {
|
|
if (lang_1.isBlank(valueAccessors))
|
|
return null;
|
|
var defaultAccessor;
|
|
var builtinAccessor;
|
|
var customAccessor;
|
|
valueAccessors.forEach(function(v) {
|
|
if (v instanceof default_value_accessor_1.DefaultValueAccessor) {
|
|
defaultAccessor = v;
|
|
} else if (v instanceof checkbox_value_accessor_1.CheckboxControlValueAccessor || v instanceof number_value_accessor_1.NumberValueAccessor || v instanceof select_control_value_accessor_1.SelectControlValueAccessor) {
|
|
if (lang_1.isPresent(builtinAccessor))
|
|
_throwError(dir, "More than one built-in value accessor matches");
|
|
builtinAccessor = v;
|
|
} else {
|
|
if (lang_1.isPresent(customAccessor))
|
|
_throwError(dir, "More than one custom value accessor matches");
|
|
customAccessor = v;
|
|
}
|
|
});
|
|
if (lang_1.isPresent(customAccessor))
|
|
return customAccessor;
|
|
if (lang_1.isPresent(builtinAccessor))
|
|
return builtinAccessor;
|
|
if (lang_1.isPresent(defaultAccessor))
|
|
return defaultAccessor;
|
|
_throwError(dir, "No valid value accessor for");
|
|
return null;
|
|
}
|
|
exports.selectValueAccessor = selectValueAccessor;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b9", ["63", "37", "20", "14", "a9", "b0", "ac", "ad"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var async_1 = $__require('63');
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var control_container_1 = $__require('a9');
|
|
var model_1 = $__require('b0');
|
|
var shared_1 = $__require('ac');
|
|
var validators_1 = $__require('ad');
|
|
var formDirectiveProvider = lang_1.CONST_EXPR(new core_1.Provider(control_container_1.ControlContainer, {useExisting: core_1.forwardRef(function() {
|
|
return NgForm;
|
|
})}));
|
|
var NgForm = (function(_super) {
|
|
__extends(NgForm, _super);
|
|
function NgForm(validators, asyncValidators) {
|
|
_super.call(this);
|
|
this.ngSubmit = new async_1.EventEmitter();
|
|
this.form = new model_1.ControlGroup({}, null, shared_1.composeValidators(validators), shared_1.composeAsyncValidators(asyncValidators));
|
|
}
|
|
Object.defineProperty(NgForm.prototype, "formDirective", {
|
|
get: function() {
|
|
return this;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgForm.prototype, "control", {
|
|
get: function() {
|
|
return this.form;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgForm.prototype, "path", {
|
|
get: function() {
|
|
return [];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgForm.prototype, "controls", {
|
|
get: function() {
|
|
return this.form.controls;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgForm.prototype.addControl = function(dir) {
|
|
var _this = this;
|
|
async_1.PromiseWrapper.scheduleMicrotask(function() {
|
|
var container = _this._findContainer(dir.path);
|
|
var ctrl = new model_1.Control();
|
|
shared_1.setUpControl(ctrl, dir);
|
|
container.addControl(dir.name, ctrl);
|
|
ctrl.updateValueAndValidity({emitEvent: false});
|
|
});
|
|
};
|
|
NgForm.prototype.getControl = function(dir) {
|
|
return this.form.find(dir.path);
|
|
};
|
|
NgForm.prototype.removeControl = function(dir) {
|
|
var _this = this;
|
|
async_1.PromiseWrapper.scheduleMicrotask(function() {
|
|
var container = _this._findContainer(dir.path);
|
|
if (lang_1.isPresent(container)) {
|
|
container.removeControl(dir.name);
|
|
container.updateValueAndValidity({emitEvent: false});
|
|
}
|
|
});
|
|
};
|
|
NgForm.prototype.addControlGroup = function(dir) {
|
|
var _this = this;
|
|
async_1.PromiseWrapper.scheduleMicrotask(function() {
|
|
var container = _this._findContainer(dir.path);
|
|
var group = new model_1.ControlGroup({});
|
|
shared_1.setUpControlGroup(group, dir);
|
|
container.addControl(dir.name, group);
|
|
group.updateValueAndValidity({emitEvent: false});
|
|
});
|
|
};
|
|
NgForm.prototype.removeControlGroup = function(dir) {
|
|
var _this = this;
|
|
async_1.PromiseWrapper.scheduleMicrotask(function() {
|
|
var container = _this._findContainer(dir.path);
|
|
if (lang_1.isPresent(container)) {
|
|
container.removeControl(dir.name);
|
|
container.updateValueAndValidity({emitEvent: false});
|
|
}
|
|
});
|
|
};
|
|
NgForm.prototype.getControlGroup = function(dir) {
|
|
return this.form.find(dir.path);
|
|
};
|
|
NgForm.prototype.updateModel = function(dir, value) {
|
|
var _this = this;
|
|
async_1.PromiseWrapper.scheduleMicrotask(function() {
|
|
var ctrl = _this.form.find(dir.path);
|
|
ctrl.updateValue(value);
|
|
});
|
|
};
|
|
NgForm.prototype.onSubmit = function() {
|
|
async_1.ObservableWrapper.callEmit(this.ngSubmit, null);
|
|
return false;
|
|
};
|
|
NgForm.prototype._findContainer = function(path) {
|
|
path.pop();
|
|
return collection_1.ListWrapper.isEmpty(path) ? this.form : this.form.find(path);
|
|
};
|
|
NgForm = __decorate([core_1.Directive({
|
|
selector: 'form:not([ngNoForm]):not([ngFormModel]),ngForm,[ngForm]',
|
|
bindings: [formDirectiveProvider],
|
|
host: {'(submit)': 'onSubmit()'},
|
|
outputs: ['ngSubmit'],
|
|
exportAs: 'ngForm'
|
|
}), __param(0, core_1.Optional()), __param(0, core_1.Self()), __param(0, core_1.Inject(validators_1.NG_VALIDATORS)), __param(1, core_1.Optional()), __param(1, core_1.Self()), __param(1, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), __metadata('design:paramtypes', [Array, Array])], NgForm);
|
|
return NgForm;
|
|
})(control_container_1.ControlContainer);
|
|
exports.NgForm = NgForm;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b5", ["14", "ab", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var lang_1 = $__require('20');
|
|
var DEFAULT_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return DefaultValueAccessor;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var DefaultValueAccessor = (function() {
|
|
function DefaultValueAccessor(_renderer, _elementRef) {
|
|
this._renderer = _renderer;
|
|
this._elementRef = _elementRef;
|
|
this.onChange = function(_) {};
|
|
this.onTouched = function() {};
|
|
}
|
|
DefaultValueAccessor.prototype.writeValue = function(value) {
|
|
var normalizedValue = lang_1.isBlank(value) ? '' : value;
|
|
this._renderer.setElementProperty(this._elementRef, 'value', normalizedValue);
|
|
};
|
|
DefaultValueAccessor.prototype.registerOnChange = function(fn) {
|
|
this.onChange = fn;
|
|
};
|
|
DefaultValueAccessor.prototype.registerOnTouched = function(fn) {
|
|
this.onTouched = fn;
|
|
};
|
|
DefaultValueAccessor = __decorate([core_1.Directive({
|
|
selector: 'input:not([type=checkbox])[ngControl],textarea[ngControl],input:not([type=checkbox])[ngFormControl],textarea[ngFormControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]',
|
|
host: {
|
|
'(input)': 'onChange($event.target.value)',
|
|
'(blur)': 'onTouched()'
|
|
},
|
|
bindings: [DEFAULT_VALUE_ACCESSOR]
|
|
}), __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])], DefaultValueAccessor);
|
|
return DefaultValueAccessor;
|
|
})();
|
|
exports.DefaultValueAccessor = DefaultValueAccessor;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b7", ["14", "ab", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var lang_1 = $__require('20');
|
|
var CHECKBOX_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return CheckboxControlValueAccessor;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var CheckboxControlValueAccessor = (function() {
|
|
function CheckboxControlValueAccessor(_renderer, _elementRef) {
|
|
this._renderer = _renderer;
|
|
this._elementRef = _elementRef;
|
|
this.onChange = function(_) {};
|
|
this.onTouched = function() {};
|
|
}
|
|
CheckboxControlValueAccessor.prototype.writeValue = function(value) {
|
|
this._renderer.setElementProperty(this._elementRef, 'checked', value);
|
|
};
|
|
CheckboxControlValueAccessor.prototype.registerOnChange = function(fn) {
|
|
this.onChange = fn;
|
|
};
|
|
CheckboxControlValueAccessor.prototype.registerOnTouched = function(fn) {
|
|
this.onTouched = fn;
|
|
};
|
|
CheckboxControlValueAccessor = __decorate([core_1.Directive({
|
|
selector: 'input[type=checkbox][ngControl],input[type=checkbox][ngFormControl],input[type=checkbox][ngModel]',
|
|
host: {
|
|
'(change)': 'onChange($event.target.checked)',
|
|
'(blur)': 'onTouched()'
|
|
},
|
|
bindings: [CHECKBOX_VALUE_ACCESSOR]
|
|
}), __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])], CheckboxControlValueAccessor);
|
|
return CheckboxControlValueAccessor;
|
|
})();
|
|
exports.CheckboxControlValueAccessor = CheckboxControlValueAccessor;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b6", ["14", "ab", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var lang_1 = $__require('20');
|
|
var NUMBER_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return NumberValueAccessor;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var NumberValueAccessor = (function() {
|
|
function NumberValueAccessor(_renderer, _elementRef) {
|
|
this._renderer = _renderer;
|
|
this._elementRef = _elementRef;
|
|
this.onChange = function(_) {};
|
|
this.onTouched = function() {};
|
|
}
|
|
NumberValueAccessor.prototype.writeValue = function(value) {
|
|
this._renderer.setElementProperty(this._elementRef, 'value', value);
|
|
};
|
|
NumberValueAccessor.prototype.registerOnChange = function(fn) {
|
|
this.onChange = function(value) {
|
|
fn(lang_1.NumberWrapper.parseFloat(value));
|
|
};
|
|
};
|
|
NumberValueAccessor.prototype.registerOnTouched = function(fn) {
|
|
this.onTouched = fn;
|
|
};
|
|
NumberValueAccessor = __decorate([core_1.Directive({
|
|
selector: 'input[type=number][ngControl],input[type=number][ngFormControl],input[type=number][ngModel]',
|
|
host: {
|
|
'(change)': 'onChange($event.target.value)',
|
|
'(input)': 'onChange($event.target.value)',
|
|
'(blur)': 'onTouched()'
|
|
},
|
|
bindings: [NUMBER_VALUE_ACCESSOR]
|
|
}), __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef])], NumberValueAccessor);
|
|
return NumberValueAccessor;
|
|
})();
|
|
exports.NumberValueAccessor = NumberValueAccessor;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ba", ["14", "aa", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var core_1 = $__require('14');
|
|
var ng_control_1 = $__require('aa');
|
|
var lang_1 = $__require('20');
|
|
var NgControlStatus = (function() {
|
|
function NgControlStatus(cd) {
|
|
this._cd = cd;
|
|
}
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassUntouched", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? this._cd.control.untouched : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassTouched", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? this._cd.control.touched : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassPristine", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? this._cd.control.pristine : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassDirty", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? this._cd.control.dirty : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassValid", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? this._cd.control.valid : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControlStatus.prototype, "ngClassInvalid", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._cd.control) ? !this._cd.control.valid : false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgControlStatus = __decorate([core_1.Directive({
|
|
selector: '[ngControl],[ngModel],[ngFormControl]',
|
|
host: {
|
|
'[class.ng-untouched]': 'ngClassUntouched',
|
|
'[class.ng-touched]': 'ngClassTouched',
|
|
'[class.ng-pristine]': 'ngClassPristine',
|
|
'[class.ng-dirty]': 'ngClassDirty',
|
|
'[class.ng-valid]': 'ngClassValid',
|
|
'[class.ng-invalid]': 'ngClassInvalid'
|
|
}
|
|
}), __param(0, core_1.Self()), __metadata('design:paramtypes', [ng_control_1.NgControl])], NgControlStatus);
|
|
return NgControlStatus;
|
|
})();
|
|
exports.NgControlStatus = NgControlStatus;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ab", ["14", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
exports.NG_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgValueAccessor"));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b8", ["14", "63", "ab", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var core_1 = $__require('14');
|
|
var async_1 = $__require('63');
|
|
var control_value_accessor_1 = $__require('ab');
|
|
var lang_1 = $__require('20');
|
|
var SELECT_VALUE_ACCESSOR = lang_1.CONST_EXPR(new core_1.Provider(control_value_accessor_1.NG_VALUE_ACCESSOR, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return SelectControlValueAccessor;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var NgSelectOption = (function() {
|
|
function NgSelectOption() {}
|
|
NgSelectOption = __decorate([core_1.Directive({selector: 'option'}), __metadata('design:paramtypes', [])], NgSelectOption);
|
|
return NgSelectOption;
|
|
})();
|
|
exports.NgSelectOption = NgSelectOption;
|
|
var SelectControlValueAccessor = (function() {
|
|
function SelectControlValueAccessor(_renderer, _elementRef, query) {
|
|
this._renderer = _renderer;
|
|
this._elementRef = _elementRef;
|
|
this.onChange = function(_) {};
|
|
this.onTouched = function() {};
|
|
this._updateValueWhenListOfOptionsChanges(query);
|
|
}
|
|
SelectControlValueAccessor.prototype.writeValue = function(value) {
|
|
this.value = value;
|
|
this._renderer.setElementProperty(this._elementRef, 'value', value);
|
|
};
|
|
SelectControlValueAccessor.prototype.registerOnChange = function(fn) {
|
|
this.onChange = fn;
|
|
};
|
|
SelectControlValueAccessor.prototype.registerOnTouched = function(fn) {
|
|
this.onTouched = fn;
|
|
};
|
|
SelectControlValueAccessor.prototype._updateValueWhenListOfOptionsChanges = function(query) {
|
|
var _this = this;
|
|
async_1.ObservableWrapper.subscribe(query.changes, function(_) {
|
|
return _this.writeValue(_this.value);
|
|
});
|
|
};
|
|
SelectControlValueAccessor = __decorate([core_1.Directive({
|
|
selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
|
|
host: {
|
|
'(change)': 'onChange($event.target.value)',
|
|
'(input)': 'onChange($event.target.value)',
|
|
'(blur)': 'onTouched()'
|
|
},
|
|
bindings: [SELECT_VALUE_ACCESSOR]
|
|
}), __param(2, core_1.Query(NgSelectOption, {descendants: true})), __metadata('design:paramtypes', [core_1.Renderer, core_1.ElementRef, core_1.QueryList])], SelectControlValueAccessor);
|
|
return SelectControlValueAccessor;
|
|
})();
|
|
exports.SelectControlValueAccessor = SelectControlValueAccessor;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b3", ["20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var AbstractControlDirective = (function() {
|
|
function AbstractControlDirective() {}
|
|
Object.defineProperty(AbstractControlDirective.prototype, "control", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "value", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.value : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "valid", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.valid : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "errors", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.errors : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.pristine : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.dirty : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "touched", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.touched : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.control) ? this.control.untouched : null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControlDirective.prototype, "path", {
|
|
get: function() {
|
|
return null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return AbstractControlDirective;
|
|
})();
|
|
exports.AbstractControlDirective = AbstractControlDirective;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("aa", ["b3", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var abstract_control_directive_1 = $__require('b3');
|
|
var exceptions_1 = $__require('3c');
|
|
var NgControl = (function(_super) {
|
|
__extends(NgControl, _super);
|
|
function NgControl() {
|
|
_super.apply(this, arguments);
|
|
this.name = null;
|
|
this.valueAccessor = null;
|
|
}
|
|
Object.defineProperty(NgControl.prototype, "validator", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgControl.prototype, "asyncValidator", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return NgControl;
|
|
})(abstract_control_directive_1.AbstractControlDirective);
|
|
exports.NgControl = NgControl;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("bb", ["20", "a8", "ae", "af", "b1", "b2", "b9", "b5", "b7", "b6", "ba", "b8", "bc", "aa"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var ng_control_name_1 = $__require('a8');
|
|
var ng_form_control_1 = $__require('ae');
|
|
var ng_model_1 = $__require('af');
|
|
var ng_control_group_1 = $__require('b1');
|
|
var ng_form_model_1 = $__require('b2');
|
|
var ng_form_1 = $__require('b9');
|
|
var default_value_accessor_1 = $__require('b5');
|
|
var checkbox_value_accessor_1 = $__require('b7');
|
|
var number_value_accessor_1 = $__require('b6');
|
|
var ng_control_status_1 = $__require('ba');
|
|
var select_control_value_accessor_1 = $__require('b8');
|
|
var validators_1 = $__require('bc');
|
|
var ng_control_name_2 = $__require('a8');
|
|
exports.NgControlName = ng_control_name_2.NgControlName;
|
|
var ng_form_control_2 = $__require('ae');
|
|
exports.NgFormControl = ng_form_control_2.NgFormControl;
|
|
var ng_model_2 = $__require('af');
|
|
exports.NgModel = ng_model_2.NgModel;
|
|
var ng_control_group_2 = $__require('b1');
|
|
exports.NgControlGroup = ng_control_group_2.NgControlGroup;
|
|
var ng_form_model_2 = $__require('b2');
|
|
exports.NgFormModel = ng_form_model_2.NgFormModel;
|
|
var ng_form_2 = $__require('b9');
|
|
exports.NgForm = ng_form_2.NgForm;
|
|
var default_value_accessor_2 = $__require('b5');
|
|
exports.DefaultValueAccessor = default_value_accessor_2.DefaultValueAccessor;
|
|
var checkbox_value_accessor_2 = $__require('b7');
|
|
exports.CheckboxControlValueAccessor = checkbox_value_accessor_2.CheckboxControlValueAccessor;
|
|
var number_value_accessor_2 = $__require('b6');
|
|
exports.NumberValueAccessor = number_value_accessor_2.NumberValueAccessor;
|
|
var ng_control_status_2 = $__require('ba');
|
|
exports.NgControlStatus = ng_control_status_2.NgControlStatus;
|
|
var select_control_value_accessor_2 = $__require('b8');
|
|
exports.SelectControlValueAccessor = select_control_value_accessor_2.SelectControlValueAccessor;
|
|
exports.NgSelectOption = select_control_value_accessor_2.NgSelectOption;
|
|
var validators_2 = $__require('bc');
|
|
exports.RequiredValidator = validators_2.RequiredValidator;
|
|
exports.MinLengthValidator = validators_2.MinLengthValidator;
|
|
exports.MaxLengthValidator = validators_2.MaxLengthValidator;
|
|
var ng_control_1 = $__require('aa');
|
|
exports.NgControl = ng_control_1.NgControl;
|
|
exports.FORM_DIRECTIVES = lang_1.CONST_EXPR([ng_control_name_1.NgControlName, ng_control_group_1.NgControlGroup, ng_form_control_1.NgFormControl, ng_model_1.NgModel, ng_form_model_1.NgFormModel, ng_form_1.NgForm, select_control_value_accessor_1.NgSelectOption, default_value_accessor_1.DefaultValueAccessor, number_value_accessor_1.NumberValueAccessor, checkbox_value_accessor_1.CheckboxControlValueAccessor, select_control_value_accessor_1.SelectControlValueAccessor, ng_control_status_1.NgControlStatus, validators_1.RequiredValidator, validators_1.MinLengthValidator, validators_1.MaxLengthValidator]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ad", ["20", "8b", "63", "37", "14", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var lang_1 = $__require('20');
|
|
var promise_1 = $__require('8b');
|
|
var async_1 = $__require('63');
|
|
var collection_1 = $__require('37');
|
|
var core_1 = $__require('14');
|
|
exports.NG_VALIDATORS = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgValidators"));
|
|
exports.NG_ASYNC_VALIDATORS = lang_1.CONST_EXPR(new core_1.OpaqueToken("NgAsyncValidators"));
|
|
var Validators = (function() {
|
|
function Validators() {}
|
|
Validators.required = function(control) {
|
|
return lang_1.isBlank(control.value) || control.value == "" ? {"required": true} : null;
|
|
};
|
|
Validators.minLength = function(minLength) {
|
|
return function(control) {
|
|
if (lang_1.isPresent(Validators.required(control)))
|
|
return null;
|
|
var v = control.value;
|
|
return v.length < minLength ? {"minlength": {
|
|
"requiredLength": minLength,
|
|
"actualLength": v.length
|
|
}} : null;
|
|
};
|
|
};
|
|
Validators.maxLength = function(maxLength) {
|
|
return function(control) {
|
|
if (lang_1.isPresent(Validators.required(control)))
|
|
return null;
|
|
var v = control.value;
|
|
return v.length > maxLength ? {"maxlength": {
|
|
"requiredLength": maxLength,
|
|
"actualLength": v.length
|
|
}} : null;
|
|
};
|
|
};
|
|
Validators.nullValidator = function(c) {
|
|
return null;
|
|
};
|
|
Validators.compose = function(validators) {
|
|
if (lang_1.isBlank(validators))
|
|
return null;
|
|
var presentValidators = validators.filter(lang_1.isPresent);
|
|
if (presentValidators.length == 0)
|
|
return null;
|
|
return function(control) {
|
|
return _mergeErrors(_executeValidators(control, presentValidators));
|
|
};
|
|
};
|
|
Validators.composeAsync = function(validators) {
|
|
if (lang_1.isBlank(validators))
|
|
return null;
|
|
var presentValidators = validators.filter(lang_1.isPresent);
|
|
if (presentValidators.length == 0)
|
|
return null;
|
|
return function(control) {
|
|
var promises = _executeValidators(control, presentValidators).map(_convertToPromise);
|
|
return promise_1.PromiseWrapper.all(promises).then(_mergeErrors);
|
|
};
|
|
};
|
|
return Validators;
|
|
})();
|
|
exports.Validators = Validators;
|
|
function _convertToPromise(obj) {
|
|
return promise_1.PromiseWrapper.isPromise(obj) ? obj : async_1.ObservableWrapper.toPromise(obj);
|
|
}
|
|
function _executeValidators(control, validators) {
|
|
return validators.map(function(v) {
|
|
return v(control);
|
|
});
|
|
}
|
|
function _mergeErrors(arrayOfErrors) {
|
|
var res = arrayOfErrors.reduce(function(res, errors) {
|
|
return lang_1.isPresent(errors) ? collection_1.StringMapWrapper.merge(res, errors) : res;
|
|
}, {});
|
|
return collection_1.StringMapWrapper.isEmpty(res) ? null : res;
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("bc", ["14", "20", "ad"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var validators_1 = $__require('ad');
|
|
var lang_2 = $__require('20');
|
|
var REQUIRED_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, {
|
|
useValue: validators_1.Validators.required,
|
|
multi: true
|
|
}));
|
|
var RequiredValidator = (function() {
|
|
function RequiredValidator() {}
|
|
RequiredValidator = __decorate([core_1.Directive({
|
|
selector: '[required][ngControl],[required][ngFormControl],[required][ngModel]',
|
|
providers: [REQUIRED_VALIDATOR]
|
|
}), __metadata('design:paramtypes', [])], RequiredValidator);
|
|
return RequiredValidator;
|
|
})();
|
|
exports.RequiredValidator = RequiredValidator;
|
|
var MIN_LENGTH_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return MinLengthValidator;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var MinLengthValidator = (function() {
|
|
function MinLengthValidator(minLength) {
|
|
this._validator = validators_1.Validators.minLength(lang_2.NumberWrapper.parseInt(minLength, 10));
|
|
}
|
|
MinLengthValidator.prototype.validate = function(c) {
|
|
return this._validator(c);
|
|
};
|
|
MinLengthValidator = __decorate([core_1.Directive({
|
|
selector: '[minlength][ngControl],[minlength][ngFormControl],[minlength][ngModel]',
|
|
providers: [MIN_LENGTH_VALIDATOR]
|
|
}), __param(0, core_1.Attribute("minlength")), __metadata('design:paramtypes', [String])], MinLengthValidator);
|
|
return MinLengthValidator;
|
|
})();
|
|
exports.MinLengthValidator = MinLengthValidator;
|
|
var MAX_LENGTH_VALIDATOR = lang_1.CONST_EXPR(new core_1.Provider(validators_1.NG_VALIDATORS, {
|
|
useExisting: core_1.forwardRef(function() {
|
|
return MaxLengthValidator;
|
|
}),
|
|
multi: true
|
|
}));
|
|
var MaxLengthValidator = (function() {
|
|
function MaxLengthValidator(maxLength) {
|
|
this._validator = validators_1.Validators.maxLength(lang_2.NumberWrapper.parseInt(maxLength, 10));
|
|
}
|
|
MaxLengthValidator.prototype.validate = function(c) {
|
|
return this._validator(c);
|
|
};
|
|
MaxLengthValidator = __decorate([core_1.Directive({
|
|
selector: '[maxlength][ngControl],[maxlength][ngFormControl],[maxlength][ngModel]',
|
|
providers: [MAX_LENGTH_VALIDATOR]
|
|
}), __param(0, core_1.Attribute("maxlength")), __metadata('design:paramtypes', [String])], MaxLengthValidator);
|
|
return MaxLengthValidator;
|
|
})();
|
|
exports.MaxLengthValidator = MaxLengthValidator;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("b0", ["20", "63", "8b", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var promise_1 = $__require('8b');
|
|
var collection_1 = $__require('37');
|
|
exports.VALID = "VALID";
|
|
exports.INVALID = "INVALID";
|
|
exports.PENDING = "PENDING";
|
|
function isControl(control) {
|
|
return control instanceof AbstractControl;
|
|
}
|
|
exports.isControl = isControl;
|
|
function _find(control, path) {
|
|
if (lang_1.isBlank(path))
|
|
return null;
|
|
if (!(path instanceof Array)) {
|
|
path = path.split("/");
|
|
}
|
|
if (path instanceof Array && collection_1.ListWrapper.isEmpty(path))
|
|
return null;
|
|
return path.reduce(function(v, name) {
|
|
if (v instanceof ControlGroup) {
|
|
return lang_1.isPresent(v.controls[name]) ? v.controls[name] : null;
|
|
} else if (v instanceof ControlArray) {
|
|
var index = name;
|
|
return lang_1.isPresent(v.at(index)) ? v.at(index) : null;
|
|
} else {
|
|
return null;
|
|
}
|
|
}, control);
|
|
}
|
|
function toObservable(r) {
|
|
return promise_1.PromiseWrapper.isPromise(r) ? async_1.ObservableWrapper.fromPromise(r) : r;
|
|
}
|
|
var AbstractControl = (function() {
|
|
function AbstractControl(validator, asyncValidator) {
|
|
this.validator = validator;
|
|
this.asyncValidator = asyncValidator;
|
|
this._pristine = true;
|
|
this._touched = false;
|
|
}
|
|
Object.defineProperty(AbstractControl.prototype, "value", {
|
|
get: function() {
|
|
return this._value;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "status", {
|
|
get: function() {
|
|
return this._status;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "valid", {
|
|
get: function() {
|
|
return this._status === exports.VALID;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "errors", {
|
|
get: function() {
|
|
return this._errors;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "pristine", {
|
|
get: function() {
|
|
return this._pristine;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "dirty", {
|
|
get: function() {
|
|
return !this.pristine;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "touched", {
|
|
get: function() {
|
|
return this._touched;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "untouched", {
|
|
get: function() {
|
|
return !this._touched;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "valueChanges", {
|
|
get: function() {
|
|
return this._valueChanges;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "statusChanges", {
|
|
get: function() {
|
|
return this._statusChanges;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(AbstractControl.prototype, "pending", {
|
|
get: function() {
|
|
return this._status == exports.PENDING;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
AbstractControl.prototype.markAsTouched = function() {
|
|
this._touched = true;
|
|
};
|
|
AbstractControl.prototype.markAsDirty = function(_a) {
|
|
var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
|
|
onlySelf = lang_1.normalizeBool(onlySelf);
|
|
this._pristine = false;
|
|
if (lang_1.isPresent(this._parent) && !onlySelf) {
|
|
this._parent.markAsDirty({onlySelf: onlySelf});
|
|
}
|
|
};
|
|
AbstractControl.prototype.markAsPending = function(_a) {
|
|
var onlySelf = (_a === void 0 ? {} : _a).onlySelf;
|
|
onlySelf = lang_1.normalizeBool(onlySelf);
|
|
this._status = exports.PENDING;
|
|
if (lang_1.isPresent(this._parent) && !onlySelf) {
|
|
this._parent.markAsPending({onlySelf: onlySelf});
|
|
}
|
|
};
|
|
AbstractControl.prototype.setParent = function(parent) {
|
|
this._parent = parent;
|
|
};
|
|
AbstractControl.prototype.updateValueAndValidity = function(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
onlySelf = _b.onlySelf,
|
|
emitEvent = _b.emitEvent;
|
|
onlySelf = lang_1.normalizeBool(onlySelf);
|
|
emitEvent = lang_1.isPresent(emitEvent) ? emitEvent : true;
|
|
this._updateValue();
|
|
this._errors = this._runValidator();
|
|
this._status = this._calculateStatus();
|
|
if (this._status == exports.VALID || this._status == exports.PENDING) {
|
|
this._runAsyncValidator(emitEvent);
|
|
}
|
|
if (emitEvent) {
|
|
async_1.ObservableWrapper.callEmit(this._valueChanges, this._value);
|
|
async_1.ObservableWrapper.callEmit(this._statusChanges, this._status);
|
|
}
|
|
if (lang_1.isPresent(this._parent) && !onlySelf) {
|
|
this._parent.updateValueAndValidity({
|
|
onlySelf: onlySelf,
|
|
emitEvent: emitEvent
|
|
});
|
|
}
|
|
};
|
|
AbstractControl.prototype._runValidator = function() {
|
|
return lang_1.isPresent(this.validator) ? this.validator(this) : null;
|
|
};
|
|
AbstractControl.prototype._runAsyncValidator = function(emitEvent) {
|
|
var _this = this;
|
|
if (lang_1.isPresent(this.asyncValidator)) {
|
|
this._status = exports.PENDING;
|
|
this._cancelExistingSubscription();
|
|
var obs = toObservable(this.asyncValidator(this));
|
|
this._asyncValidationSubscription = async_1.ObservableWrapper.subscribe(obs, function(res) {
|
|
return _this.setErrors(res, {emitEvent: emitEvent});
|
|
});
|
|
}
|
|
};
|
|
AbstractControl.prototype._cancelExistingSubscription = function() {
|
|
if (lang_1.isPresent(this._asyncValidationSubscription)) {
|
|
async_1.ObservableWrapper.dispose(this._asyncValidationSubscription);
|
|
}
|
|
};
|
|
AbstractControl.prototype.setErrors = function(errors, _a) {
|
|
var emitEvent = (_a === void 0 ? {} : _a).emitEvent;
|
|
emitEvent = lang_1.isPresent(emitEvent) ? emitEvent : true;
|
|
this._errors = errors;
|
|
this._status = this._calculateStatus();
|
|
if (emitEvent) {
|
|
async_1.ObservableWrapper.callEmit(this._statusChanges, this._status);
|
|
}
|
|
if (lang_1.isPresent(this._parent)) {
|
|
this._parent._updateControlsErrors();
|
|
}
|
|
};
|
|
AbstractControl.prototype.find = function(path) {
|
|
return _find(this, path);
|
|
};
|
|
AbstractControl.prototype.getError = function(errorCode, path) {
|
|
if (path === void 0) {
|
|
path = null;
|
|
}
|
|
var control = lang_1.isPresent(path) && !collection_1.ListWrapper.isEmpty(path) ? this.find(path) : this;
|
|
if (lang_1.isPresent(control) && lang_1.isPresent(control._errors)) {
|
|
return collection_1.StringMapWrapper.get(control._errors, errorCode);
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
AbstractControl.prototype.hasError = function(errorCode, path) {
|
|
if (path === void 0) {
|
|
path = null;
|
|
}
|
|
return lang_1.isPresent(this.getError(errorCode, path));
|
|
};
|
|
AbstractControl.prototype._updateControlsErrors = function() {
|
|
this._status = this._calculateStatus();
|
|
if (lang_1.isPresent(this._parent)) {
|
|
this._parent._updateControlsErrors();
|
|
}
|
|
};
|
|
AbstractControl.prototype._initObservables = function() {
|
|
this._valueChanges = new async_1.EventEmitter();
|
|
this._statusChanges = new async_1.EventEmitter();
|
|
};
|
|
AbstractControl.prototype._calculateStatus = function() {
|
|
if (lang_1.isPresent(this._errors))
|
|
return exports.INVALID;
|
|
if (this._anyControlsHaveStatus(exports.PENDING))
|
|
return exports.PENDING;
|
|
if (this._anyControlsHaveStatus(exports.INVALID))
|
|
return exports.INVALID;
|
|
return exports.VALID;
|
|
};
|
|
return AbstractControl;
|
|
})();
|
|
exports.AbstractControl = AbstractControl;
|
|
var Control = (function(_super) {
|
|
__extends(Control, _super);
|
|
function Control(value, validator, asyncValidator) {
|
|
if (value === void 0) {
|
|
value = null;
|
|
}
|
|
if (validator === void 0) {
|
|
validator = null;
|
|
}
|
|
if (asyncValidator === void 0) {
|
|
asyncValidator = null;
|
|
}
|
|
_super.call(this, validator, asyncValidator);
|
|
this._value = value;
|
|
this.updateValueAndValidity({
|
|
onlySelf: true,
|
|
emitEvent: false
|
|
});
|
|
this._initObservables();
|
|
}
|
|
Control.prototype.updateValue = function(value, _a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
onlySelf = _b.onlySelf,
|
|
emitEvent = _b.emitEvent,
|
|
emitModelToViewChange = _b.emitModelToViewChange;
|
|
emitModelToViewChange = lang_1.isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
|
|
this._value = value;
|
|
if (lang_1.isPresent(this._onChange) && emitModelToViewChange)
|
|
this._onChange(this._value);
|
|
this.updateValueAndValidity({
|
|
onlySelf: onlySelf,
|
|
emitEvent: emitEvent
|
|
});
|
|
};
|
|
Control.prototype._updateValue = function() {};
|
|
Control.prototype._anyControlsHaveStatus = function(status) {
|
|
return false;
|
|
};
|
|
Control.prototype.registerOnChange = function(fn) {
|
|
this._onChange = fn;
|
|
};
|
|
return Control;
|
|
})(AbstractControl);
|
|
exports.Control = Control;
|
|
var ControlGroup = (function(_super) {
|
|
__extends(ControlGroup, _super);
|
|
function ControlGroup(controls, optionals, validator, asyncValidator) {
|
|
if (optionals === void 0) {
|
|
optionals = null;
|
|
}
|
|
if (validator === void 0) {
|
|
validator = null;
|
|
}
|
|
if (asyncValidator === void 0) {
|
|
asyncValidator = null;
|
|
}
|
|
_super.call(this, validator, asyncValidator);
|
|
this.controls = controls;
|
|
this._optionals = lang_1.isPresent(optionals) ? optionals : {};
|
|
this._initObservables();
|
|
this._setParentForControls();
|
|
this.updateValueAndValidity({
|
|
onlySelf: true,
|
|
emitEvent: false
|
|
});
|
|
}
|
|
ControlGroup.prototype.addControl = function(name, control) {
|
|
this.controls[name] = control;
|
|
control.setParent(this);
|
|
};
|
|
ControlGroup.prototype.removeControl = function(name) {
|
|
collection_1.StringMapWrapper.delete(this.controls, name);
|
|
};
|
|
ControlGroup.prototype.include = function(controlName) {
|
|
collection_1.StringMapWrapper.set(this._optionals, controlName, true);
|
|
this.updateValueAndValidity();
|
|
};
|
|
ControlGroup.prototype.exclude = function(controlName) {
|
|
collection_1.StringMapWrapper.set(this._optionals, controlName, false);
|
|
this.updateValueAndValidity();
|
|
};
|
|
ControlGroup.prototype.contains = function(controlName) {
|
|
var c = collection_1.StringMapWrapper.contains(this.controls, controlName);
|
|
return c && this._included(controlName);
|
|
};
|
|
ControlGroup.prototype._setParentForControls = function() {
|
|
var _this = this;
|
|
collection_1.StringMapWrapper.forEach(this.controls, function(control, name) {
|
|
control.setParent(_this);
|
|
});
|
|
};
|
|
ControlGroup.prototype._updateValue = function() {
|
|
this._value = this._reduceValue();
|
|
};
|
|
ControlGroup.prototype._anyControlsHaveStatus = function(status) {
|
|
var _this = this;
|
|
var res = false;
|
|
collection_1.StringMapWrapper.forEach(this.controls, function(control, name) {
|
|
res = res || (_this.contains(name) && control.status == status);
|
|
});
|
|
return res;
|
|
};
|
|
ControlGroup.prototype._reduceValue = function() {
|
|
return this._reduceChildren({}, function(acc, control, name) {
|
|
acc[name] = control.value;
|
|
return acc;
|
|
});
|
|
};
|
|
ControlGroup.prototype._reduceChildren = function(initValue, fn) {
|
|
var _this = this;
|
|
var res = initValue;
|
|
collection_1.StringMapWrapper.forEach(this.controls, function(control, name) {
|
|
if (_this._included(name)) {
|
|
res = fn(res, control, name);
|
|
}
|
|
});
|
|
return res;
|
|
};
|
|
ControlGroup.prototype._included = function(controlName) {
|
|
var isOptional = collection_1.StringMapWrapper.contains(this._optionals, controlName);
|
|
return !isOptional || collection_1.StringMapWrapper.get(this._optionals, controlName);
|
|
};
|
|
return ControlGroup;
|
|
})(AbstractControl);
|
|
exports.ControlGroup = ControlGroup;
|
|
var ControlArray = (function(_super) {
|
|
__extends(ControlArray, _super);
|
|
function ControlArray(controls, validator, asyncValidator) {
|
|
if (validator === void 0) {
|
|
validator = null;
|
|
}
|
|
if (asyncValidator === void 0) {
|
|
asyncValidator = null;
|
|
}
|
|
_super.call(this, validator, asyncValidator);
|
|
this.controls = controls;
|
|
this._initObservables();
|
|
this._setParentForControls();
|
|
this.updateValueAndValidity({
|
|
onlySelf: true,
|
|
emitEvent: false
|
|
});
|
|
}
|
|
ControlArray.prototype.at = function(index) {
|
|
return this.controls[index];
|
|
};
|
|
ControlArray.prototype.push = function(control) {
|
|
this.controls.push(control);
|
|
control.setParent(this);
|
|
this.updateValueAndValidity();
|
|
};
|
|
ControlArray.prototype.insert = function(index, control) {
|
|
collection_1.ListWrapper.insert(this.controls, index, control);
|
|
control.setParent(this);
|
|
this.updateValueAndValidity();
|
|
};
|
|
ControlArray.prototype.removeAt = function(index) {
|
|
collection_1.ListWrapper.removeAt(this.controls, index);
|
|
this.updateValueAndValidity();
|
|
};
|
|
Object.defineProperty(ControlArray.prototype, "length", {
|
|
get: function() {
|
|
return this.controls.length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ControlArray.prototype._updateValue = function() {
|
|
this._value = this.controls.map(function(control) {
|
|
return control.value;
|
|
});
|
|
};
|
|
ControlArray.prototype._anyControlsHaveStatus = function(status) {
|
|
return this.controls.some(function(c) {
|
|
return c.status == status;
|
|
});
|
|
};
|
|
ControlArray.prototype._setParentForControls = function() {
|
|
var _this = this;
|
|
this.controls.forEach(function(control) {
|
|
control.setParent(_this);
|
|
});
|
|
};
|
|
return ControlArray;
|
|
})(AbstractControl);
|
|
exports.ControlArray = ControlArray;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("bd", ["14", "37", "20", "b0"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var modelModule = $__require('b0');
|
|
var FormBuilder = (function() {
|
|
function FormBuilder() {}
|
|
FormBuilder.prototype.group = function(controlsConfig, extra) {
|
|
if (extra === void 0) {
|
|
extra = null;
|
|
}
|
|
var controls = this._reduceControls(controlsConfig);
|
|
var optionals = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "optionals") : null;
|
|
var validator = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "validator") : null;
|
|
var asyncValidator = lang_1.isPresent(extra) ? collection_1.StringMapWrapper.get(extra, "asyncValidator") : null;
|
|
return new modelModule.ControlGroup(controls, optionals, validator, asyncValidator);
|
|
};
|
|
FormBuilder.prototype.control = function(value, validator, asyncValidator) {
|
|
if (validator === void 0) {
|
|
validator = null;
|
|
}
|
|
if (asyncValidator === void 0) {
|
|
asyncValidator = null;
|
|
}
|
|
return new modelModule.Control(value, validator, asyncValidator);
|
|
};
|
|
FormBuilder.prototype.array = function(controlsConfig, validator, asyncValidator) {
|
|
var _this = this;
|
|
if (validator === void 0) {
|
|
validator = null;
|
|
}
|
|
if (asyncValidator === void 0) {
|
|
asyncValidator = null;
|
|
}
|
|
var controls = controlsConfig.map(function(c) {
|
|
return _this._createControl(c);
|
|
});
|
|
return new modelModule.ControlArray(controls, validator, asyncValidator);
|
|
};
|
|
FormBuilder.prototype._reduceControls = function(controlsConfig) {
|
|
var _this = this;
|
|
var controls = {};
|
|
collection_1.StringMapWrapper.forEach(controlsConfig, function(controlConfig, controlName) {
|
|
controls[controlName] = _this._createControl(controlConfig);
|
|
});
|
|
return controls;
|
|
};
|
|
FormBuilder.prototype._createControl = function(controlConfig) {
|
|
if (controlConfig instanceof modelModule.Control || controlConfig instanceof modelModule.ControlGroup || controlConfig instanceof modelModule.ControlArray) {
|
|
return controlConfig;
|
|
} else if (lang_1.isArray(controlConfig)) {
|
|
var value = controlConfig[0];
|
|
var validator = controlConfig.length > 1 ? controlConfig[1] : null;
|
|
var asyncValidator = controlConfig.length > 2 ? controlConfig[2] : null;
|
|
return this.control(value, validator, asyncValidator);
|
|
} else {
|
|
return this.control(controlConfig);
|
|
}
|
|
};
|
|
FormBuilder = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], FormBuilder);
|
|
return FormBuilder;
|
|
})();
|
|
exports.FormBuilder = FormBuilder;
|
|
exports.FORM_PROVIDERS = lang_1.CONST_EXPR([FormBuilder]);
|
|
exports.FORM_BINDINGS = exports.FORM_PROVIDERS;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("be", ["b0", "b3", "a9", "a8", "ae", "af", "aa", "b1", "b2", "b9", "ab", "b5", "ba", "b7", "b8", "bb", "ad", "bc", "bd"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var model_1 = $__require('b0');
|
|
exports.AbstractControl = model_1.AbstractControl;
|
|
exports.Control = model_1.Control;
|
|
exports.ControlGroup = model_1.ControlGroup;
|
|
exports.ControlArray = model_1.ControlArray;
|
|
var abstract_control_directive_1 = $__require('b3');
|
|
exports.AbstractControlDirective = abstract_control_directive_1.AbstractControlDirective;
|
|
var control_container_1 = $__require('a9');
|
|
exports.ControlContainer = control_container_1.ControlContainer;
|
|
var ng_control_name_1 = $__require('a8');
|
|
exports.NgControlName = ng_control_name_1.NgControlName;
|
|
var ng_form_control_1 = $__require('ae');
|
|
exports.NgFormControl = ng_form_control_1.NgFormControl;
|
|
var ng_model_1 = $__require('af');
|
|
exports.NgModel = ng_model_1.NgModel;
|
|
var ng_control_1 = $__require('aa');
|
|
exports.NgControl = ng_control_1.NgControl;
|
|
var ng_control_group_1 = $__require('b1');
|
|
exports.NgControlGroup = ng_control_group_1.NgControlGroup;
|
|
var ng_form_model_1 = $__require('b2');
|
|
exports.NgFormModel = ng_form_model_1.NgFormModel;
|
|
var ng_form_1 = $__require('b9');
|
|
exports.NgForm = ng_form_1.NgForm;
|
|
var control_value_accessor_1 = $__require('ab');
|
|
exports.NG_VALUE_ACCESSOR = control_value_accessor_1.NG_VALUE_ACCESSOR;
|
|
var default_value_accessor_1 = $__require('b5');
|
|
exports.DefaultValueAccessor = default_value_accessor_1.DefaultValueAccessor;
|
|
var ng_control_status_1 = $__require('ba');
|
|
exports.NgControlStatus = ng_control_status_1.NgControlStatus;
|
|
var checkbox_value_accessor_1 = $__require('b7');
|
|
exports.CheckboxControlValueAccessor = checkbox_value_accessor_1.CheckboxControlValueAccessor;
|
|
var select_control_value_accessor_1 = $__require('b8');
|
|
exports.NgSelectOption = select_control_value_accessor_1.NgSelectOption;
|
|
exports.SelectControlValueAccessor = select_control_value_accessor_1.SelectControlValueAccessor;
|
|
var directives_1 = $__require('bb');
|
|
exports.FORM_DIRECTIVES = directives_1.FORM_DIRECTIVES;
|
|
var validators_1 = $__require('ad');
|
|
exports.NG_VALIDATORS = validators_1.NG_VALIDATORS;
|
|
exports.NG_ASYNC_VALIDATORS = validators_1.NG_ASYNC_VALIDATORS;
|
|
exports.Validators = validators_1.Validators;
|
|
var validators_2 = $__require('bc');
|
|
exports.RequiredValidator = validators_2.RequiredValidator;
|
|
exports.MinLengthValidator = validators_2.MinLengthValidator;
|
|
exports.MaxLengthValidator = validators_2.MaxLengthValidator;
|
|
var form_builder_1 = $__require('bd');
|
|
exports.FormBuilder = form_builder_1.FormBuilder;
|
|
exports.FORM_PROVIDERS = form_builder_1.FORM_PROVIDERS;
|
|
exports.FORM_BINDINGS = form_builder_1.FORM_BINDINGS;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("bf", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c0", ["20", "14", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var core_1 = $__require('14');
|
|
var collection_1 = $__require('37');
|
|
var NgClass = (function() {
|
|
function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
|
|
this._iterableDiffers = _iterableDiffers;
|
|
this._keyValueDiffers = _keyValueDiffers;
|
|
this._ngEl = _ngEl;
|
|
this._renderer = _renderer;
|
|
this._initialClasses = [];
|
|
}
|
|
Object.defineProperty(NgClass.prototype, "initialClasses", {
|
|
set: function(v) {
|
|
this._applyInitialClasses(true);
|
|
this._initialClasses = lang_1.isPresent(v) && lang_1.isString(v) ? v.split(' ') : [];
|
|
this._applyInitialClasses(false);
|
|
this._applyClasses(this._rawClass, false);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgClass.prototype, "rawClass", {
|
|
set: function(v) {
|
|
this._cleanupClasses(this._rawClass);
|
|
if (lang_1.isString(v)) {
|
|
v = v.split(' ');
|
|
}
|
|
this._rawClass = v;
|
|
if (lang_1.isPresent(v)) {
|
|
if (collection_1.isListLikeIterable(v)) {
|
|
this._differ = this._iterableDiffers.find(v).create(null);
|
|
this._mode = 'iterable';
|
|
} else {
|
|
this._differ = this._keyValueDiffers.find(v).create(null);
|
|
this._mode = 'keyValue';
|
|
}
|
|
} else {
|
|
this._differ = null;
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgClass.prototype.ngDoCheck = function() {
|
|
if (lang_1.isPresent(this._differ)) {
|
|
var changes = this._differ.diff(this._rawClass);
|
|
if (lang_1.isPresent(changes)) {
|
|
if (this._mode == 'iterable') {
|
|
this._applyIterableChanges(changes);
|
|
} else {
|
|
this._applyKeyValueChanges(changes);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
NgClass.prototype.ngOnDestroy = function() {
|
|
this._cleanupClasses(this._rawClass);
|
|
};
|
|
NgClass.prototype._cleanupClasses = function(rawClassVal) {
|
|
this._applyClasses(rawClassVal, true);
|
|
this._applyInitialClasses(false);
|
|
};
|
|
NgClass.prototype._applyKeyValueChanges = function(changes) {
|
|
var _this = this;
|
|
changes.forEachAddedItem(function(record) {
|
|
_this._toggleClass(record.key, record.currentValue);
|
|
});
|
|
changes.forEachChangedItem(function(record) {
|
|
_this._toggleClass(record.key, record.currentValue);
|
|
});
|
|
changes.forEachRemovedItem(function(record) {
|
|
if (record.previousValue) {
|
|
_this._toggleClass(record.key, false);
|
|
}
|
|
});
|
|
};
|
|
NgClass.prototype._applyIterableChanges = function(changes) {
|
|
var _this = this;
|
|
changes.forEachAddedItem(function(record) {
|
|
_this._toggleClass(record.item, true);
|
|
});
|
|
changes.forEachRemovedItem(function(record) {
|
|
_this._toggleClass(record.item, false);
|
|
});
|
|
};
|
|
NgClass.prototype._applyInitialClasses = function(isCleanup) {
|
|
var _this = this;
|
|
this._initialClasses.forEach(function(className) {
|
|
return _this._toggleClass(className, !isCleanup);
|
|
});
|
|
};
|
|
NgClass.prototype._applyClasses = function(rawClassVal, isCleanup) {
|
|
var _this = this;
|
|
if (lang_1.isPresent(rawClassVal)) {
|
|
if (lang_1.isArray(rawClassVal)) {
|
|
rawClassVal.forEach(function(className) {
|
|
return _this._toggleClass(className, !isCleanup);
|
|
});
|
|
} else if (rawClassVal instanceof Set) {
|
|
rawClassVal.forEach(function(className) {
|
|
return _this._toggleClass(className, !isCleanup);
|
|
});
|
|
} else {
|
|
collection_1.StringMapWrapper.forEach(rawClassVal, function(expVal, className) {
|
|
if (expVal)
|
|
_this._toggleClass(className, !isCleanup);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
NgClass.prototype._toggleClass = function(className, enabled) {
|
|
className = className.trim();
|
|
if (className.length > 0) {
|
|
if (className.indexOf(' ') > -1) {
|
|
var classes = className.split(/\s+/g);
|
|
for (var i = 0,
|
|
len = classes.length; i < len; i++) {
|
|
this._renderer.setElementClass(this._ngEl, classes[i], enabled);
|
|
}
|
|
} else {
|
|
this._renderer.setElementClass(this._ngEl, className, enabled);
|
|
}
|
|
}
|
|
};
|
|
NgClass = __decorate([core_1.Directive({
|
|
selector: '[ngClass]',
|
|
inputs: ['rawClass: ngClass', 'initialClasses: class']
|
|
}), __metadata('design:paramtypes', [core_1.IterableDiffers, core_1.KeyValueDiffers, core_1.ElementRef, core_1.Renderer])], NgClass);
|
|
return NgClass;
|
|
})();
|
|
exports.NgClass = NgClass;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c1", ["14", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var NgFor = (function() {
|
|
function NgFor(_viewContainer, _templateRef, _iterableDiffers, _cdr) {
|
|
this._viewContainer = _viewContainer;
|
|
this._templateRef = _templateRef;
|
|
this._iterableDiffers = _iterableDiffers;
|
|
this._cdr = _cdr;
|
|
}
|
|
Object.defineProperty(NgFor.prototype, "ngForOf", {
|
|
set: function(value) {
|
|
this._ngForOf = value;
|
|
if (lang_1.isBlank(this._differ) && lang_1.isPresent(value)) {
|
|
this._differ = this._iterableDiffers.find(value).create(this._cdr);
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgFor.prototype, "ngForTemplate", {
|
|
set: function(value) {
|
|
if (lang_1.isPresent(value)) {
|
|
this._templateRef = value;
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgFor.prototype.ngDoCheck = function() {
|
|
if (lang_1.isPresent(this._differ)) {
|
|
var changes = this._differ.diff(this._ngForOf);
|
|
if (lang_1.isPresent(changes))
|
|
this._applyChanges(changes);
|
|
}
|
|
};
|
|
NgFor.prototype._applyChanges = function(changes) {
|
|
var recordViewTuples = [];
|
|
changes.forEachRemovedItem(function(removedRecord) {
|
|
return recordViewTuples.push(new RecordViewTuple(removedRecord, null));
|
|
});
|
|
changes.forEachMovedItem(function(movedRecord) {
|
|
return recordViewTuples.push(new RecordViewTuple(movedRecord, null));
|
|
});
|
|
var insertTuples = this._bulkRemove(recordViewTuples);
|
|
changes.forEachAddedItem(function(addedRecord) {
|
|
return insertTuples.push(new RecordViewTuple(addedRecord, null));
|
|
});
|
|
this._bulkInsert(insertTuples);
|
|
for (var i = 0; i < insertTuples.length; i++) {
|
|
this._perViewChange(insertTuples[i].view, insertTuples[i].record);
|
|
}
|
|
for (var i = 0,
|
|
ilen = this._viewContainer.length; i < ilen; i++) {
|
|
this._viewContainer.get(i).setLocal('last', i === ilen - 1);
|
|
}
|
|
};
|
|
NgFor.prototype._perViewChange = function(view, record) {
|
|
view.setLocal('\$implicit', record.item);
|
|
view.setLocal('index', record.currentIndex);
|
|
view.setLocal('even', (record.currentIndex % 2 == 0));
|
|
view.setLocal('odd', (record.currentIndex % 2 == 1));
|
|
};
|
|
NgFor.prototype._bulkRemove = function(tuples) {
|
|
tuples.sort(function(a, b) {
|
|
return a.record.previousIndex - b.record.previousIndex;
|
|
});
|
|
var movedTuples = [];
|
|
for (var i = tuples.length - 1; i >= 0; i--) {
|
|
var tuple = tuples[i];
|
|
if (lang_1.isPresent(tuple.record.currentIndex)) {
|
|
tuple.view = this._viewContainer.detach(tuple.record.previousIndex);
|
|
movedTuples.push(tuple);
|
|
} else {
|
|
this._viewContainer.remove(tuple.record.previousIndex);
|
|
}
|
|
}
|
|
return movedTuples;
|
|
};
|
|
NgFor.prototype._bulkInsert = function(tuples) {
|
|
tuples.sort(function(a, b) {
|
|
return a.record.currentIndex - b.record.currentIndex;
|
|
});
|
|
for (var i = 0; i < tuples.length; i++) {
|
|
var tuple = tuples[i];
|
|
if (lang_1.isPresent(tuple.view)) {
|
|
this._viewContainer.insert(tuple.view, tuple.record.currentIndex);
|
|
} else {
|
|
tuple.view = this._viewContainer.createEmbeddedView(this._templateRef, tuple.record.currentIndex);
|
|
}
|
|
}
|
|
return tuples;
|
|
};
|
|
NgFor = __decorate([core_1.Directive({
|
|
selector: '[ngFor][ngForOf]',
|
|
inputs: ['ngForOf', 'ngForTemplate']
|
|
}), __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, core_1.IterableDiffers, core_1.ChangeDetectorRef])], NgFor);
|
|
return NgFor;
|
|
})();
|
|
exports.NgFor = NgFor;
|
|
var RecordViewTuple = (function() {
|
|
function RecordViewTuple(record, view) {
|
|
this.record = record;
|
|
this.view = view;
|
|
}
|
|
return RecordViewTuple;
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c2", ["14", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var NgIf = (function() {
|
|
function NgIf(_viewContainer, _templateRef) {
|
|
this._viewContainer = _viewContainer;
|
|
this._templateRef = _templateRef;
|
|
this._prevCondition = null;
|
|
}
|
|
Object.defineProperty(NgIf.prototype, "ngIf", {
|
|
set: function(newCondition) {
|
|
if (newCondition && (lang_1.isBlank(this._prevCondition) || !this._prevCondition)) {
|
|
this._prevCondition = true;
|
|
this._viewContainer.createEmbeddedView(this._templateRef);
|
|
} else if (!newCondition && (lang_1.isBlank(this._prevCondition) || this._prevCondition)) {
|
|
this._prevCondition = false;
|
|
this._viewContainer.clear();
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgIf = __decorate([core_1.Directive({
|
|
selector: '[ngIf]',
|
|
inputs: ['ngIf']
|
|
}), __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef])], NgIf);
|
|
return NgIf;
|
|
})();
|
|
exports.NgIf = NgIf;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c3", ["14", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var NgStyle = (function() {
|
|
function NgStyle(_differs, _ngEl, _renderer) {
|
|
this._differs = _differs;
|
|
this._ngEl = _ngEl;
|
|
this._renderer = _renderer;
|
|
}
|
|
Object.defineProperty(NgStyle.prototype, "rawStyle", {
|
|
set: function(v) {
|
|
this._rawStyle = v;
|
|
if (lang_1.isBlank(this._differ) && lang_1.isPresent(v)) {
|
|
this._differ = this._differs.find(this._rawStyle).create(null);
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgStyle.prototype.ngDoCheck = function() {
|
|
if (lang_1.isPresent(this._differ)) {
|
|
var changes = this._differ.diff(this._rawStyle);
|
|
if (lang_1.isPresent(changes)) {
|
|
this._applyChanges(changes);
|
|
}
|
|
}
|
|
};
|
|
NgStyle.prototype._applyChanges = function(changes) {
|
|
var _this = this;
|
|
changes.forEachAddedItem(function(record) {
|
|
_this._setStyle(record.key, record.currentValue);
|
|
});
|
|
changes.forEachChangedItem(function(record) {
|
|
_this._setStyle(record.key, record.currentValue);
|
|
});
|
|
changes.forEachRemovedItem(function(record) {
|
|
_this._setStyle(record.key, null);
|
|
});
|
|
};
|
|
NgStyle.prototype._setStyle = function(name, val) {
|
|
this._renderer.setElementStyle(this._ngEl, name, val);
|
|
};
|
|
NgStyle = __decorate([core_1.Directive({
|
|
selector: '[ngStyle]',
|
|
inputs: ['rawStyle: ngStyle']
|
|
}), __metadata('design:paramtypes', [core_1.KeyValueDiffers, core_1.ElementRef, core_1.Renderer])], NgStyle);
|
|
return NgStyle;
|
|
})();
|
|
exports.NgStyle = NgStyle;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c4", ["14", "20", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var core_1 = $__require('14');
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var _WHEN_DEFAULT = lang_1.CONST_EXPR(new Object());
|
|
var SwitchView = (function() {
|
|
function SwitchView(_viewContainerRef, _templateRef) {
|
|
this._viewContainerRef = _viewContainerRef;
|
|
this._templateRef = _templateRef;
|
|
}
|
|
SwitchView.prototype.create = function() {
|
|
this._viewContainerRef.createEmbeddedView(this._templateRef);
|
|
};
|
|
SwitchView.prototype.destroy = function() {
|
|
this._viewContainerRef.clear();
|
|
};
|
|
return SwitchView;
|
|
})();
|
|
var NgSwitch = (function() {
|
|
function NgSwitch() {
|
|
this._useDefault = false;
|
|
this._valueViews = new collection_1.Map();
|
|
this._activeViews = [];
|
|
}
|
|
Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
|
|
set: function(value) {
|
|
this._emptyAllActiveViews();
|
|
this._useDefault = false;
|
|
var views = this._valueViews.get(value);
|
|
if (lang_1.isBlank(views)) {
|
|
this._useDefault = true;
|
|
views = lang_1.normalizeBlank(this._valueViews.get(_WHEN_DEFAULT));
|
|
}
|
|
this._activateViews(views);
|
|
this._switchValue = value;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgSwitch.prototype._onWhenValueChanged = function(oldWhen, newWhen, view) {
|
|
this._deregisterView(oldWhen, view);
|
|
this._registerView(newWhen, view);
|
|
if (oldWhen === this._switchValue) {
|
|
view.destroy();
|
|
collection_1.ListWrapper.remove(this._activeViews, view);
|
|
} else if (newWhen === this._switchValue) {
|
|
if (this._useDefault) {
|
|
this._useDefault = false;
|
|
this._emptyAllActiveViews();
|
|
}
|
|
view.create();
|
|
this._activeViews.push(view);
|
|
}
|
|
if (this._activeViews.length === 0 && !this._useDefault) {
|
|
this._useDefault = true;
|
|
this._activateViews(this._valueViews.get(_WHEN_DEFAULT));
|
|
}
|
|
};
|
|
NgSwitch.prototype._emptyAllActiveViews = function() {
|
|
var activeContainers = this._activeViews;
|
|
for (var i = 0; i < activeContainers.length; i++) {
|
|
activeContainers[i].destroy();
|
|
}
|
|
this._activeViews = [];
|
|
};
|
|
NgSwitch.prototype._activateViews = function(views) {
|
|
if (lang_1.isPresent(views)) {
|
|
for (var i = 0; i < views.length; i++) {
|
|
views[i].create();
|
|
}
|
|
this._activeViews = views;
|
|
}
|
|
};
|
|
NgSwitch.prototype._registerView = function(value, view) {
|
|
var views = this._valueViews.get(value);
|
|
if (lang_1.isBlank(views)) {
|
|
views = [];
|
|
this._valueViews.set(value, views);
|
|
}
|
|
views.push(view);
|
|
};
|
|
NgSwitch.prototype._deregisterView = function(value, view) {
|
|
if (value === _WHEN_DEFAULT)
|
|
return;
|
|
var views = this._valueViews.get(value);
|
|
if (views.length == 1) {
|
|
this._valueViews.delete(value);
|
|
} else {
|
|
collection_1.ListWrapper.remove(views, view);
|
|
}
|
|
};
|
|
NgSwitch = __decorate([core_1.Directive({
|
|
selector: '[ngSwitch]',
|
|
inputs: ['ngSwitch']
|
|
}), __metadata('design:paramtypes', [])], NgSwitch);
|
|
return NgSwitch;
|
|
})();
|
|
exports.NgSwitch = NgSwitch;
|
|
var NgSwitchWhen = (function() {
|
|
function NgSwitchWhen(viewContainer, templateRef, ngSwitch) {
|
|
this._value = _WHEN_DEFAULT;
|
|
this._switch = ngSwitch;
|
|
this._view = new SwitchView(viewContainer, templateRef);
|
|
}
|
|
Object.defineProperty(NgSwitchWhen.prototype, "ngSwitchWhen", {
|
|
set: function(value) {
|
|
this._switch._onWhenValueChanged(this._value, value, this._view);
|
|
this._value = value;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgSwitchWhen = __decorate([core_1.Directive({
|
|
selector: '[ngSwitchWhen]',
|
|
inputs: ['ngSwitchWhen']
|
|
}), __param(2, core_1.Host()), __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])], NgSwitchWhen);
|
|
return NgSwitchWhen;
|
|
})();
|
|
exports.NgSwitchWhen = NgSwitchWhen;
|
|
var NgSwitchDefault = (function() {
|
|
function NgSwitchDefault(viewContainer, templateRef, sswitch) {
|
|
sswitch._registerView(_WHEN_DEFAULT, new SwitchView(viewContainer, templateRef));
|
|
}
|
|
NgSwitchDefault = __decorate([core_1.Directive({selector: '[ngSwitchDefault]'}), __param(2, core_1.Host()), __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])], NgSwitchDefault);
|
|
return NgSwitchDefault;
|
|
})();
|
|
exports.NgSwitchDefault = NgSwitchDefault;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c5", ["20", "c0", "c1", "c2", "c3", "c4"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var ng_class_1 = $__require('c0');
|
|
var ng_for_1 = $__require('c1');
|
|
var ng_if_1 = $__require('c2');
|
|
var ng_style_1 = $__require('c3');
|
|
var ng_switch_1 = $__require('c4');
|
|
exports.CORE_DIRECTIVES = lang_1.CONST_EXPR([ng_class_1.NgClass, ng_for_1.NgFor, ng_if_1.NgIf, ng_style_1.NgStyle, ng_switch_1.NgSwitch, ng_switch_1.NgSwitchWhen, ng_switch_1.NgSwitchDefault]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c6", ["c0", "c1", "c2", "c3", "c4", "bf", "c5"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
var ng_class_1 = $__require('c0');
|
|
exports.NgClass = ng_class_1.NgClass;
|
|
var ng_for_1 = $__require('c1');
|
|
exports.NgFor = ng_for_1.NgFor;
|
|
var ng_if_1 = $__require('c2');
|
|
exports.NgIf = ng_if_1.NgIf;
|
|
var ng_style_1 = $__require('c3');
|
|
exports.NgStyle = ng_style_1.NgStyle;
|
|
var ng_switch_1 = $__require('c4');
|
|
exports.NgSwitch = ng_switch_1.NgSwitch;
|
|
exports.NgSwitchWhen = ng_switch_1.NgSwitchWhen;
|
|
exports.NgSwitchDefault = ng_switch_1.NgSwitchDefault;
|
|
__export($__require('bf'));
|
|
var core_directives_1 = $__require('c5');
|
|
exports.CORE_DIRECTIVES = core_directives_1.CORE_DIRECTIVES;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c7", ["20", "be", "c6"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var forms_1 = $__require('be');
|
|
var directives_1 = $__require('c6');
|
|
exports.COMMON_DIRECTIVES = lang_1.CONST_EXPR([directives_1.CORE_DIRECTIVES, forms_1.FORM_DIRECTIVES]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("22", ["a7", "c6", "be", "c7"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
__export($__require('a7'));
|
|
__export($__require('c6'));
|
|
__export($__require('be'));
|
|
__export($__require('c7'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c8", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = Object.is || function is(x, y) {
|
|
return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("c9", ["ca", "cb", "2b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var anObject = $__require('ca'),
|
|
aFunction = $__require('cb'),
|
|
SPECIES = $__require('2b')('species');
|
|
module.exports = function(O, D) {
|
|
var C = anObject(O).constructor,
|
|
S;
|
|
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("cc", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(fn, args, that) {
|
|
var un = that === undefined;
|
|
switch (args.length) {
|
|
case 0:
|
|
return un ? fn() : fn.call(that);
|
|
case 1:
|
|
return un ? fn(args[0]) : fn.call(that, args[0]);
|
|
case 2:
|
|
return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
|
|
case 3:
|
|
return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
|
|
case 4:
|
|
return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
|
|
}
|
|
return fn.apply(that, args);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("cd", ["ce"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('ce').document && document.documentElement;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("cf", ["d0", "ce"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var isObject = $__require('d0'),
|
|
document = $__require('ce').document,
|
|
is = isObject(document) && isObject(document.createElement);
|
|
module.exports = function(it) {
|
|
return is ? document.createElement(it) : {};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d1", ["8e", "cc", "cd", "cf", "ce", "d2", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
var ctx = $__require('8e'),
|
|
invoke = $__require('cc'),
|
|
html = $__require('cd'),
|
|
cel = $__require('cf'),
|
|
global = $__require('ce'),
|
|
process = global.process,
|
|
setTask = global.setImmediate,
|
|
clearTask = global.clearImmediate,
|
|
MessageChannel = global.MessageChannel,
|
|
counter = 0,
|
|
queue = {},
|
|
ONREADYSTATECHANGE = 'onreadystatechange',
|
|
defer,
|
|
channel,
|
|
port;
|
|
var run = function() {
|
|
var id = +this;
|
|
if (queue.hasOwnProperty(id)) {
|
|
var fn = queue[id];
|
|
delete queue[id];
|
|
fn();
|
|
}
|
|
};
|
|
var listner = function(event) {
|
|
run.call(event.data);
|
|
};
|
|
if (!setTask || !clearTask) {
|
|
setTask = function setImmediate(fn) {
|
|
var args = [],
|
|
i = 1;
|
|
while (arguments.length > i)
|
|
args.push(arguments[i++]);
|
|
queue[++counter] = function() {
|
|
invoke(typeof fn == 'function' ? fn : Function(fn), args);
|
|
};
|
|
defer(counter);
|
|
return counter;
|
|
};
|
|
clearTask = function clearImmediate(id) {
|
|
delete queue[id];
|
|
};
|
|
if ($__require('d2')(process) == 'process') {
|
|
defer = function(id) {
|
|
process.nextTick(ctx(run, id, 1));
|
|
};
|
|
} else if (MessageChannel) {
|
|
channel = new MessageChannel;
|
|
port = channel.port2;
|
|
channel.port1.onmessage = listner;
|
|
defer = ctx(port.postMessage, port, 1);
|
|
} else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
|
|
defer = function(id) {
|
|
global.postMessage(id + '', '*');
|
|
};
|
|
global.addEventListener('message', listner, false);
|
|
} else if (ONREADYSTATECHANGE in cel('script')) {
|
|
defer = function(id) {
|
|
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function() {
|
|
html.removeChild(this);
|
|
run.call(id);
|
|
};
|
|
};
|
|
} else {
|
|
defer = function(id) {
|
|
setTimeout(ctx(run, id, 1), 0);
|
|
};
|
|
}
|
|
}
|
|
module.exports = {
|
|
set: setTask,
|
|
clear: clearTask
|
|
};
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d3", ["ce", "d1", "d2", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
var global = $__require('ce'),
|
|
macrotask = $__require('d1').set,
|
|
Observer = global.MutationObserver || global.WebKitMutationObserver,
|
|
process = global.process,
|
|
Promise = global.Promise,
|
|
isNode = $__require('d2')(process) == 'process',
|
|
head,
|
|
last,
|
|
notify;
|
|
var flush = function() {
|
|
var parent,
|
|
domain,
|
|
fn;
|
|
if (isNode && (parent = process.domain)) {
|
|
process.domain = null;
|
|
parent.exit();
|
|
}
|
|
while (head) {
|
|
domain = head.domain;
|
|
fn = head.fn;
|
|
if (domain)
|
|
domain.enter();
|
|
fn();
|
|
if (domain)
|
|
domain.exit();
|
|
head = head.next;
|
|
}
|
|
last = undefined;
|
|
if (parent)
|
|
parent.enter();
|
|
};
|
|
if (isNode) {
|
|
notify = function() {
|
|
process.nextTick(flush);
|
|
};
|
|
} else if (Observer) {
|
|
var toggle = 1,
|
|
node = document.createTextNode('');
|
|
new Observer(flush).observe(node, {characterData: true});
|
|
notify = function() {
|
|
node.data = toggle = -toggle;
|
|
};
|
|
} else if (Promise && Promise.resolve) {
|
|
notify = function() {
|
|
Promise.resolve().then(flush);
|
|
};
|
|
} else {
|
|
notify = function() {
|
|
macrotask.call(global, flush);
|
|
};
|
|
}
|
|
module.exports = function asap(fn) {
|
|
var task = {
|
|
fn: fn,
|
|
next: undefined,
|
|
domain: isNode && process.domain
|
|
};
|
|
if (last)
|
|
last.next = task;
|
|
if (!head) {
|
|
head = task;
|
|
notify();
|
|
}
|
|
last = task;
|
|
};
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("95", ["2b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ITERATOR = $__require('2b')('iterator'),
|
|
SAFE_CLOSING = false;
|
|
try {
|
|
var riter = [7][ITERATOR]();
|
|
riter['return'] = function() {
|
|
SAFE_CLOSING = true;
|
|
};
|
|
Array.from(riter, function() {
|
|
throw 2;
|
|
});
|
|
} catch (e) {}
|
|
module.exports = function(exec, skipClosing) {
|
|
if (!skipClosing && !SAFE_CLOSING)
|
|
return false;
|
|
var safe = false;
|
|
try {
|
|
var arr = [7],
|
|
iter = arr[ITERATOR]();
|
|
iter.next = function() {
|
|
safe = true;
|
|
};
|
|
arr[ITERATOR] = function() {
|
|
return iter;
|
|
};
|
|
exec(arr);
|
|
} catch (e) {}
|
|
return safe;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d4", ["99", "d5", "ce", "8e", "2a", "8f", "d0", "ca", "cb", "d6", "d7", "d8", "c8", "2b", "c9", "d3", "d9", "da", "db", "dc", "2d", "95", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var $ = $__require('99'),
|
|
LIBRARY = $__require('d5'),
|
|
global = $__require('ce'),
|
|
ctx = $__require('8e'),
|
|
classof = $__require('2a'),
|
|
$export = $__require('8f'),
|
|
isObject = $__require('d0'),
|
|
anObject = $__require('ca'),
|
|
aFunction = $__require('cb'),
|
|
strictNew = $__require('d6'),
|
|
forOf = $__require('d7'),
|
|
setProto = $__require('d8').set,
|
|
same = $__require('c8'),
|
|
SPECIES = $__require('2b')('species'),
|
|
speciesConstructor = $__require('c9'),
|
|
asap = $__require('d3'),
|
|
PROMISE = 'Promise',
|
|
process = global.process,
|
|
isNode = classof(process) == 'process',
|
|
P = global[PROMISE],
|
|
Wrapper;
|
|
var testResolve = function(sub) {
|
|
var test = new P(function() {});
|
|
if (sub)
|
|
test.constructor = Object;
|
|
return P.resolve(test) === test;
|
|
};
|
|
var USE_NATIVE = function() {
|
|
var works = false;
|
|
function P2(x) {
|
|
var self = new P(x);
|
|
setProto(self, P2.prototype);
|
|
return self;
|
|
}
|
|
try {
|
|
works = P && P.resolve && testResolve();
|
|
setProto(P2, P);
|
|
P2.prototype = $.create(P.prototype, {constructor: {value: P2}});
|
|
if (!(P2.resolve(5).then(function() {}) instanceof P2)) {
|
|
works = false;
|
|
}
|
|
if (works && $__require('d9')) {
|
|
var thenableThenGotten = false;
|
|
P.resolve($.setDesc({}, 'then', {get: function() {
|
|
thenableThenGotten = true;
|
|
}}));
|
|
works = thenableThenGotten;
|
|
}
|
|
} catch (e) {
|
|
works = false;
|
|
}
|
|
return works;
|
|
}();
|
|
var sameConstructor = function(a, b) {
|
|
if (LIBRARY && a === P && b === Wrapper)
|
|
return true;
|
|
return same(a, b);
|
|
};
|
|
var getConstructor = function(C) {
|
|
var S = anObject(C)[SPECIES];
|
|
return S != undefined ? S : C;
|
|
};
|
|
var isThenable = function(it) {
|
|
var then;
|
|
return isObject(it) && typeof(then = it.then) == 'function' ? then : false;
|
|
};
|
|
var PromiseCapability = function(C) {
|
|
var resolve,
|
|
reject;
|
|
this.promise = new C(function($$resolve, $$reject) {
|
|
if (resolve !== undefined || reject !== undefined)
|
|
throw TypeError('Bad Promise constructor');
|
|
resolve = $$resolve;
|
|
reject = $$reject;
|
|
});
|
|
this.resolve = aFunction(resolve), this.reject = aFunction(reject);
|
|
};
|
|
var perform = function(exec) {
|
|
try {
|
|
exec();
|
|
} catch (e) {
|
|
return {error: e};
|
|
}
|
|
};
|
|
var notify = function(record, isReject) {
|
|
if (record.n)
|
|
return;
|
|
record.n = true;
|
|
var chain = record.c;
|
|
asap(function() {
|
|
var value = record.v,
|
|
ok = record.s == 1,
|
|
i = 0;
|
|
var run = function(reaction) {
|
|
var handler = ok ? reaction.ok : reaction.fail,
|
|
resolve = reaction.resolve,
|
|
reject = reaction.reject,
|
|
result,
|
|
then;
|
|
try {
|
|
if (handler) {
|
|
if (!ok)
|
|
record.h = true;
|
|
result = handler === true ? value : handler(value);
|
|
if (result === reaction.promise) {
|
|
reject(TypeError('Promise-chain cycle'));
|
|
} else if (then = isThenable(result)) {
|
|
then.call(result, resolve, reject);
|
|
} else
|
|
resolve(result);
|
|
} else
|
|
reject(value);
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
while (chain.length > i)
|
|
run(chain[i++]);
|
|
chain.length = 0;
|
|
record.n = false;
|
|
if (isReject)
|
|
setTimeout(function() {
|
|
var promise = record.p,
|
|
handler,
|
|
console;
|
|
if (isUnhandled(promise)) {
|
|
if (isNode) {
|
|
process.emit('unhandledRejection', value, promise);
|
|
} else if (handler = global.onunhandledrejection) {
|
|
handler({
|
|
promise: promise,
|
|
reason: value
|
|
});
|
|
} else if ((console = global.console) && console.error) {
|
|
console.error('Unhandled promise rejection', value);
|
|
}
|
|
}
|
|
record.a = undefined;
|
|
}, 1);
|
|
});
|
|
};
|
|
var isUnhandled = function(promise) {
|
|
var record = promise._d,
|
|
chain = record.a || record.c,
|
|
i = 0,
|
|
reaction;
|
|
if (record.h)
|
|
return false;
|
|
while (chain.length > i) {
|
|
reaction = chain[i++];
|
|
if (reaction.fail || !isUnhandled(reaction.promise))
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
var $reject = function(value) {
|
|
var record = this;
|
|
if (record.d)
|
|
return;
|
|
record.d = true;
|
|
record = record.r || record;
|
|
record.v = value;
|
|
record.s = 2;
|
|
record.a = record.c.slice();
|
|
notify(record, true);
|
|
};
|
|
var $resolve = function(value) {
|
|
var record = this,
|
|
then;
|
|
if (record.d)
|
|
return;
|
|
record.d = true;
|
|
record = record.r || record;
|
|
try {
|
|
if (record.p === value)
|
|
throw TypeError("Promise can't be resolved itself");
|
|
if (then = isThenable(value)) {
|
|
asap(function() {
|
|
var wrapper = {
|
|
r: record,
|
|
d: false
|
|
};
|
|
try {
|
|
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
|
|
} catch (e) {
|
|
$reject.call(wrapper, e);
|
|
}
|
|
});
|
|
} else {
|
|
record.v = value;
|
|
record.s = 1;
|
|
notify(record, false);
|
|
}
|
|
} catch (e) {
|
|
$reject.call({
|
|
r: record,
|
|
d: false
|
|
}, e);
|
|
}
|
|
};
|
|
if (!USE_NATIVE) {
|
|
P = function Promise(executor) {
|
|
aFunction(executor);
|
|
var record = this._d = {
|
|
p: strictNew(this, P, PROMISE),
|
|
c: [],
|
|
a: undefined,
|
|
s: 0,
|
|
d: false,
|
|
v: undefined,
|
|
h: false,
|
|
n: false
|
|
};
|
|
try {
|
|
executor(ctx($resolve, record, 1), ctx($reject, record, 1));
|
|
} catch (err) {
|
|
$reject.call(record, err);
|
|
}
|
|
};
|
|
$__require('da')(P.prototype, {
|
|
then: function then(onFulfilled, onRejected) {
|
|
var reaction = new PromiseCapability(speciesConstructor(this, P)),
|
|
promise = reaction.promise,
|
|
record = this._d;
|
|
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
|
|
reaction.fail = typeof onRejected == 'function' && onRejected;
|
|
record.c.push(reaction);
|
|
if (record.a)
|
|
record.a.push(reaction);
|
|
if (record.s)
|
|
notify(record, false);
|
|
return promise;
|
|
},
|
|
'catch': function(onRejected) {
|
|
return this.then(undefined, onRejected);
|
|
}
|
|
});
|
|
}
|
|
$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: P});
|
|
$__require('db')(P, PROMISE);
|
|
$__require('dc')(PROMISE);
|
|
Wrapper = $__require('2d')[PROMISE];
|
|
$export($export.S + $export.F * !USE_NATIVE, PROMISE, {reject: function reject(r) {
|
|
var capability = new PromiseCapability(this),
|
|
$$reject = capability.reject;
|
|
$$reject(r);
|
|
return capability.promise;
|
|
}});
|
|
$export($export.S + $export.F * (!USE_NATIVE || testResolve(true)), PROMISE, {resolve: function resolve(x) {
|
|
if (x instanceof P && sameConstructor(x.constructor, this))
|
|
return x;
|
|
var capability = new PromiseCapability(this),
|
|
$$resolve = capability.resolve;
|
|
$$resolve(x);
|
|
return capability.promise;
|
|
}});
|
|
$export($export.S + $export.F * !(USE_NATIVE && $__require('95')(function(iter) {
|
|
P.all(iter)['catch'](function() {});
|
|
})), PROMISE, {
|
|
all: function all(iterable) {
|
|
var C = getConstructor(this),
|
|
capability = new PromiseCapability(C),
|
|
resolve = capability.resolve,
|
|
reject = capability.reject,
|
|
values = [];
|
|
var abrupt = perform(function() {
|
|
forOf(iterable, false, values.push, values);
|
|
var remaining = values.length,
|
|
results = Array(remaining);
|
|
if (remaining)
|
|
$.each.call(values, function(promise, index) {
|
|
var alreadyCalled = false;
|
|
C.resolve(promise).then(function(value) {
|
|
if (alreadyCalled)
|
|
return;
|
|
alreadyCalled = true;
|
|
results[index] = value;
|
|
--remaining || resolve(results);
|
|
}, reject);
|
|
});
|
|
else
|
|
resolve(results);
|
|
});
|
|
if (abrupt)
|
|
reject(abrupt.error);
|
|
return capability.promise;
|
|
},
|
|
race: function race(iterable) {
|
|
var C = getConstructor(this),
|
|
capability = new PromiseCapability(C),
|
|
reject = capability.reject;
|
|
var abrupt = perform(function() {
|
|
forOf(iterable, false, function(promise) {
|
|
C.resolve(promise).then(capability.resolve, reject);
|
|
});
|
|
});
|
|
if (abrupt)
|
|
reject(abrupt.error);
|
|
return capability.promise;
|
|
}
|
|
});
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("dd", ["de", "30", "2f", "d4", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('de');
|
|
$__require('30');
|
|
$__require('2f');
|
|
$__require('d4');
|
|
module.exports = $__require('2d').Promise;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f", ["dd"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('dd'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("df", ["ca", "94", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var anObject = $__require('ca'),
|
|
get = $__require('94');
|
|
module.exports = $__require('2d').getIterator = function(it) {
|
|
var iterFn = get(it);
|
|
if (typeof iterFn != 'function')
|
|
throw TypeError(it + ' is not iterable!');
|
|
return anObject(iterFn.call(it));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e0", ["2f", "30", "df"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('2f');
|
|
$__require('30');
|
|
module.exports = $__require('df');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("32", ["e0"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('e0'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e1", ["e2", "e3"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var strong = $__require('e2');
|
|
$__require('e3')('Map', function(get) {
|
|
return function Map() {
|
|
return get(this, arguments.length > 0 ? arguments[0] : undefined);
|
|
};
|
|
}, {
|
|
get: function get(key) {
|
|
var entry = strong.getEntry(this, key);
|
|
return entry && entry.v;
|
|
},
|
|
set: function set(key, value) {
|
|
return strong.def(this, key === 0 ? 0 : key, value);
|
|
}
|
|
}, strong, true);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e4", ["8f", "e5"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $export = $__require('8f');
|
|
$export($export.P, 'Map', {toJSON: $__require('e5')('Map')});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e6", ["de", "30", "2f", "e1", "e4", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('de');
|
|
$__require('30');
|
|
$__require('2f');
|
|
$__require('e1');
|
|
$__require('e4');
|
|
module.exports = $__require('2d').Map;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e7", ["e6"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('e6'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e8", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
if (typeof Number.isFinite !== "function") {
|
|
Number.isFinite = function isFinite(value) {
|
|
if (typeof value !== "number") {
|
|
return false;
|
|
}
|
|
if (value !== value || value === Infinity || value === -Infinity) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e9", ["34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
function baseGet(object, path, pathKey) {
|
|
if (object == null) {
|
|
return;
|
|
}
|
|
if (pathKey !== undefined && pathKey in toObject(object)) {
|
|
path = [pathKey];
|
|
}
|
|
var index = 0,
|
|
length = path.length;
|
|
while (object != null && index < length) {
|
|
object = object[path[index++]];
|
|
}
|
|
return (index && index == length) ? object : undefined;
|
|
}
|
|
function toObject(value) {
|
|
return isObject(value) ? value : Object(value);
|
|
}
|
|
function isObject(value) {
|
|
var type = typeof value;
|
|
return !!value && (type == 'object' || type == 'function');
|
|
}
|
|
module.exports = baseGet;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ea", ["e9"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('e9');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("eb", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var arrayTag = '[object Array]',
|
|
funcTag = '[object Function]';
|
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
function isObjectLike(value) {
|
|
return !!value && typeof value == 'object';
|
|
}
|
|
var objectProto = Object.prototype;
|
|
var fnToString = Function.prototype.toString;
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
var objToString = objectProto.toString;
|
|
var reIsNative = RegExp('^' + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
var nativeIsArray = getNative(Array, 'isArray');
|
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
function getNative(object, key) {
|
|
var value = object == null ? undefined : object[key];
|
|
return isNative(value) ? value : undefined;
|
|
}
|
|
function isLength(value) {
|
|
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
}
|
|
var isArray = nativeIsArray || function(value) {
|
|
return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
|
|
};
|
|
function isFunction(value) {
|
|
return isObject(value) && objToString.call(value) == funcTag;
|
|
}
|
|
function isObject(value) {
|
|
var type = typeof value;
|
|
return !!value && (type == 'object' || type == 'function');
|
|
}
|
|
function isNative(value) {
|
|
if (value == null) {
|
|
return false;
|
|
}
|
|
if (isFunction(value)) {
|
|
return reIsNative.test(fnToString.call(value));
|
|
}
|
|
return isObjectLike(value) && reIsHostCtor.test(value);
|
|
}
|
|
module.exports = isArray;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ec", ["eb"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('eb');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ed", ["ec", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
var isArray = $__require('ec');
|
|
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
|
|
var reEscapeChar = /\\(\\)?/g;
|
|
function baseToString(value) {
|
|
return value == null ? '' : (value + '');
|
|
}
|
|
function toPath(value) {
|
|
if (isArray(value)) {
|
|
return value;
|
|
}
|
|
var result = [];
|
|
baseToString(value).replace(rePropName, function(match, number, quote, string) {
|
|
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
|
});
|
|
return result;
|
|
}
|
|
module.exports = toPath;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ee", ["ed"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('ed');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ef", ["ea", "ee"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var baseGet = $__require('ea'),
|
|
toPath = $__require('ee');
|
|
function get(object, path, defaultValue) {
|
|
var result = object == null ? undefined : baseGet(object, toPath(path), path + '');
|
|
return result === undefined ? defaultValue : result;
|
|
}
|
|
module.exports = get;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f0", ["ef"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('ef');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f1", ["f2", "f3", "f4", "f5", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
"use strict";
|
|
var Report = $__require('f2');
|
|
var SchemaCompilation = $__require('f3');
|
|
var SchemaValidation = $__require('f4');
|
|
var Utils = $__require('f5');
|
|
function decodeJSONPointer(str) {
|
|
return decodeURIComponent(str).replace(/~[0-1]/g, function(x) {
|
|
return x === "~1" ? "/" : "~";
|
|
});
|
|
}
|
|
function getRemotePath(uri) {
|
|
var io = uri.indexOf("#");
|
|
return io === -1 ? uri : uri.slice(0, io);
|
|
}
|
|
function getQueryPath(uri) {
|
|
var io = uri.indexOf("#");
|
|
var res = io === -1 ? undefined : uri.slice(io + 1);
|
|
return res;
|
|
}
|
|
function findId(schema, id) {
|
|
if (typeof schema !== "object" || schema === null) {
|
|
return;
|
|
}
|
|
if (!id) {
|
|
return schema;
|
|
}
|
|
if (schema.id) {
|
|
if (schema.id === id || schema.id[0] === "#" && schema.id.substring(1) === id) {
|
|
return schema;
|
|
}
|
|
}
|
|
var idx,
|
|
result;
|
|
if (Array.isArray(schema)) {
|
|
idx = schema.length;
|
|
while (idx--) {
|
|
result = findId(schema[idx], id);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
} else {
|
|
var keys = Object.keys(schema);
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var k = keys[idx];
|
|
if (k.indexOf("__$") === 0) {
|
|
continue;
|
|
}
|
|
result = findId(schema[k], id);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exports.cacheSchemaByUri = function(uri, schema) {
|
|
var remotePath = getRemotePath(uri);
|
|
if (remotePath) {
|
|
this.cache[remotePath] = schema;
|
|
}
|
|
};
|
|
exports.removeFromCacheByUri = function(uri) {
|
|
var remotePath = getRemotePath(uri);
|
|
if (remotePath) {
|
|
delete this.cache[remotePath];
|
|
}
|
|
};
|
|
exports.checkCacheForUri = function(uri) {
|
|
var remotePath = getRemotePath(uri);
|
|
return remotePath ? this.cache[remotePath] != null : false;
|
|
};
|
|
exports.getSchema = function(report, schema) {
|
|
if (typeof schema === "object") {
|
|
schema = exports.getSchemaByReference.call(this, report, schema);
|
|
}
|
|
if (typeof schema === "string") {
|
|
schema = exports.getSchemaByUri.call(this, report, schema);
|
|
}
|
|
return schema;
|
|
};
|
|
exports.getSchemaByReference = function(report, key) {
|
|
var i = this.referenceCache.length;
|
|
while (i--) {
|
|
if (this.referenceCache[i][0] === key) {
|
|
return this.referenceCache[i][1];
|
|
}
|
|
}
|
|
var schema = Utils.cloneDeep(key);
|
|
this.referenceCache.push([key, schema]);
|
|
return schema;
|
|
};
|
|
exports.getSchemaByUri = function(report, uri, root) {
|
|
var remotePath = getRemotePath(uri),
|
|
queryPath = getQueryPath(uri),
|
|
result = remotePath ? this.cache[remotePath] : root;
|
|
if (result && remotePath) {
|
|
var compileRemote = result !== root;
|
|
if (compileRemote) {
|
|
report.path.push(remotePath);
|
|
var remoteReport = new Report(report);
|
|
if (SchemaCompilation.compileSchema.call(this, remoteReport, result)) {
|
|
SchemaValidation.validateSchema.call(this, remoteReport, result);
|
|
}
|
|
var remoteReportIsValid = remoteReport.isValid();
|
|
if (!remoteReportIsValid) {
|
|
report.addError("REMOTE_NOT_VALID", [uri], remoteReport);
|
|
}
|
|
report.path.pop();
|
|
if (!remoteReportIsValid) {
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|
|
if (result && queryPath) {
|
|
var parts = queryPath.split("/");
|
|
for (var idx = 0,
|
|
lim = parts.length; result && idx < lim; idx++) {
|
|
var key = decodeJSONPointer(parts[idx]);
|
|
if (idx === 0) {
|
|
result = findId(result, key);
|
|
} else {
|
|
result = result[key];
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
exports.getRemotePath = getRemotePath;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f3", ["f2", "f1", "f5"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Report = $__require('f2');
|
|
var SchemaCache = $__require('f1');
|
|
var Utils = $__require('f5');
|
|
function mergeReference(scope, ref) {
|
|
if (Utils.isAbsoluteUri(ref)) {
|
|
return ref;
|
|
}
|
|
var joinedScope = scope.join(""),
|
|
isScopeAbsolute = Utils.isAbsoluteUri(joinedScope),
|
|
isScopeRelative = Utils.isRelativeUri(joinedScope),
|
|
isRefRelative = Utils.isRelativeUri(ref),
|
|
toRemove;
|
|
if (isScopeAbsolute && isRefRelative) {
|
|
toRemove = joinedScope.match(/\/[^\/]*$/);
|
|
if (toRemove) {
|
|
joinedScope = joinedScope.slice(0, toRemove.index + 1);
|
|
}
|
|
} else if (isScopeRelative && isRefRelative) {
|
|
joinedScope = "";
|
|
} else {
|
|
toRemove = joinedScope.match(/[^#/]+$/);
|
|
if (toRemove) {
|
|
joinedScope = joinedScope.slice(0, toRemove.index);
|
|
}
|
|
}
|
|
var res = joinedScope + ref;
|
|
res = res.replace(/##/, "#");
|
|
return res;
|
|
}
|
|
function collectReferences(obj, results, scope, path) {
|
|
results = results || [];
|
|
scope = scope || [];
|
|
path = path || [];
|
|
if (typeof obj !== "object" || obj === null) {
|
|
return results;
|
|
}
|
|
if (typeof obj.id === "string") {
|
|
scope.push(obj.id);
|
|
}
|
|
if (typeof obj.$ref === "string" && typeof obj.__$refResolved === "undefined") {
|
|
results.push({
|
|
ref: mergeReference(scope, obj.$ref),
|
|
key: "$ref",
|
|
obj: obj,
|
|
path: path.slice(0)
|
|
});
|
|
}
|
|
if (typeof obj.$schema === "string" && typeof obj.__$schemaResolved === "undefined") {
|
|
results.push({
|
|
ref: mergeReference(scope, obj.$schema),
|
|
key: "$schema",
|
|
obj: obj,
|
|
path: path.slice(0)
|
|
});
|
|
}
|
|
var idx;
|
|
if (Array.isArray(obj)) {
|
|
idx = obj.length;
|
|
while (idx--) {
|
|
path.push(idx.toString());
|
|
collectReferences(obj[idx], results, scope, path);
|
|
path.pop();
|
|
}
|
|
} else {
|
|
var keys = Object.keys(obj);
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
if (keys[idx].indexOf("__$") === 0) {
|
|
continue;
|
|
}
|
|
path.push(keys[idx]);
|
|
collectReferences(obj[keys[idx]], results, scope, path);
|
|
path.pop();
|
|
}
|
|
}
|
|
if (typeof obj.id === "string") {
|
|
scope.pop();
|
|
}
|
|
return results;
|
|
}
|
|
var compileArrayOfSchemasLoop = function(mainReport, arr) {
|
|
var idx = arr.length,
|
|
compiledCount = 0;
|
|
while (idx--) {
|
|
var report = new Report(mainReport);
|
|
var isValid = exports.compileSchema.call(this, report, arr[idx]);
|
|
if (isValid) {
|
|
compiledCount++;
|
|
}
|
|
mainReport.errors = mainReport.errors.concat(report.errors);
|
|
}
|
|
return compiledCount;
|
|
};
|
|
function findId(arr, id) {
|
|
var idx = arr.length;
|
|
while (idx--) {
|
|
if (arr[idx].id === id) {
|
|
return arr[idx];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var compileArrayOfSchemas = function(report, arr) {
|
|
var compiled = 0,
|
|
lastLoopCompiled;
|
|
do {
|
|
var idx = report.errors.length;
|
|
while (idx--) {
|
|
if (report.errors[idx].code === "UNRESOLVABLE_REFERENCE") {
|
|
report.errors.splice(idx, 1);
|
|
}
|
|
}
|
|
lastLoopCompiled = compiled;
|
|
compiled = compileArrayOfSchemasLoop.call(this, report, arr);
|
|
idx = arr.length;
|
|
while (idx--) {
|
|
var sch = arr[idx];
|
|
if (sch.__$missingReferences) {
|
|
var idx2 = sch.__$missingReferences.length;
|
|
while (idx2--) {
|
|
var refObj = sch.__$missingReferences[idx2];
|
|
var response = findId(arr, refObj.ref);
|
|
if (response) {
|
|
refObj.obj["__" + refObj.key + "Resolved"] = response;
|
|
sch.__$missingReferences.splice(idx2, 1);
|
|
}
|
|
}
|
|
if (sch.__$missingReferences.length === 0) {
|
|
delete sch.__$missingReferences;
|
|
}
|
|
}
|
|
}
|
|
} while (compiled !== arr.length && compiled !== lastLoopCompiled);
|
|
return report.isValid();
|
|
};
|
|
exports.compileSchema = function(report, schema) {
|
|
report.commonErrorMessage = "SCHEMA_COMPILATION_FAILED";
|
|
if (typeof schema === "string") {
|
|
var loadedSchema = SchemaCache.getSchemaByUri.call(this, report, schema);
|
|
if (!loadedSchema) {
|
|
report.addError("SCHEMA_NOT_REACHABLE", [schema]);
|
|
return false;
|
|
}
|
|
schema = loadedSchema;
|
|
}
|
|
if (Array.isArray(schema)) {
|
|
return compileArrayOfSchemas.call(this, report, schema);
|
|
}
|
|
if (schema.__$compiled && schema.id && SchemaCache.checkCacheForUri.call(this, schema.id) === false) {
|
|
schema.__$compiled = undefined;
|
|
}
|
|
if (schema.__$compiled) {
|
|
return true;
|
|
}
|
|
if (schema.id && typeof schema.id === "string") {
|
|
SchemaCache.cacheSchemaByUri.call(this, schema.id, schema);
|
|
}
|
|
var isValidExceptReferences = report.isValid();
|
|
delete schema.__$missingReferences;
|
|
var refs = collectReferences.call(this, schema),
|
|
idx = refs.length;
|
|
while (idx--) {
|
|
var refObj = refs[idx];
|
|
var response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
|
|
if (!response) {
|
|
var schemaReader = this.getSchemaReader();
|
|
if (schemaReader) {
|
|
var s = schemaReader(refObj.ref);
|
|
if (s) {
|
|
s.id = refObj.ref;
|
|
var subreport = new Report(report);
|
|
if (!exports.compileSchema.call(this, subreport, s)) {
|
|
report.errors = report.errors.concat(subreport.errors);
|
|
} else {
|
|
response = SchemaCache.getSchemaByUri.call(this, report, refObj.ref, schema);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!response) {
|
|
var hasNotValid = report.hasError("REMOTE_NOT_VALID", [refObj.ref]);
|
|
var isAbsolute = Utils.isAbsoluteUri(refObj.ref);
|
|
var isDownloaded = false;
|
|
var ignoreUnresolvableRemotes = this.options.ignoreUnresolvableReferences === true;
|
|
if (isAbsolute) {
|
|
isDownloaded = SchemaCache.checkCacheForUri.call(this, refObj.ref);
|
|
}
|
|
if (hasNotValid) {} else if (ignoreUnresolvableRemotes && isAbsolute) {} else if (isDownloaded) {} else {
|
|
Array.prototype.push.apply(report.path, refObj.path);
|
|
report.addError("UNRESOLVABLE_REFERENCE", [refObj.ref]);
|
|
report.path.slice(0, -refObj.path.length);
|
|
if (isValidExceptReferences) {
|
|
schema.__$missingReferences = schema.__$missingReferences || [];
|
|
schema.__$missingReferences.push(refObj);
|
|
}
|
|
}
|
|
}
|
|
refObj.obj["__" + refObj.key + "Resolved"] = response;
|
|
}
|
|
var isValid = report.isValid();
|
|
if (isValid) {
|
|
schema.__$compiled = true;
|
|
} else {
|
|
if (schema.id && typeof schema.id === "string") {
|
|
SchemaCache.removeFromCacheByUri.call(this, schema.id);
|
|
}
|
|
}
|
|
return isValid;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f6", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
(function(name, definition) {
|
|
if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
|
|
module.exports = definition();
|
|
} else if (typeof define === 'function' && typeof define.amd === 'object') {
|
|
define(definition);
|
|
} else {
|
|
this[name] = definition();
|
|
}
|
|
})('validator', function(validator) {
|
|
'use strict';
|
|
validator = {version: '4.1.0'};
|
|
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
|
|
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
|
|
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
|
|
var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
|
|
var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i;
|
|
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/;
|
|
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
|
|
var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/,
|
|
isbn13Maybe = /^(?:[0-9]{13})$/;
|
|
var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/,
|
|
ipv6Block = /^[0-9A-F]{1,4}$/i;
|
|
var uuid = {
|
|
'3': /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
|
'4': /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
|
'5': /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
|
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
|
|
};
|
|
var alpha = /^[A-Z]+$/i,
|
|
alphanumeric = /^[0-9A-Z]+$/i,
|
|
numeric = /^[-+]?[0-9]+$/,
|
|
int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/,
|
|
float = /^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,
|
|
hexadecimal = /^[0-9A-F]+$/i,
|
|
decimal = /^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,
|
|
hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;
|
|
var ascii = /^[\x00-\x7F]+$/,
|
|
multibyte = /[^\x00-\x7F]/,
|
|
fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,
|
|
halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
|
|
var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
|
|
var base64 = /^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i;
|
|
var phones = {
|
|
'zh-CN': /^(\+?0?86\-?)?1[345789]\d{9}$/,
|
|
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
|
|
'en-ZA': /^(\+?27|0)\d{9}$/,
|
|
'en-AU': /^(\+?61|0)4\d{8}$/,
|
|
'en-HK': /^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,
|
|
'fr-FR': /^(\+?33|0)[67]\d{8}$/,
|
|
'pt-PT': /^(\+351)?9[1236]\d{7}$/,
|
|
'el-GR': /^(\+30)?((2\d{9})|(69\d{8}))$/,
|
|
'en-GB': /^(\+?44|0)7\d{9}$/,
|
|
'en-US': /^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,
|
|
'en-ZM': /^(\+26)?09[567]\d{7}$/,
|
|
'ru-RU': /^(\+?7|8)?9\d{9}$/
|
|
};
|
|
var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
|
|
validator.extend = function(name, fn) {
|
|
validator[name] = function() {
|
|
var args = Array.prototype.slice.call(arguments);
|
|
args[0] = validator.toString(args[0]);
|
|
return fn.apply(validator, args);
|
|
};
|
|
};
|
|
validator.init = function() {
|
|
for (var name in validator) {
|
|
if (typeof validator[name] !== 'function' || name === 'toString' || name === 'toDate' || name === 'extend' || name === 'init') {
|
|
continue;
|
|
}
|
|
validator.extend(name, validator[name]);
|
|
}
|
|
};
|
|
validator.toString = function(input) {
|
|
if (typeof input === 'object' && input !== null && input.toString) {
|
|
input = input.toString();
|
|
} else if (input === null || typeof input === 'undefined' || (isNaN(input) && !input.length)) {
|
|
input = '';
|
|
} else if (typeof input !== 'string') {
|
|
input += '';
|
|
}
|
|
return input;
|
|
};
|
|
validator.toDate = function(date) {
|
|
if (Object.prototype.toString.call(date) === '[object Date]') {
|
|
return date;
|
|
}
|
|
date = Date.parse(date);
|
|
return !isNaN(date) ? new Date(date) : null;
|
|
};
|
|
validator.toFloat = function(str) {
|
|
return parseFloat(str);
|
|
};
|
|
validator.toInt = function(str, radix) {
|
|
return parseInt(str, radix || 10);
|
|
};
|
|
validator.toBoolean = function(str, strict) {
|
|
if (strict) {
|
|
return str === '1' || str === 'true';
|
|
}
|
|
return str !== '0' && str !== 'false' && str !== '';
|
|
};
|
|
validator.equals = function(str, comparison) {
|
|
return str === validator.toString(comparison);
|
|
};
|
|
validator.contains = function(str, elem) {
|
|
return str.indexOf(validator.toString(elem)) >= 0;
|
|
};
|
|
validator.matches = function(str, pattern, modifiers) {
|
|
if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
|
|
pattern = new RegExp(pattern, modifiers);
|
|
}
|
|
return pattern.test(str);
|
|
};
|
|
var default_email_options = {
|
|
allow_display_name: false,
|
|
allow_utf8_local_part: true,
|
|
require_tld: true
|
|
};
|
|
validator.isEmail = function(str, options) {
|
|
options = merge(options, default_email_options);
|
|
if (options.allow_display_name) {
|
|
var display_email = str.match(displayName);
|
|
if (display_email) {
|
|
str = display_email[1];
|
|
}
|
|
}
|
|
var parts = str.split('@'),
|
|
domain = parts.pop(),
|
|
user = parts.join('@');
|
|
var lower_domain = domain.toLowerCase();
|
|
if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') {
|
|
user = user.replace(/\./g, '').toLowerCase();
|
|
}
|
|
if (!validator.isByteLength(user, 0, 64) || !validator.isByteLength(domain, 0, 256)) {
|
|
return false;
|
|
}
|
|
if (!validator.isFQDN(domain, {require_tld: options.require_tld})) {
|
|
return false;
|
|
}
|
|
if (user[0] === '"') {
|
|
user = user.slice(1, user.length - 1);
|
|
return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
|
|
}
|
|
var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
|
|
var user_parts = user.split('.');
|
|
for (var i = 0; i < user_parts.length; i++) {
|
|
if (!pattern.test(user_parts[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
var default_url_options = {
|
|
protocols: ['http', 'https', 'ftp'],
|
|
require_tld: true,
|
|
require_protocol: false,
|
|
require_valid_protocol: true,
|
|
allow_underscores: false,
|
|
allow_trailing_dot: false,
|
|
allow_protocol_relative_urls: false
|
|
};
|
|
validator.isURL = function(url, options) {
|
|
if (!url || url.length >= 2083 || /\s/.test(url)) {
|
|
return false;
|
|
}
|
|
if (url.indexOf('mailto:') === 0) {
|
|
return false;
|
|
}
|
|
options = merge(options, default_url_options);
|
|
var protocol,
|
|
auth,
|
|
host,
|
|
hostname,
|
|
port,
|
|
port_str,
|
|
split;
|
|
split = url.split('://');
|
|
if (split.length > 1) {
|
|
protocol = split.shift();
|
|
if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
|
|
return false;
|
|
}
|
|
} else if (options.require_protocol) {
|
|
return false;
|
|
} else if (options.allow_protocol_relative_urls && url.substr(0, 2) === '//') {
|
|
split[0] = url.substr(2);
|
|
}
|
|
url = split.join('://');
|
|
split = url.split('#');
|
|
url = split.shift();
|
|
split = url.split('?');
|
|
url = split.shift();
|
|
split = url.split('/');
|
|
url = split.shift();
|
|
split = url.split('@');
|
|
if (split.length > 1) {
|
|
auth = split.shift();
|
|
if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
|
|
return false;
|
|
}
|
|
}
|
|
hostname = split.join('@');
|
|
split = hostname.split(':');
|
|
host = split.shift();
|
|
if (split.length) {
|
|
port_str = split.join(':');
|
|
port = parseInt(port_str, 10);
|
|
if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
|
|
return false;
|
|
}
|
|
}
|
|
if (!validator.isIP(host) && !validator.isFQDN(host, options) && host !== 'localhost') {
|
|
return false;
|
|
}
|
|
if (options.host_whitelist && options.host_whitelist.indexOf(host) === -1) {
|
|
return false;
|
|
}
|
|
if (options.host_blacklist && options.host_blacklist.indexOf(host) !== -1) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
validator.isIP = function(str, version) {
|
|
version = validator.toString(version);
|
|
if (!version) {
|
|
return validator.isIP(str, 4) || validator.isIP(str, 6);
|
|
} else if (version === '4') {
|
|
if (!ipv4Maybe.test(str)) {
|
|
return false;
|
|
}
|
|
var parts = str.split('.').sort(function(a, b) {
|
|
return a - b;
|
|
});
|
|
return parts[3] <= 255;
|
|
} else if (version === '6') {
|
|
var blocks = str.split(':');
|
|
var foundOmissionBlock = false;
|
|
var foundIPv4TransitionBlock = validator.isIP(blocks[blocks.length - 1], 4);
|
|
var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8;
|
|
if (blocks.length > expectedNumberOfBlocks)
|
|
return false;
|
|
if (str === '::') {
|
|
return true;
|
|
} else if (str.substr(0, 2) === '::') {
|
|
blocks.shift();
|
|
blocks.shift();
|
|
foundOmissionBlock = true;
|
|
} else if (str.substr(str.length - 2) === '::') {
|
|
blocks.pop();
|
|
blocks.pop();
|
|
foundOmissionBlock = true;
|
|
}
|
|
for (var i = 0; i < blocks.length; ++i) {
|
|
if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
|
|
if (foundOmissionBlock)
|
|
return false;
|
|
foundOmissionBlock = true;
|
|
} else if (foundIPv4TransitionBlock && i == blocks.length - 1) {} else if (!ipv6Block.test(blocks[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
if (foundOmissionBlock) {
|
|
return blocks.length >= 1;
|
|
} else {
|
|
return blocks.length === expectedNumberOfBlocks;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var default_fqdn_options = {
|
|
require_tld: true,
|
|
allow_underscores: false,
|
|
allow_trailing_dot: false
|
|
};
|
|
validator.isFQDN = function(str, options) {
|
|
options = merge(options, default_fqdn_options);
|
|
if (options.allow_trailing_dot && str[str.length - 1] === '.') {
|
|
str = str.substring(0, str.length - 1);
|
|
}
|
|
var parts = str.split('.');
|
|
if (options.require_tld) {
|
|
var tld = parts.pop();
|
|
if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
|
|
return false;
|
|
}
|
|
}
|
|
for (var part,
|
|
i = 0; i < parts.length; i++) {
|
|
part = parts[i];
|
|
if (options.allow_underscores) {
|
|
if (part.indexOf('__') >= 0) {
|
|
return false;
|
|
}
|
|
part = part.replace(/_/g, '');
|
|
}
|
|
if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) {
|
|
return false;
|
|
}
|
|
if (/[\uff01-\uff5e]/.test(part)) {
|
|
return false;
|
|
}
|
|
if (part[0] === '-' || part[part.length - 1] === '-' || part.indexOf('---') >= 0) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
validator.isBoolean = function(str) {
|
|
return (['true', 'false', '1', '0'].indexOf(str) >= 0);
|
|
};
|
|
validator.isAlpha = function(str) {
|
|
return alpha.test(str);
|
|
};
|
|
validator.isAlphanumeric = function(str) {
|
|
return alphanumeric.test(str);
|
|
};
|
|
validator.isNumeric = function(str) {
|
|
return numeric.test(str);
|
|
};
|
|
validator.isDecimal = function(str) {
|
|
return str !== '' && decimal.test(str);
|
|
};
|
|
validator.isHexadecimal = function(str) {
|
|
return hexadecimal.test(str);
|
|
};
|
|
validator.isHexColor = function(str) {
|
|
return hexcolor.test(str);
|
|
};
|
|
validator.isLowercase = function(str) {
|
|
return str === str.toLowerCase();
|
|
};
|
|
validator.isUppercase = function(str) {
|
|
return str === str.toUpperCase();
|
|
};
|
|
validator.isInt = function(str, options) {
|
|
options = options || {};
|
|
return int.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max);
|
|
};
|
|
validator.isFloat = function(str, options) {
|
|
options = options || {};
|
|
return str !== '' && float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max);
|
|
};
|
|
validator.isDivisibleBy = function(str, num) {
|
|
return validator.toFloat(str) % validator.toInt(num) === 0;
|
|
};
|
|
validator.isNull = function(str) {
|
|
return str.length === 0;
|
|
};
|
|
validator.isLength = function(str, min, max) {
|
|
var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
|
|
var len = str.length - surrogatePairs.length;
|
|
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
};
|
|
validator.isByteLength = function(str, min, max) {
|
|
var len = encodeURI(str).split(/%..|./).length - 1;
|
|
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
};
|
|
validator.isUUID = function(str, version) {
|
|
var pattern = uuid[version ? version : 'all'];
|
|
return pattern && pattern.test(str);
|
|
};
|
|
validator.isDate = function(str) {
|
|
var normalizedDate = new Date((new Date(str)).toUTCString());
|
|
var regularDay = String(normalizedDate.getDate());
|
|
var utcDay = String(normalizedDate.getUTCDate());
|
|
var dayOrYear,
|
|
dayOrYearMatches,
|
|
year;
|
|
if (isNaN(Date.parse(normalizedDate))) {
|
|
return false;
|
|
}
|
|
dayOrYearMatches = str.match(/(^|[^:\d])[23]\d([^:\d]|$)/g);
|
|
if (!dayOrYearMatches) {
|
|
return true;
|
|
}
|
|
dayOrYear = dayOrYearMatches.map(function(digitString) {
|
|
return digitString.match(/\d+/g)[0];
|
|
}).join('/');
|
|
year = String(normalizedDate.getFullYear()).slice(-2);
|
|
if (dayOrYear === regularDay || dayOrYear === utcDay || dayOrYear === year) {
|
|
return true;
|
|
} else if ((dayOrYear === (regularDay + '/' + year)) || (dayOrYear === (year + '/' + regularDay))) {
|
|
return true;
|
|
} else if ((dayOrYear === (utcDay + '/' + year)) || (dayOrYear === (year + '/' + utcDay))) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
validator.isAfter = function(str, date) {
|
|
var comparison = validator.toDate(date || new Date()),
|
|
original = validator.toDate(str);
|
|
return !!(original && comparison && original > comparison);
|
|
};
|
|
validator.isBefore = function(str, date) {
|
|
var comparison = validator.toDate(date || new Date()),
|
|
original = validator.toDate(str);
|
|
return !!(original && comparison && original < comparison);
|
|
};
|
|
validator.isIn = function(str, options) {
|
|
var i;
|
|
if (Object.prototype.toString.call(options) === '[object Array]') {
|
|
var array = [];
|
|
for (i in options) {
|
|
array[i] = validator.toString(options[i]);
|
|
}
|
|
return array.indexOf(str) >= 0;
|
|
} else if (typeof options === 'object') {
|
|
return options.hasOwnProperty(str);
|
|
} else if (options && typeof options.indexOf === 'function') {
|
|
return options.indexOf(str) >= 0;
|
|
}
|
|
return false;
|
|
};
|
|
validator.isCreditCard = function(str) {
|
|
var sanitized = str.replace(/[^0-9]+/g, '');
|
|
if (!creditCard.test(sanitized)) {
|
|
return false;
|
|
}
|
|
var sum = 0,
|
|
digit,
|
|
tmpNum,
|
|
shouldDouble;
|
|
for (var i = sanitized.length - 1; i >= 0; i--) {
|
|
digit = sanitized.substring(i, (i + 1));
|
|
tmpNum = parseInt(digit, 10);
|
|
if (shouldDouble) {
|
|
tmpNum *= 2;
|
|
if (tmpNum >= 10) {
|
|
sum += ((tmpNum % 10) + 1);
|
|
} else {
|
|
sum += tmpNum;
|
|
}
|
|
} else {
|
|
sum += tmpNum;
|
|
}
|
|
shouldDouble = !shouldDouble;
|
|
}
|
|
return !!((sum % 10) === 0 ? sanitized : false);
|
|
};
|
|
validator.isISIN = function(str) {
|
|
if (!isin.test(str)) {
|
|
return false;
|
|
}
|
|
var checksumStr = str.replace(/[A-Z]/g, function(character) {
|
|
return parseInt(character, 36);
|
|
});
|
|
var sum = 0,
|
|
digit,
|
|
tmpNum,
|
|
shouldDouble = true;
|
|
for (var i = checksumStr.length - 2; i >= 0; i--) {
|
|
digit = checksumStr.substring(i, (i + 1));
|
|
tmpNum = parseInt(digit, 10);
|
|
if (shouldDouble) {
|
|
tmpNum *= 2;
|
|
if (tmpNum >= 10) {
|
|
sum += tmpNum + 1;
|
|
} else {
|
|
sum += tmpNum;
|
|
}
|
|
} else {
|
|
sum += tmpNum;
|
|
}
|
|
shouldDouble = !shouldDouble;
|
|
}
|
|
return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
|
|
};
|
|
validator.isISBN = function(str, version) {
|
|
version = validator.toString(version);
|
|
if (!version) {
|
|
return validator.isISBN(str, 10) || validator.isISBN(str, 13);
|
|
}
|
|
var sanitized = str.replace(/[\s-]+/g, ''),
|
|
checksum = 0,
|
|
i;
|
|
if (version === '10') {
|
|
if (!isbn10Maybe.test(sanitized)) {
|
|
return false;
|
|
}
|
|
for (i = 0; i < 9; i++) {
|
|
checksum += (i + 1) * sanitized.charAt(i);
|
|
}
|
|
if (sanitized.charAt(9) === 'X') {
|
|
checksum += 10 * 10;
|
|
} else {
|
|
checksum += 10 * sanitized.charAt(9);
|
|
}
|
|
if ((checksum % 11) === 0) {
|
|
return !!sanitized;
|
|
}
|
|
} else if (version === '13') {
|
|
if (!isbn13Maybe.test(sanitized)) {
|
|
return false;
|
|
}
|
|
var factor = [1, 3];
|
|
for (i = 0; i < 12; i++) {
|
|
checksum += factor[i % 2] * sanitized.charAt(i);
|
|
}
|
|
if (sanitized.charAt(12) - ((10 - (checksum % 10)) % 10) === 0) {
|
|
return !!sanitized;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
validator.isMobilePhone = function(str, locale) {
|
|
if (locale in phones) {
|
|
return phones[locale].test(str);
|
|
}
|
|
return false;
|
|
};
|
|
var default_currency_options = {
|
|
symbol: '$',
|
|
require_symbol: false,
|
|
allow_space_after_symbol: false,
|
|
symbol_after_digits: false,
|
|
allow_negatives: true,
|
|
parens_for_negatives: false,
|
|
negative_sign_before_digits: false,
|
|
negative_sign_after_digits: false,
|
|
allow_negative_sign_placeholder: false,
|
|
thousands_separator: ',',
|
|
decimal_separator: '.',
|
|
allow_space_after_digits: false
|
|
};
|
|
validator.isCurrency = function(str, options) {
|
|
options = merge(options, default_currency_options);
|
|
return currencyRegex(options).test(str);
|
|
};
|
|
validator.isJSON = function(str) {
|
|
try {
|
|
var obj = JSON.parse(str);
|
|
return !!obj && typeof obj === 'object';
|
|
} catch (e) {}
|
|
return false;
|
|
};
|
|
validator.isMultibyte = function(str) {
|
|
return multibyte.test(str);
|
|
};
|
|
validator.isAscii = function(str) {
|
|
return ascii.test(str);
|
|
};
|
|
validator.isFullWidth = function(str) {
|
|
return fullWidth.test(str);
|
|
};
|
|
validator.isHalfWidth = function(str) {
|
|
return halfWidth.test(str);
|
|
};
|
|
validator.isVariableWidth = function(str) {
|
|
return fullWidth.test(str) && halfWidth.test(str);
|
|
};
|
|
validator.isSurrogatePair = function(str) {
|
|
return surrogatePair.test(str);
|
|
};
|
|
validator.isBase64 = function(str) {
|
|
return base64.test(str);
|
|
};
|
|
validator.isMongoId = function(str) {
|
|
return validator.isHexadecimal(str) && str.length === 24;
|
|
};
|
|
validator.isISO8601 = function(str) {
|
|
return iso8601.test(str);
|
|
};
|
|
validator.ltrim = function(str, chars) {
|
|
var pattern = chars ? new RegExp('^[' + chars + ']+', 'g') : /^\s+/g;
|
|
return str.replace(pattern, '');
|
|
};
|
|
validator.rtrim = function(str, chars) {
|
|
var pattern = chars ? new RegExp('[' + chars + ']+$', 'g') : /\s+$/g;
|
|
return str.replace(pattern, '');
|
|
};
|
|
validator.trim = function(str, chars) {
|
|
var pattern = chars ? new RegExp('^[' + chars + ']+|[' + chars + ']+$', 'g') : /^\s+|\s+$/g;
|
|
return str.replace(pattern, '');
|
|
};
|
|
validator.escape = function(str) {
|
|
return (str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\`/g, '`'));
|
|
};
|
|
validator.stripLow = function(str, keep_new_lines) {
|
|
var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
|
|
return validator.blacklist(str, chars);
|
|
};
|
|
validator.whitelist = function(str, chars) {
|
|
return str.replace(new RegExp('[^' + chars + ']+', 'g'), '');
|
|
};
|
|
validator.blacklist = function(str, chars) {
|
|
return str.replace(new RegExp('[' + chars + ']+', 'g'), '');
|
|
};
|
|
var default_normalize_email_options = {lowercase: true};
|
|
validator.normalizeEmail = function(email, options) {
|
|
options = merge(options, default_normalize_email_options);
|
|
if (!validator.isEmail(email)) {
|
|
return false;
|
|
}
|
|
var parts = email.split('@', 2);
|
|
parts[1] = parts[1].toLowerCase();
|
|
if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
|
|
parts[0] = parts[0].toLowerCase().replace(/\./g, '');
|
|
if (parts[0][0] === '+') {
|
|
return false;
|
|
}
|
|
parts[0] = parts[0].split('+')[0];
|
|
parts[1] = 'gmail.com';
|
|
} else if (options.lowercase) {
|
|
parts[0] = parts[0].toLowerCase();
|
|
}
|
|
return parts.join('@');
|
|
};
|
|
function merge(obj, defaults) {
|
|
obj = obj || {};
|
|
for (var key in defaults) {
|
|
if (typeof obj[key] === 'undefined') {
|
|
obj[key] = defaults[key];
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
function currencyRegex(options) {
|
|
var symbol = '(\\' + options.symbol.replace(/\./g, '\\.') + ')' + (options.require_symbol ? '' : '?'),
|
|
negative = '-?',
|
|
whole_dollar_amount_without_sep = '[1-9]\\d*',
|
|
whole_dollar_amount_with_sep = '[1-9]\\d{0,2}(\\' + options.thousands_separator + '\\d{3})*',
|
|
valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
|
|
whole_dollar_amount = '(' + valid_whole_dollar_amounts.join('|') + ')?',
|
|
decimal_amount = '(\\' + options.decimal_separator + '\\d{2})?';
|
|
var pattern = whole_dollar_amount + decimal_amount;
|
|
if (options.allow_negatives && !options.parens_for_negatives) {
|
|
if (options.negative_sign_after_digits) {
|
|
pattern += negative;
|
|
} else if (options.negative_sign_before_digits) {
|
|
pattern = negative + pattern;
|
|
}
|
|
}
|
|
if (options.allow_negative_sign_placeholder) {
|
|
pattern = '( (?!\\-))?' + pattern;
|
|
} else if (options.allow_space_after_symbol) {
|
|
pattern = ' ?' + pattern;
|
|
} else if (options.allow_space_after_digits) {
|
|
pattern += '( (?!$))?';
|
|
}
|
|
if (options.symbol_after_digits) {
|
|
pattern += symbol;
|
|
} else {
|
|
pattern = symbol + pattern;
|
|
}
|
|
if (options.allow_negatives) {
|
|
if (options.parens_for_negatives) {
|
|
pattern = '(\\(' + pattern + '\\)|' + pattern + ')';
|
|
} else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
|
|
pattern = negative + pattern;
|
|
}
|
|
}
|
|
return new RegExp('^' + '(?!-? )(?=.*\\d)' + pattern + '$');
|
|
}
|
|
validator.init();
|
|
return validator;
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f7", ["f6"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('f6');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f8", ["f7"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var validator = $__require('f7');
|
|
var FormatValidators = {
|
|
"date": function(date) {
|
|
if (typeof date !== "string") {
|
|
return true;
|
|
}
|
|
var matches = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(date);
|
|
if (matches === null) {
|
|
return false;
|
|
}
|
|
if (matches[2] < "01" || matches[2] > "12" || matches[3] < "01" || matches[3] > "31") {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
"date-time": function(dateTime) {
|
|
if (typeof dateTime !== "string") {
|
|
return true;
|
|
}
|
|
var s = dateTime.toLowerCase().split("t");
|
|
if (!FormatValidators.date(s[0])) {
|
|
return false;
|
|
}
|
|
var matches = /^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$/.exec(s[1]);
|
|
if (matches === null) {
|
|
return false;
|
|
}
|
|
if (matches[1] > "23" || matches[2] > "59" || matches[3] > "59") {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
"email": function(email) {
|
|
if (typeof email !== "string") {
|
|
return true;
|
|
}
|
|
return validator.isEmail(email, {"require_tld": true});
|
|
},
|
|
"hostname": function(hostname) {
|
|
if (typeof hostname !== "string") {
|
|
return true;
|
|
}
|
|
var valid = /^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$/.test(hostname);
|
|
if (valid) {
|
|
if (hostname.length > 255) {
|
|
return false;
|
|
}
|
|
var labels = hostname.split(".");
|
|
for (var i = 0; i < labels.length; i++) {
|
|
if (labels[i].length > 63) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return valid;
|
|
},
|
|
"host-name": function(hostname) {
|
|
return FormatValidators.hostname.call(this, hostname);
|
|
},
|
|
"ipv4": function(ipv4) {
|
|
if (typeof ipv4 !== "string") {
|
|
return true;
|
|
}
|
|
return validator.isIP(ipv4, 4);
|
|
},
|
|
"ipv6": function(ipv6) {
|
|
if (typeof ipv6 !== "string") {
|
|
return true;
|
|
}
|
|
return validator.isIP(ipv6, 6);
|
|
},
|
|
"regex": function(str) {
|
|
try {
|
|
RegExp(str);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
},
|
|
"uri": function(uri) {
|
|
if (this.options.strictUris) {
|
|
return FormatValidators["strict-uri"].apply(this, arguments);
|
|
}
|
|
return typeof uri !== "string" || RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(uri);
|
|
},
|
|
"strict-uri": function(uri) {
|
|
return typeof uri !== "string" || validator.isURL(uri);
|
|
}
|
|
};
|
|
module.exports = FormatValidators;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f9", ["f8", "f2", "f5"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var FormatValidators = $__require('f8'),
|
|
Report = $__require('f2'),
|
|
Utils = $__require('f5');
|
|
var JsonValidators = {
|
|
multipleOf: function(report, schema, json) {
|
|
if (typeof json !== "number") {
|
|
return;
|
|
}
|
|
if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
|
|
report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema.description);
|
|
}
|
|
},
|
|
maximum: function(report, schema, json) {
|
|
if (typeof json !== "number") {
|
|
return;
|
|
}
|
|
if (schema.exclusiveMaximum !== true) {
|
|
if (json > schema.maximum) {
|
|
report.addError("MAXIMUM", [json, schema.maximum], null, schema.description);
|
|
}
|
|
} else {
|
|
if (json >= schema.maximum) {
|
|
report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
exclusiveMaximum: function() {},
|
|
minimum: function(report, schema, json) {
|
|
if (typeof json !== "number") {
|
|
return;
|
|
}
|
|
if (schema.exclusiveMinimum !== true) {
|
|
if (json < schema.minimum) {
|
|
report.addError("MINIMUM", [json, schema.minimum], null, schema.description);
|
|
}
|
|
} else {
|
|
if (json <= schema.minimum) {
|
|
report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
exclusiveMinimum: function() {},
|
|
maxLength: function(report, schema, json) {
|
|
if (typeof json !== "string") {
|
|
return;
|
|
}
|
|
if (Utils.ucs2decode(json).length > schema.maxLength) {
|
|
report.addError("MAX_LENGTH", [json.length, schema.maxLength], null, schema.description);
|
|
}
|
|
},
|
|
minLength: function(report, schema, json) {
|
|
if (typeof json !== "string") {
|
|
return;
|
|
}
|
|
if (Utils.ucs2decode(json).length < schema.minLength) {
|
|
report.addError("MIN_LENGTH", [json.length, schema.minLength], null, schema.description);
|
|
}
|
|
},
|
|
pattern: function(report, schema, json) {
|
|
if (typeof json !== "string") {
|
|
return;
|
|
}
|
|
if (RegExp(schema.pattern).test(json) === false) {
|
|
report.addError("PATTERN", [schema.pattern, json], null, schema.description);
|
|
}
|
|
},
|
|
additionalItems: function(report, schema, json) {
|
|
if (!Array.isArray(json)) {
|
|
return;
|
|
}
|
|
if (schema.additionalItems === false && Array.isArray(schema.items)) {
|
|
if (json.length > schema.items.length) {
|
|
report.addError("ARRAY_ADDITIONAL_ITEMS", null, null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
items: function() {},
|
|
maxItems: function(report, schema, json) {
|
|
if (!Array.isArray(json)) {
|
|
return;
|
|
}
|
|
if (json.length > schema.maxItems) {
|
|
report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], null, schema.description);
|
|
}
|
|
},
|
|
minItems: function(report, schema, json) {
|
|
if (!Array.isArray(json)) {
|
|
return;
|
|
}
|
|
if (json.length < schema.minItems) {
|
|
report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], null, schema.description);
|
|
}
|
|
},
|
|
uniqueItems: function(report, schema, json) {
|
|
if (!Array.isArray(json)) {
|
|
return;
|
|
}
|
|
if (schema.uniqueItems === true) {
|
|
var matches = [];
|
|
if (Utils.isUniqueArray(json, matches) === false) {
|
|
report.addError("ARRAY_UNIQUE", matches, null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
maxProperties: function(report, schema, json) {
|
|
if (Utils.whatIs(json) !== "object") {
|
|
return;
|
|
}
|
|
var keysCount = Object.keys(json).length;
|
|
if (keysCount > schema.maxProperties) {
|
|
report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], null, schema.description);
|
|
}
|
|
},
|
|
minProperties: function(report, schema, json) {
|
|
if (Utils.whatIs(json) !== "object") {
|
|
return;
|
|
}
|
|
var keysCount = Object.keys(json).length;
|
|
if (keysCount < schema.minProperties) {
|
|
report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], null, schema.description);
|
|
}
|
|
},
|
|
required: function(report, schema, json) {
|
|
if (Utils.whatIs(json) !== "object") {
|
|
return;
|
|
}
|
|
var idx = schema.required.length;
|
|
while (idx--) {
|
|
var requiredPropertyName = schema.required[idx];
|
|
if (json[requiredPropertyName] === undefined) {
|
|
report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
additionalProperties: function(report, schema, json) {
|
|
if (schema.properties === undefined && schema.patternProperties === undefined) {
|
|
return JsonValidators.properties.call(this, report, schema, json);
|
|
}
|
|
},
|
|
patternProperties: function(report, schema, json) {
|
|
if (schema.properties === undefined) {
|
|
return JsonValidators.properties.call(this, report, schema, json);
|
|
}
|
|
},
|
|
properties: function(report, schema, json) {
|
|
if (Utils.whatIs(json) !== "object") {
|
|
return;
|
|
}
|
|
var properties = schema.properties !== undefined ? schema.properties : {};
|
|
var patternProperties = schema.patternProperties !== undefined ? schema.patternProperties : {};
|
|
if (schema.additionalProperties === false) {
|
|
var s = Object.keys(json);
|
|
var p = Object.keys(properties);
|
|
var pp = Object.keys(patternProperties);
|
|
s = Utils.difference(s, p);
|
|
var idx = pp.length;
|
|
while (idx--) {
|
|
var regExp = RegExp(pp[idx]),
|
|
idx2 = s.length;
|
|
while (idx2--) {
|
|
if (regExp.test(s[idx2]) === true) {
|
|
s.splice(idx2, 1);
|
|
}
|
|
}
|
|
}
|
|
if (s.length > 0) {
|
|
report.addError("OBJECT_ADDITIONAL_PROPERTIES", [s], null, schema.description);
|
|
}
|
|
}
|
|
},
|
|
dependencies: function(report, schema, json) {
|
|
if (Utils.whatIs(json) !== "object") {
|
|
return;
|
|
}
|
|
var keys = Object.keys(schema.dependencies),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var dependencyName = keys[idx];
|
|
if (json[dependencyName]) {
|
|
var dependencyDefinition = schema.dependencies[dependencyName];
|
|
if (Utils.whatIs(dependencyDefinition) === "object") {
|
|
exports.validate.call(this, report, dependencyDefinition, json);
|
|
} else {
|
|
var idx2 = dependencyDefinition.length;
|
|
while (idx2--) {
|
|
var requiredPropertyName = dependencyDefinition[idx2];
|
|
if (json[requiredPropertyName] === undefined) {
|
|
report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], null, schema.description);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
enum: function(report, schema, json) {
|
|
var match = false,
|
|
idx = schema.enum.length;
|
|
while (idx--) {
|
|
if (Utils.areEqual(json, schema.enum[idx])) {
|
|
match = true;
|
|
break;
|
|
}
|
|
}
|
|
if (match === false) {
|
|
report.addError("ENUM_MISMATCH", [json], null, schema.description);
|
|
}
|
|
},
|
|
allOf: function(report, schema, json) {
|
|
var idx = schema.allOf.length;
|
|
while (idx--) {
|
|
if (exports.validate.call(this, report, schema.allOf[idx], json) === false) {
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
anyOf: function(report, schema, json) {
|
|
var subReports = [],
|
|
passed = false,
|
|
idx = schema.anyOf.length;
|
|
while (idx-- && passed === false) {
|
|
var subReport = new Report(report);
|
|
subReports.push(subReport);
|
|
passed = exports.validate.call(this, subReport, schema.anyOf[idx], json);
|
|
}
|
|
if (passed === false) {
|
|
report.addError("ANY_OF_MISSING", undefined, subReports, schema.description);
|
|
}
|
|
},
|
|
oneOf: function(report, schema, json) {
|
|
var passes = 0,
|
|
subReports = [],
|
|
idx = schema.oneOf.length;
|
|
while (idx--) {
|
|
var subReport = new Report(report, {maxErrors: 1});
|
|
subReports.push(subReport);
|
|
if (exports.validate.call(this, subReport, schema.oneOf[idx], json) === true) {
|
|
passes++;
|
|
}
|
|
}
|
|
if (passes === 0) {
|
|
report.addError("ONE_OF_MISSING", undefined, subReports, schema.description);
|
|
} else if (passes > 1) {
|
|
report.addError("ONE_OF_MULTIPLE", null, null, schema.description);
|
|
}
|
|
},
|
|
not: function(report, schema, json) {
|
|
var subReport = new Report(report);
|
|
if (exports.validate.call(this, subReport, schema.not, json) === true) {
|
|
report.addError("NOT_PASSED", null, null, schema.description);
|
|
}
|
|
},
|
|
definitions: function() {},
|
|
format: function(report, schema, json) {
|
|
var formatValidatorFn = FormatValidators[schema.format];
|
|
if (typeof formatValidatorFn === "function") {
|
|
if (formatValidatorFn.length === 2) {
|
|
report.addAsyncTask(formatValidatorFn, [json], function(result) {
|
|
if (result !== true) {
|
|
report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
|
|
}
|
|
});
|
|
} else {
|
|
if (formatValidatorFn.call(this, json) !== true) {
|
|
report.addError("INVALID_FORMAT", [schema.format, json], null, schema.description);
|
|
}
|
|
}
|
|
} else if (this.options.ignoreUnknownFormats !== true) {
|
|
report.addError("UNKNOWN_FORMAT", [schema.format], null, schema.description);
|
|
}
|
|
}
|
|
};
|
|
var recurseArray = function(report, schema, json) {
|
|
var idx = json.length;
|
|
if (Array.isArray(schema.items)) {
|
|
while (idx--) {
|
|
if (idx < schema.items.length) {
|
|
report.path.push(idx.toString());
|
|
exports.validate.call(this, report, schema.items[idx], json[idx]);
|
|
report.path.pop();
|
|
} else {
|
|
if (typeof schema.additionalItems === "object") {
|
|
report.path.push(idx.toString());
|
|
exports.validate.call(this, report, schema.additionalItems, json[idx]);
|
|
report.path.pop();
|
|
}
|
|
}
|
|
}
|
|
} else if (typeof schema.items === "object") {
|
|
while (idx--) {
|
|
report.path.push(idx.toString());
|
|
exports.validate.call(this, report, schema.items, json[idx]);
|
|
report.path.pop();
|
|
}
|
|
}
|
|
};
|
|
var recurseObject = function(report, schema, json) {
|
|
var additionalProperties = schema.additionalProperties;
|
|
if (additionalProperties === true || additionalProperties === undefined) {
|
|
additionalProperties = {};
|
|
}
|
|
var p = schema.properties ? Object.keys(schema.properties) : [];
|
|
var pp = schema.patternProperties ? Object.keys(schema.patternProperties) : [];
|
|
var keys = Object.keys(json),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var m = keys[idx],
|
|
propertyValue = json[m];
|
|
var s = [];
|
|
if (p.indexOf(m) !== -1) {
|
|
s.push(schema.properties[m]);
|
|
}
|
|
var idx2 = pp.length;
|
|
while (idx2--) {
|
|
var regexString = pp[idx2];
|
|
if (RegExp(regexString).test(m) === true) {
|
|
s.push(schema.patternProperties[regexString]);
|
|
}
|
|
}
|
|
if (s.length === 0 && additionalProperties !== false) {
|
|
s.push(additionalProperties);
|
|
}
|
|
idx2 = s.length;
|
|
while (idx2--) {
|
|
report.path.push(m);
|
|
exports.validate.call(this, report, s[idx2], propertyValue);
|
|
report.path.pop();
|
|
}
|
|
}
|
|
};
|
|
exports.validate = function(report, schema, json) {
|
|
report.commonErrorMessage = "JSON_OBJECT_VALIDATION_FAILED";
|
|
var to = Utils.whatIs(schema);
|
|
if (to !== "object") {
|
|
report.addError("SCHEMA_NOT_AN_OBJECT", [to], null, schema.description);
|
|
return false;
|
|
}
|
|
var keys = Object.keys(schema);
|
|
if (keys.length === 0) {
|
|
return true;
|
|
}
|
|
var isRoot = false;
|
|
if (!report.rootSchema) {
|
|
report.rootSchema = schema;
|
|
isRoot = true;
|
|
}
|
|
if (schema.$ref !== undefined) {
|
|
var maxRefs = 99;
|
|
while (schema.$ref && maxRefs > 0) {
|
|
if (!schema.__$refResolved) {
|
|
report.addError("REF_UNRESOLVED", [schema.$ref], null, schema.description);
|
|
break;
|
|
} else if (schema.__$refResolved === schema) {
|
|
break;
|
|
} else {
|
|
schema = schema.__$refResolved;
|
|
keys = Object.keys(schema);
|
|
}
|
|
maxRefs--;
|
|
}
|
|
if (maxRefs === 0) {
|
|
throw new Error("Circular dependency by $ref references!");
|
|
}
|
|
}
|
|
var jsonType = Utils.whatIs(json);
|
|
if (schema.type) {
|
|
if (typeof schema.type === "string") {
|
|
if (jsonType !== schema.type && (jsonType !== "integer" || schema.type !== "number")) {
|
|
report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
|
|
if (this.options.breakOnFirstError) {
|
|
return false;
|
|
}
|
|
}
|
|
} else {
|
|
if (schema.type.indexOf(jsonType) === -1 && (jsonType !== "integer" || schema.type.indexOf("number") === -1)) {
|
|
report.addError("INVALID_TYPE", [schema.type, jsonType], null, schema.description);
|
|
if (this.options.breakOnFirstError) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var idx = keys.length;
|
|
while (idx--) {
|
|
if (JsonValidators[keys[idx]]) {
|
|
JsonValidators[keys[idx]].call(this, report, schema, json);
|
|
if (report.errors.length && this.options.breakOnFirstError) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (report.errors.length === 0 || this.options.breakOnFirstError === false) {
|
|
if (jsonType === "array") {
|
|
recurseArray.call(this, report, schema, json);
|
|
} else if (jsonType === "object") {
|
|
recurseObject.call(this, report, schema, json);
|
|
}
|
|
}
|
|
if (isRoot) {
|
|
report.rootSchema = undefined;
|
|
}
|
|
return report.errors.length === 0;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("fa", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
INVALID_TYPE: "Expected type {0} but found type {1}",
|
|
INVALID_FORMAT: "Object didn't pass validation for format {0}: {1}",
|
|
ENUM_MISMATCH: "No enum match for: {0}",
|
|
ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
|
|
ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
|
|
ONE_OF_MULTIPLE: "Data is valid against more than one schema from 'oneOf'",
|
|
NOT_PASSED: "Data matches schema from 'not'",
|
|
ARRAY_LENGTH_SHORT: "Array is too short ({0}), minimum {1}",
|
|
ARRAY_LENGTH_LONG: "Array is too long ({0}), maximum {1}",
|
|
ARRAY_UNIQUE: "Array items are not unique (indexes {0} and {1})",
|
|
ARRAY_ADDITIONAL_ITEMS: "Additional items not allowed",
|
|
MULTIPLE_OF: "Value {0} is not a multiple of {1}",
|
|
MINIMUM: "Value {0} is less than minimum {1}",
|
|
MINIMUM_EXCLUSIVE: "Value {0} is equal or less than exclusive minimum {1}",
|
|
MAXIMUM: "Value {0} is greater than maximum {1}",
|
|
MAXIMUM_EXCLUSIVE: "Value {0} is equal or greater than exclusive maximum {1}",
|
|
OBJECT_PROPERTIES_MINIMUM: "Too few properties defined ({0}), minimum {1}",
|
|
OBJECT_PROPERTIES_MAXIMUM: "Too many properties defined ({0}), maximum {1}",
|
|
OBJECT_MISSING_REQUIRED_PROPERTY: "Missing required property: {0}",
|
|
OBJECT_ADDITIONAL_PROPERTIES: "Additional properties not allowed: {0}",
|
|
OBJECT_DEPENDENCY_KEY: "Dependency failed - key must exist: {0} (due to key: {1})",
|
|
MIN_LENGTH: "String is too short ({0} chars), minimum {1}",
|
|
MAX_LENGTH: "String is too long ({0} chars), maximum {1}",
|
|
PATTERN: "String does not match pattern {0}: {1}",
|
|
KEYWORD_TYPE_EXPECTED: "Keyword '{0}' is expected to be of type '{1}'",
|
|
KEYWORD_UNDEFINED_STRICT: "Keyword '{0}' must be defined in strict mode",
|
|
KEYWORD_UNEXPECTED: "Keyword '{0}' is not expected to appear in the schema",
|
|
KEYWORD_MUST_BE: "Keyword '{0}' must be {1}",
|
|
KEYWORD_DEPENDENCY: "Keyword '{0}' requires keyword '{1}'",
|
|
KEYWORD_PATTERN: "Keyword '{0}' is not a valid RegExp pattern: {1}",
|
|
KEYWORD_VALUE_TYPE: "Each element of keyword '{0}' array must be a '{1}'",
|
|
UNKNOWN_FORMAT: "There is no validation function for format '{0}'",
|
|
CUSTOM_MODE_FORCE_PROPERTIES: "{0} must define at least one property if present",
|
|
REF_UNRESOLVED: "Reference has not been resolved during compilation: {0}",
|
|
UNRESOLVABLE_REFERENCE: "Reference could not be resolved: {0}",
|
|
SCHEMA_NOT_REACHABLE: "Validator was not able to read schema with uri: {0}",
|
|
SCHEMA_TYPE_EXPECTED: "Schema is expected to be of type 'object'",
|
|
SCHEMA_NOT_AN_OBJECT: "Schema is not an object: {0}",
|
|
ASYNC_TIMEOUT: "{0} asynchronous task(s) have timed out after {1} ms",
|
|
PARENT_SCHEMA_VALIDATION_FAILED: "Schema failed to validate against its parent schema, see inner errors for details.",
|
|
REMOTE_NOT_VALID: "Remote reference didn't compile successfully: {0}"
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f2", ["fa", "f5", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
"use strict";
|
|
var Errors = $__require('fa');
|
|
var Utils = $__require('f5');
|
|
function Report(parentOrOptions, reportOptions) {
|
|
this.parentReport = parentOrOptions instanceof Report ? parentOrOptions : undefined;
|
|
this.options = parentOrOptions instanceof Report ? parentOrOptions.options : parentOrOptions || {};
|
|
this.reportOptions = reportOptions || {};
|
|
this.errors = [];
|
|
this.path = [];
|
|
this.asyncTasks = [];
|
|
}
|
|
Report.prototype.isValid = function() {
|
|
if (this.asyncTasks.length > 0) {
|
|
throw new Error("Async tasks pending, can't answer isValid");
|
|
}
|
|
return this.errors.length === 0;
|
|
};
|
|
Report.prototype.addAsyncTask = function(fn, args, asyncTaskResultProcessFn) {
|
|
this.asyncTasks.push([fn, args, asyncTaskResultProcessFn]);
|
|
};
|
|
Report.prototype.processAsyncTasks = function(timeout, callback) {
|
|
var validationTimeout = timeout || 2000,
|
|
tasksCount = this.asyncTasks.length,
|
|
idx = tasksCount,
|
|
timedOut = false,
|
|
self = this;
|
|
function finish() {
|
|
process.nextTick(function() {
|
|
var valid = self.errors.length === 0,
|
|
err = valid ? undefined : self.errors;
|
|
callback(err, valid);
|
|
});
|
|
}
|
|
function respond(asyncTaskResultProcessFn) {
|
|
return function(asyncTaskResult) {
|
|
if (timedOut) {
|
|
return;
|
|
}
|
|
asyncTaskResultProcessFn(asyncTaskResult);
|
|
if (--tasksCount === 0) {
|
|
finish();
|
|
}
|
|
};
|
|
}
|
|
if (tasksCount === 0 || this.errors.length > 0) {
|
|
finish();
|
|
return;
|
|
}
|
|
while (idx--) {
|
|
var task = this.asyncTasks[idx];
|
|
task[0].apply(null, task[1].concat(respond(task[2])));
|
|
}
|
|
setTimeout(function() {
|
|
if (tasksCount > 0) {
|
|
timedOut = true;
|
|
self.addError("ASYNC_TIMEOUT", [tasksCount, validationTimeout]);
|
|
callback(self.errors, false);
|
|
}
|
|
}, validationTimeout);
|
|
};
|
|
Report.prototype.getPath = function() {
|
|
var path = [];
|
|
if (this.parentReport) {
|
|
path = path.concat(this.parentReport.path);
|
|
}
|
|
path = path.concat(this.path);
|
|
if (this.options.reportPathAsArray !== true) {
|
|
path = "#/" + path.map(function(segment) {
|
|
if (Utils.isAbsoluteUri(segment)) {
|
|
return "uri(" + segment + ")";
|
|
}
|
|
return segment.replace(/\~/g, "~0").replace(/\//g, "~1");
|
|
}).join("/");
|
|
}
|
|
return path;
|
|
};
|
|
Report.prototype.hasError = function(errorCode, params) {
|
|
var idx = this.errors.length;
|
|
while (idx--) {
|
|
if (this.errors[idx].code === errorCode) {
|
|
var match = true;
|
|
var idx2 = this.errors[idx].params.length;
|
|
while (idx2--) {
|
|
if (this.errors[idx].params[idx2] !== params[idx2]) {
|
|
match = false;
|
|
}
|
|
}
|
|
if (match) {
|
|
return match;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
Report.prototype.addError = function(errorCode, params, subReports, schemaDescription) {
|
|
if (this.errors.length >= this.reportOptions.maxErrors) {
|
|
return;
|
|
}
|
|
if (!errorCode) {
|
|
throw new Error("No errorCode passed into addError()");
|
|
}
|
|
if (!Errors[errorCode]) {
|
|
throw new Error("No errorMessage known for code " + errorCode);
|
|
}
|
|
params = params || [];
|
|
var idx = params.length,
|
|
errorMessage = Errors[errorCode];
|
|
while (idx--) {
|
|
var whatIs = Utils.whatIs(params[idx]);
|
|
var param = (whatIs === "object" || whatIs === "null") ? JSON.stringify(params[idx]) : params[idx];
|
|
errorMessage = errorMessage.replace("{" + idx + "}", param);
|
|
}
|
|
var err = {
|
|
code: errorCode,
|
|
params: params,
|
|
message: errorMessage,
|
|
path: this.getPath()
|
|
};
|
|
if (schemaDescription) {
|
|
err.description = schemaDescription;
|
|
}
|
|
if (subReports != null) {
|
|
if (!Array.isArray(subReports)) {
|
|
subReports = [subReports];
|
|
}
|
|
err.inner = [];
|
|
idx = subReports.length;
|
|
while (idx--) {
|
|
var subReport = subReports[idx],
|
|
idx2 = subReport.errors.length;
|
|
while (idx2--) {
|
|
err.inner.push(subReport.errors[idx2]);
|
|
}
|
|
}
|
|
if (err.inner.length === 0) {
|
|
err.inner = undefined;
|
|
}
|
|
}
|
|
this.errors.push(err);
|
|
};
|
|
module.exports = Report;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f4", ["f8", "f9", "f2", "f5"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var FormatValidators = $__require('f8'),
|
|
JsonValidation = $__require('f9'),
|
|
Report = $__require('f2'),
|
|
Utils = $__require('f5');
|
|
var SchemaValidators = {
|
|
$ref: function(report, schema) {
|
|
if (typeof schema.$ref !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["$ref", "string"]);
|
|
}
|
|
},
|
|
$schema: function(report, schema) {
|
|
if (typeof schema.$schema !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["$schema", "string"]);
|
|
}
|
|
},
|
|
multipleOf: function(report, schema) {
|
|
if (typeof schema.multipleOf !== "number") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["multipleOf", "number"]);
|
|
} else if (schema.multipleOf <= 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["multipleOf", "strictly greater than 0"]);
|
|
}
|
|
},
|
|
maximum: function(report, schema) {
|
|
if (typeof schema.maximum !== "number") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["maximum", "number"]);
|
|
}
|
|
},
|
|
exclusiveMaximum: function(report, schema) {
|
|
if (typeof schema.exclusiveMaximum !== "boolean") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMaximum", "boolean"]);
|
|
} else if (schema.maximum === undefined) {
|
|
report.addError("KEYWORD_DEPENDENCY", ["exclusiveMaximum", "maximum"]);
|
|
}
|
|
},
|
|
minimum: function(report, schema) {
|
|
if (typeof schema.minimum !== "number") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["minimum", "number"]);
|
|
}
|
|
},
|
|
exclusiveMinimum: function(report, schema) {
|
|
if (typeof schema.exclusiveMinimum !== "boolean") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["exclusiveMinimum", "boolean"]);
|
|
} else if (schema.minimum === undefined) {
|
|
report.addError("KEYWORD_DEPENDENCY", ["exclusiveMinimum", "minimum"]);
|
|
}
|
|
},
|
|
maxLength: function(report, schema) {
|
|
if (Utils.whatIs(schema.maxLength) !== "integer") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["maxLength", "integer"]);
|
|
} else if (schema.maxLength < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["maxLength", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
minLength: function(report, schema) {
|
|
if (Utils.whatIs(schema.minLength) !== "integer") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["minLength", "integer"]);
|
|
} else if (schema.minLength < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["minLength", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
pattern: function(report, schema) {
|
|
if (typeof schema.pattern !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["pattern", "string"]);
|
|
} else {
|
|
try {
|
|
RegExp(schema.pattern);
|
|
} catch (e) {
|
|
report.addError("KEYWORD_PATTERN", ["pattern", schema.pattern]);
|
|
}
|
|
}
|
|
},
|
|
additionalItems: function(report, schema) {
|
|
var type = Utils.whatIs(schema.additionalItems);
|
|
if (type !== "boolean" && type !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["additionalItems", ["boolean", "object"]]);
|
|
} else if (type === "object") {
|
|
report.path.push("additionalItems");
|
|
exports.validateSchema.call(this, report, schema.additionalItems);
|
|
report.path.pop();
|
|
}
|
|
},
|
|
items: function(report, schema) {
|
|
var type = Utils.whatIs(schema.items);
|
|
if (type === "object") {
|
|
report.path.push("items");
|
|
exports.validateSchema.call(this, report, schema.items);
|
|
report.path.pop();
|
|
} else if (type === "array") {
|
|
var idx = schema.items.length;
|
|
while (idx--) {
|
|
report.path.push("items");
|
|
report.path.push(idx.toString());
|
|
exports.validateSchema.call(this, report, schema.items[idx]);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
} else {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["items", ["array", "object"]]);
|
|
}
|
|
if (this.options.forceAdditional === true && schema.additionalItems === undefined && Array.isArray(schema.items)) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalItems"]);
|
|
}
|
|
if (this.options.assumeAdditional === true && schema.additionalItems === undefined && Array.isArray(schema.items)) {
|
|
schema.additionalItems = false;
|
|
}
|
|
},
|
|
maxItems: function(report, schema) {
|
|
if (typeof schema.maxItems !== "number") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["maxItems", "integer"]);
|
|
} else if (schema.maxItems < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["maxItems", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
minItems: function(report, schema) {
|
|
if (Utils.whatIs(schema.minItems) !== "integer") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["minItems", "integer"]);
|
|
} else if (schema.minItems < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["minItems", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
uniqueItems: function(report, schema) {
|
|
if (typeof schema.uniqueItems !== "boolean") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["uniqueItems", "boolean"]);
|
|
}
|
|
},
|
|
maxProperties: function(report, schema) {
|
|
if (Utils.whatIs(schema.maxProperties) !== "integer") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["maxProperties", "integer"]);
|
|
} else if (schema.maxProperties < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["maxProperties", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
minProperties: function(report, schema) {
|
|
if (Utils.whatIs(schema.minProperties) !== "integer") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["minProperties", "integer"]);
|
|
} else if (schema.minProperties < 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["minProperties", "greater than, or equal to 0"]);
|
|
}
|
|
},
|
|
required: function(report, schema) {
|
|
if (Utils.whatIs(schema.required) !== "array") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["required", "array"]);
|
|
} else if (schema.required.length === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["required", "an array with at least one element"]);
|
|
} else {
|
|
var idx = schema.required.length;
|
|
while (idx--) {
|
|
if (typeof schema.required[idx] !== "string") {
|
|
report.addError("KEYWORD_VALUE_TYPE", ["required", "string"]);
|
|
}
|
|
}
|
|
if (Utils.isUniqueArray(schema.required) === false) {
|
|
report.addError("KEYWORD_MUST_BE", ["required", "an array with unique items"]);
|
|
}
|
|
}
|
|
},
|
|
additionalProperties: function(report, schema) {
|
|
var type = Utils.whatIs(schema.additionalProperties);
|
|
if (type !== "boolean" && type !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["additionalProperties", ["boolean", "object"]]);
|
|
} else if (type === "object") {
|
|
report.path.push("additionalProperties");
|
|
exports.validateSchema.call(this, report, schema.additionalProperties);
|
|
report.path.pop();
|
|
}
|
|
},
|
|
properties: function(report, schema) {
|
|
if (Utils.whatIs(schema.properties) !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["properties", "object"]);
|
|
return;
|
|
}
|
|
var keys = Object.keys(schema.properties),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx],
|
|
val = schema.properties[key];
|
|
report.path.push("properties");
|
|
report.path.push(key);
|
|
exports.validateSchema.call(this, report, val);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
if (this.options.forceAdditional === true && schema.additionalProperties === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["additionalProperties"]);
|
|
}
|
|
if (this.options.assumeAdditional === true && schema.additionalProperties === undefined) {
|
|
schema.additionalProperties = false;
|
|
}
|
|
if (this.options.forceProperties === true && keys.length === 0) {
|
|
report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["properties"]);
|
|
}
|
|
},
|
|
patternProperties: function(report, schema) {
|
|
if (Utils.whatIs(schema.patternProperties) !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["patternProperties", "object"]);
|
|
return;
|
|
}
|
|
var keys = Object.keys(schema.patternProperties),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx],
|
|
val = schema.patternProperties[key];
|
|
try {
|
|
RegExp(key);
|
|
} catch (e) {
|
|
report.addError("KEYWORD_PATTERN", ["patternProperties", key]);
|
|
}
|
|
report.path.push("patternProperties");
|
|
report.path.push(key.toString());
|
|
exports.validateSchema.call(this, report, val);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
if (this.options.forceProperties === true && keys.length === 0) {
|
|
report.addError("CUSTOM_MODE_FORCE_PROPERTIES", ["patternProperties"]);
|
|
}
|
|
},
|
|
dependencies: function(report, schema) {
|
|
if (Utils.whatIs(schema.dependencies) !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["dependencies", "object"]);
|
|
} else {
|
|
var keys = Object.keys(schema.dependencies),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var schemaKey = keys[idx],
|
|
schemaDependency = schema.dependencies[schemaKey],
|
|
type = Utils.whatIs(schemaDependency);
|
|
if (type === "object") {
|
|
report.path.push("dependencies");
|
|
report.path.push(schemaKey);
|
|
exports.validateSchema.call(this, report, schemaDependency);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
} else if (type === "array") {
|
|
var idx2 = schemaDependency.length;
|
|
if (idx2 === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["dependencies", "not empty array"]);
|
|
}
|
|
while (idx2--) {
|
|
if (typeof schemaDependency[idx2] !== "string") {
|
|
report.addError("KEYWORD_VALUE_TYPE", ["dependensices", "string"]);
|
|
}
|
|
}
|
|
if (Utils.isUniqueArray(schemaDependency) === false) {
|
|
report.addError("KEYWORD_MUST_BE", ["dependencies", "an array with unique items"]);
|
|
}
|
|
} else {
|
|
report.addError("KEYWORD_VALUE_TYPE", ["dependencies", "object or array"]);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
enum: function(report, schema) {
|
|
if (Array.isArray(schema.enum) === false) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["enum", "array"]);
|
|
} else if (schema.enum.length === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["enum", "an array with at least one element"]);
|
|
} else if (Utils.isUniqueArray(schema.enum) === false) {
|
|
report.addError("KEYWORD_MUST_BE", ["enum", "an array with unique elements"]);
|
|
}
|
|
},
|
|
type: function(report, schema) {
|
|
var primitiveTypes = ["array", "boolean", "integer", "number", "null", "object", "string"],
|
|
primitiveTypeStr = primitiveTypes.join(","),
|
|
isArray = Array.isArray(schema.type);
|
|
if (isArray) {
|
|
var idx = schema.type.length;
|
|
while (idx--) {
|
|
if (primitiveTypes.indexOf(schema.type[idx]) === -1) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
|
|
}
|
|
}
|
|
if (Utils.isUniqueArray(schema.type) === false) {
|
|
report.addError("KEYWORD_MUST_BE", ["type", "an object with unique properties"]);
|
|
}
|
|
} else if (typeof schema.type === "string") {
|
|
if (primitiveTypes.indexOf(schema.type) === -1) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["type", primitiveTypeStr]);
|
|
}
|
|
} else {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["type", ["string", "array"]]);
|
|
}
|
|
if (this.options.noEmptyStrings === true) {
|
|
if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
|
|
if (schema.minLength === undefined && schema.enum === undefined && schema.format === undefined) {
|
|
schema.minLength = 1;
|
|
}
|
|
}
|
|
}
|
|
if (this.options.noEmptyArrays === true) {
|
|
if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
|
|
if (schema.minItems === undefined) {
|
|
schema.minItems = 1;
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceProperties === true) {
|
|
if (schema.type === "object" || isArray && schema.type.indexOf("object") !== -1) {
|
|
if (schema.properties === undefined && schema.patternProperties === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["properties"]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceItems === true) {
|
|
if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
|
|
if (schema.items === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["items"]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceMinItems === true) {
|
|
if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
|
|
if (schema.minItems === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["minItems"]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceMaxItems === true) {
|
|
if (schema.type === "array" || isArray && schema.type.indexOf("array") !== -1) {
|
|
if (schema.maxItems === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["maxItems"]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceMinLength === true) {
|
|
if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
|
|
if (schema.minLength === undefined && schema.format === undefined && schema.enum === undefined && schema.pattern === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["minLength"]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.forceMaxLength === true) {
|
|
if (schema.type === "string" || isArray && schema.type.indexOf("string") !== -1) {
|
|
if (schema.maxLength === undefined && schema.format === undefined && schema.enum === undefined && schema.pattern === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["maxLength"]);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
allOf: function(report, schema) {
|
|
if (Array.isArray(schema.allOf) === false) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["allOf", "array"]);
|
|
} else if (schema.allOf.length === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["allOf", "an array with at least one element"]);
|
|
} else {
|
|
var idx = schema.allOf.length;
|
|
while (idx--) {
|
|
report.path.push("allOf");
|
|
report.path.push(idx.toString());
|
|
exports.validateSchema.call(this, report, schema.allOf[idx]);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
}
|
|
},
|
|
anyOf: function(report, schema) {
|
|
if (Array.isArray(schema.anyOf) === false) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["anyOf", "array"]);
|
|
} else if (schema.anyOf.length === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["anyOf", "an array with at least one element"]);
|
|
} else {
|
|
var idx = schema.anyOf.length;
|
|
while (idx--) {
|
|
report.path.push("anyOf");
|
|
report.path.push(idx.toString());
|
|
exports.validateSchema.call(this, report, schema.anyOf[idx]);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
}
|
|
},
|
|
oneOf: function(report, schema) {
|
|
if (Array.isArray(schema.oneOf) === false) {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["oneOf", "array"]);
|
|
} else if (schema.oneOf.length === 0) {
|
|
report.addError("KEYWORD_MUST_BE", ["oneOf", "an array with at least one element"]);
|
|
} else {
|
|
var idx = schema.oneOf.length;
|
|
while (idx--) {
|
|
report.path.push("oneOf");
|
|
report.path.push(idx.toString());
|
|
exports.validateSchema.call(this, report, schema.oneOf[idx]);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
}
|
|
},
|
|
not: function(report, schema) {
|
|
if (Utils.whatIs(schema.not) !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["not", "object"]);
|
|
} else {
|
|
report.path.push("not");
|
|
exports.validateSchema.call(this, report, schema.not);
|
|
report.path.pop();
|
|
}
|
|
},
|
|
definitions: function(report, schema) {
|
|
if (Utils.whatIs(schema.definitions) !== "object") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["definitions", "object"]);
|
|
} else {
|
|
var keys = Object.keys(schema.definitions),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx],
|
|
val = schema.definitions[key];
|
|
report.path.push("definitions");
|
|
report.path.push(key);
|
|
exports.validateSchema.call(this, report, val);
|
|
report.path.pop();
|
|
report.path.pop();
|
|
}
|
|
}
|
|
},
|
|
format: function(report, schema) {
|
|
if (typeof schema.format !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["format", "string"]);
|
|
} else {
|
|
if (FormatValidators[schema.format] === undefined && this.options.ignoreUnknownFormats !== true) {
|
|
report.addError("UNKNOWN_FORMAT", [schema.format]);
|
|
}
|
|
}
|
|
},
|
|
id: function(report, schema) {
|
|
if (typeof schema.id !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["id", "string"]);
|
|
}
|
|
},
|
|
title: function(report, schema) {
|
|
if (typeof schema.title !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["title", "string"]);
|
|
}
|
|
},
|
|
description: function(report, schema) {
|
|
if (typeof schema.description !== "string") {
|
|
report.addError("KEYWORD_TYPE_EXPECTED", ["description", "string"]);
|
|
}
|
|
},
|
|
"default": function() {}
|
|
};
|
|
var validateArrayOfSchemas = function(report, arr) {
|
|
var idx = arr.length;
|
|
while (idx--) {
|
|
exports.validateSchema.call(this, report, arr[idx]);
|
|
}
|
|
return report.isValid();
|
|
};
|
|
exports.validateSchema = function(report, schema) {
|
|
report.commonErrorMessage = "SCHEMA_VALIDATION_FAILED";
|
|
if (Array.isArray(schema)) {
|
|
return validateArrayOfSchemas.call(this, report, schema);
|
|
}
|
|
if (schema.__$validated) {
|
|
return true;
|
|
}
|
|
var hasParentSchema = schema.$schema && schema.id !== schema.$schema;
|
|
if (hasParentSchema) {
|
|
if (schema.__$schemaResolved && schema.__$schemaResolved !== schema) {
|
|
var subReport = new Report(report);
|
|
var valid = JsonValidation.validate.call(this, subReport, schema.__$schemaResolved, schema);
|
|
if (valid === false) {
|
|
report.addError("PARENT_SCHEMA_VALIDATION_FAILED", null, subReport);
|
|
}
|
|
} else {
|
|
if (this.options.ignoreUnresolvableReferences !== true) {
|
|
report.addError("REF_UNRESOLVED", [schema.$schema]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.noTypeless === true) {
|
|
if (schema.type !== undefined) {
|
|
var schemas = [];
|
|
if (Array.isArray(schema.anyOf)) {
|
|
schemas = schemas.concat(schema.anyOf);
|
|
}
|
|
if (Array.isArray(schema.oneOf)) {
|
|
schemas = schemas.concat(schema.oneOf);
|
|
}
|
|
if (Array.isArray(schema.allOf)) {
|
|
schemas = schemas.concat(schema.allOf);
|
|
}
|
|
schemas.forEach(function(sch) {
|
|
if (!sch.type) {
|
|
sch.type = schema.type;
|
|
}
|
|
});
|
|
}
|
|
if (schema.enum === undefined && schema.type === undefined && schema.anyOf === undefined && schema.oneOf === undefined && schema.not === undefined && schema.$ref === undefined) {
|
|
report.addError("KEYWORD_UNDEFINED_STRICT", ["type"]);
|
|
}
|
|
}
|
|
var keys = Object.keys(schema),
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx];
|
|
if (key.indexOf("__") === 0) {
|
|
continue;
|
|
}
|
|
if (SchemaValidators[key] !== undefined) {
|
|
SchemaValidators[key].call(this, report, schema);
|
|
} else if (!hasParentSchema) {
|
|
if (this.options.noExtraKeywords === true) {
|
|
report.addError("KEYWORD_UNEXPECTED", [key]);
|
|
}
|
|
}
|
|
}
|
|
if (this.options.pedanticCheck === true) {
|
|
if (schema.enum) {
|
|
var tmpSchema = Utils.clone(schema);
|
|
delete tmpSchema.enum;
|
|
delete tmpSchema.default;
|
|
report.path.push("enum");
|
|
idx = schema.enum.length;
|
|
while (idx--) {
|
|
report.path.push(idx.toString());
|
|
JsonValidation.validate.call(this, report, tmpSchema, schema.enum[idx]);
|
|
report.path.pop();
|
|
}
|
|
report.path.pop();
|
|
}
|
|
if (schema.default) {
|
|
report.path.push("default");
|
|
JsonValidation.validate.call(this, report, schema, schema.default);
|
|
report.path.pop();
|
|
}
|
|
}
|
|
var isValid = report.isValid();
|
|
if (isValid) {
|
|
schema.__$validated = true;
|
|
}
|
|
return isValid;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("f5", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports.isAbsoluteUri = function(uri) {
|
|
return /^https?:\/\//.test(uri);
|
|
};
|
|
exports.isRelativeUri = function(uri) {
|
|
return /.+#/.test(uri);
|
|
};
|
|
exports.whatIs = function(what) {
|
|
var to = typeof what;
|
|
if (to === "object") {
|
|
if (what === null) {
|
|
return "null";
|
|
}
|
|
if (Array.isArray(what)) {
|
|
return "array";
|
|
}
|
|
return "object";
|
|
}
|
|
if (to === "number") {
|
|
if (Number.isFinite(what)) {
|
|
if (what % 1 === 0) {
|
|
return "integer";
|
|
} else {
|
|
return "number";
|
|
}
|
|
}
|
|
if (Number.isNaN(what)) {
|
|
return "not-a-number";
|
|
}
|
|
return "unknown-number";
|
|
}
|
|
return to;
|
|
};
|
|
exports.areEqual = function areEqual(json1, json2) {
|
|
if (json1 === json2) {
|
|
return true;
|
|
}
|
|
var i,
|
|
len;
|
|
if (Array.isArray(json1) && Array.isArray(json2)) {
|
|
if (json1.length !== json2.length) {
|
|
return false;
|
|
}
|
|
len = json1.length;
|
|
for (i = 0; i < len; i++) {
|
|
if (!areEqual(json1[i], json2[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
if (exports.whatIs(json1) === "object" && exports.whatIs(json2) === "object") {
|
|
var keys1 = Object.keys(json1);
|
|
var keys2 = Object.keys(json2);
|
|
if (!areEqual(keys1, keys2)) {
|
|
return false;
|
|
}
|
|
len = keys1.length;
|
|
for (i = 0; i < len; i++) {
|
|
if (!areEqual(json1[keys1[i]], json2[keys1[i]])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
exports.isUniqueArray = function(arr, indexes) {
|
|
var i,
|
|
j,
|
|
l = arr.length;
|
|
for (i = 0; i < l; i++) {
|
|
for (j = i + 1; j < l; j++) {
|
|
if (exports.areEqual(arr[i], arr[j])) {
|
|
if (indexes) {
|
|
indexes.push(i, j);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
exports.difference = function(bigSet, subSet) {
|
|
var arr = [],
|
|
idx = bigSet.length;
|
|
while (idx--) {
|
|
if (subSet.indexOf(bigSet[idx]) === -1) {
|
|
arr.push(bigSet[idx]);
|
|
}
|
|
}
|
|
return arr;
|
|
};
|
|
exports.clone = function(src) {
|
|
if (typeof src === "undefined") {
|
|
return void 0;
|
|
}
|
|
if (typeof src !== "object" || src === null) {
|
|
return src;
|
|
}
|
|
var res,
|
|
idx;
|
|
if (Array.isArray(src)) {
|
|
res = [];
|
|
idx = src.length;
|
|
while (idx--) {
|
|
res[idx] = src[idx];
|
|
}
|
|
} else {
|
|
res = {};
|
|
var keys = Object.keys(src);
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx];
|
|
res[key] = src[key];
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
exports.cloneDeep = function(src) {
|
|
var visited = [],
|
|
cloned = [];
|
|
function cloneDeep(src) {
|
|
if (typeof src !== "object" || src === null) {
|
|
return src;
|
|
}
|
|
var res,
|
|
idx,
|
|
cidx;
|
|
cidx = visited.indexOf(src);
|
|
if (cidx !== -1) {
|
|
return cloned[cidx];
|
|
}
|
|
visited.push(src);
|
|
if (Array.isArray(src)) {
|
|
res = [];
|
|
cloned.push(res);
|
|
idx = src.length;
|
|
while (idx--) {
|
|
res[idx] = cloneDeep(src[idx]);
|
|
}
|
|
} else {
|
|
res = {};
|
|
cloned.push(res);
|
|
var keys = Object.keys(src);
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
var key = keys[idx];
|
|
res[key] = cloneDeep(src[key]);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
return cloneDeep(src);
|
|
};
|
|
exports.ucs2decode = function(string) {
|
|
var output = [],
|
|
counter = 0,
|
|
length = string.length,
|
|
value,
|
|
extra;
|
|
while (counter < length) {
|
|
value = string.charCodeAt(counter++);
|
|
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
extra = string.charCodeAt(counter++);
|
|
if ((extra & 0xFC00) == 0xDC00) {
|
|
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
} else {
|
|
output.push(value);
|
|
counter--;
|
|
}
|
|
} else {
|
|
output.push(value);
|
|
}
|
|
}
|
|
return output;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("fb", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"id": "http://json-schema.org/draft-04/schema#",
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
"description": "Core schema meta-schema",
|
|
"definitions": {
|
|
"schemaArray": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {"$ref": "#"}
|
|
},
|
|
"positiveInteger": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"positiveIntegerDefault0": {"allOf": [{"$ref": "#/definitions/positiveInteger"}, {"default": 0}]},
|
|
"simpleTypes": {"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]},
|
|
"stringArray": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"minItems": 1,
|
|
"uniqueItems": true
|
|
}
|
|
},
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"$schema": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"title": {"type": "string"},
|
|
"description": {"type": "string"},
|
|
"default": {},
|
|
"multipleOf": {
|
|
"type": "number",
|
|
"minimum": 0,
|
|
"exclusiveMinimum": true
|
|
},
|
|
"maximum": {"type": "number"},
|
|
"exclusiveMaximum": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"minimum": {"type": "number"},
|
|
"exclusiveMinimum": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"maxLength": {"$ref": "#/definitions/positiveInteger"},
|
|
"minLength": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
"pattern": {
|
|
"type": "string",
|
|
"format": "regex"
|
|
},
|
|
"additionalItems": {
|
|
"anyOf": [{"type": "boolean"}, {"$ref": "#"}],
|
|
"default": {}
|
|
},
|
|
"items": {
|
|
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}],
|
|
"default": {}
|
|
},
|
|
"maxItems": {"$ref": "#/definitions/positiveInteger"},
|
|
"minItems": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
"uniqueItems": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"maxProperties": {"$ref": "#/definitions/positiveInteger"},
|
|
"minProperties": {"$ref": "#/definitions/positiveIntegerDefault0"},
|
|
"required": {"$ref": "#/definitions/stringArray"},
|
|
"additionalProperties": {
|
|
"anyOf": [{"type": "boolean"}, {"$ref": "#"}],
|
|
"default": {}
|
|
},
|
|
"definitions": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#"},
|
|
"default": {}
|
|
},
|
|
"properties": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#"},
|
|
"default": {}
|
|
},
|
|
"patternProperties": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#"},
|
|
"default": {}
|
|
},
|
|
"dependencies": {
|
|
"type": "object",
|
|
"additionalProperties": {"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}]}
|
|
},
|
|
"enum": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"uniqueItems": true
|
|
},
|
|
"type": {"anyOf": [{"$ref": "#/definitions/simpleTypes"}, {
|
|
"type": "array",
|
|
"items": {"$ref": "#/definitions/simpleTypes"},
|
|
"minItems": 1,
|
|
"uniqueItems": true
|
|
}]},
|
|
"format": {"type": "string"},
|
|
"allOf": {"$ref": "#/definitions/schemaArray"},
|
|
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
|
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
|
"not": {"$ref": "#"}
|
|
},
|
|
"dependencies": {
|
|
"exclusiveMaximum": ["maximum"],
|
|
"exclusiveMinimum": ["minimum"]
|
|
},
|
|
"default": {}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("fc", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
|
|
"id": "http://json-schema.org/draft-04/hyper-schema#",
|
|
"title": "JSON Hyper-Schema",
|
|
"allOf": [{"$ref": "http://json-schema.org/draft-04/schema#"}],
|
|
"properties": {
|
|
"additionalItems": {"anyOf": [{"type": "boolean"}, {"$ref": "#"}]},
|
|
"additionalProperties": {"anyOf": [{"type": "boolean"}, {"$ref": "#"}]},
|
|
"dependencies": {"additionalProperties": {"anyOf": [{"$ref": "#"}, {"type": "array"}]}},
|
|
"items": {"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}]},
|
|
"definitions": {"additionalProperties": {"$ref": "#"}},
|
|
"patternProperties": {"additionalProperties": {"$ref": "#"}},
|
|
"properties": {"additionalProperties": {"$ref": "#"}},
|
|
"allOf": {"$ref": "#/definitions/schemaArray"},
|
|
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
|
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
|
"not": {"$ref": "#"},
|
|
"links": {
|
|
"type": "array",
|
|
"items": {"$ref": "#/definitions/linkDescription"}
|
|
},
|
|
"fragmentResolution": {"type": "string"},
|
|
"media": {
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"description": "A media type, as described in RFC 2046",
|
|
"type": "string"
|
|
},
|
|
"binaryEncoding": {
|
|
"description": "A content encoding scheme, as described in RFC 2045",
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"pathStart": {
|
|
"description": "Instances' URIs must start with this value for this schema to apply to them",
|
|
"type": "string",
|
|
"format": "uri"
|
|
}
|
|
},
|
|
"definitions": {
|
|
"schemaArray": {
|
|
"type": "array",
|
|
"items": {"$ref": "#"}
|
|
},
|
|
"linkDescription": {
|
|
"title": "Link Description Object",
|
|
"type": "object",
|
|
"required": ["href", "rel"],
|
|
"properties": {
|
|
"href": {
|
|
"description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",
|
|
"type": "string"
|
|
},
|
|
"rel": {
|
|
"description": "relation to the target resource of the link",
|
|
"type": "string"
|
|
},
|
|
"title": {
|
|
"description": "a title for the link",
|
|
"type": "string"
|
|
},
|
|
"targetSchema": {
|
|
"description": "JSON Schema describing the link target",
|
|
"$ref": "#"
|
|
},
|
|
"mediaType": {
|
|
"description": "media type (as defined by RFC 2046) describing the link target",
|
|
"type": "string"
|
|
},
|
|
"method": {
|
|
"description": "method for requesting the target of the link (e.g. for HTTP this might be \"GET\" or \"DELETE\")",
|
|
"type": "string"
|
|
},
|
|
"encType": {
|
|
"description": "The media type in which to submit data along with the request",
|
|
"type": "string",
|
|
"default": "application/json"
|
|
},
|
|
"schema": {
|
|
"description": "Schema describing the data to submit along with the request",
|
|
"$ref": "#"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("fd", ["e8", "f0", "f2", "f8", "f9", "f1", "f3", "f4", "f5", "fb", "fc", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
"use strict";
|
|
$__require('e8');
|
|
var get = $__require('f0');
|
|
var Report = $__require('f2');
|
|
var FormatValidators = $__require('f8');
|
|
var JsonValidation = $__require('f9');
|
|
var SchemaCache = $__require('f1');
|
|
var SchemaCompilation = $__require('f3');
|
|
var SchemaValidation = $__require('f4');
|
|
var Utils = $__require('f5');
|
|
var Draft4Schema = $__require('fb');
|
|
var Draft4HyperSchema = $__require('fc');
|
|
var defaultOptions = {
|
|
asyncTimeout: 2000,
|
|
forceAdditional: false,
|
|
assumeAdditional: false,
|
|
forceItems: false,
|
|
forceMinItems: false,
|
|
forceMaxItems: false,
|
|
forceMinLength: false,
|
|
forceMaxLength: false,
|
|
forceProperties: false,
|
|
ignoreUnresolvableReferences: false,
|
|
noExtraKeywords: false,
|
|
noTypeless: false,
|
|
noEmptyStrings: false,
|
|
noEmptyArrays: false,
|
|
strictUris: false,
|
|
strictMode: false,
|
|
reportPathAsArray: false,
|
|
breakOnFirstError: true,
|
|
pedanticCheck: false,
|
|
ignoreUnknownFormats: false
|
|
};
|
|
function ZSchema(options) {
|
|
this.cache = {};
|
|
this.referenceCache = [];
|
|
this.setRemoteReference("http://json-schema.org/draft-04/schema", Draft4Schema);
|
|
this.setRemoteReference("http://json-schema.org/draft-04/hyper-schema", Draft4HyperSchema);
|
|
if (typeof options === "object") {
|
|
var keys = Object.keys(options),
|
|
idx = keys.length,
|
|
key;
|
|
while (idx--) {
|
|
key = keys[idx];
|
|
if (defaultOptions[key] === undefined) {
|
|
throw new Error("Unexpected option passed to constructor: " + key);
|
|
}
|
|
}
|
|
keys = Object.keys(defaultOptions);
|
|
idx = keys.length;
|
|
while (idx--) {
|
|
key = keys[idx];
|
|
if (options[key] === undefined) {
|
|
options[key] = Utils.clone(defaultOptions[key]);
|
|
}
|
|
}
|
|
this.options = options;
|
|
} else {
|
|
this.options = Utils.clone(defaultOptions);
|
|
}
|
|
if (this.options.strictMode === true) {
|
|
this.options.forceAdditional = true;
|
|
this.options.forceItems = true;
|
|
this.options.forceMaxLength = true;
|
|
this.options.forceProperties = true;
|
|
this.options.noExtraKeywords = true;
|
|
this.options.noTypeless = true;
|
|
this.options.noEmptyStrings = true;
|
|
this.options.noEmptyArrays = true;
|
|
}
|
|
}
|
|
ZSchema.prototype.compileSchema = function(schema) {
|
|
var report = new Report(this.options);
|
|
schema = SchemaCache.getSchema.call(this, report, schema);
|
|
SchemaCompilation.compileSchema.call(this, report, schema);
|
|
this.lastReport = report;
|
|
return report.isValid();
|
|
};
|
|
ZSchema.prototype.validateSchema = function(schema) {
|
|
if (Array.isArray(schema) && schema.length === 0) {
|
|
throw new Error(".validateSchema was called with an empty array");
|
|
}
|
|
var report = new Report(this.options);
|
|
schema = SchemaCache.getSchema.call(this, report, schema);
|
|
var compiled = SchemaCompilation.compileSchema.call(this, report, schema);
|
|
if (compiled) {
|
|
SchemaValidation.validateSchema.call(this, report, schema);
|
|
}
|
|
this.lastReport = report;
|
|
return report.isValid();
|
|
};
|
|
ZSchema.prototype.validate = function(json, schema, options, callback) {
|
|
if (Utils.whatIs(options) === "function") {
|
|
callback = options;
|
|
options = {};
|
|
}
|
|
if (!options) {
|
|
options = {};
|
|
}
|
|
var whatIs = Utils.whatIs(schema);
|
|
if (whatIs !== "string" && whatIs !== "object") {
|
|
var e = new Error("Invalid .validate call - schema must be an string or object but " + whatIs + " was passed!");
|
|
if (callback) {
|
|
process.nextTick(function() {
|
|
callback(e, false);
|
|
});
|
|
return;
|
|
}
|
|
throw e;
|
|
}
|
|
var foundError = false;
|
|
var report = new Report(this.options);
|
|
if (typeof schema === "string") {
|
|
var schemaName = schema;
|
|
schema = SchemaCache.getSchema.call(this, report, schemaName);
|
|
if (!schema) {
|
|
throw new Error("Schema with id '" + schemaName + "' wasn't found in the validator cache!");
|
|
}
|
|
} else {
|
|
schema = SchemaCache.getSchema.call(this, report, schema);
|
|
}
|
|
var compiled = false;
|
|
if (!foundError) {
|
|
compiled = SchemaCompilation.compileSchema.call(this, report, schema);
|
|
}
|
|
if (!compiled) {
|
|
this.lastReport = report;
|
|
foundError = true;
|
|
}
|
|
var validated = false;
|
|
if (!foundError) {
|
|
validated = SchemaValidation.validateSchema.call(this, report, schema);
|
|
}
|
|
if (!validated) {
|
|
this.lastReport = report;
|
|
foundError = true;
|
|
}
|
|
if (options.schemaPath) {
|
|
report.rootSchema = schema;
|
|
schema = get(schema, options.schemaPath);
|
|
if (!schema) {
|
|
throw new Error("Schema path '" + options.schemaPath + "' wasn't found in the schema!");
|
|
}
|
|
}
|
|
if (!foundError) {
|
|
JsonValidation.validate.call(this, report, schema, json);
|
|
}
|
|
if (callback) {
|
|
report.processAsyncTasks(this.options.asyncTimeout, callback);
|
|
return;
|
|
} else if (report.asyncTasks.length > 0) {
|
|
throw new Error("This validation has async tasks and cannot be done in sync mode, please provide callback argument.");
|
|
}
|
|
this.lastReport = report;
|
|
return report.isValid();
|
|
};
|
|
ZSchema.prototype.getLastError = function() {
|
|
if (this.lastReport.errors.length === 0) {
|
|
return null;
|
|
}
|
|
var e = new Error();
|
|
e.name = "z-schema validation error";
|
|
e.message = this.lastReport.commonErrorMessage;
|
|
e.details = this.lastReport.errors;
|
|
return e;
|
|
};
|
|
ZSchema.prototype.getLastErrors = function() {
|
|
return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : undefined;
|
|
};
|
|
ZSchema.prototype.getMissingReferences = function(arr) {
|
|
arr = arr || this.lastReport.errors;
|
|
var res = [],
|
|
idx = arr.length;
|
|
while (idx--) {
|
|
var error = arr[idx];
|
|
if (error.code === "UNRESOLVABLE_REFERENCE") {
|
|
var reference = error.params[0];
|
|
if (res.indexOf(reference) === -1) {
|
|
res.push(reference);
|
|
}
|
|
}
|
|
if (error.inner) {
|
|
res = res.concat(this.getMissingReferences(error.inner));
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
ZSchema.prototype.getMissingRemoteReferences = function() {
|
|
var missingReferences = this.getMissingReferences(),
|
|
missingRemoteReferences = [],
|
|
idx = missingReferences.length;
|
|
while (idx--) {
|
|
var remoteReference = SchemaCache.getRemotePath(missingReferences[idx]);
|
|
if (remoteReference && missingRemoteReferences.indexOf(remoteReference) === -1) {
|
|
missingRemoteReferences.push(remoteReference);
|
|
}
|
|
}
|
|
return missingRemoteReferences;
|
|
};
|
|
ZSchema.prototype.setRemoteReference = function(uri, schema) {
|
|
if (typeof schema === "string") {
|
|
schema = JSON.parse(schema);
|
|
} else {
|
|
schema = Utils.cloneDeep(schema);
|
|
}
|
|
SchemaCache.cacheSchemaByUri.call(this, uri, schema);
|
|
};
|
|
ZSchema.prototype.getResolvedSchema = function(schema) {
|
|
var report = new Report(this.options);
|
|
schema = SchemaCache.getSchema.call(this, report, schema);
|
|
schema = Utils.cloneDeep(schema);
|
|
var visited = [];
|
|
var cleanup = function(schema) {
|
|
var key,
|
|
typeOf = Utils.whatIs(schema);
|
|
if (typeOf !== "object" && typeOf !== "array") {
|
|
return;
|
|
}
|
|
if (schema.___$visited) {
|
|
return;
|
|
}
|
|
schema.___$visited = true;
|
|
visited.push(schema);
|
|
if (schema.$ref && schema.__$refResolved) {
|
|
var from = schema.__$refResolved;
|
|
var to = schema;
|
|
delete schema.$ref;
|
|
delete schema.__$refResolved;
|
|
for (key in from) {
|
|
if (from.hasOwnProperty(key)) {
|
|
to[key] = from[key];
|
|
}
|
|
}
|
|
}
|
|
for (key in schema) {
|
|
if (schema.hasOwnProperty(key)) {
|
|
if (key.indexOf("__$") === 0) {
|
|
delete schema[key];
|
|
} else {
|
|
cleanup(schema[key]);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
cleanup(schema);
|
|
visited.forEach(function(s) {
|
|
delete s.___$visited;
|
|
});
|
|
this.lastReport = report;
|
|
if (report.isValid()) {
|
|
return schema;
|
|
} else {
|
|
throw this.getLastError();
|
|
}
|
|
};
|
|
ZSchema.prototype.setSchemaReader = function(schemaReader) {
|
|
return ZSchema.setSchemaReader(schemaReader);
|
|
};
|
|
ZSchema.prototype.getSchemaReader = function() {
|
|
return ZSchema.schemaReader;
|
|
};
|
|
ZSchema.setSchemaReader = function(schemaReader) {
|
|
ZSchema.schemaReader = schemaReader;
|
|
};
|
|
ZSchema.registerFormat = function(formatName, validatorFunction) {
|
|
FormatValidators[formatName] = validatorFunction;
|
|
};
|
|
ZSchema.unregisterFormat = function(formatName) {
|
|
delete FormatValidators[formatName];
|
|
};
|
|
ZSchema.getRegisteredFormats = function() {
|
|
return Object.keys(FormatValidators);
|
|
};
|
|
ZSchema.getDefaultOptions = function() {
|
|
return Utils.cloneDeep(defaultOptions);
|
|
};
|
|
module.exports = ZSchema;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("fe", ["fd"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('fd');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ff", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"title": "A JSON Schema for Swagger 2.0 API.",
|
|
"id": "http://swagger.io/v2/schema.json#",
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
"type": "object",
|
|
"required": ["swagger", "info", "paths"],
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"swagger": {
|
|
"type": "string",
|
|
"enum": ["2.0"],
|
|
"description": "The Swagger version of this document."
|
|
},
|
|
"info": {"$ref": "#/definitions/info"},
|
|
"host": {
|
|
"type": "string",
|
|
"pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
|
|
"description": "The host (name or ip) of the API. Example: 'swagger.io'"
|
|
},
|
|
"basePath": {
|
|
"type": "string",
|
|
"pattern": "^/",
|
|
"description": "The base path to the API. Example: '/api'."
|
|
},
|
|
"schemes": {"$ref": "#/definitions/schemesList"},
|
|
"consumes": {
|
|
"description": "A list of MIME types accepted by the API.",
|
|
"$ref": "#/definitions/mediaTypeList"
|
|
},
|
|
"produces": {
|
|
"description": "A list of MIME types the API can produce.",
|
|
"$ref": "#/definitions/mediaTypeList"
|
|
},
|
|
"paths": {"$ref": "#/definitions/paths"},
|
|
"definitions": {"$ref": "#/definitions/definitions"},
|
|
"parameters": {"$ref": "#/definitions/parameterDefinitions"},
|
|
"responses": {"$ref": "#/definitions/responseDefinitions"},
|
|
"security": {"$ref": "#/definitions/security"},
|
|
"securityDefinitions": {"$ref": "#/definitions/securityDefinitions"},
|
|
"tags": {
|
|
"type": "array",
|
|
"items": {"$ref": "#/definitions/tag"},
|
|
"uniqueItems": true
|
|
},
|
|
"externalDocs": {"$ref": "#/definitions/externalDocs"}
|
|
},
|
|
"definitions": {
|
|
"info": {
|
|
"type": "object",
|
|
"description": "General information about the API.",
|
|
"required": ["version", "title"],
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"title": {
|
|
"type": "string",
|
|
"description": "A unique and precise title of the API."
|
|
},
|
|
"version": {
|
|
"type": "string",
|
|
"description": "A semantic version number of the API."
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"termsOfService": {
|
|
"type": "string",
|
|
"description": "The terms of service for the API."
|
|
},
|
|
"contact": {"$ref": "#/definitions/contact"},
|
|
"license": {"$ref": "#/definitions/license"}
|
|
}
|
|
},
|
|
"contact": {
|
|
"type": "object",
|
|
"description": "Contact information for the owners of the API.",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The identifying name of the contact person/organization."
|
|
},
|
|
"url": {
|
|
"type": "string",
|
|
"description": "The URL pointing to the contact information.",
|
|
"format": "uri"
|
|
},
|
|
"email": {
|
|
"type": "string",
|
|
"description": "The email address of the contact person/organization.",
|
|
"format": "email"
|
|
}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"license": {
|
|
"type": "object",
|
|
"required": ["name"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the license type. It's encouraged to use an OSI compatible license."
|
|
},
|
|
"url": {
|
|
"type": "string",
|
|
"description": "The URL pointing to the license.",
|
|
"format": "uri"
|
|
}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"paths": {
|
|
"type": "object",
|
|
"description": "Relative paths to the individual endpoints. They must be relative to the 'basePath'.",
|
|
"patternProperties": {
|
|
"^x-": {"$ref": "#/definitions/vendorExtension"},
|
|
"^/": {"$ref": "#/definitions/pathItem"}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"definitions": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#/definitions/schema"},
|
|
"description": "One or more JSON objects describing the schemas being consumed and produced by the API."
|
|
},
|
|
"parameterDefinitions": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#/definitions/parameter"},
|
|
"description": "One or more JSON representations for parameters"
|
|
},
|
|
"responseDefinitions": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#/definitions/response"},
|
|
"description": "One or more JSON representations for parameters"
|
|
},
|
|
"externalDocs": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"description": "information about external documentation",
|
|
"required": ["url"],
|
|
"properties": {
|
|
"description": {"type": "string"},
|
|
"url": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"examples": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
},
|
|
"mimeType": {
|
|
"type": "string",
|
|
"description": "The MIME type of the HTTP message."
|
|
},
|
|
"operation": {
|
|
"type": "object",
|
|
"required": ["responses"],
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"tags": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"uniqueItems": true
|
|
},
|
|
"summary": {
|
|
"type": "string",
|
|
"description": "A brief summary of the operation."
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A longer description of the operation, GitHub Flavored Markdown is allowed."
|
|
},
|
|
"externalDocs": {"$ref": "#/definitions/externalDocs"},
|
|
"operationId": {
|
|
"type": "string",
|
|
"description": "A unique identifier of the operation."
|
|
},
|
|
"produces": {
|
|
"description": "A list of MIME types the API can produce.",
|
|
"$ref": "#/definitions/mediaTypeList"
|
|
},
|
|
"consumes": {
|
|
"description": "A list of MIME types the API can consume.",
|
|
"$ref": "#/definitions/mediaTypeList"
|
|
},
|
|
"parameters": {"$ref": "#/definitions/parametersList"},
|
|
"responses": {"$ref": "#/definitions/responses"},
|
|
"schemes": {"$ref": "#/definitions/schemesList"},
|
|
"deprecated": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"security": {"$ref": "#/definitions/security"}
|
|
}
|
|
},
|
|
"pathItem": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"$ref": {"type": "string"},
|
|
"get": {"$ref": "#/definitions/operation"},
|
|
"put": {"$ref": "#/definitions/operation"},
|
|
"post": {"$ref": "#/definitions/operation"},
|
|
"delete": {"$ref": "#/definitions/operation"},
|
|
"options": {"$ref": "#/definitions/operation"},
|
|
"head": {"$ref": "#/definitions/operation"},
|
|
"patch": {"$ref": "#/definitions/operation"},
|
|
"parameters": {"$ref": "#/definitions/parametersList"}
|
|
}
|
|
},
|
|
"responses": {
|
|
"type": "object",
|
|
"description": "Response objects names can either be any valid HTTP status code or 'default'.",
|
|
"minProperties": 1,
|
|
"additionalProperties": false,
|
|
"patternProperties": {
|
|
"^([0-9]{3})$|^(default)$": {"$ref": "#/definitions/responseValue"},
|
|
"^x-": {"$ref": "#/definitions/vendorExtension"}
|
|
},
|
|
"not": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
}
|
|
},
|
|
"responseValue": {"oneOf": [{"$ref": "#/definitions/response"}, {"$ref": "#/definitions/jsonReference"}]},
|
|
"response": {
|
|
"type": "object",
|
|
"required": ["description"],
|
|
"properties": {
|
|
"description": {"type": "string"},
|
|
"schema": {"oneOf": [{"$ref": "#/definitions/schema"}, {"$ref": "#/definitions/fileSchema"}]},
|
|
"headers": {"$ref": "#/definitions/headers"},
|
|
"examples": {"$ref": "#/definitions/examples"}
|
|
},
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"headers": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#/definitions/header"}
|
|
},
|
|
"header": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "integer", "boolean", "array"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormat"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"vendorExtension": {
|
|
"description": "Any property starting with x- is valid.",
|
|
"additionalProperties": true,
|
|
"additionalItems": true
|
|
},
|
|
"bodyParameter": {
|
|
"type": "object",
|
|
"required": ["name", "in", "schema"],
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the parameter."
|
|
},
|
|
"in": {
|
|
"type": "string",
|
|
"description": "Determines the location of the parameter.",
|
|
"enum": ["body"]
|
|
},
|
|
"required": {
|
|
"type": "boolean",
|
|
"description": "Determines whether or not this parameter is required or optional.",
|
|
"default": false
|
|
},
|
|
"schema": {"$ref": "#/definitions/schema"}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"headerParameterSubSchema": {
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"required": {
|
|
"type": "boolean",
|
|
"description": "Determines whether or not this parameter is required or optional.",
|
|
"default": false
|
|
},
|
|
"in": {
|
|
"type": "string",
|
|
"description": "Determines the location of the parameter.",
|
|
"enum": ["header"]
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the parameter."
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "boolean", "integer", "array"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormat"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"}
|
|
}
|
|
},
|
|
"queryParameterSubSchema": {
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"required": {
|
|
"type": "boolean",
|
|
"description": "Determines whether or not this parameter is required or optional.",
|
|
"default": false
|
|
},
|
|
"in": {
|
|
"type": "string",
|
|
"description": "Determines the location of the parameter.",
|
|
"enum": ["query"]
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the parameter."
|
|
},
|
|
"allowEmptyValue": {
|
|
"type": "boolean",
|
|
"default": false,
|
|
"description": "allows sending a parameter by name only or with an empty value."
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "boolean", "integer", "array"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormatWithMulti"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"}
|
|
}
|
|
},
|
|
"formDataParameterSubSchema": {
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"required": {
|
|
"type": "boolean",
|
|
"description": "Determines whether or not this parameter is required or optional.",
|
|
"default": false
|
|
},
|
|
"in": {
|
|
"type": "string",
|
|
"description": "Determines the location of the parameter.",
|
|
"enum": ["formData"]
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the parameter."
|
|
},
|
|
"allowEmptyValue": {
|
|
"type": "boolean",
|
|
"default": false,
|
|
"description": "allows sending a parameter by name only or with an empty value."
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "boolean", "integer", "array", "file"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormatWithMulti"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"}
|
|
}
|
|
},
|
|
"pathParameterSubSchema": {
|
|
"additionalProperties": false,
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"required": ["required"],
|
|
"properties": {
|
|
"required": {
|
|
"type": "boolean",
|
|
"enum": [true],
|
|
"description": "Determines whether or not this parameter is required or optional."
|
|
},
|
|
"in": {
|
|
"type": "string",
|
|
"description": "Determines the location of the parameter.",
|
|
"enum": ["path"]
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the parameter."
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "boolean", "integer", "array"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormat"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"}
|
|
}
|
|
},
|
|
"nonBodyParameter": {
|
|
"type": "object",
|
|
"required": ["name", "in", "type"],
|
|
"oneOf": [{"$ref": "#/definitions/headerParameterSubSchema"}, {"$ref": "#/definitions/formDataParameterSubSchema"}, {"$ref": "#/definitions/queryParameterSubSchema"}, {"$ref": "#/definitions/pathParameterSubSchema"}]
|
|
},
|
|
"parameter": {"oneOf": [{"$ref": "#/definitions/bodyParameter"}, {"$ref": "#/definitions/nonBodyParameter"}]},
|
|
"schema": {
|
|
"type": "object",
|
|
"description": "A deterministic version of a JSON Schema object.",
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"$ref": {"type": "string"},
|
|
"format": {"type": "string"},
|
|
"title": {"$ref": "http://json-schema.org/draft-04/schema#/properties/title"},
|
|
"description": {"$ref": "http://json-schema.org/draft-04/schema#/properties/description"},
|
|
"default": {"$ref": "http://json-schema.org/draft-04/schema#/properties/default"},
|
|
"multipleOf": {"$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"},
|
|
"maximum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"},
|
|
"exclusiveMaximum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"},
|
|
"minimum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"},
|
|
"exclusiveMinimum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},
|
|
"minLength": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},
|
|
"pattern": {"$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"},
|
|
"maxItems": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},
|
|
"minItems": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},
|
|
"uniqueItems": {"$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"},
|
|
"maxProperties": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},
|
|
"minProperties": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},
|
|
"required": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"},
|
|
"enum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/enum"},
|
|
"additionalProperties": {
|
|
"anyOf": [{"$ref": "#/definitions/schema"}, {"type": "boolean"}],
|
|
"default": {}
|
|
},
|
|
"type": {"$ref": "http://json-schema.org/draft-04/schema#/properties/type"},
|
|
"items": {
|
|
"anyOf": [{"$ref": "#/definitions/schema"}, {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {"$ref": "#/definitions/schema"}
|
|
}],
|
|
"default": {}
|
|
},
|
|
"allOf": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {"$ref": "#/definitions/schema"}
|
|
},
|
|
"properties": {
|
|
"type": "object",
|
|
"additionalProperties": {"$ref": "#/definitions/schema"},
|
|
"default": {}
|
|
},
|
|
"discriminator": {"type": "string"},
|
|
"readOnly": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"xml": {"$ref": "#/definitions/xml"},
|
|
"externalDocs": {"$ref": "#/definitions/externalDocs"},
|
|
"example": {}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"fileSchema": {
|
|
"type": "object",
|
|
"description": "A deterministic version of a JSON Schema object.",
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}},
|
|
"properties": {
|
|
"format": {"type": "string"},
|
|
"title": {"$ref": "http://json-schema.org/draft-04/schema#/properties/title"},
|
|
"description": {"$ref": "http://json-schema.org/draft-04/schema#/properties/description"},
|
|
"default": {"$ref": "http://json-schema.org/draft-04/schema#/properties/default"},
|
|
"required": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray"},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["file"]
|
|
},
|
|
"readOnly": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"externalDocs": {"$ref": "#/definitions/externalDocs"},
|
|
"example": {}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"primitivesItems": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["string", "number", "integer", "boolean", "array"]
|
|
},
|
|
"format": {"type": "string"},
|
|
"items": {"$ref": "#/definitions/primitivesItems"},
|
|
"collectionFormat": {"$ref": "#/definitions/collectionFormat"},
|
|
"default": {"$ref": "#/definitions/default"},
|
|
"maximum": {"$ref": "#/definitions/maximum"},
|
|
"exclusiveMaximum": {"$ref": "#/definitions/exclusiveMaximum"},
|
|
"minimum": {"$ref": "#/definitions/minimum"},
|
|
"exclusiveMinimum": {"$ref": "#/definitions/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "#/definitions/maxLength"},
|
|
"minLength": {"$ref": "#/definitions/minLength"},
|
|
"pattern": {"$ref": "#/definitions/pattern"},
|
|
"maxItems": {"$ref": "#/definitions/maxItems"},
|
|
"minItems": {"$ref": "#/definitions/minItems"},
|
|
"uniqueItems": {"$ref": "#/definitions/uniqueItems"},
|
|
"enum": {"$ref": "#/definitions/enum"},
|
|
"multipleOf": {"$ref": "#/definitions/multipleOf"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"security": {
|
|
"type": "array",
|
|
"items": {"$ref": "#/definitions/securityRequirement"},
|
|
"uniqueItems": true
|
|
},
|
|
"securityRequirement": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "array",
|
|
"items": {"type": "string"},
|
|
"uniqueItems": true
|
|
}
|
|
},
|
|
"xml": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"name": {"type": "string"},
|
|
"namespace": {"type": "string"},
|
|
"prefix": {"type": "string"},
|
|
"attribute": {
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"wrapped": {
|
|
"type": "boolean",
|
|
"default": false
|
|
}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"tag": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["name"],
|
|
"properties": {
|
|
"name": {"type": "string"},
|
|
"description": {"type": "string"},
|
|
"externalDocs": {"$ref": "#/definitions/externalDocs"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"securityDefinitions": {
|
|
"type": "object",
|
|
"additionalProperties": {"oneOf": [{"$ref": "#/definitions/basicAuthenticationSecurity"}, {"$ref": "#/definitions/apiKeySecurity"}, {"$ref": "#/definitions/oauth2ImplicitSecurity"}, {"$ref": "#/definitions/oauth2PasswordSecurity"}, {"$ref": "#/definitions/oauth2ApplicationSecurity"}, {"$ref": "#/definitions/oauth2AccessCodeSecurity"}]}
|
|
},
|
|
"basicAuthenticationSecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["basic"]
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"apiKeySecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type", "name", "in"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["apiKey"]
|
|
},
|
|
"name": {"type": "string"},
|
|
"in": {
|
|
"type": "string",
|
|
"enum": ["header", "query"]
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"oauth2ImplicitSecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type", "flow", "authorizationUrl"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["oauth2"]
|
|
},
|
|
"flow": {
|
|
"type": "string",
|
|
"enum": ["implicit"]
|
|
},
|
|
"scopes": {"$ref": "#/definitions/oauth2Scopes"},
|
|
"authorizationUrl": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"oauth2PasswordSecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type", "flow", "tokenUrl"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["oauth2"]
|
|
},
|
|
"flow": {
|
|
"type": "string",
|
|
"enum": ["password"]
|
|
},
|
|
"scopes": {"$ref": "#/definitions/oauth2Scopes"},
|
|
"tokenUrl": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"oauth2ApplicationSecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type", "flow", "tokenUrl"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["oauth2"]
|
|
},
|
|
"flow": {
|
|
"type": "string",
|
|
"enum": ["application"]
|
|
},
|
|
"scopes": {"$ref": "#/definitions/oauth2Scopes"},
|
|
"tokenUrl": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"oauth2AccessCodeSecurity": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": ["type", "flow", "authorizationUrl", "tokenUrl"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["oauth2"]
|
|
},
|
|
"flow": {
|
|
"type": "string",
|
|
"enum": ["accessCode"]
|
|
},
|
|
"scopes": {"$ref": "#/definitions/oauth2Scopes"},
|
|
"authorizationUrl": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"tokenUrl": {
|
|
"type": "string",
|
|
"format": "uri"
|
|
},
|
|
"description": {"type": "string"}
|
|
},
|
|
"patternProperties": {"^x-": {"$ref": "#/definitions/vendorExtension"}}
|
|
},
|
|
"oauth2Scopes": {
|
|
"type": "object",
|
|
"additionalProperties": {"type": "string"}
|
|
},
|
|
"mediaTypeList": {
|
|
"type": "array",
|
|
"items": {"$ref": "#/definitions/mimeType"},
|
|
"uniqueItems": true
|
|
},
|
|
"parametersList": {
|
|
"type": "array",
|
|
"description": "The parameters needed to send a valid API call.",
|
|
"additionalItems": false,
|
|
"items": {"oneOf": [{"$ref": "#/definitions/parameter"}, {"$ref": "#/definitions/jsonReference"}]},
|
|
"uniqueItems": true
|
|
},
|
|
"schemesList": {
|
|
"type": "array",
|
|
"description": "The transfer protocol of the API.",
|
|
"items": {
|
|
"type": "string",
|
|
"enum": ["http", "https", "ws", "wss"]
|
|
},
|
|
"uniqueItems": true
|
|
},
|
|
"collectionFormat": {
|
|
"type": "string",
|
|
"enum": ["csv", "ssv", "tsv", "pipes"],
|
|
"default": "csv"
|
|
},
|
|
"collectionFormatWithMulti": {
|
|
"type": "string",
|
|
"enum": ["csv", "ssv", "tsv", "pipes", "multi"],
|
|
"default": "csv"
|
|
},
|
|
"title": {"$ref": "http://json-schema.org/draft-04/schema#/properties/title"},
|
|
"description": {"$ref": "http://json-schema.org/draft-04/schema#/properties/description"},
|
|
"default": {"$ref": "http://json-schema.org/draft-04/schema#/properties/default"},
|
|
"multipleOf": {"$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf"},
|
|
"maximum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/maximum"},
|
|
"exclusiveMaximum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum"},
|
|
"minimum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/minimum"},
|
|
"exclusiveMinimum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"},
|
|
"maxLength": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},
|
|
"minLength": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},
|
|
"pattern": {"$ref": "http://json-schema.org/draft-04/schema#/properties/pattern"},
|
|
"maxItems": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"},
|
|
"minItems": {"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0"},
|
|
"uniqueItems": {"$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems"},
|
|
"enum": {"$ref": "http://json-schema.org/draft-04/schema#/properties/enum"},
|
|
"jsonReference": {
|
|
"type": "object",
|
|
"required": ["$ref"],
|
|
"additionalProperties": false,
|
|
"properties": {"$ref": {"type": "string"}}
|
|
}
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("100", ["102", "101", "fe", "ff"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var util = $__require('102'),
|
|
ono = $__require('101'),
|
|
ZSchema = $__require('fe'),
|
|
swaggerSchema = $__require('ff');
|
|
module.exports = validateSchema;
|
|
initializeZSchema();
|
|
function validateSchema(api) {
|
|
util.debug('Validating against the Swagger 2.0 schema');
|
|
var isValid = ZSchema.validate(api, swaggerSchema);
|
|
if (isValid) {
|
|
util.debug(' Validated successfully');
|
|
} else {
|
|
var err = ZSchema.getLastError();
|
|
var message = 'Swagger schema validation failed. ' + formatZSchemaError(err.details);
|
|
throw ono.syntax(err, {details: err.details}, message);
|
|
}
|
|
}
|
|
function initializeZSchema() {
|
|
ZSchema = new ZSchema({
|
|
breakOnFirstError: true,
|
|
noExtraKeywords: true,
|
|
ignoreUnknownFormats: false,
|
|
reportPathAsArray: true
|
|
});
|
|
}
|
|
function formatZSchemaError(errors, indent) {
|
|
indent = indent || ' ';
|
|
var message = '';
|
|
errors.forEach(function(error, index) {
|
|
message += util.format('\n%s%s at %s', indent, error.message, error.path.join('/'));
|
|
if (error.inner) {
|
|
message += formatZSchemaError(error.inner, indent + ' ');
|
|
}
|
|
});
|
|
return message;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("103", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch'];
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("104", ["103"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('103');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("105", ["102", "101", "104"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var util = $__require('102'),
|
|
ono = $__require('101'),
|
|
swaggerMethods = $__require('104'),
|
|
primitiveTypes = ['array', 'boolean', 'integer', 'number', 'string'],
|
|
schemaTypes = ['array', 'boolean', 'integer', 'number', 'string', 'object', 'null', undefined];
|
|
module.exports = validateSpec;
|
|
function validateSpec(api) {
|
|
util.debug('Validating against the Swagger 2.0 spec');
|
|
var paths = Object.keys(api.paths || {});
|
|
paths.forEach(function(pathName) {
|
|
var path = api.paths[pathName];
|
|
var pathId = '/paths' + pathName;
|
|
if (path && pathName.indexOf('/') === 0) {
|
|
validatePath(api, path, pathId);
|
|
}
|
|
});
|
|
util.debug(' Validated successfully');
|
|
}
|
|
function validatePath(api, path, pathId) {
|
|
swaggerMethods.forEach(function(operationName) {
|
|
var operation = path[operationName];
|
|
var operationId = pathId + '/' + operationName;
|
|
if (operation) {
|
|
validateParameters(api, path, pathId, operation, operationId);
|
|
var responses = Object.keys(operation.responses || {});
|
|
responses.forEach(function(responseName) {
|
|
var response = operation.responses[responseName];
|
|
var responseId = operationId + '/responses/' + responseName;
|
|
validateResponse(responseName, response, responseId);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function validateParameters(api, path, pathId, operation, operationId) {
|
|
var pathParams = path.parameters || [];
|
|
var operationParams = operation.parameters || [];
|
|
try {
|
|
checkForDuplicates(pathParams);
|
|
} catch (e) {
|
|
throw ono.syntax(e, 'Validation failed. %s has duplicate parameters', pathId);
|
|
}
|
|
try {
|
|
checkForDuplicates(operationParams);
|
|
} catch (e) {
|
|
throw ono.syntax(e, 'Validation failed. %s has duplicate parameters', operationId);
|
|
}
|
|
var params = pathParams.reduce(function(combinedParams, value) {
|
|
var duplicate = combinedParams.some(function(param) {
|
|
return param.in === value.in && param.name === value.name;
|
|
});
|
|
if (!duplicate) {
|
|
combinedParams.push(value);
|
|
}
|
|
return combinedParams;
|
|
}, operationParams);
|
|
validateBodyParameters(params, operationId);
|
|
validatePathParameters(params, pathId, operationId);
|
|
validateParameterTypes(params, api, operation, operationId);
|
|
}
|
|
function validateBodyParameters(params, operationId) {
|
|
var bodyParams = params.filter(function(param) {
|
|
return param.in === 'body';
|
|
});
|
|
var formParams = params.filter(function(param) {
|
|
return param.in === 'formData';
|
|
});
|
|
if (bodyParams.length > 1) {
|
|
throw ono.syntax('Validation failed. %s has %d body parameters. Only one is allowed.', operationId, bodyParams.length);
|
|
} else if (bodyParams.length > 0 && formParams.length > 0) {
|
|
throw ono.syntax('Validation failed. %s has body parameters and formData parameters. Only one or the other is allowed.', operationId);
|
|
}
|
|
}
|
|
function validatePathParameters(params, pathId, operationId) {
|
|
var placeholders = pathId.match(util.swaggerParamRegExp) || [];
|
|
for (var i = 0; i < placeholders.length; i++) {
|
|
for (var j = i + 1; j < placeholders.length; j++) {
|
|
if (placeholders[i] === placeholders[j]) {
|
|
throw ono.syntax('Validation failed. %s has multiple path placeholders named %s', operationId, placeholders[i]);
|
|
}
|
|
}
|
|
}
|
|
params.filter(function(param) {
|
|
return param.in === 'path';
|
|
}).forEach(function(param) {
|
|
if (param.required !== true) {
|
|
throw ono.syntax('Validation failed. Path parameters cannot be optional. Set required=true for the "%s" parameter at %s', param.name, operationId);
|
|
}
|
|
var match = placeholders.indexOf('{' + param.name + '}');
|
|
if (match === -1) {
|
|
throw ono.syntax('Validation failed. %s has a path parameter named "%s", ' + 'but there is no corresponding {%s} in the path string', operationId, param.name, param.name);
|
|
}
|
|
placeholders.splice(match, 1);
|
|
});
|
|
if (placeholders.length > 0) {
|
|
throw ono.syntax('Validation failed. %s is missing path parameter(s) for %s', operationId, placeholders);
|
|
}
|
|
}
|
|
function validateParameterTypes(params, api, operation, operationId) {
|
|
params.forEach(function(param) {
|
|
var parameterId = operationId + '/parameters/' + param.name;
|
|
var schema,
|
|
validTypes;
|
|
switch (param.in) {
|
|
case 'body':
|
|
schema = param.schema;
|
|
validTypes = schemaTypes;
|
|
break;
|
|
case 'formData':
|
|
schema = param;
|
|
validTypes = primitiveTypes.concat('file');
|
|
break;
|
|
default:
|
|
schema = param;
|
|
validTypes = primitiveTypes;
|
|
}
|
|
validateSchema(schema, parameterId, validTypes);
|
|
if (schema.type === 'file') {
|
|
var consumes = operation.consumes || api.consumes || [];
|
|
if (consumes.indexOf('multipart/form-data') === -1 && consumes.indexOf('application/x-www-form-urlencoded') === -1) {
|
|
throw ono.syntax('Validation failed. %s has a file parameter, so it must consume multipart/form-data ' + 'or application/x-www-form-urlencoded', operationId);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function checkForDuplicates(params) {
|
|
for (var i = 0; i < params.length - 1; i++) {
|
|
var outer = params[i];
|
|
for (var j = i + 1; j < params.length; j++) {
|
|
var inner = params[j];
|
|
if (outer.name === inner.name && outer.in === inner.in) {
|
|
throw ono.syntax('Validation failed. Found multiple %s parameters named "%s"', outer.in, outer.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function validateResponse(code, response, responseId) {
|
|
if (code !== 'default' && (code < 100 || code > 599)) {
|
|
throw ono.syntax('Validation failed. %s has an invalid response code (%s)', responseId, code);
|
|
}
|
|
var headers = Object.keys(response.headers || {});
|
|
headers.forEach(function(headerName) {
|
|
var header = response.headers[headerName];
|
|
var headerId = responseId + '/headers/' + headerName;
|
|
validateSchema(header, headerId, primitiveTypes);
|
|
});
|
|
if (response.schema) {
|
|
var validTypes = schemaTypes.concat('file');
|
|
if (validTypes.indexOf(response.schema.type) === -1) {
|
|
throw ono.syntax('Validation failed. %s has an invalid response schema type (%s)', responseId, response.schema.type);
|
|
}
|
|
}
|
|
}
|
|
function validateSchema(schema, schemaId, validTypes) {
|
|
if (validTypes.indexOf(schema.type) === -1) {
|
|
throw ono.syntax('Validation failed. %s has an invalid type (%s)', schemaId, schema.type);
|
|
}
|
|
if (schema.type === 'array' && !schema.items) {
|
|
throw ono.syntax('Validation failed. %s is an array, so it must include an "items" schema', schemaId);
|
|
}
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("102", ["106", "107"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var debug = $__require('106'),
|
|
util = $__require('107');
|
|
exports.format = util.format;
|
|
exports.inherits = util.inherits;
|
|
exports.debug = debug('swagger:parser');
|
|
exports.swaggerParamRegExp = /\{([^/}]+)}/g;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("108", ["109", "107"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $RefParserOptions = $__require('109'),
|
|
util = $__require('107');
|
|
module.exports = ParserOptions;
|
|
function ParserOptions(options) {
|
|
this.validate = {
|
|
schema: true,
|
|
spec: true
|
|
};
|
|
$RefParserOptions.apply(this, arguments);
|
|
}
|
|
util.inherits(ParserOptions, $RefParserOptions);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10a", ["10b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = typeof Promise === 'function' ? Promise : $__require('10b').Promise;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("109", ["10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
module.exports = $RefParserOptions;
|
|
function $RefParserOptions(options) {
|
|
this.allow = {
|
|
json: true,
|
|
yaml: true,
|
|
empty: true,
|
|
unknown: true
|
|
};
|
|
this.$refs = {
|
|
internal: true,
|
|
external: true,
|
|
circular: true
|
|
};
|
|
this.cache = {
|
|
fs: 60,
|
|
http: 5 * 60,
|
|
https: 5 * 60
|
|
};
|
|
this.http = {withCredentials: true};
|
|
merge(options, this);
|
|
}
|
|
function merge(src, dest) {
|
|
if (src) {
|
|
var topKeys = Object.keys(src);
|
|
for (var i = 0; i < topKeys.length; i++) {
|
|
var topKey = topKeys[i];
|
|
var srcChild = src[topKey];
|
|
if (dest[topKey] === undefined) {
|
|
dest[topKey] = srcChild;
|
|
} else {
|
|
var childKeys = Object.keys(srcChild);
|
|
for (var j = 0; j < childKeys.length; j++) {
|
|
var childKey = childKeys[j];
|
|
var srcChildValue = srcChild[childKey];
|
|
if (srcChildValue !== undefined) {
|
|
dest[topKey][childKey] = srcChildValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10d", ["109", "10e", "101"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Options = $__require('109'),
|
|
util = $__require('10e'),
|
|
ono = $__require('101');
|
|
module.exports = $Refs;
|
|
function $Refs() {
|
|
this.circular = false;
|
|
this._$refs = {};
|
|
}
|
|
$Refs.prototype.paths = function(types) {
|
|
var paths = getPaths(this._$refs, arguments);
|
|
return paths.map(function(path) {
|
|
return path.decoded;
|
|
});
|
|
};
|
|
$Refs.prototype.values = function(types) {
|
|
var $refs = this._$refs;
|
|
var paths = getPaths($refs, arguments);
|
|
return paths.reduce(function(obj, path) {
|
|
obj[path.decoded] = $refs[path.encoded].value;
|
|
return obj;
|
|
}, {});
|
|
};
|
|
$Refs.prototype.toJSON = $Refs.prototype.values;
|
|
$Refs.prototype.isExpired = function(path) {
|
|
var $ref = this._get$Ref(path);
|
|
return $ref === undefined || $ref.isExpired();
|
|
};
|
|
$Refs.prototype.expire = function(path) {
|
|
var $ref = this._get$Ref(path);
|
|
if ($ref) {
|
|
$ref.expire();
|
|
}
|
|
};
|
|
$Refs.prototype.exists = function(path) {
|
|
try {
|
|
this._resolve(path);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
$Refs.prototype.get = function(path, options) {
|
|
return this._resolve(path, options).value;
|
|
};
|
|
$Refs.prototype.set = function(path, value, options) {
|
|
var withoutHash = util.path.stripHash(path);
|
|
var $ref = this._$refs[withoutHash];
|
|
if (!$ref) {
|
|
throw ono('Error resolving $ref pointer "%s". \n"%s" not found.', path, withoutHash);
|
|
}
|
|
options = new Options(options);
|
|
$ref.set(path, value, options);
|
|
};
|
|
$Refs.prototype._resolve = function(path, options) {
|
|
var withoutHash = util.path.stripHash(path);
|
|
var $ref = this._$refs[withoutHash];
|
|
if (!$ref) {
|
|
throw ono('Error resolving $ref pointer "%s". \n"%s" not found.', path, withoutHash);
|
|
}
|
|
options = new Options(options);
|
|
return $ref.resolve(path, options);
|
|
};
|
|
$Refs.prototype._get$Ref = function(path) {
|
|
var withoutHash = util.path.stripHash(path);
|
|
return this._$refs[withoutHash];
|
|
};
|
|
function getPaths($refs, types) {
|
|
var paths = Object.keys($refs);
|
|
types = Array.isArray(types[0]) ? types[0] : Array.prototype.slice.call(types);
|
|
if (types.length > 0 && types[0]) {
|
|
paths = paths.filter(function(key) {
|
|
return types.indexOf($refs[key].pathType) !== -1;
|
|
});
|
|
}
|
|
return paths.map(function(path) {
|
|
return {
|
|
encoded: path,
|
|
decoded: $refs[path].pathType === 'fs' ? util.path.urlToLocalPath(path) : path
|
|
};
|
|
});
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10f", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
if ($__System._nodeRequire) {
|
|
module.exports = $__System._nodeRequire('fs');
|
|
} else {
|
|
exports.readFileSync = function(address) {
|
|
var output;
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', address, false);
|
|
xhr.onreadystatechange = function(e) {
|
|
if (xhr.readyState == 4) {
|
|
var status = xhr.status;
|
|
if ((status > 399 && status < 600) || status == 400) {
|
|
throw 'File read error on ' + address;
|
|
} else
|
|
output = xhr.responseText;
|
|
}
|
|
};
|
|
xhr.send(null);
|
|
return output;
|
|
};
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("110", ["10f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('10f');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("111", ["112", "113", "114", "115", "116", "117"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports = module.exports = $__require('112');
|
|
exports.Stream = $__require('113');
|
|
exports.Readable = exports;
|
|
exports.Writable = $__require('114');
|
|
exports.Duplex = $__require('115');
|
|
exports.Transform = $__require('116');
|
|
exports.PassThrough = $__require('117');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("118", ["114"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('114');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("119", ["115"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('115');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11a", ["116"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('116');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11b", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = Array.isArray || function(arr) {
|
|
return Object.prototype.toString.call(arr) == '[object Array]';
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11c", ["11b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('11b');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11d", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function EventEmitter() {
|
|
this._events = this._events || {};
|
|
this._maxListeners = this._maxListeners || undefined;
|
|
}
|
|
module.exports = EventEmitter;
|
|
EventEmitter.EventEmitter = EventEmitter;
|
|
EventEmitter.prototype._events = undefined;
|
|
EventEmitter.prototype._maxListeners = undefined;
|
|
EventEmitter.defaultMaxListeners = 10;
|
|
EventEmitter.prototype.setMaxListeners = function(n) {
|
|
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
throw TypeError('n must be a positive number');
|
|
this._maxListeners = n;
|
|
return this;
|
|
};
|
|
EventEmitter.prototype.emit = function(type) {
|
|
var er,
|
|
handler,
|
|
len,
|
|
args,
|
|
i,
|
|
listeners;
|
|
if (!this._events)
|
|
this._events = {};
|
|
if (type === 'error') {
|
|
if (!this._events.error || (isObject(this._events.error) && !this._events.error.length)) {
|
|
er = arguments[1];
|
|
if (er instanceof Error) {
|
|
throw er;
|
|
}
|
|
throw TypeError('Uncaught, unspecified "error" event.');
|
|
}
|
|
}
|
|
handler = this._events[type];
|
|
if (isUndefined(handler))
|
|
return false;
|
|
if (isFunction(handler)) {
|
|
switch (arguments.length) {
|
|
case 1:
|
|
handler.call(this);
|
|
break;
|
|
case 2:
|
|
handler.call(this, arguments[1]);
|
|
break;
|
|
case 3:
|
|
handler.call(this, arguments[1], arguments[2]);
|
|
break;
|
|
default:
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
handler.apply(this, args);
|
|
}
|
|
} else if (isObject(handler)) {
|
|
len = arguments.length;
|
|
args = new Array(len - 1);
|
|
for (i = 1; i < len; i++)
|
|
args[i - 1] = arguments[i];
|
|
listeners = handler.slice();
|
|
len = listeners.length;
|
|
for (i = 0; i < len; i++)
|
|
listeners[i].apply(this, args);
|
|
}
|
|
return true;
|
|
};
|
|
EventEmitter.prototype.addListener = function(type, listener) {
|
|
var m;
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
if (!this._events)
|
|
this._events = {};
|
|
if (this._events.newListener)
|
|
this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener);
|
|
if (!this._events[type])
|
|
this._events[type] = listener;
|
|
else if (isObject(this._events[type]))
|
|
this._events[type].push(listener);
|
|
else
|
|
this._events[type] = [this._events[type], listener];
|
|
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
var m;
|
|
if (!isUndefined(this._maxListeners)) {
|
|
m = this._maxListeners;
|
|
} else {
|
|
m = EventEmitter.defaultMaxListeners;
|
|
}
|
|
if (m && m > 0 && this._events[type].length > m) {
|
|
this._events[type].warned = true;
|
|
console.error('(node) warning: possible EventEmitter memory ' + 'leak detected. %d listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.', this._events[type].length);
|
|
if (typeof console.trace === 'function') {
|
|
console.trace();
|
|
}
|
|
}
|
|
}
|
|
return this;
|
|
};
|
|
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
EventEmitter.prototype.once = function(type, listener) {
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
var fired = false;
|
|
function g() {
|
|
this.removeListener(type, g);
|
|
if (!fired) {
|
|
fired = true;
|
|
listener.apply(this, arguments);
|
|
}
|
|
}
|
|
g.listener = listener;
|
|
this.on(type, g);
|
|
return this;
|
|
};
|
|
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
var list,
|
|
position,
|
|
length,
|
|
i;
|
|
if (!isFunction(listener))
|
|
throw TypeError('listener must be a function');
|
|
if (!this._events || !this._events[type])
|
|
return this;
|
|
list = this._events[type];
|
|
length = list.length;
|
|
position = -1;
|
|
if (list === listener || (isFunction(list.listener) && list.listener === listener)) {
|
|
delete this._events[type];
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
} else if (isObject(list)) {
|
|
for (i = length; i-- > 0; ) {
|
|
if (list[i] === listener || (list[i].listener && list[i].listener === listener)) {
|
|
position = i;
|
|
break;
|
|
}
|
|
}
|
|
if (position < 0)
|
|
return this;
|
|
if (list.length === 1) {
|
|
list.length = 0;
|
|
delete this._events[type];
|
|
} else {
|
|
list.splice(position, 1);
|
|
}
|
|
if (this._events.removeListener)
|
|
this.emit('removeListener', type, listener);
|
|
}
|
|
return this;
|
|
};
|
|
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
var key,
|
|
listeners;
|
|
if (!this._events)
|
|
return this;
|
|
if (!this._events.removeListener) {
|
|
if (arguments.length === 0)
|
|
this._events = {};
|
|
else if (this._events[type])
|
|
delete this._events[type];
|
|
return this;
|
|
}
|
|
if (arguments.length === 0) {
|
|
for (key in this._events) {
|
|
if (key === 'removeListener')
|
|
continue;
|
|
this.removeAllListeners(key);
|
|
}
|
|
this.removeAllListeners('removeListener');
|
|
this._events = {};
|
|
return this;
|
|
}
|
|
listeners = this._events[type];
|
|
if (isFunction(listeners)) {
|
|
this.removeListener(type, listeners);
|
|
} else {
|
|
while (listeners.length)
|
|
this.removeListener(type, listeners[listeners.length - 1]);
|
|
}
|
|
delete this._events[type];
|
|
return this;
|
|
};
|
|
EventEmitter.prototype.listeners = function(type) {
|
|
var ret;
|
|
if (!this._events || !this._events[type])
|
|
ret = [];
|
|
else if (isFunction(this._events[type]))
|
|
ret = [this._events[type]];
|
|
else
|
|
ret = this._events[type].slice();
|
|
return ret;
|
|
};
|
|
EventEmitter.listenerCount = function(emitter, type) {
|
|
var ret;
|
|
if (!emitter._events || !emitter._events[type])
|
|
ret = 0;
|
|
else if (isFunction(emitter._events[type]))
|
|
ret = 1;
|
|
else
|
|
ret = emitter._events[type].length;
|
|
return ret;
|
|
};
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11e", ["11d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('11d');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("11f", ["11e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('events') : $__require('11e');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("120", ["11f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('11f');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("121", ["10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
var Buffer = $__require('10c').Buffer;
|
|
var isBufferEncoding = Buffer.isEncoding || function(encoding) {
|
|
switch (encoding && encoding.toLowerCase()) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
case 'raw':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
function assertEncoding(encoding) {
|
|
if (encoding && !isBufferEncoding(encoding)) {
|
|
throw new Error('Unknown encoding: ' + encoding);
|
|
}
|
|
}
|
|
var StringDecoder = exports.StringDecoder = function(encoding) {
|
|
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
|
assertEncoding(encoding);
|
|
switch (this.encoding) {
|
|
case 'utf8':
|
|
this.surrogateSize = 3;
|
|
break;
|
|
case 'ucs2':
|
|
case 'utf16le':
|
|
this.surrogateSize = 2;
|
|
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
break;
|
|
case 'base64':
|
|
this.surrogateSize = 3;
|
|
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
break;
|
|
default:
|
|
this.write = passThroughWrite;
|
|
return;
|
|
}
|
|
this.charBuffer = new Buffer(6);
|
|
this.charReceived = 0;
|
|
this.charLength = 0;
|
|
};
|
|
StringDecoder.prototype.write = function(buffer) {
|
|
var charStr = '';
|
|
while (this.charLength) {
|
|
var available = (buffer.length >= this.charLength - this.charReceived) ? this.charLength - this.charReceived : buffer.length;
|
|
buffer.copy(this.charBuffer, this.charReceived, 0, available);
|
|
this.charReceived += available;
|
|
if (this.charReceived < this.charLength) {
|
|
return '';
|
|
}
|
|
buffer = buffer.slice(available, buffer.length);
|
|
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
this.charLength += this.surrogateSize;
|
|
charStr = '';
|
|
continue;
|
|
}
|
|
this.charReceived = this.charLength = 0;
|
|
if (buffer.length === 0) {
|
|
return charStr;
|
|
}
|
|
break;
|
|
}
|
|
this.detectIncompleteChar(buffer);
|
|
var end = buffer.length;
|
|
if (this.charLength) {
|
|
buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
|
|
end -= this.charReceived;
|
|
}
|
|
charStr += buffer.toString(this.encoding, 0, end);
|
|
var end = charStr.length - 1;
|
|
var charCode = charStr.charCodeAt(end);
|
|
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
var size = this.surrogateSize;
|
|
this.charLength += size;
|
|
this.charReceived += size;
|
|
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
buffer.copy(this.charBuffer, 0, 0, size);
|
|
return charStr.substring(0, end);
|
|
}
|
|
return charStr;
|
|
};
|
|
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
|
for (; i > 0; i--) {
|
|
var c = buffer[buffer.length - i];
|
|
if (i == 1 && c >> 5 == 0x06) {
|
|
this.charLength = 2;
|
|
break;
|
|
}
|
|
if (i <= 2 && c >> 4 == 0x0E) {
|
|
this.charLength = 3;
|
|
break;
|
|
}
|
|
if (i <= 3 && c >> 3 == 0x1E) {
|
|
this.charLength = 4;
|
|
break;
|
|
}
|
|
}
|
|
this.charReceived = i;
|
|
};
|
|
StringDecoder.prototype.end = function(buffer) {
|
|
var res = '';
|
|
if (buffer && buffer.length)
|
|
res = this.write(buffer);
|
|
if (this.charReceived) {
|
|
var cr = this.charReceived;
|
|
var buf = this.charBuffer;
|
|
var enc = this.encoding;
|
|
res += buf.slice(0, cr).toString(enc);
|
|
}
|
|
return res;
|
|
};
|
|
function passThroughWrite(buffer) {
|
|
return buffer.toString(this.encoding);
|
|
}
|
|
function utf16DetectIncompleteChar(buffer) {
|
|
this.charReceived = buffer.length % 2;
|
|
this.charLength = this.charReceived ? 2 : 0;
|
|
}
|
|
function base64DetectIncompleteChar(buffer) {
|
|
this.charReceived = buffer.length % 3;
|
|
this.charLength = this.charReceived ? 3 : 0;
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("122", ["121"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('121');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("112", ["11c", "10c", "120", "113", "123", "124", "@empty", "115", "122", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer, process) {
|
|
module.exports = Readable;
|
|
var isArray = $__require('11c');
|
|
var Buffer = $__require('10c').Buffer;
|
|
Readable.ReadableState = ReadableState;
|
|
var EE = $__require('120').EventEmitter;
|
|
if (!EE.listenerCount)
|
|
EE.listenerCount = function(emitter, type) {
|
|
return emitter.listeners(type).length;
|
|
};
|
|
var Stream = $__require('113');
|
|
var util = $__require('123');
|
|
util.inherits = $__require('124');
|
|
var StringDecoder;
|
|
var debug = $__require('@empty');
|
|
if (debug && debug.debuglog) {
|
|
debug = debug.debuglog('stream');
|
|
} else {
|
|
debug = function() {};
|
|
}
|
|
util.inherits(Readable, Stream);
|
|
function ReadableState(options, stream) {
|
|
var Duplex = $__require('115');
|
|
options = options || {};
|
|
var hwm = options.highWaterMark;
|
|
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
this.buffer = [];
|
|
this.length = 0;
|
|
this.pipes = null;
|
|
this.pipesCount = 0;
|
|
this.flowing = null;
|
|
this.ended = false;
|
|
this.endEmitted = false;
|
|
this.reading = false;
|
|
this.sync = true;
|
|
this.needReadable = false;
|
|
this.emittedReadable = false;
|
|
this.readableListening = false;
|
|
this.objectMode = !!options.objectMode;
|
|
if (stream instanceof Duplex)
|
|
this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
this.ranOut = false;
|
|
this.awaitDrain = 0;
|
|
this.readingMore = false;
|
|
this.decoder = null;
|
|
this.encoding = null;
|
|
if (options.encoding) {
|
|
if (!StringDecoder)
|
|
StringDecoder = $__require('122').StringDecoder;
|
|
this.decoder = new StringDecoder(options.encoding);
|
|
this.encoding = options.encoding;
|
|
}
|
|
}
|
|
function Readable(options) {
|
|
var Duplex = $__require('115');
|
|
if (!(this instanceof Readable))
|
|
return new Readable(options);
|
|
this._readableState = new ReadableState(options, this);
|
|
this.readable = true;
|
|
Stream.call(this);
|
|
}
|
|
Readable.prototype.push = function(chunk, encoding) {
|
|
var state = this._readableState;
|
|
if (util.isString(chunk) && !state.objectMode) {
|
|
encoding = encoding || state.defaultEncoding;
|
|
if (encoding !== state.encoding) {
|
|
chunk = new Buffer(chunk, encoding);
|
|
encoding = '';
|
|
}
|
|
}
|
|
return readableAddChunk(this, state, chunk, encoding, false);
|
|
};
|
|
Readable.prototype.unshift = function(chunk) {
|
|
var state = this._readableState;
|
|
return readableAddChunk(this, state, chunk, '', true);
|
|
};
|
|
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
|
var er = chunkInvalid(state, chunk);
|
|
if (er) {
|
|
stream.emit('error', er);
|
|
} else if (util.isNullOrUndefined(chunk)) {
|
|
state.reading = false;
|
|
if (!state.ended)
|
|
onEofChunk(stream, state);
|
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
if (state.ended && !addToFront) {
|
|
var e = new Error('stream.push() after EOF');
|
|
stream.emit('error', e);
|
|
} else if (state.endEmitted && addToFront) {
|
|
var e = new Error('stream.unshift() after end event');
|
|
stream.emit('error', e);
|
|
} else {
|
|
if (state.decoder && !addToFront && !encoding)
|
|
chunk = state.decoder.write(chunk);
|
|
if (!addToFront)
|
|
state.reading = false;
|
|
if (state.flowing && state.length === 0 && !state.sync) {
|
|
stream.emit('data', chunk);
|
|
stream.read(0);
|
|
} else {
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
if (addToFront)
|
|
state.buffer.unshift(chunk);
|
|
else
|
|
state.buffer.push(chunk);
|
|
if (state.needReadable)
|
|
emitReadable(stream);
|
|
}
|
|
maybeReadMore(stream, state);
|
|
}
|
|
} else if (!addToFront) {
|
|
state.reading = false;
|
|
}
|
|
return needMoreData(state);
|
|
}
|
|
function needMoreData(state) {
|
|
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
}
|
|
Readable.prototype.setEncoding = function(enc) {
|
|
if (!StringDecoder)
|
|
StringDecoder = $__require('122').StringDecoder;
|
|
this._readableState.decoder = new StringDecoder(enc);
|
|
this._readableState.encoding = enc;
|
|
return this;
|
|
};
|
|
var MAX_HWM = 0x800000;
|
|
function roundUpToNextPowerOf2(n) {
|
|
if (n >= MAX_HWM) {
|
|
n = MAX_HWM;
|
|
} else {
|
|
n--;
|
|
for (var p = 1; p < 32; p <<= 1)
|
|
n |= n >> p;
|
|
n++;
|
|
}
|
|
return n;
|
|
}
|
|
function howMuchToRead(n, state) {
|
|
if (state.length === 0 && state.ended)
|
|
return 0;
|
|
if (state.objectMode)
|
|
return n === 0 ? 0 : 1;
|
|
if (isNaN(n) || util.isNull(n)) {
|
|
if (state.flowing && state.buffer.length)
|
|
return state.buffer[0].length;
|
|
else
|
|
return state.length;
|
|
}
|
|
if (n <= 0)
|
|
return 0;
|
|
if (n > state.highWaterMark)
|
|
state.highWaterMark = roundUpToNextPowerOf2(n);
|
|
if (n > state.length) {
|
|
if (!state.ended) {
|
|
state.needReadable = true;
|
|
return 0;
|
|
} else
|
|
return state.length;
|
|
}
|
|
return n;
|
|
}
|
|
Readable.prototype.read = function(n) {
|
|
debug('read', n);
|
|
var state = this._readableState;
|
|
var nOrig = n;
|
|
if (!util.isNumber(n) || n > 0)
|
|
state.emittedReadable = false;
|
|
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
debug('read: emitReadable', state.length, state.ended);
|
|
if (state.length === 0 && state.ended)
|
|
endReadable(this);
|
|
else
|
|
emitReadable(this);
|
|
return null;
|
|
}
|
|
n = howMuchToRead(n, state);
|
|
if (n === 0 && state.ended) {
|
|
if (state.length === 0)
|
|
endReadable(this);
|
|
return null;
|
|
}
|
|
var doRead = state.needReadable;
|
|
debug('need readable', doRead);
|
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
doRead = true;
|
|
debug('length less than watermark', doRead);
|
|
}
|
|
if (state.ended || state.reading) {
|
|
doRead = false;
|
|
debug('reading or ended', doRead);
|
|
}
|
|
if (doRead) {
|
|
debug('do read');
|
|
state.reading = true;
|
|
state.sync = true;
|
|
if (state.length === 0)
|
|
state.needReadable = true;
|
|
this._read(state.highWaterMark);
|
|
state.sync = false;
|
|
}
|
|
if (doRead && !state.reading)
|
|
n = howMuchToRead(nOrig, state);
|
|
var ret;
|
|
if (n > 0)
|
|
ret = fromList(n, state);
|
|
else
|
|
ret = null;
|
|
if (util.isNull(ret)) {
|
|
state.needReadable = true;
|
|
n = 0;
|
|
}
|
|
state.length -= n;
|
|
if (state.length === 0 && !state.ended)
|
|
state.needReadable = true;
|
|
if (nOrig !== n && state.ended && state.length === 0)
|
|
endReadable(this);
|
|
if (!util.isNull(ret))
|
|
this.emit('data', ret);
|
|
return ret;
|
|
};
|
|
function chunkInvalid(state, chunk) {
|
|
var er = null;
|
|
if (!util.isBuffer(chunk) && !util.isString(chunk) && !util.isNullOrUndefined(chunk) && !state.objectMode) {
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
}
|
|
return er;
|
|
}
|
|
function onEofChunk(stream, state) {
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length) {
|
|
state.buffer.push(chunk);
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
}
|
|
}
|
|
state.ended = true;
|
|
emitReadable(stream);
|
|
}
|
|
function emitReadable(stream) {
|
|
var state = stream._readableState;
|
|
state.needReadable = false;
|
|
if (!state.emittedReadable) {
|
|
debug('emitReadable', state.flowing);
|
|
state.emittedReadable = true;
|
|
if (state.sync)
|
|
process.nextTick(function() {
|
|
emitReadable_(stream);
|
|
});
|
|
else
|
|
emitReadable_(stream);
|
|
}
|
|
}
|
|
function emitReadable_(stream) {
|
|
debug('emit readable');
|
|
stream.emit('readable');
|
|
flow(stream);
|
|
}
|
|
function maybeReadMore(stream, state) {
|
|
if (!state.readingMore) {
|
|
state.readingMore = true;
|
|
process.nextTick(function() {
|
|
maybeReadMore_(stream, state);
|
|
});
|
|
}
|
|
}
|
|
function maybeReadMore_(stream, state) {
|
|
var len = state.length;
|
|
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
debug('maybeReadMore read 0');
|
|
stream.read(0);
|
|
if (len === state.length)
|
|
break;
|
|
else
|
|
len = state.length;
|
|
}
|
|
state.readingMore = false;
|
|
}
|
|
Readable.prototype._read = function(n) {
|
|
this.emit('error', new Error('not implemented'));
|
|
};
|
|
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
var src = this;
|
|
var state = this._readableState;
|
|
switch (state.pipesCount) {
|
|
case 0:
|
|
state.pipes = dest;
|
|
break;
|
|
case 1:
|
|
state.pipes = [state.pipes, dest];
|
|
break;
|
|
default:
|
|
state.pipes.push(dest);
|
|
break;
|
|
}
|
|
state.pipesCount += 1;
|
|
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
var endFn = doEnd ? onend : cleanup;
|
|
if (state.endEmitted)
|
|
process.nextTick(endFn);
|
|
else
|
|
src.once('end', endFn);
|
|
dest.on('unpipe', onunpipe);
|
|
function onunpipe(readable) {
|
|
debug('onunpipe');
|
|
if (readable === src) {
|
|
cleanup();
|
|
}
|
|
}
|
|
function onend() {
|
|
debug('onend');
|
|
dest.end();
|
|
}
|
|
var ondrain = pipeOnDrain(src);
|
|
dest.on('drain', ondrain);
|
|
function cleanup() {
|
|
debug('cleanup');
|
|
dest.removeListener('close', onclose);
|
|
dest.removeListener('finish', onfinish);
|
|
dest.removeListener('drain', ondrain);
|
|
dest.removeListener('error', onerror);
|
|
dest.removeListener('unpipe', onunpipe);
|
|
src.removeListener('end', onend);
|
|
src.removeListener('end', cleanup);
|
|
src.removeListener('data', ondata);
|
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain))
|
|
ondrain();
|
|
}
|
|
src.on('data', ondata);
|
|
function ondata(chunk) {
|
|
debug('ondata');
|
|
var ret = dest.write(chunk);
|
|
if (false === ret) {
|
|
debug('false write response, pause', src._readableState.awaitDrain);
|
|
src._readableState.awaitDrain++;
|
|
src.pause();
|
|
}
|
|
}
|
|
function onerror(er) {
|
|
debug('onerror', er);
|
|
unpipe();
|
|
dest.removeListener('error', onerror);
|
|
if (EE.listenerCount(dest, 'error') === 0)
|
|
dest.emit('error', er);
|
|
}
|
|
if (!dest._events || !dest._events.error)
|
|
dest.on('error', onerror);
|
|
else if (isArray(dest._events.error))
|
|
dest._events.error.unshift(onerror);
|
|
else
|
|
dest._events.error = [onerror, dest._events.error];
|
|
function onclose() {
|
|
dest.removeListener('finish', onfinish);
|
|
unpipe();
|
|
}
|
|
dest.once('close', onclose);
|
|
function onfinish() {
|
|
debug('onfinish');
|
|
dest.removeListener('close', onclose);
|
|
unpipe();
|
|
}
|
|
dest.once('finish', onfinish);
|
|
function unpipe() {
|
|
debug('unpipe');
|
|
src.unpipe(dest);
|
|
}
|
|
dest.emit('pipe', src);
|
|
if (!state.flowing) {
|
|
debug('pipe resume');
|
|
src.resume();
|
|
}
|
|
return dest;
|
|
};
|
|
function pipeOnDrain(src) {
|
|
return function() {
|
|
var state = src._readableState;
|
|
debug('pipeOnDrain', state.awaitDrain);
|
|
if (state.awaitDrain)
|
|
state.awaitDrain--;
|
|
if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
|
|
state.flowing = true;
|
|
flow(src);
|
|
}
|
|
};
|
|
}
|
|
Readable.prototype.unpipe = function(dest) {
|
|
var state = this._readableState;
|
|
if (state.pipesCount === 0)
|
|
return this;
|
|
if (state.pipesCount === 1) {
|
|
if (dest && dest !== state.pipes)
|
|
return this;
|
|
if (!dest)
|
|
dest = state.pipes;
|
|
state.pipes = null;
|
|
state.pipesCount = 0;
|
|
state.flowing = false;
|
|
if (dest)
|
|
dest.emit('unpipe', this);
|
|
return this;
|
|
}
|
|
if (!dest) {
|
|
var dests = state.pipes;
|
|
var len = state.pipesCount;
|
|
state.pipes = null;
|
|
state.pipesCount = 0;
|
|
state.flowing = false;
|
|
for (var i = 0; i < len; i++)
|
|
dests[i].emit('unpipe', this);
|
|
return this;
|
|
}
|
|
var i = indexOf(state.pipes, dest);
|
|
if (i === -1)
|
|
return this;
|
|
state.pipes.splice(i, 1);
|
|
state.pipesCount -= 1;
|
|
if (state.pipesCount === 1)
|
|
state.pipes = state.pipes[0];
|
|
dest.emit('unpipe', this);
|
|
return this;
|
|
};
|
|
Readable.prototype.on = function(ev, fn) {
|
|
var res = Stream.prototype.on.call(this, ev, fn);
|
|
if (ev === 'data' && false !== this._readableState.flowing) {
|
|
this.resume();
|
|
}
|
|
if (ev === 'readable' && this.readable) {
|
|
var state = this._readableState;
|
|
if (!state.readableListening) {
|
|
state.readableListening = true;
|
|
state.emittedReadable = false;
|
|
state.needReadable = true;
|
|
if (!state.reading) {
|
|
var self = this;
|
|
process.nextTick(function() {
|
|
debug('readable nexttick read 0');
|
|
self.read(0);
|
|
});
|
|
} else if (state.length) {
|
|
emitReadable(this, state);
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
Readable.prototype.resume = function() {
|
|
var state = this._readableState;
|
|
if (!state.flowing) {
|
|
debug('resume');
|
|
state.flowing = true;
|
|
if (!state.reading) {
|
|
debug('resume read 0');
|
|
this.read(0);
|
|
}
|
|
resume(this, state);
|
|
}
|
|
return this;
|
|
};
|
|
function resume(stream, state) {
|
|
if (!state.resumeScheduled) {
|
|
state.resumeScheduled = true;
|
|
process.nextTick(function() {
|
|
resume_(stream, state);
|
|
});
|
|
}
|
|
}
|
|
function resume_(stream, state) {
|
|
state.resumeScheduled = false;
|
|
stream.emit('resume');
|
|
flow(stream);
|
|
if (state.flowing && !state.reading)
|
|
stream.read(0);
|
|
}
|
|
Readable.prototype.pause = function() {
|
|
debug('call pause flowing=%j', this._readableState.flowing);
|
|
if (false !== this._readableState.flowing) {
|
|
debug('pause');
|
|
this._readableState.flowing = false;
|
|
this.emit('pause');
|
|
}
|
|
return this;
|
|
};
|
|
function flow(stream) {
|
|
var state = stream._readableState;
|
|
debug('flow', state.flowing);
|
|
if (state.flowing) {
|
|
do {
|
|
var chunk = stream.read();
|
|
} while (null !== chunk && state.flowing);
|
|
}
|
|
}
|
|
Readable.prototype.wrap = function(stream) {
|
|
var state = this._readableState;
|
|
var paused = false;
|
|
var self = this;
|
|
stream.on('end', function() {
|
|
debug('wrapped end');
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length)
|
|
self.push(chunk);
|
|
}
|
|
self.push(null);
|
|
});
|
|
stream.on('data', function(chunk) {
|
|
debug('wrapped data');
|
|
if (state.decoder)
|
|
chunk = state.decoder.write(chunk);
|
|
if (!chunk || !state.objectMode && !chunk.length)
|
|
return;
|
|
var ret = self.push(chunk);
|
|
if (!ret) {
|
|
paused = true;
|
|
stream.pause();
|
|
}
|
|
});
|
|
for (var i in stream) {
|
|
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
|
|
this[i] = function(method) {
|
|
return function() {
|
|
return stream[method].apply(stream, arguments);
|
|
};
|
|
}(i);
|
|
}
|
|
}
|
|
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
forEach(events, function(ev) {
|
|
stream.on(ev, self.emit.bind(self, ev));
|
|
});
|
|
self._read = function(n) {
|
|
debug('wrapped _read', n);
|
|
if (paused) {
|
|
paused = false;
|
|
stream.resume();
|
|
}
|
|
};
|
|
return self;
|
|
};
|
|
Readable._fromList = fromList;
|
|
function fromList(n, state) {
|
|
var list = state.buffer;
|
|
var length = state.length;
|
|
var stringMode = !!state.decoder;
|
|
var objectMode = !!state.objectMode;
|
|
var ret;
|
|
if (list.length === 0)
|
|
return null;
|
|
if (length === 0)
|
|
ret = null;
|
|
else if (objectMode)
|
|
ret = list.shift();
|
|
else if (!n || n >= length) {
|
|
if (stringMode)
|
|
ret = list.join('');
|
|
else
|
|
ret = Buffer.concat(list, length);
|
|
list.length = 0;
|
|
} else {
|
|
if (n < list[0].length) {
|
|
var buf = list[0];
|
|
ret = buf.slice(0, n);
|
|
list[0] = buf.slice(n);
|
|
} else if (n === list[0].length) {
|
|
ret = list.shift();
|
|
} else {
|
|
if (stringMode)
|
|
ret = '';
|
|
else
|
|
ret = new Buffer(n);
|
|
var c = 0;
|
|
for (var i = 0,
|
|
l = list.length; i < l && c < n; i++) {
|
|
var buf = list[0];
|
|
var cpy = Math.min(n - c, buf.length);
|
|
if (stringMode)
|
|
ret += buf.slice(0, cpy);
|
|
else
|
|
buf.copy(ret, c, 0, cpy);
|
|
if (cpy < buf.length)
|
|
list[0] = buf.slice(cpy);
|
|
else
|
|
list.shift();
|
|
c += cpy;
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function endReadable(stream) {
|
|
var state = stream._readableState;
|
|
if (state.length > 0)
|
|
throw new Error('endReadable called on non-empty stream');
|
|
if (!state.endEmitted) {
|
|
state.ended = true;
|
|
process.nextTick(function() {
|
|
if (!state.endEmitted && state.length === 0) {
|
|
state.endEmitted = true;
|
|
stream.readable = false;
|
|
stream.emit('end');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function forEach(xs, f) {
|
|
for (var i = 0,
|
|
l = xs.length; i < l; i++) {
|
|
f(xs[i], i);
|
|
}
|
|
}
|
|
function indexOf(xs, x) {
|
|
for (var i = 0,
|
|
l = xs.length; i < l; i++) {
|
|
if (xs[i] === x)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
})($__require('10c').Buffer, $__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("114", ["10c", "123", "124", "113", "115", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer, process) {
|
|
module.exports = Writable;
|
|
var Buffer = $__require('10c').Buffer;
|
|
Writable.WritableState = WritableState;
|
|
var util = $__require('123');
|
|
util.inherits = $__require('124');
|
|
var Stream = $__require('113');
|
|
util.inherits(Writable, Stream);
|
|
function WriteReq(chunk, encoding, cb) {
|
|
this.chunk = chunk;
|
|
this.encoding = encoding;
|
|
this.callback = cb;
|
|
}
|
|
function WritableState(options, stream) {
|
|
var Duplex = $__require('115');
|
|
options = options || {};
|
|
var hwm = options.highWaterMark;
|
|
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
|
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
|
this.objectMode = !!options.objectMode;
|
|
if (stream instanceof Duplex)
|
|
this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
this.highWaterMark = ~~this.highWaterMark;
|
|
this.needDrain = false;
|
|
this.ending = false;
|
|
this.ended = false;
|
|
this.finished = false;
|
|
var noDecode = options.decodeStrings === false;
|
|
this.decodeStrings = !noDecode;
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
this.length = 0;
|
|
this.writing = false;
|
|
this.corked = 0;
|
|
this.sync = true;
|
|
this.bufferProcessing = false;
|
|
this.onwrite = function(er) {
|
|
onwrite(stream, er);
|
|
};
|
|
this.writecb = null;
|
|
this.writelen = 0;
|
|
this.buffer = [];
|
|
this.pendingcb = 0;
|
|
this.prefinished = false;
|
|
this.errorEmitted = false;
|
|
}
|
|
function Writable(options) {
|
|
var Duplex = $__require('115');
|
|
if (!(this instanceof Writable) && !(this instanceof Duplex))
|
|
return new Writable(options);
|
|
this._writableState = new WritableState(options, this);
|
|
this.writable = true;
|
|
Stream.call(this);
|
|
}
|
|
Writable.prototype.pipe = function() {
|
|
this.emit('error', new Error('Cannot pipe. Not readable.'));
|
|
};
|
|
function writeAfterEnd(stream, state, cb) {
|
|
var er = new Error('write after end');
|
|
stream.emit('error', er);
|
|
process.nextTick(function() {
|
|
cb(er);
|
|
});
|
|
}
|
|
function validChunk(stream, state, chunk, cb) {
|
|
var valid = true;
|
|
if (!util.isBuffer(chunk) && !util.isString(chunk) && !util.isNullOrUndefined(chunk) && !state.objectMode) {
|
|
var er = new TypeError('Invalid non-string/buffer chunk');
|
|
stream.emit('error', er);
|
|
process.nextTick(function() {
|
|
cb(er);
|
|
});
|
|
valid = false;
|
|
}
|
|
return valid;
|
|
}
|
|
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
var ret = false;
|
|
if (util.isFunction(encoding)) {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
if (util.isBuffer(chunk))
|
|
encoding = 'buffer';
|
|
else if (!encoding)
|
|
encoding = state.defaultEncoding;
|
|
if (!util.isFunction(cb))
|
|
cb = function() {};
|
|
if (state.ended)
|
|
writeAfterEnd(this, state, cb);
|
|
else if (validChunk(this, state, chunk, cb)) {
|
|
state.pendingcb++;
|
|
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
|
}
|
|
return ret;
|
|
};
|
|
Writable.prototype.cork = function() {
|
|
var state = this._writableState;
|
|
state.corked++;
|
|
};
|
|
Writable.prototype.uncork = function() {
|
|
var state = this._writableState;
|
|
if (state.corked) {
|
|
state.corked--;
|
|
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.buffer.length)
|
|
clearBuffer(this, state);
|
|
}
|
|
};
|
|
function decodeChunk(state, chunk, encoding) {
|
|
if (!state.objectMode && state.decodeStrings !== false && util.isString(chunk)) {
|
|
chunk = new Buffer(chunk, encoding);
|
|
}
|
|
return chunk;
|
|
}
|
|
function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
|
chunk = decodeChunk(state, chunk, encoding);
|
|
if (util.isBuffer(chunk))
|
|
encoding = 'buffer';
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
state.length += len;
|
|
var ret = state.length < state.highWaterMark;
|
|
if (!ret)
|
|
state.needDrain = true;
|
|
if (state.writing || state.corked)
|
|
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
|
else
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
return ret;
|
|
}
|
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
state.writelen = len;
|
|
state.writecb = cb;
|
|
state.writing = true;
|
|
state.sync = true;
|
|
if (writev)
|
|
stream._writev(chunk, state.onwrite);
|
|
else
|
|
stream._write(chunk, encoding, state.onwrite);
|
|
state.sync = false;
|
|
}
|
|
function onwriteError(stream, state, sync, er, cb) {
|
|
if (sync)
|
|
process.nextTick(function() {
|
|
state.pendingcb--;
|
|
cb(er);
|
|
});
|
|
else {
|
|
state.pendingcb--;
|
|
cb(er);
|
|
}
|
|
stream._writableState.errorEmitted = true;
|
|
stream.emit('error', er);
|
|
}
|
|
function onwriteStateUpdate(state) {
|
|
state.writing = false;
|
|
state.writecb = null;
|
|
state.length -= state.writelen;
|
|
state.writelen = 0;
|
|
}
|
|
function onwrite(stream, er) {
|
|
var state = stream._writableState;
|
|
var sync = state.sync;
|
|
var cb = state.writecb;
|
|
onwriteStateUpdate(state);
|
|
if (er)
|
|
onwriteError(stream, state, sync, er, cb);
|
|
else {
|
|
var finished = needFinish(stream, state);
|
|
if (!finished && !state.corked && !state.bufferProcessing && state.buffer.length) {
|
|
clearBuffer(stream, state);
|
|
}
|
|
if (sync) {
|
|
process.nextTick(function() {
|
|
afterWrite(stream, state, finished, cb);
|
|
});
|
|
} else {
|
|
afterWrite(stream, state, finished, cb);
|
|
}
|
|
}
|
|
}
|
|
function afterWrite(stream, state, finished, cb) {
|
|
if (!finished)
|
|
onwriteDrain(stream, state);
|
|
state.pendingcb--;
|
|
cb();
|
|
finishMaybe(stream, state);
|
|
}
|
|
function onwriteDrain(stream, state) {
|
|
if (state.length === 0 && state.needDrain) {
|
|
state.needDrain = false;
|
|
stream.emit('drain');
|
|
}
|
|
}
|
|
function clearBuffer(stream, state) {
|
|
state.bufferProcessing = true;
|
|
if (stream._writev && state.buffer.length > 1) {
|
|
var cbs = [];
|
|
for (var c = 0; c < state.buffer.length; c++)
|
|
cbs.push(state.buffer[c].callback);
|
|
state.pendingcb++;
|
|
doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
|
|
for (var i = 0; i < cbs.length; i++) {
|
|
state.pendingcb--;
|
|
cbs[i](err);
|
|
}
|
|
});
|
|
state.buffer = [];
|
|
} else {
|
|
for (var c = 0; c < state.buffer.length; c++) {
|
|
var entry = state.buffer[c];
|
|
var chunk = entry.chunk;
|
|
var encoding = entry.encoding;
|
|
var cb = entry.callback;
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
if (state.writing) {
|
|
c++;
|
|
break;
|
|
}
|
|
}
|
|
if (c < state.buffer.length)
|
|
state.buffer = state.buffer.slice(c);
|
|
else
|
|
state.buffer.length = 0;
|
|
}
|
|
state.bufferProcessing = false;
|
|
}
|
|
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
cb(new Error('not implemented'));
|
|
};
|
|
Writable.prototype._writev = null;
|
|
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
if (util.isFunction(chunk)) {
|
|
cb = chunk;
|
|
chunk = null;
|
|
encoding = null;
|
|
} else if (util.isFunction(encoding)) {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
if (!util.isNullOrUndefined(chunk))
|
|
this.write(chunk, encoding);
|
|
if (state.corked) {
|
|
state.corked = 1;
|
|
this.uncork();
|
|
}
|
|
if (!state.ending && !state.finished)
|
|
endWritable(this, state, cb);
|
|
};
|
|
function needFinish(stream, state) {
|
|
return (state.ending && state.length === 0 && !state.finished && !state.writing);
|
|
}
|
|
function prefinish(stream, state) {
|
|
if (!state.prefinished) {
|
|
state.prefinished = true;
|
|
stream.emit('prefinish');
|
|
}
|
|
}
|
|
function finishMaybe(stream, state) {
|
|
var need = needFinish(stream, state);
|
|
if (need) {
|
|
if (state.pendingcb === 0) {
|
|
prefinish(stream, state);
|
|
state.finished = true;
|
|
stream.emit('finish');
|
|
} else
|
|
prefinish(stream, state);
|
|
}
|
|
return need;
|
|
}
|
|
function endWritable(stream, state, cb) {
|
|
state.ending = true;
|
|
finishMaybe(stream, state);
|
|
if (cb) {
|
|
if (state.finished)
|
|
process.nextTick(cb);
|
|
else
|
|
stream.once('finish', cb);
|
|
}
|
|
state.ended = true;
|
|
}
|
|
})($__require('10c').Buffer, $__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("115", ["123", "124", "112", "114", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
module.exports = Duplex;
|
|
var objectKeys = Object.keys || function(obj) {
|
|
var keys = [];
|
|
for (var key in obj)
|
|
keys.push(key);
|
|
return keys;
|
|
};
|
|
var util = $__require('123');
|
|
util.inherits = $__require('124');
|
|
var Readable = $__require('112');
|
|
var Writable = $__require('114');
|
|
util.inherits(Duplex, Readable);
|
|
forEach(objectKeys(Writable.prototype), function(method) {
|
|
if (!Duplex.prototype[method])
|
|
Duplex.prototype[method] = Writable.prototype[method];
|
|
});
|
|
function Duplex(options) {
|
|
if (!(this instanceof Duplex))
|
|
return new Duplex(options);
|
|
Readable.call(this, options);
|
|
Writable.call(this, options);
|
|
if (options && options.readable === false)
|
|
this.readable = false;
|
|
if (options && options.writable === false)
|
|
this.writable = false;
|
|
this.allowHalfOpen = true;
|
|
if (options && options.allowHalfOpen === false)
|
|
this.allowHalfOpen = false;
|
|
this.once('end', onend);
|
|
}
|
|
function onend() {
|
|
if (this.allowHalfOpen || this._writableState.ended)
|
|
return;
|
|
process.nextTick(this.end.bind(this));
|
|
}
|
|
function forEach(xs, f) {
|
|
for (var i = 0,
|
|
l = xs.length; i < l; i++) {
|
|
f(xs[i], i);
|
|
}
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("116", ["115", "123", "124", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
module.exports = Transform;
|
|
var Duplex = $__require('115');
|
|
var util = $__require('123');
|
|
util.inherits = $__require('124');
|
|
util.inherits(Transform, Duplex);
|
|
function TransformState(options, stream) {
|
|
this.afterTransform = function(er, data) {
|
|
return afterTransform(stream, er, data);
|
|
};
|
|
this.needTransform = false;
|
|
this.transforming = false;
|
|
this.writecb = null;
|
|
this.writechunk = null;
|
|
}
|
|
function afterTransform(stream, er, data) {
|
|
var ts = stream._transformState;
|
|
ts.transforming = false;
|
|
var cb = ts.writecb;
|
|
if (!cb)
|
|
return stream.emit('error', new Error('no writecb in Transform class'));
|
|
ts.writechunk = null;
|
|
ts.writecb = null;
|
|
if (!util.isNullOrUndefined(data))
|
|
stream.push(data);
|
|
if (cb)
|
|
cb(er);
|
|
var rs = stream._readableState;
|
|
rs.reading = false;
|
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
stream._read(rs.highWaterMark);
|
|
}
|
|
}
|
|
function Transform(options) {
|
|
if (!(this instanceof Transform))
|
|
return new Transform(options);
|
|
Duplex.call(this, options);
|
|
this._transformState = new TransformState(options, this);
|
|
var stream = this;
|
|
this._readableState.needReadable = true;
|
|
this._readableState.sync = false;
|
|
this.once('prefinish', function() {
|
|
if (util.isFunction(this._flush))
|
|
this._flush(function(er) {
|
|
done(stream, er);
|
|
});
|
|
else
|
|
done(stream);
|
|
});
|
|
}
|
|
Transform.prototype.push = function(chunk, encoding) {
|
|
this._transformState.needTransform = false;
|
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
};
|
|
Transform.prototype._transform = function(chunk, encoding, cb) {
|
|
throw new Error('not implemented');
|
|
};
|
|
Transform.prototype._write = function(chunk, encoding, cb) {
|
|
var ts = this._transformState;
|
|
ts.writecb = cb;
|
|
ts.writechunk = chunk;
|
|
ts.writeencoding = encoding;
|
|
if (!ts.transforming) {
|
|
var rs = this._readableState;
|
|
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark)
|
|
this._read(rs.highWaterMark);
|
|
}
|
|
};
|
|
Transform.prototype._read = function(n) {
|
|
var ts = this._transformState;
|
|
if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
|
|
ts.transforming = true;
|
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
} else {
|
|
ts.needTransform = true;
|
|
}
|
|
};
|
|
function done(stream, er) {
|
|
if (er)
|
|
return stream.emit('error', er);
|
|
var ws = stream._writableState;
|
|
var ts = stream._transformState;
|
|
if (ws.length)
|
|
throw new Error('calling transform done when ws.length != 0');
|
|
if (ts.transforming)
|
|
throw new Error('calling transform done when still transforming');
|
|
return stream.push(null);
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("125", ["10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
function isArray(arg) {
|
|
if (Array.isArray) {
|
|
return Array.isArray(arg);
|
|
}
|
|
return objectToString(arg) === '[object Array]';
|
|
}
|
|
exports.isArray = isArray;
|
|
function isBoolean(arg) {
|
|
return typeof arg === 'boolean';
|
|
}
|
|
exports.isBoolean = isBoolean;
|
|
function isNull(arg) {
|
|
return arg === null;
|
|
}
|
|
exports.isNull = isNull;
|
|
function isNullOrUndefined(arg) {
|
|
return arg == null;
|
|
}
|
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
exports.isNumber = isNumber;
|
|
function isString(arg) {
|
|
return typeof arg === 'string';
|
|
}
|
|
exports.isString = isString;
|
|
function isSymbol(arg) {
|
|
return typeof arg === 'symbol';
|
|
}
|
|
exports.isSymbol = isSymbol;
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
exports.isUndefined = isUndefined;
|
|
function isRegExp(re) {
|
|
return objectToString(re) === '[object RegExp]';
|
|
}
|
|
exports.isRegExp = isRegExp;
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
exports.isObject = isObject;
|
|
function isDate(d) {
|
|
return objectToString(d) === '[object Date]';
|
|
}
|
|
exports.isDate = isDate;
|
|
function isError(e) {
|
|
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
}
|
|
exports.isError = isError;
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
exports.isFunction = isFunction;
|
|
function isPrimitive(arg) {
|
|
return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || typeof arg === 'undefined';
|
|
}
|
|
exports.isPrimitive = isPrimitive;
|
|
exports.isBuffer = Buffer.isBuffer;
|
|
function objectToString(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("123", ["125"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('125');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("117", ["116", "123", "124"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = PassThrough;
|
|
var Transform = $__require('116');
|
|
var util = $__require('123');
|
|
util.inherits = $__require('124');
|
|
util.inherits(PassThrough, Transform);
|
|
function PassThrough(options) {
|
|
if (!(this instanceof PassThrough))
|
|
return new PassThrough(options);
|
|
Transform.call(this, options);
|
|
}
|
|
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
|
cb(null, chunk);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("126", ["117"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('117');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("113", ["120", "124", "111", "118", "119", "11a", "126"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = Stream;
|
|
var EE = $__require('120').EventEmitter;
|
|
var inherits = $__require('124');
|
|
inherits(Stream, EE);
|
|
Stream.Readable = $__require('111');
|
|
Stream.Writable = $__require('118');
|
|
Stream.Duplex = $__require('119');
|
|
Stream.Transform = $__require('11a');
|
|
Stream.PassThrough = $__require('126');
|
|
Stream.Stream = Stream;
|
|
function Stream() {
|
|
EE.call(this);
|
|
}
|
|
Stream.prototype.pipe = function(dest, options) {
|
|
var source = this;
|
|
function ondata(chunk) {
|
|
if (dest.writable) {
|
|
if (false === dest.write(chunk) && source.pause) {
|
|
source.pause();
|
|
}
|
|
}
|
|
}
|
|
source.on('data', ondata);
|
|
function ondrain() {
|
|
if (source.readable && source.resume) {
|
|
source.resume();
|
|
}
|
|
}
|
|
dest.on('drain', ondrain);
|
|
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
source.on('end', onend);
|
|
source.on('close', onclose);
|
|
}
|
|
var didOnEnd = false;
|
|
function onend() {
|
|
if (didOnEnd)
|
|
return;
|
|
didOnEnd = true;
|
|
dest.end();
|
|
}
|
|
function onclose() {
|
|
if (didOnEnd)
|
|
return;
|
|
didOnEnd = true;
|
|
if (typeof dest.destroy === 'function')
|
|
dest.destroy();
|
|
}
|
|
function onerror(er) {
|
|
cleanup();
|
|
if (EE.listenerCount(this, 'error') === 0) {
|
|
throw er;
|
|
}
|
|
}
|
|
source.on('error', onerror);
|
|
dest.on('error', onerror);
|
|
function cleanup() {
|
|
source.removeListener('data', ondata);
|
|
dest.removeListener('drain', ondrain);
|
|
source.removeListener('end', onend);
|
|
source.removeListener('close', onclose);
|
|
source.removeListener('error', onerror);
|
|
dest.removeListener('error', onerror);
|
|
source.removeListener('end', cleanup);
|
|
source.removeListener('close', cleanup);
|
|
dest.removeListener('close', cleanup);
|
|
}
|
|
source.on('end', cleanup);
|
|
source.on('close', cleanup);
|
|
dest.on('close', cleanup);
|
|
dest.emit('pipe', source);
|
|
return dest;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("127", ["113"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('113');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("128", ["127"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('stream') : $__require('127');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("129", ["128"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('128');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12a", ["129", "107"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Stream = $__require('129');
|
|
var util = $__require('107');
|
|
var Response = module.exports = function(res) {
|
|
this.offset = 0;
|
|
this.readable = true;
|
|
};
|
|
util.inherits(Response, Stream);
|
|
var capable = {
|
|
streaming: true,
|
|
status2: true
|
|
};
|
|
function parseHeaders(res) {
|
|
var lines = res.getAllResponseHeaders().split(/\r?\n/);
|
|
var headers = {};
|
|
for (var i = 0; i < lines.length; i++) {
|
|
var line = lines[i];
|
|
if (line === '')
|
|
continue;
|
|
var m = line.match(/^([^:]+):\s*(.*)/);
|
|
if (m) {
|
|
var key = m[1].toLowerCase(),
|
|
value = m[2];
|
|
if (headers[key] !== undefined) {
|
|
if (isArray(headers[key])) {
|
|
headers[key].push(value);
|
|
} else {
|
|
headers[key] = [headers[key], value];
|
|
}
|
|
} else {
|
|
headers[key] = value;
|
|
}
|
|
} else {
|
|
headers[line] = true;
|
|
}
|
|
}
|
|
return headers;
|
|
}
|
|
Response.prototype.getResponse = function(xhr) {
|
|
var respType = String(xhr.responseType).toLowerCase();
|
|
if (respType === 'blob')
|
|
return xhr.responseBlob || xhr.response;
|
|
if (respType === 'arraybuffer')
|
|
return xhr.response;
|
|
return xhr.responseText;
|
|
};
|
|
Response.prototype.getHeader = function(key) {
|
|
return this.headers[key.toLowerCase()];
|
|
};
|
|
Response.prototype.handle = function(res) {
|
|
if (res.readyState === 2 && capable.status2) {
|
|
try {
|
|
this.statusCode = res.status;
|
|
this.headers = parseHeaders(res);
|
|
} catch (err) {
|
|
capable.status2 = false;
|
|
}
|
|
if (capable.status2) {
|
|
this.emit('ready');
|
|
}
|
|
} else if (capable.streaming && res.readyState === 3) {
|
|
try {
|
|
if (!this.statusCode) {
|
|
this.statusCode = res.status;
|
|
this.headers = parseHeaders(res);
|
|
this.emit('ready');
|
|
}
|
|
} catch (err) {}
|
|
try {
|
|
this._emitData(res);
|
|
} catch (err) {
|
|
capable.streaming = false;
|
|
}
|
|
} else if (res.readyState === 4) {
|
|
if (!this.statusCode) {
|
|
this.statusCode = res.status;
|
|
this.emit('ready');
|
|
}
|
|
this._emitData(res);
|
|
if (res.error) {
|
|
this.emit('error', this.getResponse(res));
|
|
} else
|
|
this.emit('end');
|
|
this.emit('close');
|
|
}
|
|
};
|
|
Response.prototype._emitData = function(res) {
|
|
var respBody = this.getResponse(res);
|
|
if (respBody.toString().match(/ArrayBuffer/)) {
|
|
this.emit('data', new Uint8Array(respBody, this.offset));
|
|
this.offset = respBody.byteLength;
|
|
return;
|
|
}
|
|
if (respBody.length > this.offset) {
|
|
this.emit('data', respBody.slice(this.offset));
|
|
this.offset = respBody.length;
|
|
}
|
|
};
|
|
var isArray = Array.isArray || function(xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12b", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
;
|
|
(function() {
|
|
var object = typeof exports != 'undefined' ? exports : this;
|
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
function InvalidCharacterError(message) {
|
|
this.message = message;
|
|
}
|
|
InvalidCharacterError.prototype = new Error;
|
|
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
|
object.btoa || (object.btoa = function(input) {
|
|
for (var block,
|
|
charCode,
|
|
idx = 0,
|
|
map = chars,
|
|
output = ''; input.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
|
|
charCode = input.charCodeAt(idx += 3 / 4);
|
|
if (charCode > 0xFF) {
|
|
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
|
}
|
|
block = block << 8 | charCode;
|
|
}
|
|
return output;
|
|
});
|
|
object.atob || (object.atob = function(input) {
|
|
input = input.replace(/=+$/, '');
|
|
if (input.length % 4 == 1) {
|
|
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
}
|
|
for (var bc = 0,
|
|
bs,
|
|
buffer,
|
|
idx = 0,
|
|
output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
|
|
buffer = chars.indexOf(buffer);
|
|
}
|
|
return output;
|
|
});
|
|
}());
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12c", ["12b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('12b');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12d", ["129", "12a", "12c", "124"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Stream = $__require('129');
|
|
var Response = $__require('12a');
|
|
var Base64 = $__require('12c');
|
|
var inherits = $__require('124');
|
|
var Request = module.exports = function(xhr, params) {
|
|
var self = this;
|
|
self.writable = true;
|
|
self.xhr = xhr;
|
|
self.body = [];
|
|
self.uri = (params.protocol || 'http:') + '//' + params.host + (params.port ? ':' + params.port : '') + (params.path || '/');
|
|
;
|
|
if (typeof params.withCredentials === 'undefined') {
|
|
params.withCredentials = true;
|
|
}
|
|
try {
|
|
xhr.withCredentials = params.withCredentials;
|
|
} catch (e) {}
|
|
if (params.responseType)
|
|
try {
|
|
xhr.responseType = params.responseType;
|
|
} catch (e) {}
|
|
xhr.open(params.method || 'GET', self.uri, true);
|
|
xhr.onerror = function(event) {
|
|
self.emit('error', new Error('Network error'));
|
|
};
|
|
self._headers = {};
|
|
if (params.headers) {
|
|
var keys = objectKeys(params.headers);
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
if (!self.isSafeRequestHeader(key))
|
|
continue;
|
|
var value = params.headers[key];
|
|
self.setHeader(key, value);
|
|
}
|
|
}
|
|
if (params.auth) {
|
|
this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth));
|
|
}
|
|
var res = new Response;
|
|
res.on('close', function() {
|
|
self.emit('close');
|
|
});
|
|
res.on('ready', function() {
|
|
self.emit('response', res);
|
|
});
|
|
res.on('error', function(err) {
|
|
self.emit('error', err);
|
|
});
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.__aborted)
|
|
return;
|
|
res.handle(xhr);
|
|
};
|
|
};
|
|
inherits(Request, Stream);
|
|
Request.prototype.setHeader = function(key, value) {
|
|
this._headers[key.toLowerCase()] = value;
|
|
};
|
|
Request.prototype.getHeader = function(key) {
|
|
return this._headers[key.toLowerCase()];
|
|
};
|
|
Request.prototype.removeHeader = function(key) {
|
|
delete this._headers[key.toLowerCase()];
|
|
};
|
|
Request.prototype.write = function(s) {
|
|
this.body.push(s);
|
|
};
|
|
Request.prototype.destroy = function(s) {
|
|
this.xhr.__aborted = true;
|
|
this.xhr.abort();
|
|
this.emit('close');
|
|
};
|
|
Request.prototype.end = function(s) {
|
|
if (s !== undefined)
|
|
this.body.push(s);
|
|
var keys = objectKeys(this._headers);
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
var value = this._headers[key];
|
|
if (isArray(value)) {
|
|
for (var j = 0; j < value.length; j++) {
|
|
this.xhr.setRequestHeader(key, value[j]);
|
|
}
|
|
} else
|
|
this.xhr.setRequestHeader(key, value);
|
|
}
|
|
if (this.body.length === 0) {
|
|
this.xhr.send('');
|
|
} else if (typeof this.body[0] === 'string') {
|
|
this.xhr.send(this.body.join(''));
|
|
} else if (isArray(this.body[0])) {
|
|
var body = [];
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
body.push.apply(body, this.body[i]);
|
|
}
|
|
this.xhr.send(body);
|
|
} else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
|
|
var len = 0;
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
len += this.body[i].length;
|
|
}
|
|
var body = new (this.body[0].constructor)(len);
|
|
var k = 0;
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
var b = this.body[i];
|
|
for (var j = 0; j < b.length; j++) {
|
|
body[k++] = b[j];
|
|
}
|
|
}
|
|
this.xhr.send(body);
|
|
} else if (isXHR2Compatible(this.body[0])) {
|
|
this.xhr.send(this.body[0]);
|
|
} else {
|
|
var body = '';
|
|
for (var i = 0; i < this.body.length; i++) {
|
|
body += this.body[i].toString();
|
|
}
|
|
this.xhr.send(body);
|
|
}
|
|
};
|
|
Request.unsafeHeaders = ["accept-charset", "accept-encoding", "access-control-request-headers", "access-control-request-method", "connection", "content-length", "cookie", "cookie2", "content-transfer-encoding", "date", "expect", "host", "keep-alive", "origin", "referer", "te", "trailer", "transfer-encoding", "upgrade", "user-agent", "via"];
|
|
Request.prototype.isSafeRequestHeader = function(headerName) {
|
|
if (!headerName)
|
|
return false;
|
|
return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1;
|
|
};
|
|
var objectKeys = Object.keys || function(obj) {
|
|
var keys = [];
|
|
for (var key in obj)
|
|
keys.push(key);
|
|
return keys;
|
|
};
|
|
var isArray = Array.isArray || function(xs) {
|
|
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
};
|
|
var indexOf = function(xs, x) {
|
|
if (xs.indexOf)
|
|
return xs.indexOf(x);
|
|
for (var i = 0; i < xs.length; i++) {
|
|
if (xs[i] === x)
|
|
return i;
|
|
}
|
|
return -1;
|
|
};
|
|
var isXHR2Compatible = function(obj) {
|
|
if (typeof Blob !== 'undefined' && obj instanceof Blob)
|
|
return true;
|
|
if (typeof ArrayBuffer !== 'undefined' && obj instanceof ArrayBuffer)
|
|
return true;
|
|
if (typeof FormData !== 'undefined' && obj instanceof FormData)
|
|
return true;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12e", ["120", "12d", "12f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
if ($__System._nodeRequire) {
|
|
module.exports = $__System._nodeRequire('http');
|
|
} else {
|
|
var http = module.exports;
|
|
var EventEmitter = $__require('120').EventEmitter;
|
|
var Request = $__require('12d');
|
|
var url = $__require('12f');
|
|
http.request = function(params, cb) {
|
|
if (typeof params === 'string') {
|
|
params = url.parse(params);
|
|
}
|
|
if (!params)
|
|
params = {};
|
|
if (!params.host && !params.port) {
|
|
params.port = parseInt(window.location.port, 10);
|
|
}
|
|
if (!params.host && params.hostname) {
|
|
params.host = params.hostname;
|
|
}
|
|
if (!params.protocol) {
|
|
if (params.scheme) {
|
|
params.protocol = params.scheme + ':';
|
|
} else {
|
|
params.protocol = window.location.protocol;
|
|
}
|
|
}
|
|
if (!params.host) {
|
|
params.host = window.location.hostname || window.location.host;
|
|
}
|
|
if (/:/.test(params.host)) {
|
|
if (!params.port) {
|
|
params.port = params.host.split(':')[1];
|
|
}
|
|
params.host = params.host.split(':')[0];
|
|
}
|
|
if (!params.port)
|
|
params.port = params.protocol == 'https:' ? 443 : 80;
|
|
var req = new Request(new xhrHttp, params);
|
|
if (cb)
|
|
req.on('response', cb);
|
|
return req;
|
|
};
|
|
http.get = function(params, cb) {
|
|
params.method = 'GET';
|
|
var req = http.request(params, cb);
|
|
req.end();
|
|
return req;
|
|
};
|
|
http.Agent = function() {};
|
|
http.Agent.defaultMaxSockets = 4;
|
|
var xhrHttp = (function() {
|
|
if (typeof window === 'undefined') {
|
|
throw new Error('no window object present');
|
|
} else if (window.XMLHttpRequest) {
|
|
return window.XMLHttpRequest;
|
|
} else if (window.ActiveXObject) {
|
|
var axs = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0', 'Microsoft.XMLHTTP'];
|
|
for (var i = 0; i < axs.length; i++) {
|
|
try {
|
|
var ax = new (window.ActiveXObject)(axs[i]);
|
|
return function() {
|
|
if (ax) {
|
|
var ax_ = ax;
|
|
ax = null;
|
|
return ax_;
|
|
} else {
|
|
return new (window.ActiveXObject)(axs[i]);
|
|
}
|
|
};
|
|
} catch (e) {}
|
|
}
|
|
throw new Error('ajax not supported in this browser');
|
|
} else {
|
|
throw new Error('ajax not supported in this browser');
|
|
}
|
|
})();
|
|
http.STATUS_CODES = {
|
|
100: 'Continue',
|
|
101: 'Switching Protocols',
|
|
102: 'Processing',
|
|
200: 'OK',
|
|
201: 'Created',
|
|
202: 'Accepted',
|
|
203: 'Non-Authoritative Information',
|
|
204: 'No Content',
|
|
205: 'Reset Content',
|
|
206: 'Partial Content',
|
|
207: 'Multi-Status',
|
|
300: 'Multiple Choices',
|
|
301: 'Moved Permanently',
|
|
302: 'Moved Temporarily',
|
|
303: 'See Other',
|
|
304: 'Not Modified',
|
|
305: 'Use Proxy',
|
|
307: 'Temporary Redirect',
|
|
400: 'Bad Request',
|
|
401: 'Unauthorized',
|
|
402: 'Payment Required',
|
|
403: 'Forbidden',
|
|
404: 'Not Found',
|
|
405: 'Method Not Allowed',
|
|
406: 'Not Acceptable',
|
|
407: 'Proxy Authentication Required',
|
|
408: 'Request Time-out',
|
|
409: 'Conflict',
|
|
410: 'Gone',
|
|
411: 'Length Required',
|
|
412: 'Precondition Failed',
|
|
413: 'Request Entity Too Large',
|
|
414: 'Request-URI Too Large',
|
|
415: 'Unsupported Media Type',
|
|
416: 'Requested Range Not Satisfiable',
|
|
417: 'Expectation Failed',
|
|
418: 'I\'m a teapot',
|
|
422: 'Unprocessable Entity',
|
|
423: 'Locked',
|
|
424: 'Failed Dependency',
|
|
425: 'Unordered Collection',
|
|
426: 'Upgrade Required',
|
|
428: 'Precondition Required',
|
|
429: 'Too Many Requests',
|
|
431: 'Request Header Fields Too Large',
|
|
500: 'Internal Server Error',
|
|
501: 'Not Implemented',
|
|
502: 'Bad Gateway',
|
|
503: 'Service Unavailable',
|
|
504: 'Gateway Time-out',
|
|
505: 'HTTP Version Not Supported',
|
|
506: 'Variant Also Negotiates',
|
|
507: 'Insufficient Storage',
|
|
509: 'Bandwidth Limit Exceeded',
|
|
510: 'Not Extended',
|
|
511: 'Network Authentication Required'
|
|
};
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("130", ["12e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('12e');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("131", ["130"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var http = $__require('130');
|
|
var https = module.exports;
|
|
for (var key in http) {
|
|
if (http.hasOwnProperty(key))
|
|
https[key] = http[key];
|
|
}
|
|
;
|
|
https.request = function(params, cb) {
|
|
if (!params)
|
|
params = {};
|
|
params.scheme = 'https';
|
|
return http.request.call(this, params, cb);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("132", ["131"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('131');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("133", ["132"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('https') : $__require('132');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("134", ["133"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('133');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("135", ["136", "10e", "101", "10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
var YAML = $__require('136'),
|
|
util = $__require('10e'),
|
|
ono = $__require('101');
|
|
module.exports = parse;
|
|
function parse(data, path, options) {
|
|
var parsed;
|
|
try {
|
|
if (options.allow.yaml) {
|
|
util.debug('Parsing YAML file: %s', path);
|
|
parsed = YAML.parse(data.toString());
|
|
util.debug(' Parsed successfully');
|
|
} else if (options.allow.json) {
|
|
util.debug('Parsing JSON file: %s', path);
|
|
parsed = JSON.parse(data.toString());
|
|
util.debug(' Parsed successfully');
|
|
} else {
|
|
parsed = data;
|
|
}
|
|
} catch (e) {
|
|
var ext = util.path.extname(path);
|
|
if (options.allow.unknown && ['.json', '.yaml', '.yml'].indexOf(ext) === -1) {
|
|
util.debug(' Unknown file format. Not parsed.');
|
|
parsed = data;
|
|
} else {
|
|
throw ono.syntax(e, 'Error parsing "%s"', path);
|
|
}
|
|
}
|
|
if (isEmpty(parsed) && !options.allow.empty) {
|
|
throw ono.syntax('Error parsing "%s". \nParsed value is empty', path);
|
|
}
|
|
return parsed;
|
|
}
|
|
function isEmpty(value) {
|
|
return !value || (typeof value === 'object' && Object.keys(value).length === 0) || (typeof value === 'string' && value.trim().length === 0) || (value instanceof Buffer && value.length === 0);
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("137", ["34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
(function(process) {
|
|
(function() {
|
|
"use strict";
|
|
function lib$es6$promise$utils$$objectOrFunction(x) {
|
|
return typeof x === 'function' || (typeof x === 'object' && x !== null);
|
|
}
|
|
function lib$es6$promise$utils$$isFunction(x) {
|
|
return typeof x === 'function';
|
|
}
|
|
function lib$es6$promise$utils$$isMaybeThenable(x) {
|
|
return typeof x === 'object' && x !== null;
|
|
}
|
|
var lib$es6$promise$utils$$_isArray;
|
|
if (!Array.isArray) {
|
|
lib$es6$promise$utils$$_isArray = function(x) {
|
|
return Object.prototype.toString.call(x) === '[object Array]';
|
|
};
|
|
} else {
|
|
lib$es6$promise$utils$$_isArray = Array.isArray;
|
|
}
|
|
var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
|
|
var lib$es6$promise$asap$$len = 0;
|
|
var lib$es6$promise$asap$$toString = {}.toString;
|
|
var lib$es6$promise$asap$$vertxNext;
|
|
var lib$es6$promise$asap$$customSchedulerFn;
|
|
var lib$es6$promise$asap$$asap = function asap(callback, arg) {
|
|
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
|
|
lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
|
|
lib$es6$promise$asap$$len += 2;
|
|
if (lib$es6$promise$asap$$len === 2) {
|
|
if (lib$es6$promise$asap$$customSchedulerFn) {
|
|
lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
|
|
} else {
|
|
lib$es6$promise$asap$$scheduleFlush();
|
|
}
|
|
}
|
|
};
|
|
function lib$es6$promise$asap$$setScheduler(scheduleFn) {
|
|
lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
|
|
}
|
|
function lib$es6$promise$asap$$setAsap(asapFn) {
|
|
lib$es6$promise$asap$$asap = asapFn;
|
|
}
|
|
var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
|
|
var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
|
|
var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
|
|
var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
|
|
var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
|
|
function lib$es6$promise$asap$$useNextTick() {
|
|
return function() {
|
|
process.nextTick(lib$es6$promise$asap$$flush);
|
|
};
|
|
}
|
|
function lib$es6$promise$asap$$useVertxTimer() {
|
|
return function() {
|
|
lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
|
|
};
|
|
}
|
|
function lib$es6$promise$asap$$useMutationObserver() {
|
|
var iterations = 0;
|
|
var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
|
|
var node = document.createTextNode('');
|
|
observer.observe(node, {characterData: true});
|
|
return function() {
|
|
node.data = (iterations = ++iterations % 2);
|
|
};
|
|
}
|
|
function lib$es6$promise$asap$$useMessageChannel() {
|
|
var channel = new MessageChannel();
|
|
channel.port1.onmessage = lib$es6$promise$asap$$flush;
|
|
return function() {
|
|
channel.port2.postMessage(0);
|
|
};
|
|
}
|
|
function lib$es6$promise$asap$$useSetTimeout() {
|
|
return function() {
|
|
setTimeout(lib$es6$promise$asap$$flush, 1);
|
|
};
|
|
}
|
|
var lib$es6$promise$asap$$queue = new Array(1000);
|
|
function lib$es6$promise$asap$$flush() {
|
|
for (var i = 0; i < lib$es6$promise$asap$$len; i += 2) {
|
|
var callback = lib$es6$promise$asap$$queue[i];
|
|
var arg = lib$es6$promise$asap$$queue[i + 1];
|
|
callback(arg);
|
|
lib$es6$promise$asap$$queue[i] = undefined;
|
|
lib$es6$promise$asap$$queue[i + 1] = undefined;
|
|
}
|
|
lib$es6$promise$asap$$len = 0;
|
|
}
|
|
function lib$es6$promise$asap$$attemptVertx() {
|
|
try {
|
|
var r = $__require;
|
|
var vertx = r('vertx');
|
|
lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
|
|
return lib$es6$promise$asap$$useVertxTimer();
|
|
} catch (e) {
|
|
return lib$es6$promise$asap$$useSetTimeout();
|
|
}
|
|
}
|
|
var lib$es6$promise$asap$$scheduleFlush;
|
|
if (lib$es6$promise$asap$$isNode) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
|
|
} else if (lib$es6$promise$asap$$BrowserMutationObserver) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
|
|
} else if (lib$es6$promise$asap$$isWorker) {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
|
|
} else if (lib$es6$promise$asap$$browserWindow === undefined && typeof $__require === 'function') {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
|
|
} else {
|
|
lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
|
|
}
|
|
function lib$es6$promise$$internal$$noop() {}
|
|
var lib$es6$promise$$internal$$PENDING = void 0;
|
|
var lib$es6$promise$$internal$$FULFILLED = 1;
|
|
var lib$es6$promise$$internal$$REJECTED = 2;
|
|
var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
|
|
function lib$es6$promise$$internal$$selfFulfillment() {
|
|
return new TypeError("You cannot resolve a promise with itself");
|
|
}
|
|
function lib$es6$promise$$internal$$cannotReturnOwn() {
|
|
return new TypeError('A promises callback cannot return that same promise.');
|
|
}
|
|
function lib$es6$promise$$internal$$getThen(promise) {
|
|
try {
|
|
return promise.then;
|
|
} catch (error) {
|
|
lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
|
|
return lib$es6$promise$$internal$$GET_THEN_ERROR;
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
|
|
try {
|
|
then.call(value, fulfillmentHandler, rejectionHandler);
|
|
} catch (e) {
|
|
return e;
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
|
|
lib$es6$promise$asap$$asap(function(promise) {
|
|
var sealed = false;
|
|
var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
|
|
if (sealed) {
|
|
return;
|
|
}
|
|
sealed = true;
|
|
if (thenable !== value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
}
|
|
}, function(reason) {
|
|
if (sealed) {
|
|
return;
|
|
}
|
|
sealed = true;
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
}, 'Settle: ' + (promise._label || ' unknown promise'));
|
|
if (!sealed && error) {
|
|
sealed = true;
|
|
lib$es6$promise$$internal$$reject(promise, error);
|
|
}
|
|
}, promise);
|
|
}
|
|
function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
|
|
if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
|
|
lib$es6$promise$$internal$$fulfill(promise, thenable._result);
|
|
} else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, thenable._result);
|
|
} else {
|
|
lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}, function(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
});
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
|
|
if (maybeThenable.constructor === promise.constructor) {
|
|
lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
|
|
} else {
|
|
var then = lib$es6$promise$$internal$$getThen(maybeThenable);
|
|
if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
|
|
} else if (then === undefined) {
|
|
lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
|
|
} else if (lib$es6$promise$utils$$isFunction(then)) {
|
|
lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
|
|
}
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$resolve(promise, value) {
|
|
if (promise === value) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
|
|
} else if (lib$es6$promise$utils$$objectOrFunction(value)) {
|
|
lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
|
|
} else {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$publishRejection(promise) {
|
|
if (promise._onerror) {
|
|
promise._onerror(promise._result);
|
|
}
|
|
lib$es6$promise$$internal$$publish(promise);
|
|
}
|
|
function lib$es6$promise$$internal$$fulfill(promise, value) {
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) {
|
|
return;
|
|
}
|
|
promise._result = value;
|
|
promise._state = lib$es6$promise$$internal$$FULFILLED;
|
|
if (promise._subscribers.length !== 0) {
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$reject(promise, reason) {
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) {
|
|
return;
|
|
}
|
|
promise._state = lib$es6$promise$$internal$$REJECTED;
|
|
promise._result = reason;
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
|
|
}
|
|
function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
|
|
var subscribers = parent._subscribers;
|
|
var length = subscribers.length;
|
|
parent._onerror = null;
|
|
subscribers[length] = child;
|
|
subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
|
|
subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
|
|
if (length === 0 && parent._state) {
|
|
lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$publish(promise) {
|
|
var subscribers = promise._subscribers;
|
|
var settled = promise._state;
|
|
if (subscribers.length === 0) {
|
|
return;
|
|
}
|
|
var child,
|
|
callback,
|
|
detail = promise._result;
|
|
for (var i = 0; i < subscribers.length; i += 3) {
|
|
child = subscribers[i];
|
|
callback = subscribers[i + settled];
|
|
if (child) {
|
|
lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
|
|
} else {
|
|
callback(detail);
|
|
}
|
|
}
|
|
promise._subscribers.length = 0;
|
|
}
|
|
function lib$es6$promise$$internal$$ErrorObject() {
|
|
this.error = null;
|
|
}
|
|
var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
|
|
function lib$es6$promise$$internal$$tryCatch(callback, detail) {
|
|
try {
|
|
return callback(detail);
|
|
} catch (e) {
|
|
lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
|
|
return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
|
|
var hasCallback = lib$es6$promise$utils$$isFunction(callback),
|
|
value,
|
|
error,
|
|
succeeded,
|
|
failed;
|
|
if (hasCallback) {
|
|
value = lib$es6$promise$$internal$$tryCatch(callback, detail);
|
|
if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
|
|
failed = true;
|
|
error = value.error;
|
|
value = null;
|
|
} else {
|
|
succeeded = true;
|
|
}
|
|
if (promise === value) {
|
|
lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
|
|
return;
|
|
}
|
|
} else {
|
|
value = detail;
|
|
succeeded = true;
|
|
}
|
|
if (promise._state !== lib$es6$promise$$internal$$PENDING) {} else if (hasCallback && succeeded) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
} else if (failed) {
|
|
lib$es6$promise$$internal$$reject(promise, error);
|
|
} else if (settled === lib$es6$promise$$internal$$FULFILLED) {
|
|
lib$es6$promise$$internal$$fulfill(promise, value);
|
|
} else if (settled === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, value);
|
|
}
|
|
}
|
|
function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
|
|
try {
|
|
resolver(function resolvePromise(value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}, function rejectPromise(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
});
|
|
} catch (e) {
|
|
lib$es6$promise$$internal$$reject(promise, e);
|
|
}
|
|
}
|
|
function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
|
|
var enumerator = this;
|
|
enumerator._instanceConstructor = Constructor;
|
|
enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
if (enumerator._validateInput(input)) {
|
|
enumerator._input = input;
|
|
enumerator.length = input.length;
|
|
enumerator._remaining = input.length;
|
|
enumerator._init();
|
|
if (enumerator.length === 0) {
|
|
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
|
|
} else {
|
|
enumerator.length = enumerator.length || 0;
|
|
enumerator._enumerate();
|
|
if (enumerator._remaining === 0) {
|
|
lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
|
|
}
|
|
}
|
|
} else {
|
|
lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
|
|
}
|
|
}
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
|
|
return lib$es6$promise$utils$$isArray(input);
|
|
};
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
|
|
return new Error('Array Methods must be provided an Array');
|
|
};
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
|
|
this._result = new Array(this.length);
|
|
};
|
|
var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
|
|
var enumerator = this;
|
|
var length = enumerator.length;
|
|
var promise = enumerator.promise;
|
|
var input = enumerator._input;
|
|
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
|
|
enumerator._eachEntry(input[i], i);
|
|
}
|
|
};
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
|
|
var enumerator = this;
|
|
var c = enumerator._instanceConstructor;
|
|
if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
|
|
if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
|
|
entry._onerror = null;
|
|
enumerator._settledAt(entry._state, i, entry._result);
|
|
} else {
|
|
enumerator._willSettleAt(c.resolve(entry), i);
|
|
}
|
|
} else {
|
|
enumerator._remaining--;
|
|
enumerator._result[i] = entry;
|
|
}
|
|
};
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
|
|
var enumerator = this;
|
|
var promise = enumerator.promise;
|
|
if (promise._state === lib$es6$promise$$internal$$PENDING) {
|
|
enumerator._remaining--;
|
|
if (state === lib$es6$promise$$internal$$REJECTED) {
|
|
lib$es6$promise$$internal$$reject(promise, value);
|
|
} else {
|
|
enumerator._result[i] = value;
|
|
}
|
|
}
|
|
if (enumerator._remaining === 0) {
|
|
lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
|
|
}
|
|
};
|
|
lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
|
|
var enumerator = this;
|
|
lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
|
|
enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
|
|
}, function(reason) {
|
|
enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
|
|
});
|
|
};
|
|
function lib$es6$promise$promise$all$$all(entries) {
|
|
return new lib$es6$promise$enumerator$$default(this, entries).promise;
|
|
}
|
|
var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
|
|
function lib$es6$promise$promise$race$$race(entries) {
|
|
var Constructor = this;
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
if (!lib$es6$promise$utils$$isArray(entries)) {
|
|
lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
|
|
return promise;
|
|
}
|
|
var length = entries.length;
|
|
function onFulfillment(value) {
|
|
lib$es6$promise$$internal$$resolve(promise, value);
|
|
}
|
|
function onRejection(reason) {
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
}
|
|
for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
|
|
lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
|
|
}
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
|
|
function lib$es6$promise$promise$resolve$$resolve(object) {
|
|
var Constructor = this;
|
|
if (object && typeof object === 'object' && object.constructor === Constructor) {
|
|
return object;
|
|
}
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
lib$es6$promise$$internal$$resolve(promise, object);
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
|
|
function lib$es6$promise$promise$reject$$reject(reason) {
|
|
var Constructor = this;
|
|
var promise = new Constructor(lib$es6$promise$$internal$$noop);
|
|
lib$es6$promise$$internal$$reject(promise, reason);
|
|
return promise;
|
|
}
|
|
var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
|
|
var lib$es6$promise$promise$$counter = 0;
|
|
function lib$es6$promise$promise$$needsResolver() {
|
|
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
|
|
}
|
|
function lib$es6$promise$promise$$needsNew() {
|
|
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
|
|
}
|
|
var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
|
|
function lib$es6$promise$promise$$Promise(resolver) {
|
|
this._id = lib$es6$promise$promise$$counter++;
|
|
this._state = undefined;
|
|
this._result = undefined;
|
|
this._subscribers = [];
|
|
if (lib$es6$promise$$internal$$noop !== resolver) {
|
|
if (!lib$es6$promise$utils$$isFunction(resolver)) {
|
|
lib$es6$promise$promise$$needsResolver();
|
|
}
|
|
if (!(this instanceof lib$es6$promise$promise$$Promise)) {
|
|
lib$es6$promise$promise$$needsNew();
|
|
}
|
|
lib$es6$promise$$internal$$initializePromise(this, resolver);
|
|
}
|
|
}
|
|
lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
|
|
lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
|
|
lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
|
|
lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
|
|
lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
|
|
lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
|
|
lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
|
|
lib$es6$promise$promise$$Promise.prototype = {
|
|
constructor: lib$es6$promise$promise$$Promise,
|
|
then: function(onFulfillment, onRejection) {
|
|
var parent = this;
|
|
var state = parent._state;
|
|
if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
|
|
return this;
|
|
}
|
|
var child = new this.constructor(lib$es6$promise$$internal$$noop);
|
|
var result = parent._result;
|
|
if (state) {
|
|
var callback = arguments[state - 1];
|
|
lib$es6$promise$asap$$asap(function() {
|
|
lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
|
|
});
|
|
} else {
|
|
lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
|
|
}
|
|
return child;
|
|
},
|
|
'catch': function(onRejection) {
|
|
return this.then(null, onRejection);
|
|
}
|
|
};
|
|
function lib$es6$promise$polyfill$$polyfill() {
|
|
var local;
|
|
if (typeof global !== 'undefined') {
|
|
local = global;
|
|
} else if (typeof self !== 'undefined') {
|
|
local = self;
|
|
} else {
|
|
try {
|
|
local = Function('return this')();
|
|
} catch (e) {
|
|
throw new Error('polyfill failed because global object is unavailable in this environment');
|
|
}
|
|
}
|
|
var P = local.Promise;
|
|
if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
|
|
return;
|
|
}
|
|
local.Promise = lib$es6$promise$promise$$default;
|
|
}
|
|
var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
|
|
var lib$es6$promise$umd$$ES6Promise = {
|
|
'Promise': lib$es6$promise$promise$$default,
|
|
'polyfill': lib$es6$promise$polyfill$$default
|
|
};
|
|
if (typeof define === 'function' && define['amd']) {
|
|
define(function() {
|
|
return lib$es6$promise$umd$$ES6Promise;
|
|
});
|
|
} else if (typeof module !== 'undefined' && module['exports']) {
|
|
module['exports'] = lib$es6$promise$umd$$ES6Promise;
|
|
} else if (typeof this !== 'undefined') {
|
|
this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
|
|
}
|
|
lib$es6$promise$polyfill$$default();
|
|
}).call(this);
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10b", ["137"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('137');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("138", ["10b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = typeof Promise === 'function' ? Promise : $__require('10b').Promise;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("139", ["110", "130", "134", "135", "10e", "13a", "138", "12f", "101", "10c", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer, process) {
|
|
'use strict';
|
|
var fs = $__require('110'),
|
|
http = $__require('130'),
|
|
https = $__require('134'),
|
|
parse = $__require('135'),
|
|
util = $__require('10e'),
|
|
$Ref = $__require('13a'),
|
|
Promise = $__require('138'),
|
|
url = $__require('12f'),
|
|
ono = $__require('101');
|
|
module.exports = read;
|
|
function read(path, $refs, options) {
|
|
try {
|
|
path = util.path.stripHash(path);
|
|
util.debug('Reading %s', path);
|
|
var $ref = $refs._get$Ref(path);
|
|
if ($ref && !$ref.isExpired()) {
|
|
util.debug(' cached from %s', $ref.pathType);
|
|
return Promise.resolve({
|
|
$ref: $ref,
|
|
cached: true
|
|
});
|
|
}
|
|
$ref = new $Ref($refs, path);
|
|
return read$Ref($ref, options);
|
|
} catch (e) {
|
|
return Promise.reject(e);
|
|
}
|
|
}
|
|
function read$Ref($ref, options) {
|
|
try {
|
|
var promise = options.$refs.external && (read$RefFile($ref, options) || read$RefUrl($ref, options));
|
|
if (promise) {
|
|
return promise.then(function(data) {
|
|
var value = parse(data, $ref.path, options);
|
|
$ref.setValue(value, options);
|
|
return {
|
|
$ref: $ref,
|
|
cached: false
|
|
};
|
|
});
|
|
} else {
|
|
return Promise.reject(ono.syntax('Unable to resolve $ref pointer "%s"', $ref.path));
|
|
}
|
|
} catch (e) {
|
|
return Promise.reject(e);
|
|
}
|
|
}
|
|
function read$RefFile($ref, options) {
|
|
if (process.browser || util.path.isUrl($ref.path)) {
|
|
return;
|
|
}
|
|
$ref.pathType = 'fs';
|
|
return new Promise(function(resolve, reject) {
|
|
var file;
|
|
try {
|
|
file = util.path.urlToLocalPath($ref.path);
|
|
} catch (err) {
|
|
reject(ono.uri(err, 'Malformed URI: %s', $ref.path));
|
|
}
|
|
util.debug('Opening file: %s', file);
|
|
try {
|
|
fs.readFile(file, function(err, data) {
|
|
if (err) {
|
|
reject(ono(err, 'Error opening file "%s"', $ref.path));
|
|
} else {
|
|
resolve(data);
|
|
}
|
|
});
|
|
} catch (err) {
|
|
reject(ono(err, 'Error opening file "%s"', file));
|
|
}
|
|
});
|
|
}
|
|
function read$RefUrl($ref, options) {
|
|
var u = url.parse($ref.path);
|
|
if (process.browser && !u.protocol) {
|
|
u.protocol = url.parse(location.href).protocol;
|
|
}
|
|
if (u.protocol === 'http:') {
|
|
$ref.pathType = 'http';
|
|
return download(http, u, options);
|
|
} else if (u.protocol === 'https:') {
|
|
$ref.pathType = 'https';
|
|
return download(https, u, options);
|
|
}
|
|
}
|
|
function download(protocol, u, options) {
|
|
return new Promise(function(resolve, reject) {
|
|
try {
|
|
util.debug('Downloading file: %s', u);
|
|
var req = protocol.get({
|
|
hostname: u.hostname,
|
|
port: u.port,
|
|
path: u.path,
|
|
auth: u.auth,
|
|
withCredentials: options.http.withCredentials
|
|
}, onResponse);
|
|
if (typeof req.setTimeout === 'function') {
|
|
req.setTimeout(5000);
|
|
}
|
|
req.on('timeout', function() {
|
|
req.abort();
|
|
});
|
|
req.on('error', function(err) {
|
|
reject(ono(err, 'Error downloading file "%s"', u.href));
|
|
});
|
|
} catch (err) {
|
|
reject(ono(err, 'Error downloading file "%s"', u.href));
|
|
}
|
|
function onResponse(res) {
|
|
var body;
|
|
res.on('data', function(data) {
|
|
if (body) {
|
|
body = Buffer.concat([new Buffer(body), new Buffer(data)]);
|
|
} else {
|
|
body = data;
|
|
}
|
|
});
|
|
res.on('end', function() {
|
|
if (res.statusCode >= 400) {
|
|
reject(ono('GET %s \nHTTP ERROR %d \n%s', u.href, res.statusCode, body));
|
|
} else if ((res.statusCode === 204 || !body || !body.length) && !options.allow.empty) {
|
|
reject(ono('GET %s \nHTTP 204: No Content', u.href));
|
|
} else {
|
|
resolve(body || '');
|
|
}
|
|
});
|
|
res.on('error', function(err) {
|
|
reject(ono(err, 'Error downloading file "%s"', u.href));
|
|
});
|
|
}
|
|
});
|
|
}
|
|
})($__require('10c').Buffer, $__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13b", ["138", "13a", "13c", "139", "10e", "12f", "101"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Promise = $__require('138'),
|
|
$Ref = $__require('13a'),
|
|
Pointer = $__require('13c'),
|
|
read = $__require('139'),
|
|
util = $__require('10e'),
|
|
url = $__require('12f'),
|
|
ono = $__require('101');
|
|
module.exports = resolve;
|
|
function resolve(parser, options) {
|
|
try {
|
|
if (!options.$refs.external) {
|
|
return Promise.resolve();
|
|
}
|
|
util.debug('Resolving $ref pointers in %s', parser._basePath);
|
|
var promises = crawl(parser.schema, parser._basePath + '#', '#', parser.$refs, options);
|
|
return Promise.all(promises);
|
|
} catch (e) {
|
|
return Promise.reject(e);
|
|
}
|
|
}
|
|
function crawl(obj, path, pathFromRoot, $refs, options) {
|
|
var promises = [];
|
|
if (obj && typeof obj === 'object') {
|
|
var keys = Object.keys(obj);
|
|
var defs = keys.indexOf('definitions');
|
|
if (defs > 0) {
|
|
keys.splice(0, 0, keys.splice(defs, 1)[0]);
|
|
}
|
|
keys.forEach(function(key) {
|
|
var keyPath = Pointer.join(path, key);
|
|
var keyPathFromRoot = Pointer.join(pathFromRoot, key);
|
|
var value = obj[key];
|
|
if ($Ref.isExternal$Ref(value)) {
|
|
util.debug('Resolving $ref pointer "%s" at %s', value.$ref, keyPath);
|
|
var $refPath = url.resolve(path, value.$ref);
|
|
var promise = crawl$Ref($refPath, keyPathFromRoot, $refs, options).catch(function(err) {
|
|
throw ono.syntax(err, 'Error at %s', keyPath);
|
|
});
|
|
promises.push(promise);
|
|
} else {
|
|
promises = promises.concat(crawl(value, keyPath, keyPathFromRoot, $refs, options));
|
|
}
|
|
});
|
|
}
|
|
return promises;
|
|
}
|
|
function crawl$Ref(path, pathFromRoot, $refs, options) {
|
|
return read(path, $refs, options).then(function(cached$Ref) {
|
|
if (!cached$Ref.cached) {
|
|
var $ref = cached$Ref.$ref;
|
|
$ref.pathFromRoot = pathFromRoot;
|
|
util.debug('Resolving $ref pointers in %s', $ref.path);
|
|
var promises = crawl($ref.value, $ref.path + '#', pathFromRoot, $refs, options);
|
|
return Promise.all(promises);
|
|
}
|
|
});
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13d", ["13a", "13c", "10e", "12f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $Ref = $__require('13a'),
|
|
Pointer = $__require('13c'),
|
|
util = $__require('10e'),
|
|
url = $__require('12f');
|
|
module.exports = bundle;
|
|
function bundle(parser, options) {
|
|
util.debug('Bundling $ref pointers in %s', parser._basePath);
|
|
remap(parser.$refs, options);
|
|
dereference(parser._basePath, parser.$refs, options);
|
|
}
|
|
function remap($refs, options) {
|
|
var remapped = [];
|
|
Object.keys($refs._$refs).forEach(function(key) {
|
|
var $ref = $refs._$refs[key];
|
|
crawl($ref.value, $ref.path + '#', $refs, remapped, options);
|
|
});
|
|
for (var i = 0; i < remapped.length; i++) {
|
|
var mapping = remapped[i];
|
|
mapping.old.$ref = mapping.new.$ref;
|
|
}
|
|
}
|
|
function crawl(obj, path, $refs, remapped, options) {
|
|
if (obj && typeof obj === 'object') {
|
|
Object.keys(obj).forEach(function(key) {
|
|
var keyPath = Pointer.join(path, key);
|
|
var value = obj[key];
|
|
if ($Ref.is$Ref(value)) {
|
|
util.debug('Re-mapping $ref pointer "%s" at %s', value.$ref, keyPath);
|
|
var $refPath = url.resolve(path, value.$ref);
|
|
var pointer = $refs._resolve($refPath, options);
|
|
var new$RefPath = pointer.$ref.pathFromRoot + util.path.getHash(pointer.path).substr(1);
|
|
util.debug(' new value: %s', new$RefPath);
|
|
remapped.push({
|
|
old: value,
|
|
new: {$ref: new$RefPath}
|
|
});
|
|
} else {
|
|
crawl(value, keyPath, $refs, remapped, options);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function dereference(basePath, $refs, options) {
|
|
basePath = util.path.stripHash(basePath);
|
|
Object.keys($refs._$refs).forEach(function(key) {
|
|
var $ref = $refs._$refs[key];
|
|
if ($ref.pathFromRoot !== '#') {
|
|
$refs.set(basePath + $ref.pathFromRoot, $ref.value, options);
|
|
}
|
|
});
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13e", ["34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
"use strict";
|
|
var next = (global.process && process.nextTick) || global.setImmediate || function(f) {
|
|
setTimeout(f, 0);
|
|
};
|
|
module.exports = function maybe(cb, promise) {
|
|
if (cb) {
|
|
promise.then(function(result) {
|
|
next(function() {
|
|
cb(null, result);
|
|
});
|
|
}, function(err) {
|
|
next(function() {
|
|
cb(err);
|
|
});
|
|
});
|
|
return undefined;
|
|
} else {
|
|
return promise;
|
|
}
|
|
};
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13f", ["13e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('13e');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("140", ["141"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
function Mark(name, buffer, position, line, column) {
|
|
this.name = name;
|
|
this.buffer = buffer;
|
|
this.position = position;
|
|
this.line = line;
|
|
this.column = column;
|
|
}
|
|
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
|
var head,
|
|
start,
|
|
tail,
|
|
end,
|
|
snippet;
|
|
if (!this.buffer) {
|
|
return null;
|
|
}
|
|
indent = indent || 4;
|
|
maxLength = maxLength || 75;
|
|
head = '';
|
|
start = this.position;
|
|
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
|
|
start -= 1;
|
|
if (this.position - start > (maxLength / 2 - 1)) {
|
|
head = ' ... ';
|
|
start += 5;
|
|
break;
|
|
}
|
|
}
|
|
tail = '';
|
|
end = this.position;
|
|
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
|
|
end += 1;
|
|
if (end - this.position > (maxLength / 2 - 1)) {
|
|
tail = ' ... ';
|
|
end -= 5;
|
|
break;
|
|
}
|
|
}
|
|
snippet = this.buffer.slice(start, end);
|
|
return common.repeat(' ', indent) + head + snippet + tail + '\n' + common.repeat(' ', indent + this.position - start + head.length) + '^';
|
|
};
|
|
Mark.prototype.toString = function toString(compact) {
|
|
var snippet,
|
|
where = '';
|
|
if (this.name) {
|
|
where += 'in "' + this.name + '" ';
|
|
}
|
|
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
|
|
if (!compact) {
|
|
snippet = this.getSnippet();
|
|
if (snippet) {
|
|
where += ':\n' + snippet;
|
|
}
|
|
}
|
|
return where;
|
|
};
|
|
module.exports = Mark;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("142", ["141", "143", "140", "144", "145"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
var YAMLException = $__require('143');
|
|
var Mark = $__require('140');
|
|
var DEFAULT_SAFE_SCHEMA = $__require('144');
|
|
var DEFAULT_FULL_SCHEMA = $__require('145');
|
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
var CONTEXT_FLOW_IN = 1;
|
|
var CONTEXT_FLOW_OUT = 2;
|
|
var CONTEXT_BLOCK_IN = 3;
|
|
var CONTEXT_BLOCK_OUT = 4;
|
|
var CHOMPING_CLIP = 1;
|
|
var CHOMPING_STRIP = 2;
|
|
var CHOMPING_KEEP = 3;
|
|
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
function is_EOL(c) {
|
|
return (c === 0x0A) || (c === 0x0D);
|
|
}
|
|
function is_WHITE_SPACE(c) {
|
|
return (c === 0x09) || (c === 0x20);
|
|
}
|
|
function is_WS_OR_EOL(c) {
|
|
return (c === 0x09) || (c === 0x20) || (c === 0x0A) || (c === 0x0D);
|
|
}
|
|
function is_FLOW_INDICATOR(c) {
|
|
return 0x2C === c || 0x5B === c || 0x5D === c || 0x7B === c || 0x7D === c;
|
|
}
|
|
function fromHexCode(c) {
|
|
var lc;
|
|
if ((0x30 <= c) && (c <= 0x39)) {
|
|
return c - 0x30;
|
|
}
|
|
lc = c | 0x20;
|
|
if ((0x61 <= lc) && (lc <= 0x66)) {
|
|
return lc - 0x61 + 10;
|
|
}
|
|
return -1;
|
|
}
|
|
function escapedHexLen(c) {
|
|
if (c === 0x78) {
|
|
return 2;
|
|
}
|
|
if (c === 0x75) {
|
|
return 4;
|
|
}
|
|
if (c === 0x55) {
|
|
return 8;
|
|
}
|
|
return 0;
|
|
}
|
|
function fromDecimalCode(c) {
|
|
if ((0x30 <= c) && (c <= 0x39)) {
|
|
return c - 0x30;
|
|
}
|
|
return -1;
|
|
}
|
|
function simpleEscapeSequence(c) {
|
|
return (c === 0x30) ? '\x00' : (c === 0x61) ? '\x07' : (c === 0x62) ? '\x08' : (c === 0x74) ? '\x09' : (c === 0x09) ? '\x09' : (c === 0x6E) ? '\x0A' : (c === 0x76) ? '\x0B' : (c === 0x66) ? '\x0C' : (c === 0x72) ? '\x0D' : (c === 0x65) ? '\x1B' : (c === 0x20) ? ' ' : (c === 0x22) ? '\x22' : (c === 0x2F) ? '/' : (c === 0x5C) ? '\x5C' : (c === 0x4E) ? '\x85' : (c === 0x5F) ? '\xA0' : (c === 0x4C) ? '\u2028' : (c === 0x50) ? '\u2029' : '';
|
|
}
|
|
function charFromCodepoint(c) {
|
|
if (c <= 0xFFFF) {
|
|
return String.fromCharCode(c);
|
|
}
|
|
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, ((c - 0x010000) & 0x03FF) + 0xDC00);
|
|
}
|
|
var simpleEscapeCheck = new Array(256);
|
|
var simpleEscapeMap = new Array(256);
|
|
for (var i = 0; i < 256; i++) {
|
|
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
}
|
|
function State(input, options) {
|
|
this.input = input;
|
|
this.filename = options['filename'] || null;
|
|
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
|
this.onWarning = options['onWarning'] || null;
|
|
this.legacy = options['legacy'] || false;
|
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
this.typeMap = this.schema.compiledTypeMap;
|
|
this.length = input.length;
|
|
this.position = 0;
|
|
this.line = 0;
|
|
this.lineStart = 0;
|
|
this.lineIndent = 0;
|
|
this.documents = [];
|
|
}
|
|
function generateError(state, message) {
|
|
return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
|
|
}
|
|
function throwError(state, message) {
|
|
throw generateError(state, message);
|
|
}
|
|
function throwWarning(state, message) {
|
|
if (state.onWarning) {
|
|
state.onWarning.call(null, generateError(state, message));
|
|
}
|
|
}
|
|
var directiveHandlers = {
|
|
YAML: function handleYamlDirective(state, name, args) {
|
|
var match,
|
|
major,
|
|
minor;
|
|
if (null !== state.version) {
|
|
throwError(state, 'duplication of %YAML directive');
|
|
}
|
|
if (1 !== args.length) {
|
|
throwError(state, 'YAML directive accepts exactly one argument');
|
|
}
|
|
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
if (null === match) {
|
|
throwError(state, 'ill-formed argument of the YAML directive');
|
|
}
|
|
major = parseInt(match[1], 10);
|
|
minor = parseInt(match[2], 10);
|
|
if (1 !== major) {
|
|
throwError(state, 'unacceptable YAML version of the document');
|
|
}
|
|
state.version = args[0];
|
|
state.checkLineBreaks = (minor < 2);
|
|
if (1 !== minor && 2 !== minor) {
|
|
throwWarning(state, 'unsupported YAML version of the document');
|
|
}
|
|
},
|
|
TAG: function handleTagDirective(state, name, args) {
|
|
var handle,
|
|
prefix;
|
|
if (2 !== args.length) {
|
|
throwError(state, 'TAG directive accepts exactly two arguments');
|
|
}
|
|
handle = args[0];
|
|
prefix = args[1];
|
|
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
|
|
}
|
|
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
}
|
|
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
|
|
}
|
|
state.tagMap[handle] = prefix;
|
|
}
|
|
};
|
|
function captureSegment(state, start, end, checkJson) {
|
|
var _position,
|
|
_length,
|
|
_character,
|
|
_result;
|
|
if (start < end) {
|
|
_result = state.input.slice(start, end);
|
|
if (checkJson) {
|
|
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
_character = _result.charCodeAt(_position);
|
|
if (!(0x09 === _character || 0x20 <= _character && _character <= 0x10FFFF)) {
|
|
throwError(state, 'expected valid JSON character');
|
|
}
|
|
}
|
|
}
|
|
state.result += _result;
|
|
}
|
|
}
|
|
function mergeMappings(state, destination, source) {
|
|
var sourceKeys,
|
|
key,
|
|
index,
|
|
quantity;
|
|
if (!common.isObject(source)) {
|
|
throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
|
|
}
|
|
sourceKeys = Object.keys(source);
|
|
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
key = sourceKeys[index];
|
|
if (!_hasOwnProperty.call(destination, key)) {
|
|
destination[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
function storeMappingPair(state, _result, keyTag, keyNode, valueNode) {
|
|
var index,
|
|
quantity;
|
|
keyNode = String(keyNode);
|
|
if (null === _result) {
|
|
_result = {};
|
|
}
|
|
if ('tag:yaml.org,2002:merge' === keyTag) {
|
|
if (Array.isArray(valueNode)) {
|
|
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
mergeMappings(state, _result, valueNode[index]);
|
|
}
|
|
} else {
|
|
mergeMappings(state, _result, valueNode);
|
|
}
|
|
} else {
|
|
_result[keyNode] = valueNode;
|
|
}
|
|
return _result;
|
|
}
|
|
function readLineBreak(state) {
|
|
var ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x0A === ch) {
|
|
state.position++;
|
|
} else if (0x0D === ch) {
|
|
state.position++;
|
|
if (0x0A === state.input.charCodeAt(state.position)) {
|
|
state.position++;
|
|
}
|
|
} else {
|
|
throwError(state, 'a line break is expected');
|
|
}
|
|
state.line += 1;
|
|
state.lineStart = state.position;
|
|
}
|
|
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
var lineBreaks = 0,
|
|
ch = state.input.charCodeAt(state.position);
|
|
while (0 !== ch) {
|
|
while (is_WHITE_SPACE(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (allowComments && 0x23 === ch) {
|
|
do {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} while (ch !== 0x0A && ch !== 0x0D && 0 !== ch);
|
|
}
|
|
if (is_EOL(ch)) {
|
|
readLineBreak(state);
|
|
ch = state.input.charCodeAt(state.position);
|
|
lineBreaks++;
|
|
state.lineIndent = 0;
|
|
while (0x20 === ch) {
|
|
state.lineIndent++;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
|
|
throwWarning(state, 'deficient indentation');
|
|
}
|
|
return lineBreaks;
|
|
}
|
|
function testDocumentSeparator(state) {
|
|
var _position = state.position,
|
|
ch;
|
|
ch = state.input.charCodeAt(_position);
|
|
if ((0x2D === ch || 0x2E === ch) && state.input.charCodeAt(_position + 1) === ch && state.input.charCodeAt(_position + 2) === ch) {
|
|
_position += 3;
|
|
ch = state.input.charCodeAt(_position);
|
|
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function writeFoldedLines(state, count) {
|
|
if (1 === count) {
|
|
state.result += ' ';
|
|
} else if (count > 1) {
|
|
state.result += common.repeat('\n', count - 1);
|
|
}
|
|
}
|
|
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
var preceding,
|
|
following,
|
|
captureStart,
|
|
captureEnd,
|
|
hasPendingContent,
|
|
_line,
|
|
_lineStart,
|
|
_lineIndent,
|
|
_kind = state.kind,
|
|
_result = state.result,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || 0x23 === ch || 0x26 === ch || 0x2A === ch || 0x21 === ch || 0x7C === ch || 0x3E === ch || 0x27 === ch || 0x22 === ch || 0x25 === ch || 0x40 === ch || 0x60 === ch) {
|
|
return false;
|
|
}
|
|
if (0x3F === ch || 0x2D === ch) {
|
|
following = state.input.charCodeAt(state.position + 1);
|
|
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
return false;
|
|
}
|
|
}
|
|
state.kind = 'scalar';
|
|
state.result = '';
|
|
captureStart = captureEnd = state.position;
|
|
hasPendingContent = false;
|
|
while (0 !== ch) {
|
|
if (0x3A === ch) {
|
|
following = state.input.charCodeAt(state.position + 1);
|
|
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
break;
|
|
}
|
|
} else if (0x23 === ch) {
|
|
preceding = state.input.charCodeAt(state.position - 1);
|
|
if (is_WS_OR_EOL(preceding)) {
|
|
break;
|
|
}
|
|
} else if ((state.position === state.lineStart && testDocumentSeparator(state)) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
break;
|
|
} else if (is_EOL(ch)) {
|
|
_line = state.line;
|
|
_lineStart = state.lineStart;
|
|
_lineIndent = state.lineIndent;
|
|
skipSeparationSpace(state, false, -1);
|
|
if (state.lineIndent >= nodeIndent) {
|
|
hasPendingContent = true;
|
|
ch = state.input.charCodeAt(state.position);
|
|
continue;
|
|
} else {
|
|
state.position = captureEnd;
|
|
state.line = _line;
|
|
state.lineStart = _lineStart;
|
|
state.lineIndent = _lineIndent;
|
|
break;
|
|
}
|
|
}
|
|
if (hasPendingContent) {
|
|
captureSegment(state, captureStart, captureEnd, false);
|
|
writeFoldedLines(state, state.line - _line);
|
|
captureStart = captureEnd = state.position;
|
|
hasPendingContent = false;
|
|
}
|
|
if (!is_WHITE_SPACE(ch)) {
|
|
captureEnd = state.position + 1;
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
captureSegment(state, captureStart, captureEnd, false);
|
|
if (state.result) {
|
|
return true;
|
|
}
|
|
state.kind = _kind;
|
|
state.result = _result;
|
|
return false;
|
|
}
|
|
function readSingleQuotedScalar(state, nodeIndent) {
|
|
var ch,
|
|
captureStart,
|
|
captureEnd;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x27 !== ch) {
|
|
return false;
|
|
}
|
|
state.kind = 'scalar';
|
|
state.result = '';
|
|
state.position++;
|
|
captureStart = captureEnd = state.position;
|
|
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
if (0x27 === ch) {
|
|
captureSegment(state, captureStart, state.position, true);
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if (0x27 === ch) {
|
|
captureStart = captureEnd = state.position;
|
|
state.position++;
|
|
} else {
|
|
return true;
|
|
}
|
|
} else if (is_EOL(ch)) {
|
|
captureSegment(state, captureStart, captureEnd, true);
|
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
captureStart = captureEnd = state.position;
|
|
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
throwError(state, 'unexpected end of the document within a single quoted scalar');
|
|
} else {
|
|
state.position++;
|
|
captureEnd = state.position;
|
|
}
|
|
}
|
|
throwError(state, 'unexpected end of the stream within a single quoted scalar');
|
|
}
|
|
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
var captureStart,
|
|
captureEnd,
|
|
hexLength,
|
|
hexResult,
|
|
tmp,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x22 !== ch) {
|
|
return false;
|
|
}
|
|
state.kind = 'scalar';
|
|
state.result = '';
|
|
state.position++;
|
|
captureStart = captureEnd = state.position;
|
|
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
if (0x22 === ch) {
|
|
captureSegment(state, captureStart, state.position, true);
|
|
state.position++;
|
|
return true;
|
|
} else if (0x5C === ch) {
|
|
captureSegment(state, captureStart, state.position, true);
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if (is_EOL(ch)) {
|
|
skipSeparationSpace(state, false, nodeIndent);
|
|
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
state.result += simpleEscapeMap[ch];
|
|
state.position++;
|
|
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
hexLength = tmp;
|
|
hexResult = 0;
|
|
for (; hexLength > 0; hexLength--) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
hexResult = (hexResult << 4) + tmp;
|
|
} else {
|
|
throwError(state, 'expected hexadecimal character');
|
|
}
|
|
}
|
|
state.result += charFromCodepoint(hexResult);
|
|
state.position++;
|
|
} else {
|
|
throwError(state, 'unknown escape sequence');
|
|
}
|
|
captureStart = captureEnd = state.position;
|
|
} else if (is_EOL(ch)) {
|
|
captureSegment(state, captureStart, captureEnd, true);
|
|
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
captureStart = captureEnd = state.position;
|
|
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
throwError(state, 'unexpected end of the document within a double quoted scalar');
|
|
} else {
|
|
state.position++;
|
|
captureEnd = state.position;
|
|
}
|
|
}
|
|
throwError(state, 'unexpected end of the stream within a double quoted scalar');
|
|
}
|
|
function readFlowCollection(state, nodeIndent) {
|
|
var readNext = true,
|
|
_line,
|
|
_tag = state.tag,
|
|
_result,
|
|
_anchor = state.anchor,
|
|
following,
|
|
terminator,
|
|
isPair,
|
|
isExplicitPair,
|
|
isMapping,
|
|
keyNode,
|
|
keyTag,
|
|
valueNode,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (ch === 0x5B) {
|
|
terminator = 0x5D;
|
|
isMapping = false;
|
|
_result = [];
|
|
} else if (ch === 0x7B) {
|
|
terminator = 0x7D;
|
|
isMapping = true;
|
|
_result = {};
|
|
} else {
|
|
return false;
|
|
}
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = _result;
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
while (0 !== ch) {
|
|
skipSeparationSpace(state, true, nodeIndent);
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (ch === terminator) {
|
|
state.position++;
|
|
state.tag = _tag;
|
|
state.anchor = _anchor;
|
|
state.kind = isMapping ? 'mapping' : 'sequence';
|
|
state.result = _result;
|
|
return true;
|
|
} else if (!readNext) {
|
|
throwError(state, 'missed comma between flow collection entries');
|
|
}
|
|
keyTag = keyNode = valueNode = null;
|
|
isPair = isExplicitPair = false;
|
|
if (0x3F === ch) {
|
|
following = state.input.charCodeAt(state.position + 1);
|
|
if (is_WS_OR_EOL(following)) {
|
|
isPair = isExplicitPair = true;
|
|
state.position++;
|
|
skipSeparationSpace(state, true, nodeIndent);
|
|
}
|
|
}
|
|
_line = state.line;
|
|
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
keyTag = state.tag;
|
|
keyNode = state.result;
|
|
skipSeparationSpace(state, true, nodeIndent);
|
|
ch = state.input.charCodeAt(state.position);
|
|
if ((isExplicitPair || state.line === _line) && 0x3A === ch) {
|
|
isPair = true;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
skipSeparationSpace(state, true, nodeIndent);
|
|
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
valueNode = state.result;
|
|
}
|
|
if (isMapping) {
|
|
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
|
} else if (isPair) {
|
|
_result.push(storeMappingPair(state, null, keyTag, keyNode, valueNode));
|
|
} else {
|
|
_result.push(keyNode);
|
|
}
|
|
skipSeparationSpace(state, true, nodeIndent);
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x2C === ch) {
|
|
readNext = true;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} else {
|
|
readNext = false;
|
|
}
|
|
}
|
|
throwError(state, 'unexpected end of the stream within a flow collection');
|
|
}
|
|
function readBlockScalar(state, nodeIndent) {
|
|
var captureStart,
|
|
folding,
|
|
chomping = CHOMPING_CLIP,
|
|
detectedIndent = false,
|
|
textIndent = nodeIndent,
|
|
emptyLines = 0,
|
|
atMoreIndented = false,
|
|
tmp,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (ch === 0x7C) {
|
|
folding = false;
|
|
} else if (ch === 0x3E) {
|
|
folding = true;
|
|
} else {
|
|
return false;
|
|
}
|
|
state.kind = 'scalar';
|
|
state.result = '';
|
|
while (0 !== ch) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if (0x2B === ch || 0x2D === ch) {
|
|
if (CHOMPING_CLIP === chomping) {
|
|
chomping = (0x2B === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
} else {
|
|
throwError(state, 'repeat of a chomping mode identifier');
|
|
}
|
|
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
if (tmp === 0) {
|
|
throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
|
|
} else if (!detectedIndent) {
|
|
textIndent = nodeIndent + tmp - 1;
|
|
detectedIndent = true;
|
|
} else {
|
|
throwError(state, 'repeat of an indentation width identifier');
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (is_WHITE_SPACE(ch)) {
|
|
do {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} while (is_WHITE_SPACE(ch));
|
|
if (0x23 === ch) {
|
|
do {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} while (!is_EOL(ch) && (0 !== ch));
|
|
}
|
|
}
|
|
while (0 !== ch) {
|
|
readLineBreak(state);
|
|
state.lineIndent = 0;
|
|
ch = state.input.charCodeAt(state.position);
|
|
while ((!detectedIndent || state.lineIndent < textIndent) && (0x20 === ch)) {
|
|
state.lineIndent++;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
textIndent = state.lineIndent;
|
|
}
|
|
if (is_EOL(ch)) {
|
|
emptyLines++;
|
|
continue;
|
|
}
|
|
if (state.lineIndent < textIndent) {
|
|
if (chomping === CHOMPING_KEEP) {
|
|
state.result += common.repeat('\n', emptyLines);
|
|
} else if (chomping === CHOMPING_CLIP) {
|
|
if (detectedIndent) {
|
|
state.result += '\n';
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (folding) {
|
|
if (is_WHITE_SPACE(ch)) {
|
|
atMoreIndented = true;
|
|
state.result += common.repeat('\n', emptyLines + 1);
|
|
} else if (atMoreIndented) {
|
|
atMoreIndented = false;
|
|
state.result += common.repeat('\n', emptyLines + 1);
|
|
} else if (0 === emptyLines) {
|
|
if (detectedIndent) {
|
|
state.result += ' ';
|
|
}
|
|
} else {
|
|
state.result += common.repeat('\n', emptyLines);
|
|
}
|
|
} else if (detectedIndent) {
|
|
state.result += common.repeat('\n', emptyLines + 1);
|
|
} else {
|
|
state.result += common.repeat('\n', emptyLines);
|
|
}
|
|
detectedIndent = true;
|
|
emptyLines = 0;
|
|
captureStart = state.position;
|
|
while (!is_EOL(ch) && (0 !== ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
captureSegment(state, captureStart, state.position, false);
|
|
}
|
|
return true;
|
|
}
|
|
function readBlockSequence(state, nodeIndent) {
|
|
var _line,
|
|
_tag = state.tag,
|
|
_anchor = state.anchor,
|
|
_result = [],
|
|
following,
|
|
detected = false,
|
|
ch;
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = _result;
|
|
}
|
|
ch = state.input.charCodeAt(state.position);
|
|
while (0 !== ch) {
|
|
if (0x2D !== ch) {
|
|
break;
|
|
}
|
|
following = state.input.charCodeAt(state.position + 1);
|
|
if (!is_WS_OR_EOL(following)) {
|
|
break;
|
|
}
|
|
detected = true;
|
|
state.position++;
|
|
if (skipSeparationSpace(state, true, -1)) {
|
|
if (state.lineIndent <= nodeIndent) {
|
|
_result.push(null);
|
|
ch = state.input.charCodeAt(state.position);
|
|
continue;
|
|
}
|
|
}
|
|
_line = state.line;
|
|
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
_result.push(state.result);
|
|
skipSeparationSpace(state, true, -1);
|
|
ch = state.input.charCodeAt(state.position);
|
|
if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
|
|
throwError(state, 'bad indentation of a sequence entry');
|
|
} else if (state.lineIndent < nodeIndent) {
|
|
break;
|
|
}
|
|
}
|
|
if (detected) {
|
|
state.tag = _tag;
|
|
state.anchor = _anchor;
|
|
state.kind = 'sequence';
|
|
state.result = _result;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
var following,
|
|
allowCompact,
|
|
_line,
|
|
_tag = state.tag,
|
|
_anchor = state.anchor,
|
|
_result = {},
|
|
keyTag = null,
|
|
keyNode = null,
|
|
valueNode = null,
|
|
atExplicitKey = false,
|
|
detected = false,
|
|
ch;
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = _result;
|
|
}
|
|
ch = state.input.charCodeAt(state.position);
|
|
while (0 !== ch) {
|
|
following = state.input.charCodeAt(state.position + 1);
|
|
_line = state.line;
|
|
if ((0x3F === ch || 0x3A === ch) && is_WS_OR_EOL(following)) {
|
|
if (0x3F === ch) {
|
|
if (atExplicitKey) {
|
|
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
keyTag = keyNode = valueNode = null;
|
|
}
|
|
detected = true;
|
|
atExplicitKey = true;
|
|
allowCompact = true;
|
|
} else if (atExplicitKey) {
|
|
atExplicitKey = false;
|
|
allowCompact = true;
|
|
} else {
|
|
throwError(state, 'incomplete explicit mapping pair; a key node is missed');
|
|
}
|
|
state.position += 1;
|
|
ch = following;
|
|
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
if (state.line === _line) {
|
|
ch = state.input.charCodeAt(state.position);
|
|
while (is_WHITE_SPACE(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (0x3A === ch) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if (!is_WS_OR_EOL(ch)) {
|
|
throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
|
|
}
|
|
if (atExplicitKey) {
|
|
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
keyTag = keyNode = valueNode = null;
|
|
}
|
|
detected = true;
|
|
atExplicitKey = false;
|
|
allowCompact = false;
|
|
keyTag = state.tag;
|
|
keyNode = state.result;
|
|
} else if (detected) {
|
|
throwError(state, 'can not read an implicit mapping pair; a colon is missed');
|
|
} else {
|
|
state.tag = _tag;
|
|
state.anchor = _anchor;
|
|
return true;
|
|
}
|
|
} else if (detected) {
|
|
throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
|
|
} else {
|
|
state.tag = _tag;
|
|
state.anchor = _anchor;
|
|
return true;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
if (atExplicitKey) {
|
|
keyNode = state.result;
|
|
} else {
|
|
valueNode = state.result;
|
|
}
|
|
}
|
|
if (!atExplicitKey) {
|
|
storeMappingPair(state, _result, keyTag, keyNode, valueNode);
|
|
keyTag = keyNode = valueNode = null;
|
|
}
|
|
skipSeparationSpace(state, true, -1);
|
|
ch = state.input.charCodeAt(state.position);
|
|
}
|
|
if (state.lineIndent > nodeIndent && (0 !== ch)) {
|
|
throwError(state, 'bad indentation of a mapping entry');
|
|
} else if (state.lineIndent < nodeIndent) {
|
|
break;
|
|
}
|
|
}
|
|
if (atExplicitKey) {
|
|
storeMappingPair(state, _result, keyTag, keyNode, null);
|
|
}
|
|
if (detected) {
|
|
state.tag = _tag;
|
|
state.anchor = _anchor;
|
|
state.kind = 'mapping';
|
|
state.result = _result;
|
|
}
|
|
return detected;
|
|
}
|
|
function readTagProperty(state) {
|
|
var _position,
|
|
isVerbatim = false,
|
|
isNamed = false,
|
|
tagHandle,
|
|
tagName,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x21 !== ch) {
|
|
return false;
|
|
}
|
|
if (null !== state.tag) {
|
|
throwError(state, 'duplication of a tag property');
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
if (0x3C === ch) {
|
|
isVerbatim = true;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} else if (0x21 === ch) {
|
|
isNamed = true;
|
|
tagHandle = '!!';
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} else {
|
|
tagHandle = '!';
|
|
}
|
|
_position = state.position;
|
|
if (isVerbatim) {
|
|
do {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} while (0 !== ch && 0x3E !== ch);
|
|
if (state.position < state.length) {
|
|
tagName = state.input.slice(_position, state.position);
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} else {
|
|
throwError(state, 'unexpected end of the stream within a verbatim tag');
|
|
}
|
|
} else {
|
|
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
if (0x21 === ch) {
|
|
if (!isNamed) {
|
|
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
throwError(state, 'named tag handle cannot contain such characters');
|
|
}
|
|
isNamed = true;
|
|
_position = state.position + 1;
|
|
} else {
|
|
throwError(state, 'tag suffix cannot contain exclamation marks');
|
|
}
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
tagName = state.input.slice(_position, state.position);
|
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
throwError(state, 'tag suffix cannot contain flow indicator characters');
|
|
}
|
|
}
|
|
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
throwError(state, 'tag name cannot contain such characters: ' + tagName);
|
|
}
|
|
if (isVerbatim) {
|
|
state.tag = tagName;
|
|
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
state.tag = state.tagMap[tagHandle] + tagName;
|
|
} else if ('!' === tagHandle) {
|
|
state.tag = '!' + tagName;
|
|
} else if ('!!' === tagHandle) {
|
|
state.tag = 'tag:yaml.org,2002:' + tagName;
|
|
} else {
|
|
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
}
|
|
return true;
|
|
}
|
|
function readAnchorProperty(state) {
|
|
var _position,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x26 !== ch) {
|
|
return false;
|
|
}
|
|
if (null !== state.anchor) {
|
|
throwError(state, 'duplication of an anchor property');
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
_position = state.position;
|
|
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (state.position === _position) {
|
|
throwError(state, 'name of an anchor node must contain at least one character');
|
|
}
|
|
state.anchor = state.input.slice(_position, state.position);
|
|
return true;
|
|
}
|
|
function readAlias(state) {
|
|
var _position,
|
|
alias,
|
|
ch;
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (0x2A !== ch) {
|
|
return false;
|
|
}
|
|
ch = state.input.charCodeAt(++state.position);
|
|
_position = state.position;
|
|
while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (state.position === _position) {
|
|
throwError(state, 'name of an alias node must contain at least one character');
|
|
}
|
|
alias = state.input.slice(_position, state.position);
|
|
if (!state.anchorMap.hasOwnProperty(alias)) {
|
|
throwError(state, 'unidentified alias "' + alias + '"');
|
|
}
|
|
state.result = state.anchorMap[alias];
|
|
skipSeparationSpace(state, true, -1);
|
|
return true;
|
|
}
|
|
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
var allowBlockStyles,
|
|
allowBlockScalars,
|
|
allowBlockCollections,
|
|
indentStatus = 1,
|
|
atNewLine = false,
|
|
hasContent = false,
|
|
typeIndex,
|
|
typeQuantity,
|
|
type,
|
|
flowIndent,
|
|
blockIndent;
|
|
state.tag = null;
|
|
state.anchor = null;
|
|
state.kind = null;
|
|
state.result = null;
|
|
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
if (allowToSeek) {
|
|
if (skipSeparationSpace(state, true, -1)) {
|
|
atNewLine = true;
|
|
if (state.lineIndent > parentIndent) {
|
|
indentStatus = 1;
|
|
} else if (state.lineIndent === parentIndent) {
|
|
indentStatus = 0;
|
|
} else if (state.lineIndent < parentIndent) {
|
|
indentStatus = -1;
|
|
}
|
|
}
|
|
}
|
|
if (1 === indentStatus) {
|
|
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
if (skipSeparationSpace(state, true, -1)) {
|
|
atNewLine = true;
|
|
allowBlockCollections = allowBlockStyles;
|
|
if (state.lineIndent > parentIndent) {
|
|
indentStatus = 1;
|
|
} else if (state.lineIndent === parentIndent) {
|
|
indentStatus = 0;
|
|
} else if (state.lineIndent < parentIndent) {
|
|
indentStatus = -1;
|
|
}
|
|
} else {
|
|
allowBlockCollections = false;
|
|
}
|
|
}
|
|
}
|
|
if (allowBlockCollections) {
|
|
allowBlockCollections = atNewLine || allowCompact;
|
|
}
|
|
if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
flowIndent = parentIndent;
|
|
} else {
|
|
flowIndent = parentIndent + 1;
|
|
}
|
|
blockIndent = state.position - state.lineStart;
|
|
if (1 === indentStatus) {
|
|
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
hasContent = true;
|
|
} else {
|
|
if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
hasContent = true;
|
|
} else if (readAlias(state)) {
|
|
hasContent = true;
|
|
if (null !== state.tag || null !== state.anchor) {
|
|
throwError(state, 'alias node should not have any properties');
|
|
}
|
|
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
hasContent = true;
|
|
if (null === state.tag) {
|
|
state.tag = '?';
|
|
}
|
|
}
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = state.result;
|
|
}
|
|
}
|
|
} else if (0 === indentStatus) {
|
|
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
}
|
|
}
|
|
if (null !== state.tag && '!' !== state.tag) {
|
|
if ('?' === state.tag) {
|
|
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
type = state.implicitTypes[typeIndex];
|
|
if (type.resolve(state.result)) {
|
|
state.result = type.construct(state.result);
|
|
state.tag = type.tag;
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = state.result;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
} else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
|
|
type = state.typeMap[state.tag];
|
|
if (null !== state.result && type.kind !== state.kind) {
|
|
throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
}
|
|
if (!type.resolve(state.result)) {
|
|
throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
|
|
} else {
|
|
state.result = type.construct(state.result);
|
|
if (null !== state.anchor) {
|
|
state.anchorMap[state.anchor] = state.result;
|
|
}
|
|
}
|
|
} else {
|
|
throwError(state, 'unknown tag !<' + state.tag + '>');
|
|
}
|
|
}
|
|
return null !== state.tag || null !== state.anchor || hasContent;
|
|
}
|
|
function readDocument(state) {
|
|
var documentStart = state.position,
|
|
_position,
|
|
directiveName,
|
|
directiveArgs,
|
|
hasDirectives = false,
|
|
ch;
|
|
state.version = null;
|
|
state.checkLineBreaks = state.legacy;
|
|
state.tagMap = {};
|
|
state.anchorMap = {};
|
|
while (0 !== (ch = state.input.charCodeAt(state.position))) {
|
|
skipSeparationSpace(state, true, -1);
|
|
ch = state.input.charCodeAt(state.position);
|
|
if (state.lineIndent > 0 || 0x25 !== ch) {
|
|
break;
|
|
}
|
|
hasDirectives = true;
|
|
ch = state.input.charCodeAt(++state.position);
|
|
_position = state.position;
|
|
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
directiveName = state.input.slice(_position, state.position);
|
|
directiveArgs = [];
|
|
if (directiveName.length < 1) {
|
|
throwError(state, 'directive name must not be less than one character in length');
|
|
}
|
|
while (0 !== ch) {
|
|
while (is_WHITE_SPACE(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
if (0x23 === ch) {
|
|
do {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
} while (0 !== ch && !is_EOL(ch));
|
|
break;
|
|
}
|
|
if (is_EOL(ch)) {
|
|
break;
|
|
}
|
|
_position = state.position;
|
|
while (0 !== ch && !is_WS_OR_EOL(ch)) {
|
|
ch = state.input.charCodeAt(++state.position);
|
|
}
|
|
directiveArgs.push(state.input.slice(_position, state.position));
|
|
}
|
|
if (0 !== ch) {
|
|
readLineBreak(state);
|
|
}
|
|
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
} else {
|
|
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
}
|
|
}
|
|
skipSeparationSpace(state, true, -1);
|
|
if (0 === state.lineIndent && 0x2D === state.input.charCodeAt(state.position) && 0x2D === state.input.charCodeAt(state.position + 1) && 0x2D === state.input.charCodeAt(state.position + 2)) {
|
|
state.position += 3;
|
|
skipSeparationSpace(state, true, -1);
|
|
} else if (hasDirectives) {
|
|
throwError(state, 'directives end mark is expected');
|
|
}
|
|
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
skipSeparationSpace(state, true, -1);
|
|
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
throwWarning(state, 'non-ASCII line breaks are interpreted as content');
|
|
}
|
|
state.documents.push(state.result);
|
|
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
if (0x2E === state.input.charCodeAt(state.position)) {
|
|
state.position += 3;
|
|
skipSeparationSpace(state, true, -1);
|
|
}
|
|
return;
|
|
}
|
|
if (state.position < (state.length - 1)) {
|
|
throwError(state, 'end of the stream or a document separator is expected');
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
function loadDocuments(input, options) {
|
|
input = String(input);
|
|
options = options || {};
|
|
if (input.length !== 0) {
|
|
if (0x0A !== input.charCodeAt(input.length - 1) && 0x0D !== input.charCodeAt(input.length - 1)) {
|
|
input += '\n';
|
|
}
|
|
if (input.charCodeAt(0) === 0xFEFF) {
|
|
input = input.slice(1);
|
|
}
|
|
}
|
|
var state = new State(input, options);
|
|
if (PATTERN_NON_PRINTABLE.test(state.input)) {
|
|
throwError(state, 'the stream contains non-printable characters');
|
|
}
|
|
state.input += '\0';
|
|
while (0x20 === state.input.charCodeAt(state.position)) {
|
|
state.lineIndent += 1;
|
|
state.position += 1;
|
|
}
|
|
while (state.position < (state.length - 1)) {
|
|
readDocument(state);
|
|
}
|
|
return state.documents;
|
|
}
|
|
function loadAll(input, iterator, options) {
|
|
var documents = loadDocuments(input, options),
|
|
index,
|
|
length;
|
|
for (index = 0, length = documents.length; index < length; index += 1) {
|
|
iterator(documents[index]);
|
|
}
|
|
}
|
|
function load(input, options) {
|
|
var documents = loadDocuments(input, options);
|
|
if (0 === documents.length) {
|
|
return undefined;
|
|
} else if (1 === documents.length) {
|
|
return documents[0];
|
|
}
|
|
throw new YAMLException('expected a single document in the stream, but found more');
|
|
}
|
|
function safeLoadAll(input, output, options) {
|
|
loadAll(input, output, common.extend({schema: DEFAULT_SAFE_SCHEMA}, options));
|
|
}
|
|
function safeLoad(input, options) {
|
|
return load(input, common.extend({schema: DEFAULT_SAFE_SCHEMA}, options));
|
|
}
|
|
module.exports.loadAll = loadAll;
|
|
module.exports.load = load;
|
|
module.exports.safeLoadAll = safeLoadAll;
|
|
module.exports.safeLoad = safeLoad;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("146", ["141", "143", "145", "144"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
var YAMLException = $__require('143');
|
|
var DEFAULT_FULL_SCHEMA = $__require('145');
|
|
var DEFAULT_SAFE_SCHEMA = $__require('144');
|
|
var _toString = Object.prototype.toString;
|
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
var CHAR_TAB = 0x09;
|
|
var CHAR_LINE_FEED = 0x0A;
|
|
var CHAR_CARRIAGE_RETURN = 0x0D;
|
|
var CHAR_SPACE = 0x20;
|
|
var CHAR_EXCLAMATION = 0x21;
|
|
var CHAR_DOUBLE_QUOTE = 0x22;
|
|
var CHAR_SHARP = 0x23;
|
|
var CHAR_PERCENT = 0x25;
|
|
var CHAR_AMPERSAND = 0x26;
|
|
var CHAR_SINGLE_QUOTE = 0x27;
|
|
var CHAR_ASTERISK = 0x2A;
|
|
var CHAR_COMMA = 0x2C;
|
|
var CHAR_MINUS = 0x2D;
|
|
var CHAR_COLON = 0x3A;
|
|
var CHAR_GREATER_THAN = 0x3E;
|
|
var CHAR_QUESTION = 0x3F;
|
|
var CHAR_COMMERCIAL_AT = 0x40;
|
|
var CHAR_LEFT_SQUARE_BRACKET = 0x5B;
|
|
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D;
|
|
var CHAR_GRAVE_ACCENT = 0x60;
|
|
var CHAR_LEFT_CURLY_BRACKET = 0x7B;
|
|
var CHAR_VERTICAL_LINE = 0x7C;
|
|
var CHAR_RIGHT_CURLY_BRACKET = 0x7D;
|
|
var ESCAPE_SEQUENCES = {};
|
|
ESCAPE_SEQUENCES[0x00] = '\\0';
|
|
ESCAPE_SEQUENCES[0x07] = '\\a';
|
|
ESCAPE_SEQUENCES[0x08] = '\\b';
|
|
ESCAPE_SEQUENCES[0x09] = '\\t';
|
|
ESCAPE_SEQUENCES[0x0A] = '\\n';
|
|
ESCAPE_SEQUENCES[0x0B] = '\\v';
|
|
ESCAPE_SEQUENCES[0x0C] = '\\f';
|
|
ESCAPE_SEQUENCES[0x0D] = '\\r';
|
|
ESCAPE_SEQUENCES[0x1B] = '\\e';
|
|
ESCAPE_SEQUENCES[0x22] = '\\"';
|
|
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
|
ESCAPE_SEQUENCES[0x85] = '\\N';
|
|
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
|
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
|
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
|
var DEPRECATED_BOOLEANS_SYNTAX = ['y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'];
|
|
function compileStyleMap(schema, map) {
|
|
var result,
|
|
keys,
|
|
index,
|
|
length,
|
|
tag,
|
|
style,
|
|
type;
|
|
if (null === map) {
|
|
return {};
|
|
}
|
|
result = {};
|
|
keys = Object.keys(map);
|
|
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
tag = keys[index];
|
|
style = String(map[tag]);
|
|
if ('!!' === tag.slice(0, 2)) {
|
|
tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
|
}
|
|
type = schema.compiledTypeMap[tag];
|
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
style = type.styleAliases[style];
|
|
}
|
|
result[tag] = style;
|
|
}
|
|
return result;
|
|
}
|
|
function encodeHex(character) {
|
|
var string,
|
|
handle,
|
|
length;
|
|
string = character.toString(16).toUpperCase();
|
|
if (character <= 0xFF) {
|
|
handle = 'x';
|
|
length = 2;
|
|
} else if (character <= 0xFFFF) {
|
|
handle = 'u';
|
|
length = 4;
|
|
} else if (character <= 0xFFFFFFFF) {
|
|
handle = 'U';
|
|
length = 8;
|
|
} else {
|
|
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
|
|
}
|
|
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
|
}
|
|
function State(options) {
|
|
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
|
this.indent = Math.max(1, (options['indent'] || 2));
|
|
this.skipInvalid = options['skipInvalid'] || false;
|
|
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
|
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
|
this.sortKeys = options['sortKeys'] || false;
|
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
this.explicitTypes = this.schema.compiledExplicit;
|
|
this.tag = null;
|
|
this.result = '';
|
|
this.duplicates = [];
|
|
this.usedDuplicates = null;
|
|
}
|
|
function indentString(string, spaces) {
|
|
var ind = common.repeat(' ', spaces),
|
|
position = 0,
|
|
next = -1,
|
|
result = '',
|
|
line,
|
|
length = string.length;
|
|
while (position < length) {
|
|
next = string.indexOf('\n', position);
|
|
if (next === -1) {
|
|
line = string.slice(position);
|
|
position = length;
|
|
} else {
|
|
line = string.slice(position, next + 1);
|
|
position = next + 1;
|
|
}
|
|
if (line.length && line !== '\n') {
|
|
result += ind;
|
|
}
|
|
result += line;
|
|
}
|
|
return result;
|
|
}
|
|
function generateNextLine(state, level) {
|
|
return '\n' + common.repeat(' ', state.indent * level);
|
|
}
|
|
function testImplicitResolving(state, str) {
|
|
var index,
|
|
length,
|
|
type;
|
|
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
type = state.implicitTypes[index];
|
|
if (type.resolve(str)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function StringBuilder(source) {
|
|
this.source = source;
|
|
this.result = '';
|
|
this.checkpoint = 0;
|
|
}
|
|
StringBuilder.prototype.takeUpTo = function(position) {
|
|
var er;
|
|
if (position < this.checkpoint) {
|
|
er = new Error('position should be > checkpoint');
|
|
er.position = position;
|
|
er.checkpoint = this.checkpoint;
|
|
throw er;
|
|
}
|
|
this.result += this.source.slice(this.checkpoint, position);
|
|
this.checkpoint = position;
|
|
return this;
|
|
};
|
|
StringBuilder.prototype.escapeChar = function() {
|
|
var character,
|
|
esc;
|
|
character = this.source.charCodeAt(this.checkpoint);
|
|
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
|
|
this.result += esc;
|
|
this.checkpoint += 1;
|
|
return this;
|
|
};
|
|
StringBuilder.prototype.finish = function() {
|
|
if (this.source.length > this.checkpoint) {
|
|
this.takeUpTo(this.source.length);
|
|
}
|
|
};
|
|
function writeScalar(state, object, level, iskey) {
|
|
var simple,
|
|
first,
|
|
spaceWrap,
|
|
folded,
|
|
literal,
|
|
single,
|
|
double,
|
|
sawLineFeed,
|
|
linePosition,
|
|
longestLine,
|
|
indent,
|
|
max,
|
|
character,
|
|
position,
|
|
escapeSeq,
|
|
hexEsc,
|
|
previous,
|
|
lineLength,
|
|
modifier,
|
|
trailingLineBreaks,
|
|
result;
|
|
if (0 === object.length) {
|
|
state.dump = "''";
|
|
return;
|
|
}
|
|
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
|
state.dump = "'" + object + "'";
|
|
return;
|
|
}
|
|
simple = true;
|
|
first = object.length ? object.charCodeAt(0) : 0;
|
|
spaceWrap = (CHAR_SPACE === first || CHAR_SPACE === object.charCodeAt(object.length - 1));
|
|
if (CHAR_MINUS === first || CHAR_QUESTION === first || CHAR_COMMERCIAL_AT === first || CHAR_GRAVE_ACCENT === first) {
|
|
simple = false;
|
|
}
|
|
if (spaceWrap) {
|
|
simple = false;
|
|
folded = false;
|
|
literal = false;
|
|
} else {
|
|
folded = !iskey;
|
|
literal = !iskey;
|
|
}
|
|
single = true;
|
|
double = new StringBuilder(object);
|
|
sawLineFeed = false;
|
|
linePosition = 0;
|
|
longestLine = 0;
|
|
indent = state.indent * level;
|
|
max = 80;
|
|
if (indent < 40) {
|
|
max -= indent;
|
|
} else {
|
|
max = 40;
|
|
}
|
|
for (position = 0; position < object.length; position++) {
|
|
character = object.charCodeAt(position);
|
|
if (simple) {
|
|
if (!simpleChar(character)) {
|
|
simple = false;
|
|
} else {
|
|
continue;
|
|
}
|
|
}
|
|
if (single && character === CHAR_SINGLE_QUOTE) {
|
|
single = false;
|
|
}
|
|
escapeSeq = ESCAPE_SEQUENCES[character];
|
|
hexEsc = needsHexEscape(character);
|
|
if (!escapeSeq && !hexEsc) {
|
|
continue;
|
|
}
|
|
if (character !== CHAR_LINE_FEED && character !== CHAR_DOUBLE_QUOTE && character !== CHAR_SINGLE_QUOTE) {
|
|
folded = false;
|
|
literal = false;
|
|
} else if (character === CHAR_LINE_FEED) {
|
|
sawLineFeed = true;
|
|
single = false;
|
|
if (position > 0) {
|
|
previous = object.charCodeAt(position - 1);
|
|
if (previous === CHAR_SPACE) {
|
|
literal = false;
|
|
folded = false;
|
|
}
|
|
}
|
|
if (folded) {
|
|
lineLength = position - linePosition;
|
|
linePosition = position;
|
|
if (lineLength > longestLine) {
|
|
longestLine = lineLength;
|
|
}
|
|
}
|
|
}
|
|
if (character !== CHAR_DOUBLE_QUOTE) {
|
|
single = false;
|
|
}
|
|
double.takeUpTo(position);
|
|
double.escapeChar();
|
|
}
|
|
if (simple && testImplicitResolving(state, object)) {
|
|
simple = false;
|
|
}
|
|
modifier = '';
|
|
if (folded || literal) {
|
|
trailingLineBreaks = 0;
|
|
if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) {
|
|
trailingLineBreaks += 1;
|
|
if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) {
|
|
trailingLineBreaks += 1;
|
|
}
|
|
}
|
|
if (trailingLineBreaks === 0) {
|
|
modifier = '-';
|
|
} else if (trailingLineBreaks === 2) {
|
|
modifier = '+';
|
|
}
|
|
}
|
|
if (literal && longestLine < max) {
|
|
folded = false;
|
|
}
|
|
if (!sawLineFeed) {
|
|
literal = false;
|
|
}
|
|
if (simple) {
|
|
state.dump = object;
|
|
} else if (single) {
|
|
state.dump = '\'' + object + '\'';
|
|
} else if (folded) {
|
|
result = fold(object, max);
|
|
state.dump = '>' + modifier + '\n' + indentString(result, indent);
|
|
} else if (literal) {
|
|
if (!modifier) {
|
|
object = object.replace(/\n$/, '');
|
|
}
|
|
state.dump = '|' + modifier + '\n' + indentString(object, indent);
|
|
} else if (double) {
|
|
double.finish();
|
|
state.dump = '"' + double.result + '"';
|
|
} else {
|
|
throw new Error('Failed to dump scalar value');
|
|
}
|
|
return;
|
|
}
|
|
function fold(object, max) {
|
|
var result = '',
|
|
position = 0,
|
|
length = object.length,
|
|
trailing = /\n+$/.exec(object),
|
|
newLine;
|
|
if (trailing) {
|
|
length = trailing.index + 1;
|
|
}
|
|
while (position < length) {
|
|
newLine = object.indexOf('\n', position);
|
|
if (newLine > length || newLine === -1) {
|
|
if (result) {
|
|
result += '\n\n';
|
|
}
|
|
result += foldLine(object.slice(position, length), max);
|
|
position = length;
|
|
} else {
|
|
if (result) {
|
|
result += '\n\n';
|
|
}
|
|
result += foldLine(object.slice(position, newLine), max);
|
|
position = newLine + 1;
|
|
}
|
|
}
|
|
if (trailing && trailing[0] !== '\n') {
|
|
result += trailing[0];
|
|
}
|
|
return result;
|
|
}
|
|
function foldLine(line, max) {
|
|
if (line === '') {
|
|
return line;
|
|
}
|
|
var foldRe = /[^\s] [^\s]/g,
|
|
result = '',
|
|
prevMatch = 0,
|
|
foldStart = 0,
|
|
match = foldRe.exec(line),
|
|
index,
|
|
foldEnd,
|
|
folded;
|
|
while (match) {
|
|
index = match.index;
|
|
if (index - foldStart > max) {
|
|
if (prevMatch !== foldStart) {
|
|
foldEnd = prevMatch;
|
|
} else {
|
|
foldEnd = index;
|
|
}
|
|
if (result) {
|
|
result += '\n';
|
|
}
|
|
folded = line.slice(foldStart, foldEnd);
|
|
result += folded;
|
|
foldStart = foldEnd + 1;
|
|
}
|
|
prevMatch = index + 1;
|
|
match = foldRe.exec(line);
|
|
}
|
|
if (result) {
|
|
result += '\n';
|
|
}
|
|
if (foldStart !== prevMatch && line.length - foldStart > max) {
|
|
result += line.slice(foldStart, prevMatch) + '\n' + line.slice(prevMatch + 1);
|
|
} else {
|
|
result += line.slice(foldStart);
|
|
}
|
|
return result;
|
|
}
|
|
function simpleChar(character) {
|
|
return CHAR_TAB !== character && CHAR_LINE_FEED !== character && CHAR_CARRIAGE_RETURN !== character && CHAR_COMMA !== character && CHAR_LEFT_SQUARE_BRACKET !== character && CHAR_RIGHT_SQUARE_BRACKET !== character && CHAR_LEFT_CURLY_BRACKET !== character && CHAR_RIGHT_CURLY_BRACKET !== character && CHAR_SHARP !== character && CHAR_AMPERSAND !== character && CHAR_ASTERISK !== character && CHAR_EXCLAMATION !== character && CHAR_VERTICAL_LINE !== character && CHAR_GREATER_THAN !== character && CHAR_SINGLE_QUOTE !== character && CHAR_DOUBLE_QUOTE !== character && CHAR_PERCENT !== character && CHAR_COLON !== character && !ESCAPE_SEQUENCES[character] && !needsHexEscape(character);
|
|
}
|
|
function needsHexEscape(character) {
|
|
return !((0x00020 <= character && character <= 0x00007E) || (0x00085 === character) || (0x000A0 <= character && character <= 0x00D7FF) || (0x0E000 <= character && character <= 0x00FFFD) || (0x10000 <= character && character <= 0x10FFFF));
|
|
}
|
|
function writeFlowSequence(state, level, object) {
|
|
var _result = '',
|
|
_tag = state.tag,
|
|
index,
|
|
length;
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
if (writeNode(state, level, object[index], false, false)) {
|
|
if (0 !== index) {
|
|
_result += ', ';
|
|
}
|
|
_result += state.dump;
|
|
}
|
|
}
|
|
state.tag = _tag;
|
|
state.dump = '[' + _result + ']';
|
|
}
|
|
function writeBlockSequence(state, level, object, compact) {
|
|
var _result = '',
|
|
_tag = state.tag,
|
|
index,
|
|
length;
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
if (writeNode(state, level + 1, object[index], true, true)) {
|
|
if (!compact || 0 !== index) {
|
|
_result += generateNextLine(state, level);
|
|
}
|
|
_result += '- ' + state.dump;
|
|
}
|
|
}
|
|
state.tag = _tag;
|
|
state.dump = _result || '[]';
|
|
}
|
|
function writeFlowMapping(state, level, object) {
|
|
var _result = '',
|
|
_tag = state.tag,
|
|
objectKeyList = Object.keys(object),
|
|
index,
|
|
length,
|
|
objectKey,
|
|
objectValue,
|
|
pairBuffer;
|
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
pairBuffer = '';
|
|
if (0 !== index) {
|
|
pairBuffer += ', ';
|
|
}
|
|
objectKey = objectKeyList[index];
|
|
objectValue = object[objectKey];
|
|
if (!writeNode(state, level, objectKey, false, false)) {
|
|
continue;
|
|
}
|
|
if (state.dump.length > 1024) {
|
|
pairBuffer += '? ';
|
|
}
|
|
pairBuffer += state.dump + ': ';
|
|
if (!writeNode(state, level, objectValue, false, false)) {
|
|
continue;
|
|
}
|
|
pairBuffer += state.dump;
|
|
_result += pairBuffer;
|
|
}
|
|
state.tag = _tag;
|
|
state.dump = '{' + _result + '}';
|
|
}
|
|
function writeBlockMapping(state, level, object, compact) {
|
|
var _result = '',
|
|
_tag = state.tag,
|
|
objectKeyList = Object.keys(object),
|
|
index,
|
|
length,
|
|
objectKey,
|
|
objectValue,
|
|
explicitPair,
|
|
pairBuffer;
|
|
if (state.sortKeys === true) {
|
|
objectKeyList.sort();
|
|
} else if (typeof state.sortKeys === 'function') {
|
|
objectKeyList.sort(state.sortKeys);
|
|
} else if (state.sortKeys) {
|
|
throw new YAMLException('sortKeys must be a boolean or a function');
|
|
}
|
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
pairBuffer = '';
|
|
if (!compact || 0 !== index) {
|
|
pairBuffer += generateNextLine(state, level);
|
|
}
|
|
objectKey = objectKeyList[index];
|
|
objectValue = object[objectKey];
|
|
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
continue;
|
|
}
|
|
explicitPair = (null !== state.tag && '?' !== state.tag) || (state.dump && state.dump.length > 1024);
|
|
if (explicitPair) {
|
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
pairBuffer += '?';
|
|
} else {
|
|
pairBuffer += '? ';
|
|
}
|
|
}
|
|
pairBuffer += state.dump;
|
|
if (explicitPair) {
|
|
pairBuffer += generateNextLine(state, level);
|
|
}
|
|
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
continue;
|
|
}
|
|
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
pairBuffer += ':';
|
|
} else {
|
|
pairBuffer += ': ';
|
|
}
|
|
pairBuffer += state.dump;
|
|
_result += pairBuffer;
|
|
}
|
|
state.tag = _tag;
|
|
state.dump = _result || '{}';
|
|
}
|
|
function detectType(state, object, explicit) {
|
|
var _result,
|
|
typeList,
|
|
index,
|
|
length,
|
|
type,
|
|
style;
|
|
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
type = typeList[index];
|
|
if ((type.instanceOf || type.predicate) && (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) && (!type.predicate || type.predicate(object))) {
|
|
state.tag = explicit ? type.tag : '?';
|
|
if (type.represent) {
|
|
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
if ('[object Function]' === _toString.call(type.represent)) {
|
|
_result = type.represent(object, style);
|
|
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
_result = type.represent[style](object, style);
|
|
} else {
|
|
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
}
|
|
state.dump = _result;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function writeNode(state, level, object, block, compact, iskey) {
|
|
state.tag = null;
|
|
state.dump = object;
|
|
if (!detectType(state, object, false)) {
|
|
detectType(state, object, true);
|
|
}
|
|
var type = _toString.call(state.dump);
|
|
if (block) {
|
|
block = (0 > state.flowLevel || state.flowLevel > level);
|
|
}
|
|
var objectOrArray = '[object Object]' === type || '[object Array]' === type,
|
|
duplicateIndex,
|
|
duplicate;
|
|
if (objectOrArray) {
|
|
duplicateIndex = state.duplicates.indexOf(object);
|
|
duplicate = duplicateIndex !== -1;
|
|
}
|
|
if ((null !== state.tag && '?' !== state.tag) || duplicate || (2 !== state.indent && level > 0)) {
|
|
compact = false;
|
|
}
|
|
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
state.dump = '*ref_' + duplicateIndex;
|
|
} else {
|
|
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
state.usedDuplicates[duplicateIndex] = true;
|
|
}
|
|
if ('[object Object]' === type) {
|
|
if (block && (0 !== Object.keys(state.dump).length)) {
|
|
writeBlockMapping(state, level, state.dump, compact);
|
|
if (duplicate) {
|
|
state.dump = '&ref_' + duplicateIndex + state.dump;
|
|
}
|
|
} else {
|
|
writeFlowMapping(state, level, state.dump);
|
|
if (duplicate) {
|
|
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
|
}
|
|
}
|
|
} else if ('[object Array]' === type) {
|
|
if (block && (0 !== state.dump.length)) {
|
|
writeBlockSequence(state, level, state.dump, compact);
|
|
if (duplicate) {
|
|
state.dump = '&ref_' + duplicateIndex + state.dump;
|
|
}
|
|
} else {
|
|
writeFlowSequence(state, level, state.dump);
|
|
if (duplicate) {
|
|
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
|
}
|
|
}
|
|
} else if ('[object String]' === type) {
|
|
if ('?' !== state.tag) {
|
|
writeScalar(state, state.dump, level, iskey);
|
|
}
|
|
} else {
|
|
if (state.skipInvalid) {
|
|
return false;
|
|
}
|
|
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
|
}
|
|
if (null !== state.tag && '?' !== state.tag) {
|
|
state.dump = '!<' + state.tag + '> ' + state.dump;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function getDuplicateReferences(object, state) {
|
|
var objects = [],
|
|
duplicatesIndexes = [],
|
|
index,
|
|
length;
|
|
inspectNode(object, objects, duplicatesIndexes);
|
|
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
}
|
|
state.usedDuplicates = new Array(length);
|
|
}
|
|
function inspectNode(object, objects, duplicatesIndexes) {
|
|
var objectKeyList,
|
|
index,
|
|
length;
|
|
if (null !== object && 'object' === typeof object) {
|
|
index = objects.indexOf(object);
|
|
if (-1 !== index) {
|
|
if (-1 === duplicatesIndexes.indexOf(index)) {
|
|
duplicatesIndexes.push(index);
|
|
}
|
|
} else {
|
|
objects.push(object);
|
|
if (Array.isArray(object)) {
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
inspectNode(object[index], objects, duplicatesIndexes);
|
|
}
|
|
} else {
|
|
objectKeyList = Object.keys(object);
|
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function dump(input, options) {
|
|
options = options || {};
|
|
var state = new State(options);
|
|
getDuplicateReferences(input, state);
|
|
if (writeNode(state, 0, input, true, true)) {
|
|
return state.dump + '\n';
|
|
}
|
|
return '';
|
|
}
|
|
function safeDump(input, options) {
|
|
return dump(input, common.extend({schema: DEFAULT_SAFE_SCHEMA}, options));
|
|
}
|
|
module.exports.dump = dump;
|
|
module.exports.safeDump = safeDump;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("147", ["141", "143", "148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
var YAMLException = $__require('143');
|
|
var Type = $__require('148');
|
|
function compileList(schema, name, result) {
|
|
var exclude = [];
|
|
schema.include.forEach(function(includedSchema) {
|
|
result = compileList(includedSchema, name, result);
|
|
});
|
|
schema[name].forEach(function(currentType) {
|
|
result.forEach(function(previousType, previousIndex) {
|
|
if (previousType.tag === currentType.tag) {
|
|
exclude.push(previousIndex);
|
|
}
|
|
});
|
|
result.push(currentType);
|
|
});
|
|
return result.filter(function(type, index) {
|
|
return -1 === exclude.indexOf(index);
|
|
});
|
|
}
|
|
function compileMap() {
|
|
var result = {},
|
|
index,
|
|
length;
|
|
function collectType(type) {
|
|
result[type.tag] = type;
|
|
}
|
|
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
arguments[index].forEach(collectType);
|
|
}
|
|
return result;
|
|
}
|
|
function Schema(definition) {
|
|
this.include = definition.include || [];
|
|
this.implicit = definition.implicit || [];
|
|
this.explicit = definition.explicit || [];
|
|
this.implicit.forEach(function(type) {
|
|
if (type.loadKind && 'scalar' !== type.loadKind) {
|
|
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
|
}
|
|
});
|
|
this.compiledImplicit = compileList(this, 'implicit', []);
|
|
this.compiledExplicit = compileList(this, 'explicit', []);
|
|
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
|
}
|
|
Schema.DEFAULT = null;
|
|
Schema.create = function createSchema() {
|
|
var schemas,
|
|
types;
|
|
switch (arguments.length) {
|
|
case 1:
|
|
schemas = Schema.DEFAULT;
|
|
types = arguments[0];
|
|
break;
|
|
case 2:
|
|
schemas = arguments[0];
|
|
types = arguments[1];
|
|
break;
|
|
default:
|
|
throw new YAMLException('Wrong number of arguments for Schema.create function');
|
|
}
|
|
schemas = common.toArray(schemas);
|
|
types = common.toArray(types);
|
|
if (!schemas.every(function(schema) {
|
|
return schema instanceof Schema;
|
|
})) {
|
|
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
|
|
}
|
|
if (!types.every(function(type) {
|
|
return type instanceof Type;
|
|
})) {
|
|
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
|
}
|
|
return new Schema({
|
|
include: schemas,
|
|
explicit: types
|
|
});
|
|
};
|
|
module.exports = Schema;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("149", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
module.exports = new Type('tag:yaml.org,2002:str', {
|
|
kind: 'scalar',
|
|
construct: function(data) {
|
|
return null !== data ? data : '';
|
|
}
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14a", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
module.exports = new Type('tag:yaml.org,2002:seq', {
|
|
kind: 'sequence',
|
|
construct: function(data) {
|
|
return null !== data ? data : [];
|
|
}
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14b", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
module.exports = new Type('tag:yaml.org,2002:map', {
|
|
kind: 'mapping',
|
|
construct: function(data) {
|
|
return null !== data ? data : {};
|
|
}
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14c", ["147", "149", "14a", "14b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Schema = $__require('147');
|
|
module.exports = new Schema({explicit: [$__require('149'), $__require('14a'), $__require('14b')]});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14d", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
function resolveYamlNull(data) {
|
|
if (null === data) {
|
|
return true;
|
|
}
|
|
var max = data.length;
|
|
return (max === 1 && data === '~') || (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
|
}
|
|
function constructYamlNull() {
|
|
return null;
|
|
}
|
|
function isNull(object) {
|
|
return null === object;
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:null', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlNull,
|
|
construct: constructYamlNull,
|
|
predicate: isNull,
|
|
represent: {
|
|
canonical: function() {
|
|
return '~';
|
|
},
|
|
lowercase: function() {
|
|
return 'null';
|
|
},
|
|
uppercase: function() {
|
|
return 'NULL';
|
|
},
|
|
camelcase: function() {
|
|
return 'Null';
|
|
}
|
|
},
|
|
defaultStyle: 'lowercase'
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14e", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
function resolveYamlBoolean(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
var max = data.length;
|
|
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
|
}
|
|
function constructYamlBoolean(data) {
|
|
return data === 'true' || data === 'True' || data === 'TRUE';
|
|
}
|
|
function isBoolean(object) {
|
|
return '[object Boolean]' === Object.prototype.toString.call(object);
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:bool', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlBoolean,
|
|
construct: constructYamlBoolean,
|
|
predicate: isBoolean,
|
|
represent: {
|
|
lowercase: function(object) {
|
|
return object ? 'true' : 'false';
|
|
},
|
|
uppercase: function(object) {
|
|
return object ? 'TRUE' : 'FALSE';
|
|
},
|
|
camelcase: function(object) {
|
|
return object ? 'True' : 'False';
|
|
}
|
|
},
|
|
defaultStyle: 'lowercase'
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14f", ["141", "148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
var Type = $__require('148');
|
|
function isHexCode(c) {
|
|
return ((0x30 <= c) && (c <= 0x39)) || ((0x41 <= c) && (c <= 0x46)) || ((0x61 <= c) && (c <= 0x66));
|
|
}
|
|
function isOctCode(c) {
|
|
return ((0x30 <= c) && (c <= 0x37));
|
|
}
|
|
function isDecCode(c) {
|
|
return ((0x30 <= c) && (c <= 0x39));
|
|
}
|
|
function resolveYamlInteger(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
var max = data.length,
|
|
index = 0,
|
|
hasDigits = false,
|
|
ch;
|
|
if (!max) {
|
|
return false;
|
|
}
|
|
ch = data[index];
|
|
if (ch === '-' || ch === '+') {
|
|
ch = data[++index];
|
|
}
|
|
if (ch === '0') {
|
|
if (index + 1 === max) {
|
|
return true;
|
|
}
|
|
ch = data[++index];
|
|
if (ch === 'b') {
|
|
index++;
|
|
for (; index < max; index++) {
|
|
ch = data[index];
|
|
if (ch === '_') {
|
|
continue;
|
|
}
|
|
if (ch !== '0' && ch !== '1') {
|
|
return false;
|
|
}
|
|
hasDigits = true;
|
|
}
|
|
return hasDigits;
|
|
}
|
|
if (ch === 'x') {
|
|
index++;
|
|
for (; index < max; index++) {
|
|
ch = data[index];
|
|
if (ch === '_') {
|
|
continue;
|
|
}
|
|
if (!isHexCode(data.charCodeAt(index))) {
|
|
return false;
|
|
}
|
|
hasDigits = true;
|
|
}
|
|
return hasDigits;
|
|
}
|
|
for (; index < max; index++) {
|
|
ch = data[index];
|
|
if (ch === '_') {
|
|
continue;
|
|
}
|
|
if (!isOctCode(data.charCodeAt(index))) {
|
|
return false;
|
|
}
|
|
hasDigits = true;
|
|
}
|
|
return hasDigits;
|
|
}
|
|
for (; index < max; index++) {
|
|
ch = data[index];
|
|
if (ch === '_') {
|
|
continue;
|
|
}
|
|
if (ch === ':') {
|
|
break;
|
|
}
|
|
if (!isDecCode(data.charCodeAt(index))) {
|
|
return false;
|
|
}
|
|
hasDigits = true;
|
|
}
|
|
if (!hasDigits) {
|
|
return false;
|
|
}
|
|
if (ch !== ':') {
|
|
return true;
|
|
}
|
|
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
}
|
|
function constructYamlInteger(data) {
|
|
var value = data,
|
|
sign = 1,
|
|
ch,
|
|
base,
|
|
digits = [];
|
|
if (value.indexOf('_') !== -1) {
|
|
value = value.replace(/_/g, '');
|
|
}
|
|
ch = value[0];
|
|
if (ch === '-' || ch === '+') {
|
|
if (ch === '-') {
|
|
sign = -1;
|
|
}
|
|
value = value.slice(1);
|
|
ch = value[0];
|
|
}
|
|
if ('0' === value) {
|
|
return 0;
|
|
}
|
|
if (ch === '0') {
|
|
if (value[1] === 'b') {
|
|
return sign * parseInt(value.slice(2), 2);
|
|
}
|
|
if (value[1] === 'x') {
|
|
return sign * parseInt(value, 16);
|
|
}
|
|
return sign * parseInt(value, 8);
|
|
}
|
|
if (value.indexOf(':') !== -1) {
|
|
value.split(':').forEach(function(v) {
|
|
digits.unshift(parseInt(v, 10));
|
|
});
|
|
value = 0;
|
|
base = 1;
|
|
digits.forEach(function(d) {
|
|
value += (d * base);
|
|
base *= 60;
|
|
});
|
|
return sign * value;
|
|
}
|
|
return sign * parseInt(value, 10);
|
|
}
|
|
function isInteger(object) {
|
|
return ('[object Number]' === Object.prototype.toString.call(object)) && (0 === object % 1 && !common.isNegativeZero(object));
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:int', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlInteger,
|
|
construct: constructYamlInteger,
|
|
predicate: isInteger,
|
|
represent: {
|
|
binary: function(object) {
|
|
return '0b' + object.toString(2);
|
|
},
|
|
octal: function(object) {
|
|
return '0' + object.toString(8);
|
|
},
|
|
decimal: function(object) {
|
|
return object.toString(10);
|
|
},
|
|
hexadecimal: function(object) {
|
|
return '0x' + object.toString(16).toUpperCase();
|
|
}
|
|
},
|
|
defaultStyle: 'decimal',
|
|
styleAliases: {
|
|
binary: [2, 'bin'],
|
|
octal: [8, 'oct'],
|
|
decimal: [10, 'dec'],
|
|
hexadecimal: [16, 'hex']
|
|
}
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("141", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function isNothing(subject) {
|
|
return (typeof subject === 'undefined') || (null === subject);
|
|
}
|
|
function isObject(subject) {
|
|
return (typeof subject === 'object') && (null !== subject);
|
|
}
|
|
function toArray(sequence) {
|
|
if (Array.isArray(sequence)) {
|
|
return sequence;
|
|
} else if (isNothing(sequence)) {
|
|
return [];
|
|
}
|
|
return [sequence];
|
|
}
|
|
function extend(target, source) {
|
|
var index,
|
|
length,
|
|
key,
|
|
sourceKeys;
|
|
if (source) {
|
|
sourceKeys = Object.keys(source);
|
|
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
key = sourceKeys[index];
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
function repeat(string, count) {
|
|
var result = '',
|
|
cycle;
|
|
for (cycle = 0; cycle < count; cycle += 1) {
|
|
result += string;
|
|
}
|
|
return result;
|
|
}
|
|
function isNegativeZero(number) {
|
|
return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
|
|
}
|
|
module.exports.isNothing = isNothing;
|
|
module.exports.isObject = isObject;
|
|
module.exports.toArray = toArray;
|
|
module.exports.repeat = repeat;
|
|
module.exports.isNegativeZero = isNegativeZero;
|
|
module.exports.extend = extend;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("150", ["141", "148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var common = $__require('141');
|
|
var Type = $__require('148');
|
|
var YAML_FLOAT_PATTERN = new RegExp('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' + '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' + '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + '|[-+]?\\.(?:inf|Inf|INF)' + '|\\.(?:nan|NaN|NAN))$');
|
|
function resolveYamlFloat(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
if (!YAML_FLOAT_PATTERN.test(data)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function constructYamlFloat(data) {
|
|
var value,
|
|
sign,
|
|
base,
|
|
digits;
|
|
value = data.replace(/_/g, '').toLowerCase();
|
|
sign = '-' === value[0] ? -1 : 1;
|
|
digits = [];
|
|
if (0 <= '+-'.indexOf(value[0])) {
|
|
value = value.slice(1);
|
|
}
|
|
if ('.inf' === value) {
|
|
return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
} else if ('.nan' === value) {
|
|
return NaN;
|
|
} else if (0 <= value.indexOf(':')) {
|
|
value.split(':').forEach(function(v) {
|
|
digits.unshift(parseFloat(v, 10));
|
|
});
|
|
value = 0.0;
|
|
base = 1;
|
|
digits.forEach(function(d) {
|
|
value += d * base;
|
|
base *= 60;
|
|
});
|
|
return sign * value;
|
|
}
|
|
return sign * parseFloat(value, 10);
|
|
}
|
|
function representYamlFloat(object, style) {
|
|
if (isNaN(object)) {
|
|
switch (style) {
|
|
case 'lowercase':
|
|
return '.nan';
|
|
case 'uppercase':
|
|
return '.NAN';
|
|
case 'camelcase':
|
|
return '.NaN';
|
|
}
|
|
} else if (Number.POSITIVE_INFINITY === object) {
|
|
switch (style) {
|
|
case 'lowercase':
|
|
return '.inf';
|
|
case 'uppercase':
|
|
return '.INF';
|
|
case 'camelcase':
|
|
return '.Inf';
|
|
}
|
|
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
switch (style) {
|
|
case 'lowercase':
|
|
return '-.inf';
|
|
case 'uppercase':
|
|
return '-.INF';
|
|
case 'camelcase':
|
|
return '-.Inf';
|
|
}
|
|
} else if (common.isNegativeZero(object)) {
|
|
return '-0.0';
|
|
}
|
|
return object.toString(10);
|
|
}
|
|
function isFloat(object) {
|
|
return ('[object Number]' === Object.prototype.toString.call(object)) && (0 !== object % 1 || common.isNegativeZero(object));
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:float', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlFloat,
|
|
construct: constructYamlFloat,
|
|
predicate: isFloat,
|
|
represent: representYamlFloat,
|
|
defaultStyle: 'lowercase'
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("151", ["147", "14c", "14d", "14e", "14f", "150"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Schema = $__require('147');
|
|
module.exports = new Schema({
|
|
include: [$__require('14c')],
|
|
implicit: [$__require('14d'), $__require('14e'), $__require('14f'), $__require('150')]
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("152", ["147", "151"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Schema = $__require('147');
|
|
module.exports = new Schema({include: [$__require('151')]});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("153", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
var YAML_TIMESTAMP_REGEXP = new RegExp('^([0-9][0-9][0-9][0-9])' + '-([0-9][0-9]?)' + '-([0-9][0-9]?)' + '(?:(?:[Tt]|[ \\t]+)' + '([0-9][0-9]?)' + ':([0-9][0-9])' + ':([0-9][0-9])' + '(?:\\.([0-9]*))?' + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + '(?::([0-9][0-9]))?))?)?$');
|
|
function resolveYamlTimestamp(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
if (YAML_TIMESTAMP_REGEXP.exec(data) === null) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function constructYamlTimestamp(data) {
|
|
var match,
|
|
year,
|
|
month,
|
|
day,
|
|
hour,
|
|
minute,
|
|
second,
|
|
fraction = 0,
|
|
delta = null,
|
|
tz_hour,
|
|
tz_minute,
|
|
date;
|
|
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
if (null === match) {
|
|
throw new Error('Date resolve error');
|
|
}
|
|
year = +(match[1]);
|
|
month = +(match[2]) - 1;
|
|
day = +(match[3]);
|
|
if (!match[4]) {
|
|
return new Date(Date.UTC(year, month, day));
|
|
}
|
|
hour = +(match[4]);
|
|
minute = +(match[5]);
|
|
second = +(match[6]);
|
|
if (match[7]) {
|
|
fraction = match[7].slice(0, 3);
|
|
while (fraction.length < 3) {
|
|
fraction += '0';
|
|
}
|
|
fraction = +fraction;
|
|
}
|
|
if (match[9]) {
|
|
tz_hour = +(match[10]);
|
|
tz_minute = +(match[11] || 0);
|
|
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
if ('-' === match[9]) {
|
|
delta = -delta;
|
|
}
|
|
}
|
|
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
if (delta) {
|
|
date.setTime(date.getTime() - delta);
|
|
}
|
|
return date;
|
|
}
|
|
function representYamlTimestamp(object) {
|
|
return object.toISOString();
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlTimestamp,
|
|
construct: constructYamlTimestamp,
|
|
instanceOf: Date,
|
|
represent: representYamlTimestamp
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("154", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
function resolveYamlMerge(data) {
|
|
return '<<' === data || null === data;
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:merge', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlMerge
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("155", ["@empty", "148"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
var NodeBuffer = $__require('@empty').Buffer;
|
|
var Type = $__require('148');
|
|
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
|
function resolveYamlBinary(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
var code,
|
|
idx,
|
|
bitlen = 0,
|
|
max = data.length,
|
|
map = BASE64_MAP;
|
|
for (idx = 0; idx < max; idx++) {
|
|
code = map.indexOf(data.charAt(idx));
|
|
if (code > 64) {
|
|
continue;
|
|
}
|
|
if (code < 0) {
|
|
return false;
|
|
}
|
|
bitlen += 6;
|
|
}
|
|
return (bitlen % 8) === 0;
|
|
}
|
|
function constructYamlBinary(data) {
|
|
var idx,
|
|
tailbits,
|
|
input = data.replace(/[\r\n=]/g, ''),
|
|
max = input.length,
|
|
map = BASE64_MAP,
|
|
bits = 0,
|
|
result = [];
|
|
for (idx = 0; idx < max; idx++) {
|
|
if ((idx % 4 === 0) && idx) {
|
|
result.push((bits >> 16) & 0xFF);
|
|
result.push((bits >> 8) & 0xFF);
|
|
result.push(bits & 0xFF);
|
|
}
|
|
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
|
}
|
|
tailbits = (max % 4) * 6;
|
|
if (tailbits === 0) {
|
|
result.push((bits >> 16) & 0xFF);
|
|
result.push((bits >> 8) & 0xFF);
|
|
result.push(bits & 0xFF);
|
|
} else if (tailbits === 18) {
|
|
result.push((bits >> 10) & 0xFF);
|
|
result.push((bits >> 2) & 0xFF);
|
|
} else if (tailbits === 12) {
|
|
result.push((bits >> 4) & 0xFF);
|
|
}
|
|
if (NodeBuffer) {
|
|
return new NodeBuffer(result);
|
|
}
|
|
return result;
|
|
}
|
|
function representYamlBinary(object) {
|
|
var result = '',
|
|
bits = 0,
|
|
idx,
|
|
tail,
|
|
max = object.length,
|
|
map = BASE64_MAP;
|
|
for (idx = 0; idx < max; idx++) {
|
|
if ((idx % 3 === 0) && idx) {
|
|
result += map[(bits >> 18) & 0x3F];
|
|
result += map[(bits >> 12) & 0x3F];
|
|
result += map[(bits >> 6) & 0x3F];
|
|
result += map[bits & 0x3F];
|
|
}
|
|
bits = (bits << 8) + object[idx];
|
|
}
|
|
tail = max % 3;
|
|
if (tail === 0) {
|
|
result += map[(bits >> 18) & 0x3F];
|
|
result += map[(bits >> 12) & 0x3F];
|
|
result += map[(bits >> 6) & 0x3F];
|
|
result += map[bits & 0x3F];
|
|
} else if (tail === 2) {
|
|
result += map[(bits >> 10) & 0x3F];
|
|
result += map[(bits >> 4) & 0x3F];
|
|
result += map[(bits << 2) & 0x3F];
|
|
result += map[64];
|
|
} else if (tail === 1) {
|
|
result += map[(bits >> 2) & 0x3F];
|
|
result += map[(bits << 4) & 0x3F];
|
|
result += map[64];
|
|
result += map[64];
|
|
}
|
|
return result;
|
|
}
|
|
function isBinary(object) {
|
|
return NodeBuffer && NodeBuffer.isBuffer(object);
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:binary', {
|
|
kind: 'scalar',
|
|
resolve: resolveYamlBinary,
|
|
construct: constructYamlBinary,
|
|
predicate: isBinary,
|
|
represent: representYamlBinary
|
|
});
|
|
})($__require('@empty').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("156", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
var _toString = Object.prototype.toString;
|
|
function resolveYamlOmap(data) {
|
|
if (null === data) {
|
|
return true;
|
|
}
|
|
var objectKeys = [],
|
|
index,
|
|
length,
|
|
pair,
|
|
pairKey,
|
|
pairHasKey,
|
|
object = data;
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
pair = object[index];
|
|
pairHasKey = false;
|
|
if ('[object Object]' !== _toString.call(pair)) {
|
|
return false;
|
|
}
|
|
for (pairKey in pair) {
|
|
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
if (!pairHasKey) {
|
|
pairHasKey = true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (!pairHasKey) {
|
|
return false;
|
|
}
|
|
if (-1 === objectKeys.indexOf(pairKey)) {
|
|
objectKeys.push(pairKey);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function constructYamlOmap(data) {
|
|
return null !== data ? data : [];
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:omap', {
|
|
kind: 'sequence',
|
|
resolve: resolveYamlOmap,
|
|
construct: constructYamlOmap
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("157", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
var _toString = Object.prototype.toString;
|
|
function resolveYamlPairs(data) {
|
|
if (null === data) {
|
|
return true;
|
|
}
|
|
var index,
|
|
length,
|
|
pair,
|
|
keys,
|
|
result,
|
|
object = data;
|
|
result = new Array(object.length);
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
pair = object[index];
|
|
if ('[object Object]' !== _toString.call(pair)) {
|
|
return false;
|
|
}
|
|
keys = Object.keys(pair);
|
|
if (1 !== keys.length) {
|
|
return false;
|
|
}
|
|
result[index] = [keys[0], pair[keys[0]]];
|
|
}
|
|
return true;
|
|
}
|
|
function constructYamlPairs(data) {
|
|
if (null === data) {
|
|
return [];
|
|
}
|
|
var index,
|
|
length,
|
|
pair,
|
|
keys,
|
|
result,
|
|
object = data;
|
|
result = new Array(object.length);
|
|
for (index = 0, length = object.length; index < length; index += 1) {
|
|
pair = object[index];
|
|
keys = Object.keys(pair);
|
|
result[index] = [keys[0], pair[keys[0]]];
|
|
}
|
|
return result;
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
|
kind: 'sequence',
|
|
resolve: resolveYamlPairs,
|
|
construct: constructYamlPairs
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("158", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
function resolveYamlSet(data) {
|
|
if (null === data) {
|
|
return true;
|
|
}
|
|
var key,
|
|
object = data;
|
|
for (key in object) {
|
|
if (_hasOwnProperty.call(object, key)) {
|
|
if (null !== object[key]) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function constructYamlSet(data) {
|
|
return null !== data ? data : {};
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:set', {
|
|
kind: 'mapping',
|
|
resolve: resolveYamlSet,
|
|
construct: constructYamlSet
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("144", ["147", "152", "153", "154", "155", "156", "157", "158"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Schema = $__require('147');
|
|
module.exports = new Schema({
|
|
include: [$__require('152')],
|
|
implicit: [$__require('153'), $__require('154')],
|
|
explicit: [$__require('155'), $__require('156'), $__require('157'), $__require('158')]
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("159", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
function resolveJavascriptUndefined() {
|
|
return true;
|
|
}
|
|
function constructJavascriptUndefined() {
|
|
return undefined;
|
|
}
|
|
function representJavascriptUndefined() {
|
|
return '';
|
|
}
|
|
function isUndefined(object) {
|
|
return 'undefined' === typeof object;
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
|
kind: 'scalar',
|
|
resolve: resolveJavascriptUndefined,
|
|
construct: constructJavascriptUndefined,
|
|
predicate: isUndefined,
|
|
represent: representJavascriptUndefined
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15a", ["148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Type = $__require('148');
|
|
function resolveJavascriptRegExp(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
if (0 === data.length) {
|
|
return false;
|
|
}
|
|
var regexp = data,
|
|
tail = /\/([gim]*)$/.exec(data),
|
|
modifiers = '';
|
|
if ('/' === regexp[0]) {
|
|
if (tail) {
|
|
modifiers = tail[1];
|
|
}
|
|
if (modifiers.length > 3) {
|
|
return false;
|
|
}
|
|
if (regexp[regexp.length - modifiers.length - 1] !== '/') {
|
|
return false;
|
|
}
|
|
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
|
}
|
|
try {
|
|
return true;
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
function constructJavascriptRegExp(data) {
|
|
var regexp = data,
|
|
tail = /\/([gim]*)$/.exec(data),
|
|
modifiers = '';
|
|
if ('/' === regexp[0]) {
|
|
if (tail) {
|
|
modifiers = tail[1];
|
|
}
|
|
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
|
}
|
|
return new RegExp(regexp, modifiers);
|
|
}
|
|
function representJavascriptRegExp(object) {
|
|
var result = '/' + object.source + '/';
|
|
if (object.global) {
|
|
result += 'g';
|
|
}
|
|
if (object.multiline) {
|
|
result += 'm';
|
|
}
|
|
if (object.ignoreCase) {
|
|
result += 'i';
|
|
}
|
|
return result;
|
|
}
|
|
function isRegExp(object) {
|
|
return '[object RegExp]' === Object.prototype.toString.call(object);
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
|
|
kind: 'scalar',
|
|
resolve: resolveJavascriptRegExp,
|
|
construct: constructJavascriptRegExp,
|
|
predicate: isRegExp,
|
|
represent: representJavascriptRegExp
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15b", ["34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
(function(process) {
|
|
(function(root, factory) {
|
|
'use strict';
|
|
if (typeof define === 'function' && define.amd) {
|
|
define(['exports'], factory);
|
|
} else if (typeof exports !== 'undefined') {
|
|
factory(exports);
|
|
} else {
|
|
factory((root.esprima = {}));
|
|
}
|
|
}(this, function(exports) {
|
|
'use strict';
|
|
var Token,
|
|
TokenName,
|
|
FnExprTokens,
|
|
Syntax,
|
|
PlaceHolders,
|
|
Messages,
|
|
Regex,
|
|
source,
|
|
strict,
|
|
index,
|
|
lineNumber,
|
|
lineStart,
|
|
hasLineTerminator,
|
|
lastIndex,
|
|
lastLineNumber,
|
|
lastLineStart,
|
|
startIndex,
|
|
startLineNumber,
|
|
startLineStart,
|
|
scanning,
|
|
length,
|
|
lookahead,
|
|
state,
|
|
extra,
|
|
isBindingElement,
|
|
isAssignmentTarget,
|
|
firstCoverInitializedNameError;
|
|
Token = {
|
|
BooleanLiteral: 1,
|
|
EOF: 2,
|
|
Identifier: 3,
|
|
Keyword: 4,
|
|
NullLiteral: 5,
|
|
NumericLiteral: 6,
|
|
Punctuator: 7,
|
|
StringLiteral: 8,
|
|
RegularExpression: 9,
|
|
Template: 10
|
|
};
|
|
TokenName = {};
|
|
TokenName[Token.BooleanLiteral] = 'Boolean';
|
|
TokenName[Token.EOF] = '<end>';
|
|
TokenName[Token.Identifier] = 'Identifier';
|
|
TokenName[Token.Keyword] = 'Keyword';
|
|
TokenName[Token.NullLiteral] = 'Null';
|
|
TokenName[Token.NumericLiteral] = 'Numeric';
|
|
TokenName[Token.Punctuator] = 'Punctuator';
|
|
TokenName[Token.StringLiteral] = 'String';
|
|
TokenName[Token.RegularExpression] = 'RegularExpression';
|
|
TokenName[Token.Template] = 'Template';
|
|
FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', 'return', 'case', 'delete', 'throw', 'void', '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', '&=', '|=', '^=', ',', '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', '<=', '<', '>', '!=', '!=='];
|
|
Syntax = {
|
|
AssignmentExpression: 'AssignmentExpression',
|
|
AssignmentPattern: 'AssignmentPattern',
|
|
ArrayExpression: 'ArrayExpression',
|
|
ArrayPattern: 'ArrayPattern',
|
|
ArrowFunctionExpression: 'ArrowFunctionExpression',
|
|
BlockStatement: 'BlockStatement',
|
|
BinaryExpression: 'BinaryExpression',
|
|
BreakStatement: 'BreakStatement',
|
|
CallExpression: 'CallExpression',
|
|
CatchClause: 'CatchClause',
|
|
ClassBody: 'ClassBody',
|
|
ClassDeclaration: 'ClassDeclaration',
|
|
ClassExpression: 'ClassExpression',
|
|
ConditionalExpression: 'ConditionalExpression',
|
|
ContinueStatement: 'ContinueStatement',
|
|
DoWhileStatement: 'DoWhileStatement',
|
|
DebuggerStatement: 'DebuggerStatement',
|
|
EmptyStatement: 'EmptyStatement',
|
|
ExportAllDeclaration: 'ExportAllDeclaration',
|
|
ExportDefaultDeclaration: 'ExportDefaultDeclaration',
|
|
ExportNamedDeclaration: 'ExportNamedDeclaration',
|
|
ExportSpecifier: 'ExportSpecifier',
|
|
ExpressionStatement: 'ExpressionStatement',
|
|
ForStatement: 'ForStatement',
|
|
ForOfStatement: 'ForOfStatement',
|
|
ForInStatement: 'ForInStatement',
|
|
FunctionDeclaration: 'FunctionDeclaration',
|
|
FunctionExpression: 'FunctionExpression',
|
|
Identifier: 'Identifier',
|
|
IfStatement: 'IfStatement',
|
|
ImportDeclaration: 'ImportDeclaration',
|
|
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
|
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
|
ImportSpecifier: 'ImportSpecifier',
|
|
Literal: 'Literal',
|
|
LabeledStatement: 'LabeledStatement',
|
|
LogicalExpression: 'LogicalExpression',
|
|
MemberExpression: 'MemberExpression',
|
|
MetaProperty: 'MetaProperty',
|
|
MethodDefinition: 'MethodDefinition',
|
|
NewExpression: 'NewExpression',
|
|
ObjectExpression: 'ObjectExpression',
|
|
ObjectPattern: 'ObjectPattern',
|
|
Program: 'Program',
|
|
Property: 'Property',
|
|
RestElement: 'RestElement',
|
|
ReturnStatement: 'ReturnStatement',
|
|
SequenceExpression: 'SequenceExpression',
|
|
SpreadElement: 'SpreadElement',
|
|
Super: 'Super',
|
|
SwitchCase: 'SwitchCase',
|
|
SwitchStatement: 'SwitchStatement',
|
|
TaggedTemplateExpression: 'TaggedTemplateExpression',
|
|
TemplateElement: 'TemplateElement',
|
|
TemplateLiteral: 'TemplateLiteral',
|
|
ThisExpression: 'ThisExpression',
|
|
ThrowStatement: 'ThrowStatement',
|
|
TryStatement: 'TryStatement',
|
|
UnaryExpression: 'UnaryExpression',
|
|
UpdateExpression: 'UpdateExpression',
|
|
VariableDeclaration: 'VariableDeclaration',
|
|
VariableDeclarator: 'VariableDeclarator',
|
|
WhileStatement: 'WhileStatement',
|
|
WithStatement: 'WithStatement',
|
|
YieldExpression: 'YieldExpression'
|
|
};
|
|
PlaceHolders = {ArrowParameterPlaceHolder: 'ArrowParameterPlaceHolder'};
|
|
Messages = {
|
|
UnexpectedToken: 'Unexpected token %0',
|
|
UnexpectedNumber: 'Unexpected number',
|
|
UnexpectedString: 'Unexpected string',
|
|
UnexpectedIdentifier: 'Unexpected identifier',
|
|
UnexpectedReserved: 'Unexpected reserved word',
|
|
UnexpectedTemplate: 'Unexpected quasi %0',
|
|
UnexpectedEOS: 'Unexpected end of input',
|
|
NewlineAfterThrow: 'Illegal newline after throw',
|
|
InvalidRegExp: 'Invalid regular expression',
|
|
UnterminatedRegExp: 'Invalid regular expression: missing /',
|
|
InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
|
|
InvalidLHSInForIn: 'Invalid left-hand side in for-in',
|
|
InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
|
|
MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
|
|
NoCatchOrFinally: 'Missing catch or finally after try',
|
|
UnknownLabel: 'Undefined label \'%0\'',
|
|
Redeclaration: '%0 \'%1\' has already been declared',
|
|
IllegalContinue: 'Illegal continue statement',
|
|
IllegalBreak: 'Illegal break statement',
|
|
IllegalReturn: 'Illegal return statement',
|
|
StrictModeWith: 'Strict mode code may not include a with statement',
|
|
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
|
|
StrictVarName: 'Variable name may not be eval or arguments in strict mode',
|
|
StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
|
|
StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
|
|
StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
|
|
StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
|
|
StrictDelete: 'Delete of an unqualified identifier in strict mode.',
|
|
StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
|
|
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
|
|
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
|
|
StrictReservedWord: 'Use of future reserved word in strict mode',
|
|
TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
|
|
ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
|
|
DefaultRestParameter: 'Unexpected token =',
|
|
ObjectPatternAsRestParameter: 'Unexpected token {',
|
|
DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
|
|
ConstructorSpecialMethod: 'Class constructor may not be an accessor',
|
|
DuplicateConstructor: 'A class may only have one constructor',
|
|
StaticPrototype: 'Classes may not have static property named prototype',
|
|
MissingFromClause: 'Unexpected token',
|
|
NoAsAfterImportNamespace: 'Unexpected token',
|
|
InvalidModuleSpecifier: 'Unexpected token',
|
|
IllegalImportDeclaration: 'Unexpected token',
|
|
IllegalExportDeclaration: 'Unexpected token',
|
|
DuplicateBinding: 'Duplicate binding %0'
|
|
};
|
|
Regex = {
|
|
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/,
|
|
NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
|
|
};
|
|
function assert(condition, message) {
|
|
if (!condition) {
|
|
throw new Error('ASSERT: ' + message);
|
|
}
|
|
}
|
|
function isDecimalDigit(ch) {
|
|
return (ch >= 0x30 && ch <= 0x39);
|
|
}
|
|
function isHexDigit(ch) {
|
|
return '0123456789abcdefABCDEF'.indexOf(ch) >= 0;
|
|
}
|
|
function isOctalDigit(ch) {
|
|
return '01234567'.indexOf(ch) >= 0;
|
|
}
|
|
function octalToDecimal(ch) {
|
|
var octal = (ch !== '0'),
|
|
code = '01234567'.indexOf(ch);
|
|
if (index < length && isOctalDigit(source[index])) {
|
|
octal = true;
|
|
code = code * 8 + '01234567'.indexOf(source[index++]);
|
|
if ('0123'.indexOf(ch) >= 0 && index < length && isOctalDigit(source[index])) {
|
|
code = code * 8 + '01234567'.indexOf(source[index++]);
|
|
}
|
|
}
|
|
return {
|
|
code: code,
|
|
octal: octal
|
|
};
|
|
}
|
|
function isWhiteSpace(ch) {
|
|
return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0);
|
|
}
|
|
function isLineTerminator(ch) {
|
|
return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029);
|
|
}
|
|
function fromCodePoint(cp) {
|
|
return (cp < 0x10000) ? String.fromCharCode(cp) : String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) + String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
|
|
}
|
|
function isIdentifierStart(ch) {
|
|
return (ch === 0x24) || (ch === 0x5F) || (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A) || (ch === 0x5C) || ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch)));
|
|
}
|
|
function isIdentifierPart(ch) {
|
|
return (ch === 0x24) || (ch === 0x5F) || (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A) || (ch >= 0x30 && ch <= 0x39) || (ch === 0x5C) || ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch)));
|
|
}
|
|
function isFutureReservedWord(id) {
|
|
switch (id) {
|
|
case 'enum':
|
|
case 'export':
|
|
case 'import':
|
|
case 'super':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function isStrictModeReservedWord(id) {
|
|
switch (id) {
|
|
case 'implements':
|
|
case 'interface':
|
|
case 'package':
|
|
case 'private':
|
|
case 'protected':
|
|
case 'public':
|
|
case 'static':
|
|
case 'yield':
|
|
case 'let':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function isRestrictedWord(id) {
|
|
return id === 'eval' || id === 'arguments';
|
|
}
|
|
function isKeyword(id) {
|
|
switch (id.length) {
|
|
case 2:
|
|
return (id === 'if') || (id === 'in') || (id === 'do');
|
|
case 3:
|
|
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try') || (id === 'let');
|
|
case 4:
|
|
return (id === 'this') || (id === 'else') || (id === 'case') || (id === 'void') || (id === 'with') || (id === 'enum');
|
|
case 5:
|
|
return (id === 'while') || (id === 'break') || (id === 'catch') || (id === 'throw') || (id === 'const') || (id === 'yield') || (id === 'class') || (id === 'super');
|
|
case 6:
|
|
return (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch') || (id === 'export') || (id === 'import');
|
|
case 7:
|
|
return (id === 'default') || (id === 'finally') || (id === 'extends');
|
|
case 8:
|
|
return (id === 'function') || (id === 'continue') || (id === 'debugger');
|
|
case 10:
|
|
return (id === 'instanceof');
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function addComment(type, value, start, end, loc) {
|
|
var comment;
|
|
assert(typeof start === 'number', 'Comment must have valid position');
|
|
state.lastCommentStart = start;
|
|
comment = {
|
|
type: type,
|
|
value: value
|
|
};
|
|
if (extra.range) {
|
|
comment.range = [start, end];
|
|
}
|
|
if (extra.loc) {
|
|
comment.loc = loc;
|
|
}
|
|
extra.comments.push(comment);
|
|
if (extra.attachComment) {
|
|
extra.leadingComments.push(comment);
|
|
extra.trailingComments.push(comment);
|
|
}
|
|
if (extra.tokenize) {
|
|
comment.type = comment.type + 'Comment';
|
|
if (extra.delegate) {
|
|
comment = extra.delegate(comment);
|
|
}
|
|
extra.tokens.push(comment);
|
|
}
|
|
}
|
|
function skipSingleLineComment(offset) {
|
|
var start,
|
|
loc,
|
|
ch,
|
|
comment;
|
|
start = index - offset;
|
|
loc = {start: {
|
|
line: lineNumber,
|
|
column: index - lineStart - offset
|
|
}};
|
|
while (index < length) {
|
|
ch = source.charCodeAt(index);
|
|
++index;
|
|
if (isLineTerminator(ch)) {
|
|
hasLineTerminator = true;
|
|
if (extra.comments) {
|
|
comment = source.slice(start + offset, index - 1);
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart - 1
|
|
};
|
|
addComment('Line', comment, start, index - 1, loc);
|
|
}
|
|
if (ch === 13 && source.charCodeAt(index) === 10) {
|
|
++index;
|
|
}
|
|
++lineNumber;
|
|
lineStart = index;
|
|
return;
|
|
}
|
|
}
|
|
if (extra.comments) {
|
|
comment = source.slice(start + offset, index);
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
};
|
|
addComment('Line', comment, start, index, loc);
|
|
}
|
|
}
|
|
function skipMultiLineComment() {
|
|
var start,
|
|
loc,
|
|
ch,
|
|
comment;
|
|
if (extra.comments) {
|
|
start = index - 2;
|
|
loc = {start: {
|
|
line: lineNumber,
|
|
column: index - lineStart - 2
|
|
}};
|
|
}
|
|
while (index < length) {
|
|
ch = source.charCodeAt(index);
|
|
if (isLineTerminator(ch)) {
|
|
if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) {
|
|
++index;
|
|
}
|
|
hasLineTerminator = true;
|
|
++lineNumber;
|
|
++index;
|
|
lineStart = index;
|
|
} else if (ch === 0x2A) {
|
|
if (source.charCodeAt(index + 1) === 0x2F) {
|
|
++index;
|
|
++index;
|
|
if (extra.comments) {
|
|
comment = source.slice(start + 2, index - 2);
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
};
|
|
addComment('Block', comment, start, index, loc);
|
|
}
|
|
return;
|
|
}
|
|
++index;
|
|
} else {
|
|
++index;
|
|
}
|
|
}
|
|
if (extra.comments) {
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
};
|
|
comment = source.slice(start + 2, index);
|
|
addComment('Block', comment, start, index, loc);
|
|
}
|
|
tolerateUnexpectedToken();
|
|
}
|
|
function skipComment() {
|
|
var ch,
|
|
start;
|
|
hasLineTerminator = false;
|
|
start = (index === 0);
|
|
while (index < length) {
|
|
ch = source.charCodeAt(index);
|
|
if (isWhiteSpace(ch)) {
|
|
++index;
|
|
} else if (isLineTerminator(ch)) {
|
|
hasLineTerminator = true;
|
|
++index;
|
|
if (ch === 0x0D && source.charCodeAt(index) === 0x0A) {
|
|
++index;
|
|
}
|
|
++lineNumber;
|
|
lineStart = index;
|
|
start = true;
|
|
} else if (ch === 0x2F) {
|
|
ch = source.charCodeAt(index + 1);
|
|
if (ch === 0x2F) {
|
|
++index;
|
|
++index;
|
|
skipSingleLineComment(2);
|
|
start = true;
|
|
} else if (ch === 0x2A) {
|
|
++index;
|
|
++index;
|
|
skipMultiLineComment();
|
|
} else {
|
|
break;
|
|
}
|
|
} else if (start && ch === 0x2D) {
|
|
if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) {
|
|
index += 3;
|
|
skipSingleLineComment(3);
|
|
} else {
|
|
break;
|
|
}
|
|
} else if (ch === 0x3C) {
|
|
if (source.slice(index + 1, index + 4) === '!--') {
|
|
++index;
|
|
++index;
|
|
++index;
|
|
++index;
|
|
skipSingleLineComment(4);
|
|
} else {
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function scanHexEscape(prefix) {
|
|
var i,
|
|
len,
|
|
ch,
|
|
code = 0;
|
|
len = (prefix === 'u') ? 4 : 2;
|
|
for (i = 0; i < len; ++i) {
|
|
if (index < length && isHexDigit(source[index])) {
|
|
ch = source[index++];
|
|
code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
return String.fromCharCode(code);
|
|
}
|
|
function scanUnicodeCodePointEscape() {
|
|
var ch,
|
|
code;
|
|
ch = source[index];
|
|
code = 0;
|
|
if (ch === '}') {
|
|
throwUnexpectedToken();
|
|
}
|
|
while (index < length) {
|
|
ch = source[index++];
|
|
if (!isHexDigit(ch)) {
|
|
break;
|
|
}
|
|
code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
|
|
}
|
|
if (code > 0x10FFFF || ch !== '}') {
|
|
throwUnexpectedToken();
|
|
}
|
|
return fromCodePoint(code);
|
|
}
|
|
function codePointAt(i) {
|
|
var cp,
|
|
first,
|
|
second;
|
|
cp = source.charCodeAt(i);
|
|
if (cp >= 0xD800 && cp <= 0xDBFF) {
|
|
second = source.charCodeAt(i + 1);
|
|
if (second >= 0xDC00 && second <= 0xDFFF) {
|
|
first = cp;
|
|
cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
|
|
}
|
|
}
|
|
return cp;
|
|
}
|
|
function getComplexIdentifier() {
|
|
var cp,
|
|
ch,
|
|
id;
|
|
cp = codePointAt(index);
|
|
id = fromCodePoint(cp);
|
|
index += id.length;
|
|
if (cp === 0x5C) {
|
|
if (source.charCodeAt(index) !== 0x75) {
|
|
throwUnexpectedToken();
|
|
}
|
|
++index;
|
|
if (source[index] === '{') {
|
|
++index;
|
|
ch = scanUnicodeCodePointEscape();
|
|
} else {
|
|
ch = scanHexEscape('u');
|
|
cp = ch.charCodeAt(0);
|
|
if (!ch || ch === '\\' || !isIdentifierStart(cp)) {
|
|
throwUnexpectedToken();
|
|
}
|
|
}
|
|
id = ch;
|
|
}
|
|
while (index < length) {
|
|
cp = codePointAt(index);
|
|
if (!isIdentifierPart(cp)) {
|
|
break;
|
|
}
|
|
ch = fromCodePoint(cp);
|
|
id += ch;
|
|
index += ch.length;
|
|
if (cp === 0x5C) {
|
|
id = id.substr(0, id.length - 1);
|
|
if (source.charCodeAt(index) !== 0x75) {
|
|
throwUnexpectedToken();
|
|
}
|
|
++index;
|
|
if (source[index] === '{') {
|
|
++index;
|
|
ch = scanUnicodeCodePointEscape();
|
|
} else {
|
|
ch = scanHexEscape('u');
|
|
cp = ch.charCodeAt(0);
|
|
if (!ch || ch === '\\' || !isIdentifierPart(cp)) {
|
|
throwUnexpectedToken();
|
|
}
|
|
}
|
|
id += ch;
|
|
}
|
|
}
|
|
return id;
|
|
}
|
|
function getIdentifier() {
|
|
var start,
|
|
ch;
|
|
start = index++;
|
|
while (index < length) {
|
|
ch = source.charCodeAt(index);
|
|
if (ch === 0x5C) {
|
|
index = start;
|
|
return getComplexIdentifier();
|
|
} else if (ch >= 0xD800 && ch < 0xDFFF) {
|
|
index = start;
|
|
return getComplexIdentifier();
|
|
}
|
|
if (isIdentifierPart(ch)) {
|
|
++index;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return source.slice(start, index);
|
|
}
|
|
function scanIdentifier() {
|
|
var start,
|
|
id,
|
|
type;
|
|
start = index;
|
|
id = (source.charCodeAt(index) === 0x5C) ? getComplexIdentifier() : getIdentifier();
|
|
if (id.length === 1) {
|
|
type = Token.Identifier;
|
|
} else if (isKeyword(id)) {
|
|
type = Token.Keyword;
|
|
} else if (id === 'null') {
|
|
type = Token.NullLiteral;
|
|
} else if (id === 'true' || id === 'false') {
|
|
type = Token.BooleanLiteral;
|
|
} else {
|
|
type = Token.Identifier;
|
|
}
|
|
return {
|
|
type: type,
|
|
value: id,
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function scanPunctuator() {
|
|
var token,
|
|
str;
|
|
token = {
|
|
type: Token.Punctuator,
|
|
value: '',
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: index,
|
|
end: index
|
|
};
|
|
str = source[index];
|
|
switch (str) {
|
|
case '(':
|
|
if (extra.tokenize) {
|
|
extra.openParenToken = extra.tokenValues.length;
|
|
}
|
|
++index;
|
|
break;
|
|
case '{':
|
|
if (extra.tokenize) {
|
|
extra.openCurlyToken = extra.tokenValues.length;
|
|
}
|
|
state.curlyStack.push('{');
|
|
++index;
|
|
break;
|
|
case '.':
|
|
++index;
|
|
if (source[index] === '.' && source[index + 1] === '.') {
|
|
index += 2;
|
|
str = '...';
|
|
}
|
|
break;
|
|
case '}':
|
|
++index;
|
|
state.curlyStack.pop();
|
|
break;
|
|
case ')':
|
|
case ';':
|
|
case ',':
|
|
case '[':
|
|
case ']':
|
|
case ':':
|
|
case '?':
|
|
case '~':
|
|
++index;
|
|
break;
|
|
default:
|
|
str = source.substr(index, 4);
|
|
if (str === '>>>=') {
|
|
index += 4;
|
|
} else {
|
|
str = str.substr(0, 3);
|
|
if (str === '===' || str === '!==' || str === '>>>' || str === '<<=' || str === '>>=') {
|
|
index += 3;
|
|
} else {
|
|
str = str.substr(0, 2);
|
|
if (str === '&&' || str === '||' || str === '==' || str === '!=' || str === '+=' || str === '-=' || str === '*=' || str === '/=' || str === '++' || str === '--' || str === '<<' || str === '>>' || str === '&=' || str === '|=' || str === '^=' || str === '%=' || str === '<=' || str === '>=' || str === '=>') {
|
|
index += 2;
|
|
} else {
|
|
str = source[index];
|
|
if ('<>=!+-*%&|^/'.indexOf(str) >= 0) {
|
|
++index;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (index === token.start) {
|
|
throwUnexpectedToken();
|
|
}
|
|
token.end = index;
|
|
token.value = str;
|
|
return token;
|
|
}
|
|
function scanHexLiteral(start) {
|
|
var number = '';
|
|
while (index < length) {
|
|
if (!isHexDigit(source[index])) {
|
|
break;
|
|
}
|
|
number += source[index++];
|
|
}
|
|
if (number.length === 0) {
|
|
throwUnexpectedToken();
|
|
}
|
|
if (isIdentifierStart(source.charCodeAt(index))) {
|
|
throwUnexpectedToken();
|
|
}
|
|
return {
|
|
type: Token.NumericLiteral,
|
|
value: parseInt('0x' + number, 16),
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function scanBinaryLiteral(start) {
|
|
var ch,
|
|
number;
|
|
number = '';
|
|
while (index < length) {
|
|
ch = source[index];
|
|
if (ch !== '0' && ch !== '1') {
|
|
break;
|
|
}
|
|
number += source[index++];
|
|
}
|
|
if (number.length === 0) {
|
|
throwUnexpectedToken();
|
|
}
|
|
if (index < length) {
|
|
ch = source.charCodeAt(index);
|
|
if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
|
|
throwUnexpectedToken();
|
|
}
|
|
}
|
|
return {
|
|
type: Token.NumericLiteral,
|
|
value: parseInt(number, 2),
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function scanOctalLiteral(prefix, start) {
|
|
var number,
|
|
octal;
|
|
if (isOctalDigit(prefix)) {
|
|
octal = true;
|
|
number = '0' + source[index++];
|
|
} else {
|
|
octal = false;
|
|
++index;
|
|
number = '';
|
|
}
|
|
while (index < length) {
|
|
if (!isOctalDigit(source[index])) {
|
|
break;
|
|
}
|
|
number += source[index++];
|
|
}
|
|
if (!octal && number.length === 0) {
|
|
throwUnexpectedToken();
|
|
}
|
|
if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) {
|
|
throwUnexpectedToken();
|
|
}
|
|
return {
|
|
type: Token.NumericLiteral,
|
|
value: parseInt(number, 8),
|
|
octal: octal,
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function isImplicitOctalLiteral() {
|
|
var i,
|
|
ch;
|
|
for (i = index + 1; i < length; ++i) {
|
|
ch = source[i];
|
|
if (ch === '8' || ch === '9') {
|
|
return false;
|
|
}
|
|
if (!isOctalDigit(ch)) {
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function scanNumericLiteral() {
|
|
var number,
|
|
start,
|
|
ch;
|
|
ch = source[index];
|
|
assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 'Numeric literal must start with a decimal digit or a decimal point');
|
|
start = index;
|
|
number = '';
|
|
if (ch !== '.') {
|
|
number = source[index++];
|
|
ch = source[index];
|
|
if (number === '0') {
|
|
if (ch === 'x' || ch === 'X') {
|
|
++index;
|
|
return scanHexLiteral(start);
|
|
}
|
|
if (ch === 'b' || ch === 'B') {
|
|
++index;
|
|
return scanBinaryLiteral(start);
|
|
}
|
|
if (ch === 'o' || ch === 'O') {
|
|
return scanOctalLiteral(ch, start);
|
|
}
|
|
if (isOctalDigit(ch)) {
|
|
if (isImplicitOctalLiteral()) {
|
|
return scanOctalLiteral(ch, start);
|
|
}
|
|
}
|
|
}
|
|
while (isDecimalDigit(source.charCodeAt(index))) {
|
|
number += source[index++];
|
|
}
|
|
ch = source[index];
|
|
}
|
|
if (ch === '.') {
|
|
number += source[index++];
|
|
while (isDecimalDigit(source.charCodeAt(index))) {
|
|
number += source[index++];
|
|
}
|
|
ch = source[index];
|
|
}
|
|
if (ch === 'e' || ch === 'E') {
|
|
number += source[index++];
|
|
ch = source[index];
|
|
if (ch === '+' || ch === '-') {
|
|
number += source[index++];
|
|
}
|
|
if (isDecimalDigit(source.charCodeAt(index))) {
|
|
while (isDecimalDigit(source.charCodeAt(index))) {
|
|
number += source[index++];
|
|
}
|
|
} else {
|
|
throwUnexpectedToken();
|
|
}
|
|
}
|
|
if (isIdentifierStart(source.charCodeAt(index))) {
|
|
throwUnexpectedToken();
|
|
}
|
|
return {
|
|
type: Token.NumericLiteral,
|
|
value: parseFloat(number),
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function scanStringLiteral() {
|
|
var str = '',
|
|
quote,
|
|
start,
|
|
ch,
|
|
unescaped,
|
|
octToDec,
|
|
octal = false;
|
|
quote = source[index];
|
|
assert((quote === '\'' || quote === '"'), 'String literal must starts with a quote');
|
|
start = index;
|
|
++index;
|
|
while (index < length) {
|
|
ch = source[index++];
|
|
if (ch === quote) {
|
|
quote = '';
|
|
break;
|
|
} else if (ch === '\\') {
|
|
ch = source[index++];
|
|
if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
|
|
switch (ch) {
|
|
case 'u':
|
|
case 'x':
|
|
if (source[index] === '{') {
|
|
++index;
|
|
str += scanUnicodeCodePointEscape();
|
|
} else {
|
|
unescaped = scanHexEscape(ch);
|
|
if (!unescaped) {
|
|
throw throwUnexpectedToken();
|
|
}
|
|
str += unescaped;
|
|
}
|
|
break;
|
|
case 'n':
|
|
str += '\n';
|
|
break;
|
|
case 'r':
|
|
str += '\r';
|
|
break;
|
|
case 't':
|
|
str += '\t';
|
|
break;
|
|
case 'b':
|
|
str += '\b';
|
|
break;
|
|
case 'f':
|
|
str += '\f';
|
|
break;
|
|
case 'v':
|
|
str += '\x0B';
|
|
break;
|
|
case '8':
|
|
case '9':
|
|
str += ch;
|
|
tolerateUnexpectedToken();
|
|
break;
|
|
default:
|
|
if (isOctalDigit(ch)) {
|
|
octToDec = octalToDecimal(ch);
|
|
octal = octToDec.octal || octal;
|
|
str += String.fromCharCode(octToDec.code);
|
|
} else {
|
|
str += ch;
|
|
}
|
|
break;
|
|
}
|
|
} else {
|
|
++lineNumber;
|
|
if (ch === '\r' && source[index] === '\n') {
|
|
++index;
|
|
}
|
|
lineStart = index;
|
|
}
|
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
break;
|
|
} else {
|
|
str += ch;
|
|
}
|
|
}
|
|
if (quote !== '') {
|
|
throwUnexpectedToken();
|
|
}
|
|
return {
|
|
type: Token.StringLiteral,
|
|
value: str,
|
|
octal: octal,
|
|
lineNumber: startLineNumber,
|
|
lineStart: startLineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function scanTemplate() {
|
|
var cooked = '',
|
|
ch,
|
|
start,
|
|
rawOffset,
|
|
terminated,
|
|
head,
|
|
tail,
|
|
restore,
|
|
unescaped;
|
|
terminated = false;
|
|
tail = false;
|
|
start = index;
|
|
head = (source[index] === '`');
|
|
rawOffset = 2;
|
|
++index;
|
|
while (index < length) {
|
|
ch = source[index++];
|
|
if (ch === '`') {
|
|
rawOffset = 1;
|
|
tail = true;
|
|
terminated = true;
|
|
break;
|
|
} else if (ch === '$') {
|
|
if (source[index] === '{') {
|
|
state.curlyStack.push('${');
|
|
++index;
|
|
terminated = true;
|
|
break;
|
|
}
|
|
cooked += ch;
|
|
} else if (ch === '\\') {
|
|
ch = source[index++];
|
|
if (!isLineTerminator(ch.charCodeAt(0))) {
|
|
switch (ch) {
|
|
case 'n':
|
|
cooked += '\n';
|
|
break;
|
|
case 'r':
|
|
cooked += '\r';
|
|
break;
|
|
case 't':
|
|
cooked += '\t';
|
|
break;
|
|
case 'u':
|
|
case 'x':
|
|
if (source[index] === '{') {
|
|
++index;
|
|
cooked += scanUnicodeCodePointEscape();
|
|
} else {
|
|
restore = index;
|
|
unescaped = scanHexEscape(ch);
|
|
if (unescaped) {
|
|
cooked += unescaped;
|
|
} else {
|
|
index = restore;
|
|
cooked += ch;
|
|
}
|
|
}
|
|
break;
|
|
case 'b':
|
|
cooked += '\b';
|
|
break;
|
|
case 'f':
|
|
cooked += '\f';
|
|
break;
|
|
case 'v':
|
|
cooked += '\v';
|
|
break;
|
|
default:
|
|
if (ch === '0') {
|
|
if (isDecimalDigit(source.charCodeAt(index))) {
|
|
throwError(Messages.TemplateOctalLiteral);
|
|
}
|
|
cooked += '\0';
|
|
} else if (isOctalDigit(ch)) {
|
|
throwError(Messages.TemplateOctalLiteral);
|
|
} else {
|
|
cooked += ch;
|
|
}
|
|
break;
|
|
}
|
|
} else {
|
|
++lineNumber;
|
|
if (ch === '\r' && source[index] === '\n') {
|
|
++index;
|
|
}
|
|
lineStart = index;
|
|
}
|
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
++lineNumber;
|
|
if (ch === '\r' && source[index] === '\n') {
|
|
++index;
|
|
}
|
|
lineStart = index;
|
|
cooked += '\n';
|
|
} else {
|
|
cooked += ch;
|
|
}
|
|
}
|
|
if (!terminated) {
|
|
throwUnexpectedToken();
|
|
}
|
|
if (!head) {
|
|
state.curlyStack.pop();
|
|
}
|
|
return {
|
|
type: Token.Template,
|
|
value: {
|
|
cooked: cooked,
|
|
raw: source.slice(start + 1, index - rawOffset)
|
|
},
|
|
head: head,
|
|
tail: tail,
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function testRegExp(pattern, flags) {
|
|
var astralSubstitute = '\uFFFF',
|
|
tmp = pattern;
|
|
if (flags.indexOf('u') >= 0) {
|
|
tmp = tmp.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function($0, $1, $2) {
|
|
var codePoint = parseInt($1 || $2, 16);
|
|
if (codePoint > 0x10FFFF) {
|
|
throwUnexpectedToken(null, Messages.InvalidRegExp);
|
|
}
|
|
if (codePoint <= 0xFFFF) {
|
|
return String.fromCharCode(codePoint);
|
|
}
|
|
return astralSubstitute;
|
|
}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, astralSubstitute);
|
|
}
|
|
try {
|
|
RegExp(tmp);
|
|
} catch (e) {
|
|
throwUnexpectedToken(null, Messages.InvalidRegExp);
|
|
}
|
|
try {
|
|
return new RegExp(pattern, flags);
|
|
} catch (exception) {
|
|
return null;
|
|
}
|
|
}
|
|
function scanRegExpBody() {
|
|
var ch,
|
|
str,
|
|
classMarker,
|
|
terminated,
|
|
body;
|
|
ch = source[index];
|
|
assert(ch === '/', 'Regular expression literal must start with a slash');
|
|
str = source[index++];
|
|
classMarker = false;
|
|
terminated = false;
|
|
while (index < length) {
|
|
ch = source[index++];
|
|
str += ch;
|
|
if (ch === '\\') {
|
|
ch = source[index++];
|
|
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
throwUnexpectedToken(null, Messages.UnterminatedRegExp);
|
|
}
|
|
str += ch;
|
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
throwUnexpectedToken(null, Messages.UnterminatedRegExp);
|
|
} else if (classMarker) {
|
|
if (ch === ']') {
|
|
classMarker = false;
|
|
}
|
|
} else {
|
|
if (ch === '/') {
|
|
terminated = true;
|
|
break;
|
|
} else if (ch === '[') {
|
|
classMarker = true;
|
|
}
|
|
}
|
|
}
|
|
if (!terminated) {
|
|
throwUnexpectedToken(null, Messages.UnterminatedRegExp);
|
|
}
|
|
body = str.substr(1, str.length - 2);
|
|
return {
|
|
value: body,
|
|
literal: str
|
|
};
|
|
}
|
|
function scanRegExpFlags() {
|
|
var ch,
|
|
str,
|
|
flags,
|
|
restore;
|
|
str = '';
|
|
flags = '';
|
|
while (index < length) {
|
|
ch = source[index];
|
|
if (!isIdentifierPart(ch.charCodeAt(0))) {
|
|
break;
|
|
}
|
|
++index;
|
|
if (ch === '\\' && index < length) {
|
|
ch = source[index];
|
|
if (ch === 'u') {
|
|
++index;
|
|
restore = index;
|
|
ch = scanHexEscape('u');
|
|
if (ch) {
|
|
flags += ch;
|
|
for (str += '\\u'; restore < index; ++restore) {
|
|
str += source[restore];
|
|
}
|
|
} else {
|
|
index = restore;
|
|
flags += 'u';
|
|
str += '\\u';
|
|
}
|
|
tolerateUnexpectedToken();
|
|
} else {
|
|
str += '\\';
|
|
tolerateUnexpectedToken();
|
|
}
|
|
} else {
|
|
flags += ch;
|
|
str += ch;
|
|
}
|
|
}
|
|
return {
|
|
value: flags,
|
|
literal: str
|
|
};
|
|
}
|
|
function scanRegExp() {
|
|
var start,
|
|
body,
|
|
flags,
|
|
value;
|
|
scanning = true;
|
|
lookahead = null;
|
|
skipComment();
|
|
start = index;
|
|
body = scanRegExpBody();
|
|
flags = scanRegExpFlags();
|
|
value = testRegExp(body.value, flags.value);
|
|
scanning = false;
|
|
if (extra.tokenize) {
|
|
return {
|
|
type: Token.RegularExpression,
|
|
value: value,
|
|
regex: {
|
|
pattern: body.value,
|
|
flags: flags.value
|
|
},
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
return {
|
|
literal: body.literal + flags.literal,
|
|
value: value,
|
|
regex: {
|
|
pattern: body.value,
|
|
flags: flags.value
|
|
},
|
|
start: start,
|
|
end: index
|
|
};
|
|
}
|
|
function collectRegex() {
|
|
var pos,
|
|
loc,
|
|
regex,
|
|
token;
|
|
skipComment();
|
|
pos = index;
|
|
loc = {start: {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
}};
|
|
regex = scanRegExp();
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
};
|
|
if (!extra.tokenize) {
|
|
if (extra.tokens.length > 0) {
|
|
token = extra.tokens[extra.tokens.length - 1];
|
|
if (token.range[0] === pos && token.type === 'Punctuator') {
|
|
if (token.value === '/' || token.value === '/=') {
|
|
extra.tokens.pop();
|
|
}
|
|
}
|
|
}
|
|
extra.tokens.push({
|
|
type: 'RegularExpression',
|
|
value: regex.literal,
|
|
regex: regex.regex,
|
|
range: [pos, index],
|
|
loc: loc
|
|
});
|
|
}
|
|
return regex;
|
|
}
|
|
function isIdentifierName(token) {
|
|
return token.type === Token.Identifier || token.type === Token.Keyword || token.type === Token.BooleanLiteral || token.type === Token.NullLiteral;
|
|
}
|
|
function advanceSlash() {
|
|
var regex,
|
|
previous,
|
|
check;
|
|
function testKeyword(value) {
|
|
return value && (value.length > 1) && (value[0] >= 'a') && (value[0] <= 'z');
|
|
}
|
|
previous = extra.tokenValues[extra.tokens.length - 1];
|
|
regex = (previous !== null);
|
|
switch (previous) {
|
|
case 'this':
|
|
case ']':
|
|
regex = false;
|
|
break;
|
|
case ')':
|
|
check = extra.tokenValues[extra.openParenToken - 1];
|
|
regex = (check === 'if' || check === 'while' || check === 'for' || check === 'with');
|
|
break;
|
|
case '}':
|
|
regex = false;
|
|
if (testKeyword(extra.tokenValues[extra.openCurlyToken - 3])) {
|
|
check = extra.tokenValues[extra.openCurlyToken - 4];
|
|
regex = check ? (FnExprTokens.indexOf(check) < 0) : false;
|
|
} else if (testKeyword(extra.tokenValues[extra.openCurlyToken - 4])) {
|
|
check = extra.tokenValues[extra.openCurlyToken - 5];
|
|
regex = check ? (FnExprTokens.indexOf(check) < 0) : true;
|
|
}
|
|
}
|
|
return regex ? collectRegex() : scanPunctuator();
|
|
}
|
|
function advance() {
|
|
var cp,
|
|
token;
|
|
if (index >= length) {
|
|
return {
|
|
type: Token.EOF,
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
start: index,
|
|
end: index
|
|
};
|
|
}
|
|
cp = source.charCodeAt(index);
|
|
if (isIdentifierStart(cp)) {
|
|
token = scanIdentifier();
|
|
if (strict && isStrictModeReservedWord(token.value)) {
|
|
token.type = Token.Keyword;
|
|
}
|
|
return token;
|
|
}
|
|
if (cp === 0x28 || cp === 0x29 || cp === 0x3B) {
|
|
return scanPunctuator();
|
|
}
|
|
if (cp === 0x27 || cp === 0x22) {
|
|
return scanStringLiteral();
|
|
}
|
|
if (cp === 0x2E) {
|
|
if (isDecimalDigit(source.charCodeAt(index + 1))) {
|
|
return scanNumericLiteral();
|
|
}
|
|
return scanPunctuator();
|
|
}
|
|
if (isDecimalDigit(cp)) {
|
|
return scanNumericLiteral();
|
|
}
|
|
if (extra.tokenize && cp === 0x2F) {
|
|
return advanceSlash();
|
|
}
|
|
if (cp === 0x60 || (cp === 0x7D && state.curlyStack[state.curlyStack.length - 1] === '${')) {
|
|
return scanTemplate();
|
|
}
|
|
if (cp >= 0xD800 && cp < 0xDFFF) {
|
|
cp = codePointAt(index);
|
|
if (isIdentifierStart(cp)) {
|
|
return scanIdentifier();
|
|
}
|
|
}
|
|
return scanPunctuator();
|
|
}
|
|
function collectToken() {
|
|
var loc,
|
|
token,
|
|
value,
|
|
entry;
|
|
loc = {start: {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
}};
|
|
token = advance();
|
|
loc.end = {
|
|
line: lineNumber,
|
|
column: index - lineStart
|
|
};
|
|
if (token.type !== Token.EOF) {
|
|
value = source.slice(token.start, token.end);
|
|
entry = {
|
|
type: TokenName[token.type],
|
|
value: value,
|
|
range: [token.start, token.end],
|
|
loc: loc
|
|
};
|
|
if (token.regex) {
|
|
entry.regex = {
|
|
pattern: token.regex.pattern,
|
|
flags: token.regex.flags
|
|
};
|
|
}
|
|
if (extra.tokenValues) {
|
|
extra.tokenValues.push((entry.type === 'Punctuator' || entry.type === 'Keyword') ? entry.value : null);
|
|
}
|
|
if (extra.tokenize) {
|
|
if (!extra.range) {
|
|
delete entry.range;
|
|
}
|
|
if (!extra.loc) {
|
|
delete entry.loc;
|
|
}
|
|
if (extra.delegate) {
|
|
entry = extra.delegate(entry);
|
|
}
|
|
}
|
|
extra.tokens.push(entry);
|
|
}
|
|
return token;
|
|
}
|
|
function lex() {
|
|
var token;
|
|
scanning = true;
|
|
lastIndex = index;
|
|
lastLineNumber = lineNumber;
|
|
lastLineStart = lineStart;
|
|
skipComment();
|
|
token = lookahead;
|
|
startIndex = index;
|
|
startLineNumber = lineNumber;
|
|
startLineStart = lineStart;
|
|
lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();
|
|
scanning = false;
|
|
return token;
|
|
}
|
|
function peek() {
|
|
scanning = true;
|
|
skipComment();
|
|
lastIndex = index;
|
|
lastLineNumber = lineNumber;
|
|
lastLineStart = lineStart;
|
|
startIndex = index;
|
|
startLineNumber = lineNumber;
|
|
startLineStart = lineStart;
|
|
lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance();
|
|
scanning = false;
|
|
}
|
|
function Position() {
|
|
this.line = startLineNumber;
|
|
this.column = startIndex - startLineStart;
|
|
}
|
|
function SourceLocation() {
|
|
this.start = new Position();
|
|
this.end = null;
|
|
}
|
|
function WrappingSourceLocation(startToken) {
|
|
this.start = {
|
|
line: startToken.lineNumber,
|
|
column: startToken.start - startToken.lineStart
|
|
};
|
|
this.end = null;
|
|
}
|
|
function Node() {
|
|
if (extra.range) {
|
|
this.range = [startIndex, 0];
|
|
}
|
|
if (extra.loc) {
|
|
this.loc = new SourceLocation();
|
|
}
|
|
}
|
|
function WrappingNode(startToken) {
|
|
if (extra.range) {
|
|
this.range = [startToken.start, 0];
|
|
}
|
|
if (extra.loc) {
|
|
this.loc = new WrappingSourceLocation(startToken);
|
|
}
|
|
}
|
|
WrappingNode.prototype = Node.prototype = {
|
|
processComment: function() {
|
|
var lastChild,
|
|
innerComments,
|
|
leadingComments,
|
|
trailingComments,
|
|
bottomRight = extra.bottomRightStack,
|
|
i,
|
|
comment,
|
|
last = bottomRight[bottomRight.length - 1];
|
|
if (this.type === Syntax.Program) {
|
|
if (this.body.length > 0) {
|
|
return;
|
|
}
|
|
}
|
|
if (this.type === Syntax.BlockStatement && this.body.length === 0) {
|
|
innerComments = [];
|
|
for (i = extra.leadingComments.length - 1; i >= 0; --i) {
|
|
comment = extra.leadingComments[i];
|
|
if (this.range[1] >= comment.range[1]) {
|
|
innerComments.unshift(comment);
|
|
extra.leadingComments.splice(i, 1);
|
|
extra.trailingComments.splice(i, 1);
|
|
}
|
|
}
|
|
if (innerComments.length) {
|
|
this.innerComments = innerComments;
|
|
return;
|
|
}
|
|
}
|
|
if (extra.trailingComments.length > 0) {
|
|
trailingComments = [];
|
|
for (i = extra.trailingComments.length - 1; i >= 0; --i) {
|
|
comment = extra.trailingComments[i];
|
|
if (comment.range[0] >= this.range[1]) {
|
|
trailingComments.unshift(comment);
|
|
extra.trailingComments.splice(i, 1);
|
|
}
|
|
}
|
|
extra.trailingComments = [];
|
|
} else {
|
|
if (last && last.trailingComments && last.trailingComments[0].range[0] >= this.range[1]) {
|
|
trailingComments = last.trailingComments;
|
|
delete last.trailingComments;
|
|
}
|
|
}
|
|
while (last && last.range[0] >= this.range[0]) {
|
|
lastChild = bottomRight.pop();
|
|
last = bottomRight[bottomRight.length - 1];
|
|
}
|
|
if (lastChild) {
|
|
if (lastChild.leadingComments) {
|
|
leadingComments = [];
|
|
for (i = lastChild.leadingComments.length - 1; i >= 0; --i) {
|
|
comment = lastChild.leadingComments[i];
|
|
if (comment.range[1] <= this.range[0]) {
|
|
leadingComments.unshift(comment);
|
|
lastChild.leadingComments.splice(i, 1);
|
|
}
|
|
}
|
|
if (!lastChild.leadingComments.length) {
|
|
lastChild.leadingComments = undefined;
|
|
}
|
|
}
|
|
} else if (extra.leadingComments.length > 0) {
|
|
leadingComments = [];
|
|
for (i = extra.leadingComments.length - 1; i >= 0; --i) {
|
|
comment = extra.leadingComments[i];
|
|
if (comment.range[1] <= this.range[0]) {
|
|
leadingComments.unshift(comment);
|
|
extra.leadingComments.splice(i, 1);
|
|
}
|
|
}
|
|
}
|
|
if (leadingComments && leadingComments.length > 0) {
|
|
this.leadingComments = leadingComments;
|
|
}
|
|
if (trailingComments && trailingComments.length > 0) {
|
|
this.trailingComments = trailingComments;
|
|
}
|
|
bottomRight.push(this);
|
|
},
|
|
finish: function() {
|
|
if (extra.range) {
|
|
this.range[1] = lastIndex;
|
|
}
|
|
if (extra.loc) {
|
|
this.loc.end = {
|
|
line: lastLineNumber,
|
|
column: lastIndex - lastLineStart
|
|
};
|
|
if (extra.source) {
|
|
this.loc.source = extra.source;
|
|
}
|
|
}
|
|
if (extra.attachComment) {
|
|
this.processComment();
|
|
}
|
|
},
|
|
finishArrayExpression: function(elements) {
|
|
this.type = Syntax.ArrayExpression;
|
|
this.elements = elements;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishArrayPattern: function(elements) {
|
|
this.type = Syntax.ArrayPattern;
|
|
this.elements = elements;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishArrowFunctionExpression: function(params, defaults, body, expression) {
|
|
this.type = Syntax.ArrowFunctionExpression;
|
|
this.id = null;
|
|
this.params = params;
|
|
this.defaults = defaults;
|
|
this.body = body;
|
|
this.generator = false;
|
|
this.expression = expression;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishAssignmentExpression: function(operator, left, right) {
|
|
this.type = Syntax.AssignmentExpression;
|
|
this.operator = operator;
|
|
this.left = left;
|
|
this.right = right;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishAssignmentPattern: function(left, right) {
|
|
this.type = Syntax.AssignmentPattern;
|
|
this.left = left;
|
|
this.right = right;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishBinaryExpression: function(operator, left, right) {
|
|
this.type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : Syntax.BinaryExpression;
|
|
this.operator = operator;
|
|
this.left = left;
|
|
this.right = right;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishBlockStatement: function(body) {
|
|
this.type = Syntax.BlockStatement;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishBreakStatement: function(label) {
|
|
this.type = Syntax.BreakStatement;
|
|
this.label = label;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishCallExpression: function(callee, args) {
|
|
this.type = Syntax.CallExpression;
|
|
this.callee = callee;
|
|
this.arguments = args;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishCatchClause: function(param, body) {
|
|
this.type = Syntax.CatchClause;
|
|
this.param = param;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishClassBody: function(body) {
|
|
this.type = Syntax.ClassBody;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishClassDeclaration: function(id, superClass, body) {
|
|
this.type = Syntax.ClassDeclaration;
|
|
this.id = id;
|
|
this.superClass = superClass;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishClassExpression: function(id, superClass, body) {
|
|
this.type = Syntax.ClassExpression;
|
|
this.id = id;
|
|
this.superClass = superClass;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishConditionalExpression: function(test, consequent, alternate) {
|
|
this.type = Syntax.ConditionalExpression;
|
|
this.test = test;
|
|
this.consequent = consequent;
|
|
this.alternate = alternate;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishContinueStatement: function(label) {
|
|
this.type = Syntax.ContinueStatement;
|
|
this.label = label;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishDebuggerStatement: function() {
|
|
this.type = Syntax.DebuggerStatement;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishDoWhileStatement: function(body, test) {
|
|
this.type = Syntax.DoWhileStatement;
|
|
this.body = body;
|
|
this.test = test;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishEmptyStatement: function() {
|
|
this.type = Syntax.EmptyStatement;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishExpressionStatement: function(expression) {
|
|
this.type = Syntax.ExpressionStatement;
|
|
this.expression = expression;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishForStatement: function(init, test, update, body) {
|
|
this.type = Syntax.ForStatement;
|
|
this.init = init;
|
|
this.test = test;
|
|
this.update = update;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishForOfStatement: function(left, right, body) {
|
|
this.type = Syntax.ForOfStatement;
|
|
this.left = left;
|
|
this.right = right;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishForInStatement: function(left, right, body) {
|
|
this.type = Syntax.ForInStatement;
|
|
this.left = left;
|
|
this.right = right;
|
|
this.body = body;
|
|
this.each = false;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishFunctionDeclaration: function(id, params, defaults, body, generator) {
|
|
this.type = Syntax.FunctionDeclaration;
|
|
this.id = id;
|
|
this.params = params;
|
|
this.defaults = defaults;
|
|
this.body = body;
|
|
this.generator = generator;
|
|
this.expression = false;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishFunctionExpression: function(id, params, defaults, body, generator) {
|
|
this.type = Syntax.FunctionExpression;
|
|
this.id = id;
|
|
this.params = params;
|
|
this.defaults = defaults;
|
|
this.body = body;
|
|
this.generator = generator;
|
|
this.expression = false;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishIdentifier: function(name) {
|
|
this.type = Syntax.Identifier;
|
|
this.name = name;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishIfStatement: function(test, consequent, alternate) {
|
|
this.type = Syntax.IfStatement;
|
|
this.test = test;
|
|
this.consequent = consequent;
|
|
this.alternate = alternate;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishLabeledStatement: function(label, body) {
|
|
this.type = Syntax.LabeledStatement;
|
|
this.label = label;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishLiteral: function(token) {
|
|
this.type = Syntax.Literal;
|
|
this.value = token.value;
|
|
this.raw = source.slice(token.start, token.end);
|
|
if (token.regex) {
|
|
this.regex = token.regex;
|
|
}
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishMemberExpression: function(accessor, object, property) {
|
|
this.type = Syntax.MemberExpression;
|
|
this.computed = accessor === '[';
|
|
this.object = object;
|
|
this.property = property;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishMetaProperty: function(meta, property) {
|
|
this.type = Syntax.MetaProperty;
|
|
this.meta = meta;
|
|
this.property = property;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishNewExpression: function(callee, args) {
|
|
this.type = Syntax.NewExpression;
|
|
this.callee = callee;
|
|
this.arguments = args;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishObjectExpression: function(properties) {
|
|
this.type = Syntax.ObjectExpression;
|
|
this.properties = properties;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishObjectPattern: function(properties) {
|
|
this.type = Syntax.ObjectPattern;
|
|
this.properties = properties;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishPostfixExpression: function(operator, argument) {
|
|
this.type = Syntax.UpdateExpression;
|
|
this.operator = operator;
|
|
this.argument = argument;
|
|
this.prefix = false;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishProgram: function(body, sourceType) {
|
|
this.type = Syntax.Program;
|
|
this.body = body;
|
|
this.sourceType = sourceType;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishProperty: function(kind, key, computed, value, method, shorthand) {
|
|
this.type = Syntax.Property;
|
|
this.key = key;
|
|
this.computed = computed;
|
|
this.value = value;
|
|
this.kind = kind;
|
|
this.method = method;
|
|
this.shorthand = shorthand;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishRestElement: function(argument) {
|
|
this.type = Syntax.RestElement;
|
|
this.argument = argument;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishReturnStatement: function(argument) {
|
|
this.type = Syntax.ReturnStatement;
|
|
this.argument = argument;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishSequenceExpression: function(expressions) {
|
|
this.type = Syntax.SequenceExpression;
|
|
this.expressions = expressions;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishSpreadElement: function(argument) {
|
|
this.type = Syntax.SpreadElement;
|
|
this.argument = argument;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishSwitchCase: function(test, consequent) {
|
|
this.type = Syntax.SwitchCase;
|
|
this.test = test;
|
|
this.consequent = consequent;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishSuper: function() {
|
|
this.type = Syntax.Super;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishSwitchStatement: function(discriminant, cases) {
|
|
this.type = Syntax.SwitchStatement;
|
|
this.discriminant = discriminant;
|
|
this.cases = cases;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishTaggedTemplateExpression: function(tag, quasi) {
|
|
this.type = Syntax.TaggedTemplateExpression;
|
|
this.tag = tag;
|
|
this.quasi = quasi;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishTemplateElement: function(value, tail) {
|
|
this.type = Syntax.TemplateElement;
|
|
this.value = value;
|
|
this.tail = tail;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishTemplateLiteral: function(quasis, expressions) {
|
|
this.type = Syntax.TemplateLiteral;
|
|
this.quasis = quasis;
|
|
this.expressions = expressions;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishThisExpression: function() {
|
|
this.type = Syntax.ThisExpression;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishThrowStatement: function(argument) {
|
|
this.type = Syntax.ThrowStatement;
|
|
this.argument = argument;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishTryStatement: function(block, handler, finalizer) {
|
|
this.type = Syntax.TryStatement;
|
|
this.block = block;
|
|
this.guardedHandlers = [];
|
|
this.handlers = handler ? [handler] : [];
|
|
this.handler = handler;
|
|
this.finalizer = finalizer;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishUnaryExpression: function(operator, argument) {
|
|
this.type = (operator === '++' || operator === '--') ? Syntax.UpdateExpression : Syntax.UnaryExpression;
|
|
this.operator = operator;
|
|
this.argument = argument;
|
|
this.prefix = true;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishVariableDeclaration: function(declarations) {
|
|
this.type = Syntax.VariableDeclaration;
|
|
this.declarations = declarations;
|
|
this.kind = 'var';
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishLexicalDeclaration: function(declarations, kind) {
|
|
this.type = Syntax.VariableDeclaration;
|
|
this.declarations = declarations;
|
|
this.kind = kind;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishVariableDeclarator: function(id, init) {
|
|
this.type = Syntax.VariableDeclarator;
|
|
this.id = id;
|
|
this.init = init;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishWhileStatement: function(test, body) {
|
|
this.type = Syntax.WhileStatement;
|
|
this.test = test;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishWithStatement: function(object, body) {
|
|
this.type = Syntax.WithStatement;
|
|
this.object = object;
|
|
this.body = body;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishExportSpecifier: function(local, exported) {
|
|
this.type = Syntax.ExportSpecifier;
|
|
this.exported = exported || local;
|
|
this.local = local;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishImportDefaultSpecifier: function(local) {
|
|
this.type = Syntax.ImportDefaultSpecifier;
|
|
this.local = local;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishImportNamespaceSpecifier: function(local) {
|
|
this.type = Syntax.ImportNamespaceSpecifier;
|
|
this.local = local;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishExportNamedDeclaration: function(declaration, specifiers, src) {
|
|
this.type = Syntax.ExportNamedDeclaration;
|
|
this.declaration = declaration;
|
|
this.specifiers = specifiers;
|
|
this.source = src;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishExportDefaultDeclaration: function(declaration) {
|
|
this.type = Syntax.ExportDefaultDeclaration;
|
|
this.declaration = declaration;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishExportAllDeclaration: function(src) {
|
|
this.type = Syntax.ExportAllDeclaration;
|
|
this.source = src;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishImportSpecifier: function(local, imported) {
|
|
this.type = Syntax.ImportSpecifier;
|
|
this.local = local || imported;
|
|
this.imported = imported;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishImportDeclaration: function(specifiers, src) {
|
|
this.type = Syntax.ImportDeclaration;
|
|
this.specifiers = specifiers;
|
|
this.source = src;
|
|
this.finish();
|
|
return this;
|
|
},
|
|
finishYieldExpression: function(argument, delegate) {
|
|
this.type = Syntax.YieldExpression;
|
|
this.argument = argument;
|
|
this.delegate = delegate;
|
|
this.finish();
|
|
return this;
|
|
}
|
|
};
|
|
function recordError(error) {
|
|
var e,
|
|
existing;
|
|
for (e = 0; e < extra.errors.length; e++) {
|
|
existing = extra.errors[e];
|
|
if (existing.index === error.index && existing.message === error.message) {
|
|
return;
|
|
}
|
|
}
|
|
extra.errors.push(error);
|
|
}
|
|
function constructError(msg, column) {
|
|
var error = new Error(msg);
|
|
try {
|
|
throw error;
|
|
} catch (base) {
|
|
if (Object.create && Object.defineProperty) {
|
|
error = Object.create(base);
|
|
Object.defineProperty(error, 'column', {value: column});
|
|
}
|
|
} finally {
|
|
return error;
|
|
}
|
|
}
|
|
function createError(line, pos, description) {
|
|
var msg,
|
|
column,
|
|
error;
|
|
msg = 'Line ' + line + ': ' + description;
|
|
column = pos - (scanning ? lineStart : lastLineStart) + 1;
|
|
error = constructError(msg, column);
|
|
error.lineNumber = line;
|
|
error.description = description;
|
|
error.index = pos;
|
|
return error;
|
|
}
|
|
function throwError(messageFormat) {
|
|
var args,
|
|
msg;
|
|
args = Array.prototype.slice.call(arguments, 1);
|
|
msg = messageFormat.replace(/%(\d)/g, function(whole, idx) {
|
|
assert(idx < args.length, 'Message reference must be in range');
|
|
return args[idx];
|
|
});
|
|
throw createError(lastLineNumber, lastIndex, msg);
|
|
}
|
|
function tolerateError(messageFormat) {
|
|
var args,
|
|
msg,
|
|
error;
|
|
args = Array.prototype.slice.call(arguments, 1);
|
|
msg = messageFormat.replace(/%(\d)/g, function(whole, idx) {
|
|
assert(idx < args.length, 'Message reference must be in range');
|
|
return args[idx];
|
|
});
|
|
error = createError(lineNumber, lastIndex, msg);
|
|
if (extra.errors) {
|
|
recordError(error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
function unexpectedTokenError(token, message) {
|
|
var value,
|
|
msg = message || Messages.UnexpectedToken;
|
|
if (token) {
|
|
if (!message) {
|
|
msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS : (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier : (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber : (token.type === Token.StringLiteral) ? Messages.UnexpectedString : (token.type === Token.Template) ? Messages.UnexpectedTemplate : Messages.UnexpectedToken;
|
|
if (token.type === Token.Keyword) {
|
|
if (isFutureReservedWord(token.value)) {
|
|
msg = Messages.UnexpectedReserved;
|
|
} else if (strict && isStrictModeReservedWord(token.value)) {
|
|
msg = Messages.StrictReservedWord;
|
|
}
|
|
}
|
|
}
|
|
value = (token.type === Token.Template) ? token.value.raw : token.value;
|
|
} else {
|
|
value = 'ILLEGAL';
|
|
}
|
|
msg = msg.replace('%0', value);
|
|
return (token && typeof token.lineNumber === 'number') ? createError(token.lineNumber, token.start, msg) : createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg);
|
|
}
|
|
function throwUnexpectedToken(token, message) {
|
|
throw unexpectedTokenError(token, message);
|
|
}
|
|
function tolerateUnexpectedToken(token, message) {
|
|
var error = unexpectedTokenError(token, message);
|
|
if (extra.errors) {
|
|
recordError(error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
function expect(value) {
|
|
var token = lex();
|
|
if (token.type !== Token.Punctuator || token.value !== value) {
|
|
throwUnexpectedToken(token);
|
|
}
|
|
}
|
|
function expectCommaSeparator() {
|
|
var token;
|
|
if (extra.errors) {
|
|
token = lookahead;
|
|
if (token.type === Token.Punctuator && token.value === ',') {
|
|
lex();
|
|
} else if (token.type === Token.Punctuator && token.value === ';') {
|
|
lex();
|
|
tolerateUnexpectedToken(token);
|
|
} else {
|
|
tolerateUnexpectedToken(token, Messages.UnexpectedToken);
|
|
}
|
|
} else {
|
|
expect(',');
|
|
}
|
|
}
|
|
function expectKeyword(keyword) {
|
|
var token = lex();
|
|
if (token.type !== Token.Keyword || token.value !== keyword) {
|
|
throwUnexpectedToken(token);
|
|
}
|
|
}
|
|
function match(value) {
|
|
return lookahead.type === Token.Punctuator && lookahead.value === value;
|
|
}
|
|
function matchKeyword(keyword) {
|
|
return lookahead.type === Token.Keyword && lookahead.value === keyword;
|
|
}
|
|
function matchContextualKeyword(keyword) {
|
|
return lookahead.type === Token.Identifier && lookahead.value === keyword;
|
|
}
|
|
function matchAssign() {
|
|
var op;
|
|
if (lookahead.type !== Token.Punctuator) {
|
|
return false;
|
|
}
|
|
op = lookahead.value;
|
|
return op === '=' || op === '*=' || op === '/=' || op === '%=' || op === '+=' || op === '-=' || op === '<<=' || op === '>>=' || op === '>>>=' || op === '&=' || op === '^=' || op === '|=';
|
|
}
|
|
function consumeSemicolon() {
|
|
if (source.charCodeAt(startIndex) === 0x3B || match(';')) {
|
|
lex();
|
|
return;
|
|
}
|
|
if (hasLineTerminator) {
|
|
return;
|
|
}
|
|
lastIndex = startIndex;
|
|
lastLineNumber = startLineNumber;
|
|
lastLineStart = startLineStart;
|
|
if (lookahead.type !== Token.EOF && !match('}')) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
}
|
|
function isolateCoverGrammar(parser) {
|
|
var oldIsBindingElement = isBindingElement,
|
|
oldIsAssignmentTarget = isAssignmentTarget,
|
|
oldFirstCoverInitializedNameError = firstCoverInitializedNameError,
|
|
result;
|
|
isBindingElement = true;
|
|
isAssignmentTarget = true;
|
|
firstCoverInitializedNameError = null;
|
|
result = parser();
|
|
if (firstCoverInitializedNameError !== null) {
|
|
throwUnexpectedToken(firstCoverInitializedNameError);
|
|
}
|
|
isBindingElement = oldIsBindingElement;
|
|
isAssignmentTarget = oldIsAssignmentTarget;
|
|
firstCoverInitializedNameError = oldFirstCoverInitializedNameError;
|
|
return result;
|
|
}
|
|
function inheritCoverGrammar(parser) {
|
|
var oldIsBindingElement = isBindingElement,
|
|
oldIsAssignmentTarget = isAssignmentTarget,
|
|
oldFirstCoverInitializedNameError = firstCoverInitializedNameError,
|
|
result;
|
|
isBindingElement = true;
|
|
isAssignmentTarget = true;
|
|
firstCoverInitializedNameError = null;
|
|
result = parser();
|
|
isBindingElement = isBindingElement && oldIsBindingElement;
|
|
isAssignmentTarget = isAssignmentTarget && oldIsAssignmentTarget;
|
|
firstCoverInitializedNameError = oldFirstCoverInitializedNameError || firstCoverInitializedNameError;
|
|
return result;
|
|
}
|
|
function parseArrayPattern(params, kind) {
|
|
var node = new Node(),
|
|
elements = [],
|
|
rest,
|
|
restNode;
|
|
expect('[');
|
|
while (!match(']')) {
|
|
if (match(',')) {
|
|
lex();
|
|
elements.push(null);
|
|
} else {
|
|
if (match('...')) {
|
|
restNode = new Node();
|
|
lex();
|
|
params.push(lookahead);
|
|
rest = parseVariableIdentifier(kind);
|
|
elements.push(restNode.finishRestElement(rest));
|
|
break;
|
|
} else {
|
|
elements.push(parsePatternWithDefault(params, kind));
|
|
}
|
|
if (!match(']')) {
|
|
expect(',');
|
|
}
|
|
}
|
|
}
|
|
expect(']');
|
|
return node.finishArrayPattern(elements);
|
|
}
|
|
function parsePropertyPattern(params, kind) {
|
|
var node = new Node(),
|
|
key,
|
|
keyToken,
|
|
computed = match('['),
|
|
init;
|
|
if (lookahead.type === Token.Identifier) {
|
|
keyToken = lookahead;
|
|
key = parseVariableIdentifier();
|
|
if (match('=')) {
|
|
params.push(keyToken);
|
|
lex();
|
|
init = parseAssignmentExpression();
|
|
return node.finishProperty('init', key, false, new WrappingNode(keyToken).finishAssignmentPattern(key, init), false, false);
|
|
} else if (!match(':')) {
|
|
params.push(keyToken);
|
|
return node.finishProperty('init', key, false, key, false, true);
|
|
}
|
|
} else {
|
|
key = parseObjectPropertyKey();
|
|
}
|
|
expect(':');
|
|
init = parsePatternWithDefault(params, kind);
|
|
return node.finishProperty('init', key, computed, init, false, false);
|
|
}
|
|
function parseObjectPattern(params, kind) {
|
|
var node = new Node(),
|
|
properties = [];
|
|
expect('{');
|
|
while (!match('}')) {
|
|
properties.push(parsePropertyPattern(params, kind));
|
|
if (!match('}')) {
|
|
expect(',');
|
|
}
|
|
}
|
|
lex();
|
|
return node.finishObjectPattern(properties);
|
|
}
|
|
function parsePattern(params, kind) {
|
|
if (match('[')) {
|
|
return parseArrayPattern(params, kind);
|
|
} else if (match('{')) {
|
|
return parseObjectPattern(params, kind);
|
|
} else if (matchKeyword('let')) {
|
|
if (kind === 'const' || kind === 'let') {
|
|
tolerateUnexpectedToken(lookahead, Messages.UnexpectedToken);
|
|
}
|
|
}
|
|
params.push(lookahead);
|
|
return parseVariableIdentifier(kind);
|
|
}
|
|
function parsePatternWithDefault(params, kind) {
|
|
var startToken = lookahead,
|
|
pattern,
|
|
previousAllowYield,
|
|
right;
|
|
pattern = parsePattern(params, kind);
|
|
if (match('=')) {
|
|
lex();
|
|
previousAllowYield = state.allowYield;
|
|
state.allowYield = true;
|
|
right = isolateCoverGrammar(parseAssignmentExpression);
|
|
state.allowYield = previousAllowYield;
|
|
pattern = new WrappingNode(startToken).finishAssignmentPattern(pattern, right);
|
|
}
|
|
return pattern;
|
|
}
|
|
function parseArrayInitializer() {
|
|
var elements = [],
|
|
node = new Node(),
|
|
restSpread;
|
|
expect('[');
|
|
while (!match(']')) {
|
|
if (match(',')) {
|
|
lex();
|
|
elements.push(null);
|
|
} else if (match('...')) {
|
|
restSpread = new Node();
|
|
lex();
|
|
restSpread.finishSpreadElement(inheritCoverGrammar(parseAssignmentExpression));
|
|
if (!match(']')) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
expect(',');
|
|
}
|
|
elements.push(restSpread);
|
|
} else {
|
|
elements.push(inheritCoverGrammar(parseAssignmentExpression));
|
|
if (!match(']')) {
|
|
expect(',');
|
|
}
|
|
}
|
|
}
|
|
lex();
|
|
return node.finishArrayExpression(elements);
|
|
}
|
|
function parsePropertyFunction(node, paramInfo, isGenerator) {
|
|
var previousStrict,
|
|
body;
|
|
isAssignmentTarget = isBindingElement = false;
|
|
previousStrict = strict;
|
|
body = isolateCoverGrammar(parseFunctionSourceElements);
|
|
if (strict && paramInfo.firstRestricted) {
|
|
tolerateUnexpectedToken(paramInfo.firstRestricted, paramInfo.message);
|
|
}
|
|
if (strict && paramInfo.stricted) {
|
|
tolerateUnexpectedToken(paramInfo.stricted, paramInfo.message);
|
|
}
|
|
strict = previousStrict;
|
|
return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body, isGenerator);
|
|
}
|
|
function parsePropertyMethodFunction() {
|
|
var params,
|
|
method,
|
|
node = new Node(),
|
|
previousAllowYield = state.allowYield;
|
|
state.allowYield = false;
|
|
params = parseParams();
|
|
state.allowYield = previousAllowYield;
|
|
state.allowYield = false;
|
|
method = parsePropertyFunction(node, params, false);
|
|
state.allowYield = previousAllowYield;
|
|
return method;
|
|
}
|
|
function parseObjectPropertyKey() {
|
|
var token,
|
|
node = new Node(),
|
|
expr;
|
|
token = lex();
|
|
switch (token.type) {
|
|
case Token.StringLiteral:
|
|
case Token.NumericLiteral:
|
|
if (strict && token.octal) {
|
|
tolerateUnexpectedToken(token, Messages.StrictOctalLiteral);
|
|
}
|
|
return node.finishLiteral(token);
|
|
case Token.Identifier:
|
|
case Token.BooleanLiteral:
|
|
case Token.NullLiteral:
|
|
case Token.Keyword:
|
|
return node.finishIdentifier(token.value);
|
|
case Token.Punctuator:
|
|
if (token.value === '[') {
|
|
expr = isolateCoverGrammar(parseAssignmentExpression);
|
|
expect(']');
|
|
return expr;
|
|
}
|
|
break;
|
|
}
|
|
throwUnexpectedToken(token);
|
|
}
|
|
function lookaheadPropertyName() {
|
|
switch (lookahead.type) {
|
|
case Token.Identifier:
|
|
case Token.StringLiteral:
|
|
case Token.BooleanLiteral:
|
|
case Token.NullLiteral:
|
|
case Token.NumericLiteral:
|
|
case Token.Keyword:
|
|
return true;
|
|
case Token.Punctuator:
|
|
return lookahead.value === '[';
|
|
}
|
|
return false;
|
|
}
|
|
function tryParseMethodDefinition(token, key, computed, node) {
|
|
var value,
|
|
options,
|
|
methodNode,
|
|
params,
|
|
previousAllowYield = state.allowYield;
|
|
if (token.type === Token.Identifier) {
|
|
if (token.value === 'get' && lookaheadPropertyName()) {
|
|
computed = match('[');
|
|
key = parseObjectPropertyKey();
|
|
methodNode = new Node();
|
|
expect('(');
|
|
expect(')');
|
|
state.allowYield = false;
|
|
value = parsePropertyFunction(methodNode, {
|
|
params: [],
|
|
defaults: [],
|
|
stricted: null,
|
|
firstRestricted: null,
|
|
message: null
|
|
}, false);
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishProperty('get', key, computed, value, false, false);
|
|
} else if (token.value === 'set' && lookaheadPropertyName()) {
|
|
computed = match('[');
|
|
key = parseObjectPropertyKey();
|
|
methodNode = new Node();
|
|
expect('(');
|
|
options = {
|
|
params: [],
|
|
defaultCount: 0,
|
|
defaults: [],
|
|
firstRestricted: null,
|
|
paramSet: {}
|
|
};
|
|
if (match(')')) {
|
|
tolerateUnexpectedToken(lookahead);
|
|
} else {
|
|
state.allowYield = false;
|
|
parseParam(options);
|
|
state.allowYield = previousAllowYield;
|
|
if (options.defaultCount === 0) {
|
|
options.defaults = [];
|
|
}
|
|
}
|
|
expect(')');
|
|
state.allowYield = false;
|
|
value = parsePropertyFunction(methodNode, options, false);
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishProperty('set', key, computed, value, false, false);
|
|
}
|
|
} else if (token.type === Token.Punctuator && token.value === '*' && lookaheadPropertyName()) {
|
|
computed = match('[');
|
|
key = parseObjectPropertyKey();
|
|
methodNode = new Node();
|
|
state.allowYield = true;
|
|
params = parseParams();
|
|
state.allowYield = previousAllowYield;
|
|
state.allowYield = false;
|
|
value = parsePropertyFunction(methodNode, params, true);
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishProperty('init', key, computed, value, true, false);
|
|
}
|
|
if (key && match('(')) {
|
|
value = parsePropertyMethodFunction();
|
|
return node.finishProperty('init', key, computed, value, true, false);
|
|
}
|
|
return null;
|
|
}
|
|
function parseObjectProperty(hasProto) {
|
|
var token = lookahead,
|
|
node = new Node(),
|
|
computed,
|
|
key,
|
|
maybeMethod,
|
|
proto,
|
|
value;
|
|
computed = match('[');
|
|
if (match('*')) {
|
|
lex();
|
|
} else {
|
|
key = parseObjectPropertyKey();
|
|
}
|
|
maybeMethod = tryParseMethodDefinition(token, key, computed, node);
|
|
if (maybeMethod) {
|
|
return maybeMethod;
|
|
}
|
|
if (!key) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
if (!computed) {
|
|
proto = (key.type === Syntax.Identifier && key.name === '__proto__') || (key.type === Syntax.Literal && key.value === '__proto__');
|
|
if (hasProto.value && proto) {
|
|
tolerateError(Messages.DuplicateProtoProperty);
|
|
}
|
|
hasProto.value |= proto;
|
|
}
|
|
if (match(':')) {
|
|
lex();
|
|
value = inheritCoverGrammar(parseAssignmentExpression);
|
|
return node.finishProperty('init', key, computed, value, false, false);
|
|
}
|
|
if (token.type === Token.Identifier) {
|
|
if (match('=')) {
|
|
firstCoverInitializedNameError = lookahead;
|
|
lex();
|
|
value = isolateCoverGrammar(parseAssignmentExpression);
|
|
return node.finishProperty('init', key, computed, new WrappingNode(token).finishAssignmentPattern(key, value), false, true);
|
|
}
|
|
return node.finishProperty('init', key, computed, key, false, true);
|
|
}
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
function parseObjectInitializer() {
|
|
var properties = [],
|
|
hasProto = {value: false},
|
|
node = new Node();
|
|
expect('{');
|
|
while (!match('}')) {
|
|
properties.push(parseObjectProperty(hasProto));
|
|
if (!match('}')) {
|
|
expectCommaSeparator();
|
|
}
|
|
}
|
|
expect('}');
|
|
return node.finishObjectExpression(properties);
|
|
}
|
|
function reinterpretExpressionAsPattern(expr) {
|
|
var i;
|
|
switch (expr.type) {
|
|
case Syntax.Identifier:
|
|
case Syntax.MemberExpression:
|
|
case Syntax.RestElement:
|
|
case Syntax.AssignmentPattern:
|
|
break;
|
|
case Syntax.SpreadElement:
|
|
expr.type = Syntax.RestElement;
|
|
reinterpretExpressionAsPattern(expr.argument);
|
|
break;
|
|
case Syntax.ArrayExpression:
|
|
expr.type = Syntax.ArrayPattern;
|
|
for (i = 0; i < expr.elements.length; i++) {
|
|
if (expr.elements[i] !== null) {
|
|
reinterpretExpressionAsPattern(expr.elements[i]);
|
|
}
|
|
}
|
|
break;
|
|
case Syntax.ObjectExpression:
|
|
expr.type = Syntax.ObjectPattern;
|
|
for (i = 0; i < expr.properties.length; i++) {
|
|
reinterpretExpressionAsPattern(expr.properties[i].value);
|
|
}
|
|
break;
|
|
case Syntax.AssignmentExpression:
|
|
expr.type = Syntax.AssignmentPattern;
|
|
reinterpretExpressionAsPattern(expr.left);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
function parseTemplateElement(option) {
|
|
var node,
|
|
token;
|
|
if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) {
|
|
throwUnexpectedToken();
|
|
}
|
|
node = new Node();
|
|
token = lex();
|
|
return node.finishTemplateElement({
|
|
raw: token.value.raw,
|
|
cooked: token.value.cooked
|
|
}, token.tail);
|
|
}
|
|
function parseTemplateLiteral() {
|
|
var quasi,
|
|
quasis,
|
|
expressions,
|
|
node = new Node();
|
|
quasi = parseTemplateElement({head: true});
|
|
quasis = [quasi];
|
|
expressions = [];
|
|
while (!quasi.tail) {
|
|
expressions.push(parseExpression());
|
|
quasi = parseTemplateElement({head: false});
|
|
quasis.push(quasi);
|
|
}
|
|
return node.finishTemplateLiteral(quasis, expressions);
|
|
}
|
|
function parseGroupExpression() {
|
|
var expr,
|
|
expressions,
|
|
startToken,
|
|
i,
|
|
params = [];
|
|
expect('(');
|
|
if (match(')')) {
|
|
lex();
|
|
if (!match('=>')) {
|
|
expect('=>');
|
|
}
|
|
return {
|
|
type: PlaceHolders.ArrowParameterPlaceHolder,
|
|
params: [],
|
|
rawParams: []
|
|
};
|
|
}
|
|
startToken = lookahead;
|
|
if (match('...')) {
|
|
expr = parseRestElement(params);
|
|
expect(')');
|
|
if (!match('=>')) {
|
|
expect('=>');
|
|
}
|
|
return {
|
|
type: PlaceHolders.ArrowParameterPlaceHolder,
|
|
params: [expr]
|
|
};
|
|
}
|
|
isBindingElement = true;
|
|
expr = inheritCoverGrammar(parseAssignmentExpression);
|
|
if (match(',')) {
|
|
isAssignmentTarget = false;
|
|
expressions = [expr];
|
|
while (startIndex < length) {
|
|
if (!match(',')) {
|
|
break;
|
|
}
|
|
lex();
|
|
if (match('...')) {
|
|
if (!isBindingElement) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
expressions.push(parseRestElement(params));
|
|
expect(')');
|
|
if (!match('=>')) {
|
|
expect('=>');
|
|
}
|
|
isBindingElement = false;
|
|
for (i = 0; i < expressions.length; i++) {
|
|
reinterpretExpressionAsPattern(expressions[i]);
|
|
}
|
|
return {
|
|
type: PlaceHolders.ArrowParameterPlaceHolder,
|
|
params: expressions
|
|
};
|
|
}
|
|
expressions.push(inheritCoverGrammar(parseAssignmentExpression));
|
|
}
|
|
expr = new WrappingNode(startToken).finishSequenceExpression(expressions);
|
|
}
|
|
expect(')');
|
|
if (match('=>')) {
|
|
if (expr.type === Syntax.Identifier && expr.name === 'yield') {
|
|
return {
|
|
type: PlaceHolders.ArrowParameterPlaceHolder,
|
|
params: [expr]
|
|
};
|
|
}
|
|
if (!isBindingElement) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
if (expr.type === Syntax.SequenceExpression) {
|
|
for (i = 0; i < expr.expressions.length; i++) {
|
|
reinterpretExpressionAsPattern(expr.expressions[i]);
|
|
}
|
|
} else {
|
|
reinterpretExpressionAsPattern(expr);
|
|
}
|
|
expr = {
|
|
type: PlaceHolders.ArrowParameterPlaceHolder,
|
|
params: expr.type === Syntax.SequenceExpression ? expr.expressions : [expr]
|
|
};
|
|
}
|
|
isBindingElement = false;
|
|
return expr;
|
|
}
|
|
function parsePrimaryExpression() {
|
|
var type,
|
|
token,
|
|
expr,
|
|
node;
|
|
if (match('(')) {
|
|
isBindingElement = false;
|
|
return inheritCoverGrammar(parseGroupExpression);
|
|
}
|
|
if (match('[')) {
|
|
return inheritCoverGrammar(parseArrayInitializer);
|
|
}
|
|
if (match('{')) {
|
|
return inheritCoverGrammar(parseObjectInitializer);
|
|
}
|
|
type = lookahead.type;
|
|
node = new Node();
|
|
if (type === Token.Identifier) {
|
|
if (state.sourceType === 'module' && lookahead.value === 'await') {
|
|
tolerateUnexpectedToken(lookahead);
|
|
}
|
|
expr = node.finishIdentifier(lex().value);
|
|
} else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
if (strict && lookahead.octal) {
|
|
tolerateUnexpectedToken(lookahead, Messages.StrictOctalLiteral);
|
|
}
|
|
expr = node.finishLiteral(lex());
|
|
} else if (type === Token.Keyword) {
|
|
if (!strict && state.allowYield && matchKeyword('yield')) {
|
|
return parseNonComputedProperty();
|
|
}
|
|
isAssignmentTarget = isBindingElement = false;
|
|
if (matchKeyword('function')) {
|
|
return parseFunctionExpression();
|
|
}
|
|
if (matchKeyword('this')) {
|
|
lex();
|
|
return node.finishThisExpression();
|
|
}
|
|
if (matchKeyword('class')) {
|
|
return parseClassExpression();
|
|
}
|
|
if (!strict && matchKeyword('let')) {
|
|
return node.finishIdentifier(lex().value);
|
|
}
|
|
throwUnexpectedToken(lex());
|
|
} else if (type === Token.BooleanLiteral) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
token = lex();
|
|
token.value = (token.value === 'true');
|
|
expr = node.finishLiteral(token);
|
|
} else if (type === Token.NullLiteral) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
token = lex();
|
|
token.value = null;
|
|
expr = node.finishLiteral(token);
|
|
} else if (match('/') || match('/=')) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
index = startIndex;
|
|
if (typeof extra.tokens !== 'undefined') {
|
|
token = collectRegex();
|
|
} else {
|
|
token = scanRegExp();
|
|
}
|
|
lex();
|
|
expr = node.finishLiteral(token);
|
|
} else if (type === Token.Template) {
|
|
expr = parseTemplateLiteral();
|
|
} else {
|
|
throwUnexpectedToken(lex());
|
|
}
|
|
return expr;
|
|
}
|
|
function parseArguments() {
|
|
var args = [],
|
|
expr;
|
|
expect('(');
|
|
if (!match(')')) {
|
|
while (startIndex < length) {
|
|
if (match('...')) {
|
|
expr = new Node();
|
|
lex();
|
|
expr.finishSpreadElement(isolateCoverGrammar(parseAssignmentExpression));
|
|
} else {
|
|
expr = isolateCoverGrammar(parseAssignmentExpression);
|
|
}
|
|
args.push(expr);
|
|
if (match(')')) {
|
|
break;
|
|
}
|
|
expectCommaSeparator();
|
|
}
|
|
}
|
|
expect(')');
|
|
return args;
|
|
}
|
|
function parseNonComputedProperty() {
|
|
var token,
|
|
node = new Node();
|
|
token = lex();
|
|
if (!isIdentifierName(token)) {
|
|
throwUnexpectedToken(token);
|
|
}
|
|
return node.finishIdentifier(token.value);
|
|
}
|
|
function parseNonComputedMember() {
|
|
expect('.');
|
|
return parseNonComputedProperty();
|
|
}
|
|
function parseComputedMember() {
|
|
var expr;
|
|
expect('[');
|
|
expr = isolateCoverGrammar(parseExpression);
|
|
expect(']');
|
|
return expr;
|
|
}
|
|
function parseNewExpression() {
|
|
var callee,
|
|
args,
|
|
node = new Node();
|
|
expectKeyword('new');
|
|
if (match('.')) {
|
|
lex();
|
|
if (lookahead.type === Token.Identifier && lookahead.value === 'target') {
|
|
if (state.inFunctionBody) {
|
|
lex();
|
|
return node.finishMetaProperty('new', 'target');
|
|
}
|
|
}
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
callee = isolateCoverGrammar(parseLeftHandSideExpression);
|
|
args = match('(') ? parseArguments() : [];
|
|
isAssignmentTarget = isBindingElement = false;
|
|
return node.finishNewExpression(callee, args);
|
|
}
|
|
function parseLeftHandSideExpressionAllowCall() {
|
|
var quasi,
|
|
expr,
|
|
args,
|
|
property,
|
|
startToken,
|
|
previousAllowIn = state.allowIn;
|
|
startToken = lookahead;
|
|
state.allowIn = true;
|
|
if (matchKeyword('super') && state.inFunctionBody) {
|
|
expr = new Node();
|
|
lex();
|
|
expr = expr.finishSuper();
|
|
if (!match('(') && !match('.') && !match('[')) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
} else {
|
|
expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression);
|
|
}
|
|
for (; ; ) {
|
|
if (match('.')) {
|
|
isBindingElement = false;
|
|
isAssignmentTarget = true;
|
|
property = parseNonComputedMember();
|
|
expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);
|
|
} else if (match('(')) {
|
|
isBindingElement = false;
|
|
isAssignmentTarget = false;
|
|
args = parseArguments();
|
|
expr = new WrappingNode(startToken).finishCallExpression(expr, args);
|
|
} else if (match('[')) {
|
|
isBindingElement = false;
|
|
isAssignmentTarget = true;
|
|
property = parseComputedMember();
|
|
expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);
|
|
} else if (lookahead.type === Token.Template && lookahead.head) {
|
|
quasi = parseTemplateLiteral();
|
|
expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
state.allowIn = previousAllowIn;
|
|
return expr;
|
|
}
|
|
function parseLeftHandSideExpression() {
|
|
var quasi,
|
|
expr,
|
|
property,
|
|
startToken;
|
|
assert(state.allowIn, 'callee of new expression always allow in keyword.');
|
|
startToken = lookahead;
|
|
if (matchKeyword('super') && state.inFunctionBody) {
|
|
expr = new Node();
|
|
lex();
|
|
expr = expr.finishSuper();
|
|
if (!match('[') && !match('.')) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
} else {
|
|
expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression);
|
|
}
|
|
for (; ; ) {
|
|
if (match('[')) {
|
|
isBindingElement = false;
|
|
isAssignmentTarget = true;
|
|
property = parseComputedMember();
|
|
expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property);
|
|
} else if (match('.')) {
|
|
isBindingElement = false;
|
|
isAssignmentTarget = true;
|
|
property = parseNonComputedMember();
|
|
expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property);
|
|
} else if (lookahead.type === Token.Template && lookahead.head) {
|
|
quasi = parseTemplateLiteral();
|
|
expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return expr;
|
|
}
|
|
function parsePostfixExpression() {
|
|
var expr,
|
|
token,
|
|
startToken = lookahead;
|
|
expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall);
|
|
if (!hasLineTerminator && lookahead.type === Token.Punctuator) {
|
|
if (match('++') || match('--')) {
|
|
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
|
|
tolerateError(Messages.StrictLHSPostfix);
|
|
}
|
|
if (!isAssignmentTarget) {
|
|
tolerateError(Messages.InvalidLHSInAssignment);
|
|
}
|
|
isAssignmentTarget = isBindingElement = false;
|
|
token = lex();
|
|
expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr);
|
|
}
|
|
}
|
|
return expr;
|
|
}
|
|
function parseUnaryExpression() {
|
|
var token,
|
|
expr,
|
|
startToken;
|
|
if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
|
|
expr = parsePostfixExpression();
|
|
} else if (match('++') || match('--')) {
|
|
startToken = lookahead;
|
|
token = lex();
|
|
expr = inheritCoverGrammar(parseUnaryExpression);
|
|
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
|
|
tolerateError(Messages.StrictLHSPrefix);
|
|
}
|
|
if (!isAssignmentTarget) {
|
|
tolerateError(Messages.InvalidLHSInAssignment);
|
|
}
|
|
expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
|
|
isAssignmentTarget = isBindingElement = false;
|
|
} else if (match('+') || match('-') || match('~') || match('!')) {
|
|
startToken = lookahead;
|
|
token = lex();
|
|
expr = inheritCoverGrammar(parseUnaryExpression);
|
|
expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
|
|
isAssignmentTarget = isBindingElement = false;
|
|
} else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
|
|
startToken = lookahead;
|
|
token = lex();
|
|
expr = inheritCoverGrammar(parseUnaryExpression);
|
|
expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr);
|
|
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
|
|
tolerateError(Messages.StrictDelete);
|
|
}
|
|
isAssignmentTarget = isBindingElement = false;
|
|
} else {
|
|
expr = parsePostfixExpression();
|
|
}
|
|
return expr;
|
|
}
|
|
function binaryPrecedence(token, allowIn) {
|
|
var prec = 0;
|
|
if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
|
|
return 0;
|
|
}
|
|
switch (token.value) {
|
|
case '||':
|
|
prec = 1;
|
|
break;
|
|
case '&&':
|
|
prec = 2;
|
|
break;
|
|
case '|':
|
|
prec = 3;
|
|
break;
|
|
case '^':
|
|
prec = 4;
|
|
break;
|
|
case '&':
|
|
prec = 5;
|
|
break;
|
|
case '==':
|
|
case '!=':
|
|
case '===':
|
|
case '!==':
|
|
prec = 6;
|
|
break;
|
|
case '<':
|
|
case '>':
|
|
case '<=':
|
|
case '>=':
|
|
case 'instanceof':
|
|
prec = 7;
|
|
break;
|
|
case 'in':
|
|
prec = allowIn ? 7 : 0;
|
|
break;
|
|
case '<<':
|
|
case '>>':
|
|
case '>>>':
|
|
prec = 8;
|
|
break;
|
|
case '+':
|
|
case '-':
|
|
prec = 9;
|
|
break;
|
|
case '*':
|
|
case '/':
|
|
case '%':
|
|
prec = 11;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return prec;
|
|
}
|
|
function parseBinaryExpression() {
|
|
var marker,
|
|
markers,
|
|
expr,
|
|
token,
|
|
prec,
|
|
stack,
|
|
right,
|
|
operator,
|
|
left,
|
|
i;
|
|
marker = lookahead;
|
|
left = inheritCoverGrammar(parseUnaryExpression);
|
|
token = lookahead;
|
|
prec = binaryPrecedence(token, state.allowIn);
|
|
if (prec === 0) {
|
|
return left;
|
|
}
|
|
isAssignmentTarget = isBindingElement = false;
|
|
token.prec = prec;
|
|
lex();
|
|
markers = [marker, lookahead];
|
|
right = isolateCoverGrammar(parseUnaryExpression);
|
|
stack = [left, token, right];
|
|
while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) {
|
|
while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
|
|
right = stack.pop();
|
|
operator = stack.pop().value;
|
|
left = stack.pop();
|
|
markers.pop();
|
|
expr = new WrappingNode(markers[markers.length - 1]).finishBinaryExpression(operator, left, right);
|
|
stack.push(expr);
|
|
}
|
|
token = lex();
|
|
token.prec = prec;
|
|
stack.push(token);
|
|
markers.push(lookahead);
|
|
expr = isolateCoverGrammar(parseUnaryExpression);
|
|
stack.push(expr);
|
|
}
|
|
i = stack.length - 1;
|
|
expr = stack[i];
|
|
markers.pop();
|
|
while (i > 1) {
|
|
expr = new WrappingNode(markers.pop()).finishBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
|
|
i -= 2;
|
|
}
|
|
return expr;
|
|
}
|
|
function parseConditionalExpression() {
|
|
var expr,
|
|
previousAllowIn,
|
|
consequent,
|
|
alternate,
|
|
startToken;
|
|
startToken = lookahead;
|
|
expr = inheritCoverGrammar(parseBinaryExpression);
|
|
if (match('?')) {
|
|
lex();
|
|
previousAllowIn = state.allowIn;
|
|
state.allowIn = true;
|
|
consequent = isolateCoverGrammar(parseAssignmentExpression);
|
|
state.allowIn = previousAllowIn;
|
|
expect(':');
|
|
alternate = isolateCoverGrammar(parseAssignmentExpression);
|
|
expr = new WrappingNode(startToken).finishConditionalExpression(expr, consequent, alternate);
|
|
isAssignmentTarget = isBindingElement = false;
|
|
}
|
|
return expr;
|
|
}
|
|
function parseConciseBody() {
|
|
if (match('{')) {
|
|
return parseFunctionSourceElements();
|
|
}
|
|
return isolateCoverGrammar(parseAssignmentExpression);
|
|
}
|
|
function checkPatternParam(options, param) {
|
|
var i;
|
|
switch (param.type) {
|
|
case Syntax.Identifier:
|
|
validateParam(options, param, param.name);
|
|
break;
|
|
case Syntax.RestElement:
|
|
checkPatternParam(options, param.argument);
|
|
break;
|
|
case Syntax.AssignmentPattern:
|
|
checkPatternParam(options, param.left);
|
|
break;
|
|
case Syntax.ArrayPattern:
|
|
for (i = 0; i < param.elements.length; i++) {
|
|
if (param.elements[i] !== null) {
|
|
checkPatternParam(options, param.elements[i]);
|
|
}
|
|
}
|
|
break;
|
|
case Syntax.YieldExpression:
|
|
break;
|
|
default:
|
|
assert(param.type === Syntax.ObjectPattern, 'Invalid type');
|
|
for (i = 0; i < param.properties.length; i++) {
|
|
checkPatternParam(options, param.properties[i].value);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
function reinterpretAsCoverFormalsList(expr) {
|
|
var i,
|
|
len,
|
|
param,
|
|
params,
|
|
defaults,
|
|
defaultCount,
|
|
options,
|
|
token;
|
|
defaults = [];
|
|
defaultCount = 0;
|
|
params = [expr];
|
|
switch (expr.type) {
|
|
case Syntax.Identifier:
|
|
break;
|
|
case PlaceHolders.ArrowParameterPlaceHolder:
|
|
params = expr.params;
|
|
break;
|
|
default:
|
|
return null;
|
|
}
|
|
options = {paramSet: {}};
|
|
for (i = 0, len = params.length; i < len; i += 1) {
|
|
param = params[i];
|
|
switch (param.type) {
|
|
case Syntax.AssignmentPattern:
|
|
params[i] = param.left;
|
|
if (param.right.type === Syntax.YieldExpression) {
|
|
if (param.right.argument) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
param.right.type = Syntax.Identifier;
|
|
param.right.name = 'yield';
|
|
delete param.right.argument;
|
|
delete param.right.delegate;
|
|
}
|
|
defaults.push(param.right);
|
|
++defaultCount;
|
|
checkPatternParam(options, param.left);
|
|
break;
|
|
default:
|
|
checkPatternParam(options, param);
|
|
params[i] = param;
|
|
defaults.push(null);
|
|
break;
|
|
}
|
|
}
|
|
if (strict || !state.allowYield) {
|
|
for (i = 0, len = params.length; i < len; i += 1) {
|
|
param = params[i];
|
|
if (param.type === Syntax.YieldExpression) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
}
|
|
}
|
|
if (options.message === Messages.StrictParamDupe) {
|
|
token = strict ? options.stricted : options.firstRestricted;
|
|
throwUnexpectedToken(token, options.message);
|
|
}
|
|
if (defaultCount === 0) {
|
|
defaults = [];
|
|
}
|
|
return {
|
|
params: params,
|
|
defaults: defaults,
|
|
stricted: options.stricted,
|
|
firstRestricted: options.firstRestricted,
|
|
message: options.message
|
|
};
|
|
}
|
|
function parseArrowFunctionExpression(options, node) {
|
|
var previousStrict,
|
|
previousAllowYield,
|
|
body;
|
|
if (hasLineTerminator) {
|
|
tolerateUnexpectedToken(lookahead);
|
|
}
|
|
expect('=>');
|
|
previousStrict = strict;
|
|
previousAllowYield = state.allowYield;
|
|
state.allowYield = true;
|
|
body = parseConciseBody();
|
|
if (strict && options.firstRestricted) {
|
|
throwUnexpectedToken(options.firstRestricted, options.message);
|
|
}
|
|
if (strict && options.stricted) {
|
|
tolerateUnexpectedToken(options.stricted, options.message);
|
|
}
|
|
strict = previousStrict;
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishArrowFunctionExpression(options.params, options.defaults, body, body.type !== Syntax.BlockStatement);
|
|
}
|
|
function parseYieldExpression() {
|
|
var argument,
|
|
expr,
|
|
delegate,
|
|
previousAllowYield;
|
|
argument = null;
|
|
expr = new Node();
|
|
expectKeyword('yield');
|
|
if (!hasLineTerminator) {
|
|
previousAllowYield = state.allowYield;
|
|
state.allowYield = false;
|
|
delegate = match('*');
|
|
if (delegate) {
|
|
lex();
|
|
argument = parseAssignmentExpression();
|
|
} else {
|
|
if (!match(';') && !match('}') && !match(')') && lookahead.type !== Token.EOF) {
|
|
argument = parseAssignmentExpression();
|
|
}
|
|
}
|
|
state.allowYield = previousAllowYield;
|
|
}
|
|
return expr.finishYieldExpression(argument, delegate);
|
|
}
|
|
function parseAssignmentExpression() {
|
|
var token,
|
|
expr,
|
|
right,
|
|
list,
|
|
startToken;
|
|
startToken = lookahead;
|
|
token = lookahead;
|
|
if (!state.allowYield && matchKeyword('yield')) {
|
|
return parseYieldExpression();
|
|
}
|
|
expr = parseConditionalExpression();
|
|
if (expr.type === PlaceHolders.ArrowParameterPlaceHolder || match('=>')) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
list = reinterpretAsCoverFormalsList(expr);
|
|
if (list) {
|
|
firstCoverInitializedNameError = null;
|
|
return parseArrowFunctionExpression(list, new WrappingNode(startToken));
|
|
}
|
|
return expr;
|
|
}
|
|
if (matchAssign()) {
|
|
if (!isAssignmentTarget) {
|
|
tolerateError(Messages.InvalidLHSInAssignment);
|
|
}
|
|
if (strict && expr.type === Syntax.Identifier) {
|
|
if (isRestrictedWord(expr.name)) {
|
|
tolerateUnexpectedToken(token, Messages.StrictLHSAssignment);
|
|
}
|
|
if (isStrictModeReservedWord(expr.name)) {
|
|
tolerateUnexpectedToken(token, Messages.StrictReservedWord);
|
|
}
|
|
}
|
|
if (!match('=')) {
|
|
isAssignmentTarget = isBindingElement = false;
|
|
} else {
|
|
reinterpretExpressionAsPattern(expr);
|
|
}
|
|
token = lex();
|
|
right = isolateCoverGrammar(parseAssignmentExpression);
|
|
expr = new WrappingNode(startToken).finishAssignmentExpression(token.value, expr, right);
|
|
firstCoverInitializedNameError = null;
|
|
}
|
|
return expr;
|
|
}
|
|
function parseExpression() {
|
|
var expr,
|
|
startToken = lookahead,
|
|
expressions;
|
|
expr = isolateCoverGrammar(parseAssignmentExpression);
|
|
if (match(',')) {
|
|
expressions = [expr];
|
|
while (startIndex < length) {
|
|
if (!match(',')) {
|
|
break;
|
|
}
|
|
lex();
|
|
expressions.push(isolateCoverGrammar(parseAssignmentExpression));
|
|
}
|
|
expr = new WrappingNode(startToken).finishSequenceExpression(expressions);
|
|
}
|
|
return expr;
|
|
}
|
|
function parseStatementListItem() {
|
|
if (lookahead.type === Token.Keyword) {
|
|
switch (lookahead.value) {
|
|
case 'export':
|
|
if (state.sourceType !== 'module') {
|
|
tolerateUnexpectedToken(lookahead, Messages.IllegalExportDeclaration);
|
|
}
|
|
return parseExportDeclaration();
|
|
case 'import':
|
|
if (state.sourceType !== 'module') {
|
|
tolerateUnexpectedToken(lookahead, Messages.IllegalImportDeclaration);
|
|
}
|
|
return parseImportDeclaration();
|
|
case 'const':
|
|
return parseLexicalDeclaration({inFor: false});
|
|
case 'function':
|
|
return parseFunctionDeclaration(new Node());
|
|
case 'class':
|
|
return parseClassDeclaration();
|
|
}
|
|
}
|
|
if (matchKeyword('let') && isLexicalDeclaration()) {
|
|
return parseLexicalDeclaration({inFor: false});
|
|
}
|
|
return parseStatement();
|
|
}
|
|
function parseStatementList() {
|
|
var list = [];
|
|
while (startIndex < length) {
|
|
if (match('}')) {
|
|
break;
|
|
}
|
|
list.push(parseStatementListItem());
|
|
}
|
|
return list;
|
|
}
|
|
function parseBlock() {
|
|
var block,
|
|
node = new Node();
|
|
expect('{');
|
|
block = parseStatementList();
|
|
expect('}');
|
|
return node.finishBlockStatement(block);
|
|
}
|
|
function parseVariableIdentifier(kind) {
|
|
var token,
|
|
node = new Node();
|
|
token = lex();
|
|
if (token.type === Token.Keyword && token.value === 'yield') {
|
|
if (strict) {
|
|
tolerateUnexpectedToken(token, Messages.StrictReservedWord);
|
|
}
|
|
if (!state.allowYield) {
|
|
throwUnexpectedToken(token);
|
|
}
|
|
} else if (token.type !== Token.Identifier) {
|
|
if (strict && token.type === Token.Keyword && isStrictModeReservedWord(token.value)) {
|
|
tolerateUnexpectedToken(token, Messages.StrictReservedWord);
|
|
} else {
|
|
if (strict || token.value !== 'let' || kind !== 'var') {
|
|
throwUnexpectedToken(token);
|
|
}
|
|
}
|
|
} else if (state.sourceType === 'module' && token.type === Token.Identifier && token.value === 'await') {
|
|
tolerateUnexpectedToken(token);
|
|
}
|
|
return node.finishIdentifier(token.value);
|
|
}
|
|
function parseVariableDeclaration(options) {
|
|
var init = null,
|
|
id,
|
|
node = new Node(),
|
|
params = [];
|
|
id = parsePattern(params, 'var');
|
|
if (strict && isRestrictedWord(id.name)) {
|
|
tolerateError(Messages.StrictVarName);
|
|
}
|
|
if (match('=')) {
|
|
lex();
|
|
init = isolateCoverGrammar(parseAssignmentExpression);
|
|
} else if (id.type !== Syntax.Identifier && !options.inFor) {
|
|
expect('=');
|
|
}
|
|
return node.finishVariableDeclarator(id, init);
|
|
}
|
|
function parseVariableDeclarationList(options) {
|
|
var list = [];
|
|
do {
|
|
list.push(parseVariableDeclaration({inFor: options.inFor}));
|
|
if (!match(',')) {
|
|
break;
|
|
}
|
|
lex();
|
|
} while (startIndex < length);
|
|
return list;
|
|
}
|
|
function parseVariableStatement(node) {
|
|
var declarations;
|
|
expectKeyword('var');
|
|
declarations = parseVariableDeclarationList({inFor: false});
|
|
consumeSemicolon();
|
|
return node.finishVariableDeclaration(declarations);
|
|
}
|
|
function parseLexicalBinding(kind, options) {
|
|
var init = null,
|
|
id,
|
|
node = new Node(),
|
|
params = [];
|
|
id = parsePattern(params, kind);
|
|
if (strict && id.type === Syntax.Identifier && isRestrictedWord(id.name)) {
|
|
tolerateError(Messages.StrictVarName);
|
|
}
|
|
if (kind === 'const') {
|
|
if (!matchKeyword('in') && !matchContextualKeyword('of')) {
|
|
expect('=');
|
|
init = isolateCoverGrammar(parseAssignmentExpression);
|
|
}
|
|
} else if ((!options.inFor && id.type !== Syntax.Identifier) || match('=')) {
|
|
expect('=');
|
|
init = isolateCoverGrammar(parseAssignmentExpression);
|
|
}
|
|
return node.finishVariableDeclarator(id, init);
|
|
}
|
|
function parseBindingList(kind, options) {
|
|
var list = [];
|
|
do {
|
|
list.push(parseLexicalBinding(kind, options));
|
|
if (!match(',')) {
|
|
break;
|
|
}
|
|
lex();
|
|
} while (startIndex < length);
|
|
return list;
|
|
}
|
|
function tokenizerState() {
|
|
return {
|
|
index: index,
|
|
lineNumber: lineNumber,
|
|
lineStart: lineStart,
|
|
hasLineTerminator: hasLineTerminator,
|
|
lastIndex: lastIndex,
|
|
lastLineNumber: lastLineNumber,
|
|
lastLineStart: lastLineStart,
|
|
startIndex: startIndex,
|
|
startLineNumber: startLineNumber,
|
|
startLineStart: startLineStart,
|
|
lookahead: lookahead,
|
|
tokenCount: extra.tokens ? extra.tokens.length : 0
|
|
};
|
|
}
|
|
function resetTokenizerState(ts) {
|
|
index = ts.index;
|
|
lineNumber = ts.lineNumber;
|
|
lineStart = ts.lineStart;
|
|
hasLineTerminator = ts.hasLineTerminator;
|
|
lastIndex = ts.lastIndex;
|
|
lastLineNumber = ts.lastLineNumber;
|
|
lastLineStart = ts.lastLineStart;
|
|
startIndex = ts.startIndex;
|
|
startLineNumber = ts.startLineNumber;
|
|
startLineStart = ts.startLineStart;
|
|
lookahead = ts.lookahead;
|
|
if (extra.tokens) {
|
|
extra.tokens.splice(ts.tokenCount, extra.tokens.length);
|
|
}
|
|
}
|
|
function isLexicalDeclaration() {
|
|
var lexical,
|
|
ts;
|
|
ts = tokenizerState();
|
|
lex();
|
|
lexical = (lookahead.type === Token.Identifier) || match('[') || match('{') || matchKeyword('let') || matchKeyword('yield');
|
|
resetTokenizerState(ts);
|
|
return lexical;
|
|
}
|
|
function parseLexicalDeclaration(options) {
|
|
var kind,
|
|
declarations,
|
|
node = new Node();
|
|
kind = lex().value;
|
|
assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const');
|
|
declarations = parseBindingList(kind, options);
|
|
consumeSemicolon();
|
|
return node.finishLexicalDeclaration(declarations, kind);
|
|
}
|
|
function parseRestElement(params) {
|
|
var param,
|
|
node = new Node();
|
|
lex();
|
|
if (match('{')) {
|
|
throwError(Messages.ObjectPatternAsRestParameter);
|
|
}
|
|
params.push(lookahead);
|
|
param = parseVariableIdentifier();
|
|
if (match('=')) {
|
|
throwError(Messages.DefaultRestParameter);
|
|
}
|
|
if (!match(')')) {
|
|
throwError(Messages.ParameterAfterRestParameter);
|
|
}
|
|
return node.finishRestElement(param);
|
|
}
|
|
function parseEmptyStatement(node) {
|
|
expect(';');
|
|
return node.finishEmptyStatement();
|
|
}
|
|
function parseExpressionStatement(node) {
|
|
var expr = parseExpression();
|
|
consumeSemicolon();
|
|
return node.finishExpressionStatement(expr);
|
|
}
|
|
function parseIfStatement(node) {
|
|
var test,
|
|
consequent,
|
|
alternate;
|
|
expectKeyword('if');
|
|
expect('(');
|
|
test = parseExpression();
|
|
expect(')');
|
|
consequent = parseStatement();
|
|
if (matchKeyword('else')) {
|
|
lex();
|
|
alternate = parseStatement();
|
|
} else {
|
|
alternate = null;
|
|
}
|
|
return node.finishIfStatement(test, consequent, alternate);
|
|
}
|
|
function parseDoWhileStatement(node) {
|
|
var body,
|
|
test,
|
|
oldInIteration;
|
|
expectKeyword('do');
|
|
oldInIteration = state.inIteration;
|
|
state.inIteration = true;
|
|
body = parseStatement();
|
|
state.inIteration = oldInIteration;
|
|
expectKeyword('while');
|
|
expect('(');
|
|
test = parseExpression();
|
|
expect(')');
|
|
if (match(';')) {
|
|
lex();
|
|
}
|
|
return node.finishDoWhileStatement(body, test);
|
|
}
|
|
function parseWhileStatement(node) {
|
|
var test,
|
|
body,
|
|
oldInIteration;
|
|
expectKeyword('while');
|
|
expect('(');
|
|
test = parseExpression();
|
|
expect(')');
|
|
oldInIteration = state.inIteration;
|
|
state.inIteration = true;
|
|
body = parseStatement();
|
|
state.inIteration = oldInIteration;
|
|
return node.finishWhileStatement(test, body);
|
|
}
|
|
function parseForStatement(node) {
|
|
var init,
|
|
forIn,
|
|
initSeq,
|
|
initStartToken,
|
|
test,
|
|
update,
|
|
left,
|
|
right,
|
|
kind,
|
|
declarations,
|
|
body,
|
|
oldInIteration,
|
|
previousAllowIn = state.allowIn;
|
|
init = test = update = null;
|
|
forIn = true;
|
|
expectKeyword('for');
|
|
expect('(');
|
|
if (match(';')) {
|
|
lex();
|
|
} else {
|
|
if (matchKeyword('var')) {
|
|
init = new Node();
|
|
lex();
|
|
state.allowIn = false;
|
|
declarations = parseVariableDeclarationList({inFor: true});
|
|
state.allowIn = previousAllowIn;
|
|
if (declarations.length === 1 && matchKeyword('in')) {
|
|
init = init.finishVariableDeclaration(declarations);
|
|
lex();
|
|
left = init;
|
|
right = parseExpression();
|
|
init = null;
|
|
} else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) {
|
|
init = init.finishVariableDeclaration(declarations);
|
|
lex();
|
|
left = init;
|
|
right = parseAssignmentExpression();
|
|
init = null;
|
|
forIn = false;
|
|
} else {
|
|
init = init.finishVariableDeclaration(declarations);
|
|
expect(';');
|
|
}
|
|
} else if (matchKeyword('const') || matchKeyword('let')) {
|
|
init = new Node();
|
|
kind = lex().value;
|
|
if (!strict && lookahead.value === 'in') {
|
|
init = init.finishIdentifier(kind);
|
|
lex();
|
|
left = init;
|
|
right = parseExpression();
|
|
init = null;
|
|
} else {
|
|
state.allowIn = false;
|
|
declarations = parseBindingList(kind, {inFor: true});
|
|
state.allowIn = previousAllowIn;
|
|
if (declarations.length === 1 && declarations[0].init === null && matchKeyword('in')) {
|
|
init = init.finishLexicalDeclaration(declarations, kind);
|
|
lex();
|
|
left = init;
|
|
right = parseExpression();
|
|
init = null;
|
|
} else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) {
|
|
init = init.finishLexicalDeclaration(declarations, kind);
|
|
lex();
|
|
left = init;
|
|
right = parseAssignmentExpression();
|
|
init = null;
|
|
forIn = false;
|
|
} else {
|
|
consumeSemicolon();
|
|
init = init.finishLexicalDeclaration(declarations, kind);
|
|
}
|
|
}
|
|
} else {
|
|
initStartToken = lookahead;
|
|
state.allowIn = false;
|
|
init = inheritCoverGrammar(parseAssignmentExpression);
|
|
state.allowIn = previousAllowIn;
|
|
if (matchKeyword('in')) {
|
|
if (!isAssignmentTarget) {
|
|
tolerateError(Messages.InvalidLHSInForIn);
|
|
}
|
|
lex();
|
|
reinterpretExpressionAsPattern(init);
|
|
left = init;
|
|
right = parseExpression();
|
|
init = null;
|
|
} else if (matchContextualKeyword('of')) {
|
|
if (!isAssignmentTarget) {
|
|
tolerateError(Messages.InvalidLHSInForLoop);
|
|
}
|
|
lex();
|
|
reinterpretExpressionAsPattern(init);
|
|
left = init;
|
|
right = parseAssignmentExpression();
|
|
init = null;
|
|
forIn = false;
|
|
} else {
|
|
if (match(',')) {
|
|
initSeq = [init];
|
|
while (match(',')) {
|
|
lex();
|
|
initSeq.push(isolateCoverGrammar(parseAssignmentExpression));
|
|
}
|
|
init = new WrappingNode(initStartToken).finishSequenceExpression(initSeq);
|
|
}
|
|
expect(';');
|
|
}
|
|
}
|
|
}
|
|
if (typeof left === 'undefined') {
|
|
if (!match(';')) {
|
|
test = parseExpression();
|
|
}
|
|
expect(';');
|
|
if (!match(')')) {
|
|
update = parseExpression();
|
|
}
|
|
}
|
|
expect(')');
|
|
oldInIteration = state.inIteration;
|
|
state.inIteration = true;
|
|
body = isolateCoverGrammar(parseStatement);
|
|
state.inIteration = oldInIteration;
|
|
return (typeof left === 'undefined') ? node.finishForStatement(init, test, update, body) : forIn ? node.finishForInStatement(left, right, body) : node.finishForOfStatement(left, right, body);
|
|
}
|
|
function parseContinueStatement(node) {
|
|
var label = null,
|
|
key;
|
|
expectKeyword('continue');
|
|
if (source.charCodeAt(startIndex) === 0x3B) {
|
|
lex();
|
|
if (!state.inIteration) {
|
|
throwError(Messages.IllegalContinue);
|
|
}
|
|
return node.finishContinueStatement(null);
|
|
}
|
|
if (hasLineTerminator) {
|
|
if (!state.inIteration) {
|
|
throwError(Messages.IllegalContinue);
|
|
}
|
|
return node.finishContinueStatement(null);
|
|
}
|
|
if (lookahead.type === Token.Identifier) {
|
|
label = parseVariableIdentifier();
|
|
key = '$' + label.name;
|
|
if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
|
|
throwError(Messages.UnknownLabel, label.name);
|
|
}
|
|
}
|
|
consumeSemicolon();
|
|
if (label === null && !state.inIteration) {
|
|
throwError(Messages.IllegalContinue);
|
|
}
|
|
return node.finishContinueStatement(label);
|
|
}
|
|
function parseBreakStatement(node) {
|
|
var label = null,
|
|
key;
|
|
expectKeyword('break');
|
|
if (source.charCodeAt(lastIndex) === 0x3B) {
|
|
lex();
|
|
if (!(state.inIteration || state.inSwitch)) {
|
|
throwError(Messages.IllegalBreak);
|
|
}
|
|
return node.finishBreakStatement(null);
|
|
}
|
|
if (hasLineTerminator) {
|
|
if (!(state.inIteration || state.inSwitch)) {
|
|
throwError(Messages.IllegalBreak);
|
|
}
|
|
} else if (lookahead.type === Token.Identifier) {
|
|
label = parseVariableIdentifier();
|
|
key = '$' + label.name;
|
|
if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
|
|
throwError(Messages.UnknownLabel, label.name);
|
|
}
|
|
}
|
|
consumeSemicolon();
|
|
if (label === null && !(state.inIteration || state.inSwitch)) {
|
|
throwError(Messages.IllegalBreak);
|
|
}
|
|
return node.finishBreakStatement(label);
|
|
}
|
|
function parseReturnStatement(node) {
|
|
var argument = null;
|
|
expectKeyword('return');
|
|
if (!state.inFunctionBody) {
|
|
tolerateError(Messages.IllegalReturn);
|
|
}
|
|
if (source.charCodeAt(lastIndex) === 0x20) {
|
|
if (isIdentifierStart(source.charCodeAt(lastIndex + 1))) {
|
|
argument = parseExpression();
|
|
consumeSemicolon();
|
|
return node.finishReturnStatement(argument);
|
|
}
|
|
}
|
|
if (hasLineTerminator) {
|
|
return node.finishReturnStatement(null);
|
|
}
|
|
if (!match(';')) {
|
|
if (!match('}') && lookahead.type !== Token.EOF) {
|
|
argument = parseExpression();
|
|
}
|
|
}
|
|
consumeSemicolon();
|
|
return node.finishReturnStatement(argument);
|
|
}
|
|
function parseWithStatement(node) {
|
|
var object,
|
|
body;
|
|
if (strict) {
|
|
tolerateError(Messages.StrictModeWith);
|
|
}
|
|
expectKeyword('with');
|
|
expect('(');
|
|
object = parseExpression();
|
|
expect(')');
|
|
body = parseStatement();
|
|
return node.finishWithStatement(object, body);
|
|
}
|
|
function parseSwitchCase() {
|
|
var test,
|
|
consequent = [],
|
|
statement,
|
|
node = new Node();
|
|
if (matchKeyword('default')) {
|
|
lex();
|
|
test = null;
|
|
} else {
|
|
expectKeyword('case');
|
|
test = parseExpression();
|
|
}
|
|
expect(':');
|
|
while (startIndex < length) {
|
|
if (match('}') || matchKeyword('default') || matchKeyword('case')) {
|
|
break;
|
|
}
|
|
statement = parseStatementListItem();
|
|
consequent.push(statement);
|
|
}
|
|
return node.finishSwitchCase(test, consequent);
|
|
}
|
|
function parseSwitchStatement(node) {
|
|
var discriminant,
|
|
cases,
|
|
clause,
|
|
oldInSwitch,
|
|
defaultFound;
|
|
expectKeyword('switch');
|
|
expect('(');
|
|
discriminant = parseExpression();
|
|
expect(')');
|
|
expect('{');
|
|
cases = [];
|
|
if (match('}')) {
|
|
lex();
|
|
return node.finishSwitchStatement(discriminant, cases);
|
|
}
|
|
oldInSwitch = state.inSwitch;
|
|
state.inSwitch = true;
|
|
defaultFound = false;
|
|
while (startIndex < length) {
|
|
if (match('}')) {
|
|
break;
|
|
}
|
|
clause = parseSwitchCase();
|
|
if (clause.test === null) {
|
|
if (defaultFound) {
|
|
throwError(Messages.MultipleDefaultsInSwitch);
|
|
}
|
|
defaultFound = true;
|
|
}
|
|
cases.push(clause);
|
|
}
|
|
state.inSwitch = oldInSwitch;
|
|
expect('}');
|
|
return node.finishSwitchStatement(discriminant, cases);
|
|
}
|
|
function parseThrowStatement(node) {
|
|
var argument;
|
|
expectKeyword('throw');
|
|
if (hasLineTerminator) {
|
|
throwError(Messages.NewlineAfterThrow);
|
|
}
|
|
argument = parseExpression();
|
|
consumeSemicolon();
|
|
return node.finishThrowStatement(argument);
|
|
}
|
|
function parseCatchClause() {
|
|
var param,
|
|
params = [],
|
|
paramMap = {},
|
|
key,
|
|
i,
|
|
body,
|
|
node = new Node();
|
|
expectKeyword('catch');
|
|
expect('(');
|
|
if (match(')')) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
param = parsePattern(params);
|
|
for (i = 0; i < params.length; i++) {
|
|
key = '$' + params[i].value;
|
|
if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
|
|
tolerateError(Messages.DuplicateBinding, params[i].value);
|
|
}
|
|
paramMap[key] = true;
|
|
}
|
|
if (strict && isRestrictedWord(param.name)) {
|
|
tolerateError(Messages.StrictCatchVariable);
|
|
}
|
|
expect(')');
|
|
body = parseBlock();
|
|
return node.finishCatchClause(param, body);
|
|
}
|
|
function parseTryStatement(node) {
|
|
var block,
|
|
handler = null,
|
|
finalizer = null;
|
|
expectKeyword('try');
|
|
block = parseBlock();
|
|
if (matchKeyword('catch')) {
|
|
handler = parseCatchClause();
|
|
}
|
|
if (matchKeyword('finally')) {
|
|
lex();
|
|
finalizer = parseBlock();
|
|
}
|
|
if (!handler && !finalizer) {
|
|
throwError(Messages.NoCatchOrFinally);
|
|
}
|
|
return node.finishTryStatement(block, handler, finalizer);
|
|
}
|
|
function parseDebuggerStatement(node) {
|
|
expectKeyword('debugger');
|
|
consumeSemicolon();
|
|
return node.finishDebuggerStatement();
|
|
}
|
|
function parseStatement() {
|
|
var type = lookahead.type,
|
|
expr,
|
|
labeledBody,
|
|
key,
|
|
node;
|
|
if (type === Token.EOF) {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
if (type === Token.Punctuator && lookahead.value === '{') {
|
|
return parseBlock();
|
|
}
|
|
isAssignmentTarget = isBindingElement = true;
|
|
node = new Node();
|
|
if (type === Token.Punctuator) {
|
|
switch (lookahead.value) {
|
|
case ';':
|
|
return parseEmptyStatement(node);
|
|
case '(':
|
|
return parseExpressionStatement(node);
|
|
default:
|
|
break;
|
|
}
|
|
} else if (type === Token.Keyword) {
|
|
switch (lookahead.value) {
|
|
case 'break':
|
|
return parseBreakStatement(node);
|
|
case 'continue':
|
|
return parseContinueStatement(node);
|
|
case 'debugger':
|
|
return parseDebuggerStatement(node);
|
|
case 'do':
|
|
return parseDoWhileStatement(node);
|
|
case 'for':
|
|
return parseForStatement(node);
|
|
case 'function':
|
|
return parseFunctionDeclaration(node);
|
|
case 'if':
|
|
return parseIfStatement(node);
|
|
case 'return':
|
|
return parseReturnStatement(node);
|
|
case 'switch':
|
|
return parseSwitchStatement(node);
|
|
case 'throw':
|
|
return parseThrowStatement(node);
|
|
case 'try':
|
|
return parseTryStatement(node);
|
|
case 'var':
|
|
return parseVariableStatement(node);
|
|
case 'while':
|
|
return parseWhileStatement(node);
|
|
case 'with':
|
|
return parseWithStatement(node);
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
expr = parseExpression();
|
|
if ((expr.type === Syntax.Identifier) && match(':')) {
|
|
lex();
|
|
key = '$' + expr.name;
|
|
if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
|
|
throwError(Messages.Redeclaration, 'Label', expr.name);
|
|
}
|
|
state.labelSet[key] = true;
|
|
labeledBody = parseStatement();
|
|
delete state.labelSet[key];
|
|
return node.finishLabeledStatement(expr, labeledBody);
|
|
}
|
|
consumeSemicolon();
|
|
return node.finishExpressionStatement(expr);
|
|
}
|
|
function parseFunctionSourceElements() {
|
|
var statement,
|
|
body = [],
|
|
token,
|
|
directive,
|
|
firstRestricted,
|
|
oldLabelSet,
|
|
oldInIteration,
|
|
oldInSwitch,
|
|
oldInFunctionBody,
|
|
oldParenthesisCount,
|
|
node = new Node();
|
|
expect('{');
|
|
while (startIndex < length) {
|
|
if (lookahead.type !== Token.StringLiteral) {
|
|
break;
|
|
}
|
|
token = lookahead;
|
|
statement = parseStatementListItem();
|
|
body.push(statement);
|
|
if (statement.expression.type !== Syntax.Literal) {
|
|
break;
|
|
}
|
|
directive = source.slice(token.start + 1, token.end - 1);
|
|
if (directive === 'use strict') {
|
|
strict = true;
|
|
if (firstRestricted) {
|
|
tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral);
|
|
}
|
|
} else {
|
|
if (!firstRestricted && token.octal) {
|
|
firstRestricted = token;
|
|
}
|
|
}
|
|
}
|
|
oldLabelSet = state.labelSet;
|
|
oldInIteration = state.inIteration;
|
|
oldInSwitch = state.inSwitch;
|
|
oldInFunctionBody = state.inFunctionBody;
|
|
oldParenthesisCount = state.parenthesizedCount;
|
|
state.labelSet = {};
|
|
state.inIteration = false;
|
|
state.inSwitch = false;
|
|
state.inFunctionBody = true;
|
|
state.parenthesizedCount = 0;
|
|
while (startIndex < length) {
|
|
if (match('}')) {
|
|
break;
|
|
}
|
|
body.push(parseStatementListItem());
|
|
}
|
|
expect('}');
|
|
state.labelSet = oldLabelSet;
|
|
state.inIteration = oldInIteration;
|
|
state.inSwitch = oldInSwitch;
|
|
state.inFunctionBody = oldInFunctionBody;
|
|
state.parenthesizedCount = oldParenthesisCount;
|
|
return node.finishBlockStatement(body);
|
|
}
|
|
function validateParam(options, param, name) {
|
|
var key = '$' + name;
|
|
if (strict) {
|
|
if (isRestrictedWord(name)) {
|
|
options.stricted = param;
|
|
options.message = Messages.StrictParamName;
|
|
}
|
|
if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
|
|
options.stricted = param;
|
|
options.message = Messages.StrictParamDupe;
|
|
}
|
|
} else if (!options.firstRestricted) {
|
|
if (isRestrictedWord(name)) {
|
|
options.firstRestricted = param;
|
|
options.message = Messages.StrictParamName;
|
|
} else if (isStrictModeReservedWord(name)) {
|
|
options.firstRestricted = param;
|
|
options.message = Messages.StrictReservedWord;
|
|
} else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
|
|
options.stricted = param;
|
|
options.message = Messages.StrictParamDupe;
|
|
}
|
|
}
|
|
options.paramSet[key] = true;
|
|
}
|
|
function parseParam(options) {
|
|
var token,
|
|
param,
|
|
params = [],
|
|
i,
|
|
def;
|
|
token = lookahead;
|
|
if (token.value === '...') {
|
|
param = parseRestElement(params);
|
|
validateParam(options, param.argument, param.argument.name);
|
|
options.params.push(param);
|
|
options.defaults.push(null);
|
|
return false;
|
|
}
|
|
param = parsePatternWithDefault(params);
|
|
for (i = 0; i < params.length; i++) {
|
|
validateParam(options, params[i], params[i].value);
|
|
}
|
|
if (param.type === Syntax.AssignmentPattern) {
|
|
def = param.right;
|
|
param = param.left;
|
|
++options.defaultCount;
|
|
}
|
|
options.params.push(param);
|
|
options.defaults.push(def);
|
|
return !match(')');
|
|
}
|
|
function parseParams(firstRestricted) {
|
|
var options;
|
|
options = {
|
|
params: [],
|
|
defaultCount: 0,
|
|
defaults: [],
|
|
firstRestricted: firstRestricted
|
|
};
|
|
expect('(');
|
|
if (!match(')')) {
|
|
options.paramSet = {};
|
|
while (startIndex < length) {
|
|
if (!parseParam(options)) {
|
|
break;
|
|
}
|
|
expect(',');
|
|
}
|
|
}
|
|
expect(')');
|
|
if (options.defaultCount === 0) {
|
|
options.defaults = [];
|
|
}
|
|
return {
|
|
params: options.params,
|
|
defaults: options.defaults,
|
|
stricted: options.stricted,
|
|
firstRestricted: options.firstRestricted,
|
|
message: options.message
|
|
};
|
|
}
|
|
function parseFunctionDeclaration(node, identifierIsOptional) {
|
|
var id = null,
|
|
params = [],
|
|
defaults = [],
|
|
body,
|
|
token,
|
|
stricted,
|
|
tmp,
|
|
firstRestricted,
|
|
message,
|
|
previousStrict,
|
|
isGenerator,
|
|
previousAllowYield;
|
|
previousAllowYield = state.allowYield;
|
|
expectKeyword('function');
|
|
isGenerator = match('*');
|
|
if (isGenerator) {
|
|
lex();
|
|
}
|
|
if (!identifierIsOptional || !match('(')) {
|
|
token = lookahead;
|
|
id = parseVariableIdentifier();
|
|
if (strict) {
|
|
if (isRestrictedWord(token.value)) {
|
|
tolerateUnexpectedToken(token, Messages.StrictFunctionName);
|
|
}
|
|
} else {
|
|
if (isRestrictedWord(token.value)) {
|
|
firstRestricted = token;
|
|
message = Messages.StrictFunctionName;
|
|
} else if (isStrictModeReservedWord(token.value)) {
|
|
firstRestricted = token;
|
|
message = Messages.StrictReservedWord;
|
|
}
|
|
}
|
|
}
|
|
state.allowYield = !isGenerator;
|
|
tmp = parseParams(firstRestricted);
|
|
params = tmp.params;
|
|
defaults = tmp.defaults;
|
|
stricted = tmp.stricted;
|
|
firstRestricted = tmp.firstRestricted;
|
|
if (tmp.message) {
|
|
message = tmp.message;
|
|
}
|
|
previousStrict = strict;
|
|
body = parseFunctionSourceElements();
|
|
if (strict && firstRestricted) {
|
|
throwUnexpectedToken(firstRestricted, message);
|
|
}
|
|
if (strict && stricted) {
|
|
tolerateUnexpectedToken(stricted, message);
|
|
}
|
|
strict = previousStrict;
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishFunctionDeclaration(id, params, defaults, body, isGenerator);
|
|
}
|
|
function parseFunctionExpression() {
|
|
var token,
|
|
id = null,
|
|
stricted,
|
|
firstRestricted,
|
|
message,
|
|
tmp,
|
|
params = [],
|
|
defaults = [],
|
|
body,
|
|
previousStrict,
|
|
node = new Node(),
|
|
isGenerator,
|
|
previousAllowYield;
|
|
previousAllowYield = state.allowYield;
|
|
expectKeyword('function');
|
|
isGenerator = match('*');
|
|
if (isGenerator) {
|
|
lex();
|
|
}
|
|
state.allowYield = !isGenerator;
|
|
if (!match('(')) {
|
|
token = lookahead;
|
|
id = (!strict && !isGenerator && matchKeyword('yield')) ? parseNonComputedProperty() : parseVariableIdentifier();
|
|
if (strict) {
|
|
if (isRestrictedWord(token.value)) {
|
|
tolerateUnexpectedToken(token, Messages.StrictFunctionName);
|
|
}
|
|
} else {
|
|
if (isRestrictedWord(token.value)) {
|
|
firstRestricted = token;
|
|
message = Messages.StrictFunctionName;
|
|
} else if (isStrictModeReservedWord(token.value)) {
|
|
firstRestricted = token;
|
|
message = Messages.StrictReservedWord;
|
|
}
|
|
}
|
|
}
|
|
tmp = parseParams(firstRestricted);
|
|
params = tmp.params;
|
|
defaults = tmp.defaults;
|
|
stricted = tmp.stricted;
|
|
firstRestricted = tmp.firstRestricted;
|
|
if (tmp.message) {
|
|
message = tmp.message;
|
|
}
|
|
previousStrict = strict;
|
|
body = parseFunctionSourceElements();
|
|
if (strict && firstRestricted) {
|
|
throwUnexpectedToken(firstRestricted, message);
|
|
}
|
|
if (strict && stricted) {
|
|
tolerateUnexpectedToken(stricted, message);
|
|
}
|
|
strict = previousStrict;
|
|
state.allowYield = previousAllowYield;
|
|
return node.finishFunctionExpression(id, params, defaults, body, isGenerator);
|
|
}
|
|
function parseClassBody() {
|
|
var classBody,
|
|
token,
|
|
isStatic,
|
|
hasConstructor = false,
|
|
body,
|
|
method,
|
|
computed,
|
|
key;
|
|
classBody = new Node();
|
|
expect('{');
|
|
body = [];
|
|
while (!match('}')) {
|
|
if (match(';')) {
|
|
lex();
|
|
} else {
|
|
method = new Node();
|
|
token = lookahead;
|
|
isStatic = false;
|
|
computed = match('[');
|
|
if (match('*')) {
|
|
lex();
|
|
} else {
|
|
key = parseObjectPropertyKey();
|
|
if (key.name === 'static' && (lookaheadPropertyName() || match('*'))) {
|
|
token = lookahead;
|
|
isStatic = true;
|
|
computed = match('[');
|
|
if (match('*')) {
|
|
lex();
|
|
} else {
|
|
key = parseObjectPropertyKey();
|
|
}
|
|
}
|
|
}
|
|
method = tryParseMethodDefinition(token, key, computed, method);
|
|
if (method) {
|
|
method['static'] = isStatic;
|
|
if (method.kind === 'init') {
|
|
method.kind = 'method';
|
|
}
|
|
if (!isStatic) {
|
|
if (!method.computed && (method.key.name || method.key.value.toString()) === 'constructor') {
|
|
if (method.kind !== 'method' || !method.method || method.value.generator) {
|
|
throwUnexpectedToken(token, Messages.ConstructorSpecialMethod);
|
|
}
|
|
if (hasConstructor) {
|
|
throwUnexpectedToken(token, Messages.DuplicateConstructor);
|
|
} else {
|
|
hasConstructor = true;
|
|
}
|
|
method.kind = 'constructor';
|
|
}
|
|
} else {
|
|
if (!method.computed && (method.key.name || method.key.value.toString()) === 'prototype') {
|
|
throwUnexpectedToken(token, Messages.StaticPrototype);
|
|
}
|
|
}
|
|
method.type = Syntax.MethodDefinition;
|
|
delete method.method;
|
|
delete method.shorthand;
|
|
body.push(method);
|
|
} else {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
}
|
|
}
|
|
lex();
|
|
return classBody.finishClassBody(body);
|
|
}
|
|
function parseClassDeclaration(identifierIsOptional) {
|
|
var id = null,
|
|
superClass = null,
|
|
classNode = new Node(),
|
|
classBody,
|
|
previousStrict = strict;
|
|
strict = true;
|
|
expectKeyword('class');
|
|
if (!identifierIsOptional || lookahead.type === Token.Identifier) {
|
|
id = parseVariableIdentifier();
|
|
}
|
|
if (matchKeyword('extends')) {
|
|
lex();
|
|
superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall);
|
|
}
|
|
classBody = parseClassBody();
|
|
strict = previousStrict;
|
|
return classNode.finishClassDeclaration(id, superClass, classBody);
|
|
}
|
|
function parseClassExpression() {
|
|
var id = null,
|
|
superClass = null,
|
|
classNode = new Node(),
|
|
classBody,
|
|
previousStrict = strict;
|
|
strict = true;
|
|
expectKeyword('class');
|
|
if (lookahead.type === Token.Identifier) {
|
|
id = parseVariableIdentifier();
|
|
}
|
|
if (matchKeyword('extends')) {
|
|
lex();
|
|
superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall);
|
|
}
|
|
classBody = parseClassBody();
|
|
strict = previousStrict;
|
|
return classNode.finishClassExpression(id, superClass, classBody);
|
|
}
|
|
function parseModuleSpecifier() {
|
|
var node = new Node();
|
|
if (lookahead.type !== Token.StringLiteral) {
|
|
throwError(Messages.InvalidModuleSpecifier);
|
|
}
|
|
return node.finishLiteral(lex());
|
|
}
|
|
function parseExportSpecifier() {
|
|
var exported,
|
|
local,
|
|
node = new Node(),
|
|
def;
|
|
if (matchKeyword('default')) {
|
|
def = new Node();
|
|
lex();
|
|
local = def.finishIdentifier('default');
|
|
} else {
|
|
local = parseVariableIdentifier();
|
|
}
|
|
if (matchContextualKeyword('as')) {
|
|
lex();
|
|
exported = parseNonComputedProperty();
|
|
}
|
|
return node.finishExportSpecifier(local, exported);
|
|
}
|
|
function parseExportNamedDeclaration(node) {
|
|
var declaration = null,
|
|
isExportFromIdentifier,
|
|
src = null,
|
|
specifiers = [];
|
|
if (lookahead.type === Token.Keyword) {
|
|
switch (lookahead.value) {
|
|
case 'let':
|
|
case 'const':
|
|
declaration = parseLexicalDeclaration({inFor: false});
|
|
return node.finishExportNamedDeclaration(declaration, specifiers, null);
|
|
case 'var':
|
|
case 'class':
|
|
case 'function':
|
|
declaration = parseStatementListItem();
|
|
return node.finishExportNamedDeclaration(declaration, specifiers, null);
|
|
}
|
|
}
|
|
expect('{');
|
|
while (!match('}')) {
|
|
isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
|
|
specifiers.push(parseExportSpecifier());
|
|
if (!match('}')) {
|
|
expect(',');
|
|
if (match('}')) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
expect('}');
|
|
if (matchContextualKeyword('from')) {
|
|
lex();
|
|
src = parseModuleSpecifier();
|
|
consumeSemicolon();
|
|
} else if (isExportFromIdentifier) {
|
|
throwError(lookahead.value ? Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
} else {
|
|
consumeSemicolon();
|
|
}
|
|
return node.finishExportNamedDeclaration(declaration, specifiers, src);
|
|
}
|
|
function parseExportDefaultDeclaration(node) {
|
|
var declaration = null,
|
|
expression = null;
|
|
expectKeyword('default');
|
|
if (matchKeyword('function')) {
|
|
declaration = parseFunctionDeclaration(new Node(), true);
|
|
return node.finishExportDefaultDeclaration(declaration);
|
|
}
|
|
if (matchKeyword('class')) {
|
|
declaration = parseClassDeclaration(true);
|
|
return node.finishExportDefaultDeclaration(declaration);
|
|
}
|
|
if (matchContextualKeyword('from')) {
|
|
throwError(Messages.UnexpectedToken, lookahead.value);
|
|
}
|
|
if (match('{')) {
|
|
expression = parseObjectInitializer();
|
|
} else if (match('[')) {
|
|
expression = parseArrayInitializer();
|
|
} else {
|
|
expression = parseAssignmentExpression();
|
|
}
|
|
consumeSemicolon();
|
|
return node.finishExportDefaultDeclaration(expression);
|
|
}
|
|
function parseExportAllDeclaration(node) {
|
|
var src;
|
|
expect('*');
|
|
if (!matchContextualKeyword('from')) {
|
|
throwError(lookahead.value ? Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
}
|
|
lex();
|
|
src = parseModuleSpecifier();
|
|
consumeSemicolon();
|
|
return node.finishExportAllDeclaration(src);
|
|
}
|
|
function parseExportDeclaration() {
|
|
var node = new Node();
|
|
if (state.inFunctionBody) {
|
|
throwError(Messages.IllegalExportDeclaration);
|
|
}
|
|
expectKeyword('export');
|
|
if (matchKeyword('default')) {
|
|
return parseExportDefaultDeclaration(node);
|
|
}
|
|
if (match('*')) {
|
|
return parseExportAllDeclaration(node);
|
|
}
|
|
return parseExportNamedDeclaration(node);
|
|
}
|
|
function parseImportSpecifier() {
|
|
var local,
|
|
imported,
|
|
node = new Node();
|
|
imported = parseNonComputedProperty();
|
|
if (matchContextualKeyword('as')) {
|
|
lex();
|
|
local = parseVariableIdentifier();
|
|
}
|
|
return node.finishImportSpecifier(local, imported);
|
|
}
|
|
function parseNamedImports() {
|
|
var specifiers = [];
|
|
expect('{');
|
|
while (!match('}')) {
|
|
specifiers.push(parseImportSpecifier());
|
|
if (!match('}')) {
|
|
expect(',');
|
|
if (match('}')) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
expect('}');
|
|
return specifiers;
|
|
}
|
|
function parseImportDefaultSpecifier() {
|
|
var local,
|
|
node = new Node();
|
|
local = parseNonComputedProperty();
|
|
return node.finishImportDefaultSpecifier(local);
|
|
}
|
|
function parseImportNamespaceSpecifier() {
|
|
var local,
|
|
node = new Node();
|
|
expect('*');
|
|
if (!matchContextualKeyword('as')) {
|
|
throwError(Messages.NoAsAfterImportNamespace);
|
|
}
|
|
lex();
|
|
local = parseNonComputedProperty();
|
|
return node.finishImportNamespaceSpecifier(local);
|
|
}
|
|
function parseImportDeclaration() {
|
|
var specifiers = [],
|
|
src,
|
|
node = new Node();
|
|
if (state.inFunctionBody) {
|
|
throwError(Messages.IllegalImportDeclaration);
|
|
}
|
|
expectKeyword('import');
|
|
if (lookahead.type === Token.StringLiteral) {
|
|
src = parseModuleSpecifier();
|
|
} else {
|
|
if (match('{')) {
|
|
specifiers = specifiers.concat(parseNamedImports());
|
|
} else if (match('*')) {
|
|
specifiers.push(parseImportNamespaceSpecifier());
|
|
} else if (isIdentifierName(lookahead) && !matchKeyword('default')) {
|
|
specifiers.push(parseImportDefaultSpecifier());
|
|
if (match(',')) {
|
|
lex();
|
|
if (match('*')) {
|
|
specifiers.push(parseImportNamespaceSpecifier());
|
|
} else if (match('{')) {
|
|
specifiers = specifiers.concat(parseNamedImports());
|
|
} else {
|
|
throwUnexpectedToken(lookahead);
|
|
}
|
|
}
|
|
} else {
|
|
throwUnexpectedToken(lex());
|
|
}
|
|
if (!matchContextualKeyword('from')) {
|
|
throwError(lookahead.value ? Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
|
|
}
|
|
lex();
|
|
src = parseModuleSpecifier();
|
|
}
|
|
consumeSemicolon();
|
|
return node.finishImportDeclaration(specifiers, src);
|
|
}
|
|
function parseScriptBody() {
|
|
var statement,
|
|
body = [],
|
|
token,
|
|
directive,
|
|
firstRestricted;
|
|
while (startIndex < length) {
|
|
token = lookahead;
|
|
if (token.type !== Token.StringLiteral) {
|
|
break;
|
|
}
|
|
statement = parseStatementListItem();
|
|
body.push(statement);
|
|
if (statement.expression.type !== Syntax.Literal) {
|
|
break;
|
|
}
|
|
directive = source.slice(token.start + 1, token.end - 1);
|
|
if (directive === 'use strict') {
|
|
strict = true;
|
|
if (firstRestricted) {
|
|
tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral);
|
|
}
|
|
} else {
|
|
if (!firstRestricted && token.octal) {
|
|
firstRestricted = token;
|
|
}
|
|
}
|
|
}
|
|
while (startIndex < length) {
|
|
statement = parseStatementListItem();
|
|
if (typeof statement === 'undefined') {
|
|
break;
|
|
}
|
|
body.push(statement);
|
|
}
|
|
return body;
|
|
}
|
|
function parseProgram() {
|
|
var body,
|
|
node;
|
|
peek();
|
|
node = new Node();
|
|
body = parseScriptBody();
|
|
return node.finishProgram(body, state.sourceType);
|
|
}
|
|
function filterTokenLocation() {
|
|
var i,
|
|
entry,
|
|
token,
|
|
tokens = [];
|
|
for (i = 0; i < extra.tokens.length; ++i) {
|
|
entry = extra.tokens[i];
|
|
token = {
|
|
type: entry.type,
|
|
value: entry.value
|
|
};
|
|
if (entry.regex) {
|
|
token.regex = {
|
|
pattern: entry.regex.pattern,
|
|
flags: entry.regex.flags
|
|
};
|
|
}
|
|
if (extra.range) {
|
|
token.range = entry.range;
|
|
}
|
|
if (extra.loc) {
|
|
token.loc = entry.loc;
|
|
}
|
|
tokens.push(token);
|
|
}
|
|
extra.tokens = tokens;
|
|
}
|
|
function tokenize(code, options, delegate) {
|
|
var toString,
|
|
tokens;
|
|
toString = String;
|
|
if (typeof code !== 'string' && !(code instanceof String)) {
|
|
code = toString(code);
|
|
}
|
|
source = code;
|
|
index = 0;
|
|
lineNumber = (source.length > 0) ? 1 : 0;
|
|
lineStart = 0;
|
|
startIndex = index;
|
|
startLineNumber = lineNumber;
|
|
startLineStart = lineStart;
|
|
length = source.length;
|
|
lookahead = null;
|
|
state = {
|
|
allowIn: true,
|
|
allowYield: true,
|
|
labelSet: {},
|
|
inFunctionBody: false,
|
|
inIteration: false,
|
|
inSwitch: false,
|
|
lastCommentStart: -1,
|
|
curlyStack: []
|
|
};
|
|
extra = {};
|
|
options = options || {};
|
|
options.tokens = true;
|
|
extra.tokens = [];
|
|
extra.tokenValues = [];
|
|
extra.tokenize = true;
|
|
extra.delegate = delegate;
|
|
extra.openParenToken = -1;
|
|
extra.openCurlyToken = -1;
|
|
extra.range = (typeof options.range === 'boolean') && options.range;
|
|
extra.loc = (typeof options.loc === 'boolean') && options.loc;
|
|
if (typeof options.comment === 'boolean' && options.comment) {
|
|
extra.comments = [];
|
|
}
|
|
if (typeof options.tolerant === 'boolean' && options.tolerant) {
|
|
extra.errors = [];
|
|
}
|
|
try {
|
|
peek();
|
|
if (lookahead.type === Token.EOF) {
|
|
return extra.tokens;
|
|
}
|
|
lex();
|
|
while (lookahead.type !== Token.EOF) {
|
|
try {
|
|
lex();
|
|
} catch (lexError) {
|
|
if (extra.errors) {
|
|
recordError(lexError);
|
|
break;
|
|
} else {
|
|
throw lexError;
|
|
}
|
|
}
|
|
}
|
|
tokens = extra.tokens;
|
|
if (typeof extra.errors !== 'undefined') {
|
|
tokens.errors = extra.errors;
|
|
}
|
|
} catch (e) {
|
|
throw e;
|
|
} finally {
|
|
extra = {};
|
|
}
|
|
return tokens;
|
|
}
|
|
function parse(code, options) {
|
|
var program,
|
|
toString;
|
|
toString = String;
|
|
if (typeof code !== 'string' && !(code instanceof String)) {
|
|
code = toString(code);
|
|
}
|
|
source = code;
|
|
index = 0;
|
|
lineNumber = (source.length > 0) ? 1 : 0;
|
|
lineStart = 0;
|
|
startIndex = index;
|
|
startLineNumber = lineNumber;
|
|
startLineStart = lineStart;
|
|
length = source.length;
|
|
lookahead = null;
|
|
state = {
|
|
allowIn: true,
|
|
allowYield: true,
|
|
labelSet: {},
|
|
inFunctionBody: false,
|
|
inIteration: false,
|
|
inSwitch: false,
|
|
lastCommentStart: -1,
|
|
curlyStack: [],
|
|
sourceType: 'script'
|
|
};
|
|
strict = false;
|
|
extra = {};
|
|
if (typeof options !== 'undefined') {
|
|
extra.range = (typeof options.range === 'boolean') && options.range;
|
|
extra.loc = (typeof options.loc === 'boolean') && options.loc;
|
|
extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
|
|
if (extra.loc && options.source !== null && options.source !== undefined) {
|
|
extra.source = toString(options.source);
|
|
}
|
|
if (typeof options.tokens === 'boolean' && options.tokens) {
|
|
extra.tokens = [];
|
|
}
|
|
if (typeof options.comment === 'boolean' && options.comment) {
|
|
extra.comments = [];
|
|
}
|
|
if (typeof options.tolerant === 'boolean' && options.tolerant) {
|
|
extra.errors = [];
|
|
}
|
|
if (extra.attachComment) {
|
|
extra.range = true;
|
|
extra.comments = [];
|
|
extra.bottomRightStack = [];
|
|
extra.trailingComments = [];
|
|
extra.leadingComments = [];
|
|
}
|
|
if (options.sourceType === 'module') {
|
|
state.sourceType = options.sourceType;
|
|
strict = true;
|
|
}
|
|
}
|
|
try {
|
|
program = parseProgram();
|
|
if (typeof extra.comments !== 'undefined') {
|
|
program.comments = extra.comments;
|
|
}
|
|
if (typeof extra.tokens !== 'undefined') {
|
|
filterTokenLocation();
|
|
program.tokens = extra.tokens;
|
|
}
|
|
if (typeof extra.errors !== 'undefined') {
|
|
program.errors = extra.errors;
|
|
}
|
|
} catch (e) {
|
|
throw e;
|
|
} finally {
|
|
extra = {};
|
|
}
|
|
return program;
|
|
}
|
|
exports.version = '2.7.0';
|
|
exports.tokenize = tokenize;
|
|
exports.parse = parse;
|
|
exports.Syntax = (function() {
|
|
var name,
|
|
types = {};
|
|
if (typeof Object.create === 'function') {
|
|
types = Object.create(null);
|
|
}
|
|
for (name in Syntax) {
|
|
if (Syntax.hasOwnProperty(name)) {
|
|
types[name] = Syntax[name];
|
|
}
|
|
}
|
|
if (typeof Object.freeze === 'function') {
|
|
Object.freeze(types);
|
|
}
|
|
return types;
|
|
}());
|
|
}));
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15c", ["15b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('15b');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("148", ["143"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var YAMLException = $__require('143');
|
|
var TYPE_CONSTRUCTOR_OPTIONS = ['kind', 'resolve', 'construct', 'instanceOf', 'predicate', 'represent', 'defaultStyle', 'styleAliases'];
|
|
var YAML_NODE_KINDS = ['scalar', 'sequence', 'mapping'];
|
|
function compileStyleAliases(map) {
|
|
var result = {};
|
|
if (null !== map) {
|
|
Object.keys(map).forEach(function(style) {
|
|
map[style].forEach(function(alias) {
|
|
result[String(alias)] = style;
|
|
});
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
function Type(tag, options) {
|
|
options = options || {};
|
|
Object.keys(options).forEach(function(name) {
|
|
if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
|
|
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
}
|
|
});
|
|
this.tag = tag;
|
|
this.kind = options['kind'] || null;
|
|
this.resolve = options['resolve'] || function() {
|
|
return true;
|
|
};
|
|
this.construct = options['construct'] || function(data) {
|
|
return data;
|
|
};
|
|
this.instanceOf = options['instanceOf'] || null;
|
|
this.predicate = options['predicate'] || null;
|
|
this.represent = options['represent'] || null;
|
|
this.defaultStyle = options['defaultStyle'] || null;
|
|
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
|
if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
|
|
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
}
|
|
}
|
|
module.exports = Type;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15d", ["15c", "148"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var esprima;
|
|
try {
|
|
esprima = $__require('15c');
|
|
} catch (_) {
|
|
if (typeof window !== 'undefined') {
|
|
esprima = window.esprima;
|
|
}
|
|
}
|
|
var Type = $__require('148');
|
|
function resolveJavascriptFunction(data) {
|
|
if (null === data) {
|
|
return false;
|
|
}
|
|
try {
|
|
var source = '(' + data + ')',
|
|
ast = esprima.parse(source, {range: true});
|
|
if ('Program' !== ast.type || 1 !== ast.body.length || 'ExpressionStatement' !== ast.body[0].type || 'FunctionExpression' !== ast.body[0].expression.type) {
|
|
return false;
|
|
}
|
|
return true;
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
}
|
|
function constructJavascriptFunction(data) {
|
|
var source = '(' + data + ')',
|
|
ast = esprima.parse(source, {range: true}),
|
|
params = [],
|
|
body;
|
|
if ('Program' !== ast.type || 1 !== ast.body.length || 'ExpressionStatement' !== ast.body[0].type || 'FunctionExpression' !== ast.body[0].expression.type) {
|
|
throw new Error('Failed to resolve function');
|
|
}
|
|
ast.body[0].expression.params.forEach(function(param) {
|
|
params.push(param.name);
|
|
});
|
|
body = ast.body[0].expression.body.range;
|
|
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
|
}
|
|
function representJavascriptFunction(object) {
|
|
return object.toString();
|
|
}
|
|
function isFunction(object) {
|
|
return '[object Function]' === Object.prototype.toString.call(object);
|
|
}
|
|
module.exports = new Type('tag:yaml.org,2002:js/function', {
|
|
kind: 'scalar',
|
|
resolve: resolveJavascriptFunction,
|
|
construct: constructJavascriptFunction,
|
|
predicate: isFunction,
|
|
represent: representJavascriptFunction
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("145", ["147", "144", "159", "15a", "15d"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Schema = $__require('147');
|
|
module.exports = Schema.DEFAULT = new Schema({
|
|
include: [$__require('144')],
|
|
explicit: [$__require('159'), $__require('15a'), $__require('15d')]
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("143", ["107"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var inherits = $__require('107').inherits;
|
|
function YAMLException(reason, mark) {
|
|
Error.call(this);
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, this.constructor);
|
|
} else {
|
|
this.stack = (new Error()).stack || '';
|
|
}
|
|
this.name = 'YAMLException';
|
|
this.reason = reason;
|
|
this.mark = mark;
|
|
this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
|
|
}
|
|
inherits(YAMLException, Error);
|
|
YAMLException.prototype.toString = function toString(compact) {
|
|
var result = this.name + ': ';
|
|
result += this.reason || '(unknown reason)';
|
|
if (!compact && this.mark) {
|
|
result += ' ' + this.mark.toString();
|
|
}
|
|
return result;
|
|
};
|
|
module.exports = YAMLException;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15e", ["142", "146", "148", "147", "14c", "151", "152", "144", "145", "143"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var loader = $__require('142');
|
|
var dumper = $__require('146');
|
|
function deprecated(name) {
|
|
return function() {
|
|
throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
|
};
|
|
}
|
|
module.exports.Type = $__require('148');
|
|
module.exports.Schema = $__require('147');
|
|
module.exports.FAILSAFE_SCHEMA = $__require('14c');
|
|
module.exports.JSON_SCHEMA = $__require('151');
|
|
module.exports.CORE_SCHEMA = $__require('152');
|
|
module.exports.DEFAULT_SAFE_SCHEMA = $__require('144');
|
|
module.exports.DEFAULT_FULL_SCHEMA = $__require('145');
|
|
module.exports.load = loader.load;
|
|
module.exports.loadAll = loader.loadAll;
|
|
module.exports.safeLoad = loader.safeLoad;
|
|
module.exports.safeLoadAll = loader.safeLoadAll;
|
|
module.exports.dump = dumper.dump;
|
|
module.exports.safeDump = dumper.safeDump;
|
|
module.exports.YAMLException = $__require('143');
|
|
module.exports.MINIMAL_SCHEMA = $__require('14c');
|
|
module.exports.SAFE_SCHEMA = $__require('144');
|
|
module.exports.DEFAULT_SCHEMA = $__require('145');
|
|
module.exports.scan = deprecated('scan');
|
|
module.exports.parse = deprecated('parse');
|
|
module.exports.compose = deprecated('compose');
|
|
module.exports.addConstructor = deprecated('addConstructor');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("15f", ["15e"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var yaml = $__require('15e');
|
|
module.exports = yaml;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("160", ["15f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('15f');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("136", ["160"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var yaml = $__require('160');
|
|
module.exports = {
|
|
parse: function yamlParse(text, reviver) {
|
|
return yaml.safeLoad(text);
|
|
},
|
|
stringify: function yamlStringify(value, replacer, space) {
|
|
var indent = (typeof space === 'string' ? space.length : space) || 2;
|
|
return yaml.safeDump(value, {indent: indent});
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("161", ["138", "109", "10d", "13a", "139", "13b", "13d", "162", "10e", "12f", "13f", "101", "136", "10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
var Promise = $__require('138'),
|
|
Options = $__require('109'),
|
|
$Refs = $__require('10d'),
|
|
$Ref = $__require('13a'),
|
|
read = $__require('139'),
|
|
resolve = $__require('13b'),
|
|
bundle = $__require('13d'),
|
|
dereference = $__require('162'),
|
|
util = $__require('10e'),
|
|
url = $__require('12f'),
|
|
maybe = $__require('13f'),
|
|
ono = $__require('101');
|
|
module.exports = $RefParser;
|
|
module.exports.YAML = $__require('136');
|
|
function $RefParser() {
|
|
this.schema = null;
|
|
this.$refs = new $Refs();
|
|
this._basePath = '';
|
|
}
|
|
$RefParser.parse = function(schema, options, callback) {
|
|
var Class = this;
|
|
return new Class().parse(schema, options, callback);
|
|
};
|
|
$RefParser.prototype.parse = function(schema, options, callback) {
|
|
var args = normalizeArgs(arguments);
|
|
if (args.schema && typeof args.schema === 'object') {
|
|
this.schema = args.schema;
|
|
this._basePath = '';
|
|
var $ref = new $Ref(this.$refs, this._basePath);
|
|
$ref.setValue(this.schema, args.options);
|
|
return maybe(args.callback, Promise.resolve(this.schema));
|
|
}
|
|
if (!args.schema || typeof args.schema !== 'string') {
|
|
var err = ono('Expected a file path, URL, or object. Got %s', args.schema);
|
|
return maybe(args.callback, Promise.reject(err));
|
|
}
|
|
var me = this;
|
|
args.schema = util.path.localPathToUrl(args.schema);
|
|
args.schema = url.resolve(util.path.cwd(), args.schema);
|
|
this._basePath = util.path.stripHash(args.schema);
|
|
return read(args.schema, this.$refs, args.options).then(function(cached$Ref) {
|
|
var value = cached$Ref.$ref.value;
|
|
if (!value || typeof value !== 'object' || value instanceof Buffer) {
|
|
throw ono.syntax('"%s" is not a valid JSON Schema', me._basePath);
|
|
} else {
|
|
me.schema = value;
|
|
return maybe(args.callback, Promise.resolve(me.schema));
|
|
}
|
|
}).catch(function(e) {
|
|
return maybe(args.callback, Promise.reject(e));
|
|
});
|
|
};
|
|
$RefParser.resolve = function(schema, options, callback) {
|
|
var Class = this;
|
|
return new Class().resolve(schema, options, callback);
|
|
};
|
|
$RefParser.prototype.resolve = function(schema, options, callback) {
|
|
var me = this;
|
|
var args = normalizeArgs(arguments);
|
|
return this.parse(args.schema, args.options).then(function() {
|
|
return resolve(me, args.options);
|
|
}).then(function() {
|
|
return maybe(args.callback, Promise.resolve(me.$refs));
|
|
}).catch(function(err) {
|
|
return maybe(args.callback, Promise.reject(err));
|
|
});
|
|
};
|
|
$RefParser.bundle = function(schema, options, callback) {
|
|
var Class = this;
|
|
return new Class().bundle(schema, options, callback);
|
|
};
|
|
$RefParser.prototype.bundle = function(schema, options, callback) {
|
|
var me = this;
|
|
var args = normalizeArgs(arguments);
|
|
return this.resolve(args.schema, args.options).then(function() {
|
|
bundle(me, args.options);
|
|
return maybe(args.callback, Promise.resolve(me.schema));
|
|
}).catch(function(err) {
|
|
return maybe(args.callback, Promise.reject(err));
|
|
});
|
|
};
|
|
$RefParser.dereference = function(schema, options, callback) {
|
|
var Class = this;
|
|
return new Class().dereference(schema, options, callback);
|
|
};
|
|
$RefParser.prototype.dereference = function(schema, options, callback) {
|
|
var me = this;
|
|
var args = normalizeArgs(arguments);
|
|
return this.resolve(args.schema, args.options).then(function() {
|
|
dereference(me, args.options);
|
|
return maybe(args.callback, Promise.resolve(me.schema));
|
|
}).catch(function(err) {
|
|
return maybe(args.callback, Promise.reject(err));
|
|
});
|
|
};
|
|
function normalizeArgs(args) {
|
|
var options = args[1],
|
|
callback = args[2];
|
|
if (typeof options === 'function') {
|
|
callback = options;
|
|
options = undefined;
|
|
}
|
|
if (!(options instanceof Options)) {
|
|
options = new Options(options);
|
|
}
|
|
return {
|
|
schema: args[0],
|
|
options: options,
|
|
callback: callback
|
|
};
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("163", ["161"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('161');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13a", ["13c", "10e", "10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
module.exports = $Ref;
|
|
var Pointer = $__require('13c'),
|
|
util = $__require('10e');
|
|
function $Ref($refs, path) {
|
|
path = util.path.stripHash(path);
|
|
$refs._$refs[path] = this;
|
|
this.$refs = $refs;
|
|
this.path = path;
|
|
this.pathType = undefined;
|
|
this.pathFromRoot = '#';
|
|
this.value = undefined;
|
|
this.expires = undefined;
|
|
}
|
|
$Ref.prototype.isExpired = function() {
|
|
return !!(this.expires && this.expires <= new Date());
|
|
};
|
|
$Ref.prototype.expire = function() {
|
|
this.expires = new Date();
|
|
};
|
|
$Ref.prototype.setValue = function(value, options) {
|
|
this.value = value;
|
|
var cacheDuration = options.cache[this.pathType];
|
|
if (cacheDuration > 0) {
|
|
var expires = Date.now() + (cacheDuration * 1000);
|
|
this.expires = new Date(expires);
|
|
}
|
|
};
|
|
$Ref.prototype.exists = function(path) {
|
|
try {
|
|
this.resolve(path);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
$Ref.prototype.get = function(path, options) {
|
|
return this.resolve(path, options).value;
|
|
};
|
|
$Ref.prototype.resolve = function(path, options) {
|
|
var pointer = new Pointer(this, path);
|
|
return pointer.resolve(this.value, options);
|
|
};
|
|
$Ref.prototype.set = function(path, value, options) {
|
|
var pointer = new Pointer(this, path);
|
|
this.value = pointer.set(this.value, value, options);
|
|
};
|
|
$Ref.is$Ref = function(value) {
|
|
return value && typeof value === 'object' && typeof value.$ref === 'string' && value.$ref.length > 0;
|
|
};
|
|
$Ref.isExternal$Ref = function(value) {
|
|
return $Ref.is$Ref(value) && value.$ref[0] !== '#';
|
|
};
|
|
$Ref.isAllowed$Ref = function(value, options) {
|
|
if ($Ref.is$Ref(value)) {
|
|
if (value.$ref[0] === '#') {
|
|
if (options.$refs.internal) {
|
|
return true;
|
|
}
|
|
} else if (options.$refs.external) {
|
|
return true;
|
|
}
|
|
}
|
|
};
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("164", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
;
|
|
(function(exports) {
|
|
'use strict';
|
|
var Arr = (typeof Uint8Array !== 'undefined') ? Uint8Array : Array;
|
|
var PLUS = '+'.charCodeAt(0);
|
|
var SLASH = '/'.charCodeAt(0);
|
|
var NUMBER = '0'.charCodeAt(0);
|
|
var LOWER = 'a'.charCodeAt(0);
|
|
var UPPER = 'A'.charCodeAt(0);
|
|
var PLUS_URL_SAFE = '-'.charCodeAt(0);
|
|
var SLASH_URL_SAFE = '_'.charCodeAt(0);
|
|
function decode(elt) {
|
|
var code = elt.charCodeAt(0);
|
|
if (code === PLUS || code === PLUS_URL_SAFE)
|
|
return 62;
|
|
if (code === SLASH || code === SLASH_URL_SAFE)
|
|
return 63;
|
|
if (code < NUMBER)
|
|
return -1;
|
|
if (code < NUMBER + 10)
|
|
return code - NUMBER + 26 + 26;
|
|
if (code < UPPER + 26)
|
|
return code - UPPER;
|
|
if (code < LOWER + 26)
|
|
return code - LOWER + 26;
|
|
}
|
|
function b64ToByteArray(b64) {
|
|
var i,
|
|
j,
|
|
l,
|
|
tmp,
|
|
placeHolders,
|
|
arr;
|
|
if (b64.length % 4 > 0) {
|
|
throw new Error('Invalid string. Length must be a multiple of 4');
|
|
}
|
|
var len = b64.length;
|
|
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0;
|
|
arr = new Arr(b64.length * 3 / 4 - placeHolders);
|
|
l = placeHolders > 0 ? b64.length - 4 : b64.length;
|
|
var L = 0;
|
|
function push(v) {
|
|
arr[L++] = v;
|
|
}
|
|
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3));
|
|
push((tmp & 0xFF0000) >> 16);
|
|
push((tmp & 0xFF00) >> 8);
|
|
push(tmp & 0xFF);
|
|
}
|
|
if (placeHolders === 2) {
|
|
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4);
|
|
push(tmp & 0xFF);
|
|
} else if (placeHolders === 1) {
|
|
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2);
|
|
push((tmp >> 8) & 0xFF);
|
|
push(tmp & 0xFF);
|
|
}
|
|
return arr;
|
|
}
|
|
function uint8ToBase64(uint8) {
|
|
var i,
|
|
extraBytes = uint8.length % 3,
|
|
output = "",
|
|
temp,
|
|
length;
|
|
function encode(num) {
|
|
return lookup.charAt(num);
|
|
}
|
|
function tripletToBase64(num) {
|
|
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F);
|
|
}
|
|
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
|
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
|
|
output += tripletToBase64(temp);
|
|
}
|
|
switch (extraBytes) {
|
|
case 1:
|
|
temp = uint8[uint8.length - 1];
|
|
output += encode(temp >> 2);
|
|
output += encode((temp << 4) & 0x3F);
|
|
output += '==';
|
|
break;
|
|
case 2:
|
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);
|
|
output += encode(temp >> 10);
|
|
output += encode((temp >> 4) & 0x3F);
|
|
output += encode((temp << 2) & 0x3F);
|
|
output += '=';
|
|
break;
|
|
}
|
|
return output;
|
|
}
|
|
exports.toByteArray = b64ToByteArray;
|
|
exports.fromByteArray = uint8ToBase64;
|
|
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("165", ["164"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('164');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("166", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
var e,
|
|
m;
|
|
var eLen = nBytes * 8 - mLen - 1;
|
|
var eMax = (1 << eLen) - 1;
|
|
var eBias = eMax >> 1;
|
|
var nBits = -7;
|
|
var i = isLE ? (nBytes - 1) : 0;
|
|
var d = isLE ? -1 : 1;
|
|
var s = buffer[offset + i];
|
|
i += d;
|
|
e = s & ((1 << (-nBits)) - 1);
|
|
s >>= (-nBits);
|
|
nBits += eLen;
|
|
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
m = e & ((1 << (-nBits)) - 1);
|
|
e >>= (-nBits);
|
|
nBits += mLen;
|
|
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
if (e === 0) {
|
|
e = 1 - eBias;
|
|
} else if (e === eMax) {
|
|
return m ? NaN : ((s ? -1 : 1) * Infinity);
|
|
} else {
|
|
m = m + Math.pow(2, mLen);
|
|
e = e - eBias;
|
|
}
|
|
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
};
|
|
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
var e,
|
|
m,
|
|
c;
|
|
var eLen = nBytes * 8 - mLen - 1;
|
|
var eMax = (1 << eLen) - 1;
|
|
var eBias = eMax >> 1;
|
|
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
|
|
var i = isLE ? 0 : (nBytes - 1);
|
|
var d = isLE ? 1 : -1;
|
|
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
|
|
value = Math.abs(value);
|
|
if (isNaN(value) || value === Infinity) {
|
|
m = isNaN(value) ? 1 : 0;
|
|
e = eMax;
|
|
} else {
|
|
e = Math.floor(Math.log(value) / Math.LN2);
|
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
e--;
|
|
c *= 2;
|
|
}
|
|
if (e + eBias >= 1) {
|
|
value += rt / c;
|
|
} else {
|
|
value += rt * Math.pow(2, 1 - eBias);
|
|
}
|
|
if (value * c >= 2) {
|
|
e++;
|
|
c /= 2;
|
|
}
|
|
if (e + eBias >= eMax) {
|
|
m = 0;
|
|
e = eMax;
|
|
} else if (e + eBias >= 1) {
|
|
m = (value * c - 1) * Math.pow(2, mLen);
|
|
e = e + eBias;
|
|
} else {
|
|
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
e = 0;
|
|
}
|
|
}
|
|
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
e = (e << mLen) | m;
|
|
eLen += mLen;
|
|
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
buffer[offset + i - d] |= s * 128;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("167", ["166"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('166');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("168", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toString = {}.toString;
|
|
module.exports = Array.isArray || function(arr) {
|
|
return toString.call(arr) == '[object Array]';
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("169", ["168"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('168');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16a", ["165", "167", "169"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var base64 = $__require('165');
|
|
var ieee754 = $__require('167');
|
|
var isArray = $__require('169');
|
|
exports.Buffer = Buffer;
|
|
exports.SlowBuffer = SlowBuffer;
|
|
exports.INSPECT_MAX_BYTES = 50;
|
|
Buffer.poolSize = 8192;
|
|
var rootParent = {};
|
|
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ? global.TYPED_ARRAY_SUPPORT : typedArraySupport();
|
|
function typedArraySupport() {
|
|
function Bar() {}
|
|
try {
|
|
var arr = new Uint8Array(1);
|
|
arr.foo = function() {
|
|
return 42;
|
|
};
|
|
arr.constructor = Bar;
|
|
return arr.foo() === 42 && arr.constructor === Bar && typeof arr.subarray === 'function' && arr.subarray(1, 1).byteLength === 0;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
function kMaxLength() {
|
|
return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff;
|
|
}
|
|
function Buffer(arg) {
|
|
if (!(this instanceof Buffer)) {
|
|
if (arguments.length > 1)
|
|
return new Buffer(arg, arguments[1]);
|
|
return new Buffer(arg);
|
|
}
|
|
this.length = 0;
|
|
this.parent = undefined;
|
|
if (typeof arg === 'number') {
|
|
return fromNumber(this, arg);
|
|
}
|
|
if (typeof arg === 'string') {
|
|
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8');
|
|
}
|
|
return fromObject(this, arg);
|
|
}
|
|
function fromNumber(that, length) {
|
|
that = allocate(that, length < 0 ? 0 : checked(length) | 0);
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
for (var i = 0; i < length; i++) {
|
|
that[i] = 0;
|
|
}
|
|
}
|
|
return that;
|
|
}
|
|
function fromString(that, string, encoding) {
|
|
if (typeof encoding !== 'string' || encoding === '')
|
|
encoding = 'utf8';
|
|
var length = byteLength(string, encoding) | 0;
|
|
that = allocate(that, length);
|
|
that.write(string, encoding);
|
|
return that;
|
|
}
|
|
function fromObject(that, object) {
|
|
if (Buffer.isBuffer(object))
|
|
return fromBuffer(that, object);
|
|
if (isArray(object))
|
|
return fromArray(that, object);
|
|
if (object == null) {
|
|
throw new TypeError('must start with number, buffer, array or string');
|
|
}
|
|
if (typeof ArrayBuffer !== 'undefined') {
|
|
if (object.buffer instanceof ArrayBuffer) {
|
|
return fromTypedArray(that, object);
|
|
}
|
|
if (object instanceof ArrayBuffer) {
|
|
return fromArrayBuffer(that, object);
|
|
}
|
|
}
|
|
if (object.length)
|
|
return fromArrayLike(that, object);
|
|
return fromJsonObject(that, object);
|
|
}
|
|
function fromBuffer(that, buffer) {
|
|
var length = checked(buffer.length) | 0;
|
|
that = allocate(that, length);
|
|
buffer.copy(that, 0, 0, length);
|
|
return that;
|
|
}
|
|
function fromArray(that, array) {
|
|
var length = checked(array.length) | 0;
|
|
that = allocate(that, length);
|
|
for (var i = 0; i < length; i += 1) {
|
|
that[i] = array[i] & 255;
|
|
}
|
|
return that;
|
|
}
|
|
function fromTypedArray(that, array) {
|
|
var length = checked(array.length) | 0;
|
|
that = allocate(that, length);
|
|
for (var i = 0; i < length; i += 1) {
|
|
that[i] = array[i] & 255;
|
|
}
|
|
return that;
|
|
}
|
|
function fromArrayBuffer(that, array) {
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
array.byteLength;
|
|
that = Buffer._augment(new Uint8Array(array));
|
|
} else {
|
|
that = fromTypedArray(that, new Uint8Array(array));
|
|
}
|
|
return that;
|
|
}
|
|
function fromArrayLike(that, array) {
|
|
var length = checked(array.length) | 0;
|
|
that = allocate(that, length);
|
|
for (var i = 0; i < length; i += 1) {
|
|
that[i] = array[i] & 255;
|
|
}
|
|
return that;
|
|
}
|
|
function fromJsonObject(that, object) {
|
|
var array;
|
|
var length = 0;
|
|
if (object.type === 'Buffer' && isArray(object.data)) {
|
|
array = object.data;
|
|
length = checked(array.length) | 0;
|
|
}
|
|
that = allocate(that, length);
|
|
for (var i = 0; i < length; i += 1) {
|
|
that[i] = array[i] & 255;
|
|
}
|
|
return that;
|
|
}
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
Buffer.prototype.__proto__ = Uint8Array.prototype;
|
|
Buffer.__proto__ = Uint8Array;
|
|
}
|
|
function allocate(that, length) {
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
that = Buffer._augment(new Uint8Array(length));
|
|
that.__proto__ = Buffer.prototype;
|
|
} else {
|
|
that.length = length;
|
|
that._isBuffer = true;
|
|
}
|
|
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1;
|
|
if (fromPool)
|
|
that.parent = rootParent;
|
|
return that;
|
|
}
|
|
function checked(length) {
|
|
if (length >= kMaxLength()) {
|
|
throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength().toString(16) + ' bytes');
|
|
}
|
|
return length | 0;
|
|
}
|
|
function SlowBuffer(subject, encoding) {
|
|
if (!(this instanceof SlowBuffer))
|
|
return new SlowBuffer(subject, encoding);
|
|
var buf = new Buffer(subject, encoding);
|
|
delete buf.parent;
|
|
return buf;
|
|
}
|
|
Buffer.isBuffer = function isBuffer(b) {
|
|
return !!(b != null && b._isBuffer);
|
|
};
|
|
Buffer.compare = function compare(a, b) {
|
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
throw new TypeError('Arguments must be Buffers');
|
|
}
|
|
if (a === b)
|
|
return 0;
|
|
var x = a.length;
|
|
var y = b.length;
|
|
var i = 0;
|
|
var len = Math.min(x, y);
|
|
while (i < len) {
|
|
if (a[i] !== b[i])
|
|
break;
|
|
++i;
|
|
}
|
|
if (i !== len) {
|
|
x = a[i];
|
|
y = b[i];
|
|
}
|
|
if (x < y)
|
|
return -1;
|
|
if (y < x)
|
|
return 1;
|
|
return 0;
|
|
};
|
|
Buffer.isEncoding = function isEncoding(encoding) {
|
|
switch (String(encoding).toLowerCase()) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'raw':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
Buffer.concat = function concat(list, length) {
|
|
if (!isArray(list))
|
|
throw new TypeError('list argument must be an Array of Buffers.');
|
|
if (list.length === 0) {
|
|
return new Buffer(0);
|
|
}
|
|
var i;
|
|
if (length === undefined) {
|
|
length = 0;
|
|
for (i = 0; i < list.length; i++) {
|
|
length += list[i].length;
|
|
}
|
|
}
|
|
var buf = new Buffer(length);
|
|
var pos = 0;
|
|
for (i = 0; i < list.length; i++) {
|
|
var item = list[i];
|
|
item.copy(buf, pos);
|
|
pos += item.length;
|
|
}
|
|
return buf;
|
|
};
|
|
function byteLength(string, encoding) {
|
|
if (typeof string !== 'string')
|
|
string = '' + string;
|
|
var len = string.length;
|
|
if (len === 0)
|
|
return 0;
|
|
var loweredCase = false;
|
|
for (; ; ) {
|
|
switch (encoding) {
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'raw':
|
|
case 'raws':
|
|
return len;
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return utf8ToBytes(string).length;
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return len * 2;
|
|
case 'hex':
|
|
return len >>> 1;
|
|
case 'base64':
|
|
return base64ToBytes(string).length;
|
|
default:
|
|
if (loweredCase)
|
|
return utf8ToBytes(string).length;
|
|
encoding = ('' + encoding).toLowerCase();
|
|
loweredCase = true;
|
|
}
|
|
}
|
|
}
|
|
Buffer.byteLength = byteLength;
|
|
Buffer.prototype.length = undefined;
|
|
Buffer.prototype.parent = undefined;
|
|
function slowToString(encoding, start, end) {
|
|
var loweredCase = false;
|
|
start = start | 0;
|
|
end = end === undefined || end === Infinity ? this.length : end | 0;
|
|
if (!encoding)
|
|
encoding = 'utf8';
|
|
if (start < 0)
|
|
start = 0;
|
|
if (end > this.length)
|
|
end = this.length;
|
|
if (end <= start)
|
|
return '';
|
|
while (true) {
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return hexSlice(this, start, end);
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return utf8Slice(this, start, end);
|
|
case 'ascii':
|
|
return asciiSlice(this, start, end);
|
|
case 'binary':
|
|
return binarySlice(this, start, end);
|
|
case 'base64':
|
|
return base64Slice(this, start, end);
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return utf16leSlice(this, start, end);
|
|
default:
|
|
if (loweredCase)
|
|
throw new TypeError('Unknown encoding: ' + encoding);
|
|
encoding = (encoding + '').toLowerCase();
|
|
loweredCase = true;
|
|
}
|
|
}
|
|
}
|
|
Buffer.prototype.toString = function toString() {
|
|
var length = this.length | 0;
|
|
if (length === 0)
|
|
return '';
|
|
if (arguments.length === 0)
|
|
return utf8Slice(this, 0, length);
|
|
return slowToString.apply(this, arguments);
|
|
};
|
|
Buffer.prototype.equals = function equals(b) {
|
|
if (!Buffer.isBuffer(b))
|
|
throw new TypeError('Argument must be a Buffer');
|
|
if (this === b)
|
|
return true;
|
|
return Buffer.compare(this, b) === 0;
|
|
};
|
|
Buffer.prototype.inspect = function inspect() {
|
|
var str = '';
|
|
var max = exports.INSPECT_MAX_BYTES;
|
|
if (this.length > 0) {
|
|
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
|
|
if (this.length > max)
|
|
str += ' ... ';
|
|
}
|
|
return '<Buffer ' + str + '>';
|
|
};
|
|
Buffer.prototype.compare = function compare(b) {
|
|
if (!Buffer.isBuffer(b))
|
|
throw new TypeError('Argument must be a Buffer');
|
|
if (this === b)
|
|
return 0;
|
|
return Buffer.compare(this, b);
|
|
};
|
|
Buffer.prototype.indexOf = function indexOf(val, byteOffset) {
|
|
if (byteOffset > 0x7fffffff)
|
|
byteOffset = 0x7fffffff;
|
|
else if (byteOffset < -0x80000000)
|
|
byteOffset = -0x80000000;
|
|
byteOffset >>= 0;
|
|
if (this.length === 0)
|
|
return -1;
|
|
if (byteOffset >= this.length)
|
|
return -1;
|
|
if (byteOffset < 0)
|
|
byteOffset = Math.max(this.length + byteOffset, 0);
|
|
if (typeof val === 'string') {
|
|
if (val.length === 0)
|
|
return -1;
|
|
return String.prototype.indexOf.call(this, val, byteOffset);
|
|
}
|
|
if (Buffer.isBuffer(val)) {
|
|
return arrayIndexOf(this, val, byteOffset);
|
|
}
|
|
if (typeof val === 'number') {
|
|
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
|
return Uint8Array.prototype.indexOf.call(this, val, byteOffset);
|
|
}
|
|
return arrayIndexOf(this, [val], byteOffset);
|
|
}
|
|
function arrayIndexOf(arr, val, byteOffset) {
|
|
var foundIndex = -1;
|
|
for (var i = 0; byteOffset + i < arr.length; i++) {
|
|
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
|
if (foundIndex === -1)
|
|
foundIndex = i;
|
|
if (i - foundIndex + 1 === val.length)
|
|
return byteOffset + foundIndex;
|
|
} else {
|
|
foundIndex = -1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
throw new TypeError('val must be string, number or Buffer');
|
|
};
|
|
Buffer.prototype.get = function get(offset) {
|
|
console.log('.get() is deprecated. Access using array indexes instead.');
|
|
return this.readUInt8(offset);
|
|
};
|
|
Buffer.prototype.set = function set(v, offset) {
|
|
console.log('.set() is deprecated. Access using array indexes instead.');
|
|
return this.writeUInt8(v, offset);
|
|
};
|
|
function hexWrite(buf, string, offset, length) {
|
|
offset = Number(offset) || 0;
|
|
var remaining = buf.length - offset;
|
|
if (!length) {
|
|
length = remaining;
|
|
} else {
|
|
length = Number(length);
|
|
if (length > remaining) {
|
|
length = remaining;
|
|
}
|
|
}
|
|
var strLen = string.length;
|
|
if (strLen % 2 !== 0)
|
|
throw new Error('Invalid hex string');
|
|
if (length > strLen / 2) {
|
|
length = strLen / 2;
|
|
}
|
|
for (var i = 0; i < length; i++) {
|
|
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
if (isNaN(parsed))
|
|
throw new Error('Invalid hex string');
|
|
buf[offset + i] = parsed;
|
|
}
|
|
return i;
|
|
}
|
|
function utf8Write(buf, string, offset, length) {
|
|
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
}
|
|
function asciiWrite(buf, string, offset, length) {
|
|
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
}
|
|
function binaryWrite(buf, string, offset, length) {
|
|
return asciiWrite(buf, string, offset, length);
|
|
}
|
|
function base64Write(buf, string, offset, length) {
|
|
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
}
|
|
function ucs2Write(buf, string, offset, length) {
|
|
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
}
|
|
Buffer.prototype.write = function write(string, offset, length, encoding) {
|
|
if (offset === undefined) {
|
|
encoding = 'utf8';
|
|
length = this.length;
|
|
offset = 0;
|
|
} else if (length === undefined && typeof offset === 'string') {
|
|
encoding = offset;
|
|
length = this.length;
|
|
offset = 0;
|
|
} else if (isFinite(offset)) {
|
|
offset = offset | 0;
|
|
if (isFinite(length)) {
|
|
length = length | 0;
|
|
if (encoding === undefined)
|
|
encoding = 'utf8';
|
|
} else {
|
|
encoding = length;
|
|
length = undefined;
|
|
}
|
|
} else {
|
|
var swap = encoding;
|
|
encoding = offset;
|
|
offset = length | 0;
|
|
length = swap;
|
|
}
|
|
var remaining = this.length - offset;
|
|
if (length === undefined || length > remaining)
|
|
length = remaining;
|
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
throw new RangeError('attempt to write outside buffer bounds');
|
|
}
|
|
if (!encoding)
|
|
encoding = 'utf8';
|
|
var loweredCase = false;
|
|
for (; ; ) {
|
|
switch (encoding) {
|
|
case 'hex':
|
|
return hexWrite(this, string, offset, length);
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return utf8Write(this, string, offset, length);
|
|
case 'ascii':
|
|
return asciiWrite(this, string, offset, length);
|
|
case 'binary':
|
|
return binaryWrite(this, string, offset, length);
|
|
case 'base64':
|
|
return base64Write(this, string, offset, length);
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return ucs2Write(this, string, offset, length);
|
|
default:
|
|
if (loweredCase)
|
|
throw new TypeError('Unknown encoding: ' + encoding);
|
|
encoding = ('' + encoding).toLowerCase();
|
|
loweredCase = true;
|
|
}
|
|
}
|
|
};
|
|
Buffer.prototype.toJSON = function toJSON() {
|
|
return {
|
|
type: 'Buffer',
|
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
};
|
|
};
|
|
function base64Slice(buf, start, end) {
|
|
if (start === 0 && end === buf.length) {
|
|
return base64.fromByteArray(buf);
|
|
} else {
|
|
return base64.fromByteArray(buf.slice(start, end));
|
|
}
|
|
}
|
|
function utf8Slice(buf, start, end) {
|
|
end = Math.min(buf.length, end);
|
|
var res = [];
|
|
var i = start;
|
|
while (i < end) {
|
|
var firstByte = buf[i];
|
|
var codePoint = null;
|
|
var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 : (firstByte > 0xBF) ? 2 : 1;
|
|
if (i + bytesPerSequence <= end) {
|
|
var secondByte,
|
|
thirdByte,
|
|
fourthByte,
|
|
tempCodePoint;
|
|
switch (bytesPerSequence) {
|
|
case 1:
|
|
if (firstByte < 0x80) {
|
|
codePoint = firstByte;
|
|
}
|
|
break;
|
|
case 2:
|
|
secondByte = buf[i + 1];
|
|
if ((secondByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
if (tempCodePoint > 0x7F) {
|
|
codePoint = tempCodePoint;
|
|
}
|
|
}
|
|
break;
|
|
case 3:
|
|
secondByte = buf[i + 1];
|
|
thirdByte = buf[i + 2];
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
codePoint = tempCodePoint;
|
|
}
|
|
}
|
|
break;
|
|
case 4:
|
|
secondByte = buf[i + 1];
|
|
thirdByte = buf[i + 2];
|
|
fourthByte = buf[i + 3];
|
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
codePoint = tempCodePoint;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (codePoint === null) {
|
|
codePoint = 0xFFFD;
|
|
bytesPerSequence = 1;
|
|
} else if (codePoint > 0xFFFF) {
|
|
codePoint -= 0x10000;
|
|
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
}
|
|
res.push(codePoint);
|
|
i += bytesPerSequence;
|
|
}
|
|
return decodeCodePointsArray(res);
|
|
}
|
|
var MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
function decodeCodePointsArray(codePoints) {
|
|
var len = codePoints.length;
|
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
return String.fromCharCode.apply(String, codePoints);
|
|
}
|
|
var res = '';
|
|
var i = 0;
|
|
while (i < len) {
|
|
res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
|
|
}
|
|
return res;
|
|
}
|
|
function asciiSlice(buf, start, end) {
|
|
var ret = '';
|
|
end = Math.min(buf.length, end);
|
|
for (var i = start; i < end; i++) {
|
|
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
}
|
|
return ret;
|
|
}
|
|
function binarySlice(buf, start, end) {
|
|
var ret = '';
|
|
end = Math.min(buf.length, end);
|
|
for (var i = start; i < end; i++) {
|
|
ret += String.fromCharCode(buf[i]);
|
|
}
|
|
return ret;
|
|
}
|
|
function hexSlice(buf, start, end) {
|
|
var len = buf.length;
|
|
if (!start || start < 0)
|
|
start = 0;
|
|
if (!end || end < 0 || end > len)
|
|
end = len;
|
|
var out = '';
|
|
for (var i = start; i < end; i++) {
|
|
out += toHex(buf[i]);
|
|
}
|
|
return out;
|
|
}
|
|
function utf16leSlice(buf, start, end) {
|
|
var bytes = buf.slice(start, end);
|
|
var res = '';
|
|
for (var i = 0; i < bytes.length; i += 2) {
|
|
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
}
|
|
return res;
|
|
}
|
|
Buffer.prototype.slice = function slice(start, end) {
|
|
var len = this.length;
|
|
start = ~~start;
|
|
end = end === undefined ? len : ~~end;
|
|
if (start < 0) {
|
|
start += len;
|
|
if (start < 0)
|
|
start = 0;
|
|
} else if (start > len) {
|
|
start = len;
|
|
}
|
|
if (end < 0) {
|
|
end += len;
|
|
if (end < 0)
|
|
end = 0;
|
|
} else if (end > len) {
|
|
end = len;
|
|
}
|
|
if (end < start)
|
|
end = start;
|
|
var newBuf;
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
newBuf = Buffer._augment(this.subarray(start, end));
|
|
} else {
|
|
var sliceLen = end - start;
|
|
newBuf = new Buffer(sliceLen, undefined);
|
|
for (var i = 0; i < sliceLen; i++) {
|
|
newBuf[i] = this[i + start];
|
|
}
|
|
}
|
|
if (newBuf.length)
|
|
newBuf.parent = this.parent || this;
|
|
return newBuf;
|
|
};
|
|
function checkOffset(offset, ext, length) {
|
|
if ((offset % 1) !== 0 || offset < 0)
|
|
throw new RangeError('offset is not uint');
|
|
if (offset + ext > length)
|
|
throw new RangeError('Trying to access beyond buffer length');
|
|
}
|
|
Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert)
|
|
checkOffset(offset, byteLength, this.length);
|
|
var val = this[offset];
|
|
var mul = 1;
|
|
var i = 0;
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
val += this[offset + i] * mul;
|
|
}
|
|
return val;
|
|
};
|
|
Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert) {
|
|
checkOffset(offset, byteLength, this.length);
|
|
}
|
|
var val = this[offset + --byteLength];
|
|
var mul = 1;
|
|
while (byteLength > 0 && (mul *= 0x100)) {
|
|
val += this[offset + --byteLength] * mul;
|
|
}
|
|
return val;
|
|
};
|
|
Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 1, this.length);
|
|
return this[offset];
|
|
};
|
|
Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 2, this.length);
|
|
return this[offset] | (this[offset + 1] << 8);
|
|
};
|
|
Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 2, this.length);
|
|
return (this[offset] << 8) | this[offset + 1];
|
|
};
|
|
Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return ((this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + (this[offset + 3] * 0x1000000);
|
|
};
|
|
Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return (this[offset] * 0x1000000) + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]);
|
|
};
|
|
Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert)
|
|
checkOffset(offset, byteLength, this.length);
|
|
var val = this[offset];
|
|
var mul = 1;
|
|
var i = 0;
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
val += this[offset + i] * mul;
|
|
}
|
|
mul *= 0x80;
|
|
if (val >= mul)
|
|
val -= Math.pow(2, 8 * byteLength);
|
|
return val;
|
|
};
|
|
Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert)
|
|
checkOffset(offset, byteLength, this.length);
|
|
var i = byteLength;
|
|
var mul = 1;
|
|
var val = this[offset + --i];
|
|
while (i > 0 && (mul *= 0x100)) {
|
|
val += this[offset + --i] * mul;
|
|
}
|
|
mul *= 0x80;
|
|
if (val >= mul)
|
|
val -= Math.pow(2, 8 * byteLength);
|
|
return val;
|
|
};
|
|
Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 1, this.length);
|
|
if (!(this[offset] & 0x80))
|
|
return (this[offset]);
|
|
return ((0xff - this[offset] + 1) * -1);
|
|
};
|
|
Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 2, this.length);
|
|
var val = this[offset] | (this[offset + 1] << 8);
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val;
|
|
};
|
|
Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 2, this.length);
|
|
var val = this[offset + 1] | (this[offset] << 8);
|
|
return (val & 0x8000) ? val | 0xFFFF0000 : val;
|
|
};
|
|
Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return (this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24);
|
|
};
|
|
Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | (this[offset + 3]);
|
|
};
|
|
Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return ieee754.read(this, offset, true, 23, 4);
|
|
};
|
|
Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 4, this.length);
|
|
return ieee754.read(this, offset, false, 23, 4);
|
|
};
|
|
Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 8, this.length);
|
|
return ieee754.read(this, offset, true, 52, 8);
|
|
};
|
|
Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
if (!noAssert)
|
|
checkOffset(offset, 8, this.length);
|
|
return ieee754.read(this, offset, false, 52, 8);
|
|
};
|
|
function checkInt(buf, value, offset, ext, max, min) {
|
|
if (!Buffer.isBuffer(buf))
|
|
throw new TypeError('buffer must be a Buffer instance');
|
|
if (value > max || value < min)
|
|
throw new RangeError('value is out of bounds');
|
|
if (offset + ext > buf.length)
|
|
throw new RangeError('index out of range');
|
|
}
|
|
Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0);
|
|
var mul = 1;
|
|
var i = 0;
|
|
this[offset] = value & 0xFF;
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
this[offset + i] = (value / mul) & 0xFF;
|
|
}
|
|
return offset + byteLength;
|
|
};
|
|
Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
byteLength = byteLength | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0);
|
|
var i = byteLength - 1;
|
|
var mul = 1;
|
|
this[offset + i] = value & 0xFF;
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
this[offset + i] = (value / mul) & 0xFF;
|
|
}
|
|
return offset + byteLength;
|
|
};
|
|
Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 1, 0xff, 0);
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT)
|
|
value = Math.floor(value);
|
|
this[offset] = (value & 0xff);
|
|
return offset + 1;
|
|
};
|
|
function objectWriteUInt16(buf, value, offset, littleEndian) {
|
|
if (value < 0)
|
|
value = 0xffff + value + 1;
|
|
for (var i = 0,
|
|
j = Math.min(buf.length - offset, 2); i < j; i++) {
|
|
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8;
|
|
}
|
|
}
|
|
Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 2, 0xffff, 0);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff);
|
|
this[offset + 1] = (value >>> 8);
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, true);
|
|
}
|
|
return offset + 2;
|
|
};
|
|
Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 2, 0xffff, 0);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 8);
|
|
this[offset + 1] = (value & 0xff);
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, false);
|
|
}
|
|
return offset + 2;
|
|
};
|
|
function objectWriteUInt32(buf, value, offset, littleEndian) {
|
|
if (value < 0)
|
|
value = 0xffffffff + value + 1;
|
|
for (var i = 0,
|
|
j = Math.min(buf.length - offset, 4); i < j; i++) {
|
|
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
|
|
}
|
|
}
|
|
Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset + 3] = (value >>> 24);
|
|
this[offset + 2] = (value >>> 16);
|
|
this[offset + 1] = (value >>> 8);
|
|
this[offset] = (value & 0xff);
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, true);
|
|
}
|
|
return offset + 4;
|
|
};
|
|
Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 24);
|
|
this[offset + 1] = (value >>> 16);
|
|
this[offset + 2] = (value >>> 8);
|
|
this[offset + 3] = (value & 0xff);
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, false);
|
|
}
|
|
return offset + 4;
|
|
};
|
|
Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert) {
|
|
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
}
|
|
var i = 0;
|
|
var mul = 1;
|
|
var sub = value < 0 ? 1 : 0;
|
|
this[offset] = value & 0xFF;
|
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
}
|
|
return offset + byteLength;
|
|
};
|
|
Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert) {
|
|
var limit = Math.pow(2, 8 * byteLength - 1);
|
|
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
}
|
|
var i = byteLength - 1;
|
|
var mul = 1;
|
|
var sub = value < 0 ? 1 : 0;
|
|
this[offset + i] = value & 0xFF;
|
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
}
|
|
return offset + byteLength;
|
|
};
|
|
Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 1, 0x7f, -0x80);
|
|
if (!Buffer.TYPED_ARRAY_SUPPORT)
|
|
value = Math.floor(value);
|
|
if (value < 0)
|
|
value = 0xff + value + 1;
|
|
this[offset] = (value & 0xff);
|
|
return offset + 1;
|
|
};
|
|
Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 2, 0x7fff, -0x8000);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff);
|
|
this[offset + 1] = (value >>> 8);
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, true);
|
|
}
|
|
return offset + 2;
|
|
};
|
|
Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 2, 0x7fff, -0x8000);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 8);
|
|
this[offset + 1] = (value & 0xff);
|
|
} else {
|
|
objectWriteUInt16(this, value, offset, false);
|
|
}
|
|
return offset + 2;
|
|
};
|
|
Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value & 0xff);
|
|
this[offset + 1] = (value >>> 8);
|
|
this[offset + 2] = (value >>> 16);
|
|
this[offset + 3] = (value >>> 24);
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, true);
|
|
}
|
|
return offset + 4;
|
|
};
|
|
Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
value = +value;
|
|
offset = offset | 0;
|
|
if (!noAssert)
|
|
checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
|
|
if (value < 0)
|
|
value = 0xffffffff + value + 1;
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
this[offset] = (value >>> 24);
|
|
this[offset + 1] = (value >>> 16);
|
|
this[offset + 2] = (value >>> 8);
|
|
this[offset + 3] = (value & 0xff);
|
|
} else {
|
|
objectWriteUInt32(this, value, offset, false);
|
|
}
|
|
return offset + 4;
|
|
};
|
|
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
if (value > max || value < min)
|
|
throw new RangeError('value is out of bounds');
|
|
if (offset + ext > buf.length)
|
|
throw new RangeError('index out of range');
|
|
if (offset < 0)
|
|
throw new RangeError('index out of range');
|
|
}
|
|
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
|
|
}
|
|
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
return offset + 4;
|
|
}
|
|
Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
return writeFloat(this, value, offset, true, noAssert);
|
|
};
|
|
Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
return writeFloat(this, value, offset, false, noAssert);
|
|
};
|
|
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
if (!noAssert) {
|
|
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
|
|
}
|
|
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
return offset + 8;
|
|
}
|
|
Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
return writeDouble(this, value, offset, true, noAssert);
|
|
};
|
|
Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
return writeDouble(this, value, offset, false, noAssert);
|
|
};
|
|
Buffer.prototype.copy = function copy(target, targetStart, start, end) {
|
|
if (!start)
|
|
start = 0;
|
|
if (!end && end !== 0)
|
|
end = this.length;
|
|
if (targetStart >= target.length)
|
|
targetStart = target.length;
|
|
if (!targetStart)
|
|
targetStart = 0;
|
|
if (end > 0 && end < start)
|
|
end = start;
|
|
if (end === start)
|
|
return 0;
|
|
if (target.length === 0 || this.length === 0)
|
|
return 0;
|
|
if (targetStart < 0) {
|
|
throw new RangeError('targetStart out of bounds');
|
|
}
|
|
if (start < 0 || start >= this.length)
|
|
throw new RangeError('sourceStart out of bounds');
|
|
if (end < 0)
|
|
throw new RangeError('sourceEnd out of bounds');
|
|
if (end > this.length)
|
|
end = this.length;
|
|
if (target.length - targetStart < end - start) {
|
|
end = target.length - targetStart + start;
|
|
}
|
|
var len = end - start;
|
|
var i;
|
|
if (this === target && start < targetStart && targetStart < end) {
|
|
for (i = len - 1; i >= 0; i--) {
|
|
target[i + targetStart] = this[i + start];
|
|
}
|
|
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
for (i = 0; i < len; i++) {
|
|
target[i + targetStart] = this[i + start];
|
|
}
|
|
} else {
|
|
target._set(this.subarray(start, start + len), targetStart);
|
|
}
|
|
return len;
|
|
};
|
|
Buffer.prototype.fill = function fill(value, start, end) {
|
|
if (!value)
|
|
value = 0;
|
|
if (!start)
|
|
start = 0;
|
|
if (!end)
|
|
end = this.length;
|
|
if (end < start)
|
|
throw new RangeError('end < start');
|
|
if (end === start)
|
|
return;
|
|
if (this.length === 0)
|
|
return;
|
|
if (start < 0 || start >= this.length)
|
|
throw new RangeError('start out of bounds');
|
|
if (end < 0 || end > this.length)
|
|
throw new RangeError('end out of bounds');
|
|
var i;
|
|
if (typeof value === 'number') {
|
|
for (i = start; i < end; i++) {
|
|
this[i] = value;
|
|
}
|
|
} else {
|
|
var bytes = utf8ToBytes(value.toString());
|
|
var len = bytes.length;
|
|
for (i = start; i < end; i++) {
|
|
this[i] = bytes[i % len];
|
|
}
|
|
}
|
|
return this;
|
|
};
|
|
Buffer.prototype.toArrayBuffer = function toArrayBuffer() {
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
return (new Buffer(this)).buffer;
|
|
} else {
|
|
var buf = new Uint8Array(this.length);
|
|
for (var i = 0,
|
|
len = buf.length; i < len; i += 1) {
|
|
buf[i] = this[i];
|
|
}
|
|
return buf.buffer;
|
|
}
|
|
} else {
|
|
throw new TypeError('Buffer.toArrayBuffer not supported in this browser');
|
|
}
|
|
};
|
|
var BP = Buffer.prototype;
|
|
Buffer._augment = function _augment(arr) {
|
|
arr.constructor = Buffer;
|
|
arr._isBuffer = true;
|
|
arr._set = arr.set;
|
|
arr.get = BP.get;
|
|
arr.set = BP.set;
|
|
arr.write = BP.write;
|
|
arr.toString = BP.toString;
|
|
arr.toLocaleString = BP.toString;
|
|
arr.toJSON = BP.toJSON;
|
|
arr.equals = BP.equals;
|
|
arr.compare = BP.compare;
|
|
arr.indexOf = BP.indexOf;
|
|
arr.copy = BP.copy;
|
|
arr.slice = BP.slice;
|
|
arr.readUIntLE = BP.readUIntLE;
|
|
arr.readUIntBE = BP.readUIntBE;
|
|
arr.readUInt8 = BP.readUInt8;
|
|
arr.readUInt16LE = BP.readUInt16LE;
|
|
arr.readUInt16BE = BP.readUInt16BE;
|
|
arr.readUInt32LE = BP.readUInt32LE;
|
|
arr.readUInt32BE = BP.readUInt32BE;
|
|
arr.readIntLE = BP.readIntLE;
|
|
arr.readIntBE = BP.readIntBE;
|
|
arr.readInt8 = BP.readInt8;
|
|
arr.readInt16LE = BP.readInt16LE;
|
|
arr.readInt16BE = BP.readInt16BE;
|
|
arr.readInt32LE = BP.readInt32LE;
|
|
arr.readInt32BE = BP.readInt32BE;
|
|
arr.readFloatLE = BP.readFloatLE;
|
|
arr.readFloatBE = BP.readFloatBE;
|
|
arr.readDoubleLE = BP.readDoubleLE;
|
|
arr.readDoubleBE = BP.readDoubleBE;
|
|
arr.writeUInt8 = BP.writeUInt8;
|
|
arr.writeUIntLE = BP.writeUIntLE;
|
|
arr.writeUIntBE = BP.writeUIntBE;
|
|
arr.writeUInt16LE = BP.writeUInt16LE;
|
|
arr.writeUInt16BE = BP.writeUInt16BE;
|
|
arr.writeUInt32LE = BP.writeUInt32LE;
|
|
arr.writeUInt32BE = BP.writeUInt32BE;
|
|
arr.writeIntLE = BP.writeIntLE;
|
|
arr.writeIntBE = BP.writeIntBE;
|
|
arr.writeInt8 = BP.writeInt8;
|
|
arr.writeInt16LE = BP.writeInt16LE;
|
|
arr.writeInt16BE = BP.writeInt16BE;
|
|
arr.writeInt32LE = BP.writeInt32LE;
|
|
arr.writeInt32BE = BP.writeInt32BE;
|
|
arr.writeFloatLE = BP.writeFloatLE;
|
|
arr.writeFloatBE = BP.writeFloatBE;
|
|
arr.writeDoubleLE = BP.writeDoubleLE;
|
|
arr.writeDoubleBE = BP.writeDoubleBE;
|
|
arr.fill = BP.fill;
|
|
arr.inspect = BP.inspect;
|
|
arr.toArrayBuffer = BP.toArrayBuffer;
|
|
return arr;
|
|
};
|
|
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
|
|
function base64clean(str) {
|
|
str = stringtrim(str).replace(INVALID_BASE64_RE, '');
|
|
if (str.length < 2)
|
|
return '';
|
|
while (str.length % 4 !== 0) {
|
|
str = str + '=';
|
|
}
|
|
return str;
|
|
}
|
|
function stringtrim(str) {
|
|
if (str.trim)
|
|
return str.trim();
|
|
return str.replace(/^\s+|\s+$/g, '');
|
|
}
|
|
function toHex(n) {
|
|
if (n < 16)
|
|
return '0' + n.toString(16);
|
|
return n.toString(16);
|
|
}
|
|
function utf8ToBytes(string, units) {
|
|
units = units || Infinity;
|
|
var codePoint;
|
|
var length = string.length;
|
|
var leadSurrogate = null;
|
|
var bytes = [];
|
|
for (var i = 0; i < length; i++) {
|
|
codePoint = string.charCodeAt(i);
|
|
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
if (!leadSurrogate) {
|
|
if (codePoint > 0xDBFF) {
|
|
if ((units -= 3) > -1)
|
|
bytes.push(0xEF, 0xBF, 0xBD);
|
|
continue;
|
|
} else if (i + 1 === length) {
|
|
if ((units -= 3) > -1)
|
|
bytes.push(0xEF, 0xBF, 0xBD);
|
|
continue;
|
|
}
|
|
leadSurrogate = codePoint;
|
|
continue;
|
|
}
|
|
if (codePoint < 0xDC00) {
|
|
if ((units -= 3) > -1)
|
|
bytes.push(0xEF, 0xBF, 0xBD);
|
|
leadSurrogate = codePoint;
|
|
continue;
|
|
}
|
|
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
} else if (leadSurrogate) {
|
|
if ((units -= 3) > -1)
|
|
bytes.push(0xEF, 0xBF, 0xBD);
|
|
}
|
|
leadSurrogate = null;
|
|
if (codePoint < 0x80) {
|
|
if ((units -= 1) < 0)
|
|
break;
|
|
bytes.push(codePoint);
|
|
} else if (codePoint < 0x800) {
|
|
if ((units -= 2) < 0)
|
|
break;
|
|
bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
|
|
} else if (codePoint < 0x10000) {
|
|
if ((units -= 3) < 0)
|
|
break;
|
|
bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
|
|
} else if (codePoint < 0x110000) {
|
|
if ((units -= 4) < 0)
|
|
break;
|
|
bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
|
|
} else {
|
|
throw new Error('Invalid code point');
|
|
}
|
|
}
|
|
return bytes;
|
|
}
|
|
function asciiToBytes(str) {
|
|
var byteArray = [];
|
|
for (var i = 0; i < str.length; i++) {
|
|
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
}
|
|
return byteArray;
|
|
}
|
|
function utf16leToBytes(str, units) {
|
|
var c,
|
|
hi,
|
|
lo;
|
|
var byteArray = [];
|
|
for (var i = 0; i < str.length; i++) {
|
|
if ((units -= 2) < 0)
|
|
break;
|
|
c = str.charCodeAt(i);
|
|
hi = c >> 8;
|
|
lo = c % 256;
|
|
byteArray.push(lo);
|
|
byteArray.push(hi);
|
|
}
|
|
return byteArray;
|
|
}
|
|
function base64ToBytes(str) {
|
|
return base64.toByteArray(base64clean(str));
|
|
}
|
|
function blitBuffer(src, dst, offset, length) {
|
|
for (var i = 0; i < length; i++) {
|
|
if ((i + offset >= dst.length) || (i >= src.length))
|
|
break;
|
|
dst[i + offset] = src[i];
|
|
}
|
|
return i;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16b", ["16a"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('16a');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16c", ["16b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('buffer') : $__require('16b');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10c", ["16c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('16c');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("13c", ["13a", "10e", "12f", "101", "10c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(Buffer) {
|
|
'use strict';
|
|
module.exports = Pointer;
|
|
var $Ref = $__require('13a'),
|
|
util = $__require('10e'),
|
|
url = $__require('12f'),
|
|
ono = $__require('101'),
|
|
slashes = /\//g,
|
|
tildes = /~/g,
|
|
escapedSlash = /~1/g,
|
|
escapedTilde = /~0/g;
|
|
function Pointer($ref, path) {
|
|
this.$ref = $ref;
|
|
this.path = path;
|
|
this.value = undefined;
|
|
this.circular = false;
|
|
}
|
|
Pointer.prototype.resolve = function(obj, options) {
|
|
var tokens = Pointer.parse(this.path);
|
|
this.value = obj;
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
if (resolveIf$Ref(this, options)) {
|
|
this.path = Pointer.join(this.path, tokens.slice(i));
|
|
}
|
|
var token = tokens[i];
|
|
if (this.value[token] === undefined) {
|
|
throw ono.syntax('Error resolving $ref pointer "%s". \nToken "%s" does not exist.', this.path, token);
|
|
} else {
|
|
this.value = this.value[token];
|
|
}
|
|
}
|
|
resolveIf$Ref(this, options);
|
|
return this;
|
|
};
|
|
Pointer.prototype.set = function(obj, value, options) {
|
|
var tokens = Pointer.parse(this.path);
|
|
var token;
|
|
if (tokens.length === 0) {
|
|
this.value = value;
|
|
return value;
|
|
}
|
|
this.value = obj;
|
|
for (var i = 0; i < tokens.length - 1; i++) {
|
|
resolveIf$Ref(this, options);
|
|
token = tokens[i];
|
|
if (this.value && this.value[token] !== undefined) {
|
|
this.value = this.value[token];
|
|
} else {
|
|
this.value = setValue(this, token, {});
|
|
}
|
|
}
|
|
resolveIf$Ref(this, options);
|
|
token = tokens[tokens.length - 1];
|
|
setValue(this, token, value);
|
|
return obj;
|
|
};
|
|
Pointer.parse = function(path) {
|
|
var pointer = util.path.getHash(path).substr(1);
|
|
if (!pointer) {
|
|
return [];
|
|
}
|
|
pointer = pointer.split('/');
|
|
for (var i = 0; i < pointer.length; i++) {
|
|
pointer[i] = decodeURI(pointer[i].replace(escapedSlash, '/').replace(escapedTilde, '~'));
|
|
}
|
|
if (pointer[0] !== '') {
|
|
throw ono.syntax('Invalid $ref pointer "%s". Pointers must begin with "#/"', pointer);
|
|
}
|
|
return pointer.slice(1);
|
|
};
|
|
Pointer.join = function(base, tokens) {
|
|
if (base.indexOf('#') === -1) {
|
|
base += '#';
|
|
}
|
|
tokens = Array.isArray(tokens) ? tokens : [tokens];
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
var token = tokens[i];
|
|
base += '/' + encodeURI(token.replace(tildes, '~0').replace(slashes, '~1'));
|
|
}
|
|
return base;
|
|
};
|
|
function resolveIf$Ref(pointer, options) {
|
|
if ($Ref.isAllowed$Ref(pointer.value, options)) {
|
|
var $refPath = url.resolve(pointer.path, pointer.value.$ref);
|
|
if ($refPath === pointer.path) {
|
|
pointer.circular = true;
|
|
} else {
|
|
if (Object.keys(pointer.value).length === 1) {
|
|
var resolved = pointer.$ref.$refs._resolve($refPath);
|
|
pointer.$ref = resolved.$ref;
|
|
pointer.path = resolved.path;
|
|
pointer.value = resolved.value;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function setValue(pointer, token, value) {
|
|
if (pointer.value && typeof pointer.value === 'object') {
|
|
if (token === '-' && Array.isArray(pointer.value)) {
|
|
pointer.value.push(value);
|
|
} else {
|
|
pointer.value[token] = value;
|
|
}
|
|
} else {
|
|
throw ono.syntax('Error assigning $ref pointer "%s". \nCannot set "%s" of a non-object.', pointer.path, token);
|
|
}
|
|
return value;
|
|
}
|
|
})($__require('10c').Buffer);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16d", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var s = 1000;
|
|
var m = s * 60;
|
|
var h = m * 60;
|
|
var d = h * 24;
|
|
var y = d * 365.25;
|
|
module.exports = function(val, options) {
|
|
options = options || {};
|
|
if ('string' == typeof val)
|
|
return parse(val);
|
|
return options.long ? long(val) : short(val);
|
|
};
|
|
function parse(str) {
|
|
str = '' + str;
|
|
if (str.length > 10000)
|
|
return;
|
|
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
|
|
if (!match)
|
|
return;
|
|
var n = parseFloat(match[1]);
|
|
var type = (match[2] || 'ms').toLowerCase();
|
|
switch (type) {
|
|
case 'years':
|
|
case 'year':
|
|
case 'yrs':
|
|
case 'yr':
|
|
case 'y':
|
|
return n * y;
|
|
case 'days':
|
|
case 'day':
|
|
case 'd':
|
|
return n * d;
|
|
case 'hours':
|
|
case 'hour':
|
|
case 'hrs':
|
|
case 'hr':
|
|
case 'h':
|
|
return n * h;
|
|
case 'minutes':
|
|
case 'minute':
|
|
case 'mins':
|
|
case 'min':
|
|
case 'm':
|
|
return n * m;
|
|
case 'seconds':
|
|
case 'second':
|
|
case 'secs':
|
|
case 'sec':
|
|
case 's':
|
|
return n * s;
|
|
case 'milliseconds':
|
|
case 'millisecond':
|
|
case 'msecs':
|
|
case 'msec':
|
|
case 'ms':
|
|
return n;
|
|
}
|
|
}
|
|
function short(ms) {
|
|
if (ms >= d)
|
|
return Math.round(ms / d) + 'd';
|
|
if (ms >= h)
|
|
return Math.round(ms / h) + 'h';
|
|
if (ms >= m)
|
|
return Math.round(ms / m) + 'm';
|
|
if (ms >= s)
|
|
return Math.round(ms / s) + 's';
|
|
return ms + 'ms';
|
|
}
|
|
function long(ms) {
|
|
return plural(ms, d, 'day') || plural(ms, h, 'hour') || plural(ms, m, 'minute') || plural(ms, s, 'second') || ms + ' ms';
|
|
}
|
|
function plural(ms, n, name) {
|
|
if (ms < n)
|
|
return;
|
|
if (ms < n * 1.5)
|
|
return Math.floor(ms / n) + ' ' + name;
|
|
return Math.ceil(ms / n) + ' ' + name + 's';
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16e", ["16d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('16d');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("16f", ["16e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports = module.exports = debug;
|
|
exports.coerce = coerce;
|
|
exports.disable = disable;
|
|
exports.enable = enable;
|
|
exports.enabled = enabled;
|
|
exports.humanize = $__require('16e');
|
|
exports.names = [];
|
|
exports.skips = [];
|
|
exports.formatters = {};
|
|
var prevColor = 0;
|
|
var prevTime;
|
|
function selectColor() {
|
|
return exports.colors[prevColor++ % exports.colors.length];
|
|
}
|
|
function debug(namespace) {
|
|
function disabled() {}
|
|
disabled.enabled = false;
|
|
function enabled() {
|
|
var self = enabled;
|
|
var curr = +new Date();
|
|
var ms = curr - (prevTime || curr);
|
|
self.diff = ms;
|
|
self.prev = prevTime;
|
|
self.curr = curr;
|
|
prevTime = curr;
|
|
if (null == self.useColors)
|
|
self.useColors = exports.useColors();
|
|
if (null == self.color && self.useColors)
|
|
self.color = selectColor();
|
|
var args = Array.prototype.slice.call(arguments);
|
|
args[0] = exports.coerce(args[0]);
|
|
if ('string' !== typeof args[0]) {
|
|
args = ['%o'].concat(args);
|
|
}
|
|
var index = 0;
|
|
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
|
if (match === '%%')
|
|
return match;
|
|
index++;
|
|
var formatter = exports.formatters[format];
|
|
if ('function' === typeof formatter) {
|
|
var val = args[index];
|
|
match = formatter.call(self, val);
|
|
args.splice(index, 1);
|
|
index--;
|
|
}
|
|
return match;
|
|
});
|
|
if ('function' === typeof exports.formatArgs) {
|
|
args = exports.formatArgs.apply(self, args);
|
|
}
|
|
var logFn = enabled.log || exports.log || console.log.bind(console);
|
|
logFn.apply(self, args);
|
|
}
|
|
enabled.enabled = true;
|
|
var fn = exports.enabled(namespace) ? enabled : disabled;
|
|
fn.namespace = namespace;
|
|
return fn;
|
|
}
|
|
function enable(namespaces) {
|
|
exports.save(namespaces);
|
|
var split = (namespaces || '').split(/[\s,]+/);
|
|
var len = split.length;
|
|
for (var i = 0; i < len; i++) {
|
|
if (!split[i])
|
|
continue;
|
|
namespaces = split[i].replace(/\*/g, '.*?');
|
|
if (namespaces[0] === '-') {
|
|
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
} else {
|
|
exports.names.push(new RegExp('^' + namespaces + '$'));
|
|
}
|
|
}
|
|
}
|
|
function disable() {
|
|
exports.enable('');
|
|
}
|
|
function enabled(name) {
|
|
var i,
|
|
len;
|
|
for (i = 0, len = exports.skips.length; i < len; i++) {
|
|
if (exports.skips[i].test(name)) {
|
|
return false;
|
|
}
|
|
}
|
|
for (i = 0, len = exports.names.length; i < len; i++) {
|
|
if (exports.names[i].test(name)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function coerce(val) {
|
|
if (val instanceof Error)
|
|
return val.stack || val.message;
|
|
return val;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("170", ["16f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports = module.exports = $__require('16f');
|
|
exports.log = log;
|
|
exports.formatArgs = formatArgs;
|
|
exports.save = save;
|
|
exports.load = load;
|
|
exports.useColors = useColors;
|
|
exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage();
|
|
exports.colors = ['lightseagreen', 'forestgreen', 'goldenrod', 'dodgerblue', 'darkorchid', 'crimson'];
|
|
function useColors() {
|
|
return ('WebkitAppearance' in document.documentElement.style) || (window.console && (console.firebug || (console.exception && console.table))) || (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
|
}
|
|
exports.formatters.j = function(v) {
|
|
return JSON.stringify(v);
|
|
};
|
|
function formatArgs() {
|
|
var args = arguments;
|
|
var useColors = this.useColors;
|
|
args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff);
|
|
if (!useColors)
|
|
return args;
|
|
var c = 'color: ' + this.color;
|
|
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
|
var index = 0;
|
|
var lastC = 0;
|
|
args[0].replace(/%[a-z%]/g, function(match) {
|
|
if ('%%' === match)
|
|
return;
|
|
index++;
|
|
if ('%c' === match) {
|
|
lastC = index;
|
|
}
|
|
});
|
|
args.splice(lastC, 0, c);
|
|
return args;
|
|
}
|
|
function log() {
|
|
return 'object' === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments);
|
|
}
|
|
function save(namespaces) {
|
|
try {
|
|
if (null == namespaces) {
|
|
exports.storage.removeItem('debug');
|
|
} else {
|
|
exports.storage.debug = namespaces;
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
function load() {
|
|
var r;
|
|
try {
|
|
r = exports.storage.debug;
|
|
} catch (e) {}
|
|
return r;
|
|
}
|
|
exports.enable(load());
|
|
function localstorage() {
|
|
try {
|
|
return window.localStorage;
|
|
} catch (e) {}
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("106", ["170"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('170');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("10e", ["106", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var debug = $__require('106'),
|
|
isWindows = /^win/.test(process.platform),
|
|
forwardSlashPattern = /\//g,
|
|
protocolPattern = /^[a-z0-9.+-]+:\/\//i;
|
|
var urlEncodePatterns = [/\?/g, '%3F', /\#/g, '%23', isWindows ? /\\/g : /\//, '/'];
|
|
var urlDecodePatterns = [/\%23/g, '#', /\%24/g, '$', /\%26/g, '&', /\%2C/g, ',', /\%40/g, '@'];
|
|
exports.debug = debug('json-schema-ref-parser');
|
|
exports.path = {};
|
|
exports.path.cwd = function cwd() {
|
|
return process.browser ? location.href : process.cwd() + '/';
|
|
};
|
|
exports.path.isUrl = function isUrl(path) {
|
|
return protocolPattern.test(path);
|
|
};
|
|
exports.path.localPathToUrl = function localPathToUrl(path) {
|
|
if (!process.browser && !exports.path.isUrl(path)) {
|
|
for (var i = 0; i < urlEncodePatterns.length; i += 2) {
|
|
path = path.replace(urlEncodePatterns[i], urlEncodePatterns[i + 1]);
|
|
}
|
|
path = encodeURI(path);
|
|
}
|
|
return path;
|
|
};
|
|
exports.path.urlToLocalPath = function urlToLocalPath(url) {
|
|
url = decodeURI(url);
|
|
for (var i = 0; i < urlDecodePatterns.length; i += 2) {
|
|
url = url.replace(urlDecodePatterns[i], urlDecodePatterns[i + 1]);
|
|
}
|
|
if (isWindows) {
|
|
url = url.replace(forwardSlashPattern, '\\');
|
|
}
|
|
return url;
|
|
};
|
|
exports.path.getHash = function getHash(path) {
|
|
var hashIndex = path.indexOf('#');
|
|
if (hashIndex >= 0) {
|
|
return path.substr(hashIndex);
|
|
}
|
|
return '';
|
|
};
|
|
exports.path.stripHash = function stripHash(path) {
|
|
var hashIndex = path.indexOf('#');
|
|
if (hashIndex >= 0) {
|
|
path = path.substr(0, hashIndex);
|
|
}
|
|
return path;
|
|
};
|
|
exports.path.extname = function extname(path) {
|
|
var lastDot = path.lastIndexOf('.');
|
|
if (lastDot >= 0) {
|
|
return path.substr(lastDot).toLowerCase();
|
|
}
|
|
return '';
|
|
};
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("171", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function isBuffer(arg) {
|
|
return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function';
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("172", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
if (typeof Object.create === 'function') {
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
ctor.super_ = superCtor;
|
|
ctor.prototype = Object.create(superCtor.prototype, {constructor: {
|
|
value: ctor,
|
|
enumerable: false,
|
|
writable: true,
|
|
configurable: true
|
|
}});
|
|
};
|
|
} else {
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
ctor.super_ = superCtor;
|
|
var TempCtor = function() {};
|
|
TempCtor.prototype = superCtor.prototype;
|
|
ctor.prototype = new TempCtor();
|
|
ctor.prototype.constructor = ctor;
|
|
};
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("124", ["172"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('172');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("173", ["171", "124", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
var formatRegExp = /%[sdj%]/g;
|
|
exports.format = function(f) {
|
|
if (!isString(f)) {
|
|
var objects = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
objects.push(inspect(arguments[i]));
|
|
}
|
|
return objects.join(' ');
|
|
}
|
|
var i = 1;
|
|
var args = arguments;
|
|
var len = args.length;
|
|
var str = String(f).replace(formatRegExp, function(x) {
|
|
if (x === '%%')
|
|
return '%';
|
|
if (i >= len)
|
|
return x;
|
|
switch (x) {
|
|
case '%s':
|
|
return String(args[i++]);
|
|
case '%d':
|
|
return Number(args[i++]);
|
|
case '%j':
|
|
try {
|
|
return JSON.stringify(args[i++]);
|
|
} catch (_) {
|
|
return '[Circular]';
|
|
}
|
|
default:
|
|
return x;
|
|
}
|
|
});
|
|
for (var x = args[i]; i < len; x = args[++i]) {
|
|
if (isNull(x) || !isObject(x)) {
|
|
str += ' ' + x;
|
|
} else {
|
|
str += ' ' + inspect(x);
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
exports.deprecate = function(fn, msg) {
|
|
if (isUndefined(global.process)) {
|
|
return function() {
|
|
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
};
|
|
}
|
|
if (process.noDeprecation === true) {
|
|
return fn;
|
|
}
|
|
var warned = false;
|
|
function deprecated() {
|
|
if (!warned) {
|
|
if (process.throwDeprecation) {
|
|
throw new Error(msg);
|
|
} else if (process.traceDeprecation) {
|
|
console.trace(msg);
|
|
} else {
|
|
console.error(msg);
|
|
}
|
|
warned = true;
|
|
}
|
|
return fn.apply(this, arguments);
|
|
}
|
|
return deprecated;
|
|
};
|
|
var debugs = {};
|
|
var debugEnviron;
|
|
exports.debuglog = function(set) {
|
|
if (isUndefined(debugEnviron))
|
|
debugEnviron = process.env.NODE_DEBUG || '';
|
|
set = set.toUpperCase();
|
|
if (!debugs[set]) {
|
|
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
|
var pid = process.pid;
|
|
debugs[set] = function() {
|
|
var msg = exports.format.apply(exports, arguments);
|
|
console.error('%s %d: %s', set, pid, msg);
|
|
};
|
|
} else {
|
|
debugs[set] = function() {};
|
|
}
|
|
}
|
|
return debugs[set];
|
|
};
|
|
function inspect(obj, opts) {
|
|
var ctx = {
|
|
seen: [],
|
|
stylize: stylizeNoColor
|
|
};
|
|
if (arguments.length >= 3)
|
|
ctx.depth = arguments[2];
|
|
if (arguments.length >= 4)
|
|
ctx.colors = arguments[3];
|
|
if (isBoolean(opts)) {
|
|
ctx.showHidden = opts;
|
|
} else if (opts) {
|
|
exports._extend(ctx, opts);
|
|
}
|
|
if (isUndefined(ctx.showHidden))
|
|
ctx.showHidden = false;
|
|
if (isUndefined(ctx.depth))
|
|
ctx.depth = 2;
|
|
if (isUndefined(ctx.colors))
|
|
ctx.colors = false;
|
|
if (isUndefined(ctx.customInspect))
|
|
ctx.customInspect = true;
|
|
if (ctx.colors)
|
|
ctx.stylize = stylizeWithColor;
|
|
return formatValue(ctx, obj, ctx.depth);
|
|
}
|
|
exports.inspect = inspect;
|
|
inspect.colors = {
|
|
'bold': [1, 22],
|
|
'italic': [3, 23],
|
|
'underline': [4, 24],
|
|
'inverse': [7, 27],
|
|
'white': [37, 39],
|
|
'grey': [90, 39],
|
|
'black': [30, 39],
|
|
'blue': [34, 39],
|
|
'cyan': [36, 39],
|
|
'green': [32, 39],
|
|
'magenta': [35, 39],
|
|
'red': [31, 39],
|
|
'yellow': [33, 39]
|
|
};
|
|
inspect.styles = {
|
|
'special': 'cyan',
|
|
'number': 'yellow',
|
|
'boolean': 'yellow',
|
|
'undefined': 'grey',
|
|
'null': 'bold',
|
|
'string': 'green',
|
|
'date': 'magenta',
|
|
'regexp': 'red'
|
|
};
|
|
function stylizeWithColor(str, styleType) {
|
|
var style = inspect.styles[styleType];
|
|
if (style) {
|
|
return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm';
|
|
} else {
|
|
return str;
|
|
}
|
|
}
|
|
function stylizeNoColor(str, styleType) {
|
|
return str;
|
|
}
|
|
function arrayToHash(array) {
|
|
var hash = {};
|
|
array.forEach(function(val, idx) {
|
|
hash[val] = true;
|
|
});
|
|
return hash;
|
|
}
|
|
function formatValue(ctx, value, recurseTimes) {
|
|
if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== exports.inspect && !(value.constructor && value.constructor.prototype === value)) {
|
|
var ret = value.inspect(recurseTimes, ctx);
|
|
if (!isString(ret)) {
|
|
ret = formatValue(ctx, ret, recurseTimes);
|
|
}
|
|
return ret;
|
|
}
|
|
var primitive = formatPrimitive(ctx, value);
|
|
if (primitive) {
|
|
return primitive;
|
|
}
|
|
var keys = Object.keys(value);
|
|
var visibleKeys = arrayToHash(keys);
|
|
if (ctx.showHidden) {
|
|
keys = Object.getOwnPropertyNames(value);
|
|
}
|
|
if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
return formatError(value);
|
|
}
|
|
if (keys.length === 0) {
|
|
if (isFunction(value)) {
|
|
var name = value.name ? ': ' + value.name : '';
|
|
return ctx.stylize('[Function' + name + ']', 'special');
|
|
}
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
}
|
|
if (isDate(value)) {
|
|
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
}
|
|
if (isError(value)) {
|
|
return formatError(value);
|
|
}
|
|
}
|
|
var base = '',
|
|
array = false,
|
|
braces = ['{', '}'];
|
|
if (isArray(value)) {
|
|
array = true;
|
|
braces = ['[', ']'];
|
|
}
|
|
if (isFunction(value)) {
|
|
var n = value.name ? ': ' + value.name : '';
|
|
base = ' [Function' + n + ']';
|
|
}
|
|
if (isRegExp(value)) {
|
|
base = ' ' + RegExp.prototype.toString.call(value);
|
|
}
|
|
if (isDate(value)) {
|
|
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
}
|
|
if (isError(value)) {
|
|
base = ' ' + formatError(value);
|
|
}
|
|
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
return braces[0] + base + braces[1];
|
|
}
|
|
if (recurseTimes < 0) {
|
|
if (isRegExp(value)) {
|
|
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
} else {
|
|
return ctx.stylize('[Object]', 'special');
|
|
}
|
|
}
|
|
ctx.seen.push(value);
|
|
var output;
|
|
if (array) {
|
|
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
} else {
|
|
output = keys.map(function(key) {
|
|
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
});
|
|
}
|
|
ctx.seen.pop();
|
|
return reduceToSingleString(output, base, braces);
|
|
}
|
|
function formatPrimitive(ctx, value) {
|
|
if (isUndefined(value))
|
|
return ctx.stylize('undefined', 'undefined');
|
|
if (isString(value)) {
|
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"') + '\'';
|
|
return ctx.stylize(simple, 'string');
|
|
}
|
|
if (isNumber(value))
|
|
return ctx.stylize('' + value, 'number');
|
|
if (isBoolean(value))
|
|
return ctx.stylize('' + value, 'boolean');
|
|
if (isNull(value))
|
|
return ctx.stylize('null', 'null');
|
|
}
|
|
function formatError(value) {
|
|
return '[' + Error.prototype.toString.call(value) + ']';
|
|
}
|
|
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
var output = [];
|
|
for (var i = 0,
|
|
l = value.length; i < l; ++i) {
|
|
if (hasOwnProperty(value, String(i))) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
|
} else {
|
|
output.push('');
|
|
}
|
|
}
|
|
keys.forEach(function(key) {
|
|
if (!key.match(/^\d+$/)) {
|
|
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
|
}
|
|
});
|
|
return output;
|
|
}
|
|
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
var name,
|
|
str,
|
|
desc;
|
|
desc = Object.getOwnPropertyDescriptor(value, key) || {value: value[key]};
|
|
if (desc.get) {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
} else {
|
|
str = ctx.stylize('[Getter]', 'special');
|
|
}
|
|
} else {
|
|
if (desc.set) {
|
|
str = ctx.stylize('[Setter]', 'special');
|
|
}
|
|
}
|
|
if (!hasOwnProperty(visibleKeys, key)) {
|
|
name = '[' + key + ']';
|
|
}
|
|
if (!str) {
|
|
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
if (isNull(recurseTimes)) {
|
|
str = formatValue(ctx, desc.value, null);
|
|
} else {
|
|
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
}
|
|
if (str.indexOf('\n') > -1) {
|
|
if (array) {
|
|
str = str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n').substr(2);
|
|
} else {
|
|
str = '\n' + str.split('\n').map(function(line) {
|
|
return ' ' + line;
|
|
}).join('\n');
|
|
}
|
|
}
|
|
} else {
|
|
str = ctx.stylize('[Circular]', 'special');
|
|
}
|
|
}
|
|
if (isUndefined(name)) {
|
|
if (array && key.match(/^\d+$/)) {
|
|
return str;
|
|
}
|
|
name = JSON.stringify('' + key);
|
|
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
name = name.substr(1, name.length - 2);
|
|
name = ctx.stylize(name, 'name');
|
|
} else {
|
|
name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
|
|
name = ctx.stylize(name, 'string');
|
|
}
|
|
}
|
|
return name + ': ' + str;
|
|
}
|
|
function reduceToSingleString(output, base, braces) {
|
|
var numLinesEst = 0;
|
|
var length = output.reduce(function(prev, cur) {
|
|
numLinesEst++;
|
|
if (cur.indexOf('\n') >= 0)
|
|
numLinesEst++;
|
|
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
}, 0);
|
|
if (length > 60) {
|
|
return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1];
|
|
}
|
|
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
}
|
|
function isArray(ar) {
|
|
return Array.isArray(ar);
|
|
}
|
|
exports.isArray = isArray;
|
|
function isBoolean(arg) {
|
|
return typeof arg === 'boolean';
|
|
}
|
|
exports.isBoolean = isBoolean;
|
|
function isNull(arg) {
|
|
return arg === null;
|
|
}
|
|
exports.isNull = isNull;
|
|
function isNullOrUndefined(arg) {
|
|
return arg == null;
|
|
}
|
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
exports.isNumber = isNumber;
|
|
function isString(arg) {
|
|
return typeof arg === 'string';
|
|
}
|
|
exports.isString = isString;
|
|
function isSymbol(arg) {
|
|
return typeof arg === 'symbol';
|
|
}
|
|
exports.isSymbol = isSymbol;
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
exports.isUndefined = isUndefined;
|
|
function isRegExp(re) {
|
|
return isObject(re) && objectToString(re) === '[object RegExp]';
|
|
}
|
|
exports.isRegExp = isRegExp;
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
exports.isObject = isObject;
|
|
function isDate(d) {
|
|
return isObject(d) && objectToString(d) === '[object Date]';
|
|
}
|
|
exports.isDate = isDate;
|
|
function isError(e) {
|
|
return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
}
|
|
exports.isError = isError;
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
exports.isFunction = isFunction;
|
|
function isPrimitive(arg) {
|
|
return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || typeof arg === 'undefined';
|
|
}
|
|
exports.isPrimitive = isPrimitive;
|
|
exports.isBuffer = $__require('171');
|
|
function objectToString(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
function pad(n) {
|
|
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
}
|
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
function timestamp() {
|
|
var d = new Date();
|
|
var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':');
|
|
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
}
|
|
exports.log = function() {
|
|
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
};
|
|
exports.inherits = $__require('124');
|
|
exports._extend = function(origin, add) {
|
|
if (!add || !isObject(add))
|
|
return origin;
|
|
var keys = Object.keys(add);
|
|
var i = keys.length;
|
|
while (i--) {
|
|
origin[keys[i]] = add[keys[i]];
|
|
}
|
|
return origin;
|
|
};
|
|
function hasOwnProperty(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("174", ["173"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('173');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("175", ["174"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('util') : $__require('174');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("107", ["175"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('175');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("176", ["107"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var util = $__require('107'),
|
|
slice = Array.prototype.slice;
|
|
module.exports = create(Error);
|
|
module.exports.error = create(Error);
|
|
module.exports.eval = create(EvalError);
|
|
module.exports.range = create(RangeError);
|
|
module.exports.reference = create(ReferenceError);
|
|
module.exports.syntax = create(SyntaxError);
|
|
module.exports.type = create(TypeError);
|
|
module.exports.uri = create(URIError);
|
|
module.exports.formatter = util.format;
|
|
function create(Klass) {
|
|
return function ono(err, props, message, params) {
|
|
var formattedMessage,
|
|
stack;
|
|
var formatter = module.exports.formatter;
|
|
if (typeof(err) === 'string') {
|
|
formattedMessage = formatter.apply(null, arguments);
|
|
err = props = undefined;
|
|
} else if (typeof(props) === 'string') {
|
|
formattedMessage = formatter.apply(null, slice.call(arguments, 1));
|
|
} else {
|
|
formattedMessage = formatter.apply(null, slice.call(arguments, 2));
|
|
}
|
|
if (!(err instanceof Error)) {
|
|
props = err;
|
|
err = undefined;
|
|
}
|
|
if (err) {
|
|
formattedMessage += (formattedMessage ? ' \n' : '') + err.message;
|
|
stack = err.stack;
|
|
}
|
|
var error = new Klass(formattedMessage);
|
|
extendError(error, stack, props);
|
|
return error;
|
|
};
|
|
}
|
|
function extendError(error, stack, props) {
|
|
if (stack) {
|
|
error.stack += ' \n\n' + stack;
|
|
}
|
|
if (props && typeof(props) === 'object') {
|
|
var keys = Object.keys(props);
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
error[key] = props[key];
|
|
}
|
|
}
|
|
error.toJSON = errorToJSON;
|
|
}
|
|
function errorToJSON() {
|
|
var json = {
|
|
name: this.name,
|
|
message: this.message
|
|
};
|
|
var keys = Object.keys(this);
|
|
keys = keys.concat(['description', 'number', 'fileName', 'lineNumber', 'columnNumber', 'stack']);
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
var value = this[key];
|
|
if (value !== undefined) {
|
|
json[key] = value;
|
|
}
|
|
}
|
|
return json;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("101", ["176"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('176');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("177", ["34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
(function(process) {
|
|
;
|
|
(function(root) {
|
|
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
var freeModule = typeof module == 'object' && module && !module.nodeType && module;
|
|
var freeGlobal = typeof global == 'object' && global;
|
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
|
|
root = freeGlobal;
|
|
}
|
|
var punycode,
|
|
maxInt = 2147483647,
|
|
base = 36,
|
|
tMin = 1,
|
|
tMax = 26,
|
|
skew = 38,
|
|
damp = 700,
|
|
initialBias = 72,
|
|
initialN = 128,
|
|
delimiter = '-',
|
|
regexPunycode = /^xn--/,
|
|
regexNonASCII = /[^\x20-\x7E]/,
|
|
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
|
|
errors = {
|
|
'overflow': 'Overflow: input needs wider integers to process',
|
|
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
'invalid-input': 'Invalid input'
|
|
},
|
|
baseMinusTMin = base - tMin,
|
|
floor = Math.floor,
|
|
stringFromCharCode = String.fromCharCode,
|
|
key;
|
|
function error(type) {
|
|
throw RangeError(errors[type]);
|
|
}
|
|
function map(array, fn) {
|
|
var length = array.length;
|
|
var result = [];
|
|
while (length--) {
|
|
result[length] = fn(array[length]);
|
|
}
|
|
return result;
|
|
}
|
|
function mapDomain(string, fn) {
|
|
var parts = string.split('@');
|
|
var result = '';
|
|
if (parts.length > 1) {
|
|
result = parts[0] + '@';
|
|
string = parts[1];
|
|
}
|
|
string = string.replace(regexSeparators, '\x2E');
|
|
var labels = string.split('.');
|
|
var encoded = map(labels, fn).join('.');
|
|
return result + encoded;
|
|
}
|
|
function ucs2decode(string) {
|
|
var output = [],
|
|
counter = 0,
|
|
length = string.length,
|
|
value,
|
|
extra;
|
|
while (counter < length) {
|
|
value = string.charCodeAt(counter++);
|
|
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
extra = string.charCodeAt(counter++);
|
|
if ((extra & 0xFC00) == 0xDC00) {
|
|
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
} else {
|
|
output.push(value);
|
|
counter--;
|
|
}
|
|
} else {
|
|
output.push(value);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
function ucs2encode(array) {
|
|
return map(array, function(value) {
|
|
var output = '';
|
|
if (value > 0xFFFF) {
|
|
value -= 0x10000;
|
|
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
|
value = 0xDC00 | value & 0x3FF;
|
|
}
|
|
output += stringFromCharCode(value);
|
|
return output;
|
|
}).join('');
|
|
}
|
|
function basicToDigit(codePoint) {
|
|
if (codePoint - 48 < 10) {
|
|
return codePoint - 22;
|
|
}
|
|
if (codePoint - 65 < 26) {
|
|
return codePoint - 65;
|
|
}
|
|
if (codePoint - 97 < 26) {
|
|
return codePoint - 97;
|
|
}
|
|
return base;
|
|
}
|
|
function digitToBasic(digit, flag) {
|
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
}
|
|
function adapt(delta, numPoints, firstTime) {
|
|
var k = 0;
|
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
delta += floor(delta / numPoints);
|
|
for (; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
delta = floor(delta / baseMinusTMin);
|
|
}
|
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
}
|
|
function decode(input) {
|
|
var output = [],
|
|
inputLength = input.length,
|
|
out,
|
|
i = 0,
|
|
n = initialN,
|
|
bias = initialBias,
|
|
basic,
|
|
j,
|
|
index,
|
|
oldi,
|
|
w,
|
|
k,
|
|
digit,
|
|
t,
|
|
baseMinusT;
|
|
basic = input.lastIndexOf(delimiter);
|
|
if (basic < 0) {
|
|
basic = 0;
|
|
}
|
|
for (j = 0; j < basic; ++j) {
|
|
if (input.charCodeAt(j) >= 0x80) {
|
|
error('not-basic');
|
|
}
|
|
output.push(input.charCodeAt(j));
|
|
}
|
|
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
for (oldi = i, w = 1, k = base; ; k += base) {
|
|
if (index >= inputLength) {
|
|
error('invalid-input');
|
|
}
|
|
digit = basicToDigit(input.charCodeAt(index++));
|
|
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
error('overflow');
|
|
}
|
|
i += digit * w;
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
if (digit < t) {
|
|
break;
|
|
}
|
|
baseMinusT = base - t;
|
|
if (w > floor(maxInt / baseMinusT)) {
|
|
error('overflow');
|
|
}
|
|
w *= baseMinusT;
|
|
}
|
|
out = output.length + 1;
|
|
bias = adapt(i - oldi, out, oldi == 0);
|
|
if (floor(i / out) > maxInt - n) {
|
|
error('overflow');
|
|
}
|
|
n += floor(i / out);
|
|
i %= out;
|
|
output.splice(i++, 0, n);
|
|
}
|
|
return ucs2encode(output);
|
|
}
|
|
function encode(input) {
|
|
var n,
|
|
delta,
|
|
handledCPCount,
|
|
basicLength,
|
|
bias,
|
|
j,
|
|
m,
|
|
q,
|
|
k,
|
|
t,
|
|
currentValue,
|
|
output = [],
|
|
inputLength,
|
|
handledCPCountPlusOne,
|
|
baseMinusT,
|
|
qMinusT;
|
|
input = ucs2decode(input);
|
|
inputLength = input.length;
|
|
n = initialN;
|
|
delta = 0;
|
|
bias = initialBias;
|
|
for (j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
if (currentValue < 0x80) {
|
|
output.push(stringFromCharCode(currentValue));
|
|
}
|
|
}
|
|
handledCPCount = basicLength = output.length;
|
|
if (basicLength) {
|
|
output.push(delimiter);
|
|
}
|
|
while (handledCPCount < inputLength) {
|
|
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
if (currentValue >= n && currentValue < m) {
|
|
m = currentValue;
|
|
}
|
|
}
|
|
handledCPCountPlusOne = handledCPCount + 1;
|
|
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
error('overflow');
|
|
}
|
|
delta += (m - n) * handledCPCountPlusOne;
|
|
n = m;
|
|
for (j = 0; j < inputLength; ++j) {
|
|
currentValue = input[j];
|
|
if (currentValue < n && ++delta > maxInt) {
|
|
error('overflow');
|
|
}
|
|
if (currentValue == n) {
|
|
for (q = delta, k = base; ; k += base) {
|
|
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
if (q < t) {
|
|
break;
|
|
}
|
|
qMinusT = q - t;
|
|
baseMinusT = base - t;
|
|
output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
|
|
q = floor(qMinusT / baseMinusT);
|
|
}
|
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
delta = 0;
|
|
++handledCPCount;
|
|
}
|
|
}
|
|
++delta;
|
|
++n;
|
|
}
|
|
return output.join('');
|
|
}
|
|
function toUnicode(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
});
|
|
}
|
|
function toASCII(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
|
|
});
|
|
}
|
|
punycode = {
|
|
'version': '1.3.2',
|
|
'ucs2': {
|
|
'decode': ucs2decode,
|
|
'encode': ucs2encode
|
|
},
|
|
'decode': decode,
|
|
'encode': encode,
|
|
'toASCII': toASCII,
|
|
'toUnicode': toUnicode
|
|
};
|
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
define('punycode', function() {
|
|
return punycode;
|
|
});
|
|
} else if (freeExports && freeModule) {
|
|
if (module.exports == freeExports) {
|
|
freeModule.exports = punycode;
|
|
} else {
|
|
for (key in punycode) {
|
|
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
}
|
|
}
|
|
} else {
|
|
root.punycode = punycode;
|
|
}
|
|
}(this));
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("178", ["177"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('177');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("179", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function hasOwnProperty(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
module.exports = function(qs, sep, eq, options) {
|
|
sep = sep || '&';
|
|
eq = eq || '=';
|
|
var obj = {};
|
|
if (typeof qs !== 'string' || qs.length === 0) {
|
|
return obj;
|
|
}
|
|
var regexp = /\+/g;
|
|
qs = qs.split(sep);
|
|
var maxKeys = 1000;
|
|
if (options && typeof options.maxKeys === 'number') {
|
|
maxKeys = options.maxKeys;
|
|
}
|
|
var len = qs.length;
|
|
if (maxKeys > 0 && len > maxKeys) {
|
|
len = maxKeys;
|
|
}
|
|
for (var i = 0; i < len; ++i) {
|
|
var x = qs[i].replace(regexp, '%20'),
|
|
idx = x.indexOf(eq),
|
|
kstr,
|
|
vstr,
|
|
k,
|
|
v;
|
|
if (idx >= 0) {
|
|
kstr = x.substr(0, idx);
|
|
vstr = x.substr(idx + 1);
|
|
} else {
|
|
kstr = x;
|
|
vstr = '';
|
|
}
|
|
k = decodeURIComponent(kstr);
|
|
v = decodeURIComponent(vstr);
|
|
if (!hasOwnProperty(obj, k)) {
|
|
obj[k] = v;
|
|
} else if (Array.isArray(obj[k])) {
|
|
obj[k].push(v);
|
|
} else {
|
|
obj[k] = [obj[k], v];
|
|
}
|
|
}
|
|
return obj;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17a", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var stringifyPrimitive = function(v) {
|
|
switch (typeof v) {
|
|
case 'string':
|
|
return v;
|
|
case 'boolean':
|
|
return v ? 'true' : 'false';
|
|
case 'number':
|
|
return isFinite(v) ? v : '';
|
|
default:
|
|
return '';
|
|
}
|
|
};
|
|
module.exports = function(obj, sep, eq, name) {
|
|
sep = sep || '&';
|
|
eq = eq || '=';
|
|
if (obj === null) {
|
|
obj = undefined;
|
|
}
|
|
if (typeof obj === 'object') {
|
|
return Object.keys(obj).map(function(k) {
|
|
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
|
if (Array.isArray(obj[k])) {
|
|
return obj[k].map(function(v) {
|
|
return ks + encodeURIComponent(stringifyPrimitive(v));
|
|
}).join(sep);
|
|
} else {
|
|
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
|
}
|
|
}).join(sep);
|
|
}
|
|
if (!name)
|
|
return '';
|
|
return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17b", ["179", "17a"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports.decode = exports.parse = $__require('179');
|
|
exports.encode = exports.stringify = $__require('17a');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17c", ["17b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('17b');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17d", ["178", "17c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var punycode = $__require('178');
|
|
exports.parse = urlParse;
|
|
exports.resolve = urlResolve;
|
|
exports.resolveObject = urlResolveObject;
|
|
exports.format = urlFormat;
|
|
exports.Url = Url;
|
|
function Url() {
|
|
this.protocol = null;
|
|
this.slashes = null;
|
|
this.auth = null;
|
|
this.host = null;
|
|
this.port = null;
|
|
this.hostname = null;
|
|
this.hash = null;
|
|
this.search = null;
|
|
this.query = null;
|
|
this.pathname = null;
|
|
this.path = null;
|
|
this.href = null;
|
|
}
|
|
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
|
portPattern = /:[0-9]*$/,
|
|
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
|
autoEscape = ['\''].concat(unwise),
|
|
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
|
hostEndingChars = ['/', '?', '#'],
|
|
hostnameMaxLen = 255,
|
|
hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/,
|
|
hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/,
|
|
unsafeProtocol = {
|
|
'javascript': true,
|
|
'javascript:': true
|
|
},
|
|
hostlessProtocol = {
|
|
'javascript': true,
|
|
'javascript:': true
|
|
},
|
|
slashedProtocol = {
|
|
'http': true,
|
|
'https': true,
|
|
'ftp': true,
|
|
'gopher': true,
|
|
'file': true,
|
|
'http:': true,
|
|
'https:': true,
|
|
'ftp:': true,
|
|
'gopher:': true,
|
|
'file:': true
|
|
},
|
|
querystring = $__require('17c');
|
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
if (url && isObject(url) && url instanceof Url)
|
|
return url;
|
|
var u = new Url;
|
|
u.parse(url, parseQueryString, slashesDenoteHost);
|
|
return u;
|
|
}
|
|
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
|
if (!isString(url)) {
|
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
}
|
|
var rest = url;
|
|
rest = rest.trim();
|
|
var proto = protocolPattern.exec(rest);
|
|
if (proto) {
|
|
proto = proto[0];
|
|
var lowerProto = proto.toLowerCase();
|
|
this.protocol = lowerProto;
|
|
rest = rest.substr(proto.length);
|
|
}
|
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
var slashes = rest.substr(0, 2) === '//';
|
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
rest = rest.substr(2);
|
|
this.slashes = true;
|
|
}
|
|
}
|
|
if (!hostlessProtocol[proto] && (slashes || (proto && !slashedProtocol[proto]))) {
|
|
var hostEnd = -1;
|
|
for (var i = 0; i < hostEndingChars.length; i++) {
|
|
var hec = rest.indexOf(hostEndingChars[i]);
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
hostEnd = hec;
|
|
}
|
|
var auth,
|
|
atSign;
|
|
if (hostEnd === -1) {
|
|
atSign = rest.lastIndexOf('@');
|
|
} else {
|
|
atSign = rest.lastIndexOf('@', hostEnd);
|
|
}
|
|
if (atSign !== -1) {
|
|
auth = rest.slice(0, atSign);
|
|
rest = rest.slice(atSign + 1);
|
|
this.auth = decodeURIComponent(auth);
|
|
}
|
|
hostEnd = -1;
|
|
for (var i = 0; i < nonHostChars.length; i++) {
|
|
var hec = rest.indexOf(nonHostChars[i]);
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
hostEnd = hec;
|
|
}
|
|
if (hostEnd === -1)
|
|
hostEnd = rest.length;
|
|
this.host = rest.slice(0, hostEnd);
|
|
rest = rest.slice(hostEnd);
|
|
this.parseHost();
|
|
this.hostname = this.hostname || '';
|
|
var ipv6Hostname = this.hostname[0] === '[' && this.hostname[this.hostname.length - 1] === ']';
|
|
if (!ipv6Hostname) {
|
|
var hostparts = this.hostname.split(/\./);
|
|
for (var i = 0,
|
|
l = hostparts.length; i < l; i++) {
|
|
var part = hostparts[i];
|
|
if (!part)
|
|
continue;
|
|
if (!part.match(hostnamePartPattern)) {
|
|
var newpart = '';
|
|
for (var j = 0,
|
|
k = part.length; j < k; j++) {
|
|
if (part.charCodeAt(j) > 127) {
|
|
newpart += 'x';
|
|
} else {
|
|
newpart += part[j];
|
|
}
|
|
}
|
|
if (!newpart.match(hostnamePartPattern)) {
|
|
var validParts = hostparts.slice(0, i);
|
|
var notHost = hostparts.slice(i + 1);
|
|
var bit = part.match(hostnamePartStart);
|
|
if (bit) {
|
|
validParts.push(bit[1]);
|
|
notHost.unshift(bit[2]);
|
|
}
|
|
if (notHost.length) {
|
|
rest = '/' + notHost.join('.') + rest;
|
|
}
|
|
this.hostname = validParts.join('.');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.hostname.length > hostnameMaxLen) {
|
|
this.hostname = '';
|
|
} else {
|
|
this.hostname = this.hostname.toLowerCase();
|
|
}
|
|
if (!ipv6Hostname) {
|
|
var domainArray = this.hostname.split('.');
|
|
var newOut = [];
|
|
for (var i = 0; i < domainArray.length; ++i) {
|
|
var s = domainArray[i];
|
|
newOut.push(s.match(/[^A-Za-z0-9_-]/) ? 'xn--' + punycode.encode(s) : s);
|
|
}
|
|
this.hostname = newOut.join('.');
|
|
}
|
|
var p = this.port ? ':' + this.port : '';
|
|
var h = this.hostname || '';
|
|
this.host = h + p;
|
|
this.href += this.host;
|
|
if (ipv6Hostname) {
|
|
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
|
if (rest[0] !== '/') {
|
|
rest = '/' + rest;
|
|
}
|
|
}
|
|
}
|
|
if (!unsafeProtocol[lowerProto]) {
|
|
for (var i = 0,
|
|
l = autoEscape.length; i < l; i++) {
|
|
var ae = autoEscape[i];
|
|
var esc = encodeURIComponent(ae);
|
|
if (esc === ae) {
|
|
esc = escape(ae);
|
|
}
|
|
rest = rest.split(ae).join(esc);
|
|
}
|
|
}
|
|
var hash = rest.indexOf('#');
|
|
if (hash !== -1) {
|
|
this.hash = rest.substr(hash);
|
|
rest = rest.slice(0, hash);
|
|
}
|
|
var qm = rest.indexOf('?');
|
|
if (qm !== -1) {
|
|
this.search = rest.substr(qm);
|
|
this.query = rest.substr(qm + 1);
|
|
if (parseQueryString) {
|
|
this.query = querystring.parse(this.query);
|
|
}
|
|
rest = rest.slice(0, qm);
|
|
} else if (parseQueryString) {
|
|
this.search = '';
|
|
this.query = {};
|
|
}
|
|
if (rest)
|
|
this.pathname = rest;
|
|
if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
|
|
this.pathname = '/';
|
|
}
|
|
if (this.pathname || this.search) {
|
|
var p = this.pathname || '';
|
|
var s = this.search || '';
|
|
this.path = p + s;
|
|
}
|
|
this.href = this.format();
|
|
return this;
|
|
};
|
|
function urlFormat(obj) {
|
|
if (isString(obj))
|
|
obj = urlParse(obj);
|
|
if (!(obj instanceof Url))
|
|
return Url.prototype.format.call(obj);
|
|
return obj.format();
|
|
}
|
|
Url.prototype.format = function() {
|
|
var auth = this.auth || '';
|
|
if (auth) {
|
|
auth = encodeURIComponent(auth);
|
|
auth = auth.replace(/%3A/i, ':');
|
|
auth += '@';
|
|
}
|
|
var protocol = this.protocol || '',
|
|
pathname = this.pathname || '',
|
|
hash = this.hash || '',
|
|
host = false,
|
|
query = '';
|
|
if (this.host) {
|
|
host = auth + this.host;
|
|
} else if (this.hostname) {
|
|
host = auth + (this.hostname.indexOf(':') === -1 ? this.hostname : '[' + this.hostname + ']');
|
|
if (this.port) {
|
|
host += ':' + this.port;
|
|
}
|
|
}
|
|
if (this.query && isObject(this.query) && Object.keys(this.query).length) {
|
|
query = querystring.stringify(this.query);
|
|
}
|
|
var search = this.search || (query && ('?' + query)) || '';
|
|
if (protocol && protocol.substr(-1) !== ':')
|
|
protocol += ':';
|
|
if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
host = '//' + (host || '');
|
|
if (pathname && pathname.charAt(0) !== '/')
|
|
pathname = '/' + pathname;
|
|
} else if (!host) {
|
|
host = '';
|
|
}
|
|
if (hash && hash.charAt(0) !== '#')
|
|
hash = '#' + hash;
|
|
if (search && search.charAt(0) !== '?')
|
|
search = '?' + search;
|
|
pathname = pathname.replace(/[?#]/g, function(match) {
|
|
return encodeURIComponent(match);
|
|
});
|
|
search = search.replace('#', '%23');
|
|
return protocol + host + pathname + search + hash;
|
|
};
|
|
function urlResolve(source, relative) {
|
|
return urlParse(source, false, true).resolve(relative);
|
|
}
|
|
Url.prototype.resolve = function(relative) {
|
|
return this.resolveObject(urlParse(relative, false, true)).format();
|
|
};
|
|
function urlResolveObject(source, relative) {
|
|
if (!source)
|
|
return relative;
|
|
return urlParse(source, false, true).resolveObject(relative);
|
|
}
|
|
Url.prototype.resolveObject = function(relative) {
|
|
if (isString(relative)) {
|
|
var rel = new Url();
|
|
rel.parse(relative, false, true);
|
|
relative = rel;
|
|
}
|
|
var result = new Url();
|
|
Object.keys(this).forEach(function(k) {
|
|
result[k] = this[k];
|
|
}, this);
|
|
result.hash = relative.hash;
|
|
if (relative.href === '') {
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (relative.slashes && !relative.protocol) {
|
|
Object.keys(relative).forEach(function(k) {
|
|
if (k !== 'protocol')
|
|
result[k] = relative[k];
|
|
});
|
|
if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
|
|
result.path = result.pathname = '/';
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (relative.protocol && relative.protocol !== result.protocol) {
|
|
if (!slashedProtocol[relative.protocol]) {
|
|
Object.keys(relative).forEach(function(k) {
|
|
result[k] = relative[k];
|
|
});
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
result.protocol = relative.protocol;
|
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
var relPath = (relative.pathname || '').split('/');
|
|
while (relPath.length && !(relative.host = relPath.shift()))
|
|
;
|
|
if (!relative.host)
|
|
relative.host = '';
|
|
if (!relative.hostname)
|
|
relative.hostname = '';
|
|
if (relPath[0] !== '')
|
|
relPath.unshift('');
|
|
if (relPath.length < 2)
|
|
relPath.unshift('');
|
|
result.pathname = relPath.join('/');
|
|
} else {
|
|
result.pathname = relative.pathname;
|
|
}
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
result.host = relative.host || '';
|
|
result.auth = relative.auth;
|
|
result.hostname = relative.hostname || relative.host;
|
|
result.port = relative.port;
|
|
if (result.pathname || result.search) {
|
|
var p = result.pathname || '';
|
|
var s = result.search || '';
|
|
result.path = p + s;
|
|
}
|
|
result.slashes = result.slashes || relative.slashes;
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
|
isRelAbs = (relative.host || relative.pathname && relative.pathname.charAt(0) === '/'),
|
|
mustEndAbs = (isRelAbs || isSourceAbs || (result.host && relative.pathname)),
|
|
removeAllDots = mustEndAbs,
|
|
srcPath = result.pathname && result.pathname.split('/') || [],
|
|
relPath = relative.pathname && relative.pathname.split('/') || [],
|
|
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
if (psychotic) {
|
|
result.hostname = '';
|
|
result.port = null;
|
|
if (result.host) {
|
|
if (srcPath[0] === '')
|
|
srcPath[0] = result.host;
|
|
else
|
|
srcPath.unshift(result.host);
|
|
}
|
|
result.host = '';
|
|
if (relative.protocol) {
|
|
relative.hostname = null;
|
|
relative.port = null;
|
|
if (relative.host) {
|
|
if (relPath[0] === '')
|
|
relPath[0] = relative.host;
|
|
else
|
|
relPath.unshift(relative.host);
|
|
}
|
|
relative.host = null;
|
|
}
|
|
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
|
}
|
|
if (isRelAbs) {
|
|
result.host = (relative.host || relative.host === '') ? relative.host : result.host;
|
|
result.hostname = (relative.hostname || relative.hostname === '') ? relative.hostname : result.hostname;
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
srcPath = relPath;
|
|
} else if (relPath.length) {
|
|
if (!srcPath)
|
|
srcPath = [];
|
|
srcPath.pop();
|
|
srcPath = srcPath.concat(relPath);
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
} else if (!isNullOrUndefined(relative.search)) {
|
|
if (psychotic) {
|
|
result.hostname = result.host = srcPath.shift();
|
|
var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
|
|
if (authInHost) {
|
|
result.auth = authInHost.shift();
|
|
result.host = result.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (!srcPath.length) {
|
|
result.pathname = null;
|
|
if (result.search) {
|
|
result.path = '/' + result.search;
|
|
} else {
|
|
result.path = null;
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
var last = srcPath.slice(-1)[0];
|
|
var hasTrailingSlash = ((result.host || relative.host) && (last === '.' || last === '..') || last === '');
|
|
var up = 0;
|
|
for (var i = srcPath.length; i >= 0; i--) {
|
|
last = srcPath[i];
|
|
if (last == '.') {
|
|
srcPath.splice(i, 1);
|
|
} else if (last === '..') {
|
|
srcPath.splice(i, 1);
|
|
up++;
|
|
} else if (up) {
|
|
srcPath.splice(i, 1);
|
|
up--;
|
|
}
|
|
}
|
|
if (!mustEndAbs && !removeAllDots) {
|
|
for (; up--; up) {
|
|
srcPath.unshift('..');
|
|
}
|
|
}
|
|
if (mustEndAbs && srcPath[0] !== '' && (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
|
srcPath.unshift('');
|
|
}
|
|
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
|
srcPath.push('');
|
|
}
|
|
var isAbsolute = srcPath[0] === '' || (srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
if (psychotic) {
|
|
result.hostname = result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : '';
|
|
var authInHost = result.host && result.host.indexOf('@') > 0 ? result.host.split('@') : false;
|
|
if (authInHost) {
|
|
result.auth = authInHost.shift();
|
|
result.host = result.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
|
if (mustEndAbs && !isAbsolute) {
|
|
srcPath.unshift('');
|
|
}
|
|
if (!srcPath.length) {
|
|
result.pathname = null;
|
|
result.path = null;
|
|
} else {
|
|
result.pathname = srcPath.join('/');
|
|
}
|
|
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
result.path = (result.pathname ? result.pathname : '') + (result.search ? result.search : '');
|
|
}
|
|
result.auth = relative.auth || result.auth;
|
|
result.slashes = result.slashes || relative.slashes;
|
|
result.href = result.format();
|
|
return result;
|
|
};
|
|
Url.prototype.parseHost = function() {
|
|
var host = this.host;
|
|
var port = portPattern.exec(host);
|
|
if (port) {
|
|
port = port[0];
|
|
if (port !== ':') {
|
|
this.port = port.substr(1);
|
|
}
|
|
host = host.substr(0, host.length - port.length);
|
|
}
|
|
if (host)
|
|
this.hostname = host;
|
|
};
|
|
function isString(arg) {
|
|
return typeof arg === "string";
|
|
}
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
function isNull(arg) {
|
|
return arg === null;
|
|
}
|
|
function isNullOrUndefined(arg) {
|
|
return arg == null;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17e", ["17d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('17d');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("17f", ["17e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? $__System._nodeRequire('url') : $__require('17e');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("12f", ["17f"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('17f');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("162", ["13a", "13c", "10e", "101", "12f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $Ref = $__require('13a'),
|
|
Pointer = $__require('13c'),
|
|
util = $__require('10e'),
|
|
ono = $__require('101'),
|
|
url = $__require('12f');
|
|
module.exports = dereference;
|
|
function dereference(parser, options) {
|
|
util.debug('Dereferencing $ref pointers in %s', parser._basePath);
|
|
parser.$refs.circular = false;
|
|
crawl(parser.schema, parser._basePath, [], parser.$refs, options);
|
|
}
|
|
function crawl(obj, path, parents, $refs, options) {
|
|
var isCircular = false;
|
|
if (obj && typeof obj === 'object') {
|
|
parents.push(obj);
|
|
Object.keys(obj).forEach(function(key) {
|
|
var keyPath = Pointer.join(path, key);
|
|
var value = obj[key];
|
|
var circular = false;
|
|
if ($Ref.isAllowed$Ref(value, options)) {
|
|
util.debug('Dereferencing $ref pointer "%s" at %s', value.$ref, keyPath);
|
|
var $refPath = url.resolve(path, value.$ref);
|
|
var pointer = $refs._resolve($refPath, options);
|
|
circular = pointer.circular || parents.indexOf(pointer.value) !== -1;
|
|
circular && foundCircularReference(keyPath, $refs, options);
|
|
var dereferencedValue = getDereferencedValue(value, pointer.value);
|
|
if (!circular) {
|
|
circular = crawl(dereferencedValue, pointer.path, parents, $refs, options);
|
|
}
|
|
if (!circular || options.$refs.circular === true) {
|
|
obj[key] = dereferencedValue;
|
|
}
|
|
} else {
|
|
if (parents.indexOf(value) === -1) {
|
|
circular = crawl(value, keyPath, parents, $refs, options);
|
|
} else {
|
|
circular = foundCircularReference(keyPath, $refs, options);
|
|
}
|
|
}
|
|
isCircular = isCircular || circular;
|
|
});
|
|
parents.pop();
|
|
}
|
|
return isCircular;
|
|
}
|
|
function getDereferencedValue(currentValue, resolvedValue) {
|
|
if (resolvedValue && typeof resolvedValue === 'object' && Object.keys(currentValue).length > 1) {
|
|
var merged = {};
|
|
Object.keys(currentValue).forEach(function(key) {
|
|
if (key !== '$ref') {
|
|
merged[key] = currentValue[key];
|
|
}
|
|
});
|
|
Object.keys(resolvedValue).forEach(function(key) {
|
|
if (!(key in merged)) {
|
|
merged[key] = resolvedValue[key];
|
|
}
|
|
});
|
|
return merged;
|
|
} else {
|
|
return resolvedValue;
|
|
}
|
|
}
|
|
function foundCircularReference(keyPath, $refs, options) {
|
|
$refs.circular = true;
|
|
if (!options.$refs.circular) {
|
|
throw ono.reference('Circular $ref pointer found at %s', keyPath);
|
|
}
|
|
return true;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("180", ["100", "105", "102", "108", "10a", "13f", "101", "163", "162"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var validateSchema = $__require('100'),
|
|
validateSpec = $__require('105'),
|
|
util = $__require('102'),
|
|
Options = $__require('108'),
|
|
Promise = $__require('10a'),
|
|
maybe = $__require('13f'),
|
|
ono = $__require('101'),
|
|
$RefParser = $__require('163'),
|
|
dereference = $__require('162');
|
|
module.exports = SwaggerParser;
|
|
function SwaggerParser() {
|
|
$RefParser.apply(this, arguments);
|
|
}
|
|
util.inherits(SwaggerParser, $RefParser);
|
|
SwaggerParser.YAML = $RefParser.YAML;
|
|
SwaggerParser.parse = $RefParser.parse;
|
|
SwaggerParser.resolve = $RefParser.resolve;
|
|
SwaggerParser.bundle = $RefParser.bundle;
|
|
SwaggerParser.dereference = $RefParser.dereference;
|
|
Object.defineProperty(SwaggerParser.prototype, 'api', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: function() {
|
|
return this.schema;
|
|
}
|
|
});
|
|
SwaggerParser.prototype.parse = function(api, options, callback) {
|
|
if (typeof options === 'function') {
|
|
callback = options;
|
|
options = undefined;
|
|
}
|
|
options = new Options(options);
|
|
var apiParam = api;
|
|
return $RefParser.prototype.parse.call(this, api, options).then(function(schema) {
|
|
var supportedSwaggerVersions = ['2.0'];
|
|
if (schema.swagger === undefined || schema.info === undefined || schema.paths === undefined) {
|
|
throw ono.syntax('%s is not a valid Swagger API definition', apiParam);
|
|
} else if (typeof schema.swagger === 'number') {
|
|
throw ono.syntax('Swagger version number must be a string (e.g. "2.0") not a number.');
|
|
} else if (typeof schema.info.version === 'number') {
|
|
throw ono.syntax('API version number must be a string (e.g. "1.0.0") not a number.');
|
|
} else if (supportedSwaggerVersions.indexOf(schema.swagger) === -1) {
|
|
throw ono.syntax('Unsupported Swagger version: %d. Swagger Parser only supports version %s', schema.swagger, supportedSwaggerVersions.join(', '));
|
|
}
|
|
return maybe(callback, Promise.resolve(schema));
|
|
}).catch(function(err) {
|
|
return maybe(callback, Promise.reject(err));
|
|
});
|
|
};
|
|
SwaggerParser.validate = function(api, options, callback) {
|
|
var Class = this;
|
|
return new Class().validate(api, options, callback);
|
|
};
|
|
SwaggerParser.prototype.validate = function(api, options, callback) {
|
|
if (typeof options === 'function') {
|
|
callback = options;
|
|
options = undefined;
|
|
}
|
|
options = new Options(options);
|
|
var me = this;
|
|
var circular$RefOption = options.$refs.circular;
|
|
options.validate.schema && (options.$refs.circular = 'ignore');
|
|
return this.dereference(api, options).then(function() {
|
|
options.$refs.circular = circular$RefOption;
|
|
if (options.validate.schema) {
|
|
validateSchema(me.api);
|
|
if (me.$refs.circular) {
|
|
if (circular$RefOption === true) {
|
|
dereference(me, options);
|
|
} else if (circular$RefOption === false) {
|
|
throw ono.reference('The API contains circular references');
|
|
}
|
|
}
|
|
}
|
|
if (options.validate.spec) {
|
|
validateSpec(me.api);
|
|
}
|
|
return maybe(callback, Promise.resolve(me.schema));
|
|
}).catch(function(err) {
|
|
return maybe(callback, Promise.reject(err));
|
|
});
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("181", ["180"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('180');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("de", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("182", ["183", "184"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toInteger = $__require('183'),
|
|
defined = $__require('184');
|
|
module.exports = function(TO_STRING) {
|
|
return function(that, pos) {
|
|
var s = String(defined(that)),
|
|
i = toInteger(pos),
|
|
l = s.length,
|
|
a,
|
|
b;
|
|
if (i < 0 || i >= l)
|
|
return TO_STRING ? '' : undefined;
|
|
a = s.charCodeAt(i);
|
|
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
|
};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("30", ["182", "185"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $at = $__require('182')(true);
|
|
$__require('185')(String, 'String', function(iterated) {
|
|
this._t = String(iterated);
|
|
this._i = 0;
|
|
}, function() {
|
|
var O = this._t,
|
|
index = this._i,
|
|
point;
|
|
if (index >= O.length)
|
|
return {
|
|
value: undefined,
|
|
done: true
|
|
};
|
|
point = $at(O, index);
|
|
this._i += point.length;
|
|
return {
|
|
value: point,
|
|
done: false
|
|
};
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("186", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function() {};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("187", ["186", "188", "2c", "189", "185"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var addToUnscopables = $__require('186'),
|
|
step = $__require('188'),
|
|
Iterators = $__require('2c'),
|
|
toIObject = $__require('189');
|
|
module.exports = $__require('185')(Array, 'Array', function(iterated, kind) {
|
|
this._t = toIObject(iterated);
|
|
this._i = 0;
|
|
this._k = kind;
|
|
}, function() {
|
|
var O = this._t,
|
|
kind = this._k,
|
|
index = this._i++;
|
|
if (!O || index >= O.length) {
|
|
this._t = undefined;
|
|
return step(1);
|
|
}
|
|
if (kind == 'keys')
|
|
return step(0, index);
|
|
if (kind == 'values')
|
|
return step(0, O[index]);
|
|
return step(0, [index, O[index]]);
|
|
}, 'values');
|
|
Iterators.Arguments = Iterators.Array;
|
|
addToUnscopables('keys');
|
|
addToUnscopables('values');
|
|
addToUnscopables('entries');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2f", ["187", "2c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('187');
|
|
var Iterators = $__require('2c');
|
|
Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d5", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18a", ["99", "18b", "db", "18c", "2b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99'),
|
|
descriptor = $__require('18b'),
|
|
setToStringTag = $__require('db'),
|
|
IteratorPrototype = {};
|
|
$__require('18c')(IteratorPrototype, $__require('2b')('iterator'), function() {
|
|
return this;
|
|
});
|
|
module.exports = function(Constructor, NAME, next) {
|
|
Constructor.prototype = $.create(IteratorPrototype, {next: descriptor(1, next)});
|
|
setToStringTag(Constructor, NAME + ' Iterator');
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("185", ["d5", "8f", "18d", "18c", "18e", "2c", "18a", "db", "99", "2b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var LIBRARY = $__require('d5'),
|
|
$export = $__require('8f'),
|
|
redefine = $__require('18d'),
|
|
hide = $__require('18c'),
|
|
has = $__require('18e'),
|
|
Iterators = $__require('2c'),
|
|
$iterCreate = $__require('18a'),
|
|
setToStringTag = $__require('db'),
|
|
getProto = $__require('99').getProto,
|
|
ITERATOR = $__require('2b')('iterator'),
|
|
BUGGY = !([].keys && 'next' in [].keys()),
|
|
FF_ITERATOR = '@@iterator',
|
|
KEYS = 'keys',
|
|
VALUES = 'values';
|
|
var returnThis = function() {
|
|
return this;
|
|
};
|
|
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
|
$iterCreate(Constructor, NAME, next);
|
|
var getMethod = function(kind) {
|
|
if (!BUGGY && kind in proto)
|
|
return proto[kind];
|
|
switch (kind) {
|
|
case KEYS:
|
|
return function keys() {
|
|
return new Constructor(this, kind);
|
|
};
|
|
case VALUES:
|
|
return function values() {
|
|
return new Constructor(this, kind);
|
|
};
|
|
}
|
|
return function entries() {
|
|
return new Constructor(this, kind);
|
|
};
|
|
};
|
|
var TAG = NAME + ' Iterator',
|
|
DEF_VALUES = DEFAULT == VALUES,
|
|
VALUES_BUG = false,
|
|
proto = Base.prototype,
|
|
$native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT],
|
|
$default = $native || getMethod(DEFAULT),
|
|
methods,
|
|
key;
|
|
if ($native) {
|
|
var IteratorPrototype = getProto($default.call(new Base));
|
|
setToStringTag(IteratorPrototype, TAG, true);
|
|
if (!LIBRARY && has(proto, FF_ITERATOR))
|
|
hide(IteratorPrototype, ITERATOR, returnThis);
|
|
if (DEF_VALUES && $native.name !== VALUES) {
|
|
VALUES_BUG = true;
|
|
$default = function values() {
|
|
return $native.call(this);
|
|
};
|
|
}
|
|
}
|
|
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
|
|
hide(proto, ITERATOR, $default);
|
|
}
|
|
Iterators[NAME] = $default;
|
|
Iterators[TAG] = returnThis;
|
|
if (DEFAULT) {
|
|
methods = {
|
|
values: DEF_VALUES ? $default : getMethod(VALUES),
|
|
keys: IS_SET ? $default : getMethod(KEYS),
|
|
entries: !DEF_VALUES ? $default : getMethod('entries')
|
|
};
|
|
if (FORCED)
|
|
for (key in methods) {
|
|
if (!(key in proto))
|
|
redefine(proto, key, methods[key]);
|
|
}
|
|
else
|
|
$export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
|
}
|
|
return methods;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("188", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(done, value) {
|
|
return {
|
|
value: value,
|
|
done: !!done
|
|
};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("dc", ["2d", "99", "d9", "2b"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var core = $__require('2d'),
|
|
$ = $__require('99'),
|
|
DESCRIPTORS = $__require('d9'),
|
|
SPECIES = $__require('2b')('species');
|
|
module.exports = function(KEY) {
|
|
var C = core[KEY];
|
|
if (DESCRIPTORS && C && !C[SPECIES])
|
|
$.setDesc(C, SPECIES, {
|
|
configurable: true,
|
|
get: function() {
|
|
return this;
|
|
}
|
|
});
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e2", ["99", "18c", "da", "8e", "d6", "184", "d7", "185", "188", "18f", "18e", "d0", "dc", "d9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99'),
|
|
hide = $__require('18c'),
|
|
redefineAll = $__require('da'),
|
|
ctx = $__require('8e'),
|
|
strictNew = $__require('d6'),
|
|
defined = $__require('184'),
|
|
forOf = $__require('d7'),
|
|
$iterDefine = $__require('185'),
|
|
step = $__require('188'),
|
|
ID = $__require('18f')('id'),
|
|
$has = $__require('18e'),
|
|
isObject = $__require('d0'),
|
|
setSpecies = $__require('dc'),
|
|
DESCRIPTORS = $__require('d9'),
|
|
isExtensible = Object.isExtensible || isObject,
|
|
SIZE = DESCRIPTORS ? '_s' : 'size',
|
|
id = 0;
|
|
var fastKey = function(it, create) {
|
|
if (!isObject(it))
|
|
return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
|
|
if (!$has(it, ID)) {
|
|
if (!isExtensible(it))
|
|
return 'F';
|
|
if (!create)
|
|
return 'E';
|
|
hide(it, ID, ++id);
|
|
}
|
|
return 'O' + it[ID];
|
|
};
|
|
var getEntry = function(that, key) {
|
|
var index = fastKey(key),
|
|
entry;
|
|
if (index !== 'F')
|
|
return that._i[index];
|
|
for (entry = that._f; entry; entry = entry.n) {
|
|
if (entry.k == key)
|
|
return entry;
|
|
}
|
|
};
|
|
module.exports = {
|
|
getConstructor: function(wrapper, NAME, IS_MAP, ADDER) {
|
|
var C = wrapper(function(that, iterable) {
|
|
strictNew(that, C, NAME);
|
|
that._i = $.create(null);
|
|
that._f = undefined;
|
|
that._l = undefined;
|
|
that[SIZE] = 0;
|
|
if (iterable != undefined)
|
|
forOf(iterable, IS_MAP, that[ADDER], that);
|
|
});
|
|
redefineAll(C.prototype, {
|
|
clear: function clear() {
|
|
for (var that = this,
|
|
data = that._i,
|
|
entry = that._f; entry; entry = entry.n) {
|
|
entry.r = true;
|
|
if (entry.p)
|
|
entry.p = entry.p.n = undefined;
|
|
delete data[entry.i];
|
|
}
|
|
that._f = that._l = undefined;
|
|
that[SIZE] = 0;
|
|
},
|
|
'delete': function(key) {
|
|
var that = this,
|
|
entry = getEntry(that, key);
|
|
if (entry) {
|
|
var next = entry.n,
|
|
prev = entry.p;
|
|
delete that._i[entry.i];
|
|
entry.r = true;
|
|
if (prev)
|
|
prev.n = next;
|
|
if (next)
|
|
next.p = prev;
|
|
if (that._f == entry)
|
|
that._f = next;
|
|
if (that._l == entry)
|
|
that._l = prev;
|
|
that[SIZE]--;
|
|
}
|
|
return !!entry;
|
|
},
|
|
forEach: function forEach(callbackfn) {
|
|
var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3),
|
|
entry;
|
|
while (entry = entry ? entry.n : this._f) {
|
|
f(entry.v, entry.k, this);
|
|
while (entry && entry.r)
|
|
entry = entry.p;
|
|
}
|
|
},
|
|
has: function has(key) {
|
|
return !!getEntry(this, key);
|
|
}
|
|
});
|
|
if (DESCRIPTORS)
|
|
$.setDesc(C.prototype, 'size', {get: function() {
|
|
return defined(this[SIZE]);
|
|
}});
|
|
return C;
|
|
},
|
|
def: function(that, key, value) {
|
|
var entry = getEntry(that, key),
|
|
prev,
|
|
index;
|
|
if (entry) {
|
|
entry.v = value;
|
|
} else {
|
|
that._l = entry = {
|
|
i: index = fastKey(key, true),
|
|
k: key,
|
|
v: value,
|
|
p: prev = that._l,
|
|
n: undefined,
|
|
r: false
|
|
};
|
|
if (!that._f)
|
|
that._f = entry;
|
|
if (prev)
|
|
prev.n = entry;
|
|
that[SIZE]++;
|
|
if (index !== 'F')
|
|
that._i[index] = entry;
|
|
}
|
|
return that;
|
|
},
|
|
getEntry: getEntry,
|
|
setStrong: function(C, NAME, IS_MAP) {
|
|
$iterDefine(C, NAME, function(iterated, kind) {
|
|
this._t = iterated;
|
|
this._k = kind;
|
|
this._l = undefined;
|
|
}, function() {
|
|
var that = this,
|
|
kind = that._k,
|
|
entry = that._l;
|
|
while (entry && entry.r)
|
|
entry = entry.p;
|
|
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
|
|
that._t = undefined;
|
|
return step(1);
|
|
}
|
|
if (kind == 'keys')
|
|
return step(0, entry.k);
|
|
if (kind == 'values')
|
|
return step(0, entry.v);
|
|
return step(0, [entry.k, entry.v]);
|
|
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
|
setSpecies(NAME);
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18b", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(bitmap, value) {
|
|
return {
|
|
enumerable: !(bitmap & 1),
|
|
configurable: !(bitmap & 2),
|
|
writable: !(bitmap & 4),
|
|
value: value
|
|
};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18c", ["99", "18b", "d9"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99'),
|
|
createDesc = $__require('18b');
|
|
module.exports = $__require('d9') ? function(object, key, value) {
|
|
return $.setDesc(object, key, createDesc(1, value));
|
|
} : function(object, key, value) {
|
|
object[key] = value;
|
|
return object;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18d", ["18c"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('18c');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("da", ["18d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var redefine = $__require('18d');
|
|
module.exports = function(target, src) {
|
|
for (var key in src)
|
|
redefine(target, key, src[key]);
|
|
return target;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d6", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(it, Constructor, name) {
|
|
if (!(it instanceof Constructor))
|
|
throw TypeError(name + ": use the 'new' operator!");
|
|
return it;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18e", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
module.exports = function(it, key) {
|
|
return hasOwnProperty.call(it, key);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("db", ["99", "18e", "2b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var def = $__require('99').setDesc,
|
|
has = $__require('18e'),
|
|
TAG = $__require('2b')('toStringTag');
|
|
module.exports = function(it, tag, stat) {
|
|
if (it && !has(it = stat ? it : it.prototype, TAG))
|
|
def(it, TAG, {
|
|
configurable: true,
|
|
value: tag
|
|
});
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d9", ["9b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = !$__require('9b')(function() {
|
|
return Object.defineProperty({}, 'a', {get: function() {
|
|
return 7;
|
|
}}).a != 7;
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e3", ["99", "ce", "8f", "9b", "18c", "da", "d7", "d6", "d0", "db", "d9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99'),
|
|
global = $__require('ce'),
|
|
$export = $__require('8f'),
|
|
fails = $__require('9b'),
|
|
hide = $__require('18c'),
|
|
redefineAll = $__require('da'),
|
|
forOf = $__require('d7'),
|
|
strictNew = $__require('d6'),
|
|
isObject = $__require('d0'),
|
|
setToStringTag = $__require('db'),
|
|
DESCRIPTORS = $__require('d9');
|
|
module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
|
var Base = global[NAME],
|
|
C = Base,
|
|
ADDER = IS_MAP ? 'set' : 'add',
|
|
proto = C && C.prototype,
|
|
O = {};
|
|
if (!DESCRIPTORS || typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function() {
|
|
new C().entries().next();
|
|
}))) {
|
|
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
|
redefineAll(C.prototype, methods);
|
|
} else {
|
|
C = wrapper(function(target, iterable) {
|
|
strictNew(target, C, NAME);
|
|
target._c = new Base;
|
|
if (iterable != undefined)
|
|
forOf(iterable, IS_MAP, target[ADDER], target);
|
|
});
|
|
$.each.call('add,clear,delete,forEach,get,has,set,keys,values,entries'.split(','), function(KEY) {
|
|
var IS_ADDER = KEY == 'add' || KEY == 'set';
|
|
if (KEY in proto && !(IS_WEAK && KEY == 'clear'))
|
|
hide(C.prototype, KEY, function(a, b) {
|
|
if (!IS_ADDER && IS_WEAK && !isObject(a))
|
|
return KEY == 'get' ? undefined : false;
|
|
var result = this._c[KEY](a === 0 ? 0 : a, b);
|
|
return IS_ADDER ? this : result;
|
|
});
|
|
});
|
|
if ('size' in proto)
|
|
$.setDesc(C.prototype, 'size', {get: function() {
|
|
return this._c.size;
|
|
}});
|
|
}
|
|
setToStringTag(C, NAME);
|
|
O[NAME] = C;
|
|
$export($export.G + $export.W + $export.F, O);
|
|
if (!IS_WEAK)
|
|
common.setStrong(C, NAME, IS_MAP);
|
|
return C;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("190", ["e2", "e3"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var strong = $__require('e2');
|
|
$__require('e3')('Set', function(get) {
|
|
return function Set() {
|
|
return get(this, arguments.length > 0 ? arguments[0] : undefined);
|
|
};
|
|
}, {add: function add(value) {
|
|
return strong.def(this, value = value === 0 ? 0 : value, value);
|
|
}}, strong);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("91", ["ca"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var anObject = $__require('ca');
|
|
module.exports = function(iterator, fn, value, entries) {
|
|
try {
|
|
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
} catch (e) {
|
|
var ret = iterator['return'];
|
|
if (ret !== undefined)
|
|
anObject(ret.call(iterator));
|
|
throw e;
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("92", ["2c", "2b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Iterators = $__require('2c'),
|
|
ITERATOR = $__require('2b')('iterator'),
|
|
ArrayProto = Array.prototype;
|
|
module.exports = function(it) {
|
|
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("183", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ceil = Math.ceil,
|
|
floor = Math.floor;
|
|
module.exports = function(it) {
|
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("93", ["183"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toInteger = $__require('183'),
|
|
min = Math.min;
|
|
module.exports = function(it) {
|
|
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2c", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("94", ["2a", "2b", "2c", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var classof = $__require('2a'),
|
|
ITERATOR = $__require('2b')('iterator'),
|
|
Iterators = $__require('2c');
|
|
module.exports = $__require('2d').getIteratorMethod = function(it) {
|
|
if (it != undefined)
|
|
return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d7", ["8e", "91", "92", "ca", "93", "94"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ctx = $__require('8e'),
|
|
call = $__require('91'),
|
|
isArrayIter = $__require('92'),
|
|
anObject = $__require('ca'),
|
|
toLength = $__require('93'),
|
|
getIterFn = $__require('94');
|
|
module.exports = function(iterable, entries, fn, that) {
|
|
var iterFn = getIterFn(iterable),
|
|
f = ctx(fn, that, entries ? 2 : 1),
|
|
index = 0,
|
|
length,
|
|
step,
|
|
iterator;
|
|
if (typeof iterFn != 'function')
|
|
throw TypeError(iterable + ' is not iterable!');
|
|
if (isArrayIter(iterFn))
|
|
for (length = toLength(iterable.length); length > index; index++) {
|
|
entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
|
}
|
|
else
|
|
for (iterator = iterFn.call(iterable); !(step = iterator.next()).done; ) {
|
|
call(iterator, f, step.value, entries);
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("191", ["ce"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var global = $__require('ce'),
|
|
SHARED = '__core-js_shared__',
|
|
store = global[SHARED] || (global[SHARED] = {});
|
|
module.exports = function(key) {
|
|
return store[key] || (store[key] = {});
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("18f", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var id = 0,
|
|
px = Math.random();
|
|
module.exports = function(key) {
|
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2b", ["191", "18f", "ce"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var store = $__require('191')('wks'),
|
|
uid = $__require('18f'),
|
|
Symbol = $__require('ce').Symbol;
|
|
module.exports = function(name) {
|
|
return store[name] || (store[name] = Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2a", ["d2", "2b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var cof = $__require('d2'),
|
|
TAG = $__require('2b')('toStringTag'),
|
|
ARG = cof(function() {
|
|
return arguments;
|
|
}()) == 'Arguments';
|
|
module.exports = function(it) {
|
|
var O,
|
|
T,
|
|
B;
|
|
return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof(T = (O = Object(it))[TAG]) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("e5", ["d7", "2a"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var forOf = $__require('d7'),
|
|
classof = $__require('2a');
|
|
module.exports = function(NAME) {
|
|
return function toJSON() {
|
|
if (classof(this) != NAME)
|
|
throw TypeError(NAME + "#toJSON isn't generic");
|
|
var arr = [];
|
|
forOf(this, false, arr.push, arr);
|
|
return arr;
|
|
};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("192", ["8f", "e5"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $export = $__require('8f');
|
|
$export($export.P, 'Set', {toJSON: $__require('e5')('Set')});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("193", ["de", "30", "2f", "190", "192", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('de');
|
|
$__require('30');
|
|
$__require('2f');
|
|
$__require('190');
|
|
$__require('192');
|
|
module.exports = $__require('2d').Set;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e", ["193"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('193'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('194', ['1e'], function (_export) {
|
|
var _Set, methods;
|
|
|
|
return {
|
|
setters: [function (_e) {
|
|
_Set = _e['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
methods = new _Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch']);
|
|
|
|
_export('methods', methods);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('1b', ['6', '7', '24', '32', '181', '194', '1f', 'e7', 'c'], function (_export) {
|
|
var _createClass, _classCallCheck, _Object$keys, _getIterator, SwaggerParser, swaggerMethods, _Promise, _Map, JsonPointer, SchemaManager;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_3) {
|
|
_Object$keys = _3['default'];
|
|
}, function (_4) {
|
|
_getIterator = _4['default'];
|
|
}, function (_5) {
|
|
SwaggerParser = _5['default'];
|
|
}, function (_6) {
|
|
swaggerMethods = _6.methods;
|
|
}, function (_f) {
|
|
_Promise = _f['default'];
|
|
}, function (_e7) {
|
|
_Map = _e7['default'];
|
|
}, function (_c) {
|
|
JsonPointer = _c['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
SchemaManager = (function () {
|
|
function SchemaManager() {
|
|
_classCallCheck(this, SchemaManager);
|
|
|
|
if (SchemaManager.prototype._instance) {
|
|
return SchemaManager.prototype._instance;
|
|
}
|
|
|
|
SchemaManager.prototype._instance = this;
|
|
|
|
this._schema = {};
|
|
}
|
|
|
|
_createClass(SchemaManager, [{
|
|
key: 'load',
|
|
value: function load(url) {
|
|
var _this = this;
|
|
|
|
var promise = new _Promise(function (resolve, reject) {
|
|
_this._schema = {};
|
|
|
|
SwaggerParser.bundle(url, { http: { withCredentials: false } }).then(function (schema) {
|
|
_this._schema = schema;
|
|
resolve(_this._schema);
|
|
_this.init();
|
|
}, function (err) {
|
|
return reject(err);
|
|
});
|
|
});
|
|
|
|
return promise;
|
|
}
|
|
|
|
/* calculate common used values */
|
|
}, {
|
|
key: 'init',
|
|
value: function init() {
|
|
this.apiUrl = this._schema.schemes[0] + '://' + this._schema.host + this._schema.basePath;
|
|
if (this.apiUrl.endsWith('/')) {
|
|
this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1);
|
|
}
|
|
}
|
|
}, {
|
|
key: 'byPointer',
|
|
value: function byPointer(pointer) {
|
|
var res = null;
|
|
try {
|
|
res = JsonPointer.get(this._schema, pointer);
|
|
} catch (e) {/*skip*/}
|
|
return res;
|
|
}
|
|
}, {
|
|
key: 'resolveRefs',
|
|
value: function resolveRefs(obj) {
|
|
var _this2 = this;
|
|
|
|
_Object$keys(obj).forEach(function (key) {
|
|
if (obj[key].$ref) {
|
|
var resolved = _this2.byPointer(obj[key].$ref);
|
|
resolved._pointer = obj[key].$ref;
|
|
obj[key] = resolved;
|
|
}
|
|
});
|
|
return obj;
|
|
}
|
|
}, {
|
|
key: 'getMethodParams',
|
|
value: function getMethodParams(methodPtr, resolveRefs) {
|
|
/* inject JsonPointer into array elements */
|
|
function injectPointers(array, root) {
|
|
if (!Array.isArray(array)) {
|
|
throw new Error('parameters must be an array. Got ' + typeof array + ' at ' + root);
|
|
}
|
|
return array.map(function (element, idx) {
|
|
element._pointer = JsonPointer.join(root, idx);
|
|
return element;
|
|
});
|
|
}
|
|
|
|
// accept pointer directly to parameters as well
|
|
if (JsonPointer.baseName(methodPtr) === 'parameters') {
|
|
methodPtr = JsonPointer.dirName(methodPtr);
|
|
}
|
|
|
|
//get path params
|
|
var pathParamsPtr = JsonPointer.join(JsonPointer.dirName(methodPtr), ['parameters']);
|
|
var pathParams = this.byPointer(pathParamsPtr) || [];
|
|
|
|
var methodParamsPtr = JsonPointer.join(methodPtr, ['parameters']);
|
|
var methodParams = this.byPointer(methodParamsPtr) || [];
|
|
pathParams = injectPointers(pathParams, pathParamsPtr);
|
|
methodParams = injectPointers(methodParams, methodParamsPtr);
|
|
|
|
if (resolveRefs) {
|
|
methodParams = this.resolveRefs(methodParams);
|
|
pathParams = this.resolveRefs(pathParams);
|
|
}
|
|
return methodParams.concat(pathParams);
|
|
}
|
|
}, {
|
|
key: 'getTagsMap',
|
|
value: function getTagsMap() {
|
|
var tags = this._schema.tags || [];
|
|
var tagsMap = {};
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = _getIterator(tags), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var tag = _step.value;
|
|
|
|
tagsMap[tag.name] = {
|
|
description: tag.description,
|
|
'x-traitTag': tag['x-traitTag'] || false
|
|
};
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator['return']) {
|
|
_iterator['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
|
|
return tagsMap;
|
|
}
|
|
|
|
/* returns ES6 Map */
|
|
}, {
|
|
key: 'buildMenuTree',
|
|
value: function buildMenuTree() {
|
|
var tag2MethodMapping = new _Map();
|
|
|
|
var definedTags = this._schema.tags || [];
|
|
// add tags into map to preserve order
|
|
var _iteratorNormalCompletion2 = true;
|
|
var _didIteratorError2 = false;
|
|
var _iteratorError2 = undefined;
|
|
|
|
try {
|
|
for (var _iterator2 = _getIterator(definedTags), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
var tag = _step2.value;
|
|
|
|
tag2MethodMapping.set(tag.name, {
|
|
'description': tag.description,
|
|
'x-traitTag': tag['x-traitTag'],
|
|
'methods': []
|
|
});
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError2 = true;
|
|
_iteratorError2 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion2 && _iterator2['return']) {
|
|
_iterator2['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError2) {
|
|
throw _iteratorError2;
|
|
}
|
|
}
|
|
}
|
|
|
|
var paths = this._schema.paths;
|
|
var _iteratorNormalCompletion3 = true;
|
|
var _didIteratorError3 = false;
|
|
var _iteratorError3 = undefined;
|
|
|
|
try {
|
|
for (var _iterator3 = _getIterator(_Object$keys(paths)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
var path = _step3.value;
|
|
|
|
var methods = _Object$keys(paths[path]).filter(function (k) {
|
|
return swaggerMethods.has(k);
|
|
});
|
|
var _iteratorNormalCompletion4 = true;
|
|
var _didIteratorError4 = false;
|
|
var _iteratorError4 = undefined;
|
|
|
|
try {
|
|
for (var _iterator4 = _getIterator(methods), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
var method = _step4.value;
|
|
|
|
var methodInfo = paths[path][method];
|
|
var tags = methodInfo.tags;
|
|
|
|
//TODO: mb need to do something cleverer
|
|
if (!tags || !tags.length) {
|
|
tags = ['[Other]'];
|
|
}
|
|
var methodPointer = JsonPointer.compile(['paths', path, method]);
|
|
var methodSummary = methodInfo.summary;
|
|
var _iteratorNormalCompletion5 = true;
|
|
var _didIteratorError5 = false;
|
|
var _iteratorError5 = undefined;
|
|
|
|
try {
|
|
for (var _iterator5 = _getIterator(tags), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
var tag = _step5.value;
|
|
|
|
var tagDetails = tag2MethodMapping.get(tag);
|
|
if (!tagDetails) {
|
|
tagDetails = {};
|
|
tag2MethodMapping.set(tag, tagDetails);
|
|
}
|
|
if (tagDetails['x-traitTag']) continue;
|
|
if (!tagDetails.methods) tagDetails.methods = [];
|
|
tagDetails.methods.push({ pointer: methodPointer, summary: methodSummary });
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError5 = true;
|
|
_iteratorError5 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion5 && _iterator5['return']) {
|
|
_iterator5['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError5) {
|
|
throw _iteratorError5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError4 = true;
|
|
_iteratorError4 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion4 && _iterator4['return']) {
|
|
_iterator4['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError4) {
|
|
throw _iteratorError4;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError3 = true;
|
|
_iteratorError3 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion3 && _iterator3['return']) {
|
|
_iterator3['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError3) {
|
|
throw _iteratorError3;
|
|
}
|
|
}
|
|
}
|
|
|
|
return tag2MethodMapping;
|
|
}
|
|
}, {
|
|
key: 'schema',
|
|
get: function get() {
|
|
// TODO: consider returning promise
|
|
return this._schema;
|
|
}
|
|
}], [{
|
|
key: 'instance',
|
|
value: function instance() {
|
|
return new SchemaManager();
|
|
}
|
|
}]);
|
|
|
|
return SchemaManager;
|
|
})();
|
|
|
|
_export('default', SchemaManager);
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("90", ["184"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var defined = $__require('184');
|
|
module.exports = function(it) {
|
|
return Object(defined(it));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("195", ["90", "196"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toObject = $__require('90');
|
|
$__require('196')('keys', function($keys) {
|
|
return function keys(it) {
|
|
return $keys(toObject(it));
|
|
};
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("197", ["195", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('195');
|
|
module.exports = $__require('2d').Object.keys;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("24", ["197"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('197'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("198", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
"format cjs";
|
|
;
|
|
(function() {
|
|
var block = {
|
|
newline: /^\n+/,
|
|
code: /^( {4}[^\n]+\n*)+/,
|
|
fences: noop,
|
|
hr: /^( *[-*_]){3,} *(?:\n+|$)/,
|
|
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
|
nptable: noop,
|
|
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
|
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
|
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
|
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
|
table: noop,
|
|
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
|
|
text: /^[^\n]+/
|
|
};
|
|
block.bullet = /(?:[*+-]|\d+\.)/;
|
|
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
|
block.item = replace(block.item, 'gm')(/bull/g, block.bullet)();
|
|
block.list = replace(block.list)(/bull/g, block.bullet)('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')('def', '\\n+(?=' + block.def.source + ')')();
|
|
block.blockquote = replace(block.blockquote)('def', block.def)();
|
|
block._tag = '(?!(?:' + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
|
|
block.html = replace(block.html)('comment', /<!--[\s\S]*?-->/)('closed', /<(tag)[\s\S]+?<\/\1>/)('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g, block._tag)();
|
|
block.paragraph = replace(block.paragraph)('hr', block.hr)('heading', block.heading)('lheading', block.lheading)('blockquote', block.blockquote)('tag', '<' + block._tag)('def', block.def)();
|
|
block.normal = merge({}, block);
|
|
block.gfm = merge({}, block.normal, {
|
|
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
|
|
paragraph: /^/,
|
|
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
|
});
|
|
block.gfm.paragraph = replace(block.paragraph)('(?!', '(?!' + block.gfm.fences.source.replace('\\1', '\\2') + '|' + block.list.source.replace('\\1', '\\3') + '|')();
|
|
block.tables = merge({}, block.gfm, {
|
|
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
|
|
table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
|
|
});
|
|
function Lexer(options) {
|
|
this.tokens = [];
|
|
this.tokens.links = {};
|
|
this.options = options || marked.defaults;
|
|
this.rules = block.normal;
|
|
if (this.options.gfm) {
|
|
if (this.options.tables) {
|
|
this.rules = block.tables;
|
|
} else {
|
|
this.rules = block.gfm;
|
|
}
|
|
}
|
|
}
|
|
Lexer.rules = block;
|
|
Lexer.lex = function(src, options) {
|
|
var lexer = new Lexer(options);
|
|
return lexer.lex(src);
|
|
};
|
|
Lexer.prototype.lex = function(src) {
|
|
src = src.replace(/\r\n|\r/g, '\n').replace(/\t/g, ' ').replace(/\u00a0/g, ' ').replace(/\u2424/g, '\n');
|
|
return this.token(src, true);
|
|
};
|
|
Lexer.prototype.token = function(src, top, bq) {
|
|
var src = src.replace(/^ +$/gm, ''),
|
|
next,
|
|
loose,
|
|
cap,
|
|
bull,
|
|
b,
|
|
item,
|
|
space,
|
|
i,
|
|
l;
|
|
while (src) {
|
|
if (cap = this.rules.newline.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
if (cap[0].length > 1) {
|
|
this.tokens.push({type: 'space'});
|
|
}
|
|
}
|
|
if (cap = this.rules.code.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
cap = cap[0].replace(/^ {4}/gm, '');
|
|
this.tokens.push({
|
|
type: 'code',
|
|
text: !this.options.pedantic ? cap.replace(/\n+$/, '') : cap
|
|
});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.fences.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: 'code',
|
|
lang: cap[2],
|
|
text: cap[3] || ''
|
|
});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.heading.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: 'heading',
|
|
depth: cap[1].length,
|
|
text: cap[2]
|
|
});
|
|
continue;
|
|
}
|
|
if (top && (cap = this.rules.nptable.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
item = {
|
|
type: 'table',
|
|
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
cells: cap[3].replace(/\n$/, '').split('\n')
|
|
};
|
|
for (i = 0; i < item.align.length; i++) {
|
|
if (/^ *-+: *$/.test(item.align[i])) {
|
|
item.align[i] = 'right';
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
item.align[i] = 'center';
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
item.align[i] = 'left';
|
|
} else {
|
|
item.align[i] = null;
|
|
}
|
|
}
|
|
for (i = 0; i < item.cells.length; i++) {
|
|
item.cells[i] = item.cells[i].split(/ *\| */);
|
|
}
|
|
this.tokens.push(item);
|
|
continue;
|
|
}
|
|
if (cap = this.rules.lheading.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: 'heading',
|
|
depth: cap[2] === '=' ? 1 : 2,
|
|
text: cap[1]
|
|
});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.hr.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({type: 'hr'});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.blockquote.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({type: 'blockquote_start'});
|
|
cap = cap[0].replace(/^ *> ?/gm, '');
|
|
this.token(cap, top, true);
|
|
this.tokens.push({type: 'blockquote_end'});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.list.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
bull = cap[2];
|
|
this.tokens.push({
|
|
type: 'list_start',
|
|
ordered: bull.length > 1
|
|
});
|
|
cap = cap[0].match(this.rules.item);
|
|
next = false;
|
|
l = cap.length;
|
|
i = 0;
|
|
for (; i < l; i++) {
|
|
item = cap[i];
|
|
space = item.length;
|
|
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
|
if (~item.indexOf('\n ')) {
|
|
space -= item.length;
|
|
item = !this.options.pedantic ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') : item.replace(/^ {1,4}/gm, '');
|
|
}
|
|
if (this.options.smartLists && i !== l - 1) {
|
|
b = block.bullet.exec(cap[i + 1])[0];
|
|
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
|
src = cap.slice(i + 1).join('\n') + src;
|
|
i = l - 1;
|
|
}
|
|
}
|
|
loose = next || /\n\n(?!\s*$)/.test(item);
|
|
if (i !== l - 1) {
|
|
next = item.charAt(item.length - 1) === '\n';
|
|
if (!loose)
|
|
loose = next;
|
|
}
|
|
this.tokens.push({type: loose ? 'loose_item_start' : 'list_item_start'});
|
|
this.token(item, false, bq);
|
|
this.tokens.push({type: 'list_item_end'});
|
|
}
|
|
this.tokens.push({type: 'list_end'});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.html.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: this.options.sanitize ? 'paragraph' : 'html',
|
|
pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
text: cap[0]
|
|
});
|
|
continue;
|
|
}
|
|
if ((!bq && top) && (cap = this.rules.def.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.links[cap[1].toLowerCase()] = {
|
|
href: cap[2],
|
|
title: cap[3]
|
|
};
|
|
continue;
|
|
}
|
|
if (top && (cap = this.rules.table.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
item = {
|
|
type: 'table',
|
|
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
|
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
|
|
};
|
|
for (i = 0; i < item.align.length; i++) {
|
|
if (/^ *-+: *$/.test(item.align[i])) {
|
|
item.align[i] = 'right';
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
item.align[i] = 'center';
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
item.align[i] = 'left';
|
|
} else {
|
|
item.align[i] = null;
|
|
}
|
|
}
|
|
for (i = 0; i < item.cells.length; i++) {
|
|
item.cells[i] = item.cells[i].replace(/^ *\| *| *\| *$/g, '').split(/ *\| */);
|
|
}
|
|
this.tokens.push(item);
|
|
continue;
|
|
}
|
|
if (top && (cap = this.rules.paragraph.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: 'paragraph',
|
|
text: cap[1].charAt(cap[1].length - 1) === '\n' ? cap[1].slice(0, -1) : cap[1]
|
|
});
|
|
continue;
|
|
}
|
|
if (cap = this.rules.text.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.tokens.push({
|
|
type: 'text',
|
|
text: cap[0]
|
|
});
|
|
continue;
|
|
}
|
|
if (src) {
|
|
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
}
|
|
}
|
|
return this.tokens;
|
|
};
|
|
var inline = {
|
|
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
|
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
|
url: noop,
|
|
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
|
link: /^!?\[(inside)\]\(href\)/,
|
|
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
|
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
|
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
|
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
|
br: /^ {2,}\n(?!\s*$)/,
|
|
del: noop,
|
|
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
|
};
|
|
inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
|
|
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
|
inline.link = replace(inline.link)('inside', inline._inside)('href', inline._href)();
|
|
inline.reflink = replace(inline.reflink)('inside', inline._inside)();
|
|
inline.normal = merge({}, inline);
|
|
inline.pedantic = merge({}, inline.normal, {
|
|
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
|
});
|
|
inline.gfm = merge({}, inline.normal, {
|
|
escape: replace(inline.escape)('])', '~|])')(),
|
|
url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
|
|
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
|
text: replace(inline.text)(']|', '~]|')('|', '|https?://|')()
|
|
});
|
|
inline.breaks = merge({}, inline.gfm, {
|
|
br: replace(inline.br)('{2,}', '*')(),
|
|
text: replace(inline.gfm.text)('{2,}', '*')()
|
|
});
|
|
function InlineLexer(links, options) {
|
|
this.options = options || marked.defaults;
|
|
this.links = links;
|
|
this.rules = inline.normal;
|
|
this.renderer = this.options.renderer || new Renderer;
|
|
this.renderer.options = this.options;
|
|
if (!this.links) {
|
|
throw new Error('Tokens array requires a `links` property.');
|
|
}
|
|
if (this.options.gfm) {
|
|
if (this.options.breaks) {
|
|
this.rules = inline.breaks;
|
|
} else {
|
|
this.rules = inline.gfm;
|
|
}
|
|
} else if (this.options.pedantic) {
|
|
this.rules = inline.pedantic;
|
|
}
|
|
}
|
|
InlineLexer.rules = inline;
|
|
InlineLexer.output = function(src, links, options) {
|
|
var inline = new InlineLexer(links, options);
|
|
return inline.output(src);
|
|
};
|
|
InlineLexer.prototype.output = function(src) {
|
|
var out = '',
|
|
link,
|
|
text,
|
|
href,
|
|
cap;
|
|
while (src) {
|
|
if (cap = this.rules.escape.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += cap[1];
|
|
continue;
|
|
}
|
|
if (cap = this.rules.autolink.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
if (cap[2] === '@') {
|
|
text = cap[1].charAt(6) === ':' ? this.mangle(cap[1].substring(7)) : this.mangle(cap[1]);
|
|
href = this.mangle('mailto:') + text;
|
|
} else {
|
|
text = escape(cap[1]);
|
|
href = text;
|
|
}
|
|
out += this.renderer.link(href, null, text);
|
|
continue;
|
|
}
|
|
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
text = escape(cap[1]);
|
|
href = text;
|
|
out += this.renderer.link(href, null, text);
|
|
continue;
|
|
}
|
|
if (cap = this.rules.tag.exec(src)) {
|
|
if (!this.inLink && /^<a /i.test(cap[0])) {
|
|
this.inLink = true;
|
|
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
|
this.inLink = false;
|
|
}
|
|
src = src.substring(cap[0].length);
|
|
out += this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]) : cap[0];
|
|
continue;
|
|
}
|
|
if (cap = this.rules.link.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
this.inLink = true;
|
|
out += this.outputLink(cap, {
|
|
href: cap[2],
|
|
title: cap[3]
|
|
});
|
|
this.inLink = false;
|
|
continue;
|
|
}
|
|
if ((cap = this.rules.reflink.exec(src)) || (cap = this.rules.nolink.exec(src))) {
|
|
src = src.substring(cap[0].length);
|
|
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
link = this.links[link.toLowerCase()];
|
|
if (!link || !link.href) {
|
|
out += cap[0].charAt(0);
|
|
src = cap[0].substring(1) + src;
|
|
continue;
|
|
}
|
|
this.inLink = true;
|
|
out += this.outputLink(cap, link);
|
|
this.inLink = false;
|
|
continue;
|
|
}
|
|
if (cap = this.rules.strong.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.strong(this.output(cap[2] || cap[1]));
|
|
continue;
|
|
}
|
|
if (cap = this.rules.em.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.em(this.output(cap[2] || cap[1]));
|
|
continue;
|
|
}
|
|
if (cap = this.rules.code.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.codespan(escape(cap[2], true));
|
|
continue;
|
|
}
|
|
if (cap = this.rules.br.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.br();
|
|
continue;
|
|
}
|
|
if (cap = this.rules.del.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.del(this.output(cap[1]));
|
|
continue;
|
|
}
|
|
if (cap = this.rules.text.exec(src)) {
|
|
src = src.substring(cap[0].length);
|
|
out += this.renderer.text(escape(this.smartypants(cap[0])));
|
|
continue;
|
|
}
|
|
if (src) {
|
|
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
InlineLexer.prototype.outputLink = function(cap, link) {
|
|
var href = escape(link.href),
|
|
title = link.title ? escape(link.title) : null;
|
|
return cap[0].charAt(0) !== '!' ? this.renderer.link(href, title, this.output(cap[1])) : this.renderer.image(href, title, escape(cap[1]));
|
|
};
|
|
InlineLexer.prototype.smartypants = function(text) {
|
|
if (!this.options.smartypants)
|
|
return text;
|
|
return text.replace(/---/g, '\u2014').replace(/--/g, '\u2013').replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018').replace(/'/g, '\u2019').replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c').replace(/"/g, '\u201d').replace(/\.{3}/g, '\u2026');
|
|
};
|
|
InlineLexer.prototype.mangle = function(text) {
|
|
if (!this.options.mangle)
|
|
return text;
|
|
var out = '',
|
|
l = text.length,
|
|
i = 0,
|
|
ch;
|
|
for (; i < l; i++) {
|
|
ch = text.charCodeAt(i);
|
|
if (Math.random() > 0.5) {
|
|
ch = 'x' + ch.toString(16);
|
|
}
|
|
out += '&#' + ch + ';';
|
|
}
|
|
return out;
|
|
};
|
|
function Renderer(options) {
|
|
this.options = options || {};
|
|
}
|
|
Renderer.prototype.code = function(code, lang, escaped) {
|
|
if (this.options.highlight) {
|
|
var out = this.options.highlight(code, lang);
|
|
if (out != null && out !== code) {
|
|
escaped = true;
|
|
code = out;
|
|
}
|
|
}
|
|
if (!lang) {
|
|
return '<pre><code>' + (escaped ? code : escape(code, true)) + '\n</code></pre>';
|
|
}
|
|
return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + '\n</code></pre>\n';
|
|
};
|
|
Renderer.prototype.blockquote = function(quote) {
|
|
return '<blockquote>\n' + quote + '</blockquote>\n';
|
|
};
|
|
Renderer.prototype.html = function(html) {
|
|
return html;
|
|
};
|
|
Renderer.prototype.heading = function(text, level, raw) {
|
|
return '<h' + level + ' id="' + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-') + '">' + text + '</h' + level + '>\n';
|
|
};
|
|
Renderer.prototype.hr = function() {
|
|
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
};
|
|
Renderer.prototype.list = function(body, ordered) {
|
|
var type = ordered ? 'ol' : 'ul';
|
|
return '<' + type + '>\n' + body + '</' + type + '>\n';
|
|
};
|
|
Renderer.prototype.listitem = function(text) {
|
|
return '<li>' + text + '</li>\n';
|
|
};
|
|
Renderer.prototype.paragraph = function(text) {
|
|
return '<p>' + text + '</p>\n';
|
|
};
|
|
Renderer.prototype.table = function(header, body) {
|
|
return '<table>\n' + '<thead>\n' + header + '</thead>\n' + '<tbody>\n' + body + '</tbody>\n' + '</table>\n';
|
|
};
|
|
Renderer.prototype.tablerow = function(content) {
|
|
return '<tr>\n' + content + '</tr>\n';
|
|
};
|
|
Renderer.prototype.tablecell = function(content, flags) {
|
|
var type = flags.header ? 'th' : 'td';
|
|
var tag = flags.align ? '<' + type + ' style="text-align:' + flags.align + '">' : '<' + type + '>';
|
|
return tag + content + '</' + type + '>\n';
|
|
};
|
|
Renderer.prototype.strong = function(text) {
|
|
return '<strong>' + text + '</strong>';
|
|
};
|
|
Renderer.prototype.em = function(text) {
|
|
return '<em>' + text + '</em>';
|
|
};
|
|
Renderer.prototype.codespan = function(text) {
|
|
return '<code>' + text + '</code>';
|
|
};
|
|
Renderer.prototype.br = function() {
|
|
return this.options.xhtml ? '<br/>' : '<br>';
|
|
};
|
|
Renderer.prototype.del = function(text) {
|
|
return '<del>' + text + '</del>';
|
|
};
|
|
Renderer.prototype.link = function(href, title, text) {
|
|
if (this.options.sanitize) {
|
|
try {
|
|
var prot = decodeURIComponent(unescape(href)).replace(/[^\w:]/g, '').toLowerCase();
|
|
} catch (e) {
|
|
return '';
|
|
}
|
|
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
|
|
return '';
|
|
}
|
|
}
|
|
var out = '<a href="' + href + '"';
|
|
if (title) {
|
|
out += ' title="' + title + '"';
|
|
}
|
|
out += '>' + text + '</a>';
|
|
return out;
|
|
};
|
|
Renderer.prototype.image = function(href, title, text) {
|
|
var out = '<img src="' + href + '" alt="' + text + '"';
|
|
if (title) {
|
|
out += ' title="' + title + '"';
|
|
}
|
|
out += this.options.xhtml ? '/>' : '>';
|
|
return out;
|
|
};
|
|
Renderer.prototype.text = function(text) {
|
|
return text;
|
|
};
|
|
function Parser(options) {
|
|
this.tokens = [];
|
|
this.token = null;
|
|
this.options = options || marked.defaults;
|
|
this.options.renderer = this.options.renderer || new Renderer;
|
|
this.renderer = this.options.renderer;
|
|
this.renderer.options = this.options;
|
|
}
|
|
Parser.parse = function(src, options, renderer) {
|
|
var parser = new Parser(options, renderer);
|
|
return parser.parse(src);
|
|
};
|
|
Parser.prototype.parse = function(src) {
|
|
this.inline = new InlineLexer(src.links, this.options, this.renderer);
|
|
this.tokens = src.reverse();
|
|
var out = '';
|
|
while (this.next()) {
|
|
out += this.tok();
|
|
}
|
|
return out;
|
|
};
|
|
Parser.prototype.next = function() {
|
|
return this.token = this.tokens.pop();
|
|
};
|
|
Parser.prototype.peek = function() {
|
|
return this.tokens[this.tokens.length - 1] || 0;
|
|
};
|
|
Parser.prototype.parseText = function() {
|
|
var body = this.token.text;
|
|
while (this.peek().type === 'text') {
|
|
body += '\n' + this.next().text;
|
|
}
|
|
return this.inline.output(body);
|
|
};
|
|
Parser.prototype.tok = function() {
|
|
switch (this.token.type) {
|
|
case 'space':
|
|
{
|
|
return '';
|
|
}
|
|
case 'hr':
|
|
{
|
|
return this.renderer.hr();
|
|
}
|
|
case 'heading':
|
|
{
|
|
return this.renderer.heading(this.inline.output(this.token.text), this.token.depth, this.token.text);
|
|
}
|
|
case 'code':
|
|
{
|
|
return this.renderer.code(this.token.text, this.token.lang, this.token.escaped);
|
|
}
|
|
case 'table':
|
|
{
|
|
var header = '',
|
|
body = '',
|
|
i,
|
|
row,
|
|
cell,
|
|
flags,
|
|
j;
|
|
cell = '';
|
|
for (i = 0; i < this.token.header.length; i++) {
|
|
flags = {
|
|
header: true,
|
|
align: this.token.align[i]
|
|
};
|
|
cell += this.renderer.tablecell(this.inline.output(this.token.header[i]), {
|
|
header: true,
|
|
align: this.token.align[i]
|
|
});
|
|
}
|
|
header += this.renderer.tablerow(cell);
|
|
for (i = 0; i < this.token.cells.length; i++) {
|
|
row = this.token.cells[i];
|
|
cell = '';
|
|
for (j = 0; j < row.length; j++) {
|
|
cell += this.renderer.tablecell(this.inline.output(row[j]), {
|
|
header: false,
|
|
align: this.token.align[j]
|
|
});
|
|
}
|
|
body += this.renderer.tablerow(cell);
|
|
}
|
|
return this.renderer.table(header, body);
|
|
}
|
|
case 'blockquote_start':
|
|
{
|
|
var body = '';
|
|
while (this.next().type !== 'blockquote_end') {
|
|
body += this.tok();
|
|
}
|
|
return this.renderer.blockquote(body);
|
|
}
|
|
case 'list_start':
|
|
{
|
|
var body = '',
|
|
ordered = this.token.ordered;
|
|
while (this.next().type !== 'list_end') {
|
|
body += this.tok();
|
|
}
|
|
return this.renderer.list(body, ordered);
|
|
}
|
|
case 'list_item_start':
|
|
{
|
|
var body = '';
|
|
while (this.next().type !== 'list_item_end') {
|
|
body += this.token.type === 'text' ? this.parseText() : this.tok();
|
|
}
|
|
return this.renderer.listitem(body);
|
|
}
|
|
case 'loose_item_start':
|
|
{
|
|
var body = '';
|
|
while (this.next().type !== 'list_item_end') {
|
|
body += this.tok();
|
|
}
|
|
return this.renderer.listitem(body);
|
|
}
|
|
case 'html':
|
|
{
|
|
var html = !this.token.pre && !this.options.pedantic ? this.inline.output(this.token.text) : this.token.text;
|
|
return this.renderer.html(html);
|
|
}
|
|
case 'paragraph':
|
|
{
|
|
return this.renderer.paragraph(this.inline.output(this.token.text));
|
|
}
|
|
case 'text':
|
|
{
|
|
return this.renderer.paragraph(this.parseText());
|
|
}
|
|
}
|
|
};
|
|
function escape(html, encode) {
|
|
return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
}
|
|
function unescape(html) {
|
|
return html.replace(/&([#\w]+);/g, function(_, n) {
|
|
n = n.toLowerCase();
|
|
if (n === 'colon')
|
|
return ':';
|
|
if (n.charAt(0) === '#') {
|
|
return n.charAt(1) === 'x' ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
|
|
}
|
|
return '';
|
|
});
|
|
}
|
|
function replace(regex, opt) {
|
|
regex = regex.source;
|
|
opt = opt || '';
|
|
return function self(name, val) {
|
|
if (!name)
|
|
return new RegExp(regex, opt);
|
|
val = val.source || val;
|
|
val = val.replace(/(^|[^\[])\^/g, '$1');
|
|
regex = regex.replace(name, val);
|
|
return self;
|
|
};
|
|
}
|
|
function noop() {}
|
|
noop.exec = noop;
|
|
function merge(obj) {
|
|
var i = 1,
|
|
target,
|
|
key;
|
|
for (; i < arguments.length; i++) {
|
|
target = arguments[i];
|
|
for (key in target) {
|
|
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
obj[key] = target[key];
|
|
}
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
function marked(src, opt, callback) {
|
|
if (callback || typeof opt === 'function') {
|
|
if (!callback) {
|
|
callback = opt;
|
|
opt = null;
|
|
}
|
|
opt = merge({}, marked.defaults, opt || {});
|
|
var highlight = opt.highlight,
|
|
tokens,
|
|
pending,
|
|
i = 0;
|
|
try {
|
|
tokens = Lexer.lex(src, opt);
|
|
} catch (e) {
|
|
return callback(e);
|
|
}
|
|
pending = tokens.length;
|
|
var done = function(err) {
|
|
if (err) {
|
|
opt.highlight = highlight;
|
|
return callback(err);
|
|
}
|
|
var out;
|
|
try {
|
|
out = Parser.parse(tokens, opt);
|
|
} catch (e) {
|
|
err = e;
|
|
}
|
|
opt.highlight = highlight;
|
|
return err ? callback(err) : callback(null, out);
|
|
};
|
|
if (!highlight || highlight.length < 3) {
|
|
return done();
|
|
}
|
|
delete opt.highlight;
|
|
if (!pending)
|
|
return done();
|
|
for (; i < tokens.length; i++) {
|
|
(function(token) {
|
|
if (token.type !== 'code') {
|
|
return --pending || done();
|
|
}
|
|
return highlight(token.text, token.lang, function(err, code) {
|
|
if (err)
|
|
return done(err);
|
|
if (code == null || code === token.text) {
|
|
return --pending || done();
|
|
}
|
|
token.text = code;
|
|
token.escaped = true;
|
|
--pending || done();
|
|
});
|
|
})(tokens[i]);
|
|
}
|
|
return;
|
|
}
|
|
try {
|
|
if (opt)
|
|
opt = merge({}, marked.defaults, opt);
|
|
return Parser.parse(Lexer.lex(src, opt), opt);
|
|
} catch (e) {
|
|
e.message += '\nPlease report this to https://github.com/chjj/marked.';
|
|
if ((opt || marked.defaults).silent) {
|
|
return '<p>An error occured:</p><pre>' + escape(e.message + '', true) + '</pre>';
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
marked.options = marked.setOptions = function(opt) {
|
|
merge(marked.defaults, opt);
|
|
return marked;
|
|
};
|
|
marked.defaults = {
|
|
gfm: true,
|
|
tables: true,
|
|
breaks: false,
|
|
pedantic: false,
|
|
sanitize: false,
|
|
sanitizer: null,
|
|
mangle: true,
|
|
smartLists: false,
|
|
silent: false,
|
|
highlight: null,
|
|
langPrefix: 'lang-',
|
|
smartypants: false,
|
|
headerPrefix: '',
|
|
renderer: new Renderer,
|
|
xhtml: false
|
|
};
|
|
marked.Parser = Parser;
|
|
marked.parser = Parser.parse;
|
|
marked.Renderer = Renderer;
|
|
marked.Lexer = Lexer;
|
|
marked.lexer = Lexer.lex;
|
|
marked.InlineLexer = InlineLexer;
|
|
marked.inlineLexer = InlineLexer.output;
|
|
marked.parse = marked;
|
|
if (typeof module !== 'undefined' && typeof exports === 'object') {
|
|
module.exports = marked;
|
|
} else if (typeof define === 'function' && define.amd) {
|
|
define(function() {
|
|
return marked;
|
|
});
|
|
} else {
|
|
this.marked = marked;
|
|
}
|
|
}).call(function() {
|
|
return this || (typeof window !== 'undefined' ? window : global);
|
|
}());
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("199", ["198"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('198');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('19a', ['4', '5', '6', '7', '14', '20', '24', '199', '3c', 'c'], function (_export) {
|
|
var _get, _inherits, _createClass, _classCallCheck, Pipe, isString, stringify, isBlank, _Object$keys, marked, BaseException, JsonPointer, InvalidPipeArgumentException, KeysPipe, ValuesPipe, JsonPointerEscapePipe, MarkedPipe;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_4) {
|
|
_createClass = _4['default'];
|
|
}, function (_3) {
|
|
_classCallCheck = _3['default'];
|
|
}, function (_6) {
|
|
Pipe = _6.Pipe;
|
|
}, function (_7) {
|
|
isString = _7.isString;
|
|
stringify = _7.stringify;
|
|
isBlank = _7.isBlank;
|
|
}, function (_5) {
|
|
_Object$keys = _5['default'];
|
|
}, function (_8) {
|
|
marked = _8['default'];
|
|
}, function (_c) {
|
|
BaseException = _c.BaseException;
|
|
}, function (_c2) {
|
|
JsonPointer = _c2.JsonPointer;
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
marked.setOptions({
|
|
renderer: new marked.Renderer(),
|
|
gfm: true,
|
|
tables: true,
|
|
breaks: false,
|
|
pedantic: false,
|
|
smartLists: true,
|
|
smartypants: false
|
|
});
|
|
|
|
InvalidPipeArgumentException = (function (_BaseException) {
|
|
_inherits(InvalidPipeArgumentException, _BaseException);
|
|
|
|
function InvalidPipeArgumentException(type, value) {
|
|
_classCallCheck(this, InvalidPipeArgumentException);
|
|
|
|
_get(Object.getPrototypeOf(InvalidPipeArgumentException.prototype), 'constructor', this).call(this, 'Invalid argument \'' + value + '\' for pipe \'' + stringify(type) + '\'');
|
|
}
|
|
|
|
return InvalidPipeArgumentException;
|
|
})(BaseException);
|
|
|
|
KeysPipe = (function () {
|
|
function KeysPipe() {
|
|
_classCallCheck(this, _KeysPipe);
|
|
}
|
|
|
|
_createClass(KeysPipe, [{
|
|
key: 'transform',
|
|
value: function transform(value) {
|
|
if (isBlank(value)) return value;
|
|
if (typeof value !== 'object') {
|
|
throw new InvalidPipeArgumentException(ValuesPipe, value);
|
|
}
|
|
return _Object$keys(value);
|
|
}
|
|
}]);
|
|
|
|
var _KeysPipe = KeysPipe;
|
|
KeysPipe = Pipe({ name: 'keys' })(KeysPipe) || KeysPipe;
|
|
return KeysPipe;
|
|
})();
|
|
|
|
_export('KeysPipe', KeysPipe);
|
|
|
|
ValuesPipe = (function () {
|
|
function ValuesPipe() {
|
|
_classCallCheck(this, _ValuesPipe);
|
|
}
|
|
|
|
_createClass(ValuesPipe, [{
|
|
key: 'transform',
|
|
value: function transform(value) {
|
|
if (isBlank(value)) return value;
|
|
if (typeof value !== 'object') {
|
|
throw new InvalidPipeArgumentException(ValuesPipe, value);
|
|
}
|
|
return _Object$keys(value).map(function (key) {
|
|
return value[key];
|
|
});
|
|
}
|
|
}]);
|
|
|
|
var _ValuesPipe = ValuesPipe;
|
|
ValuesPipe = Pipe({ name: 'values' })(ValuesPipe) || ValuesPipe;
|
|
return ValuesPipe;
|
|
})();
|
|
|
|
_export('ValuesPipe', ValuesPipe);
|
|
|
|
JsonPointerEscapePipe = (function () {
|
|
function JsonPointerEscapePipe() {
|
|
_classCallCheck(this, _JsonPointerEscapePipe);
|
|
}
|
|
|
|
_createClass(JsonPointerEscapePipe, [{
|
|
key: 'transform',
|
|
value: function transform(value) {
|
|
if (isBlank(value)) return value;
|
|
if (!isString(value)) {
|
|
throw new InvalidPipeArgumentException(JsonPointerEscapePipe, value);
|
|
}
|
|
return JsonPointer.escape(value);
|
|
}
|
|
}]);
|
|
|
|
var _JsonPointerEscapePipe = JsonPointerEscapePipe;
|
|
JsonPointerEscapePipe = Pipe({ name: 'jsonPointerEscape' })(JsonPointerEscapePipe) || JsonPointerEscapePipe;
|
|
return JsonPointerEscapePipe;
|
|
})();
|
|
|
|
_export('JsonPointerEscapePipe', JsonPointerEscapePipe);
|
|
|
|
MarkedPipe = (function () {
|
|
function MarkedPipe() {
|
|
_classCallCheck(this, _MarkedPipe);
|
|
}
|
|
|
|
_createClass(MarkedPipe, [{
|
|
key: 'transform',
|
|
value: function transform(value) {
|
|
if (isBlank(value)) return value;
|
|
if (!isString(value)) {
|
|
throw new InvalidPipeArgumentException(JsonPointerEscapePipe, value);
|
|
}
|
|
return marked(value);
|
|
}
|
|
}]);
|
|
|
|
var _MarkedPipe = MarkedPipe;
|
|
MarkedPipe = Pipe({ name: 'marked' })(MarkedPipe) || MarkedPipe;
|
|
return MarkedPipe;
|
|
})();
|
|
|
|
_export('MarkedPipe', MarkedPipe);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('3', ['6', '7', '14', '17', '22', '24', '32', '97', '1b', 'c', '19a'], function (_export) {
|
|
var _createClass, _classCallCheck, Component, View, OnInit, OnDestroy, ChangeDetectionStrategy, _Object$assign, CORE_DIRECTIVES, JsonPipe, _Object$keys, _getIterator, _toConsumableArray, SchemaManager, JsonPointer, MarkedPipe, JsonPointerEscapePipe, commonInputs, BaseComponent;
|
|
|
|
// json pointer to the schema chunk
|
|
|
|
// internal helper function
|
|
function safeConcat(a, b) {
|
|
var res = a && a.slice() || [];
|
|
b = b == null ? [] : b;
|
|
return res.concat(b);
|
|
}
|
|
|
|
/**
|
|
* Class decorator
|
|
* Simplifies setup of component metainfo
|
|
* All options are options from either Component or View angular2 decorator
|
|
* For detailed info look angular2 doc
|
|
* @param {Object} options - component options
|
|
* @param {string[]} options.inputs - component inputs
|
|
* @param {*[]} options.directives - directives used by component
|
|
* (except CORE_DIRECTIVES)
|
|
* @param {*[]} options.pipes - pipes used by component
|
|
* @param {*[]} options.providers - component providers
|
|
* @param {string} options.templateUrl - path to component template
|
|
* @param {string} options.template - component template html
|
|
* @param {string} options.styles - component css styles
|
|
*/
|
|
|
|
function RedocComponent(options) {
|
|
var inputs = safeConcat(options.inputs, commonInputs);
|
|
var directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
|
var pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe, JsonPipe]);
|
|
|
|
return function decorator(target) {
|
|
|
|
var componentDecorator = Component({
|
|
selector: options.selector,
|
|
inputs: inputs,
|
|
outputs: options.outputs,
|
|
lifecycle: [OnInit, OnDestroy],
|
|
providers: options.providers,
|
|
changeDetection: options.changeDetection || ChangeDetectionStrategy.Detached
|
|
});
|
|
var viewDecorator = View({
|
|
templateUrl: options.templateUrl,
|
|
template: options.template,
|
|
styles: options.styles,
|
|
directives: directives,
|
|
pipes: pipes
|
|
});
|
|
|
|
return componentDecorator(viewDecorator(target) || target) || target;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Generic Component
|
|
* @class
|
|
*/
|
|
return {
|
|
setters: [function (_) {
|
|
_createClass = _['default'];
|
|
}, function (_2) {
|
|
_classCallCheck = _2['default'];
|
|
}, function (_7) {
|
|
Component = _7.Component;
|
|
View = _7.View;
|
|
OnInit = _7.OnInit;
|
|
OnDestroy = _7.OnDestroy;
|
|
ChangeDetectionStrategy = _7.ChangeDetectionStrategy;
|
|
}, function (_4) {
|
|
_Object$assign = _4['default'];
|
|
}, function (_8) {
|
|
CORE_DIRECTIVES = _8.CORE_DIRECTIVES;
|
|
JsonPipe = _8.JsonPipe;
|
|
}, function (_5) {
|
|
_Object$keys = _5['default'];
|
|
}, function (_6) {
|
|
_getIterator = _6['default'];
|
|
}, function (_3) {
|
|
_toConsumableArray = _3['default'];
|
|
}, function (_b) {
|
|
SchemaManager = _b['default'];
|
|
}, function (_c) {
|
|
JsonPointer = _c['default'];
|
|
}, function (_a) {
|
|
MarkedPipe = _a.MarkedPipe;
|
|
JsonPointerEscapePipe = _a.JsonPointerEscapePipe;
|
|
}],
|
|
execute: function () {
|
|
|
|
// common inputs for all components
|
|
'use strict';
|
|
|
|
_export('RedocComponent', RedocComponent);
|
|
|
|
commonInputs = ['pointer'];
|
|
|
|
BaseComponent = (function () {
|
|
function BaseComponent(schemaMgr) {
|
|
_classCallCheck(this, BaseComponent);
|
|
|
|
this.schemaMgr = schemaMgr;
|
|
this.schema = schemaMgr.schema;
|
|
this.componentSchema = null;
|
|
}
|
|
|
|
/**
|
|
* onInit method is run by angular2 after all component inputs are resolved
|
|
*/
|
|
|
|
_createClass(BaseComponent, [{
|
|
key: 'ngOnInit',
|
|
value: function ngOnInit() {
|
|
this.componentSchema = this.schemaMgr.byPointer(this.pointer || '');
|
|
this.prepareModel();
|
|
this.init();
|
|
}
|
|
}, {
|
|
key: 'ngOnDestroy',
|
|
value: function ngOnDestroy() {
|
|
this.destroy();
|
|
}
|
|
|
|
/**
|
|
* simple in-place schema dereferencing. Schema is already bundled so no need in global dereferencing.
|
|
* TODO: doesn't support circular references
|
|
*/
|
|
}, {
|
|
key: 'dereference',
|
|
value: function dereference() {
|
|
var _this = this;
|
|
|
|
var schema = arguments.length <= 0 || arguments[0] === undefined ? _Object$assign({}, this.componentSchema) : arguments[0];
|
|
|
|
//schema = Object.assign({}, schema);
|
|
if (schema && schema.$ref) {
|
|
var resolved = this.schemaMgr.byPointer(schema.$ref);
|
|
var baseName = JsonPointer.baseName(schema.$ref);
|
|
// if resolved schema doesn't have title use name from ref
|
|
resolved = _Object$assign({}, resolved);
|
|
resolved.title = resolved.title || baseName;
|
|
resolved._pointer = schema.$ref;
|
|
_Object$assign(schema, resolved);
|
|
delete schema.$ref;
|
|
}
|
|
|
|
_Object$keys(schema).forEach(function (key) {
|
|
var value = schema[key];
|
|
if (value && typeof value === 'object') {
|
|
_this.dereference(value);
|
|
}
|
|
});
|
|
this.componentSchema = schema;
|
|
}
|
|
}, {
|
|
key: 'joinAllOf',
|
|
value: function joinAllOf() {
|
|
var schema = arguments.length <= 0 || arguments[0] === undefined ? this.componentSchema : arguments[0];
|
|
|
|
var self = this;
|
|
function merge(into, schemas) {
|
|
if (into.required || into.properties) {
|
|
var errMessage = 'Can\'t merge allOf: properties or required fields are specified on the same level as allOf\n ' + into;
|
|
throw new Error(errMessage);
|
|
}
|
|
into.required = [];
|
|
into.properties = {};
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = _getIterator(schemas), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var subSchema = _step.value;
|
|
|
|
// TODO: add support for merge array schemas
|
|
if (typeof subSchema !== 'object' || subSchema.type !== 'object') {
|
|
var errMessage = 'Can\'t merge allOf: only subschemas with type: object can be merged\n ' + subSchema;
|
|
throw new Error(errMessage);
|
|
}
|
|
|
|
self.joinAllOf(subSchema);
|
|
|
|
// TODO: add check if can be merged correctly (no different properties with the same name)
|
|
if (subSchema.properties) {
|
|
_Object$assign(into.properties, subSchema.properties);
|
|
}
|
|
if (subSchema.required) {
|
|
var _into$required;
|
|
|
|
(_into$required = into.required).push.apply(_into$required, _toConsumableArray(subSchema.required));
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator['return']) {
|
|
_iterator['return']();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
|
|
into.type = 'object';
|
|
into.allOf = null;
|
|
}
|
|
if (schema.allOf) {
|
|
merge(schema, schema.allOf);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Used to prepare model based on component schema
|
|
* @abstract
|
|
*/
|
|
}, {
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {}
|
|
|
|
/**
|
|
* Used to initialize component. Run after prepareModel
|
|
* @abstract
|
|
*/
|
|
}, {
|
|
key: 'init',
|
|
value: function init() {}
|
|
|
|
/**
|
|
+ Used to destroy component
|
|
* @abstract
|
|
*/
|
|
}, {
|
|
key: 'destroy',
|
|
value: function destroy() {}
|
|
}]);
|
|
|
|
return BaseComponent;
|
|
})();
|
|
|
|
_export('BaseComponent', BaseComponent);
|
|
|
|
BaseComponent.parameters = [[SchemaManager]];
|
|
}
|
|
};
|
|
});
|
|
$__System.registerDynamic("19b", ["19c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var decorators_1 = $__require('19c');
|
|
exports.Class = decorators_1.Class;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("19d", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.enableProdMode = lang_1.enableProdMode;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("19e", ["20", "63", "3c", "19f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.Type = lang_1.Type;
|
|
var async_1 = $__require('63');
|
|
exports.EventEmitter = async_1.EventEmitter;
|
|
var exceptions_1 = $__require('3c');
|
|
exports.WrappedException = exceptions_1.WrappedException;
|
|
var exception_handler_1 = $__require('19f');
|
|
exports.ExceptionHandler = exception_handler_1.ExceptionHandler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5b", ["52", "20", "39", "88", "63", "37", "5e", "1a0", "3c", "1a1", "1a2", "4c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var ng_zone_1 = $__require('52');
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var application_tokens_1 = $__require('88');
|
|
var async_1 = $__require('63');
|
|
var collection_1 = $__require('37');
|
|
var testability_1 = $__require('5e');
|
|
var dynamic_component_loader_1 = $__require('1a0');
|
|
var exceptions_1 = $__require('3c');
|
|
var view_ref_1 = $__require('1a1');
|
|
var console_1 = $__require('1a2');
|
|
var profile_1 = $__require('4c');
|
|
var lang_2 = $__require('20');
|
|
function _componentProviders(appComponentType) {
|
|
return [di_1.provide(application_tokens_1.APP_COMPONENT, {useValue: appComponentType}), di_1.provide(application_tokens_1.APP_COMPONENT_REF_PROMISE, {
|
|
useFactory: function(dynamicComponentLoader, appRef, injector) {
|
|
var ref;
|
|
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector, function() {
|
|
appRef._unloadComponent(ref);
|
|
}).then(function(componentRef) {
|
|
ref = componentRef;
|
|
if (lang_1.isPresent(componentRef.location.nativeElement)) {
|
|
injector.get(testability_1.TestabilityRegistry).registerApplication(componentRef.location.nativeElement, injector.get(testability_1.Testability));
|
|
}
|
|
return componentRef;
|
|
});
|
|
},
|
|
deps: [dynamic_component_loader_1.DynamicComponentLoader, ApplicationRef, di_1.Injector]
|
|
}), di_1.provide(appComponentType, {
|
|
useFactory: function(p) {
|
|
return p.then(function(ref) {
|
|
return ref.instance;
|
|
});
|
|
},
|
|
deps: [application_tokens_1.APP_COMPONENT_REF_PROMISE]
|
|
})];
|
|
}
|
|
function createNgZone() {
|
|
return new ng_zone_1.NgZone({enableLongStackTrace: lang_1.assertionsEnabled()});
|
|
}
|
|
exports.createNgZone = createNgZone;
|
|
var _platform;
|
|
var _platformProviders;
|
|
function platform(providers) {
|
|
lang_2.lockMode();
|
|
if (lang_1.isPresent(_platform)) {
|
|
if (collection_1.ListWrapper.equals(_platformProviders, providers)) {
|
|
return _platform;
|
|
} else {
|
|
throw new exceptions_1.BaseException("platform cannot be initialized with different sets of providers.");
|
|
}
|
|
} else {
|
|
return _createPlatform(providers);
|
|
}
|
|
}
|
|
exports.platform = platform;
|
|
function disposePlatform() {
|
|
if (lang_1.isPresent(_platform)) {
|
|
_platform.dispose();
|
|
_platform = null;
|
|
}
|
|
}
|
|
exports.disposePlatform = disposePlatform;
|
|
function _createPlatform(providers) {
|
|
_platformProviders = providers;
|
|
var injector = di_1.Injector.resolveAndCreate(providers);
|
|
_platform = new PlatformRef_(injector, function() {
|
|
_platform = null;
|
|
_platformProviders = null;
|
|
});
|
|
_runPlatformInitializers(injector);
|
|
return _platform;
|
|
}
|
|
function _runPlatformInitializers(injector) {
|
|
var inits = injector.getOptional(application_tokens_1.PLATFORM_INITIALIZER);
|
|
if (lang_1.isPresent(inits))
|
|
inits.forEach(function(init) {
|
|
return init();
|
|
});
|
|
}
|
|
var PlatformRef = (function() {
|
|
function PlatformRef() {}
|
|
Object.defineProperty(PlatformRef.prototype, "injector", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return PlatformRef;
|
|
})();
|
|
exports.PlatformRef = PlatformRef;
|
|
var PlatformRef_ = (function(_super) {
|
|
__extends(PlatformRef_, _super);
|
|
function PlatformRef_(_injector, _dispose) {
|
|
_super.call(this);
|
|
this._injector = _injector;
|
|
this._dispose = _dispose;
|
|
this._applications = [];
|
|
this._disposeListeners = [];
|
|
}
|
|
PlatformRef_.prototype.registerDisposeListener = function(dispose) {
|
|
this._disposeListeners.push(dispose);
|
|
};
|
|
Object.defineProperty(PlatformRef_.prototype, "injector", {
|
|
get: function() {
|
|
return this._injector;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
PlatformRef_.prototype.application = function(providers) {
|
|
var app = this._initApp(createNgZone(), providers);
|
|
return app;
|
|
};
|
|
PlatformRef_.prototype.asyncApplication = function(bindingFn, additionalProviders) {
|
|
var _this = this;
|
|
var zone = createNgZone();
|
|
var completer = async_1.PromiseWrapper.completer();
|
|
zone.run(function() {
|
|
async_1.PromiseWrapper.then(bindingFn(zone), function(providers) {
|
|
if (lang_1.isPresent(additionalProviders)) {
|
|
providers = collection_1.ListWrapper.concat(providers, additionalProviders);
|
|
}
|
|
completer.resolve(_this._initApp(zone, providers));
|
|
});
|
|
});
|
|
return completer.promise;
|
|
};
|
|
PlatformRef_.prototype._initApp = function(zone, providers) {
|
|
var _this = this;
|
|
var injector;
|
|
var app;
|
|
zone.run(function() {
|
|
providers = collection_1.ListWrapper.concat(providers, [di_1.provide(ng_zone_1.NgZone, {useValue: zone}), di_1.provide(ApplicationRef, {
|
|
useFactory: function() {
|
|
return app;
|
|
},
|
|
deps: []
|
|
})]);
|
|
var exceptionHandler;
|
|
try {
|
|
injector = _this.injector.resolveAndCreateChild(providers);
|
|
exceptionHandler = injector.get(exceptions_1.ExceptionHandler);
|
|
zone.overrideOnErrorHandler(function(e, s) {
|
|
return exceptionHandler.call(e, s);
|
|
});
|
|
} catch (e) {
|
|
if (lang_1.isPresent(exceptionHandler)) {
|
|
exceptionHandler.call(e, e.stack);
|
|
} else {
|
|
lang_1.print(e.toString());
|
|
}
|
|
}
|
|
});
|
|
app = new ApplicationRef_(this, zone, injector);
|
|
this._applications.push(app);
|
|
_runAppInitializers(injector);
|
|
return app;
|
|
};
|
|
PlatformRef_.prototype.dispose = function() {
|
|
collection_1.ListWrapper.clone(this._applications).forEach(function(app) {
|
|
return app.dispose();
|
|
});
|
|
this._disposeListeners.forEach(function(dispose) {
|
|
return dispose();
|
|
});
|
|
this._dispose();
|
|
};
|
|
PlatformRef_.prototype._applicationDisposed = function(app) {
|
|
collection_1.ListWrapper.remove(this._applications, app);
|
|
};
|
|
return PlatformRef_;
|
|
})(PlatformRef);
|
|
exports.PlatformRef_ = PlatformRef_;
|
|
function _runAppInitializers(injector) {
|
|
var inits = injector.getOptional(application_tokens_1.APP_INITIALIZER);
|
|
if (lang_1.isPresent(inits))
|
|
inits.forEach(function(init) {
|
|
return init();
|
|
});
|
|
}
|
|
var ApplicationRef = (function() {
|
|
function ApplicationRef() {}
|
|
Object.defineProperty(ApplicationRef.prototype, "injector", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(ApplicationRef.prototype, "zone", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(ApplicationRef.prototype, "componentTypes", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return ApplicationRef;
|
|
})();
|
|
exports.ApplicationRef = ApplicationRef;
|
|
var ApplicationRef_ = (function(_super) {
|
|
__extends(ApplicationRef_, _super);
|
|
function ApplicationRef_(_platform, _zone, _injector) {
|
|
var _this = this;
|
|
_super.call(this);
|
|
this._platform = _platform;
|
|
this._zone = _zone;
|
|
this._injector = _injector;
|
|
this._bootstrapListeners = [];
|
|
this._disposeListeners = [];
|
|
this._rootComponents = [];
|
|
this._rootComponentTypes = [];
|
|
this._changeDetectorRefs = [];
|
|
this._runningTick = false;
|
|
this._enforceNoNewChanges = false;
|
|
if (lang_1.isPresent(this._zone)) {
|
|
async_1.ObservableWrapper.subscribe(this._zone.onTurnDone, function(_) {
|
|
_this._zone.run(function() {
|
|
_this.tick();
|
|
});
|
|
});
|
|
}
|
|
this._enforceNoNewChanges = lang_1.assertionsEnabled();
|
|
}
|
|
ApplicationRef_.prototype.registerBootstrapListener = function(listener) {
|
|
this._bootstrapListeners.push(listener);
|
|
};
|
|
ApplicationRef_.prototype.registerDisposeListener = function(dispose) {
|
|
this._disposeListeners.push(dispose);
|
|
};
|
|
ApplicationRef_.prototype.registerChangeDetector = function(changeDetector) {
|
|
this._changeDetectorRefs.push(changeDetector);
|
|
};
|
|
ApplicationRef_.prototype.unregisterChangeDetector = function(changeDetector) {
|
|
collection_1.ListWrapper.remove(this._changeDetectorRefs, changeDetector);
|
|
};
|
|
ApplicationRef_.prototype.bootstrap = function(componentType, providers) {
|
|
var _this = this;
|
|
var completer = async_1.PromiseWrapper.completer();
|
|
this._zone.run(function() {
|
|
var componentProviders = _componentProviders(componentType);
|
|
if (lang_1.isPresent(providers)) {
|
|
componentProviders.push(providers);
|
|
}
|
|
var exceptionHandler = _this._injector.get(exceptions_1.ExceptionHandler);
|
|
_this._rootComponentTypes.push(componentType);
|
|
try {
|
|
var injector = _this._injector.resolveAndCreateChild(componentProviders);
|
|
var compRefToken = injector.get(application_tokens_1.APP_COMPONENT_REF_PROMISE);
|
|
var tick = function(componentRef) {
|
|
_this._loadComponent(componentRef);
|
|
completer.resolve(componentRef);
|
|
};
|
|
var tickResult = async_1.PromiseWrapper.then(compRefToken, tick);
|
|
if (lang_1.IS_DART) {
|
|
async_1.PromiseWrapper.then(tickResult, function(_) {});
|
|
}
|
|
async_1.PromiseWrapper.then(tickResult, null, function(err, stackTrace) {
|
|
return completer.reject(err, stackTrace);
|
|
});
|
|
} catch (e) {
|
|
exceptionHandler.call(e, e.stack);
|
|
completer.reject(e, e.stack);
|
|
}
|
|
});
|
|
return completer.promise.then(function(_) {
|
|
var c = _this._injector.get(console_1.Console);
|
|
var modeDescription = lang_1.assertionsEnabled() ? "in the development mode. Call enableProdMode() to enable the production mode." : "in the production mode. Call enableDevMode() to enable the development mode.";
|
|
c.log("Angular 2 is running " + modeDescription);
|
|
return _;
|
|
});
|
|
};
|
|
ApplicationRef_.prototype._loadComponent = function(ref) {
|
|
var appChangeDetector = view_ref_1.internalView(ref.hostView).changeDetector;
|
|
this._changeDetectorRefs.push(appChangeDetector.ref);
|
|
this.tick();
|
|
this._rootComponents.push(ref);
|
|
this._bootstrapListeners.forEach(function(listener) {
|
|
return listener(ref);
|
|
});
|
|
};
|
|
ApplicationRef_.prototype._unloadComponent = function(ref) {
|
|
if (!collection_1.ListWrapper.contains(this._rootComponents, ref)) {
|
|
return;
|
|
}
|
|
this.unregisterChangeDetector(view_ref_1.internalView(ref.hostView).changeDetector.ref);
|
|
collection_1.ListWrapper.remove(this._rootComponents, ref);
|
|
};
|
|
Object.defineProperty(ApplicationRef_.prototype, "injector", {
|
|
get: function() {
|
|
return this._injector;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ApplicationRef_.prototype, "zone", {
|
|
get: function() {
|
|
return this._zone;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ApplicationRef_.prototype.tick = function() {
|
|
if (this._runningTick) {
|
|
throw new exceptions_1.BaseException("ApplicationRef.tick is called recursively");
|
|
}
|
|
var s = ApplicationRef_._tickScope();
|
|
try {
|
|
this._runningTick = true;
|
|
this._changeDetectorRefs.forEach(function(detector) {
|
|
return detector.detectChanges();
|
|
});
|
|
if (this._enforceNoNewChanges) {
|
|
this._changeDetectorRefs.forEach(function(detector) {
|
|
return detector.checkNoChanges();
|
|
});
|
|
}
|
|
} finally {
|
|
this._runningTick = false;
|
|
profile_1.wtfLeave(s);
|
|
}
|
|
};
|
|
ApplicationRef_.prototype.dispose = function() {
|
|
collection_1.ListWrapper.clone(this._rootComponents).forEach(function(ref) {
|
|
return ref.dispose();
|
|
});
|
|
this._disposeListeners.forEach(function(dispose) {
|
|
return dispose();
|
|
});
|
|
this._platform._applicationDisposed(this);
|
|
};
|
|
Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
|
|
get: function() {
|
|
return this._rootComponentTypes;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ApplicationRef_._tickScope = profile_1.wtfCreateScope('ApplicationRef#tick()');
|
|
return ApplicationRef_;
|
|
})(ApplicationRef);
|
|
exports.ApplicationRef_ = ApplicationRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a3", ["52"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var ng_zone_1 = $__require('52');
|
|
exports.NgZone = ng_zone_1.NgZone;
|
|
exports.NgZoneError = ng_zone_1.NgZoneError;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a4", ["56"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var api_1 = $__require('56');
|
|
exports.Renderer = api_1.Renderer;
|
|
exports.RenderViewRef = api_1.RenderViewRef;
|
|
exports.RenderProtoViewRef = api_1.RenderProtoViewRef;
|
|
exports.RenderFragmentRef = api_1.RenderFragmentRef;
|
|
exports.RenderViewWithFragments = api_1.RenderViewWithFragments;
|
|
exports.RenderTemplateCmd = api_1.RenderTemplateCmd;
|
|
exports.RenderTextCmd = api_1.RenderTextCmd;
|
|
exports.RenderNgContentCmd = api_1.RenderNgContentCmd;
|
|
exports.RenderBeginElementCmd = api_1.RenderBeginElementCmd;
|
|
exports.RenderBeginComponentCmd = api_1.RenderBeginComponentCmd;
|
|
exports.RenderEmbeddedTemplateCmd = api_1.RenderEmbeddedTemplateCmd;
|
|
exports.RenderBeginCmd = api_1.RenderBeginCmd;
|
|
exports.RenderComponentTemplate = api_1.RenderComponentTemplate;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a5", ["7e", "7f", "60", "1a6", "1a7", "1a0", "1a8", "1a9", "1a1", "1aa"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var directive_resolver_1 = $__require('7e');
|
|
exports.DirectiveResolver = directive_resolver_1.DirectiveResolver;
|
|
var view_resolver_1 = $__require('7f');
|
|
exports.ViewResolver = view_resolver_1.ViewResolver;
|
|
var compiler_1 = $__require('60');
|
|
exports.Compiler = compiler_1.Compiler;
|
|
var view_manager_1 = $__require('1a6');
|
|
exports.AppViewManager = view_manager_1.AppViewManager;
|
|
var query_list_1 = $__require('1a7');
|
|
exports.QueryList = query_list_1.QueryList;
|
|
var dynamic_component_loader_1 = $__require('1a0');
|
|
exports.DynamicComponentLoader = dynamic_component_loader_1.DynamicComponentLoader;
|
|
var element_ref_1 = $__require('1a8');
|
|
exports.ElementRef = element_ref_1.ElementRef;
|
|
var template_ref_1 = $__require('1a9');
|
|
exports.TemplateRef = template_ref_1.TemplateRef;
|
|
var view_ref_1 = $__require('1a1');
|
|
exports.ViewRef = view_ref_1.ViewRef;
|
|
exports.ProtoViewRef = view_ref_1.ProtoViewRef;
|
|
var view_container_ref_1 = $__require('1aa');
|
|
exports.ViewContainerRef = view_container_ref_1.ViewContainerRef;
|
|
var dynamic_component_loader_2 = $__require('1a0');
|
|
exports.ComponentRef = dynamic_component_loader_2.ComponentRef;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("57", ["20", "3c", "1ab", "1a1"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var view_1 = $__require('1ab');
|
|
var view_ref_1 = $__require('1a1');
|
|
var DebugElement = (function() {
|
|
function DebugElement() {}
|
|
Object.defineProperty(DebugElement.prototype, "componentInstance", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(DebugElement.prototype, "nativeElement", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(DebugElement.prototype, "elementRef", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(DebugElement.prototype, "children", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(DebugElement.prototype, "componentViewChildren", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
DebugElement.prototype.query = function(predicate, scope) {
|
|
if (scope === void 0) {
|
|
scope = Scope.all;
|
|
}
|
|
var results = this.queryAll(predicate, scope);
|
|
return results.length > 0 ? results[0] : null;
|
|
};
|
|
DebugElement.prototype.queryAll = function(predicate, scope) {
|
|
if (scope === void 0) {
|
|
scope = Scope.all;
|
|
}
|
|
var elementsInScope = scope(this);
|
|
return elementsInScope.filter(predicate);
|
|
};
|
|
return DebugElement;
|
|
})();
|
|
exports.DebugElement = DebugElement;
|
|
var DebugElement_ = (function(_super) {
|
|
__extends(DebugElement_, _super);
|
|
function DebugElement_(_parentView, _boundElementIndex) {
|
|
_super.call(this);
|
|
this._parentView = _parentView;
|
|
this._boundElementIndex = _boundElementIndex;
|
|
this._elementInjector = this._parentView.elementInjectors[this._boundElementIndex];
|
|
}
|
|
Object.defineProperty(DebugElement_.prototype, "componentInstance", {
|
|
get: function() {
|
|
if (!lang_1.isPresent(this._elementInjector)) {
|
|
return null;
|
|
}
|
|
return this._elementInjector.getComponent();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DebugElement_.prototype, "nativeElement", {
|
|
get: function() {
|
|
return this.elementRef.nativeElement;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DebugElement_.prototype, "elementRef", {
|
|
get: function() {
|
|
return this._parentView.elementRefs[this._boundElementIndex];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DebugElement_.prototype.getDirectiveInstance = function(directiveIndex) {
|
|
return this._elementInjector.getDirectiveAtIndex(directiveIndex);
|
|
};
|
|
Object.defineProperty(DebugElement_.prototype, "children", {
|
|
get: function() {
|
|
return this._getChildElements(this._parentView, this._boundElementIndex);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DebugElement_.prototype, "componentViewChildren", {
|
|
get: function() {
|
|
var shadowView = this._parentView.getNestedView(this._boundElementIndex);
|
|
if (!lang_1.isPresent(shadowView) || shadowView.proto.type !== view_1.ViewType.COMPONENT) {
|
|
return [];
|
|
}
|
|
return this._getChildElements(shadowView, null);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DebugElement_.prototype.triggerEventHandler = function(eventName, eventObj) {
|
|
this._parentView.triggerEventHandlers(eventName, eventObj, this._boundElementIndex);
|
|
};
|
|
DebugElement_.prototype.hasDirective = function(type) {
|
|
if (!lang_1.isPresent(this._elementInjector)) {
|
|
return false;
|
|
}
|
|
return this._elementInjector.hasDirective(type);
|
|
};
|
|
DebugElement_.prototype.inject = function(type) {
|
|
if (!lang_1.isPresent(this._elementInjector)) {
|
|
return null;
|
|
}
|
|
return this._elementInjector.get(type);
|
|
};
|
|
DebugElement_.prototype.getLocal = function(name) {
|
|
return this._parentView.locals.get(name);
|
|
};
|
|
DebugElement_.prototype._getChildElements = function(view, parentBoundElementIndex) {
|
|
var _this = this;
|
|
var els = [];
|
|
var parentElementBinder = null;
|
|
if (lang_1.isPresent(parentBoundElementIndex)) {
|
|
parentElementBinder = view.proto.elementBinders[parentBoundElementIndex - view.elementOffset];
|
|
}
|
|
for (var i = 0; i < view.proto.elementBinders.length; ++i) {
|
|
var binder = view.proto.elementBinders[i];
|
|
if (binder.parent == parentElementBinder) {
|
|
els.push(new DebugElement_(view, view.elementOffset + i));
|
|
var views = view.viewContainers[view.elementOffset + i];
|
|
if (lang_1.isPresent(views)) {
|
|
views.views.forEach(function(nextView) {
|
|
els = els.concat(_this._getChildElements(nextView, null));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
return els;
|
|
};
|
|
return DebugElement_;
|
|
})(DebugElement);
|
|
exports.DebugElement_ = DebugElement_;
|
|
function inspectElement(elementRef) {
|
|
return new DebugElement_(view_ref_1.internalView(elementRef.parentView), elementRef.boundElementIndex);
|
|
}
|
|
exports.inspectElement = inspectElement;
|
|
function asNativeElements(arr) {
|
|
return arr.map(function(debugEl) {
|
|
return debugEl.nativeElement;
|
|
});
|
|
}
|
|
exports.asNativeElements = asNativeElements;
|
|
var Scope = (function() {
|
|
function Scope() {}
|
|
Scope.all = function(debugElement) {
|
|
var scope = [];
|
|
scope.push(debugElement);
|
|
debugElement.children.forEach(function(child) {
|
|
return scope = scope.concat(Scope.all(child));
|
|
});
|
|
debugElement.componentViewChildren.forEach(function(child) {
|
|
return scope = scope.concat(Scope.all(child));
|
|
});
|
|
return scope;
|
|
};
|
|
Scope.light = function(debugElement) {
|
|
var scope = [];
|
|
debugElement.children.forEach(function(child) {
|
|
scope.push(child);
|
|
scope = scope.concat(Scope.light(child));
|
|
});
|
|
return scope;
|
|
};
|
|
Scope.view = function(debugElement) {
|
|
var scope = [];
|
|
debugElement.componentViewChildren.forEach(function(child) {
|
|
scope.push(child);
|
|
scope = scope.concat(Scope.light(child));
|
|
});
|
|
return scope;
|
|
};
|
|
return Scope;
|
|
})();
|
|
exports.Scope = Scope;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a2", ["39", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var Console = (function() {
|
|
function Console() {}
|
|
Console.prototype.log = function(message) {
|
|
lang_1.print(message);
|
|
};
|
|
Console = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], Console);
|
|
return Console;
|
|
})();
|
|
exports.Console = Console;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("52", ["37", "20", "63", "4c", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var profile_1 = $__require('4c');
|
|
var NgZoneError = (function() {
|
|
function NgZoneError(error, stackTrace) {
|
|
this.error = error;
|
|
this.stackTrace = stackTrace;
|
|
}
|
|
return NgZoneError;
|
|
})();
|
|
exports.NgZoneError = NgZoneError;
|
|
var NgZone = (function() {
|
|
function NgZone(_a) {
|
|
var enableLongStackTrace = _a.enableLongStackTrace;
|
|
this._runScope = profile_1.wtfCreateScope("NgZone#run()");
|
|
this._microtaskScope = profile_1.wtfCreateScope("NgZone#microtask()");
|
|
this._pendingMicrotasks = 0;
|
|
this._hasExecutedCodeInInnerZone = false;
|
|
this._nestedRun = 0;
|
|
this._inVmTurnDone = false;
|
|
this._pendingTimeouts = [];
|
|
if (lang_1.global.zone) {
|
|
this._disabled = false;
|
|
this._mountZone = lang_1.global.zone;
|
|
this._innerZone = this._createInnerZone(this._mountZone, enableLongStackTrace);
|
|
} else {
|
|
this._disabled = true;
|
|
this._mountZone = null;
|
|
}
|
|
this._onTurnStartEvents = new async_1.EventEmitter(false);
|
|
this._onTurnDoneEvents = new async_1.EventEmitter(false);
|
|
this._onEventDoneEvents = new async_1.EventEmitter(false);
|
|
this._onErrorEvents = new async_1.EventEmitter(false);
|
|
}
|
|
NgZone.prototype.overrideOnTurnStart = function(onTurnStartHook) {
|
|
this._onTurnStart = lang_1.normalizeBlank(onTurnStartHook);
|
|
};
|
|
Object.defineProperty(NgZone.prototype, "onTurnStart", {
|
|
get: function() {
|
|
return this._onTurnStartEvents;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgZone.prototype._notifyOnTurnStart = function(parentRun) {
|
|
var _this = this;
|
|
parentRun.call(this._innerZone, function() {
|
|
_this._onTurnStartEvents.emit(null);
|
|
});
|
|
};
|
|
NgZone.prototype.overrideOnTurnDone = function(onTurnDoneHook) {
|
|
this._onTurnDone = lang_1.normalizeBlank(onTurnDoneHook);
|
|
};
|
|
Object.defineProperty(NgZone.prototype, "onTurnDone", {
|
|
get: function() {
|
|
return this._onTurnDoneEvents;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgZone.prototype._notifyOnTurnDone = function(parentRun) {
|
|
var _this = this;
|
|
parentRun.call(this._innerZone, function() {
|
|
_this._onTurnDoneEvents.emit(null);
|
|
});
|
|
};
|
|
NgZone.prototype.overrideOnEventDone = function(onEventDoneFn, opt_waitForAsync) {
|
|
var _this = this;
|
|
if (opt_waitForAsync === void 0) {
|
|
opt_waitForAsync = false;
|
|
}
|
|
var normalizedOnEventDone = lang_1.normalizeBlank(onEventDoneFn);
|
|
if (opt_waitForAsync) {
|
|
this._onEventDone = function() {
|
|
if (!_this._pendingTimeouts.length) {
|
|
normalizedOnEventDone();
|
|
}
|
|
};
|
|
} else {
|
|
this._onEventDone = normalizedOnEventDone;
|
|
}
|
|
};
|
|
Object.defineProperty(NgZone.prototype, "onEventDone", {
|
|
get: function() {
|
|
return this._onEventDoneEvents;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgZone.prototype._notifyOnEventDone = function() {
|
|
var _this = this;
|
|
this.runOutsideAngular(function() {
|
|
_this._onEventDoneEvents.emit(null);
|
|
});
|
|
};
|
|
Object.defineProperty(NgZone.prototype, "hasPendingMicrotasks", {
|
|
get: function() {
|
|
return this._pendingMicrotasks > 0;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgZone.prototype, "hasPendingTimers", {
|
|
get: function() {
|
|
return this._pendingTimeouts.length > 0;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(NgZone.prototype, "hasPendingAsyncTasks", {
|
|
get: function() {
|
|
return this.hasPendingMicrotasks || this.hasPendingTimers;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgZone.prototype.overrideOnErrorHandler = function(errorHandler) {
|
|
this._onErrorHandler = lang_1.normalizeBlank(errorHandler);
|
|
};
|
|
Object.defineProperty(NgZone.prototype, "onError", {
|
|
get: function() {
|
|
return this._onErrorEvents;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NgZone.prototype.run = function(fn) {
|
|
if (this._disabled) {
|
|
return fn();
|
|
} else {
|
|
var s = this._runScope();
|
|
try {
|
|
return this._innerZone.run(fn);
|
|
} finally {
|
|
profile_1.wtfLeave(s);
|
|
}
|
|
}
|
|
};
|
|
NgZone.prototype.runOutsideAngular = function(fn) {
|
|
if (this._disabled) {
|
|
return fn();
|
|
} else {
|
|
return this._mountZone.run(fn);
|
|
}
|
|
};
|
|
NgZone.prototype._createInnerZone = function(zone, enableLongStackTrace) {
|
|
var microtaskScope = this._microtaskScope;
|
|
var ngZone = this;
|
|
var errorHandling;
|
|
if (enableLongStackTrace) {
|
|
errorHandling = collection_1.StringMapWrapper.merge(Zone.longStackTraceZone, {onError: function(e) {
|
|
ngZone._notifyOnError(this, e);
|
|
}});
|
|
} else {
|
|
errorHandling = {onError: function(e) {
|
|
ngZone._notifyOnError(this, e);
|
|
}};
|
|
}
|
|
return zone.fork(errorHandling).fork({
|
|
'$run': function(parentRun) {
|
|
return function() {
|
|
try {
|
|
ngZone._nestedRun++;
|
|
if (!ngZone._hasExecutedCodeInInnerZone) {
|
|
ngZone._hasExecutedCodeInInnerZone = true;
|
|
ngZone._notifyOnTurnStart(parentRun);
|
|
if (ngZone._onTurnStart) {
|
|
parentRun.call(ngZone._innerZone, ngZone._onTurnStart);
|
|
}
|
|
}
|
|
return parentRun.apply(this, arguments);
|
|
} finally {
|
|
ngZone._nestedRun--;
|
|
if (ngZone._pendingMicrotasks == 0 && ngZone._nestedRun == 0 && !this._inVmTurnDone) {
|
|
if (ngZone._hasExecutedCodeInInnerZone) {
|
|
try {
|
|
this._inVmTurnDone = true;
|
|
ngZone._notifyOnTurnDone(parentRun);
|
|
if (ngZone._onTurnDone) {
|
|
parentRun.call(ngZone._innerZone, ngZone._onTurnDone);
|
|
}
|
|
} finally {
|
|
this._inVmTurnDone = false;
|
|
ngZone._hasExecutedCodeInInnerZone = false;
|
|
}
|
|
}
|
|
if (ngZone._pendingMicrotasks === 0) {
|
|
ngZone._notifyOnEventDone();
|
|
if (lang_1.isPresent(ngZone._onEventDone)) {
|
|
ngZone.runOutsideAngular(ngZone._onEventDone);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
},
|
|
'$scheduleMicrotask': function(parentScheduleMicrotask) {
|
|
return function(fn) {
|
|
ngZone._pendingMicrotasks++;
|
|
var microtask = function() {
|
|
var s = microtaskScope();
|
|
try {
|
|
fn();
|
|
} finally {
|
|
ngZone._pendingMicrotasks--;
|
|
profile_1.wtfLeave(s);
|
|
}
|
|
};
|
|
parentScheduleMicrotask.call(this, microtask);
|
|
};
|
|
},
|
|
'$setTimeout': function(parentSetTimeout) {
|
|
return function(fn, delay) {
|
|
var args = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
args[_i - 2] = arguments[_i];
|
|
}
|
|
var id;
|
|
var cb = function() {
|
|
fn();
|
|
collection_1.ListWrapper.remove(ngZone._pendingTimeouts, id);
|
|
};
|
|
id = parentSetTimeout(cb, delay, args);
|
|
ngZone._pendingTimeouts.push(id);
|
|
return id;
|
|
};
|
|
},
|
|
'$clearTimeout': function(parentClearTimeout) {
|
|
return function(id) {
|
|
parentClearTimeout(id);
|
|
collection_1.ListWrapper.remove(ngZone._pendingTimeouts, id);
|
|
};
|
|
},
|
|
_innerZone: true
|
|
});
|
|
};
|
|
NgZone.prototype._notifyOnError = function(zone, e) {
|
|
if (lang_1.isPresent(this._onErrorHandler) || async_1.ObservableWrapper.hasSubscribers(this._onErrorEvents)) {
|
|
var trace = [lang_1.normalizeBlank(e.stack)];
|
|
while (zone && zone.constructedAtException) {
|
|
trace.push(zone.constructedAtException.get());
|
|
zone = zone.parent;
|
|
}
|
|
if (async_1.ObservableWrapper.hasSubscribers(this._onErrorEvents)) {
|
|
async_1.ObservableWrapper.callEmit(this._onErrorEvents, new NgZoneError(e, trace));
|
|
}
|
|
if (lang_1.isPresent(this._onErrorHandler)) {
|
|
this._onErrorHandler(e, trace);
|
|
}
|
|
} else {
|
|
console.log('## _notifyOnError ##');
|
|
console.log(e.stack);
|
|
throw e;
|
|
}
|
|
};
|
|
return NgZone;
|
|
})();
|
|
exports.NgZone = NgZone;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5e", ["39", "37", "20", "3c", "52", "63"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var ng_zone_1 = $__require('52');
|
|
var async_1 = $__require('63');
|
|
var Testability = (function() {
|
|
function Testability(_ngZone) {
|
|
this._pendingCount = 0;
|
|
this._callbacks = [];
|
|
this._isAngularEventPending = false;
|
|
this._watchAngularEvents(_ngZone);
|
|
}
|
|
Testability.prototype._watchAngularEvents = function(_ngZone) {
|
|
var _this = this;
|
|
async_1.ObservableWrapper.subscribe(_ngZone.onTurnStart, function(_) {
|
|
_this._isAngularEventPending = true;
|
|
});
|
|
_ngZone.runOutsideAngular(function() {
|
|
async_1.ObservableWrapper.subscribe(_ngZone.onEventDone, function(_) {
|
|
if (!_ngZone.hasPendingTimers) {
|
|
_this._isAngularEventPending = false;
|
|
_this._runCallbacksIfReady();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
Testability.prototype.increasePendingRequestCount = function() {
|
|
this._pendingCount += 1;
|
|
return this._pendingCount;
|
|
};
|
|
Testability.prototype.decreasePendingRequestCount = function() {
|
|
this._pendingCount -= 1;
|
|
if (this._pendingCount < 0) {
|
|
throw new exceptions_1.BaseException('pending async requests below zero');
|
|
}
|
|
this._runCallbacksIfReady();
|
|
return this._pendingCount;
|
|
};
|
|
Testability.prototype.isStable = function() {
|
|
return this._pendingCount == 0 && !this._isAngularEventPending;
|
|
};
|
|
Testability.prototype._runCallbacksIfReady = function() {
|
|
var _this = this;
|
|
if (!this.isStable()) {
|
|
return;
|
|
}
|
|
async_1.PromiseWrapper.resolve(null).then(function(_) {
|
|
while (_this._callbacks.length !== 0) {
|
|
(_this._callbacks.pop())();
|
|
}
|
|
});
|
|
};
|
|
Testability.prototype.whenStable = function(callback) {
|
|
this._callbacks.push(callback);
|
|
this._runCallbacksIfReady();
|
|
};
|
|
Testability.prototype.getPendingRequestCount = function() {
|
|
return this._pendingCount;
|
|
};
|
|
Testability.prototype.isAngularEventPending = function() {
|
|
return this._isAngularEventPending;
|
|
};
|
|
Testability.prototype.findBindings = function(using, provider, exactMatch) {
|
|
return [];
|
|
};
|
|
Testability.prototype.findProviders = function(using, provider, exactMatch) {
|
|
return [];
|
|
};
|
|
Testability = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [ng_zone_1.NgZone])], Testability);
|
|
return Testability;
|
|
})();
|
|
exports.Testability = Testability;
|
|
var TestabilityRegistry = (function() {
|
|
function TestabilityRegistry() {
|
|
this._applications = new collection_1.Map();
|
|
_testabilityGetter.addToWindow(this);
|
|
}
|
|
TestabilityRegistry.prototype.registerApplication = function(token, testability) {
|
|
this._applications.set(token, testability);
|
|
};
|
|
TestabilityRegistry.prototype.getTestability = function(elem) {
|
|
return this._applications.get(elem);
|
|
};
|
|
TestabilityRegistry.prototype.getAllTestabilities = function() {
|
|
return collection_1.MapWrapper.values(this._applications);
|
|
};
|
|
TestabilityRegistry.prototype.findTestabilityInTree = function(elem, findInAncestors) {
|
|
if (findInAncestors === void 0) {
|
|
findInAncestors = true;
|
|
}
|
|
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
|
|
};
|
|
TestabilityRegistry = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], TestabilityRegistry);
|
|
return TestabilityRegistry;
|
|
})();
|
|
exports.TestabilityRegistry = TestabilityRegistry;
|
|
var _NoopGetTestability = (function() {
|
|
function _NoopGetTestability() {}
|
|
_NoopGetTestability.prototype.addToWindow = function(registry) {};
|
|
_NoopGetTestability.prototype.findTestabilityInTree = function(registry, elem, findInAncestors) {
|
|
return null;
|
|
};
|
|
_NoopGetTestability = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], _NoopGetTestability);
|
|
return _NoopGetTestability;
|
|
})();
|
|
function setTestabilityGetter(getter) {
|
|
_testabilityGetter = getter;
|
|
}
|
|
exports.setTestabilityGetter = setTestabilityGetter;
|
|
var _testabilityGetter = lang_1.CONST_EXPR(new _NoopGetTestability());
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ac", ["20", "39", "1a2", "81", "5e"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var console_1 = $__require('1a2');
|
|
var reflection_1 = $__require('81');
|
|
var testability_1 = $__require('5e');
|
|
function _reflector() {
|
|
return reflection_1.reflector;
|
|
}
|
|
exports.PLATFORM_COMMON_PROVIDERS = lang_1.CONST_EXPR([new di_1.Provider(reflection_1.Reflector, {
|
|
useFactory: _reflector,
|
|
deps: []
|
|
}), testability_1.TestabilityRegistry, console_1.Console]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("60", ["61", "39", "20", "3c", "63", "81", "64"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var proto_view_factory_1 = $__require('61');
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var async_1 = $__require('63');
|
|
var reflection_1 = $__require('81');
|
|
var template_commands_1 = $__require('64');
|
|
var Compiler = (function() {
|
|
function Compiler() {}
|
|
return Compiler;
|
|
})();
|
|
exports.Compiler = Compiler;
|
|
function _isCompiledHostTemplate(type) {
|
|
return type instanceof template_commands_1.CompiledHostTemplate;
|
|
}
|
|
var Compiler_ = (function(_super) {
|
|
__extends(Compiler_, _super);
|
|
function Compiler_(_protoViewFactory) {
|
|
_super.call(this);
|
|
this._protoViewFactory = _protoViewFactory;
|
|
}
|
|
Compiler_.prototype.compileInHost = function(componentType) {
|
|
var metadatas = reflection_1.reflector.annotations(componentType);
|
|
var compiledHostTemplate = metadatas.find(_isCompiledHostTemplate);
|
|
if (lang_1.isBlank(compiledHostTemplate)) {
|
|
throw new exceptions_1.BaseException("No precompiled template for component " + lang_1.stringify(componentType) + " found");
|
|
}
|
|
return async_1.PromiseWrapper.resolve(this._createProtoView(compiledHostTemplate));
|
|
};
|
|
Compiler_.prototype._createProtoView = function(compiledHostTemplate) {
|
|
return this._protoViewFactory.createHost(compiledHostTemplate).ref;
|
|
};
|
|
Compiler_.prototype.clearCache = function() {
|
|
this._protoViewFactory.clearCache();
|
|
};
|
|
Compiler_ = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [proto_view_factory_1.ProtoViewFactory])], Compiler_);
|
|
return Compiler_;
|
|
})(Compiler);
|
|
exports.Compiler_ = Compiler_;
|
|
function internalCreateProtoView(compiler, compiledHostTemplate) {
|
|
return compiler._createProtoView(compiledHostTemplate);
|
|
}
|
|
exports.internalCreateProtoView = internalCreateProtoView;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ad", ["39", "37", "1ae", "20", "1ab", "1a8", "1a9", "1af"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var collection_1 = $__require('37');
|
|
var eli = $__require('1ae');
|
|
var lang_1 = $__require('20');
|
|
var viewModule = $__require('1ab');
|
|
var element_ref_1 = $__require('1a8');
|
|
var template_ref_1 = $__require('1a9');
|
|
var pipes_1 = $__require('1af');
|
|
var AppViewManagerUtils = (function() {
|
|
function AppViewManagerUtils() {}
|
|
AppViewManagerUtils.prototype.getComponentInstance = function(parentView, boundElementIndex) {
|
|
var eli = parentView.elementInjectors[boundElementIndex];
|
|
return eli.getComponent();
|
|
};
|
|
AppViewManagerUtils.prototype.createView = function(mergedParentViewProto, renderViewWithFragments, viewManager, renderer) {
|
|
var renderFragments = renderViewWithFragments.fragmentRefs;
|
|
var renderView = renderViewWithFragments.viewRef;
|
|
var elementCount = mergedParentViewProto.mergeInfo.elementCount;
|
|
var viewCount = mergedParentViewProto.mergeInfo.viewCount;
|
|
var elementRefs = collection_1.ListWrapper.createFixedSize(elementCount);
|
|
var viewContainers = collection_1.ListWrapper.createFixedSize(elementCount);
|
|
var preBuiltObjects = collection_1.ListWrapper.createFixedSize(elementCount);
|
|
var elementInjectors = collection_1.ListWrapper.createFixedSize(elementCount);
|
|
var views = collection_1.ListWrapper.createFixedSize(viewCount);
|
|
var elementOffset = 0;
|
|
var textOffset = 0;
|
|
var fragmentIdx = 0;
|
|
var containerElementIndicesByViewIndex = collection_1.ListWrapper.createFixedSize(viewCount);
|
|
for (var viewOffset = 0; viewOffset < viewCount; viewOffset++) {
|
|
var containerElementIndex = containerElementIndicesByViewIndex[viewOffset];
|
|
var containerElementInjector = lang_1.isPresent(containerElementIndex) ? elementInjectors[containerElementIndex] : null;
|
|
var parentView = lang_1.isPresent(containerElementInjector) ? preBuiltObjects[containerElementIndex].view : null;
|
|
var protoView = lang_1.isPresent(containerElementIndex) ? parentView.proto.elementBinders[containerElementIndex - parentView.elementOffset].nestedProtoView : mergedParentViewProto;
|
|
var renderFragment = null;
|
|
if (viewOffset === 0 || protoView.type === viewModule.ViewType.EMBEDDED) {
|
|
renderFragment = renderFragments[fragmentIdx++];
|
|
}
|
|
var currentView = new viewModule.AppView(renderer, protoView, viewOffset, elementOffset, textOffset, protoView.protoLocals, renderView, renderFragment, containerElementInjector);
|
|
views[viewOffset] = currentView;
|
|
if (lang_1.isPresent(containerElementIndex)) {
|
|
preBuiltObjects[containerElementIndex].nestedView = currentView;
|
|
}
|
|
var rootElementInjectors = [];
|
|
var nestedViewOffset = viewOffset + 1;
|
|
for (var binderIdx = 0; binderIdx < protoView.elementBinders.length; binderIdx++) {
|
|
var binder = protoView.elementBinders[binderIdx];
|
|
var boundElementIndex = elementOffset + binderIdx;
|
|
var elementInjector = null;
|
|
if (lang_1.isPresent(binder.nestedProtoView) && binder.nestedProtoView.isMergable) {
|
|
containerElementIndicesByViewIndex[nestedViewOffset] = boundElementIndex;
|
|
nestedViewOffset += binder.nestedProtoView.mergeInfo.viewCount;
|
|
}
|
|
var protoElementInjector = binder.protoElementInjector;
|
|
if (lang_1.isPresent(protoElementInjector)) {
|
|
if (lang_1.isPresent(protoElementInjector.parent)) {
|
|
var parentElementInjector = elementInjectors[elementOffset + protoElementInjector.parent.index];
|
|
elementInjector = protoElementInjector.instantiate(parentElementInjector);
|
|
} else {
|
|
elementInjector = protoElementInjector.instantiate(null);
|
|
rootElementInjectors.push(elementInjector);
|
|
}
|
|
}
|
|
elementInjectors[boundElementIndex] = elementInjector;
|
|
var el = new element_ref_1.ElementRef_(currentView.ref, boundElementIndex, renderer);
|
|
elementRefs[el.boundElementIndex] = el;
|
|
if (lang_1.isPresent(elementInjector)) {
|
|
var templateRef = lang_1.isPresent(binder.nestedProtoView) && binder.nestedProtoView.type === viewModule.ViewType.EMBEDDED ? new template_ref_1.TemplateRef_(el) : null;
|
|
preBuiltObjects[boundElementIndex] = new eli.PreBuiltObjects(viewManager, currentView, el, templateRef);
|
|
}
|
|
}
|
|
currentView.init(protoView.changeDetectorFactory(currentView), elementInjectors, rootElementInjectors, preBuiltObjects, views, elementRefs, viewContainers);
|
|
if (lang_1.isPresent(parentView) && protoView.type === viewModule.ViewType.COMPONENT) {
|
|
parentView.changeDetector.addViewChild(currentView.changeDetector);
|
|
}
|
|
elementOffset += protoView.elementBinders.length;
|
|
textOffset += protoView.textBindingCount;
|
|
}
|
|
return views[0];
|
|
};
|
|
AppViewManagerUtils.prototype.hydrateRootHostView = function(hostView, injector) {
|
|
this._hydrateView(hostView, injector, null, new Object(), null);
|
|
};
|
|
AppViewManagerUtils.prototype.attachViewInContainer = function(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, view) {
|
|
if (lang_1.isBlank(contextView)) {
|
|
contextView = parentView;
|
|
contextBoundElementIndex = boundElementIndex;
|
|
}
|
|
parentView.changeDetector.addContentChild(view.changeDetector);
|
|
var viewContainer = parentView.viewContainers[boundElementIndex];
|
|
if (lang_1.isBlank(viewContainer)) {
|
|
viewContainer = new viewModule.AppViewContainer();
|
|
parentView.viewContainers[boundElementIndex] = viewContainer;
|
|
}
|
|
collection_1.ListWrapper.insert(viewContainer.views, index, view);
|
|
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
|
|
for (var i = view.rootElementInjectors.length - 1; i >= 0; i--) {
|
|
if (lang_1.isPresent(elementInjector.parent)) {
|
|
view.rootElementInjectors[i].link(elementInjector.parent);
|
|
}
|
|
}
|
|
elementInjector.traverseAndSetQueriesAsDirty();
|
|
};
|
|
AppViewManagerUtils.prototype.detachViewInContainer = function(parentView, boundElementIndex, index) {
|
|
var viewContainer = parentView.viewContainers[boundElementIndex];
|
|
var view = viewContainer.views[index];
|
|
parentView.elementInjectors[boundElementIndex].traverseAndSetQueriesAsDirty();
|
|
view.changeDetector.remove();
|
|
collection_1.ListWrapper.removeAt(viewContainer.views, index);
|
|
for (var i = 0; i < view.rootElementInjectors.length; ++i) {
|
|
var inj = view.rootElementInjectors[i];
|
|
inj.unlink();
|
|
}
|
|
};
|
|
AppViewManagerUtils.prototype.hydrateViewInContainer = function(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, imperativelyCreatedProviders) {
|
|
if (lang_1.isBlank(contextView)) {
|
|
contextView = parentView;
|
|
contextBoundElementIndex = boundElementIndex;
|
|
}
|
|
var viewContainer = parentView.viewContainers[boundElementIndex];
|
|
var view = viewContainer.views[index];
|
|
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
|
|
var injector = lang_1.isPresent(imperativelyCreatedProviders) ? di_1.Injector.fromResolvedProviders(imperativelyCreatedProviders) : null;
|
|
this._hydrateView(view, injector, elementInjector.getHost(), contextView.context, contextView.locals);
|
|
};
|
|
AppViewManagerUtils.prototype._hydrateView = function(initView, imperativelyCreatedInjector, hostElementInjector, context, parentLocals) {
|
|
var viewIdx = initView.viewOffset;
|
|
var endViewOffset = viewIdx + initView.proto.mergeInfo.viewCount - 1;
|
|
while (viewIdx <= endViewOffset) {
|
|
var currView = initView.views[viewIdx];
|
|
var currProtoView = currView.proto;
|
|
if (currView !== initView && currView.proto.type === viewModule.ViewType.EMBEDDED) {
|
|
viewIdx += currView.proto.mergeInfo.viewCount;
|
|
} else {
|
|
if (currView !== initView) {
|
|
imperativelyCreatedInjector = null;
|
|
parentLocals = null;
|
|
hostElementInjector = currView.containerElementInjector;
|
|
context = hostElementInjector.getComponent();
|
|
}
|
|
currView.context = context;
|
|
currView.locals.parent = parentLocals;
|
|
var binders = currProtoView.elementBinders;
|
|
for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {
|
|
var boundElementIndex = binderIdx + currView.elementOffset;
|
|
var elementInjector = initView.elementInjectors[boundElementIndex];
|
|
if (lang_1.isPresent(elementInjector)) {
|
|
elementInjector.hydrate(imperativelyCreatedInjector, hostElementInjector, currView.preBuiltObjects[boundElementIndex]);
|
|
this._populateViewLocals(currView, elementInjector, boundElementIndex);
|
|
this._setUpEventEmitters(currView, elementInjector, boundElementIndex);
|
|
}
|
|
}
|
|
var pipes = lang_1.isPresent(hostElementInjector) ? new pipes_1.Pipes(currView.proto.pipes, hostElementInjector.getInjector()) : null;
|
|
currView.changeDetector.hydrate(currView.context, currView.locals, currView, pipes);
|
|
viewIdx++;
|
|
}
|
|
}
|
|
};
|
|
AppViewManagerUtils.prototype._populateViewLocals = function(view, elementInjector, boundElementIdx) {
|
|
if (lang_1.isPresent(elementInjector.getDirectiveVariableBindings())) {
|
|
elementInjector.getDirectiveVariableBindings().forEach(function(directiveIndex, name) {
|
|
if (lang_1.isBlank(directiveIndex)) {
|
|
view.locals.set(name, view.elementRefs[boundElementIdx].nativeElement);
|
|
} else {
|
|
view.locals.set(name, elementInjector.getDirectiveAtIndex(directiveIndex));
|
|
}
|
|
});
|
|
}
|
|
};
|
|
AppViewManagerUtils.prototype._setUpEventEmitters = function(view, elementInjector, boundElementIndex) {
|
|
var emitters = elementInjector.getEventEmitterAccessors();
|
|
for (var directiveIndex = 0; directiveIndex < emitters.length; ++directiveIndex) {
|
|
var directiveEmitters = emitters[directiveIndex];
|
|
var directive = elementInjector.getDirectiveAtIndex(directiveIndex);
|
|
for (var eventIndex = 0; eventIndex < directiveEmitters.length; ++eventIndex) {
|
|
var eventEmitterAccessor = directiveEmitters[eventIndex];
|
|
eventEmitterAccessor.subscribe(view, boundElementIndex, directive);
|
|
}
|
|
}
|
|
};
|
|
AppViewManagerUtils.prototype.dehydrateView = function(initView) {
|
|
var endViewOffset = initView.viewOffset + initView.proto.mergeInfo.viewCount - 1;
|
|
for (var viewIdx = initView.viewOffset; viewIdx <= endViewOffset; viewIdx++) {
|
|
var currView = initView.views[viewIdx];
|
|
if (currView.hydrated()) {
|
|
if (lang_1.isPresent(currView.locals)) {
|
|
currView.locals.clearValues();
|
|
}
|
|
currView.context = null;
|
|
currView.changeDetector.dehydrate();
|
|
var binders = currView.proto.elementBinders;
|
|
for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {
|
|
var eli = initView.elementInjectors[currView.elementOffset + binderIdx];
|
|
if (lang_1.isPresent(eli)) {
|
|
eli.dehydrate();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
AppViewManagerUtils = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], AppViewManagerUtils);
|
|
return AppViewManagerUtils;
|
|
})();
|
|
exports.AppViewManagerUtils = AppViewManagerUtils;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b0", ["39", "20", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
exports.APP_VIEW_POOL_CAPACITY = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppViewPool.viewPoolCapacity'));
|
|
var AppViewPool = (function() {
|
|
function AppViewPool(poolCapacityPerProtoView) {
|
|
this._pooledViewsPerProtoView = new collection_1.Map();
|
|
this._poolCapacityPerProtoView = poolCapacityPerProtoView;
|
|
}
|
|
AppViewPool.prototype.getView = function(protoView) {
|
|
var pooledViews = this._pooledViewsPerProtoView.get(protoView);
|
|
if (lang_1.isPresent(pooledViews) && pooledViews.length > 0) {
|
|
return pooledViews.pop();
|
|
}
|
|
return null;
|
|
};
|
|
AppViewPool.prototype.returnView = function(view) {
|
|
var protoView = view.proto;
|
|
var pooledViews = this._pooledViewsPerProtoView.get(protoView);
|
|
if (lang_1.isBlank(pooledViews)) {
|
|
pooledViews = [];
|
|
this._pooledViewsPerProtoView.set(protoView, pooledViews);
|
|
}
|
|
var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView;
|
|
if (haveRemainingCapacity) {
|
|
pooledViews.push(view);
|
|
}
|
|
return haveRemainingCapacity;
|
|
};
|
|
AppViewPool = __decorate([di_1.Injectable(), __param(0, di_1.Inject(exports.APP_VIEW_POOL_CAPACITY)), __metadata('design:paramtypes', [Object])], AppViewPool);
|
|
return AppViewPool;
|
|
})();
|
|
exports.AppViewPool = AppViewPool;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("55", ["39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var AppViewListener = (function() {
|
|
function AppViewListener() {}
|
|
AppViewListener.prototype.onViewCreated = function(view) {};
|
|
AppViewListener.prototype.onViewDestroyed = function(view) {};
|
|
AppViewListener = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], AppViewListener);
|
|
return AppViewListener;
|
|
})();
|
|
exports.AppViewListener = AppViewListener;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b1", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var SelectedPipe = (function() {
|
|
function SelectedPipe(pipe, pure) {
|
|
this.pipe = pipe;
|
|
this.pure = pure;
|
|
}
|
|
return SelectedPipe;
|
|
})();
|
|
exports.SelectedPipe = SelectedPipe;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1af", ["20", "3c", "37", "1b1"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var cd = $__require('1b1');
|
|
var ProtoPipes = (function() {
|
|
function ProtoPipes(config) {
|
|
this.config = config;
|
|
this.config = config;
|
|
}
|
|
ProtoPipes.fromProviders = function(providers) {
|
|
var config = {};
|
|
providers.forEach(function(b) {
|
|
return config[b.name] = b;
|
|
});
|
|
return new ProtoPipes(config);
|
|
};
|
|
ProtoPipes.prototype.get = function(name) {
|
|
var provider = this.config[name];
|
|
if (lang_1.isBlank(provider))
|
|
throw new exceptions_1.BaseException("Cannot find pipe '" + name + "'.");
|
|
return provider;
|
|
};
|
|
return ProtoPipes;
|
|
})();
|
|
exports.ProtoPipes = ProtoPipes;
|
|
var Pipes = (function() {
|
|
function Pipes(proto, injector) {
|
|
this.proto = proto;
|
|
this.injector = injector;
|
|
this._config = {};
|
|
}
|
|
Pipes.prototype.get = function(name) {
|
|
var cached = collection_1.StringMapWrapper.get(this._config, name);
|
|
if (lang_1.isPresent(cached))
|
|
return cached;
|
|
var p = this.proto.get(name);
|
|
var transform = this.injector.instantiateResolved(p);
|
|
var res = new cd.SelectedPipe(transform, p.pure);
|
|
if (p.pure) {
|
|
collection_1.StringMapWrapper.set(this._config, name, res);
|
|
}
|
|
return res;
|
|
};
|
|
return Pipes;
|
|
})();
|
|
exports.Pipes = Pipes;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b2", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
|
var DASH_CASE_REGEXP = /-([a-z])/g;
|
|
function camelCaseToDashCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP, function(m) {
|
|
return '-' + m[1].toLowerCase();
|
|
});
|
|
}
|
|
exports.camelCaseToDashCase = camelCaseToDashCase;
|
|
function dashCaseToCamelCase(input) {
|
|
return lang_1.StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP, function(m) {
|
|
return m[1].toUpperCase();
|
|
});
|
|
}
|
|
exports.dashCaseToCamelCase = dashCaseToCamelCase;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ab", ["37", "6e", "1b3", "20", "3c", "1a1", "1b2"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var change_detection_1 = $__require('6e');
|
|
var interfaces_1 = $__require('1b3');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var view_ref_1 = $__require('1a1');
|
|
var util_1 = $__require('1b2');
|
|
var view_ref_2 = $__require('1a1');
|
|
var interfaces_2 = $__require('1b3');
|
|
exports.DebugContext = interfaces_2.DebugContext;
|
|
var REFLECT_PREFIX = 'ng-reflect-';
|
|
(function(ViewType) {
|
|
ViewType[ViewType["HOST"] = 0] = "HOST";
|
|
ViewType[ViewType["COMPONENT"] = 1] = "COMPONENT";
|
|
ViewType[ViewType["EMBEDDED"] = 2] = "EMBEDDED";
|
|
})(exports.ViewType || (exports.ViewType = {}));
|
|
var ViewType = exports.ViewType;
|
|
var AppViewContainer = (function() {
|
|
function AppViewContainer() {
|
|
this.views = [];
|
|
}
|
|
return AppViewContainer;
|
|
})();
|
|
exports.AppViewContainer = AppViewContainer;
|
|
var AppView = (function() {
|
|
function AppView(renderer, proto, viewOffset, elementOffset, textOffset, protoLocals, render, renderFragment, containerElementInjector) {
|
|
this.renderer = renderer;
|
|
this.proto = proto;
|
|
this.viewOffset = viewOffset;
|
|
this.elementOffset = elementOffset;
|
|
this.textOffset = textOffset;
|
|
this.render = render;
|
|
this.renderFragment = renderFragment;
|
|
this.containerElementInjector = containerElementInjector;
|
|
this.views = null;
|
|
this.elementInjectors = null;
|
|
this.viewContainers = null;
|
|
this.preBuiltObjects = null;
|
|
this.changeDetector = null;
|
|
this.context = null;
|
|
this.ref = new view_ref_2.ViewRef_(this);
|
|
this.locals = new change_detection_1.Locals(null, collection_1.MapWrapper.clone(protoLocals));
|
|
}
|
|
AppView.prototype.init = function(changeDetector, elementInjectors, rootElementInjectors, preBuiltObjects, views, elementRefs, viewContainers) {
|
|
this.changeDetector = changeDetector;
|
|
this.elementInjectors = elementInjectors;
|
|
this.rootElementInjectors = rootElementInjectors;
|
|
this.preBuiltObjects = preBuiltObjects;
|
|
this.views = views;
|
|
this.elementRefs = elementRefs;
|
|
this.viewContainers = viewContainers;
|
|
};
|
|
AppView.prototype.setLocal = function(contextName, value) {
|
|
if (!this.hydrated())
|
|
throw new exceptions_1.BaseException('Cannot set locals on dehydrated view.');
|
|
if (!this.proto.templateVariableBindings.has(contextName)) {
|
|
return;
|
|
}
|
|
var templateName = this.proto.templateVariableBindings.get(contextName);
|
|
this.locals.set(templateName, value);
|
|
};
|
|
AppView.prototype.hydrated = function() {
|
|
return lang_1.isPresent(this.context);
|
|
};
|
|
AppView.prototype.triggerEventHandlers = function(eventName, eventObj, boundElementIndex) {
|
|
var locals = new collection_1.Map();
|
|
locals.set('$event', eventObj);
|
|
this.dispatchEvent(boundElementIndex, eventName, locals);
|
|
};
|
|
AppView.prototype.notifyOnBinding = function(b, currentValue) {
|
|
if (b.isTextNode()) {
|
|
this.renderer.setText(this.render, b.elementIndex + this.textOffset, currentValue);
|
|
} else {
|
|
var elementRef = this.elementRefs[this.elementOffset + b.elementIndex];
|
|
if (b.isElementProperty()) {
|
|
this.renderer.setElementProperty(elementRef, b.name, currentValue);
|
|
} else if (b.isElementAttribute()) {
|
|
this.renderer.setElementAttribute(elementRef, b.name, lang_1.isPresent(currentValue) ? "" + currentValue : null);
|
|
} else if (b.isElementClass()) {
|
|
this.renderer.setElementClass(elementRef, b.name, currentValue);
|
|
} else if (b.isElementStyle()) {
|
|
var unit = lang_1.isPresent(b.unit) ? b.unit : '';
|
|
this.renderer.setElementStyle(elementRef, b.name, lang_1.isPresent(currentValue) ? "" + currentValue + unit : null);
|
|
} else {
|
|
throw new exceptions_1.BaseException('Unsupported directive record');
|
|
}
|
|
}
|
|
};
|
|
AppView.prototype.logBindingUpdate = function(b, value) {
|
|
if (b.isDirective() || b.isElementProperty()) {
|
|
var elementRef = this.elementRefs[this.elementOffset + b.elementIndex];
|
|
this.renderer.setBindingDebugInfo(elementRef, "" + REFLECT_PREFIX + util_1.camelCaseToDashCase(b.name), "" + value);
|
|
}
|
|
};
|
|
AppView.prototype.notifyAfterContentChecked = function() {
|
|
var eiCount = this.proto.elementBinders.length;
|
|
var ei = this.elementInjectors;
|
|
for (var i = eiCount - 1; i >= 0; i--) {
|
|
if (lang_1.isPresent(ei[i + this.elementOffset]))
|
|
ei[i + this.elementOffset].ngAfterContentChecked();
|
|
}
|
|
};
|
|
AppView.prototype.notifyAfterViewChecked = function() {
|
|
var eiCount = this.proto.elementBinders.length;
|
|
var ei = this.elementInjectors;
|
|
for (var i = eiCount - 1; i >= 0; i--) {
|
|
if (lang_1.isPresent(ei[i + this.elementOffset]))
|
|
ei[i + this.elementOffset].ngAfterViewChecked();
|
|
}
|
|
};
|
|
AppView.prototype.getDirectiveFor = function(directive) {
|
|
var elementInjector = this.elementInjectors[this.elementOffset + directive.elementIndex];
|
|
return elementInjector.getDirectiveAtIndex(directive.directiveIndex);
|
|
};
|
|
AppView.prototype.getNestedView = function(boundElementIndex) {
|
|
var eli = this.elementInjectors[boundElementIndex];
|
|
return lang_1.isPresent(eli) ? eli.getNestedView() : null;
|
|
};
|
|
AppView.prototype.getContainerElement = function() {
|
|
return lang_1.isPresent(this.containerElementInjector) ? this.containerElementInjector.getElementRef() : null;
|
|
};
|
|
AppView.prototype.getDebugContext = function(elementIndex, directiveIndex) {
|
|
try {
|
|
var offsettedIndex = this.elementOffset + elementIndex;
|
|
var hasRefForIndex = offsettedIndex < this.elementRefs.length;
|
|
var elementRef = hasRefForIndex ? this.elementRefs[this.elementOffset + elementIndex] : null;
|
|
var container = this.getContainerElement();
|
|
var ei = hasRefForIndex ? this.elementInjectors[this.elementOffset + elementIndex] : null;
|
|
var element = lang_1.isPresent(elementRef) ? elementRef.nativeElement : null;
|
|
var componentElement = lang_1.isPresent(container) ? container.nativeElement : null;
|
|
var directive = lang_1.isPresent(directiveIndex) ? this.getDirectiveFor(directiveIndex) : null;
|
|
var injector = lang_1.isPresent(ei) ? ei.getInjector() : null;
|
|
return new interfaces_1.DebugContext(element, componentElement, directive, this.context, _localsToStringMap(this.locals), injector);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
};
|
|
AppView.prototype.getDetectorFor = function(directive) {
|
|
var childView = this.getNestedView(this.elementOffset + directive.elementIndex);
|
|
return lang_1.isPresent(childView) ? childView.changeDetector : null;
|
|
};
|
|
AppView.prototype.invokeElementMethod = function(elementIndex, methodName, args) {
|
|
this.renderer.invokeElementMethod(this.elementRefs[elementIndex], methodName, args);
|
|
};
|
|
AppView.prototype.dispatchRenderEvent = function(boundElementIndex, eventName, locals) {
|
|
var elementRef = this.elementRefs[boundElementIndex];
|
|
var view = view_ref_1.internalView(elementRef.parentView);
|
|
return view.dispatchEvent(elementRef.boundElementIndex, eventName, locals);
|
|
};
|
|
AppView.prototype.dispatchEvent = function(boundElementIndex, eventName, locals) {
|
|
try {
|
|
if (this.hydrated()) {
|
|
return !this.changeDetector.handleEvent(eventName, boundElementIndex - this.elementOffset, new change_detection_1.Locals(this.locals, locals));
|
|
} else {
|
|
return true;
|
|
}
|
|
} catch (e) {
|
|
var c = this.getDebugContext(boundElementIndex - this.elementOffset, null);
|
|
var context = lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals, c.injector) : null;
|
|
throw new EventEvaluationError(eventName, e, e.stack, context);
|
|
}
|
|
};
|
|
Object.defineProperty(AppView.prototype, "ownBindersCount", {
|
|
get: function() {
|
|
return this.proto.elementBinders.length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return AppView;
|
|
})();
|
|
exports.AppView = AppView;
|
|
function _localsToStringMap(locals) {
|
|
var res = {};
|
|
var c = locals;
|
|
while (lang_1.isPresent(c)) {
|
|
res = collection_1.StringMapWrapper.merge(res, collection_1.MapWrapper.toStringMap(c.current));
|
|
c = c.parent;
|
|
}
|
|
return res;
|
|
}
|
|
var _Context = (function() {
|
|
function _Context(element, componentElement, context, locals, injector) {
|
|
this.element = element;
|
|
this.componentElement = componentElement;
|
|
this.context = context;
|
|
this.locals = locals;
|
|
this.injector = injector;
|
|
}
|
|
return _Context;
|
|
})();
|
|
var EventEvaluationError = (function(_super) {
|
|
__extends(EventEvaluationError, _super);
|
|
function EventEvaluationError(eventName, originalException, originalStack, context) {
|
|
_super.call(this, "Error during evaluation of \"" + eventName + "\"", originalException, originalStack, context);
|
|
}
|
|
return EventEvaluationError;
|
|
})(exceptions_1.WrappedException);
|
|
var AppProtoViewMergeInfo = (function() {
|
|
function AppProtoViewMergeInfo(embeddedViewCount, elementCount, viewCount) {
|
|
this.embeddedViewCount = embeddedViewCount;
|
|
this.elementCount = elementCount;
|
|
this.viewCount = viewCount;
|
|
}
|
|
return AppProtoViewMergeInfo;
|
|
})();
|
|
exports.AppProtoViewMergeInfo = AppProtoViewMergeInfo;
|
|
var AppProtoView = (function() {
|
|
function AppProtoView(templateId, templateCmds, type, isMergable, changeDetectorFactory, templateVariableBindings, pipes) {
|
|
this.templateId = templateId;
|
|
this.templateCmds = templateCmds;
|
|
this.type = type;
|
|
this.isMergable = isMergable;
|
|
this.changeDetectorFactory = changeDetectorFactory;
|
|
this.templateVariableBindings = templateVariableBindings;
|
|
this.pipes = pipes;
|
|
this.elementBinders = null;
|
|
this.mergeInfo = null;
|
|
this.variableLocations = null;
|
|
this.textBindingCount = null;
|
|
this.render = null;
|
|
this.ref = new view_ref_2.ProtoViewRef_(this);
|
|
}
|
|
AppProtoView.prototype.init = function(render, elementBinders, textBindingCount, mergeInfo, variableLocations) {
|
|
var _this = this;
|
|
this.render = render;
|
|
this.elementBinders = elementBinders;
|
|
this.textBindingCount = textBindingCount;
|
|
this.mergeInfo = mergeInfo;
|
|
this.variableLocations = variableLocations;
|
|
this.protoLocals = new collection_1.Map();
|
|
if (lang_1.isPresent(this.templateVariableBindings)) {
|
|
this.templateVariableBindings.forEach(function(templateName, _) {
|
|
_this.protoLocals.set(templateName, null);
|
|
});
|
|
}
|
|
if (lang_1.isPresent(variableLocations)) {
|
|
variableLocations.forEach(function(_, templateName) {
|
|
_this.protoLocals.set(templateName, null);
|
|
});
|
|
}
|
|
};
|
|
AppProtoView.prototype.isInitialized = function() {
|
|
return lang_1.isPresent(this.elementBinders);
|
|
};
|
|
return AppProtoView;
|
|
})();
|
|
exports.AppProtoView = AppProtoView;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b4", ["20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var ElementBinder = (function() {
|
|
function ElementBinder(index, parent, distanceToParent, protoElementInjector, componentDirective, nestedProtoView) {
|
|
this.index = index;
|
|
this.parent = parent;
|
|
this.distanceToParent = distanceToParent;
|
|
this.protoElementInjector = protoElementInjector;
|
|
this.componentDirective = componentDirective;
|
|
this.nestedProtoView = nestedProtoView;
|
|
if (lang_1.isBlank(index)) {
|
|
throw new exceptions_1.BaseException('null index not allowed.');
|
|
}
|
|
}
|
|
return ElementBinder;
|
|
})();
|
|
exports.ElementBinder = ElementBinder;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1aa", ["37", "3c", "20", "1a1"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var exceptions_1 = $__require('3c');
|
|
var lang_1 = $__require('20');
|
|
var view_ref_1 = $__require('1a1');
|
|
var ViewContainerRef = (function() {
|
|
function ViewContainerRef() {}
|
|
ViewContainerRef.prototype.clear = function() {
|
|
for (var i = this.length - 1; i >= 0; i--) {
|
|
this.remove(i);
|
|
}
|
|
};
|
|
Object.defineProperty(ViewContainerRef.prototype, "length", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return ViewContainerRef;
|
|
})();
|
|
exports.ViewContainerRef = ViewContainerRef;
|
|
var ViewContainerRef_ = (function(_super) {
|
|
__extends(ViewContainerRef_, _super);
|
|
function ViewContainerRef_(viewManager, element) {
|
|
_super.call(this);
|
|
this.viewManager = viewManager;
|
|
this.element = element;
|
|
}
|
|
ViewContainerRef_.prototype._getViews = function() {
|
|
var element = this.element;
|
|
var vc = view_ref_1.internalView(element.parentView).viewContainers[element.boundElementIndex];
|
|
return lang_1.isPresent(vc) ? vc.views : [];
|
|
};
|
|
ViewContainerRef_.prototype.get = function(index) {
|
|
return this._getViews()[index].ref;
|
|
};
|
|
Object.defineProperty(ViewContainerRef_.prototype, "length", {
|
|
get: function() {
|
|
return this._getViews().length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ViewContainerRef_.prototype.createEmbeddedView = function(templateRef, index) {
|
|
if (index === void 0) {
|
|
index = -1;
|
|
}
|
|
if (index == -1)
|
|
index = this.length;
|
|
return this.viewManager.createEmbeddedViewInContainer(this.element, index, templateRef);
|
|
};
|
|
ViewContainerRef_.prototype.createHostView = function(protoViewRef, index, dynamicallyCreatedProviders) {
|
|
if (protoViewRef === void 0) {
|
|
protoViewRef = null;
|
|
}
|
|
if (index === void 0) {
|
|
index = -1;
|
|
}
|
|
if (dynamicallyCreatedProviders === void 0) {
|
|
dynamicallyCreatedProviders = null;
|
|
}
|
|
if (index == -1)
|
|
index = this.length;
|
|
return this.viewManager.createHostViewInContainer(this.element, index, protoViewRef, dynamicallyCreatedProviders);
|
|
};
|
|
ViewContainerRef_.prototype.insert = function(viewRef, index) {
|
|
if (index === void 0) {
|
|
index = -1;
|
|
}
|
|
if (index == -1)
|
|
index = this.length;
|
|
return this.viewManager.attachViewInContainer(this.element, index, viewRef);
|
|
};
|
|
ViewContainerRef_.prototype.indexOf = function(viewRef) {
|
|
return collection_1.ListWrapper.indexOf(this._getViews(), view_ref_1.internalView(viewRef));
|
|
};
|
|
ViewContainerRef_.prototype.remove = function(index) {
|
|
if (index === void 0) {
|
|
index = -1;
|
|
}
|
|
if (index == -1)
|
|
index = this.length - 1;
|
|
this.viewManager.destroyViewInContainer(this.element, index);
|
|
};
|
|
ViewContainerRef_.prototype.detach = function(index) {
|
|
if (index === void 0) {
|
|
index = -1;
|
|
}
|
|
if (index == -1)
|
|
index = this.length - 1;
|
|
return this.viewManager.detachViewInContainer(this.element, index);
|
|
};
|
|
return ViewContainerRef_;
|
|
})(ViewContainerRef);
|
|
exports.ViewContainerRef_ = ViewContainerRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a8", ["3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var exceptions_1 = $__require('3c');
|
|
var ElementRef = (function() {
|
|
function ElementRef() {}
|
|
Object.defineProperty(ElementRef.prototype, "nativeElement", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(ElementRef.prototype, "renderView", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ElementRef;
|
|
})();
|
|
exports.ElementRef = ElementRef;
|
|
var ElementRef_ = (function(_super) {
|
|
__extends(ElementRef_, _super);
|
|
function ElementRef_(parentView, boundElementIndex, _renderer) {
|
|
_super.call(this);
|
|
this.parentView = parentView;
|
|
this.boundElementIndex = boundElementIndex;
|
|
this._renderer = _renderer;
|
|
}
|
|
Object.defineProperty(ElementRef_.prototype, "renderView", {
|
|
get: function() {
|
|
return this.parentView.render;
|
|
},
|
|
set: function(value) {
|
|
exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ElementRef_.prototype, "nativeElement", {
|
|
get: function() {
|
|
return this._renderer.getNativeElementSync(this);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ElementRef_;
|
|
})(ElementRef);
|
|
exports.ElementRef_ = ElementRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a1", ["20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
function internalView(viewRef) {
|
|
return viewRef._view;
|
|
}
|
|
exports.internalView = internalView;
|
|
function internalProtoView(protoViewRef) {
|
|
return lang_1.isPresent(protoViewRef) ? protoViewRef._protoView : null;
|
|
}
|
|
exports.internalProtoView = internalProtoView;
|
|
var ViewRef = (function() {
|
|
function ViewRef() {}
|
|
Object.defineProperty(ViewRef.prototype, "changeDetectorRef", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
set: function(value) {
|
|
exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ViewRef;
|
|
})();
|
|
exports.ViewRef = ViewRef;
|
|
var ViewRef_ = (function(_super) {
|
|
__extends(ViewRef_, _super);
|
|
function ViewRef_(_view) {
|
|
_super.call(this);
|
|
this._changeDetectorRef = null;
|
|
this._view = _view;
|
|
}
|
|
Object.defineProperty(ViewRef_.prototype, "render", {
|
|
get: function() {
|
|
return this._view.render;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewRef_.prototype, "renderFragment", {
|
|
get: function() {
|
|
return this._view.renderFragment;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewRef_.prototype, "changeDetectorRef", {
|
|
get: function() {
|
|
if (this._changeDetectorRef === null) {
|
|
this._changeDetectorRef = this._view.changeDetector.ref;
|
|
}
|
|
return this._changeDetectorRef;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ViewRef_.prototype.setLocal = function(variableName, value) {
|
|
this._view.setLocal(variableName, value);
|
|
};
|
|
return ViewRef_;
|
|
})(ViewRef);
|
|
exports.ViewRef_ = ViewRef_;
|
|
var ProtoViewRef = (function() {
|
|
function ProtoViewRef() {}
|
|
return ProtoViewRef;
|
|
})();
|
|
exports.ProtoViewRef = ProtoViewRef;
|
|
var ProtoViewRef_ = (function(_super) {
|
|
__extends(ProtoViewRef_, _super);
|
|
function ProtoViewRef_(_protoView) {
|
|
_super.call(this);
|
|
this._protoView = _protoView;
|
|
}
|
|
return ProtoViewRef_;
|
|
})(ProtoViewRef);
|
|
exports.ProtoViewRef_ = ProtoViewRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a9", ["1a1"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var view_ref_1 = $__require('1a1');
|
|
var TemplateRef = (function() {
|
|
function TemplateRef() {}
|
|
return TemplateRef;
|
|
})();
|
|
exports.TemplateRef = TemplateRef;
|
|
var TemplateRef_ = (function(_super) {
|
|
__extends(TemplateRef_, _super);
|
|
function TemplateRef_(elementRef) {
|
|
_super.call(this);
|
|
this.elementRef = elementRef;
|
|
}
|
|
TemplateRef_.prototype._getProtoView = function() {
|
|
var elementRef = this.elementRef;
|
|
var parentView = view_ref_1.internalView(elementRef.parentView);
|
|
return parentView.proto.elementBinders[elementRef.boundElementIndex - parentView.elementOffset].nestedProtoView;
|
|
};
|
|
Object.defineProperty(TemplateRef_.prototype, "protoViewRef", {
|
|
get: function() {
|
|
return this._getProtoView().ref;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
TemplateRef_.prototype.hasLocal = function(name) {
|
|
return this._getProtoView().templateVariableBindings.has(name);
|
|
};
|
|
return TemplateRef_;
|
|
})(TemplateRef);
|
|
exports.TemplateRef_ = TemplateRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("80", ["20", "7c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var interfaces_1 = $__require('7c');
|
|
function hasLifecycleHook(lcInterface, token) {
|
|
if (!(token instanceof lang_1.Type))
|
|
return false;
|
|
var proto = token.prototype;
|
|
switch (lcInterface) {
|
|
case interfaces_1.LifecycleHooks.AfterContentInit:
|
|
return !!proto.ngAfterContentInit;
|
|
case interfaces_1.LifecycleHooks.AfterContentChecked:
|
|
return !!proto.ngAfterContentChecked;
|
|
case interfaces_1.LifecycleHooks.AfterViewInit:
|
|
return !!proto.ngAfterViewInit;
|
|
case interfaces_1.LifecycleHooks.AfterViewChecked:
|
|
return !!proto.ngAfterViewChecked;
|
|
case interfaces_1.LifecycleHooks.OnChanges:
|
|
return !!proto.ngOnChanges;
|
|
case interfaces_1.LifecycleHooks.DoCheck:
|
|
return !!proto.ngDoCheck;
|
|
case interfaces_1.LifecycleHooks.OnDestroy:
|
|
return !!proto.ngOnDestroy;
|
|
case interfaces_1.LifecycleHooks.OnInit:
|
|
return !!proto.ngOnInit;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
exports.hasLifecycleHook = hasLifecycleHook;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("8b", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var PromiseWrapper = (function() {
|
|
function PromiseWrapper() {}
|
|
PromiseWrapper.resolve = function(obj) {
|
|
return Promise.resolve(obj);
|
|
};
|
|
PromiseWrapper.reject = function(obj, _) {
|
|
return Promise.reject(obj);
|
|
};
|
|
PromiseWrapper.catchError = function(promise, onError) {
|
|
return promise.catch(onError);
|
|
};
|
|
PromiseWrapper.all = function(promises) {
|
|
if (promises.length == 0)
|
|
return Promise.resolve([]);
|
|
return Promise.all(promises);
|
|
};
|
|
PromiseWrapper.then = function(promise, success, rejection) {
|
|
return promise.then(success, rejection);
|
|
};
|
|
PromiseWrapper.wrap = function(computation) {
|
|
return new Promise(function(res, rej) {
|
|
try {
|
|
res(computation());
|
|
} catch (e) {
|
|
rej(e);
|
|
}
|
|
});
|
|
};
|
|
PromiseWrapper.scheduleMicrotask = function(computation) {
|
|
PromiseWrapper.then(PromiseWrapper.resolve(null), computation, function(_) {});
|
|
};
|
|
PromiseWrapper.isPromise = function(obj) {
|
|
return obj instanceof Promise;
|
|
};
|
|
PromiseWrapper.completer = function() {
|
|
var resolve;
|
|
var reject;
|
|
var p = new Promise(function(res, rej) {
|
|
resolve = res;
|
|
reject = rej;
|
|
});
|
|
return {
|
|
promise: p,
|
|
resolve: resolve,
|
|
reject: reject
|
|
};
|
|
};
|
|
return PromiseWrapper;
|
|
})();
|
|
exports.PromiseWrapper = PromiseWrapper;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b5", ["1b6", "1b7"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var Subscription_1 = $__require('1b6');
|
|
var Subscriber_1 = $__require('1b7');
|
|
var SubjectSubscription = (function(_super) {
|
|
__extends(SubjectSubscription, _super);
|
|
function SubjectSubscription(subject, observer) {
|
|
_super.call(this);
|
|
this.subject = subject;
|
|
this.observer = observer;
|
|
this.isUnsubscribed = false;
|
|
}
|
|
SubjectSubscription.prototype.unsubscribe = function() {
|
|
if (this.isUnsubscribed) {
|
|
return;
|
|
}
|
|
this.isUnsubscribed = true;
|
|
var subject = this.subject;
|
|
var observers = subject.observers;
|
|
this.subject = void 0;
|
|
if (!observers || observers.length === 0 || subject.isUnsubscribed) {
|
|
return;
|
|
}
|
|
if (this.observer instanceof Subscriber_1.Subscriber) {
|
|
this.observer.unsubscribe();
|
|
}
|
|
var subscriberIndex = observers.indexOf(this.observer);
|
|
if (subscriberIndex !== -1) {
|
|
observers.splice(subscriberIndex, 1);
|
|
}
|
|
};
|
|
return SubjectSubscription;
|
|
})(Subscription_1.Subscription);
|
|
exports.SubjectSubscription = SubjectSubscription;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b8", ["1b9", "1b7", "1b6", "1b5", "1ba"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var Observable_1 = $__require('1b9');
|
|
var Subscriber_1 = $__require('1b7');
|
|
var Subscription_1 = $__require('1b6');
|
|
var SubjectSubscription_1 = $__require('1b5');
|
|
var rxSubscriber_1 = $__require('1ba');
|
|
var subscriptionAdd = Subscription_1.Subscription.prototype.add;
|
|
var subscriptionRemove = Subscription_1.Subscription.prototype.remove;
|
|
var subscriptionUnsubscribe = Subscription_1.Subscription.prototype.unsubscribe;
|
|
var subscriberNext = Subscriber_1.Subscriber.prototype.next;
|
|
var subscriberError = Subscriber_1.Subscriber.prototype.error;
|
|
var subscriberComplete = Subscriber_1.Subscriber.prototype.complete;
|
|
var _subscriberNext = Subscriber_1.Subscriber.prototype._next;
|
|
var _subscriberError = Subscriber_1.Subscriber.prototype._error;
|
|
var _subscriberComplete = Subscriber_1.Subscriber.prototype._complete;
|
|
var Subject = (function(_super) {
|
|
__extends(Subject, _super);
|
|
function Subject() {
|
|
_super.apply(this, arguments);
|
|
this.observers = [];
|
|
this.isUnsubscribed = false;
|
|
this.dispatching = false;
|
|
this.errorSignal = false;
|
|
this.completeSignal = false;
|
|
}
|
|
Subject.prototype[rxSubscriber_1.rxSubscriber] = function() {
|
|
return this;
|
|
};
|
|
Subject.create = function(source, destination) {
|
|
return new BidirectionalSubject(source, destination);
|
|
};
|
|
Subject.prototype.lift = function(operator) {
|
|
var subject = new BidirectionalSubject(this, this.destination || this);
|
|
subject.operator = operator;
|
|
return subject;
|
|
};
|
|
Subject.prototype._subscribe = function(subscriber) {
|
|
if (subscriber.isUnsubscribed) {
|
|
return;
|
|
} else if (this.errorSignal) {
|
|
subscriber.error(this.errorInstance);
|
|
return;
|
|
} else if (this.completeSignal) {
|
|
subscriber.complete();
|
|
return;
|
|
} else if (this.isUnsubscribed) {
|
|
throw new Error('Cannot subscribe to a disposed Subject.');
|
|
}
|
|
this.observers.push(subscriber);
|
|
return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
|
|
};
|
|
Subject.prototype.add = function(subscription) {
|
|
subscriptionAdd.call(this, subscription);
|
|
};
|
|
Subject.prototype.remove = function(subscription) {
|
|
subscriptionRemove.call(this, subscription);
|
|
};
|
|
Subject.prototype.unsubscribe = function() {
|
|
this.observers = void 0;
|
|
subscriptionUnsubscribe.call(this);
|
|
};
|
|
Subject.prototype.next = function(value) {
|
|
if (this.isUnsubscribed) {
|
|
return;
|
|
}
|
|
this.dispatching = true;
|
|
this._next(value);
|
|
this.dispatching = false;
|
|
if (this.errorSignal) {
|
|
this.error(this.errorInstance);
|
|
} else if (this.completeSignal) {
|
|
this.complete();
|
|
}
|
|
};
|
|
Subject.prototype.error = function(err) {
|
|
if (this.isUnsubscribed || this.completeSignal) {
|
|
return;
|
|
}
|
|
this.errorSignal = true;
|
|
this.errorInstance = err;
|
|
if (this.dispatching) {
|
|
return;
|
|
}
|
|
this._error(err);
|
|
this.unsubscribe();
|
|
};
|
|
Subject.prototype.complete = function() {
|
|
if (this.isUnsubscribed || this.errorSignal) {
|
|
return;
|
|
}
|
|
this.completeSignal = true;
|
|
if (this.dispatching) {
|
|
return;
|
|
}
|
|
this._complete();
|
|
this.unsubscribe();
|
|
};
|
|
Subject.prototype._next = function(value) {
|
|
var index = -1;
|
|
var observers = this.observers.slice(0);
|
|
var len = observers.length;
|
|
while (++index < len) {
|
|
observers[index].next(value);
|
|
}
|
|
};
|
|
Subject.prototype._error = function(err) {
|
|
var index = -1;
|
|
var observers = this.observers;
|
|
var len = observers.length;
|
|
this.observers = void 0;
|
|
this.isUnsubscribed = true;
|
|
while (++index < len) {
|
|
observers[index].error(err);
|
|
}
|
|
this.isUnsubscribed = false;
|
|
};
|
|
Subject.prototype._complete = function() {
|
|
var index = -1;
|
|
var observers = this.observers;
|
|
var len = observers.length;
|
|
this.observers = void 0;
|
|
this.isUnsubscribed = true;
|
|
while (++index < len) {
|
|
observers[index].complete();
|
|
}
|
|
this.isUnsubscribed = false;
|
|
};
|
|
return Subject;
|
|
})(Observable_1.Observable);
|
|
exports.Subject = Subject;
|
|
var BidirectionalSubject = (function(_super) {
|
|
__extends(BidirectionalSubject, _super);
|
|
function BidirectionalSubject(source, destination) {
|
|
_super.call(this);
|
|
this.source = source;
|
|
this.destination = destination;
|
|
}
|
|
BidirectionalSubject.prototype._subscribe = function(subscriber) {
|
|
var operator = this.operator;
|
|
return this.source._subscribe.call(this.source, operator ? operator.call(subscriber) : subscriber);
|
|
};
|
|
BidirectionalSubject.prototype.next = function(value) {
|
|
subscriberNext.call(this, value);
|
|
};
|
|
BidirectionalSubject.prototype.error = function(err) {
|
|
subscriberError.call(this, err);
|
|
};
|
|
BidirectionalSubject.prototype.complete = function() {
|
|
subscriberComplete.call(this);
|
|
};
|
|
BidirectionalSubject.prototype._next = function(value) {
|
|
_subscriberNext.call(this, value);
|
|
};
|
|
BidirectionalSubject.prototype._error = function(err) {
|
|
_subscriberError.call(this, err);
|
|
};
|
|
BidirectionalSubject.prototype._complete = function() {
|
|
_subscriberComplete.call(this);
|
|
};
|
|
return BidirectionalSubject;
|
|
})(Subject);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1bb", ["1b6"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var Subscription_1 = $__require('1b6');
|
|
var QueueAction = (function(_super) {
|
|
__extends(QueueAction, _super);
|
|
function QueueAction(scheduler, work) {
|
|
_super.call(this);
|
|
this.scheduler = scheduler;
|
|
this.work = work;
|
|
}
|
|
QueueAction.prototype.schedule = function(state) {
|
|
if (this.isUnsubscribed) {
|
|
return this;
|
|
}
|
|
this.state = state;
|
|
var scheduler = this.scheduler;
|
|
scheduler.actions.push(this);
|
|
scheduler.flush();
|
|
return this;
|
|
};
|
|
QueueAction.prototype.execute = function() {
|
|
if (this.isUnsubscribed) {
|
|
throw new Error('How did did we execute a canceled Action?');
|
|
}
|
|
this.work(this.state);
|
|
};
|
|
QueueAction.prototype.unsubscribe = function() {
|
|
var scheduler = this.scheduler;
|
|
var actions = scheduler.actions;
|
|
var index = actions.indexOf(this);
|
|
this.work = void 0;
|
|
this.state = void 0;
|
|
this.scheduler = void 0;
|
|
if (index !== -1) {
|
|
actions.splice(index, 1);
|
|
}
|
|
_super.prototype.unsubscribe.call(this);
|
|
};
|
|
return QueueAction;
|
|
})(Subscription_1.Subscription);
|
|
exports.QueueAction = QueueAction;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1bc", ["1bb"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var QueueAction_1 = $__require('1bb');
|
|
var FutureAction = (function(_super) {
|
|
__extends(FutureAction, _super);
|
|
function FutureAction(scheduler, work) {
|
|
_super.call(this, scheduler, work);
|
|
this.scheduler = scheduler;
|
|
this.work = work;
|
|
}
|
|
FutureAction.prototype.schedule = function(state, delay) {
|
|
var _this = this;
|
|
if (delay === void 0) {
|
|
delay = 0;
|
|
}
|
|
if (this.isUnsubscribed) {
|
|
return this;
|
|
}
|
|
this.delay = delay;
|
|
this.state = state;
|
|
var id = this.id;
|
|
if (id != null) {
|
|
this.id = undefined;
|
|
clearTimeout(id);
|
|
}
|
|
var scheduler = this.scheduler;
|
|
this.id = setTimeout(function() {
|
|
_this.id = void 0;
|
|
scheduler.actions.push(_this);
|
|
scheduler.flush();
|
|
}, this.delay);
|
|
return this;
|
|
};
|
|
FutureAction.prototype.unsubscribe = function() {
|
|
var id = this.id;
|
|
if (id != null) {
|
|
this.id = void 0;
|
|
clearTimeout(id);
|
|
}
|
|
_super.prototype.unsubscribe.call(this);
|
|
};
|
|
return FutureAction;
|
|
})(QueueAction_1.QueueAction);
|
|
exports.FutureAction = FutureAction;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1bd", ["1bb", "1bc"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var QueueAction_1 = $__require('1bb');
|
|
var FutureAction_1 = $__require('1bc');
|
|
var QueueScheduler = (function() {
|
|
function QueueScheduler() {
|
|
this.actions = [];
|
|
this.active = false;
|
|
this.scheduled = false;
|
|
}
|
|
QueueScheduler.prototype.now = function() {
|
|
return Date.now();
|
|
};
|
|
QueueScheduler.prototype.flush = function() {
|
|
if (this.active || this.scheduled) {
|
|
return;
|
|
}
|
|
this.active = true;
|
|
var actions = this.actions;
|
|
for (var action = void 0; action = actions.shift(); ) {
|
|
action.execute();
|
|
}
|
|
this.active = false;
|
|
};
|
|
QueueScheduler.prototype.schedule = function(work, delay, state) {
|
|
if (delay === void 0) {
|
|
delay = 0;
|
|
}
|
|
return (delay <= 0) ? this.scheduleNow(work, state) : this.scheduleLater(work, delay, state);
|
|
};
|
|
QueueScheduler.prototype.scheduleNow = function(work, state) {
|
|
return new QueueAction_1.QueueAction(this, work).schedule(state);
|
|
};
|
|
QueueScheduler.prototype.scheduleLater = function(work, delay, state) {
|
|
return new FutureAction_1.FutureAction(this, work).schedule(state, delay);
|
|
};
|
|
return QueueScheduler;
|
|
})();
|
|
exports.QueueScheduler = QueueScheduler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1be", ["1bd"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var QueueScheduler_1 = $__require('1bd');
|
|
exports.queue = new QueueScheduler_1.QueueScheduler();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1bf", ["1b9", "1b6", "1be"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var Observable_1 = $__require('1b9');
|
|
var Subscription_1 = $__require('1b6');
|
|
var queue_1 = $__require('1be');
|
|
var PromiseObservable = (function(_super) {
|
|
__extends(PromiseObservable, _super);
|
|
function PromiseObservable(promise, scheduler) {
|
|
if (scheduler === void 0) {
|
|
scheduler = queue_1.queue;
|
|
}
|
|
_super.call(this);
|
|
this.promise = promise;
|
|
this.scheduler = scheduler;
|
|
this._isScalar = false;
|
|
}
|
|
PromiseObservable.create = function(promise, scheduler) {
|
|
if (scheduler === void 0) {
|
|
scheduler = queue_1.queue;
|
|
}
|
|
return new PromiseObservable(promise, scheduler);
|
|
};
|
|
PromiseObservable.prototype._subscribe = function(subscriber) {
|
|
var _this = this;
|
|
var scheduler = this.scheduler;
|
|
var promise = this.promise;
|
|
if (scheduler === queue_1.queue) {
|
|
if (this._isScalar) {
|
|
subscriber.next(this.value);
|
|
subscriber.complete();
|
|
} else {
|
|
promise.then(function(value) {
|
|
_this._isScalar = true;
|
|
_this.value = value;
|
|
subscriber.next(value);
|
|
subscriber.complete();
|
|
}, function(err) {
|
|
return subscriber.error(err);
|
|
}).then(null, function(err) {
|
|
setTimeout(function() {
|
|
throw err;
|
|
});
|
|
});
|
|
}
|
|
} else {
|
|
var subscription = new Subscription_1.Subscription();
|
|
if (this._isScalar) {
|
|
var value = this.value;
|
|
subscription.add(scheduler.schedule(dispatchNext, 0, {
|
|
value: value,
|
|
subscriber: subscriber
|
|
}));
|
|
} else {
|
|
promise.then(function(value) {
|
|
_this._isScalar = true;
|
|
_this.value = value;
|
|
subscription.add(scheduler.schedule(dispatchNext, 0, {
|
|
value: value,
|
|
subscriber: subscriber
|
|
}));
|
|
}, function(err) {
|
|
return subscription.add(scheduler.schedule(dispatchError, 0, {
|
|
err: err,
|
|
subscriber: subscriber
|
|
}));
|
|
}).then(null, function(err) {
|
|
scheduler.schedule(function() {
|
|
throw err;
|
|
});
|
|
});
|
|
}
|
|
return subscription;
|
|
}
|
|
};
|
|
return PromiseObservable;
|
|
})(Observable_1.Observable);
|
|
exports.PromiseObservable = PromiseObservable;
|
|
function dispatchNext(_a) {
|
|
var value = _a.value,
|
|
subscriber = _a.subscriber;
|
|
subscriber.next(value);
|
|
subscriber.complete();
|
|
}
|
|
function dispatchError(_a) {
|
|
var err = _a.err,
|
|
subscriber = _a.subscriber;
|
|
subscriber.error(err);
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c0", ["1c1"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var root_1 = $__require('1c1');
|
|
function toPromise(PromiseCtor) {
|
|
var _this = this;
|
|
if (!PromiseCtor) {
|
|
if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
|
|
PromiseCtor = root_1.root.Rx.config.Promise;
|
|
} else if (root_1.root.Promise) {
|
|
PromiseCtor = root_1.root.Promise;
|
|
}
|
|
}
|
|
if (!PromiseCtor) {
|
|
throw new Error('no Promise impl found');
|
|
}
|
|
return new PromiseCtor(function(resolve, reject) {
|
|
var value;
|
|
_this.subscribe(function(x) {
|
|
return value = x;
|
|
}, function(err) {
|
|
return reject(err);
|
|
}, function() {
|
|
return resolve(value);
|
|
});
|
|
});
|
|
}
|
|
exports.toPromise = toPromise;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c2", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function throwError(e) {
|
|
throw e;
|
|
}
|
|
exports.throwError = throwError;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c3", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function tryOrOnError(target) {
|
|
function tryCatcher() {
|
|
try {
|
|
tryCatcher.target.apply(this, arguments);
|
|
} catch (e) {
|
|
this.error(e);
|
|
}
|
|
}
|
|
tryCatcher.target = target;
|
|
return tryCatcher;
|
|
}
|
|
exports.tryOrOnError = tryOrOnError;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c4", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function noop() {}
|
|
exports.noop = noop;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b6", ["1c4"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var noop_1 = $__require('1c4');
|
|
var Subscription = (function() {
|
|
function Subscription(_unsubscribe) {
|
|
this.isUnsubscribed = false;
|
|
if (_unsubscribe) {
|
|
this._unsubscribe = _unsubscribe;
|
|
}
|
|
}
|
|
Subscription.prototype._unsubscribe = function() {
|
|
noop_1.noop();
|
|
};
|
|
Subscription.prototype.unsubscribe = function() {
|
|
if (this.isUnsubscribed) {
|
|
return;
|
|
}
|
|
this.isUnsubscribed = true;
|
|
var unsubscribe = this._unsubscribe;
|
|
var subscriptions = this._subscriptions;
|
|
this._subscriptions = void 0;
|
|
if (unsubscribe) {
|
|
unsubscribe.call(this);
|
|
}
|
|
if (subscriptions != null) {
|
|
var index = -1;
|
|
var len = subscriptions.length;
|
|
while (++index < len) {
|
|
subscriptions[index].unsubscribe();
|
|
}
|
|
}
|
|
};
|
|
Subscription.prototype.add = function(subscription) {
|
|
if (!subscription || (subscription === this) || (subscription === Subscription.EMPTY)) {
|
|
return;
|
|
}
|
|
var sub = subscription;
|
|
switch (typeof subscription) {
|
|
case 'function':
|
|
sub = new Subscription(subscription);
|
|
case 'object':
|
|
if (sub.isUnsubscribed || typeof sub.unsubscribe !== 'function') {
|
|
break;
|
|
} else if (this.isUnsubscribed) {
|
|
sub.unsubscribe();
|
|
} else {
|
|
var subscriptions = this._subscriptions || (this._subscriptions = []);
|
|
subscriptions.push(sub);
|
|
}
|
|
break;
|
|
default:
|
|
throw new Error('Unrecognized subscription ' + subscription + ' added to Subscription.');
|
|
}
|
|
};
|
|
Subscription.prototype.remove = function(subscription) {
|
|
if (subscription == null || (subscription === this) || (subscription === Subscription.EMPTY)) {
|
|
return;
|
|
}
|
|
var subscriptions = this._subscriptions;
|
|
if (subscriptions) {
|
|
var subscriptionIndex = subscriptions.indexOf(subscription);
|
|
if (subscriptionIndex !== -1) {
|
|
subscriptions.splice(subscriptionIndex, 1);
|
|
}
|
|
}
|
|
};
|
|
Subscription.EMPTY = (function(empty) {
|
|
empty.isUnsubscribed = true;
|
|
return empty;
|
|
}(new Subscription()));
|
|
return Subscription;
|
|
})();
|
|
exports.Subscription = Subscription;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b7", ["1c4", "1c2", "1c3", "1b6", "1ba"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var noop_1 = $__require('1c4');
|
|
var throwError_1 = $__require('1c2');
|
|
var tryOrOnError_1 = $__require('1c3');
|
|
var Subscription_1 = $__require('1b6');
|
|
var rxSubscriber_1 = $__require('1ba');
|
|
var Subscriber = (function(_super) {
|
|
__extends(Subscriber, _super);
|
|
function Subscriber(destination) {
|
|
_super.call(this);
|
|
this.destination = destination;
|
|
this._isUnsubscribed = false;
|
|
if (!this.destination) {
|
|
return;
|
|
}
|
|
var subscription = destination._subscription;
|
|
if (subscription) {
|
|
this._subscription = subscription;
|
|
} else if (destination instanceof Subscriber) {
|
|
this._subscription = destination;
|
|
}
|
|
}
|
|
Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function() {
|
|
return this;
|
|
};
|
|
Object.defineProperty(Subscriber.prototype, "isUnsubscribed", {
|
|
get: function() {
|
|
var subscription = this._subscription;
|
|
if (subscription) {
|
|
return this._isUnsubscribed || subscription.isUnsubscribed;
|
|
} else {
|
|
return this._isUnsubscribed;
|
|
}
|
|
},
|
|
set: function(value) {
|
|
var subscription = this._subscription;
|
|
if (subscription) {
|
|
subscription.isUnsubscribed = Boolean(value);
|
|
} else {
|
|
this._isUnsubscribed = Boolean(value);
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Subscriber.create = function(next, error, complete) {
|
|
var subscriber = new Subscriber();
|
|
subscriber._next = (typeof next === 'function') && tryOrOnError_1.tryOrOnError(next) || noop_1.noop;
|
|
subscriber._error = (typeof error === 'function') && error || throwError_1.throwError;
|
|
subscriber._complete = (typeof complete === 'function') && complete || noop_1.noop;
|
|
return subscriber;
|
|
};
|
|
Subscriber.prototype.add = function(sub) {
|
|
var _subscription = this._subscription;
|
|
if (_subscription) {
|
|
_subscription.add(sub);
|
|
} else {
|
|
_super.prototype.add.call(this, sub);
|
|
}
|
|
};
|
|
Subscriber.prototype.remove = function(sub) {
|
|
if (this._subscription) {
|
|
this._subscription.remove(sub);
|
|
} else {
|
|
_super.prototype.remove.call(this, sub);
|
|
}
|
|
};
|
|
Subscriber.prototype.unsubscribe = function() {
|
|
if (this._isUnsubscribed) {
|
|
return;
|
|
} else if (this._subscription) {
|
|
this._isUnsubscribed = true;
|
|
} else {
|
|
_super.prototype.unsubscribe.call(this);
|
|
}
|
|
};
|
|
Subscriber.prototype._next = function(value) {
|
|
var destination = this.destination;
|
|
if (destination.next) {
|
|
destination.next(value);
|
|
}
|
|
};
|
|
Subscriber.prototype._error = function(err) {
|
|
var destination = this.destination;
|
|
if (destination.error) {
|
|
destination.error(err);
|
|
}
|
|
};
|
|
Subscriber.prototype._complete = function() {
|
|
var destination = this.destination;
|
|
if (destination.complete) {
|
|
destination.complete();
|
|
}
|
|
};
|
|
Subscriber.prototype.next = function(value) {
|
|
if (!this.isUnsubscribed) {
|
|
this._next(value);
|
|
}
|
|
};
|
|
Subscriber.prototype.error = function(err) {
|
|
if (!this.isUnsubscribed) {
|
|
this._error(err);
|
|
this.unsubscribe();
|
|
}
|
|
};
|
|
Subscriber.prototype.complete = function() {
|
|
if (!this.isUnsubscribed) {
|
|
this._complete();
|
|
this.unsubscribe();
|
|
}
|
|
};
|
|
return Subscriber;
|
|
})(Subscription_1.Subscription);
|
|
exports.Subscriber = Subscriber;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c1", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var objectTypes = {
|
|
'boolean': false,
|
|
'function': true,
|
|
'object': true,
|
|
'number': false,
|
|
'string': false,
|
|
'undefined': false
|
|
};
|
|
exports.root = (objectTypes[typeof self] && self) || (objectTypes[typeof window] && window);
|
|
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
|
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
|
var freeGlobal = objectTypes[typeof global] && global;
|
|
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
|
exports.root = freeGlobal;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c5", ["1c1"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var root_1 = $__require('1c1');
|
|
function polyfillSymbol(root) {
|
|
var Symbol = ensureSymbol(root);
|
|
ensureIterator(Symbol, root);
|
|
ensureObservable(Symbol);
|
|
ensureFor(Symbol);
|
|
return Symbol;
|
|
}
|
|
exports.polyfillSymbol = polyfillSymbol;
|
|
function ensureFor(Symbol) {
|
|
if (!Symbol.for) {
|
|
Symbol.for = symbolForPolyfill;
|
|
}
|
|
}
|
|
exports.ensureFor = ensureFor;
|
|
var id = 0;
|
|
function ensureSymbol(root) {
|
|
if (!root.Symbol) {
|
|
root.Symbol = function symbolFuncPolyfill(description) {
|
|
return "@@Symbol(" + description + "):" + id++;
|
|
};
|
|
}
|
|
return root.Symbol;
|
|
}
|
|
exports.ensureSymbol = ensureSymbol;
|
|
function symbolForPolyfill(key) {
|
|
return '@@' + key;
|
|
}
|
|
exports.symbolForPolyfill = symbolForPolyfill;
|
|
function ensureIterator(Symbol, root) {
|
|
if (!Symbol.iterator) {
|
|
if (typeof Symbol.for === 'function') {
|
|
Symbol.iterator = Symbol.for('iterator');
|
|
} else if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {
|
|
Symbol.iterator = '@@iterator';
|
|
} else if (root.Map) {
|
|
var keys = Object.getOwnPropertyNames(root.Map.prototype);
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
var key = keys[i];
|
|
if (key !== 'entries' && key !== 'size' && root.Map.prototype[key] === root.Map.prototype['entries']) {
|
|
Symbol.iterator = key;
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
Symbol.iterator = '@@iterator';
|
|
}
|
|
}
|
|
}
|
|
exports.ensureIterator = ensureIterator;
|
|
function ensureObservable(Symbol) {
|
|
if (!Symbol.observable) {
|
|
if (typeof Symbol.for === 'function') {
|
|
Symbol.observable = Symbol.for('observable');
|
|
} else {
|
|
Symbol.observable = '@@observable';
|
|
}
|
|
}
|
|
}
|
|
exports.ensureObservable = ensureObservable;
|
|
exports.SymbolShim = polyfillSymbol(root_1.root);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ba", ["1c5"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var SymbolShim_1 = $__require('1c5');
|
|
exports.rxSubscriber = SymbolShim_1.SymbolShim.for('rxSubscriber');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b9", ["1b7", "1c1", "1c5", "1ba"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var Subscriber_1 = $__require('1b7');
|
|
var root_1 = $__require('1c1');
|
|
var SymbolShim_1 = $__require('1c5');
|
|
var rxSubscriber_1 = $__require('1ba');
|
|
var Observable = (function() {
|
|
function Observable(subscribe) {
|
|
this._isScalar = false;
|
|
if (subscribe) {
|
|
this._subscribe = subscribe;
|
|
}
|
|
}
|
|
Observable.prototype.lift = function(operator) {
|
|
var observable = new Observable();
|
|
observable.source = this;
|
|
observable.operator = operator;
|
|
return observable;
|
|
};
|
|
Observable.prototype[SymbolShim_1.SymbolShim.observable] = function() {
|
|
return this;
|
|
};
|
|
Observable.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
var subscriber;
|
|
if (observerOrNext && typeof observerOrNext === 'object') {
|
|
if (observerOrNext instanceof Subscriber_1.Subscriber) {
|
|
subscriber = observerOrNext;
|
|
} else if (observerOrNext[rxSubscriber_1.rxSubscriber]) {
|
|
subscriber = observerOrNext[rxSubscriber_1.rxSubscriber]();
|
|
} else {
|
|
subscriber = new Subscriber_1.Subscriber(observerOrNext);
|
|
}
|
|
} else {
|
|
var next = observerOrNext;
|
|
subscriber = Subscriber_1.Subscriber.create(next, error, complete);
|
|
}
|
|
subscriber.add(this._subscribe(subscriber));
|
|
return subscriber;
|
|
};
|
|
Observable.prototype.forEach = function(next, thisArg, PromiseCtor) {
|
|
if (!PromiseCtor) {
|
|
if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
|
|
PromiseCtor = root_1.root.Rx.config.Promise;
|
|
} else if (root_1.root.Promise) {
|
|
PromiseCtor = root_1.root.Promise;
|
|
}
|
|
}
|
|
if (!PromiseCtor) {
|
|
throw new Error('no Promise impl found');
|
|
}
|
|
var nextHandler;
|
|
if (thisArg) {
|
|
nextHandler = function nextHandlerFn(value) {
|
|
var _a = nextHandlerFn,
|
|
thisArg = _a.thisArg,
|
|
next = _a.next;
|
|
return next.call(thisArg, value);
|
|
};
|
|
nextHandler.thisArg = thisArg;
|
|
nextHandler.next = next;
|
|
} else {
|
|
nextHandler = next;
|
|
}
|
|
var promiseCallback = function promiseCallbackFn(resolve, reject) {
|
|
var _a = promiseCallbackFn,
|
|
source = _a.source,
|
|
nextHandler = _a.nextHandler;
|
|
source.subscribe(nextHandler, reject, resolve);
|
|
};
|
|
promiseCallback.source = this;
|
|
promiseCallback.nextHandler = nextHandler;
|
|
return new PromiseCtor(promiseCallback);
|
|
};
|
|
Observable.prototype._subscribe = function(subscriber) {
|
|
return this.source._subscribe(this.operator.call(subscriber));
|
|
};
|
|
Observable.create = function(subscribe) {
|
|
return new Observable(subscribe);
|
|
};
|
|
return Observable;
|
|
})();
|
|
exports.Observable = Observable;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("63", ["20", "8b", "1b8", "1bf", "1c0", "1b9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var promise_1 = $__require('8b');
|
|
exports.PromiseWrapper = promise_1.PromiseWrapper;
|
|
exports.Promise = promise_1.Promise;
|
|
var Subject_1 = $__require('1b8');
|
|
var fromPromise_1 = $__require('1bf');
|
|
var toPromise_1 = $__require('1c0');
|
|
var Observable_1 = $__require('1b9');
|
|
exports.Observable = Observable_1.Observable;
|
|
var Subject_2 = $__require('1b8');
|
|
exports.Subject = Subject_2.Subject;
|
|
var TimerWrapper = (function() {
|
|
function TimerWrapper() {}
|
|
TimerWrapper.setTimeout = function(fn, millis) {
|
|
return lang_1.global.setTimeout(fn, millis);
|
|
};
|
|
TimerWrapper.clearTimeout = function(id) {
|
|
lang_1.global.clearTimeout(id);
|
|
};
|
|
TimerWrapper.setInterval = function(fn, millis) {
|
|
return lang_1.global.setInterval(fn, millis);
|
|
};
|
|
TimerWrapper.clearInterval = function(id) {
|
|
lang_1.global.clearInterval(id);
|
|
};
|
|
return TimerWrapper;
|
|
})();
|
|
exports.TimerWrapper = TimerWrapper;
|
|
var ObservableWrapper = (function() {
|
|
function ObservableWrapper() {}
|
|
ObservableWrapper.subscribe = function(emitter, onNext, onError, onComplete) {
|
|
if (onComplete === void 0) {
|
|
onComplete = function() {};
|
|
}
|
|
onError = (typeof onError === "function") && onError || lang_1.noop;
|
|
onComplete = (typeof onComplete === "function") && onComplete || lang_1.noop;
|
|
return emitter.subscribe({
|
|
next: onNext,
|
|
error: onError,
|
|
complete: onComplete
|
|
});
|
|
};
|
|
ObservableWrapper.isObservable = function(obs) {
|
|
return !!obs.subscribe;
|
|
};
|
|
ObservableWrapper.hasSubscribers = function(obs) {
|
|
return obs.observers.length > 0;
|
|
};
|
|
ObservableWrapper.dispose = function(subscription) {
|
|
subscription.unsubscribe();
|
|
};
|
|
ObservableWrapper.callNext = function(emitter, value) {
|
|
emitter.next(value);
|
|
};
|
|
ObservableWrapper.callEmit = function(emitter, value) {
|
|
emitter.emit(value);
|
|
};
|
|
ObservableWrapper.callError = function(emitter, error) {
|
|
emitter.error(error);
|
|
};
|
|
ObservableWrapper.callComplete = function(emitter) {
|
|
emitter.complete();
|
|
};
|
|
ObservableWrapper.fromPromise = function(promise) {
|
|
return fromPromise_1.PromiseObservable.create(promise);
|
|
};
|
|
ObservableWrapper.toPromise = function(obj) {
|
|
return toPromise_1.toPromise.call(obj);
|
|
};
|
|
return ObservableWrapper;
|
|
})();
|
|
exports.ObservableWrapper = ObservableWrapper;
|
|
var EventEmitter = (function(_super) {
|
|
__extends(EventEmitter, _super);
|
|
function EventEmitter(isAsync) {
|
|
if (isAsync === void 0) {
|
|
isAsync = true;
|
|
}
|
|
_super.call(this);
|
|
this._isAsync = isAsync;
|
|
}
|
|
EventEmitter.prototype.emit = function(value) {
|
|
_super.prototype.next.call(this, value);
|
|
};
|
|
EventEmitter.prototype.next = function(value) {
|
|
_super.prototype.next.call(this, value);
|
|
};
|
|
EventEmitter.prototype.subscribe = function(generatorOrNext, error, complete) {
|
|
var schedulerFn;
|
|
var errorFn = function(err) {
|
|
return null;
|
|
};
|
|
var completeFn = function() {
|
|
return null;
|
|
};
|
|
if (generatorOrNext && typeof generatorOrNext === 'object') {
|
|
schedulerFn = this._isAsync ? function(value) {
|
|
setTimeout(function() {
|
|
return generatorOrNext.next(value);
|
|
});
|
|
} : function(value) {
|
|
generatorOrNext.next(value);
|
|
};
|
|
if (generatorOrNext.error) {
|
|
errorFn = this._isAsync ? function(err) {
|
|
setTimeout(function() {
|
|
return generatorOrNext.error(err);
|
|
});
|
|
} : function(err) {
|
|
generatorOrNext.error(err);
|
|
};
|
|
}
|
|
if (generatorOrNext.complete) {
|
|
completeFn = this._isAsync ? function() {
|
|
setTimeout(function() {
|
|
return generatorOrNext.complete();
|
|
});
|
|
} : function() {
|
|
generatorOrNext.complete();
|
|
};
|
|
}
|
|
} else {
|
|
schedulerFn = this._isAsync ? function(value) {
|
|
setTimeout(function() {
|
|
return generatorOrNext(value);
|
|
});
|
|
} : function(value) {
|
|
generatorOrNext(value);
|
|
};
|
|
if (error) {
|
|
errorFn = this._isAsync ? function(err) {
|
|
setTimeout(function() {
|
|
return error(err);
|
|
});
|
|
} : function(err) {
|
|
error(err);
|
|
};
|
|
}
|
|
if (complete) {
|
|
completeFn = this._isAsync ? function() {
|
|
setTimeout(function() {
|
|
return complete();
|
|
});
|
|
} : function() {
|
|
complete();
|
|
};
|
|
}
|
|
}
|
|
return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
|
|
};
|
|
return EventEmitter;
|
|
})(Subject_1.Subject);
|
|
exports.EventEmitter = EventEmitter;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a7", ["37", "20", "63"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var async_1 = $__require('63');
|
|
var QueryList = (function() {
|
|
function QueryList() {
|
|
this._results = [];
|
|
this._emitter = new async_1.EventEmitter();
|
|
}
|
|
Object.defineProperty(QueryList.prototype, "changes", {
|
|
get: function() {
|
|
return this._emitter;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryList.prototype, "length", {
|
|
get: function() {
|
|
return this._results.length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryList.prototype, "first", {
|
|
get: function() {
|
|
return collection_1.ListWrapper.first(this._results);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryList.prototype, "last", {
|
|
get: function() {
|
|
return collection_1.ListWrapper.last(this._results);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
QueryList.prototype.map = function(fn) {
|
|
return this._results.map(fn);
|
|
};
|
|
QueryList.prototype.filter = function(fn) {
|
|
return this._results.filter(fn);
|
|
};
|
|
QueryList.prototype.reduce = function(fn, init) {
|
|
return this._results.reduce(fn, init);
|
|
};
|
|
QueryList.prototype.toArray = function() {
|
|
return collection_1.ListWrapper.clone(this._results);
|
|
};
|
|
QueryList.prototype[lang_1.getSymbolIterator()] = function() {
|
|
return this._results[lang_1.getSymbolIterator()]();
|
|
};
|
|
QueryList.prototype.toString = function() {
|
|
return this._results.toString();
|
|
};
|
|
QueryList.prototype.reset = function(res) {
|
|
this._results = res;
|
|
};
|
|
QueryList.prototype.notifyOnChanges = function() {
|
|
this._emitter.emit(this);
|
|
};
|
|
return QueryList;
|
|
})();
|
|
exports.QueryList = QueryList;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c6", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports.EVENT_TARGET_SEPARATOR = ':';
|
|
var EventConfig = (function() {
|
|
function EventConfig(fieldName, eventName, isLongForm) {
|
|
this.fieldName = fieldName;
|
|
this.eventName = eventName;
|
|
this.isLongForm = isLongForm;
|
|
}
|
|
EventConfig.parse = function(eventConfig) {
|
|
var fieldName = eventConfig,
|
|
eventName = eventConfig,
|
|
isLongForm = false;
|
|
var separatorIdx = eventConfig.indexOf(exports.EVENT_TARGET_SEPARATOR);
|
|
if (separatorIdx > -1) {
|
|
fieldName = eventConfig.substring(0, separatorIdx).trim();
|
|
eventName = eventConfig.substring(separatorIdx + 1).trim();
|
|
isLongForm = true;
|
|
}
|
|
return new EventConfig(fieldName, eventName, isLongForm);
|
|
};
|
|
EventConfig.prototype.getFullName = function() {
|
|
return this.isLongForm ? "" + this.fieldName + exports.EVENT_TARGET_SEPARATOR + this.eventName : this.eventName;
|
|
};
|
|
return EventConfig;
|
|
})();
|
|
exports.EventConfig = EventConfig;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c7", ["1c8", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var provider_1 = $__require('1c8');
|
|
var di_1 = $__require('39');
|
|
var PipeProvider = (function(_super) {
|
|
__extends(PipeProvider, _super);
|
|
function PipeProvider(name, pure, key, resolvedFactories, multiBinding) {
|
|
_super.call(this, key, resolvedFactories, multiBinding);
|
|
this.name = name;
|
|
this.pure = pure;
|
|
}
|
|
PipeProvider.createFromType = function(type, metadata) {
|
|
var provider = new di_1.Provider(type, {useClass: type});
|
|
var rb = provider_1.resolveProvider(provider);
|
|
return new PipeProvider(metadata.name, metadata.pure, rb.key, rb.resolvedFactories, rb.multiProvider);
|
|
};
|
|
return PipeProvider;
|
|
})(provider_1.ResolvedProvider_);
|
|
exports.PipeProvider = PipeProvider;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7c", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(LifecycleHooks) {
|
|
LifecycleHooks[LifecycleHooks["OnInit"] = 0] = "OnInit";
|
|
LifecycleHooks[LifecycleHooks["OnDestroy"] = 1] = "OnDestroy";
|
|
LifecycleHooks[LifecycleHooks["DoCheck"] = 2] = "DoCheck";
|
|
LifecycleHooks[LifecycleHooks["OnChanges"] = 3] = "OnChanges";
|
|
LifecycleHooks[LifecycleHooks["AfterContentInit"] = 4] = "AfterContentInit";
|
|
LifecycleHooks[LifecycleHooks["AfterContentChecked"] = 5] = "AfterContentChecked";
|
|
LifecycleHooks[LifecycleHooks["AfterViewInit"] = 6] = "AfterViewInit";
|
|
LifecycleHooks[LifecycleHooks["AfterViewChecked"] = 7] = "AfterViewChecked";
|
|
})(exports.LifecycleHooks || (exports.LifecycleHooks = {}));
|
|
var LifecycleHooks = exports.LifecycleHooks;
|
|
exports.LIFECYCLE_HOOKS_VALUES = [LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges, LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit, LifecycleHooks.AfterViewChecked];
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ae", ["20", "3c", "63", "37", "39", "1c9", "1c8", "1ca", "1a6", "1aa", "1a8", "1a9", "7d", "80", "6e", "1a7", "81", "1c6", "1c7", "7c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var async_1 = $__require('63');
|
|
var collection_1 = $__require('37');
|
|
var di_1 = $__require('39');
|
|
var injector_1 = $__require('1c9');
|
|
var provider_1 = $__require('1c8');
|
|
var di_2 = $__require('1ca');
|
|
var avmModule = $__require('1a6');
|
|
var view_container_ref_1 = $__require('1aa');
|
|
var element_ref_1 = $__require('1a8');
|
|
var template_ref_1 = $__require('1a9');
|
|
var directives_1 = $__require('7d');
|
|
var directive_lifecycle_reflector_1 = $__require('80');
|
|
var change_detection_1 = $__require('6e');
|
|
var query_list_1 = $__require('1a7');
|
|
var reflection_1 = $__require('81');
|
|
var event_config_1 = $__require('1c6');
|
|
var pipe_provider_1 = $__require('1c7');
|
|
var interfaces_1 = $__require('7c');
|
|
var view_container_ref_2 = $__require('1aa');
|
|
var _staticKeys;
|
|
var StaticKeys = (function() {
|
|
function StaticKeys() {
|
|
this.viewManagerId = di_1.Key.get(avmModule.AppViewManager).id;
|
|
this.templateRefId = di_1.Key.get(template_ref_1.TemplateRef).id;
|
|
this.viewContainerId = di_1.Key.get(view_container_ref_1.ViewContainerRef).id;
|
|
this.changeDetectorRefId = di_1.Key.get(change_detection_1.ChangeDetectorRef).id;
|
|
this.elementRefId = di_1.Key.get(element_ref_1.ElementRef).id;
|
|
}
|
|
StaticKeys.instance = function() {
|
|
if (lang_1.isBlank(_staticKeys))
|
|
_staticKeys = new StaticKeys();
|
|
return _staticKeys;
|
|
};
|
|
return StaticKeys;
|
|
})();
|
|
exports.StaticKeys = StaticKeys;
|
|
var TreeNode = (function() {
|
|
function TreeNode(parent) {
|
|
if (lang_1.isPresent(parent)) {
|
|
parent.addChild(this);
|
|
} else {
|
|
this._parent = null;
|
|
}
|
|
}
|
|
TreeNode.prototype.addChild = function(child) {
|
|
child._parent = this;
|
|
};
|
|
TreeNode.prototype.remove = function() {
|
|
this._parent = null;
|
|
};
|
|
Object.defineProperty(TreeNode.prototype, "parent", {
|
|
get: function() {
|
|
return this._parent;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return TreeNode;
|
|
})();
|
|
exports.TreeNode = TreeNode;
|
|
var DirectiveDependency = (function(_super) {
|
|
__extends(DirectiveDependency, _super);
|
|
function DirectiveDependency(key, optional, lowerBoundVisibility, upperBoundVisibility, properties, attributeName, queryDecorator) {
|
|
_super.call(this, key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
|
|
this.attributeName = attributeName;
|
|
this.queryDecorator = queryDecorator;
|
|
this._verify();
|
|
}
|
|
DirectiveDependency.prototype._verify = function() {
|
|
var count = 0;
|
|
if (lang_1.isPresent(this.queryDecorator))
|
|
count++;
|
|
if (lang_1.isPresent(this.attributeName))
|
|
count++;
|
|
if (count > 1)
|
|
throw new exceptions_1.BaseException('A directive injectable can contain only one of the following @Attribute or @Query.');
|
|
};
|
|
DirectiveDependency.createFrom = function(d) {
|
|
return new DirectiveDependency(d.key, d.optional, d.lowerBoundVisibility, d.upperBoundVisibility, d.properties, DirectiveDependency._attributeName(d.properties), DirectiveDependency._query(d.properties));
|
|
};
|
|
DirectiveDependency._attributeName = function(properties) {
|
|
var p = properties.find(function(p) {
|
|
return p instanceof di_2.AttributeMetadata;
|
|
});
|
|
return lang_1.isPresent(p) ? p.attributeName : null;
|
|
};
|
|
DirectiveDependency._query = function(properties) {
|
|
return properties.find(function(p) {
|
|
return p instanceof di_2.QueryMetadata;
|
|
});
|
|
};
|
|
return DirectiveDependency;
|
|
})(di_1.Dependency);
|
|
exports.DirectiveDependency = DirectiveDependency;
|
|
var DirectiveProvider = (function(_super) {
|
|
__extends(DirectiveProvider, _super);
|
|
function DirectiveProvider(key, factory, deps, metadata, providers, viewProviders) {
|
|
_super.call(this, key, [new provider_1.ResolvedFactory(factory, deps)], false);
|
|
this.metadata = metadata;
|
|
this.providers = providers;
|
|
this.viewProviders = viewProviders;
|
|
this.callOnDestroy = directive_lifecycle_reflector_1.hasLifecycleHook(interfaces_1.LifecycleHooks.OnDestroy, key.token);
|
|
}
|
|
Object.defineProperty(DirectiveProvider.prototype, "displayName", {
|
|
get: function() {
|
|
return this.key.displayName;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveProvider.prototype, "queries", {
|
|
get: function() {
|
|
if (lang_1.isBlank(this.metadata.queries))
|
|
return [];
|
|
var res = [];
|
|
collection_1.StringMapWrapper.forEach(this.metadata.queries, function(meta, fieldName) {
|
|
var setter = reflection_1.reflector.setter(fieldName);
|
|
res.push(new QueryMetadataWithSetter(setter, meta));
|
|
});
|
|
return res;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveProvider.prototype, "eventEmitters", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.metadata) && lang_1.isPresent(this.metadata.outputs) ? this.metadata.outputs : [];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DirectiveProvider.createFromProvider = function(provider, meta) {
|
|
if (lang_1.isBlank(meta)) {
|
|
meta = new directives_1.DirectiveMetadata();
|
|
}
|
|
var rb = provider_1.resolveProvider(provider);
|
|
var rf = rb.resolvedFactories[0];
|
|
var deps = rf.dependencies.map(DirectiveDependency.createFrom);
|
|
var providers = lang_1.isPresent(meta.providers) ? meta.providers : [];
|
|
var viewBindigs = meta instanceof directives_1.ComponentMetadata && lang_1.isPresent(meta.viewProviders) ? meta.viewProviders : [];
|
|
return new DirectiveProvider(rb.key, rf.factory, deps, meta, providers, viewBindigs);
|
|
};
|
|
DirectiveProvider.createFromType = function(type, annotation) {
|
|
var provider = new di_1.Provider(type, {useClass: type});
|
|
return DirectiveProvider.createFromProvider(provider, annotation);
|
|
};
|
|
return DirectiveProvider;
|
|
})(provider_1.ResolvedProvider_);
|
|
exports.DirectiveProvider = DirectiveProvider;
|
|
var PreBuiltObjects = (function() {
|
|
function PreBuiltObjects(viewManager, view, elementRef, templateRef) {
|
|
this.viewManager = viewManager;
|
|
this.view = view;
|
|
this.elementRef = elementRef;
|
|
this.templateRef = templateRef;
|
|
this.nestedView = null;
|
|
}
|
|
return PreBuiltObjects;
|
|
})();
|
|
exports.PreBuiltObjects = PreBuiltObjects;
|
|
var QueryMetadataWithSetter = (function() {
|
|
function QueryMetadataWithSetter(setter, metadata) {
|
|
this.setter = setter;
|
|
this.metadata = metadata;
|
|
}
|
|
return QueryMetadataWithSetter;
|
|
})();
|
|
exports.QueryMetadataWithSetter = QueryMetadataWithSetter;
|
|
var EventEmitterAccessor = (function() {
|
|
function EventEmitterAccessor(eventName, getter) {
|
|
this.eventName = eventName;
|
|
this.getter = getter;
|
|
}
|
|
EventEmitterAccessor.prototype.subscribe = function(view, boundElementIndex, directive) {
|
|
var _this = this;
|
|
var eventEmitter = this.getter(directive);
|
|
return async_1.ObservableWrapper.subscribe(eventEmitter, function(eventObj) {
|
|
return view.triggerEventHandlers(_this.eventName, eventObj, boundElementIndex);
|
|
});
|
|
};
|
|
return EventEmitterAccessor;
|
|
})();
|
|
exports.EventEmitterAccessor = EventEmitterAccessor;
|
|
function _createEventEmitterAccessors(bwv) {
|
|
var provider = bwv.provider;
|
|
if (!(provider instanceof DirectiveProvider))
|
|
return [];
|
|
var db = provider;
|
|
return db.eventEmitters.map(function(eventConfig) {
|
|
var parsedEvent = event_config_1.EventConfig.parse(eventConfig);
|
|
return new EventEmitterAccessor(parsedEvent.eventName, reflection_1.reflector.getter(parsedEvent.fieldName));
|
|
});
|
|
}
|
|
function _createProtoQueryRefs(providers) {
|
|
var res = [];
|
|
collection_1.ListWrapper.forEachWithIndex(providers, function(b, i) {
|
|
if (b.provider instanceof DirectiveProvider) {
|
|
var directiveProvider = b.provider;
|
|
var queries = directiveProvider.queries;
|
|
queries.forEach(function(q) {
|
|
return res.push(new ProtoQueryRef(i, q.setter, q.metadata));
|
|
});
|
|
var deps = directiveProvider.resolvedFactory.dependencies;
|
|
deps.forEach(function(d) {
|
|
if (lang_1.isPresent(d.queryDecorator))
|
|
res.push(new ProtoQueryRef(i, null, d.queryDecorator));
|
|
});
|
|
}
|
|
});
|
|
return res;
|
|
}
|
|
var ProtoElementInjector = (function() {
|
|
function ProtoElementInjector(parent, index, bwv, distanceToParent, _firstProviderIsComponent, directiveVariableBindings) {
|
|
this.parent = parent;
|
|
this.index = index;
|
|
this.distanceToParent = distanceToParent;
|
|
this.directiveVariableBindings = directiveVariableBindings;
|
|
this._firstProviderIsComponent = _firstProviderIsComponent;
|
|
var length = bwv.length;
|
|
this.protoInjector = new injector_1.ProtoInjector(bwv);
|
|
this.eventEmitterAccessors = collection_1.ListWrapper.createFixedSize(length);
|
|
for (var i = 0; i < length; ++i) {
|
|
this.eventEmitterAccessors[i] = _createEventEmitterAccessors(bwv[i]);
|
|
}
|
|
this.protoQueryRefs = _createProtoQueryRefs(bwv);
|
|
}
|
|
ProtoElementInjector.create = function(parent, index, providers, firstProviderIsComponent, distanceToParent, directiveVariableBindings) {
|
|
var bd = [];
|
|
ProtoElementInjector._createDirectiveProviderWithVisibility(providers, bd, firstProviderIsComponent);
|
|
if (firstProviderIsComponent) {
|
|
ProtoElementInjector._createViewProvidersWithVisibility(providers, bd);
|
|
}
|
|
ProtoElementInjector._createProvidersWithVisibility(providers, bd);
|
|
return new ProtoElementInjector(parent, index, bd, distanceToParent, firstProviderIsComponent, directiveVariableBindings);
|
|
};
|
|
ProtoElementInjector._createDirectiveProviderWithVisibility = function(dirProviders, bd, firstProviderIsComponent) {
|
|
dirProviders.forEach(function(dirProvider) {
|
|
bd.push(ProtoElementInjector._createProviderWithVisibility(firstProviderIsComponent, dirProvider, dirProviders, dirProvider));
|
|
});
|
|
};
|
|
ProtoElementInjector._createProvidersWithVisibility = function(dirProviders, bd) {
|
|
var providersFromAllDirectives = [];
|
|
dirProviders.forEach(function(dirProvider) {
|
|
providersFromAllDirectives = collection_1.ListWrapper.concat(providersFromAllDirectives, dirProvider.providers);
|
|
});
|
|
var resolved = di_1.Injector.resolve(providersFromAllDirectives);
|
|
resolved.forEach(function(b) {
|
|
return bd.push(new injector_1.ProviderWithVisibility(b, injector_1.Visibility.Public));
|
|
});
|
|
};
|
|
ProtoElementInjector._createProviderWithVisibility = function(firstProviderIsComponent, dirProvider, dirProviders, provider) {
|
|
var isComponent = firstProviderIsComponent && dirProviders[0] === dirProvider;
|
|
return new injector_1.ProviderWithVisibility(provider, isComponent ? injector_1.Visibility.PublicAndPrivate : injector_1.Visibility.Public);
|
|
};
|
|
ProtoElementInjector._createViewProvidersWithVisibility = function(dirProviders, bd) {
|
|
var resolvedViewProviders = di_1.Injector.resolve(dirProviders[0].viewProviders);
|
|
resolvedViewProviders.forEach(function(b) {
|
|
return bd.push(new injector_1.ProviderWithVisibility(b, injector_1.Visibility.Private));
|
|
});
|
|
};
|
|
ProtoElementInjector.prototype.instantiate = function(parent) {
|
|
return new ElementInjector(this, parent);
|
|
};
|
|
ProtoElementInjector.prototype.directParent = function() {
|
|
return this.distanceToParent < 2 ? this.parent : null;
|
|
};
|
|
Object.defineProperty(ProtoElementInjector.prototype, "hasBindings", {
|
|
get: function() {
|
|
return this.eventEmitterAccessors.length > 0;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ProtoElementInjector.prototype.getProviderAtIndex = function(index) {
|
|
return this.protoInjector.getProviderAtIndex(index);
|
|
};
|
|
return ProtoElementInjector;
|
|
})();
|
|
exports.ProtoElementInjector = ProtoElementInjector;
|
|
var _Context = (function() {
|
|
function _Context(element, componentElement, injector) {
|
|
this.element = element;
|
|
this.componentElement = componentElement;
|
|
this.injector = injector;
|
|
}
|
|
return _Context;
|
|
})();
|
|
var ElementInjector = (function(_super) {
|
|
__extends(ElementInjector, _super);
|
|
function ElementInjector(_proto, parent) {
|
|
var _this = this;
|
|
_super.call(this, parent);
|
|
this._preBuiltObjects = null;
|
|
this._proto = _proto;
|
|
this._injector = new di_1.Injector(this._proto.protoInjector, null, this, function() {
|
|
return _this._debugContext();
|
|
});
|
|
var injectorStrategy = this._injector.internalStrategy;
|
|
this._strategy = injectorStrategy instanceof injector_1.InjectorInlineStrategy ? new ElementInjectorInlineStrategy(injectorStrategy, this) : new ElementInjectorDynamicStrategy(injectorStrategy, this);
|
|
this.hydrated = false;
|
|
this._queryStrategy = this._buildQueryStrategy();
|
|
}
|
|
ElementInjector.prototype.dehydrate = function() {
|
|
this.hydrated = false;
|
|
this._host = null;
|
|
this._preBuiltObjects = null;
|
|
this._strategy.callOnDestroy();
|
|
this._strategy.dehydrate();
|
|
this._queryStrategy.dehydrate();
|
|
};
|
|
ElementInjector.prototype.hydrate = function(imperativelyCreatedInjector, host, preBuiltObjects) {
|
|
this._host = host;
|
|
this._preBuiltObjects = preBuiltObjects;
|
|
this._reattachInjectors(imperativelyCreatedInjector);
|
|
this._queryStrategy.hydrate();
|
|
this._strategy.hydrate();
|
|
this.hydrated = true;
|
|
};
|
|
ElementInjector.prototype._debugContext = function() {
|
|
var p = this._preBuiltObjects;
|
|
var index = p.elementRef.boundElementIndex - p.view.elementOffset;
|
|
var c = this._preBuiltObjects.view.getDebugContext(index, null);
|
|
return lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.injector) : null;
|
|
};
|
|
ElementInjector.prototype._reattachInjectors = function(imperativelyCreatedInjector) {
|
|
if (lang_1.isPresent(this._parent)) {
|
|
if (lang_1.isPresent(imperativelyCreatedInjector)) {
|
|
this._reattachInjector(this._injector, imperativelyCreatedInjector, false);
|
|
this._reattachInjector(imperativelyCreatedInjector, this._parent._injector, false);
|
|
} else {
|
|
this._reattachInjector(this._injector, this._parent._injector, false);
|
|
}
|
|
} else if (lang_1.isPresent(this._host)) {
|
|
if (lang_1.isPresent(imperativelyCreatedInjector)) {
|
|
this._reattachInjector(this._injector, imperativelyCreatedInjector, false);
|
|
this._reattachInjector(imperativelyCreatedInjector, this._host._injector, true);
|
|
} else {
|
|
this._reattachInjector(this._injector, this._host._injector, true);
|
|
}
|
|
} else {
|
|
if (lang_1.isPresent(imperativelyCreatedInjector)) {
|
|
this._reattachInjector(this._injector, imperativelyCreatedInjector, true);
|
|
}
|
|
}
|
|
};
|
|
ElementInjector.prototype._reattachInjector = function(injector, parentInjector, isBoundary) {
|
|
injector.internalStrategy.attach(parentInjector, isBoundary);
|
|
};
|
|
ElementInjector.prototype.hasVariableBinding = function(name) {
|
|
var vb = this._proto.directiveVariableBindings;
|
|
return lang_1.isPresent(vb) && vb.has(name);
|
|
};
|
|
ElementInjector.prototype.getVariableBinding = function(name) {
|
|
var index = this._proto.directiveVariableBindings.get(name);
|
|
return lang_1.isPresent(index) ? this.getDirectiveAtIndex(index) : this.getElementRef();
|
|
};
|
|
ElementInjector.prototype.get = function(token) {
|
|
return this._injector.get(token);
|
|
};
|
|
ElementInjector.prototype.hasDirective = function(type) {
|
|
return lang_1.isPresent(this._injector.getOptional(type));
|
|
};
|
|
ElementInjector.prototype.getEventEmitterAccessors = function() {
|
|
return this._proto.eventEmitterAccessors;
|
|
};
|
|
ElementInjector.prototype.getDirectiveVariableBindings = function() {
|
|
return this._proto.directiveVariableBindings;
|
|
};
|
|
ElementInjector.prototype.getComponent = function() {
|
|
return this._strategy.getComponent();
|
|
};
|
|
ElementInjector.prototype.getInjector = function() {
|
|
return this._injector;
|
|
};
|
|
ElementInjector.prototype.getElementRef = function() {
|
|
return this._preBuiltObjects.elementRef;
|
|
};
|
|
ElementInjector.prototype.getViewContainerRef = function() {
|
|
return new view_container_ref_2.ViewContainerRef_(this._preBuiltObjects.viewManager, this.getElementRef());
|
|
};
|
|
ElementInjector.prototype.getNestedView = function() {
|
|
return this._preBuiltObjects.nestedView;
|
|
};
|
|
ElementInjector.prototype.getView = function() {
|
|
return this._preBuiltObjects.view;
|
|
};
|
|
ElementInjector.prototype.directParent = function() {
|
|
return this._proto.distanceToParent < 2 ? this.parent : null;
|
|
};
|
|
ElementInjector.prototype.isComponentKey = function(key) {
|
|
return this._strategy.isComponentKey(key);
|
|
};
|
|
ElementInjector.prototype.getDependency = function(injector, provider, dep) {
|
|
var key = dep.key;
|
|
if (provider instanceof DirectiveProvider) {
|
|
var dirDep = dep;
|
|
var dirProvider = provider;
|
|
var staticKeys = StaticKeys.instance();
|
|
if (key.id === staticKeys.viewManagerId)
|
|
return this._preBuiltObjects.viewManager;
|
|
if (lang_1.isPresent(dirDep.attributeName))
|
|
return this._buildAttribute(dirDep);
|
|
if (lang_1.isPresent(dirDep.queryDecorator))
|
|
return this._queryStrategy.findQuery(dirDep.queryDecorator).list;
|
|
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
|
|
if (dirProvider.metadata instanceof directives_1.ComponentMetadata) {
|
|
var componentView = this._preBuiltObjects.view.getNestedView(this._preBuiltObjects.elementRef.boundElementIndex);
|
|
return componentView.changeDetector.ref;
|
|
} else {
|
|
return this._preBuiltObjects.view.changeDetector.ref;
|
|
}
|
|
}
|
|
if (dirDep.key.id === StaticKeys.instance().elementRefId) {
|
|
return this.getElementRef();
|
|
}
|
|
if (dirDep.key.id === StaticKeys.instance().viewContainerId) {
|
|
return this.getViewContainerRef();
|
|
}
|
|
if (dirDep.key.id === StaticKeys.instance().templateRefId) {
|
|
if (lang_1.isBlank(this._preBuiltObjects.templateRef)) {
|
|
if (dirDep.optional) {
|
|
return null;
|
|
}
|
|
throw new di_1.NoProviderError(null, dirDep.key);
|
|
}
|
|
return this._preBuiltObjects.templateRef;
|
|
}
|
|
} else if (provider instanceof pipe_provider_1.PipeProvider) {
|
|
if (dep.key.id === StaticKeys.instance().changeDetectorRefId) {
|
|
var componentView = this._preBuiltObjects.view.getNestedView(this._preBuiltObjects.elementRef.boundElementIndex);
|
|
return componentView.changeDetector.ref;
|
|
}
|
|
}
|
|
return injector_1.UNDEFINED;
|
|
};
|
|
ElementInjector.prototype._buildAttribute = function(dep) {
|
|
var attributes = this._proto.attributes;
|
|
if (lang_1.isPresent(attributes) && attributes.has(dep.attributeName)) {
|
|
return attributes.get(dep.attributeName);
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
ElementInjector.prototype.addDirectivesMatchingQuery = function(query, list) {
|
|
var templateRef = lang_1.isBlank(this._preBuiltObjects) ? null : this._preBuiltObjects.templateRef;
|
|
if (query.selector === template_ref_1.TemplateRef && lang_1.isPresent(templateRef)) {
|
|
list.push(templateRef);
|
|
}
|
|
this._strategy.addDirectivesMatchingQuery(query, list);
|
|
};
|
|
ElementInjector.prototype._buildQueryStrategy = function() {
|
|
if (this._proto.protoQueryRefs.length === 0) {
|
|
return _emptyQueryStrategy;
|
|
} else if (this._proto.protoQueryRefs.length <= InlineQueryStrategy.NUMBER_OF_SUPPORTED_QUERIES) {
|
|
return new InlineQueryStrategy(this);
|
|
} else {
|
|
return new DynamicQueryStrategy(this);
|
|
}
|
|
};
|
|
ElementInjector.prototype.link = function(parent) {
|
|
parent.addChild(this);
|
|
};
|
|
ElementInjector.prototype.unlink = function() {
|
|
this.remove();
|
|
};
|
|
ElementInjector.prototype.getDirectiveAtIndex = function(index) {
|
|
return this._injector.getAt(index);
|
|
};
|
|
ElementInjector.prototype.hasInstances = function() {
|
|
return this._proto.hasBindings && this.hydrated;
|
|
};
|
|
ElementInjector.prototype.getHost = function() {
|
|
return this._host;
|
|
};
|
|
ElementInjector.prototype.getBoundElementIndex = function() {
|
|
return this._proto.index;
|
|
};
|
|
ElementInjector.prototype.getRootViewInjectors = function() {
|
|
if (!this.hydrated)
|
|
return [];
|
|
var view = this._preBuiltObjects.view;
|
|
var nestedView = view.getNestedView(view.elementOffset + this.getBoundElementIndex());
|
|
return lang_1.isPresent(nestedView) ? nestedView.rootElementInjectors : [];
|
|
};
|
|
ElementInjector.prototype.ngAfterViewChecked = function() {
|
|
this._queryStrategy.updateViewQueries();
|
|
};
|
|
ElementInjector.prototype.ngAfterContentChecked = function() {
|
|
this._queryStrategy.updateContentQueries();
|
|
};
|
|
ElementInjector.prototype.traverseAndSetQueriesAsDirty = function() {
|
|
var inj = this;
|
|
while (lang_1.isPresent(inj)) {
|
|
inj._setQueriesAsDirty();
|
|
inj = inj.parent;
|
|
}
|
|
};
|
|
ElementInjector.prototype._setQueriesAsDirty = function() {
|
|
this._queryStrategy.setContentQueriesAsDirty();
|
|
if (lang_1.isPresent(this._host))
|
|
this._host._queryStrategy.setViewQueriesAsDirty();
|
|
};
|
|
return ElementInjector;
|
|
})(TreeNode);
|
|
exports.ElementInjector = ElementInjector;
|
|
var _EmptyQueryStrategy = (function() {
|
|
function _EmptyQueryStrategy() {}
|
|
_EmptyQueryStrategy.prototype.setContentQueriesAsDirty = function() {};
|
|
_EmptyQueryStrategy.prototype.setViewQueriesAsDirty = function() {};
|
|
_EmptyQueryStrategy.prototype.hydrate = function() {};
|
|
_EmptyQueryStrategy.prototype.dehydrate = function() {};
|
|
_EmptyQueryStrategy.prototype.updateContentQueries = function() {};
|
|
_EmptyQueryStrategy.prototype.updateViewQueries = function() {};
|
|
_EmptyQueryStrategy.prototype.findQuery = function(query) {
|
|
throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
|
|
};
|
|
return _EmptyQueryStrategy;
|
|
})();
|
|
var _emptyQueryStrategy = new _EmptyQueryStrategy();
|
|
var InlineQueryStrategy = (function() {
|
|
function InlineQueryStrategy(ei) {
|
|
var protoRefs = ei._proto.protoQueryRefs;
|
|
if (protoRefs.length > 0)
|
|
this.query0 = new QueryRef(protoRefs[0], ei);
|
|
if (protoRefs.length > 1)
|
|
this.query1 = new QueryRef(protoRefs[1], ei);
|
|
if (protoRefs.length > 2)
|
|
this.query2 = new QueryRef(protoRefs[2], ei);
|
|
}
|
|
InlineQueryStrategy.prototype.setContentQueriesAsDirty = function() {
|
|
if (lang_1.isPresent(this.query0) && !this.query0.isViewQuery)
|
|
this.query0.dirty = true;
|
|
if (lang_1.isPresent(this.query1) && !this.query1.isViewQuery)
|
|
this.query1.dirty = true;
|
|
if (lang_1.isPresent(this.query2) && !this.query2.isViewQuery)
|
|
this.query2.dirty = true;
|
|
};
|
|
InlineQueryStrategy.prototype.setViewQueriesAsDirty = function() {
|
|
if (lang_1.isPresent(this.query0) && this.query0.isViewQuery)
|
|
this.query0.dirty = true;
|
|
if (lang_1.isPresent(this.query1) && this.query1.isViewQuery)
|
|
this.query1.dirty = true;
|
|
if (lang_1.isPresent(this.query2) && this.query2.isViewQuery)
|
|
this.query2.dirty = true;
|
|
};
|
|
InlineQueryStrategy.prototype.hydrate = function() {
|
|
if (lang_1.isPresent(this.query0))
|
|
this.query0.hydrate();
|
|
if (lang_1.isPresent(this.query1))
|
|
this.query1.hydrate();
|
|
if (lang_1.isPresent(this.query2))
|
|
this.query2.hydrate();
|
|
};
|
|
InlineQueryStrategy.prototype.dehydrate = function() {
|
|
if (lang_1.isPresent(this.query0))
|
|
this.query0.dehydrate();
|
|
if (lang_1.isPresent(this.query1))
|
|
this.query1.dehydrate();
|
|
if (lang_1.isPresent(this.query2))
|
|
this.query2.dehydrate();
|
|
};
|
|
InlineQueryStrategy.prototype.updateContentQueries = function() {
|
|
if (lang_1.isPresent(this.query0) && !this.query0.isViewQuery) {
|
|
this.query0.update();
|
|
}
|
|
if (lang_1.isPresent(this.query1) && !this.query1.isViewQuery) {
|
|
this.query1.update();
|
|
}
|
|
if (lang_1.isPresent(this.query2) && !this.query2.isViewQuery) {
|
|
this.query2.update();
|
|
}
|
|
};
|
|
InlineQueryStrategy.prototype.updateViewQueries = function() {
|
|
if (lang_1.isPresent(this.query0) && this.query0.isViewQuery) {
|
|
this.query0.update();
|
|
}
|
|
if (lang_1.isPresent(this.query1) && this.query1.isViewQuery) {
|
|
this.query1.update();
|
|
}
|
|
if (lang_1.isPresent(this.query2) && this.query2.isViewQuery) {
|
|
this.query2.update();
|
|
}
|
|
};
|
|
InlineQueryStrategy.prototype.findQuery = function(query) {
|
|
if (lang_1.isPresent(this.query0) && this.query0.protoQueryRef.query === query) {
|
|
return this.query0;
|
|
}
|
|
if (lang_1.isPresent(this.query1) && this.query1.protoQueryRef.query === query) {
|
|
return this.query1;
|
|
}
|
|
if (lang_1.isPresent(this.query2) && this.query2.protoQueryRef.query === query) {
|
|
return this.query2;
|
|
}
|
|
throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
|
|
};
|
|
InlineQueryStrategy.NUMBER_OF_SUPPORTED_QUERIES = 3;
|
|
return InlineQueryStrategy;
|
|
})();
|
|
var DynamicQueryStrategy = (function() {
|
|
function DynamicQueryStrategy(ei) {
|
|
this.queries = ei._proto.protoQueryRefs.map(function(p) {
|
|
return new QueryRef(p, ei);
|
|
});
|
|
}
|
|
DynamicQueryStrategy.prototype.setContentQueriesAsDirty = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
if (!q.isViewQuery)
|
|
q.dirty = true;
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.setViewQueriesAsDirty = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
if (q.isViewQuery)
|
|
q.dirty = true;
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.hydrate = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
q.hydrate();
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.dehydrate = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
q.dehydrate();
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.updateContentQueries = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
if (!q.isViewQuery) {
|
|
q.update();
|
|
}
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.updateViewQueries = function() {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
if (q.isViewQuery) {
|
|
q.update();
|
|
}
|
|
}
|
|
};
|
|
DynamicQueryStrategy.prototype.findQuery = function(query) {
|
|
for (var i = 0; i < this.queries.length; ++i) {
|
|
var q = this.queries[i];
|
|
if (q.protoQueryRef.query === query) {
|
|
return q;
|
|
}
|
|
}
|
|
throw new exceptions_1.BaseException("Cannot find query for directive " + query + ".");
|
|
};
|
|
return DynamicQueryStrategy;
|
|
})();
|
|
var ElementInjectorInlineStrategy = (function() {
|
|
function ElementInjectorInlineStrategy(injectorStrategy, _ei) {
|
|
this.injectorStrategy = injectorStrategy;
|
|
this._ei = _ei;
|
|
}
|
|
ElementInjectorInlineStrategy.prototype.hydrate = function() {
|
|
var i = this.injectorStrategy;
|
|
var p = i.protoStrategy;
|
|
i.resetConstructionCounter();
|
|
if (p.provider0 instanceof DirectiveProvider && lang_1.isPresent(p.keyId0) && i.obj0 === injector_1.UNDEFINED)
|
|
i.obj0 = i.instantiateProvider(p.provider0, p.visibility0);
|
|
if (p.provider1 instanceof DirectiveProvider && lang_1.isPresent(p.keyId1) && i.obj1 === injector_1.UNDEFINED)
|
|
i.obj1 = i.instantiateProvider(p.provider1, p.visibility1);
|
|
if (p.provider2 instanceof DirectiveProvider && lang_1.isPresent(p.keyId2) && i.obj2 === injector_1.UNDEFINED)
|
|
i.obj2 = i.instantiateProvider(p.provider2, p.visibility2);
|
|
if (p.provider3 instanceof DirectiveProvider && lang_1.isPresent(p.keyId3) && i.obj3 === injector_1.UNDEFINED)
|
|
i.obj3 = i.instantiateProvider(p.provider3, p.visibility3);
|
|
if (p.provider4 instanceof DirectiveProvider && lang_1.isPresent(p.keyId4) && i.obj4 === injector_1.UNDEFINED)
|
|
i.obj4 = i.instantiateProvider(p.provider4, p.visibility4);
|
|
if (p.provider5 instanceof DirectiveProvider && lang_1.isPresent(p.keyId5) && i.obj5 === injector_1.UNDEFINED)
|
|
i.obj5 = i.instantiateProvider(p.provider5, p.visibility5);
|
|
if (p.provider6 instanceof DirectiveProvider && lang_1.isPresent(p.keyId6) && i.obj6 === injector_1.UNDEFINED)
|
|
i.obj6 = i.instantiateProvider(p.provider6, p.visibility6);
|
|
if (p.provider7 instanceof DirectiveProvider && lang_1.isPresent(p.keyId7) && i.obj7 === injector_1.UNDEFINED)
|
|
i.obj7 = i.instantiateProvider(p.provider7, p.visibility7);
|
|
if (p.provider8 instanceof DirectiveProvider && lang_1.isPresent(p.keyId8) && i.obj8 === injector_1.UNDEFINED)
|
|
i.obj8 = i.instantiateProvider(p.provider8, p.visibility8);
|
|
if (p.provider9 instanceof DirectiveProvider && lang_1.isPresent(p.keyId9) && i.obj9 === injector_1.UNDEFINED)
|
|
i.obj9 = i.instantiateProvider(p.provider9, p.visibility9);
|
|
};
|
|
ElementInjectorInlineStrategy.prototype.dehydrate = function() {
|
|
var i = this.injectorStrategy;
|
|
i.obj0 = injector_1.UNDEFINED;
|
|
i.obj1 = injector_1.UNDEFINED;
|
|
i.obj2 = injector_1.UNDEFINED;
|
|
i.obj3 = injector_1.UNDEFINED;
|
|
i.obj4 = injector_1.UNDEFINED;
|
|
i.obj5 = injector_1.UNDEFINED;
|
|
i.obj6 = injector_1.UNDEFINED;
|
|
i.obj7 = injector_1.UNDEFINED;
|
|
i.obj8 = injector_1.UNDEFINED;
|
|
i.obj9 = injector_1.UNDEFINED;
|
|
};
|
|
ElementInjectorInlineStrategy.prototype.callOnDestroy = function() {
|
|
var i = this.injectorStrategy;
|
|
var p = i.protoStrategy;
|
|
if (p.provider0 instanceof DirectiveProvider && p.provider0.callOnDestroy) {
|
|
i.obj0.ngOnDestroy();
|
|
}
|
|
if (p.provider1 instanceof DirectiveProvider && p.provider1.callOnDestroy) {
|
|
i.obj1.ngOnDestroy();
|
|
}
|
|
if (p.provider2 instanceof DirectiveProvider && p.provider2.callOnDestroy) {
|
|
i.obj2.ngOnDestroy();
|
|
}
|
|
if (p.provider3 instanceof DirectiveProvider && p.provider3.callOnDestroy) {
|
|
i.obj3.ngOnDestroy();
|
|
}
|
|
if (p.provider4 instanceof DirectiveProvider && p.provider4.callOnDestroy) {
|
|
i.obj4.ngOnDestroy();
|
|
}
|
|
if (p.provider5 instanceof DirectiveProvider && p.provider5.callOnDestroy) {
|
|
i.obj5.ngOnDestroy();
|
|
}
|
|
if (p.provider6 instanceof DirectiveProvider && p.provider6.callOnDestroy) {
|
|
i.obj6.ngOnDestroy();
|
|
}
|
|
if (p.provider7 instanceof DirectiveProvider && p.provider7.callOnDestroy) {
|
|
i.obj7.ngOnDestroy();
|
|
}
|
|
if (p.provider8 instanceof DirectiveProvider && p.provider8.callOnDestroy) {
|
|
i.obj8.ngOnDestroy();
|
|
}
|
|
if (p.provider9 instanceof DirectiveProvider && p.provider9.callOnDestroy) {
|
|
i.obj9.ngOnDestroy();
|
|
}
|
|
};
|
|
ElementInjectorInlineStrategy.prototype.getComponent = function() {
|
|
return this.injectorStrategy.obj0;
|
|
};
|
|
ElementInjectorInlineStrategy.prototype.isComponentKey = function(key) {
|
|
return this._ei._proto._firstProviderIsComponent && lang_1.isPresent(key) && key.id === this.injectorStrategy.protoStrategy.keyId0;
|
|
};
|
|
ElementInjectorInlineStrategy.prototype.addDirectivesMatchingQuery = function(query, list) {
|
|
var i = this.injectorStrategy;
|
|
var p = i.protoStrategy;
|
|
if (lang_1.isPresent(p.provider0) && p.provider0.key.token === query.selector) {
|
|
if (i.obj0 === injector_1.UNDEFINED)
|
|
i.obj0 = i.instantiateProvider(p.provider0, p.visibility0);
|
|
list.push(i.obj0);
|
|
}
|
|
if (lang_1.isPresent(p.provider1) && p.provider1.key.token === query.selector) {
|
|
if (i.obj1 === injector_1.UNDEFINED)
|
|
i.obj1 = i.instantiateProvider(p.provider1, p.visibility1);
|
|
list.push(i.obj1);
|
|
}
|
|
if (lang_1.isPresent(p.provider2) && p.provider2.key.token === query.selector) {
|
|
if (i.obj2 === injector_1.UNDEFINED)
|
|
i.obj2 = i.instantiateProvider(p.provider2, p.visibility2);
|
|
list.push(i.obj2);
|
|
}
|
|
if (lang_1.isPresent(p.provider3) && p.provider3.key.token === query.selector) {
|
|
if (i.obj3 === injector_1.UNDEFINED)
|
|
i.obj3 = i.instantiateProvider(p.provider3, p.visibility3);
|
|
list.push(i.obj3);
|
|
}
|
|
if (lang_1.isPresent(p.provider4) && p.provider4.key.token === query.selector) {
|
|
if (i.obj4 === injector_1.UNDEFINED)
|
|
i.obj4 = i.instantiateProvider(p.provider4, p.visibility4);
|
|
list.push(i.obj4);
|
|
}
|
|
if (lang_1.isPresent(p.provider5) && p.provider5.key.token === query.selector) {
|
|
if (i.obj5 === injector_1.UNDEFINED)
|
|
i.obj5 = i.instantiateProvider(p.provider5, p.visibility5);
|
|
list.push(i.obj5);
|
|
}
|
|
if (lang_1.isPresent(p.provider6) && p.provider6.key.token === query.selector) {
|
|
if (i.obj6 === injector_1.UNDEFINED)
|
|
i.obj6 = i.instantiateProvider(p.provider6, p.visibility6);
|
|
list.push(i.obj6);
|
|
}
|
|
if (lang_1.isPresent(p.provider7) && p.provider7.key.token === query.selector) {
|
|
if (i.obj7 === injector_1.UNDEFINED)
|
|
i.obj7 = i.instantiateProvider(p.provider7, p.visibility7);
|
|
list.push(i.obj7);
|
|
}
|
|
if (lang_1.isPresent(p.provider8) && p.provider8.key.token === query.selector) {
|
|
if (i.obj8 === injector_1.UNDEFINED)
|
|
i.obj8 = i.instantiateProvider(p.provider8, p.visibility8);
|
|
list.push(i.obj8);
|
|
}
|
|
if (lang_1.isPresent(p.provider9) && p.provider9.key.token === query.selector) {
|
|
if (i.obj9 === injector_1.UNDEFINED)
|
|
i.obj9 = i.instantiateProvider(p.provider9, p.visibility9);
|
|
list.push(i.obj9);
|
|
}
|
|
};
|
|
return ElementInjectorInlineStrategy;
|
|
})();
|
|
var ElementInjectorDynamicStrategy = (function() {
|
|
function ElementInjectorDynamicStrategy(injectorStrategy, _ei) {
|
|
this.injectorStrategy = injectorStrategy;
|
|
this._ei = _ei;
|
|
}
|
|
ElementInjectorDynamicStrategy.prototype.hydrate = function() {
|
|
var inj = this.injectorStrategy;
|
|
var p = inj.protoStrategy;
|
|
inj.resetConstructionCounter();
|
|
for (var i = 0; i < p.keyIds.length; i++) {
|
|
if (p.providers[i] instanceof DirectiveProvider && lang_1.isPresent(p.keyIds[i]) && inj.objs[i] === injector_1.UNDEFINED) {
|
|
inj.objs[i] = inj.instantiateProvider(p.providers[i], p.visibilities[i]);
|
|
}
|
|
}
|
|
};
|
|
ElementInjectorDynamicStrategy.prototype.dehydrate = function() {
|
|
var inj = this.injectorStrategy;
|
|
collection_1.ListWrapper.fill(inj.objs, injector_1.UNDEFINED);
|
|
};
|
|
ElementInjectorDynamicStrategy.prototype.callOnDestroy = function() {
|
|
var ist = this.injectorStrategy;
|
|
var p = ist.protoStrategy;
|
|
for (var i = 0; i < p.providers.length; i++) {
|
|
if (p.providers[i] instanceof DirectiveProvider && p.providers[i].callOnDestroy) {
|
|
ist.objs[i].ngOnDestroy();
|
|
}
|
|
}
|
|
};
|
|
ElementInjectorDynamicStrategy.prototype.getComponent = function() {
|
|
return this.injectorStrategy.objs[0];
|
|
};
|
|
ElementInjectorDynamicStrategy.prototype.isComponentKey = function(key) {
|
|
var p = this.injectorStrategy.protoStrategy;
|
|
return this._ei._proto._firstProviderIsComponent && lang_1.isPresent(key) && key.id === p.keyIds[0];
|
|
};
|
|
ElementInjectorDynamicStrategy.prototype.addDirectivesMatchingQuery = function(query, list) {
|
|
var ist = this.injectorStrategy;
|
|
var p = ist.protoStrategy;
|
|
for (var i = 0; i < p.providers.length; i++) {
|
|
if (p.providers[i].key.token === query.selector) {
|
|
if (ist.objs[i] === injector_1.UNDEFINED) {
|
|
ist.objs[i] = ist.instantiateProvider(p.providers[i], p.visibilities[i]);
|
|
}
|
|
list.push(ist.objs[i]);
|
|
}
|
|
}
|
|
};
|
|
return ElementInjectorDynamicStrategy;
|
|
})();
|
|
var ProtoQueryRef = (function() {
|
|
function ProtoQueryRef(dirIndex, setter, query) {
|
|
this.dirIndex = dirIndex;
|
|
this.setter = setter;
|
|
this.query = query;
|
|
}
|
|
Object.defineProperty(ProtoQueryRef.prototype, "usesPropertySyntax", {
|
|
get: function() {
|
|
return lang_1.isPresent(this.setter);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ProtoQueryRef;
|
|
})();
|
|
exports.ProtoQueryRef = ProtoQueryRef;
|
|
var QueryRef = (function() {
|
|
function QueryRef(protoQueryRef, originator) {
|
|
this.protoQueryRef = protoQueryRef;
|
|
this.originator = originator;
|
|
}
|
|
Object.defineProperty(QueryRef.prototype, "isViewQuery", {
|
|
get: function() {
|
|
return this.protoQueryRef.query.isViewQuery;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
QueryRef.prototype.update = function() {
|
|
if (!this.dirty)
|
|
return;
|
|
this._update();
|
|
this.dirty = false;
|
|
if (this.protoQueryRef.usesPropertySyntax) {
|
|
var dir = this.originator.getDirectiveAtIndex(this.protoQueryRef.dirIndex);
|
|
if (this.protoQueryRef.query.first) {
|
|
this.protoQueryRef.setter(dir, this.list.length > 0 ? this.list.first : null);
|
|
} else {
|
|
this.protoQueryRef.setter(dir, this.list);
|
|
}
|
|
}
|
|
this.list.notifyOnChanges();
|
|
};
|
|
QueryRef.prototype._update = function() {
|
|
var aggregator = [];
|
|
if (this.protoQueryRef.query.isViewQuery) {
|
|
var view = this.originator.getView();
|
|
var nestedView = view.getNestedView(view.elementOffset + this.originator.getBoundElementIndex());
|
|
if (lang_1.isPresent(nestedView))
|
|
this._visitView(nestedView, aggregator);
|
|
} else {
|
|
this._visit(this.originator, aggregator);
|
|
}
|
|
this.list.reset(aggregator);
|
|
};
|
|
;
|
|
QueryRef.prototype._visit = function(inj, aggregator) {
|
|
var view = inj.getView();
|
|
var startIdx = view.elementOffset + inj._proto.index;
|
|
for (var i = startIdx; i < view.elementOffset + view.ownBindersCount; i++) {
|
|
var curInj = view.elementInjectors[i];
|
|
if (lang_1.isBlank(curInj))
|
|
continue;
|
|
if (i > startIdx && (lang_1.isBlank(curInj) || lang_1.isBlank(curInj.parent) || view.elementOffset + curInj.parent._proto.index < startIdx)) {
|
|
break;
|
|
}
|
|
if (!this.protoQueryRef.query.descendants && !(curInj.parent == this.originator || curInj == this.originator))
|
|
continue;
|
|
this._visitInjector(curInj, aggregator);
|
|
var vc = view.viewContainers[i];
|
|
if (lang_1.isPresent(vc))
|
|
this._visitViewContainer(vc, aggregator);
|
|
}
|
|
};
|
|
QueryRef.prototype._visitInjector = function(inj, aggregator) {
|
|
if (this.protoQueryRef.query.isVarBindingQuery) {
|
|
this._aggregateVariableBinding(inj, aggregator);
|
|
} else {
|
|
this._aggregateDirective(inj, aggregator);
|
|
}
|
|
};
|
|
QueryRef.prototype._visitViewContainer = function(vc, aggregator) {
|
|
for (var j = 0; j < vc.views.length; j++) {
|
|
this._visitView(vc.views[j], aggregator);
|
|
}
|
|
};
|
|
QueryRef.prototype._visitView = function(view, aggregator) {
|
|
for (var i = view.elementOffset; i < view.elementOffset + view.ownBindersCount; i++) {
|
|
var inj = view.elementInjectors[i];
|
|
if (lang_1.isBlank(inj))
|
|
continue;
|
|
this._visitInjector(inj, aggregator);
|
|
var vc = view.viewContainers[i];
|
|
if (lang_1.isPresent(vc))
|
|
this._visitViewContainer(vc, aggregator);
|
|
}
|
|
};
|
|
QueryRef.prototype._aggregateVariableBinding = function(inj, aggregator) {
|
|
var vb = this.protoQueryRef.query.varBindings;
|
|
for (var i = 0; i < vb.length; ++i) {
|
|
if (inj.hasVariableBinding(vb[i])) {
|
|
aggregator.push(inj.getVariableBinding(vb[i]));
|
|
}
|
|
}
|
|
};
|
|
QueryRef.prototype._aggregateDirective = function(inj, aggregator) {
|
|
inj.addDirectivesMatchingQuery(this.protoQueryRef.query, aggregator);
|
|
};
|
|
QueryRef.prototype.dehydrate = function() {
|
|
this.list = null;
|
|
};
|
|
QueryRef.prototype.hydrate = function() {
|
|
this.list = new query_list_1.QueryList();
|
|
this.dirty = true;
|
|
};
|
|
return QueryRef;
|
|
})();
|
|
exports.QueryRef = QueryRef;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7e", ["39", "20", "3c", "37", "50", "81"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var metadata_1 = $__require('50');
|
|
var reflection_1 = $__require('81');
|
|
function _isDirectiveMetadata(type) {
|
|
return type instanceof metadata_1.DirectiveMetadata;
|
|
}
|
|
var DirectiveResolver = (function() {
|
|
function DirectiveResolver() {}
|
|
DirectiveResolver.prototype.resolve = function(type) {
|
|
var typeMetadata = reflection_1.reflector.annotations(di_1.resolveForwardRef(type));
|
|
if (lang_1.isPresent(typeMetadata)) {
|
|
var metadata = typeMetadata.find(_isDirectiveMetadata);
|
|
if (lang_1.isPresent(metadata)) {
|
|
var propertyMetadata = reflection_1.reflector.propMetadata(type);
|
|
return this._mergeWithPropertyMetadata(metadata, propertyMetadata);
|
|
}
|
|
}
|
|
throw new exceptions_1.BaseException("No Directive annotation found on " + lang_1.stringify(type));
|
|
};
|
|
DirectiveResolver.prototype._mergeWithPropertyMetadata = function(dm, propertyMetadata) {
|
|
var inputs = [];
|
|
var outputs = [];
|
|
var host = {};
|
|
var queries = {};
|
|
collection_1.StringMapWrapper.forEach(propertyMetadata, function(metadata, propName) {
|
|
metadata.forEach(function(a) {
|
|
if (a instanceof metadata_1.InputMetadata) {
|
|
if (lang_1.isPresent(a.bindingPropertyName)) {
|
|
inputs.push(propName + ": " + a.bindingPropertyName);
|
|
} else {
|
|
inputs.push(propName);
|
|
}
|
|
}
|
|
if (a instanceof metadata_1.OutputMetadata) {
|
|
if (lang_1.isPresent(a.bindingPropertyName)) {
|
|
outputs.push(propName + ": " + a.bindingPropertyName);
|
|
} else {
|
|
outputs.push(propName);
|
|
}
|
|
}
|
|
if (a instanceof metadata_1.HostBindingMetadata) {
|
|
if (lang_1.isPresent(a.hostPropertyName)) {
|
|
host[("[" + a.hostPropertyName + "]")] = propName;
|
|
} else {
|
|
host[("[" + propName + "]")] = propName;
|
|
}
|
|
}
|
|
if (a instanceof metadata_1.HostListenerMetadata) {
|
|
var args = lang_1.isPresent(a.args) ? a.args.join(', ') : '';
|
|
host[("(" + a.eventName + ")")] = propName + "(" + args + ")";
|
|
}
|
|
if (a instanceof metadata_1.ContentChildrenMetadata) {
|
|
queries[propName] = a;
|
|
}
|
|
if (a instanceof metadata_1.ViewChildrenMetadata) {
|
|
queries[propName] = a;
|
|
}
|
|
if (a instanceof metadata_1.ContentChildMetadata) {
|
|
queries[propName] = a;
|
|
}
|
|
if (a instanceof metadata_1.ViewChildMetadata) {
|
|
queries[propName] = a;
|
|
}
|
|
});
|
|
});
|
|
return this._merge(dm, inputs, outputs, host, queries);
|
|
};
|
|
DirectiveResolver.prototype._merge = function(dm, inputs, outputs, host, queries) {
|
|
var mergedInputs = lang_1.isPresent(dm.inputs) ? collection_1.ListWrapper.concat(dm.inputs, inputs) : inputs;
|
|
var mergedOutputs = lang_1.isPresent(dm.outputs) ? collection_1.ListWrapper.concat(dm.outputs, outputs) : outputs;
|
|
var mergedHost = lang_1.isPresent(dm.host) ? collection_1.StringMapWrapper.merge(dm.host, host) : host;
|
|
var mergedQueries = lang_1.isPresent(dm.queries) ? collection_1.StringMapWrapper.merge(dm.queries, queries) : queries;
|
|
if (dm instanceof metadata_1.ComponentMetadata) {
|
|
return new metadata_1.ComponentMetadata({
|
|
selector: dm.selector,
|
|
inputs: mergedInputs,
|
|
outputs: mergedOutputs,
|
|
host: mergedHost,
|
|
exportAs: dm.exportAs,
|
|
moduleId: dm.moduleId,
|
|
queries: mergedQueries,
|
|
changeDetection: dm.changeDetection,
|
|
providers: dm.providers,
|
|
viewProviders: dm.viewProviders
|
|
});
|
|
} else {
|
|
return new metadata_1.DirectiveMetadata({
|
|
selector: dm.selector,
|
|
inputs: mergedInputs,
|
|
outputs: mergedOutputs,
|
|
host: mergedHost,
|
|
exportAs: dm.exportAs,
|
|
queries: mergedQueries,
|
|
providers: dm.providers
|
|
});
|
|
}
|
|
};
|
|
DirectiveResolver = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], DirectiveResolver);
|
|
return DirectiveResolver;
|
|
})();
|
|
exports.DirectiveResolver = DirectiveResolver;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7f", ["39", "7b", "7d", "20", "3c", "37", "81"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var view_1 = $__require('7b');
|
|
var directives_1 = $__require('7d');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var reflection_1 = $__require('81');
|
|
var ViewResolver = (function() {
|
|
function ViewResolver() {
|
|
this._cache = new collection_1.Map();
|
|
}
|
|
ViewResolver.prototype.resolve = function(component) {
|
|
var view = this._cache.get(component);
|
|
if (lang_1.isBlank(view)) {
|
|
view = this._resolve(component);
|
|
this._cache.set(component, view);
|
|
}
|
|
return view;
|
|
};
|
|
ViewResolver.prototype._resolve = function(component) {
|
|
var compMeta;
|
|
var viewMeta;
|
|
reflection_1.reflector.annotations(component).forEach(function(m) {
|
|
if (m instanceof view_1.ViewMetadata) {
|
|
viewMeta = m;
|
|
}
|
|
if (m instanceof directives_1.ComponentMetadata) {
|
|
compMeta = m;
|
|
}
|
|
});
|
|
if (lang_1.isPresent(compMeta)) {
|
|
if (lang_1.isBlank(compMeta.template) && lang_1.isBlank(compMeta.templateUrl) && lang_1.isBlank(viewMeta)) {
|
|
throw new exceptions_1.BaseException("Component '" + lang_1.stringify(component) + "' must have either 'template', 'templateUrl', or '@View' set.");
|
|
} else if (lang_1.isPresent(compMeta.template) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("template", component);
|
|
} else if (lang_1.isPresent(compMeta.templateUrl) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("templateUrl", component);
|
|
} else if (lang_1.isPresent(compMeta.directives) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("directives", component);
|
|
} else if (lang_1.isPresent(compMeta.pipes) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("pipes", component);
|
|
} else if (lang_1.isPresent(compMeta.encapsulation) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("encapsulation", component);
|
|
} else if (lang_1.isPresent(compMeta.styles) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("styles", component);
|
|
} else if (lang_1.isPresent(compMeta.styleUrls) && lang_1.isPresent(viewMeta)) {
|
|
this._throwMixingViewAndComponent("styleUrls", component);
|
|
} else if (lang_1.isPresent(viewMeta)) {
|
|
return viewMeta;
|
|
} else {
|
|
return new view_1.ViewMetadata({
|
|
templateUrl: compMeta.templateUrl,
|
|
template: compMeta.template,
|
|
directives: compMeta.directives,
|
|
pipes: compMeta.pipes,
|
|
encapsulation: compMeta.encapsulation,
|
|
styles: compMeta.styles,
|
|
styleUrls: compMeta.styleUrls
|
|
});
|
|
}
|
|
} else {
|
|
if (lang_1.isBlank(viewMeta)) {
|
|
throw new exceptions_1.BaseException("No View decorator found on component '" + lang_1.stringify(component) + "'");
|
|
} else {
|
|
return viewMeta;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
ViewResolver.prototype._throwMixingViewAndComponent = function(propertyName, component) {
|
|
throw new exceptions_1.BaseException("Component '" + lang_1.stringify(component) + "' cannot have both '" + propertyName + "' and '@View' set at the same time\"");
|
|
};
|
|
ViewResolver = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], ViewResolver);
|
|
return ViewResolver;
|
|
})();
|
|
exports.ViewResolver = ViewResolver;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1cb", ["39", "20", "3c", "50", "81"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var metadata_1 = $__require('50');
|
|
var reflection_1 = $__require('81');
|
|
function _isPipeMetadata(type) {
|
|
return type instanceof metadata_1.PipeMetadata;
|
|
}
|
|
var PipeResolver = (function() {
|
|
function PipeResolver() {}
|
|
PipeResolver.prototype.resolve = function(type) {
|
|
var metas = reflection_1.reflector.annotations(di_1.resolveForwardRef(type));
|
|
if (lang_1.isPresent(metas)) {
|
|
var annotation = metas.find(_isPipeMetadata);
|
|
if (lang_1.isPresent(annotation)) {
|
|
return annotation;
|
|
}
|
|
}
|
|
throw new exceptions_1.BaseException("No Pipe decorator found on " + lang_1.stringify(type));
|
|
};
|
|
PipeResolver = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [])], PipeResolver);
|
|
return PipeResolver;
|
|
})();
|
|
exports.PipeResolver = PipeResolver;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("82", ["39", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
exports.PLATFORM_DIRECTIVES = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Directives"));
|
|
exports.PLATFORM_PIPES = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Pipes"));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("56", ["3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var exceptions_1 = $__require('3c');
|
|
var RenderProtoViewRef = (function() {
|
|
function RenderProtoViewRef() {}
|
|
return RenderProtoViewRef;
|
|
})();
|
|
exports.RenderProtoViewRef = RenderProtoViewRef;
|
|
var RenderFragmentRef = (function() {
|
|
function RenderFragmentRef() {}
|
|
return RenderFragmentRef;
|
|
})();
|
|
exports.RenderFragmentRef = RenderFragmentRef;
|
|
var RenderViewRef = (function() {
|
|
function RenderViewRef() {}
|
|
return RenderViewRef;
|
|
})();
|
|
exports.RenderViewRef = RenderViewRef;
|
|
var RenderTemplateCmd = (function() {
|
|
function RenderTemplateCmd() {}
|
|
return RenderTemplateCmd;
|
|
})();
|
|
exports.RenderTemplateCmd = RenderTemplateCmd;
|
|
var RenderBeginCmd = (function(_super) {
|
|
__extends(RenderBeginCmd, _super);
|
|
function RenderBeginCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderBeginCmd.prototype, "ngContentIndex", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(RenderBeginCmd.prototype, "isBound", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderBeginCmd;
|
|
})(RenderTemplateCmd);
|
|
exports.RenderBeginCmd = RenderBeginCmd;
|
|
var RenderTextCmd = (function(_super) {
|
|
__extends(RenderTextCmd, _super);
|
|
function RenderTextCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderTextCmd.prototype, "value", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderTextCmd;
|
|
})(RenderBeginCmd);
|
|
exports.RenderTextCmd = RenderTextCmd;
|
|
var RenderNgContentCmd = (function(_super) {
|
|
__extends(RenderNgContentCmd, _super);
|
|
function RenderNgContentCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderNgContentCmd.prototype, "index", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(RenderNgContentCmd.prototype, "ngContentIndex", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderNgContentCmd;
|
|
})(RenderTemplateCmd);
|
|
exports.RenderNgContentCmd = RenderNgContentCmd;
|
|
var RenderBeginElementCmd = (function(_super) {
|
|
__extends(RenderBeginElementCmd, _super);
|
|
function RenderBeginElementCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderBeginElementCmd.prototype, "name", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(RenderBeginElementCmd.prototype, "attrNameAndValues", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(RenderBeginElementCmd.prototype, "eventTargetAndNames", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderBeginElementCmd;
|
|
})(RenderBeginCmd);
|
|
exports.RenderBeginElementCmd = RenderBeginElementCmd;
|
|
var RenderBeginComponentCmd = (function(_super) {
|
|
__extends(RenderBeginComponentCmd, _super);
|
|
function RenderBeginComponentCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderBeginComponentCmd.prototype, "templateId", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderBeginComponentCmd;
|
|
})(RenderBeginElementCmd);
|
|
exports.RenderBeginComponentCmd = RenderBeginComponentCmd;
|
|
var RenderEmbeddedTemplateCmd = (function(_super) {
|
|
__extends(RenderEmbeddedTemplateCmd, _super);
|
|
function RenderEmbeddedTemplateCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(RenderEmbeddedTemplateCmd.prototype, "isMerged", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(RenderEmbeddedTemplateCmd.prototype, "children", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
return RenderEmbeddedTemplateCmd;
|
|
})(RenderBeginElementCmd);
|
|
exports.RenderEmbeddedTemplateCmd = RenderEmbeddedTemplateCmd;
|
|
var RenderViewWithFragments = (function() {
|
|
function RenderViewWithFragments(viewRef, fragmentRefs) {
|
|
this.viewRef = viewRef;
|
|
this.fragmentRefs = fragmentRefs;
|
|
}
|
|
return RenderViewWithFragments;
|
|
})();
|
|
exports.RenderViewWithFragments = RenderViewWithFragments;
|
|
var RenderComponentTemplate = (function() {
|
|
function RenderComponentTemplate(id, shortId, encapsulation, commands, styles) {
|
|
this.id = id;
|
|
this.shortId = shortId;
|
|
this.encapsulation = encapsulation;
|
|
this.commands = commands;
|
|
this.styles = styles;
|
|
}
|
|
return RenderComponentTemplate;
|
|
})();
|
|
exports.RenderComponentTemplate = RenderComponentTemplate;
|
|
var Renderer = (function() {
|
|
function Renderer() {}
|
|
return Renderer;
|
|
})();
|
|
exports.Renderer = Renderer;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ca", ["20", "39", "1cc"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var metadata_1 = $__require('1cc');
|
|
var AttributeMetadata = (function(_super) {
|
|
__extends(AttributeMetadata, _super);
|
|
function AttributeMetadata(attributeName) {
|
|
_super.call(this);
|
|
this.attributeName = attributeName;
|
|
}
|
|
Object.defineProperty(AttributeMetadata.prototype, "token", {
|
|
get: function() {
|
|
return this;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
AttributeMetadata.prototype.toString = function() {
|
|
return "@Attribute(" + lang_1.stringify(this.attributeName) + ")";
|
|
};
|
|
AttributeMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], AttributeMetadata);
|
|
return AttributeMetadata;
|
|
})(metadata_1.DependencyMetadata);
|
|
exports.AttributeMetadata = AttributeMetadata;
|
|
var QueryMetadata = (function(_super) {
|
|
__extends(QueryMetadata, _super);
|
|
function QueryMetadata(_selector, _a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
_c = _b.descendants,
|
|
descendants = _c === void 0 ? false : _c,
|
|
_d = _b.first,
|
|
first = _d === void 0 ? false : _d;
|
|
_super.call(this);
|
|
this._selector = _selector;
|
|
this.descendants = descendants;
|
|
this.first = first;
|
|
}
|
|
Object.defineProperty(QueryMetadata.prototype, "isViewQuery", {
|
|
get: function() {
|
|
return false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryMetadata.prototype, "selector", {
|
|
get: function() {
|
|
return di_1.resolveForwardRef(this._selector);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryMetadata.prototype, "isVarBindingQuery", {
|
|
get: function() {
|
|
return lang_1.isString(this.selector);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(QueryMetadata.prototype, "varBindings", {
|
|
get: function() {
|
|
return this.selector.split(',');
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
QueryMetadata.prototype.toString = function() {
|
|
return "@Query(" + lang_1.stringify(this.selector) + ")";
|
|
};
|
|
QueryMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object, Object])], QueryMetadata);
|
|
return QueryMetadata;
|
|
})(metadata_1.DependencyMetadata);
|
|
exports.QueryMetadata = QueryMetadata;
|
|
var ContentChildrenMetadata = (function(_super) {
|
|
__extends(ContentChildrenMetadata, _super);
|
|
function ContentChildrenMetadata(_selector, _a) {
|
|
var _b = (_a === void 0 ? {} : _a).descendants,
|
|
descendants = _b === void 0 ? false : _b;
|
|
_super.call(this, _selector, {descendants: descendants});
|
|
}
|
|
ContentChildrenMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object, Object])], ContentChildrenMetadata);
|
|
return ContentChildrenMetadata;
|
|
})(QueryMetadata);
|
|
exports.ContentChildrenMetadata = ContentChildrenMetadata;
|
|
var ContentChildMetadata = (function(_super) {
|
|
__extends(ContentChildMetadata, _super);
|
|
function ContentChildMetadata(_selector) {
|
|
_super.call(this, _selector, {
|
|
descendants: true,
|
|
first: true
|
|
});
|
|
}
|
|
ContentChildMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], ContentChildMetadata);
|
|
return ContentChildMetadata;
|
|
})(QueryMetadata);
|
|
exports.ContentChildMetadata = ContentChildMetadata;
|
|
var ViewQueryMetadata = (function(_super) {
|
|
__extends(ViewQueryMetadata, _super);
|
|
function ViewQueryMetadata(_selector, _a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
_c = _b.descendants,
|
|
descendants = _c === void 0 ? false : _c,
|
|
_d = _b.first,
|
|
first = _d === void 0 ? false : _d;
|
|
_super.call(this, _selector, {
|
|
descendants: descendants,
|
|
first: first
|
|
});
|
|
}
|
|
Object.defineProperty(ViewQueryMetadata.prototype, "isViewQuery", {
|
|
get: function() {
|
|
return true;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ViewQueryMetadata.prototype.toString = function() {
|
|
return "@ViewQuery(" + lang_1.stringify(this.selector) + ")";
|
|
};
|
|
ViewQueryMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object, Object])], ViewQueryMetadata);
|
|
return ViewQueryMetadata;
|
|
})(QueryMetadata);
|
|
exports.ViewQueryMetadata = ViewQueryMetadata;
|
|
var ViewChildrenMetadata = (function(_super) {
|
|
__extends(ViewChildrenMetadata, _super);
|
|
function ViewChildrenMetadata(_selector) {
|
|
_super.call(this, _selector, {descendants: true});
|
|
}
|
|
ViewChildrenMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], ViewChildrenMetadata);
|
|
return ViewChildrenMetadata;
|
|
})(ViewQueryMetadata);
|
|
exports.ViewChildrenMetadata = ViewChildrenMetadata;
|
|
var ViewChildMetadata = (function(_super) {
|
|
__extends(ViewChildMetadata, _super);
|
|
function ViewChildMetadata(_selector) {
|
|
_super.call(this, _selector, {
|
|
descendants: true,
|
|
first: true
|
|
});
|
|
}
|
|
ViewChildMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], ViewChildMetadata);
|
|
return ViewChildMetadata;
|
|
})(ViewQueryMetadata);
|
|
exports.ViewChildMetadata = ViewChildMetadata;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1cd", ["20", "3c", "37", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var di_1 = $__require('39');
|
|
var IterableDiffers = (function() {
|
|
function IterableDiffers(factories) {
|
|
this.factories = factories;
|
|
}
|
|
IterableDiffers.create = function(factories, parent) {
|
|
if (lang_1.isPresent(parent)) {
|
|
var copied = collection_1.ListWrapper.clone(parent.factories);
|
|
factories = factories.concat(copied);
|
|
return new IterableDiffers(factories);
|
|
} else {
|
|
return new IterableDiffers(factories);
|
|
}
|
|
};
|
|
IterableDiffers.extend = function(factories) {
|
|
return new di_1.Provider(IterableDiffers, {
|
|
useFactory: function(parent) {
|
|
if (lang_1.isBlank(parent)) {
|
|
throw new exceptions_1.BaseException('Cannot extend IterableDiffers without a parent injector');
|
|
}
|
|
return IterableDiffers.create(factories, parent);
|
|
},
|
|
deps: [[IterableDiffers, new di_1.SkipSelfMetadata(), new di_1.OptionalMetadata()]]
|
|
});
|
|
};
|
|
IterableDiffers.prototype.find = function(iterable) {
|
|
var factory = this.factories.find(function(f) {
|
|
return f.supports(iterable);
|
|
});
|
|
if (lang_1.isPresent(factory)) {
|
|
return factory;
|
|
} else {
|
|
throw new exceptions_1.BaseException("Cannot find a differ supporting object '" + iterable + "'");
|
|
}
|
|
};
|
|
IterableDiffers = __decorate([di_1.Injectable(), lang_1.CONST(), __metadata('design:paramtypes', [Array])], IterableDiffers);
|
|
return IterableDiffers;
|
|
})();
|
|
exports.IterableDiffers = IterableDiffers;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ce", ["20", "3c", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var lang_2 = $__require('20');
|
|
var DefaultIterableDifferFactory = (function() {
|
|
function DefaultIterableDifferFactory() {}
|
|
DefaultIterableDifferFactory.prototype.supports = function(obj) {
|
|
return collection_1.isListLikeIterable(obj);
|
|
};
|
|
DefaultIterableDifferFactory.prototype.create = function(cdRef) {
|
|
return new DefaultIterableDiffer();
|
|
};
|
|
DefaultIterableDifferFactory = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], DefaultIterableDifferFactory);
|
|
return DefaultIterableDifferFactory;
|
|
})();
|
|
exports.DefaultIterableDifferFactory = DefaultIterableDifferFactory;
|
|
var DefaultIterableDiffer = (function() {
|
|
function DefaultIterableDiffer() {
|
|
this._collection = null;
|
|
this._length = null;
|
|
this._linkedRecords = null;
|
|
this._unlinkedRecords = null;
|
|
this._previousItHead = null;
|
|
this._itHead = null;
|
|
this._itTail = null;
|
|
this._additionsHead = null;
|
|
this._additionsTail = null;
|
|
this._movesHead = null;
|
|
this._movesTail = null;
|
|
this._removalsHead = null;
|
|
this._removalsTail = null;
|
|
}
|
|
Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
|
|
get: function() {
|
|
return this._collection;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
|
|
get: function() {
|
|
return this._length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DefaultIterableDiffer.prototype.forEachItem = function(fn) {
|
|
var record;
|
|
for (record = this._itHead; record !== null; record = record._next) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.forEachPreviousItem = function(fn) {
|
|
var record;
|
|
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.forEachAddedItem = function(fn) {
|
|
var record;
|
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.forEachMovedItem = function(fn) {
|
|
var record;
|
|
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.forEachRemovedItem = function(fn) {
|
|
var record;
|
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.diff = function(collection) {
|
|
if (lang_2.isBlank(collection))
|
|
collection = [];
|
|
if (!collection_1.isListLikeIterable(collection)) {
|
|
throw new exceptions_1.BaseException("Error trying to diff '" + collection + "'");
|
|
}
|
|
if (this.check(collection)) {
|
|
return this;
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype.onDestroy = function() {};
|
|
DefaultIterableDiffer.prototype.check = function(collection) {
|
|
var _this = this;
|
|
this._reset();
|
|
var record = this._itHead;
|
|
var mayBeDirty = false;
|
|
var index;
|
|
var item;
|
|
if (lang_2.isArray(collection)) {
|
|
var list = collection;
|
|
this._length = collection.length;
|
|
for (index = 0; index < this._length; index++) {
|
|
item = list[index];
|
|
if (record === null || !lang_2.looseIdentical(record.item, item)) {
|
|
record = this._mismatch(record, item, index);
|
|
mayBeDirty = true;
|
|
} else if (mayBeDirty) {
|
|
record = this._verifyReinsertion(record, item, index);
|
|
}
|
|
record = record._next;
|
|
}
|
|
} else {
|
|
index = 0;
|
|
collection_1.iterateListLike(collection, function(item) {
|
|
if (record === null || !lang_2.looseIdentical(record.item, item)) {
|
|
record = _this._mismatch(record, item, index);
|
|
mayBeDirty = true;
|
|
} else if (mayBeDirty) {
|
|
record = _this._verifyReinsertion(record, item, index);
|
|
}
|
|
record = record._next;
|
|
index++;
|
|
});
|
|
this._length = index;
|
|
}
|
|
this._truncate(record);
|
|
this._collection = collection;
|
|
return this.isDirty;
|
|
};
|
|
Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
|
|
get: function() {
|
|
return this._additionsHead !== null || this._movesHead !== null || this._removalsHead !== null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DefaultIterableDiffer.prototype._reset = function() {
|
|
if (this.isDirty) {
|
|
var record;
|
|
var nextRecord;
|
|
for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
|
|
record._nextPrevious = record._next;
|
|
}
|
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
|
record.previousIndex = record.currentIndex;
|
|
}
|
|
this._additionsHead = this._additionsTail = null;
|
|
for (record = this._movesHead; record !== null; record = nextRecord) {
|
|
record.previousIndex = record.currentIndex;
|
|
nextRecord = record._nextMoved;
|
|
}
|
|
this._movesHead = this._movesTail = null;
|
|
this._removalsHead = this._removalsTail = null;
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype._mismatch = function(record, item, index) {
|
|
var previousRecord;
|
|
if (record === null) {
|
|
previousRecord = this._itTail;
|
|
} else {
|
|
previousRecord = record._prev;
|
|
this._remove(record);
|
|
}
|
|
record = this._linkedRecords === null ? null : this._linkedRecords.get(item, index);
|
|
if (record !== null) {
|
|
this._moveAfter(record, previousRecord, index);
|
|
} else {
|
|
record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(item);
|
|
if (record !== null) {
|
|
this._reinsertAfter(record, previousRecord, index);
|
|
} else {
|
|
record = this._addAfter(new CollectionChangeRecord(item), previousRecord, index);
|
|
}
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._verifyReinsertion = function(record, item, index) {
|
|
var reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(item);
|
|
if (reinsertRecord !== null) {
|
|
record = this._reinsertAfter(reinsertRecord, record._prev, index);
|
|
} else if (record.currentIndex != index) {
|
|
record.currentIndex = index;
|
|
this._addToMoves(record, index);
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._truncate = function(record) {
|
|
while (record !== null) {
|
|
var nextRecord = record._next;
|
|
this._addToRemovals(this._unlink(record));
|
|
record = nextRecord;
|
|
}
|
|
if (this._unlinkedRecords !== null) {
|
|
this._unlinkedRecords.clear();
|
|
}
|
|
if (this._additionsTail !== null) {
|
|
this._additionsTail._nextAdded = null;
|
|
}
|
|
if (this._movesTail !== null) {
|
|
this._movesTail._nextMoved = null;
|
|
}
|
|
if (this._itTail !== null) {
|
|
this._itTail._next = null;
|
|
}
|
|
if (this._removalsTail !== null) {
|
|
this._removalsTail._nextRemoved = null;
|
|
}
|
|
};
|
|
DefaultIterableDiffer.prototype._reinsertAfter = function(record, prevRecord, index) {
|
|
if (this._unlinkedRecords !== null) {
|
|
this._unlinkedRecords.remove(record);
|
|
}
|
|
var prev = record._prevRemoved;
|
|
var next = record._nextRemoved;
|
|
if (prev === null) {
|
|
this._removalsHead = next;
|
|
} else {
|
|
prev._nextRemoved = next;
|
|
}
|
|
if (next === null) {
|
|
this._removalsTail = prev;
|
|
} else {
|
|
next._prevRemoved = prev;
|
|
}
|
|
this._insertAfter(record, prevRecord, index);
|
|
this._addToMoves(record, index);
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._moveAfter = function(record, prevRecord, index) {
|
|
this._unlink(record);
|
|
this._insertAfter(record, prevRecord, index);
|
|
this._addToMoves(record, index);
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._addAfter = function(record, prevRecord, index) {
|
|
this._insertAfter(record, prevRecord, index);
|
|
if (this._additionsTail === null) {
|
|
this._additionsTail = this._additionsHead = record;
|
|
} else {
|
|
this._additionsTail = this._additionsTail._nextAdded = record;
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._insertAfter = function(record, prevRecord, index) {
|
|
var next = prevRecord === null ? this._itHead : prevRecord._next;
|
|
record._next = next;
|
|
record._prev = prevRecord;
|
|
if (next === null) {
|
|
this._itTail = record;
|
|
} else {
|
|
next._prev = record;
|
|
}
|
|
if (prevRecord === null) {
|
|
this._itHead = record;
|
|
} else {
|
|
prevRecord._next = record;
|
|
}
|
|
if (this._linkedRecords === null) {
|
|
this._linkedRecords = new _DuplicateMap();
|
|
}
|
|
this._linkedRecords.put(record);
|
|
record.currentIndex = index;
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._remove = function(record) {
|
|
return this._addToRemovals(this._unlink(record));
|
|
};
|
|
DefaultIterableDiffer.prototype._unlink = function(record) {
|
|
if (this._linkedRecords !== null) {
|
|
this._linkedRecords.remove(record);
|
|
}
|
|
var prev = record._prev;
|
|
var next = record._next;
|
|
if (prev === null) {
|
|
this._itHead = next;
|
|
} else {
|
|
prev._next = next;
|
|
}
|
|
if (next === null) {
|
|
this._itTail = prev;
|
|
} else {
|
|
next._prev = prev;
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._addToMoves = function(record, toIndex) {
|
|
if (record.previousIndex === toIndex) {
|
|
return record;
|
|
}
|
|
if (this._movesTail === null) {
|
|
this._movesTail = this._movesHead = record;
|
|
} else {
|
|
this._movesTail = this._movesTail._nextMoved = record;
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype._addToRemovals = function(record) {
|
|
if (this._unlinkedRecords === null) {
|
|
this._unlinkedRecords = new _DuplicateMap();
|
|
}
|
|
this._unlinkedRecords.put(record);
|
|
record.currentIndex = null;
|
|
record._nextRemoved = null;
|
|
if (this._removalsTail === null) {
|
|
this._removalsTail = this._removalsHead = record;
|
|
record._prevRemoved = null;
|
|
} else {
|
|
record._prevRemoved = this._removalsTail;
|
|
this._removalsTail = this._removalsTail._nextRemoved = record;
|
|
}
|
|
return record;
|
|
};
|
|
DefaultIterableDiffer.prototype.toString = function() {
|
|
var record;
|
|
var list = [];
|
|
for (record = this._itHead; record !== null; record = record._next) {
|
|
list.push(record);
|
|
}
|
|
var previous = [];
|
|
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
|
|
previous.push(record);
|
|
}
|
|
var additions = [];
|
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
|
additions.push(record);
|
|
}
|
|
var moves = [];
|
|
for (record = this._movesHead; record !== null; record = record._nextMoved) {
|
|
moves.push(record);
|
|
}
|
|
var removals = [];
|
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
|
removals.push(record);
|
|
}
|
|
return "collection: " + list.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" + "additions: " + additions.join(', ') + "\n" + "moves: " + moves.join(', ') + "\n" + "removals: " + removals.join(', ') + "\n";
|
|
};
|
|
return DefaultIterableDiffer;
|
|
})();
|
|
exports.DefaultIterableDiffer = DefaultIterableDiffer;
|
|
var CollectionChangeRecord = (function() {
|
|
function CollectionChangeRecord(item) {
|
|
this.item = item;
|
|
this.currentIndex = null;
|
|
this.previousIndex = null;
|
|
this._nextPrevious = null;
|
|
this._prev = null;
|
|
this._next = null;
|
|
this._prevDup = null;
|
|
this._nextDup = null;
|
|
this._prevRemoved = null;
|
|
this._nextRemoved = null;
|
|
this._nextAdded = null;
|
|
this._nextMoved = null;
|
|
}
|
|
CollectionChangeRecord.prototype.toString = function() {
|
|
return this.previousIndex === this.currentIndex ? lang_2.stringify(this.item) : lang_2.stringify(this.item) + '[' + lang_2.stringify(this.previousIndex) + '->' + lang_2.stringify(this.currentIndex) + ']';
|
|
};
|
|
return CollectionChangeRecord;
|
|
})();
|
|
exports.CollectionChangeRecord = CollectionChangeRecord;
|
|
var _DuplicateItemRecordList = (function() {
|
|
function _DuplicateItemRecordList() {
|
|
this._head = null;
|
|
this._tail = null;
|
|
}
|
|
_DuplicateItemRecordList.prototype.add = function(record) {
|
|
if (this._head === null) {
|
|
this._head = this._tail = record;
|
|
record._nextDup = null;
|
|
record._prevDup = null;
|
|
} else {
|
|
this._tail._nextDup = record;
|
|
record._prevDup = this._tail;
|
|
record._nextDup = null;
|
|
this._tail = record;
|
|
}
|
|
};
|
|
_DuplicateItemRecordList.prototype.get = function(item, afterIndex) {
|
|
var record;
|
|
for (record = this._head; record !== null; record = record._nextDup) {
|
|
if ((afterIndex === null || afterIndex < record.currentIndex) && lang_2.looseIdentical(record.item, item)) {
|
|
return record;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
_DuplicateItemRecordList.prototype.remove = function(record) {
|
|
var prev = record._prevDup;
|
|
var next = record._nextDup;
|
|
if (prev === null) {
|
|
this._head = next;
|
|
} else {
|
|
prev._nextDup = next;
|
|
}
|
|
if (next === null) {
|
|
this._tail = prev;
|
|
} else {
|
|
next._prevDup = prev;
|
|
}
|
|
return this._head === null;
|
|
};
|
|
return _DuplicateItemRecordList;
|
|
})();
|
|
var _DuplicateMap = (function() {
|
|
function _DuplicateMap() {
|
|
this.map = new Map();
|
|
}
|
|
_DuplicateMap.prototype.put = function(record) {
|
|
var key = lang_2.getMapKey(record.item);
|
|
var duplicates = this.map.get(key);
|
|
if (!lang_2.isPresent(duplicates)) {
|
|
duplicates = new _DuplicateItemRecordList();
|
|
this.map.set(key, duplicates);
|
|
}
|
|
duplicates.add(record);
|
|
};
|
|
_DuplicateMap.prototype.get = function(value, afterIndex) {
|
|
if (afterIndex === void 0) {
|
|
afterIndex = null;
|
|
}
|
|
var key = lang_2.getMapKey(value);
|
|
var recordList = this.map.get(key);
|
|
return lang_2.isBlank(recordList) ? null : recordList.get(value, afterIndex);
|
|
};
|
|
_DuplicateMap.prototype.remove = function(record) {
|
|
var key = lang_2.getMapKey(record.item);
|
|
var recordList = this.map.get(key);
|
|
if (recordList.remove(record)) {
|
|
this.map.delete(key);
|
|
}
|
|
return record;
|
|
};
|
|
Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
|
|
get: function() {
|
|
return this.map.size === 0;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
_DuplicateMap.prototype.clear = function() {
|
|
this.map.clear();
|
|
};
|
|
_DuplicateMap.prototype.toString = function() {
|
|
return '_DuplicateMap(' + lang_2.stringify(this.map) + ')';
|
|
};
|
|
return _DuplicateMap;
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1cf", ["20", "3c", "37", "39"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var di_1 = $__require('39');
|
|
var KeyValueDiffers = (function() {
|
|
function KeyValueDiffers(factories) {
|
|
this.factories = factories;
|
|
}
|
|
KeyValueDiffers.create = function(factories, parent) {
|
|
if (lang_1.isPresent(parent)) {
|
|
var copied = collection_1.ListWrapper.clone(parent.factories);
|
|
factories = factories.concat(copied);
|
|
return new KeyValueDiffers(factories);
|
|
} else {
|
|
return new KeyValueDiffers(factories);
|
|
}
|
|
};
|
|
KeyValueDiffers.extend = function(factories) {
|
|
return new di_1.Provider(KeyValueDiffers, {
|
|
useFactory: function(parent) {
|
|
if (lang_1.isBlank(parent)) {
|
|
throw new exceptions_1.BaseException('Cannot extend KeyValueDiffers without a parent injector');
|
|
}
|
|
return KeyValueDiffers.create(factories, parent);
|
|
},
|
|
deps: [[KeyValueDiffers, new di_1.SkipSelfMetadata(), new di_1.OptionalMetadata()]]
|
|
});
|
|
};
|
|
KeyValueDiffers.prototype.find = function(kv) {
|
|
var factory = this.factories.find(function(f) {
|
|
return f.supports(kv);
|
|
});
|
|
if (lang_1.isPresent(factory)) {
|
|
return factory;
|
|
} else {
|
|
throw new exceptions_1.BaseException("Cannot find a differ supporting object '" + kv + "'");
|
|
}
|
|
};
|
|
KeyValueDiffers = __decorate([di_1.Injectable(), lang_1.CONST(), __metadata('design:paramtypes', [Array])], KeyValueDiffers);
|
|
return KeyValueDiffers;
|
|
})();
|
|
exports.KeyValueDiffers = KeyValueDiffers;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d0", ["37", "20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var DefaultKeyValueDifferFactory = (function() {
|
|
function DefaultKeyValueDifferFactory() {}
|
|
DefaultKeyValueDifferFactory.prototype.supports = function(obj) {
|
|
return obj instanceof Map || lang_1.isJsObject(obj);
|
|
};
|
|
DefaultKeyValueDifferFactory.prototype.create = function(cdRef) {
|
|
return new DefaultKeyValueDiffer();
|
|
};
|
|
DefaultKeyValueDifferFactory = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], DefaultKeyValueDifferFactory);
|
|
return DefaultKeyValueDifferFactory;
|
|
})();
|
|
exports.DefaultKeyValueDifferFactory = DefaultKeyValueDifferFactory;
|
|
var DefaultKeyValueDiffer = (function() {
|
|
function DefaultKeyValueDiffer() {
|
|
this._records = new Map();
|
|
this._mapHead = null;
|
|
this._previousMapHead = null;
|
|
this._changesHead = null;
|
|
this._changesTail = null;
|
|
this._additionsHead = null;
|
|
this._additionsTail = null;
|
|
this._removalsHead = null;
|
|
this._removalsTail = null;
|
|
}
|
|
Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
|
|
get: function() {
|
|
return this._additionsHead !== null || this._changesHead !== null || this._removalsHead !== null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DefaultKeyValueDiffer.prototype.forEachItem = function(fn) {
|
|
var record;
|
|
for (record = this._mapHead; record !== null; record = record._next) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.forEachPreviousItem = function(fn) {
|
|
var record;
|
|
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.forEachChangedItem = function(fn) {
|
|
var record;
|
|
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.forEachAddedItem = function(fn) {
|
|
var record;
|
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.forEachRemovedItem = function(fn) {
|
|
var record;
|
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
|
fn(record);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.diff = function(map) {
|
|
if (lang_1.isBlank(map))
|
|
map = collection_1.MapWrapper.createFromPairs([]);
|
|
if (!(map instanceof Map || lang_1.isJsObject(map))) {
|
|
throw new exceptions_1.BaseException("Error trying to diff '" + map + "'");
|
|
}
|
|
if (this.check(map)) {
|
|
return this;
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.onDestroy = function() {};
|
|
DefaultKeyValueDiffer.prototype.check = function(map) {
|
|
var _this = this;
|
|
this._reset();
|
|
var records = this._records;
|
|
var oldSeqRecord = this._mapHead;
|
|
var lastOldSeqRecord = null;
|
|
var lastNewSeqRecord = null;
|
|
var seqChanged = false;
|
|
this._forEach(map, function(value, key) {
|
|
var newSeqRecord;
|
|
if (oldSeqRecord !== null && key === oldSeqRecord.key) {
|
|
newSeqRecord = oldSeqRecord;
|
|
if (!lang_1.looseIdentical(value, oldSeqRecord.currentValue)) {
|
|
oldSeqRecord.previousValue = oldSeqRecord.currentValue;
|
|
oldSeqRecord.currentValue = value;
|
|
_this._addToChanges(oldSeqRecord);
|
|
}
|
|
} else {
|
|
seqChanged = true;
|
|
if (oldSeqRecord !== null) {
|
|
oldSeqRecord._next = null;
|
|
_this._removeFromSeq(lastOldSeqRecord, oldSeqRecord);
|
|
_this._addToRemovals(oldSeqRecord);
|
|
}
|
|
if (records.has(key)) {
|
|
newSeqRecord = records.get(key);
|
|
} else {
|
|
newSeqRecord = new KVChangeRecord(key);
|
|
records.set(key, newSeqRecord);
|
|
newSeqRecord.currentValue = value;
|
|
_this._addToAdditions(newSeqRecord);
|
|
}
|
|
}
|
|
if (seqChanged) {
|
|
if (_this._isInRemovals(newSeqRecord)) {
|
|
_this._removeFromRemovals(newSeqRecord);
|
|
}
|
|
if (lastNewSeqRecord == null) {
|
|
_this._mapHead = newSeqRecord;
|
|
} else {
|
|
lastNewSeqRecord._next = newSeqRecord;
|
|
}
|
|
}
|
|
lastOldSeqRecord = oldSeqRecord;
|
|
lastNewSeqRecord = newSeqRecord;
|
|
oldSeqRecord = oldSeqRecord === null ? null : oldSeqRecord._next;
|
|
});
|
|
this._truncate(lastOldSeqRecord, oldSeqRecord);
|
|
return this.isDirty;
|
|
};
|
|
DefaultKeyValueDiffer.prototype._reset = function() {
|
|
if (this.isDirty) {
|
|
var record;
|
|
for (record = this._previousMapHead = this._mapHead; record !== null; record = record._next) {
|
|
record._nextPrevious = record._next;
|
|
}
|
|
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
|
record.previousValue = record.currentValue;
|
|
}
|
|
for (record = this._additionsHead; record != null; record = record._nextAdded) {
|
|
record.previousValue = record.currentValue;
|
|
}
|
|
this._changesHead = this._changesTail = null;
|
|
this._additionsHead = this._additionsTail = null;
|
|
this._removalsHead = this._removalsTail = null;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype._truncate = function(lastRecord, record) {
|
|
while (record !== null) {
|
|
if (lastRecord === null) {
|
|
this._mapHead = null;
|
|
} else {
|
|
lastRecord._next = null;
|
|
}
|
|
var nextRecord = record._next;
|
|
this._addToRemovals(record);
|
|
lastRecord = record;
|
|
record = nextRecord;
|
|
}
|
|
for (var rec = this._removalsHead; rec !== null; rec = rec._nextRemoved) {
|
|
rec.previousValue = rec.currentValue;
|
|
rec.currentValue = null;
|
|
this._records.delete(rec.key);
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype._isInRemovals = function(record) {
|
|
return record === this._removalsHead || record._nextRemoved !== null || record._prevRemoved !== null;
|
|
};
|
|
DefaultKeyValueDiffer.prototype._addToRemovals = function(record) {
|
|
if (this._removalsHead === null) {
|
|
this._removalsHead = this._removalsTail = record;
|
|
} else {
|
|
this._removalsTail._nextRemoved = record;
|
|
record._prevRemoved = this._removalsTail;
|
|
this._removalsTail = record;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype._removeFromSeq = function(prev, record) {
|
|
var next = record._next;
|
|
if (prev === null) {
|
|
this._mapHead = next;
|
|
} else {
|
|
prev._next = next;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype._removeFromRemovals = function(record) {
|
|
var prev = record._prevRemoved;
|
|
var next = record._nextRemoved;
|
|
if (prev === null) {
|
|
this._removalsHead = next;
|
|
} else {
|
|
prev._nextRemoved = next;
|
|
}
|
|
if (next === null) {
|
|
this._removalsTail = prev;
|
|
} else {
|
|
next._prevRemoved = prev;
|
|
}
|
|
record._prevRemoved = record._nextRemoved = null;
|
|
};
|
|
DefaultKeyValueDiffer.prototype._addToAdditions = function(record) {
|
|
if (this._additionsHead === null) {
|
|
this._additionsHead = this._additionsTail = record;
|
|
} else {
|
|
this._additionsTail._nextAdded = record;
|
|
this._additionsTail = record;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype._addToChanges = function(record) {
|
|
if (this._changesHead === null) {
|
|
this._changesHead = this._changesTail = record;
|
|
} else {
|
|
this._changesTail._nextChanged = record;
|
|
this._changesTail = record;
|
|
}
|
|
};
|
|
DefaultKeyValueDiffer.prototype.toString = function() {
|
|
var items = [];
|
|
var previous = [];
|
|
var changes = [];
|
|
var additions = [];
|
|
var removals = [];
|
|
var record;
|
|
for (record = this._mapHead; record !== null; record = record._next) {
|
|
items.push(lang_1.stringify(record));
|
|
}
|
|
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
|
|
previous.push(lang_1.stringify(record));
|
|
}
|
|
for (record = this._changesHead; record !== null; record = record._nextChanged) {
|
|
changes.push(lang_1.stringify(record));
|
|
}
|
|
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
|
|
additions.push(lang_1.stringify(record));
|
|
}
|
|
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
|
|
removals.push(lang_1.stringify(record));
|
|
}
|
|
return "map: " + items.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" + "additions: " + additions.join(', ') + "\n" + "changes: " + changes.join(', ') + "\n" + "removals: " + removals.join(', ') + "\n";
|
|
};
|
|
DefaultKeyValueDiffer.prototype._forEach = function(obj, fn) {
|
|
if (obj instanceof Map) {
|
|
obj.forEach(fn);
|
|
} else {
|
|
collection_1.StringMapWrapper.forEach(obj, fn);
|
|
}
|
|
};
|
|
return DefaultKeyValueDiffer;
|
|
})();
|
|
exports.DefaultKeyValueDiffer = DefaultKeyValueDiffer;
|
|
var KVChangeRecord = (function() {
|
|
function KVChangeRecord(key) {
|
|
this.key = key;
|
|
this.previousValue = null;
|
|
this.currentValue = null;
|
|
this._nextPrevious = null;
|
|
this._next = null;
|
|
this._nextAdded = null;
|
|
this._nextRemoved = null;
|
|
this._prevRemoved = null;
|
|
this._nextChanged = null;
|
|
}
|
|
KVChangeRecord.prototype.toString = function() {
|
|
return lang_1.looseIdentical(this.previousValue, this.currentValue) ? lang_1.stringify(this.key) : (lang_1.stringify(this.key) + '[' + lang_1.stringify(this.previousValue) + '->' + lang_1.stringify(this.currentValue) + ']');
|
|
};
|
|
return KVChangeRecord;
|
|
})();
|
|
exports.KVChangeRecord = KVChangeRecord;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d1", ["1d2", "37", "20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var decorators_1 = $__require('1d2');
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
(function(TokenType) {
|
|
TokenType[TokenType["Character"] = 0] = "Character";
|
|
TokenType[TokenType["Identifier"] = 1] = "Identifier";
|
|
TokenType[TokenType["Keyword"] = 2] = "Keyword";
|
|
TokenType[TokenType["String"] = 3] = "String";
|
|
TokenType[TokenType["Operator"] = 4] = "Operator";
|
|
TokenType[TokenType["Number"] = 5] = "Number";
|
|
})(exports.TokenType || (exports.TokenType = {}));
|
|
var TokenType = exports.TokenType;
|
|
var Lexer = (function() {
|
|
function Lexer() {}
|
|
Lexer.prototype.tokenize = function(text) {
|
|
var scanner = new _Scanner(text);
|
|
var tokens = [];
|
|
var token = scanner.scanToken();
|
|
while (token != null) {
|
|
tokens.push(token);
|
|
token = scanner.scanToken();
|
|
}
|
|
return tokens;
|
|
};
|
|
Lexer = __decorate([decorators_1.Injectable(), __metadata('design:paramtypes', [])], Lexer);
|
|
return Lexer;
|
|
})();
|
|
exports.Lexer = Lexer;
|
|
var Token = (function() {
|
|
function Token(index, type, numValue, strValue) {
|
|
this.index = index;
|
|
this.type = type;
|
|
this.numValue = numValue;
|
|
this.strValue = strValue;
|
|
}
|
|
Token.prototype.isCharacter = function(code) {
|
|
return (this.type == TokenType.Character && this.numValue == code);
|
|
};
|
|
Token.prototype.isNumber = function() {
|
|
return (this.type == TokenType.Number);
|
|
};
|
|
Token.prototype.isString = function() {
|
|
return (this.type == TokenType.String);
|
|
};
|
|
Token.prototype.isOperator = function(operater) {
|
|
return (this.type == TokenType.Operator && this.strValue == operater);
|
|
};
|
|
Token.prototype.isIdentifier = function() {
|
|
return (this.type == TokenType.Identifier);
|
|
};
|
|
Token.prototype.isKeyword = function() {
|
|
return (this.type == TokenType.Keyword);
|
|
};
|
|
Token.prototype.isKeywordVar = function() {
|
|
return (this.type == TokenType.Keyword && this.strValue == "var");
|
|
};
|
|
Token.prototype.isKeywordNull = function() {
|
|
return (this.type == TokenType.Keyword && this.strValue == "null");
|
|
};
|
|
Token.prototype.isKeywordUndefined = function() {
|
|
return (this.type == TokenType.Keyword && this.strValue == "undefined");
|
|
};
|
|
Token.prototype.isKeywordTrue = function() {
|
|
return (this.type == TokenType.Keyword && this.strValue == "true");
|
|
};
|
|
Token.prototype.isKeywordFalse = function() {
|
|
return (this.type == TokenType.Keyword && this.strValue == "false");
|
|
};
|
|
Token.prototype.toNumber = function() {
|
|
return (this.type == TokenType.Number) ? this.numValue : -1;
|
|
};
|
|
Token.prototype.toString = function() {
|
|
switch (this.type) {
|
|
case TokenType.Character:
|
|
case TokenType.Identifier:
|
|
case TokenType.Keyword:
|
|
case TokenType.Operator:
|
|
case TokenType.String:
|
|
return this.strValue;
|
|
case TokenType.Number:
|
|
return this.numValue.toString();
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
return Token;
|
|
})();
|
|
exports.Token = Token;
|
|
function newCharacterToken(index, code) {
|
|
return new Token(index, TokenType.Character, code, lang_1.StringWrapper.fromCharCode(code));
|
|
}
|
|
function newIdentifierToken(index, text) {
|
|
return new Token(index, TokenType.Identifier, 0, text);
|
|
}
|
|
function newKeywordToken(index, text) {
|
|
return new Token(index, TokenType.Keyword, 0, text);
|
|
}
|
|
function newOperatorToken(index, text) {
|
|
return new Token(index, TokenType.Operator, 0, text);
|
|
}
|
|
function newStringToken(index, text) {
|
|
return new Token(index, TokenType.String, 0, text);
|
|
}
|
|
function newNumberToken(index, n) {
|
|
return new Token(index, TokenType.Number, n, "");
|
|
}
|
|
exports.EOF = new Token(-1, TokenType.Character, 0, "");
|
|
exports.$EOF = 0;
|
|
exports.$TAB = 9;
|
|
exports.$LF = 10;
|
|
exports.$VTAB = 11;
|
|
exports.$FF = 12;
|
|
exports.$CR = 13;
|
|
exports.$SPACE = 32;
|
|
exports.$BANG = 33;
|
|
exports.$DQ = 34;
|
|
exports.$HASH = 35;
|
|
exports.$$ = 36;
|
|
exports.$PERCENT = 37;
|
|
exports.$AMPERSAND = 38;
|
|
exports.$SQ = 39;
|
|
exports.$LPAREN = 40;
|
|
exports.$RPAREN = 41;
|
|
exports.$STAR = 42;
|
|
exports.$PLUS = 43;
|
|
exports.$COMMA = 44;
|
|
exports.$MINUS = 45;
|
|
exports.$PERIOD = 46;
|
|
exports.$SLASH = 47;
|
|
exports.$COLON = 58;
|
|
exports.$SEMICOLON = 59;
|
|
exports.$LT = 60;
|
|
exports.$EQ = 61;
|
|
exports.$GT = 62;
|
|
exports.$QUESTION = 63;
|
|
var $0 = 48;
|
|
var $9 = 57;
|
|
var $A = 65,
|
|
$E = 69,
|
|
$Z = 90;
|
|
exports.$LBRACKET = 91;
|
|
exports.$BACKSLASH = 92;
|
|
exports.$RBRACKET = 93;
|
|
var $CARET = 94;
|
|
var $_ = 95;
|
|
var $a = 97,
|
|
$e = 101,
|
|
$f = 102,
|
|
$n = 110,
|
|
$r = 114,
|
|
$t = 116,
|
|
$u = 117,
|
|
$v = 118,
|
|
$z = 122;
|
|
exports.$LBRACE = 123;
|
|
exports.$BAR = 124;
|
|
exports.$RBRACE = 125;
|
|
var $NBSP = 160;
|
|
var ScannerError = (function(_super) {
|
|
__extends(ScannerError, _super);
|
|
function ScannerError(message) {
|
|
_super.call(this);
|
|
this.message = message;
|
|
}
|
|
ScannerError.prototype.toString = function() {
|
|
return this.message;
|
|
};
|
|
return ScannerError;
|
|
})(exceptions_1.BaseException);
|
|
exports.ScannerError = ScannerError;
|
|
var _Scanner = (function() {
|
|
function _Scanner(input) {
|
|
this.input = input;
|
|
this.peek = 0;
|
|
this.index = -1;
|
|
this.length = input.length;
|
|
this.advance();
|
|
}
|
|
_Scanner.prototype.advance = function() {
|
|
this.peek = ++this.index >= this.length ? exports.$EOF : lang_1.StringWrapper.charCodeAt(this.input, this.index);
|
|
};
|
|
_Scanner.prototype.scanToken = function() {
|
|
var input = this.input,
|
|
length = this.length,
|
|
peek = this.peek,
|
|
index = this.index;
|
|
while (peek <= exports.$SPACE) {
|
|
if (++index >= length) {
|
|
peek = exports.$EOF;
|
|
break;
|
|
} else {
|
|
peek = lang_1.StringWrapper.charCodeAt(input, index);
|
|
}
|
|
}
|
|
this.peek = peek;
|
|
this.index = index;
|
|
if (index >= length) {
|
|
return null;
|
|
}
|
|
if (isIdentifierStart(peek))
|
|
return this.scanIdentifier();
|
|
if (isDigit(peek))
|
|
return this.scanNumber(index);
|
|
var start = index;
|
|
switch (peek) {
|
|
case exports.$PERIOD:
|
|
this.advance();
|
|
return isDigit(this.peek) ? this.scanNumber(start) : newCharacterToken(start, exports.$PERIOD);
|
|
case exports.$LPAREN:
|
|
case exports.$RPAREN:
|
|
case exports.$LBRACE:
|
|
case exports.$RBRACE:
|
|
case exports.$LBRACKET:
|
|
case exports.$RBRACKET:
|
|
case exports.$COMMA:
|
|
case exports.$COLON:
|
|
case exports.$SEMICOLON:
|
|
return this.scanCharacter(start, peek);
|
|
case exports.$SQ:
|
|
case exports.$DQ:
|
|
return this.scanString();
|
|
case exports.$HASH:
|
|
case exports.$PLUS:
|
|
case exports.$MINUS:
|
|
case exports.$STAR:
|
|
case exports.$SLASH:
|
|
case exports.$PERCENT:
|
|
case $CARET:
|
|
return this.scanOperator(start, lang_1.StringWrapper.fromCharCode(peek));
|
|
case exports.$QUESTION:
|
|
return this.scanComplexOperator(start, '?', exports.$PERIOD, '.');
|
|
case exports.$LT:
|
|
case exports.$GT:
|
|
return this.scanComplexOperator(start, lang_1.StringWrapper.fromCharCode(peek), exports.$EQ, '=');
|
|
case exports.$BANG:
|
|
case exports.$EQ:
|
|
return this.scanComplexOperator(start, lang_1.StringWrapper.fromCharCode(peek), exports.$EQ, '=', exports.$EQ, '=');
|
|
case exports.$AMPERSAND:
|
|
return this.scanComplexOperator(start, '&', exports.$AMPERSAND, '&');
|
|
case exports.$BAR:
|
|
return this.scanComplexOperator(start, '|', exports.$BAR, '|');
|
|
case $NBSP:
|
|
while (isWhitespace(this.peek))
|
|
this.advance();
|
|
return this.scanToken();
|
|
}
|
|
this.error("Unexpected character [" + lang_1.StringWrapper.fromCharCode(peek) + "]", 0);
|
|
return null;
|
|
};
|
|
_Scanner.prototype.scanCharacter = function(start, code) {
|
|
assert(this.peek == code);
|
|
this.advance();
|
|
return newCharacterToken(start, code);
|
|
};
|
|
_Scanner.prototype.scanOperator = function(start, str) {
|
|
assert(this.peek == lang_1.StringWrapper.charCodeAt(str, 0));
|
|
assert(collection_1.SetWrapper.has(OPERATORS, str));
|
|
this.advance();
|
|
return newOperatorToken(start, str);
|
|
};
|
|
_Scanner.prototype.scanComplexOperator = function(start, one, twoCode, two, threeCode, three) {
|
|
assert(this.peek == lang_1.StringWrapper.charCodeAt(one, 0));
|
|
this.advance();
|
|
var str = one;
|
|
if (this.peek == twoCode) {
|
|
this.advance();
|
|
str += two;
|
|
}
|
|
if (lang_1.isPresent(threeCode) && this.peek == threeCode) {
|
|
this.advance();
|
|
str += three;
|
|
}
|
|
assert(collection_1.SetWrapper.has(OPERATORS, str));
|
|
return newOperatorToken(start, str);
|
|
};
|
|
_Scanner.prototype.scanIdentifier = function() {
|
|
assert(isIdentifierStart(this.peek));
|
|
var start = this.index;
|
|
this.advance();
|
|
while (isIdentifierPart(this.peek))
|
|
this.advance();
|
|
var str = this.input.substring(start, this.index);
|
|
if (collection_1.SetWrapper.has(KEYWORDS, str)) {
|
|
return newKeywordToken(start, str);
|
|
} else {
|
|
return newIdentifierToken(start, str);
|
|
}
|
|
};
|
|
_Scanner.prototype.scanNumber = function(start) {
|
|
assert(isDigit(this.peek));
|
|
var simple = (this.index === start);
|
|
this.advance();
|
|
while (true) {
|
|
if (isDigit(this.peek)) {} else if (this.peek == exports.$PERIOD) {
|
|
simple = false;
|
|
} else if (isExponentStart(this.peek)) {
|
|
this.advance();
|
|
if (isExponentSign(this.peek))
|
|
this.advance();
|
|
if (!isDigit(this.peek))
|
|
this.error('Invalid exponent', -1);
|
|
simple = false;
|
|
} else {
|
|
break;
|
|
}
|
|
this.advance();
|
|
}
|
|
var str = this.input.substring(start, this.index);
|
|
var value = simple ? lang_1.NumberWrapper.parseIntAutoRadix(str) : lang_1.NumberWrapper.parseFloat(str);
|
|
return newNumberToken(start, value);
|
|
};
|
|
_Scanner.prototype.scanString = function() {
|
|
assert(this.peek == exports.$SQ || this.peek == exports.$DQ);
|
|
var start = this.index;
|
|
var quote = this.peek;
|
|
this.advance();
|
|
var buffer;
|
|
var marker = this.index;
|
|
var input = this.input;
|
|
while (this.peek != quote) {
|
|
if (this.peek == exports.$BACKSLASH) {
|
|
if (buffer == null)
|
|
buffer = new lang_1.StringJoiner();
|
|
buffer.add(input.substring(marker, this.index));
|
|
this.advance();
|
|
var unescapedCode;
|
|
if (this.peek == $u) {
|
|
var hex = input.substring(this.index + 1, this.index + 5);
|
|
try {
|
|
unescapedCode = lang_1.NumberWrapper.parseInt(hex, 16);
|
|
} catch (e) {
|
|
this.error("Invalid unicode escape [\\u" + hex + "]", 0);
|
|
}
|
|
for (var i = 0; i < 5; i++) {
|
|
this.advance();
|
|
}
|
|
} else {
|
|
unescapedCode = unescape(this.peek);
|
|
this.advance();
|
|
}
|
|
buffer.add(lang_1.StringWrapper.fromCharCode(unescapedCode));
|
|
marker = this.index;
|
|
} else if (this.peek == exports.$EOF) {
|
|
this.error('Unterminated quote', 0);
|
|
} else {
|
|
this.advance();
|
|
}
|
|
}
|
|
var last = input.substring(marker, this.index);
|
|
this.advance();
|
|
var unescaped = last;
|
|
if (buffer != null) {
|
|
buffer.add(last);
|
|
unescaped = buffer.toString();
|
|
}
|
|
return newStringToken(start, unescaped);
|
|
};
|
|
_Scanner.prototype.error = function(message, offset) {
|
|
var position = this.index + offset;
|
|
throw new ScannerError("Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
|
|
};
|
|
return _Scanner;
|
|
})();
|
|
function isWhitespace(code) {
|
|
return (code >= exports.$TAB && code <= exports.$SPACE) || (code == $NBSP);
|
|
}
|
|
function isIdentifierStart(code) {
|
|
return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || (code == $_) || (code == exports.$$);
|
|
}
|
|
function isIdentifier(input) {
|
|
if (input.length == 0)
|
|
return false;
|
|
var scanner = new _Scanner(input);
|
|
if (!isIdentifierStart(scanner.peek))
|
|
return false;
|
|
scanner.advance();
|
|
while (scanner.peek !== exports.$EOF) {
|
|
if (!isIdentifierPart(scanner.peek))
|
|
return false;
|
|
scanner.advance();
|
|
}
|
|
return true;
|
|
}
|
|
exports.isIdentifier = isIdentifier;
|
|
function isIdentifierPart(code) {
|
|
return ($a <= code && code <= $z) || ($A <= code && code <= $Z) || ($0 <= code && code <= $9) || (code == $_) || (code == exports.$$);
|
|
}
|
|
function isDigit(code) {
|
|
return $0 <= code && code <= $9;
|
|
}
|
|
function isExponentStart(code) {
|
|
return code == $e || code == $E;
|
|
}
|
|
function isExponentSign(code) {
|
|
return code == exports.$MINUS || code == exports.$PLUS;
|
|
}
|
|
function unescape(code) {
|
|
switch (code) {
|
|
case $n:
|
|
return exports.$LF;
|
|
case $f:
|
|
return exports.$FF;
|
|
case $r:
|
|
return exports.$CR;
|
|
case $t:
|
|
return exports.$TAB;
|
|
case $v:
|
|
return exports.$VTAB;
|
|
default:
|
|
return code;
|
|
}
|
|
}
|
|
var OPERATORS = collection_1.SetWrapper.createFromList(['+', '-', '*', '/', '%', '^', '=', '==', '!=', '===', '!==', '<', '>', '<=', '>=', '&&', '||', '&', '|', '!', '?', '#', '?.']);
|
|
var KEYWORDS = collection_1.SetWrapper.createFromList(['var', 'null', 'undefined', 'true', 'false', 'if', 'else']);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d3", ["1d2", "20", "3c", "37", "1d1", "81", "1d4"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var decorators_1 = $__require('1d2');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var lexer_1 = $__require('1d1');
|
|
var reflection_1 = $__require('81');
|
|
var ast_1 = $__require('1d4');
|
|
var _implicitReceiver = new ast_1.ImplicitReceiver();
|
|
var INTERPOLATION_REGEXP = /\{\{(.*?)\}\}/g;
|
|
var ParseException = (function(_super) {
|
|
__extends(ParseException, _super);
|
|
function ParseException(message, input, errLocation, ctxLocation) {
|
|
_super.call(this, "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation);
|
|
}
|
|
return ParseException;
|
|
})(exceptions_1.BaseException);
|
|
var Parser = (function() {
|
|
function Parser(_lexer, providedReflector) {
|
|
if (providedReflector === void 0) {
|
|
providedReflector = null;
|
|
}
|
|
this._lexer = _lexer;
|
|
this._reflector = lang_1.isPresent(providedReflector) ? providedReflector : reflection_1.reflector;
|
|
}
|
|
Parser.prototype.parseAction = function(input, location) {
|
|
this._checkNoInterpolation(input, location);
|
|
var tokens = this._lexer.tokenize(input);
|
|
var ast = new _ParseAST(input, location, tokens, this._reflector, true).parseChain();
|
|
return new ast_1.ASTWithSource(ast, input, location);
|
|
};
|
|
Parser.prototype.parseBinding = function(input, location) {
|
|
var ast = this._parseBindingAst(input, location);
|
|
return new ast_1.ASTWithSource(ast, input, location);
|
|
};
|
|
Parser.prototype.parseSimpleBinding = function(input, location) {
|
|
var ast = this._parseBindingAst(input, location);
|
|
if (!SimpleExpressionChecker.check(ast)) {
|
|
throw new ParseException('Host binding expression can only contain field access and constants', input, location);
|
|
}
|
|
return new ast_1.ASTWithSource(ast, input, location);
|
|
};
|
|
Parser.prototype._parseBindingAst = function(input, location) {
|
|
var quote = this._parseQuote(input, location);
|
|
if (lang_1.isPresent(quote)) {
|
|
return quote;
|
|
}
|
|
this._checkNoInterpolation(input, location);
|
|
var tokens = this._lexer.tokenize(input);
|
|
return new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
|
|
};
|
|
Parser.prototype._parseQuote = function(input, location) {
|
|
if (lang_1.isBlank(input))
|
|
return null;
|
|
var prefixSeparatorIndex = input.indexOf(':');
|
|
if (prefixSeparatorIndex == -1)
|
|
return null;
|
|
var prefix = input.substring(0, prefixSeparatorIndex).trim();
|
|
if (!lexer_1.isIdentifier(prefix))
|
|
return null;
|
|
var uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
|
|
return new ast_1.Quote(prefix, uninterpretedExpression, location);
|
|
};
|
|
Parser.prototype.parseTemplateBindings = function(input, location) {
|
|
var tokens = this._lexer.tokenize(input);
|
|
return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings();
|
|
};
|
|
Parser.prototype.parseInterpolation = function(input, location) {
|
|
var parts = lang_1.StringWrapper.split(input, INTERPOLATION_REGEXP);
|
|
if (parts.length <= 1) {
|
|
return null;
|
|
}
|
|
var strings = [];
|
|
var expressions = [];
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var part = parts[i];
|
|
if (i % 2 === 0) {
|
|
strings.push(part);
|
|
} else if (part.trim().length > 0) {
|
|
var tokens = this._lexer.tokenize(part);
|
|
var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
|
|
expressions.push(ast);
|
|
} else {
|
|
throw new ParseException('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i) + " in", location);
|
|
}
|
|
}
|
|
return new ast_1.ASTWithSource(new ast_1.Interpolation(strings, expressions), input, location);
|
|
};
|
|
Parser.prototype.wrapLiteralPrimitive = function(input, location) {
|
|
return new ast_1.ASTWithSource(new ast_1.LiteralPrimitive(input), input, location);
|
|
};
|
|
Parser.prototype._checkNoInterpolation = function(input, location) {
|
|
var parts = lang_1.StringWrapper.split(input, INTERPOLATION_REGEXP);
|
|
if (parts.length > 1) {
|
|
throw new ParseException('Got interpolation ({{}}) where expression was expected', input, "at column " + this._findInterpolationErrorColumn(parts, 1) + " in", location);
|
|
}
|
|
};
|
|
Parser.prototype._findInterpolationErrorColumn = function(parts, partInErrIdx) {
|
|
var errLocation = '';
|
|
for (var j = 0; j < partInErrIdx; j++) {
|
|
errLocation += j % 2 === 0 ? parts[j] : "{{" + parts[j] + "}}";
|
|
}
|
|
return errLocation.length;
|
|
};
|
|
Parser = __decorate([decorators_1.Injectable(), __metadata('design:paramtypes', [lexer_1.Lexer, reflection_1.Reflector])], Parser);
|
|
return Parser;
|
|
})();
|
|
exports.Parser = Parser;
|
|
var _ParseAST = (function() {
|
|
function _ParseAST(input, location, tokens, reflector, parseAction) {
|
|
this.input = input;
|
|
this.location = location;
|
|
this.tokens = tokens;
|
|
this.reflector = reflector;
|
|
this.parseAction = parseAction;
|
|
this.index = 0;
|
|
}
|
|
_ParseAST.prototype.peek = function(offset) {
|
|
var i = this.index + offset;
|
|
return i < this.tokens.length ? this.tokens[i] : lexer_1.EOF;
|
|
};
|
|
Object.defineProperty(_ParseAST.prototype, "next", {
|
|
get: function() {
|
|
return this.peek(0);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(_ParseAST.prototype, "inputIndex", {
|
|
get: function() {
|
|
return (this.index < this.tokens.length) ? this.next.index : this.input.length;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
_ParseAST.prototype.advance = function() {
|
|
this.index++;
|
|
};
|
|
_ParseAST.prototype.optionalCharacter = function(code) {
|
|
if (this.next.isCharacter(code)) {
|
|
this.advance();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
_ParseAST.prototype.optionalKeywordVar = function() {
|
|
if (this.peekKeywordVar()) {
|
|
this.advance();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
_ParseAST.prototype.peekKeywordVar = function() {
|
|
return this.next.isKeywordVar() || this.next.isOperator('#');
|
|
};
|
|
_ParseAST.prototype.expectCharacter = function(code) {
|
|
if (this.optionalCharacter(code))
|
|
return;
|
|
this.error("Missing expected " + lang_1.StringWrapper.fromCharCode(code));
|
|
};
|
|
_ParseAST.prototype.optionalOperator = function(op) {
|
|
if (this.next.isOperator(op)) {
|
|
this.advance();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
_ParseAST.prototype.expectOperator = function(operator) {
|
|
if (this.optionalOperator(operator))
|
|
return;
|
|
this.error("Missing expected operator " + operator);
|
|
};
|
|
_ParseAST.prototype.expectIdentifierOrKeyword = function() {
|
|
var n = this.next;
|
|
if (!n.isIdentifier() && !n.isKeyword()) {
|
|
this.error("Unexpected token " + n + ", expected identifier or keyword");
|
|
}
|
|
this.advance();
|
|
return n.toString();
|
|
};
|
|
_ParseAST.prototype.expectIdentifierOrKeywordOrString = function() {
|
|
var n = this.next;
|
|
if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
|
|
this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
|
|
}
|
|
this.advance();
|
|
return n.toString();
|
|
};
|
|
_ParseAST.prototype.parseChain = function() {
|
|
var exprs = [];
|
|
while (this.index < this.tokens.length) {
|
|
var expr = this.parsePipe();
|
|
exprs.push(expr);
|
|
if (this.optionalCharacter(lexer_1.$SEMICOLON)) {
|
|
if (!this.parseAction) {
|
|
this.error("Binding expression cannot contain chained expression");
|
|
}
|
|
while (this.optionalCharacter(lexer_1.$SEMICOLON)) {}
|
|
} else if (this.index < this.tokens.length) {
|
|
this.error("Unexpected token '" + this.next + "'");
|
|
}
|
|
}
|
|
if (exprs.length == 0)
|
|
return new ast_1.EmptyExpr();
|
|
if (exprs.length == 1)
|
|
return exprs[0];
|
|
return new ast_1.Chain(exprs);
|
|
};
|
|
_ParseAST.prototype.parsePipe = function() {
|
|
var result = this.parseExpression();
|
|
if (this.optionalOperator("|")) {
|
|
if (this.parseAction) {
|
|
this.error("Cannot have a pipe in an action expression");
|
|
}
|
|
do {
|
|
var name = this.expectIdentifierOrKeyword();
|
|
var args = [];
|
|
while (this.optionalCharacter(lexer_1.$COLON)) {
|
|
args.push(this.parseExpression());
|
|
}
|
|
result = new ast_1.BindingPipe(result, name, args);
|
|
} while (this.optionalOperator("|"));
|
|
}
|
|
return result;
|
|
};
|
|
_ParseAST.prototype.parseExpression = function() {
|
|
return this.parseConditional();
|
|
};
|
|
_ParseAST.prototype.parseConditional = function() {
|
|
var start = this.inputIndex;
|
|
var result = this.parseLogicalOr();
|
|
if (this.optionalOperator('?')) {
|
|
var yes = this.parsePipe();
|
|
if (!this.optionalCharacter(lexer_1.$COLON)) {
|
|
var end = this.inputIndex;
|
|
var expression = this.input.substring(start, end);
|
|
this.error("Conditional expression " + expression + " requires all 3 expressions");
|
|
}
|
|
var no = this.parsePipe();
|
|
return new ast_1.Conditional(result, yes, no);
|
|
} else {
|
|
return result;
|
|
}
|
|
};
|
|
_ParseAST.prototype.parseLogicalOr = function() {
|
|
var result = this.parseLogicalAnd();
|
|
while (this.optionalOperator('||')) {
|
|
result = new ast_1.Binary('||', result, this.parseLogicalAnd());
|
|
}
|
|
return result;
|
|
};
|
|
_ParseAST.prototype.parseLogicalAnd = function() {
|
|
var result = this.parseEquality();
|
|
while (this.optionalOperator('&&')) {
|
|
result = new ast_1.Binary('&&', result, this.parseEquality());
|
|
}
|
|
return result;
|
|
};
|
|
_ParseAST.prototype.parseEquality = function() {
|
|
var result = this.parseRelational();
|
|
while (true) {
|
|
if (this.optionalOperator('==')) {
|
|
result = new ast_1.Binary('==', result, this.parseRelational());
|
|
} else if (this.optionalOperator('===')) {
|
|
result = new ast_1.Binary('===', result, this.parseRelational());
|
|
} else if (this.optionalOperator('!=')) {
|
|
result = new ast_1.Binary('!=', result, this.parseRelational());
|
|
} else if (this.optionalOperator('!==')) {
|
|
result = new ast_1.Binary('!==', result, this.parseRelational());
|
|
} else {
|
|
return result;
|
|
}
|
|
}
|
|
};
|
|
_ParseAST.prototype.parseRelational = function() {
|
|
var result = this.parseAdditive();
|
|
while (true) {
|
|
if (this.optionalOperator('<')) {
|
|
result = new ast_1.Binary('<', result, this.parseAdditive());
|
|
} else if (this.optionalOperator('>')) {
|
|
result = new ast_1.Binary('>', result, this.parseAdditive());
|
|
} else if (this.optionalOperator('<=')) {
|
|
result = new ast_1.Binary('<=', result, this.parseAdditive());
|
|
} else if (this.optionalOperator('>=')) {
|
|
result = new ast_1.Binary('>=', result, this.parseAdditive());
|
|
} else {
|
|
return result;
|
|
}
|
|
}
|
|
};
|
|
_ParseAST.prototype.parseAdditive = function() {
|
|
var result = this.parseMultiplicative();
|
|
while (true) {
|
|
if (this.optionalOperator('+')) {
|
|
result = new ast_1.Binary('+', result, this.parseMultiplicative());
|
|
} else if (this.optionalOperator('-')) {
|
|
result = new ast_1.Binary('-', result, this.parseMultiplicative());
|
|
} else {
|
|
return result;
|
|
}
|
|
}
|
|
};
|
|
_ParseAST.prototype.parseMultiplicative = function() {
|
|
var result = this.parsePrefix();
|
|
while (true) {
|
|
if (this.optionalOperator('*')) {
|
|
result = new ast_1.Binary('*', result, this.parsePrefix());
|
|
} else if (this.optionalOperator('%')) {
|
|
result = new ast_1.Binary('%', result, this.parsePrefix());
|
|
} else if (this.optionalOperator('/')) {
|
|
result = new ast_1.Binary('/', result, this.parsePrefix());
|
|
} else {
|
|
return result;
|
|
}
|
|
}
|
|
};
|
|
_ParseAST.prototype.parsePrefix = function() {
|
|
if (this.optionalOperator('+')) {
|
|
return this.parsePrefix();
|
|
} else if (this.optionalOperator('-')) {
|
|
return new ast_1.Binary('-', new ast_1.LiteralPrimitive(0), this.parsePrefix());
|
|
} else if (this.optionalOperator('!')) {
|
|
return new ast_1.PrefixNot(this.parsePrefix());
|
|
} else {
|
|
return this.parseCallChain();
|
|
}
|
|
};
|
|
_ParseAST.prototype.parseCallChain = function() {
|
|
var result = this.parsePrimary();
|
|
while (true) {
|
|
if (this.optionalCharacter(lexer_1.$PERIOD)) {
|
|
result = this.parseAccessMemberOrMethodCall(result, false);
|
|
} else if (this.optionalOperator('?.')) {
|
|
result = this.parseAccessMemberOrMethodCall(result, true);
|
|
} else if (this.optionalCharacter(lexer_1.$LBRACKET)) {
|
|
var key = this.parsePipe();
|
|
this.expectCharacter(lexer_1.$RBRACKET);
|
|
if (this.optionalOperator("=")) {
|
|
var value = this.parseConditional();
|
|
result = new ast_1.KeyedWrite(result, key, value);
|
|
} else {
|
|
result = new ast_1.KeyedRead(result, key);
|
|
}
|
|
} else if (this.optionalCharacter(lexer_1.$LPAREN)) {
|
|
var args = this.parseCallArguments();
|
|
this.expectCharacter(lexer_1.$RPAREN);
|
|
result = new ast_1.FunctionCall(result, args);
|
|
} else {
|
|
return result;
|
|
}
|
|
}
|
|
};
|
|
_ParseAST.prototype.parsePrimary = function() {
|
|
if (this.optionalCharacter(lexer_1.$LPAREN)) {
|
|
var result = this.parsePipe();
|
|
this.expectCharacter(lexer_1.$RPAREN);
|
|
return result;
|
|
} else if (this.next.isKeywordNull() || this.next.isKeywordUndefined()) {
|
|
this.advance();
|
|
return new ast_1.LiteralPrimitive(null);
|
|
} else if (this.next.isKeywordTrue()) {
|
|
this.advance();
|
|
return new ast_1.LiteralPrimitive(true);
|
|
} else if (this.next.isKeywordFalse()) {
|
|
this.advance();
|
|
return new ast_1.LiteralPrimitive(false);
|
|
} else if (this.optionalCharacter(lexer_1.$LBRACKET)) {
|
|
var elements = this.parseExpressionList(lexer_1.$RBRACKET);
|
|
this.expectCharacter(lexer_1.$RBRACKET);
|
|
return new ast_1.LiteralArray(elements);
|
|
} else if (this.next.isCharacter(lexer_1.$LBRACE)) {
|
|
return this.parseLiteralMap();
|
|
} else if (this.next.isIdentifier()) {
|
|
return this.parseAccessMemberOrMethodCall(_implicitReceiver, false);
|
|
} else if (this.next.isNumber()) {
|
|
var value = this.next.toNumber();
|
|
this.advance();
|
|
return new ast_1.LiteralPrimitive(value);
|
|
} else if (this.next.isString()) {
|
|
var literalValue = this.next.toString();
|
|
this.advance();
|
|
return new ast_1.LiteralPrimitive(literalValue);
|
|
} else if (this.index >= this.tokens.length) {
|
|
this.error("Unexpected end of expression: " + this.input);
|
|
} else {
|
|
this.error("Unexpected token " + this.next);
|
|
}
|
|
throw new exceptions_1.BaseException("Fell through all cases in parsePrimary");
|
|
};
|
|
_ParseAST.prototype.parseExpressionList = function(terminator) {
|
|
var result = [];
|
|
if (!this.next.isCharacter(terminator)) {
|
|
do {
|
|
result.push(this.parsePipe());
|
|
} while (this.optionalCharacter(lexer_1.$COMMA));
|
|
}
|
|
return result;
|
|
};
|
|
_ParseAST.prototype.parseLiteralMap = function() {
|
|
var keys = [];
|
|
var values = [];
|
|
this.expectCharacter(lexer_1.$LBRACE);
|
|
if (!this.optionalCharacter(lexer_1.$RBRACE)) {
|
|
do {
|
|
var key = this.expectIdentifierOrKeywordOrString();
|
|
keys.push(key);
|
|
this.expectCharacter(lexer_1.$COLON);
|
|
values.push(this.parsePipe());
|
|
} while (this.optionalCharacter(lexer_1.$COMMA));
|
|
this.expectCharacter(lexer_1.$RBRACE);
|
|
}
|
|
return new ast_1.LiteralMap(keys, values);
|
|
};
|
|
_ParseAST.prototype.parseAccessMemberOrMethodCall = function(receiver, isSafe) {
|
|
if (isSafe === void 0) {
|
|
isSafe = false;
|
|
}
|
|
var id = this.expectIdentifierOrKeyword();
|
|
if (this.optionalCharacter(lexer_1.$LPAREN)) {
|
|
var args = this.parseCallArguments();
|
|
this.expectCharacter(lexer_1.$RPAREN);
|
|
var fn = this.reflector.method(id);
|
|
return isSafe ? new ast_1.SafeMethodCall(receiver, id, fn, args) : new ast_1.MethodCall(receiver, id, fn, args);
|
|
} else {
|
|
if (isSafe) {
|
|
if (this.optionalOperator("=")) {
|
|
this.error("The '?.' operator cannot be used in the assignment");
|
|
} else {
|
|
return new ast_1.SafePropertyRead(receiver, id, this.reflector.getter(id));
|
|
}
|
|
} else {
|
|
if (this.optionalOperator("=")) {
|
|
if (!this.parseAction) {
|
|
this.error("Bindings cannot contain assignments");
|
|
}
|
|
var value = this.parseConditional();
|
|
return new ast_1.PropertyWrite(receiver, id, this.reflector.setter(id), value);
|
|
} else {
|
|
return new ast_1.PropertyRead(receiver, id, this.reflector.getter(id));
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
_ParseAST.prototype.parseCallArguments = function() {
|
|
if (this.next.isCharacter(lexer_1.$RPAREN))
|
|
return [];
|
|
var positionals = [];
|
|
do {
|
|
positionals.push(this.parsePipe());
|
|
} while (this.optionalCharacter(lexer_1.$COMMA));
|
|
return positionals;
|
|
};
|
|
_ParseAST.prototype.parseBlockContent = function() {
|
|
if (!this.parseAction) {
|
|
this.error("Binding expression cannot contain chained expression");
|
|
}
|
|
var exprs = [];
|
|
while (this.index < this.tokens.length && !this.next.isCharacter(lexer_1.$RBRACE)) {
|
|
var expr = this.parseExpression();
|
|
exprs.push(expr);
|
|
if (this.optionalCharacter(lexer_1.$SEMICOLON)) {
|
|
while (this.optionalCharacter(lexer_1.$SEMICOLON)) {}
|
|
}
|
|
}
|
|
if (exprs.length == 0)
|
|
return new ast_1.EmptyExpr();
|
|
if (exprs.length == 1)
|
|
return exprs[0];
|
|
return new ast_1.Chain(exprs);
|
|
};
|
|
_ParseAST.prototype.expectTemplateBindingKey = function() {
|
|
var result = '';
|
|
var operatorFound = false;
|
|
do {
|
|
result += this.expectIdentifierOrKeywordOrString();
|
|
operatorFound = this.optionalOperator('-');
|
|
if (operatorFound) {
|
|
result += '-';
|
|
}
|
|
} while (operatorFound);
|
|
return result.toString();
|
|
};
|
|
_ParseAST.prototype.parseTemplateBindings = function() {
|
|
var bindings = [];
|
|
var prefix = null;
|
|
while (this.index < this.tokens.length) {
|
|
var keyIsVar = this.optionalKeywordVar();
|
|
var key = this.expectTemplateBindingKey();
|
|
if (!keyIsVar) {
|
|
if (prefix == null) {
|
|
prefix = key;
|
|
} else {
|
|
key = prefix + key[0].toUpperCase() + key.substring(1);
|
|
}
|
|
}
|
|
this.optionalCharacter(lexer_1.$COLON);
|
|
var name = null;
|
|
var expression = null;
|
|
if (keyIsVar) {
|
|
if (this.optionalOperator("=")) {
|
|
name = this.expectTemplateBindingKey();
|
|
} else {
|
|
name = '\$implicit';
|
|
}
|
|
} else if (this.next !== lexer_1.EOF && !this.peekKeywordVar()) {
|
|
var start = this.inputIndex;
|
|
var ast = this.parsePipe();
|
|
var source = this.input.substring(start, this.inputIndex);
|
|
expression = new ast_1.ASTWithSource(ast, source, this.location);
|
|
}
|
|
bindings.push(new ast_1.TemplateBinding(key, keyIsVar, name, expression));
|
|
if (!this.optionalCharacter(lexer_1.$SEMICOLON)) {
|
|
this.optionalCharacter(lexer_1.$COMMA);
|
|
}
|
|
}
|
|
return bindings;
|
|
};
|
|
_ParseAST.prototype.error = function(message, index) {
|
|
if (index === void 0) {
|
|
index = null;
|
|
}
|
|
if (lang_1.isBlank(index))
|
|
index = this.index;
|
|
var location = (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" : "at the end of the expression";
|
|
throw new ParseException(message, this.input, location, this.location);
|
|
};
|
|
return _ParseAST;
|
|
})();
|
|
exports._ParseAST = _ParseAST;
|
|
var SimpleExpressionChecker = (function() {
|
|
function SimpleExpressionChecker() {
|
|
this.simple = true;
|
|
}
|
|
SimpleExpressionChecker.check = function(ast) {
|
|
var s = new SimpleExpressionChecker();
|
|
ast.visit(s);
|
|
return s.simple;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitImplicitReceiver = function(ast) {};
|
|
SimpleExpressionChecker.prototype.visitInterpolation = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitLiteralPrimitive = function(ast) {};
|
|
SimpleExpressionChecker.prototype.visitPropertyRead = function(ast) {};
|
|
SimpleExpressionChecker.prototype.visitPropertyWrite = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitSafePropertyRead = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitMethodCall = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitSafeMethodCall = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitFunctionCall = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitLiteralArray = function(ast) {
|
|
this.visitAll(ast.expressions);
|
|
};
|
|
SimpleExpressionChecker.prototype.visitLiteralMap = function(ast) {
|
|
this.visitAll(ast.values);
|
|
};
|
|
SimpleExpressionChecker.prototype.visitBinary = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitPrefixNot = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitConditional = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitPipe = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitKeyedRead = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitKeyedWrite = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitAll = function(asts) {
|
|
var res = collection_1.ListWrapper.createFixedSize(asts.length);
|
|
for (var i = 0; i < asts.length; ++i) {
|
|
res[i] = asts[i].visit(this);
|
|
}
|
|
return res;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitChain = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
SimpleExpressionChecker.prototype.visitQuote = function(ast) {
|
|
this.simple = false;
|
|
};
|
|
return SimpleExpressionChecker;
|
|
})();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d5", ["20", "3c", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var Locals = (function() {
|
|
function Locals(parent, current) {
|
|
this.parent = parent;
|
|
this.current = current;
|
|
}
|
|
Locals.prototype.contains = function(name) {
|
|
if (this.current.has(name)) {
|
|
return true;
|
|
}
|
|
if (lang_1.isPresent(this.parent)) {
|
|
return this.parent.contains(name);
|
|
}
|
|
return false;
|
|
};
|
|
Locals.prototype.get = function(name) {
|
|
if (this.current.has(name)) {
|
|
return this.current.get(name);
|
|
}
|
|
if (lang_1.isPresent(this.parent)) {
|
|
return this.parent.get(name);
|
|
}
|
|
throw new exceptions_1.BaseException("Cannot find '" + name + "'");
|
|
};
|
|
Locals.prototype.set = function(name, value) {
|
|
if (this.current.has(name)) {
|
|
this.current.set(name, value);
|
|
} else {
|
|
throw new exceptions_1.BaseException("Setting of new keys post-construction is not supported. Key: " + name + ".");
|
|
}
|
|
};
|
|
Locals.prototype.clearValues = function() {
|
|
collection_1.MapWrapper.clearValues(this.current);
|
|
};
|
|
return Locals;
|
|
})();
|
|
exports.Locals = Locals;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1b3", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var DebugContext = (function() {
|
|
function DebugContext(element, componentElement, directive, context, locals, injector) {
|
|
this.element = element;
|
|
this.componentElement = componentElement;
|
|
this.directive = directive;
|
|
this.context = context;
|
|
this.locals = locals;
|
|
this.injector = injector;
|
|
}
|
|
return DebugContext;
|
|
})();
|
|
exports.DebugContext = DebugContext;
|
|
var ChangeDetectorGenConfig = (function() {
|
|
function ChangeDetectorGenConfig(genDebugInfo, logBindingUpdate, useJit) {
|
|
this.genDebugInfo = genDebugInfo;
|
|
this.logBindingUpdate = logBindingUpdate;
|
|
this.useJit = useJit;
|
|
}
|
|
return ChangeDetectorGenConfig;
|
|
})();
|
|
exports.ChangeDetectorGenConfig = ChangeDetectorGenConfig;
|
|
var ChangeDetectorDefinition = (function() {
|
|
function ChangeDetectorDefinition(id, strategy, variableNames, bindingRecords, eventRecords, directiveRecords, genConfig) {
|
|
this.id = id;
|
|
this.strategy = strategy;
|
|
this.variableNames = variableNames;
|
|
this.bindingRecords = bindingRecords;
|
|
this.eventRecords = eventRecords;
|
|
this.directiveRecords = directiveRecords;
|
|
this.genConfig = genConfig;
|
|
}
|
|
return ChangeDetectorDefinition;
|
|
})();
|
|
exports.ChangeDetectorDefinition = ChangeDetectorDefinition;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d6", ["20", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var _STATE_ACCESSOR = "state";
|
|
var _CONTEXT_ACCESSOR = "context";
|
|
var _PROP_BINDING_INDEX = "propertyBindingIndex";
|
|
var _DIRECTIVES_ACCESSOR = "directiveIndices";
|
|
var _DISPATCHER_ACCESSOR = "dispatcher";
|
|
var _LOCALS_ACCESSOR = "locals";
|
|
var _MODE_ACCESSOR = "mode";
|
|
var _PIPES_ACCESSOR = "pipes";
|
|
var _PROTOS_ACCESSOR = "protos";
|
|
exports.CONTEXT_ACCESSOR = "context";
|
|
exports.CONTEXT_INDEX = 0;
|
|
var _FIELD_PREFIX = 'this.';
|
|
var _whiteSpaceRegExp = /\W/g;
|
|
function sanitizeName(s) {
|
|
return lang_1.StringWrapper.replaceAll(s, _whiteSpaceRegExp, '');
|
|
}
|
|
exports.sanitizeName = sanitizeName;
|
|
var CodegenNameUtil = (function() {
|
|
function CodegenNameUtil(_records, _eventBindings, _directiveRecords, _utilName) {
|
|
this._records = _records;
|
|
this._eventBindings = _eventBindings;
|
|
this._directiveRecords = _directiveRecords;
|
|
this._utilName = _utilName;
|
|
this._sanitizedEventNames = new collection_1.Map();
|
|
this._sanitizedNames = collection_1.ListWrapper.createFixedSize(this._records.length + 1);
|
|
this._sanitizedNames[exports.CONTEXT_INDEX] = exports.CONTEXT_ACCESSOR;
|
|
for (var i = 0,
|
|
iLen = this._records.length; i < iLen; ++i) {
|
|
this._sanitizedNames[i + 1] = sanitizeName("" + this._records[i].name + i);
|
|
}
|
|
for (var ebIndex = 0; ebIndex < _eventBindings.length; ++ebIndex) {
|
|
var eb = _eventBindings[ebIndex];
|
|
var names = [exports.CONTEXT_ACCESSOR];
|
|
for (var i = 0,
|
|
iLen = eb.records.length; i < iLen; ++i) {
|
|
names.push(sanitizeName("" + eb.records[i].name + i + "_" + ebIndex));
|
|
}
|
|
this._sanitizedEventNames.set(eb, names);
|
|
}
|
|
}
|
|
CodegenNameUtil.prototype._addFieldPrefix = function(name) {
|
|
return "" + _FIELD_PREFIX + name;
|
|
};
|
|
CodegenNameUtil.prototype.getDispatcherName = function() {
|
|
return this._addFieldPrefix(_DISPATCHER_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getPipesAccessorName = function() {
|
|
return this._addFieldPrefix(_PIPES_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getProtosName = function() {
|
|
return this._addFieldPrefix(_PROTOS_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getDirectivesAccessorName = function() {
|
|
return this._addFieldPrefix(_DIRECTIVES_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getLocalsAccessorName = function() {
|
|
return this._addFieldPrefix(_LOCALS_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getStateName = function() {
|
|
return this._addFieldPrefix(_STATE_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getModeName = function() {
|
|
return this._addFieldPrefix(_MODE_ACCESSOR);
|
|
};
|
|
CodegenNameUtil.prototype.getPropertyBindingIndex = function() {
|
|
return this._addFieldPrefix(_PROP_BINDING_INDEX);
|
|
};
|
|
CodegenNameUtil.prototype.getLocalName = function(idx) {
|
|
return "l_" + this._sanitizedNames[idx];
|
|
};
|
|
CodegenNameUtil.prototype.getEventLocalName = function(eb, idx) {
|
|
return "l_" + this._sanitizedEventNames.get(eb)[idx];
|
|
};
|
|
CodegenNameUtil.prototype.getChangeName = function(idx) {
|
|
return "c_" + this._sanitizedNames[idx];
|
|
};
|
|
CodegenNameUtil.prototype.genInitLocals = function() {
|
|
var declarations = [];
|
|
var assignments = [];
|
|
for (var i = 0,
|
|
iLen = this.getFieldCount(); i < iLen; ++i) {
|
|
if (i == exports.CONTEXT_INDEX) {
|
|
declarations.push(this.getLocalName(i) + " = " + this.getFieldName(i));
|
|
} else {
|
|
var rec = this._records[i - 1];
|
|
if (rec.argumentToPureFunction) {
|
|
var changeName = this.getChangeName(i);
|
|
declarations.push(this.getLocalName(i) + "," + changeName);
|
|
assignments.push(changeName);
|
|
} else {
|
|
declarations.push("" + this.getLocalName(i));
|
|
}
|
|
}
|
|
}
|
|
var assignmentsCode = collection_1.ListWrapper.isEmpty(assignments) ? '' : assignments.join('=') + " = false;";
|
|
return "var " + declarations.join(',') + ";" + assignmentsCode;
|
|
};
|
|
CodegenNameUtil.prototype.genInitEventLocals = function() {
|
|
var _this = this;
|
|
var res = [(this.getLocalName(exports.CONTEXT_INDEX) + " = " + this.getFieldName(exports.CONTEXT_INDEX))];
|
|
this._sanitizedEventNames.forEach(function(names, eb) {
|
|
for (var i = 0; i < names.length; ++i) {
|
|
if (i !== exports.CONTEXT_INDEX) {
|
|
res.push("" + _this.getEventLocalName(eb, i));
|
|
}
|
|
}
|
|
});
|
|
return res.length > 1 ? "var " + res.join(',') + ";" : '';
|
|
};
|
|
CodegenNameUtil.prototype.getPreventDefaultAccesor = function() {
|
|
return "preventDefault";
|
|
};
|
|
CodegenNameUtil.prototype.getFieldCount = function() {
|
|
return this._sanitizedNames.length;
|
|
};
|
|
CodegenNameUtil.prototype.getFieldName = function(idx) {
|
|
return this._addFieldPrefix(this._sanitizedNames[idx]);
|
|
};
|
|
CodegenNameUtil.prototype.getAllFieldNames = function() {
|
|
var fieldList = [];
|
|
for (var k = 0,
|
|
kLen = this.getFieldCount(); k < kLen; ++k) {
|
|
if (k === 0 || this._records[k - 1].shouldBeChecked()) {
|
|
fieldList.push(this.getFieldName(k));
|
|
}
|
|
}
|
|
for (var i = 0,
|
|
iLen = this._records.length; i < iLen; ++i) {
|
|
var rec = this._records[i];
|
|
if (rec.isPipeRecord()) {
|
|
fieldList.push(this.getPipeName(rec.selfIndex));
|
|
}
|
|
}
|
|
for (var j = 0,
|
|
jLen = this._directiveRecords.length; j < jLen; ++j) {
|
|
var dRec = this._directiveRecords[j];
|
|
fieldList.push(this.getDirectiveName(dRec.directiveIndex));
|
|
if (!dRec.isDefaultChangeDetection()) {
|
|
fieldList.push(this.getDetectorName(dRec.directiveIndex));
|
|
}
|
|
}
|
|
return fieldList;
|
|
};
|
|
CodegenNameUtil.prototype.genDehydrateFields = function() {
|
|
var fields = this.getAllFieldNames();
|
|
collection_1.ListWrapper.removeAt(fields, exports.CONTEXT_INDEX);
|
|
if (collection_1.ListWrapper.isEmpty(fields))
|
|
return '';
|
|
fields.push(this._utilName + ".uninitialized;");
|
|
return fields.join(' = ');
|
|
};
|
|
CodegenNameUtil.prototype.genPipeOnDestroy = function() {
|
|
var _this = this;
|
|
return this._records.filter(function(r) {
|
|
return r.isPipeRecord();
|
|
}).map(function(r) {
|
|
return (_this._utilName + ".callPipeOnDestroy(" + _this.getPipeName(r.selfIndex) + ");");
|
|
}).join('\n');
|
|
};
|
|
CodegenNameUtil.prototype.getPipeName = function(idx) {
|
|
return this._addFieldPrefix(this._sanitizedNames[idx] + "_pipe");
|
|
};
|
|
CodegenNameUtil.prototype.getDirectiveName = function(d) {
|
|
return this._addFieldPrefix("directive_" + d.name);
|
|
};
|
|
CodegenNameUtil.prototype.getDetectorName = function(d) {
|
|
return this._addFieldPrefix("detector_" + d.name);
|
|
};
|
|
return CodegenNameUtil;
|
|
})();
|
|
exports.CodegenNameUtil = CodegenNameUtil;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d7", ["20", "1d8", "1d9", "1da", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var codegen_facade_1 = $__require('1d8');
|
|
var proto_record_1 = $__require('1d9');
|
|
var constants_1 = $__require('1da');
|
|
var exceptions_1 = $__require('3c');
|
|
var CodegenLogicUtil = (function() {
|
|
function CodegenLogicUtil(_names, _utilName, _changeDetectorStateName, _changeDetection) {
|
|
this._names = _names;
|
|
this._utilName = _utilName;
|
|
this._changeDetectorStateName = _changeDetectorStateName;
|
|
this._changeDetection = _changeDetection;
|
|
}
|
|
CodegenLogicUtil.prototype.genPropertyBindingEvalValue = function(protoRec) {
|
|
var _this = this;
|
|
return this._genEvalValue(protoRec, function(idx) {
|
|
return _this._names.getLocalName(idx);
|
|
}, this._names.getLocalsAccessorName());
|
|
};
|
|
CodegenLogicUtil.prototype.genEventBindingEvalValue = function(eventRecord, protoRec) {
|
|
var _this = this;
|
|
return this._genEvalValue(protoRec, function(idx) {
|
|
return _this._names.getEventLocalName(eventRecord, idx);
|
|
}, "locals");
|
|
};
|
|
CodegenLogicUtil.prototype._genEvalValue = function(protoRec, getLocalName, localsAccessor) {
|
|
var context = (protoRec.contextIndex == -1) ? this._names.getDirectiveName(protoRec.directiveIndex) : getLocalName(protoRec.contextIndex);
|
|
var argString = protoRec.args.map(function(arg) {
|
|
return getLocalName(arg);
|
|
}).join(", ");
|
|
var rhs;
|
|
switch (protoRec.mode) {
|
|
case proto_record_1.RecordType.Self:
|
|
rhs = context;
|
|
break;
|
|
case proto_record_1.RecordType.Const:
|
|
rhs = codegen_facade_1.codify(protoRec.funcOrValue);
|
|
break;
|
|
case proto_record_1.RecordType.PropertyRead:
|
|
rhs = this._observe(context + "." + protoRec.name, protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.SafeProperty:
|
|
var read = this._observe(context + "." + protoRec.name, protoRec);
|
|
rhs = this._utilName + ".isValueBlank(" + context + ") ? null : " + this._observe(read, protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.PropertyWrite:
|
|
rhs = context + "." + protoRec.name + " = " + getLocalName(protoRec.args[0]);
|
|
break;
|
|
case proto_record_1.RecordType.Local:
|
|
rhs = this._observe(localsAccessor + ".get(" + codegen_facade_1.rawString(protoRec.name) + ")", protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.InvokeMethod:
|
|
rhs = this._observe(context + "." + protoRec.name + "(" + argString + ")", protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.SafeMethodInvoke:
|
|
var invoke = context + "." + protoRec.name + "(" + argString + ")";
|
|
rhs = this._utilName + ".isValueBlank(" + context + ") ? null : " + this._observe(invoke, protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.InvokeClosure:
|
|
rhs = context + "(" + argString + ")";
|
|
break;
|
|
case proto_record_1.RecordType.PrimitiveOp:
|
|
rhs = this._utilName + "." + protoRec.name + "(" + argString + ")";
|
|
break;
|
|
case proto_record_1.RecordType.CollectionLiteral:
|
|
rhs = this._utilName + "." + protoRec.name + "(" + argString + ")";
|
|
break;
|
|
case proto_record_1.RecordType.Interpolate:
|
|
rhs = this._genInterpolation(protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.KeyedRead:
|
|
rhs = this._observe(context + "[" + getLocalName(protoRec.args[0]) + "]", protoRec);
|
|
break;
|
|
case proto_record_1.RecordType.KeyedWrite:
|
|
rhs = context + "[" + getLocalName(protoRec.args[0]) + "] = " + getLocalName(protoRec.args[1]);
|
|
break;
|
|
case proto_record_1.RecordType.Chain:
|
|
rhs = 'null';
|
|
break;
|
|
default:
|
|
throw new exceptions_1.BaseException("Unknown operation " + protoRec.mode);
|
|
}
|
|
return getLocalName(protoRec.selfIndex) + " = " + rhs + ";";
|
|
};
|
|
CodegenLogicUtil.prototype._observe = function(exp, rec) {
|
|
if (this._changeDetection === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
return "this.observeValue(" + exp + ", " + rec.selfIndex + ")";
|
|
} else {
|
|
return exp;
|
|
}
|
|
};
|
|
CodegenLogicUtil.prototype.genPropertyBindingTargets = function(propertyBindingTargets, genDebugInfo) {
|
|
var _this = this;
|
|
var bs = propertyBindingTargets.map(function(b) {
|
|
if (lang_1.isBlank(b))
|
|
return "null";
|
|
var debug = genDebugInfo ? codegen_facade_1.codify(b.debug) : "null";
|
|
return _this._utilName + ".bindingTarget(" + codegen_facade_1.codify(b.mode) + ", " + b.elementIndex + ", " + codegen_facade_1.codify(b.name) + ", " + codegen_facade_1.codify(b.unit) + ", " + debug + ")";
|
|
});
|
|
return "[" + bs.join(", ") + "]";
|
|
};
|
|
CodegenLogicUtil.prototype.genDirectiveIndices = function(directiveRecords) {
|
|
var _this = this;
|
|
var bs = directiveRecords.map(function(b) {
|
|
return (_this._utilName + ".directiveIndex(" + b.directiveIndex.elementIndex + ", " + b.directiveIndex.directiveIndex + ")");
|
|
});
|
|
return "[" + bs.join(", ") + "]";
|
|
};
|
|
CodegenLogicUtil.prototype._genInterpolation = function(protoRec) {
|
|
var iVals = [];
|
|
for (var i = 0; i < protoRec.args.length; ++i) {
|
|
iVals.push(codegen_facade_1.codify(protoRec.fixedArgs[i]));
|
|
iVals.push(this._utilName + ".s(" + this._names.getLocalName(protoRec.args[i]) + ")");
|
|
}
|
|
iVals.push(codegen_facade_1.codify(protoRec.fixedArgs[protoRec.args.length]));
|
|
return codegen_facade_1.combineGeneratedStrings(iVals);
|
|
};
|
|
CodegenLogicUtil.prototype.genHydrateDirectives = function(directiveRecords) {
|
|
var res = [];
|
|
for (var i = 0; i < directiveRecords.length; ++i) {
|
|
var r = directiveRecords[i];
|
|
res.push(this._names.getDirectiveName(r.directiveIndex) + " = " + this._genReadDirective(i) + ";");
|
|
}
|
|
return res.join("\n");
|
|
};
|
|
CodegenLogicUtil.prototype._genReadDirective = function(index) {
|
|
if (this._changeDetection === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
return "this.observeDirective(this.getDirectiveFor(directives, " + index + "), " + index + ")";
|
|
} else {
|
|
return "this.getDirectiveFor(directives, " + index + ")";
|
|
}
|
|
};
|
|
CodegenLogicUtil.prototype.genHydrateDetectors = function(directiveRecords) {
|
|
var res = [];
|
|
for (var i = 0; i < directiveRecords.length; ++i) {
|
|
var r = directiveRecords[i];
|
|
if (!r.isDefaultChangeDetection()) {
|
|
res.push(this._names.getDetectorName(r.directiveIndex) + " = this.getDetectorFor(directives, " + i + ");");
|
|
}
|
|
}
|
|
return res.join("\n");
|
|
};
|
|
CodegenLogicUtil.prototype.genContentLifecycleCallbacks = function(directiveRecords) {
|
|
var res = [];
|
|
var eq = lang_1.IS_DART ? '==' : '===';
|
|
for (var i = directiveRecords.length - 1; i >= 0; --i) {
|
|
var dir = directiveRecords[i];
|
|
if (dir.callAfterContentInit) {
|
|
res.push("if(" + this._names.getStateName() + " " + eq + " " + this._changeDetectorStateName + ".NeverChecked) " + this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterContentInit();");
|
|
}
|
|
if (dir.callAfterContentChecked) {
|
|
res.push(this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterContentChecked();");
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
CodegenLogicUtil.prototype.genViewLifecycleCallbacks = function(directiveRecords) {
|
|
var res = [];
|
|
var eq = lang_1.IS_DART ? '==' : '===';
|
|
for (var i = directiveRecords.length - 1; i >= 0; --i) {
|
|
var dir = directiveRecords[i];
|
|
if (dir.callAfterViewInit) {
|
|
res.push("if(" + this._names.getStateName() + " " + eq + " " + this._changeDetectorStateName + ".NeverChecked) " + this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterViewInit();");
|
|
}
|
|
if (dir.callAfterViewChecked) {
|
|
res.push(this._names.getDirectiveName(dir.directiveIndex) + ".ngAfterViewChecked();");
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
return CodegenLogicUtil;
|
|
})();
|
|
exports.CodegenLogicUtil = CodegenLogicUtil;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d8", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function codify(obj) {
|
|
return JSON.stringify(obj);
|
|
}
|
|
exports.codify = codify;
|
|
function rawString(str) {
|
|
return "'" + str + "'";
|
|
}
|
|
exports.rawString = rawString;
|
|
function combineGeneratedStrings(vals) {
|
|
return vals.join(' + ');
|
|
}
|
|
exports.combineGeneratedStrings = combineGeneratedStrings;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d4", ["37", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var AST = (function() {
|
|
function AST() {}
|
|
AST.prototype.visit = function(visitor) {
|
|
return null;
|
|
};
|
|
AST.prototype.toString = function() {
|
|
return "AST";
|
|
};
|
|
return AST;
|
|
})();
|
|
exports.AST = AST;
|
|
var Quote = (function(_super) {
|
|
__extends(Quote, _super);
|
|
function Quote(prefix, uninterpretedExpression, location) {
|
|
_super.call(this);
|
|
this.prefix = prefix;
|
|
this.uninterpretedExpression = uninterpretedExpression;
|
|
this.location = location;
|
|
}
|
|
Quote.prototype.visit = function(visitor) {
|
|
return visitor.visitQuote(this);
|
|
};
|
|
Quote.prototype.toString = function() {
|
|
return "Quote";
|
|
};
|
|
return Quote;
|
|
})(AST);
|
|
exports.Quote = Quote;
|
|
var EmptyExpr = (function(_super) {
|
|
__extends(EmptyExpr, _super);
|
|
function EmptyExpr() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
EmptyExpr.prototype.visit = function(visitor) {};
|
|
return EmptyExpr;
|
|
})(AST);
|
|
exports.EmptyExpr = EmptyExpr;
|
|
var ImplicitReceiver = (function(_super) {
|
|
__extends(ImplicitReceiver, _super);
|
|
function ImplicitReceiver() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
ImplicitReceiver.prototype.visit = function(visitor) {
|
|
return visitor.visitImplicitReceiver(this);
|
|
};
|
|
return ImplicitReceiver;
|
|
})(AST);
|
|
exports.ImplicitReceiver = ImplicitReceiver;
|
|
var Chain = (function(_super) {
|
|
__extends(Chain, _super);
|
|
function Chain(expressions) {
|
|
_super.call(this);
|
|
this.expressions = expressions;
|
|
}
|
|
Chain.prototype.visit = function(visitor) {
|
|
return visitor.visitChain(this);
|
|
};
|
|
return Chain;
|
|
})(AST);
|
|
exports.Chain = Chain;
|
|
var Conditional = (function(_super) {
|
|
__extends(Conditional, _super);
|
|
function Conditional(condition, trueExp, falseExp) {
|
|
_super.call(this);
|
|
this.condition = condition;
|
|
this.trueExp = trueExp;
|
|
this.falseExp = falseExp;
|
|
}
|
|
Conditional.prototype.visit = function(visitor) {
|
|
return visitor.visitConditional(this);
|
|
};
|
|
return Conditional;
|
|
})(AST);
|
|
exports.Conditional = Conditional;
|
|
var PropertyRead = (function(_super) {
|
|
__extends(PropertyRead, _super);
|
|
function PropertyRead(receiver, name, getter) {
|
|
_super.call(this);
|
|
this.receiver = receiver;
|
|
this.name = name;
|
|
this.getter = getter;
|
|
}
|
|
PropertyRead.prototype.visit = function(visitor) {
|
|
return visitor.visitPropertyRead(this);
|
|
};
|
|
return PropertyRead;
|
|
})(AST);
|
|
exports.PropertyRead = PropertyRead;
|
|
var PropertyWrite = (function(_super) {
|
|
__extends(PropertyWrite, _super);
|
|
function PropertyWrite(receiver, name, setter, value) {
|
|
_super.call(this);
|
|
this.receiver = receiver;
|
|
this.name = name;
|
|
this.setter = setter;
|
|
this.value = value;
|
|
}
|
|
PropertyWrite.prototype.visit = function(visitor) {
|
|
return visitor.visitPropertyWrite(this);
|
|
};
|
|
return PropertyWrite;
|
|
})(AST);
|
|
exports.PropertyWrite = PropertyWrite;
|
|
var SafePropertyRead = (function(_super) {
|
|
__extends(SafePropertyRead, _super);
|
|
function SafePropertyRead(receiver, name, getter) {
|
|
_super.call(this);
|
|
this.receiver = receiver;
|
|
this.name = name;
|
|
this.getter = getter;
|
|
}
|
|
SafePropertyRead.prototype.visit = function(visitor) {
|
|
return visitor.visitSafePropertyRead(this);
|
|
};
|
|
return SafePropertyRead;
|
|
})(AST);
|
|
exports.SafePropertyRead = SafePropertyRead;
|
|
var KeyedRead = (function(_super) {
|
|
__extends(KeyedRead, _super);
|
|
function KeyedRead(obj, key) {
|
|
_super.call(this);
|
|
this.obj = obj;
|
|
this.key = key;
|
|
}
|
|
KeyedRead.prototype.visit = function(visitor) {
|
|
return visitor.visitKeyedRead(this);
|
|
};
|
|
return KeyedRead;
|
|
})(AST);
|
|
exports.KeyedRead = KeyedRead;
|
|
var KeyedWrite = (function(_super) {
|
|
__extends(KeyedWrite, _super);
|
|
function KeyedWrite(obj, key, value) {
|
|
_super.call(this);
|
|
this.obj = obj;
|
|
this.key = key;
|
|
this.value = value;
|
|
}
|
|
KeyedWrite.prototype.visit = function(visitor) {
|
|
return visitor.visitKeyedWrite(this);
|
|
};
|
|
return KeyedWrite;
|
|
})(AST);
|
|
exports.KeyedWrite = KeyedWrite;
|
|
var BindingPipe = (function(_super) {
|
|
__extends(BindingPipe, _super);
|
|
function BindingPipe(exp, name, args) {
|
|
_super.call(this);
|
|
this.exp = exp;
|
|
this.name = name;
|
|
this.args = args;
|
|
}
|
|
BindingPipe.prototype.visit = function(visitor) {
|
|
return visitor.visitPipe(this);
|
|
};
|
|
return BindingPipe;
|
|
})(AST);
|
|
exports.BindingPipe = BindingPipe;
|
|
var LiteralPrimitive = (function(_super) {
|
|
__extends(LiteralPrimitive, _super);
|
|
function LiteralPrimitive(value) {
|
|
_super.call(this);
|
|
this.value = value;
|
|
}
|
|
LiteralPrimitive.prototype.visit = function(visitor) {
|
|
return visitor.visitLiteralPrimitive(this);
|
|
};
|
|
return LiteralPrimitive;
|
|
})(AST);
|
|
exports.LiteralPrimitive = LiteralPrimitive;
|
|
var LiteralArray = (function(_super) {
|
|
__extends(LiteralArray, _super);
|
|
function LiteralArray(expressions) {
|
|
_super.call(this);
|
|
this.expressions = expressions;
|
|
}
|
|
LiteralArray.prototype.visit = function(visitor) {
|
|
return visitor.visitLiteralArray(this);
|
|
};
|
|
return LiteralArray;
|
|
})(AST);
|
|
exports.LiteralArray = LiteralArray;
|
|
var LiteralMap = (function(_super) {
|
|
__extends(LiteralMap, _super);
|
|
function LiteralMap(keys, values) {
|
|
_super.call(this);
|
|
this.keys = keys;
|
|
this.values = values;
|
|
}
|
|
LiteralMap.prototype.visit = function(visitor) {
|
|
return visitor.visitLiteralMap(this);
|
|
};
|
|
return LiteralMap;
|
|
})(AST);
|
|
exports.LiteralMap = LiteralMap;
|
|
var Interpolation = (function(_super) {
|
|
__extends(Interpolation, _super);
|
|
function Interpolation(strings, expressions) {
|
|
_super.call(this);
|
|
this.strings = strings;
|
|
this.expressions = expressions;
|
|
}
|
|
Interpolation.prototype.visit = function(visitor) {
|
|
return visitor.visitInterpolation(this);
|
|
};
|
|
return Interpolation;
|
|
})(AST);
|
|
exports.Interpolation = Interpolation;
|
|
var Binary = (function(_super) {
|
|
__extends(Binary, _super);
|
|
function Binary(operation, left, right) {
|
|
_super.call(this);
|
|
this.operation = operation;
|
|
this.left = left;
|
|
this.right = right;
|
|
}
|
|
Binary.prototype.visit = function(visitor) {
|
|
return visitor.visitBinary(this);
|
|
};
|
|
return Binary;
|
|
})(AST);
|
|
exports.Binary = Binary;
|
|
var PrefixNot = (function(_super) {
|
|
__extends(PrefixNot, _super);
|
|
function PrefixNot(expression) {
|
|
_super.call(this);
|
|
this.expression = expression;
|
|
}
|
|
PrefixNot.prototype.visit = function(visitor) {
|
|
return visitor.visitPrefixNot(this);
|
|
};
|
|
return PrefixNot;
|
|
})(AST);
|
|
exports.PrefixNot = PrefixNot;
|
|
var MethodCall = (function(_super) {
|
|
__extends(MethodCall, _super);
|
|
function MethodCall(receiver, name, fn, args) {
|
|
_super.call(this);
|
|
this.receiver = receiver;
|
|
this.name = name;
|
|
this.fn = fn;
|
|
this.args = args;
|
|
}
|
|
MethodCall.prototype.visit = function(visitor) {
|
|
return visitor.visitMethodCall(this);
|
|
};
|
|
return MethodCall;
|
|
})(AST);
|
|
exports.MethodCall = MethodCall;
|
|
var SafeMethodCall = (function(_super) {
|
|
__extends(SafeMethodCall, _super);
|
|
function SafeMethodCall(receiver, name, fn, args) {
|
|
_super.call(this);
|
|
this.receiver = receiver;
|
|
this.name = name;
|
|
this.fn = fn;
|
|
this.args = args;
|
|
}
|
|
SafeMethodCall.prototype.visit = function(visitor) {
|
|
return visitor.visitSafeMethodCall(this);
|
|
};
|
|
return SafeMethodCall;
|
|
})(AST);
|
|
exports.SafeMethodCall = SafeMethodCall;
|
|
var FunctionCall = (function(_super) {
|
|
__extends(FunctionCall, _super);
|
|
function FunctionCall(target, args) {
|
|
_super.call(this);
|
|
this.target = target;
|
|
this.args = args;
|
|
}
|
|
FunctionCall.prototype.visit = function(visitor) {
|
|
return visitor.visitFunctionCall(this);
|
|
};
|
|
return FunctionCall;
|
|
})(AST);
|
|
exports.FunctionCall = FunctionCall;
|
|
var ASTWithSource = (function(_super) {
|
|
__extends(ASTWithSource, _super);
|
|
function ASTWithSource(ast, source, location) {
|
|
_super.call(this);
|
|
this.ast = ast;
|
|
this.source = source;
|
|
this.location = location;
|
|
}
|
|
ASTWithSource.prototype.visit = function(visitor) {
|
|
return this.ast.visit(visitor);
|
|
};
|
|
ASTWithSource.prototype.toString = function() {
|
|
return this.source + " in " + this.location;
|
|
};
|
|
return ASTWithSource;
|
|
})(AST);
|
|
exports.ASTWithSource = ASTWithSource;
|
|
var TemplateBinding = (function() {
|
|
function TemplateBinding(key, keyIsVar, name, expression) {
|
|
this.key = key;
|
|
this.keyIsVar = keyIsVar;
|
|
this.name = name;
|
|
this.expression = expression;
|
|
}
|
|
return TemplateBinding;
|
|
})();
|
|
exports.TemplateBinding = TemplateBinding;
|
|
var RecursiveAstVisitor = (function() {
|
|
function RecursiveAstVisitor() {}
|
|
RecursiveAstVisitor.prototype.visitBinary = function(ast) {
|
|
ast.left.visit(this);
|
|
ast.right.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitChain = function(ast) {
|
|
return this.visitAll(ast.expressions);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitConditional = function(ast) {
|
|
ast.condition.visit(this);
|
|
ast.trueExp.visit(this);
|
|
ast.falseExp.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitPipe = function(ast) {
|
|
ast.exp.visit(this);
|
|
this.visitAll(ast.args);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitFunctionCall = function(ast) {
|
|
ast.target.visit(this);
|
|
this.visitAll(ast.args);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitImplicitReceiver = function(ast) {
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitInterpolation = function(ast) {
|
|
return this.visitAll(ast.expressions);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitKeyedRead = function(ast) {
|
|
ast.obj.visit(this);
|
|
ast.key.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitKeyedWrite = function(ast) {
|
|
ast.obj.visit(this);
|
|
ast.key.visit(this);
|
|
ast.value.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitLiteralArray = function(ast) {
|
|
return this.visitAll(ast.expressions);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitLiteralMap = function(ast) {
|
|
return this.visitAll(ast.values);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitLiteralPrimitive = function(ast) {
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitMethodCall = function(ast) {
|
|
ast.receiver.visit(this);
|
|
return this.visitAll(ast.args);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitPrefixNot = function(ast) {
|
|
ast.expression.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitPropertyRead = function(ast) {
|
|
ast.receiver.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitPropertyWrite = function(ast) {
|
|
ast.receiver.visit(this);
|
|
ast.value.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitSafePropertyRead = function(ast) {
|
|
ast.receiver.visit(this);
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitSafeMethodCall = function(ast) {
|
|
ast.receiver.visit(this);
|
|
return this.visitAll(ast.args);
|
|
};
|
|
RecursiveAstVisitor.prototype.visitAll = function(asts) {
|
|
var _this = this;
|
|
asts.forEach(function(ast) {
|
|
return ast.visit(_this);
|
|
});
|
|
return null;
|
|
};
|
|
RecursiveAstVisitor.prototype.visitQuote = function(ast) {
|
|
return null;
|
|
};
|
|
return RecursiveAstVisitor;
|
|
})();
|
|
exports.RecursiveAstVisitor = RecursiveAstVisitor;
|
|
var AstTransformer = (function() {
|
|
function AstTransformer() {}
|
|
AstTransformer.prototype.visitImplicitReceiver = function(ast) {
|
|
return ast;
|
|
};
|
|
AstTransformer.prototype.visitInterpolation = function(ast) {
|
|
return new Interpolation(ast.strings, this.visitAll(ast.expressions));
|
|
};
|
|
AstTransformer.prototype.visitLiteralPrimitive = function(ast) {
|
|
return new LiteralPrimitive(ast.value);
|
|
};
|
|
AstTransformer.prototype.visitPropertyRead = function(ast) {
|
|
return new PropertyRead(ast.receiver.visit(this), ast.name, ast.getter);
|
|
};
|
|
AstTransformer.prototype.visitPropertyWrite = function(ast) {
|
|
return new PropertyWrite(ast.receiver.visit(this), ast.name, ast.setter, ast.value);
|
|
};
|
|
AstTransformer.prototype.visitSafePropertyRead = function(ast) {
|
|
return new SafePropertyRead(ast.receiver.visit(this), ast.name, ast.getter);
|
|
};
|
|
AstTransformer.prototype.visitMethodCall = function(ast) {
|
|
return new MethodCall(ast.receiver.visit(this), ast.name, ast.fn, this.visitAll(ast.args));
|
|
};
|
|
AstTransformer.prototype.visitSafeMethodCall = function(ast) {
|
|
return new SafeMethodCall(ast.receiver.visit(this), ast.name, ast.fn, this.visitAll(ast.args));
|
|
};
|
|
AstTransformer.prototype.visitFunctionCall = function(ast) {
|
|
return new FunctionCall(ast.target.visit(this), this.visitAll(ast.args));
|
|
};
|
|
AstTransformer.prototype.visitLiteralArray = function(ast) {
|
|
return new LiteralArray(this.visitAll(ast.expressions));
|
|
};
|
|
AstTransformer.prototype.visitLiteralMap = function(ast) {
|
|
return new LiteralMap(ast.keys, this.visitAll(ast.values));
|
|
};
|
|
AstTransformer.prototype.visitBinary = function(ast) {
|
|
return new Binary(ast.operation, ast.left.visit(this), ast.right.visit(this));
|
|
};
|
|
AstTransformer.prototype.visitPrefixNot = function(ast) {
|
|
return new PrefixNot(ast.expression.visit(this));
|
|
};
|
|
AstTransformer.prototype.visitConditional = function(ast) {
|
|
return new Conditional(ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
|
|
};
|
|
AstTransformer.prototype.visitPipe = function(ast) {
|
|
return new BindingPipe(ast.exp.visit(this), ast.name, this.visitAll(ast.args));
|
|
};
|
|
AstTransformer.prototype.visitKeyedRead = function(ast) {
|
|
return new KeyedRead(ast.obj.visit(this), ast.key.visit(this));
|
|
};
|
|
AstTransformer.prototype.visitKeyedWrite = function(ast) {
|
|
return new KeyedWrite(ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
|
|
};
|
|
AstTransformer.prototype.visitAll = function(asts) {
|
|
var res = collection_1.ListWrapper.createFixedSize(asts.length);
|
|
for (var i = 0; i < asts.length; ++i) {
|
|
res[i] = asts[i].visit(this);
|
|
}
|
|
return res;
|
|
};
|
|
AstTransformer.prototype.visitChain = function(ast) {
|
|
return new Chain(this.visitAll(ast.expressions));
|
|
};
|
|
AstTransformer.prototype.visitQuote = function(ast) {
|
|
return new Quote(ast.prefix, ast.uninterpretedExpression, ast.location);
|
|
};
|
|
return AstTransformer;
|
|
})();
|
|
exports.AstTransformer = AstTransformer;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1db", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var EventBinding = (function() {
|
|
function EventBinding(eventName, elIndex, dirIndex, records) {
|
|
this.eventName = eventName;
|
|
this.elIndex = elIndex;
|
|
this.dirIndex = dirIndex;
|
|
this.records = records;
|
|
}
|
|
return EventBinding;
|
|
})();
|
|
exports.EventBinding = EventBinding;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1dc", ["20", "37", "1d9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var proto_record_1 = $__require('1d9');
|
|
function coalesce(srcRecords) {
|
|
var dstRecords = [];
|
|
var excludedIdxs = [];
|
|
var indexMap = new collection_1.Map();
|
|
var skipDepth = 0;
|
|
var skipSources = collection_1.ListWrapper.createFixedSize(srcRecords.length);
|
|
for (var protoIndex = 0; protoIndex < srcRecords.length; protoIndex++) {
|
|
var skipRecord = skipSources[protoIndex];
|
|
if (lang_1.isPresent(skipRecord)) {
|
|
skipDepth--;
|
|
skipRecord.fixedArgs[0] = dstRecords.length;
|
|
}
|
|
var src = srcRecords[protoIndex];
|
|
var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
|
|
if (dst.isSkipRecord()) {
|
|
dstRecords.push(dst);
|
|
skipDepth++;
|
|
skipSources[dst.fixedArgs[0]] = dst;
|
|
} else {
|
|
var record = _mayBeAddRecord(dst, dstRecords, excludedIdxs, skipDepth > 0);
|
|
indexMap.set(src.selfIndex, record.selfIndex);
|
|
}
|
|
}
|
|
return _optimizeSkips(dstRecords);
|
|
}
|
|
exports.coalesce = coalesce;
|
|
function _optimizeSkips(srcRecords) {
|
|
var dstRecords = [];
|
|
var skipSources = collection_1.ListWrapper.createFixedSize(srcRecords.length);
|
|
var indexMap = new collection_1.Map();
|
|
for (var protoIndex = 0; protoIndex < srcRecords.length; protoIndex++) {
|
|
var skipRecord = skipSources[protoIndex];
|
|
if (lang_1.isPresent(skipRecord)) {
|
|
skipRecord.fixedArgs[0] = dstRecords.length;
|
|
}
|
|
var src = srcRecords[protoIndex];
|
|
if (src.isSkipRecord()) {
|
|
if (src.isConditionalSkipRecord() && src.fixedArgs[0] === protoIndex + 2 && protoIndex < srcRecords.length - 1 && srcRecords[protoIndex + 1].mode === proto_record_1.RecordType.SkipRecords) {
|
|
src.mode = src.mode === proto_record_1.RecordType.SkipRecordsIf ? proto_record_1.RecordType.SkipRecordsIfNot : proto_record_1.RecordType.SkipRecordsIf;
|
|
src.fixedArgs[0] = srcRecords[protoIndex + 1].fixedArgs[0];
|
|
protoIndex++;
|
|
}
|
|
if (src.fixedArgs[0] > protoIndex + 1) {
|
|
var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
|
|
dstRecords.push(dst);
|
|
skipSources[dst.fixedArgs[0]] = dst;
|
|
}
|
|
} else {
|
|
var dst = _cloneAndUpdateIndexes(src, dstRecords, indexMap);
|
|
dstRecords.push(dst);
|
|
indexMap.set(src.selfIndex, dst.selfIndex);
|
|
}
|
|
}
|
|
return dstRecords;
|
|
}
|
|
function _mayBeAddRecord(record, dstRecords, excludedIdxs, excluded) {
|
|
var match = _findFirstMatch(record, dstRecords, excludedIdxs);
|
|
if (lang_1.isPresent(match)) {
|
|
if (record.lastInBinding) {
|
|
dstRecords.push(_createSelfRecord(record, match.selfIndex, dstRecords.length + 1));
|
|
match.referencedBySelf = true;
|
|
} else {
|
|
if (record.argumentToPureFunction) {
|
|
match.argumentToPureFunction = true;
|
|
}
|
|
}
|
|
return match;
|
|
}
|
|
if (excluded) {
|
|
excludedIdxs.push(record.selfIndex);
|
|
}
|
|
dstRecords.push(record);
|
|
return record;
|
|
}
|
|
function _findFirstMatch(record, dstRecords, excludedIdxs) {
|
|
return dstRecords.find(function(rr) {
|
|
return excludedIdxs.indexOf(rr.selfIndex) == -1 && rr.mode !== proto_record_1.RecordType.DirectiveLifecycle && _haveSameDirIndex(rr, record) && rr.mode === record.mode && lang_1.looseIdentical(rr.funcOrValue, record.funcOrValue) && rr.contextIndex === record.contextIndex && lang_1.looseIdentical(rr.name, record.name) && collection_1.ListWrapper.equals(rr.args, record.args);
|
|
});
|
|
}
|
|
function _cloneAndUpdateIndexes(record, dstRecords, indexMap) {
|
|
var args = record.args.map(function(src) {
|
|
return _srcToDstSelfIndex(indexMap, src);
|
|
});
|
|
var contextIndex = _srcToDstSelfIndex(indexMap, record.contextIndex);
|
|
var selfIndex = dstRecords.length + 1;
|
|
return new proto_record_1.ProtoRecord(record.mode, record.name, record.funcOrValue, args, record.fixedArgs, contextIndex, record.directiveIndex, selfIndex, record.bindingRecord, record.lastInBinding, record.lastInDirective, record.argumentToPureFunction, record.referencedBySelf, record.propertyBindingIndex);
|
|
}
|
|
function _srcToDstSelfIndex(indexMap, srcIdx) {
|
|
var dstIdx = indexMap.get(srcIdx);
|
|
return lang_1.isPresent(dstIdx) ? dstIdx : srcIdx;
|
|
}
|
|
function _createSelfRecord(r, contextIndex, selfIndex) {
|
|
return new proto_record_1.ProtoRecord(proto_record_1.RecordType.Self, "self", null, [], r.fixedArgs, contextIndex, r.directiveIndex, selfIndex, r.bindingRecord, r.lastInBinding, r.lastInDirective, false, false, r.propertyBindingIndex);
|
|
}
|
|
function _haveSameDirIndex(a, b) {
|
|
var di1 = lang_1.isBlank(a.directiveIndex) ? null : a.directiveIndex.directiveIndex;
|
|
var ei1 = lang_1.isBlank(a.directiveIndex) ? null : a.directiveIndex.elementIndex;
|
|
var di2 = lang_1.isBlank(b.directiveIndex) ? null : b.directiveIndex.directiveIndex;
|
|
var ei2 = lang_1.isBlank(b.directiveIndex) ? null : b.directiveIndex.elementIndex;
|
|
return di1 === di2 && ei1 === ei2;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1dd", ["20", "3c", "37", "1d4", "1de", "1df", "1e0", "1db", "1dc", "1d9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var ast_1 = $__require('1d4');
|
|
var change_detection_util_1 = $__require('1de');
|
|
var dynamic_change_detector_1 = $__require('1df');
|
|
var directive_record_1 = $__require('1e0');
|
|
var event_binding_1 = $__require('1db');
|
|
var coalesce_1 = $__require('1dc');
|
|
var proto_record_1 = $__require('1d9');
|
|
var DynamicProtoChangeDetector = (function() {
|
|
function DynamicProtoChangeDetector(_definition) {
|
|
this._definition = _definition;
|
|
this._propertyBindingRecords = createPropertyRecords(_definition);
|
|
this._eventBindingRecords = createEventRecords(_definition);
|
|
this._propertyBindingTargets = this._definition.bindingRecords.map(function(b) {
|
|
return b.target;
|
|
});
|
|
this._directiveIndices = this._definition.directiveRecords.map(function(d) {
|
|
return d.directiveIndex;
|
|
});
|
|
}
|
|
DynamicProtoChangeDetector.prototype.instantiate = function(dispatcher) {
|
|
return new dynamic_change_detector_1.DynamicChangeDetector(this._definition.id, dispatcher, this._propertyBindingRecords.length, this._propertyBindingTargets, this._directiveIndices, this._definition.strategy, this._propertyBindingRecords, this._eventBindingRecords, this._definition.directiveRecords, this._definition.genConfig);
|
|
};
|
|
return DynamicProtoChangeDetector;
|
|
})();
|
|
exports.DynamicProtoChangeDetector = DynamicProtoChangeDetector;
|
|
function createPropertyRecords(definition) {
|
|
var recordBuilder = new ProtoRecordBuilder();
|
|
collection_1.ListWrapper.forEachWithIndex(definition.bindingRecords, function(b, index) {
|
|
return recordBuilder.add(b, definition.variableNames, index);
|
|
});
|
|
return coalesce_1.coalesce(recordBuilder.records);
|
|
}
|
|
exports.createPropertyRecords = createPropertyRecords;
|
|
function createEventRecords(definition) {
|
|
var varNames = collection_1.ListWrapper.concat(['$event'], definition.variableNames);
|
|
return definition.eventRecords.map(function(er) {
|
|
var records = _ConvertAstIntoProtoRecords.create(er, varNames);
|
|
var dirIndex = er.implicitReceiver instanceof directive_record_1.DirectiveIndex ? er.implicitReceiver : null;
|
|
return new event_binding_1.EventBinding(er.target.name, er.target.elementIndex, dirIndex, records);
|
|
});
|
|
}
|
|
exports.createEventRecords = createEventRecords;
|
|
var ProtoRecordBuilder = (function() {
|
|
function ProtoRecordBuilder() {
|
|
this.records = [];
|
|
}
|
|
ProtoRecordBuilder.prototype.add = function(b, variableNames, bindingIndex) {
|
|
var oldLast = collection_1.ListWrapper.last(this.records);
|
|
if (lang_1.isPresent(oldLast) && oldLast.bindingRecord.directiveRecord == b.directiveRecord) {
|
|
oldLast.lastInDirective = false;
|
|
}
|
|
var numberOfRecordsBefore = this.records.length;
|
|
this._appendRecords(b, variableNames, bindingIndex);
|
|
var newLast = collection_1.ListWrapper.last(this.records);
|
|
if (lang_1.isPresent(newLast) && newLast !== oldLast) {
|
|
newLast.lastInBinding = true;
|
|
newLast.lastInDirective = true;
|
|
this._setArgumentToPureFunction(numberOfRecordsBefore);
|
|
}
|
|
};
|
|
ProtoRecordBuilder.prototype._setArgumentToPureFunction = function(startIndex) {
|
|
var _this = this;
|
|
for (var i = startIndex; i < this.records.length; ++i) {
|
|
var rec = this.records[i];
|
|
if (rec.isPureFunction()) {
|
|
rec.args.forEach(function(recordIndex) {
|
|
return _this.records[recordIndex - 1].argumentToPureFunction = true;
|
|
});
|
|
}
|
|
if (rec.mode === proto_record_1.RecordType.Pipe) {
|
|
rec.args.forEach(function(recordIndex) {
|
|
return _this.records[recordIndex - 1].argumentToPureFunction = true;
|
|
});
|
|
this.records[rec.contextIndex - 1].argumentToPureFunction = true;
|
|
}
|
|
}
|
|
};
|
|
ProtoRecordBuilder.prototype._appendRecords = function(b, variableNames, bindingIndex) {
|
|
if (b.isDirectiveLifecycle()) {
|
|
this.records.push(new proto_record_1.ProtoRecord(proto_record_1.RecordType.DirectiveLifecycle, b.lifecycleEvent, null, [], [], -1, null, this.records.length + 1, b, false, false, false, false, null));
|
|
} else {
|
|
_ConvertAstIntoProtoRecords.append(this.records, b, variableNames, bindingIndex);
|
|
}
|
|
};
|
|
return ProtoRecordBuilder;
|
|
})();
|
|
exports.ProtoRecordBuilder = ProtoRecordBuilder;
|
|
var _ConvertAstIntoProtoRecords = (function() {
|
|
function _ConvertAstIntoProtoRecords(_records, _bindingRecord, _variableNames, _bindingIndex) {
|
|
this._records = _records;
|
|
this._bindingRecord = _bindingRecord;
|
|
this._variableNames = _variableNames;
|
|
this._bindingIndex = _bindingIndex;
|
|
}
|
|
_ConvertAstIntoProtoRecords.append = function(records, b, variableNames, bindingIndex) {
|
|
var c = new _ConvertAstIntoProtoRecords(records, b, variableNames, bindingIndex);
|
|
b.ast.visit(c);
|
|
};
|
|
_ConvertAstIntoProtoRecords.create = function(b, variableNames) {
|
|
var rec = [];
|
|
_ConvertAstIntoProtoRecords.append(rec, b, variableNames, null);
|
|
rec[rec.length - 1].lastInBinding = true;
|
|
return rec;
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitImplicitReceiver = function(ast) {
|
|
return this._bindingRecord.implicitReceiver;
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitInterpolation = function(ast) {
|
|
var args = this._visitAll(ast.expressions);
|
|
return this._addRecord(proto_record_1.RecordType.Interpolate, "interpolate", _interpolationFn(ast.strings), args, ast.strings, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitLiteralPrimitive = function(ast) {
|
|
return this._addRecord(proto_record_1.RecordType.Const, "literal", ast.value, [], null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitPropertyRead = function(ast) {
|
|
var receiver = ast.receiver.visit(this);
|
|
if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name) && ast.receiver instanceof ast_1.ImplicitReceiver) {
|
|
return this._addRecord(proto_record_1.RecordType.Local, ast.name, ast.name, [], null, receiver);
|
|
} else {
|
|
return this._addRecord(proto_record_1.RecordType.PropertyRead, ast.name, ast.getter, [], null, receiver);
|
|
}
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitPropertyWrite = function(ast) {
|
|
if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name) && ast.receiver instanceof ast_1.ImplicitReceiver) {
|
|
throw new exceptions_1.BaseException("Cannot reassign a variable binding " + ast.name);
|
|
} else {
|
|
var receiver = ast.receiver.visit(this);
|
|
var value = ast.value.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.PropertyWrite, ast.name, ast.setter, [value], null, receiver);
|
|
}
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitKeyedWrite = function(ast) {
|
|
var obj = ast.obj.visit(this);
|
|
var key = ast.key.visit(this);
|
|
var value = ast.value.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.KeyedWrite, null, null, [key, value], null, obj);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitSafePropertyRead = function(ast) {
|
|
var receiver = ast.receiver.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.SafeProperty, ast.name, ast.getter, [], null, receiver);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitMethodCall = function(ast) {
|
|
var receiver = ast.receiver.visit(this);
|
|
var args = this._visitAll(ast.args);
|
|
if (lang_1.isPresent(this._variableNames) && collection_1.ListWrapper.contains(this._variableNames, ast.name)) {
|
|
var target = this._addRecord(proto_record_1.RecordType.Local, ast.name, ast.name, [], null, receiver);
|
|
return this._addRecord(proto_record_1.RecordType.InvokeClosure, "closure", null, args, null, target);
|
|
} else {
|
|
return this._addRecord(proto_record_1.RecordType.InvokeMethod, ast.name, ast.fn, args, null, receiver);
|
|
}
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitSafeMethodCall = function(ast) {
|
|
var receiver = ast.receiver.visit(this);
|
|
var args = this._visitAll(ast.args);
|
|
return this._addRecord(proto_record_1.RecordType.SafeMethodInvoke, ast.name, ast.fn, args, null, receiver);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitFunctionCall = function(ast) {
|
|
var target = ast.target.visit(this);
|
|
var args = this._visitAll(ast.args);
|
|
return this._addRecord(proto_record_1.RecordType.InvokeClosure, "closure", null, args, null, target);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitLiteralArray = function(ast) {
|
|
var primitiveName = "arrayFn" + ast.expressions.length;
|
|
return this._addRecord(proto_record_1.RecordType.CollectionLiteral, primitiveName, _arrayFn(ast.expressions.length), this._visitAll(ast.expressions), null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitLiteralMap = function(ast) {
|
|
return this._addRecord(proto_record_1.RecordType.CollectionLiteral, _mapPrimitiveName(ast.keys), change_detection_util_1.ChangeDetectionUtil.mapFn(ast.keys), this._visitAll(ast.values), null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitBinary = function(ast) {
|
|
var left = ast.left.visit(this);
|
|
switch (ast.operation) {
|
|
case '&&':
|
|
var branchEnd = [null];
|
|
this._addRecord(proto_record_1.RecordType.SkipRecordsIfNot, "SkipRecordsIfNot", null, [], branchEnd, left);
|
|
var right = ast.right.visit(this);
|
|
branchEnd[0] = right;
|
|
return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [left, right, left], null, 0);
|
|
case '||':
|
|
var branchEnd = [null];
|
|
this._addRecord(proto_record_1.RecordType.SkipRecordsIf, "SkipRecordsIf", null, [], branchEnd, left);
|
|
var right = ast.right.visit(this);
|
|
branchEnd[0] = right;
|
|
return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [left, left, right], null, 0);
|
|
default:
|
|
var right = ast.right.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.PrimitiveOp, _operationToPrimitiveName(ast.operation), _operationToFunction(ast.operation), [left, right], null, 0);
|
|
}
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitPrefixNot = function(ast) {
|
|
var exp = ast.expression.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "operation_negate", change_detection_util_1.ChangeDetectionUtil.operation_negate, [exp], null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitConditional = function(ast) {
|
|
var condition = ast.condition.visit(this);
|
|
var startOfFalseBranch = [null];
|
|
var endOfFalseBranch = [null];
|
|
this._addRecord(proto_record_1.RecordType.SkipRecordsIfNot, "SkipRecordsIfNot", null, [], startOfFalseBranch, condition);
|
|
var whenTrue = ast.trueExp.visit(this);
|
|
var skip = this._addRecord(proto_record_1.RecordType.SkipRecords, "SkipRecords", null, [], endOfFalseBranch, 0);
|
|
var whenFalse = ast.falseExp.visit(this);
|
|
startOfFalseBranch[0] = skip;
|
|
endOfFalseBranch[0] = whenFalse;
|
|
return this._addRecord(proto_record_1.RecordType.PrimitiveOp, "cond", change_detection_util_1.ChangeDetectionUtil.cond, [condition, whenTrue, whenFalse], null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitPipe = function(ast) {
|
|
var value = ast.exp.visit(this);
|
|
var args = this._visitAll(ast.args);
|
|
return this._addRecord(proto_record_1.RecordType.Pipe, ast.name, ast.name, args, null, value);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitKeyedRead = function(ast) {
|
|
var obj = ast.obj.visit(this);
|
|
var key = ast.key.visit(this);
|
|
return this._addRecord(proto_record_1.RecordType.KeyedRead, "keyedAccess", change_detection_util_1.ChangeDetectionUtil.keyedAccess, [key], null, obj);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitChain = function(ast) {
|
|
var _this = this;
|
|
var args = ast.expressions.map(function(e) {
|
|
return e.visit(_this);
|
|
});
|
|
return this._addRecord(proto_record_1.RecordType.Chain, "chain", null, args, null, 0);
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype.visitQuote = function(ast) {
|
|
throw new exceptions_1.BaseException(("Caught uninterpreted expression at " + ast.location + ": " + ast.uninterpretedExpression + ". ") + ("Expression prefix " + ast.prefix + " did not match a template transformer to interpret the expression."));
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype._visitAll = function(asts) {
|
|
var res = collection_1.ListWrapper.createFixedSize(asts.length);
|
|
for (var i = 0; i < asts.length; ++i) {
|
|
res[i] = asts[i].visit(this);
|
|
}
|
|
return res;
|
|
};
|
|
_ConvertAstIntoProtoRecords.prototype._addRecord = function(type, name, funcOrValue, args, fixedArgs, context) {
|
|
var selfIndex = this._records.length + 1;
|
|
if (context instanceof directive_record_1.DirectiveIndex) {
|
|
this._records.push(new proto_record_1.ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1, context, selfIndex, this._bindingRecord, false, false, false, false, this._bindingIndex));
|
|
} else {
|
|
this._records.push(new proto_record_1.ProtoRecord(type, name, funcOrValue, args, fixedArgs, context, null, selfIndex, this._bindingRecord, false, false, false, false, this._bindingIndex));
|
|
}
|
|
return selfIndex;
|
|
};
|
|
return _ConvertAstIntoProtoRecords;
|
|
})();
|
|
function _arrayFn(length) {
|
|
switch (length) {
|
|
case 0:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn0;
|
|
case 1:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn1;
|
|
case 2:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn2;
|
|
case 3:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn3;
|
|
case 4:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn4;
|
|
case 5:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn5;
|
|
case 6:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn6;
|
|
case 7:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn7;
|
|
case 8:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn8;
|
|
case 9:
|
|
return change_detection_util_1.ChangeDetectionUtil.arrayFn9;
|
|
default:
|
|
throw new exceptions_1.BaseException("Does not support literal maps with more than 9 elements");
|
|
}
|
|
}
|
|
function _mapPrimitiveName(keys) {
|
|
var stringifiedKeys = keys.map(function(k) {
|
|
return lang_1.isString(k) ? "\"" + k + "\"" : "" + k;
|
|
}).join(', ');
|
|
return "mapFn([" + stringifiedKeys + "])";
|
|
}
|
|
function _operationToPrimitiveName(operation) {
|
|
switch (operation) {
|
|
case '+':
|
|
return "operation_add";
|
|
case '-':
|
|
return "operation_subtract";
|
|
case '*':
|
|
return "operation_multiply";
|
|
case '/':
|
|
return "operation_divide";
|
|
case '%':
|
|
return "operation_remainder";
|
|
case '==':
|
|
return "operation_equals";
|
|
case '!=':
|
|
return "operation_not_equals";
|
|
case '===':
|
|
return "operation_identical";
|
|
case '!==':
|
|
return "operation_not_identical";
|
|
case '<':
|
|
return "operation_less_then";
|
|
case '>':
|
|
return "operation_greater_then";
|
|
case '<=':
|
|
return "operation_less_or_equals_then";
|
|
case '>=':
|
|
return "operation_greater_or_equals_then";
|
|
default:
|
|
throw new exceptions_1.BaseException("Unsupported operation " + operation);
|
|
}
|
|
}
|
|
function _operationToFunction(operation) {
|
|
switch (operation) {
|
|
case '+':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_add;
|
|
case '-':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_subtract;
|
|
case '*':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_multiply;
|
|
case '/':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_divide;
|
|
case '%':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_remainder;
|
|
case '==':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_equals;
|
|
case '!=':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_not_equals;
|
|
case '===':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_identical;
|
|
case '!==':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_not_identical;
|
|
case '<':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_less_then;
|
|
case '>':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_greater_then;
|
|
case '<=':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_less_or_equals_then;
|
|
case '>=':
|
|
return change_detection_util_1.ChangeDetectionUtil.operation_greater_or_equals_then;
|
|
default:
|
|
throw new exceptions_1.BaseException("Unsupported operation " + operation);
|
|
}
|
|
}
|
|
function s(v) {
|
|
return lang_1.isPresent(v) ? "" + v : '';
|
|
}
|
|
function _interpolationFn(strings) {
|
|
var length = strings.length;
|
|
var c0 = length > 0 ? strings[0] : null;
|
|
var c1 = length > 1 ? strings[1] : null;
|
|
var c2 = length > 2 ? strings[2] : null;
|
|
var c3 = length > 3 ? strings[3] : null;
|
|
var c4 = length > 4 ? strings[4] : null;
|
|
var c5 = length > 5 ? strings[5] : null;
|
|
var c6 = length > 6 ? strings[6] : null;
|
|
var c7 = length > 7 ? strings[7] : null;
|
|
var c8 = length > 8 ? strings[8] : null;
|
|
var c9 = length > 9 ? strings[9] : null;
|
|
switch (length - 1) {
|
|
case 1:
|
|
return function(a1) {
|
|
return c0 + s(a1) + c1;
|
|
};
|
|
case 2:
|
|
return function(a1, a2) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2;
|
|
};
|
|
case 3:
|
|
return function(a1, a2, a3) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3;
|
|
};
|
|
case 4:
|
|
return function(a1, a2, a3, a4) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4;
|
|
};
|
|
case 5:
|
|
return function(a1, a2, a3, a4, a5) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5;
|
|
};
|
|
case 6:
|
|
return function(a1, a2, a3, a4, a5, a6) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6;
|
|
};
|
|
case 7:
|
|
return function(a1, a2, a3, a4, a5, a6, a7) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7;
|
|
};
|
|
case 8:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7 + s(a8) + c8;
|
|
};
|
|
case 9:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
return c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7 + s(a8) + c8 + s(a9) + c9;
|
|
};
|
|
default:
|
|
throw new exceptions_1.BaseException("Does not support more than 9 expressions");
|
|
}
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("85", ["20", "3c", "37", "1e1", "1de", "1d9", "1d6", "1d7", "1d8", "1da", "1dd"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var abstract_change_detector_1 = $__require('1e1');
|
|
var change_detection_util_1 = $__require('1de');
|
|
var proto_record_1 = $__require('1d9');
|
|
var codegen_name_util_1 = $__require('1d6');
|
|
var codegen_logic_util_1 = $__require('1d7');
|
|
var codegen_facade_1 = $__require('1d8');
|
|
var constants_1 = $__require('1da');
|
|
var proto_change_detector_1 = $__require('1dd');
|
|
var IS_CHANGED_LOCAL = "isChanged";
|
|
var CHANGES_LOCAL = "changes";
|
|
var ChangeDetectorJITGenerator = (function() {
|
|
function ChangeDetectorJITGenerator(definition, changeDetectionUtilVarName, abstractChangeDetectorVarName, changeDetectorStateVarName) {
|
|
this.changeDetectionUtilVarName = changeDetectionUtilVarName;
|
|
this.abstractChangeDetectorVarName = abstractChangeDetectorVarName;
|
|
this.changeDetectorStateVarName = changeDetectorStateVarName;
|
|
var propertyBindingRecords = proto_change_detector_1.createPropertyRecords(definition);
|
|
var eventBindingRecords = proto_change_detector_1.createEventRecords(definition);
|
|
var propertyBindingTargets = definition.bindingRecords.map(function(b) {
|
|
return b.target;
|
|
});
|
|
this.id = definition.id;
|
|
this.changeDetectionStrategy = definition.strategy;
|
|
this.genConfig = definition.genConfig;
|
|
this.records = propertyBindingRecords;
|
|
this.propertyBindingTargets = propertyBindingTargets;
|
|
this.eventBindings = eventBindingRecords;
|
|
this.directiveRecords = definition.directiveRecords;
|
|
this._names = new codegen_name_util_1.CodegenNameUtil(this.records, this.eventBindings, this.directiveRecords, this.changeDetectionUtilVarName);
|
|
this._logic = new codegen_logic_util_1.CodegenLogicUtil(this._names, this.changeDetectionUtilVarName, this.changeDetectorStateVarName, this.changeDetectionStrategy);
|
|
this.typeName = codegen_name_util_1.sanitizeName("ChangeDetector_" + this.id);
|
|
}
|
|
ChangeDetectorJITGenerator.prototype.generate = function() {
|
|
var factorySource = "\n " + this.generateSource() + "\n return function(dispatcher) {\n return new " + this.typeName + "(dispatcher);\n }\n ";
|
|
return new Function(this.abstractChangeDetectorVarName, this.changeDetectionUtilVarName, this.changeDetectorStateVarName, factorySource)(abstract_change_detector_1.AbstractChangeDetector, change_detection_util_1.ChangeDetectionUtil, constants_1.ChangeDetectorState);
|
|
};
|
|
ChangeDetectorJITGenerator.prototype.generateSource = function() {
|
|
return "\n var " + this.typeName + " = function " + this.typeName + "(dispatcher) {\n " + this.abstractChangeDetectorVarName + ".call(\n this, " + JSON.stringify(this.id) + ", dispatcher, " + this.records.length + ",\n " + this.typeName + ".gen_propertyBindingTargets, " + this.typeName + ".gen_directiveIndices,\n " + codegen_facade_1.codify(this.changeDetectionStrategy) + ");\n this.dehydrateDirectives(false);\n }\n\n " + this.typeName + ".prototype = Object.create(" + this.abstractChangeDetectorVarName + ".prototype);\n\n " + this.typeName + ".prototype.detectChangesInRecordsInternal = function(throwOnChange) {\n " + this._names.genInitLocals() + "\n var " + IS_CHANGED_LOCAL + " = false;\n var " + CHANGES_LOCAL + " = null;\n\n " + this._genAllRecords(this.records) + "\n }\n\n " + this._maybeGenHandleEventInternal() + "\n\n " + this._maybeGenAfterContentLifecycleCallbacks() + "\n\n " + this._maybeGenAfterViewLifecycleCallbacks() + "\n\n " + this._maybeGenHydrateDirectives() + "\n\n " + this._maybeGenDehydrateDirectives() + "\n\n " + this._genPropertyBindingTargets() + "\n\n " + this._genDirectiveIndices() + "\n ";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genPropertyBindingTargets = function() {
|
|
var targets = this._logic.genPropertyBindingTargets(this.propertyBindingTargets, this.genConfig.genDebugInfo);
|
|
return this.typeName + ".gen_propertyBindingTargets = " + targets + ";";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genDirectiveIndices = function() {
|
|
var indices = this._logic.genDirectiveIndices(this.directiveRecords);
|
|
return this.typeName + ".gen_directiveIndices = " + indices + ";";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenHandleEventInternal = function() {
|
|
var _this = this;
|
|
if (this.eventBindings.length > 0) {
|
|
var handlers = this.eventBindings.map(function(eb) {
|
|
return _this._genEventBinding(eb);
|
|
}).join("\n");
|
|
return "\n " + this.typeName + ".prototype.handleEventInternal = function(eventName, elIndex, locals) {\n var " + this._names.getPreventDefaultAccesor() + " = false;\n " + this._names.genInitEventLocals() + "\n " + handlers + "\n return " + this._names.getPreventDefaultAccesor() + ";\n }\n ";
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genEventBinding = function(eb) {
|
|
var _this = this;
|
|
var codes = [];
|
|
this._endOfBlockIdxs = [];
|
|
collection_1.ListWrapper.forEachWithIndex(eb.records, function(r, i) {
|
|
var code;
|
|
if (r.isConditionalSkipRecord()) {
|
|
code = _this._genConditionalSkip(r, _this._names.getEventLocalName(eb, i));
|
|
} else if (r.isUnconditionalSkipRecord()) {
|
|
code = _this._genUnconditionalSkip(r);
|
|
} else {
|
|
code = _this._genEventBindingEval(eb, r);
|
|
}
|
|
code += _this._genEndOfSkipBlock(i);
|
|
codes.push(code);
|
|
});
|
|
return "\n if (eventName === \"" + eb.eventName + "\" && elIndex === " + eb.elIndex + ") {\n " + codes.join("\n") + "\n }";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genEventBindingEval = function(eb, r) {
|
|
if (r.lastInBinding) {
|
|
var evalRecord = this._logic.genEventBindingEvalValue(eb, r);
|
|
var markPath = this._genMarkPathToRootAsCheckOnce(r);
|
|
var prevDefault = this._genUpdatePreventDefault(eb, r);
|
|
return evalRecord + "\n" + markPath + "\n" + prevDefault;
|
|
} else {
|
|
return this._logic.genEventBindingEvalValue(eb, r);
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genMarkPathToRootAsCheckOnce = function(r) {
|
|
var br = r.bindingRecord;
|
|
if (br.isDefaultChangeDetection()) {
|
|
return "";
|
|
} else {
|
|
return this._names.getDetectorName(br.directiveRecord.directiveIndex) + ".markPathToRootAsCheckOnce();";
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genUpdatePreventDefault = function(eb, r) {
|
|
var local = this._names.getEventLocalName(eb, r.selfIndex);
|
|
return "if (" + local + " === false) { " + this._names.getPreventDefaultAccesor() + " = true};";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenDehydrateDirectives = function() {
|
|
var destroyPipesCode = this._names.genPipeOnDestroy();
|
|
if (destroyPipesCode) {
|
|
destroyPipesCode = "if (destroyPipes) { " + destroyPipesCode + " }";
|
|
}
|
|
var dehydrateFieldsCode = this._names.genDehydrateFields();
|
|
if (!destroyPipesCode && !dehydrateFieldsCode)
|
|
return '';
|
|
return this.typeName + ".prototype.dehydrateDirectives = function(destroyPipes) {\n " + destroyPipesCode + "\n " + dehydrateFieldsCode + "\n }";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenHydrateDirectives = function() {
|
|
var hydrateDirectivesCode = this._logic.genHydrateDirectives(this.directiveRecords);
|
|
var hydrateDetectorsCode = this._logic.genHydrateDetectors(this.directiveRecords);
|
|
if (!hydrateDirectivesCode && !hydrateDetectorsCode)
|
|
return '';
|
|
return this.typeName + ".prototype.hydrateDirectives = function(directives) {\n " + hydrateDirectivesCode + "\n " + hydrateDetectorsCode + "\n }";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenAfterContentLifecycleCallbacks = function() {
|
|
var notifications = this._logic.genContentLifecycleCallbacks(this.directiveRecords);
|
|
if (notifications.length > 0) {
|
|
var directiveNotifications = notifications.join("\n");
|
|
return "\n " + this.typeName + ".prototype.afterContentLifecycleCallbacksInternal = function() {\n " + directiveNotifications + "\n }\n ";
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenAfterViewLifecycleCallbacks = function() {
|
|
var notifications = this._logic.genViewLifecycleCallbacks(this.directiveRecords);
|
|
if (notifications.length > 0) {
|
|
var directiveNotifications = notifications.join("\n");
|
|
return "\n " + this.typeName + ".prototype.afterViewLifecycleCallbacksInternal = function() {\n " + directiveNotifications + "\n }\n ";
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genAllRecords = function(rs) {
|
|
var codes = [];
|
|
this._endOfBlockIdxs = [];
|
|
for (var i = 0; i < rs.length; i++) {
|
|
var code = void 0;
|
|
var r = rs[i];
|
|
if (r.isLifeCycleRecord()) {
|
|
code = this._genDirectiveLifecycle(r);
|
|
} else if (r.isPipeRecord()) {
|
|
code = this._genPipeCheck(r);
|
|
} else if (r.isConditionalSkipRecord()) {
|
|
code = this._genConditionalSkip(r, this._names.getLocalName(r.contextIndex));
|
|
} else if (r.isUnconditionalSkipRecord()) {
|
|
code = this._genUnconditionalSkip(r);
|
|
} else {
|
|
code = this._genReferenceCheck(r);
|
|
}
|
|
code = "\n " + this._maybeFirstInBinding(r) + "\n " + code + "\n " + this._maybeGenLastInDirective(r) + "\n " + this._genEndOfSkipBlock(i) + "\n ";
|
|
codes.push(code);
|
|
}
|
|
return codes.join("\n");
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genConditionalSkip = function(r, condition) {
|
|
var maybeNegate = r.mode === proto_record_1.RecordType.SkipRecordsIf ? '!' : '';
|
|
this._endOfBlockIdxs.push(r.fixedArgs[0] - 1);
|
|
return "if (" + maybeNegate + condition + ") {";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genUnconditionalSkip = function(r) {
|
|
this._endOfBlockIdxs.pop();
|
|
this._endOfBlockIdxs.push(r.fixedArgs[0] - 1);
|
|
return "} else {";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genEndOfSkipBlock = function(protoIndex) {
|
|
if (!collection_1.ListWrapper.isEmpty(this._endOfBlockIdxs)) {
|
|
var endOfBlock = collection_1.ListWrapper.last(this._endOfBlockIdxs);
|
|
if (protoIndex === endOfBlock) {
|
|
this._endOfBlockIdxs.pop();
|
|
return '}';
|
|
}
|
|
}
|
|
return '';
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genDirectiveLifecycle = function(r) {
|
|
if (r.name === "DoCheck") {
|
|
return this._genOnCheck(r);
|
|
} else if (r.name === "OnInit") {
|
|
return this._genOnInit(r);
|
|
} else if (r.name === "OnChanges") {
|
|
return this._genOnChange(r);
|
|
} else {
|
|
throw new exceptions_1.BaseException("Unknown lifecycle event '" + r.name + "'");
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genPipeCheck = function(r) {
|
|
var _this = this;
|
|
var context = this._names.getLocalName(r.contextIndex);
|
|
var argString = r.args.map(function(arg) {
|
|
return _this._names.getLocalName(arg);
|
|
}).join(", ");
|
|
var oldValue = this._names.getFieldName(r.selfIndex);
|
|
var newValue = this._names.getLocalName(r.selfIndex);
|
|
var pipe = this._names.getPipeName(r.selfIndex);
|
|
var pipeName = r.name;
|
|
var init = "\n if (" + pipe + " === " + this.changeDetectionUtilVarName + ".uninitialized) {\n " + pipe + " = " + this._names.getPipesAccessorName() + ".get('" + pipeName + "');\n }\n ";
|
|
var read = newValue + " = " + pipe + ".pipe.transform(" + context + ", [" + argString + "]);";
|
|
var contexOrArgCheck = r.args.map(function(a) {
|
|
return _this._names.getChangeName(a);
|
|
});
|
|
contexOrArgCheck.push(this._names.getChangeName(r.contextIndex));
|
|
var condition = "!" + pipe + ".pure || (" + contexOrArgCheck.join(" || ") + ")";
|
|
var check = "\n if (" + this.changeDetectionUtilVarName + ".looseNotIdentical(" + oldValue + ", " + newValue + ")) {\n " + newValue + " = " + this.changeDetectionUtilVarName + ".unwrapValue(" + newValue + ")\n " + this._genChangeMarker(r) + "\n " + this._genUpdateDirectiveOrElement(r) + "\n " + this._genAddToChanges(r) + "\n " + oldValue + " = " + newValue + ";\n }\n ";
|
|
var genCode = r.shouldBeChecked() ? "" + read + check : read;
|
|
if (r.isUsedByOtherRecord()) {
|
|
return init + " if (" + condition + ") { " + genCode + " } else { " + newValue + " = " + oldValue + "; }";
|
|
} else {
|
|
return init + " if (" + condition + ") { " + genCode + " }";
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genReferenceCheck = function(r) {
|
|
var _this = this;
|
|
var oldValue = this._names.getFieldName(r.selfIndex);
|
|
var newValue = this._names.getLocalName(r.selfIndex);
|
|
var read = "\n " + this._logic.genPropertyBindingEvalValue(r) + "\n ";
|
|
var check = "\n if (" + this.changeDetectionUtilVarName + ".looseNotIdentical(" + oldValue + ", " + newValue + ")) {\n " + this._genChangeMarker(r) + "\n " + this._genUpdateDirectiveOrElement(r) + "\n " + this._genAddToChanges(r) + "\n " + oldValue + " = " + newValue + ";\n }\n ";
|
|
var genCode = r.shouldBeChecked() ? "" + read + check : read;
|
|
if (r.isPureFunction()) {
|
|
var condition = r.args.map(function(a) {
|
|
return _this._names.getChangeName(a);
|
|
}).join(" || ");
|
|
if (r.isUsedByOtherRecord()) {
|
|
return "if (" + condition + ") { " + genCode + " } else { " + newValue + " = " + oldValue + "; }";
|
|
} else {
|
|
return "if (" + condition + ") { " + genCode + " }";
|
|
}
|
|
} else {
|
|
return genCode;
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genChangeMarker = function(r) {
|
|
return r.argumentToPureFunction ? this._names.getChangeName(r.selfIndex) + " = true" : "";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genUpdateDirectiveOrElement = function(r) {
|
|
if (!r.lastInBinding)
|
|
return "";
|
|
var newValue = this._names.getLocalName(r.selfIndex);
|
|
var oldValue = this._names.getFieldName(r.selfIndex);
|
|
var notifyDebug = this.genConfig.logBindingUpdate ? "this.logBindingUpdate(" + newValue + ");" : "";
|
|
var br = r.bindingRecord;
|
|
if (br.target.isDirective()) {
|
|
var directiveProperty = this._names.getDirectiveName(br.directiveRecord.directiveIndex) + "." + br.target.name;
|
|
return "\n " + this._genThrowOnChangeCheck(oldValue, newValue) + "\n " + directiveProperty + " = " + newValue + ";\n " + notifyDebug + "\n " + IS_CHANGED_LOCAL + " = true;\n ";
|
|
} else {
|
|
return "\n " + this._genThrowOnChangeCheck(oldValue, newValue) + "\n this.notifyDispatcher(" + newValue + ");\n " + notifyDebug + "\n ";
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genThrowOnChangeCheck = function(oldValue, newValue) {
|
|
if (lang_1.assertionsEnabled()) {
|
|
return "\n if(throwOnChange) {\n this.throwOnChangeError(" + oldValue + ", " + newValue + ");\n }\n ";
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genAddToChanges = function(r) {
|
|
var newValue = this._names.getLocalName(r.selfIndex);
|
|
var oldValue = this._names.getFieldName(r.selfIndex);
|
|
if (!r.bindingRecord.callOnChanges())
|
|
return "";
|
|
return CHANGES_LOCAL + " = this.addChange(" + CHANGES_LOCAL + ", " + oldValue + ", " + newValue + ");";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeFirstInBinding = function(r) {
|
|
var prev = change_detection_util_1.ChangeDetectionUtil.protoByIndex(this.records, r.selfIndex - 1);
|
|
var firstInBinding = lang_1.isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
|
|
return firstInBinding && !r.bindingRecord.isDirectiveLifecycle() ? this._names.getPropertyBindingIndex() + " = " + r.propertyBindingIndex + ";" : '';
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._maybeGenLastInDirective = function(r) {
|
|
if (!r.lastInDirective)
|
|
return "";
|
|
return "\n " + CHANGES_LOCAL + " = null;\n " + this._genNotifyOnPushDetectors(r) + "\n " + IS_CHANGED_LOCAL + " = false;\n ";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genOnCheck = function(r) {
|
|
var br = r.bindingRecord;
|
|
return "if (!throwOnChange) " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngDoCheck();";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genOnInit = function(r) {
|
|
var br = r.bindingRecord;
|
|
return "if (!throwOnChange && " + this._names.getStateName() + " === " + this.changeDetectorStateVarName + ".NeverChecked) " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngOnInit();";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genOnChange = function(r) {
|
|
var br = r.bindingRecord;
|
|
return "if (!throwOnChange && " + CHANGES_LOCAL + ") " + this._names.getDirectiveName(br.directiveRecord.directiveIndex) + ".ngOnChanges(" + CHANGES_LOCAL + ");";
|
|
};
|
|
ChangeDetectorJITGenerator.prototype._genNotifyOnPushDetectors = function(r) {
|
|
var br = r.bindingRecord;
|
|
if (!r.lastInDirective || br.isDefaultChangeDetection())
|
|
return "";
|
|
var retVal = "\n if(" + IS_CHANGED_LOCAL + ") {\n " + this._names.getDetectorName(br.directiveRecord.directiveIndex) + ".markAsCheckOnce();\n }\n ";
|
|
return retVal;
|
|
};
|
|
return ChangeDetectorJITGenerator;
|
|
})();
|
|
exports.ChangeDetectorJITGenerator = ChangeDetectorJITGenerator;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e2", ["85"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var change_detection_jit_generator_1 = $__require('85');
|
|
var JitProtoChangeDetector = (function() {
|
|
function JitProtoChangeDetector(definition) {
|
|
this.definition = definition;
|
|
this._factory = this._createFactory(definition);
|
|
}
|
|
JitProtoChangeDetector.isSupported = function() {
|
|
return true;
|
|
};
|
|
JitProtoChangeDetector.prototype.instantiate = function(dispatcher) {
|
|
return this._factory(dispatcher);
|
|
};
|
|
JitProtoChangeDetector.prototype._createFactory = function(definition) {
|
|
return new change_detection_jit_generator_1.ChangeDetectorJITGenerator(definition, 'util', 'AbstractChangeDetector', 'ChangeDetectorStatus').generate();
|
|
};
|
|
return JitProtoChangeDetector;
|
|
})();
|
|
exports.JitProtoChangeDetector = JitProtoChangeDetector;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e3", ["3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var exceptions_1 = $__require('3c');
|
|
var ExpressionChangedAfterItHasBeenCheckedException = (function(_super) {
|
|
__extends(ExpressionChangedAfterItHasBeenCheckedException, _super);
|
|
function ExpressionChangedAfterItHasBeenCheckedException(exp, oldValue, currValue, context) {
|
|
_super.call(this, ("Expression '" + exp + "' has changed after it was checked. ") + ("Previous value: '" + oldValue + "'. Current value: '" + currValue + "'"));
|
|
}
|
|
return ExpressionChangedAfterItHasBeenCheckedException;
|
|
})(exceptions_1.BaseException);
|
|
exports.ExpressionChangedAfterItHasBeenCheckedException = ExpressionChangedAfterItHasBeenCheckedException;
|
|
var ChangeDetectionError = (function(_super) {
|
|
__extends(ChangeDetectionError, _super);
|
|
function ChangeDetectionError(exp, originalException, originalStack, context) {
|
|
_super.call(this, originalException + " in [" + exp + "]", originalException, originalStack, context);
|
|
this.location = exp;
|
|
}
|
|
return ChangeDetectionError;
|
|
})(exceptions_1.WrappedException);
|
|
exports.ChangeDetectionError = ChangeDetectionError;
|
|
var DehydratedException = (function(_super) {
|
|
__extends(DehydratedException, _super);
|
|
function DehydratedException() {
|
|
_super.call(this, 'Attempt to detect changes on a dehydrated detector.');
|
|
}
|
|
return DehydratedException;
|
|
})(exceptions_1.BaseException);
|
|
exports.DehydratedException = DehydratedException;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e4", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var trace;
|
|
var events;
|
|
function detectWTF() {
|
|
var wtf = lang_1.global['wtf'];
|
|
if (wtf) {
|
|
trace = wtf['trace'];
|
|
if (trace) {
|
|
events = trace['events'];
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
exports.detectWTF = detectWTF;
|
|
function createScope(signature, flags) {
|
|
if (flags === void 0) {
|
|
flags = null;
|
|
}
|
|
return events.createScope(signature, flags);
|
|
}
|
|
exports.createScope = createScope;
|
|
function leave(scope, returnValue) {
|
|
trace.leaveScope(scope, returnValue);
|
|
return returnValue;
|
|
}
|
|
exports.leave = leave;
|
|
function startTimeRange(rangeType, action) {
|
|
return trace.beginTimeRange(rangeType, action);
|
|
}
|
|
exports.startTimeRange = startTimeRange;
|
|
function endTimeRange(range) {
|
|
trace.endTimeRange(range);
|
|
}
|
|
exports.endTimeRange = endTimeRange;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4c", ["1e4"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var impl = $__require('1e4');
|
|
exports.wtfEnabled = impl.detectWTF();
|
|
function noopScope(arg0, arg1) {
|
|
return null;
|
|
}
|
|
exports.wtfCreateScope = exports.wtfEnabled ? impl.createScope : function(signature, flags) {
|
|
return noopScope;
|
|
};
|
|
exports.wtfLeave = exports.wtfEnabled ? impl.leave : function(s, r) {
|
|
return r;
|
|
};
|
|
exports.wtfStartTimeRange = exports.wtfEnabled ? impl.startTimeRange : function(rangeType, action) {
|
|
return null;
|
|
};
|
|
exports.wtfEndTimeRange = exports.wtfEnabled ? impl.endTimeRange : function(r) {
|
|
return null;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e5", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function isObservable(value) {
|
|
return false;
|
|
}
|
|
exports.isObservable = isObservable;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e1", ["20", "37", "1de", "1e6", "1e3", "1da", "4c", "1e5"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var collection_1 = $__require('37');
|
|
var change_detection_util_1 = $__require('1de');
|
|
var change_detector_ref_1 = $__require('1e6');
|
|
var exceptions_1 = $__require('1e3');
|
|
var constants_1 = $__require('1da');
|
|
var profile_1 = $__require('4c');
|
|
var observable_facade_1 = $__require('1e5');
|
|
var _scope_check = profile_1.wtfCreateScope("ChangeDetector#check(ascii id, bool throwOnChange)");
|
|
var _Context = (function() {
|
|
function _Context(element, componentElement, context, locals, injector, expression) {
|
|
this.element = element;
|
|
this.componentElement = componentElement;
|
|
this.context = context;
|
|
this.locals = locals;
|
|
this.injector = injector;
|
|
this.expression = expression;
|
|
}
|
|
return _Context;
|
|
})();
|
|
var AbstractChangeDetector = (function() {
|
|
function AbstractChangeDetector(id, dispatcher, numberOfPropertyProtoRecords, bindingTargets, directiveIndices, strategy) {
|
|
this.id = id;
|
|
this.dispatcher = dispatcher;
|
|
this.numberOfPropertyProtoRecords = numberOfPropertyProtoRecords;
|
|
this.bindingTargets = bindingTargets;
|
|
this.directiveIndices = directiveIndices;
|
|
this.strategy = strategy;
|
|
this.contentChildren = [];
|
|
this.viewChildren = [];
|
|
this.state = constants_1.ChangeDetectorState.NeverChecked;
|
|
this.locals = null;
|
|
this.mode = null;
|
|
this.pipes = null;
|
|
this.ref = new change_detector_ref_1.ChangeDetectorRef_(this);
|
|
}
|
|
AbstractChangeDetector.prototype.addContentChild = function(cd) {
|
|
this.contentChildren.push(cd);
|
|
cd.parent = this;
|
|
};
|
|
AbstractChangeDetector.prototype.removeContentChild = function(cd) {
|
|
collection_1.ListWrapper.remove(this.contentChildren, cd);
|
|
};
|
|
AbstractChangeDetector.prototype.addViewChild = function(cd) {
|
|
this.viewChildren.push(cd);
|
|
cd.parent = this;
|
|
};
|
|
AbstractChangeDetector.prototype.removeViewChild = function(cd) {
|
|
collection_1.ListWrapper.remove(this.viewChildren, cd);
|
|
};
|
|
AbstractChangeDetector.prototype.remove = function() {
|
|
this.parent.removeContentChild(this);
|
|
};
|
|
AbstractChangeDetector.prototype.handleEvent = function(eventName, elIndex, locals) {
|
|
var res = this.handleEventInternal(eventName, elIndex, locals);
|
|
this.markPathToRootAsCheckOnce();
|
|
return res;
|
|
};
|
|
AbstractChangeDetector.prototype.handleEventInternal = function(eventName, elIndex, locals) {
|
|
return false;
|
|
};
|
|
AbstractChangeDetector.prototype.detectChanges = function() {
|
|
this.runDetectChanges(false);
|
|
};
|
|
AbstractChangeDetector.prototype.checkNoChanges = function() {
|
|
if (lang_1.assertionsEnabled()) {
|
|
this.runDetectChanges(true);
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype.runDetectChanges = function(throwOnChange) {
|
|
if (this.mode === constants_1.ChangeDetectionStrategy.Detached || this.mode === constants_1.ChangeDetectionStrategy.Checked || this.state === constants_1.ChangeDetectorState.Errored)
|
|
return;
|
|
var s = _scope_check(this.id, throwOnChange);
|
|
this.detectChangesInRecords(throwOnChange);
|
|
this._detectChangesContentChildren(throwOnChange);
|
|
if (!throwOnChange)
|
|
this.afterContentLifecycleCallbacks();
|
|
this._detectChangesInViewChildren(throwOnChange);
|
|
if (!throwOnChange)
|
|
this.afterViewLifecycleCallbacks();
|
|
if (this.mode === constants_1.ChangeDetectionStrategy.CheckOnce)
|
|
this.mode = constants_1.ChangeDetectionStrategy.Checked;
|
|
this.state = constants_1.ChangeDetectorState.CheckedBefore;
|
|
profile_1.wtfLeave(s);
|
|
};
|
|
AbstractChangeDetector.prototype.detectChangesInRecords = function(throwOnChange) {
|
|
if (!this.hydrated()) {
|
|
this.throwDehydratedError();
|
|
}
|
|
try {
|
|
this.detectChangesInRecordsInternal(throwOnChange);
|
|
} catch (e) {
|
|
if (!(e instanceof exceptions_1.ExpressionChangedAfterItHasBeenCheckedException)) {
|
|
this.state = constants_1.ChangeDetectorState.Errored;
|
|
}
|
|
this._throwError(e, e.stack);
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype.detectChangesInRecordsInternal = function(throwOnChange) {};
|
|
AbstractChangeDetector.prototype.hydrate = function(context, locals, directives, pipes) {
|
|
this.mode = change_detection_util_1.ChangeDetectionUtil.changeDetectionMode(this.strategy);
|
|
this.context = context;
|
|
if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
this.observeComponent(context);
|
|
}
|
|
this.locals = locals;
|
|
this.pipes = pipes;
|
|
this.hydrateDirectives(directives);
|
|
this.state = constants_1.ChangeDetectorState.NeverChecked;
|
|
};
|
|
AbstractChangeDetector.prototype.hydrateDirectives = function(directives) {};
|
|
AbstractChangeDetector.prototype.dehydrate = function() {
|
|
this.dehydrateDirectives(true);
|
|
if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
this._unsubsribeFromObservables();
|
|
}
|
|
this.context = null;
|
|
this.locals = null;
|
|
this.pipes = null;
|
|
};
|
|
AbstractChangeDetector.prototype.dehydrateDirectives = function(destroyPipes) {};
|
|
AbstractChangeDetector.prototype.hydrated = function() {
|
|
return lang_1.isPresent(this.context);
|
|
};
|
|
AbstractChangeDetector.prototype.afterContentLifecycleCallbacks = function() {
|
|
this.dispatcher.notifyAfterContentChecked();
|
|
this.afterContentLifecycleCallbacksInternal();
|
|
};
|
|
AbstractChangeDetector.prototype.afterContentLifecycleCallbacksInternal = function() {};
|
|
AbstractChangeDetector.prototype.afterViewLifecycleCallbacks = function() {
|
|
this.dispatcher.notifyAfterViewChecked();
|
|
this.afterViewLifecycleCallbacksInternal();
|
|
};
|
|
AbstractChangeDetector.prototype.afterViewLifecycleCallbacksInternal = function() {};
|
|
AbstractChangeDetector.prototype._detectChangesContentChildren = function(throwOnChange) {
|
|
var c = this.contentChildren;
|
|
for (var i = 0; i < c.length; ++i) {
|
|
c[i].runDetectChanges(throwOnChange);
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype._detectChangesInViewChildren = function(throwOnChange) {
|
|
var c = this.viewChildren;
|
|
for (var i = 0; i < c.length; ++i) {
|
|
c[i].runDetectChanges(throwOnChange);
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype.markAsCheckOnce = function() {
|
|
this.mode = constants_1.ChangeDetectionStrategy.CheckOnce;
|
|
};
|
|
AbstractChangeDetector.prototype.markPathToRootAsCheckOnce = function() {
|
|
var c = this;
|
|
while (lang_1.isPresent(c) && c.mode !== constants_1.ChangeDetectionStrategy.Detached) {
|
|
if (c.mode === constants_1.ChangeDetectionStrategy.Checked)
|
|
c.mode = constants_1.ChangeDetectionStrategy.CheckOnce;
|
|
c = c.parent;
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype._unsubsribeFromObservables = function() {
|
|
if (lang_1.isPresent(this.subscriptions)) {
|
|
for (var i = 0; i < this.subscriptions.length; ++i) {
|
|
var s = this.subscriptions[i];
|
|
if (lang_1.isPresent(this.subscriptions[i])) {
|
|
s.cancel();
|
|
this.subscriptions[i] = null;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype.observeValue = function(value, index) {
|
|
var _this = this;
|
|
if (observable_facade_1.isObservable(value)) {
|
|
this._createArrayToStoreObservables();
|
|
if (lang_1.isBlank(this.subscriptions[index])) {
|
|
this.streams[index] = value.changes;
|
|
this.subscriptions[index] = value.changes.listen(function(_) {
|
|
return _this.ref.markForCheck();
|
|
});
|
|
} else if (this.streams[index] !== value.changes) {
|
|
this.subscriptions[index].cancel();
|
|
this.streams[index] = value.changes;
|
|
this.subscriptions[index] = value.changes.listen(function(_) {
|
|
return _this.ref.markForCheck();
|
|
});
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
AbstractChangeDetector.prototype.observeDirective = function(value, index) {
|
|
var _this = this;
|
|
if (observable_facade_1.isObservable(value)) {
|
|
this._createArrayToStoreObservables();
|
|
var arrayIndex = this.numberOfPropertyProtoRecords + index + 2;
|
|
this.streams[arrayIndex] = value.changes;
|
|
this.subscriptions[arrayIndex] = value.changes.listen(function(_) {
|
|
return _this.ref.markForCheck();
|
|
});
|
|
}
|
|
return value;
|
|
};
|
|
AbstractChangeDetector.prototype.observeComponent = function(value) {
|
|
var _this = this;
|
|
if (observable_facade_1.isObservable(value)) {
|
|
this._createArrayToStoreObservables();
|
|
var index = this.numberOfPropertyProtoRecords + 1;
|
|
this.streams[index] = value.changes;
|
|
this.subscriptions[index] = value.changes.listen(function(_) {
|
|
return _this.ref.markForCheck();
|
|
});
|
|
}
|
|
return value;
|
|
};
|
|
AbstractChangeDetector.prototype._createArrayToStoreObservables = function() {
|
|
if (lang_1.isBlank(this.subscriptions)) {
|
|
this.subscriptions = collection_1.ListWrapper.createFixedSize(this.numberOfPropertyProtoRecords + this.directiveIndices.length + 2);
|
|
this.streams = collection_1.ListWrapper.createFixedSize(this.numberOfPropertyProtoRecords + this.directiveIndices.length + 2);
|
|
}
|
|
};
|
|
AbstractChangeDetector.prototype.getDirectiveFor = function(directives, index) {
|
|
return directives.getDirectiveFor(this.directiveIndices[index]);
|
|
};
|
|
AbstractChangeDetector.prototype.getDetectorFor = function(directives, index) {
|
|
return directives.getDetectorFor(this.directiveIndices[index]);
|
|
};
|
|
AbstractChangeDetector.prototype.notifyDispatcher = function(value) {
|
|
this.dispatcher.notifyOnBinding(this._currentBinding(), value);
|
|
};
|
|
AbstractChangeDetector.prototype.logBindingUpdate = function(value) {
|
|
this.dispatcher.logBindingUpdate(this._currentBinding(), value);
|
|
};
|
|
AbstractChangeDetector.prototype.addChange = function(changes, oldValue, newValue) {
|
|
if (lang_1.isBlank(changes)) {
|
|
changes = {};
|
|
}
|
|
changes[this._currentBinding().name] = change_detection_util_1.ChangeDetectionUtil.simpleChange(oldValue, newValue);
|
|
return changes;
|
|
};
|
|
AbstractChangeDetector.prototype._throwError = function(exception, stack) {
|
|
var error;
|
|
try {
|
|
var c = this.dispatcher.getDebugContext(this._currentBinding().elementIndex, null);
|
|
var context = lang_1.isPresent(c) ? new _Context(c.element, c.componentElement, c.context, c.locals, c.injector, this._currentBinding().debug) : null;
|
|
error = new exceptions_1.ChangeDetectionError(this._currentBinding().debug, exception, stack, context);
|
|
} catch (e) {
|
|
error = new exceptions_1.ChangeDetectionError(null, exception, stack, null);
|
|
}
|
|
throw error;
|
|
};
|
|
AbstractChangeDetector.prototype.throwOnChangeError = function(oldValue, newValue) {
|
|
throw new exceptions_1.ExpressionChangedAfterItHasBeenCheckedException(this._currentBinding().debug, oldValue, newValue, null);
|
|
};
|
|
AbstractChangeDetector.prototype.throwDehydratedError = function() {
|
|
throw new exceptions_1.DehydratedException();
|
|
};
|
|
AbstractChangeDetector.prototype._currentBinding = function() {
|
|
return this.bindingTargets[this.propertyBindingIndex];
|
|
};
|
|
return AbstractChangeDetector;
|
|
})();
|
|
exports.AbstractChangeDetector = AbstractChangeDetector;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d9", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(RecordType) {
|
|
RecordType[RecordType["Self"] = 0] = "Self";
|
|
RecordType[RecordType["Const"] = 1] = "Const";
|
|
RecordType[RecordType["PrimitiveOp"] = 2] = "PrimitiveOp";
|
|
RecordType[RecordType["PropertyRead"] = 3] = "PropertyRead";
|
|
RecordType[RecordType["PropertyWrite"] = 4] = "PropertyWrite";
|
|
RecordType[RecordType["Local"] = 5] = "Local";
|
|
RecordType[RecordType["InvokeMethod"] = 6] = "InvokeMethod";
|
|
RecordType[RecordType["InvokeClosure"] = 7] = "InvokeClosure";
|
|
RecordType[RecordType["KeyedRead"] = 8] = "KeyedRead";
|
|
RecordType[RecordType["KeyedWrite"] = 9] = "KeyedWrite";
|
|
RecordType[RecordType["Pipe"] = 10] = "Pipe";
|
|
RecordType[RecordType["Interpolate"] = 11] = "Interpolate";
|
|
RecordType[RecordType["SafeProperty"] = 12] = "SafeProperty";
|
|
RecordType[RecordType["CollectionLiteral"] = 13] = "CollectionLiteral";
|
|
RecordType[RecordType["SafeMethodInvoke"] = 14] = "SafeMethodInvoke";
|
|
RecordType[RecordType["DirectiveLifecycle"] = 15] = "DirectiveLifecycle";
|
|
RecordType[RecordType["Chain"] = 16] = "Chain";
|
|
RecordType[RecordType["SkipRecordsIf"] = 17] = "SkipRecordsIf";
|
|
RecordType[RecordType["SkipRecordsIfNot"] = 18] = "SkipRecordsIfNot";
|
|
RecordType[RecordType["SkipRecords"] = 19] = "SkipRecords";
|
|
})(exports.RecordType || (exports.RecordType = {}));
|
|
var RecordType = exports.RecordType;
|
|
var ProtoRecord = (function() {
|
|
function ProtoRecord(mode, name, funcOrValue, args, fixedArgs, contextIndex, directiveIndex, selfIndex, bindingRecord, lastInBinding, lastInDirective, argumentToPureFunction, referencedBySelf, propertyBindingIndex) {
|
|
this.mode = mode;
|
|
this.name = name;
|
|
this.funcOrValue = funcOrValue;
|
|
this.args = args;
|
|
this.fixedArgs = fixedArgs;
|
|
this.contextIndex = contextIndex;
|
|
this.directiveIndex = directiveIndex;
|
|
this.selfIndex = selfIndex;
|
|
this.bindingRecord = bindingRecord;
|
|
this.lastInBinding = lastInBinding;
|
|
this.lastInDirective = lastInDirective;
|
|
this.argumentToPureFunction = argumentToPureFunction;
|
|
this.referencedBySelf = referencedBySelf;
|
|
this.propertyBindingIndex = propertyBindingIndex;
|
|
}
|
|
ProtoRecord.prototype.isPureFunction = function() {
|
|
return this.mode === RecordType.Interpolate || this.mode === RecordType.CollectionLiteral;
|
|
};
|
|
ProtoRecord.prototype.isUsedByOtherRecord = function() {
|
|
return !this.lastInBinding || this.referencedBySelf;
|
|
};
|
|
ProtoRecord.prototype.shouldBeChecked = function() {
|
|
return this.argumentToPureFunction || this.lastInBinding || this.isPureFunction() || this.isPipeRecord();
|
|
};
|
|
ProtoRecord.prototype.isPipeRecord = function() {
|
|
return this.mode === RecordType.Pipe;
|
|
};
|
|
ProtoRecord.prototype.isConditionalSkipRecord = function() {
|
|
return this.mode === RecordType.SkipRecordsIfNot || this.mode === RecordType.SkipRecordsIf;
|
|
};
|
|
ProtoRecord.prototype.isUnconditionalSkipRecord = function() {
|
|
return this.mode === RecordType.SkipRecords;
|
|
};
|
|
ProtoRecord.prototype.isSkipRecord = function() {
|
|
return this.isConditionalSkipRecord() || this.isUnconditionalSkipRecord();
|
|
};
|
|
ProtoRecord.prototype.isLifeCycleRecord = function() {
|
|
return this.mode === RecordType.DirectiveLifecycle;
|
|
};
|
|
return ProtoRecord;
|
|
})();
|
|
exports.ProtoRecord = ProtoRecord;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1df", ["20", "3c", "37", "1e1", "1de", "1da", "1d9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var abstract_change_detector_1 = $__require('1e1');
|
|
var change_detection_util_1 = $__require('1de');
|
|
var constants_1 = $__require('1da');
|
|
var proto_record_1 = $__require('1d9');
|
|
var DynamicChangeDetector = (function(_super) {
|
|
__extends(DynamicChangeDetector, _super);
|
|
function DynamicChangeDetector(id, dispatcher, numberOfPropertyProtoRecords, propertyBindingTargets, directiveIndices, strategy, _records, _eventBindings, _directiveRecords, _genConfig) {
|
|
_super.call(this, id, dispatcher, numberOfPropertyProtoRecords, propertyBindingTargets, directiveIndices, strategy);
|
|
this._records = _records;
|
|
this._eventBindings = _eventBindings;
|
|
this._directiveRecords = _directiveRecords;
|
|
this._genConfig = _genConfig;
|
|
this.directives = null;
|
|
var len = _records.length + 1;
|
|
this.values = collection_1.ListWrapper.createFixedSize(len);
|
|
this.localPipes = collection_1.ListWrapper.createFixedSize(len);
|
|
this.prevContexts = collection_1.ListWrapper.createFixedSize(len);
|
|
this.changes = collection_1.ListWrapper.createFixedSize(len);
|
|
this.dehydrateDirectives(false);
|
|
}
|
|
DynamicChangeDetector.prototype.handleEventInternal = function(eventName, elIndex, locals) {
|
|
var _this = this;
|
|
var preventDefault = false;
|
|
this._matchingEventBindings(eventName, elIndex).forEach(function(rec) {
|
|
var res = _this._processEventBinding(rec, locals);
|
|
if (res === false) {
|
|
preventDefault = true;
|
|
}
|
|
});
|
|
return preventDefault;
|
|
};
|
|
DynamicChangeDetector.prototype._processEventBinding = function(eb, locals) {
|
|
var values = collection_1.ListWrapper.createFixedSize(eb.records.length);
|
|
values[0] = this.values[0];
|
|
for (var protoIdx = 0; protoIdx < eb.records.length; ++protoIdx) {
|
|
var proto = eb.records[protoIdx];
|
|
if (proto.isSkipRecord()) {
|
|
protoIdx += this._computeSkipLength(protoIdx, proto, values);
|
|
} else {
|
|
var res = this._calculateCurrValue(proto, values, locals);
|
|
if (proto.lastInBinding) {
|
|
this._markPathAsCheckOnce(proto);
|
|
return res;
|
|
} else {
|
|
this._writeSelf(proto, res, values);
|
|
}
|
|
}
|
|
}
|
|
throw new exceptions_1.BaseException("Cannot be reached");
|
|
};
|
|
DynamicChangeDetector.prototype._computeSkipLength = function(protoIndex, proto, values) {
|
|
if (proto.mode === proto_record_1.RecordType.SkipRecords) {
|
|
return proto.fixedArgs[0] - protoIndex - 1;
|
|
}
|
|
if (proto.mode === proto_record_1.RecordType.SkipRecordsIf) {
|
|
var condition = this._readContext(proto, values);
|
|
return condition ? proto.fixedArgs[0] - protoIndex - 1 : 0;
|
|
}
|
|
if (proto.mode === proto_record_1.RecordType.SkipRecordsIfNot) {
|
|
var condition = this._readContext(proto, values);
|
|
return condition ? 0 : proto.fixedArgs[0] - protoIndex - 1;
|
|
}
|
|
throw new exceptions_1.BaseException("Cannot be reached");
|
|
};
|
|
DynamicChangeDetector.prototype._markPathAsCheckOnce = function(proto) {
|
|
if (!proto.bindingRecord.isDefaultChangeDetection()) {
|
|
var dir = proto.bindingRecord.directiveRecord;
|
|
this._getDetectorFor(dir.directiveIndex).markPathToRootAsCheckOnce();
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._matchingEventBindings = function(eventName, elIndex) {
|
|
return this._eventBindings.filter(function(eb) {
|
|
return eb.eventName == eventName && eb.elIndex === elIndex;
|
|
});
|
|
};
|
|
DynamicChangeDetector.prototype.hydrateDirectives = function(directives) {
|
|
this.values[0] = this.context;
|
|
this.directives = directives;
|
|
if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
for (var i = 0; i < this.directiveIndices.length; ++i) {
|
|
var index = this.directiveIndices[i];
|
|
_super.prototype.observeDirective.call(this, directives.getDirectiveFor(index), i);
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype.dehydrateDirectives = function(destroyPipes) {
|
|
if (destroyPipes) {
|
|
this._destroyPipes();
|
|
}
|
|
this.values[0] = null;
|
|
this.directives = null;
|
|
collection_1.ListWrapper.fill(this.values, change_detection_util_1.ChangeDetectionUtil.uninitialized, 1);
|
|
collection_1.ListWrapper.fill(this.changes, false);
|
|
collection_1.ListWrapper.fill(this.localPipes, null);
|
|
collection_1.ListWrapper.fill(this.prevContexts, change_detection_util_1.ChangeDetectionUtil.uninitialized);
|
|
};
|
|
DynamicChangeDetector.prototype._destroyPipes = function() {
|
|
for (var i = 0; i < this.localPipes.length; ++i) {
|
|
if (lang_1.isPresent(this.localPipes[i])) {
|
|
change_detection_util_1.ChangeDetectionUtil.callPipeOnDestroy(this.localPipes[i]);
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype.checkNoChanges = function() {
|
|
this.runDetectChanges(true);
|
|
};
|
|
DynamicChangeDetector.prototype.detectChangesInRecordsInternal = function(throwOnChange) {
|
|
var protos = this._records;
|
|
var changes = null;
|
|
var isChanged = false;
|
|
for (var protoIdx = 0; protoIdx < protos.length; ++protoIdx) {
|
|
var proto = protos[protoIdx];
|
|
var bindingRecord = proto.bindingRecord;
|
|
var directiveRecord = bindingRecord.directiveRecord;
|
|
if (this._firstInBinding(proto)) {
|
|
this.propertyBindingIndex = proto.propertyBindingIndex;
|
|
}
|
|
if (proto.isLifeCycleRecord()) {
|
|
if (proto.name === "DoCheck" && !throwOnChange) {
|
|
this._getDirectiveFor(directiveRecord.directiveIndex).ngDoCheck();
|
|
} else if (proto.name === "OnInit" && !throwOnChange && this.state == constants_1.ChangeDetectorState.NeverChecked) {
|
|
this._getDirectiveFor(directiveRecord.directiveIndex).ngOnInit();
|
|
} else if (proto.name === "OnChanges" && lang_1.isPresent(changes) && !throwOnChange) {
|
|
this._getDirectiveFor(directiveRecord.directiveIndex).ngOnChanges(changes);
|
|
}
|
|
} else if (proto.isSkipRecord()) {
|
|
protoIdx += this._computeSkipLength(protoIdx, proto, this.values);
|
|
} else {
|
|
var change = this._check(proto, throwOnChange, this.values, this.locals);
|
|
if (lang_1.isPresent(change)) {
|
|
this._updateDirectiveOrElement(change, bindingRecord);
|
|
isChanged = true;
|
|
changes = this._addChange(bindingRecord, change, changes);
|
|
}
|
|
}
|
|
if (proto.lastInDirective) {
|
|
changes = null;
|
|
if (isChanged && !bindingRecord.isDefaultChangeDetection()) {
|
|
this._getDetectorFor(directiveRecord.directiveIndex).markAsCheckOnce();
|
|
}
|
|
isChanged = false;
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._firstInBinding = function(r) {
|
|
var prev = change_detection_util_1.ChangeDetectionUtil.protoByIndex(this._records, r.selfIndex - 1);
|
|
return lang_1.isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
|
|
};
|
|
DynamicChangeDetector.prototype.afterContentLifecycleCallbacksInternal = function() {
|
|
var dirs = this._directiveRecords;
|
|
for (var i = dirs.length - 1; i >= 0; --i) {
|
|
var dir = dirs[i];
|
|
if (dir.callAfterContentInit && this.state == constants_1.ChangeDetectorState.NeverChecked) {
|
|
this._getDirectiveFor(dir.directiveIndex).ngAfterContentInit();
|
|
}
|
|
if (dir.callAfterContentChecked) {
|
|
this._getDirectiveFor(dir.directiveIndex).ngAfterContentChecked();
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype.afterViewLifecycleCallbacksInternal = function() {
|
|
var dirs = this._directiveRecords;
|
|
for (var i = dirs.length - 1; i >= 0; --i) {
|
|
var dir = dirs[i];
|
|
if (dir.callAfterViewInit && this.state == constants_1.ChangeDetectorState.NeverChecked) {
|
|
this._getDirectiveFor(dir.directiveIndex).ngAfterViewInit();
|
|
}
|
|
if (dir.callAfterViewChecked) {
|
|
this._getDirectiveFor(dir.directiveIndex).ngAfterViewChecked();
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._updateDirectiveOrElement = function(change, bindingRecord) {
|
|
if (lang_1.isBlank(bindingRecord.directiveRecord)) {
|
|
_super.prototype.notifyDispatcher.call(this, change.currentValue);
|
|
} else {
|
|
var directiveIndex = bindingRecord.directiveRecord.directiveIndex;
|
|
bindingRecord.setter(this._getDirectiveFor(directiveIndex), change.currentValue);
|
|
}
|
|
if (this._genConfig.logBindingUpdate) {
|
|
_super.prototype.logBindingUpdate.call(this, change.currentValue);
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._addChange = function(bindingRecord, change, changes) {
|
|
if (bindingRecord.callOnChanges()) {
|
|
return _super.prototype.addChange.call(this, changes, change.previousValue, change.currentValue);
|
|
} else {
|
|
return changes;
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._getDirectiveFor = function(directiveIndex) {
|
|
return this.directives.getDirectiveFor(directiveIndex);
|
|
};
|
|
DynamicChangeDetector.prototype._getDetectorFor = function(directiveIndex) {
|
|
return this.directives.getDetectorFor(directiveIndex);
|
|
};
|
|
DynamicChangeDetector.prototype._check = function(proto, throwOnChange, values, locals) {
|
|
if (proto.isPipeRecord()) {
|
|
return this._pipeCheck(proto, throwOnChange, values);
|
|
} else {
|
|
return this._referenceCheck(proto, throwOnChange, values, locals);
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._referenceCheck = function(proto, throwOnChange, values, locals) {
|
|
if (this._pureFuncAndArgsDidNotChange(proto)) {
|
|
this._setChanged(proto, false);
|
|
return null;
|
|
}
|
|
var currValue = this._calculateCurrValue(proto, values, locals);
|
|
if (this.strategy === constants_1.ChangeDetectionStrategy.OnPushObserve) {
|
|
_super.prototype.observeValue.call(this, currValue, proto.selfIndex);
|
|
}
|
|
if (proto.shouldBeChecked()) {
|
|
var prevValue = this._readSelf(proto, values);
|
|
if (change_detection_util_1.ChangeDetectionUtil.looseNotIdentical(prevValue, currValue)) {
|
|
if (proto.lastInBinding) {
|
|
var change = change_detection_util_1.ChangeDetectionUtil.simpleChange(prevValue, currValue);
|
|
if (throwOnChange)
|
|
this.throwOnChangeError(prevValue, currValue);
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return change;
|
|
} else {
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return null;
|
|
}
|
|
} else {
|
|
this._setChanged(proto, false);
|
|
return null;
|
|
}
|
|
} else {
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return null;
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._calculateCurrValue = function(proto, values, locals) {
|
|
switch (proto.mode) {
|
|
case proto_record_1.RecordType.Self:
|
|
return this._readContext(proto, values);
|
|
case proto_record_1.RecordType.Const:
|
|
return proto.funcOrValue;
|
|
case proto_record_1.RecordType.PropertyRead:
|
|
var context = this._readContext(proto, values);
|
|
return proto.funcOrValue(context);
|
|
case proto_record_1.RecordType.SafeProperty:
|
|
var context = this._readContext(proto, values);
|
|
return lang_1.isBlank(context) ? null : proto.funcOrValue(context);
|
|
case proto_record_1.RecordType.PropertyWrite:
|
|
var context = this._readContext(proto, values);
|
|
var value = this._readArgs(proto, values)[0];
|
|
proto.funcOrValue(context, value);
|
|
return value;
|
|
case proto_record_1.RecordType.KeyedWrite:
|
|
var context = this._readContext(proto, values);
|
|
var key = this._readArgs(proto, values)[0];
|
|
var value = this._readArgs(proto, values)[1];
|
|
context[key] = value;
|
|
return value;
|
|
case proto_record_1.RecordType.Local:
|
|
return locals.get(proto.name);
|
|
case proto_record_1.RecordType.InvokeMethod:
|
|
var context = this._readContext(proto, values);
|
|
var args = this._readArgs(proto, values);
|
|
return proto.funcOrValue(context, args);
|
|
case proto_record_1.RecordType.SafeMethodInvoke:
|
|
var context = this._readContext(proto, values);
|
|
if (lang_1.isBlank(context)) {
|
|
return null;
|
|
}
|
|
var args = this._readArgs(proto, values);
|
|
return proto.funcOrValue(context, args);
|
|
case proto_record_1.RecordType.KeyedRead:
|
|
var arg = this._readArgs(proto, values)[0];
|
|
return this._readContext(proto, values)[arg];
|
|
case proto_record_1.RecordType.Chain:
|
|
var args = this._readArgs(proto, values);
|
|
return args[args.length - 1];
|
|
case proto_record_1.RecordType.InvokeClosure:
|
|
return lang_1.FunctionWrapper.apply(this._readContext(proto, values), this._readArgs(proto, values));
|
|
case proto_record_1.RecordType.Interpolate:
|
|
case proto_record_1.RecordType.PrimitiveOp:
|
|
case proto_record_1.RecordType.CollectionLiteral:
|
|
return lang_1.FunctionWrapper.apply(proto.funcOrValue, this._readArgs(proto, values));
|
|
default:
|
|
throw new exceptions_1.BaseException("Unknown operation " + proto.mode);
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._pipeCheck = function(proto, throwOnChange, values) {
|
|
var context = this._readContext(proto, values);
|
|
var selectedPipe = this._pipeFor(proto, context);
|
|
if (!selectedPipe.pure || this._argsOrContextChanged(proto)) {
|
|
var args = this._readArgs(proto, values);
|
|
var currValue = selectedPipe.pipe.transform(context, args);
|
|
if (proto.shouldBeChecked()) {
|
|
var prevValue = this._readSelf(proto, values);
|
|
if (change_detection_util_1.ChangeDetectionUtil.looseNotIdentical(prevValue, currValue)) {
|
|
currValue = change_detection_util_1.ChangeDetectionUtil.unwrapValue(currValue);
|
|
if (proto.lastInBinding) {
|
|
var change = change_detection_util_1.ChangeDetectionUtil.simpleChange(prevValue, currValue);
|
|
if (throwOnChange)
|
|
this.throwOnChangeError(prevValue, currValue);
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return change;
|
|
} else {
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return null;
|
|
}
|
|
} else {
|
|
this._setChanged(proto, false);
|
|
return null;
|
|
}
|
|
} else {
|
|
this._writeSelf(proto, currValue, values);
|
|
this._setChanged(proto, true);
|
|
return null;
|
|
}
|
|
}
|
|
};
|
|
DynamicChangeDetector.prototype._pipeFor = function(proto, context) {
|
|
var storedPipe = this._readPipe(proto);
|
|
if (lang_1.isPresent(storedPipe))
|
|
return storedPipe;
|
|
var pipe = this.pipes.get(proto.name);
|
|
this._writePipe(proto, pipe);
|
|
return pipe;
|
|
};
|
|
DynamicChangeDetector.prototype._readContext = function(proto, values) {
|
|
if (proto.contextIndex == -1) {
|
|
return this._getDirectiveFor(proto.directiveIndex);
|
|
}
|
|
return values[proto.contextIndex];
|
|
};
|
|
DynamicChangeDetector.prototype._readSelf = function(proto, values) {
|
|
return values[proto.selfIndex];
|
|
};
|
|
DynamicChangeDetector.prototype._writeSelf = function(proto, value, values) {
|
|
values[proto.selfIndex] = value;
|
|
};
|
|
DynamicChangeDetector.prototype._readPipe = function(proto) {
|
|
return this.localPipes[proto.selfIndex];
|
|
};
|
|
DynamicChangeDetector.prototype._writePipe = function(proto, value) {
|
|
this.localPipes[proto.selfIndex] = value;
|
|
};
|
|
DynamicChangeDetector.prototype._setChanged = function(proto, value) {
|
|
if (proto.argumentToPureFunction)
|
|
this.changes[proto.selfIndex] = value;
|
|
};
|
|
DynamicChangeDetector.prototype._pureFuncAndArgsDidNotChange = function(proto) {
|
|
return proto.isPureFunction() && !this._argsChanged(proto);
|
|
};
|
|
DynamicChangeDetector.prototype._argsChanged = function(proto) {
|
|
var args = proto.args;
|
|
for (var i = 0; i < args.length; ++i) {
|
|
if (this.changes[args[i]]) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
DynamicChangeDetector.prototype._argsOrContextChanged = function(proto) {
|
|
return this._argsChanged(proto) || this.changes[proto.contextIndex];
|
|
};
|
|
DynamicChangeDetector.prototype._readArgs = function(proto, values) {
|
|
var res = collection_1.ListWrapper.createFixedSize(proto.args.length);
|
|
var args = proto.args;
|
|
for (var i = 0; i < args.length; ++i) {
|
|
res[i] = values[args[i]];
|
|
}
|
|
return res;
|
|
};
|
|
return DynamicChangeDetector;
|
|
})(abstract_change_detector_1.AbstractChangeDetector);
|
|
exports.DynamicChangeDetector = DynamicChangeDetector;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e6", ["1da"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var constants_1 = $__require('1da');
|
|
var ChangeDetectorRef = (function() {
|
|
function ChangeDetectorRef() {}
|
|
return ChangeDetectorRef;
|
|
})();
|
|
exports.ChangeDetectorRef = ChangeDetectorRef;
|
|
var ChangeDetectorRef_ = (function(_super) {
|
|
__extends(ChangeDetectorRef_, _super);
|
|
function ChangeDetectorRef_(_cd) {
|
|
_super.call(this);
|
|
this._cd = _cd;
|
|
}
|
|
ChangeDetectorRef_.prototype.markForCheck = function() {
|
|
this._cd.markPathToRootAsCheckOnce();
|
|
};
|
|
ChangeDetectorRef_.prototype.detach = function() {
|
|
this._cd.mode = constants_1.ChangeDetectionStrategy.Detached;
|
|
};
|
|
ChangeDetectorRef_.prototype.detectChanges = function() {
|
|
this._cd.detectChanges();
|
|
};
|
|
ChangeDetectorRef_.prototype.checkNoChanges = function() {
|
|
this._cd.checkNoChanges();
|
|
};
|
|
ChangeDetectorRef_.prototype.reattach = function() {
|
|
this._cd.mode = constants_1.ChangeDetectionStrategy.CheckAlways;
|
|
this.markForCheck();
|
|
};
|
|
return ChangeDetectorRef_;
|
|
})(ChangeDetectorRef);
|
|
exports.ChangeDetectorRef_ = ChangeDetectorRef_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e7", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function implementsOnDestroy(pipe) {
|
|
return pipe.constructor.prototype.ngOnDestroy;
|
|
}
|
|
exports.implementsOnDestroy = implementsOnDestroy;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e8", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var DIRECTIVE_LIFECYCLE = "directiveLifecycle";
|
|
var BINDING = "native";
|
|
var DIRECTIVE = "directive";
|
|
var ELEMENT_PROPERTY = "elementProperty";
|
|
var ELEMENT_ATTRIBUTE = "elementAttribute";
|
|
var ELEMENT_CLASS = "elementClass";
|
|
var ELEMENT_STYLE = "elementStyle";
|
|
var TEXT_NODE = "textNode";
|
|
var EVENT = "event";
|
|
var HOST_EVENT = "hostEvent";
|
|
var BindingTarget = (function() {
|
|
function BindingTarget(mode, elementIndex, name, unit, debug) {
|
|
this.mode = mode;
|
|
this.elementIndex = elementIndex;
|
|
this.name = name;
|
|
this.unit = unit;
|
|
this.debug = debug;
|
|
}
|
|
BindingTarget.prototype.isDirective = function() {
|
|
return this.mode === DIRECTIVE;
|
|
};
|
|
BindingTarget.prototype.isElementProperty = function() {
|
|
return this.mode === ELEMENT_PROPERTY;
|
|
};
|
|
BindingTarget.prototype.isElementAttribute = function() {
|
|
return this.mode === ELEMENT_ATTRIBUTE;
|
|
};
|
|
BindingTarget.prototype.isElementClass = function() {
|
|
return this.mode === ELEMENT_CLASS;
|
|
};
|
|
BindingTarget.prototype.isElementStyle = function() {
|
|
return this.mode === ELEMENT_STYLE;
|
|
};
|
|
BindingTarget.prototype.isTextNode = function() {
|
|
return this.mode === TEXT_NODE;
|
|
};
|
|
return BindingTarget;
|
|
})();
|
|
exports.BindingTarget = BindingTarget;
|
|
var BindingRecord = (function() {
|
|
function BindingRecord(mode, target, implicitReceiver, ast, setter, lifecycleEvent, directiveRecord) {
|
|
this.mode = mode;
|
|
this.target = target;
|
|
this.implicitReceiver = implicitReceiver;
|
|
this.ast = ast;
|
|
this.setter = setter;
|
|
this.lifecycleEvent = lifecycleEvent;
|
|
this.directiveRecord = directiveRecord;
|
|
}
|
|
BindingRecord.prototype.isDirectiveLifecycle = function() {
|
|
return this.mode === DIRECTIVE_LIFECYCLE;
|
|
};
|
|
BindingRecord.prototype.callOnChanges = function() {
|
|
return lang_1.isPresent(this.directiveRecord) && this.directiveRecord.callOnChanges;
|
|
};
|
|
BindingRecord.prototype.isDefaultChangeDetection = function() {
|
|
return lang_1.isBlank(this.directiveRecord) || this.directiveRecord.isDefaultChangeDetection();
|
|
};
|
|
BindingRecord.createDirectiveDoCheck = function(directiveRecord) {
|
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "DoCheck", directiveRecord);
|
|
};
|
|
BindingRecord.createDirectiveOnInit = function(directiveRecord) {
|
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnInit", directiveRecord);
|
|
};
|
|
BindingRecord.createDirectiveOnChanges = function(directiveRecord) {
|
|
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnChanges", directiveRecord);
|
|
};
|
|
BindingRecord.createForDirective = function(ast, propertyName, setter, directiveRecord) {
|
|
var elementIndex = directiveRecord.directiveIndex.elementIndex;
|
|
var t = new BindingTarget(DIRECTIVE, elementIndex, propertyName, null, ast.toString());
|
|
return new BindingRecord(DIRECTIVE, t, 0, ast, setter, null, directiveRecord);
|
|
};
|
|
BindingRecord.createForElementProperty = function(ast, elementIndex, propertyName) {
|
|
var t = new BindingTarget(ELEMENT_PROPERTY, elementIndex, propertyName, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForElementAttribute = function(ast, elementIndex, attributeName) {
|
|
var t = new BindingTarget(ELEMENT_ATTRIBUTE, elementIndex, attributeName, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForElementClass = function(ast, elementIndex, className) {
|
|
var t = new BindingTarget(ELEMENT_CLASS, elementIndex, className, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForElementStyle = function(ast, elementIndex, styleName, unit) {
|
|
var t = new BindingTarget(ELEMENT_STYLE, elementIndex, styleName, unit, ast.toString());
|
|
return new BindingRecord(BINDING, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForHostProperty = function(directiveIndex, ast, propertyName) {
|
|
var t = new BindingTarget(ELEMENT_PROPERTY, directiveIndex.elementIndex, propertyName, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForHostAttribute = function(directiveIndex, ast, attributeName) {
|
|
var t = new BindingTarget(ELEMENT_ATTRIBUTE, directiveIndex.elementIndex, attributeName, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForHostClass = function(directiveIndex, ast, className) {
|
|
var t = new BindingTarget(ELEMENT_CLASS, directiveIndex.elementIndex, className, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForHostStyle = function(directiveIndex, ast, styleName, unit) {
|
|
var t = new BindingTarget(ELEMENT_STYLE, directiveIndex.elementIndex, styleName, unit, ast.toString());
|
|
return new BindingRecord(BINDING, t, directiveIndex, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForTextNode = function(ast, elementIndex) {
|
|
var t = new BindingTarget(TEXT_NODE, elementIndex, null, null, ast.toString());
|
|
return new BindingRecord(BINDING, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForEvent = function(ast, eventName, elementIndex) {
|
|
var t = new BindingTarget(EVENT, elementIndex, eventName, null, ast.toString());
|
|
return new BindingRecord(EVENT, t, 0, ast, null, null, null);
|
|
};
|
|
BindingRecord.createForHostEvent = function(ast, eventName, directiveRecord) {
|
|
var directiveIndex = directiveRecord.directiveIndex;
|
|
var t = new BindingTarget(HOST_EVENT, directiveIndex.elementIndex, eventName, null, ast.toString());
|
|
return new BindingRecord(HOST_EVENT, t, directiveIndex, ast, null, null, directiveRecord);
|
|
};
|
|
return BindingRecord;
|
|
})();
|
|
exports.BindingRecord = BindingRecord;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1da", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
(function(ChangeDetectorState) {
|
|
ChangeDetectorState[ChangeDetectorState["NeverChecked"] = 0] = "NeverChecked";
|
|
ChangeDetectorState[ChangeDetectorState["CheckedBefore"] = 1] = "CheckedBefore";
|
|
ChangeDetectorState[ChangeDetectorState["Errored"] = 2] = "Errored";
|
|
})(exports.ChangeDetectorState || (exports.ChangeDetectorState = {}));
|
|
var ChangeDetectorState = exports.ChangeDetectorState;
|
|
(function(ChangeDetectionStrategy) {
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["CheckOnce"] = 0] = "CheckOnce";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["Checked"] = 1] = "Checked";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["CheckAlways"] = 2] = "CheckAlways";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["Detached"] = 3] = "Detached";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPush"] = 4] = "OnPush";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["Default"] = 5] = "Default";
|
|
ChangeDetectionStrategy[ChangeDetectionStrategy["OnPushObserve"] = 6] = "OnPushObserve";
|
|
})(exports.ChangeDetectionStrategy || (exports.ChangeDetectionStrategy = {}));
|
|
var ChangeDetectionStrategy = exports.ChangeDetectionStrategy;
|
|
exports.CHANGE_DETECTION_STRATEGY_VALUES = [ChangeDetectionStrategy.CheckOnce, ChangeDetectionStrategy.Checked, ChangeDetectionStrategy.CheckAlways, ChangeDetectionStrategy.Detached, ChangeDetectionStrategy.OnPush, ChangeDetectionStrategy.Default, ChangeDetectionStrategy.OnPushObserve];
|
|
exports.CHANGE_DETECTOR_STATE_VALUES = [ChangeDetectorState.NeverChecked, ChangeDetectorState.CheckedBefore, ChangeDetectorState.Errored];
|
|
function isDefaultChangeDetectionStrategy(changeDetectionStrategy) {
|
|
return lang_1.isBlank(changeDetectionStrategy) || changeDetectionStrategy === ChangeDetectionStrategy.Default;
|
|
}
|
|
exports.isDefaultChangeDetectionStrategy = isDefaultChangeDetectionStrategy;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e0", ["20", "1da"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var constants_1 = $__require('1da');
|
|
var DirectiveIndex = (function() {
|
|
function DirectiveIndex(elementIndex, directiveIndex) {
|
|
this.elementIndex = elementIndex;
|
|
this.directiveIndex = directiveIndex;
|
|
}
|
|
Object.defineProperty(DirectiveIndex.prototype, "name", {
|
|
get: function() {
|
|
return this.elementIndex + "_" + this.directiveIndex;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return DirectiveIndex;
|
|
})();
|
|
exports.DirectiveIndex = DirectiveIndex;
|
|
var DirectiveRecord = (function() {
|
|
function DirectiveRecord(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
directiveIndex = _b.directiveIndex,
|
|
callAfterContentInit = _b.callAfterContentInit,
|
|
callAfterContentChecked = _b.callAfterContentChecked,
|
|
callAfterViewInit = _b.callAfterViewInit,
|
|
callAfterViewChecked = _b.callAfterViewChecked,
|
|
callOnChanges = _b.callOnChanges,
|
|
callDoCheck = _b.callDoCheck,
|
|
callOnInit = _b.callOnInit,
|
|
changeDetection = _b.changeDetection;
|
|
this.directiveIndex = directiveIndex;
|
|
this.callAfterContentInit = lang_1.normalizeBool(callAfterContentInit);
|
|
this.callAfterContentChecked = lang_1.normalizeBool(callAfterContentChecked);
|
|
this.callOnChanges = lang_1.normalizeBool(callOnChanges);
|
|
this.callAfterViewInit = lang_1.normalizeBool(callAfterViewInit);
|
|
this.callAfterViewChecked = lang_1.normalizeBool(callAfterViewChecked);
|
|
this.callDoCheck = lang_1.normalizeBool(callDoCheck);
|
|
this.callOnInit = lang_1.normalizeBool(callOnInit);
|
|
this.changeDetection = changeDetection;
|
|
}
|
|
DirectiveRecord.prototype.isDefaultChangeDetection = function() {
|
|
return constants_1.isDefaultChangeDetectionStrategy(this.changeDetection);
|
|
};
|
|
return DirectiveRecord;
|
|
})();
|
|
exports.DirectiveRecord = DirectiveRecord;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1de", ["20", "3c", "37", "1da", "1e7", "1e8", "1e0"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var constants_1 = $__require('1da');
|
|
var pipe_lifecycle_reflector_1 = $__require('1e7');
|
|
var binding_record_1 = $__require('1e8');
|
|
var directive_record_1 = $__require('1e0');
|
|
var WrappedValue = (function() {
|
|
function WrappedValue(wrapped) {
|
|
this.wrapped = wrapped;
|
|
}
|
|
WrappedValue.wrap = function(value) {
|
|
var w = _wrappedValues[_wrappedIndex++ % 5];
|
|
w.wrapped = value;
|
|
return w;
|
|
};
|
|
return WrappedValue;
|
|
})();
|
|
exports.WrappedValue = WrappedValue;
|
|
var _wrappedValues = [new WrappedValue(null), new WrappedValue(null), new WrappedValue(null), new WrappedValue(null), new WrappedValue(null)];
|
|
var _wrappedIndex = 0;
|
|
var SimpleChange = (function() {
|
|
function SimpleChange(previousValue, currentValue) {
|
|
this.previousValue = previousValue;
|
|
this.currentValue = currentValue;
|
|
}
|
|
SimpleChange.prototype.isFirstChange = function() {
|
|
return this.previousValue === ChangeDetectionUtil.uninitialized;
|
|
};
|
|
return SimpleChange;
|
|
})();
|
|
exports.SimpleChange = SimpleChange;
|
|
var _simpleChangesIndex = 0;
|
|
var _simpleChanges = [new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null), new SimpleChange(null, null)];
|
|
function _simpleChange(previousValue, currentValue) {
|
|
var index = _simpleChangesIndex++ % 20;
|
|
var s = _simpleChanges[index];
|
|
s.previousValue = previousValue;
|
|
s.currentValue = currentValue;
|
|
return s;
|
|
}
|
|
var ChangeDetectionUtil = (function() {
|
|
function ChangeDetectionUtil() {}
|
|
ChangeDetectionUtil.arrayFn0 = function() {
|
|
return [];
|
|
};
|
|
ChangeDetectionUtil.arrayFn1 = function(a1) {
|
|
return [a1];
|
|
};
|
|
ChangeDetectionUtil.arrayFn2 = function(a1, a2) {
|
|
return [a1, a2];
|
|
};
|
|
ChangeDetectionUtil.arrayFn3 = function(a1, a2, a3) {
|
|
return [a1, a2, a3];
|
|
};
|
|
ChangeDetectionUtil.arrayFn4 = function(a1, a2, a3, a4) {
|
|
return [a1, a2, a3, a4];
|
|
};
|
|
ChangeDetectionUtil.arrayFn5 = function(a1, a2, a3, a4, a5) {
|
|
return [a1, a2, a3, a4, a5];
|
|
};
|
|
ChangeDetectionUtil.arrayFn6 = function(a1, a2, a3, a4, a5, a6) {
|
|
return [a1, a2, a3, a4, a5, a6];
|
|
};
|
|
ChangeDetectionUtil.arrayFn7 = function(a1, a2, a3, a4, a5, a6, a7) {
|
|
return [a1, a2, a3, a4, a5, a6, a7];
|
|
};
|
|
ChangeDetectionUtil.arrayFn8 = function(a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
return [a1, a2, a3, a4, a5, a6, a7, a8];
|
|
};
|
|
ChangeDetectionUtil.arrayFn9 = function(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
return [a1, a2, a3, a4, a5, a6, a7, a8, a9];
|
|
};
|
|
ChangeDetectionUtil.operation_negate = function(value) {
|
|
return !value;
|
|
};
|
|
ChangeDetectionUtil.operation_add = function(left, right) {
|
|
return left + right;
|
|
};
|
|
ChangeDetectionUtil.operation_subtract = function(left, right) {
|
|
return left - right;
|
|
};
|
|
ChangeDetectionUtil.operation_multiply = function(left, right) {
|
|
return left * right;
|
|
};
|
|
ChangeDetectionUtil.operation_divide = function(left, right) {
|
|
return left / right;
|
|
};
|
|
ChangeDetectionUtil.operation_remainder = function(left, right) {
|
|
return left % right;
|
|
};
|
|
ChangeDetectionUtil.operation_equals = function(left, right) {
|
|
return left == right;
|
|
};
|
|
ChangeDetectionUtil.operation_not_equals = function(left, right) {
|
|
return left != right;
|
|
};
|
|
ChangeDetectionUtil.operation_identical = function(left, right) {
|
|
return left === right;
|
|
};
|
|
ChangeDetectionUtil.operation_not_identical = function(left, right) {
|
|
return left !== right;
|
|
};
|
|
ChangeDetectionUtil.operation_less_then = function(left, right) {
|
|
return left < right;
|
|
};
|
|
ChangeDetectionUtil.operation_greater_then = function(left, right) {
|
|
return left > right;
|
|
};
|
|
ChangeDetectionUtil.operation_less_or_equals_then = function(left, right) {
|
|
return left <= right;
|
|
};
|
|
ChangeDetectionUtil.operation_greater_or_equals_then = function(left, right) {
|
|
return left >= right;
|
|
};
|
|
ChangeDetectionUtil.cond = function(cond, trueVal, falseVal) {
|
|
return cond ? trueVal : falseVal;
|
|
};
|
|
ChangeDetectionUtil.mapFn = function(keys) {
|
|
function buildMap(values) {
|
|
var res = collection_1.StringMapWrapper.create();
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
collection_1.StringMapWrapper.set(res, keys[i], values[i]);
|
|
}
|
|
return res;
|
|
}
|
|
switch (keys.length) {
|
|
case 0:
|
|
return function() {
|
|
return [];
|
|
};
|
|
case 1:
|
|
return function(a1) {
|
|
return buildMap([a1]);
|
|
};
|
|
case 2:
|
|
return function(a1, a2) {
|
|
return buildMap([a1, a2]);
|
|
};
|
|
case 3:
|
|
return function(a1, a2, a3) {
|
|
return buildMap([a1, a2, a3]);
|
|
};
|
|
case 4:
|
|
return function(a1, a2, a3, a4) {
|
|
return buildMap([a1, a2, a3, a4]);
|
|
};
|
|
case 5:
|
|
return function(a1, a2, a3, a4, a5) {
|
|
return buildMap([a1, a2, a3, a4, a5]);
|
|
};
|
|
case 6:
|
|
return function(a1, a2, a3, a4, a5, a6) {
|
|
return buildMap([a1, a2, a3, a4, a5, a6]);
|
|
};
|
|
case 7:
|
|
return function(a1, a2, a3, a4, a5, a6, a7) {
|
|
return buildMap([a1, a2, a3, a4, a5, a6, a7]);
|
|
};
|
|
case 8:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
return buildMap([a1, a2, a3, a4, a5, a6, a7, a8]);
|
|
};
|
|
case 9:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
return buildMap([a1, a2, a3, a4, a5, a6, a7, a8, a9]);
|
|
};
|
|
default:
|
|
throw new exceptions_1.BaseException("Does not support literal maps with more than 9 elements");
|
|
}
|
|
};
|
|
ChangeDetectionUtil.keyedAccess = function(obj, args) {
|
|
return obj[args[0]];
|
|
};
|
|
ChangeDetectionUtil.unwrapValue = function(value) {
|
|
if (value instanceof WrappedValue) {
|
|
return value.wrapped;
|
|
} else {
|
|
return value;
|
|
}
|
|
};
|
|
ChangeDetectionUtil.changeDetectionMode = function(strategy) {
|
|
return constants_1.isDefaultChangeDetectionStrategy(strategy) ? constants_1.ChangeDetectionStrategy.CheckAlways : constants_1.ChangeDetectionStrategy.CheckOnce;
|
|
};
|
|
ChangeDetectionUtil.simpleChange = function(previousValue, currentValue) {
|
|
return _simpleChange(previousValue, currentValue);
|
|
};
|
|
ChangeDetectionUtil.isValueBlank = function(value) {
|
|
return lang_1.isBlank(value);
|
|
};
|
|
ChangeDetectionUtil.s = function(value) {
|
|
return lang_1.isPresent(value) ? "" + value : '';
|
|
};
|
|
ChangeDetectionUtil.protoByIndex = function(protos, selfIndex) {
|
|
return selfIndex < 1 ? null : protos[selfIndex - 1];
|
|
};
|
|
ChangeDetectionUtil.callPipeOnDestroy = function(selectedPipe) {
|
|
if (pipe_lifecycle_reflector_1.implementsOnDestroy(selectedPipe.pipe)) {
|
|
selectedPipe.pipe.ngOnDestroy();
|
|
}
|
|
};
|
|
ChangeDetectionUtil.bindingTarget = function(mode, elementIndex, name, unit, debug) {
|
|
return new binding_record_1.BindingTarget(mode, elementIndex, name, unit, debug);
|
|
};
|
|
ChangeDetectionUtil.directiveIndex = function(elementIndex, directiveIndex) {
|
|
return new directive_record_1.DirectiveIndex(elementIndex, directiveIndex);
|
|
};
|
|
ChangeDetectionUtil.looseNotIdentical = function(a, b) {
|
|
return !lang_1.looseIdentical(a, b);
|
|
};
|
|
ChangeDetectionUtil.uninitialized = lang_1.CONST_EXPR(new Object());
|
|
return ChangeDetectionUtil;
|
|
})();
|
|
exports.ChangeDetectionUtil = ChangeDetectionUtil;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6e", ["1cd", "1ce", "1cf", "1d0", "20", "1d4", "1d1", "1d3", "1d5", "1e3", "1b3", "1da", "1dd", "1e2", "1e8", "1e0", "1df", "1e6", "1de"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var iterable_differs_1 = $__require('1cd');
|
|
var default_iterable_differ_1 = $__require('1ce');
|
|
var keyvalue_differs_1 = $__require('1cf');
|
|
var default_keyvalue_differ_1 = $__require('1d0');
|
|
var lang_1 = $__require('20');
|
|
var ast_1 = $__require('1d4');
|
|
exports.ASTWithSource = ast_1.ASTWithSource;
|
|
exports.AST = ast_1.AST;
|
|
exports.AstTransformer = ast_1.AstTransformer;
|
|
exports.PropertyRead = ast_1.PropertyRead;
|
|
exports.LiteralArray = ast_1.LiteralArray;
|
|
exports.ImplicitReceiver = ast_1.ImplicitReceiver;
|
|
var lexer_1 = $__require('1d1');
|
|
exports.Lexer = lexer_1.Lexer;
|
|
var parser_1 = $__require('1d3');
|
|
exports.Parser = parser_1.Parser;
|
|
var locals_1 = $__require('1d5');
|
|
exports.Locals = locals_1.Locals;
|
|
var exceptions_1 = $__require('1e3');
|
|
exports.DehydratedException = exceptions_1.DehydratedException;
|
|
exports.ExpressionChangedAfterItHasBeenCheckedException = exceptions_1.ExpressionChangedAfterItHasBeenCheckedException;
|
|
exports.ChangeDetectionError = exceptions_1.ChangeDetectionError;
|
|
var interfaces_1 = $__require('1b3');
|
|
exports.ChangeDetectorDefinition = interfaces_1.ChangeDetectorDefinition;
|
|
exports.DebugContext = interfaces_1.DebugContext;
|
|
exports.ChangeDetectorGenConfig = interfaces_1.ChangeDetectorGenConfig;
|
|
var constants_1 = $__require('1da');
|
|
exports.ChangeDetectionStrategy = constants_1.ChangeDetectionStrategy;
|
|
exports.CHANGE_DETECTION_STRATEGY_VALUES = constants_1.CHANGE_DETECTION_STRATEGY_VALUES;
|
|
var proto_change_detector_1 = $__require('1dd');
|
|
exports.DynamicProtoChangeDetector = proto_change_detector_1.DynamicProtoChangeDetector;
|
|
var jit_proto_change_detector_1 = $__require('1e2');
|
|
exports.JitProtoChangeDetector = jit_proto_change_detector_1.JitProtoChangeDetector;
|
|
var binding_record_1 = $__require('1e8');
|
|
exports.BindingRecord = binding_record_1.BindingRecord;
|
|
exports.BindingTarget = binding_record_1.BindingTarget;
|
|
var directive_record_1 = $__require('1e0');
|
|
exports.DirectiveIndex = directive_record_1.DirectiveIndex;
|
|
exports.DirectiveRecord = directive_record_1.DirectiveRecord;
|
|
var dynamic_change_detector_1 = $__require('1df');
|
|
exports.DynamicChangeDetector = dynamic_change_detector_1.DynamicChangeDetector;
|
|
var change_detector_ref_1 = $__require('1e6');
|
|
exports.ChangeDetectorRef = change_detector_ref_1.ChangeDetectorRef;
|
|
var iterable_differs_2 = $__require('1cd');
|
|
exports.IterableDiffers = iterable_differs_2.IterableDiffers;
|
|
var keyvalue_differs_2 = $__require('1cf');
|
|
exports.KeyValueDiffers = keyvalue_differs_2.KeyValueDiffers;
|
|
var change_detection_util_1 = $__require('1de');
|
|
exports.WrappedValue = change_detection_util_1.WrappedValue;
|
|
exports.SimpleChange = change_detection_util_1.SimpleChange;
|
|
exports.keyValDiff = lang_1.CONST_EXPR([lang_1.CONST_EXPR(new default_keyvalue_differ_1.DefaultKeyValueDifferFactory())]);
|
|
exports.iterableDiff = lang_1.CONST_EXPR([lang_1.CONST_EXPR(new default_iterable_differ_1.DefaultIterableDifferFactory())]);
|
|
exports.defaultIterableDiffers = lang_1.CONST_EXPR(new iterable_differs_1.IterableDiffers(exports.iterableDiff));
|
|
exports.defaultKeyValueDiffers = lang_1.CONST_EXPR(new keyvalue_differs_1.KeyValueDiffers(exports.keyValDiff));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1e9", ["6e"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var change_detection_1 = $__require('6e');
|
|
exports.ChangeDetectionStrategy = change_detection_1.ChangeDetectionStrategy;
|
|
exports.ExpressionChangedAfterItHasBeenCheckedException = change_detection_1.ExpressionChangedAfterItHasBeenCheckedException;
|
|
exports.ChangeDetectionError = change_detection_1.ChangeDetectionError;
|
|
exports.ChangeDetectorRef = change_detection_1.ChangeDetectorRef;
|
|
exports.WrappedValue = change_detection_1.WrappedValue;
|
|
exports.SimpleChange = change_detection_1.SimpleChange;
|
|
exports.IterableDiffers = change_detection_1.IterableDiffers;
|
|
exports.KeyValueDiffers = change_detection_1.KeyValueDiffers;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7d", ["20", "1cc", "1e9"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var metadata_1 = $__require('1cc');
|
|
var change_detection_1 = $__require('1e9');
|
|
var DirectiveMetadata = (function(_super) {
|
|
__extends(DirectiveMetadata, _super);
|
|
function DirectiveMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
selector = _b.selector,
|
|
inputs = _b.inputs,
|
|
outputs = _b.outputs,
|
|
properties = _b.properties,
|
|
events = _b.events,
|
|
host = _b.host,
|
|
bindings = _b.bindings,
|
|
providers = _b.providers,
|
|
exportAs = _b.exportAs,
|
|
queries = _b.queries;
|
|
_super.call(this);
|
|
this.selector = selector;
|
|
this._inputs = inputs;
|
|
this._properties = properties;
|
|
this._outputs = outputs;
|
|
this._events = events;
|
|
this.host = host;
|
|
this.exportAs = exportAs;
|
|
this.queries = queries;
|
|
this._providers = providers;
|
|
this._bindings = bindings;
|
|
}
|
|
Object.defineProperty(DirectiveMetadata.prototype, "inputs", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._properties) && this._properties.length > 0 ? this._properties : this._inputs;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveMetadata.prototype, "properties", {
|
|
get: function() {
|
|
return this.inputs;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveMetadata.prototype, "outputs", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._events) && this._events.length > 0 ? this._events : this._outputs;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveMetadata.prototype, "events", {
|
|
get: function() {
|
|
return this.outputs;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveMetadata.prototype, "providers", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._bindings) && this._bindings.length > 0 ? this._bindings : this._providers;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(DirectiveMetadata.prototype, "bindings", {
|
|
get: function() {
|
|
return this.providers;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DirectiveMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], DirectiveMetadata);
|
|
return DirectiveMetadata;
|
|
})(metadata_1.InjectableMetadata);
|
|
exports.DirectiveMetadata = DirectiveMetadata;
|
|
var ComponentMetadata = (function(_super) {
|
|
__extends(ComponentMetadata, _super);
|
|
function ComponentMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
selector = _b.selector,
|
|
inputs = _b.inputs,
|
|
outputs = _b.outputs,
|
|
properties = _b.properties,
|
|
events = _b.events,
|
|
host = _b.host,
|
|
exportAs = _b.exportAs,
|
|
moduleId = _b.moduleId,
|
|
bindings = _b.bindings,
|
|
providers = _b.providers,
|
|
viewBindings = _b.viewBindings,
|
|
viewProviders = _b.viewProviders,
|
|
_c = _b.changeDetection,
|
|
changeDetection = _c === void 0 ? change_detection_1.ChangeDetectionStrategy.Default : _c,
|
|
queries = _b.queries,
|
|
templateUrl = _b.templateUrl,
|
|
template = _b.template,
|
|
styleUrls = _b.styleUrls,
|
|
styles = _b.styles,
|
|
directives = _b.directives,
|
|
pipes = _b.pipes,
|
|
encapsulation = _b.encapsulation;
|
|
_super.call(this, {
|
|
selector: selector,
|
|
inputs: inputs,
|
|
outputs: outputs,
|
|
properties: properties,
|
|
events: events,
|
|
host: host,
|
|
exportAs: exportAs,
|
|
bindings: bindings,
|
|
providers: providers,
|
|
queries: queries
|
|
});
|
|
this.changeDetection = changeDetection;
|
|
this._viewProviders = viewProviders;
|
|
this._viewBindings = viewBindings;
|
|
this.templateUrl = templateUrl;
|
|
this.template = template;
|
|
this.styleUrls = styleUrls;
|
|
this.styles = styles;
|
|
this.directives = directives;
|
|
this.pipes = pipes;
|
|
this.encapsulation = encapsulation;
|
|
this.moduleId = moduleId;
|
|
}
|
|
Object.defineProperty(ComponentMetadata.prototype, "viewProviders", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._viewBindings) && this._viewBindings.length > 0 ? this._viewBindings : this._viewProviders;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ComponentMetadata.prototype, "viewBindings", {
|
|
get: function() {
|
|
return this.viewProviders;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ComponentMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], ComponentMetadata);
|
|
return ComponentMetadata;
|
|
})(DirectiveMetadata);
|
|
exports.ComponentMetadata = ComponentMetadata;
|
|
var PipeMetadata = (function(_super) {
|
|
__extends(PipeMetadata, _super);
|
|
function PipeMetadata(_a) {
|
|
var name = _a.name,
|
|
pure = _a.pure;
|
|
_super.call(this);
|
|
this.name = name;
|
|
this._pure = pure;
|
|
}
|
|
Object.defineProperty(PipeMetadata.prototype, "pure", {
|
|
get: function() {
|
|
return lang_1.isPresent(this._pure) ? this._pure : true;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
PipeMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], PipeMetadata);
|
|
return PipeMetadata;
|
|
})(metadata_1.InjectableMetadata);
|
|
exports.PipeMetadata = PipeMetadata;
|
|
var InputMetadata = (function() {
|
|
function InputMetadata(bindingPropertyName) {
|
|
this.bindingPropertyName = bindingPropertyName;
|
|
}
|
|
InputMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], InputMetadata);
|
|
return InputMetadata;
|
|
})();
|
|
exports.InputMetadata = InputMetadata;
|
|
var OutputMetadata = (function() {
|
|
function OutputMetadata(bindingPropertyName) {
|
|
this.bindingPropertyName = bindingPropertyName;
|
|
}
|
|
OutputMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], OutputMetadata);
|
|
return OutputMetadata;
|
|
})();
|
|
exports.OutputMetadata = OutputMetadata;
|
|
var HostBindingMetadata = (function() {
|
|
function HostBindingMetadata(hostPropertyName) {
|
|
this.hostPropertyName = hostPropertyName;
|
|
}
|
|
HostBindingMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], HostBindingMetadata);
|
|
return HostBindingMetadata;
|
|
})();
|
|
exports.HostBindingMetadata = HostBindingMetadata;
|
|
var HostListenerMetadata = (function() {
|
|
function HostListenerMetadata(eventName, args) {
|
|
this.eventName = eventName;
|
|
this.args = args;
|
|
}
|
|
HostListenerMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String, Array])], HostListenerMetadata);
|
|
return HostListenerMetadata;
|
|
})();
|
|
exports.HostListenerMetadata = HostListenerMetadata;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7b", ["20", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
(function(ViewEncapsulation) {
|
|
ViewEncapsulation[ViewEncapsulation["Emulated"] = 0] = "Emulated";
|
|
ViewEncapsulation[ViewEncapsulation["Native"] = 1] = "Native";
|
|
ViewEncapsulation[ViewEncapsulation["None"] = 2] = "None";
|
|
})(exports.ViewEncapsulation || (exports.ViewEncapsulation = {}));
|
|
var ViewEncapsulation = exports.ViewEncapsulation;
|
|
exports.VIEW_ENCAPSULATION_VALUES = [ViewEncapsulation.Emulated, ViewEncapsulation.Native, ViewEncapsulation.None];
|
|
var ViewMetadata = (function() {
|
|
function ViewMetadata(_a) {
|
|
var _b = _a === void 0 ? {} : _a,
|
|
templateUrl = _b.templateUrl,
|
|
template = _b.template,
|
|
directives = _b.directives,
|
|
pipes = _b.pipes,
|
|
encapsulation = _b.encapsulation,
|
|
styles = _b.styles,
|
|
styleUrls = _b.styleUrls;
|
|
this.templateUrl = templateUrl;
|
|
this.template = template;
|
|
this.styleUrls = styleUrls;
|
|
this.styles = styles;
|
|
this.directives = directives;
|
|
this.pipes = pipes;
|
|
this.encapsulation = encapsulation;
|
|
}
|
|
ViewMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], ViewMetadata);
|
|
return ViewMetadata;
|
|
})();
|
|
exports.ViewMetadata = ViewMetadata;
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("50", ["1ca", "7d", "7b", "19c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var di_1 = $__require('1ca');
|
|
exports.QueryMetadata = di_1.QueryMetadata;
|
|
exports.ContentChildrenMetadata = di_1.ContentChildrenMetadata;
|
|
exports.ContentChildMetadata = di_1.ContentChildMetadata;
|
|
exports.ViewChildrenMetadata = di_1.ViewChildrenMetadata;
|
|
exports.ViewQueryMetadata = di_1.ViewQueryMetadata;
|
|
exports.ViewChildMetadata = di_1.ViewChildMetadata;
|
|
exports.AttributeMetadata = di_1.AttributeMetadata;
|
|
var directives_1 = $__require('7d');
|
|
exports.ComponentMetadata = directives_1.ComponentMetadata;
|
|
exports.DirectiveMetadata = directives_1.DirectiveMetadata;
|
|
exports.PipeMetadata = directives_1.PipeMetadata;
|
|
exports.InputMetadata = directives_1.InputMetadata;
|
|
exports.OutputMetadata = directives_1.OutputMetadata;
|
|
exports.HostBindingMetadata = directives_1.HostBindingMetadata;
|
|
exports.HostListenerMetadata = directives_1.HostListenerMetadata;
|
|
var view_1 = $__require('7b');
|
|
exports.ViewMetadata = view_1.ViewMetadata;
|
|
exports.ViewEncapsulation = view_1.ViewEncapsulation;
|
|
var di_2 = $__require('1ca');
|
|
var directives_2 = $__require('7d');
|
|
var view_2 = $__require('7b');
|
|
var decorators_1 = $__require('19c');
|
|
exports.Component = decorators_1.makeDecorator(directives_2.ComponentMetadata, function(fn) {
|
|
return fn.View = exports.View;
|
|
});
|
|
exports.Directive = decorators_1.makeDecorator(directives_2.DirectiveMetadata);
|
|
exports.View = decorators_1.makeDecorator(view_2.ViewMetadata, function(fn) {
|
|
return fn.View = exports.View;
|
|
});
|
|
exports.Attribute = decorators_1.makeParamDecorator(di_2.AttributeMetadata);
|
|
exports.Query = decorators_1.makeParamDecorator(di_2.QueryMetadata);
|
|
exports.ContentChildren = decorators_1.makePropDecorator(di_2.ContentChildrenMetadata);
|
|
exports.ContentChild = decorators_1.makePropDecorator(di_2.ContentChildMetadata);
|
|
exports.ViewChildren = decorators_1.makePropDecorator(di_2.ViewChildrenMetadata);
|
|
exports.ViewChild = decorators_1.makePropDecorator(di_2.ViewChildMetadata);
|
|
exports.ViewQuery = decorators_1.makeParamDecorator(di_2.ViewQueryMetadata);
|
|
exports.Pipe = decorators_1.makeDecorator(directives_2.PipeMetadata);
|
|
exports.Input = decorators_1.makePropDecorator(directives_2.InputMetadata);
|
|
exports.Output = decorators_1.makePropDecorator(directives_2.OutputMetadata);
|
|
exports.HostBinding = decorators_1.makePropDecorator(directives_2.HostBindingMetadata);
|
|
exports.HostListener = decorators_1.makePropDecorator(directives_2.HostListenerMetadata);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("64", ["20", "3c", "56", "50"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var api_1 = $__require('56');
|
|
var metadata_1 = $__require('50');
|
|
var metadata_2 = $__require('50');
|
|
exports.ViewEncapsulation = metadata_2.ViewEncapsulation;
|
|
var CompiledHostTemplate = (function() {
|
|
function CompiledHostTemplate(template) {
|
|
this.template = template;
|
|
}
|
|
CompiledHostTemplate = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [CompiledComponentTemplate])], CompiledHostTemplate);
|
|
return CompiledHostTemplate;
|
|
})();
|
|
exports.CompiledHostTemplate = CompiledHostTemplate;
|
|
var CompiledComponentTemplate = (function() {
|
|
function CompiledComponentTemplate(id, changeDetectorFactory, commands, styles) {
|
|
this.id = id;
|
|
this.changeDetectorFactory = changeDetectorFactory;
|
|
this.commands = commands;
|
|
this.styles = styles;
|
|
}
|
|
CompiledComponentTemplate = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String, Function, Array, Array])], CompiledComponentTemplate);
|
|
return CompiledComponentTemplate;
|
|
})();
|
|
exports.CompiledComponentTemplate = CompiledComponentTemplate;
|
|
var EMPTY_ARR = lang_1.CONST_EXPR([]);
|
|
var TextCmd = (function() {
|
|
function TextCmd(value, isBound, ngContentIndex) {
|
|
this.value = value;
|
|
this.isBound = isBound;
|
|
this.ngContentIndex = ngContentIndex;
|
|
}
|
|
TextCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitText(this, context);
|
|
};
|
|
TextCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String, Boolean, Number])], TextCmd);
|
|
return TextCmd;
|
|
})();
|
|
exports.TextCmd = TextCmd;
|
|
var NgContentCmd = (function() {
|
|
function NgContentCmd(index, ngContentIndex) {
|
|
this.index = index;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.isBound = false;
|
|
}
|
|
NgContentCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitNgContent(this, context);
|
|
};
|
|
NgContentCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Number, Number])], NgContentCmd);
|
|
return NgContentCmd;
|
|
})();
|
|
exports.NgContentCmd = NgContentCmd;
|
|
var IBeginElementCmd = (function(_super) {
|
|
__extends(IBeginElementCmd, _super);
|
|
function IBeginElementCmd() {
|
|
_super.apply(this, arguments);
|
|
}
|
|
Object.defineProperty(IBeginElementCmd.prototype, "variableNameAndValues", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(IBeginElementCmd.prototype, "eventTargetAndNames", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(IBeginElementCmd.prototype, "directives", {
|
|
get: function() {
|
|
return exceptions_1.unimplemented();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return IBeginElementCmd;
|
|
})(api_1.RenderBeginElementCmd);
|
|
exports.IBeginElementCmd = IBeginElementCmd;
|
|
var BeginElementCmd = (function() {
|
|
function BeginElementCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, isBound, ngContentIndex) {
|
|
this.name = name;
|
|
this.attrNameAndValues = attrNameAndValues;
|
|
this.eventTargetAndNames = eventTargetAndNames;
|
|
this.variableNameAndValues = variableNameAndValues;
|
|
this.directives = directives;
|
|
this.isBound = isBound;
|
|
this.ngContentIndex = ngContentIndex;
|
|
}
|
|
BeginElementCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitBeginElement(this, context);
|
|
};
|
|
BeginElementCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String, Array, Array, Array, Array, Boolean, Number])], BeginElementCmd);
|
|
return BeginElementCmd;
|
|
})();
|
|
exports.BeginElementCmd = BeginElementCmd;
|
|
var EndElementCmd = (function() {
|
|
function EndElementCmd() {}
|
|
EndElementCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitEndElement(context);
|
|
};
|
|
EndElementCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], EndElementCmd);
|
|
return EndElementCmd;
|
|
})();
|
|
exports.EndElementCmd = EndElementCmd;
|
|
var BeginComponentCmd = (function() {
|
|
function BeginComponentCmd(name, attrNameAndValues, eventTargetAndNames, variableNameAndValues, directives, encapsulation, ngContentIndex, templateGetter) {
|
|
this.name = name;
|
|
this.attrNameAndValues = attrNameAndValues;
|
|
this.eventTargetAndNames = eventTargetAndNames;
|
|
this.variableNameAndValues = variableNameAndValues;
|
|
this.directives = directives;
|
|
this.encapsulation = encapsulation;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.templateGetter = templateGetter;
|
|
this.isBound = true;
|
|
}
|
|
Object.defineProperty(BeginComponentCmd.prototype, "templateId", {
|
|
get: function() {
|
|
return this.templateGetter().id;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
BeginComponentCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitBeginComponent(this, context);
|
|
};
|
|
BeginComponentCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String, Array, Array, Array, Array, Number, Number, Function])], BeginComponentCmd);
|
|
return BeginComponentCmd;
|
|
})();
|
|
exports.BeginComponentCmd = BeginComponentCmd;
|
|
var EndComponentCmd = (function() {
|
|
function EndComponentCmd() {}
|
|
EndComponentCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitEndComponent(context);
|
|
};
|
|
EndComponentCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], EndComponentCmd);
|
|
return EndComponentCmd;
|
|
})();
|
|
exports.EndComponentCmd = EndComponentCmd;
|
|
var EmbeddedTemplateCmd = (function() {
|
|
function EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged, ngContentIndex, changeDetectorFactory, children) {
|
|
this.attrNameAndValues = attrNameAndValues;
|
|
this.variableNameAndValues = variableNameAndValues;
|
|
this.directives = directives;
|
|
this.isMerged = isMerged;
|
|
this.ngContentIndex = ngContentIndex;
|
|
this.changeDetectorFactory = changeDetectorFactory;
|
|
this.children = children;
|
|
this.isBound = true;
|
|
this.name = null;
|
|
this.eventTargetAndNames = EMPTY_ARR;
|
|
}
|
|
EmbeddedTemplateCmd.prototype.visit = function(visitor, context) {
|
|
return visitor.visitEmbeddedTemplate(this, context);
|
|
};
|
|
EmbeddedTemplateCmd = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Array, Array, Array, Boolean, Number, Function, Array])], EmbeddedTemplateCmd);
|
|
return EmbeddedTemplateCmd;
|
|
})();
|
|
exports.EmbeddedTemplateCmd = EmbeddedTemplateCmd;
|
|
function visitAllCommands(visitor, cmds, context) {
|
|
if (context === void 0) {
|
|
context = null;
|
|
}
|
|
for (var i = 0; i < cmds.length; i++) {
|
|
cmds[i].visit(visitor, context);
|
|
}
|
|
}
|
|
exports.visitAllCommands = visitAllCommands;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("19c", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
function extractAnnotation(annotation) {
|
|
if (lang_1.isFunction(annotation) && annotation.hasOwnProperty('annotation')) {
|
|
annotation = annotation.annotation;
|
|
}
|
|
return annotation;
|
|
}
|
|
function applyParams(fnOrArray, key) {
|
|
if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function || fnOrArray === Number || fnOrArray === Array) {
|
|
throw new Error("Can not use native " + lang_1.stringify(fnOrArray) + " as constructor");
|
|
}
|
|
if (lang_1.isFunction(fnOrArray)) {
|
|
return fnOrArray;
|
|
} else if (fnOrArray instanceof Array) {
|
|
var annotations = fnOrArray;
|
|
var fn = fnOrArray[fnOrArray.length - 1];
|
|
if (!lang_1.isFunction(fn)) {
|
|
throw new Error("Last position of Class method array must be Function in key " + key + " was '" + lang_1.stringify(fn) + "'");
|
|
}
|
|
var annoLength = annotations.length - 1;
|
|
if (annoLength != fn.length) {
|
|
throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + lang_1.stringify(fn));
|
|
}
|
|
var paramsAnnotations = [];
|
|
for (var i = 0,
|
|
ii = annotations.length - 1; i < ii; i++) {
|
|
var paramAnnotations = [];
|
|
paramsAnnotations.push(paramAnnotations);
|
|
var annotation = annotations[i];
|
|
if (annotation instanceof Array) {
|
|
for (var j = 0; j < annotation.length; j++) {
|
|
paramAnnotations.push(extractAnnotation(annotation[j]));
|
|
}
|
|
} else if (lang_1.isFunction(annotation)) {
|
|
paramAnnotations.push(extractAnnotation(annotation));
|
|
} else {
|
|
paramAnnotations.push(annotation);
|
|
}
|
|
}
|
|
Reflect.defineMetadata('parameters', paramsAnnotations, fn);
|
|
return fn;
|
|
} else {
|
|
throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + lang_1.stringify(fnOrArray) + "'");
|
|
}
|
|
}
|
|
function Class(clsDef) {
|
|
var constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
|
|
var proto = constructor.prototype;
|
|
if (clsDef.hasOwnProperty('extends')) {
|
|
if (lang_1.isFunction(clsDef.extends)) {
|
|
constructor.prototype = proto = Object.create(clsDef.extends.prototype);
|
|
} else {
|
|
throw new Error("Class definition 'extends' property must be a constructor function was: " + lang_1.stringify(clsDef.extends));
|
|
}
|
|
}
|
|
for (var key in clsDef) {
|
|
if (key != 'extends' && key != 'prototype' && clsDef.hasOwnProperty(key)) {
|
|
proto[key] = applyParams(clsDef[key], key);
|
|
}
|
|
}
|
|
if (this && this.annotations instanceof Array) {
|
|
Reflect.defineMetadata('annotations', this.annotations, constructor);
|
|
}
|
|
return constructor;
|
|
}
|
|
exports.Class = Class;
|
|
var Reflect = lang_1.global.Reflect;
|
|
if (!(Reflect && Reflect.getMetadata)) {
|
|
throw 'reflect-metadata shim is required when using class decorators';
|
|
}
|
|
function makeDecorator(annotationCls, chainFn) {
|
|
if (chainFn === void 0) {
|
|
chainFn = null;
|
|
}
|
|
function DecoratorFactory(objOrType) {
|
|
var annotationInstance = new annotationCls(objOrType);
|
|
if (this instanceof annotationCls) {
|
|
return annotationInstance;
|
|
} else {
|
|
var chainAnnotation = lang_1.isFunction(this) && this.annotations instanceof Array ? this.annotations : [];
|
|
chainAnnotation.push(annotationInstance);
|
|
var TypeDecorator = function TypeDecorator(cls) {
|
|
var annotations = Reflect.getOwnMetadata('annotations', cls);
|
|
annotations = annotations || [];
|
|
annotations.push(annotationInstance);
|
|
Reflect.defineMetadata('annotations', annotations, cls);
|
|
return cls;
|
|
};
|
|
TypeDecorator.annotations = chainAnnotation;
|
|
TypeDecorator.Class = Class;
|
|
if (chainFn)
|
|
chainFn(TypeDecorator);
|
|
return TypeDecorator;
|
|
}
|
|
}
|
|
DecoratorFactory.prototype = Object.create(annotationCls.prototype);
|
|
return DecoratorFactory;
|
|
}
|
|
exports.makeDecorator = makeDecorator;
|
|
function makeParamDecorator(annotationCls) {
|
|
function ParamDecoratorFactory() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i - 0] = arguments[_i];
|
|
}
|
|
var annotationInstance = Object.create(annotationCls.prototype);
|
|
annotationCls.apply(annotationInstance, args);
|
|
if (this instanceof annotationCls) {
|
|
return annotationInstance;
|
|
} else {
|
|
ParamDecorator.annotation = annotationInstance;
|
|
return ParamDecorator;
|
|
}
|
|
function ParamDecorator(cls, unusedKey, index) {
|
|
var parameters = Reflect.getMetadata('parameters', cls);
|
|
parameters = parameters || [];
|
|
while (parameters.length <= index) {
|
|
parameters.push(null);
|
|
}
|
|
parameters[index] = parameters[index] || [];
|
|
var annotationsForParam = parameters[index];
|
|
annotationsForParam.push(annotationInstance);
|
|
Reflect.defineMetadata('parameters', parameters, cls);
|
|
return cls;
|
|
}
|
|
}
|
|
ParamDecoratorFactory.prototype = Object.create(annotationCls.prototype);
|
|
return ParamDecoratorFactory;
|
|
}
|
|
exports.makeParamDecorator = makeParamDecorator;
|
|
function makePropDecorator(decoratorCls) {
|
|
function PropDecoratorFactory() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i - 0] = arguments[_i];
|
|
}
|
|
var decoratorInstance = Object.create(decoratorCls.prototype);
|
|
decoratorCls.apply(decoratorInstance, args);
|
|
if (this instanceof decoratorCls) {
|
|
return decoratorInstance;
|
|
} else {
|
|
return function PropDecorator(target, name) {
|
|
var meta = Reflect.getOwnMetadata('propMetadata', target.constructor);
|
|
meta = meta || {};
|
|
meta[name] = meta[name] || [];
|
|
meta[name].unshift(decoratorInstance);
|
|
Reflect.defineMetadata('propMetadata', meta, target.constructor);
|
|
};
|
|
}
|
|
}
|
|
PropDecoratorFactory.prototype = Object.create(decoratorCls.prototype);
|
|
return PropDecoratorFactory;
|
|
}
|
|
exports.makePropDecorator = makePropDecorator;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1d2", ["1cc", "19c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var metadata_1 = $__require('1cc');
|
|
var decorators_1 = $__require('19c');
|
|
exports.Inject = decorators_1.makeParamDecorator(metadata_1.InjectMetadata);
|
|
exports.Optional = decorators_1.makeParamDecorator(metadata_1.OptionalMetadata);
|
|
exports.Injectable = decorators_1.makeDecorator(metadata_1.InjectableMetadata);
|
|
exports.Self = decorators_1.makeParamDecorator(metadata_1.SelfMetadata);
|
|
exports.Host = decorators_1.makeParamDecorator(metadata_1.HostMetadata);
|
|
exports.SkipSelf = decorators_1.makeParamDecorator(metadata_1.SkipSelfMetadata);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ea", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var process = module.exports = {};
|
|
var queue = [];
|
|
var draining = false;
|
|
var currentQueue;
|
|
var queueIndex = -1;
|
|
function cleanUpNextTick() {
|
|
draining = false;
|
|
if (currentQueue.length) {
|
|
queue = currentQueue.concat(queue);
|
|
} else {
|
|
queueIndex = -1;
|
|
}
|
|
if (queue.length) {
|
|
drainQueue();
|
|
}
|
|
}
|
|
function drainQueue() {
|
|
if (draining) {
|
|
return;
|
|
}
|
|
var timeout = setTimeout(cleanUpNextTick);
|
|
draining = true;
|
|
var len = queue.length;
|
|
while (len) {
|
|
currentQueue = queue;
|
|
queue = [];
|
|
while (++queueIndex < len) {
|
|
if (currentQueue) {
|
|
currentQueue[queueIndex].run();
|
|
}
|
|
}
|
|
queueIndex = -1;
|
|
len = queue.length;
|
|
}
|
|
currentQueue = null;
|
|
draining = false;
|
|
clearTimeout(timeout);
|
|
}
|
|
process.nextTick = function(fun) {
|
|
var args = new Array(arguments.length - 1);
|
|
if (arguments.length > 1) {
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
args[i - 1] = arguments[i];
|
|
}
|
|
}
|
|
queue.push(new Item(fun, args));
|
|
if (queue.length === 1 && !draining) {
|
|
setTimeout(drainQueue, 0);
|
|
}
|
|
};
|
|
function Item(fun, array) {
|
|
this.fun = fun;
|
|
this.array = array;
|
|
}
|
|
Item.prototype.run = function() {
|
|
this.fun.apply(null, this.array);
|
|
};
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
process.version = '';
|
|
process.versions = {};
|
|
function noop() {}
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
process.binding = function(name) {
|
|
throw new Error('process.binding is not supported');
|
|
};
|
|
process.cwd = function() {
|
|
return '/';
|
|
};
|
|
process.chdir = function(dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
process.umask = function() {
|
|
return 0;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1eb", ["1ea"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('1ea');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ec", ["1eb"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__System._nodeRequire ? process : $__require('1eb');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("34", ["1ec"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('1ec');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c9", ["37", "1c8", "1ed", "20", "1ee", "1cc", "34"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
(function(process) {
|
|
'use strict';
|
|
var collection_1 = $__require('37');
|
|
var provider_1 = $__require('1c8');
|
|
var exceptions_1 = $__require('1ed');
|
|
var lang_1 = $__require('20');
|
|
var key_1 = $__require('1ee');
|
|
var metadata_1 = $__require('1cc');
|
|
var _MAX_CONSTRUCTION_COUNTER = 10;
|
|
exports.UNDEFINED = lang_1.CONST_EXPR(new Object());
|
|
(function(Visibility) {
|
|
Visibility[Visibility["Public"] = 0] = "Public";
|
|
Visibility[Visibility["Private"] = 1] = "Private";
|
|
Visibility[Visibility["PublicAndPrivate"] = 2] = "PublicAndPrivate";
|
|
})(exports.Visibility || (exports.Visibility = {}));
|
|
var Visibility = exports.Visibility;
|
|
function canSee(src, dst) {
|
|
return (src === dst) || (dst === Visibility.PublicAndPrivate || src === Visibility.PublicAndPrivate);
|
|
}
|
|
var ProtoInjectorInlineStrategy = (function() {
|
|
function ProtoInjectorInlineStrategy(protoEI, bwv) {
|
|
this.provider0 = null;
|
|
this.provider1 = null;
|
|
this.provider2 = null;
|
|
this.provider3 = null;
|
|
this.provider4 = null;
|
|
this.provider5 = null;
|
|
this.provider6 = null;
|
|
this.provider7 = null;
|
|
this.provider8 = null;
|
|
this.provider9 = null;
|
|
this.keyId0 = null;
|
|
this.keyId1 = null;
|
|
this.keyId2 = null;
|
|
this.keyId3 = null;
|
|
this.keyId4 = null;
|
|
this.keyId5 = null;
|
|
this.keyId6 = null;
|
|
this.keyId7 = null;
|
|
this.keyId8 = null;
|
|
this.keyId9 = null;
|
|
this.visibility0 = null;
|
|
this.visibility1 = null;
|
|
this.visibility2 = null;
|
|
this.visibility3 = null;
|
|
this.visibility4 = null;
|
|
this.visibility5 = null;
|
|
this.visibility6 = null;
|
|
this.visibility7 = null;
|
|
this.visibility8 = null;
|
|
this.visibility9 = null;
|
|
var length = bwv.length;
|
|
if (length > 0) {
|
|
this.provider0 = bwv[0].provider;
|
|
this.keyId0 = bwv[0].getKeyId();
|
|
this.visibility0 = bwv[0].visibility;
|
|
}
|
|
if (length > 1) {
|
|
this.provider1 = bwv[1].provider;
|
|
this.keyId1 = bwv[1].getKeyId();
|
|
this.visibility1 = bwv[1].visibility;
|
|
}
|
|
if (length > 2) {
|
|
this.provider2 = bwv[2].provider;
|
|
this.keyId2 = bwv[2].getKeyId();
|
|
this.visibility2 = bwv[2].visibility;
|
|
}
|
|
if (length > 3) {
|
|
this.provider3 = bwv[3].provider;
|
|
this.keyId3 = bwv[3].getKeyId();
|
|
this.visibility3 = bwv[3].visibility;
|
|
}
|
|
if (length > 4) {
|
|
this.provider4 = bwv[4].provider;
|
|
this.keyId4 = bwv[4].getKeyId();
|
|
this.visibility4 = bwv[4].visibility;
|
|
}
|
|
if (length > 5) {
|
|
this.provider5 = bwv[5].provider;
|
|
this.keyId5 = bwv[5].getKeyId();
|
|
this.visibility5 = bwv[5].visibility;
|
|
}
|
|
if (length > 6) {
|
|
this.provider6 = bwv[6].provider;
|
|
this.keyId6 = bwv[6].getKeyId();
|
|
this.visibility6 = bwv[6].visibility;
|
|
}
|
|
if (length > 7) {
|
|
this.provider7 = bwv[7].provider;
|
|
this.keyId7 = bwv[7].getKeyId();
|
|
this.visibility7 = bwv[7].visibility;
|
|
}
|
|
if (length > 8) {
|
|
this.provider8 = bwv[8].provider;
|
|
this.keyId8 = bwv[8].getKeyId();
|
|
this.visibility8 = bwv[8].visibility;
|
|
}
|
|
if (length > 9) {
|
|
this.provider9 = bwv[9].provider;
|
|
this.keyId9 = bwv[9].getKeyId();
|
|
this.visibility9 = bwv[9].visibility;
|
|
}
|
|
}
|
|
ProtoInjectorInlineStrategy.prototype.getProviderAtIndex = function(index) {
|
|
if (index == 0)
|
|
return this.provider0;
|
|
if (index == 1)
|
|
return this.provider1;
|
|
if (index == 2)
|
|
return this.provider2;
|
|
if (index == 3)
|
|
return this.provider3;
|
|
if (index == 4)
|
|
return this.provider4;
|
|
if (index == 5)
|
|
return this.provider5;
|
|
if (index == 6)
|
|
return this.provider6;
|
|
if (index == 7)
|
|
return this.provider7;
|
|
if (index == 8)
|
|
return this.provider8;
|
|
if (index == 9)
|
|
return this.provider9;
|
|
throw new exceptions_1.OutOfBoundsError(index);
|
|
};
|
|
ProtoInjectorInlineStrategy.prototype.createInjectorStrategy = function(injector) {
|
|
return new InjectorInlineStrategy(injector, this);
|
|
};
|
|
return ProtoInjectorInlineStrategy;
|
|
})();
|
|
exports.ProtoInjectorInlineStrategy = ProtoInjectorInlineStrategy;
|
|
var ProtoInjectorDynamicStrategy = (function() {
|
|
function ProtoInjectorDynamicStrategy(protoInj, bwv) {
|
|
var len = bwv.length;
|
|
this.providers = collection_1.ListWrapper.createFixedSize(len);
|
|
this.keyIds = collection_1.ListWrapper.createFixedSize(len);
|
|
this.visibilities = collection_1.ListWrapper.createFixedSize(len);
|
|
for (var i = 0; i < len; i++) {
|
|
this.providers[i] = bwv[i].provider;
|
|
this.keyIds[i] = bwv[i].getKeyId();
|
|
this.visibilities[i] = bwv[i].visibility;
|
|
}
|
|
}
|
|
ProtoInjectorDynamicStrategy.prototype.getProviderAtIndex = function(index) {
|
|
if (index < 0 || index >= this.providers.length) {
|
|
throw new exceptions_1.OutOfBoundsError(index);
|
|
}
|
|
return this.providers[index];
|
|
};
|
|
ProtoInjectorDynamicStrategy.prototype.createInjectorStrategy = function(ei) {
|
|
return new InjectorDynamicStrategy(this, ei);
|
|
};
|
|
return ProtoInjectorDynamicStrategy;
|
|
})();
|
|
exports.ProtoInjectorDynamicStrategy = ProtoInjectorDynamicStrategy;
|
|
var ProtoInjector = (function() {
|
|
function ProtoInjector(bwv) {
|
|
this.numberOfProviders = bwv.length;
|
|
this._strategy = bwv.length > _MAX_CONSTRUCTION_COUNTER ? new ProtoInjectorDynamicStrategy(this, bwv) : new ProtoInjectorInlineStrategy(this, bwv);
|
|
}
|
|
ProtoInjector.prototype.getProviderAtIndex = function(index) {
|
|
return this._strategy.getProviderAtIndex(index);
|
|
};
|
|
return ProtoInjector;
|
|
})();
|
|
exports.ProtoInjector = ProtoInjector;
|
|
var InjectorInlineStrategy = (function() {
|
|
function InjectorInlineStrategy(injector, protoStrategy) {
|
|
this.injector = injector;
|
|
this.protoStrategy = protoStrategy;
|
|
this.obj0 = exports.UNDEFINED;
|
|
this.obj1 = exports.UNDEFINED;
|
|
this.obj2 = exports.UNDEFINED;
|
|
this.obj3 = exports.UNDEFINED;
|
|
this.obj4 = exports.UNDEFINED;
|
|
this.obj5 = exports.UNDEFINED;
|
|
this.obj6 = exports.UNDEFINED;
|
|
this.obj7 = exports.UNDEFINED;
|
|
this.obj8 = exports.UNDEFINED;
|
|
this.obj9 = exports.UNDEFINED;
|
|
}
|
|
InjectorInlineStrategy.prototype.resetConstructionCounter = function() {
|
|
this.injector._constructionCounter = 0;
|
|
};
|
|
InjectorInlineStrategy.prototype.instantiateProvider = function(provider, visibility) {
|
|
return this.injector._new(provider, visibility);
|
|
};
|
|
InjectorInlineStrategy.prototype.attach = function(parent, isHost) {
|
|
var inj = this.injector;
|
|
inj._parent = parent;
|
|
inj._isHost = isHost;
|
|
};
|
|
InjectorInlineStrategy.prototype.getObjByKeyId = function(keyId, visibility) {
|
|
var p = this.protoStrategy;
|
|
var inj = this.injector;
|
|
if (p.keyId0 === keyId && canSee(p.visibility0, visibility)) {
|
|
if (this.obj0 === exports.UNDEFINED) {
|
|
this.obj0 = inj._new(p.provider0, p.visibility0);
|
|
}
|
|
return this.obj0;
|
|
}
|
|
if (p.keyId1 === keyId && canSee(p.visibility1, visibility)) {
|
|
if (this.obj1 === exports.UNDEFINED) {
|
|
this.obj1 = inj._new(p.provider1, p.visibility1);
|
|
}
|
|
return this.obj1;
|
|
}
|
|
if (p.keyId2 === keyId && canSee(p.visibility2, visibility)) {
|
|
if (this.obj2 === exports.UNDEFINED) {
|
|
this.obj2 = inj._new(p.provider2, p.visibility2);
|
|
}
|
|
return this.obj2;
|
|
}
|
|
if (p.keyId3 === keyId && canSee(p.visibility3, visibility)) {
|
|
if (this.obj3 === exports.UNDEFINED) {
|
|
this.obj3 = inj._new(p.provider3, p.visibility3);
|
|
}
|
|
return this.obj3;
|
|
}
|
|
if (p.keyId4 === keyId && canSee(p.visibility4, visibility)) {
|
|
if (this.obj4 === exports.UNDEFINED) {
|
|
this.obj4 = inj._new(p.provider4, p.visibility4);
|
|
}
|
|
return this.obj4;
|
|
}
|
|
if (p.keyId5 === keyId && canSee(p.visibility5, visibility)) {
|
|
if (this.obj5 === exports.UNDEFINED) {
|
|
this.obj5 = inj._new(p.provider5, p.visibility5);
|
|
}
|
|
return this.obj5;
|
|
}
|
|
if (p.keyId6 === keyId && canSee(p.visibility6, visibility)) {
|
|
if (this.obj6 === exports.UNDEFINED) {
|
|
this.obj6 = inj._new(p.provider6, p.visibility6);
|
|
}
|
|
return this.obj6;
|
|
}
|
|
if (p.keyId7 === keyId && canSee(p.visibility7, visibility)) {
|
|
if (this.obj7 === exports.UNDEFINED) {
|
|
this.obj7 = inj._new(p.provider7, p.visibility7);
|
|
}
|
|
return this.obj7;
|
|
}
|
|
if (p.keyId8 === keyId && canSee(p.visibility8, visibility)) {
|
|
if (this.obj8 === exports.UNDEFINED) {
|
|
this.obj8 = inj._new(p.provider8, p.visibility8);
|
|
}
|
|
return this.obj8;
|
|
}
|
|
if (p.keyId9 === keyId && canSee(p.visibility9, visibility)) {
|
|
if (this.obj9 === exports.UNDEFINED) {
|
|
this.obj9 = inj._new(p.provider9, p.visibility9);
|
|
}
|
|
return this.obj9;
|
|
}
|
|
return exports.UNDEFINED;
|
|
};
|
|
InjectorInlineStrategy.prototype.getObjAtIndex = function(index) {
|
|
if (index == 0)
|
|
return this.obj0;
|
|
if (index == 1)
|
|
return this.obj1;
|
|
if (index == 2)
|
|
return this.obj2;
|
|
if (index == 3)
|
|
return this.obj3;
|
|
if (index == 4)
|
|
return this.obj4;
|
|
if (index == 5)
|
|
return this.obj5;
|
|
if (index == 6)
|
|
return this.obj6;
|
|
if (index == 7)
|
|
return this.obj7;
|
|
if (index == 8)
|
|
return this.obj8;
|
|
if (index == 9)
|
|
return this.obj9;
|
|
throw new exceptions_1.OutOfBoundsError(index);
|
|
};
|
|
InjectorInlineStrategy.prototype.getMaxNumberOfObjects = function() {
|
|
return _MAX_CONSTRUCTION_COUNTER;
|
|
};
|
|
return InjectorInlineStrategy;
|
|
})();
|
|
exports.InjectorInlineStrategy = InjectorInlineStrategy;
|
|
var InjectorDynamicStrategy = (function() {
|
|
function InjectorDynamicStrategy(protoStrategy, injector) {
|
|
this.protoStrategy = protoStrategy;
|
|
this.injector = injector;
|
|
this.objs = collection_1.ListWrapper.createFixedSize(protoStrategy.providers.length);
|
|
collection_1.ListWrapper.fill(this.objs, exports.UNDEFINED);
|
|
}
|
|
InjectorDynamicStrategy.prototype.resetConstructionCounter = function() {
|
|
this.injector._constructionCounter = 0;
|
|
};
|
|
InjectorDynamicStrategy.prototype.instantiateProvider = function(provider, visibility) {
|
|
return this.injector._new(provider, visibility);
|
|
};
|
|
InjectorDynamicStrategy.prototype.attach = function(parent, isHost) {
|
|
var inj = this.injector;
|
|
inj._parent = parent;
|
|
inj._isHost = isHost;
|
|
};
|
|
InjectorDynamicStrategy.prototype.getObjByKeyId = function(keyId, visibility) {
|
|
var p = this.protoStrategy;
|
|
for (var i = 0; i < p.keyIds.length; i++) {
|
|
if (p.keyIds[i] === keyId && canSee(p.visibilities[i], visibility)) {
|
|
if (this.objs[i] === exports.UNDEFINED) {
|
|
this.objs[i] = this.injector._new(p.providers[i], p.visibilities[i]);
|
|
}
|
|
return this.objs[i];
|
|
}
|
|
}
|
|
return exports.UNDEFINED;
|
|
};
|
|
InjectorDynamicStrategy.prototype.getObjAtIndex = function(index) {
|
|
if (index < 0 || index >= this.objs.length) {
|
|
throw new exceptions_1.OutOfBoundsError(index);
|
|
}
|
|
return this.objs[index];
|
|
};
|
|
InjectorDynamicStrategy.prototype.getMaxNumberOfObjects = function() {
|
|
return this.objs.length;
|
|
};
|
|
return InjectorDynamicStrategy;
|
|
})();
|
|
exports.InjectorDynamicStrategy = InjectorDynamicStrategy;
|
|
var ProviderWithVisibility = (function() {
|
|
function ProviderWithVisibility(provider, visibility) {
|
|
this.provider = provider;
|
|
this.visibility = visibility;
|
|
}
|
|
;
|
|
ProviderWithVisibility.prototype.getKeyId = function() {
|
|
return this.provider.key.id;
|
|
};
|
|
return ProviderWithVisibility;
|
|
})();
|
|
exports.ProviderWithVisibility = ProviderWithVisibility;
|
|
var Injector = (function() {
|
|
function Injector(_proto, _parent, _depProvider, _debugContext) {
|
|
if (_parent === void 0) {
|
|
_parent = null;
|
|
}
|
|
if (_depProvider === void 0) {
|
|
_depProvider = null;
|
|
}
|
|
if (_debugContext === void 0) {
|
|
_debugContext = null;
|
|
}
|
|
this._depProvider = _depProvider;
|
|
this._debugContext = _debugContext;
|
|
this._isHost = false;
|
|
this._constructionCounter = 0;
|
|
this._proto = _proto;
|
|
this._parent = _parent;
|
|
this._strategy = _proto._strategy.createInjectorStrategy(this);
|
|
}
|
|
Injector.resolve = function(providers) {
|
|
return provider_1.resolveProviders(providers);
|
|
};
|
|
Injector.resolveAndCreate = function(providers) {
|
|
var resolvedProviders = Injector.resolve(providers);
|
|
return Injector.fromResolvedProviders(resolvedProviders);
|
|
};
|
|
Injector.fromResolvedProviders = function(providers) {
|
|
var bd = providers.map(function(b) {
|
|
return new ProviderWithVisibility(b, Visibility.Public);
|
|
});
|
|
var proto = new ProtoInjector(bd);
|
|
return new Injector(proto, null, null);
|
|
};
|
|
Injector.fromResolvedBindings = function(providers) {
|
|
return Injector.fromResolvedProviders(providers);
|
|
};
|
|
Injector.prototype.debugContext = function() {
|
|
return this._debugContext();
|
|
};
|
|
Injector.prototype.get = function(token) {
|
|
return this._getByKey(key_1.Key.get(token), null, null, false, Visibility.PublicAndPrivate);
|
|
};
|
|
Injector.prototype.getOptional = function(token) {
|
|
return this._getByKey(key_1.Key.get(token), null, null, true, Visibility.PublicAndPrivate);
|
|
};
|
|
Injector.prototype.getAt = function(index) {
|
|
return this._strategy.getObjAtIndex(index);
|
|
};
|
|
Object.defineProperty(Injector.prototype, "parent", {
|
|
get: function() {
|
|
return this._parent;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Injector.prototype, "internalStrategy", {
|
|
get: function() {
|
|
return this._strategy;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Injector.prototype.resolveAndCreateChild = function(providers) {
|
|
var resolvedProviders = Injector.resolve(providers);
|
|
return this.createChildFromResolved(resolvedProviders);
|
|
};
|
|
Injector.prototype.createChildFromResolved = function(providers) {
|
|
var bd = providers.map(function(b) {
|
|
return new ProviderWithVisibility(b, Visibility.Public);
|
|
});
|
|
var proto = new ProtoInjector(bd);
|
|
var inj = new Injector(proto, null, null);
|
|
inj._parent = this;
|
|
return inj;
|
|
};
|
|
Injector.prototype.resolveAndInstantiate = function(provider) {
|
|
return this.instantiateResolved(Injector.resolve([provider])[0]);
|
|
};
|
|
Injector.prototype.instantiateResolved = function(provider) {
|
|
return this._instantiateProvider(provider, Visibility.PublicAndPrivate);
|
|
};
|
|
Injector.prototype._new = function(provider, visibility) {
|
|
if (this._constructionCounter++ > this._strategy.getMaxNumberOfObjects()) {
|
|
throw new exceptions_1.CyclicDependencyError(this, provider.key);
|
|
}
|
|
return this._instantiateProvider(provider, visibility);
|
|
};
|
|
Injector.prototype._instantiateProvider = function(provider, visibility) {
|
|
if (provider.multiProvider) {
|
|
var res = collection_1.ListWrapper.createFixedSize(provider.resolvedFactories.length);
|
|
for (var i = 0; i < provider.resolvedFactories.length; ++i) {
|
|
res[i] = this._instantiate(provider, provider.resolvedFactories[i], visibility);
|
|
}
|
|
return res;
|
|
} else {
|
|
return this._instantiate(provider, provider.resolvedFactories[0], visibility);
|
|
}
|
|
};
|
|
Injector.prototype._instantiate = function(provider, resolvedFactory, visibility) {
|
|
var factory = resolvedFactory.factory;
|
|
var deps = resolvedFactory.dependencies;
|
|
var length = deps.length;
|
|
var d0,
|
|
d1,
|
|
d2,
|
|
d3,
|
|
d4,
|
|
d5,
|
|
d6,
|
|
d7,
|
|
d8,
|
|
d9,
|
|
d10,
|
|
d11,
|
|
d12,
|
|
d13,
|
|
d14,
|
|
d15,
|
|
d16,
|
|
d17,
|
|
d18,
|
|
d19;
|
|
try {
|
|
d0 = length > 0 ? this._getByDependency(provider, deps[0], visibility) : null;
|
|
d1 = length > 1 ? this._getByDependency(provider, deps[1], visibility) : null;
|
|
d2 = length > 2 ? this._getByDependency(provider, deps[2], visibility) : null;
|
|
d3 = length > 3 ? this._getByDependency(provider, deps[3], visibility) : null;
|
|
d4 = length > 4 ? this._getByDependency(provider, deps[4], visibility) : null;
|
|
d5 = length > 5 ? this._getByDependency(provider, deps[5], visibility) : null;
|
|
d6 = length > 6 ? this._getByDependency(provider, deps[6], visibility) : null;
|
|
d7 = length > 7 ? this._getByDependency(provider, deps[7], visibility) : null;
|
|
d8 = length > 8 ? this._getByDependency(provider, deps[8], visibility) : null;
|
|
d9 = length > 9 ? this._getByDependency(provider, deps[9], visibility) : null;
|
|
d10 = length > 10 ? this._getByDependency(provider, deps[10], visibility) : null;
|
|
d11 = length > 11 ? this._getByDependency(provider, deps[11], visibility) : null;
|
|
d12 = length > 12 ? this._getByDependency(provider, deps[12], visibility) : null;
|
|
d13 = length > 13 ? this._getByDependency(provider, deps[13], visibility) : null;
|
|
d14 = length > 14 ? this._getByDependency(provider, deps[14], visibility) : null;
|
|
d15 = length > 15 ? this._getByDependency(provider, deps[15], visibility) : null;
|
|
d16 = length > 16 ? this._getByDependency(provider, deps[16], visibility) : null;
|
|
d17 = length > 17 ? this._getByDependency(provider, deps[17], visibility) : null;
|
|
d18 = length > 18 ? this._getByDependency(provider, deps[18], visibility) : null;
|
|
d19 = length > 19 ? this._getByDependency(provider, deps[19], visibility) : null;
|
|
} catch (e) {
|
|
if (e instanceof exceptions_1.AbstractProviderError || e instanceof exceptions_1.InstantiationError) {
|
|
e.addKey(this, provider.key);
|
|
}
|
|
throw e;
|
|
}
|
|
var obj;
|
|
try {
|
|
switch (length) {
|
|
case 0:
|
|
obj = factory();
|
|
break;
|
|
case 1:
|
|
obj = factory(d0);
|
|
break;
|
|
case 2:
|
|
obj = factory(d0, d1);
|
|
break;
|
|
case 3:
|
|
obj = factory(d0, d1, d2);
|
|
break;
|
|
case 4:
|
|
obj = factory(d0, d1, d2, d3);
|
|
break;
|
|
case 5:
|
|
obj = factory(d0, d1, d2, d3, d4);
|
|
break;
|
|
case 6:
|
|
obj = factory(d0, d1, d2, d3, d4, d5);
|
|
break;
|
|
case 7:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6);
|
|
break;
|
|
case 8:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7);
|
|
break;
|
|
case 9:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8);
|
|
break;
|
|
case 10:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9);
|
|
break;
|
|
case 11:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10);
|
|
break;
|
|
case 12:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11);
|
|
break;
|
|
case 13:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12);
|
|
break;
|
|
case 14:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13);
|
|
break;
|
|
case 15:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14);
|
|
break;
|
|
case 16:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15);
|
|
break;
|
|
case 17:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16);
|
|
break;
|
|
case 18:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17);
|
|
break;
|
|
case 19:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18);
|
|
break;
|
|
case 20:
|
|
obj = factory(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19);
|
|
break;
|
|
}
|
|
} catch (e) {
|
|
throw new exceptions_1.InstantiationError(this, e, e.stack, provider.key);
|
|
}
|
|
return obj;
|
|
};
|
|
Injector.prototype._getByDependency = function(provider, dep, providerVisibility) {
|
|
var special = lang_1.isPresent(this._depProvider) ? this._depProvider.getDependency(this, provider, dep) : exports.UNDEFINED;
|
|
if (special !== exports.UNDEFINED) {
|
|
return special;
|
|
} else {
|
|
return this._getByKey(dep.key, dep.lowerBoundVisibility, dep.upperBoundVisibility, dep.optional, providerVisibility);
|
|
}
|
|
};
|
|
Injector.prototype._getByKey = function(key, lowerBoundVisibility, upperBoundVisibility, optional, providerVisibility) {
|
|
if (key === INJECTOR_KEY) {
|
|
return this;
|
|
}
|
|
if (upperBoundVisibility instanceof metadata_1.SelfMetadata) {
|
|
return this._getByKeySelf(key, optional, providerVisibility);
|
|
} else if (upperBoundVisibility instanceof metadata_1.HostMetadata) {
|
|
return this._getByKeyHost(key, optional, providerVisibility, lowerBoundVisibility);
|
|
} else {
|
|
return this._getByKeyDefault(key, optional, providerVisibility, lowerBoundVisibility);
|
|
}
|
|
};
|
|
Injector.prototype._throwOrNull = function(key, optional) {
|
|
if (optional) {
|
|
return null;
|
|
} else {
|
|
throw new exceptions_1.NoProviderError(this, key);
|
|
}
|
|
};
|
|
Injector.prototype._getByKeySelf = function(key, optional, providerVisibility) {
|
|
var obj = this._strategy.getObjByKeyId(key.id, providerVisibility);
|
|
return (obj !== exports.UNDEFINED) ? obj : this._throwOrNull(key, optional);
|
|
};
|
|
Injector.prototype._getByKeyHost = function(key, optional, providerVisibility, lowerBoundVisibility) {
|
|
var inj = this;
|
|
if (lowerBoundVisibility instanceof metadata_1.SkipSelfMetadata) {
|
|
if (inj._isHost) {
|
|
return this._getPrivateDependency(key, optional, inj);
|
|
} else {
|
|
inj = inj._parent;
|
|
}
|
|
}
|
|
while (inj != null) {
|
|
var obj = inj._strategy.getObjByKeyId(key.id, providerVisibility);
|
|
if (obj !== exports.UNDEFINED)
|
|
return obj;
|
|
if (lang_1.isPresent(inj._parent) && inj._isHost) {
|
|
return this._getPrivateDependency(key, optional, inj);
|
|
} else {
|
|
inj = inj._parent;
|
|
}
|
|
}
|
|
return this._throwOrNull(key, optional);
|
|
};
|
|
Injector.prototype._getPrivateDependency = function(key, optional, inj) {
|
|
var obj = inj._parent._strategy.getObjByKeyId(key.id, Visibility.Private);
|
|
return (obj !== exports.UNDEFINED) ? obj : this._throwOrNull(key, optional);
|
|
};
|
|
Injector.prototype._getByKeyDefault = function(key, optional, providerVisibility, lowerBoundVisibility) {
|
|
var inj = this;
|
|
if (lowerBoundVisibility instanceof metadata_1.SkipSelfMetadata) {
|
|
providerVisibility = inj._isHost ? Visibility.PublicAndPrivate : Visibility.Public;
|
|
inj = inj._parent;
|
|
}
|
|
while (inj != null) {
|
|
var obj = inj._strategy.getObjByKeyId(key.id, providerVisibility);
|
|
if (obj !== exports.UNDEFINED)
|
|
return obj;
|
|
providerVisibility = inj._isHost ? Visibility.PublicAndPrivate : Visibility.Public;
|
|
inj = inj._parent;
|
|
}
|
|
return this._throwOrNull(key, optional);
|
|
};
|
|
Object.defineProperty(Injector.prototype, "displayName", {
|
|
get: function() {
|
|
return "Injector(providers: [" + _mapProviders(this, function(b) {
|
|
return (" \"" + b.key.displayName + "\" ");
|
|
}).join(", ") + "])";
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Injector.prototype.toString = function() {
|
|
return this.displayName;
|
|
};
|
|
return Injector;
|
|
})();
|
|
exports.Injector = Injector;
|
|
var INJECTOR_KEY = key_1.Key.get(Injector);
|
|
function _mapProviders(injector, fn) {
|
|
var res = [];
|
|
for (var i = 0; i < injector._proto.numberOfProviders; ++i) {
|
|
res.push(fn(injector._proto.getProviderAtIndex(i)));
|
|
}
|
|
return res;
|
|
}
|
|
})($__require('34'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1cc", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var InjectMetadata = (function() {
|
|
function InjectMetadata(token) {
|
|
this.token = token;
|
|
}
|
|
InjectMetadata.prototype.toString = function() {
|
|
return "@Inject(" + lang_1.stringify(this.token) + ")";
|
|
};
|
|
InjectMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], InjectMetadata);
|
|
return InjectMetadata;
|
|
})();
|
|
exports.InjectMetadata = InjectMetadata;
|
|
var OptionalMetadata = (function() {
|
|
function OptionalMetadata() {}
|
|
OptionalMetadata.prototype.toString = function() {
|
|
return "@Optional()";
|
|
};
|
|
OptionalMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], OptionalMetadata);
|
|
return OptionalMetadata;
|
|
})();
|
|
exports.OptionalMetadata = OptionalMetadata;
|
|
var DependencyMetadata = (function() {
|
|
function DependencyMetadata() {}
|
|
Object.defineProperty(DependencyMetadata.prototype, "token", {
|
|
get: function() {
|
|
return null;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
DependencyMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], DependencyMetadata);
|
|
return DependencyMetadata;
|
|
})();
|
|
exports.DependencyMetadata = DependencyMetadata;
|
|
var InjectableMetadata = (function() {
|
|
function InjectableMetadata() {}
|
|
InjectableMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], InjectableMetadata);
|
|
return InjectableMetadata;
|
|
})();
|
|
exports.InjectableMetadata = InjectableMetadata;
|
|
var SelfMetadata = (function() {
|
|
function SelfMetadata() {}
|
|
SelfMetadata.prototype.toString = function() {
|
|
return "@Self()";
|
|
};
|
|
SelfMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], SelfMetadata);
|
|
return SelfMetadata;
|
|
})();
|
|
exports.SelfMetadata = SelfMetadata;
|
|
var SkipSelfMetadata = (function() {
|
|
function SkipSelfMetadata() {}
|
|
SkipSelfMetadata.prototype.toString = function() {
|
|
return "@SkipSelf()";
|
|
};
|
|
SkipSelfMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], SkipSelfMetadata);
|
|
return SkipSelfMetadata;
|
|
})();
|
|
exports.SkipSelfMetadata = SkipSelfMetadata;
|
|
var HostMetadata = (function() {
|
|
function HostMetadata() {}
|
|
HostMetadata.prototype.toString = function() {
|
|
return "@Host()";
|
|
};
|
|
HostMetadata = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [])], HostMetadata);
|
|
return HostMetadata;
|
|
})();
|
|
exports.HostMetadata = HostMetadata;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1c8", ["20", "3c", "37", "81", "1ee", "1cc", "1ed", "1ef"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var reflection_1 = $__require('81');
|
|
var key_1 = $__require('1ee');
|
|
var metadata_1 = $__require('1cc');
|
|
var exceptions_2 = $__require('1ed');
|
|
var forward_ref_1 = $__require('1ef');
|
|
var Dependency = (function() {
|
|
function Dependency(key, optional, lowerBoundVisibility, upperBoundVisibility, properties) {
|
|
this.key = key;
|
|
this.optional = optional;
|
|
this.lowerBoundVisibility = lowerBoundVisibility;
|
|
this.upperBoundVisibility = upperBoundVisibility;
|
|
this.properties = properties;
|
|
}
|
|
Dependency.fromKey = function(key) {
|
|
return new Dependency(key, false, null, null, []);
|
|
};
|
|
return Dependency;
|
|
})();
|
|
exports.Dependency = Dependency;
|
|
var _EMPTY_LIST = lang_1.CONST_EXPR([]);
|
|
var Provider = (function() {
|
|
function Provider(token, _a) {
|
|
var useClass = _a.useClass,
|
|
useValue = _a.useValue,
|
|
useExisting = _a.useExisting,
|
|
useFactory = _a.useFactory,
|
|
deps = _a.deps,
|
|
multi = _a.multi;
|
|
this.token = token;
|
|
this.useClass = useClass;
|
|
this.useValue = useValue;
|
|
this.useExisting = useExisting;
|
|
this.useFactory = useFactory;
|
|
this.dependencies = deps;
|
|
this._multi = multi;
|
|
}
|
|
Object.defineProperty(Provider.prototype, "multi", {
|
|
get: function() {
|
|
return lang_1.normalizeBool(this._multi);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Provider = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object, Object])], Provider);
|
|
return Provider;
|
|
})();
|
|
exports.Provider = Provider;
|
|
var Binding = (function(_super) {
|
|
__extends(Binding, _super);
|
|
function Binding(token, _a) {
|
|
var toClass = _a.toClass,
|
|
toValue = _a.toValue,
|
|
toAlias = _a.toAlias,
|
|
toFactory = _a.toFactory,
|
|
deps = _a.deps,
|
|
multi = _a.multi;
|
|
_super.call(this, token, {
|
|
useClass: toClass,
|
|
useValue: toValue,
|
|
useExisting: toAlias,
|
|
useFactory: toFactory,
|
|
deps: deps,
|
|
multi: multi
|
|
});
|
|
}
|
|
Object.defineProperty(Binding.prototype, "toClass", {
|
|
get: function() {
|
|
return this.useClass;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Binding.prototype, "toAlias", {
|
|
get: function() {
|
|
return this.useExisting;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Binding.prototype, "toFactory", {
|
|
get: function() {
|
|
return this.useFactory;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(Binding.prototype, "toValue", {
|
|
get: function() {
|
|
return this.useValue;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Binding = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object, Object])], Binding);
|
|
return Binding;
|
|
})(Provider);
|
|
exports.Binding = Binding;
|
|
var ResolvedProvider_ = (function() {
|
|
function ResolvedProvider_(key, resolvedFactories, multiProvider) {
|
|
this.key = key;
|
|
this.resolvedFactories = resolvedFactories;
|
|
this.multiProvider = multiProvider;
|
|
}
|
|
Object.defineProperty(ResolvedProvider_.prototype, "resolvedFactory", {
|
|
get: function() {
|
|
return this.resolvedFactories[0];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ResolvedProvider_;
|
|
})();
|
|
exports.ResolvedProvider_ = ResolvedProvider_;
|
|
var ResolvedFactory = (function() {
|
|
function ResolvedFactory(factory, dependencies) {
|
|
this.factory = factory;
|
|
this.dependencies = dependencies;
|
|
}
|
|
return ResolvedFactory;
|
|
})();
|
|
exports.ResolvedFactory = ResolvedFactory;
|
|
function bind(token) {
|
|
return new ProviderBuilder(token);
|
|
}
|
|
exports.bind = bind;
|
|
function provide(token, _a) {
|
|
var useClass = _a.useClass,
|
|
useValue = _a.useValue,
|
|
useExisting = _a.useExisting,
|
|
useFactory = _a.useFactory,
|
|
deps = _a.deps,
|
|
multi = _a.multi;
|
|
return new Provider(token, {
|
|
useClass: useClass,
|
|
useValue: useValue,
|
|
useExisting: useExisting,
|
|
useFactory: useFactory,
|
|
deps: deps,
|
|
multi: multi
|
|
});
|
|
}
|
|
exports.provide = provide;
|
|
var ProviderBuilder = (function() {
|
|
function ProviderBuilder(token) {
|
|
this.token = token;
|
|
}
|
|
ProviderBuilder.prototype.toClass = function(type) {
|
|
if (!lang_1.isType(type)) {
|
|
throw new exceptions_1.BaseException("Trying to create a class provider but \"" + lang_1.stringify(type) + "\" is not a class!");
|
|
}
|
|
return new Provider(this.token, {useClass: type});
|
|
};
|
|
ProviderBuilder.prototype.toValue = function(value) {
|
|
return new Provider(this.token, {useValue: value});
|
|
};
|
|
ProviderBuilder.prototype.toAlias = function(aliasToken) {
|
|
if (lang_1.isBlank(aliasToken)) {
|
|
throw new exceptions_1.BaseException("Can not alias " + lang_1.stringify(this.token) + " to a blank value!");
|
|
}
|
|
return new Provider(this.token, {useExisting: aliasToken});
|
|
};
|
|
ProviderBuilder.prototype.toFactory = function(factory, dependencies) {
|
|
if (!lang_1.isFunction(factory)) {
|
|
throw new exceptions_1.BaseException("Trying to create a factory provider but \"" + lang_1.stringify(factory) + "\" is not a function!");
|
|
}
|
|
return new Provider(this.token, {
|
|
useFactory: factory,
|
|
deps: dependencies
|
|
});
|
|
};
|
|
return ProviderBuilder;
|
|
})();
|
|
exports.ProviderBuilder = ProviderBuilder;
|
|
function resolveFactory(provider) {
|
|
var factoryFn;
|
|
var resolvedDeps;
|
|
if (lang_1.isPresent(provider.useClass)) {
|
|
var useClass = forward_ref_1.resolveForwardRef(provider.useClass);
|
|
factoryFn = reflection_1.reflector.factory(useClass);
|
|
resolvedDeps = _dependenciesFor(useClass);
|
|
} else if (lang_1.isPresent(provider.useExisting)) {
|
|
factoryFn = function(aliasInstance) {
|
|
return aliasInstance;
|
|
};
|
|
resolvedDeps = [Dependency.fromKey(key_1.Key.get(provider.useExisting))];
|
|
} else if (lang_1.isPresent(provider.useFactory)) {
|
|
factoryFn = provider.useFactory;
|
|
resolvedDeps = _constructDependencies(provider.useFactory, provider.dependencies);
|
|
} else {
|
|
factoryFn = function() {
|
|
return provider.useValue;
|
|
};
|
|
resolvedDeps = _EMPTY_LIST;
|
|
}
|
|
return new ResolvedFactory(factoryFn, resolvedDeps);
|
|
}
|
|
exports.resolveFactory = resolveFactory;
|
|
function resolveProvider(provider) {
|
|
return new ResolvedProvider_(key_1.Key.get(provider.token), [resolveFactory(provider)], false);
|
|
}
|
|
exports.resolveProvider = resolveProvider;
|
|
function resolveProviders(providers) {
|
|
var normalized = _createListOfProviders(_normalizeProviders(providers, new Map()));
|
|
return normalized.map(function(b) {
|
|
if (b instanceof _NormalizedProvider) {
|
|
return new ResolvedProvider_(b.key, [b.resolvedFactory], false);
|
|
} else {
|
|
var arr = b;
|
|
return new ResolvedProvider_(arr[0].key, arr.map(function(_) {
|
|
return _.resolvedFactory;
|
|
}), true);
|
|
}
|
|
});
|
|
}
|
|
exports.resolveProviders = resolveProviders;
|
|
var _NormalizedProvider = (function() {
|
|
function _NormalizedProvider(key, resolvedFactory) {
|
|
this.key = key;
|
|
this.resolvedFactory = resolvedFactory;
|
|
}
|
|
return _NormalizedProvider;
|
|
})();
|
|
function _createListOfProviders(flattenedProviders) {
|
|
return collection_1.MapWrapper.values(flattenedProviders);
|
|
}
|
|
function _normalizeProviders(providers, res) {
|
|
providers.forEach(function(b) {
|
|
if (b instanceof lang_1.Type) {
|
|
_normalizeProvider(provide(b, {useClass: b}), res);
|
|
} else if (b instanceof Provider) {
|
|
_normalizeProvider(b, res);
|
|
} else if (b instanceof Array) {
|
|
_normalizeProviders(b, res);
|
|
} else if (b instanceof ProviderBuilder) {
|
|
throw new exceptions_2.InvalidProviderError(b.token);
|
|
} else {
|
|
throw new exceptions_2.InvalidProviderError(b);
|
|
}
|
|
});
|
|
return res;
|
|
}
|
|
function _normalizeProvider(b, res) {
|
|
var key = key_1.Key.get(b.token);
|
|
var factory = resolveFactory(b);
|
|
var normalized = new _NormalizedProvider(key, factory);
|
|
if (b.multi) {
|
|
var existingProvider = res.get(key.id);
|
|
if (existingProvider instanceof Array) {
|
|
existingProvider.push(normalized);
|
|
} else if (lang_1.isBlank(existingProvider)) {
|
|
res.set(key.id, [normalized]);
|
|
} else {
|
|
throw new exceptions_2.MixingMultiProvidersWithRegularProvidersError(existingProvider, b);
|
|
}
|
|
} else {
|
|
var existingProvider = res.get(key.id);
|
|
if (existingProvider instanceof Array) {
|
|
throw new exceptions_2.MixingMultiProvidersWithRegularProvidersError(existingProvider, b);
|
|
}
|
|
res.set(key.id, normalized);
|
|
}
|
|
}
|
|
function _constructDependencies(factoryFunction, dependencies) {
|
|
if (lang_1.isBlank(dependencies)) {
|
|
return _dependenciesFor(factoryFunction);
|
|
} else {
|
|
var params = dependencies.map(function(t) {
|
|
return [t];
|
|
});
|
|
return dependencies.map(function(t) {
|
|
return _extractToken(factoryFunction, t, params);
|
|
});
|
|
}
|
|
}
|
|
function _dependenciesFor(typeOrFunc) {
|
|
var params = reflection_1.reflector.parameters(typeOrFunc);
|
|
if (lang_1.isBlank(params))
|
|
return [];
|
|
if (params.some(lang_1.isBlank)) {
|
|
throw new exceptions_2.NoAnnotationError(typeOrFunc, params);
|
|
}
|
|
return params.map(function(p) {
|
|
return _extractToken(typeOrFunc, p, params);
|
|
});
|
|
}
|
|
function _extractToken(typeOrFunc, metadata, params) {
|
|
var depProps = [];
|
|
var token = null;
|
|
var optional = false;
|
|
if (!lang_1.isArray(metadata)) {
|
|
if (metadata instanceof metadata_1.InjectMetadata) {
|
|
return _createDependency(metadata.token, optional, null, null, depProps);
|
|
} else {
|
|
return _createDependency(metadata, optional, null, null, depProps);
|
|
}
|
|
}
|
|
var lowerBoundVisibility = null;
|
|
var upperBoundVisibility = null;
|
|
for (var i = 0; i < metadata.length; ++i) {
|
|
var paramMetadata = metadata[i];
|
|
if (paramMetadata instanceof lang_1.Type) {
|
|
token = paramMetadata;
|
|
} else if (paramMetadata instanceof metadata_1.InjectMetadata) {
|
|
token = paramMetadata.token;
|
|
} else if (paramMetadata instanceof metadata_1.OptionalMetadata) {
|
|
optional = true;
|
|
} else if (paramMetadata instanceof metadata_1.SelfMetadata) {
|
|
upperBoundVisibility = paramMetadata;
|
|
} else if (paramMetadata instanceof metadata_1.HostMetadata) {
|
|
upperBoundVisibility = paramMetadata;
|
|
} else if (paramMetadata instanceof metadata_1.SkipSelfMetadata) {
|
|
lowerBoundVisibility = paramMetadata;
|
|
} else if (paramMetadata instanceof metadata_1.DependencyMetadata) {
|
|
if (lang_1.isPresent(paramMetadata.token)) {
|
|
token = paramMetadata.token;
|
|
}
|
|
depProps.push(paramMetadata);
|
|
}
|
|
}
|
|
token = forward_ref_1.resolveForwardRef(token);
|
|
if (lang_1.isPresent(token)) {
|
|
return _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps);
|
|
} else {
|
|
throw new exceptions_2.NoAnnotationError(typeOrFunc, params);
|
|
}
|
|
}
|
|
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps) {
|
|
return new Dependency(key_1.Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility, depProps);
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f0", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var TypeLiteral = (function() {
|
|
function TypeLiteral() {}
|
|
Object.defineProperty(TypeLiteral.prototype, "type", {
|
|
get: function() {
|
|
throw new Error("Type literals are only supported in Dart");
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return TypeLiteral;
|
|
})();
|
|
exports.TypeLiteral = TypeLiteral;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ef", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
function forwardRef(forwardRefFn) {
|
|
forwardRefFn.__forward_ref__ = forwardRef;
|
|
forwardRefFn.toString = function() {
|
|
return lang_1.stringify(this());
|
|
};
|
|
return forwardRefFn;
|
|
}
|
|
exports.forwardRef = forwardRef;
|
|
function resolveForwardRef(type) {
|
|
if (lang_1.isFunction(type) && type.hasOwnProperty('__forward_ref__') && type.__forward_ref__ === forwardRef) {
|
|
return type();
|
|
} else {
|
|
return type;
|
|
}
|
|
}
|
|
exports.resolveForwardRef = resolveForwardRef;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ee", ["20", "3c", "1f0", "1ef"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var type_literal_1 = $__require('1f0');
|
|
var forward_ref_1 = $__require('1ef');
|
|
var type_literal_2 = $__require('1f0');
|
|
exports.TypeLiteral = type_literal_2.TypeLiteral;
|
|
var Key = (function() {
|
|
function Key(token, id) {
|
|
this.token = token;
|
|
this.id = id;
|
|
if (lang_1.isBlank(token)) {
|
|
throw new exceptions_1.BaseException('Token must be defined!');
|
|
}
|
|
}
|
|
Object.defineProperty(Key.prototype, "displayName", {
|
|
get: function() {
|
|
return lang_1.stringify(this.token);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Key.get = function(token) {
|
|
return _globalKeyRegistry.get(forward_ref_1.resolveForwardRef(token));
|
|
};
|
|
Object.defineProperty(Key, "numberOfKeys", {
|
|
get: function() {
|
|
return _globalKeyRegistry.numberOfKeys;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return Key;
|
|
})();
|
|
exports.Key = Key;
|
|
var KeyRegistry = (function() {
|
|
function KeyRegistry() {
|
|
this._allKeys = new Map();
|
|
}
|
|
KeyRegistry.prototype.get = function(token) {
|
|
if (token instanceof Key)
|
|
return token;
|
|
var theToken = token;
|
|
if (token instanceof type_literal_1.TypeLiteral) {
|
|
theToken = token.type;
|
|
}
|
|
token = theToken;
|
|
if (this._allKeys.has(token)) {
|
|
return this._allKeys.get(token);
|
|
}
|
|
var newKey = new Key(token, Key.numberOfKeys);
|
|
this._allKeys.set(token, newKey);
|
|
return newKey;
|
|
};
|
|
Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
|
|
get: function() {
|
|
return this._allKeys.size;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return KeyRegistry;
|
|
})();
|
|
exports.KeyRegistry = KeyRegistry;
|
|
var _globalKeyRegistry = new KeyRegistry();
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ed", ["37", "20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var collection_1 = $__require('37');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
function findFirstClosedCycle(keys) {
|
|
var res = [];
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
if (collection_1.ListWrapper.contains(res, keys[i])) {
|
|
res.push(keys[i]);
|
|
return res;
|
|
} else {
|
|
res.push(keys[i]);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function constructResolvingPath(keys) {
|
|
if (keys.length > 1) {
|
|
var reversed = findFirstClosedCycle(collection_1.ListWrapper.reversed(keys));
|
|
var tokenStrs = reversed.map(function(k) {
|
|
return lang_1.stringify(k.token);
|
|
});
|
|
return " (" + tokenStrs.join(' -> ') + ")";
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
var AbstractProviderError = (function(_super) {
|
|
__extends(AbstractProviderError, _super);
|
|
function AbstractProviderError(injector, key, constructResolvingMessage) {
|
|
_super.call(this, "DI Exception");
|
|
this.keys = [key];
|
|
this.injectors = [injector];
|
|
this.constructResolvingMessage = constructResolvingMessage;
|
|
this.message = this.constructResolvingMessage(this.keys);
|
|
}
|
|
AbstractProviderError.prototype.addKey = function(injector, key) {
|
|
this.injectors.push(injector);
|
|
this.keys.push(key);
|
|
this.message = this.constructResolvingMessage(this.keys);
|
|
};
|
|
Object.defineProperty(AbstractProviderError.prototype, "context", {
|
|
get: function() {
|
|
return this.injectors[this.injectors.length - 1].debugContext();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return AbstractProviderError;
|
|
})(exceptions_1.BaseException);
|
|
exports.AbstractProviderError = AbstractProviderError;
|
|
var NoProviderError = (function(_super) {
|
|
__extends(NoProviderError, _super);
|
|
function NoProviderError(injector, key) {
|
|
_super.call(this, injector, key, function(keys) {
|
|
var first = lang_1.stringify(collection_1.ListWrapper.first(keys).token);
|
|
return "No provider for " + first + "!" + constructResolvingPath(keys);
|
|
});
|
|
}
|
|
return NoProviderError;
|
|
})(AbstractProviderError);
|
|
exports.NoProviderError = NoProviderError;
|
|
var CyclicDependencyError = (function(_super) {
|
|
__extends(CyclicDependencyError, _super);
|
|
function CyclicDependencyError(injector, key) {
|
|
_super.call(this, injector, key, function(keys) {
|
|
return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
|
|
});
|
|
}
|
|
return CyclicDependencyError;
|
|
})(AbstractProviderError);
|
|
exports.CyclicDependencyError = CyclicDependencyError;
|
|
var InstantiationError = (function(_super) {
|
|
__extends(InstantiationError, _super);
|
|
function InstantiationError(injector, originalException, originalStack, key) {
|
|
_super.call(this, "DI Exception", originalException, originalStack, null);
|
|
this.keys = [key];
|
|
this.injectors = [injector];
|
|
}
|
|
InstantiationError.prototype.addKey = function(injector, key) {
|
|
this.injectors.push(injector);
|
|
this.keys.push(key);
|
|
};
|
|
Object.defineProperty(InstantiationError.prototype, "wrapperMessage", {
|
|
get: function() {
|
|
var first = lang_1.stringify(collection_1.ListWrapper.first(this.keys).token);
|
|
return "Error during instantiation of " + first + "!" + constructResolvingPath(this.keys) + ".";
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(InstantiationError.prototype, "causeKey", {
|
|
get: function() {
|
|
return this.keys[0];
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(InstantiationError.prototype, "context", {
|
|
get: function() {
|
|
return this.injectors[this.injectors.length - 1].debugContext();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return InstantiationError;
|
|
})(exceptions_1.WrappedException);
|
|
exports.InstantiationError = InstantiationError;
|
|
var InvalidProviderError = (function(_super) {
|
|
__extends(InvalidProviderError, _super);
|
|
function InvalidProviderError(provider) {
|
|
_super.call(this, "Invalid provider - only instances of Provider and Type are allowed, got: " + provider.toString());
|
|
}
|
|
return InvalidProviderError;
|
|
})(exceptions_1.BaseException);
|
|
exports.InvalidProviderError = InvalidProviderError;
|
|
var NoAnnotationError = (function(_super) {
|
|
__extends(NoAnnotationError, _super);
|
|
function NoAnnotationError(typeOrFunc, params) {
|
|
_super.call(this, NoAnnotationError._genMessage(typeOrFunc, params));
|
|
}
|
|
NoAnnotationError._genMessage = function(typeOrFunc, params) {
|
|
var signature = [];
|
|
for (var i = 0,
|
|
ii = params.length; i < ii; i++) {
|
|
var parameter = params[i];
|
|
if (lang_1.isBlank(parameter) || parameter.length == 0) {
|
|
signature.push('?');
|
|
} else {
|
|
signature.push(parameter.map(lang_1.stringify).join(' '));
|
|
}
|
|
}
|
|
return "Cannot resolve all parameters for " + lang_1.stringify(typeOrFunc) + "(" + signature.join(', ') + "). " + 'Make sure they all have valid type or annotations.';
|
|
};
|
|
return NoAnnotationError;
|
|
})(exceptions_1.BaseException);
|
|
exports.NoAnnotationError = NoAnnotationError;
|
|
var OutOfBoundsError = (function(_super) {
|
|
__extends(OutOfBoundsError, _super);
|
|
function OutOfBoundsError(index) {
|
|
_super.call(this, "Index " + index + " is out-of-bounds.");
|
|
}
|
|
return OutOfBoundsError;
|
|
})(exceptions_1.BaseException);
|
|
exports.OutOfBoundsError = OutOfBoundsError;
|
|
var MixingMultiProvidersWithRegularProvidersError = (function(_super) {
|
|
__extends(MixingMultiProvidersWithRegularProvidersError, _super);
|
|
function MixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
|
|
_super.call(this, "Cannot mix multi providers and regular providers, got: " + provider1.toString() + " " + provider2.toString());
|
|
}
|
|
return MixingMultiProvidersWithRegularProvidersError;
|
|
})(exceptions_1.BaseException);
|
|
exports.MixingMultiProvidersWithRegularProvidersError = MixingMultiProvidersWithRegularProvidersError;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f1", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var OpaqueToken = (function() {
|
|
function OpaqueToken(_desc) {
|
|
this._desc = _desc;
|
|
}
|
|
OpaqueToken.prototype.toString = function() {
|
|
return "Token " + this._desc;
|
|
};
|
|
OpaqueToken = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], OpaqueToken);
|
|
return OpaqueToken;
|
|
})();
|
|
exports.OpaqueToken = OpaqueToken;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("39", ["1cc", "1d2", "1ef", "1c9", "1c8", "1ee", "1ed", "1f1"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
var metadata_1 = $__require('1cc');
|
|
exports.InjectMetadata = metadata_1.InjectMetadata;
|
|
exports.OptionalMetadata = metadata_1.OptionalMetadata;
|
|
exports.InjectableMetadata = metadata_1.InjectableMetadata;
|
|
exports.SelfMetadata = metadata_1.SelfMetadata;
|
|
exports.HostMetadata = metadata_1.HostMetadata;
|
|
exports.SkipSelfMetadata = metadata_1.SkipSelfMetadata;
|
|
exports.DependencyMetadata = metadata_1.DependencyMetadata;
|
|
__export($__require('1d2'));
|
|
var forward_ref_1 = $__require('1ef');
|
|
exports.forwardRef = forward_ref_1.forwardRef;
|
|
exports.resolveForwardRef = forward_ref_1.resolveForwardRef;
|
|
var injector_1 = $__require('1c9');
|
|
exports.Injector = injector_1.Injector;
|
|
var provider_1 = $__require('1c8');
|
|
exports.Binding = provider_1.Binding;
|
|
exports.ProviderBuilder = provider_1.ProviderBuilder;
|
|
exports.ResolvedFactory = provider_1.ResolvedFactory;
|
|
exports.Dependency = provider_1.Dependency;
|
|
exports.bind = provider_1.bind;
|
|
exports.Provider = provider_1.Provider;
|
|
exports.provide = provider_1.provide;
|
|
var key_1 = $__require('1ee');
|
|
exports.Key = key_1.Key;
|
|
exports.TypeLiteral = key_1.TypeLiteral;
|
|
var exceptions_1 = $__require('1ed');
|
|
exports.NoProviderError = exceptions_1.NoProviderError;
|
|
exports.AbstractProviderError = exceptions_1.AbstractProviderError;
|
|
exports.CyclicDependencyError = exceptions_1.CyclicDependencyError;
|
|
exports.InstantiationError = exceptions_1.InstantiationError;
|
|
exports.InvalidProviderError = exceptions_1.InvalidProviderError;
|
|
exports.NoAnnotationError = exceptions_1.NoAnnotationError;
|
|
exports.OutOfBoundsError = exceptions_1.OutOfBoundsError;
|
|
var opaque_token_1 = $__require('1f1');
|
|
exports.OpaqueToken = opaque_token_1.OpaqueToken;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("88", ["39", "20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
exports.APP_COMPONENT_REF_PROMISE = lang_1.CONST_EXPR(new di_1.OpaqueToken('Promise<ComponentRef>'));
|
|
exports.APP_COMPONENT = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppComponent'));
|
|
exports.APP_ID = lang_1.CONST_EXPR(new di_1.OpaqueToken('AppId'));
|
|
function _appIdRandomProviderFactory() {
|
|
return "" + _randomChar() + _randomChar() + _randomChar();
|
|
}
|
|
exports.APP_ID_RANDOM_PROVIDER = lang_1.CONST_EXPR(new di_1.Provider(exports.APP_ID, {
|
|
useFactory: _appIdRandomProviderFactory,
|
|
deps: []
|
|
}));
|
|
function _randomChar() {
|
|
return lang_1.StringWrapper.fromCharCode(97 + lang_1.Math.floor(lang_1.Math.random() * 25));
|
|
}
|
|
exports.PLATFORM_INITIALIZER = lang_1.CONST_EXPR(new di_1.OpaqueToken("Platform Initializer"));
|
|
exports.APP_INITIALIZER = lang_1.CONST_EXPR(new di_1.OpaqueToken("Application Initializer"));
|
|
exports.PACKAGE_ROOT_URL = lang_1.CONST_EXPR(new di_1.OpaqueToken("Application Packages Root URL"));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("61", ["20", "56", "39", "1c7", "1af", "1ab", "1b4", "1ae", "7e", "7f", "1cb", "7b", "82", "64", "88"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var lang_1 = $__require('20');
|
|
var api_1 = $__require('56');
|
|
var di_1 = $__require('39');
|
|
var pipe_provider_1 = $__require('1c7');
|
|
var pipes_1 = $__require('1af');
|
|
var view_1 = $__require('1ab');
|
|
var element_binder_1 = $__require('1b4');
|
|
var element_injector_1 = $__require('1ae');
|
|
var directive_resolver_1 = $__require('7e');
|
|
var view_resolver_1 = $__require('7f');
|
|
var pipe_resolver_1 = $__require('1cb');
|
|
var view_2 = $__require('7b');
|
|
var platform_directives_and_pipes_1 = $__require('82');
|
|
var template_commands_1 = $__require('64');
|
|
var api_2 = $__require('56');
|
|
var application_tokens_1 = $__require('88');
|
|
var ProtoViewFactory = (function() {
|
|
function ProtoViewFactory(_renderer, _platformPipes, _directiveResolver, _viewResolver, _pipeResolver, _appId) {
|
|
this._renderer = _renderer;
|
|
this._platformPipes = _platformPipes;
|
|
this._directiveResolver = _directiveResolver;
|
|
this._viewResolver = _viewResolver;
|
|
this._pipeResolver = _pipeResolver;
|
|
this._appId = _appId;
|
|
this._cache = new Map();
|
|
this._nextTemplateId = 0;
|
|
}
|
|
ProtoViewFactory.prototype.clearCache = function() {
|
|
this._cache.clear();
|
|
};
|
|
ProtoViewFactory.prototype.createHost = function(compiledHostTemplate) {
|
|
var compiledTemplate = compiledHostTemplate.template;
|
|
var result = this._cache.get(compiledTemplate.id);
|
|
if (lang_1.isBlank(result)) {
|
|
var emptyMap = {};
|
|
var shortId = this._appId + "-" + this._nextTemplateId++;
|
|
this._renderer.registerComponentTemplate(new api_1.RenderComponentTemplate(compiledTemplate.id, shortId, view_2.ViewEncapsulation.None, compiledTemplate.commands, []));
|
|
result = new view_1.AppProtoView(compiledTemplate.id, compiledTemplate.commands, view_1.ViewType.HOST, true, compiledTemplate.changeDetectorFactory, null, new pipes_1.ProtoPipes(emptyMap));
|
|
this._cache.set(compiledTemplate.id, result);
|
|
}
|
|
return result;
|
|
};
|
|
ProtoViewFactory.prototype._createComponent = function(cmd) {
|
|
var _this = this;
|
|
var nestedProtoView = this._cache.get(cmd.templateId);
|
|
if (lang_1.isBlank(nestedProtoView)) {
|
|
var component = cmd.directives[0];
|
|
var view = this._viewResolver.resolve(component);
|
|
var compiledTemplate = cmd.templateGetter();
|
|
var styles = _flattenStyleArr(compiledTemplate.styles, []);
|
|
var shortId = this._appId + "-" + this._nextTemplateId++;
|
|
this._renderer.registerComponentTemplate(new api_1.RenderComponentTemplate(compiledTemplate.id, shortId, cmd.encapsulation, compiledTemplate.commands, styles));
|
|
var boundPipes = this._flattenPipes(view).map(function(pipe) {
|
|
return _this._bindPipe(pipe);
|
|
});
|
|
nestedProtoView = new view_1.AppProtoView(compiledTemplate.id, compiledTemplate.commands, view_1.ViewType.COMPONENT, true, compiledTemplate.changeDetectorFactory, null, pipes_1.ProtoPipes.fromProviders(boundPipes));
|
|
this._cache.set(compiledTemplate.id, nestedProtoView);
|
|
this._initializeProtoView(nestedProtoView, null);
|
|
}
|
|
return nestedProtoView;
|
|
};
|
|
ProtoViewFactory.prototype._createEmbeddedTemplate = function(cmd, parent) {
|
|
var nestedProtoView = new view_1.AppProtoView(parent.templateId, cmd.children, view_1.ViewType.EMBEDDED, cmd.isMerged, cmd.changeDetectorFactory, arrayToMap(cmd.variableNameAndValues, true), new pipes_1.ProtoPipes(parent.pipes.config));
|
|
if (cmd.isMerged) {
|
|
this.initializeProtoViewIfNeeded(nestedProtoView);
|
|
}
|
|
return nestedProtoView;
|
|
};
|
|
ProtoViewFactory.prototype.initializeProtoViewIfNeeded = function(protoView) {
|
|
if (!protoView.isInitialized()) {
|
|
var render = this._renderer.createProtoView(protoView.templateId, protoView.templateCmds);
|
|
this._initializeProtoView(protoView, render);
|
|
}
|
|
};
|
|
ProtoViewFactory.prototype._initializeProtoView = function(protoView, render) {
|
|
var initializer = new _ProtoViewInitializer(protoView, this._directiveResolver, this);
|
|
template_commands_1.visitAllCommands(initializer, protoView.templateCmds);
|
|
var mergeInfo = new view_1.AppProtoViewMergeInfo(initializer.mergeEmbeddedViewCount, initializer.mergeElementCount, initializer.mergeViewCount);
|
|
protoView.init(render, initializer.elementBinders, initializer.boundTextCount, mergeInfo, initializer.variableLocations);
|
|
};
|
|
ProtoViewFactory.prototype._bindPipe = function(typeOrProvider) {
|
|
var meta = this._pipeResolver.resolve(typeOrProvider);
|
|
return pipe_provider_1.PipeProvider.createFromType(typeOrProvider, meta);
|
|
};
|
|
ProtoViewFactory.prototype._flattenPipes = function(view) {
|
|
var pipes = [];
|
|
if (lang_1.isPresent(this._platformPipes)) {
|
|
_flattenArray(this._platformPipes, pipes);
|
|
}
|
|
if (lang_1.isPresent(view.pipes)) {
|
|
_flattenArray(view.pipes, pipes);
|
|
}
|
|
return pipes;
|
|
};
|
|
ProtoViewFactory = __decorate([di_1.Injectable(), __param(1, di_1.Optional()), __param(1, di_1.Inject(platform_directives_and_pipes_1.PLATFORM_PIPES)), __param(5, di_1.Inject(application_tokens_1.APP_ID)), __metadata('design:paramtypes', [api_2.Renderer, Array, directive_resolver_1.DirectiveResolver, view_resolver_1.ViewResolver, pipe_resolver_1.PipeResolver, String])], ProtoViewFactory);
|
|
return ProtoViewFactory;
|
|
})();
|
|
exports.ProtoViewFactory = ProtoViewFactory;
|
|
function createComponent(protoViewFactory, cmd) {
|
|
return protoViewFactory._createComponent(cmd);
|
|
}
|
|
function createEmbeddedTemplate(protoViewFactory, cmd, parent) {
|
|
return protoViewFactory._createEmbeddedTemplate(cmd, parent);
|
|
}
|
|
var _ProtoViewInitializer = (function() {
|
|
function _ProtoViewInitializer(_protoView, _directiveResolver, _protoViewFactory) {
|
|
this._protoView = _protoView;
|
|
this._directiveResolver = _directiveResolver;
|
|
this._protoViewFactory = _protoViewFactory;
|
|
this.variableLocations = new Map();
|
|
this.boundTextCount = 0;
|
|
this.boundElementIndex = 0;
|
|
this.elementBinderStack = [];
|
|
this.distanceToParentElementBinder = 0;
|
|
this.distanceToParentProtoElementInjector = 0;
|
|
this.elementBinders = [];
|
|
this.mergeEmbeddedViewCount = 0;
|
|
this.mergeElementCount = 0;
|
|
this.mergeViewCount = 1;
|
|
}
|
|
_ProtoViewInitializer.prototype.visitText = function(cmd, context) {
|
|
if (cmd.isBound) {
|
|
this.boundTextCount++;
|
|
}
|
|
return null;
|
|
};
|
|
_ProtoViewInitializer.prototype.visitNgContent = function(cmd, context) {
|
|
return null;
|
|
};
|
|
_ProtoViewInitializer.prototype.visitBeginElement = function(cmd, context) {
|
|
if (cmd.isBound) {
|
|
this._visitBeginBoundElement(cmd, null);
|
|
} else {
|
|
this._visitBeginElement(cmd, null, null);
|
|
}
|
|
return null;
|
|
};
|
|
_ProtoViewInitializer.prototype.visitEndElement = function(context) {
|
|
return this._visitEndElement();
|
|
};
|
|
_ProtoViewInitializer.prototype.visitBeginComponent = function(cmd, context) {
|
|
var nestedProtoView = createComponent(this._protoViewFactory, cmd);
|
|
return this._visitBeginBoundElement(cmd, nestedProtoView);
|
|
};
|
|
_ProtoViewInitializer.prototype.visitEndComponent = function(context) {
|
|
return this._visitEndElement();
|
|
};
|
|
_ProtoViewInitializer.prototype.visitEmbeddedTemplate = function(cmd, context) {
|
|
var nestedProtoView = createEmbeddedTemplate(this._protoViewFactory, cmd, this._protoView);
|
|
if (cmd.isMerged) {
|
|
this.mergeEmbeddedViewCount++;
|
|
}
|
|
this._visitBeginBoundElement(cmd, nestedProtoView);
|
|
return this._visitEndElement();
|
|
};
|
|
_ProtoViewInitializer.prototype._visitBeginBoundElement = function(cmd, nestedProtoView) {
|
|
if (lang_1.isPresent(nestedProtoView) && nestedProtoView.isMergable) {
|
|
this.mergeElementCount += nestedProtoView.mergeInfo.elementCount;
|
|
this.mergeViewCount += nestedProtoView.mergeInfo.viewCount;
|
|
this.mergeEmbeddedViewCount += nestedProtoView.mergeInfo.embeddedViewCount;
|
|
}
|
|
var elementBinder = _createElementBinder(this._directiveResolver, nestedProtoView, this.elementBinderStack, this.boundElementIndex, this.distanceToParentElementBinder, this.distanceToParentProtoElementInjector, cmd);
|
|
this.elementBinders.push(elementBinder);
|
|
var protoElementInjector = elementBinder.protoElementInjector;
|
|
for (var i = 0; i < cmd.variableNameAndValues.length; i += 2) {
|
|
this.variableLocations.set(cmd.variableNameAndValues[i], this.boundElementIndex);
|
|
}
|
|
this.boundElementIndex++;
|
|
this.mergeElementCount++;
|
|
return this._visitBeginElement(cmd, elementBinder, protoElementInjector);
|
|
};
|
|
_ProtoViewInitializer.prototype._visitBeginElement = function(cmd, elementBinder, protoElementInjector) {
|
|
this.distanceToParentElementBinder = lang_1.isPresent(elementBinder) ? 1 : this.distanceToParentElementBinder + 1;
|
|
this.distanceToParentProtoElementInjector = lang_1.isPresent(protoElementInjector) ? 1 : this.distanceToParentProtoElementInjector + 1;
|
|
this.elementBinderStack.push(elementBinder);
|
|
return null;
|
|
};
|
|
_ProtoViewInitializer.prototype._visitEndElement = function() {
|
|
var parentElementBinder = this.elementBinderStack.pop();
|
|
var parentProtoElementInjector = lang_1.isPresent(parentElementBinder) ? parentElementBinder.protoElementInjector : null;
|
|
this.distanceToParentElementBinder = lang_1.isPresent(parentElementBinder) ? parentElementBinder.distanceToParent : this.distanceToParentElementBinder - 1;
|
|
this.distanceToParentProtoElementInjector = lang_1.isPresent(parentProtoElementInjector) ? parentProtoElementInjector.distanceToParent : this.distanceToParentProtoElementInjector - 1;
|
|
return null;
|
|
};
|
|
return _ProtoViewInitializer;
|
|
})();
|
|
function _createElementBinder(directiveResolver, nestedProtoView, elementBinderStack, boundElementIndex, distanceToParentBinder, distanceToParentPei, beginElementCmd) {
|
|
var parentElementBinder = null;
|
|
var parentProtoElementInjector = null;
|
|
if (distanceToParentBinder > 0) {
|
|
parentElementBinder = elementBinderStack[elementBinderStack.length - distanceToParentBinder];
|
|
}
|
|
if (lang_1.isBlank(parentElementBinder)) {
|
|
distanceToParentBinder = -1;
|
|
}
|
|
if (distanceToParentPei > 0) {
|
|
var peiBinder = elementBinderStack[elementBinderStack.length - distanceToParentPei];
|
|
if (lang_1.isPresent(peiBinder)) {
|
|
parentProtoElementInjector = peiBinder.protoElementInjector;
|
|
}
|
|
}
|
|
if (lang_1.isBlank(parentProtoElementInjector)) {
|
|
distanceToParentPei = -1;
|
|
}
|
|
var componentDirectiveProvider = null;
|
|
var isEmbeddedTemplate = false;
|
|
var directiveProviders = beginElementCmd.directives.map(function(type) {
|
|
return provideDirective(directiveResolver, type);
|
|
});
|
|
if (beginElementCmd instanceof template_commands_1.BeginComponentCmd) {
|
|
componentDirectiveProvider = directiveProviders[0];
|
|
} else if (beginElementCmd instanceof template_commands_1.EmbeddedTemplateCmd) {
|
|
isEmbeddedTemplate = true;
|
|
}
|
|
var protoElementInjector = null;
|
|
var hasVariables = beginElementCmd.variableNameAndValues.length > 0;
|
|
if (directiveProviders.length > 0 || hasVariables || isEmbeddedTemplate) {
|
|
var directiveVariableBindings = new Map();
|
|
if (!isEmbeddedTemplate) {
|
|
directiveVariableBindings = createDirectiveVariableBindings(beginElementCmd.variableNameAndValues, directiveProviders);
|
|
}
|
|
protoElementInjector = element_injector_1.ProtoElementInjector.create(parentProtoElementInjector, boundElementIndex, directiveProviders, lang_1.isPresent(componentDirectiveProvider), distanceToParentPei, directiveVariableBindings);
|
|
protoElementInjector.attributes = arrayToMap(beginElementCmd.attrNameAndValues, false);
|
|
}
|
|
return new element_binder_1.ElementBinder(boundElementIndex, parentElementBinder, distanceToParentBinder, protoElementInjector, componentDirectiveProvider, nestedProtoView);
|
|
}
|
|
function provideDirective(directiveResolver, type) {
|
|
var annotation = directiveResolver.resolve(type);
|
|
return element_injector_1.DirectiveProvider.createFromType(type, annotation);
|
|
}
|
|
function createDirectiveVariableBindings(variableNameAndValues, directiveProviders) {
|
|
var directiveVariableBindings = new Map();
|
|
for (var i = 0; i < variableNameAndValues.length; i += 2) {
|
|
var templateName = variableNameAndValues[i];
|
|
var dirIndex = variableNameAndValues[i + 1];
|
|
if (lang_1.isNumber(dirIndex)) {
|
|
directiveVariableBindings.set(templateName, dirIndex);
|
|
} else {
|
|
directiveVariableBindings.set(templateName, null);
|
|
}
|
|
}
|
|
return directiveVariableBindings;
|
|
}
|
|
exports.createDirectiveVariableBindings = createDirectiveVariableBindings;
|
|
function arrayToMap(arr, inverse) {
|
|
var result = new Map();
|
|
for (var i = 0; i < arr.length; i += 2) {
|
|
if (inverse) {
|
|
result.set(arr[i + 1], arr[i]);
|
|
} else {
|
|
result.set(arr[i], arr[i + 1]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function _flattenArray(tree, out) {
|
|
for (var i = 0; i < tree.length; i++) {
|
|
var item = di_1.resolveForwardRef(tree[i]);
|
|
if (lang_1.isArray(item)) {
|
|
_flattenArray(item, out);
|
|
} else {
|
|
out.push(item);
|
|
}
|
|
}
|
|
}
|
|
function _flattenStyleArr(arr, out) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var entry = arr[i];
|
|
if (lang_1.isArray(entry)) {
|
|
_flattenStyleArr(entry, out);
|
|
} else {
|
|
out.push(entry);
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a6", ["39", "20", "3c", "1ab", "1a1", "56", "1ad", "1b0", "55", "4c", "61"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
var di_1 = $__require('39');
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var viewModule = $__require('1ab');
|
|
var view_ref_1 = $__require('1a1');
|
|
var api_1 = $__require('56');
|
|
var view_manager_utils_1 = $__require('1ad');
|
|
var view_pool_1 = $__require('1b0');
|
|
var view_listener_1 = $__require('55');
|
|
var profile_1 = $__require('4c');
|
|
var proto_view_factory_1 = $__require('61');
|
|
var AppViewManager = (function() {
|
|
function AppViewManager() {}
|
|
AppViewManager.prototype.getHostElement = function(hostViewRef) {
|
|
var hostView = view_ref_1.internalView(hostViewRef);
|
|
if (hostView.proto.type !== viewModule.ViewType.HOST) {
|
|
throw new exceptions_1.BaseException('This operation is only allowed on host views');
|
|
}
|
|
return hostView.elementRefs[hostView.elementOffset];
|
|
};
|
|
return AppViewManager;
|
|
})();
|
|
exports.AppViewManager = AppViewManager;
|
|
var AppViewManager_ = (function(_super) {
|
|
__extends(AppViewManager_, _super);
|
|
function AppViewManager_(_viewPool, _viewListener, _utils, _renderer, _protoViewFactory) {
|
|
_super.call(this);
|
|
this._viewPool = _viewPool;
|
|
this._viewListener = _viewListener;
|
|
this._utils = _utils;
|
|
this._renderer = _renderer;
|
|
this._createRootHostViewScope = profile_1.wtfCreateScope('AppViewManager#createRootHostView()');
|
|
this._destroyRootHostViewScope = profile_1.wtfCreateScope('AppViewManager#destroyRootHostView()');
|
|
this._createEmbeddedViewInContainerScope = profile_1.wtfCreateScope('AppViewManager#createEmbeddedViewInContainer()');
|
|
this._createHostViewInContainerScope = profile_1.wtfCreateScope('AppViewManager#createHostViewInContainer()');
|
|
this._destroyViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#destroyViewInContainer()');
|
|
this._attachViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#attachViewInContainer()');
|
|
this._detachViewInContainerScope = profile_1.wtfCreateScope('AppViewMananger#detachViewInContainer()');
|
|
this._protoViewFactory = _protoViewFactory;
|
|
}
|
|
AppViewManager_.prototype.getViewContainer = function(location) {
|
|
var hostView = view_ref_1.internalView(location.parentView);
|
|
return hostView.elementInjectors[location.boundElementIndex].getViewContainerRef();
|
|
};
|
|
AppViewManager_.prototype.getNamedElementInComponentView = function(hostLocation, variableName) {
|
|
var hostView = view_ref_1.internalView(hostLocation.parentView);
|
|
var boundElementIndex = hostLocation.boundElementIndex;
|
|
var componentView = hostView.getNestedView(boundElementIndex);
|
|
if (lang_1.isBlank(componentView)) {
|
|
throw new exceptions_1.BaseException("There is no component directive at element " + boundElementIndex);
|
|
}
|
|
var binderIdx = componentView.proto.variableLocations.get(variableName);
|
|
if (lang_1.isBlank(binderIdx)) {
|
|
throw new exceptions_1.BaseException("Could not find variable " + variableName);
|
|
}
|
|
return componentView.elementRefs[componentView.elementOffset + binderIdx];
|
|
};
|
|
AppViewManager_.prototype.getComponent = function(hostLocation) {
|
|
var hostView = view_ref_1.internalView(hostLocation.parentView);
|
|
var boundElementIndex = hostLocation.boundElementIndex;
|
|
return this._utils.getComponentInstance(hostView, boundElementIndex);
|
|
};
|
|
AppViewManager_.prototype.createRootHostView = function(hostProtoViewRef, overrideSelector, injector) {
|
|
var s = this._createRootHostViewScope();
|
|
var hostProtoView = view_ref_1.internalProtoView(hostProtoViewRef);
|
|
this._protoViewFactory.initializeProtoViewIfNeeded(hostProtoView);
|
|
var hostElementSelector = overrideSelector;
|
|
if (lang_1.isBlank(hostElementSelector)) {
|
|
hostElementSelector = hostProtoView.elementBinders[0].componentDirective.metadata.selector;
|
|
}
|
|
var renderViewWithFragments = this._renderer.createRootHostView(hostProtoView.render, hostProtoView.mergeInfo.embeddedViewCount + 1, hostElementSelector);
|
|
var hostView = this._createMainView(hostProtoView, renderViewWithFragments);
|
|
this._renderer.hydrateView(hostView.render);
|
|
this._utils.hydrateRootHostView(hostView, injector);
|
|
return profile_1.wtfLeave(s, hostView.ref);
|
|
};
|
|
AppViewManager_.prototype.destroyRootHostView = function(hostViewRef) {
|
|
var s = this._destroyRootHostViewScope();
|
|
var hostView = view_ref_1.internalView(hostViewRef);
|
|
this._renderer.detachFragment(hostView.renderFragment);
|
|
this._renderer.dehydrateView(hostView.render);
|
|
this._viewDehydrateRecurse(hostView);
|
|
this._viewListener.onViewDestroyed(hostView);
|
|
this._renderer.destroyView(hostView.render);
|
|
profile_1.wtfLeave(s);
|
|
};
|
|
AppViewManager_.prototype.createEmbeddedViewInContainer = function(viewContainerLocation, index, templateRef) {
|
|
var s = this._createEmbeddedViewInContainerScope();
|
|
var protoView = view_ref_1.internalProtoView(templateRef.protoViewRef);
|
|
if (protoView.type !== viewModule.ViewType.EMBEDDED) {
|
|
throw new exceptions_1.BaseException('This method can only be called with embedded ProtoViews!');
|
|
}
|
|
this._protoViewFactory.initializeProtoViewIfNeeded(protoView);
|
|
return profile_1.wtfLeave(s, this._createViewInContainer(viewContainerLocation, index, protoView, templateRef.elementRef, null));
|
|
};
|
|
AppViewManager_.prototype.createHostViewInContainer = function(viewContainerLocation, index, protoViewRef, imperativelyCreatedInjector) {
|
|
var s = this._createHostViewInContainerScope();
|
|
var protoView = view_ref_1.internalProtoView(protoViewRef);
|
|
if (protoView.type !== viewModule.ViewType.HOST) {
|
|
throw new exceptions_1.BaseException('This method can only be called with host ProtoViews!');
|
|
}
|
|
this._protoViewFactory.initializeProtoViewIfNeeded(protoView);
|
|
return profile_1.wtfLeave(s, this._createViewInContainer(viewContainerLocation, index, protoView, viewContainerLocation, imperativelyCreatedInjector));
|
|
};
|
|
AppViewManager_.prototype._createViewInContainer = function(viewContainerLocation, index, protoView, context, imperativelyCreatedInjector) {
|
|
var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
|
|
var boundElementIndex = viewContainerLocation.boundElementIndex;
|
|
var contextView = view_ref_1.internalView(context.parentView);
|
|
var contextBoundElementIndex = context.boundElementIndex;
|
|
var embeddedFragmentView = contextView.getNestedView(contextBoundElementIndex);
|
|
var view;
|
|
if (protoView.type === viewModule.ViewType.EMBEDDED && lang_1.isPresent(embeddedFragmentView) && !embeddedFragmentView.hydrated()) {
|
|
view = embeddedFragmentView;
|
|
this._attachRenderView(parentView, boundElementIndex, index, view);
|
|
} else {
|
|
view = this._createPooledView(protoView);
|
|
this._attachRenderView(parentView, boundElementIndex, index, view);
|
|
this._renderer.hydrateView(view.render);
|
|
}
|
|
this._utils.attachViewInContainer(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, view);
|
|
try {
|
|
this._utils.hydrateViewInContainer(parentView, boundElementIndex, contextView, contextBoundElementIndex, index, imperativelyCreatedInjector);
|
|
} catch (e) {
|
|
this._utils.detachViewInContainer(parentView, boundElementIndex, index);
|
|
throw e;
|
|
}
|
|
return view.ref;
|
|
};
|
|
AppViewManager_.prototype._attachRenderView = function(parentView, boundElementIndex, index, view) {
|
|
var elementRef = parentView.elementRefs[boundElementIndex];
|
|
if (index === 0) {
|
|
this._renderer.attachFragmentAfterElement(elementRef, view.renderFragment);
|
|
} else {
|
|
var prevView = parentView.viewContainers[boundElementIndex].views[index - 1];
|
|
this._renderer.attachFragmentAfterFragment(prevView.renderFragment, view.renderFragment);
|
|
}
|
|
};
|
|
AppViewManager_.prototype.destroyViewInContainer = function(viewContainerLocation, index) {
|
|
var s = this._destroyViewInContainerScope();
|
|
var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
|
|
var boundElementIndex = viewContainerLocation.boundElementIndex;
|
|
this._destroyViewInContainer(parentView, boundElementIndex, index);
|
|
profile_1.wtfLeave(s);
|
|
};
|
|
AppViewManager_.prototype.attachViewInContainer = function(viewContainerLocation, index, viewRef) {
|
|
var s = this._attachViewInContainerScope();
|
|
var view = view_ref_1.internalView(viewRef);
|
|
var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
|
|
var boundElementIndex = viewContainerLocation.boundElementIndex;
|
|
this._utils.attachViewInContainer(parentView, boundElementIndex, null, null, index, view);
|
|
this._attachRenderView(parentView, boundElementIndex, index, view);
|
|
return profile_1.wtfLeave(s, viewRef);
|
|
};
|
|
AppViewManager_.prototype.detachViewInContainer = function(viewContainerLocation, index) {
|
|
var s = this._detachViewInContainerScope();
|
|
var parentView = view_ref_1.internalView(viewContainerLocation.parentView);
|
|
var boundElementIndex = viewContainerLocation.boundElementIndex;
|
|
var viewContainer = parentView.viewContainers[boundElementIndex];
|
|
var view = viewContainer.views[index];
|
|
this._utils.detachViewInContainer(parentView, boundElementIndex, index);
|
|
this._renderer.detachFragment(view.renderFragment);
|
|
return profile_1.wtfLeave(s, view.ref);
|
|
};
|
|
AppViewManager_.prototype._createMainView = function(protoView, renderViewWithFragments) {
|
|
var mergedParentView = this._utils.createView(protoView, renderViewWithFragments, this, this._renderer);
|
|
this._renderer.setEventDispatcher(mergedParentView.render, mergedParentView);
|
|
this._viewListener.onViewCreated(mergedParentView);
|
|
return mergedParentView;
|
|
};
|
|
AppViewManager_.prototype._createPooledView = function(protoView) {
|
|
var view = this._viewPool.getView(protoView);
|
|
if (lang_1.isBlank(view)) {
|
|
view = this._createMainView(protoView, this._renderer.createView(protoView.render, protoView.mergeInfo.embeddedViewCount + 1));
|
|
}
|
|
return view;
|
|
};
|
|
AppViewManager_.prototype._destroyPooledView = function(view) {
|
|
var wasReturned = this._viewPool.returnView(view);
|
|
if (!wasReturned) {
|
|
this._viewListener.onViewDestroyed(view);
|
|
this._renderer.destroyView(view.render);
|
|
}
|
|
};
|
|
AppViewManager_.prototype._destroyViewInContainer = function(parentView, boundElementIndex, index) {
|
|
var viewContainer = parentView.viewContainers[boundElementIndex];
|
|
var view = viewContainer.views[index];
|
|
this._viewDehydrateRecurse(view);
|
|
this._utils.detachViewInContainer(parentView, boundElementIndex, index);
|
|
if (view.viewOffset > 0) {
|
|
this._renderer.detachFragment(view.renderFragment);
|
|
} else {
|
|
this._renderer.dehydrateView(view.render);
|
|
this._renderer.detachFragment(view.renderFragment);
|
|
this._destroyPooledView(view);
|
|
}
|
|
};
|
|
AppViewManager_.prototype._viewDehydrateRecurse = function(view) {
|
|
if (view.hydrated()) {
|
|
this._utils.dehydrateView(view);
|
|
}
|
|
var viewContainers = view.viewContainers;
|
|
var startViewOffset = view.viewOffset;
|
|
var endViewOffset = view.viewOffset + view.proto.mergeInfo.viewCount - 1;
|
|
var elementOffset = view.elementOffset;
|
|
for (var viewIdx = startViewOffset; viewIdx <= endViewOffset; viewIdx++) {
|
|
var currView = view.views[viewIdx];
|
|
for (var binderIdx = 0; binderIdx < currView.proto.elementBinders.length; binderIdx++, elementOffset++) {
|
|
var vc = viewContainers[elementOffset];
|
|
if (lang_1.isPresent(vc)) {
|
|
for (var j = vc.views.length - 1; j >= 0; j--) {
|
|
this._destroyViewInContainer(currView, elementOffset, j);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
AppViewManager_ = __decorate([di_1.Injectable(), __param(4, di_1.Inject(di_1.forwardRef(function() {
|
|
return proto_view_factory_1.ProtoViewFactory;
|
|
}))), __metadata('design:paramtypes', [view_pool_1.AppViewPool, view_listener_1.AppViewListener, view_manager_utils_1.AppViewManagerUtils, api_1.Renderer, Object])], AppViewManager_);
|
|
return AppViewManager_;
|
|
})(AppViewManager);
|
|
exports.AppViewManager_ = AppViewManager_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1a0", ["39", "60", "20", "1a6"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
|
var c = arguments.length,
|
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i = decorators.length - 1; i >= 0; i--)
|
|
if (d = decorators[i])
|
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(k, v);
|
|
};
|
|
var di_1 = $__require('39');
|
|
var compiler_1 = $__require('60');
|
|
var lang_1 = $__require('20');
|
|
var view_manager_1 = $__require('1a6');
|
|
var ComponentRef = (function() {
|
|
function ComponentRef() {}
|
|
Object.defineProperty(ComponentRef.prototype, "hostView", {
|
|
get: function() {
|
|
return this.location.parentView;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ComponentRef.prototype, "hostComponent", {
|
|
get: function() {
|
|
return this.instance;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return ComponentRef;
|
|
})();
|
|
exports.ComponentRef = ComponentRef;
|
|
var ComponentRef_ = (function(_super) {
|
|
__extends(ComponentRef_, _super);
|
|
function ComponentRef_(location, instance, componentType, injector, _dispose) {
|
|
_super.call(this);
|
|
this._dispose = _dispose;
|
|
this.location = location;
|
|
this.instance = instance;
|
|
this.componentType = componentType;
|
|
this.injector = injector;
|
|
}
|
|
Object.defineProperty(ComponentRef_.prototype, "hostComponentType", {
|
|
get: function() {
|
|
return this.componentType;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ComponentRef_.prototype.dispose = function() {
|
|
this._dispose();
|
|
};
|
|
return ComponentRef_;
|
|
})(ComponentRef);
|
|
exports.ComponentRef_ = ComponentRef_;
|
|
var DynamicComponentLoader = (function() {
|
|
function DynamicComponentLoader() {}
|
|
return DynamicComponentLoader;
|
|
})();
|
|
exports.DynamicComponentLoader = DynamicComponentLoader;
|
|
var DynamicComponentLoader_ = (function(_super) {
|
|
__extends(DynamicComponentLoader_, _super);
|
|
function DynamicComponentLoader_(_compiler, _viewManager) {
|
|
_super.call(this);
|
|
this._compiler = _compiler;
|
|
this._viewManager = _viewManager;
|
|
}
|
|
DynamicComponentLoader_.prototype.loadAsRoot = function(type, overrideSelector, injector, onDispose) {
|
|
var _this = this;
|
|
return this._compiler.compileInHost(type).then(function(hostProtoViewRef) {
|
|
var hostViewRef = _this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
|
|
var newLocation = _this._viewManager.getHostElement(hostViewRef);
|
|
var component = _this._viewManager.getComponent(newLocation);
|
|
var dispose = function() {
|
|
if (lang_1.isPresent(onDispose)) {
|
|
onDispose();
|
|
}
|
|
_this._viewManager.destroyRootHostView(hostViewRef);
|
|
};
|
|
return new ComponentRef_(newLocation, component, type, injector, dispose);
|
|
});
|
|
};
|
|
DynamicComponentLoader_.prototype.loadIntoLocation = function(type, hostLocation, anchorName, providers) {
|
|
if (providers === void 0) {
|
|
providers = null;
|
|
}
|
|
return this.loadNextToLocation(type, this._viewManager.getNamedElementInComponentView(hostLocation, anchorName), providers);
|
|
};
|
|
DynamicComponentLoader_.prototype.loadNextToLocation = function(type, location, providers) {
|
|
var _this = this;
|
|
if (providers === void 0) {
|
|
providers = null;
|
|
}
|
|
return this._compiler.compileInHost(type).then(function(hostProtoViewRef) {
|
|
var viewContainer = _this._viewManager.getViewContainer(location);
|
|
var hostViewRef = viewContainer.createHostView(hostProtoViewRef, viewContainer.length, providers);
|
|
var newLocation = _this._viewManager.getHostElement(hostViewRef);
|
|
var component = _this._viewManager.getComponent(newLocation);
|
|
var dispose = function() {
|
|
var index = viewContainer.indexOf(hostViewRef);
|
|
if (index !== -1) {
|
|
viewContainer.remove(index);
|
|
}
|
|
};
|
|
return new ComponentRef_(newLocation, component, type, null, dispose);
|
|
});
|
|
};
|
|
DynamicComponentLoader_ = __decorate([di_1.Injectable(), __metadata('design:paramtypes', [compiler_1.Compiler, view_manager_1.AppViewManager])], DynamicComponentLoader_);
|
|
return DynamicComponentLoader_;
|
|
})(DynamicComponentLoader);
|
|
exports.DynamicComponentLoader_ = DynamicComponentLoader_;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f2", ["20", "39", "88", "6e", "1b0", "1a6", "1ad", "7f", "55", "61", "7e", "1cb", "60", "1a0"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var di_1 = $__require('39');
|
|
var application_tokens_1 = $__require('88');
|
|
var change_detection_1 = $__require('6e');
|
|
var view_pool_1 = $__require('1b0');
|
|
var view_manager_1 = $__require('1a6');
|
|
var view_manager_2 = $__require('1a6');
|
|
var view_manager_utils_1 = $__require('1ad');
|
|
var view_resolver_1 = $__require('7f');
|
|
var view_listener_1 = $__require('55');
|
|
var proto_view_factory_1 = $__require('61');
|
|
var directive_resolver_1 = $__require('7e');
|
|
var pipe_resolver_1 = $__require('1cb');
|
|
var compiler_1 = $__require('60');
|
|
var compiler_2 = $__require('60');
|
|
var dynamic_component_loader_1 = $__require('1a0');
|
|
var dynamic_component_loader_2 = $__require('1a0');
|
|
exports.APPLICATION_COMMON_PROVIDERS = lang_1.CONST_EXPR([new di_1.Provider(compiler_1.Compiler, {useClass: compiler_2.Compiler_}), application_tokens_1.APP_ID_RANDOM_PROVIDER, view_pool_1.AppViewPool, new di_1.Provider(view_pool_1.APP_VIEW_POOL_CAPACITY, {useValue: 10000}), new di_1.Provider(view_manager_1.AppViewManager, {useClass: view_manager_2.AppViewManager_}), view_manager_utils_1.AppViewManagerUtils, view_listener_1.AppViewListener, proto_view_factory_1.ProtoViewFactory, view_resolver_1.ViewResolver, new di_1.Provider(change_detection_1.IterableDiffers, {useValue: change_detection_1.defaultIterableDiffers}), new di_1.Provider(change_detection_1.KeyValueDiffers, {useValue: change_detection_1.defaultKeyValueDiffers}), directive_resolver_1.DirectiveResolver, pipe_resolver_1.PipeResolver, new di_1.Provider(dynamic_component_loader_1.DynamicComponentLoader, {useClass: dynamic_component_loader_2.DynamicComponentLoader_})]);
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f3", ["20", "3c", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var ReflectionInfo = (function() {
|
|
function ReflectionInfo(annotations, parameters, factory, interfaces, propMetadata) {
|
|
this.annotations = annotations;
|
|
this.parameters = parameters;
|
|
this.factory = factory;
|
|
this.interfaces = interfaces;
|
|
this.propMetadata = propMetadata;
|
|
}
|
|
return ReflectionInfo;
|
|
})();
|
|
exports.ReflectionInfo = ReflectionInfo;
|
|
var Reflector = (function() {
|
|
function Reflector(reflectionCapabilities) {
|
|
this._injectableInfo = new collection_1.Map();
|
|
this._getters = new collection_1.Map();
|
|
this._setters = new collection_1.Map();
|
|
this._methods = new collection_1.Map();
|
|
this._usedKeys = null;
|
|
this.reflectionCapabilities = reflectionCapabilities;
|
|
}
|
|
Reflector.prototype.isReflectionEnabled = function() {
|
|
return this.reflectionCapabilities.isReflectionEnabled();
|
|
};
|
|
Reflector.prototype.trackUsage = function() {
|
|
this._usedKeys = new collection_1.Set();
|
|
};
|
|
Reflector.prototype.listUnusedKeys = function() {
|
|
var _this = this;
|
|
if (this._usedKeys == null) {
|
|
throw new exceptions_1.BaseException('Usage tracking is disabled');
|
|
}
|
|
var allTypes = collection_1.MapWrapper.keys(this._injectableInfo);
|
|
return allTypes.filter(function(key) {
|
|
return !collection_1.SetWrapper.has(_this._usedKeys, key);
|
|
});
|
|
};
|
|
Reflector.prototype.registerFunction = function(func, funcInfo) {
|
|
this._injectableInfo.set(func, funcInfo);
|
|
};
|
|
Reflector.prototype.registerType = function(type, typeInfo) {
|
|
this._injectableInfo.set(type, typeInfo);
|
|
};
|
|
Reflector.prototype.registerGetters = function(getters) {
|
|
_mergeMaps(this._getters, getters);
|
|
};
|
|
Reflector.prototype.registerSetters = function(setters) {
|
|
_mergeMaps(this._setters, setters);
|
|
};
|
|
Reflector.prototype.registerMethods = function(methods) {
|
|
_mergeMaps(this._methods, methods);
|
|
};
|
|
Reflector.prototype.factory = function(type) {
|
|
if (this._containsReflectionInfo(type)) {
|
|
var res = this._getReflectionInfo(type).factory;
|
|
return lang_1.isPresent(res) ? res : null;
|
|
} else {
|
|
return this.reflectionCapabilities.factory(type);
|
|
}
|
|
};
|
|
Reflector.prototype.parameters = function(typeOrFunc) {
|
|
if (this._injectableInfo.has(typeOrFunc)) {
|
|
var res = this._getReflectionInfo(typeOrFunc).parameters;
|
|
return lang_1.isPresent(res) ? res : [];
|
|
} else {
|
|
return this.reflectionCapabilities.parameters(typeOrFunc);
|
|
}
|
|
};
|
|
Reflector.prototype.annotations = function(typeOrFunc) {
|
|
if (this._injectableInfo.has(typeOrFunc)) {
|
|
var res = this._getReflectionInfo(typeOrFunc).annotations;
|
|
return lang_1.isPresent(res) ? res : [];
|
|
} else {
|
|
return this.reflectionCapabilities.annotations(typeOrFunc);
|
|
}
|
|
};
|
|
Reflector.prototype.propMetadata = function(typeOrFunc) {
|
|
if (this._injectableInfo.has(typeOrFunc)) {
|
|
var res = this._getReflectionInfo(typeOrFunc).propMetadata;
|
|
return lang_1.isPresent(res) ? res : {};
|
|
} else {
|
|
return this.reflectionCapabilities.propMetadata(typeOrFunc);
|
|
}
|
|
};
|
|
Reflector.prototype.interfaces = function(type) {
|
|
if (this._injectableInfo.has(type)) {
|
|
var res = this._getReflectionInfo(type).interfaces;
|
|
return lang_1.isPresent(res) ? res : [];
|
|
} else {
|
|
return this.reflectionCapabilities.interfaces(type);
|
|
}
|
|
};
|
|
Reflector.prototype.getter = function(name) {
|
|
if (this._getters.has(name)) {
|
|
return this._getters.get(name);
|
|
} else {
|
|
return this.reflectionCapabilities.getter(name);
|
|
}
|
|
};
|
|
Reflector.prototype.setter = function(name) {
|
|
if (this._setters.has(name)) {
|
|
return this._setters.get(name);
|
|
} else {
|
|
return this.reflectionCapabilities.setter(name);
|
|
}
|
|
};
|
|
Reflector.prototype.method = function(name) {
|
|
if (this._methods.has(name)) {
|
|
return this._methods.get(name);
|
|
} else {
|
|
return this.reflectionCapabilities.method(name);
|
|
}
|
|
};
|
|
Reflector.prototype._getReflectionInfo = function(typeOrFunc) {
|
|
if (lang_1.isPresent(this._usedKeys)) {
|
|
this._usedKeys.add(typeOrFunc);
|
|
}
|
|
return this._injectableInfo.get(typeOrFunc);
|
|
};
|
|
Reflector.prototype._containsReflectionInfo = function(typeOrFunc) {
|
|
return this._injectableInfo.has(typeOrFunc);
|
|
};
|
|
Reflector.prototype.importUri = function(type) {
|
|
return this.reflectionCapabilities.importUri(type);
|
|
};
|
|
return Reflector;
|
|
})();
|
|
exports.Reflector = Reflector;
|
|
function _mergeMaps(target, config) {
|
|
collection_1.StringMapWrapper.forEach(config, function(v, k) {
|
|
return target.set(k, v);
|
|
});
|
|
}
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("20", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var globalScope;
|
|
if (typeof window === 'undefined') {
|
|
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
|
globalScope = self;
|
|
} else {
|
|
globalScope = global;
|
|
}
|
|
} else {
|
|
globalScope = window;
|
|
}
|
|
;
|
|
exports.IS_DART = false;
|
|
var _global = globalScope;
|
|
exports.global = _global;
|
|
exports.Type = Function;
|
|
function getTypeNameForDebugging(type) {
|
|
return type['name'];
|
|
}
|
|
exports.getTypeNameForDebugging = getTypeNameForDebugging;
|
|
exports.Math = _global.Math;
|
|
exports.Date = _global.Date;
|
|
var _devMode = true;
|
|
var _modeLocked = false;
|
|
function lockMode() {
|
|
_modeLocked = true;
|
|
}
|
|
exports.lockMode = lockMode;
|
|
function enableProdMode() {
|
|
if (_modeLocked) {
|
|
throw 'Cannot enable prod mode after platform setup.';
|
|
}
|
|
_devMode = false;
|
|
}
|
|
exports.enableProdMode = enableProdMode;
|
|
function assertionsEnabled() {
|
|
return _devMode;
|
|
}
|
|
exports.assertionsEnabled = assertionsEnabled;
|
|
_global.assert = function assert(condition) {};
|
|
function CONST_EXPR(expr) {
|
|
return expr;
|
|
}
|
|
exports.CONST_EXPR = CONST_EXPR;
|
|
function CONST() {
|
|
return function(target) {
|
|
return target;
|
|
};
|
|
}
|
|
exports.CONST = CONST;
|
|
function isPresent(obj) {
|
|
return obj !== undefined && obj !== null;
|
|
}
|
|
exports.isPresent = isPresent;
|
|
function isBlank(obj) {
|
|
return obj === undefined || obj === null;
|
|
}
|
|
exports.isBlank = isBlank;
|
|
function isString(obj) {
|
|
return typeof obj === "string";
|
|
}
|
|
exports.isString = isString;
|
|
function isFunction(obj) {
|
|
return typeof obj === "function";
|
|
}
|
|
exports.isFunction = isFunction;
|
|
function isType(obj) {
|
|
return isFunction(obj);
|
|
}
|
|
exports.isType = isType;
|
|
function isStringMap(obj) {
|
|
return typeof obj === 'object' && obj !== null;
|
|
}
|
|
exports.isStringMap = isStringMap;
|
|
function isPromise(obj) {
|
|
return obj instanceof _global.Promise;
|
|
}
|
|
exports.isPromise = isPromise;
|
|
function isArray(obj) {
|
|
return Array.isArray(obj);
|
|
}
|
|
exports.isArray = isArray;
|
|
function isNumber(obj) {
|
|
return typeof obj === 'number';
|
|
}
|
|
exports.isNumber = isNumber;
|
|
function isDate(obj) {
|
|
return obj instanceof exports.Date && !isNaN(obj.valueOf());
|
|
}
|
|
exports.isDate = isDate;
|
|
function noop() {}
|
|
exports.noop = noop;
|
|
function stringify(token) {
|
|
if (typeof token === 'string') {
|
|
return token;
|
|
}
|
|
if (token === undefined || token === null) {
|
|
return '' + token;
|
|
}
|
|
if (token.name) {
|
|
return token.name;
|
|
}
|
|
var res = token.toString();
|
|
var newLineIndex = res.indexOf("\n");
|
|
return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
|
|
}
|
|
exports.stringify = stringify;
|
|
function serializeEnum(val) {
|
|
return val;
|
|
}
|
|
exports.serializeEnum = serializeEnum;
|
|
function deserializeEnum(val, values) {
|
|
return val;
|
|
}
|
|
exports.deserializeEnum = deserializeEnum;
|
|
var StringWrapper = (function() {
|
|
function StringWrapper() {}
|
|
StringWrapper.fromCharCode = function(code) {
|
|
return String.fromCharCode(code);
|
|
};
|
|
StringWrapper.charCodeAt = function(s, index) {
|
|
return s.charCodeAt(index);
|
|
};
|
|
StringWrapper.split = function(s, regExp) {
|
|
return s.split(regExp);
|
|
};
|
|
StringWrapper.equals = function(s, s2) {
|
|
return s === s2;
|
|
};
|
|
StringWrapper.stripLeft = function(s, charVal) {
|
|
if (s && s.length) {
|
|
var pos = 0;
|
|
for (var i = 0; i < s.length; i++) {
|
|
if (s[i] != charVal)
|
|
break;
|
|
pos++;
|
|
}
|
|
s = s.substring(pos);
|
|
}
|
|
return s;
|
|
};
|
|
StringWrapper.stripRight = function(s, charVal) {
|
|
if (s && s.length) {
|
|
var pos = s.length;
|
|
for (var i = s.length - 1; i >= 0; i--) {
|
|
if (s[i] != charVal)
|
|
break;
|
|
pos--;
|
|
}
|
|
s = s.substring(0, pos);
|
|
}
|
|
return s;
|
|
};
|
|
StringWrapper.replace = function(s, from, replace) {
|
|
return s.replace(from, replace);
|
|
};
|
|
StringWrapper.replaceAll = function(s, from, replace) {
|
|
return s.replace(from, replace);
|
|
};
|
|
StringWrapper.slice = function(s, from, to) {
|
|
if (from === void 0) {
|
|
from = 0;
|
|
}
|
|
if (to === void 0) {
|
|
to = null;
|
|
}
|
|
return s.slice(from, to === null ? undefined : to);
|
|
};
|
|
StringWrapper.replaceAllMapped = function(s, from, cb) {
|
|
return s.replace(from, function() {
|
|
var matches = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
matches[_i - 0] = arguments[_i];
|
|
}
|
|
matches.splice(-2, 2);
|
|
return cb(matches);
|
|
});
|
|
};
|
|
StringWrapper.contains = function(s, substr) {
|
|
return s.indexOf(substr) != -1;
|
|
};
|
|
StringWrapper.compare = function(a, b) {
|
|
if (a < b) {
|
|
return -1;
|
|
} else if (a > b) {
|
|
return 1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
};
|
|
return StringWrapper;
|
|
})();
|
|
exports.StringWrapper = StringWrapper;
|
|
var StringJoiner = (function() {
|
|
function StringJoiner(parts) {
|
|
if (parts === void 0) {
|
|
parts = [];
|
|
}
|
|
this.parts = parts;
|
|
}
|
|
StringJoiner.prototype.add = function(part) {
|
|
this.parts.push(part);
|
|
};
|
|
StringJoiner.prototype.toString = function() {
|
|
return this.parts.join("");
|
|
};
|
|
return StringJoiner;
|
|
})();
|
|
exports.StringJoiner = StringJoiner;
|
|
var NumberParseError = (function(_super) {
|
|
__extends(NumberParseError, _super);
|
|
function NumberParseError(message) {
|
|
_super.call(this);
|
|
this.message = message;
|
|
}
|
|
NumberParseError.prototype.toString = function() {
|
|
return this.message;
|
|
};
|
|
return NumberParseError;
|
|
})(Error);
|
|
exports.NumberParseError = NumberParseError;
|
|
var NumberWrapper = (function() {
|
|
function NumberWrapper() {}
|
|
NumberWrapper.toFixed = function(n, fractionDigits) {
|
|
return n.toFixed(fractionDigits);
|
|
};
|
|
NumberWrapper.equal = function(a, b) {
|
|
return a === b;
|
|
};
|
|
NumberWrapper.parseIntAutoRadix = function(text) {
|
|
var result = parseInt(text);
|
|
if (isNaN(result)) {
|
|
throw new NumberParseError("Invalid integer literal when parsing " + text);
|
|
}
|
|
return result;
|
|
};
|
|
NumberWrapper.parseInt = function(text, radix) {
|
|
if (radix == 10) {
|
|
if (/^(\-|\+)?[0-9]+$/.test(text)) {
|
|
return parseInt(text, radix);
|
|
}
|
|
} else if (radix == 16) {
|
|
if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
|
|
return parseInt(text, radix);
|
|
}
|
|
} else {
|
|
var result = parseInt(text, radix);
|
|
if (!isNaN(result)) {
|
|
return result;
|
|
}
|
|
}
|
|
throw new NumberParseError("Invalid integer literal when parsing " + text + " in base " + radix);
|
|
};
|
|
NumberWrapper.parseFloat = function(text) {
|
|
return parseFloat(text);
|
|
};
|
|
Object.defineProperty(NumberWrapper, "NaN", {
|
|
get: function() {
|
|
return NaN;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
NumberWrapper.isNaN = function(value) {
|
|
return isNaN(value);
|
|
};
|
|
NumberWrapper.isInteger = function(value) {
|
|
return Number.isInteger(value);
|
|
};
|
|
return NumberWrapper;
|
|
})();
|
|
exports.NumberWrapper = NumberWrapper;
|
|
exports.RegExp = _global.RegExp;
|
|
var RegExpWrapper = (function() {
|
|
function RegExpWrapper() {}
|
|
RegExpWrapper.create = function(regExpStr, flags) {
|
|
if (flags === void 0) {
|
|
flags = '';
|
|
}
|
|
flags = flags.replace(/g/g, '');
|
|
return new _global.RegExp(regExpStr, flags + 'g');
|
|
};
|
|
RegExpWrapper.firstMatch = function(regExp, input) {
|
|
regExp.lastIndex = 0;
|
|
return regExp.exec(input);
|
|
};
|
|
RegExpWrapper.test = function(regExp, input) {
|
|
regExp.lastIndex = 0;
|
|
return regExp.test(input);
|
|
};
|
|
RegExpWrapper.matcher = function(regExp, input) {
|
|
regExp.lastIndex = 0;
|
|
return {
|
|
re: regExp,
|
|
input: input
|
|
};
|
|
};
|
|
return RegExpWrapper;
|
|
})();
|
|
exports.RegExpWrapper = RegExpWrapper;
|
|
var RegExpMatcherWrapper = (function() {
|
|
function RegExpMatcherWrapper() {}
|
|
RegExpMatcherWrapper.next = function(matcher) {
|
|
return matcher.re.exec(matcher.input);
|
|
};
|
|
return RegExpMatcherWrapper;
|
|
})();
|
|
exports.RegExpMatcherWrapper = RegExpMatcherWrapper;
|
|
var FunctionWrapper = (function() {
|
|
function FunctionWrapper() {}
|
|
FunctionWrapper.apply = function(fn, posArgs) {
|
|
return fn.apply(null, posArgs);
|
|
};
|
|
return FunctionWrapper;
|
|
})();
|
|
exports.FunctionWrapper = FunctionWrapper;
|
|
function looseIdentical(a, b) {
|
|
return a === b || typeof a === "number" && typeof b === "number" && isNaN(a) && isNaN(b);
|
|
}
|
|
exports.looseIdentical = looseIdentical;
|
|
function getMapKey(value) {
|
|
return value;
|
|
}
|
|
exports.getMapKey = getMapKey;
|
|
function normalizeBlank(obj) {
|
|
return isBlank(obj) ? null : obj;
|
|
}
|
|
exports.normalizeBlank = normalizeBlank;
|
|
function normalizeBool(obj) {
|
|
return isBlank(obj) ? false : obj;
|
|
}
|
|
exports.normalizeBool = normalizeBool;
|
|
function isJsObject(o) {
|
|
return o !== null && (typeof o === "function" || typeof o === "object");
|
|
}
|
|
exports.isJsObject = isJsObject;
|
|
function print(obj) {
|
|
console.log(obj);
|
|
}
|
|
exports.print = print;
|
|
var Json = (function() {
|
|
function Json() {}
|
|
Json.parse = function(s) {
|
|
return _global.JSON.parse(s);
|
|
};
|
|
Json.stringify = function(data) {
|
|
return _global.JSON.stringify(data, null, 2);
|
|
};
|
|
return Json;
|
|
})();
|
|
exports.Json = Json;
|
|
var DateWrapper = (function() {
|
|
function DateWrapper() {}
|
|
DateWrapper.create = function(year, month, day, hour, minutes, seconds, milliseconds) {
|
|
if (month === void 0) {
|
|
month = 1;
|
|
}
|
|
if (day === void 0) {
|
|
day = 1;
|
|
}
|
|
if (hour === void 0) {
|
|
hour = 0;
|
|
}
|
|
if (minutes === void 0) {
|
|
minutes = 0;
|
|
}
|
|
if (seconds === void 0) {
|
|
seconds = 0;
|
|
}
|
|
if (milliseconds === void 0) {
|
|
milliseconds = 0;
|
|
}
|
|
return new exports.Date(year, month - 1, day, hour, minutes, seconds, milliseconds);
|
|
};
|
|
DateWrapper.fromISOString = function(str) {
|
|
return new exports.Date(str);
|
|
};
|
|
DateWrapper.fromMillis = function(ms) {
|
|
return new exports.Date(ms);
|
|
};
|
|
DateWrapper.toMillis = function(date) {
|
|
return date.getTime();
|
|
};
|
|
DateWrapper.now = function() {
|
|
return new exports.Date();
|
|
};
|
|
DateWrapper.toJson = function(date) {
|
|
return date.toJSON();
|
|
};
|
|
return DateWrapper;
|
|
})();
|
|
exports.DateWrapper = DateWrapper;
|
|
function setValueOnPath(global, path, value) {
|
|
var parts = path.split('.');
|
|
var obj = global;
|
|
while (parts.length > 1) {
|
|
var name = parts.shift();
|
|
if (obj.hasOwnProperty(name) && isPresent(obj[name])) {
|
|
obj = obj[name];
|
|
} else {
|
|
obj = obj[name] = {};
|
|
}
|
|
}
|
|
if (obj === undefined || obj === null) {
|
|
obj = {};
|
|
}
|
|
obj[parts.shift()] = value;
|
|
}
|
|
exports.setValueOnPath = setValueOnPath;
|
|
var _symbolIterator = null;
|
|
function getSymbolIterator() {
|
|
if (isBlank(_symbolIterator)) {
|
|
if (isPresent(Symbol) && isPresent(Symbol.iterator)) {
|
|
_symbolIterator = Symbol.iterator;
|
|
} else {
|
|
var keys = Object.getOwnPropertyNames(Map.prototype);
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
var key = keys[i];
|
|
if (key !== 'entries' && key !== 'size' && Map.prototype[key] === Map.prototype['entries']) {
|
|
_symbolIterator = key;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return _symbolIterator;
|
|
}
|
|
exports.getSymbolIterator = getSymbolIterator;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("37", ["20"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
exports.Map = lang_1.global.Map;
|
|
exports.Set = lang_1.global.Set;
|
|
var createMapFromPairs = (function() {
|
|
try {
|
|
if (new exports.Map([[1, 2]]).size === 1) {
|
|
return function createMapFromPairs(pairs) {
|
|
return new exports.Map(pairs);
|
|
};
|
|
}
|
|
} catch (e) {}
|
|
return function createMapAndPopulateFromPairs(pairs) {
|
|
var map = new exports.Map();
|
|
for (var i = 0; i < pairs.length; i++) {
|
|
var pair = pairs[i];
|
|
map.set(pair[0], pair[1]);
|
|
}
|
|
return map;
|
|
};
|
|
})();
|
|
var createMapFromMap = (function() {
|
|
try {
|
|
if (new exports.Map(new exports.Map())) {
|
|
return function createMapFromMap(m) {
|
|
return new exports.Map(m);
|
|
};
|
|
}
|
|
} catch (e) {}
|
|
return function createMapAndPopulateFromMap(m) {
|
|
var map = new exports.Map();
|
|
m.forEach(function(v, k) {
|
|
map.set(k, v);
|
|
});
|
|
return map;
|
|
};
|
|
})();
|
|
var _clearValues = (function() {
|
|
if ((new exports.Map()).keys().next) {
|
|
return function _clearValues(m) {
|
|
var keyIterator = m.keys();
|
|
var k;
|
|
while (!((k = keyIterator.next()).done)) {
|
|
m.set(k.value, null);
|
|
}
|
|
};
|
|
} else {
|
|
return function _clearValuesWithForeEach(m) {
|
|
m.forEach(function(v, k) {
|
|
m.set(k, null);
|
|
});
|
|
};
|
|
}
|
|
})();
|
|
var _arrayFromMap = (function() {
|
|
try {
|
|
if ((new exports.Map()).values().next) {
|
|
return function createArrayFromMap(m, getValues) {
|
|
return getValues ? Array.from(m.values()) : Array.from(m.keys());
|
|
};
|
|
}
|
|
} catch (e) {}
|
|
return function createArrayFromMapWithForeach(m, getValues) {
|
|
var res = ListWrapper.createFixedSize(m.size),
|
|
i = 0;
|
|
m.forEach(function(v, k) {
|
|
res[i] = getValues ? v : k;
|
|
i++;
|
|
});
|
|
return res;
|
|
};
|
|
})();
|
|
var MapWrapper = (function() {
|
|
function MapWrapper() {}
|
|
MapWrapper.clone = function(m) {
|
|
return createMapFromMap(m);
|
|
};
|
|
MapWrapper.createFromStringMap = function(stringMap) {
|
|
var result = new exports.Map();
|
|
for (var prop in stringMap) {
|
|
result.set(prop, stringMap[prop]);
|
|
}
|
|
return result;
|
|
};
|
|
MapWrapper.toStringMap = function(m) {
|
|
var r = {};
|
|
m.forEach(function(v, k) {
|
|
return r[k] = v;
|
|
});
|
|
return r;
|
|
};
|
|
MapWrapper.createFromPairs = function(pairs) {
|
|
return createMapFromPairs(pairs);
|
|
};
|
|
MapWrapper.clearValues = function(m) {
|
|
_clearValues(m);
|
|
};
|
|
MapWrapper.iterable = function(m) {
|
|
return m;
|
|
};
|
|
MapWrapper.keys = function(m) {
|
|
return _arrayFromMap(m, false);
|
|
};
|
|
MapWrapper.values = function(m) {
|
|
return _arrayFromMap(m, true);
|
|
};
|
|
return MapWrapper;
|
|
})();
|
|
exports.MapWrapper = MapWrapper;
|
|
var StringMapWrapper = (function() {
|
|
function StringMapWrapper() {}
|
|
StringMapWrapper.create = function() {
|
|
return {};
|
|
};
|
|
StringMapWrapper.contains = function(map, key) {
|
|
return map.hasOwnProperty(key);
|
|
};
|
|
StringMapWrapper.get = function(map, key) {
|
|
return map.hasOwnProperty(key) ? map[key] : undefined;
|
|
};
|
|
StringMapWrapper.set = function(map, key, value) {
|
|
map[key] = value;
|
|
};
|
|
StringMapWrapper.keys = function(map) {
|
|
return Object.keys(map);
|
|
};
|
|
StringMapWrapper.isEmpty = function(map) {
|
|
for (var prop in map) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
StringMapWrapper.delete = function(map, key) {
|
|
delete map[key];
|
|
};
|
|
StringMapWrapper.forEach = function(map, callback) {
|
|
for (var prop in map) {
|
|
if (map.hasOwnProperty(prop)) {
|
|
callback(map[prop], prop);
|
|
}
|
|
}
|
|
};
|
|
StringMapWrapper.merge = function(m1, m2) {
|
|
var m = {};
|
|
for (var attr in m1) {
|
|
if (m1.hasOwnProperty(attr)) {
|
|
m[attr] = m1[attr];
|
|
}
|
|
}
|
|
for (var attr in m2) {
|
|
if (m2.hasOwnProperty(attr)) {
|
|
m[attr] = m2[attr];
|
|
}
|
|
}
|
|
return m;
|
|
};
|
|
StringMapWrapper.equals = function(m1, m2) {
|
|
var k1 = Object.keys(m1);
|
|
var k2 = Object.keys(m2);
|
|
if (k1.length != k2.length) {
|
|
return false;
|
|
}
|
|
var key;
|
|
for (var i = 0; i < k1.length; i++) {
|
|
key = k1[i];
|
|
if (m1[key] !== m2[key]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
return StringMapWrapper;
|
|
})();
|
|
exports.StringMapWrapper = StringMapWrapper;
|
|
var ListWrapper = (function() {
|
|
function ListWrapper() {}
|
|
ListWrapper.createFixedSize = function(size) {
|
|
return new Array(size);
|
|
};
|
|
ListWrapper.createGrowableSize = function(size) {
|
|
return new Array(size);
|
|
};
|
|
ListWrapper.clone = function(array) {
|
|
return array.slice(0);
|
|
};
|
|
ListWrapper.forEachWithIndex = function(array, fn) {
|
|
for (var i = 0; i < array.length; i++) {
|
|
fn(array[i], i);
|
|
}
|
|
};
|
|
ListWrapper.first = function(array) {
|
|
if (!array)
|
|
return null;
|
|
return array[0];
|
|
};
|
|
ListWrapper.last = function(array) {
|
|
if (!array || array.length == 0)
|
|
return null;
|
|
return array[array.length - 1];
|
|
};
|
|
ListWrapper.indexOf = function(array, value, startIndex) {
|
|
if (startIndex === void 0) {
|
|
startIndex = 0;
|
|
}
|
|
return array.indexOf(value, startIndex);
|
|
};
|
|
ListWrapper.contains = function(list, el) {
|
|
return list.indexOf(el) !== -1;
|
|
};
|
|
ListWrapper.reversed = function(array) {
|
|
var a = ListWrapper.clone(array);
|
|
return a.reverse();
|
|
};
|
|
ListWrapper.concat = function(a, b) {
|
|
return a.concat(b);
|
|
};
|
|
ListWrapper.insert = function(list, index, value) {
|
|
list.splice(index, 0, value);
|
|
};
|
|
ListWrapper.removeAt = function(list, index) {
|
|
var res = list[index];
|
|
list.splice(index, 1);
|
|
return res;
|
|
};
|
|
ListWrapper.removeAll = function(list, items) {
|
|
for (var i = 0; i < items.length; ++i) {
|
|
var index = list.indexOf(items[i]);
|
|
list.splice(index, 1);
|
|
}
|
|
};
|
|
ListWrapper.remove = function(list, el) {
|
|
var index = list.indexOf(el);
|
|
if (index > -1) {
|
|
list.splice(index, 1);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
ListWrapper.clear = function(list) {
|
|
list.length = 0;
|
|
};
|
|
ListWrapper.isEmpty = function(list) {
|
|
return list.length == 0;
|
|
};
|
|
ListWrapper.fill = function(list, value, start, end) {
|
|
if (start === void 0) {
|
|
start = 0;
|
|
}
|
|
if (end === void 0) {
|
|
end = null;
|
|
}
|
|
list.fill(value, start, end === null ? list.length : end);
|
|
};
|
|
ListWrapper.equals = function(a, b) {
|
|
if (a.length != b.length)
|
|
return false;
|
|
for (var i = 0; i < a.length; ++i) {
|
|
if (a[i] !== b[i])
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
ListWrapper.slice = function(l, from, to) {
|
|
if (from === void 0) {
|
|
from = 0;
|
|
}
|
|
if (to === void 0) {
|
|
to = null;
|
|
}
|
|
return l.slice(from, to === null ? undefined : to);
|
|
};
|
|
ListWrapper.splice = function(l, from, length) {
|
|
return l.splice(from, length);
|
|
};
|
|
ListWrapper.sort = function(l, compareFn) {
|
|
if (lang_1.isPresent(compareFn)) {
|
|
l.sort(compareFn);
|
|
} else {
|
|
l.sort();
|
|
}
|
|
};
|
|
ListWrapper.toString = function(l) {
|
|
return l.toString();
|
|
};
|
|
ListWrapper.toJSON = function(l) {
|
|
return JSON.stringify(l);
|
|
};
|
|
ListWrapper.maximum = function(list, predicate) {
|
|
if (list.length == 0) {
|
|
return null;
|
|
}
|
|
var solution = null;
|
|
var maxValue = -Infinity;
|
|
for (var index = 0; index < list.length; index++) {
|
|
var candidate = list[index];
|
|
if (lang_1.isBlank(candidate)) {
|
|
continue;
|
|
}
|
|
var candidateValue = predicate(candidate);
|
|
if (candidateValue > maxValue) {
|
|
solution = candidate;
|
|
maxValue = candidateValue;
|
|
}
|
|
}
|
|
return solution;
|
|
};
|
|
return ListWrapper;
|
|
})();
|
|
exports.ListWrapper = ListWrapper;
|
|
function isListLikeIterable(obj) {
|
|
if (!lang_1.isJsObject(obj))
|
|
return false;
|
|
return lang_1.isArray(obj) || (!(obj instanceof exports.Map) && lang_1.getSymbolIterator() in obj);
|
|
}
|
|
exports.isListLikeIterable = isListLikeIterable;
|
|
function iterateListLike(obj, fn) {
|
|
if (lang_1.isArray(obj)) {
|
|
for (var i = 0; i < obj.length; i++) {
|
|
fn(obj[i]);
|
|
}
|
|
} else {
|
|
var iterator = obj[lang_1.getSymbolIterator()]();
|
|
var item;
|
|
while (!((item = iterator.next()).done)) {
|
|
fn(item.value);
|
|
}
|
|
}
|
|
}
|
|
exports.iterateListLike = iterateListLike;
|
|
var createSetFromList = (function() {
|
|
var test = new exports.Set([1, 2, 3]);
|
|
if (test.size === 3) {
|
|
return function createSetFromList(lst) {
|
|
return new exports.Set(lst);
|
|
};
|
|
} else {
|
|
return function createSetAndPopulateFromList(lst) {
|
|
var res = new exports.Set(lst);
|
|
if (res.size !== lst.length) {
|
|
for (var i = 0; i < lst.length; i++) {
|
|
res.add(lst[i]);
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
}
|
|
})();
|
|
var SetWrapper = (function() {
|
|
function SetWrapper() {}
|
|
SetWrapper.createFromList = function(lst) {
|
|
return createSetFromList(lst);
|
|
};
|
|
SetWrapper.has = function(s, key) {
|
|
return s.has(key);
|
|
};
|
|
SetWrapper.delete = function(m, k) {
|
|
m.delete(k);
|
|
};
|
|
return SetWrapper;
|
|
})();
|
|
exports.SetWrapper = SetWrapper;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("19f", ["20", "3c", "37"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var collection_1 = $__require('37');
|
|
var _ArrayLogger = (function() {
|
|
function _ArrayLogger() {
|
|
this.res = [];
|
|
}
|
|
_ArrayLogger.prototype.log = function(s) {
|
|
this.res.push(s);
|
|
};
|
|
_ArrayLogger.prototype.logError = function(s) {
|
|
this.res.push(s);
|
|
};
|
|
_ArrayLogger.prototype.logGroup = function(s) {
|
|
this.res.push(s);
|
|
};
|
|
_ArrayLogger.prototype.logGroupEnd = function() {};
|
|
;
|
|
return _ArrayLogger;
|
|
})();
|
|
var ExceptionHandler = (function() {
|
|
function ExceptionHandler(_logger, _rethrowException) {
|
|
if (_rethrowException === void 0) {
|
|
_rethrowException = true;
|
|
}
|
|
this._logger = _logger;
|
|
this._rethrowException = _rethrowException;
|
|
}
|
|
ExceptionHandler.exceptionToString = function(exception, stackTrace, reason) {
|
|
if (stackTrace === void 0) {
|
|
stackTrace = null;
|
|
}
|
|
if (reason === void 0) {
|
|
reason = null;
|
|
}
|
|
var l = new _ArrayLogger();
|
|
var e = new ExceptionHandler(l, false);
|
|
e.call(exception, stackTrace, reason);
|
|
return l.res.join("\n");
|
|
};
|
|
ExceptionHandler.prototype.call = function(exception, stackTrace, reason) {
|
|
if (stackTrace === void 0) {
|
|
stackTrace = null;
|
|
}
|
|
if (reason === void 0) {
|
|
reason = null;
|
|
}
|
|
var originalException = this._findOriginalException(exception);
|
|
var originalStack = this._findOriginalStack(exception);
|
|
var context = this._findContext(exception);
|
|
this._logger.logGroup("EXCEPTION: " + this._extractMessage(exception));
|
|
if (lang_1.isPresent(stackTrace) && lang_1.isBlank(originalStack)) {
|
|
this._logger.logError("STACKTRACE:");
|
|
this._logger.logError(this._longStackTrace(stackTrace));
|
|
}
|
|
if (lang_1.isPresent(reason)) {
|
|
this._logger.logError("REASON: " + reason);
|
|
}
|
|
if (lang_1.isPresent(originalException)) {
|
|
this._logger.logError("ORIGINAL EXCEPTION: " + this._extractMessage(originalException));
|
|
}
|
|
if (lang_1.isPresent(originalStack)) {
|
|
this._logger.logError("ORIGINAL STACKTRACE:");
|
|
this._logger.logError(this._longStackTrace(originalStack));
|
|
}
|
|
if (lang_1.isPresent(context)) {
|
|
this._logger.logError("ERROR CONTEXT:");
|
|
this._logger.logError(context);
|
|
}
|
|
this._logger.logGroupEnd();
|
|
if (this._rethrowException)
|
|
throw exception;
|
|
};
|
|
ExceptionHandler.prototype._extractMessage = function(exception) {
|
|
return exception instanceof exceptions_1.WrappedException ? exception.wrapperMessage : exception.toString();
|
|
};
|
|
ExceptionHandler.prototype._longStackTrace = function(stackTrace) {
|
|
return collection_1.isListLikeIterable(stackTrace) ? stackTrace.join("\n\n-----async gap-----\n") : stackTrace.toString();
|
|
};
|
|
ExceptionHandler.prototype._findContext = function(exception) {
|
|
try {
|
|
if (!(exception instanceof exceptions_1.WrappedException))
|
|
return null;
|
|
return lang_1.isPresent(exception.context) ? exception.context : this._findContext(exception.originalException);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
};
|
|
ExceptionHandler.prototype._findOriginalException = function(exception) {
|
|
if (!(exception instanceof exceptions_1.WrappedException))
|
|
return null;
|
|
var e = exception.originalException;
|
|
while (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
|
|
e = e.originalException;
|
|
}
|
|
return e;
|
|
};
|
|
ExceptionHandler.prototype._findOriginalStack = function(exception) {
|
|
if (!(exception instanceof exceptions_1.WrappedException))
|
|
return null;
|
|
var e = exception;
|
|
var stack = exception.originalStack;
|
|
while (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
|
|
e = e.originalException;
|
|
if (e instanceof exceptions_1.WrappedException && lang_1.isPresent(e.originalException)) {
|
|
stack = e.originalStack;
|
|
}
|
|
}
|
|
return stack;
|
|
};
|
|
return ExceptionHandler;
|
|
})();
|
|
exports.ExceptionHandler = ExceptionHandler;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("3c", ["19f"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var __extends = (this && this.__extends) || function(d, b) {
|
|
for (var p in b)
|
|
if (b.hasOwnProperty(p))
|
|
d[p] = b[p];
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
};
|
|
var exception_handler_1 = $__require('19f');
|
|
var exception_handler_2 = $__require('19f');
|
|
exports.ExceptionHandler = exception_handler_2.ExceptionHandler;
|
|
var BaseException = (function(_super) {
|
|
__extends(BaseException, _super);
|
|
function BaseException(message) {
|
|
if (message === void 0) {
|
|
message = "--";
|
|
}
|
|
_super.call(this, message);
|
|
this.message = message;
|
|
this.stack = (new Error(message)).stack;
|
|
}
|
|
BaseException.prototype.toString = function() {
|
|
return this.message;
|
|
};
|
|
return BaseException;
|
|
})(Error);
|
|
exports.BaseException = BaseException;
|
|
var WrappedException = (function(_super) {
|
|
__extends(WrappedException, _super);
|
|
function WrappedException(_wrapperMessage, _originalException, _originalStack, _context) {
|
|
_super.call(this, _wrapperMessage);
|
|
this._wrapperMessage = _wrapperMessage;
|
|
this._originalException = _originalException;
|
|
this._originalStack = _originalStack;
|
|
this._context = _context;
|
|
this._wrapperStack = (new Error(_wrapperMessage)).stack;
|
|
}
|
|
Object.defineProperty(WrappedException.prototype, "wrapperMessage", {
|
|
get: function() {
|
|
return this._wrapperMessage;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(WrappedException.prototype, "wrapperStack", {
|
|
get: function() {
|
|
return this._wrapperStack;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(WrappedException.prototype, "originalException", {
|
|
get: function() {
|
|
return this._originalException;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(WrappedException.prototype, "originalStack", {
|
|
get: function() {
|
|
return this._originalStack;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(WrappedException.prototype, "context", {
|
|
get: function() {
|
|
return this._context;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(WrappedException.prototype, "message", {
|
|
get: function() {
|
|
return exception_handler_1.ExceptionHandler.exceptionToString(this);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
WrappedException.prototype.toString = function() {
|
|
return this.message;
|
|
};
|
|
return WrappedException;
|
|
})(Error);
|
|
exports.WrappedException = WrappedException;
|
|
function makeTypeError(message) {
|
|
return new TypeError(message);
|
|
}
|
|
exports.makeTypeError = makeTypeError;
|
|
function unimplemented() {
|
|
throw new BaseException('unimplemented');
|
|
}
|
|
exports.unimplemented = unimplemented;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("8c", ["20", "3c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var lang_1 = $__require('20');
|
|
var exceptions_1 = $__require('3c');
|
|
var ReflectionCapabilities = (function() {
|
|
function ReflectionCapabilities(reflect) {
|
|
this._reflect = lang_1.isPresent(reflect) ? reflect : lang_1.global.Reflect;
|
|
}
|
|
ReflectionCapabilities.prototype.isReflectionEnabled = function() {
|
|
return true;
|
|
};
|
|
ReflectionCapabilities.prototype.factory = function(t) {
|
|
switch (t.length) {
|
|
case 0:
|
|
return function() {
|
|
return new t();
|
|
};
|
|
case 1:
|
|
return function(a1) {
|
|
return new t(a1);
|
|
};
|
|
case 2:
|
|
return function(a1, a2) {
|
|
return new t(a1, a2);
|
|
};
|
|
case 3:
|
|
return function(a1, a2, a3) {
|
|
return new t(a1, a2, a3);
|
|
};
|
|
case 4:
|
|
return function(a1, a2, a3, a4) {
|
|
return new t(a1, a2, a3, a4);
|
|
};
|
|
case 5:
|
|
return function(a1, a2, a3, a4, a5) {
|
|
return new t(a1, a2, a3, a4, a5);
|
|
};
|
|
case 6:
|
|
return function(a1, a2, a3, a4, a5, a6) {
|
|
return new t(a1, a2, a3, a4, a5, a6);
|
|
};
|
|
case 7:
|
|
return function(a1, a2, a3, a4, a5, a6, a7) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7);
|
|
};
|
|
case 8:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8);
|
|
};
|
|
case 9:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
|
};
|
|
case 10:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
|
};
|
|
case 11:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
|
|
};
|
|
case 12:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
|
|
};
|
|
case 13:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
|
|
};
|
|
case 14:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
|
|
};
|
|
case 15:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
|
|
};
|
|
case 16:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16);
|
|
};
|
|
case 17:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17);
|
|
};
|
|
case 18:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18);
|
|
};
|
|
case 19:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19);
|
|
};
|
|
case 20:
|
|
return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) {
|
|
return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
|
|
};
|
|
}
|
|
;
|
|
throw new Error("Cannot create a factory for '" + lang_1.stringify(t) + "' because its constructor has more than 20 arguments");
|
|
};
|
|
ReflectionCapabilities.prototype._zipTypesAndAnnotaions = function(paramTypes, paramAnnotations) {
|
|
var result;
|
|
if (typeof paramTypes === 'undefined') {
|
|
result = new Array(paramAnnotations.length);
|
|
} else {
|
|
result = new Array(paramTypes.length);
|
|
}
|
|
for (var i = 0; i < result.length; i++) {
|
|
if (typeof paramTypes === 'undefined') {
|
|
result[i] = [];
|
|
} else if (paramTypes[i] != Object) {
|
|
result[i] = [paramTypes[i]];
|
|
} else {
|
|
result[i] = [];
|
|
}
|
|
if (lang_1.isPresent(paramAnnotations) && lang_1.isPresent(paramAnnotations[i])) {
|
|
result[i] = result[i].concat(paramAnnotations[i]);
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
ReflectionCapabilities.prototype.parameters = function(typeOrFunc) {
|
|
if (lang_1.isPresent(typeOrFunc.parameters)) {
|
|
return typeOrFunc.parameters;
|
|
}
|
|
if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
|
|
var paramAnnotations = this._reflect.getMetadata('parameters', typeOrFunc);
|
|
var paramTypes = this._reflect.getMetadata('design:paramtypes', typeOrFunc);
|
|
if (lang_1.isPresent(paramTypes) || lang_1.isPresent(paramAnnotations)) {
|
|
return this._zipTypesAndAnnotaions(paramTypes, paramAnnotations);
|
|
}
|
|
}
|
|
var parameters = new Array(typeOrFunc.length);
|
|
parameters.fill(undefined);
|
|
return parameters;
|
|
};
|
|
ReflectionCapabilities.prototype.annotations = function(typeOrFunc) {
|
|
if (lang_1.isPresent(typeOrFunc.annotations)) {
|
|
var annotations = typeOrFunc.annotations;
|
|
if (lang_1.isFunction(annotations) && annotations.annotations) {
|
|
annotations = annotations.annotations;
|
|
}
|
|
return annotations;
|
|
}
|
|
if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
|
|
var annotations = this._reflect.getMetadata('annotations', typeOrFunc);
|
|
if (lang_1.isPresent(annotations))
|
|
return annotations;
|
|
}
|
|
return [];
|
|
};
|
|
ReflectionCapabilities.prototype.propMetadata = function(typeOrFunc) {
|
|
if (lang_1.isPresent(typeOrFunc.propMetadata)) {
|
|
var propMetadata = typeOrFunc.propMetadata;
|
|
if (lang_1.isFunction(propMetadata) && propMetadata.propMetadata) {
|
|
propMetadata = propMetadata.propMetadata;
|
|
}
|
|
return propMetadata;
|
|
}
|
|
if (lang_1.isPresent(this._reflect) && lang_1.isPresent(this._reflect.getMetadata)) {
|
|
var propMetadata = this._reflect.getMetadata('propMetadata', typeOrFunc);
|
|
if (lang_1.isPresent(propMetadata))
|
|
return propMetadata;
|
|
}
|
|
return {};
|
|
};
|
|
ReflectionCapabilities.prototype.interfaces = function(type) {
|
|
throw new exceptions_1.BaseException("JavaScript does not support interfaces");
|
|
};
|
|
ReflectionCapabilities.prototype.getter = function(name) {
|
|
return new Function('o', 'return o.' + name + ';');
|
|
};
|
|
ReflectionCapabilities.prototype.setter = function(name) {
|
|
return new Function('o', 'v', 'return o.' + name + ' = v;');
|
|
};
|
|
ReflectionCapabilities.prototype.method = function(name) {
|
|
var functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
|
|
return new Function('o', 'args', functionBody);
|
|
};
|
|
ReflectionCapabilities.prototype.importUri = function(type) {
|
|
return './';
|
|
};
|
|
return ReflectionCapabilities;
|
|
})();
|
|
exports.ReflectionCapabilities = ReflectionCapabilities;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("81", ["1f3", "8c"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var reflector_1 = $__require('1f3');
|
|
var reflector_2 = $__require('1f3');
|
|
exports.Reflector = reflector_2.Reflector;
|
|
exports.ReflectionInfo = reflector_2.ReflectionInfo;
|
|
var reflection_capabilities_1 = $__require('8c');
|
|
exports.reflector = new reflector_1.Reflector(new reflection_capabilities_1.ReflectionCapabilities());
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("14", ["50", "19b", "19d", "39", "19e", "20", "5b", "88", "1a3", "1a4", "1a5", "57", "5e", "1e9", "82", "1ac", "1f2", "81"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
function __export(m) {
|
|
for (var p in m)
|
|
if (!exports.hasOwnProperty(p))
|
|
exports[p] = m[p];
|
|
}
|
|
__export($__require('50'));
|
|
__export($__require('19b'));
|
|
__export($__require('19d'));
|
|
__export($__require('39'));
|
|
__export($__require('19e'));
|
|
var lang_1 = $__require('20');
|
|
exports.enableProdMode = lang_1.enableProdMode;
|
|
var application_ref_1 = $__require('5b');
|
|
exports.platform = application_ref_1.platform;
|
|
exports.createNgZone = application_ref_1.createNgZone;
|
|
exports.PlatformRef = application_ref_1.PlatformRef;
|
|
exports.ApplicationRef = application_ref_1.ApplicationRef;
|
|
var application_tokens_1 = $__require('88');
|
|
exports.APP_ID = application_tokens_1.APP_ID;
|
|
exports.APP_COMPONENT = application_tokens_1.APP_COMPONENT;
|
|
exports.APP_INITIALIZER = application_tokens_1.APP_INITIALIZER;
|
|
exports.PACKAGE_ROOT_URL = application_tokens_1.PACKAGE_ROOT_URL;
|
|
exports.PLATFORM_INITIALIZER = application_tokens_1.PLATFORM_INITIALIZER;
|
|
__export($__require('1a3'));
|
|
__export($__require('1a4'));
|
|
__export($__require('1a5'));
|
|
var debug_element_1 = $__require('57');
|
|
exports.DebugElement = debug_element_1.DebugElement;
|
|
exports.Scope = debug_element_1.Scope;
|
|
exports.inspectElement = debug_element_1.inspectElement;
|
|
exports.asNativeElements = debug_element_1.asNativeElements;
|
|
__export($__require('5e'));
|
|
__export($__require('1e9'));
|
|
__export($__require('82'));
|
|
__export($__require('1ac'));
|
|
__export($__require('1f2'));
|
|
__export($__require('81'));
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d2", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toString = {}.toString;
|
|
module.exports = function(it) {
|
|
return toString.call(it).slice(8, -1);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9a", ["d2"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var cof = $__require('d2');
|
|
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it) {
|
|
return cof(it) == 'String' ? it.split('') : Object(it);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("184", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(it) {
|
|
if (it == undefined)
|
|
throw TypeError("Can't call method on " + it);
|
|
return it;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("189", ["9a", "184"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var IObject = $__require('9a'),
|
|
defined = $__require('184');
|
|
module.exports = function(it) {
|
|
return IObject(defined(it));
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("9b", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(exec) {
|
|
try {
|
|
return !!exec();
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("196", ["8f", "2d", "9b"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $export = $__require('8f'),
|
|
core = $__require('2d'),
|
|
fails = $__require('9b');
|
|
module.exports = function(KEY, exec) {
|
|
var fn = (core.Object || {})[KEY] || Object[KEY],
|
|
exp = {};
|
|
exp[KEY] = exec(fn);
|
|
$export($export.S + $export.F * fails(function() {
|
|
fn(1);
|
|
}), 'Object', exp);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f4", ["189", "196"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var toIObject = $__require('189');
|
|
$__require('196')('getOwnPropertyDescriptor', function($getOwnPropertyDescriptor) {
|
|
return function getOwnPropertyDescriptor(it, key) {
|
|
return $getOwnPropertyDescriptor(toIObject(it), key);
|
|
};
|
|
});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f5", ["99", "1f4"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99');
|
|
$__require('1f4');
|
|
module.exports = function getOwnPropertyDescriptor(it, key) {
|
|
return $.getDesc(it, key);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f6", ["1f5"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('1f5'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("4", ["1f6"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var _Object$getOwnPropertyDescriptor = $__require('1f6')["default"];
|
|
exports["default"] = function get(_x, _x2, _x3) {
|
|
var _again = true;
|
|
_function: while (_again) {
|
|
var object = _x,
|
|
property = _x2,
|
|
receiver = _x3;
|
|
_again = false;
|
|
if (object === null)
|
|
object = Function.prototype;
|
|
var desc = _Object$getOwnPropertyDescriptor(object, property);
|
|
if (desc === undefined) {
|
|
var parent = Object.getPrototypeOf(object);
|
|
if (parent === null) {
|
|
return undefined;
|
|
} else {
|
|
_x = parent;
|
|
_x2 = property;
|
|
_x3 = receiver;
|
|
_again = true;
|
|
desc = parent = undefined;
|
|
continue _function;
|
|
}
|
|
} else if ("value" in desc) {
|
|
return desc.value;
|
|
} else {
|
|
var getter = desc.get;
|
|
if (getter === undefined) {
|
|
return undefined;
|
|
}
|
|
return getter.call(receiver);
|
|
}
|
|
}
|
|
};
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f7", ["99"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99');
|
|
module.exports = function create(P, D) {
|
|
return $.create(P, D);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f8", ["1f7"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('1f7'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ce", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
|
|
if (typeof __g == 'number')
|
|
__g = global;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("8f", ["ce", "2d", "8e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var global = $__require('ce'),
|
|
core = $__require('2d'),
|
|
ctx = $__require('8e'),
|
|
PROTOTYPE = 'prototype';
|
|
var $export = function(type, name, source) {
|
|
var IS_FORCED = type & $export.F,
|
|
IS_GLOBAL = type & $export.G,
|
|
IS_STATIC = type & $export.S,
|
|
IS_PROTO = type & $export.P,
|
|
IS_BIND = type & $export.B,
|
|
IS_WRAP = type & $export.W,
|
|
exports = IS_GLOBAL ? core : core[name] || (core[name] = {}),
|
|
target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE],
|
|
key,
|
|
own,
|
|
out;
|
|
if (IS_GLOBAL)
|
|
source = name;
|
|
for (key in source) {
|
|
own = !IS_FORCED && target && key in target;
|
|
if (own && key in exports)
|
|
continue;
|
|
out = own ? target[key] : source[key];
|
|
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] : IS_BIND && own ? ctx(out, global) : IS_WRAP && target[key] == out ? (function(C) {
|
|
var F = function(param) {
|
|
return this instanceof C ? new C(param) : C(param);
|
|
};
|
|
F[PROTOTYPE] = C[PROTOTYPE];
|
|
return F;
|
|
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
|
|
if (IS_PROTO)
|
|
(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out;
|
|
}
|
|
};
|
|
$export.F = 1;
|
|
$export.G = 2;
|
|
$export.S = 4;
|
|
$export.P = 8;
|
|
$export.B = 16;
|
|
$export.W = 32;
|
|
module.exports = $export;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d0", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(it) {
|
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("ca", ["d0"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var isObject = $__require('d0');
|
|
module.exports = function(it) {
|
|
if (!isObject(it))
|
|
throw TypeError(it + ' is not an object!');
|
|
return it;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("cb", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = function(it) {
|
|
if (typeof it != 'function')
|
|
throw TypeError(it + ' is not a function!');
|
|
return it;
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("8e", ["cb"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var aFunction = $__require('cb');
|
|
module.exports = function(fn, that, length) {
|
|
aFunction(fn);
|
|
if (that === undefined)
|
|
return fn;
|
|
switch (length) {
|
|
case 1:
|
|
return function(a) {
|
|
return fn.call(that, a);
|
|
};
|
|
case 2:
|
|
return function(a, b) {
|
|
return fn.call(that, a, b);
|
|
};
|
|
case 3:
|
|
return function(a, b, c) {
|
|
return fn.call(that, a, b, c);
|
|
};
|
|
}
|
|
return function() {
|
|
return fn.apply(that, arguments);
|
|
};
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("d8", ["99", "d0", "ca", "8e"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var getDesc = $__require('99').getDesc,
|
|
isObject = $__require('d0'),
|
|
anObject = $__require('ca');
|
|
var check = function(O, proto) {
|
|
anObject(O);
|
|
if (!isObject(proto) && proto !== null)
|
|
throw TypeError(proto + ": can't set as prototype!");
|
|
};
|
|
module.exports = {
|
|
set: Object.setPrototypeOf || ('__proto__' in {} ? function(test, buggy, set) {
|
|
try {
|
|
set = $__require('8e')(Function.call, getDesc(Object.prototype, '__proto__').set, 2);
|
|
set(test, []);
|
|
buggy = !(test instanceof Array);
|
|
} catch (e) {
|
|
buggy = true;
|
|
}
|
|
return function setPrototypeOf(O, proto) {
|
|
check(O, proto);
|
|
if (buggy)
|
|
O.__proto__ = proto;
|
|
else
|
|
set(O, proto);
|
|
return O;
|
|
};
|
|
}({}, false) : undefined),
|
|
check: check
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1f9", ["8f", "d8"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $export = $__require('8f');
|
|
$export($export.S, 'Object', {setPrototypeOf: $__require('d8').set});
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("2d", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var core = module.exports = {version: '1.2.6'};
|
|
if (typeof __e == 'number')
|
|
__e = core;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1fa", ["1f9", "2d"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
$__require('1f9');
|
|
module.exports = $__require('2d').Object.setPrototypeOf;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1fb", ["1fa"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('1fa'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("5", ["1f8", "1fb"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var _Object$create = $__require('1f8')["default"];
|
|
var _Object$setPrototypeOf = $__require('1fb')["default"];
|
|
exports["default"] = function(subClass, superClass) {
|
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
}
|
|
subClass.prototype = _Object$create(superClass && superClass.prototype, {constructor: {
|
|
value: subClass,
|
|
enumerable: false,
|
|
writable: true,
|
|
configurable: true
|
|
}});
|
|
if (superClass)
|
|
_Object$setPrototypeOf ? _Object$setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
};
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("99", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $Object = Object;
|
|
module.exports = {
|
|
create: $Object.create,
|
|
getProto: $Object.getPrototypeOf,
|
|
isEnum: {}.propertyIsEnumerable,
|
|
getDesc: $Object.getOwnPropertyDescriptor,
|
|
setDesc: $Object.defineProperty,
|
|
setDescs: $Object.defineProperties,
|
|
getKeys: $Object.keys,
|
|
getNames: $Object.getOwnPropertyNames,
|
|
getSymbols: $Object.getOwnPropertySymbols,
|
|
each: [].forEach
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1fc", ["99"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var $ = $__require('99');
|
|
module.exports = function defineProperty(it, key, desc) {
|
|
return $.setDesc(it, key, desc);
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1fd", ["1fc"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = {
|
|
"default": $__require('1fc'),
|
|
__esModule: true
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("6", ["1fd"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var _Object$defineProperty = $__require('1fd')["default"];
|
|
exports["default"] = (function() {
|
|
function defineProperties(target, props) {
|
|
for (var i = 0; i < props.length; i++) {
|
|
var descriptor = props[i];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
_Object$defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
return function(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
};
|
|
})();
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("7", [], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
exports["default"] = function(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
};
|
|
exports.__esModule = true;
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1fe", [], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var toString = Object.prototype.toString;
|
|
module.exports = function forEach(obj, fn, ctx) {
|
|
if (toString.call(fn) !== '[object Function]') {
|
|
throw new TypeError('iterator must be a function');
|
|
}
|
|
var l = obj.length;
|
|
if (l === +l) {
|
|
for (var i = 0; i < l; i++) {
|
|
fn.call(ctx, obj[i], i, obj);
|
|
}
|
|
} else {
|
|
for (var k in obj) {
|
|
if (hasOwn.call(obj, k)) {
|
|
fn.call(ctx, obj[k], k, obj);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("1ff", ["1fe"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('1fe');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("200", ["1ff"], true, function($__require, exports, module) {
|
|
"use strict";
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
var each = $__require('1ff');
|
|
module.exports = api;
|
|
function api(obj, pointer, value) {
|
|
if (arguments.length === 3) {
|
|
return api.set(obj, pointer, value);
|
|
}
|
|
if (arguments.length === 2) {
|
|
return api.get(obj, pointer);
|
|
}
|
|
var wrapped = api.bind(api, obj);
|
|
for (var name in api) {
|
|
if (api.hasOwnProperty(name)) {
|
|
wrapped[name] = api[name].bind(wrapped, obj);
|
|
}
|
|
}
|
|
return wrapped;
|
|
}
|
|
api.get = function get(obj, pointer) {
|
|
var tok,
|
|
refTokens = api.parse(pointer);
|
|
while (refTokens.length) {
|
|
tok = refTokens.shift();
|
|
if (!(tok in obj)) {
|
|
throw new Error('Invalid reference token: ' + tok);
|
|
}
|
|
obj = obj[tok];
|
|
}
|
|
return obj;
|
|
};
|
|
api.set = function set(obj, pointer, value) {
|
|
var refTokens = api.parse(pointer),
|
|
tok,
|
|
nextTok = refTokens[0];
|
|
while (refTokens.length > 1) {
|
|
tok = refTokens.shift();
|
|
if (tok === '-' && Array.isArray(obj)) {
|
|
tok = obj.length;
|
|
}
|
|
nextTok = refTokens[0];
|
|
if (!(tok in obj)) {
|
|
if (nextTok.match(/^(\d+|-)$/)) {
|
|
obj[tok] = [];
|
|
} else {
|
|
obj[tok] = {};
|
|
}
|
|
}
|
|
obj = obj[tok];
|
|
}
|
|
if (nextTok === '-' && Array.isArray(obj)) {
|
|
nextTok = obj.length;
|
|
}
|
|
obj[nextTok] = value;
|
|
return this;
|
|
};
|
|
api.remove = function(obj, pointer) {
|
|
var refTokens = api.parse(pointer);
|
|
var finalToken = refTokens.pop();
|
|
if (finalToken === undefined) {
|
|
throw new Error('Invalid JSON pointer for remove: "' + pointer + '"');
|
|
}
|
|
delete api.get(obj, api.compile(refTokens))[finalToken];
|
|
};
|
|
api.dict = function dict(obj, descend) {
|
|
var results = {};
|
|
api.walk(obj, function(value, pointer) {
|
|
results[pointer] = value;
|
|
}, descend);
|
|
return results;
|
|
};
|
|
api.walk = function walk(obj, iterator, descend) {
|
|
var refTokens = [];
|
|
descend = descend || function(value) {
|
|
var type = Object.prototype.toString.call(value);
|
|
return type === '[object Object]' || type === '[object Array]';
|
|
};
|
|
(function next(cur) {
|
|
each(cur, function(value, key) {
|
|
refTokens.push(String(key));
|
|
if (descend(value)) {
|
|
next(value);
|
|
} else {
|
|
iterator(value, api.compile(refTokens));
|
|
}
|
|
refTokens.pop();
|
|
});
|
|
}(obj));
|
|
};
|
|
api.has = function has(obj, pointer) {
|
|
try {
|
|
api.get(obj, pointer);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
api.escape = function escape(str) {
|
|
return str.toString().replace(/~/g, '~0').replace(/\//g, '~1');
|
|
};
|
|
api.unescape = function unescape(str) {
|
|
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
};
|
|
api.parse = function parse(pointer) {
|
|
if (pointer === '') {
|
|
return [];
|
|
}
|
|
if (pointer.charAt(0) !== '/') {
|
|
throw new Error('Invalid JSON pointer: ' + pointer);
|
|
}
|
|
return pointer.substring(1).split(/\//).map(api.unescape);
|
|
};
|
|
api.compile = function compile(refTokens) {
|
|
if (refTokens.length === 0) {
|
|
return '';
|
|
}
|
|
return '/' + refTokens.map(api.escape).join('/');
|
|
};
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.registerDynamic("201", ["200"], true, function($__require, exports, module) {
|
|
;
|
|
var global = this,
|
|
__define = global.define;
|
|
global.define = undefined;
|
|
module.exports = $__require('200');
|
|
global.define = __define;
|
|
return module.exports;
|
|
});
|
|
|
|
$__System.register('c', ['4', '5', '6', '7', '201'], function (_export) {
|
|
var _get, _inherits, _createClass, _classCallCheck, JsonPointerLib, JsonPointer;
|
|
|
|
return {
|
|
setters: [function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_5) {
|
|
JsonPointerLib = _5['default'];
|
|
}],
|
|
execute: function () {
|
|
|
|
/**
|
|
* Wrapper for JsonPointer. Provides common operations
|
|
*/
|
|
'use strict';
|
|
|
|
JsonPointer = (function (_JsonPointerLib) {
|
|
_inherits(JsonPointer, _JsonPointerLib);
|
|
|
|
function JsonPointer() {
|
|
_classCallCheck(this, JsonPointer);
|
|
|
|
_get(Object.getPrototypeOf(JsonPointer.prototype), 'constructor', this).apply(this, arguments);
|
|
}
|
|
|
|
_createClass(JsonPointer, null, [{
|
|
key: 'baseName',
|
|
|
|
/**
|
|
* returns last JsonPointer token
|
|
* if level > 1 returns levels last (second last/third last)
|
|
* @example
|
|
* // returns subpath
|
|
* JsonPointerHelper.baseName('/path/0/subpath')
|
|
* // returns foo
|
|
* JsonPointerHelper.baseName('/path/foo/subpath', 2)
|
|
*/
|
|
value: function baseName(pointer) {
|
|
var level = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
|
|
|
|
var tokens = JsonPointer.parse(pointer);
|
|
return tokens[tokens.length - level];
|
|
}
|
|
|
|
/**
|
|
* returns dirname of pointer
|
|
* if level > 1 returns corresponding dirname in the hierarchy
|
|
* @example
|
|
* // returns /path/0
|
|
* JsonPointerHelper.dirName('/path/0/subpath')
|
|
* // returns /path
|
|
* JsonPointerHelper.dirName('/path/foo/subpath', 2)
|
|
*/
|
|
}, {
|
|
key: 'dirName',
|
|
value: function dirName(pointer) {
|
|
var level = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
|
|
|
|
var tokens = JsonPointer.parse(pointer);
|
|
return JsonPointer.compile(tokens.slice(0, tokens.length - level));
|
|
}
|
|
|
|
/**
|
|
* overridden JsonPointer original parse to take care of prefixing '#' symbol
|
|
* that is not valid JsonPointer
|
|
*/
|
|
}, {
|
|
key: 'parse',
|
|
value: function parse(pointer) {
|
|
var ptr = pointer;
|
|
if (ptr.charAt(0) === '#') {
|
|
ptr = ptr.substring(1);
|
|
}
|
|
return JsonPointerLib._origParse(ptr);
|
|
}
|
|
|
|
/**
|
|
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
*
|
|
* @param {string} base - The base path
|
|
* @param {string|string[]} tokens - The token(s) to append (e.g. ["name", "first"])
|
|
* @returns {string}
|
|
*/
|
|
}, {
|
|
key: 'join',
|
|
value: function join(base, tokens) {
|
|
// TODO: optimize
|
|
var baseTokens = JsonPointer.parse(base);
|
|
var resTokens = baseTokens.concat(tokens);
|
|
return JsonPointer.compile(resTokens);
|
|
}
|
|
}]);
|
|
|
|
return JsonPointer;
|
|
})(JsonPointerLib);
|
|
|
|
_export('JsonPointer', JsonPointer);
|
|
|
|
JsonPointerLib._origParse = JsonPointerLib.parse;
|
|
JsonPointerLib.parse = JsonPointer.parse;
|
|
|
|
_export('default', JsonPointer);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('a', ['3', '4', '5', '6', '7', '14', '24', '97', 'c'], function (_export) {
|
|
var RedocComponent, BaseComponent, _get, _inherits, _createClass, _classCallCheck, ElementRef, _Object$keys, _toConsumableArray, JsonPointer, JsonSchema;
|
|
|
|
return {
|
|
setters: [function (_7) {
|
|
RedocComponent = _7.RedocComponent;
|
|
BaseComponent = _7.BaseComponent;
|
|
}, function (_) {
|
|
_get = _['default'];
|
|
}, function (_2) {
|
|
_inherits = _2['default'];
|
|
}, function (_3) {
|
|
_createClass = _3['default'];
|
|
}, function (_4) {
|
|
_classCallCheck = _4['default'];
|
|
}, function (_8) {
|
|
ElementRef = _8.ElementRef;
|
|
}, function (_6) {
|
|
_Object$keys = _6['default'];
|
|
}, function (_5) {
|
|
_toConsumableArray = _5['default'];
|
|
}, function (_c) {
|
|
JsonPointer = _c['default'];
|
|
}],
|
|
execute: function () {
|
|
'use strict';
|
|
|
|
JsonSchema = (function (_BaseComponent) {
|
|
_inherits(JsonSchema, _BaseComponent);
|
|
|
|
function JsonSchema(schemaMgr, elementRef) {
|
|
_classCallCheck(this, _JsonSchema);
|
|
|
|
_get(Object.getPrototypeOf(_JsonSchema.prototype), 'constructor', this).call(this, schemaMgr);
|
|
this.element = elementRef.nativeElement;
|
|
}
|
|
|
|
_createClass(JsonSchema, [{
|
|
key: 'prepareModel',
|
|
value: function prepareModel() {
|
|
var _this = this;
|
|
|
|
this.data = {};
|
|
this.data.properties = [];
|
|
|
|
if (!this.componentSchema) {
|
|
// TODO
|
|
this.errorMessage = 'Can\'t load component schema';
|
|
console.warn(this.errorMessage + ': ' + this.pointer);
|
|
return;
|
|
}
|
|
|
|
this.dereference();
|
|
var schema = this.componentSchema;
|
|
|
|
if (schema.type === 'array') {
|
|
this.isArray = true;
|
|
schema = schema.items;
|
|
}
|
|
this.joinAllOf(schema);
|
|
|
|
if (schema.type !== 'object') {
|
|
this.isTrivial = true;
|
|
this._displayType = schema.type;
|
|
if (schema.format) this._displayType = this.displayType + ' <' + schema.format + '>';
|
|
return;
|
|
}
|
|
|
|
this.pointer = schema._pointer || this.pointer;
|
|
|
|
this.requiredMap = {};
|
|
if (this.schema.required) {
|
|
this.schema.required.forEach(function (prop) {
|
|
return _this.requiredMap[prop] = true;
|
|
});
|
|
}
|
|
|
|
if (!schema.properties) {
|
|
this.isTrivial = true;
|
|
this._displayType = schema.type + ' (Custom key-value pairs)';
|
|
return;
|
|
}
|
|
var props = _Object$keys(schema.properties).map(function (prop) {
|
|
var propData = schema.properties[prop];
|
|
_this.injectPropData(prop, propData);
|
|
return propData;
|
|
});
|
|
this.data.properties = props;
|
|
}
|
|
}, {
|
|
key: 'adjustNameColumnWidth',
|
|
value: function adjustNameColumnWidth() {
|
|
// TODO handle internal schemes differently
|
|
var names = [].slice.call(this.element.querySelectorAll('.param-name'));
|
|
var widths = names.map(function (el) {
|
|
return el.offsetWidth;
|
|
});
|
|
var maxWidth = Math.max.apply(Math, _toConsumableArray(widths));
|
|
if (!maxWidth) return;
|
|
names.forEach(function (el) {
|
|
el.style.minWidth = maxWidth + 'px';
|
|
});
|
|
}
|
|
}, {
|
|
key: 'injectPropData',
|
|
value: function injectPropData(prop, propData) {
|
|
propData._name = prop;
|
|
propData.isRequired = this.requiredMap[prop];
|
|
propData._displayType = propData.type;
|
|
if (propData.type === 'array') {
|
|
var itemType = propData.items.type;
|
|
var itemFormat = propData.items.format;
|
|
if (itemType === 'object') {
|
|
itemType = propData.items.title || 'object';
|
|
propData._pointer = propData.items._pointer || JsonPointer.join(this.pointer, ['properties', prop, 'items']);
|
|
}
|
|
propData._displayType = 'array of ' + itemType;
|
|
propData.format = itemFormat;
|
|
propData._isArray = true;
|
|
}
|
|
|
|
if (propData.type === 'object') {
|
|
propData._displayType = propData.title || 'object';
|
|
}
|
|
|
|
if (propData.format) propData._displayFormat = '<' + propData.format + '>';
|
|
}
|
|
}, {
|
|
key: 'init',
|
|
value: function init() {
|
|
var _this2 = this;
|
|
|
|
setTimeout(function () {
|
|
return _this2.adjustNameColumnWidth();
|
|
});
|
|
}
|
|
}]);
|
|
|
|
var _JsonSchema = JsonSchema;
|
|
JsonSchema = RedocComponent({
|
|
selector: 'json-schema',
|
|
template: '\n <small *ngIf="errorMessage">{{errorMessage}}</small>\n <span *ngIf="isTrivial" class="param-type param-type-trivial" [ngClass]="type">{{_displayType}}</span>\n <div *ngIf="!isTrivial" class="params-wrap" [ngClass]="{\'params-array\': isArray}">\n <div *ngFor="#prop of data.properties" class="param-wrap">\n <div class="param">\n <div class="param-name">\n <span>{{prop._name}}</span>\n </div>\n <div class="param-info">\n <div>\n <span class="param-type" [ngClass]="prop.type">{{prop._displayType}} {{prop._displayFormat}}</span>\n <span *ngIf="prop.isRequired" class="param-required">Required</span>\n </div>\n <div class="param-description" innerHtml="{{prop.description | marked}}"></div>\n </div>\n </div>\n <div class="param-schema" [ngClass]="{\'param-array\': prop._isArray}" *ngIf="prop._pointer">\n <json-schema pointer="{{prop._pointer}}" [isArray]=\'prop._isArray\'>\n </json-schema>\n </div>\n </div>\n </div>\n ',
|
|
styles: ['\n .param-schema {\n padding-left: 12.5px;\n border-left: 1px solid #7D97CE; }\n\n .param-wrap {\n position: relative; }\n\n .param-schema:before {\n content: "";\n position: absolute;\n left: 13.5px;\n top: 20px;\n bottom: 0;\n border-left: 1px solid #7D97CE; }\n\n .param-name {\n font-size: 14px;\n padding: 10px 25px 10px 0;\n font-weight: bold;\n box-sizing: border-box;\n line-height: 20px;\n border-left: 1px solid #7D97CE;\n white-space: nowrap;\n position: relative; }\n .param-name > span {\n vertical-align: middle; }\n\n .param-info {\n width: 100%;\n padding: 10px 0;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc; }\n\n .param {\n display: flex; }\n\n .param-required {\n color: red;\n font-weight: bold;\n font-size: 12px;\n line-height: 20px;\n vertical-align: middle; }\n\n .param-type {\n text-transform: capitalize;\n color: #999;\n font-size: 12px;\n line-height: 20px;\n vertical-align: middle;\n font-weight: bold; }\n\n .param-type-trivial {\n margin: 10px 10px 0;\n display: inline-block; }\n\n /* tree */\n .param-name > span:before {\n content: "";\n display: inline-block;\n width: 7px;\n height: 7px;\n background-color: #7D97CE;\n margin: 0 10px;\n vertical-align: middle; }\n\n .param-name > span:after {\n content: "";\n position: absolute;\n border-top: 1px solid #7D97CE;\n width: 10px;\n left: 0;\n top: 20px; }\n\n .param-wrap:first-of-type .param-name:before {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n top: 0;\n border-left: 1px solid white;\n height: 20px; }\n\n .param-wrap:last-of-type > .param > .param-name:after {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n border-left: 1px solid white;\n top: 21px;\n background-color: white;\n bottom: 0; }\n\n .param-wrap:last-of-type > .param-schema {\n border-left-color: transparent; }\n\n .param-schema .param-wrap:first-of-type .param-name:before {\n display: none !important; }\n\n /* styles for array-schema for array */\n .params-wrap.params-array:before, .params-wrap.params-array:after {\n display: block;\n font-weight: bold;\n color: #999;\n font-size: 12px;\n line-height: 1.5; }\n\n .params-wrap.params-array:after {\n content: "]"; }\n\n .params-wrap.params-array:before {\n content: "Array ["; }\n\n .params-wrap.params-array {\n padding-left: 10px; }\n\n .param-schema.param-array:before {\n bottom: 9px;\n width: 10px;\n border-left-style: dashed;\n border-bottom: 1px dashed #7D97CE; }\n\n .params-wrap.params-array > .param-wrap:first-of-type > .param > .param-name:after {\n content: "";\n display: block;\n position: absolute;\n left: -1px;\n top: 0;\n border-left: 1px solid white;\n height: 20px; }\n '],
|
|
directives: [JsonSchema],
|
|
inputs: ['isArray']
|
|
})(JsonSchema) || JsonSchema;
|
|
return JsonSchema;
|
|
})(BaseComponent);
|
|
|
|
_export('default', JsonSchema);
|
|
|
|
JsonSchema.parameters = JsonSchema.parameters.concat([[ElementRef]]);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('202', ['2', '8', '9', '10', 'b', '1a', 'd', 'e', 'f', '1c', 'a'], function (_export) {
|
|
'use strict';
|
|
|
|
var ApiInfo, ApiLogo, ParamsList, MethodsList, Method, Redoc, ResponsesList, ResponsesSamples, SchemaSample, SideMenu, JsonSchema, REDOC_COMPONENTS;
|
|
return {
|
|
setters: [function (_) {
|
|
ApiInfo = _['default'];
|
|
}, function (_2) {
|
|
ApiLogo = _2['default'];
|
|
}, function (_4) {
|
|
ParamsList = _4['default'];
|
|
}, function (_3) {
|
|
MethodsList = _3['default'];
|
|
}, function (_b) {
|
|
Method = _b['default'];
|
|
}, function (_a) {
|
|
Redoc = _a['default'];
|
|
}, function (_d) {
|
|
ResponsesList = _d['default'];
|
|
}, function (_e) {
|
|
ResponsesSamples = _e['default'];
|
|
}, function (_f) {
|
|
SchemaSample = _f['default'];
|
|
}, function (_c) {
|
|
SideMenu = _c['default'];
|
|
}, function (_a2) {
|
|
JsonSchema = _a2['default'];
|
|
}],
|
|
execute: function () {
|
|
REDOC_COMPONENTS = [ApiInfo, ApiLogo, JsonSchema, Method, MethodsList, ParamsList, Redoc, ResponsesList, ResponsesSamples, SchemaSample, SideMenu];
|
|
|
|
_export('ApiInfo', ApiInfo);
|
|
|
|
_export('ApiLogo', ApiLogo);
|
|
|
|
_export('JsonSchema', JsonSchema);
|
|
|
|
_export('Method', Method);
|
|
|
|
_export('MethodsList', MethodsList);
|
|
|
|
_export('ParamsList', ParamsList);
|
|
|
|
_export('Redoc', Redoc);
|
|
|
|
_export('ResponsesList', ResponsesList);
|
|
|
|
_export('ResponsesSamples', ResponsesSamples);
|
|
|
|
_export('SchemaSample', SchemaSample);
|
|
|
|
_export('SideMenu', SideMenu);
|
|
|
|
_export('REDOC_COMPONENTS', REDOC_COMPONENTS);
|
|
}
|
|
};
|
|
});
|
|
$__System.register('1', ['202'], function (_export) {
|
|
'use strict';
|
|
|
|
var Redoc, init;
|
|
return {
|
|
setters: [function (_) {
|
|
Redoc = _.Redoc;
|
|
}],
|
|
execute: function () {
|
|
init = Redoc.init;
|
|
|
|
_export('init', init);
|
|
|
|
window.Redoc = Redoc;
|
|
}
|
|
};
|
|
});
|
|
})
|
|
(function(factory) {
|
|
if (typeof define == 'function' && define.amd)
|
|
define([], factory);
|
|
else
|
|
factory();
|
|
});
|
|
|
|
//# sourceMappingURL=redoc.full.js.map
|