Created
March 28, 2016 04:36
-
-
Save aadamsx/eaa33784cffadd1bd455 to your computer and use it in GitHub Desktop.
Standalone Blaze, Tracker etc
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package = {}; | |
_.contains = _.includes; | |
/* Package-scope variables */ | |
var Meteor; | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/client_environment.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
/** // 1 | |
* @summary The Meteor namespace // 2 | |
* @namespace Meteor // 3 | |
*/ // 4 | |
Meteor = { // 5 | |
// 6 | |
/** // 7 | |
* @summary Boolean variable. True if running in client environment. // 8 | |
* @locus Anywhere // 9 | |
* @static // 10 | |
* @type {Boolean} // 11 | |
*/ // 12 | |
isClient: true, // 13 | |
// 14 | |
/** // 15 | |
* @summary Boolean variable. True if running in server environment. // 16 | |
* @locus Anywhere // 17 | |
* @static // 18 | |
* @type {Boolean} // 19 | |
*/ // 20 | |
isServer: false, // 21 | |
isCordova: false // 22 | |
}; // 23 | |
// 24 | |
if (typeof __meteor_runtime_config__ === 'object' && // 25 | |
__meteor_runtime_config__.PUBLIC_SETTINGS) { // 26 | |
/** // 27 | |
* @summary `Meteor.settings` contains deployment-specific configuration options. You can initialize settings by passing the `--settings` option (which takes the name of a file containing JSON data) to `meteor run` or `meteor deploy`. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the `METEOR_SETTINGS` environment variable. If the settings object contains a key named `public`, then `Meteor.settings.public` will be available on the client as well as the server. All other properties of `Meteor.settings` are only defined on the server. You can rely on `Meteor.settings` and `Meteor.settings.public` being defined objects (not undefined) on both client and server even if there are no settings specified. Changes to `Meteor.settings.public` at runtime will be picked up by new client connections. | |
* @locus Anywhere // 29 | |
* @type {Object} // 30 | |
*/ // 31 | |
Meteor.settings = { 'public': __meteor_runtime_config__.PUBLIC_SETTINGS }; // 32 | |
} // 33 | |
// 34 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/helpers.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
if (Meteor.isServer) // 1 | |
var Future = Npm.require('fibers/future'); // 2 | |
// 3 | |
if (typeof __meteor_runtime_config__ === 'object' && // 4 | |
__meteor_runtime_config__.meteorRelease) { // 5 | |
/** // 6 | |
* @summary `Meteor.release` is a string containing the name of the [release](#meteorupdate) with which the project was built (for example, `"1.2.3"`). It is `undefined` if the project was built using a git checkout of Meteor. | |
* @locus Anywhere // 8 | |
* @type {String} // 9 | |
*/ // 10 | |
Meteor.release = __meteor_runtime_config__.meteorRelease; // 11 | |
} // 12 | |
// 13 | |
// XXX find a better home for these? Ideally they would be _.get, // 14 | |
// _.ensure, _.delete.. // 15 | |
// 16 | |
_.extend(Meteor, { // 17 | |
// _get(a,b,c,d) returns a[b][c][d], or else undefined if a[b] or // 18 | |
// a[b][c] doesn't exist. // 19 | |
// // 20 | |
_get: function (obj /*, arguments */) { // 21 | |
for (var i = 1; i < arguments.length; i++) { // 22 | |
if (!(arguments[i] in obj)) // 23 | |
return undefined; // 24 | |
obj = obj[arguments[i]]; // 25 | |
} // 26 | |
return obj; // 27 | |
}, // 28 | |
// 29 | |
// _ensure(a,b,c,d) ensures that a[b][c][d] exists. If it does not, // 30 | |
// it is created and set to {}. Either way, it is returned. // 31 | |
// // 32 | |
_ensure: function (obj /*, arguments */) { // 33 | |
for (var i = 1; i < arguments.length; i++) { // 34 | |
var key = arguments[i]; // 35 | |
if (!(key in obj)) // 36 | |
obj[key] = {}; // 37 | |
obj = obj[key]; // 38 | |
} // 39 | |
// 40 | |
return obj; // 41 | |
}, // 42 | |
// 43 | |
// _delete(a, b, c, d) deletes a[b][c][d], then a[b][c] unless it // 44 | |
// isn't empty, then a[b] unless it isn't empty. // 45 | |
// // 46 | |
_delete: function (obj /*, arguments */) { // 47 | |
var stack = [obj]; // 48 | |
var leaf = true; // 49 | |
for (var i = 1; i < arguments.length - 1; i++) { // 50 | |
var key = arguments[i]; // 51 | |
if (!(key in obj)) { // 52 | |
leaf = false; // 53 | |
break; // 54 | |
} // 55 | |
obj = obj[key]; // 56 | |
if (typeof obj !== "object") // 57 | |
break; // 58 | |
stack.push(obj); // 59 | |
} // 60 | |
// 61 | |
for (var i = stack.length - 1; i >= 0; i--) { // 62 | |
var key = arguments[i+1]; // 63 | |
// 64 | |
if (leaf) // 65 | |
leaf = false; // 66 | |
else // 67 | |
for (var other in stack[i][key]) // 68 | |
return; // not empty -- we're done // 69 | |
// 70 | |
delete stack[i][key]; // 71 | |
} // 72 | |
}, // 73 | |
// 74 | |
// wrapAsync can wrap any function that takes some number of arguments that // 75 | |
// can't be undefined, followed by some optional arguments, where the callback // 76 | |
// is the last optional argument. // 77 | |
// e.g. fs.readFile(pathname, [callback]), // 78 | |
// fs.open(pathname, flags, [mode], [callback]) // 79 | |
// For maximum effectiveness and least confusion, wrapAsync should be used on // 80 | |
// functions where the callback is the only argument of type Function. // 81 | |
// 82 | |
/** // 83 | |
* @memberOf Meteor // 84 | |
* @summary Wrap a function that takes a callback function as its final parameter. The signature of the callback of the wrapped function should be `function(error, result){}`. On the server, the wrapped function can be used either synchronously (without passing a callback) or asynchronously (when a callback is passed). On the client, a callback is always required; errors will be logged if there is no callback. If a callback is provided, the environment captured when the original function was called will be restored in the callback. | |
* @locus Anywhere // 86 | |
* @param {Function} func A function that takes a callback as its final parameter // 87 | |
* @param {Object} [context] Optional `this` object against which the original function will be invoked | |
*/ // 89 | |
wrapAsync: function (fn, context) { // 90 | |
return function (/* arguments */) { // 91 | |
var self = context || this; // 92 | |
var newArgs = _.toArray(arguments); // 93 | |
var callback; // 94 | |
// 95 | |
for (var i = newArgs.length - 1; i >= 0; --i) { // 96 | |
var arg = newArgs[i]; // 97 | |
var type = typeof arg; // 98 | |
if (type !== "undefined") { // 99 | |
if (type === "function") { // 100 | |
callback = arg; // 101 | |
} // 102 | |
break; // 103 | |
} // 104 | |
} // 105 | |
// 106 | |
if (! callback) { // 107 | |
if (Meteor.isClient) { // 108 | |
callback = logErr; // 109 | |
} else { // 110 | |
var fut = new Future(); // 111 | |
callback = fut.resolver(); // 112 | |
} // 113 | |
++i; // Insert the callback just after arg. // 114 | |
} // 115 | |
// 116 | |
newArgs[i] = Meteor.bindEnvironment(callback); // 117 | |
var result = fn.apply(self, newArgs); // 118 | |
return fut ? fut.wait() : result; // 119 | |
}; // 120 | |
}, // 121 | |
// 122 | |
// Sets child's prototype to a new object whose prototype is parent's // 123 | |
// prototype. Used as: // 124 | |
// Meteor._inherits(ClassB, ClassA). // 125 | |
// _.extend(ClassB.prototype, { ... }) // 126 | |
// Inspired by CoffeeScript's `extend` and Google Closure's `goog.inherits`. // 127 | |
_inherits: function (Child, Parent) { // 128 | |
// copy Parent static properties // 129 | |
for (var key in Parent) { // 130 | |
// make sure we only copy hasOwnProperty properties vs. prototype // 131 | |
// properties // 132 | |
if (_.has(Parent, key)) // 133 | |
Child[key] = Parent[key]; // 134 | |
} // 135 | |
// 136 | |
// a middle member of prototype chain: takes the prototype from the Parent // 137 | |
var Middle = function () { // 138 | |
this.constructor = Child; // 139 | |
}; // 140 | |
Middle.prototype = Parent.prototype; // 141 | |
Child.prototype = new Middle(); // 142 | |
Child.__super__ = Parent.prototype; // 143 | |
return Child; // 144 | |
} // 145 | |
}); // 146 | |
// 147 | |
var warnedAboutWrapAsync = false; // 148 | |
// 149 | |
/** // 150 | |
* @deprecated in 0.9.3 // 151 | |
*/ // 152 | |
Meteor._wrapAsync = function(fn, context) { // 153 | |
if (! warnedAboutWrapAsync) { // 154 | |
Meteor._debug("Meteor._wrapAsync has been renamed to Meteor.wrapAsync"); // 155 | |
warnedAboutWrapAsync = true; // 156 | |
} // 157 | |
return Meteor.wrapAsync.apply(Meteor, arguments); // 158 | |
}; // 159 | |
// 160 | |
function logErr(err) { // 161 | |
if (err) { // 162 | |
return Meteor._debug( // 163 | |
"Exception in callback of async function", // 164 | |
err.stack ? err.stack : err // 165 | |
); // 166 | |
} // 167 | |
} // 168 | |
// 169 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/setimmediate.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Chooses one of three setImmediate implementations: // 1 | |
// // 2 | |
// * Native setImmediate (IE 10, Node 0.9+) // 3 | |
// // 4 | |
// * postMessage (many browsers) // 5 | |
// // 6 | |
// * setTimeout (fallback) // 7 | |
// // 8 | |
// The postMessage implementation is based on // 9 | |
// https://github.com/NobleJS/setImmediate/tree/1.0.1 // 10 | |
// // 11 | |
// Don't use `nextTick` for Node since it runs its callbacks before // 12 | |
// I/O, which is stricter than we're looking for. // 13 | |
// // 14 | |
// Not installed as a polyfill, as our public API is `Meteor.defer`. // 15 | |
// Since we're not trying to be a polyfill, we have some // 16 | |
// simplifications: // 17 | |
// // 18 | |
// If one invocation of a setImmediate callback pauses itself by a // 19 | |
// call to alert/prompt/showModelDialog, the NobleJS polyfill // 20 | |
// implementation ensured that no setImmedate callback would run until // 21 | |
// the first invocation completed. While correct per the spec, what it // 22 | |
// would mean for us in practice is that any reactive updates relying // 23 | |
// on Meteor.defer would be hung in the main window until the modal // 24 | |
// dialog was dismissed. Thus we only ensure that a setImmediate // 25 | |
// function is called in a later event loop. // 26 | |
// // 27 | |
// We don't need to support using a string to be eval'ed for the // 28 | |
// callback, arguments to the function, or clearImmediate. // 29 | |
// 30 | |
"use strict"; // 31 | |
// 32 | |
var global = this; // 33 | |
// 34 | |
// 35 | |
// IE 10, Node >= 9.1 // 36 | |
// 37 | |
function useSetImmediate() { // 38 | |
if (! global.setImmediate) // 39 | |
return null; // 40 | |
else { // 41 | |
var setImmediate = function (fn) { // 42 | |
global.setImmediate(fn); // 43 | |
}; // 44 | |
setImmediate.implementation = 'setImmediate'; // 45 | |
return setImmediate; // 46 | |
} // 47 | |
} // 48 | |
// 49 | |
// 50 | |
// Android 2.3.6, Chrome 26, Firefox 20, IE 8-9, iOS 5.1.1 Safari // 51 | |
// 52 | |
function usePostMessage() { // 53 | |
// The test against `importScripts` prevents this implementation // 54 | |
// from being installed inside a web worker, where // 55 | |
// `global.postMessage` means something completely different and // 56 | |
// can't be used for this purpose. // 57 | |
// 58 | |
if (!global.postMessage || global.importScripts) { // 59 | |
return null; // 60 | |
} // 61 | |
// 62 | |
// Avoid synchronous post message implementations. // 63 | |
// 64 | |
var postMessageIsAsynchronous = true; // 65 | |
var oldOnMessage = global.onmessage; // 66 | |
global.onmessage = function () { // 67 | |
postMessageIsAsynchronous = false; // 68 | |
}; // 69 | |
global.postMessage("", "*"); // 70 | |
global.onmessage = oldOnMessage; // 71 | |
// 72 | |
if (! postMessageIsAsynchronous) // 73 | |
return null; // 74 | |
// 75 | |
var funcIndex = 0; // 76 | |
var funcs = {}; // 77 | |
// 78 | |
// Installs an event handler on `global` for the `message` event: see // 79 | |
// * https://developer.mozilla.org/en/DOM/window.postMessage // 80 | |
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages // 81 | |
// 82 | |
// XXX use Random.id() here? // 83 | |
var MESSAGE_PREFIX = "Meteor._setImmediate." + Math.random() + '.'; // 84 | |
// 85 | |
function isStringAndStartsWith(string, putativeStart) { // 86 | |
return (typeof string === "string" && // 87 | |
string.substring(0, putativeStart.length) === putativeStart); // 88 | |
} // 89 | |
// 90 | |
function onGlobalMessage(event) { // 91 | |
// This will catch all incoming messages (even from other // 92 | |
// windows!), so we need to try reasonably hard to avoid letting // 93 | |
// anyone else trick us into firing off. We test the origin is // 94 | |
// still this window, and that a (randomly generated) // 95 | |
// unpredictable identifying prefix is present. // 96 | |
if (event.source === global && // 97 | |
isStringAndStartsWith(event.data, MESSAGE_PREFIX)) { // 98 | |
var index = event.data.substring(MESSAGE_PREFIX.length); // 99 | |
try { // 100 | |
if (funcs[index]) // 101 | |
funcs[index](); // 102 | |
} // 103 | |
finally { // 104 | |
delete funcs[index]; // 105 | |
} // 106 | |
} // 107 | |
} // 108 | |
// 109 | |
if (global.addEventListener) { // 110 | |
global.addEventListener("message", onGlobalMessage, false); // 111 | |
} else { // 112 | |
global.attachEvent("onmessage", onGlobalMessage); // 113 | |
} // 114 | |
// 115 | |
var setImmediate = function (fn) { // 116 | |
// Make `global` post a message to itself with the handle and // 117 | |
// identifying prefix, thus asynchronously invoking our // 118 | |
// onGlobalMessage listener above. // 119 | |
++funcIndex; // 120 | |
funcs[funcIndex] = fn; // 121 | |
global.postMessage(MESSAGE_PREFIX + funcIndex, "*"); // 122 | |
}; // 123 | |
setImmediate.implementation = 'postMessage'; // 124 | |
return setImmediate; // 125 | |
} // 126 | |
// 127 | |
// 128 | |
function useTimeout() { // 129 | |
var setImmediate = function (fn) { // 130 | |
global.setTimeout(fn, 0); // 131 | |
}; // 132 | |
setImmediate.implementation = 'setTimeout'; // 133 | |
return setImmediate; // 134 | |
} // 135 | |
// 136 | |
// 137 | |
Meteor._setImmediate = // 138 | |
useSetImmediate() || // 139 | |
usePostMessage() || // 140 | |
useTimeout(); // 141 | |
// 142 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/timers.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
var withoutInvocation = function (f) { // 1 | |
if (Package.ddp) { // 2 | |
var _CurrentInvocation = Package.ddp.DDP._CurrentInvocation; // 3 | |
if (_CurrentInvocation.get() && _CurrentInvocation.get().isSimulation) // 4 | |
throw new Error("Can't set timers inside simulations"); // 5 | |
return function () { _CurrentInvocation.withValue(null, f); }; // 6 | |
} // 7 | |
else // 8 | |
return f; // 9 | |
}; // 10 | |
// 11 | |
var bindAndCatch = function (context, f) { // 12 | |
return Meteor.bindEnvironment(withoutInvocation(f), context); // 13 | |
}; // 14 | |
// 15 | |
_.extend(Meteor, { // 16 | |
// Meteor.setTimeout and Meteor.setInterval callbacks scheduled // 17 | |
// inside a server method are not part of the method invocation and // 18 | |
// should clear out the CurrentInvocation environment variable. // 19 | |
// 20 | |
/** // 21 | |
* @memberOf Meteor // 22 | |
* @summary Call a function in the future after waiting for a specified delay. // 23 | |
* @locus Anywhere // 24 | |
* @param {Function} func The function to run // 25 | |
* @param {Number} delay Number of milliseconds to wait before calling function // 26 | |
*/ // 27 | |
setTimeout: function (f, duration) { // 28 | |
return setTimeout(bindAndCatch("setTimeout callback", f), duration); // 29 | |
}, // 30 | |
// 31 | |
/** // 32 | |
* @memberOf Meteor // 33 | |
* @summary Call a function repeatedly, with a time delay between calls. // 34 | |
* @locus Anywhere // 35 | |
* @param {Function} func The function to run // 36 | |
* @param {Number} delay Number of milliseconds to wait between each function call. // 37 | |
*/ // 38 | |
setInterval: function (f, duration) { // 39 | |
return setInterval(bindAndCatch("setInterval callback", f), duration); // 40 | |
}, // 41 | |
// 42 | |
/** // 43 | |
* @memberOf Meteor // 44 | |
* @summary Cancel a repeating function call scheduled by `Meteor.setInterval`. // 45 | |
* @locus Anywhere // 46 | |
* @param {Number} id The handle returned by `Meteor.setInterval` // 47 | |
*/ // 48 | |
clearInterval: function(x) { // 49 | |
return clearInterval(x); // 50 | |
}, // 51 | |
// 52 | |
/** // 53 | |
* @memberOf Meteor // 54 | |
* @summary Cancel a function call scheduled by `Meteor.setTimeout`. // 55 | |
* @locus Anywhere // 56 | |
* @param {Number} id The handle returned by `Meteor.setTimeout` // 57 | |
*/ // 58 | |
clearTimeout: function(x) { // 59 | |
return clearTimeout(x); // 60 | |
}, // 61 | |
// 62 | |
// XXX consider making this guarantee ordering of defer'd callbacks, like // 63 | |
// Tracker.afterFlush or Node's nextTick (in practice). Then tests can do: // 64 | |
// callSomethingThatDefersSomeWork(); // 65 | |
// Meteor.defer(expect(somethingThatValidatesThatTheWorkHappened)); // 66 | |
defer: function (f) { // 67 | |
Meteor._setImmediate(bindAndCatch("defer callback", f)); // 68 | |
} // 69 | |
}); // 70 | |
// 71 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/errors.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Makes an error subclass which properly contains a stack trace in most // 1 | |
// environments. constructor can set fields on `this` (and should probably set // 2 | |
// `message`, which is what gets displayed at the top of a stack trace). // 3 | |
// // 4 | |
Meteor.makeErrorType = function (name, constructor) { // 5 | |
var errorClass = function (/*arguments*/) { // 6 | |
var self = this; // 7 | |
// 8 | |
// Ensure we get a proper stack trace in most Javascript environments // 9 | |
if (Error.captureStackTrace) { // 10 | |
// V8 environments (Chrome and Node.js) // 11 | |
Error.captureStackTrace(self, errorClass); // 12 | |
} else { // 13 | |
// Firefox // 14 | |
var e = new Error; // 15 | |
e.__proto__ = errorClass.prototype; // 16 | |
if (e instanceof errorClass) // 17 | |
self = e; // 18 | |
} // 19 | |
// Safari magically works. // 20 | |
// 21 | |
constructor.apply(self, arguments); // 22 | |
// 23 | |
self.errorType = name; // 24 | |
// 25 | |
return self; // 26 | |
}; // 27 | |
// 28 | |
Meteor._inherits(errorClass, Error); // 29 | |
// 30 | |
return errorClass; // 31 | |
}; // 32 | |
// 33 | |
// This should probably be in the livedata package, but we don't want // 34 | |
// to require you to use the livedata package to get it. Eventually we // 35 | |
// should probably rename it to DDP.Error and put it back in the // 36 | |
// 'livedata' package (which we should rename to 'ddp' also.) // 37 | |
// // 38 | |
// Note: The DDP server assumes that Meteor.Error EJSON-serializes as an object // 39 | |
// containing 'error' and optionally 'reason' and 'details'. // 40 | |
// The DDP client manually puts these into Meteor.Error objects. (We don't use // 41 | |
// EJSON.addType here because the type is determined by location in the // 42 | |
// protocol, not text on the wire.) // 43 | |
// 44 | |
/** // 45 | |
* @summary This class represents a symbolic error thrown by a method. // 46 | |
* @locus Anywhere // 47 | |
* @class // 48 | |
* @param {String} error A string code uniquely identifying this kind of error. // 49 | |
* This string should be used by callers of the method to determine the // 50 | |
* appropriate action to take, instead of attempting to parse the reason // 51 | |
* or details fields. For example: // 52 | |
* // 53 | |
* ``` // 54 | |
* // on the server, pick a code unique to this error // 55 | |
* // the reason field should be a useful debug message // 56 | |
* throw new Meteor.Error("logged-out", // 57 | |
* "The user must be logged in to post a comment."); // 58 | |
* // 59 | |
* // on the client // 60 | |
* Meteor.call("methodName", function (error) { // 61 | |
* // identify the error // 62 | |
* if (error && error.error === "logged-out") { // 63 | |
* // show a nice error message // 64 | |
* Session.set("errorMessage", "Please log in to post a comment."); // 65 | |
* } // 66 | |
* }); // 67 | |
* ``` // 68 | |
* // 69 | |
* For legacy reasons, some built-in Meteor functions such as `check` throw // 70 | |
* errors with a number in this field. // 71 | |
* // 72 | |
* @param {String} [reason] Optional. A short human-readable summary of the // 73 | |
* error, like 'Not Found'. // 74 | |
* @param {String} [details] Optional. Additional information about the error, // 75 | |
* like a textual stack trace. // 76 | |
*/ // 77 | |
Meteor.Error = Meteor.makeErrorType( // 78 | |
"Meteor.Error", // 79 | |
function (error, reason, details) { // 80 | |
var self = this; // 81 | |
// 82 | |
// String code uniquely identifying this kind of error. // 83 | |
self.error = error; // 84 | |
// 85 | |
// Optional: A short human-readable summary of the error. Not // 86 | |
// intended to be shown to end users, just developers. ("Not Found", // 87 | |
// "Internal Server Error") // 88 | |
self.reason = reason; // 89 | |
// 90 | |
// Optional: Additional information about the error, say for // 91 | |
// debugging. It might be a (textual) stack trace if the server is // 92 | |
// willing to provide one. The corresponding thing in HTTP would be // 93 | |
// the body of a 404 or 500 response. (The difference is that we // 94 | |
// never expect this to be shown to end users, only developers, so // 95 | |
// it doesn't need to be pretty.) // 96 | |
self.details = details; // 97 | |
// 98 | |
// This is what gets displayed at the top of a stack trace. Current // 99 | |
// format is "[404]" (if no reason is set) or "File not found [404]" // 100 | |
if (self.reason) // 101 | |
self.message = self.reason + ' [' + self.error + ']'; // 102 | |
else // 103 | |
self.message = '[' + self.error + ']'; // 104 | |
}); // 105 | |
// 106 | |
// Meteor.Error is basically data and is sent over DDP, so you should be able to // 107 | |
// properly EJSON-clone it. This is especially important because if a // 108 | |
// Meteor.Error is thrown through a Future, the error, reason, and details // 109 | |
// properties become non-enumerable so a standard Object clone won't preserve // 110 | |
// them and they will be lost from DDP. // 111 | |
Meteor.Error.prototype.clone = function () { // 112 | |
var self = this; // 113 | |
return new Meteor.Error(self.error, self.reason, self.details); // 114 | |
}; // 115 | |
// 116 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/fiber_stubs_client.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// This file is a partial analogue to fiber_helpers.js, which allows the client // 1 | |
// to use a queue too, and also to call noYieldsAllowed. // 2 | |
// 3 | |
// The client has no ability to yield, so noYieldsAllowed is a noop. // 4 | |
// // 5 | |
Meteor._noYieldsAllowed = function (f) { // 6 | |
return f(); // 7 | |
}; // 8 | |
// 9 | |
// An even simpler queue of tasks than the fiber-enabled one. This one just // 10 | |
// runs all the tasks when you call runTask or flush, synchronously. // 11 | |
// // 12 | |
Meteor._SynchronousQueue = function () { // 13 | |
var self = this; // 14 | |
self._tasks = []; // 15 | |
self._running = false; // 16 | |
self._runTimeout = null; // 17 | |
}; // 18 | |
// 19 | |
_.extend(Meteor._SynchronousQueue.prototype, { // 20 | |
runTask: function (task) { // 21 | |
var self = this; // 22 | |
if (!self.safeToRunTask()) // 23 | |
throw new Error("Could not synchronously run a task from a running task"); // 24 | |
self._tasks.push(task); // 25 | |
var tasks = self._tasks; // 26 | |
self._tasks = []; // 27 | |
self._running = true; // 28 | |
// 29 | |
if (self._runTimeout) { // 30 | |
// Since we're going to drain the queue, we can forget about the timeout // 31 | |
// which tries to run it. (But if one of our tasks queues something else, // 32 | |
// the timeout will be correctly re-created.) // 33 | |
clearTimeout(self._runTimeout); // 34 | |
self._runTimeout = null; // 35 | |
} // 36 | |
// 37 | |
try { // 38 | |
while (!_.isEmpty(tasks)) { // 39 | |
var t = tasks.shift(); // 40 | |
try { // 41 | |
t(); // 42 | |
} catch (e) { // 43 | |
if (_.isEmpty(tasks)) { // 44 | |
// this was the last task, that is, the one we're calling runTask // 45 | |
// for. // 46 | |
throw e; // 47 | |
} else { // 48 | |
Meteor._debug("Exception in queued task: " + (e.stack || e)); // 49 | |
} // 50 | |
} // 51 | |
} // 52 | |
} finally { // 53 | |
self._running = false; // 54 | |
} // 55 | |
}, // 56 | |
// 57 | |
queueTask: function (task) { // 58 | |
var self = this; // 59 | |
self._tasks.push(task); // 60 | |
// Intentionally not using Meteor.setTimeout, because it doesn't like runing // 61 | |
// in stubs for now. // 62 | |
if (!self._runTimeout) { // 63 | |
self._runTimeout = setTimeout(_.bind(self.flush, self), 0); // 64 | |
} // 65 | |
}, // 66 | |
// 67 | |
flush: function () { // 68 | |
var self = this; // 69 | |
self.runTask(function () {}); // 70 | |
}, // 71 | |
// 72 | |
drain: function () { // 73 | |
var self = this; // 74 | |
if (!self.safeToRunTask()) // 75 | |
return; // 76 | |
while (!_.isEmpty(self._tasks)) { // 77 | |
self.flush(); // 78 | |
} // 79 | |
}, // 80 | |
// 81 | |
safeToRunTask: function () { // 82 | |
var self = this; // 83 | |
return !self._running; // 84 | |
} // 85 | |
}); // 86 | |
// 87 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/startup_client.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
var queue = []; // 1 | |
var loaded = !Meteor.isCordova && // 2 | |
(document.readyState === "loaded" || document.readyState == "complete"); // 3 | |
// 4 | |
var awaitingEventsCount = 1; // 5 | |
var ready = function() { // 6 | |
awaitingEventsCount--; // 7 | |
if (awaitingEventsCount > 0) // 8 | |
return; // 9 | |
// 10 | |
loaded = true; // 11 | |
var runStartupCallbacks = function () { // 12 | |
if (Meteor.isCordova) { // 13 | |
if (! cordova.plugins || ! cordova.plugins.CordovaUpdate) { // 14 | |
// XXX This timeout should not be necessary. // 15 | |
// Cordova indicates that all the cordova plugins files have been loaded // 16 | |
// and plugins are ready to be used when the "deviceready" callback // 17 | |
// fires. Even though we wait for the "deviceready" event, plugins // 18 | |
// have been observed to still not be ready (likely a Cordova bug). // 19 | |
// We check the availability of the Cordova-Update plugin (the only // 20 | |
// plugin that we always include for sure) and retry a bit later if it // 21 | |
// is nowhere to be found. Experiments have found that either all // 22 | |
// plugins are attached or none. // 23 | |
Meteor.setTimeout(runStartupCallbacks, 20); // 24 | |
return; // 25 | |
} // 26 | |
} // 27 | |
// 28 | |
while (queue.length) // 29 | |
(queue.shift())(); // 30 | |
}; // 31 | |
runStartupCallbacks(); // 32 | |
}; // 33 | |
// 34 | |
if (document.addEventListener) { // 35 | |
document.addEventListener('DOMContentLoaded', ready, false); // 36 | |
// 37 | |
if (Meteor.isCordova) { // 38 | |
awaitingEventsCount++; // 39 | |
document.addEventListener('deviceready', ready, false); // 40 | |
} // 41 | |
// 42 | |
window.addEventListener('load', ready, false); // 43 | |
} else { // 44 | |
document.attachEvent('onreadystatechange', function () { // 45 | |
if (document.readyState === "complete") // 46 | |
ready(); // 47 | |
}); // 48 | |
window.attachEvent('load', ready); // 49 | |
} // 50 | |
// 51 | |
/** // 52 | |
* @summary Run code when a client or a server starts. // 53 | |
* @locus Anywhere // 54 | |
* @param {Function} func A function to run on startup. // 55 | |
*/ // 56 | |
Meteor.startup = function (cb) { // 57 | |
var doScroll = !document.addEventListener && // 58 | |
document.documentElement.doScroll; // 59 | |
// 60 | |
if (!doScroll || window !== top) { // 61 | |
if (loaded) // 62 | |
cb(); // 63 | |
else // 64 | |
queue.push(cb); // 65 | |
} else { // 66 | |
try { doScroll('left'); } // 67 | |
catch (e) { // 68 | |
setTimeout(function() { Meteor.startup(cb); }, 50); // 69 | |
return; // 70 | |
}; // 71 | |
cb(); // 72 | |
} // 73 | |
}; // 74 | |
// 75 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/debug.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
var suppress = 0; // 1 | |
// 2 | |
// replacement for console.log. This is a temporary API. We should // 3 | |
// provide a real logging API soon (possibly just a polyfill for // 4 | |
// console?) // 5 | |
// // 6 | |
// NOTE: this is used on the server to print the warning about // 7 | |
// having autopublish enabled when you probably meant to turn it // 8 | |
// off. it's not really the proper use of something called // 9 | |
// _debug. the intent is for this message to go to the terminal and // 10 | |
// be very visible. if you change _debug to go someplace else, etc, // 11 | |
// please fix the autopublish code to do something reasonable. // 12 | |
// // 13 | |
Meteor._debug = function (/* arguments */) { // 14 | |
if (suppress) { // 15 | |
suppress--; // 16 | |
return; // 17 | |
} // 18 | |
if (typeof console !== 'undefined' && // 19 | |
typeof console.log !== 'undefined') { // 20 | |
if (arguments.length == 0) { // IE Companion breaks otherwise // 21 | |
// IE10 PP4 requires at least one argument // 22 | |
console.log(''); // 23 | |
} else { // 24 | |
// IE doesn't have console.log.apply, it's not a real Object. // 25 | |
// http://stackoverflow.com/questions/5538972/console-log-apply-not-working-in-ie9 // 26 | |
// http://patik.com/blog/complete-cross-browser-console-log/ // 27 | |
if (typeof console.log.apply === "function") { // 28 | |
// Most browsers // 29 | |
// 30 | |
// Chrome and Safari only hyperlink URLs to source files in first argument of // 31 | |
// console.log, so try to call it with one argument if possible. // 32 | |
// Approach taken here: If all arguments are strings, join them on space. // 33 | |
// See https://github.com/meteor/meteor/pull/732#issuecomment-13975991 // 34 | |
var allArgumentsOfTypeString = true; // 35 | |
for (var i = 0; i < arguments.length; i++) // 36 | |
if (typeof arguments[i] !== "string") // 37 | |
allArgumentsOfTypeString = false; // 38 | |
// 39 | |
if (allArgumentsOfTypeString) // 40 | |
console.log.apply(console, [Array.prototype.join.call(arguments, " ")]); // 41 | |
else // 42 | |
console.log.apply(console, arguments); // 43 | |
// 44 | |
} else if (typeof Function.prototype.bind === "function") { // 45 | |
// IE9 // 46 | |
var log = Function.prototype.bind.call(console.log, console); // 47 | |
log.apply(console, arguments); // 48 | |
} else { // 49 | |
// IE8 // 50 | |
Function.prototype.call.call(console.log, console, Array.prototype.slice.call(arguments)); // 51 | |
} // 52 | |
} // 53 | |
} // 54 | |
}; // 55 | |
// 56 | |
// Suppress the next 'count' Meteor._debug messsages. Use this to // 57 | |
// stop tests from spamming the console. // 58 | |
// // 59 | |
Meteor._suppress_log = function (count) { // 60 | |
suppress += count; // 61 | |
}; // 62 | |
// 63 | |
Meteor._suppressed_log_expected = function () { // 64 | |
return suppress !== 0; // 65 | |
}; // 66 | |
// 67 | |
// 68 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/string_utils.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Like Perl's quotemeta: quotes all regexp metacharacters. // 1 | |
// Code taken from // 2 | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions // 3 | |
Meteor._escapeRegExp = function (string) { // 4 | |
return String(string).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // 5 | |
}; // 6 | |
// 7 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/dynamics_browser.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Simple implementation of dynamic scoping, for use in browsers // 1 | |
// 2 | |
var nextSlot = 0; // 3 | |
var currentValues = []; // 4 | |
// 5 | |
Meteor.EnvironmentVariable = function () { // 6 | |
this.slot = nextSlot++; // 7 | |
}; // 8 | |
// 9 | |
_.extend(Meteor.EnvironmentVariable.prototype, { // 10 | |
get: function () { // 11 | |
return currentValues[this.slot]; // 12 | |
}, // 13 | |
// 14 | |
getOrNullIfOutsideFiber: function () { // 15 | |
return this.get(); // 16 | |
}, // 17 | |
// 18 | |
withValue: function (value, func) { // 19 | |
var saved = currentValues[this.slot]; // 20 | |
try { // 21 | |
currentValues[this.slot] = value; // 22 | |
var ret = func(); // 23 | |
} finally { // 24 | |
currentValues[this.slot] = saved; // 25 | |
} // 26 | |
return ret; // 27 | |
} // 28 | |
}); // 29 | |
// 30 | |
Meteor.bindEnvironment = function (func, onException, _this) { // 31 | |
// needed in order to be able to create closures inside func and // 32 | |
// have the closed variables not change back to their original // 33 | |
// values // 34 | |
var boundValues = _.clone(currentValues); // 35 | |
// 36 | |
if (!onException || typeof(onException) === 'string') { // 37 | |
var description = onException || "callback of async function"; // 38 | |
onException = function (error) { // 39 | |
Meteor._debug( // 40 | |
"Exception in " + description + ":", // 41 | |
error && error.stack || error // 42 | |
); // 43 | |
}; // 44 | |
} // 45 | |
// 46 | |
return function (/* arguments */) { // 47 | |
var savedValues = currentValues; // 48 | |
try { // 49 | |
currentValues = boundValues; // 50 | |
var ret = func.apply(_this, _.toArray(arguments)); // 51 | |
} catch (e) { // 52 | |
// note: callback-hook currently relies on the fact that if onException // 53 | |
// throws in the browser, the wrapped call throws. // 54 | |
onException(e); // 55 | |
} finally { // 56 | |
currentValues = savedValues; // 57 | |
} // 58 | |
return ret; // 59 | |
}; // 60 | |
}; // 61 | |
// 62 | |
Meteor._nodeCodeMustBeInFiber = function () { // 63 | |
// no-op on browser // 64 | |
}; // 65 | |
// 66 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/meteor/url_common.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
/** // 1 | |
* @summary Generate an absolute URL pointing to the application. The server reads from the `ROOT_URL` environment variable to determine where it is running. This is taken care of automatically for apps deployed with `meteor deploy`, but must be provided when using `meteor build`. | |
* @locus Anywhere // 3 | |
* @param {String} [path] A path to append to the root URL. Do not include a leading "`/`". // 4 | |
* @param {Object} [options] // 5 | |
* @param {Boolean} options.secure Create an HTTPS URL. // 6 | |
* @param {Boolean} options.replaceLocalhost Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name. | |
* @param {String} options.rootUrl Override the default ROOT_URL from the server environment. For example: "`http://foo.example.com`" | |
*/ // 9 | |
Meteor.absoluteUrl = function (path, options) { // 10 | |
// path is optional // 11 | |
if (!options && typeof path === 'object') { // 12 | |
options = path; // 13 | |
path = undefined; // 14 | |
} // 15 | |
// merge options with defaults // 16 | |
options = _.extend({}, Meteor.absoluteUrl.defaultOptions, options || {}); // 17 | |
// 18 | |
var url = options.rootUrl; // 19 | |
if (!url) // 20 | |
throw new Error("Must pass options.rootUrl or set ROOT_URL in the server environment"); // 21 | |
// 22 | |
if (!/^http[s]?:\/\//i.test(url)) // url starts with 'http://' or 'https://' // 23 | |
url = 'http://' + url; // we will later fix to https if options.secure is set // 24 | |
// 25 | |
if (!/\/$/.test(url)) // url ends with '/' // 26 | |
url += '/'; // 27 | |
// 28 | |
if (path) // 29 | |
url += path; // 30 | |
// 31 | |
// turn http to https if secure option is set, and we're not talking // 32 | |
// to localhost. // 33 | |
if (options.secure && // 34 | |
/^http:/.test(url) && // url starts with 'http:' // 35 | |
!/http:\/\/localhost[:\/]/.test(url) && // doesn't match localhost // 36 | |
!/http:\/\/127\.0\.0\.1[:\/]/.test(url)) // or 127.0.0.1 // 37 | |
url = url.replace(/^http:/, 'https:'); // 38 | |
// 39 | |
if (options.replaceLocalhost) // 40 | |
url = url.replace(/^http:\/\/localhost([:\/].*)/, 'http://127.0.0.1$1'); // 41 | |
// 42 | |
return url; // 43 | |
}; // 44 | |
// 45 | |
// allow later packages to override default options // 46 | |
Meteor.absoluteUrl.defaultOptions = { }; // 47 | |
if (typeof __meteor_runtime_config__ === "object" && // 48 | |
__meteor_runtime_config__.ROOT_URL) // 49 | |
Meteor.absoluteUrl.defaultOptions.rootUrl = __meteor_runtime_config__.ROOT_URL; // 50 | |
// 51 | |
// 52 | |
Meteor._relativeToSiteRootUrl = function (link) { // 53 | |
if (typeof __meteor_runtime_config__ === "object" && // 54 | |
link.substr(0, 1) === "/") // 55 | |
link = (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || "") + link; // 56 | |
return link; // 57 | |
}; // 58 | |
// 59 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.meteor = { | |
Meteor: Meteor | |
}; | |
/* Package-scope variables */ | |
var Base64; | |
(function(){ | |
///////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/base64/packages/base64.js // | |
// // | |
///////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
////////////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/base64/base64.js // // 5 | |
// // // 6 | |
////////////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
// Base 64 encoding // 1 // 9 | |
// 2 // 10 | |
var BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // 11 | |
// 4 // 12 | |
var BASE_64_VALS = {}; // 5 // 13 | |
// 6 // 14 | |
for (var i = 0; i < BASE_64_CHARS.length; i++) { // 7 // 15 | |
BASE_64_VALS[BASE_64_CHARS.charAt(i)] = i; // 8 // 16 | |
}; // 9 // 17 | |
// 10 // 18 | |
Base64 = {}; // 11 // 19 | |
// 12 // 20 | |
Base64.encode = function (array) { // 13 // 21 | |
// 14 // 22 | |
if (typeof array === "string") { // 15 // 23 | |
var str = array; // 16 // 24 | |
array = Base64.newBinary(str.length); // 17 // 25 | |
for (var i = 0; i < str.length; i++) { // 18 // 26 | |
var ch = str.charCodeAt(i); // 19 // 27 | |
if (ch > 0xFF) { // 20 // 28 | |
throw new Error( // 21 // 29 | |
"Not ascii. Base64.encode can only take ascii strings."); // 22 // 30 | |
} // 23 // 31 | |
array[i] = ch; // 24 // 32 | |
} // 25 // 33 | |
} // 26 // 34 | |
// 27 // 35 | |
var answer = []; // 28 // 36 | |
var a = null; // 29 // 37 | |
var b = null; // 30 // 38 | |
var c = null; // 31 // 39 | |
var d = null; // 32 // 40 | |
for (var i = 0; i < array.length; i++) { // 33 // 41 | |
switch (i % 3) { // 34 // 42 | |
case 0: // 35 // 43 | |
a = (array[i] >> 2) & 0x3F; // 36 // 44 | |
b = (array[i] & 0x03) << 4; // 37 // 45 | |
break; // 38 // 46 | |
case 1: // 39 // 47 | |
b = b | (array[i] >> 4) & 0xF; // 40 // 48 | |
c = (array[i] & 0xF) << 2; // 41 // 49 | |
break; // 42 // 50 | |
case 2: // 43 // 51 | |
c = c | (array[i] >> 6) & 0x03; // 44 // 52 | |
d = array[i] & 0x3F; // 45 // 53 | |
answer.push(getChar(a)); // 46 // 54 | |
answer.push(getChar(b)); // 47 // 55 | |
answer.push(getChar(c)); // 48 // 56 | |
answer.push(getChar(d)); // 49 // 57 | |
a = null; // 50 // 58 | |
b = null; // 51 // 59 | |
c = null; // 52 // 60 | |
d = null; // 53 // 61 | |
break; // 54 // 62 | |
} // 55 // 63 | |
} // 56 // 64 | |
if (a != null) { // 57 // 65 | |
answer.push(getChar(a)); // 58 // 66 | |
answer.push(getChar(b)); // 59 // 67 | |
if (c == null) // 60 // 68 | |
answer.push('='); // 61 // 69 | |
else // 62 // 70 | |
answer.push(getChar(c)); // 63 // 71 | |
if (d == null) // 64 // 72 | |
answer.push('='); // 65 // 73 | |
} // 66 // 74 | |
return answer.join(""); // 67 // 75 | |
}; // 68 // 76 | |
// 69 // 77 | |
var getChar = function (val) { // 70 // 78 | |
return BASE_64_CHARS.charAt(val); // 71 // 79 | |
}; // 72 // 80 | |
// 73 // 81 | |
var getVal = function (ch) { // 74 // 82 | |
if (ch === '=') { // 75 // 83 | |
return -1; // 76 // 84 | |
} // 77 // 85 | |
return BASE_64_VALS[ch]; // 78 // 86 | |
}; // 79 // 87 | |
// 80 // 88 | |
// XXX This is a weird place for this to live, but it's used both by // 81 // 89 | |
// this package and 'ejson', and we can't put it in 'ejson' without // 82 // 90 | |
// introducing a circular dependency. It should probably be in its own // 83 // 91 | |
// package or as a helper in a package that both 'base64' and 'ejson' // 84 // 92 | |
// use. // 85 // 93 | |
Base64.newBinary = function (len) { // 86 // 94 | |
if (typeof Uint8Array === 'undefined' || typeof ArrayBuffer === 'undefined') { // 87 // 95 | |
var ret = []; // 88 // 96 | |
for (var i = 0; i < len; i++) { // 89 // 97 | |
ret.push(0); // 90 // 98 | |
} // 91 // 99 | |
ret.$Uint8ArrayPolyfill = true; // 92 // 100 | |
return ret; // 93 // 101 | |
} // 94 // 102 | |
return new Uint8Array(new ArrayBuffer(len)); // 95 // 103 | |
}; // 96 // 104 | |
// 97 // 105 | |
Base64.decode = function (str) { // 98 // 106 | |
var len = Math.floor((str.length*3)/4); // 99 // 107 | |
if (str.charAt(str.length - 1) == '=') { // 100 | |
len--; // 101 | |
if (str.charAt(str.length - 2) == '=') // 102 | |
len--; // 103 | |
} // 104 | |
var arr = Base64.newBinary(len); // 105 | |
// 106 | |
var one = null; // 107 | |
var two = null; // 108 | |
var three = null; // 109 | |
// 110 | |
var j = 0; // 111 | |
// 112 | |
for (var i = 0; i < str.length; i++) { // 113 | |
var c = str.charAt(i); // 114 | |
var v = getVal(c); // 115 | |
switch (i % 4) { // 116 | |
case 0: // 117 | |
if (v < 0) // 118 | |
throw new Error('invalid base64 string'); // 119 | |
one = v << 2; // 120 | |
break; // 121 | |
case 1: // 122 | |
if (v < 0) // 123 | |
throw new Error('invalid base64 string'); // 124 | |
one = one | (v >> 4); // 125 | |
arr[j++] = one; // 126 | |
two = (v & 0x0F) << 4; // 127 | |
break; // 128 | |
case 2: // 129 | |
if (v >= 0) { // 130 | |
two = two | (v >> 2); // 131 | |
arr[j++] = two; // 132 | |
three = (v & 0x03) << 6; // 133 | |
} // 134 | |
break; // 135 | |
case 3: // 136 | |
if (v >= 0) { // 137 | |
arr[j++] = three | v; // 138 | |
} // 139 | |
break; // 140 | |
} // 141 | |
} // 142 | |
return arr; // 143 | |
}; // 144 | |
// 145 | |
////////////////////////////////////////////////////////////////////////////////////////// // 154 | |
// 155 | |
}).call(this); // 156 | |
// 157 | |
///////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.base64 = { | |
Base64: Base64 | |
}; | |
/* Package-scope variables */ | |
var EJSON, EJSONTest; | |
(function(){ | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/ejson/packages/ejson.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/ejson/ejson.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
/** // 1 | |
* @namespace // 2 | |
* @summary Namespace for EJSON functions // 3 | |
*/ // 4 | |
EJSON = {}; // 5 | |
EJSONTest = {}; // 6 | |
// 7 | |
// 8 | |
// 9 | |
// Custom type interface definition // 10 | |
/** // 11 | |
* @class CustomType // 12 | |
* @instanceName customType // 13 | |
* @memberOf EJSON // 14 | |
* @summary The interface that a class must satisfy to be able to become an // 15 | |
* EJSON custom type via EJSON.addType. // 16 | |
*/ // 17 | |
// 18 | |
/** // 19 | |
* @function typeName // 20 | |
* @memberOf EJSON.CustomType // 21 | |
* @summary Return the tag used to identify this type. This must match the tag used to register this type with [`EJSON.addType`](#ejson_add_type). | |
* @locus Anywhere // 23 | |
* @instance // 24 | |
*/ // 25 | |
// 26 | |
/** // 27 | |
* @function toJSONValue // 28 | |
* @memberOf EJSON.CustomType // 29 | |
* @summary Serialize this instance into a JSON-compatible value. // 30 | |
* @locus Anywhere // 31 | |
* @instance // 32 | |
*/ // 33 | |
// 34 | |
/** // 35 | |
* @function clone // 36 | |
* @memberOf EJSON.CustomType // 37 | |
* @summary Return a value `r` such that `this.equals(r)` is true, and modifications to `r` do not affect `this` and vice versa. | |
* @locus Anywhere // 39 | |
* @instance // 40 | |
*/ // 41 | |
// 42 | |
/** // 43 | |
* @function equals // 44 | |
* @memberOf EJSON.CustomType // 45 | |
* @summary Return `true` if `other` has a value equal to `this`; `false` otherwise. // 46 | |
* @locus Anywhere // 47 | |
* @param {Object} other Another object to compare this to. // 48 | |
* @instance // 49 | |
*/ // 50 | |
// 51 | |
// 52 | |
var customTypes = {}; // 53 | |
// Add a custom type, using a method of your choice to get to and // 54 | |
// from a basic JSON-able representation. The factory argument // 55 | |
// is a function of JSON-able --> your object // 56 | |
// The type you add must have: // 57 | |
// - A toJSONValue() method, so that Meteor can serialize it // 58 | |
// - a typeName() method, to show how to look it up in our type table. // 59 | |
// It is okay if these methods are monkey-patched on. // 60 | |
// EJSON.clone will use toJSONValue and the given factory to produce // 61 | |
// a clone, but you may specify a method clone() that will be // 62 | |
// used instead. // 63 | |
// Similarly, EJSON.equals will use toJSONValue to make comparisons, // 64 | |
// but you may provide a method equals() instead. // 65 | |
/** // 66 | |
* @summary Add a custom datatype to EJSON. // 67 | |
* @locus Anywhere // 68 | |
* @param {String} name A tag for your custom type; must be unique among custom data types defined in your project, and must match the result of your type's `typeName` method. | |
* @param {Function} factory A function that deserializes a JSON-compatible value into an instance of your type. This should match the serialization performed by your type's `toJSONValue` method. | |
*/ // 71 | |
EJSON.addType = function (name, factory) { // 72 | |
if (_.has(customTypes, name)) // 73 | |
throw new Error("Type " + name + " already present"); // 74 | |
customTypes[name] = factory; // 75 | |
}; // 76 | |
// 77 | |
var isInfOrNan = function (obj) { // 78 | |
return _.isNaN(obj) || obj === Infinity || obj === -Infinity; // 79 | |
}; // 80 | |
// 81 | |
var builtinConverters = [ // 82 | |
{ // Date // 83 | |
matchJSONValue: function (obj) { // 84 | |
return _.has(obj, '$date') && _.size(obj) === 1; // 85 | |
}, // 86 | |
matchObject: function (obj) { // 87 | |
return obj instanceof Date; // 88 | |
}, // 89 | |
toJSONValue: function (obj) { // 90 | |
return {$date: obj.getTime()}; // 91 | |
}, // 92 | |
fromJSONValue: function (obj) { // 93 | |
return new Date(obj.$date); // 94 | |
} // 95 | |
}, // 96 | |
{ // NaN, Inf, -Inf. (These are the only objects with typeof !== 'object' // 97 | |
// which we match.) // 98 | |
matchJSONValue: function (obj) { // 99 | |
return _.has(obj, '$InfNaN') && _.size(obj) === 1; // 100 | |
}, // 101 | |
matchObject: isInfOrNan, // 102 | |
toJSONValue: function (obj) { // 103 | |
var sign; // 104 | |
if (_.isNaN(obj)) // 105 | |
sign = 0; // 106 | |
else if (obj === Infinity) // 107 | |
sign = 1; // 108 | |
else // 109 | |
sign = -1; // 110 | |
return {$InfNaN: sign}; // 111 | |
}, // 112 | |
fromJSONValue: function (obj) { // 113 | |
return obj.$InfNaN/0; // 114 | |
} // 115 | |
}, // 116 | |
{ // Binary // 117 | |
matchJSONValue: function (obj) { // 118 | |
return _.has(obj, '$binary') && _.size(obj) === 1; // 119 | |
}, // 120 | |
matchObject: function (obj) { // 121 | |
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array // 122 | |
|| (obj && _.has(obj, '$Uint8ArrayPolyfill')); // 123 | |
}, // 124 | |
toJSONValue: function (obj) { // 125 | |
return {$binary: Base64.encode(obj)}; // 126 | |
}, // 127 | |
fromJSONValue: function (obj) { // 128 | |
return Base64.decode(obj.$binary); // 129 | |
} // 130 | |
}, // 131 | |
{ // Escaping one level // 132 | |
matchJSONValue: function (obj) { // 133 | |
return _.has(obj, '$escape') && _.size(obj) === 1; // 134 | |
}, // 135 | |
matchObject: function (obj) { // 136 | |
if (_.isEmpty(obj) || _.size(obj) > 2) { // 137 | |
return false; // 138 | |
} // 139 | |
return _.any(builtinConverters, function (converter) { // 140 | |
return converter.matchJSONValue(obj); // 141 | |
}); // 142 | |
}, // 143 | |
toJSONValue: function (obj) { // 144 | |
var newObj = {}; // 145 | |
_.each(obj, function (value, key) { // 146 | |
newObj[key] = EJSON.toJSONValue(value); // 147 | |
}); // 148 | |
return {$escape: newObj}; // 149 | |
}, // 150 | |
fromJSONValue: function (obj) { // 151 | |
var newObj = {}; // 152 | |
_.each(obj.$escape, function (value, key) { // 153 | |
newObj[key] = EJSON.fromJSONValue(value); // 154 | |
}); // 155 | |
return newObj; // 156 | |
} // 157 | |
}, // 158 | |
{ // Custom // 159 | |
matchJSONValue: function (obj) { // 160 | |
return _.has(obj, '$type') && _.has(obj, '$value') && _.size(obj) === 2; // 161 | |
}, // 162 | |
matchObject: function (obj) { // 163 | |
return EJSON._isCustomType(obj); // 164 | |
}, // 165 | |
toJSONValue: function (obj) { // 166 | |
var jsonValue = Meteor._noYieldsAllowed(function () { // 167 | |
return obj.toJSONValue(); // 168 | |
}); // 169 | |
return {$type: obj.typeName(), $value: jsonValue}; // 170 | |
}, // 171 | |
fromJSONValue: function (obj) { // 172 | |
var typeName = obj.$type; // 173 | |
if (!_.has(customTypes, typeName)) // 174 | |
throw new Error("Custom EJSON type " + typeName + " is not defined"); // 175 | |
var converter = customTypes[typeName]; // 176 | |
return Meteor._noYieldsAllowed(function () { // 177 | |
return converter(obj.$value); // 178 | |
}); // 179 | |
} // 180 | |
} // 181 | |
]; // 182 | |
// 183 | |
EJSON._isCustomType = function (obj) { // 184 | |
return obj && // 185 | |
typeof obj.toJSONValue === 'function' && // 186 | |
typeof obj.typeName === 'function' && // 187 | |
_.has(customTypes, obj.typeName()); // 188 | |
}; // 189 | |
// 190 | |
EJSON._getTypes = function () { // 191 | |
return customTypes; // 192 | |
}; // 193 | |
// 194 | |
EJSON._getConverters = function () { // 195 | |
return builtinConverters; // 196 | |
}; // 197 | |
// 198 | |
// for both arrays and objects, in-place modification. // 199 | |
var adjustTypesToJSONValue = // 200 | |
EJSON._adjustTypesToJSONValue = function (obj) { // 201 | |
// Is it an atom that we need to adjust? // 202 | |
if (obj === null) // 203 | |
return null; // 204 | |
var maybeChanged = toJSONValueHelper(obj); // 205 | |
if (maybeChanged !== undefined) // 206 | |
return maybeChanged; // 207 | |
// 208 | |
// Other atoms are unchanged. // 209 | |
if (typeof obj !== 'object') // 210 | |
return obj; // 211 | |
// 212 | |
// Iterate over array or object structure. // 213 | |
_.each(obj, function (value, key) { // 214 | |
if (typeof value !== 'object' && value !== undefined && // 215 | |
!isInfOrNan(value)) // 216 | |
return; // continue // 217 | |
// 218 | |
var changed = toJSONValueHelper(value); // 219 | |
if (changed) { // 220 | |
obj[key] = changed; // 221 | |
return; // on to the next key // 222 | |
} // 223 | |
// if we get here, value is an object but not adjustable // 224 | |
// at this level. recurse. // 225 | |
adjustTypesToJSONValue(value); // 226 | |
}); // 227 | |
return obj; // 228 | |
}; // 229 | |
// 230 | |
// Either return the JSON-compatible version of the argument, or undefined (if // 231 | |
// the item isn't itself replaceable, but maybe some fields in it are) // 232 | |
var toJSONValueHelper = function (item) { // 233 | |
for (var i = 0; i < builtinConverters.length; i++) { // 234 | |
var converter = builtinConverters[i]; // 235 | |
if (converter.matchObject(item)) { // 236 | |
return converter.toJSONValue(item); // 237 | |
} // 238 | |
} // 239 | |
return undefined; // 240 | |
}; // 241 | |
// 242 | |
/** // 243 | |
* @summary Serialize an EJSON-compatible value into its plain JSON representation. // 244 | |
* @locus Anywhere // 245 | |
* @param {EJSON} val A value to serialize to plain JSON. // 246 | |
*/ // 247 | |
EJSON.toJSONValue = function (item) { // 248 | |
var changed = toJSONValueHelper(item); // 249 | |
if (changed !== undefined) // 250 | |
return changed; // 251 | |
if (typeof item === 'object') { // 252 | |
item = EJSON.clone(item); // 253 | |
adjustTypesToJSONValue(item); // 254 | |
} // 255 | |
return item; // 256 | |
}; // 257 | |
// 258 | |
// for both arrays and objects. Tries its best to just // 259 | |
// use the object you hand it, but may return something // 260 | |
// different if the object you hand it itself needs changing. // 261 | |
// // 262 | |
var adjustTypesFromJSONValue = // 263 | |
EJSON._adjustTypesFromJSONValue = function (obj) { // 264 | |
if (obj === null) // 265 | |
return null; // 266 | |
var maybeChanged = fromJSONValueHelper(obj); // 267 | |
if (maybeChanged !== obj) // 268 | |
return maybeChanged; // 269 | |
// 270 | |
// Other atoms are unchanged. // 271 | |
if (typeof obj !== 'object') // 272 | |
return obj; // 273 | |
// 274 | |
_.each(obj, function (value, key) { // 275 | |
if (typeof value === 'object') { // 276 | |
var changed = fromJSONValueHelper(value); // 277 | |
if (value !== changed) { // 278 | |
obj[key] = changed; // 279 | |
return; // 280 | |
} // 281 | |
// if we get here, value is an object but not adjustable // 282 | |
// at this level. recurse. // 283 | |
adjustTypesFromJSONValue(value); // 284 | |
} // 285 | |
}); // 286 | |
return obj; // 287 | |
}; // 288 | |
// 289 | |
// Either return the argument changed to have the non-json // 290 | |
// rep of itself (the Object version) or the argument itself. // 291 | |
// 292 | |
// DOES NOT RECURSE. For actually getting the fully-changed value, use // 293 | |
// EJSON.fromJSONValue // 294 | |
var fromJSONValueHelper = function (value) { // 295 | |
if (typeof value === 'object' && value !== null) { // 296 | |
if (_.size(value) <= 2 // 297 | |
&& _.all(value, function (v, k) { // 298 | |
return typeof k === 'string' && k.substr(0, 1) === '$'; // 299 | |
})) { // 300 | |
for (var i = 0; i < builtinConverters.length; i++) { // 301 | |
var converter = builtinConverters[i]; // 302 | |
if (converter.matchJSONValue(value)) { // 303 | |
return converter.fromJSONValue(value); // 304 | |
} // 305 | |
} // 306 | |
} // 307 | |
} // 308 | |
return value; // 309 | |
}; // 310 | |
// 311 | |
/** // 312 | |
* @summary Deserialize an EJSON value from its plain JSON representation. // 313 | |
* @locus Anywhere // 314 | |
* @param {JSONCompatible} val A value to deserialize into EJSON. // 315 | |
*/ // 316 | |
EJSON.fromJSONValue = function (item) { // 317 | |
var changed = fromJSONValueHelper(item); // 318 | |
if (changed === item && typeof item === 'object') { // 319 | |
item = EJSON.clone(item); // 320 | |
adjustTypesFromJSONValue(item); // 321 | |
return item; // 322 | |
} else { // 323 | |
return changed; // 324 | |
} // 325 | |
}; // 326 | |
// 327 | |
/** // 328 | |
* @summary Serialize a value to a string. // 329 | |
// 330 | |
For EJSON values, the serialization fully represents the value. For non-EJSON values, serializes the same way as `JSON.stringify`. | |
* @locus Anywhere // 332 | |
* @param {EJSON} val A value to stringify. // 333 | |
* @param {Object} [options] // 334 | |
* @param {Boolean | Integer | String} options.indent Indents objects and arrays for easy readability. When `true`, indents by 2 spaces; when an integer, indents by that number of spaces; and when a string, uses the string as the indentation pattern. | |
* @param {Boolean} options.canonical When `true`, stringifies keys in an object in sorted order. // 336 | |
*/ // 337 | |
EJSON.stringify = function (item, options) { // 338 | |
var json = EJSON.toJSONValue(item); // 339 | |
if (options && (options.canonical || options.indent)) { // 340 | |
return EJSON._canonicalStringify(json, options); // 341 | |
} else { // 342 | |
return JSON.stringify(json); // 343 | |
} // 344 | |
}; // 345 | |
// 346 | |
/** // 347 | |
* @summary Parse a string into an EJSON value. Throws an error if the string is not valid EJSON. // 348 | |
* @locus Anywhere // 349 | |
* @param {String} str A string to parse into an EJSON value. // 350 | |
*/ // 351 | |
EJSON.parse = function (item) { // 352 | |
if (typeof item !== 'string') // 353 | |
throw new Error("EJSON.parse argument should be a string"); // 354 | |
return EJSON.fromJSONValue(JSON.parse(item)); // 355 | |
}; // 356 | |
// 357 | |
/** // 358 | |
* @summary Returns true if `x` is a buffer of binary data, as returned from [`EJSON.newBinary`](#ejson_new_binary). | |
* @param {Object} x The variable to check. // 360 | |
* @locus Anywhere // 361 | |
*/ // 362 | |
EJSON.isBinary = function (obj) { // 363 | |
return !!((typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array) || // 364 | |
(obj && obj.$Uint8ArrayPolyfill)); // 365 | |
}; // 366 | |
// 367 | |
/** // 368 | |
* @summary Return true if `a` and `b` are equal to each other. Return false otherwise. Uses the `equals` method on `a` if present, otherwise performs a deep comparison. | |
* @locus Anywhere // 370 | |
* @param {EJSON} a // 371 | |
* @param {EJSON} b // 372 | |
* @param {Object} [options] // 373 | |
* @param {Boolean} options.keyOrderSensitive Compare in key sensitive order, if supported by the JavaScript implementation. For example, `{a: 1, b: 2}` is equal to `{b: 2, a: 1}` only when `keyOrderSensitive` is `false`. The default is `false`. | |
*/ // 375 | |
EJSON.equals = function (a, b, options) { // 376 | |
var i; // 377 | |
var keyOrderSensitive = !!(options && options.keyOrderSensitive); // 378 | |
if (a === b) // 379 | |
return true; // 380 | |
if (_.isNaN(a) && _.isNaN(b)) // 381 | |
return true; // This differs from the IEEE spec for NaN equality, b/c we don't want // 382 | |
// anything ever with a NaN to be poisoned from becoming equal to anything. // 383 | |
if (!a || !b) // if either one is falsy, they'd have to be === to be equal // 384 | |
return false; // 385 | |
if (!(typeof a === 'object' && typeof b === 'object')) // 386 | |
return false; // 387 | |
if (a instanceof Date && b instanceof Date) // 388 | |
return a.valueOf() === b.valueOf(); // 389 | |
if (EJSON.isBinary(a) && EJSON.isBinary(b)) { // 390 | |
if (a.length !== b.length) // 391 | |
return false; // 392 | |
for (i = 0; i < a.length; i++) { // 393 | |
if (a[i] !== b[i]) // 394 | |
return false; // 395 | |
} // 396 | |
return true; // 397 | |
} // 398 | |
if (typeof (a.equals) === 'function') // 399 | |
return a.equals(b, options); // 400 | |
if (typeof (b.equals) === 'function') // 401 | |
return b.equals(a, options); // 402 | |
if (a instanceof Array) { // 403 | |
if (!(b instanceof Array)) // 404 | |
return false; // 405 | |
if (a.length !== b.length) // 406 | |
return false; // 407 | |
for (i = 0; i < a.length; i++) { // 408 | |
if (!EJSON.equals(a[i], b[i], options)) // 409 | |
return false; // 410 | |
} // 411 | |
return true; // 412 | |
} // 413 | |
// fallback for custom types that don't implement their own equals // 414 | |
switch (EJSON._isCustomType(a) + EJSON._isCustomType(b)) { // 415 | |
case 1: return false; // 416 | |
case 2: return EJSON.equals(EJSON.toJSONValue(a), EJSON.toJSONValue(b)); // 417 | |
} // 418 | |
// fall back to structural equality of objects // 419 | |
var ret; // 420 | |
if (keyOrderSensitive) { // 421 | |
var bKeys = []; // 422 | |
_.each(b, function (val, x) { // 423 | |
bKeys.push(x); // 424 | |
}); // 425 | |
i = 0; // 426 | |
ret = _.all(a, function (val, x) { // 427 | |
if (i >= bKeys.length) { // 428 | |
return false; // 429 | |
} // 430 | |
if (x !== bKeys[i]) { // 431 | |
return false; // 432 | |
} // 433 | |
if (!EJSON.equals(val, b[bKeys[i]], options)) { // 434 | |
return false; // 435 | |
} // 436 | |
i++; // 437 | |
return true; // 438 | |
}); // 439 | |
return ret && i === bKeys.length; // 440 | |
} else { // 441 | |
i = 0; // 442 | |
ret = _.all(a, function (val, key) { // 443 | |
if (!_.has(b, key)) { // 444 | |
return false; // 445 | |
} // 446 | |
if (!EJSON.equals(val, b[key], options)) { // 447 | |
return false; // 448 | |
} // 449 | |
i++; // 450 | |
return true; // 451 | |
}); // 452 | |
return ret && _.size(b) === i; // 453 | |
} // 454 | |
}; // 455 | |
// 456 | |
/** // 457 | |
* @summary Return a deep copy of `val`. // 458 | |
* @locus Anywhere // 459 | |
* @param {EJSON} val A value to copy. // 460 | |
*/ // 461 | |
EJSON.clone = function (v) { // 462 | |
var ret; // 463 | |
if (typeof v !== "object") // 464 | |
return v; // 465 | |
if (v === null) // 466 | |
return null; // null has typeof "object" // 467 | |
if (v instanceof Date) // 468 | |
return new Date(v.getTime()); // 469 | |
// RegExps are not really EJSON elements (eg we don't define a serialization // 470 | |
// for them), but they're immutable anyway, so we can support them in clone. // 471 | |
if (v instanceof RegExp) // 472 | |
return v; // 473 | |
if (EJSON.isBinary(v)) { // 474 | |
ret = EJSON.newBinary(v.length); // 475 | |
for (var i = 0; i < v.length; i++) { // 476 | |
ret[i] = v[i]; // 477 | |
} // 478 | |
return ret; // 479 | |
} // 480 | |
// XXX: Use something better than underscore's isArray // 481 | |
if (_.isArray(v) || _.isArguments(v)) { // 482 | |
// For some reason, _.map doesn't work in this context on Opera (weird test // 483 | |
// failures). // 484 | |
ret = []; // 485 | |
for (i = 0; i < v.length; i++) // 486 | |
ret[i] = EJSON.clone(v[i]); // 487 | |
return ret; // 488 | |
} // 489 | |
// handle general user-defined typed Objects if they have a clone method // 490 | |
if (typeof v.clone === 'function') { // 491 | |
return v.clone(); // 492 | |
} // 493 | |
// handle other custom types // 494 | |
if (EJSON._isCustomType(v)) { // 495 | |
return EJSON.fromJSONValue(EJSON.clone(EJSON.toJSONValue(v)), true); // 496 | |
} // 497 | |
// handle other objects // 498 | |
ret = {}; // 499 | |
_.each(v, function (value, key) { // 500 | |
ret[key] = EJSON.clone(value); // 501 | |
}); // 502 | |
return ret; // 503 | |
}; // 504 | |
// 505 | |
/** // 506 | |
* @summary Allocate a new buffer of binary data that EJSON can serialize. // 507 | |
* @locus Anywhere // 508 | |
* @param {Number} size The number of bytes of binary data to allocate. // 509 | |
*/ // 510 | |
// EJSON.newBinary is the public documented API for this functionality, // 511 | |
// but the implementation is in the 'base64' package to avoid // 512 | |
// introducing a circular dependency. (If the implementation were here, // 513 | |
// then 'base64' would have to use EJSON.newBinary, and 'ejson' would // 514 | |
// also have to use 'base64'.) // 515 | |
EJSON.newBinary = Base64.newBinary; // 516 | |
// 517 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// 527 | |
}).call(this); // 528 | |
// 529 | |
// 530 | |
// 531 | |
// 532 | |
// 533 | |
// 534 | |
(function(){ // 535 | |
// 536 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/ejson/stringify.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Based on json2.js from https://github.com/douglascrockford/JSON-js // 1 | |
// // 2 | |
// json2.js // 3 | |
// 2012-10-08 // 4 | |
// // 5 | |
// Public Domain. // 6 | |
// // 7 | |
// NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. // 8 | |
// 9 | |
function quote(string) { // 10 | |
return JSON.stringify(string); // 11 | |
} // 12 | |
// 13 | |
var str = function (key, holder, singleIndent, outerIndent, canonical) { // 14 | |
// 15 | |
// Produce a string from holder[key]. // 16 | |
// 17 | |
var i; // The loop counter. // 18 | |
var k; // The member key. // 19 | |
var v; // The member value. // 20 | |
var length; // 21 | |
var innerIndent = outerIndent; // 22 | |
var partial; // 23 | |
var value = holder[key]; // 24 | |
// 25 | |
// What happens next depends on the value's type. // 26 | |
// 27 | |
switch (typeof value) { // 28 | |
case 'string': // 29 | |
return quote(value); // 30 | |
case 'number': // 31 | |
// JSON numbers must be finite. Encode non-finite numbers as null. // 32 | |
return isFinite(value) ? String(value) : 'null'; // 33 | |
case 'boolean': // 34 | |
return String(value); // 35 | |
// If the type is 'object', we might be dealing with an object or an array or // 36 | |
// null. // 37 | |
case 'object': // 38 | |
// Due to a specification blunder in ECMAScript, typeof null is 'object', // 39 | |
// so watch out for that case. // 40 | |
if (!value) { // 41 | |
return 'null'; // 42 | |
} // 43 | |
// Make an array to hold the partial results of stringifying this object value. // 44 | |
innerIndent = outerIndent + singleIndent; // 45 | |
partial = []; // 46 | |
// 47 | |
// Is the value an array? // 48 | |
if (_.isArray(value) || _.isArguments(value)) { // 49 | |
// 50 | |
// The value is an array. Stringify every element. Use null as a placeholder // 51 | |
// for non-JSON values. // 52 | |
// 53 | |
length = value.length; // 54 | |
for (i = 0; i < length; i += 1) { // 55 | |
partial[i] = str(i, value, singleIndent, innerIndent, canonical) || 'null'; // 56 | |
} // 57 | |
// 58 | |
// Join all of the elements together, separated with commas, and wrap them in // 59 | |
// brackets. // 60 | |
// 61 | |
if (partial.length === 0) { // 62 | |
v = '[]'; // 63 | |
} else if (innerIndent) { // 64 | |
v = '[\n' + innerIndent + partial.join(',\n' + innerIndent) + '\n' + outerIndent + ']'; // 65 | |
} else { // 66 | |
v = '[' + partial.join(',') + ']'; // 67 | |
} // 68 | |
return v; // 69 | |
} // 70 | |
// 71 | |
// 72 | |
// Iterate through all of the keys in the object. // 73 | |
var keys = _.keys(value); // 74 | |
if (canonical) // 75 | |
keys = keys.sort(); // 76 | |
_.each(keys, function (k) { // 77 | |
v = str(k, value, singleIndent, innerIndent, canonical); // 78 | |
if (v) { // 79 | |
partial.push(quote(k) + (innerIndent ? ': ' : ':') + v); // 80 | |
} // 81 | |
}); // 82 | |
// 83 | |
// 84 | |
// Join all of the member texts together, separated with commas, // 85 | |
// and wrap them in braces. // 86 | |
// 87 | |
if (partial.length === 0) { // 88 | |
v = '{}'; // 89 | |
} else if (innerIndent) { // 90 | |
v = '{\n' + innerIndent + partial.join(',\n' + innerIndent) + '\n' + outerIndent + '}'; // 91 | |
} else { // 92 | |
v = '{' + partial.join(',') + '}'; // 93 | |
} // 94 | |
return v; // 95 | |
} // 96 | |
} // 97 | |
// 98 | |
// If the JSON object does not yet have a stringify method, give it one. // 99 | |
// 100 | |
EJSON._canonicalStringify = function (value, options) { // 101 | |
// Make a fake root object containing our value under the key of ''. // 102 | |
// Return the result of stringifying the value. // 103 | |
options = _.extend({ // 104 | |
indent: "", // 105 | |
canonical: false // 106 | |
}, options); // 107 | |
if (options.indent === true) { // 108 | |
options.indent = " "; // 109 | |
} else if (typeof options.indent === 'number') { // 110 | |
var newIndent = ""; // 111 | |
for (var i = 0; i < options.indent; i++) { // 112 | |
newIndent += ' '; // 113 | |
} // 114 | |
options.indent = newIndent; // 115 | |
} // 116 | |
return str('', {'': value}, options.indent, "", options.canonical); // 117 | |
}; // 118 | |
// 119 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// 663 | |
}).call(this); // 664 | |
// 665 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.ejson = { | |
EJSON: EJSON, | |
EJSONTest: EJSONTest | |
}; | |
/* Package-scope variables */ | |
var check, Match; | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/check/match.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// XXX docs // 1 | |
// 2 | |
// Things we explicitly do NOT support: // 3 | |
// - heterogenous arrays // 4 | |
// 5 | |
var currentArgumentChecker = new Meteor.EnvironmentVariable; // 6 | |
// 7 | |
/** // 8 | |
* @summary Check that a value matches a [pattern](#matchpatterns). // 9 | |
* If the value does not match the pattern, throw a `Match.Error`. // 10 | |
* // 11 | |
* Particularly useful to assert that arguments to a function have the right // 12 | |
* types and structure. // 13 | |
* @locus Anywhere // 14 | |
* @param {Any} value The value to check // 15 | |
* @param {MatchPattern} pattern The pattern to match // 16 | |
* `value` against // 17 | |
*/ // 18 | |
check = function (value, pattern) { // 19 | |
// Record that check got called, if somebody cared. // 20 | |
// // 21 | |
// We use getOrNullIfOutsideFiber so that it's OK to call check() // 22 | |
// from non-Fiber server contexts; the downside is that if you forget to // 23 | |
// bindEnvironment on some random callback in your method/publisher, // 24 | |
// it might not find the argumentChecker and you'll get an error about // 25 | |
// not checking an argument that it looks like you're checking (instead // 26 | |
// of just getting a "Node code must run in a Fiber" error). // 27 | |
var argChecker = currentArgumentChecker.getOrNullIfOutsideFiber(); // 28 | |
if (argChecker) // 29 | |
argChecker.checking(value); // 30 | |
var result = testSubtree(value, pattern); // 31 | |
if (result) { // 32 | |
var err = new Match.Error(result.message); // 33 | |
if (result.path) { // 34 | |
err.message += " in field " + result.path; // 35 | |
err.path = result.path; // 36 | |
} // 37 | |
throw err; // 38 | |
} // 39 | |
}; // 40 | |
// 41 | |
/** // 42 | |
* @namespace Match // 43 | |
* @summary The namespace for all Match types and methods. // 44 | |
*/ // 45 | |
Match = { // 46 | |
Optional: function (pattern) { // 47 | |
return new Optional(pattern); // 48 | |
}, // 49 | |
OneOf: function (/*arguments*/) { // 50 | |
return new OneOf(_.toArray(arguments)); // 51 | |
}, // 52 | |
Any: ['__any__'], // 53 | |
Where: function (condition) { // 54 | |
return new Where(condition); // 55 | |
}, // 56 | |
ObjectIncluding: function (pattern) { // 57 | |
return new ObjectIncluding(pattern); // 58 | |
}, // 59 | |
ObjectWithValues: function (pattern) { // 60 | |
return new ObjectWithValues(pattern); // 61 | |
}, // 62 | |
// Matches only signed 32-bit integers // 63 | |
Integer: ['__integer__'], // 64 | |
// 65 | |
// XXX matchers should know how to describe themselves for errors // 66 | |
Error: Meteor.makeErrorType("Match.Error", function (msg) { // 67 | |
this.message = "Match error: " + msg; // 68 | |
// The path of the value that failed to match. Initially empty, this gets // 69 | |
// populated by catching and rethrowing the exception as it goes back up the // 70 | |
// stack. // 71 | |
// E.g.: "vals[3].entity.created" // 72 | |
this.path = ""; // 73 | |
// If this gets sent over DDP, don't give full internal details but at least // 74 | |
// provide something better than 500 Internal server error. // 75 | |
this.sanitizedError = new Meteor.Error(400, "Match failed"); // 76 | |
}), // 77 | |
// 78 | |
// Tests to see if value matches pattern. Unlike check, it merely returns true // 79 | |
// or false (unless an error other than Match.Error was thrown). It does not // 80 | |
// interact with _failIfArgumentsAreNotAllChecked. // 81 | |
// XXX maybe also implement a Match.match which returns more information about // 82 | |
// failures but without using exception handling or doing what check() // 83 | |
// does with _failIfArgumentsAreNotAllChecked and Meteor.Error conversion // 84 | |
// 85 | |
/** // 86 | |
* @summary Returns true if the value matches the pattern. // 87 | |
* @locus Anywhere // 88 | |
* @param {Any} value The value to check // 89 | |
* @param {MatchPattern} pattern The pattern to match `value` against // 90 | |
*/ // 91 | |
test: function (value, pattern) { // 92 | |
return !testSubtree(value, pattern); // 93 | |
}, // 94 | |
// 95 | |
// Runs `f.apply(context, args)`. If check() is not called on every element of // 96 | |
// `args` (either directly or in the first level of an array), throws an error // 97 | |
// (using `description` in the message). // 98 | |
// // 99 | |
_failIfArgumentsAreNotAllChecked: function (f, context, args, description) { // 100 | |
var argChecker = new ArgumentChecker(args, description); // 101 | |
var result = currentArgumentChecker.withValue(argChecker, function () { // 102 | |
return f.apply(context, args); // 103 | |
}); // 104 | |
// If f didn't itself throw, make sure it checked all of its arguments. // 105 | |
argChecker.throwUnlessAllArgumentsHaveBeenChecked(); // 106 | |
return result; // 107 | |
} // 108 | |
}; // 109 | |
// 110 | |
var Optional = function (pattern) { // 111 | |
this.pattern = pattern; // 112 | |
}; // 113 | |
// 114 | |
var OneOf = function (choices) { // 115 | |
if (_.isEmpty(choices)) // 116 | |
throw new Error("Must provide at least one choice to Match.OneOf"); // 117 | |
this.choices = choices; // 118 | |
}; // 119 | |
// 120 | |
var Where = function (condition) { // 121 | |
this.condition = condition; // 122 | |
}; // 123 | |
// 124 | |
var ObjectIncluding = function (pattern) { // 125 | |
this.pattern = pattern; // 126 | |
}; // 127 | |
// 128 | |
var ObjectWithValues = function (pattern) { // 129 | |
this.pattern = pattern; // 130 | |
}; // 131 | |
// 132 | |
var typeofChecks = [ // 133 | |
[String, "string"], // 134 | |
[Number, "number"], // 135 | |
[Boolean, "boolean"], // 136 | |
// While we don't allow undefined in EJSON, this is good for optional // 137 | |
// arguments with OneOf. // 138 | |
[undefined, "undefined"] // 139 | |
]; // 140 | |
// 141 | |
// Return `false` if it matches. Otherwise, return an object with a `message` and a `path` field. // 142 | |
var testSubtree = function (value, pattern) { // 143 | |
// Match anything! // 144 | |
if (pattern === Match.Any) // 145 | |
return false; // 146 | |
// 147 | |
// Basic atomic types. // 148 | |
// Do not match boxed objects (e.g. String, Boolean) // 149 | |
for (var i = 0; i < typeofChecks.length; ++i) { // 150 | |
if (pattern === typeofChecks[i][0]) { // 151 | |
if (typeof value === typeofChecks[i][1]) // 152 | |
return false; // 153 | |
return { // 154 | |
message: "Expected " + typeofChecks[i][1] + ", got " + typeof value, // 155 | |
path: "" // 156 | |
}; // 157 | |
} // 158 | |
} // 159 | |
if (pattern === null) { // 160 | |
if (value === null) // 161 | |
return false; // 162 | |
return { // 163 | |
message: "Expected null, got " + EJSON.stringify(value), // 164 | |
path: "" // 165 | |
}; // 166 | |
} // 167 | |
// 168 | |
// Strings, numbers, and booleans match literally. Goes well with Match.OneOf. // 169 | |
if (typeof pattern === "string" || typeof pattern === "number" || typeof pattern === "boolean") { // 170 | |
if (value === pattern) // 171 | |
return false; // 172 | |
return { // 173 | |
message: "Expected " + pattern + ", got " + EJSON.stringify(value), // 174 | |
path: "" // 175 | |
}; // 176 | |
} // 177 | |
// 178 | |
// Match.Integer is special type encoded with array // 179 | |
if (pattern === Match.Integer) { // 180 | |
// There is no consistent and reliable way to check if variable is a 64-bit // 181 | |
// integer. One of the popular solutions is to get reminder of division by 1 // 182 | |
// but this method fails on really large floats with big precision. // 183 | |
// E.g.: 1.348192308491824e+23 % 1 === 0 in V8 // 184 | |
// Bitwise operators work consistantly but always cast variable to 32-bit // 185 | |
// signed integer according to JavaScript specs. // 186 | |
if (typeof value === "number" && (value | 0) === value) // 187 | |
return false; // 188 | |
return { // 189 | |
message: "Expected Integer, got " + (value instanceof Object ? EJSON.stringify(value) : value), | |
path: "" // 191 | |
}; // 192 | |
} // 193 | |
// 194 | |
// "Object" is shorthand for Match.ObjectIncluding({}); // 195 | |
if (pattern === Object) // 196 | |
pattern = Match.ObjectIncluding({}); // 197 | |
// 198 | |
// Array (checked AFTER Any, which is implemented as an Array). // 199 | |
if (pattern instanceof Array) { // 200 | |
if (pattern.length !== 1) { // 201 | |
return { // 202 | |
message: "Bad pattern: arrays must have one type element" + EJSON.stringify(pattern), // 203 | |
path: "" // 204 | |
}; // 205 | |
} // 206 | |
if (!_.isArray(value) && !_.isArguments(value)) { // 207 | |
return { // 208 | |
message: "Expected array, got " + EJSON.stringify(value), // 209 | |
path: "" // 210 | |
}; // 211 | |
} // 212 | |
// 213 | |
for (var i = 0, length = value.length; i < length; i++) { // 214 | |
var result = testSubtree(value[i], pattern[0]); // 215 | |
if (result) { // 216 | |
result.path = _prependPath(i, result.path); // 217 | |
return result; // 218 | |
} // 219 | |
} // 220 | |
return false; // 221 | |
} // 222 | |
// 223 | |
// Arbitrary validation checks. The condition can return false or throw a // 224 | |
// Match.Error (ie, it can internally use check()) to fail. // 225 | |
if (pattern instanceof Where) { // 226 | |
var result; // 227 | |
try { // 228 | |
result = pattern.condition(value); // 229 | |
} catch (err) { // 230 | |
if (!(err instanceof Match.Error)) // 231 | |
throw err; // 232 | |
return { // 233 | |
message: err.message, // 234 | |
path: err.path // 235 | |
}; // 236 | |
} // 237 | |
if (pattern.condition(value)) // 238 | |
return false; // 239 | |
// XXX this error is terrible // 240 | |
return { // 241 | |
message: "Failed Match.Where validation", // 242 | |
path: "" // 243 | |
}; // 244 | |
} // 245 | |
// 246 | |
// 247 | |
if (pattern instanceof Optional) // 248 | |
pattern = Match.OneOf(undefined, pattern.pattern); // 249 | |
// 250 | |
if (pattern instanceof OneOf) { // 251 | |
for (var i = 0; i < pattern.choices.length; ++i) { // 252 | |
var result = testSubtree(value, pattern.choices[i]); // 253 | |
if (!result) { // 254 | |
// No error? Yay, return. // 255 | |
return false; // 256 | |
} // 257 | |
// Match errors just mean try another choice. // 258 | |
} // 259 | |
// XXX this error is terrible // 260 | |
return { // 261 | |
message: "Failed Match.OneOf or Match.Optional validation", // 262 | |
path: "" // 263 | |
}; // 264 | |
} // 265 | |
// 266 | |
// A function that isn't something we special-case is assumed to be a // 267 | |
// constructor. // 268 | |
if (pattern instanceof Function) { // 269 | |
if (value instanceof pattern) // 270 | |
return false; // 271 | |
return { // 272 | |
message: "Expected " + (pattern.name ||"particular constructor"), // 273 | |
path: "" // 274 | |
}; // 275 | |
} // 276 | |
// 277 | |
var unknownKeysAllowed = false; // 278 | |
var unknownKeyPattern; // 279 | |
if (pattern instanceof ObjectIncluding) { // 280 | |
unknownKeysAllowed = true; // 281 | |
pattern = pattern.pattern; // 282 | |
} // 283 | |
if (pattern instanceof ObjectWithValues) { // 284 | |
unknownKeysAllowed = true; // 285 | |
unknownKeyPattern = [pattern.pattern]; // 286 | |
pattern = {}; // no required keys // 287 | |
} // 288 | |
// 289 | |
if (typeof pattern !== "object") { // 290 | |
return { // 291 | |
message: "Bad pattern: unknown pattern type", // 292 | |
path: "" // 293 | |
}; // 294 | |
} // 295 | |
// 296 | |
// An object, with required and optional keys. Note that this does NOT do // 297 | |
// structural matches against objects of special types that happen to match // 298 | |
// the pattern: this really needs to be a plain old {Object}! // 299 | |
if (typeof value !== 'object') { // 300 | |
return { // 301 | |
message: "Expected object, got " + typeof value, // 302 | |
path: "" // 303 | |
}; // 304 | |
} // 305 | |
if (value === null) { // 306 | |
return { // 307 | |
message: "Expected object, got null", // 308 | |
path: "" // 309 | |
}; // 310 | |
} // 311 | |
if (value.constructor !== Object) { // 312 | |
return { // 313 | |
message: "Expected plain object", // 314 | |
path: "" // 315 | |
}; // 316 | |
} // 317 | |
// 318 | |
var requiredPatterns = {}; // 319 | |
var optionalPatterns = {}; // 320 | |
_.each(pattern, function (subPattern, key) { // 321 | |
if (subPattern instanceof Optional) // 322 | |
optionalPatterns[key] = subPattern.pattern; // 323 | |
else // 324 | |
requiredPatterns[key] = subPattern; // 325 | |
}); // 326 | |
// 327 | |
for (var keys = _.keys(value), i = 0, length = keys.length; i < length; i++) { // 328 | |
var key = keys[i]; // 329 | |
var subValue = value[key]; // 330 | |
if (_.has(requiredPatterns, key)) { // 331 | |
var result = testSubtree(subValue, requiredPatterns[key]); // 332 | |
if (result) { // 333 | |
result.path = _prependPath(key, result.path); // 334 | |
return result; // 335 | |
} // 336 | |
delete requiredPatterns[key]; // 337 | |
} else if (_.has(optionalPatterns, key)) { // 338 | |
var result = testSubtree(subValue, optionalPatterns[key]); // 339 | |
if (result) { // 340 | |
result.path = _prependPath(key, result.path); // 341 | |
return result; // 342 | |
} // 343 | |
} else { // 344 | |
if (!unknownKeysAllowed) { // 345 | |
return { // 346 | |
message: "Unknown key", // 347 | |
path: key // 348 | |
}; // 349 | |
} // 350 | |
if (unknownKeyPattern) { // 351 | |
var result = testSubtree(subValue, unknownKeyPattern[0]); // 352 | |
if (result) { // 353 | |
result.path = _prependPath(key, result.path); // 354 | |
return result; // 355 | |
} // 356 | |
} // 357 | |
} // 358 | |
} // 359 | |
// 360 | |
var keys = _.keys(requiredPatterns); // 361 | |
if (keys.length) { // 362 | |
return { // 363 | |
message: "Missing key '" + keys[0] + "'", // 364 | |
path: "" // 365 | |
}; // 366 | |
} // 367 | |
}; // 368 | |
// 369 | |
var ArgumentChecker = function (args, description) { // 370 | |
var self = this; // 371 | |
// Make a SHALLOW copy of the arguments. (We'll be doing identity checks // 372 | |
// against its contents.) // 373 | |
self.args = _.clone(args); // 374 | |
// Since the common case will be to check arguments in order, and we splice // 375 | |
// out arguments when we check them, make it so we splice out from the end // 376 | |
// rather than the beginning. // 377 | |
self.args.reverse(); // 378 | |
self.description = description; // 379 | |
}; // 380 | |
// 381 | |
_.extend(ArgumentChecker.prototype, { // 382 | |
checking: function (value) { // 383 | |
var self = this; // 384 | |
if (self._checkingOneValue(value)) // 385 | |
return; // 386 | |
// Allow check(arguments, [String]) or check(arguments.slice(1), [String]) // 387 | |
// or check([foo, bar], [String]) to count... but only if value wasn't // 388 | |
// itself an argument. // 389 | |
if (_.isArray(value) || _.isArguments(value)) { // 390 | |
_.each(value, _.bind(self._checkingOneValue, self)); // 391 | |
} // 392 | |
}, // 393 | |
_checkingOneValue: function (value) { // 394 | |
var self = this; // 395 | |
for (var i = 0; i < self.args.length; ++i) { // 396 | |
// Is this value one of the arguments? (This can have a false positive if // 397 | |
// the argument is an interned primitive, but it's still a good enough // 398 | |
// check.) // 399 | |
// (NaN is not === to itself, so we have to check specially.) // 400 | |
if (value === self.args[i] || (_.isNaN(value) && _.isNaN(self.args[i]))) { // 401 | |
self.args.splice(i, 1); // 402 | |
return true; // 403 | |
} // 404 | |
} // 405 | |
return false; // 406 | |
}, // 407 | |
throwUnlessAllArgumentsHaveBeenChecked: function () { // 408 | |
var self = this; // 409 | |
if (!_.isEmpty(self.args)) // 410 | |
throw new Error("Did not check() all arguments during " + // 411 | |
self.description); // 412 | |
} // 413 | |
}); // 414 | |
// 415 | |
var _jsKeywords = ["do", "if", "in", "for", "let", "new", "try", "var", "case", // 416 | |
"else", "enum", "eval", "false", "null", "this", "true", "void", "with", // 417 | |
"break", "catch", "class", "const", "super", "throw", "while", "yield", // 418 | |
"delete", "export", "import", "public", "return", "static", "switch", // 419 | |
"typeof", "default", "extends", "finally", "package", "private", "continue", // 420 | |
"debugger", "function", "arguments", "interface", "protected", "implements", // 421 | |
"instanceof"]; // 422 | |
// 423 | |
// Assumes the base of path is already escaped properly // 424 | |
// returns key + base // 425 | |
var _prependPath = function (key, base) { // 426 | |
if ((typeof key) === "number" || key.match(/^[0-9]+$/)) // 427 | |
key = "[" + key + "]"; // 428 | |
else if (!key.match(/^[a-z_$][0-9a-z_$]*$/i) || _.contains(_jsKeywords, key)) // 429 | |
key = JSON.stringify([key]); // 430 | |
// 431 | |
if (base && base[0] !== "[") // 432 | |
return key + '.' + base; // 433 | |
return key + base; // 434 | |
}; // 435 | |
// 436 | |
// 437 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.check = { | |
check: check, | |
Match: Match | |
}; | |
/* Package-scope variables */ | |
var HTML, IDENTITY, SLICE; | |
(function(){ | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/htmljs/packages/htmljs.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
//////////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/htmljs/preamble.js // // 5 | |
// // // 6 | |
//////////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
HTML = {}; // 1 // 9 | |
// 2 // 10 | |
IDENTITY = function (x) { return x; }; // 3 // 11 | |
SLICE = Array.prototype.slice; // 4 // 12 | |
// 5 // 13 | |
//////////////////////////////////////////////////////////////////////////////////////// // 14 | |
// 15 | |
}).call(this); // 16 | |
// 17 | |
// 18 | |
// 19 | |
// 20 | |
// 21 | |
// 22 | |
(function(){ // 23 | |
// 24 | |
//////////////////////////////////////////////////////////////////////////////////////// // 25 | |
// // // 26 | |
// packages/htmljs/visitors.js // // 27 | |
// // // 28 | |
//////////////////////////////////////////////////////////////////////////////////////// // 29 | |
// // 30 | |
////////////////////////////// VISITORS // 1 // 31 | |
// 2 // 32 | |
// _assign is like _.extend or the upcoming Object.assign. // 3 // 33 | |
// Copy src's own, enumerable properties onto tgt and return // 4 // 34 | |
// tgt. // 5 // 35 | |
var _hasOwnProperty = Object.prototype.hasOwnProperty; // 6 // 36 | |
var _assign = function (tgt, src) { // 7 // 37 | |
for (var k in src) { // 8 // 38 | |
if (_hasOwnProperty.call(src, k)) // 9 // 39 | |
tgt[k] = src[k]; // 10 // 40 | |
} // 11 // 41 | |
return tgt; // 12 // 42 | |
}; // 13 // 43 | |
// 14 // 44 | |
HTML.Visitor = function (props) { // 15 // 45 | |
_assign(this, props); // 16 // 46 | |
}; // 17 // 47 | |
// 18 // 48 | |
HTML.Visitor.def = function (options) { // 19 // 49 | |
_assign(this.prototype, options); // 20 // 50 | |
}; // 21 // 51 | |
// 22 // 52 | |
HTML.Visitor.extend = function (options) { // 23 // 53 | |
var curType = this; // 24 // 54 | |
var subType = function HTMLVisitorSubtype(/*arguments*/) { // 25 // 55 | |
HTML.Visitor.apply(this, arguments); // 26 // 56 | |
}; // 27 // 57 | |
subType.prototype = new curType; // 28 // 58 | |
subType.extend = curType.extend; // 29 // 59 | |
subType.def = curType.def; // 30 // 60 | |
if (options) // 31 // 61 | |
_assign(subType.prototype, options); // 32 // 62 | |
return subType; // 33 // 63 | |
}; // 34 // 64 | |
// 35 // 65 | |
HTML.Visitor.def({ // 36 // 66 | |
visit: function (content/*, ...*/) { // 37 // 67 | |
if (content == null) // 38 // 68 | |
// null or undefined. // 39 // 69 | |
return this.visitNull.apply(this, arguments); // 40 // 70 | |
// 41 // 71 | |
if (typeof content === 'object') { // 42 // 72 | |
if (content.htmljsType) { // 43 // 73 | |
switch (content.htmljsType) { // 44 // 74 | |
case HTML.Tag.htmljsType: // 45 // 75 | |
return this.visitTag.apply(this, arguments); // 46 // 76 | |
case HTML.CharRef.htmljsType: // 47 // 77 | |
return this.visitCharRef.apply(this, arguments); // 48 // 78 | |
case HTML.Comment.htmljsType: // 49 // 79 | |
return this.visitComment.apply(this, arguments); // 50 // 80 | |
case HTML.Raw.htmljsType: // 51 // 81 | |
return this.visitRaw.apply(this, arguments); // 52 // 82 | |
default: // 53 // 83 | |
throw new Error("Unknown htmljs type: " + content.htmljsType); // 54 // 84 | |
} // 55 // 85 | |
} // 56 // 86 | |
// 57 // 87 | |
if (HTML.isArray(content)) // 58 // 88 | |
return this.visitArray.apply(this, arguments); // 59 // 89 | |
// 60 // 90 | |
return this.visitObject.apply(this, arguments); // 61 // 91 | |
// 62 // 92 | |
} else if ((typeof content === 'string') || // 63 // 93 | |
(typeof content === 'boolean') || // 64 // 94 | |
(typeof content === 'number')) { // 65 // 95 | |
return this.visitPrimitive.apply(this, arguments); // 66 // 96 | |
// 67 // 97 | |
} else if (typeof content === 'function') { // 68 // 98 | |
return this.visitFunction.apply(this, arguments); // 69 // 99 | |
} // 70 // 100 | |
// 71 // 101 | |
throw new Error("Unexpected object in htmljs: " + content); // 72 // 102 | |
// 73 // 103 | |
}, // 74 // 104 | |
visitNull: function (nullOrUndefined/*, ...*/) {}, // 75 // 105 | |
visitPrimitive: function (stringBooleanOrNumber/*, ...*/) {}, // 76 // 106 | |
visitArray: function (array/*, ...*/) {}, // 77 // 107 | |
visitComment: function (comment/*, ...*/) {}, // 78 // 108 | |
visitCharRef: function (charRef/*, ...*/) {}, // 79 // 109 | |
visitRaw: function (raw/*, ...*/) {}, // 80 // 110 | |
visitTag: function (tag/*, ...*/) {}, // 81 // 111 | |
visitObject: function (obj/*, ...*/) { // 82 // 112 | |
throw new Error("Unexpected object in htmljs: " + obj); // 83 // 113 | |
}, // 84 // 114 | |
visitFunction: function (fn/*, ...*/) { // 85 // 115 | |
throw new Error("Unexpected function in htmljs: " + obj); // 86 // 116 | |
} // 87 // 117 | |
}); // 88 // 118 | |
// 89 // 119 | |
HTML.TransformingVisitor = HTML.Visitor.extend(); // 90 // 120 | |
HTML.TransformingVisitor.def({ // 91 // 121 | |
visitNull: IDENTITY, // 92 // 122 | |
visitPrimitive: IDENTITY, // 93 // 123 | |
visitArray: function (array/*, ...*/) { // 94 // 124 | |
var argsCopy = SLICE.call(arguments); // 95 // 125 | |
var result = array; // 96 // 126 | |
for (var i = 0; i < array.length; i++) { // 97 // 127 | |
var oldItem = array[i]; // 98 // 128 | |
argsCopy[0] = oldItem; // 99 // 129 | |
var newItem = this.visit.apply(this, argsCopy); // 100 | |
if (newItem !== oldItem) { // 101 | |
// copy `array` on write // 102 | |
if (result === array) // 103 | |
result = array.slice(); // 104 | |
result[i] = newItem; // 105 | |
} // 106 | |
} // 107 | |
return result; // 108 | |
}, // 109 | |
visitComment: IDENTITY, // 110 | |
visitCharRef: IDENTITY, // 111 | |
visitRaw: IDENTITY, // 112 | |
visitObject: IDENTITY, // 113 | |
visitFunction: IDENTITY, // 114 | |
visitTag: function (tag/*, ...*/) { // 115 | |
var oldChildren = tag.children; // 116 | |
var argsCopy = SLICE.call(arguments); // 117 | |
argsCopy[0] = oldChildren; // 118 | |
var newChildren = this.visitChildren.apply(this, argsCopy); // 119 | |
// 120 | |
var oldAttrs = tag.attrs; // 121 | |
argsCopy[0] = oldAttrs; // 122 | |
var newAttrs = this.visitAttributes.apply(this, argsCopy); // 123 | |
// 124 | |
if (newAttrs === oldAttrs && newChildren === oldChildren) // 125 | |
return tag; // 126 | |
// 127 | |
var newTag = HTML.getTag(tag.tagName).apply(null, newChildren); // 128 | |
newTag.attrs = newAttrs; // 129 | |
return newTag; // 130 | |
}, // 131 | |
visitChildren: function (children/*, ...*/) { // 132 | |
return this.visitArray.apply(this, arguments); // 133 | |
}, // 134 | |
// Transform the `.attrs` property of a tag, which may be a dictionary, // 135 | |
// an array, or in some uses, a foreign object (such as // 136 | |
// a template tag). // 137 | |
visitAttributes: function (attrs/*, ...*/) { // 138 | |
if (HTML.isArray(attrs)) { // 139 | |
var argsCopy = SLICE.call(arguments); // 140 | |
var result = attrs; // 141 | |
for (var i = 0; i < attrs.length; i++) { // 142 | |
var oldItem = attrs[i]; // 143 | |
argsCopy[0] = oldItem; // 144 | |
var newItem = this.visitAttributes.apply(this, argsCopy); // 145 | |
if (newItem !== oldItem) { // 146 | |
// copy on write // 147 | |
if (result === attrs) // 148 | |
result = attrs.slice(); // 149 | |
result[i] = newItem; // 150 | |
} // 151 | |
} // 152 | |
return result; // 153 | |
} // 154 | |
// 155 | |
if (attrs && HTML.isConstructedObject(attrs)) { // 156 | |
throw new Error("The basic HTML.TransformingVisitor does not support " + // 157 | |
"foreign objects in attributes. Define a custom " + // 158 | |
"visitAttributes for this case."); // 159 | |
} // 160 | |
// 161 | |
var oldAttrs = attrs; // 162 | |
var newAttrs = oldAttrs; // 163 | |
if (oldAttrs) { // 164 | |
var attrArgs = [null, null]; // 165 | |
attrArgs.push.apply(attrArgs, arguments); // 166 | |
for (var k in oldAttrs) { // 167 | |
var oldValue = oldAttrs[k]; // 168 | |
attrArgs[0] = k; // 169 | |
attrArgs[1] = oldValue; // 170 | |
var newValue = this.visitAttribute.apply(this, attrArgs); // 171 | |
if (newValue !== oldValue) { // 172 | |
// copy on write // 173 | |
if (newAttrs === oldAttrs) // 174 | |
newAttrs = _assign({}, oldAttrs); // 175 | |
newAttrs[k] = newValue; // 176 | |
} // 177 | |
} // 178 | |
} // 179 | |
// 180 | |
return newAttrs; // 181 | |
}, // 182 | |
// Transform the value of one attribute name/value in an // 183 | |
// attributes dictionary. // 184 | |
visitAttribute: function (name, value, tag/*, ...*/) { // 185 | |
var args = SLICE.call(arguments, 2); // 186 | |
args[0] = value; // 187 | |
return this.visit.apply(this, args); // 188 | |
} // 189 | |
}); // 190 | |
// 191 | |
// 192 | |
HTML.ToTextVisitor = HTML.Visitor.extend(); // 193 | |
HTML.ToTextVisitor.def({ // 194 | |
visitNull: function (nullOrUndefined) { // 195 | |
return ''; // 196 | |
}, // 197 | |
visitPrimitive: function (stringBooleanOrNumber) { // 198 | |
var str = String(stringBooleanOrNumber); // 199 | |
if (this.textMode === HTML.TEXTMODE.RCDATA) { // 200 | |
return str.replace(/&/g, '&').replace(/</g, '<'); // 201 | |
} else if (this.textMode === HTML.TEXTMODE.ATTRIBUTE) { // 202 | |
// escape `&` and `"` this time, not `&` and `<` // 203 | |
return str.replace(/&/g, '&').replace(/"/g, '"'); // 204 | |
} else { // 205 | |
return str; // 206 | |
} // 207 | |
}, // 208 | |
visitArray: function (array) { // 209 | |
var parts = []; // 210 | |
for (var i = 0; i < array.length; i++) // 211 | |
parts.push(this.visit(array[i])); // 212 | |
return parts.join(''); // 213 | |
}, // 214 | |
visitComment: function (comment) { // 215 | |
throw new Error("Can't have a comment here"); // 216 | |
}, // 217 | |
visitCharRef: function (charRef) { // 218 | |
if (this.textMode === HTML.TEXTMODE.RCDATA || // 219 | |
this.textMode === HTML.TEXTMODE.ATTRIBUTE) { // 220 | |
return charRef.html; // 221 | |
} else { // 222 | |
return charRef.str; // 223 | |
} // 224 | |
}, // 225 | |
visitRaw: function (raw) { // 226 | |
return raw.value; // 227 | |
}, // 228 | |
visitTag: function (tag) { // 229 | |
// Really we should just disallow Tags here. However, at the // 230 | |
// moment it's useful to stringify any HTML we find. In // 231 | |
// particular, when you include a template within `{{#markdown}}`, // 232 | |
// we render the template as text, and since there's currently // 233 | |
// no way to make the template be *parsed* as text (e.g. `<template // 234 | |
// type="text">`), we hackishly support HTML tags in markdown // 235 | |
// in templates by parsing them and stringifying them. // 236 | |
return this.visit(this.toHTML(tag)); // 237 | |
}, // 238 | |
visitObject: function (x) { // 239 | |
throw new Error("Unexpected object in htmljs in toText: " + x); // 240 | |
}, // 241 | |
toHTML: function (node) { // 242 | |
return HTML.toHTML(node); // 243 | |
} // 244 | |
}); // 245 | |
// 246 | |
// 247 | |
// 248 | |
HTML.ToHTMLVisitor = HTML.Visitor.extend(); // 249 | |
HTML.ToHTMLVisitor.def({ // 250 | |
visitNull: function (nullOrUndefined) { // 251 | |
return ''; // 252 | |
}, // 253 | |
visitPrimitive: function (stringBooleanOrNumber) { // 254 | |
var str = String(stringBooleanOrNumber); // 255 | |
return str.replace(/&/g, '&').replace(/</g, '<'); // 256 | |
}, // 257 | |
visitArray: function (array) { // 258 | |
var parts = []; // 259 | |
for (var i = 0; i < array.length; i++) // 260 | |
parts.push(this.visit(array[i])); // 261 | |
return parts.join(''); // 262 | |
}, // 263 | |
visitComment: function (comment) { // 264 | |
return '<!--' + comment.sanitizedValue + '-->'; // 265 | |
}, // 266 | |
visitCharRef: function (charRef) { // 267 | |
return charRef.html; // 268 | |
}, // 269 | |
visitRaw: function (raw) { // 270 | |
return raw.value; // 271 | |
}, // 272 | |
visitTag: function (tag) { // 273 | |
var attrStrs = []; // 274 | |
// 275 | |
var tagName = tag.tagName; // 276 | |
var children = tag.children; // 277 | |
// 278 | |
var attrs = tag.attrs; // 279 | |
if (attrs) { // 280 | |
attrs = HTML.flattenAttributes(attrs); // 281 | |
for (var k in attrs) { // 282 | |
if (k === 'value' && tagName === 'textarea') { // 283 | |
children = [attrs[k], children]; // 284 | |
} else { // 285 | |
var v = this.toText(attrs[k], HTML.TEXTMODE.ATTRIBUTE); // 286 | |
attrStrs.push(' ' + k + '="' + v + '"'); // 287 | |
} // 288 | |
} // 289 | |
} // 290 | |
// 291 | |
var startTag = '<' + tagName + attrStrs.join('') + '>'; // 292 | |
// 293 | |
var childStrs = []; // 294 | |
var content; // 295 | |
if (tagName === 'textarea') { // 296 | |
// 297 | |
for (var i = 0; i < children.length; i++) // 298 | |
childStrs.push(this.toText(children[i], HTML.TEXTMODE.RCDATA)); // 299 | |
// 300 | |
content = childStrs.join(''); // 301 | |
if (content.slice(0, 1) === '\n') // 302 | |
// TEXTAREA will absorb a newline, so if we see one, add // 303 | |
// another one. // 304 | |
content = '\n' + content; // 305 | |
// 306 | |
} else { // 307 | |
for (var i = 0; i < children.length; i++) // 308 | |
childStrs.push(this.visit(children[i])); // 309 | |
// 310 | |
content = childStrs.join(''); // 311 | |
} // 312 | |
// 313 | |
var result = startTag + content; // 314 | |
// 315 | |
if (children.length || ! HTML.isVoidElement(tagName)) { // 316 | |
// "Void" elements like BR are the only ones that don't get a close // 317 | |
// tag in HTML5. They shouldn't have contents, either, so we could // 318 | |
// throw an error upon seeing contents here. // 319 | |
result += '</' + tagName + '>'; // 320 | |
} // 321 | |
// 322 | |
return result; // 323 | |
}, // 324 | |
visitObject: function (x) { // 325 | |
throw new Error("Unexpected object in htmljs in toHTML: " + x); // 326 | |
}, // 327 | |
toText: function (node, textMode) { // 328 | |
return HTML.toText(node, textMode); // 329 | |
} // 330 | |
}); // 331 | |
// 332 | |
//////////////////////////////////////////////////////////////////////////////////////// // 363 | |
// 364 | |
}).call(this); // 365 | |
// 366 | |
// 367 | |
// 368 | |
// 369 | |
// 370 | |
// 371 | |
(function(){ // 372 | |
// 373 | |
//////////////////////////////////////////////////////////////////////////////////////// // 374 | |
// // // 375 | |
// packages/htmljs/html.js // // 376 | |
// // // 377 | |
//////////////////////////////////////////////////////////////////////////////////////// // 378 | |
// // 379 | |
// 1 // 380 | |
// 2 // 381 | |
HTML.Tag = function () {}; // 3 // 382 | |
HTML.Tag.prototype.tagName = ''; // this will be set per Tag subclass // 4 // 383 | |
HTML.Tag.prototype.attrs = null; // 5 // 384 | |
HTML.Tag.prototype.children = Object.freeze ? Object.freeze([]) : []; // 6 // 385 | |
HTML.Tag.prototype.htmljsType = HTML.Tag.htmljsType = ['Tag']; // 7 // 386 | |
// 8 // 387 | |
// Given "p" create the function `HTML.P`. // 9 // 388 | |
var makeTagConstructor = function (tagName) { // 10 // 389 | |
// HTMLTag is the per-tagName constructor of a HTML.Tag subclass // 11 // 390 | |
var HTMLTag = function (/*arguments*/) { // 12 // 391 | |
// Work with or without `new`. If not called with `new`, // 13 // 392 | |
// perform instantiation by recursively calling this constructor. // 14 // 393 | |
// We can't pass varargs, so pass no args. // 15 // 394 | |
var instance = (this instanceof HTML.Tag) ? this : new HTMLTag; // 16 // 395 | |
// 17 // 396 | |
var i = 0; // 18 // 397 | |
var attrs = arguments.length && arguments[0]; // 19 // 398 | |
if (attrs && (typeof attrs === 'object')) { // 20 // 399 | |
// Treat vanilla JS object as an attributes dictionary. // 21 // 400 | |
if (! HTML.isConstructedObject(attrs)) { // 22 // 401 | |
instance.attrs = attrs; // 23 // 402 | |
i++; // 24 // 403 | |
} else if (attrs instanceof HTML.Attrs) { // 25 // 404 | |
var array = attrs.value; // 26 // 405 | |
if (array.length === 1) { // 27 // 406 | |
instance.attrs = array[0]; // 28 // 407 | |
} else if (array.length > 1) { // 29 // 408 | |
instance.attrs = array; // 30 // 409 | |
} // 31 // 410 | |
i++; // 32 // 411 | |
} // 33 // 412 | |
} // 34 // 413 | |
// 35 // 414 | |
// 36 // 415 | |
// If no children, don't create an array at all, use the prototype's // 37 // 416 | |
// (frozen, empty) array. This way we don't create an empty array // 38 // 417 | |
// every time someone creates a tag without `new` and this constructor // 39 // 418 | |
// calls itself with no arguments (above). // 40 // 419 | |
if (i < arguments.length) // 41 // 420 | |
instance.children = SLICE.call(arguments, i); // 42 // 421 | |
// 43 // 422 | |
return instance; // 44 // 423 | |
}; // 45 // 424 | |
HTMLTag.prototype = new HTML.Tag; // 46 // 425 | |
HTMLTag.prototype.constructor = HTMLTag; // 47 // 426 | |
HTMLTag.prototype.tagName = tagName; // 48 // 427 | |
// 49 // 428 | |
return HTMLTag; // 50 // 429 | |
}; // 51 // 430 | |
// 52 // 431 | |
// Not an HTMLjs node, but a wrapper to pass multiple attrs dictionaries // 53 // 432 | |
// to a tag (for the purpose of implementing dynamic attributes). // 54 // 433 | |
var Attrs = HTML.Attrs = function (/*attrs dictionaries*/) { // 55 // 434 | |
// Work with or without `new`. If not called with `new`, // 56 // 435 | |
// perform instantiation by recursively calling this constructor. // 57 // 436 | |
// We can't pass varargs, so pass no args. // 58 // 437 | |
var instance = (this instanceof Attrs) ? this : new Attrs; // 59 // 438 | |
// 60 // 439 | |
instance.value = SLICE.call(arguments); // 61 // 440 | |
// 62 // 441 | |
return instance; // 63 // 442 | |
}; // 64 // 443 | |
// 65 // 444 | |
////////////////////////////// KNOWN ELEMENTS // 66 // 445 | |
// 67 // 446 | |
HTML.getTag = function (tagName) { // 68 // 447 | |
var symbolName = HTML.getSymbolName(tagName); // 69 // 448 | |
if (symbolName === tagName) // all-caps tagName // 70 // 449 | |
throw new Error("Use the lowercase or camelCase form of '" + tagName + "' here"); // 450 | |
// 72 // 451 | |
if (! HTML[symbolName]) // 73 // 452 | |
HTML[symbolName] = makeTagConstructor(tagName); // 74 // 453 | |
// 75 // 454 | |
return HTML[symbolName]; // 76 // 455 | |
}; // 77 // 456 | |
// 78 // 457 | |
HTML.ensureTag = function (tagName) { // 79 // 458 | |
HTML.getTag(tagName); // don't return it // 80 // 459 | |
}; // 81 // 460 | |
// 82 // 461 | |
HTML.isTagEnsured = function (tagName) { // 83 // 462 | |
return HTML.isKnownElement(tagName); // 84 // 463 | |
}; // 85 // 464 | |
// 86 // 465 | |
HTML.getSymbolName = function (tagName) { // 87 // 466 | |
// "foo-bar" -> "FOO_BAR" // 88 // 467 | |
return tagName.toUpperCase().replace(/-/g, '_'); // 89 // 468 | |
}; // 90 // 469 | |
// 91 // 470 | |
HTML.knownElementNames = 'a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup command data datagrid datalist dd del details dfn dir div dl dt em embed eventsource fieldset figcaption figure font footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins isindex kbd keygen label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td textarea tfoot th thead time title tr track tt u ul var video wbr'.split(' '); | |
// (we add the SVG ones below) // 93 // 472 | |
// 94 // 473 | |
HTML.knownSVGElementNames = 'altGlyph altGlyphDef altGlyphItem animate animateColor animateMotion animateTransform circle clipPath color-profile cursor defs desc ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font font-face font-face-format font-face-name font-face-src font-face-uri foreignObject g glyph glyphRef hkern image line linearGradient marker mask metadata missing-glyph path pattern polygon polyline radialGradient rect set stop style svg switch symbol text textPath title tref tspan use view vkern'.split(' '); | |
// Append SVG element names to list of known element names // 96 // 475 | |
HTML.knownElementNames = HTML.knownElementNames.concat(HTML.knownSVGElementNames); // 97 // 476 | |
// 98 // 477 | |
HTML.voidElementNames = 'area base br col command embed hr img input keygen link meta param source track wbr'.split(' '); | |
// 100 | |
// Speed up search through lists of known elements by creating internal "sets" // 101 | |
// of strings. // 102 | |
var YES = {yes:true}; // 103 | |
var makeSet = function (array) { // 104 | |
var set = {}; // 105 | |
for (var i = 0; i < array.length; i++) // 106 | |
set[array[i]] = YES; // 107 | |
return set; // 108 | |
}; // 109 | |
var voidElementSet = makeSet(HTML.voidElementNames); // 110 | |
var knownElementSet = makeSet(HTML.knownElementNames); // 111 | |
var knownSVGElementSet = makeSet(HTML.knownSVGElementNames); // 112 | |
// 113 | |
HTML.isKnownElement = function (tagName) { // 114 | |
return knownElementSet[tagName] === YES; // 115 | |
}; // 116 | |
// 117 | |
HTML.isKnownSVGElement = function (tagName) { // 118 | |
return knownSVGElementSet[tagName] === YES; // 119 | |
}; // 120 | |
// 121 | |
HTML.isVoidElement = function (tagName) { // 122 | |
return voidElementSet[tagName] === YES; // 123 | |
}; // 124 | |
// 125 | |
// 126 | |
// Ensure tags for all known elements // 127 | |
for (var i = 0; i < HTML.knownElementNames.length; i++) // 128 | |
HTML.ensureTag(HTML.knownElementNames[i]); // 129 | |
// 130 | |
// 131 | |
var CharRef = HTML.CharRef = function (attrs) { // 132 | |
if (! (this instanceof CharRef)) // 133 | |
// called without `new` // 134 | |
return new CharRef(attrs); // 135 | |
// 136 | |
if (! (attrs && attrs.html && attrs.str)) // 137 | |
throw new Error( // 138 | |
"HTML.CharRef must be constructed with ({html:..., str:...})"); // 139 | |
// 140 | |
this.html = attrs.html; // 141 | |
this.str = attrs.str; // 142 | |
}; // 143 | |
CharRef.prototype.htmljsType = CharRef.htmljsType = ['CharRef']; // 144 | |
// 145 | |
var Comment = HTML.Comment = function (value) { // 146 | |
if (! (this instanceof Comment)) // 147 | |
// called without `new` // 148 | |
return new Comment(value); // 149 | |
// 150 | |
if (typeof value !== 'string') // 151 | |
throw new Error('HTML.Comment must be constructed with a string'); // 152 | |
// 153 | |
this.value = value; // 154 | |
// Kill illegal hyphens in comment value (no way to escape them in HTML) // 155 | |
this.sanitizedValue = value.replace(/^-|--+|-$/g, ''); // 156 | |
}; // 157 | |
Comment.prototype.htmljsType = Comment.htmljsType = ['Comment']; // 158 | |
// 159 | |
var Raw = HTML.Raw = function (value) { // 160 | |
if (! (this instanceof Raw)) // 161 | |
// called without `new` // 162 | |
return new Raw(value); // 163 | |
// 164 | |
if (typeof value !== 'string') // 165 | |
throw new Error('HTML.Raw must be constructed with a string'); // 166 | |
// 167 | |
this.value = value; // 168 | |
}; // 169 | |
Raw.prototype.htmljsType = Raw.htmljsType = ['Raw']; // 170 | |
// 171 | |
// 172 | |
HTML.isArray = function (x) { // 173 | |
// could change this to use the more convoluted Object.prototype.toString // 174 | |
// approach that works when objects are passed between frames, but does // 175 | |
// it matter? // 176 | |
return (x instanceof Array); // 177 | |
}; // 178 | |
// 179 | |
HTML.isConstructedObject = function (x) { // 180 | |
// Figure out if `x` is "an instance of some class" or just a plain // 181 | |
// object literal. It correctly treats an object literal like // 182 | |
// `{ constructor: ... }` as an object literal. It won't detect // 183 | |
// instances of classes that lack a `constructor` property (e.g. // 184 | |
// if you assign to a prototype when setting up the class as in: // 185 | |
// `Foo = function () { ... }; Foo.prototype = { ... }`, then // 186 | |
// `(new Foo).constructor` is `Object`, not `Foo`). // 187 | |
return (x && (typeof x === 'object') && // 188 | |
(x.constructor !== Object) && // 189 | |
(typeof x.constructor === 'function') && // 190 | |
(x instanceof x.constructor)); // 191 | |
}; // 192 | |
// 193 | |
HTML.isNully = function (node) { // 194 | |
if (node == null) // 195 | |
// null or undefined // 196 | |
return true; // 197 | |
// 198 | |
if (HTML.isArray(node)) { // 199 | |
// is it an empty array or an array of all nully items? // 200 | |
for (var i = 0; i < node.length; i++) // 201 | |
if (! HTML.isNully(node[i])) // 202 | |
return false; // 203 | |
return true; // 204 | |
} // 205 | |
// 206 | |
return false; // 207 | |
}; // 208 | |
// 209 | |
HTML.isValidAttributeName = function (name) { // 210 | |
return /^[:_A-Za-z][:_A-Za-z0-9.\-]*/.test(name); // 211 | |
}; // 212 | |
// 213 | |
// If `attrs` is an array of attributes dictionaries, combines them // 214 | |
// into one. Removes attributes that are "nully." // 215 | |
HTML.flattenAttributes = function (attrs) { // 216 | |
if (! attrs) // 217 | |
return attrs; // 218 | |
// 219 | |
var isArray = HTML.isArray(attrs); // 220 | |
if (isArray && attrs.length === 0) // 221 | |
return null; // 222 | |
// 223 | |
var result = {}; // 224 | |
for (var i = 0, N = (isArray ? attrs.length : 1); i < N; i++) { // 225 | |
var oneAttrs = (isArray ? attrs[i] : attrs); // 226 | |
if ((typeof oneAttrs !== 'object') || // 227 | |
HTML.isConstructedObject(oneAttrs)) // 228 | |
throw new Error("Expected plain JS object as attrs, found: " + oneAttrs); // 229 | |
for (var name in oneAttrs) { // 230 | |
if (! HTML.isValidAttributeName(name)) // 231 | |
throw new Error("Illegal HTML attribute name: " + name); // 232 | |
var value = oneAttrs[name]; // 233 | |
if (! HTML.isNully(value)) // 234 | |
result[name] = value; // 235 | |
} // 236 | |
} // 237 | |
// 238 | |
return result; // 239 | |
}; // 240 | |
// 241 | |
// 242 | |
// 243 | |
////////////////////////////// TOHTML // 244 | |
// 245 | |
HTML.toHTML = function (content) { // 246 | |
return (new HTML.ToHTMLVisitor).visit(content); // 247 | |
}; // 248 | |
// 249 | |
// Escaping modes for outputting text when generating HTML. // 250 | |
HTML.TEXTMODE = { // 251 | |
STRING: 1, // 252 | |
RCDATA: 2, // 253 | |
ATTRIBUTE: 3 // 254 | |
}; // 255 | |
// 256 | |
// 257 | |
HTML.toText = function (content, textMode) { // 258 | |
if (! textMode) // 259 | |
throw new Error("textMode required for HTML.toText"); // 260 | |
if (! (textMode === HTML.TEXTMODE.STRING || // 261 | |
textMode === HTML.TEXTMODE.RCDATA || // 262 | |
textMode === HTML.TEXTMODE.ATTRIBUTE)) // 263 | |
throw new Error("Unknown textMode: " + textMode); // 264 | |
// 265 | |
var visitor = new HTML.ToTextVisitor({textMode: textMode});; // 266 | |
return visitor.visit(content); // 267 | |
}; // 268 | |
// 269 | |
//////////////////////////////////////////////////////////////////////////////////////// // 649 | |
// 650 | |
}).call(this); // 651 | |
// 652 | |
/////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.htmljs = { | |
HTML: HTML | |
}; | |
/* Package-scope variables */ | |
var Tracker, Deps; | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/tracker/tracker.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
///////////////////////////////////////////////////// // 1 | |
// Package docs at http://docs.meteor.com/#tracker // // 2 | |
///////////////////////////////////////////////////// // 3 | |
// 4 | |
/** // 5 | |
* @namespace Tracker // 6 | |
* @summary The namespace for Tracker-related methods. // 7 | |
*/ // 8 | |
Tracker = {}; // 9 | |
// 10 | |
// http://docs.meteor.com/#tracker_active // 11 | |
// 12 | |
/** // 13 | |
* @summary True if there is a current computation, meaning that dependencies on reactive data sources will be tracked and potentially cause the current computation to be rerun. | |
* @locus Client // 15 | |
* @type {Boolean} // 16 | |
*/ // 17 | |
Tracker.active = false; // 18 | |
// 19 | |
// http://docs.meteor.com/#tracker_currentcomputation // 20 | |
// 21 | |
/** // 22 | |
* @summary The current computation, or `null` if there isn't one. The current computation is the [`Tracker.Computation`](#tracker_computation) object created by the innermost active call to `Tracker.autorun`, and it's the computation that gains dependencies when reactive data sources are accessed. | |
* @locus Client // 24 | |
* @type {Tracker.Computation} // 25 | |
*/ // 26 | |
Tracker.currentComputation = null; // 27 | |
// 28 | |
// References to all computations created within the Tracker by id. // 29 | |
// Keeping these references on an underscore property gives more control to // 30 | |
// tooling and packages extending Tracker without increasing the API surface. // 31 | |
// These can used to monkey-patch computations, their functions, use // 32 | |
// computation ids for tracking, etc. // 33 | |
Tracker._computations = {}; // 34 | |
// 35 | |
var setCurrentComputation = function (c) { // 36 | |
Tracker.currentComputation = c; // 37 | |
Tracker.active = !! c; // 38 | |
}; // 39 | |
// 40 | |
var _debugFunc = function () { // 41 | |
// We want this code to work without Meteor, and also without // 42 | |
// "console" (which is technically non-standard and may be missing // 43 | |
// on some browser we come across, like it was on IE 7). // 44 | |
// // 45 | |
// Lazy evaluation because `Meteor` does not exist right away.(??) // 46 | |
return (typeof Meteor !== "undefined" ? Meteor._debug : // 47 | |
((typeof console !== "undefined") && console.error ? // 48 | |
function () { console.error.apply(console, arguments); } : // 49 | |
function () {})); // 50 | |
}; // 51 | |
// 52 | |
var _maybeSuppressMoreLogs = function (messagesLength) { // 53 | |
// Sometimes when running tests, we intentionally suppress logs on expected // 54 | |
// printed errors. Since the current implementation of _throwOrLog can log // 55 | |
// multiple separate log messages, suppress all of them if at least one suppress // 56 | |
// is expected as we still want them to count as one. // 57 | |
if (typeof Meteor !== "undefined") { // 58 | |
if (Meteor._suppressed_log_expected()) { // 59 | |
Meteor._suppress_log(messagesLength - 1); // 60 | |
} // 61 | |
} // 62 | |
}; // 63 | |
// 64 | |
var _throwOrLog = function (from, e) { // 65 | |
if (throwFirstError) { // 66 | |
throw e; // 67 | |
} else { // 68 | |
var printArgs = ["Exception from Tracker " + from + " function:"]; // 69 | |
if (e.stack && e.message && e.name) { // 70 | |
var idx = e.stack.indexOf(e.message); // 71 | |
if (idx < 0 || idx > e.name.length + 2) { // check for "Error: " // 72 | |
// message is not part of the stack // 73 | |
var message = e.name + ": " + e.message; // 74 | |
printArgs.push(message); // 75 | |
} // 76 | |
} // 77 | |
printArgs.push(e.stack); // 78 | |
_maybeSuppressMoreLogs(printArgs.length); // 79 | |
// 80 | |
for (var i = 0; i < printArgs.length; i++) { // 81 | |
_debugFunc()(printArgs[i]); // 82 | |
} // 83 | |
} // 84 | |
}; // 85 | |
// 86 | |
// Takes a function `f`, and wraps it in a `Meteor._noYieldsAllowed` // 87 | |
// block if we are running on the server. On the client, returns the // 88 | |
// original function (since `Meteor._noYieldsAllowed` is a // 89 | |
// no-op). This has the benefit of not adding an unnecessary stack // 90 | |
// frame on the client. // 91 | |
var withNoYieldsAllowed = function (f) { // 92 | |
if ((typeof Meteor === 'undefined') || Meteor.isClient) { // 93 | |
return f; // 94 | |
} else { // 95 | |
return function () { // 96 | |
var args = arguments; // 97 | |
Meteor._noYieldsAllowed(function () { // 98 | |
f.apply(null, args); // 99 | |
}); // 100 | |
}; // 101 | |
} // 102 | |
}; // 103 | |
// 104 | |
var nextId = 1; // 105 | |
// computations whose callbacks we should call at flush time // 106 | |
var pendingComputations = []; // 107 | |
// `true` if a Tracker.flush is scheduled, or if we are in Tracker.flush now // 108 | |
var willFlush = false; // 109 | |
// `true` if we are in Tracker.flush now // 110 | |
var inFlush = false; // 111 | |
// `true` if we are computing a computation now, either first time // 112 | |
// or recompute. This matches Tracker.active unless we are inside // 113 | |
// Tracker.nonreactive, which nullfies currentComputation even though // 114 | |
// an enclosing computation may still be running. // 115 | |
var inCompute = false; // 116 | |
// `true` if the `_throwFirstError` option was passed in to the call // 117 | |
// to Tracker.flush that we are in. When set, throw rather than log the // 118 | |
// first error encountered while flushing. Before throwing the error, // 119 | |
// finish flushing (from a finally block), logging any subsequent // 120 | |
// errors. // 121 | |
var throwFirstError = false; // 122 | |
// 123 | |
var afterFlushCallbacks = []; // 124 | |
// 125 | |
var requireFlush = function () { // 126 | |
if (! willFlush) { // 127 | |
// We want this code to work without Meteor, see debugFunc above // 128 | |
if (typeof Meteor !== "undefined") // 129 | |
Meteor._setImmediate(Tracker._runFlush); // 130 | |
else // 131 | |
setTimeout(Tracker._runFlush, 0); // 132 | |
willFlush = true; // 133 | |
} // 134 | |
}; // 135 | |
// 136 | |
// Tracker.Computation constructor is visible but private // 137 | |
// (throws an error if you try to call it) // 138 | |
var constructingComputation = false; // 139 | |
// 140 | |
// // 141 | |
// http://docs.meteor.com/#tracker_computation // 142 | |
// 143 | |
/** // 144 | |
* @summary A Computation object represents code that is repeatedly rerun // 145 | |
* in response to // 146 | |
* reactive data changes. Computations don't have return values; they just // 147 | |
* perform actions, such as rerendering a template on the screen. Computations // 148 | |
* are created using Tracker.autorun. Use stop to prevent further rerunning of a // 149 | |
* computation. // 150 | |
* @instancename computation // 151 | |
*/ // 152 | |
Tracker.Computation = function (f, parent, onError) { // 153 | |
if (! constructingComputation) // 154 | |
throw new Error( // 155 | |
"Tracker.Computation constructor is private; use Tracker.autorun"); // 156 | |
constructingComputation = false; // 157 | |
// 158 | |
var self = this; // 159 | |
// 160 | |
// http://docs.meteor.com/#computation_stopped // 161 | |
// 162 | |
/** // 163 | |
* @summary True if this computation has been stopped. // 164 | |
* @locus Client // 165 | |
* @memberOf Tracker.Computation // 166 | |
* @instance // 167 | |
* @name stopped // 168 | |
*/ // 169 | |
self.stopped = false; // 170 | |
// 171 | |
// http://docs.meteor.com/#computation_invalidated // 172 | |
// 173 | |
/** // 174 | |
* @summary True if this computation has been invalidated (and not yet rerun), or if it has been stopped. // 175 | |
* @locus Client // 176 | |
* @memberOf Tracker.Computation // 177 | |
* @instance // 178 | |
* @name invalidated // 179 | |
* @type {Boolean} // 180 | |
*/ // 181 | |
self.invalidated = false; // 182 | |
// 183 | |
// http://docs.meteor.com/#computation_firstrun // 184 | |
// 185 | |
/** // 186 | |
* @summary True during the initial run of the computation at the time `Tracker.autorun` is called, and false on subsequent reruns and at other times. | |
* @locus Client // 188 | |
* @memberOf Tracker.Computation // 189 | |
* @instance // 190 | |
* @name firstRun // 191 | |
* @type {Boolean} // 192 | |
*/ // 193 | |
self.firstRun = true; // 194 | |
// 195 | |
self._id = nextId++; // 196 | |
self._onInvalidateCallbacks = []; // 197 | |
self._onStopCallbacks = []; // 198 | |
// the plan is at some point to use the parent relation // 199 | |
// to constrain the order that computations are processed // 200 | |
self._parent = parent; // 201 | |
self._func = f; // 202 | |
self._onError = onError; // 203 | |
self._recomputing = false; // 204 | |
// 205 | |
// Register the computation within the global Tracker. // 206 | |
Tracker._computations[self._id] = self; // 207 | |
// 208 | |
var errored = true; // 209 | |
try { // 210 | |
self._compute(); // 211 | |
errored = false; // 212 | |
} finally { // 213 | |
self.firstRun = false; // 214 | |
if (errored) // 215 | |
self.stop(); // 216 | |
} // 217 | |
}; // 218 | |
// 219 | |
// http://docs.meteor.com/#computation_oninvalidate // 220 | |
// 221 | |
/** // 222 | |
* @summary Registers `callback` to run when this computation is next invalidated, or runs it immediately if the computation is already invalidated. The callback is run exactly once and not upon future invalidations unless `onInvalidate` is called again after the computation becomes valid again. | |
* @locus Client // 224 | |
* @param {Function} callback Function to be called on invalidation. Receives one argument, the computation that was invalidated. | |
*/ // 226 | |
Tracker.Computation.prototype.onInvalidate = function (f) { // 227 | |
var self = this; // 228 | |
// 229 | |
if (typeof f !== 'function') // 230 | |
throw new Error("onInvalidate requires a function"); // 231 | |
// 232 | |
if (self.invalidated) { // 233 | |
Tracker.nonreactive(function () { // 234 | |
withNoYieldsAllowed(f)(self); // 235 | |
}); // 236 | |
} else { // 237 | |
self._onInvalidateCallbacks.push(f); // 238 | |
} // 239 | |
}; // 240 | |
// 241 | |
/** // 242 | |
* @summary Registers `callback` to run when this computation is stopped, or runs it immediately if the computation is already stopped. The callback is run after any `onInvalidate` callbacks. | |
* @locus Client // 244 | |
* @param {Function} callback Function to be called on stop. Receives one argument, the computation that was stopped. | |
*/ // 246 | |
Tracker.Computation.prototype.onStop = function (f) { // 247 | |
var self = this; // 248 | |
// 249 | |
if (typeof f !== 'function') // 250 | |
throw new Error("onStop requires a function"); // 251 | |
// 252 | |
if (self.stopped) { // 253 | |
Tracker.nonreactive(function () { // 254 | |
withNoYieldsAllowed(f)(self); // 255 | |
}); // 256 | |
} else { // 257 | |
self._onStopCallbacks.push(f); // 258 | |
} // 259 | |
}; // 260 | |
// 261 | |
// http://docs.meteor.com/#computation_invalidate // 262 | |
// 263 | |
/** // 264 | |
* @summary Invalidates this computation so that it will be rerun. // 265 | |
* @locus Client // 266 | |
*/ // 267 | |
Tracker.Computation.prototype.invalidate = function () { // 268 | |
var self = this; // 269 | |
if (! self.invalidated) { // 270 | |
// if we're currently in _recompute(), don't enqueue // 271 | |
// ourselves, since we'll rerun immediately anyway. // 272 | |
if (! self._recomputing && ! self.stopped) { // 273 | |
requireFlush(); // 274 | |
pendingComputations.push(this); // 275 | |
} // 276 | |
// 277 | |
self.invalidated = true; // 278 | |
// 279 | |
// callbacks can't add callbacks, because // 280 | |
// self.invalidated === true. // 281 | |
for(var i = 0, f; f = self._onInvalidateCallbacks[i]; i++) { // 282 | |
Tracker.nonreactive(function () { // 283 | |
withNoYieldsAllowed(f)(self); // 284 | |
}); // 285 | |
} // 286 | |
self._onInvalidateCallbacks = []; // 287 | |
} // 288 | |
}; // 289 | |
// 290 | |
// http://docs.meteor.com/#computation_stop // 291 | |
// 292 | |
/** // 293 | |
* @summary Prevents this computation from rerunning. // 294 | |
* @locus Client // 295 | |
*/ // 296 | |
Tracker.Computation.prototype.stop = function () { // 297 | |
var self = this; // 298 | |
// 299 | |
if (! self.stopped) { // 300 | |
self.stopped = true; // 301 | |
self.invalidate(); // 302 | |
// Unregister from global Tracker. // 303 | |
delete Tracker._computations[self._id]; // 304 | |
for(var i = 0, f; f = self._onStopCallbacks[i]; i++) { // 305 | |
Tracker.nonreactive(function () { // 306 | |
withNoYieldsAllowed(f)(self); // 307 | |
}); // 308 | |
} // 309 | |
self._onStopCallbacks = []; // 310 | |
} // 311 | |
}; // 312 | |
// 313 | |
Tracker.Computation.prototype._compute = function () { // 314 | |
var self = this; // 315 | |
self.invalidated = false; // 316 | |
// 317 | |
var previous = Tracker.currentComputation; // 318 | |
setCurrentComputation(self); // 319 | |
var previousInCompute = inCompute; // 320 | |
inCompute = true; // 321 | |
try { // 322 | |
withNoYieldsAllowed(self._func)(self); // 323 | |
} finally { // 324 | |
setCurrentComputation(previous); // 325 | |
inCompute = previousInCompute; // 326 | |
} // 327 | |
}; // 328 | |
// 329 | |
Tracker.Computation.prototype._needsRecompute = function () { // 330 | |
var self = this; // 331 | |
return self.invalidated && ! self.stopped; // 332 | |
}; // 333 | |
// 334 | |
Tracker.Computation.prototype._recompute = function () { // 335 | |
var self = this; // 336 | |
// 337 | |
self._recomputing = true; // 338 | |
try { // 339 | |
if (self._needsRecompute()) { // 340 | |
try { // 341 | |
self._compute(); // 342 | |
} catch (e) { // 343 | |
if (self._onError) { // 344 | |
self._onError(e); // 345 | |
} else { // 346 | |
_throwOrLog("recompute", e); // 347 | |
} // 348 | |
} // 349 | |
} // 350 | |
} finally { // 351 | |
self._recomputing = false; // 352 | |
} // 353 | |
}; // 354 | |
// 355 | |
// // 356 | |
// http://docs.meteor.com/#tracker_dependency // 357 | |
// 358 | |
/** // 359 | |
* @summary A Dependency represents an atomic unit of reactive data that a // 360 | |
* computation might depend on. Reactive data sources such as Session or // 361 | |
* Minimongo internally create different Dependency objects for different // 362 | |
* pieces of data, each of which may be depended on by multiple computations. // 363 | |
* When the data changes, the computations are invalidated. // 364 | |
* @class // 365 | |
* @instanceName dependency // 366 | |
*/ // 367 | |
Tracker.Dependency = function () { // 368 | |
this._dependentsById = {}; // 369 | |
}; // 370 | |
// 371 | |
// http://docs.meteor.com/#dependency_depend // 372 | |
// // 373 | |
// Adds `computation` to this set if it is not already // 374 | |
// present. Returns true if `computation` is a new member of the set. // 375 | |
// If no argument, defaults to currentComputation, or does nothing // 376 | |
// if there is no currentComputation. // 377 | |
// 378 | |
/** // 379 | |
* @summary Declares that the current computation (or `fromComputation` if given) depends on `dependency`. The computation will be invalidated the next time `dependency` changes. | |
// 381 | |
If there is no current computation and `depend()` is called with no arguments, it does nothing and returns false. // 382 | |
// 383 | |
Returns true if the computation is a new dependent of `dependency` rather than an existing one. // 384 | |
* @locus Client // 385 | |
* @param {Tracker.Computation} [fromComputation] An optional computation declared to depend on `dependency` instead of the current computation. | |
* @returns {Boolean} // 387 | |
*/ // 388 | |
Tracker.Dependency.prototype.depend = function (computation) { // 389 | |
if (! computation) { // 390 | |
if (! Tracker.active) // 391 | |
return false; // 392 | |
// 393 | |
computation = Tracker.currentComputation; // 394 | |
} // 395 | |
var self = this; // 396 | |
var id = computation._id; // 397 | |
if (! (id in self._dependentsById)) { // 398 | |
self._dependentsById[id] = computation; // 399 | |
computation.onInvalidate(function () { // 400 | |
delete self._dependentsById[id]; // 401 | |
}); // 402 | |
return true; // 403 | |
} // 404 | |
return false; // 405 | |
}; // 406 | |
// 407 | |
// http://docs.meteor.com/#dependency_changed // 408 | |
// 409 | |
/** // 410 | |
* @summary Invalidate all dependent computations immediately and remove them as dependents. // 411 | |
* @locus Client // 412 | |
*/ // 413 | |
Tracker.Dependency.prototype.changed = function () { // 414 | |
var self = this; // 415 | |
for (var id in self._dependentsById) // 416 | |
self._dependentsById[id].invalidate(); // 417 | |
}; // 418 | |
// 419 | |
// http://docs.meteor.com/#dependency_hasdependents // 420 | |
// 421 | |
/** // 422 | |
* @summary True if this Dependency has one or more dependent Computations, which would be invalidated if this Dependency were to change. | |
* @locus Client // 424 | |
* @returns {Boolean} // 425 | |
*/ // 426 | |
Tracker.Dependency.prototype.hasDependents = function () { // 427 | |
var self = this; // 428 | |
for(var id in self._dependentsById) // 429 | |
return true; // 430 | |
return false; // 431 | |
}; // 432 | |
// 433 | |
// http://docs.meteor.com/#tracker_flush // 434 | |
// 435 | |
/** // 436 | |
* @summary Process all reactive updates immediately and ensure that all invalidated computations are rerun. // 437 | |
* @locus Client // 438 | |
*/ // 439 | |
Tracker.flush = function (options) { // 440 | |
Tracker._runFlush({ finishSynchronously: true, // 441 | |
throwFirstError: options && options._throwFirstError }); // 442 | |
}; // 443 | |
// 444 | |
// Run all pending computations and afterFlush callbacks. If we were not called // 445 | |
// directly via Tracker.flush, this may return before they're all done to allow // 446 | |
// the event loop to run a little before continuing. // 447 | |
Tracker._runFlush = function (options) { // 448 | |
// XXX What part of the comment below is still true? (We no longer // 449 | |
// have Spark) // 450 | |
// // 451 | |
// Nested flush could plausibly happen if, say, a flush causes // 452 | |
// DOM mutation, which causes a "blur" event, which runs an // 453 | |
// app event handler that calls Tracker.flush. At the moment // 454 | |
// Spark blocks event handlers during DOM mutation anyway, // 455 | |
// because the LiveRange tree isn't valid. And we don't have // 456 | |
// any useful notion of a nested flush. // 457 | |
// // 458 | |
// https://app.asana.com/0/159908330244/385138233856 // 459 | |
if (inFlush) // 460 | |
throw new Error("Can't call Tracker.flush while flushing"); // 461 | |
// 462 | |
if (inCompute) // 463 | |
throw new Error("Can't flush inside Tracker.autorun"); // 464 | |
// 465 | |
options = options || {}; // 466 | |
// 467 | |
inFlush = true; // 468 | |
willFlush = true; // 469 | |
throwFirstError = !! options.throwFirstError; // 470 | |
// 471 | |
var recomputedCount = 0; // 472 | |
var finishedTry = false; // 473 | |
try { // 474 | |
while (pendingComputations.length || // 475 | |
afterFlushCallbacks.length) { // 476 | |
// 477 | |
// recompute all pending computations // 478 | |
while (pendingComputations.length) { // 479 | |
var comp = pendingComputations.shift(); // 480 | |
comp._recompute(); // 481 | |
if (comp._needsRecompute()) { // 482 | |
pendingComputations.unshift(comp); // 483 | |
} // 484 | |
// 485 | |
if (! options.finishSynchronously && ++recomputedCount > 1000) { // 486 | |
finishedTry = true; // 487 | |
return; // 488 | |
} // 489 | |
} // 490 | |
// 491 | |
if (afterFlushCallbacks.length) { // 492 | |
// call one afterFlush callback, which may // 493 | |
// invalidate more computations // 494 | |
var func = afterFlushCallbacks.shift(); // 495 | |
try { // 496 | |
func(); // 497 | |
} catch (e) { // 498 | |
_throwOrLog("afterFlush", e); // 499 | |
} // 500 | |
} // 501 | |
} // 502 | |
finishedTry = true; // 503 | |
} finally { // 504 | |
if (! finishedTry) { // 505 | |
// we're erroring due to throwFirstError being true. // 506 | |
inFlush = false; // needed before calling `Tracker.flush()` again // 507 | |
// finish flushing // 508 | |
Tracker._runFlush({ // 509 | |
finishSynchronously: options.finishSynchronously, // 510 | |
throwFirstError: false // 511 | |
}); // 512 | |
} // 513 | |
willFlush = false; // 514 | |
inFlush = false; // 515 | |
if (pendingComputations.length || afterFlushCallbacks.length) { // 516 | |
// We're yielding because we ran a bunch of computations and we aren't // 517 | |
// required to finish synchronously, so we'd like to give the event loop a // 518 | |
// chance. We should flush again soon. // 519 | |
if (options.finishSynchronously) { // 520 | |
throw new Error("still have more to do?"); // shouldn't happen // 521 | |
} // 522 | |
setTimeout(requireFlush, 10); // 523 | |
} // 524 | |
} // 525 | |
}; // 526 | |
// 527 | |
// http://docs.meteor.com/#tracker_autorun // 528 | |
// // 529 | |
// Run f(). Record its dependencies. Rerun it whenever the // 530 | |
// dependencies change. // 531 | |
// // 532 | |
// Returns a new Computation, which is also passed to f. // 533 | |
// // 534 | |
// Links the computation to the current computation // 535 | |
// so that it is stopped if the current computation is invalidated. // 536 | |
// 537 | |
/** // 538 | |
* @callback Tracker.ComputationFunction // 539 | |
* @param {Tracker.Computation} // 540 | |
*/ // 541 | |
/** // 542 | |
* @summary Run a function now and rerun it later whenever its dependencies // 543 | |
* change. Returns a Computation object that can be used to stop or observe the // 544 | |
* rerunning. // 545 | |
* @locus Client // 546 | |
* @param {Tracker.ComputationFunction} runFunc The function to run. It receives // 547 | |
* one argument: the Computation object that will be returned. // 548 | |
* @param {Object} [options] // 549 | |
* @param {Function} options.onError Optional. The function to run when an error // 550 | |
* happens in the Computation. The only argument it recieves is the Error // 551 | |
* thrown. Defaults to the error being logged to the console. // 552 | |
* @returns {Tracker.Computation} // 553 | |
*/ // 554 | |
Tracker.autorun = function (f, options) { // 555 | |
if (typeof f !== 'function') // 556 | |
throw new Error('Tracker.autorun requires a function argument'); // 557 | |
// 558 | |
options = options || {}; // 559 | |
// 560 | |
constructingComputation = true; // 561 | |
var c = new Tracker.Computation( // 562 | |
f, Tracker.currentComputation, options.onError); // 563 | |
// 564 | |
if (Tracker.active) // 565 | |
Tracker.onInvalidate(function () { // 566 | |
c.stop(); // 567 | |
}); // 568 | |
// 569 | |
return c; // 570 | |
}; // 571 | |
// 572 | |
// http://docs.meteor.com/#tracker_nonreactive // 573 | |
// // 574 | |
// Run `f` with no current computation, returning the return value // 575 | |
// of `f`. Used to turn off reactivity for the duration of `f`, // 576 | |
// so that reactive data sources accessed by `f` will not result in any // 577 | |
// computations being invalidated. // 578 | |
// 579 | |
/** // 580 | |
* @summary Run a function without tracking dependencies. // 581 | |
* @locus Client // 582 | |
* @param {Function} func A function to call immediately. // 583 | |
*/ // 584 | |
Tracker.nonreactive = function (f) { // 585 | |
var previous = Tracker.currentComputation; // 586 | |
setCurrentComputation(null); // 587 | |
try { // 588 | |
return f(); // 589 | |
} finally { // 590 | |
setCurrentComputation(previous); // 591 | |
} // 592 | |
}; // 593 | |
// 594 | |
// http://docs.meteor.com/#tracker_oninvalidate // 595 | |
// 596 | |
/** // 597 | |
* @summary Registers a new [`onInvalidate`](#computation_oninvalidate) callback on the current computation (which must exist), to be called immediately when the current computation is invalidated or stopped. | |
* @locus Client // 599 | |
* @param {Function} callback A callback function that will be invoked as `func(c)`, where `c` is the computation on which the callback is registered. | |
*/ // 601 | |
Tracker.onInvalidate = function (f) { // 602 | |
if (! Tracker.active) // 603 | |
throw new Error("Tracker.onInvalidate requires a currentComputation"); // 604 | |
// 605 | |
Tracker.currentComputation.onInvalidate(f); // 606 | |
}; // 607 | |
// 608 | |
// http://docs.meteor.com/#tracker_afterflush // 609 | |
// 610 | |
/** // 611 | |
* @summary Schedules a function to be called during the next flush, or later in the current flush if one is in progress, after all invalidated computations have been rerun. The function will be run once and not on subsequent flushes unless `afterFlush` is called again. | |
* @locus Client // 613 | |
* @param {Function} callback A function to call at flush time. // 614 | |
*/ // 615 | |
Tracker.afterFlush = function (f) { // 616 | |
afterFlushCallbacks.push(f); // 617 | |
requireFlush(); // 618 | |
}; // 619 | |
// 620 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/tracker/deprecated.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Deprecated functions. // 1 | |
// 2 | |
// These functions used to be on the Meteor object (and worked slightly // 3 | |
// differently). // 4 | |
// XXX COMPAT WITH 0.5.7 // 5 | |
Meteor.flush = Tracker.flush; // 6 | |
Meteor.autorun = Tracker.autorun; // 7 | |
// 8 | |
// We used to require a special "autosubscribe" call to reactively subscribe to // 9 | |
// things. Now, it works with autorun. // 10 | |
// XXX COMPAT WITH 0.5.4 // 11 | |
Meteor.autosubscribe = Tracker.autorun; // 12 | |
// 13 | |
// This Tracker API briefly existed in 0.5.8 and 0.5.9 // 14 | |
// XXX COMPAT WITH 0.5.9 // 15 | |
Tracker.depend = function (d) { // 16 | |
return d.depend(); // 17 | |
}; // 18 | |
// 19 | |
Deps = Tracker; // 20 | |
// 21 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.tracker = { | |
Tracker: Tracker, | |
Deps: Deps | |
}; | |
/* Package-scope variables */ | |
var IdMap; | |
(function(){ | |
////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/id-map/packages/id-map.js // | |
// // | |
////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
//////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/id-map/id-map.js // // 5 | |
// // // 6 | |
//////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
IdMap = function (idStringify, idParse) { // 1 // 9 | |
var self = this; // 2 // 10 | |
self._map = {}; // 3 // 11 | |
self._idStringify = idStringify || JSON.stringify; // 4 // 12 | |
self._idParse = idParse || JSON.parse; // 5 // 13 | |
}; // 6 // 14 | |
// 7 // 15 | |
// Some of these methods are designed to match methods on OrderedDict, since // 8 // 16 | |
// (eg) ObserveMultiplex and _CachingChangeObserver use them interchangeably. // 17 | |
// (Conceivably, this should be replaced with "UnorderedDict" with a specific // 18 | |
// set of methods that overlap between the two.) // 11 | |
// 12 | |
_.extend(IdMap.prototype, { // 13 | |
get: function (id) { // 14 | |
var self = this; // 15 | |
var key = self._idStringify(id); // 16 | |
return self._map[key]; // 17 | |
}, // 18 | |
set: function (id, value) { // 19 | |
var self = this; // 20 | |
var key = self._idStringify(id); // 21 | |
self._map[key] = value; // 22 | |
}, // 23 | |
remove: function (id) { // 24 | |
var self = this; // 25 | |
var key = self._idStringify(id); // 26 | |
delete self._map[key]; // 27 | |
}, // 28 | |
has: function (id) { // 29 | |
var self = this; // 30 | |
var key = self._idStringify(id); // 31 | |
return _.has(self._map, key); // 32 | |
}, // 33 | |
empty: function () { // 34 | |
var self = this; // 35 | |
return _.isEmpty(self._map); // 36 | |
}, // 37 | |
clear: function () { // 38 | |
var self = this; // 39 | |
self._map = {}; // 40 | |
}, // 41 | |
// Iterates over the items in the map. Return `false` to break the loop. // 42 | |
forEach: function (iterator) { // 43 | |
var self = this; // 44 | |
// don't use _.each, because we can't break out of it. // 45 | |
var keys = _.keys(self._map); // 46 | |
for (var i = 0; i < keys.length; i++) { // 47 | |
var breakIfFalse = iterator.call(null, self._map[keys[i]], // 48 | |
self._idParse(keys[i])); // 49 | |
if (breakIfFalse === false) // 50 | |
return; // 51 | |
} // 52 | |
}, // 53 | |
size: function () { // 54 | |
var self = this; // 55 | |
return _.size(self._map); // 56 | |
}, // 57 | |
setDefault: function (id, def) { // 58 | |
var self = this; // 59 | |
var key = self._idStringify(id); // 60 | |
if (_.has(self._map, key)) // 61 | |
return self._map[key]; // 62 | |
self._map[key] = def; // 63 | |
return def; // 64 | |
}, // 65 | |
// Assumes that values are EJSON-cloneable, and that we don't need to clone // 74 | |
// IDs (ie, that nobody is going to mutate an ObjectId). // 67 | |
clone: function () { // 68 | |
var self = this; // 69 | |
var clone = new IdMap(self._idStringify, self._idParse); // 70 | |
self.forEach(function (value, id) { // 71 | |
clone.set(id, EJSON.clone(value)); // 72 | |
}); // 73 | |
return clone; // 74 | |
} // 75 | |
}); // 76 | |
// 77 | |
// 78 | |
//////////////////////////////////////////////////////////////////////////////// // 87 | |
// 88 | |
}).call(this); // 89 | |
// 90 | |
////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['id-map'] = { | |
IdMap: IdMap | |
}; | |
/* Package-scope variables */ | |
var babelHelpers; | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/babel-runtime/packages/babel-runtime.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/babel-runtime/babel-runtime.js // // 5 | |
// // // 6 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
var hasOwn = Object.prototype.hasOwnProperty; // 1 // 9 | |
// 2 // 10 | |
function canDefineNonEnumerableProperties() { // 3 // 11 | |
var testObj = {}; // 4 // 12 | |
var testPropName = "t"; // 5 // 13 | |
// 6 // 14 | |
try { // 7 // 15 | |
Object.defineProperty(testObj, testPropName, { // 8 // 16 | |
enumerable: false, // 9 // 17 | |
value: testObj // 10 // 18 | |
}); // 11 // 19 | |
// 12 // 20 | |
for (var k in testObj) { // 13 // 21 | |
if (k === testPropName) { // 14 // 22 | |
return false; // 15 // 23 | |
} // 16 // 24 | |
} // 17 // 25 | |
} catch (e) { // 18 // 26 | |
return false; // 19 // 27 | |
} // 20 // 28 | |
// 21 // 29 | |
return testObj[testPropName] === testObj; // 22 // 30 | |
} // 23 // 31 | |
// 24 // 32 | |
// The name `babelHelpers` is hard-coded in Babel. Otherwise we would make it // 25 // 33 | |
// something capitalized and more descriptive, like `BabelRuntime`. // 26 // 34 | |
babelHelpers = { // 27 // 35 | |
// Meteor-specific runtime helper for wrapping the object of for-in // 28 // 36 | |
// loops, so that inherited Array methods defined by es5-shim can be // 29 // 37 | |
// ignored in browsers where they cannot be defined as non-enumerable. // 30 // 38 | |
sanitizeForInObject: canDefineNonEnumerableProperties() // 31 // 39 | |
? function (value) { return value; } // 32 // 40 | |
: function (obj) { // 33 // 41 | |
if (Array.isArray(obj)) { // 34 // 42 | |
var newObj = {}; // 35 // 43 | |
var keys = Object.keys(obj); // 36 // 44 | |
var keyCount = keys.length; // 37 // 45 | |
for (var i = 0; i < keyCount; ++i) { // 38 // 46 | |
var key = keys[i]; // 39 // 47 | |
newObj[key] = obj[key]; // 40 // 48 | |
} // 41 // 49 | |
return newObj; // 42 // 50 | |
} // 43 // 51 | |
// 44 // 52 | |
return obj; // 45 // 53 | |
}, // 46 // 54 | |
// 47 // 55 | |
// es6.templateLiterals // 48 // 56 | |
// Constructs the object passed to the tag function in a tagged // 49 // 57 | |
// template literal. // 50 // 58 | |
taggedTemplateLiteralLoose: function (strings, raw) { // 51 // 59 | |
// Babel's own version of this calls Object.freeze on `strings` and // 52 // 60 | |
// `strings.raw`, but it doesn't seem worth the compatibility and // 53 // 61 | |
// performance concerns. If you're writing code against this helper, // 54 // 62 | |
// don't add properties to these objects. // 55 // 63 | |
strings.raw = raw; // 56 // 64 | |
return strings; // 57 // 65 | |
}, // 58 // 66 | |
// 59 // 67 | |
// es6.classes // 60 // 68 | |
// Checks that a class constructor is being called with `new`, and throws // 61 // 69 | |
// an error if it is not. // 62 // 70 | |
classCallCheck: function (instance, Constructor) { // 63 // 71 | |
if (!(instance instanceof Constructor)) { // 64 // 72 | |
throw new TypeError("Cannot call a class as a function"); // 65 // 73 | |
} // 66 // 74 | |
}, // 67 // 75 | |
// 68 // 76 | |
// es6.classes // 69 // 77 | |
inherits: function (subClass, superClass) { // 70 // 78 | |
if (typeof superClass !== "function" && superClass !== null) { // 71 // 79 | |
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); // 80 | |
} // 73 // 81 | |
// 74 // 82 | |
if (superClass) { // 75 // 83 | |
if (Object.create) { // 76 // 84 | |
// All but IE 8 // 77 // 85 | |
subClass.prototype = Object.create(superClass.prototype, { // 78 // 86 | |
constructor: { // 79 // 87 | |
value: subClass, // 80 // 88 | |
enumerable: false, // 81 // 89 | |
writable: true, // 82 // 90 | |
configurable: true // 83 // 91 | |
} // 84 // 92 | |
}); // 85 // 93 | |
} else { // 86 // 94 | |
// IE 8 path. Slightly worse for modern browsers, because `constructor` // 87 // 95 | |
// is enumerable and shows up in the inspector unnecessarily. // 88 // 96 | |
// It's not an "own" property of any instance though. // 89 // 97 | |
// // 90 // 98 | |
// For correctness when writing code, // 91 // 99 | |
// don't enumerate all the own-and-inherited properties of an instance // 92 // 100 | |
// of a class and expect not to find `constructor` (but who does that?). // 93 // 101 | |
var F = function () { // 94 // 102 | |
this.constructor = subClass; // 95 // 103 | |
}; // 96 // 104 | |
F.prototype = superClass.prototype; // 97 // 105 | |
subClass.prototype = new F(); // 98 // 106 | |
} // 99 // 107 | |
// 100 | |
// For modern browsers, this would be `subClass.__proto__ = superClass`, // 101 | |
// but IE <=10 don't support `__proto__`, and in this case the difference // 102 | |
// would be detectable; code that works in modern browsers could easily // 103 | |
// fail on IE 8 if we ever used the `__proto__` trick. // 104 | |
// // 105 | |
// There's no perfect way to make static methods inherited if they are // 106 | |
// assigned after declaration of the classes. The best we can do is // 107 | |
// to copy them. In other words, when you write `class Foo // 108 | |
// extends Bar`, we copy the static methods from Bar onto Foo, but future // 109 | |
// ones are not copied. // 110 | |
// // 111 | |
// For correctness when writing code, don't add static methods to a class // 112 | |
// after you subclass it. // 113 | |
for (var k in superClass) { // 114 | |
if (hasOwn.call(superClass, k)) { // 115 | |
subClass[k] = superClass[k]; // 116 | |
} // 117 | |
} // 118 | |
} // 119 | |
}, // 120 | |
// 121 | |
createClass: (function () { // 122 | |
var hasDefineProperty = false; // 123 | |
try { // 124 | |
// IE 8 has a broken Object.defineProperty, so feature-test by // 125 | |
// trying to call it. // 126 | |
Object.defineProperty({}, 'x', {}); // 127 | |
hasDefineProperty = true; // 128 | |
} catch (e) {} // 129 | |
// 130 | |
function defineProperties(target, props) { // 131 | |
for (var i = 0; i < props.length; i++) { // 132 | |
var descriptor = props[i]; // 133 | |
descriptor.enumerable = descriptor.enumerable || false; // 134 | |
descriptor.configurable = true; // 135 | |
if ("value" in descriptor) descriptor.writable = true; // 136 | |
Object.defineProperty(target, descriptor.key, descriptor); // 137 | |
} // 138 | |
} // 139 | |
// 140 | |
return function (Constructor, protoProps, staticProps) { // 141 | |
if (! hasDefineProperty) { // 142 | |
// e.g. `class Foo { get bar() {} }`. If you try to use getters and // 143 | |
// setters in IE 8, you will get a big nasty error, with or without // 144 | |
// Babel. I don't know of any other syntax features besides getters // 145 | |
// and setters that will trigger this error. // 146 | |
throw new Error( // 147 | |
"Your browser does not support this type of class property. " + // 148 | |
"For example, Internet Explorer 8 does not support getters and " + // 149 | |
"setters."); // 150 | |
} // 151 | |
// 152 | |
if (protoProps) defineProperties(Constructor.prototype, protoProps); // 153 | |
if (staticProps) defineProperties(Constructor, staticProps); // 154 | |
return Constructor; // 155 | |
}; // 156 | |
})(), // 157 | |
// 158 | |
// es7.objectRestSpread and react (JSX) // 159 | |
_extends: Object.assign || (function (target) { // 160 | |
for (var i = 1; i < arguments.length; i++) { // 161 | |
var source = arguments[i]; // 162 | |
for (var key in source) { // 163 | |
if (hasOwn.call(source, key)) { // 164 | |
target[key] = source[key]; // 165 | |
} // 166 | |
} // 167 | |
} // 168 | |
return target; // 169 | |
}), // 170 | |
// 171 | |
// es6.destructuring // 172 | |
objectWithoutProperties: function (obj, keys) { // 173 | |
var target = {}; // 174 | |
outer: for (var i in obj) { // 175 | |
if (! hasOwn.call(obj, i)) continue; // 176 | |
for (var j = 0; j < keys.length; j++) { // 177 | |
if (keys[j] === i) continue outer; // 178 | |
} // 179 | |
target[i] = obj[i]; // 180 | |
} // 181 | |
return target; // 182 | |
}, // 183 | |
// 184 | |
// es6.destructuring // 185 | |
objectDestructuringEmpty: function (obj) { // 186 | |
if (obj == null) throw new TypeError("Cannot destructure undefined"); // 187 | |
}, // 188 | |
// 189 | |
// es6.spread // 190 | |
bind: Function.prototype.bind || (function () { // 191 | |
var isCallable = function (value) { return typeof value === 'function'; }; // 192 | |
var $Object = Object; // 193 | |
var to_string = Object.prototype.toString; // 194 | |
var array_slice = Array.prototype.slice; // 195 | |
var array_concat = Array.prototype.concat; // 196 | |
var array_push = Array.prototype.push; // 197 | |
var max = Math.max; // 198 | |
var Empty = function Empty() {}; // 199 | |
// 200 | |
// Copied from es5-shim.js (3ac7942). See original for more comments. // 201 | |
return function bind(that) { // 202 | |
var target = this; // 203 | |
if (!isCallable(target)) { // 204 | |
throw new TypeError('Function.prototype.bind called on incompatible ' + target); // 205 | |
} // 206 | |
// 207 | |
var args = array_slice.call(arguments, 1); // 208 | |
// 209 | |
var bound; // 210 | |
var binder = function () { // 211 | |
// 212 | |
if (this instanceof bound) { // 213 | |
var result = target.apply( // 214 | |
this, // 215 | |
array_concat.call(args, array_slice.call(arguments)) // 216 | |
); // 217 | |
if ($Object(result) === result) { // 218 | |
return result; // 219 | |
} // 220 | |
return this; // 221 | |
} else { // 222 | |
return target.apply( // 223 | |
that, // 224 | |
array_concat.call(args, array_slice.call(arguments)) // 225 | |
); // 226 | |
} // 227 | |
}; // 228 | |
// 229 | |
var boundLength = max(0, target.length - args.length); // 230 | |
// 231 | |
var boundArgs = []; // 232 | |
for (var i = 0; i < boundLength; i++) { // 233 | |
array_push.call(boundArgs, '$' + i); // 234 | |
} // 235 | |
// 236 | |
// Create a Function from source code so that it has the right `.length`. // 237 | |
// Probably not important for Babel. This code violates CSPs that ban // 238 | |
// `eval`, but the browsers that need this polyfill don't have CSP! // 239 | |
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder); | |
// 241 | |
if (target.prototype) { // 242 | |
Empty.prototype = target.prototype; // 243 | |
bound.prototype = new Empty(); // 244 | |
Empty.prototype = null; // 245 | |
} // 246 | |
// 247 | |
return bound; // 248 | |
}; // 249 | |
// 250 | |
})(), // 251 | |
// 252 | |
slice: Array.prototype.slice // 253 | |
}; // 254 | |
// 255 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 264 | |
// 265 | |
}).call(this); // 266 | |
// 267 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['babel-runtime'] = { | |
babelHelpers: babelHelpers | |
}; | |
/* Package-scope variables */ | |
var Symbol, Map, Set, __g, __e; | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/ecmascript-runtime/.npm/package/node_modules/meteor-ecmascript-runtime/client.js // | |
// This file is in bare mode and is not in its own closure. // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
/******/ (function(modules) { // webpackBootstrap // 1 | |
/******/ // The module cache // 2 | |
/******/ var installedModules = {}; // 3 | |
// 4 | |
/******/ // The require function // 5 | |
/******/ function __webpack_require__(moduleId) { // 6 | |
// 7 | |
/******/ // Check if module is in cache // 8 | |
/******/ if(installedModules[moduleId]) // 9 | |
/******/ return installedModules[moduleId].exports; // 10 | |
// 11 | |
/******/ // Create a new module (and put it into the cache) // 12 | |
/******/ var module = installedModules[moduleId] = { // 13 | |
/******/ exports: {}, // 14 | |
/******/ id: moduleId, // 15 | |
/******/ loaded: false // 16 | |
/******/ }; // 17 | |
// 18 | |
/******/ // Execute the module function // 19 | |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); // 20 | |
// 21 | |
/******/ // Flag the module as loaded // 22 | |
/******/ module.loaded = true; // 23 | |
// 24 | |
/******/ // Return the exports of the module // 25 | |
/******/ return module.exports; // 26 | |
/******/ } // 27 | |
// 28 | |
// 29 | |
/******/ // expose the modules object (__webpack_modules__) // 30 | |
/******/ __webpack_require__.m = modules; // 31 | |
// 32 | |
/******/ // expose the module cache // 33 | |
/******/ __webpack_require__.c = installedModules; // 34 | |
// 35 | |
/******/ // __webpack_public_path__ // 36 | |
/******/ __webpack_require__.p = ""; // 37 | |
// 38 | |
/******/ // Load entry module and return exports // 39 | |
/******/ return __webpack_require__(0); // 40 | |
/******/ }) // 41 | |
/************************************************************************/ // 42 | |
/******/ ([ // 43 | |
/* 0 */ // 44 | |
/***/ function(module, exports, __webpack_require__) { // 45 | |
// 46 | |
__webpack_require__(1); // 47 | |
__webpack_require__(50); // 48 | |
__webpack_require__(77); // 49 | |
__webpack_require__(96); // 50 | |
// 51 | |
Symbol = exports.Symbol = __webpack_require__(99); // 52 | |
Map = exports.Map = __webpack_require__(100); // 53 | |
Set = exports.Set = __webpack_require__(108); // 54 | |
// 55 | |
// 56 | |
/***/ }, // 57 | |
/* 1 */ // 58 | |
/***/ function(module, exports, __webpack_require__) { // 59 | |
// 60 | |
__webpack_require__(2); // 61 | |
__webpack_require__(28); // 62 | |
__webpack_require__(31); // 63 | |
__webpack_require__(33); // 64 | |
__webpack_require__(37); // 65 | |
__webpack_require__(39); // 66 | |
__webpack_require__(41); // 67 | |
__webpack_require__(42); // 68 | |
__webpack_require__(43); // 69 | |
__webpack_require__(44); // 70 | |
__webpack_require__(45); // 71 | |
__webpack_require__(46); // 72 | |
__webpack_require__(47); // 73 | |
__webpack_require__(48); // 74 | |
__webpack_require__(49); // 75 | |
// 76 | |
module.exports = __webpack_require__(9).Object; // 77 | |
// 78 | |
/***/ }, // 79 | |
/* 2 */ // 80 | |
/***/ function(module, exports, __webpack_require__) { // 81 | |
// 82 | |
'use strict'; // 83 | |
// ECMAScript 6 symbols shim // 84 | |
var $ = __webpack_require__(3) // 85 | |
, global = __webpack_require__(4) // 86 | |
, has = __webpack_require__(5) // 87 | |
, SUPPORT_DESC = __webpack_require__(6) // 88 | |
, $def = __webpack_require__(8) // 89 | |
, $redef = __webpack_require__(12) // 90 | |
, $fails = __webpack_require__(7) // 91 | |
, shared = __webpack_require__(14) // 92 | |
, setTag = __webpack_require__(15) // 93 | |
, uid = __webpack_require__(13) // 94 | |
, wks = __webpack_require__(16) // 95 | |
, keyOf = __webpack_require__(17) // 96 | |
, $names = __webpack_require__(22) // 97 | |
, enumKeys = __webpack_require__(23) // 98 | |
, isArray = __webpack_require__(24) // 99 | |
, isObject = __webpack_require__(25) // 100 | |
, anObject = __webpack_require__(26) // 101 | |
, toIObject = __webpack_require__(18) // 102 | |
, createDesc = __webpack_require__(11) // 103 | |
, getDesc = $.getDesc // 104 | |
, setDesc = $.setDesc // 105 | |
, _create = $.create // 106 | |
, getNames = $names.get // 107 | |
, $Symbol = global.Symbol // 108 | |
, $JSON = global.JSON // 109 | |
, _stringify = $JSON && $JSON.stringify // 110 | |
, setter = false // 111 | |
, HIDDEN = wks('_hidden') // 112 | |
, isEnum = $.isEnum // 113 | |
, SymbolRegistry = shared('symbol-registry') // 114 | |
, AllSymbols = shared('symbols') // 115 | |
, useNative = typeof $Symbol == 'function' // 116 | |
, ObjectProto = Object.prototype; // 117 | |
// 118 | |
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 // 119 | |
var setSymbolDesc = SUPPORT_DESC && $fails(function(){ // 120 | |
return _create(setDesc({}, 'a', { // 121 | |
get: function(){ return setDesc(this, 'a', {value: 7}).a; } // 122 | |
})).a != 7; // 123 | |
}) ? function(it, key, D){ // 124 | |
var protoDesc = getDesc(ObjectProto, key); // 125 | |
if(protoDesc)delete ObjectProto[key]; // 126 | |
setDesc(it, key, D); // 127 | |
if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc); // 128 | |
} : setDesc; // 129 | |
// 130 | |
var wrap = function(tag){ // 131 | |
var sym = AllSymbols[tag] = _create($Symbol.prototype); // 132 | |
sym._k = tag; // 133 | |
SUPPORT_DESC && setter && setSymbolDesc(ObjectProto, tag, { // 134 | |
configurable: true, // 135 | |
set: function(value){ // 136 | |
if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; // 137 | |
setSymbolDesc(this, tag, createDesc(1, value)); // 138 | |
} // 139 | |
}); // 140 | |
return sym; // 141 | |
}; // 142 | |
// 143 | |
var isSymbol = function(it){ // 144 | |
return typeof it == 'symbol'; // 145 | |
}; // 146 | |
// 147 | |
var $defineProperty = function defineProperty(it, key, D){ // 148 | |
if(D && has(AllSymbols, key)){ // 149 | |
if(!D.enumerable){ // 150 | |
if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {})); // 151 | |
it[HIDDEN][key] = true; // 152 | |
} else { // 153 | |
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; // 154 | |
D = _create(D, {enumerable: createDesc(0, false)}); // 155 | |
} return setSymbolDesc(it, key, D); // 156 | |
} return setDesc(it, key, D); // 157 | |
}; // 158 | |
var $defineProperties = function defineProperties(it, P){ // 159 | |
anObject(it); // 160 | |
var keys = enumKeys(P = toIObject(P)) // 161 | |
, i = 0 // 162 | |
, l = keys.length // 163 | |
, key; // 164 | |
while(l > i)$defineProperty(it, key = keys[i++], P[key]); // 165 | |
return it; // 166 | |
}; // 167 | |
var $create = function create(it, P){ // 168 | |
return P === undefined ? _create(it) : $defineProperties(_create(it), P); // 169 | |
}; // 170 | |
var $propertyIsEnumerable = function propertyIsEnumerable(key){ // 171 | |
var E = isEnum.call(this, key); // 172 | |
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] // 173 | |
? E : true; // 174 | |
}; // 175 | |
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){ // 176 | |
var D = getDesc(it = toIObject(it), key); // 177 | |
if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true; // 178 | |
return D; // 179 | |
}; // 180 | |
var $getOwnPropertyNames = function getOwnPropertyNames(it){ // 181 | |
var names = getNames(toIObject(it)) // 182 | |
, result = [] // 183 | |
, i = 0 // 184 | |
, key; // 185 | |
while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key); // 186 | |
return result; // 187 | |
}; // 188 | |
var $getOwnPropertySymbols = function getOwnPropertySymbols(it){ // 189 | |
var names = getNames(toIObject(it)) // 190 | |
, result = [] // 191 | |
, i = 0 // 192 | |
, key; // 193 | |
while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]); // 194 | |
return result; // 195 | |
}; // 196 | |
var $stringify = function stringify(it){ // 197 | |
var args = [it] // 198 | |
, i = 1 // 199 | |
, replacer, $replacer; // 200 | |
while(arguments.length > i)args.push(arguments[i++]); // 201 | |
replacer = args[1]; // 202 | |
if(typeof replacer == 'function')$replacer = replacer; // 203 | |
if($replacer || !isArray(replacer))replacer = function(key, value){ // 204 | |
if($replacer)value = $replacer.call(this, key, value); // 205 | |
if(!isSymbol(value))return value; // 206 | |
}; // 207 | |
args[1] = replacer; // 208 | |
return _stringify.apply($JSON, args); // 209 | |
}; // 210 | |
var buggyJSON = $fails(function(){ // 211 | |
var S = $Symbol(); // 212 | |
// MS Edge converts symbol values to JSON as {} // 213 | |
// WebKit converts symbol values to JSON as null // 214 | |
// V8 throws on boxed symbols // 215 | |
return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}'; // 216 | |
}); // 217 | |
// 218 | |
// 19.4.1.1 Symbol([description]) // 219 | |
if(!useNative){ // 220 | |
$Symbol = function Symbol(){ // 221 | |
if(isSymbol(this))throw TypeError('Symbol is not a constructor'); // 222 | |
return wrap(uid(arguments[0])); // 223 | |
}; // 224 | |
$redef($Symbol.prototype, 'toString', function toString(){ // 225 | |
return this._k; // 226 | |
}); // 227 | |
// 228 | |
isSymbol = function(it){ // 229 | |
return it instanceof $Symbol; // 230 | |
}; // 231 | |
// 232 | |
$.create = $create; // 233 | |
$.isEnum = $propertyIsEnumerable; // 234 | |
$.getDesc = $getOwnPropertyDescriptor; // 235 | |
$.setDesc = $defineProperty; // 236 | |
$.setDescs = $defineProperties; // 237 | |
$.getNames = $names.get = $getOwnPropertyNames; // 238 | |
$.getSymbols = $getOwnPropertySymbols; // 239 | |
// 240 | |
if(SUPPORT_DESC && !__webpack_require__(27)){ // 241 | |
$redef(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); // 242 | |
} // 243 | |
} // 244 | |
// 245 | |
var symbolStatics = { // 246 | |
// 19.4.2.1 Symbol.for(key) // 247 | |
'for': function(key){ // 248 | |
return has(SymbolRegistry, key += '') // 249 | |
? SymbolRegistry[key] // 250 | |
: SymbolRegistry[key] = $Symbol(key); // 251 | |
}, // 252 | |
// 19.4.2.5 Symbol.keyFor(sym) // 253 | |
keyFor: function keyFor(key){ // 254 | |
return keyOf(SymbolRegistry, key); // 255 | |
}, // 256 | |
useSetter: function(){ setter = true; }, // 257 | |
useSimple: function(){ setter = false; } // 258 | |
}; // 259 | |
// 19.4.2.2 Symbol.hasInstance // 260 | |
// 19.4.2.3 Symbol.isConcatSpreadable // 261 | |
// 19.4.2.4 Symbol.iterator // 262 | |
// 19.4.2.6 Symbol.match // 263 | |
// 19.4.2.8 Symbol.replace // 264 | |
// 19.4.2.9 Symbol.search // 265 | |
// 19.4.2.10 Symbol.species // 266 | |
// 19.4.2.11 Symbol.split // 267 | |
// 19.4.2.12 Symbol.toPrimitive // 268 | |
// 19.4.2.13 Symbol.toStringTag // 269 | |
// 19.4.2.14 Symbol.unscopables // 270 | |
$.each.call(( // 271 | |
'hasInstance,isConcatSpreadable,iterator,match,replace,search,' + // 272 | |
'species,split,toPrimitive,toStringTag,unscopables' // 273 | |
).split(','), function(it){ // 274 | |
var sym = wks(it); // 275 | |
symbolStatics[it] = useNative ? sym : wrap(sym); // 276 | |
} // 277 | |
); // 278 | |
// 279 | |
setter = true; // 280 | |
// 281 | |
$def($def.G + $def.W, {Symbol: $Symbol}); // 282 | |
// 283 | |
$def($def.S, 'Symbol', symbolStatics); // 284 | |
// 285 | |
$def($def.S + $def.F * !useNative, 'Object', { // 286 | |
// 19.1.2.2 Object.create(O [, Properties]) // 287 | |
create: $create, // 288 | |
// 19.1.2.4 Object.defineProperty(O, P, Attributes) // 289 | |
defineProperty: $defineProperty, // 290 | |
// 19.1.2.3 Object.defineProperties(O, Properties) // 291 | |
defineProperties: $defineProperties, // 292 | |
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) // 293 | |
getOwnPropertyDescriptor: $getOwnPropertyDescriptor, // 294 | |
// 19.1.2.7 Object.getOwnPropertyNames(O) // 295 | |
getOwnPropertyNames: $getOwnPropertyNames, // 296 | |
// 19.1.2.8 Object.getOwnPropertySymbols(O) // 297 | |
getOwnPropertySymbols: $getOwnPropertySymbols // 298 | |
}); // 299 | |
// 300 | |
// 24.3.2 JSON.stringify(value [, replacer [, space]]) // 301 | |
$JSON && $def($def.S + $def.F * (!useNative || buggyJSON), 'JSON', {stringify: $stringify}); // 302 | |
// 303 | |
// 19.4.3.5 Symbol.prototype[@@toStringTag] // 304 | |
setTag($Symbol, 'Symbol'); // 305 | |
// 20.2.1.9 Math[@@toStringTag] // 306 | |
setTag(Math, 'Math', true); // 307 | |
// 24.3.3 JSON[@@toStringTag] // 308 | |
setTag(global.JSON, 'JSON', true); // 309 | |
// 310 | |
/***/ }, // 311 | |
/* 3 */ // 312 | |
/***/ function(module, exports) { // 313 | |
// 314 | |
var $Object = Object; // 315 | |
module.exports = { // 316 | |
create: $Object.create, // 317 | |
getProto: $Object.getPrototypeOf, // 318 | |
isEnum: {}.propertyIsEnumerable, // 319 | |
getDesc: $Object.getOwnPropertyDescriptor, // 320 | |
setDesc: $Object.defineProperty, // 321 | |
setDescs: $Object.defineProperties, // 322 | |
getKeys: $Object.keys, // 323 | |
getNames: $Object.getOwnPropertyNames, // 324 | |
getSymbols: $Object.getOwnPropertySymbols, // 325 | |
each: [].forEach // 326 | |
}; // 327 | |
// 328 | |
/***/ }, // 329 | |
/* 4 */ // 330 | |
/***/ function(module, exports) { // 331 | |
// 332 | |
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 // 333 | |
var UNDEFINED = 'undefined'; // 334 | |
var global = module.exports = typeof window != UNDEFINED && window.Math == Math // 335 | |
? window : typeof self != UNDEFINED && self.Math == Math ? self : Function('return this')(); // 336 | |
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef // 337 | |
// 338 | |
/***/ }, // 339 | |
/* 5 */ // 340 | |
/***/ function(module, exports) { // 341 | |
// 342 | |
var hasOwnProperty = {}.hasOwnProperty; // 343 | |
module.exports = function(it, key){ // 344 | |
return hasOwnProperty.call(it, key); // 345 | |
}; // 346 | |
// 347 | |
/***/ }, // 348 | |
/* 6 */ // 349 | |
/***/ function(module, exports, __webpack_require__) { // 350 | |
// 351 | |
// Thank's IE8 for his funny defineProperty // 352 | |
module.exports = !__webpack_require__(7)(function(){ // 353 | |
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; // 354 | |
}); // 355 | |
// 356 | |
/***/ }, // 357 | |
/* 7 */ // 358 | |
/***/ function(module, exports) { // 359 | |
// 360 | |
module.exports = function(exec){ // 361 | |
try { // 362 | |
return !!exec(); // 363 | |
} catch(e){ // 364 | |
return true; // 365 | |
} // 366 | |
}; // 367 | |
// 368 | |
/***/ }, // 369 | |
/* 8 */ // 370 | |
/***/ function(module, exports, __webpack_require__) { // 371 | |
// 372 | |
var global = __webpack_require__(4) // 373 | |
, core = __webpack_require__(9) // 374 | |
, hide = __webpack_require__(10) // 375 | |
, $redef = __webpack_require__(12) // 376 | |
, PROTOTYPE = 'prototype'; // 377 | |
var ctx = function(fn, that){ // 378 | |
return function(){ // 379 | |
return fn.apply(that, arguments); // 380 | |
}; // 381 | |
}; // 382 | |
var $def = function(type, name, source){ // 383 | |
var key, own, out, exp // 384 | |
, isGlobal = type & $def.G // 385 | |
, isProto = type & $def.P // 386 | |
, target = isGlobal ? global : type & $def.S // 387 | |
? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] // 388 | |
, exports = isGlobal ? core : core[name] || (core[name] = {}); // 389 | |
if(isGlobal)source = name; // 390 | |
for(key in source){ // 391 | |
// contains in native // 392 | |
own = !(type & $def.F) && target && key in target; // 393 | |
// export native or passed // 394 | |
out = (own ? target : source)[key]; // 395 | |
// bind timers to global for call from export context // 396 | |
if(type & $def.B && own)exp = ctx(out, global); // 397 | |
else exp = isProto && typeof out == 'function' ? ctx(Function.call, out) : out; // 398 | |
// extend global // 399 | |
if(target && !own)$redef(target, key, out); // 400 | |
// export // 401 | |
if(exports[key] != out)hide(exports, key, exp); // 402 | |
if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; // 403 | |
} // 404 | |
}; // 405 | |
global.core = core; // 406 | |
// type bitmap // 407 | |
$def.F = 1; // forced // 408 | |
$def.G = 2; // global // 409 | |
$def.S = 4; // static // 410 | |
$def.P = 8; // proto // 411 | |
$def.B = 16; // bind // 412 | |
$def.W = 32; // wrap // 413 | |
module.exports = $def; // 414 | |
// 415 | |
/***/ }, // 416 | |
/* 9 */ // 417 | |
/***/ function(module, exports) { // 418 | |
// 419 | |
var core = module.exports = {version: '1.2.1'}; // 420 | |
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef // 421 | |
// 422 | |
/***/ }, // 423 | |
/* 10 */ // 424 | |
/***/ function(module, exports, __webpack_require__) { // 425 | |
// 426 | |
var $ = __webpack_require__(3) // 427 | |
, createDesc = __webpack_require__(11); // 428 | |
module.exports = __webpack_require__(6) ? function(object, key, value){ // 429 | |
return $.setDesc(object, key, createDesc(1, value)); // 430 | |
} : function(object, key, value){ // 431 | |
object[key] = value; // 432 | |
return object; // 433 | |
}; // 434 | |
// 435 | |
/***/ }, // 436 | |
/* 11 */ // 437 | |
/***/ function(module, exports) { // 438 | |
// 439 | |
module.exports = function(bitmap, value){ // 440 | |
return { // 441 | |
enumerable : !(bitmap & 1), // 442 | |
configurable: !(bitmap & 2), // 443 | |
writable : !(bitmap & 4), // 444 | |
value : value // 445 | |
}; // 446 | |
}; // 447 | |
// 448 | |
/***/ }, // 449 | |
/* 12 */ // 450 | |
/***/ function(module, exports, __webpack_require__) { // 451 | |
// 452 | |
// add fake Function#toString // 453 | |
// for correct work wrapped methods / constructors with methods like LoDash isNative // 454 | |
var global = __webpack_require__(4) // 455 | |
, hide = __webpack_require__(10) // 456 | |
, SRC = __webpack_require__(13)('src') // 457 | |
, TO_STRING = 'toString' // 458 | |
, $toString = Function[TO_STRING] // 459 | |
, TPL = ('' + $toString).split(TO_STRING); // 460 | |
// 461 | |
__webpack_require__(9).inspectSource = function(it){ // 462 | |
return $toString.call(it); // 463 | |
}; // 464 | |
// 465 | |
(module.exports = function(O, key, val, safe){ // 466 | |
if(typeof val == 'function'){ // 467 | |
hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); // 468 | |
if(!('name' in val))val.name = key; // 469 | |
} // 470 | |
if(O === global){ // 471 | |
O[key] = val; // 472 | |
} else { // 473 | |
if(!safe)delete O[key]; // 474 | |
hide(O, key, val); // 475 | |
} // 476 | |
})(Function.prototype, TO_STRING, function toString(){ // 477 | |
return typeof this == 'function' && this[SRC] || $toString.call(this); // 478 | |
}); // 479 | |
// 480 | |
/***/ }, // 481 | |
/* 13 */ // 482 | |
/***/ function(module, exports) { // 483 | |
// 484 | |
var id = 0 // 485 | |
, px = Math.random(); // 486 | |
module.exports = function(key){ // 487 | |
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); // 488 | |
}; // 489 | |
// 490 | |
/***/ }, // 491 | |
/* 14 */ // 492 | |
/***/ function(module, exports, __webpack_require__) { // 493 | |
// 494 | |
var global = __webpack_require__(4) // 495 | |
, SHARED = '__core-js_shared__' // 496 | |
, store = global[SHARED] || (global[SHARED] = {}); // 497 | |
module.exports = function(key){ // 498 | |
return store[key] || (store[key] = {}); // 499 | |
}; // 500 | |
// 501 | |
/***/ }, // 502 | |
/* 15 */ // 503 | |
/***/ function(module, exports, __webpack_require__) { // 504 | |
// 505 | |
var has = __webpack_require__(5) // 506 | |
, hide = __webpack_require__(10) // 507 | |
, TAG = __webpack_require__(16)('toStringTag'); // 508 | |
// 509 | |
module.exports = function(it, tag, stat){ // 510 | |
if(it && !has(it = stat ? it : it.prototype, TAG))hide(it, TAG, tag); // 511 | |
}; // 512 | |
// 513 | |
/***/ }, // 514 | |
/* 16 */ // 515 | |
/***/ function(module, exports, __webpack_require__) { // 516 | |
// 517 | |
var store = __webpack_require__(14)('wks') // 518 | |
, Symbol = __webpack_require__(4).Symbol; // 519 | |
module.exports = function(name){ // 520 | |
return store[name] || (store[name] = // 521 | |
Symbol && Symbol[name] || (Symbol || __webpack_require__(13))('Symbol.' + name)); // 522 | |
}; // 523 | |
// 524 | |
/***/ }, // 525 | |
/* 17 */ // 526 | |
/***/ function(module, exports, __webpack_require__) { // 527 | |
// 528 | |
var $ = __webpack_require__(3) // 529 | |
, toIObject = __webpack_require__(18); // 530 | |
module.exports = function(object, el){ // 531 | |
var O = toIObject(object) // 532 | |
, keys = $.getKeys(O) // 533 | |
, length = keys.length // 534 | |
, index = 0 // 535 | |
, key; // 536 | |
while(length > index)if(O[key = keys[index++]] === el)return key; // 537 | |
}; // 538 | |
// 539 | |
/***/ }, // 540 | |
/* 18 */ // 541 | |
/***/ function(module, exports, __webpack_require__) { // 542 | |
// 543 | |
// to indexed object, toObject with fallback for non-array-like ES3 strings // 544 | |
var IObject = __webpack_require__(19) // 545 | |
, defined = __webpack_require__(21); // 546 | |
module.exports = function(it){ // 547 | |
return IObject(defined(it)); // 548 | |
}; // 549 | |
// 550 | |
/***/ }, // 551 | |
/* 19 */ // 552 | |
/***/ function(module, exports, __webpack_require__) { // 553 | |
// 554 | |
// indexed object, fallback for non-array-like ES3 strings // 555 | |
var cof = __webpack_require__(20); // 556 | |
module.exports = 0 in Object('z') ? Object : function(it){ // 557 | |
return cof(it) == 'String' ? it.split('') : Object(it); // 558 | |
}; // 559 | |
// 560 | |
/***/ }, // 561 | |
/* 20 */ // 562 | |
/***/ function(module, exports) { // 563 | |
// 564 | |
var toString = {}.toString; // 565 | |
// 566 | |
module.exports = function(it){ // 567 | |
return toString.call(it).slice(8, -1); // 568 | |
}; // 569 | |
// 570 | |
/***/ }, // 571 | |
/* 21 */ // 572 | |
/***/ function(module, exports) { // 573 | |
// 574 | |
// 7.2.1 RequireObjectCoercible(argument) // 575 | |
module.exports = function(it){ // 576 | |
if(it == undefined)throw TypeError("Can't call method on " + it); // 577 | |
return it; // 578 | |
}; // 579 | |
// 580 | |
/***/ }, // 581 | |
/* 22 */ // 582 | |
/***/ function(module, exports, __webpack_require__) { // 583 | |
// 584 | |
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window // 585 | |
var toString = {}.toString // 586 | |
, toIObject = __webpack_require__(18) // 587 | |
, getNames = __webpack_require__(3).getNames; // 588 | |
// 589 | |
var windowNames = typeof window == 'object' && Object.getOwnPropertyNames // 590 | |
? Object.getOwnPropertyNames(window) : []; // 591 | |
// 592 | |
var getWindowNames = function(it){ // 593 | |
try { // 594 | |
return getNames(it); // 595 | |
} catch(e){ // 596 | |
return windowNames.slice(); // 597 | |
} // 598 | |
}; // 599 | |
// 600 | |
module.exports.get = function getOwnPropertyNames(it){ // 601 | |
if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it); // 602 | |
return getNames(toIObject(it)); // 603 | |
}; // 604 | |
// 605 | |
/***/ }, // 606 | |
/* 23 */ // 607 | |
/***/ function(module, exports, __webpack_require__) { // 608 | |
// 609 | |
// all enumerable object keys, includes symbols // 610 | |
var $ = __webpack_require__(3); // 611 | |
module.exports = function(it){ // 612 | |
var keys = $.getKeys(it) // 613 | |
, getSymbols = $.getSymbols; // 614 | |
if(getSymbols){ // 615 | |
var symbols = getSymbols(it) // 616 | |
, isEnum = $.isEnum // 617 | |
, i = 0 // 618 | |
, key; // 619 | |
while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key); // 620 | |
} // 621 | |
return keys; // 622 | |
}; // 623 | |
// 624 | |
/***/ }, // 625 | |
/* 24 */ // 626 | |
/***/ function(module, exports, __webpack_require__) { // 627 | |
// 628 | |
// 7.2.2 IsArray(argument) // 629 | |
var cof = __webpack_require__(20); // 630 | |
module.exports = Array.isArray || function(arg){ // 631 | |
return cof(arg) == 'Array'; // 632 | |
}; // 633 | |
// 634 | |
/***/ }, // 635 | |
/* 25 */ // 636 | |
/***/ function(module, exports) { // 637 | |
// 638 | |
module.exports = function(it){ // 639 | |
return typeof it === 'object' ? it !== null : typeof it === 'function'; // 640 | |
}; // 641 | |
// 642 | |
/***/ }, // 643 | |
/* 26 */ // 644 | |
/***/ function(module, exports, __webpack_require__) { // 645 | |
// 646 | |
var isObject = __webpack_require__(25); // 647 | |
module.exports = function(it){ // 648 | |
if(!isObject(it))throw TypeError(it + ' is not an object!'); // 649 | |
return it; // 650 | |
}; // 651 | |
// 652 | |
/***/ }, // 653 | |
/* 27 */ // 654 | |
/***/ function(module, exports) { // 655 | |
// 656 | |
module.exports = false; // 657 | |
// 658 | |
/***/ }, // 659 | |
/* 28 */ // 660 | |
/***/ function(module, exports, __webpack_require__) { // 661 | |
// 662 | |
// 19.1.3.1 Object.assign(target, source) // 663 | |
var $def = __webpack_require__(8); // 664 | |
// 665 | |
$def($def.S + $def.F, 'Object', {assign: __webpack_require__(29)}); // 666 | |
// 667 | |
/***/ }, // 668 | |
/* 29 */ // 669 | |
/***/ function(module, exports, __webpack_require__) { // 670 | |
// 671 | |
// 19.1.2.1 Object.assign(target, source, ...) // 672 | |
var toObject = __webpack_require__(30) // 673 | |
, IObject = __webpack_require__(19) // 674 | |
, enumKeys = __webpack_require__(23) // 675 | |
, has = __webpack_require__(5); // 676 | |
// 677 | |
// should work with symbols and should have deterministic property order (V8 bug) // 678 | |
module.exports = __webpack_require__(7)(function(){ // 679 | |
var a = Object.assign // 680 | |
, A = {} // 681 | |
, B = {} // 682 | |
, S = Symbol() // 683 | |
, K = 'abcdefghijklmnopqrst'; // 684 | |
A[S] = 7; // 685 | |
K.split('').forEach(function(k){ B[k] = k; }); // 686 | |
return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; // 687 | |
}) ? function assign(target, source){ // eslint-disable-line no-unused-vars // 688 | |
var T = toObject(target) // 689 | |
, l = arguments.length // 690 | |
, i = 1; // 691 | |
while(l > i){ // 692 | |
var S = IObject(arguments[i++]) // 693 | |
, keys = enumKeys(S) // 694 | |
, length = keys.length // 695 | |
, j = 0 // 696 | |
, key; // 697 | |
while(length > j)if(has(S, key = keys[j++]))T[key] = S[key]; // 698 | |
} // 699 | |
return T; // 700 | |
} : Object.assign; // 701 | |
// 702 | |
/***/ }, // 703 | |
/* 30 */ // 704 | |
/***/ function(module, exports, __webpack_require__) { // 705 | |
// 706 | |
// 7.1.13 ToObject(argument) // 707 | |
var defined = __webpack_require__(21); // 708 | |
module.exports = function(it){ // 709 | |
return Object(defined(it)); // 710 | |
}; // 711 | |
// 712 | |
/***/ }, // 713 | |
/* 31 */ // 714 | |
/***/ function(module, exports, __webpack_require__) { // 715 | |
// 716 | |
// 19.1.3.10 Object.is(value1, value2) // 717 | |
var $def = __webpack_require__(8); // 718 | |
$def($def.S, 'Object', { // 719 | |
is: __webpack_require__(32) // 720 | |
}); // 721 | |
// 722 | |
/***/ }, // 723 | |
/* 32 */ // 724 | |
/***/ function(module, exports) { // 725 | |
// 726 | |
module.exports = Object.is || function is(x, y){ // 727 | |
return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; // 728 | |
}; // 729 | |
// 730 | |
/***/ }, // 731 | |
/* 33 */ // 732 | |
/***/ function(module, exports, __webpack_require__) { // 733 | |
// 734 | |
// 19.1.3.19 Object.setPrototypeOf(O, proto) // 735 | |
var $def = __webpack_require__(8); // 736 | |
$def($def.S, 'Object', {setPrototypeOf: __webpack_require__(34).set}); // 737 | |
// 738 | |
/***/ }, // 739 | |
/* 34 */ // 740 | |
/***/ function(module, exports, __webpack_require__) { // 741 | |
// 742 | |
// Works with __proto__ only. Old v8 can't work with null proto objects. // 743 | |
/* eslint-disable no-proto */ // 744 | |
var getDesc = __webpack_require__(3).getDesc // 745 | |
, isObject = __webpack_require__(25) // 746 | |
, anObject = __webpack_require__(26); // 747 | |
var check = function(O, proto){ // 748 | |
anObject(O); // 749 | |
if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!"); // 750 | |
}; // 751 | |
module.exports = { // 752 | |
set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line no-proto // 753 | |
function(test, buggy, set){ // 754 | |
try { // 755 | |
set = __webpack_require__(35)(Function.call, getDesc(Object.prototype, '__proto__').set, 2); // 756 | |
set(test, []); // 757 | |
buggy = !(test instanceof Array); // 758 | |
} catch(e){ buggy = true; } // 759 | |
return function setPrototypeOf(O, proto){ // 760 | |
check(O, proto); // 761 | |
if(buggy)O.__proto__ = proto; // 762 | |
else set(O, proto); // 763 | |
return O; // 764 | |
}; // 765 | |
}({}, false) : undefined), // 766 | |
check: check // 767 | |
}; // 768 | |
// 769 | |
/***/ }, // 770 | |
/* 35 */ // 771 | |
/***/ function(module, exports, __webpack_require__) { // 772 | |
// 773 | |
// optional / simple context binding // 774 | |
var aFunction = __webpack_require__(36); // 775 | |
module.exports = function(fn, that, length){ // 776 | |
aFunction(fn); // 777 | |
if(that === undefined)return fn; // 778 | |
switch(length){ // 779 | |
case 1: return function(a){ // 780 | |
return fn.call(that, a); // 781 | |
}; // 782 | |
case 2: return function(a, b){ // 783 | |
return fn.call(that, a, b); // 784 | |
}; // 785 | |
case 3: return function(a, b, c){ // 786 | |
return fn.call(that, a, b, c); // 787 | |
}; // 788 | |
} // 789 | |
return function(/* ...args */){ // 790 | |
return fn.apply(that, arguments); // 791 | |
}; // 792 | |
}; // 793 | |
// 794 | |
/***/ }, // 795 | |
/* 36 */ // 796 | |
/***/ function(module, exports) { // 797 | |
// 798 | |
module.exports = function(it){ // 799 | |
if(typeof it != 'function')throw TypeError(it + ' is not a function!'); // 800 | |
return it; // 801 | |
}; // 802 | |
// 803 | |
/***/ }, // 804 | |
/* 37 */ // 805 | |
/***/ function(module, exports, __webpack_require__) { // 806 | |
// 807 | |
'use strict'; // 808 | |
// 19.1.3.6 Object.prototype.toString() // 809 | |
var classof = __webpack_require__(38) // 810 | |
, test = {}; // 811 | |
test[__webpack_require__(16)('toStringTag')] = 'z'; // 812 | |
if(test + '' != '[object z]'){ // 813 | |
__webpack_require__(12)(Object.prototype, 'toString', function toString(){ // 814 | |
return '[object ' + classof(this) + ']'; // 815 | |
}, true); // 816 | |
} // 817 | |
// 818 | |
/***/ }, // 819 | |
/* 38 */ // 820 | |
/***/ function(module, exports, __webpack_require__) { // 821 | |
// 822 | |
// getting tag from 19.1.3.6 Object.prototype.toString() // 823 | |
var cof = __webpack_require__(20) // 824 | |
, TAG = __webpack_require__(16)('toStringTag') // 825 | |
// ES3 wrong here // 826 | |
, ARG = cof(function(){ return arguments; }()) == 'Arguments'; // 827 | |
// 828 | |
module.exports = function(it){ // 829 | |
var O, T, B; // 830 | |
return it === undefined ? 'Undefined' : it === null ? 'Null' // 831 | |
// @@toStringTag case // 832 | |
: typeof (T = (O = Object(it))[TAG]) == 'string' ? T // 833 | |
// builtinTag case // 834 | |
: ARG ? cof(O) // 835 | |
// ES3 arguments fallback // 836 | |
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; // 837 | |
}; // 838 | |
// 839 | |
/***/ }, // 840 | |
/* 39 */ // 841 | |
/***/ function(module, exports, __webpack_require__) { // 842 | |
// 843 | |
// 19.1.2.5 Object.freeze(O) // 844 | |
var isObject = __webpack_require__(25); // 845 | |
// 846 | |
__webpack_require__(40)('freeze', function($freeze){ // 847 | |
return function freeze(it){ // 848 | |
return $freeze && isObject(it) ? $freeze(it) : it; // 849 | |
}; // 850 | |
}); // 851 | |
// 852 | |
/***/ }, // 853 | |
/* 40 */ // 854 | |
/***/ function(module, exports, __webpack_require__) { // 855 | |
// 856 | |
// most Object methods by ES6 should accept primitives // 857 | |
module.exports = function(KEY, exec){ // 858 | |
var $def = __webpack_require__(8) // 859 | |
, fn = (__webpack_require__(9).Object || {})[KEY] || Object[KEY] // 860 | |
, exp = {}; // 861 | |
exp[KEY] = exec(fn); // 862 | |
$def($def.S + $def.F * __webpack_require__(7)(function(){ fn(1); }), 'Object', exp); // 863 | |
}; // 864 | |
// 865 | |
/***/ }, // 866 | |
/* 41 */ // 867 | |
/***/ function(module, exports, __webpack_require__) { // 868 | |
// 869 | |
// 19.1.2.17 Object.seal(O) // 870 | |
var isObject = __webpack_require__(25); // 871 | |
// 872 | |
__webpack_require__(40)('seal', function($seal){ // 873 | |
return function seal(it){ // 874 | |
return $seal && isObject(it) ? $seal(it) : it; // 875 | |
}; // 876 | |
}); // 877 | |
// 878 | |
/***/ }, // 879 | |
/* 42 */ // 880 | |
/***/ function(module, exports, __webpack_require__) { // 881 | |
// 882 | |
// 19.1.2.15 Object.preventExtensions(O) // 883 | |
var isObject = __webpack_require__(25); // 884 | |
// 885 | |
__webpack_require__(40)('preventExtensions', function($preventExtensions){ // 886 | |
return function preventExtensions(it){ // 887 | |
return $preventExtensions && isObject(it) ? $preventExtensions(it) : it; // 888 | |
}; // 889 | |
}); // 890 | |
// 891 | |
/***/ }, // 892 | |
/* 43 */ // 893 | |
/***/ function(module, exports, __webpack_require__) { // 894 | |
// 895 | |
// 19.1.2.12 Object.isFrozen(O) // 896 | |
var isObject = __webpack_require__(25); // 897 | |
// 898 | |
__webpack_require__(40)('isFrozen', function($isFrozen){ // 899 | |
return function isFrozen(it){ // 900 | |
return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true; // 901 | |
}; // 902 | |
}); // 903 | |
// 904 | |
/***/ }, // 905 | |
/* 44 */ // 906 | |
/***/ function(module, exports, __webpack_require__) { // 907 | |
// 908 | |
// 19.1.2.13 Object.isSealed(O) // 909 | |
var isObject = __webpack_require__(25); // 910 | |
// 911 | |
__webpack_require__(40)('isSealed', function($isSealed){ // 912 | |
return function isSealed(it){ // 913 | |
return isObject(it) ? $isSealed ? $isSealed(it) : false : true; // 914 | |
}; // 915 | |
}); // 916 | |
// 917 | |
/***/ }, // 918 | |
/* 45 */ // 919 | |
/***/ function(module, exports, __webpack_require__) { // 920 | |
// 921 | |
// 19.1.2.11 Object.isExtensible(O) // 922 | |
var isObject = __webpack_require__(25); // 923 | |
// 924 | |
__webpack_require__(40)('isExtensible', function($isExtensible){ // 925 | |
return function isExtensible(it){ // 926 | |
return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false; // 927 | |
}; // 928 | |
}); // 929 | |
// 930 | |
/***/ }, // 931 | |
/* 46 */ // 932 | |
/***/ function(module, exports, __webpack_require__) { // 933 | |
// 934 | |
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) // 935 | |
var toIObject = __webpack_require__(18); // 936 | |
// 937 | |
__webpack_require__(40)('getOwnPropertyDescriptor', function($getOwnPropertyDescriptor){ // 938 | |
return function getOwnPropertyDescriptor(it, key){ // 939 | |
return $getOwnPropertyDescriptor(toIObject(it), key); // 940 | |
}; // 941 | |
}); // 942 | |
// 943 | |
/***/ }, // 944 | |
/* 47 */ // 945 | |
/***/ function(module, exports, __webpack_require__) { // 946 | |
// 947 | |
// 19.1.2.9 Object.getPrototypeOf(O) // 948 | |
var toObject = __webpack_require__(30); // 949 | |
// 950 | |
__webpack_require__(40)('getPrototypeOf', function($getPrototypeOf){ // 951 | |
return function getPrototypeOf(it){ // 952 | |
return $getPrototypeOf(toObject(it)); // 953 | |
}; // 954 | |
}); // 955 | |
// 956 | |
/***/ }, // 957 | |
/* 48 */ // 958 | |
/***/ function(module, exports, __webpack_require__) { // 959 | |
// 960 | |
// 19.1.2.14 Object.keys(O) // 961 | |
var toObject = __webpack_require__(30); // 962 | |
// 963 | |
__webpack_require__(40)('keys', function($keys){ // 964 | |
return function keys(it){ // 965 | |
return $keys(toObject(it)); // 966 | |
}; // 967 | |
}); // 968 | |
// 969 | |
/***/ }, // 970 | |
/* 49 */ // 971 | |
/***/ function(module, exports, __webpack_require__) { // 972 | |
// 973 | |
// 19.1.2.7 Object.getOwnPropertyNames(O) // 974 | |
__webpack_require__(40)('getOwnPropertyNames', function(){ // 975 | |
return __webpack_require__(22).get; // 976 | |
}); // 977 | |
// 978 | |
/***/ }, // 979 | |
/* 50 */ // 980 | |
/***/ function(module, exports, __webpack_require__) { // 981 | |
// 982 | |
__webpack_require__(51); // 983 | |
__webpack_require__(57); // 984 | |
__webpack_require__(63); // 985 | |
__webpack_require__(64); // 986 | |
__webpack_require__(66); // 987 | |
__webpack_require__(69); // 988 | |
__webpack_require__(72); // 989 | |
__webpack_require__(74); // 990 | |
__webpack_require__(76); // 991 | |
module.exports = __webpack_require__(9).Array; // 992 | |
// 993 | |
/***/ }, // 994 | |
/* 51 */ // 995 | |
/***/ function(module, exports, __webpack_require__) { // 996 | |
// 997 | |
'use strict'; // 998 | |
var $at = __webpack_require__(52)(true); // 999 | |
// 1000 | |
// 21.1.3.27 String.prototype[@@iterator]() // 1001 | |
__webpack_require__(54)(String, 'String', function(iterated){ // 1002 | |
this._t = String(iterated); // target // 1003 | |
this._i = 0; // next index // 1004 | |
// 21.1.5.2.1 %StringIteratorPrototype%.next() // 1005 | |
}, function(){ // 1006 | |
var O = this._t // 1007 | |
, index = this._i // 1008 | |
, point; // 1009 | |
if(index >= O.length)return {value: undefined, done: true}; // 1010 | |
point = $at(O, index); // 1011 | |
this._i += point.length; // 1012 | |
return {value: point, done: false}; // 1013 | |
}); // 1014 | |
// 1015 | |
/***/ }, // 1016 | |
/* 52 */ // 1017 | |
/***/ function(module, exports, __webpack_require__) { // 1018 | |
// 1019 | |
// true -> String#at // 1020 | |
// false -> String#codePointAt // 1021 | |
var toInteger = __webpack_require__(53) // 1022 | |
, defined = __webpack_require__(21); // 1023 | |
module.exports = function(TO_STRING){ // 1024 | |
return function(that, pos){ // 1025 | |
var s = String(defined(that)) // 1026 | |
, i = toInteger(pos) // 1027 | |
, l = s.length // 1028 | |
, a, b; // 1029 | |
if(i < 0 || i >= l)return TO_STRING ? '' : undefined; // 1030 | |
a = s.charCodeAt(i); // 1031 | |
return a < 0xd800 || a > 0xdbff || i + 1 === l // 1032 | |
|| (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff // 1033 | |
? TO_STRING ? s.charAt(i) : a // 1034 | |
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; // 1035 | |
}; // 1036 | |
}; // 1037 | |
// 1038 | |
/***/ }, // 1039 | |
/* 53 */ // 1040 | |
/***/ function(module, exports) { // 1041 | |
// 1042 | |
// 7.1.4 ToInteger // 1043 | |
var ceil = Math.ceil // 1044 | |
, floor = Math.floor; // 1045 | |
module.exports = function(it){ // 1046 | |
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); // 1047 | |
}; // 1048 | |
// 1049 | |
/***/ }, // 1050 | |
/* 54 */ // 1051 | |
/***/ function(module, exports, __webpack_require__) { // 1052 | |
// 1053 | |
'use strict'; // 1054 | |
var LIBRARY = __webpack_require__(27) // 1055 | |
, $def = __webpack_require__(8) // 1056 | |
, $redef = __webpack_require__(12) // 1057 | |
, hide = __webpack_require__(10) // 1058 | |
, has = __webpack_require__(5) // 1059 | |
, SYMBOL_ITERATOR = __webpack_require__(16)('iterator') // 1060 | |
, Iterators = __webpack_require__(55) // 1061 | |
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` // 1062 | |
, FF_ITERATOR = '@@iterator' // 1063 | |
, KEYS = 'keys' // 1064 | |
, VALUES = 'values'; // 1065 | |
var returnThis = function(){ return this; }; // 1066 | |
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){ // 1067 | |
__webpack_require__(56)(Constructor, NAME, next); // 1068 | |
var createMethod = function(kind){ // 1069 | |
switch(kind){ // 1070 | |
case KEYS: return function keys(){ return new Constructor(this, kind); }; // 1071 | |
case VALUES: return function values(){ return new Constructor(this, kind); }; // 1072 | |
} return function entries(){ return new Constructor(this, kind); }; // 1073 | |
}; // 1074 | |
var TAG = NAME + ' Iterator' // 1075 | |
, proto = Base.prototype // 1076 | |
, _native = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] // 1077 | |
, _default = _native || createMethod(DEFAULT) // 1078 | |
, methods, key; // 1079 | |
// Fix native // 1080 | |
if(_native){ // 1081 | |
var IteratorPrototype = __webpack_require__(3).getProto(_default.call(new Base)); // 1082 | |
// Set @@toStringTag to native iterators // 1083 | |
__webpack_require__(15)(IteratorPrototype, TAG, true); // 1084 | |
// FF fix // 1085 | |
if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, SYMBOL_ITERATOR, returnThis); // 1086 | |
} // 1087 | |
// Define iterator // 1088 | |
if(!LIBRARY || FORCE)hide(proto, SYMBOL_ITERATOR, _default); // 1089 | |
// Plug for library // 1090 | |
Iterators[NAME] = _default; // 1091 | |
Iterators[TAG] = returnThis; // 1092 | |
if(DEFAULT){ // 1093 | |
methods = { // 1094 | |
keys: IS_SET ? _default : createMethod(KEYS), // 1095 | |
values: DEFAULT == VALUES ? _default : createMethod(VALUES), // 1096 | |
entries: DEFAULT != VALUES ? _default : createMethod('entries') // 1097 | |
}; // 1098 | |
if(FORCE)for(key in methods){ // 1099 | |
if(!(key in proto))$redef(proto, key, methods[key]); // 1100 | |
} else $def($def.P + $def.F * BUGGY, NAME, methods); // 1101 | |
} // 1102 | |
}; // 1103 | |
// 1104 | |
/***/ }, // 1105 | |
/* 55 */ // 1106 | |
/***/ function(module, exports) { // 1107 | |
// 1108 | |
module.exports = {}; // 1109 | |
// 1110 | |
/***/ }, // 1111 | |
/* 56 */ // 1112 | |
/***/ function(module, exports, __webpack_require__) { // 1113 | |
// 1114 | |
'use strict'; // 1115 | |
var $ = __webpack_require__(3) // 1116 | |
, IteratorPrototype = {}; // 1117 | |
// 1118 | |
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() // 1119 | |
__webpack_require__(10)(IteratorPrototype, __webpack_require__(16)('iterator'), function(){ return this; }); | |
// 1121 | |
module.exports = function(Constructor, NAME, next){ // 1122 | |
Constructor.prototype = $.create(IteratorPrototype, {next: __webpack_require__(11)(1,next)}); // 1123 | |
__webpack_require__(15)(Constructor, NAME + ' Iterator'); // 1124 | |
}; // 1125 | |
// 1126 | |
/***/ }, // 1127 | |
/* 57 */ // 1128 | |
/***/ function(module, exports, __webpack_require__) { // 1129 | |
// 1130 | |
'use strict'; // 1131 | |
var ctx = __webpack_require__(35) // 1132 | |
, $def = __webpack_require__(8) // 1133 | |
, toObject = __webpack_require__(30) // 1134 | |
, call = __webpack_require__(58) // 1135 | |
, isArrayIter = __webpack_require__(59) // 1136 | |
, toLength = __webpack_require__(60) // 1137 | |
, getIterFn = __webpack_require__(61); // 1138 | |
$def($def.S + $def.F * !__webpack_require__(62)(function(iter){ Array.from(iter); }), 'Array', { // 1139 | |
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) // 1140 | |
from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ // 1141 | |
var O = toObject(arrayLike) // 1142 | |
, C = typeof this == 'function' ? this : Array // 1143 | |
, mapfn = arguments[1] // 1144 | |
, mapping = mapfn !== undefined // 1145 | |
, index = 0 // 1146 | |
, iterFn = getIterFn(O) // 1147 | |
, length, result, step, iterator; // 1148 | |
if(mapping)mapfn = ctx(mapfn, arguments[2], 2); // 1149 | |
// if object isn't iterable or it's array with default iterator - use simple case // 1150 | |
if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ // 1151 | |
for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ // 1152 | |
result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; // 1153 | |
} // 1154 | |
} else { // 1155 | |
length = toLength(O.length); // 1156 | |
for(result = new C(length); length > index; index++){ // 1157 | |
result[index] = mapping ? mapfn(O[index], index) : O[index]; // 1158 | |
} // 1159 | |
} // 1160 | |
result.length = index; // 1161 | |
return result; // 1162 | |
} // 1163 | |
}); // 1164 | |
// 1165 | |
// 1166 | |
/***/ }, // 1167 | |
/* 58 */ // 1168 | |
/***/ function(module, exports, __webpack_require__) { // 1169 | |
// 1170 | |
// call something on iterator step with safe closing on error // 1171 | |
var anObject = __webpack_require__(26); // 1172 | |
module.exports = function(iterator, fn, value, entries){ // 1173 | |
try { // 1174 | |
return entries ? fn(anObject(value)[0], value[1]) : fn(value); // 1175 | |
// 7.4.6 IteratorClose(iterator, completion) // 1176 | |
} catch(e){ // 1177 | |
var ret = iterator['return']; // 1178 | |
if(ret !== undefined)anObject(ret.call(iterator)); // 1179 | |
throw e; // 1180 | |
} // 1181 | |
}; // 1182 | |
// 1183 | |
/***/ }, // 1184 | |
/* 59 */ // 1185 | |
/***/ function(module, exports, __webpack_require__) { // 1186 | |
// 1187 | |
// check on default Array iterator // 1188 | |
var Iterators = __webpack_require__(55) // 1189 | |
, ITERATOR = __webpack_require__(16)('iterator'); // 1190 | |
module.exports = function(it){ // 1191 | |
return (Iterators.Array || Array.prototype[ITERATOR]) === it; // 1192 | |
}; // 1193 | |
// 1194 | |
/***/ }, // 1195 | |
/* 60 */ // 1196 | |
/***/ function(module, exports, __webpack_require__) { // 1197 | |
// 1198 | |
// 7.1.15 ToLength // 1199 | |
var toInteger = __webpack_require__(53) // 1200 | |
, min = Math.min; // 1201 | |
module.exports = function(it){ // 1202 | |
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 // 1203 | |
}; // 1204 | |
// 1205 | |
/***/ }, // 1206 | |
/* 61 */ // 1207 | |
/***/ function(module, exports, __webpack_require__) { // 1208 | |
// 1209 | |
var classof = __webpack_require__(38) // 1210 | |
, ITERATOR = __webpack_require__(16)('iterator') // 1211 | |
, Iterators = __webpack_require__(55); // 1212 | |
module.exports = __webpack_require__(9).getIteratorMethod = function(it){ // 1213 | |
if(it != undefined)return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)]; // 1214 | |
}; // 1215 | |
// 1216 | |
/***/ }, // 1217 | |
/* 62 */ // 1218 | |
/***/ function(module, exports, __webpack_require__) { // 1219 | |
// 1220 | |
var SYMBOL_ITERATOR = __webpack_require__(16)('iterator') // 1221 | |
, SAFE_CLOSING = false; // 1222 | |
try { // 1223 | |
var riter = [7][SYMBOL_ITERATOR](); // 1224 | |
riter['return'] = function(){ SAFE_CLOSING = true; }; // 1225 | |
Array.from(riter, function(){ throw 2; }); // 1226 | |
} catch(e){ /* empty */ } // 1227 | |
module.exports = function(exec){ // 1228 | |
if(!SAFE_CLOSING)return false; // 1229 | |
var safe = false; // 1230 | |
try { // 1231 | |
var arr = [7] // 1232 | |
, iter = arr[SYMBOL_ITERATOR](); // 1233 | |
iter.next = function(){ safe = true; }; // 1234 | |
arr[SYMBOL_ITERATOR] = function(){ return iter; }; // 1235 | |
exec(arr); // 1236 | |
} catch(e){ /* empty */ } // 1237 | |
return safe; // 1238 | |
}; // 1239 | |
// 1240 | |
/***/ }, // 1241 | |
/* 63 */ // 1242 | |
/***/ function(module, exports, __webpack_require__) { // 1243 | |
// 1244 | |
'use strict'; // 1245 | |
var $def = __webpack_require__(8); // 1246 | |
// 1247 | |
// WebKit Array.of isn't generic // 1248 | |
$def($def.S + $def.F * __webpack_require__(7)(function(){ // 1249 | |
function F(){} // 1250 | |
return !(Array.of.call(F) instanceof F); // 1251 | |
}), 'Array', { // 1252 | |
// 22.1.2.3 Array.of( ...items) // 1253 | |
of: function of(/* ...args */){ // 1254 | |
var index = 0 // 1255 | |
, length = arguments.length // 1256 | |
, result = new (typeof this == 'function' ? this : Array)(length); // 1257 | |
while(length > index)result[index] = arguments[index++]; // 1258 | |
result.length = length; // 1259 | |
return result; // 1260 | |
} // 1261 | |
}); // 1262 | |
// 1263 | |
/***/ }, // 1264 | |
/* 64 */ // 1265 | |
/***/ function(module, exports, __webpack_require__) { // 1266 | |
// 1267 | |
__webpack_require__(65)(Array); // 1268 | |
// 1269 | |
/***/ }, // 1270 | |
/* 65 */ // 1271 | |
/***/ function(module, exports, __webpack_require__) { // 1272 | |
// 1273 | |
'use strict'; // 1274 | |
var $ = __webpack_require__(3) // 1275 | |
, SPECIES = __webpack_require__(16)('species'); // 1276 | |
module.exports = function(C){ // 1277 | |
if(__webpack_require__(6) && !(SPECIES in C))$.setDesc(C, SPECIES, { // 1278 | |
configurable: true, // 1279 | |
get: function(){ return this; } // 1280 | |
}); // 1281 | |
}; // 1282 | |
// 1283 | |
/***/ }, // 1284 | |
/* 66 */ // 1285 | |
/***/ function(module, exports, __webpack_require__) { // 1286 | |
// 1287 | |
'use strict'; // 1288 | |
var setUnscope = __webpack_require__(67) // 1289 | |
, step = __webpack_require__(68) // 1290 | |
, Iterators = __webpack_require__(55) // 1291 | |
, toIObject = __webpack_require__(18); // 1292 | |
// 1293 | |
// 22.1.3.4 Array.prototype.entries() // 1294 | |
// 22.1.3.13 Array.prototype.keys() // 1295 | |
// 22.1.3.29 Array.prototype.values() // 1296 | |
// 22.1.3.30 Array.prototype[@@iterator]() // 1297 | |
__webpack_require__(54)(Array, 'Array', function(iterated, kind){ // 1298 | |
this._t = toIObject(iterated); // target // 1299 | |
this._i = 0; // next index // 1300 | |
this._k = kind; // kind // 1301 | |
// 22.1.5.2.1 %ArrayIteratorPrototype%.next() // 1302 | |
}, function(){ // 1303 | |
var O = this._t // 1304 | |
, kind = this._k // 1305 | |
, index = this._i++; // 1306 | |
if(!O || index >= O.length){ // 1307 | |
this._t = undefined; // 1308 | |
return step(1); // 1309 | |
} // 1310 | |
if(kind == 'keys' )return step(0, index); // 1311 | |
if(kind == 'values')return step(0, O[index]); // 1312 | |
return step(0, [index, O[index]]); // 1313 | |
}, 'values'); // 1314 | |
// 1315 | |
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) // 1316 | |
Iterators.Arguments = Iterators.Array; // 1317 | |
// 1318 | |
setUnscope('keys'); // 1319 | |
setUnscope('values'); // 1320 | |
setUnscope('entries'); // 1321 | |
// 1322 | |
/***/ }, // 1323 | |
/* 67 */ // 1324 | |
/***/ function(module, exports, __webpack_require__) { // 1325 | |
// 1326 | |
// 22.1.3.31 Array.prototype[@@unscopables] // 1327 | |
var UNSCOPABLES = __webpack_require__(16)('unscopables'); // 1328 | |
if([][UNSCOPABLES] == undefined)__webpack_require__(10)(Array.prototype, UNSCOPABLES, {}); // 1329 | |
module.exports = function(key){ // 1330 | |
[][UNSCOPABLES][key] = true; // 1331 | |
}; // 1332 | |
// 1333 | |
/***/ }, // 1334 | |
/* 68 */ // 1335 | |
/***/ function(module, exports) { // 1336 | |
// 1337 | |
module.exports = function(done, value){ // 1338 | |
return {value: value, done: !!done}; // 1339 | |
}; // 1340 | |
// 1341 | |
/***/ }, // 1342 | |
/* 69 */ // 1343 | |
/***/ function(module, exports, __webpack_require__) { // 1344 | |
// 1345 | |
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) // 1346 | |
'use strict'; // 1347 | |
var $def = __webpack_require__(8); // 1348 | |
// 1349 | |
$def($def.P, 'Array', {copyWithin: __webpack_require__(70)}); // 1350 | |
// 1351 | |
__webpack_require__(67)('copyWithin'); // 1352 | |
// 1353 | |
/***/ }, // 1354 | |
/* 70 */ // 1355 | |
/***/ function(module, exports, __webpack_require__) { // 1356 | |
// 1357 | |
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length) // 1358 | |
'use strict'; // 1359 | |
var toObject = __webpack_require__(30) // 1360 | |
, toIndex = __webpack_require__(71) // 1361 | |
, toLength = __webpack_require__(60); // 1362 | |
// 1363 | |
module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){ // 1364 | |
var O = toObject(this) // 1365 | |
, len = toLength(O.length) // 1366 | |
, to = toIndex(target, len) // 1367 | |
, from = toIndex(start, len) // 1368 | |
, end = arguments[2] // 1369 | |
, count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to) // 1370 | |
, inc = 1; // 1371 | |
if(from < to && to < from + count){ // 1372 | |
inc = -1; // 1373 | |
from += count - 1; // 1374 | |
to += count - 1; // 1375 | |
} // 1376 | |
while(count-- > 0){ // 1377 | |
if(from in O)O[to] = O[from]; // 1378 | |
else delete O[to]; // 1379 | |
to += inc; // 1380 | |
from += inc; // 1381 | |
} return O; // 1382 | |
}; // 1383 | |
// 1384 | |
/***/ }, // 1385 | |
/* 71 */ // 1386 | |
/***/ function(module, exports, __webpack_require__) { // 1387 | |
// 1388 | |
var toInteger = __webpack_require__(53) // 1389 | |
, max = Math.max // 1390 | |
, min = Math.min; // 1391 | |
module.exports = function(index, length){ // 1392 | |
index = toInteger(index); // 1393 | |
return index < 0 ? max(index + length, 0) : min(index, length); // 1394 | |
}; // 1395 | |
// 1396 | |
/***/ }, // 1397 | |
/* 72 */ // 1398 | |
/***/ function(module, exports, __webpack_require__) { // 1399 | |
// 1400 | |
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) // 1401 | |
var $def = __webpack_require__(8); // 1402 | |
// 1403 | |
$def($def.P, 'Array', {fill: __webpack_require__(73)}); // 1404 | |
// 1405 | |
__webpack_require__(67)('fill'); // 1406 | |
// 1407 | |
/***/ }, // 1408 | |
/* 73 */ // 1409 | |
/***/ function(module, exports, __webpack_require__) { // 1410 | |
// 1411 | |
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length) // 1412 | |
'use strict'; // 1413 | |
var toObject = __webpack_require__(30) // 1414 | |
, toIndex = __webpack_require__(71) // 1415 | |
, toLength = __webpack_require__(60); // 1416 | |
module.exports = [].fill || function fill(value /*, start = 0, end = @length */){ // 1417 | |
var O = toObject(this, true) // 1418 | |
, length = toLength(O.length) // 1419 | |
, index = toIndex(arguments[1], length) // 1420 | |
, end = arguments[2] // 1421 | |
, endPos = end === undefined ? length : toIndex(end, length); // 1422 | |
while(endPos > index)O[index++] = value; // 1423 | |
return O; // 1424 | |
}; // 1425 | |
// 1426 | |
/***/ }, // 1427 | |
/* 74 */ // 1428 | |
/***/ function(module, exports, __webpack_require__) { // 1429 | |
// 1430 | |
'use strict'; // 1431 | |
// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) // 1432 | |
var KEY = 'find' // 1433 | |
, $def = __webpack_require__(8) // 1434 | |
, forced = true // 1435 | |
, $find = __webpack_require__(75)(5); // 1436 | |
// Shouldn't skip holes // 1437 | |
if(KEY in [])Array(1)[KEY](function(){ forced = false; }); // 1438 | |
$def($def.P + $def.F * forced, 'Array', { // 1439 | |
find: function find(callbackfn/*, that = undefined */){ // 1440 | |
return $find(this, callbackfn, arguments[1]); // 1441 | |
} // 1442 | |
}); // 1443 | |
__webpack_require__(67)(KEY); // 1444 | |
// 1445 | |
/***/ }, // 1446 | |
/* 75 */ // 1447 | |
/***/ function(module, exports, __webpack_require__) { // 1448 | |
// 1449 | |
// 0 -> Array#forEach // 1450 | |
// 1 -> Array#map // 1451 | |
// 2 -> Array#filter // 1452 | |
// 3 -> Array#some // 1453 | |
// 4 -> Array#every // 1454 | |
// 5 -> Array#find // 1455 | |
// 6 -> Array#findIndex // 1456 | |
var ctx = __webpack_require__(35) // 1457 | |
, isObject = __webpack_require__(25) // 1458 | |
, IObject = __webpack_require__(19) // 1459 | |
, toObject = __webpack_require__(30) // 1460 | |
, toLength = __webpack_require__(60) // 1461 | |
, isArray = __webpack_require__(24) // 1462 | |
, SPECIES = __webpack_require__(16)('species'); // 1463 | |
// 9.4.2.3 ArraySpeciesCreate(originalArray, length) // 1464 | |
var ASC = function(original, length){ // 1465 | |
var C; // 1466 | |
if(isArray(original) && isObject(C = original.constructor)){ // 1467 | |
C = C[SPECIES]; // 1468 | |
if(C === null)C = undefined; // 1469 | |
} return new(C === undefined ? Array : C)(length); // 1470 | |
}; // 1471 | |
module.exports = function(TYPE){ // 1472 | |
var IS_MAP = TYPE == 1 // 1473 | |
, IS_FILTER = TYPE == 2 // 1474 | |
, IS_SOME = TYPE == 3 // 1475 | |
, IS_EVERY = TYPE == 4 // 1476 | |
, IS_FIND_INDEX = TYPE == 6 // 1477 | |
, NO_HOLES = TYPE == 5 || IS_FIND_INDEX; // 1478 | |
return function($this, callbackfn, that){ // 1479 | |
var O = toObject($this) // 1480 | |
, self = IObject(O) // 1481 | |
, f = ctx(callbackfn, that, 3) // 1482 | |
, length = toLength(self.length) // 1483 | |
, index = 0 // 1484 | |
, result = IS_MAP ? ASC($this, length) : IS_FILTER ? ASC($this, 0) : undefined // 1485 | |
, val, res; // 1486 | |
for(;length > index; index++)if(NO_HOLES || index in self){ // 1487 | |
val = self[index]; // 1488 | |
res = f(val, index, O); // 1489 | |
if(TYPE){ // 1490 | |
if(IS_MAP)result[index] = res; // map // 1491 | |
else if(res)switch(TYPE){ // 1492 | |
case 3: return true; // some // 1493 | |
case 5: return val; // find // 1494 | |
case 6: return index; // findIndex // 1495 | |
case 2: result.push(val); // filter // 1496 | |
} else if(IS_EVERY)return false; // every // 1497 | |
} // 1498 | |
} // 1499 | |
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; // 1500 | |
}; // 1501 | |
}; // 1502 | |
// 1503 | |
/***/ }, // 1504 | |
/* 76 */ // 1505 | |
/***/ function(module, exports, __webpack_require__) { // 1506 | |
// 1507 | |
'use strict'; // 1508 | |
// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) // 1509 | |
var KEY = 'findIndex' // 1510 | |
, $def = __webpack_require__(8) // 1511 | |
, forced = true // 1512 | |
, $find = __webpack_require__(75)(6); // 1513 | |
// Shouldn't skip holes // 1514 | |
if(KEY in [])Array(1)[KEY](function(){ forced = false; }); // 1515 | |
$def($def.P + $def.F * forced, 'Array', { // 1516 | |
findIndex: function findIndex(callbackfn/*, that = undefined */){ // 1517 | |
return $find(this, callbackfn, arguments[1]); // 1518 | |
} // 1519 | |
}); // 1520 | |
__webpack_require__(67)(KEY); // 1521 | |
// 1522 | |
/***/ }, // 1523 | |
/* 77 */ // 1524 | |
/***/ function(module, exports, __webpack_require__) { // 1525 | |
// 1526 | |
__webpack_require__(78); // 1527 | |
__webpack_require__(79); // 1528 | |
__webpack_require__(80); // 1529 | |
__webpack_require__(51); // 1530 | |
__webpack_require__(82); // 1531 | |
__webpack_require__(83); // 1532 | |
__webpack_require__(87); // 1533 | |
__webpack_require__(88); // 1534 | |
__webpack_require__(90); // 1535 | |
__webpack_require__(91); // 1536 | |
__webpack_require__(93); // 1537 | |
__webpack_require__(94); // 1538 | |
__webpack_require__(95); // 1539 | |
module.exports = __webpack_require__(9).String; // 1540 | |
// 1541 | |
/***/ }, // 1542 | |
/* 78 */ // 1543 | |
/***/ function(module, exports, __webpack_require__) { // 1544 | |
// 1545 | |
var $def = __webpack_require__(8) // 1546 | |
, toIndex = __webpack_require__(71) // 1547 | |
, fromCharCode = String.fromCharCode // 1548 | |
, $fromCodePoint = String.fromCodePoint; // 1549 | |
// 1550 | |
// length should be 1, old FF problem // 1551 | |
$def($def.S + $def.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { // 1552 | |
// 21.1.2.2 String.fromCodePoint(...codePoints) // 1553 | |
fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars // 1554 | |
var res = [] // 1555 | |
, len = arguments.length // 1556 | |
, i = 0 // 1557 | |
, code; // 1558 | |
while(len > i){ // 1559 | |
code = +arguments[i++]; // 1560 | |
if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point'); // 1561 | |
res.push(code < 0x10000 // 1562 | |
? fromCharCode(code) // 1563 | |
: fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00) // 1564 | |
); // 1565 | |
} return res.join(''); // 1566 | |
} // 1567 | |
}); // 1568 | |
// 1569 | |
/***/ }, // 1570 | |
/* 79 */ // 1571 | |
/***/ function(module, exports, __webpack_require__) { // 1572 | |
// 1573 | |
var $def = __webpack_require__(8) // 1574 | |
, toIObject = __webpack_require__(18) // 1575 | |
, toLength = __webpack_require__(60); // 1576 | |
// 1577 | |
$def($def.S, 'String', { // 1578 | |
// 21.1.2.4 String.raw(callSite, ...substitutions) // 1579 | |
raw: function raw(callSite){ // 1580 | |
var tpl = toIObject(callSite.raw) // 1581 | |
, len = toLength(tpl.length) // 1582 | |
, sln = arguments.length // 1583 | |
, res = [] // 1584 | |
, i = 0; // 1585 | |
while(len > i){ // 1586 | |
res.push(String(tpl[i++])); // 1587 | |
if(i < sln)res.push(String(arguments[i])); // 1588 | |
} return res.join(''); // 1589 | |
} // 1590 | |
}); // 1591 | |
// 1592 | |
/***/ }, // 1593 | |
/* 80 */ // 1594 | |
/***/ function(module, exports, __webpack_require__) { // 1595 | |
// 1596 | |
'use strict'; // 1597 | |
// 21.1.3.25 String.prototype.trim() // 1598 | |
__webpack_require__(81)('trim', function($trim){ // 1599 | |
return function trim(){ // 1600 | |
return $trim(this, 3); // 1601 | |
}; // 1602 | |
}); // 1603 | |
// 1604 | |
/***/ }, // 1605 | |
/* 81 */ // 1606 | |
/***/ function(module, exports, __webpack_require__) { // 1607 | |
// 1608 | |
// 1 -> String#trimLeft // 1609 | |
// 2 -> String#trimRight // 1610 | |
// 3 -> String#trim // 1611 | |
var trim = function(string, TYPE){ // 1612 | |
string = String(defined(string)); // 1613 | |
if(TYPE & 1)string = string.replace(ltrim, ''); // 1614 | |
if(TYPE & 2)string = string.replace(rtrim, ''); // 1615 | |
return string; // 1616 | |
}; // 1617 | |
// 1618 | |
var $def = __webpack_require__(8) // 1619 | |
, defined = __webpack_require__(21) // 1620 | |
, spaces = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + // 1621 | |
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF' // 1622 | |
, space = '[' + spaces + ']' // 1623 | |
, non = '\u200b\u0085' // 1624 | |
, ltrim = RegExp('^' + space + space + '*') // 1625 | |
, rtrim = RegExp(space + space + '*$'); // 1626 | |
// 1627 | |
module.exports = function(KEY, exec){ // 1628 | |
var exp = {}; // 1629 | |
exp[KEY] = exec(trim); // 1630 | |
$def($def.P + $def.F * __webpack_require__(7)(function(){ // 1631 | |
return !!spaces[KEY]() || non[KEY]() != non; // 1632 | |
}), 'String', exp); // 1633 | |
}; // 1634 | |
// 1635 | |
/***/ }, // 1636 | |
/* 82 */ // 1637 | |
/***/ function(module, exports, __webpack_require__) { // 1638 | |
// 1639 | |
'use strict'; // 1640 | |
var $def = __webpack_require__(8) // 1641 | |
, $at = __webpack_require__(52)(false); // 1642 | |
$def($def.P, 'String', { // 1643 | |
// 21.1.3.3 String.prototype.codePointAt(pos) // 1644 | |
codePointAt: function codePointAt(pos){ // 1645 | |
return $at(this, pos); // 1646 | |
} // 1647 | |
}); // 1648 | |
// 1649 | |
/***/ }, // 1650 | |
/* 83 */ // 1651 | |
/***/ function(module, exports, __webpack_require__) { // 1652 | |
// 1653 | |
// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition]) // 1654 | |
'use strict'; // 1655 | |
var $def = __webpack_require__(8) // 1656 | |
, toLength = __webpack_require__(60) // 1657 | |
, context = __webpack_require__(84) // 1658 | |
, ENDS_WITH = 'endsWith' // 1659 | |
, $endsWith = ''[ENDS_WITH]; // 1660 | |
// 1661 | |
$def($def.P + $def.F * __webpack_require__(86)(ENDS_WITH), 'String', { // 1662 | |
endsWith: function endsWith(searchString /*, endPosition = @length */){ // 1663 | |
var that = context(this, searchString, ENDS_WITH) // 1664 | |
, endPosition = arguments[1] // 1665 | |
, len = toLength(that.length) // 1666 | |
, end = endPosition === undefined ? len : Math.min(toLength(endPosition), len) // 1667 | |
, search = String(searchString); // 1668 | |
return $endsWith // 1669 | |
? $endsWith.call(that, search, end) // 1670 | |
: that.slice(end - search.length, end) === search; // 1671 | |
} // 1672 | |
}); // 1673 | |
// 1674 | |
/***/ }, // 1675 | |
/* 84 */ // 1676 | |
/***/ function(module, exports, __webpack_require__) { // 1677 | |
// 1678 | |
// helper for String#{startsWith, endsWith, includes} // 1679 | |
var isRegExp = __webpack_require__(85) // 1680 | |
, defined = __webpack_require__(21); // 1681 | |
// 1682 | |
module.exports = function(that, searchString, NAME){ // 1683 | |
if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!"); // 1684 | |
return String(defined(that)); // 1685 | |
}; // 1686 | |
// 1687 | |
/***/ }, // 1688 | |
/* 85 */ // 1689 | |
/***/ function(module, exports, __webpack_require__) { // 1690 | |
// 1691 | |
// 7.2.8 IsRegExp(argument) // 1692 | |
var isObject = __webpack_require__(25) // 1693 | |
, cof = __webpack_require__(20) // 1694 | |
, MATCH = __webpack_require__(16)('match'); // 1695 | |
module.exports = function(it){ // 1696 | |
var isRegExp; // 1697 | |
return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); // 1698 | |
}; // 1699 | |
// 1700 | |
/***/ }, // 1701 | |
/* 86 */ // 1702 | |
/***/ function(module, exports, __webpack_require__) { // 1703 | |
// 1704 | |
module.exports = function(KEY){ // 1705 | |
var re = /./; // 1706 | |
try { // 1707 | |
'/./'[KEY](re); // 1708 | |
} catch(e){ // 1709 | |
try { // 1710 | |
re[__webpack_require__(16)('match')] = false; // 1711 | |
return !'/./'[KEY](re); // 1712 | |
} catch(e){ /* empty */ } // 1713 | |
} return true; // 1714 | |
}; // 1715 | |
// 1716 | |
/***/ }, // 1717 | |
/* 87 */ // 1718 | |
/***/ function(module, exports, __webpack_require__) { // 1719 | |
// 1720 | |
// 21.1.3.7 String.prototype.includes(searchString, position = 0) // 1721 | |
'use strict'; // 1722 | |
var $def = __webpack_require__(8) // 1723 | |
, context = __webpack_require__(84) // 1724 | |
, INCLUDES = 'includes'; // 1725 | |
// 1726 | |
$def($def.P + $def.F * __webpack_require__(86)(INCLUDES), 'String', { // 1727 | |
includes: function includes(searchString /*, position = 0 */){ // 1728 | |
return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments[1]); // 1729 | |
} // 1730 | |
}); // 1731 | |
// 1732 | |
/***/ }, // 1733 | |
/* 88 */ // 1734 | |
/***/ function(module, exports, __webpack_require__) { // 1735 | |
// 1736 | |
var $def = __webpack_require__(8); // 1737 | |
// 1738 | |
$def($def.P, 'String', { // 1739 | |
// 21.1.3.13 String.prototype.repeat(count) // 1740 | |
repeat: __webpack_require__(89) // 1741 | |
}); // 1742 | |
// 1743 | |
/***/ }, // 1744 | |
/* 89 */ // 1745 | |
/***/ function(module, exports, __webpack_require__) { // 1746 | |
// 1747 | |
'use strict'; // 1748 | |
var toInteger = __webpack_require__(53) // 1749 | |
, defined = __webpack_require__(21); // 1750 | |
// 1751 | |
module.exports = function repeat(count){ // 1752 | |
var str = String(defined(this)) // 1753 | |
, res = '' // 1754 | |
, n = toInteger(count); // 1755 | |
if(n < 0 || n == Infinity)throw RangeError("Count can't be negative"); // 1756 | |
for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str; // 1757 | |
return res; // 1758 | |
}; // 1759 | |
// 1760 | |
/***/ }, // 1761 | |
/* 90 */ // 1762 | |
/***/ function(module, exports, __webpack_require__) { // 1763 | |
// 1764 | |
// 21.1.3.18 String.prototype.startsWith(searchString [, position ]) // 1765 | |
'use strict'; // 1766 | |
var $def = __webpack_require__(8) // 1767 | |
, toLength = __webpack_require__(60) // 1768 | |
, context = __webpack_require__(84) // 1769 | |
, STARTS_WITH = 'startsWith' // 1770 | |
, $startsWith = ''[STARTS_WITH]; // 1771 | |
// 1772 | |
$def($def.P + $def.F * __webpack_require__(86)(STARTS_WITH), 'String', { // 1773 | |
startsWith: function startsWith(searchString /*, position = 0 */){ // 1774 | |
var that = context(this, searchString, STARTS_WITH) // 1775 | |
, index = toLength(Math.min(arguments[1], that.length)) // 1776 | |
, search = String(searchString); // 1777 | |
return $startsWith // 1778 | |
? $startsWith.call(that, search, index) // 1779 | |
: that.slice(index, index + search.length) === search; // 1780 | |
} // 1781 | |
}); // 1782 | |
// 1783 | |
/***/ }, // 1784 | |
/* 91 */ // 1785 | |
/***/ function(module, exports, __webpack_require__) { // 1786 | |
// 1787 | |
// @@match logic // 1788 | |
__webpack_require__(92)('match', 1, function(defined, MATCH){ // 1789 | |
// 21.1.3.11 String.prototype.match(regexp) // 1790 | |
return function match(regexp){ // 1791 | |
'use strict'; // 1792 | |
var O = defined(this) // 1793 | |
, fn = regexp == undefined ? undefined : regexp[MATCH]; // 1794 | |
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); // 1795 | |
}; // 1796 | |
}); // 1797 | |
// 1798 | |
/***/ }, // 1799 | |
/* 92 */ // 1800 | |
/***/ function(module, exports, __webpack_require__) { // 1801 | |
// 1802 | |
'use strict'; // 1803 | |
module.exports = function(KEY, length, exec){ // 1804 | |
var defined = __webpack_require__(21) // 1805 | |
, SYMBOL = __webpack_require__(16)(KEY) // 1806 | |
, original = ''[KEY]; // 1807 | |
if(__webpack_require__(7)(function(){ // 1808 | |
var O = {}; // 1809 | |
O[SYMBOL] = function(){ return 7; }; // 1810 | |
return ''[KEY](O) != 7; // 1811 | |
})){ // 1812 | |
__webpack_require__(12)(String.prototype, KEY, exec(defined, SYMBOL, original)); // 1813 | |
__webpack_require__(10)(RegExp.prototype, SYMBOL, length == 2 // 1814 | |
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) // 1815 | |
// 21.2.5.11 RegExp.prototype[@@split](string, limit) // 1816 | |
? function(string, arg){ return original.call(string, this, arg); } // 1817 | |
// 21.2.5.6 RegExp.prototype[@@match](string) // 1818 | |
// 21.2.5.9 RegExp.prototype[@@search](string) // 1819 | |
: function(string){ return original.call(string, this); } // 1820 | |
); // 1821 | |
} // 1822 | |
}; // 1823 | |
// 1824 | |
/***/ }, // 1825 | |
/* 93 */ // 1826 | |
/***/ function(module, exports, __webpack_require__) { // 1827 | |
// 1828 | |
// @@replace logic // 1829 | |
__webpack_require__(92)('replace', 2, function(defined, REPLACE, $replace){ // 1830 | |
// 21.1.3.14 String.prototype.replace(searchValue, replaceValue) // 1831 | |
return function replace(searchValue, replaceValue){ // 1832 | |
'use strict'; // 1833 | |
var O = defined(this) // 1834 | |
, fn = searchValue == undefined ? undefined : searchValue[REPLACE]; // 1835 | |
return fn !== undefined // 1836 | |
? fn.call(searchValue, O, replaceValue) // 1837 | |
: $replace.call(String(O), searchValue, replaceValue); // 1838 | |
}; // 1839 | |
}); // 1840 | |
// 1841 | |
/***/ }, // 1842 | |
/* 94 */ // 1843 | |
/***/ function(module, exports, __webpack_require__) { // 1844 | |
// 1845 | |
// @@search logic // 1846 | |
__webpack_require__(92)('search', 1, function(defined, SEARCH){ // 1847 | |
// 21.1.3.15 String.prototype.search(regexp) // 1848 | |
return function search(regexp){ // 1849 | |
'use strict'; // 1850 | |
var O = defined(this) // 1851 | |
, fn = regexp == undefined ? undefined : regexp[SEARCH]; // 1852 | |
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O)); // 1853 | |
}; // 1854 | |
}); // 1855 | |
// 1856 | |
/***/ }, // 1857 | |
/* 95 */ // 1858 | |
/***/ function(module, exports, __webpack_require__) { // 1859 | |
// 1860 | |
// @@split logic // 1861 | |
__webpack_require__(92)('split', 2, function(defined, SPLIT, $split){ // 1862 | |
// 21.1.3.17 String.prototype.split(separator, limit) // 1863 | |
return function split(separator, limit){ // 1864 | |
'use strict'; // 1865 | |
var O = defined(this) // 1866 | |
, fn = separator == undefined ? undefined : separator[SPLIT]; // 1867 | |
return fn !== undefined // 1868 | |
? fn.call(separator, O, limit) // 1869 | |
: $split.call(String(O), separator, limit); // 1870 | |
}; // 1871 | |
}); // 1872 | |
// 1873 | |
/***/ }, // 1874 | |
/* 96 */ // 1875 | |
/***/ function(module, exports, __webpack_require__) { // 1876 | |
// 1877 | |
__webpack_require__(97); // 1878 | |
__webpack_require__(98); // 1879 | |
module.exports = __webpack_require__(9).Function; // 1880 | |
// 1881 | |
/***/ }, // 1882 | |
/* 97 */ // 1883 | |
/***/ function(module, exports, __webpack_require__) { // 1884 | |
// 1885 | |
var setDesc = __webpack_require__(3).setDesc // 1886 | |
, createDesc = __webpack_require__(11) // 1887 | |
, has = __webpack_require__(5) // 1888 | |
, FProto = Function.prototype // 1889 | |
, nameRE = /^\s*function ([^ (]*)/ // 1890 | |
, NAME = 'name'; // 1891 | |
// 19.2.4.2 name // 1892 | |
NAME in FProto || __webpack_require__(6) && setDesc(FProto, NAME, { // 1893 | |
configurable: true, // 1894 | |
get: function(){ // 1895 | |
var match = ('' + this).match(nameRE) // 1896 | |
, name = match ? match[1] : ''; // 1897 | |
has(this, NAME) || setDesc(this, NAME, createDesc(5, name)); // 1898 | |
return name; // 1899 | |
} // 1900 | |
}); // 1901 | |
// 1902 | |
/***/ }, // 1903 | |
/* 98 */ // 1904 | |
/***/ function(module, exports, __webpack_require__) { // 1905 | |
// 1906 | |
'use strict'; // 1907 | |
var $ = __webpack_require__(3) // 1908 | |
, isObject = __webpack_require__(25) // 1909 | |
, HAS_INSTANCE = __webpack_require__(16)('hasInstance') // 1910 | |
, FunctionProto = Function.prototype; // 1911 | |
// 19.2.3.6 Function.prototype[@@hasInstance](V) // 1912 | |
if(!(HAS_INSTANCE in FunctionProto))$.setDesc(FunctionProto, HAS_INSTANCE, {value: function(O){ // 1913 | |
if(typeof this != 'function' || !isObject(O))return false; // 1914 | |
if(!isObject(this.prototype))return O instanceof this; // 1915 | |
// for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this: // 1916 | |
while(O = $.getProto(O))if(this.prototype === O)return true; // 1917 | |
return false; // 1918 | |
}}); // 1919 | |
// 1920 | |
/***/ }, // 1921 | |
/* 99 */ // 1922 | |
/***/ function(module, exports, __webpack_require__) { // 1923 | |
// 1924 | |
__webpack_require__(2); // 1925 | |
module.exports = __webpack_require__(9).Symbol; // 1926 | |
// 1927 | |
/***/ }, // 1928 | |
/* 100 */ // 1929 | |
/***/ function(module, exports, __webpack_require__) { // 1930 | |
// 1931 | |
__webpack_require__(37); // 1932 | |
__webpack_require__(51); // 1933 | |
__webpack_require__(101); // 1934 | |
__webpack_require__(102); // 1935 | |
module.exports = __webpack_require__(9).Map; // 1936 | |
// 1937 | |
/***/ }, // 1938 | |
/* 101 */ // 1939 | |
/***/ function(module, exports, __webpack_require__) { // 1940 | |
// 1941 | |
__webpack_require__(66); // 1942 | |
var global = __webpack_require__(4) // 1943 | |
, hide = __webpack_require__(10) // 1944 | |
, Iterators = __webpack_require__(55) // 1945 | |
, ITERATOR = __webpack_require__(16)('iterator') // 1946 | |
, NL = global.NodeList // 1947 | |
, HTC = global.HTMLCollection // 1948 | |
, NLProto = NL && NL.prototype // 1949 | |
, HTCProto = HTC && HTC.prototype // 1950 | |
, ArrayValues = Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array; // 1951 | |
if(NL && !(ITERATOR in NLProto))hide(NLProto, ITERATOR, ArrayValues); // 1952 | |
if(HTC && !(ITERATOR in HTCProto))hide(HTCProto, ITERATOR, ArrayValues); // 1953 | |
// 1954 | |
/***/ }, // 1955 | |
/* 102 */ // 1956 | |
/***/ function(module, exports, __webpack_require__) { // 1957 | |
// 1958 | |
'use strict'; // 1959 | |
var strong = __webpack_require__(103); // 1960 | |
// 1961 | |
// 23.1 Map Objects // 1962 | |
__webpack_require__(107)('Map', function(get){ // 1963 | |
return function Map(){ return get(this, arguments[0]); }; // 1964 | |
}, { // 1965 | |
// 23.1.3.6 Map.prototype.get(key) // 1966 | |
get: function get(key){ // 1967 | |
var entry = strong.getEntry(this, key); // 1968 | |
return entry && entry.v; // 1969 | |
}, // 1970 | |
// 23.1.3.9 Map.prototype.set(key, value) // 1971 | |
set: function set(key, value){ // 1972 | |
return strong.def(this, key === 0 ? 0 : key, value); // 1973 | |
} // 1974 | |
}, strong, true); // 1975 | |
// 1976 | |
/***/ }, // 1977 | |
/* 103 */ // 1978 | |
/***/ function(module, exports, __webpack_require__) { // 1979 | |
// 1980 | |
'use strict'; // 1981 | |
var $ = __webpack_require__(3) // 1982 | |
, hide = __webpack_require__(10) // 1983 | |
, ctx = __webpack_require__(35) // 1984 | |
, species = __webpack_require__(65) // 1985 | |
, strictNew = __webpack_require__(104) // 1986 | |
, defined = __webpack_require__(21) // 1987 | |
, forOf = __webpack_require__(105) // 1988 | |
, step = __webpack_require__(68) // 1989 | |
, ID = __webpack_require__(13)('id') // 1990 | |
, $has = __webpack_require__(5) // 1991 | |
, isObject = __webpack_require__(25) // 1992 | |
, isExtensible = Object.isExtensible || isObject // 1993 | |
, SUPPORT_DESC = __webpack_require__(6) // 1994 | |
, SIZE = SUPPORT_DESC ? '_s' : 'size' // 1995 | |
, id = 0; // 1996 | |
// 1997 | |
var fastKey = function(it, create){ // 1998 | |
// return primitive with prefix // 1999 | |
if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; // 2000 | |
if(!$has(it, ID)){ // 2001 | |
// can't set id to frozen object // 2002 | |
if(!isExtensible(it))return 'F'; // 2003 | |
// not necessary to add id // 2004 | |
if(!create)return 'E'; // 2005 | |
// add missing object id // 2006 | |
hide(it, ID, ++id); // 2007 | |
// return object id with prefix // 2008 | |
} return 'O' + it[ID]; // 2009 | |
}; // 2010 | |
// 2011 | |
var getEntry = function(that, key){ // 2012 | |
// fast case // 2013 | |
var index = fastKey(key), entry; // 2014 | |
if(index !== 'F')return that._i[index]; // 2015 | |
// frozen object case // 2016 | |
for(entry = that._f; entry; entry = entry.n){ // 2017 | |
if(entry.k == key)return entry; // 2018 | |
} // 2019 | |
}; // 2020 | |
// 2021 | |
module.exports = { // 2022 | |
getConstructor: function(wrapper, NAME, IS_MAP, ADDER){ // 2023 | |
var C = wrapper(function(that, iterable){ // 2024 | |
strictNew(that, C, NAME); // 2025 | |
that._i = $.create(null); // index // 2026 | |
that._f = undefined; // first entry // 2027 | |
that._l = undefined; // last entry // 2028 | |
that[SIZE] = 0; // size // 2029 | |
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); // 2030 | |
}); // 2031 | |
__webpack_require__(106)(C.prototype, { // 2032 | |
// 23.1.3.1 Map.prototype.clear() // 2033 | |
// 23.2.3.2 Set.prototype.clear() // 2034 | |
clear: function clear(){ // 2035 | |
for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){ // 2036 | |
entry.r = true; // 2037 | |
if(entry.p)entry.p = entry.p.n = undefined; // 2038 | |
delete data[entry.i]; // 2039 | |
} // 2040 | |
that._f = that._l = undefined; // 2041 | |
that[SIZE] = 0; // 2042 | |
}, // 2043 | |
// 23.1.3.3 Map.prototype.delete(key) // 2044 | |
// 23.2.3.4 Set.prototype.delete(value) // 2045 | |
'delete': function(key){ // 2046 | |
var that = this // 2047 | |
, entry = getEntry(that, key); // 2048 | |
if(entry){ // 2049 | |
var next = entry.n // 2050 | |
, prev = entry.p; // 2051 | |
delete that._i[entry.i]; // 2052 | |
entry.r = true; // 2053 | |
if(prev)prev.n = next; // 2054 | |
if(next)next.p = prev; // 2055 | |
if(that._f == entry)that._f = next; // 2056 | |
if(that._l == entry)that._l = prev; // 2057 | |
that[SIZE]--; // 2058 | |
} return !!entry; // 2059 | |
}, // 2060 | |
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) // 2061 | |
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) // 2062 | |
forEach: function forEach(callbackfn /*, that = undefined */){ // 2063 | |
var f = ctx(callbackfn, arguments[1], 3) // 2064 | |
, entry; // 2065 | |
while(entry = entry ? entry.n : this._f){ // 2066 | |
f(entry.v, entry.k, this); // 2067 | |
// revert to the last existing entry // 2068 | |
while(entry && entry.r)entry = entry.p; // 2069 | |
} // 2070 | |
}, // 2071 | |
// 23.1.3.7 Map.prototype.has(key) // 2072 | |
// 23.2.3.7 Set.prototype.has(value) // 2073 | |
has: function has(key){ // 2074 | |
return !!getEntry(this, key); // 2075 | |
} // 2076 | |
}); // 2077 | |
if(SUPPORT_DESC)$.setDesc(C.prototype, 'size', { // 2078 | |
get: function(){ // 2079 | |
return defined(this[SIZE]); // 2080 | |
} // 2081 | |
}); // 2082 | |
return C; // 2083 | |
}, // 2084 | |
def: function(that, key, value){ // 2085 | |
var entry = getEntry(that, key) // 2086 | |
, prev, index; // 2087 | |
// change existing entry // 2088 | |
if(entry){ // 2089 | |
entry.v = value; // 2090 | |
// create new entry // 2091 | |
} else { // 2092 | |
that._l = entry = { // 2093 | |
i: index = fastKey(key, true), // <- index // 2094 | |
k: key, // <- key // 2095 | |
v: value, // <- value // 2096 | |
p: prev = that._l, // <- previous entry // 2097 | |
n: undefined, // <- next entry // 2098 | |
r: false // <- removed // 2099 | |
}; // 2100 | |
if(!that._f)that._f = entry; // 2101 | |
if(prev)prev.n = entry; // 2102 | |
that[SIZE]++; // 2103 | |
// add to index // 2104 | |
if(index !== 'F')that._i[index] = entry; // 2105 | |
} return that; // 2106 | |
}, // 2107 | |
getEntry: getEntry, // 2108 | |
setStrong: function(C, NAME, IS_MAP){ // 2109 | |
// add .keys, .values, .entries, [@@iterator] // 2110 | |
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 // 2111 | |
__webpack_require__(54)(C, NAME, function(iterated, kind){ // 2112 | |
this._t = iterated; // target // 2113 | |
this._k = kind; // kind // 2114 | |
this._l = undefined; // previous // 2115 | |
}, function(){ // 2116 | |
var that = this // 2117 | |
, kind = that._k // 2118 | |
, entry = that._l; // 2119 | |
// revert to the last existing entry // 2120 | |
while(entry && entry.r)entry = entry.p; // 2121 | |
// get next entry // 2122 | |
if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){ // 2123 | |
// or finish the iteration // 2124 | |
that._t = undefined; // 2125 | |
return step(1); // 2126 | |
} // 2127 | |
// return step by kind // 2128 | |
if(kind == 'keys' )return step(0, entry.k); // 2129 | |
if(kind == 'values')return step(0, entry.v); // 2130 | |
return step(0, [entry.k, entry.v]); // 2131 | |
}, IS_MAP ? 'entries' : 'values' , !IS_MAP, true); // 2132 | |
// 2133 | |
// add [@@species], 23.1.2.2, 23.2.2.2 // 2134 | |
species(C); // 2135 | |
species(__webpack_require__(9)[NAME]); // for wrapper // 2136 | |
} // 2137 | |
}; // 2138 | |
// 2139 | |
/***/ }, // 2140 | |
/* 104 */ // 2141 | |
/***/ function(module, exports) { // 2142 | |
// 2143 | |
module.exports = function(it, Constructor, name){ // 2144 | |
if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!"); // 2145 | |
return it; // 2146 | |
}; // 2147 | |
// 2148 | |
/***/ }, // 2149 | |
/* 105 */ // 2150 | |
/***/ function(module, exports, __webpack_require__) { // 2151 | |
// 2152 | |
var ctx = __webpack_require__(35) // 2153 | |
, call = __webpack_require__(58) // 2154 | |
, isArrayIter = __webpack_require__(59) // 2155 | |
, anObject = __webpack_require__(26) // 2156 | |
, toLength = __webpack_require__(60) // 2157 | |
, getIterFn = __webpack_require__(61); // 2158 | |
module.exports = function(iterable, entries, fn, that){ // 2159 | |
var iterFn = getIterFn(iterable) // 2160 | |
, f = ctx(fn, that, entries ? 2 : 1) // 2161 | |
, index = 0 // 2162 | |
, length, step, iterator; // 2163 | |
if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!'); // 2164 | |
// fast case for arrays with default iterator // 2165 | |
if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){ // 2166 | |
entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); // 2167 | |
} else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){ // 2168 | |
call(iterator, f, step.value, entries); // 2169 | |
} // 2170 | |
}; // 2171 | |
// 2172 | |
/***/ }, // 2173 | |
/* 106 */ // 2174 | |
/***/ function(module, exports, __webpack_require__) { // 2175 | |
// 2176 | |
var $redef = __webpack_require__(12); // 2177 | |
module.exports = function(target, src){ // 2178 | |
for(var key in src)$redef(target, key, src[key]); // 2179 | |
return target; // 2180 | |
}; // 2181 | |
// 2182 | |
/***/ }, // 2183 | |
/* 107 */ // 2184 | |
/***/ function(module, exports, __webpack_require__) { // 2185 | |
// 2186 | |
'use strict'; // 2187 | |
var global = __webpack_require__(4) // 2188 | |
, $def = __webpack_require__(8) // 2189 | |
, forOf = __webpack_require__(105) // 2190 | |
, strictNew = __webpack_require__(104); // 2191 | |
// 2192 | |
module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ // 2193 | |
var Base = global[NAME] // 2194 | |
, C = Base // 2195 | |
, ADDER = IS_MAP ? 'set' : 'add' // 2196 | |
, proto = C && C.prototype // 2197 | |
, O = {}; // 2198 | |
var fixMethod = function(KEY){ // 2199 | |
var fn = proto[KEY]; // 2200 | |
__webpack_require__(12)(proto, KEY, // 2201 | |
KEY == 'delete' ? function(a){ return fn.call(this, a === 0 ? 0 : a); } // 2202 | |
: KEY == 'has' ? function has(a){ return fn.call(this, a === 0 ? 0 : a); } // 2203 | |
: KEY == 'get' ? function get(a){ return fn.call(this, a === 0 ? 0 : a); } // 2204 | |
: KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; } // 2205 | |
: function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; } // 2206 | |
); // 2207 | |
}; // 2208 | |
if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !__webpack_require__(7)(function(){ // 2209 | |
new C().entries().next(); // 2210 | |
}))){ // 2211 | |
// create collection constructor // 2212 | |
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); // 2213 | |
__webpack_require__(106)(C.prototype, methods); // 2214 | |
} else { // 2215 | |
var inst = new C // 2216 | |
, chain = inst[ADDER](IS_WEAK ? {} : -0, 1) // 2217 | |
, buggyZero; // 2218 | |
// wrap for init collections from iterable // 2219 | |
if(!__webpack_require__(62)(function(iter){ new C(iter); })){ // eslint-disable-line no-new // 2220 | |
C = wrapper(function(target, iterable){ // 2221 | |
strictNew(target, C, NAME); // 2222 | |
var that = new Base; // 2223 | |
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); // 2224 | |
return that; // 2225 | |
}); // 2226 | |
C.prototype = proto; // 2227 | |
proto.constructor = C; // 2228 | |
} // 2229 | |
IS_WEAK || inst.forEach(function(val, key){ // 2230 | |
buggyZero = 1 / key === -Infinity; // 2231 | |
}); // 2232 | |
// fix converting -0 key to +0 // 2233 | |
if(buggyZero){ // 2234 | |
fixMethod('delete'); // 2235 | |
fixMethod('has'); // 2236 | |
IS_MAP && fixMethod('get'); // 2237 | |
} // 2238 | |
// + fix .add & .set for chaining // 2239 | |
if(buggyZero || chain !== inst)fixMethod(ADDER); // 2240 | |
// weak collections should not contains .clear method // 2241 | |
if(IS_WEAK && proto.clear)delete proto.clear; // 2242 | |
} // 2243 | |
// 2244 | |
__webpack_require__(15)(C, NAME); // 2245 | |
// 2246 | |
O[NAME] = C; // 2247 | |
$def($def.G + $def.W + $def.F * (C != Base), O); // 2248 | |
// 2249 | |
if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP); // 2250 | |
// 2251 | |
return C; // 2252 | |
}; // 2253 | |
// 2254 | |
/***/ }, // 2255 | |
/* 108 */ // 2256 | |
/***/ function(module, exports, __webpack_require__) { // 2257 | |
// 2258 | |
__webpack_require__(37); // 2259 | |
__webpack_require__(51); // 2260 | |
__webpack_require__(101); // 2261 | |
__webpack_require__(109); // 2262 | |
module.exports = __webpack_require__(9).Set; // 2263 | |
// 2264 | |
/***/ }, // 2265 | |
/* 109 */ // 2266 | |
/***/ function(module, exports, __webpack_require__) { // 2267 | |
// 2268 | |
'use strict'; // 2269 | |
var strong = __webpack_require__(103); // 2270 | |
// 2271 | |
// 23.2 Set Objects // 2272 | |
__webpack_require__(107)('Set', function(get){ // 2273 | |
return function Set(){ return get(this, arguments[0]); }; // 2274 | |
}, { // 2275 | |
// 23.2.3.1 Set.prototype.add(value) // 2276 | |
add: function add(value){ // 2277 | |
return strong.def(this, value = value === 0 ? 0 : value, value); // 2278 | |
} // 2279 | |
}, strong); // 2280 | |
// 2281 | |
/***/ } // 2282 | |
/******/ ]); // 2283 | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['ecmascript-runtime'] = { | |
Symbol: Symbol, | |
Map: Map, | |
Set: Set | |
}; | |
/* Package-scope variables */ | |
var Promise; | |
(function(){ | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/promise/.npm/package/node_modules/meteor-promise/promise.bundle.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
/******/ (function(modules) { // webpackBootstrap // 1 | |
/******/ // The module cache // 2 | |
/******/ var installedModules = {}; // 3 | |
// 4 | |
/******/ // The require function // 5 | |
/******/ function __webpack_require__(moduleId) { // 6 | |
// 7 | |
/******/ // Check if module is in cache // 8 | |
/******/ if(installedModules[moduleId]) // 9 | |
/******/ return installedModules[moduleId].exports; // 10 | |
// 11 | |
/******/ // Create a new module (and put it into the cache) // 12 | |
/******/ var module = installedModules[moduleId] = { // 13 | |
/******/ exports: {}, // 14 | |
/******/ id: moduleId, // 15 | |
/******/ loaded: false // 16 | |
/******/ }; // 17 | |
// 18 | |
/******/ // Execute the module function // 19 | |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); // 20 | |
// 21 | |
/******/ // Flag the module as loaded // 22 | |
/******/ module.loaded = true; // 23 | |
// 24 | |
/******/ // Return the exports of the module // 25 | |
/******/ return module.exports; // 26 | |
/******/ } // 27 | |
// 28 | |
// 29 | |
/******/ // expose the modules object (__webpack_modules__) // 30 | |
/******/ __webpack_require__.m = modules; // 31 | |
// 32 | |
/******/ // expose the module cache // 33 | |
/******/ __webpack_require__.c = installedModules; // 34 | |
// 35 | |
/******/ // __webpack_public_path__ // 36 | |
/******/ __webpack_require__.p = ""; // 37 | |
// 38 | |
/******/ // Load entry module and return exports // 39 | |
/******/ return __webpack_require__(0); // 40 | |
/******/ }) // 41 | |
/************************************************************************/ // 42 | |
/******/ ([ // 43 | |
/* 0 */ // 44 | |
/***/ function(module, exports, __webpack_require__) { // 45 | |
// 46 | |
var MeteorPromise = __webpack_require__(1); // 47 | |
// 48 | |
var es6PromiseThen = MeteorPromise.prototype.then; // 49 | |
MeteorPromise.prototype.then = function (onResolved, onRejected) { // 50 | |
if (typeof Meteor === "object" && // 51 | |
typeof Meteor.bindEnvironment === "function") { // 52 | |
return es6PromiseThen.call( // 53 | |
this, // 54 | |
onResolved && Meteor.bindEnvironment(onResolved, raise), // 55 | |
onRejected && Meteor.bindEnvironment(onRejected, raise) // 56 | |
); // 57 | |
} // 58 | |
return es6PromiseThen.call(this, onResolved, onRejected); // 59 | |
}; // 60 | |
// 61 | |
function raise(exception) { // 62 | |
throw exception; // 63 | |
} // 64 | |
// 65 | |
Promise = MeteorPromise; // 66 | |
// 67 | |
// 68 | |
/***/ }, // 69 | |
/* 1 */ // 70 | |
/***/ function(module, exports, __webpack_require__) { // 71 | |
// 72 | |
/* WEBPACK VAR INJECTION */(function(global) {var hasOwn = Object.prototype.hasOwnProperty; // 73 | |
// 74 | |
var g = // 75 | |
typeof global === "object" ? global : // 76 | |
typeof window === "object" ? window : // 77 | |
typeof self === "object" ? self : this; // 78 | |
// 79 | |
var GlobalPromise = g.Promise; // 80 | |
var NpmPromise = __webpack_require__(2); // 81 | |
// 82 | |
function copyMethods(target, source) { // 83 | |
Object.keys(source).forEach(function (key) { // 84 | |
var value = source[key]; // 85 | |
if (typeof value === "function" && // 86 | |
! hasOwn.call(target, key)) { // 87 | |
target[key] = value; // 88 | |
} // 89 | |
}); // 90 | |
} // 91 | |
// 92 | |
if (typeof GlobalPromise === "function") { // 93 | |
copyMethods(GlobalPromise, NpmPromise); // 94 | |
copyMethods(GlobalPromise.prototype, NpmPromise.prototype); // 95 | |
module.exports = GlobalPromise; // 96 | |
} else { // 97 | |
module.exports = NpmPromise; // 98 | |
} // 99 | |
// 100 | |
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) // 101 | |
// 102 | |
/***/ }, // 103 | |
/* 2 */ // 104 | |
/***/ function(module, exports, __webpack_require__) { // 105 | |
// 106 | |
'use strict'; // 107 | |
// 108 | |
module.exports = __webpack_require__(3) // 109 | |
// 110 | |
// 111 | |
/***/ }, // 112 | |
/* 3 */ // 113 | |
/***/ function(module, exports, __webpack_require__) { // 114 | |
// 115 | |
'use strict'; // 116 | |
// 117 | |
module.exports = __webpack_require__(4); // 118 | |
__webpack_require__(6); // 119 | |
__webpack_require__(7); // 120 | |
__webpack_require__(8); // 121 | |
__webpack_require__(9); // 122 | |
// 123 | |
// 124 | |
/***/ }, // 125 | |
/* 4 */ // 126 | |
/***/ function(module, exports, __webpack_require__) { // 127 | |
// 128 | |
'use strict'; // 129 | |
// 130 | |
var asap = __webpack_require__(5); // 131 | |
// 132 | |
function noop() {} // 133 | |
// 134 | |
// States: // 135 | |
// // 136 | |
// 0 - pending // 137 | |
// 1 - fulfilled with _value // 138 | |
// 2 - rejected with _value // 139 | |
// 3 - adopted the state of another promise, _value // 140 | |
// // 141 | |
// once the state is no longer pending (0) it is immutable // 142 | |
// 143 | |
// All `_` prefixed properties will be reduced to `_{random number}` // 144 | |
// at build time to obfuscate them and discourage their use. // 145 | |
// We don't use symbols or Object.defineProperty to fully hide them // 146 | |
// because the performance isn't good enough. // 147 | |
// 148 | |
// 149 | |
// to avoid using try/catch inside critical functions, we // 150 | |
// extract them to here. // 151 | |
var LAST_ERROR = null; // 152 | |
var IS_ERROR = {}; // 153 | |
function getThen(obj) { // 154 | |
try { // 155 | |
return obj.then; // 156 | |
} catch (ex) { // 157 | |
LAST_ERROR = ex; // 158 | |
return IS_ERROR; // 159 | |
} // 160 | |
} // 161 | |
// 162 | |
function tryCallOne(fn, a) { // 163 | |
try { // 164 | |
return fn(a); // 165 | |
} catch (ex) { // 166 | |
LAST_ERROR = ex; // 167 | |
return IS_ERROR; // 168 | |
} // 169 | |
} // 170 | |
function tryCallTwo(fn, a, b) { // 171 | |
try { // 172 | |
fn(a, b); // 173 | |
} catch (ex) { // 174 | |
LAST_ERROR = ex; // 175 | |
return IS_ERROR; // 176 | |
} // 177 | |
} // 178 | |
// 179 | |
module.exports = Promise; // 180 | |
// 181 | |
function Promise(fn) { // 182 | |
if (typeof this !== 'object') { // 183 | |
throw new TypeError('Promises must be constructed via new'); // 184 | |
} // 185 | |
if (typeof fn !== 'function') { // 186 | |
throw new TypeError('not a function'); // 187 | |
} // 188 | |
this._37 = 0; // 189 | |
this._12 = null; // 190 | |
this._59 = []; // 191 | |
if (fn === noop) return; // 192 | |
doResolve(fn, this); // 193 | |
} // 194 | |
Promise._99 = noop; // 195 | |
// 196 | |
Promise.prototype.then = function(onFulfilled, onRejected) { // 197 | |
if (this.constructor !== Promise) { // 198 | |
return safeThen(this, onFulfilled, onRejected); // 199 | |
} // 200 | |
var res = new Promise(noop); // 201 | |
handle(this, new Handler(onFulfilled, onRejected, res)); // 202 | |
return res; // 203 | |
}; // 204 | |
// 205 | |
function safeThen(self, onFulfilled, onRejected) { // 206 | |
return new self.constructor(function (resolve, reject) { // 207 | |
var res = new Promise(noop); // 208 | |
res.then(resolve, reject); // 209 | |
handle(self, new Handler(onFulfilled, onRejected, res)); // 210 | |
}); // 211 | |
}; // 212 | |
function handle(self, deferred) { // 213 | |
while (self._37 === 3) { // 214 | |
self = self._12; // 215 | |
} // 216 | |
if (self._37 === 0) { // 217 | |
self._59.push(deferred); // 218 | |
return; // 219 | |
} // 220 | |
asap(function() { // 221 | |
var cb = self._37 === 1 ? deferred.onFulfilled : deferred.onRejected; // 222 | |
if (cb === null) { // 223 | |
if (self._37 === 1) { // 224 | |
resolve(deferred.promise, self._12); // 225 | |
} else { // 226 | |
reject(deferred.promise, self._12); // 227 | |
} // 228 | |
return; // 229 | |
} // 230 | |
var ret = tryCallOne(cb, self._12); // 231 | |
if (ret === IS_ERROR) { // 232 | |
reject(deferred.promise, LAST_ERROR); // 233 | |
} else { // 234 | |
resolve(deferred.promise, ret); // 235 | |
} // 236 | |
}); // 237 | |
} // 238 | |
function resolve(self, newValue) { // 239 | |
// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure | |
if (newValue === self) { // 241 | |
return reject( // 242 | |
self, // 243 | |
new TypeError('A promise cannot be resolved with itself.') // 244 | |
); // 245 | |
} // 246 | |
if ( // 247 | |
newValue && // 248 | |
(typeof newValue === 'object' || typeof newValue === 'function') // 249 | |
) { // 250 | |
var then = getThen(newValue); // 251 | |
if (then === IS_ERROR) { // 252 | |
return reject(self, LAST_ERROR); // 253 | |
} // 254 | |
if ( // 255 | |
then === self.then && // 256 | |
newValue instanceof Promise // 257 | |
) { // 258 | |
self._37 = 3; // 259 | |
self._12 = newValue; // 260 | |
finale(self); // 261 | |
return; // 262 | |
} else if (typeof then === 'function') { // 263 | |
doResolve(then.bind(newValue), self); // 264 | |
return; // 265 | |
} // 266 | |
} // 267 | |
self._37 = 1; // 268 | |
self._12 = newValue; // 269 | |
finale(self); // 270 | |
} // 271 | |
// 272 | |
function reject(self, newValue) { // 273 | |
self._37 = 2; // 274 | |
self._12 = newValue; // 275 | |
finale(self); // 276 | |
} // 277 | |
function finale(self) { // 278 | |
for (var i = 0; i < self._59.length; i++) { // 279 | |
handle(self, self._59[i]); // 280 | |
} // 281 | |
self._59 = null; // 282 | |
} // 283 | |
// 284 | |
function Handler(onFulfilled, onRejected, promise){ // 285 | |
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; // 286 | |
this.onRejected = typeof onRejected === 'function' ? onRejected : null; // 287 | |
this.promise = promise; // 288 | |
} // 289 | |
// 290 | |
/** // 291 | |
* Take a potentially misbehaving resolver function and make sure // 292 | |
* onFulfilled and onRejected are only called once. // 293 | |
* // 294 | |
* Makes no guarantees about asynchrony. // 295 | |
*/ // 296 | |
function doResolve(fn, promise) { // 297 | |
var done = false; // 298 | |
var res = tryCallTwo(fn, function (value) { // 299 | |
if (done) return; // 300 | |
done = true; // 301 | |
resolve(promise, value); // 302 | |
}, function (reason) { // 303 | |
if (done) return; // 304 | |
done = true; // 305 | |
reject(promise, reason); // 306 | |
}) // 307 | |
if (!done && res === IS_ERROR) { // 308 | |
done = true; // 309 | |
reject(promise, LAST_ERROR); // 310 | |
} // 311 | |
} // 312 | |
// 313 | |
// 314 | |
/***/ }, // 315 | |
/* 5 */ // 316 | |
/***/ function(module, exports) { // 317 | |
// 318 | |
/* WEBPACK VAR INJECTION */(function(global) {"use strict"; // 319 | |
// 320 | |
// Use the fastest means possible to execute a task in its own turn, with // 321 | |
// priority over other events including IO, animation, reflow, and redraw // 322 | |
// events in browsers. // 323 | |
// // 324 | |
// An exception thrown by a task will permanently interrupt the processing of // 325 | |
// subsequent tasks. The higher level `asap` function ensures that if an // 326 | |
// exception is thrown by a task, that the task queue will continue flushing as // 327 | |
// soon as possible, but if you use `rawAsap` directly, you are responsible to // 328 | |
// either ensure that no exceptions are thrown from your task, or to manually // 329 | |
// call `rawAsap.requestFlush` if an exception is thrown. // 330 | |
module.exports = rawAsap; // 331 | |
function rawAsap(task) { // 332 | |
if (!queue.length) { // 333 | |
requestFlush(); // 334 | |
flushing = true; // 335 | |
} // 336 | |
// Equivalent to push, but avoids a function call. // 337 | |
queue[queue.length] = task; // 338 | |
} // 339 | |
// 340 | |
var queue = []; // 341 | |
// Once a flush has been requested, no further calls to `requestFlush` are // 342 | |
// necessary until the next `flush` completes. // 343 | |
var flushing = false; // 344 | |
// `requestFlush` is an implementation-specific method that attempts to kick // 345 | |
// off a `flush` event as quickly as possible. `flush` will attempt to exhaust // 346 | |
// the event queue before yielding to the browser's own event loop. // 347 | |
var requestFlush; // 348 | |
// The position of the next task to execute in the task queue. This is // 349 | |
// preserved between calls to `flush` so that it can be resumed if // 350 | |
// a task throws an exception. // 351 | |
var index = 0; // 352 | |
// If a task schedules additional tasks recursively, the task queue can grow // 353 | |
// unbounded. To prevent memory exhaustion, the task queue will periodically // 354 | |
// truncate already-completed tasks. // 355 | |
var capacity = 1024; // 356 | |
// 357 | |
// The flush function processes all tasks that have been scheduled with // 358 | |
// `rawAsap` unless and until one of those tasks throws an exception. // 359 | |
// If a task throws an exception, `flush` ensures that its state will remain // 360 | |
// consistent and will resume where it left off when called again. // 361 | |
// However, `flush` does not make any arrangements to be called again if an // 362 | |
// exception is thrown. // 363 | |
function flush() { // 364 | |
while (index < queue.length) { // 365 | |
var currentIndex = index; // 366 | |
// Advance the index before calling the task. This ensures that we will // 367 | |
// begin flushing on the next task the task throws an error. // 368 | |
index = index + 1; // 369 | |
queue[currentIndex].call(); // 370 | |
// Prevent leaking memory for long chains of recursive calls to `asap`. // 371 | |
// If we call `asap` within tasks scheduled by `asap`, the queue will // 372 | |
// grow, but to avoid an O(n) walk for every task we execute, we don't // 373 | |
// shift tasks off the queue after they have been executed. // 374 | |
// Instead, we periodically shift 1024 tasks off the queue. // 375 | |
if (index > capacity) { // 376 | |
// Manually shift all values starting at the index back to the // 377 | |
// beginning of the queue. // 378 | |
for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { // 379 | |
queue[scan] = queue[scan + index]; // 380 | |
} // 381 | |
queue.length -= index; // 382 | |
index = 0; // 383 | |
} // 384 | |
} // 385 | |
queue.length = 0; // 386 | |
index = 0; // 387 | |
flushing = false; // 388 | |
} // 389 | |
// 390 | |
// `requestFlush` is implemented using a strategy based on data collected from // 391 | |
// every available SauceLabs Selenium web driver worker at time of writing. // 392 | |
// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 // 393 | |
// 394 | |
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // 395 | |
// have WebKitMutationObserver but not un-prefixed MutationObserver. // 396 | |
// Must use `global` instead of `window` to work in both frames and web // 397 | |
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. // 398 | |
var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver; // 399 | |
// 400 | |
// MutationObservers are desirable because they have high priority and work // 401 | |
// reliably everywhere they are implemented. // 402 | |
// They are implemented in all modern browsers. // 403 | |
// // 404 | |
// - Android 4-4.3 // 405 | |
// - Chrome 26-34 // 406 | |
// - Firefox 14-29 // 407 | |
// - Internet Explorer 11 // 408 | |
// - iPad Safari 6-7.1 // 409 | |
// - iPhone Safari 7-7.1 // 410 | |
// - Safari 6-7 // 411 | |
if (typeof BrowserMutationObserver === "function") { // 412 | |
requestFlush = makeRequestCallFromMutationObserver(flush); // 413 | |
// 414 | |
// MessageChannels are desirable because they give direct access to the HTML // 415 | |
// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera // 416 | |
// 11-12, and in web workers in many engines. // 417 | |
// Although message channels yield to any queued rendering and IO tasks, they // 418 | |
// would be better than imposing the 4ms delay of timers. // 419 | |
// However, they do not work reliably in Internet Explorer or Safari. // 420 | |
// 421 | |
// Internet Explorer 10 is the only browser that has setImmediate but does // 422 | |
// not have MutationObservers. // 423 | |
// Although setImmediate yields to the browser's renderer, it would be // 424 | |
// preferrable to falling back to setTimeout since it does not have // 425 | |
// the minimum 4ms penalty. // 426 | |
// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and // 427 | |
// Desktop to a lesser extent) that renders both setImmediate and // 428 | |
// MessageChannel useless for the purposes of ASAP. // 429 | |
// https://github.com/kriskowal/q/issues/396 // 430 | |
// 431 | |
// Timers are implemented universally. // 432 | |
// We fall back to timers in workers in most engines, and in foreground // 433 | |
// contexts in the following browsers. // 434 | |
// However, note that even this simple case requires nuances to operate in a // 435 | |
// broad spectrum of browsers. // 436 | |
// // 437 | |
// - Firefox 3-13 // 438 | |
// - Internet Explorer 6-9 // 439 | |
// - iPad Safari 4.3 // 440 | |
// - Lynx 2.8.7 // 441 | |
} else { // 442 | |
requestFlush = makeRequestCallFromTimer(flush); // 443 | |
} // 444 | |
// 445 | |
// `requestFlush` requests that the high priority event queue be flushed as // 446 | |
// soon as possible. // 447 | |
// This is useful to prevent an error thrown in a task from stalling the event // 448 | |
// queue if the exception handled by Node.js’s // 449 | |
// `process.on("uncaughtException")` or by a domain. // 450 | |
rawAsap.requestFlush = requestFlush; // 451 | |
// 452 | |
// To request a high priority event, we induce a mutation observer by toggling // 453 | |
// the text of a text node between "1" and "-1". // 454 | |
function makeRequestCallFromMutationObserver(callback) { // 455 | |
var toggle = 1; // 456 | |
var observer = new BrowserMutationObserver(callback); // 457 | |
var node = document.createTextNode(""); // 458 | |
observer.observe(node, {characterData: true}); // 459 | |
return function requestCall() { // 460 | |
toggle = -toggle; // 461 | |
node.data = toggle; // 462 | |
}; // 463 | |
} // 464 | |
// 465 | |
// The message channel technique was discovered by Malte Ubl and was the // 466 | |
// original foundation for this library. // 467 | |
// http://www.nonblocking.io/2011/06/windownexttick.html // 468 | |
// 469 | |
// Safari 6.0.5 (at least) intermittently fails to create message ports on a // 470 | |
// page's first load. Thankfully, this version of Safari supports // 471 | |
// MutationObservers, so we don't need to fall back in that case. // 472 | |
// 473 | |
// function makeRequestCallFromMessageChannel(callback) { // 474 | |
// var channel = new MessageChannel(); // 475 | |
// channel.port1.onmessage = callback; // 476 | |
// return function requestCall() { // 477 | |
// channel.port2.postMessage(0); // 478 | |
// }; // 479 | |
// } // 480 | |
// 481 | |
// For reasons explained above, we are also unable to use `setImmediate` // 482 | |
// under any circumstances. // 483 | |
// Even if we were, there is another bug in Internet Explorer 10. // 484 | |
// It is not sufficient to assign `setImmediate` to `requestFlush` because // 485 | |
// `setImmediate` must be called *by name* and therefore must be wrapped in a // 486 | |
// closure. // 487 | |
// Never forget. // 488 | |
// 489 | |
// function makeRequestCallFromSetImmediate(callback) { // 490 | |
// return function requestCall() { // 491 | |
// setImmediate(callback); // 492 | |
// }; // 493 | |
// } // 494 | |
// 495 | |
// Safari 6.0 has a problem where timers will get lost while the user is // 496 | |
// scrolling. This problem does not impact ASAP because Safari 6.0 supports // 497 | |
// mutation observers, so that implementation is used instead. // 498 | |
// However, if we ever elect to use timers in Safari, the prevalent work-around // 499 | |
// is to add a scroll event listener that calls for a flush. // 500 | |
// 501 | |
// `setTimeout` does not call the passed callback if the delay is less than // 502 | |
// approximately 7 in web workers in Firefox 8 through 18, and sometimes not // 503 | |
// even then. // 504 | |
// 505 | |
function makeRequestCallFromTimer(callback) { // 506 | |
return function requestCall() { // 507 | |
// We dispatch a timeout with a specified delay of 0 for engines that // 508 | |
// can reliably accommodate that request. This will usually be snapped // 509 | |
// to a 4 milisecond delay, but once we're flushing, there's no delay // 510 | |
// between events. // 511 | |
var timeoutHandle = setTimeout(handleTimer, 0); // 512 | |
// However, since this timer gets frequently dropped in Firefox // 513 | |
// workers, we enlist an interval handle that will try to fire // 514 | |
// an event 20 times per second until it succeeds. // 515 | |
var intervalHandle = setInterval(handleTimer, 50); // 516 | |
// 517 | |
function handleTimer() { // 518 | |
// Whichever timer succeeds will cancel both timers and // 519 | |
// execute the callback. // 520 | |
clearTimeout(timeoutHandle); // 521 | |
clearInterval(intervalHandle); // 522 | |
callback(); // 523 | |
} // 524 | |
}; // 525 | |
} // 526 | |
// 527 | |
// This is for `asap.js` only. // 528 | |
// Its name will be periodically randomized to break any code that depends on // 529 | |
// its existence. // 530 | |
rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; // 531 | |
// 532 | |
// ASAP was originally a nextTick shim included in Q. This was factored out // 533 | |
// into this ASAP package. It was later adapted to RSVP which made further // 534 | |
// amendments. These decisions, particularly to marginalize MessageChannel and // 535 | |
// to capture the MutationObserver implementation in a closure, were integrated // 536 | |
// back into ASAP proper. // 537 | |
// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js // 538 | |
// 539 | |
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) // 540 | |
// 541 | |
/***/ }, // 542 | |
/* 6 */ // 543 | |
/***/ function(module, exports, __webpack_require__) { // 544 | |
// 545 | |
'use strict'; // 546 | |
// 547 | |
var Promise = __webpack_require__(4); // 548 | |
// 549 | |
module.exports = Promise; // 550 | |
Promise.prototype.done = function (onFulfilled, onRejected) { // 551 | |
var self = arguments.length ? this.then.apply(this, arguments) : this; // 552 | |
self.then(null, function (err) { // 553 | |
setTimeout(function () { // 554 | |
throw err; // 555 | |
}, 0); // 556 | |
}); // 557 | |
}; // 558 | |
// 559 | |
// 560 | |
/***/ }, // 561 | |
/* 7 */ // 562 | |
/***/ function(module, exports, __webpack_require__) { // 563 | |
// 564 | |
'use strict'; // 565 | |
// 566 | |
var Promise = __webpack_require__(4); // 567 | |
// 568 | |
module.exports = Promise; // 569 | |
Promise.prototype['finally'] = function (f) { // 570 | |
return this.then(function (value) { // 571 | |
return Promise.resolve(f()).then(function () { // 572 | |
return value; // 573 | |
}); // 574 | |
}, function (err) { // 575 | |
return Promise.resolve(f()).then(function () { // 576 | |
throw err; // 577 | |
}); // 578 | |
}); // 579 | |
}; // 580 | |
// 581 | |
// 582 | |
/***/ }, // 583 | |
/* 8 */ // 584 | |
/***/ function(module, exports, __webpack_require__) { // 585 | |
// 586 | |
'use strict'; // 587 | |
// 588 | |
//This file contains the ES6 extensions to the core Promises/A+ API // 589 | |
// 590 | |
var Promise = __webpack_require__(4); // 591 | |
// 592 | |
module.exports = Promise; // 593 | |
// 594 | |
/* Static Functions */ // 595 | |
// 596 | |
var TRUE = valuePromise(true); // 597 | |
var FALSE = valuePromise(false); // 598 | |
var NULL = valuePromise(null); // 599 | |
var UNDEFINED = valuePromise(undefined); // 600 | |
var ZERO = valuePromise(0); // 601 | |
var EMPTYSTRING = valuePromise(''); // 602 | |
// 603 | |
function valuePromise(value) { // 604 | |
var p = new Promise(Promise._99); // 605 | |
p._37 = 1; // 606 | |
p._12 = value; // 607 | |
return p; // 608 | |
} // 609 | |
Promise.resolve = function (value) { // 610 | |
if (value instanceof Promise) return value; // 611 | |
// 612 | |
if (value === null) return NULL; // 613 | |
if (value === undefined) return UNDEFINED; // 614 | |
if (value === true) return TRUE; // 615 | |
if (value === false) return FALSE; // 616 | |
if (value === 0) return ZERO; // 617 | |
if (value === '') return EMPTYSTRING; // 618 | |
// 619 | |
if (typeof value === 'object' || typeof value === 'function') { // 620 | |
try { // 621 | |
var then = value.then; // 622 | |
if (typeof then === 'function') { // 623 | |
return new Promise(then.bind(value)); // 624 | |
} // 625 | |
} catch (ex) { // 626 | |
return new Promise(function (resolve, reject) { // 627 | |
reject(ex); // 628 | |
}); // 629 | |
} // 630 | |
} // 631 | |
return valuePromise(value); // 632 | |
}; // 633 | |
// 634 | |
Promise.all = function (arr) { // 635 | |
var args = Array.prototype.slice.call(arr); // 636 | |
// 637 | |
return new Promise(function (resolve, reject) { // 638 | |
if (args.length === 0) return resolve([]); // 639 | |
var remaining = args.length; // 640 | |
function res(i, val) { // 641 | |
if (val && (typeof val === 'object' || typeof val === 'function')) { // 642 | |
if (val instanceof Promise && val.then === Promise.prototype.then) { // 643 | |
while (val._37 === 3) { // 644 | |
val = val._12; // 645 | |
} // 646 | |
if (val._37 === 1) return res(i, val._12); // 647 | |
if (val._37 === 2) reject(val._12); // 648 | |
val.then(function (val) { // 649 | |
res(i, val); // 650 | |
}, reject); // 651 | |
return; // 652 | |
} else { // 653 | |
var then = val.then; // 654 | |
if (typeof then === 'function') { // 655 | |
var p = new Promise(then.bind(val)); // 656 | |
p.then(function (val) { // 657 | |
res(i, val); // 658 | |
}, reject); // 659 | |
return; // 660 | |
} // 661 | |
} // 662 | |
} // 663 | |
args[i] = val; // 664 | |
if (--remaining === 0) { // 665 | |
resolve(args); // 666 | |
} // 667 | |
} // 668 | |
for (var i = 0; i < args.length; i++) { // 669 | |
res(i, args[i]); // 670 | |
} // 671 | |
}); // 672 | |
}; // 673 | |
// 674 | |
Promise.reject = function (value) { // 675 | |
return new Promise(function (resolve, reject) { // 676 | |
reject(value); // 677 | |
}); // 678 | |
}; // 679 | |
// 680 | |
Promise.race = function (values) { // 681 | |
return new Promise(function (resolve, reject) { // 682 | |
values.forEach(function(value){ // 683 | |
Promise.resolve(value).then(resolve, reject); // 684 | |
}); // 685 | |
}); // 686 | |
}; // 687 | |
// 688 | |
/* Prototype Methods */ // 689 | |
// 690 | |
Promise.prototype['catch'] = function (onRejected) { // 691 | |
return this.then(null, onRejected); // 692 | |
}; // 693 | |
// 694 | |
// 695 | |
/***/ }, // 696 | |
/* 9 */ // 697 | |
/***/ function(module, exports, __webpack_require__) { // 698 | |
// 699 | |
'use strict'; // 700 | |
// 701 | |
// This file contains then/promise specific extensions that are only useful // 702 | |
// for node.js interop // 703 | |
// 704 | |
var Promise = __webpack_require__(4); // 705 | |
var asap = __webpack_require__(10); // 706 | |
// 707 | |
module.exports = Promise; // 708 | |
// 709 | |
/* Static Functions */ // 710 | |
// 711 | |
Promise.denodeify = function (fn, argumentCount) { // 712 | |
argumentCount = argumentCount || Infinity; // 713 | |
return function () { // 714 | |
var self = this; // 715 | |
var args = Array.prototype.slice.call(arguments, 0, // 716 | |
argumentCount > 0 ? argumentCount : 0); // 717 | |
return new Promise(function (resolve, reject) { // 718 | |
args.push(function (err, res) { // 719 | |
if (err) reject(err); // 720 | |
else resolve(res); // 721 | |
}) // 722 | |
var res = fn.apply(self, args); // 723 | |
if (res && // 724 | |
( // 725 | |
typeof res === 'object' || // 726 | |
typeof res === 'function' // 727 | |
) && // 728 | |
typeof res.then === 'function' // 729 | |
) { // 730 | |
resolve(res); // 731 | |
} // 732 | |
}) // 733 | |
} // 734 | |
} // 735 | |
Promise.nodeify = function (fn) { // 736 | |
return function () { // 737 | |
var args = Array.prototype.slice.call(arguments); // 738 | |
var callback = // 739 | |
typeof args[args.length - 1] === 'function' ? args.pop() : null; // 740 | |
var ctx = this; // 741 | |
try { // 742 | |
return fn.apply(this, arguments).nodeify(callback, ctx); // 743 | |
} catch (ex) { // 744 | |
if (callback === null || typeof callback == 'undefined') { // 745 | |
return new Promise(function (resolve, reject) { // 746 | |
reject(ex); // 747 | |
}); // 748 | |
} else { // 749 | |
asap(function () { // 750 | |
callback.call(ctx, ex); // 751 | |
}) // 752 | |
} // 753 | |
} // 754 | |
} // 755 | |
} // 756 | |
// 757 | |
Promise.prototype.nodeify = function (callback, ctx) { // 758 | |
if (typeof callback != 'function') return this; // 759 | |
// 760 | |
this.then(function (value) { // 761 | |
asap(function () { // 762 | |
callback.call(ctx, null, value); // 763 | |
}); // 764 | |
}, function (err) { // 765 | |
asap(function () { // 766 | |
callback.call(ctx, err); // 767 | |
}); // 768 | |
}); // 769 | |
} // 770 | |
// 771 | |
// 772 | |
/***/ }, // 773 | |
/* 10 */ // 774 | |
/***/ function(module, exports, __webpack_require__) { // 775 | |
// 776 | |
"use strict"; // 777 | |
// 778 | |
// rawAsap provides everything we need except exception management. // 779 | |
var rawAsap = __webpack_require__(5); // 780 | |
// RawTasks are recycled to reduce GC churn. // 781 | |
var freeTasks = []; // 782 | |
// We queue errors to ensure they are thrown in right order (FIFO). // 783 | |
// Array-as-queue is good enough here, since we are just dealing with exceptions. // 784 | |
var pendingErrors = []; // 785 | |
var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); // 786 | |
// 787 | |
function throwFirstError() { // 788 | |
if (pendingErrors.length) { // 789 | |
throw pendingErrors.shift(); // 790 | |
} // 791 | |
} // 792 | |
// 793 | |
/** // 794 | |
* Calls a task as soon as possible after returning, in its own event, with priority // 795 | |
* over other events like animation, reflow, and repaint. An error thrown from an // 796 | |
* event will not interrupt, nor even substantially slow down the processing of // 797 | |
* other events, but will be rather postponed to a lower priority event. // 798 | |
* @param {{call}} task A callable object, typically a function that takes no // 799 | |
* arguments. // 800 | |
*/ // 801 | |
module.exports = asap; // 802 | |
function asap(task) { // 803 | |
var rawTask; // 804 | |
if (freeTasks.length) { // 805 | |
rawTask = freeTasks.pop(); // 806 | |
} else { // 807 | |
rawTask = new RawTask(); // 808 | |
} // 809 | |
rawTask.task = task; // 810 | |
rawAsap(rawTask); // 811 | |
} // 812 | |
// 813 | |
// We wrap tasks with recyclable task objects. A task object implements // 814 | |
// `call`, just like a function. // 815 | |
function RawTask() { // 816 | |
this.task = null; // 817 | |
} // 818 | |
// 819 | |
// The sole purpose of wrapping the task is to catch the exception and recycle // 820 | |
// the task object after its single use. // 821 | |
RawTask.prototype.call = function () { // 822 | |
try { // 823 | |
this.task.call(); // 824 | |
} catch (error) { // 825 | |
if (asap.onerror) { // 826 | |
// This hook exists purely for testing purposes. // 827 | |
// Its name will be periodically randomized to break any code that // 828 | |
// depends on its existence. // 829 | |
asap.onerror(error); // 830 | |
} else { // 831 | |
// In a web browser, exceptions are not fatal. However, to avoid // 832 | |
// slowing down the queue of pending tasks, we rethrow the error in a // 833 | |
// lower priority turn. // 834 | |
pendingErrors.push(error); // 835 | |
requestErrorThrow(); // 836 | |
} // 837 | |
} finally { // 838 | |
this.task = null; // 839 | |
freeTasks[freeTasks.length] = this; // 840 | |
} // 841 | |
}; // 842 | |
// 843 | |
// 844 | |
/***/ } // 845 | |
/******/ ]); // 846 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.promise = { | |
Promise: Promise | |
}; | |
/* Package-scope variables */ | |
var Random; | |
(function(){ | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/random/random.js // | |
// // | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// We use cryptographically strong PRNGs (crypto.getRandomBytes() on the server, // | |
// window.crypto.getRandomValues() in the browser) when available. If these // | |
// PRNGs fail, we fall back to the Alea PRNG, which is not cryptographically // | |
// strong, and we seed it with various sources such as the date, Math.random, // | |
// and window size on the client. When using crypto.getRandomValues(), our // | |
// primitive is hexString(), from which we construct fraction(). When using // | |
// window.crypto.getRandomValues() or alea, the primitive is fraction and we use // | |
// that to construct hex string. // | |
// | |
if (Meteor.isServer) var nodeCrypto = Npm.require('crypto'); // 10 | |
// | |
// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript // | |
// for a full discussion and Alea implementation. // | |
var Alea = function () { // 15 | |
function Mash() { // 16 | |
var n = 0xefc8249d; // 17 | |
// | |
var mash = function (data) { // 19 | |
data = data.toString(); // 20 | |
for (var i = 0; i < data.length; i++) { // 21 | |
n += data.charCodeAt(i); // 22 | |
var h = 0.02519603282416938 * n; // 23 | |
n = h >>> 0; // 24 | |
h -= n; // 25 | |
h *= n; // 26 | |
n = h >>> 0; // 27 | |
h -= n; // 28 | |
n += h * 0x100000000; // 2^32 // 29 | |
} // | |
return (n >>> 0) * 2.3283064365386963e-10; // 2^-32 // 31 | |
}; // | |
// | |
mash.version = 'Mash 0.9'; // 34 | |
return mash; // 35 | |
} // | |
// | |
return (function (args) { // 38 | |
var s0 = 0; // 39 | |
var s1 = 0; // 40 | |
var s2 = 0; // 41 | |
var c = 1; // 42 | |
// | |
if (args.length == 0) { // 44 | |
args = [+new Date()]; // 45 | |
} // | |
var mash = Mash(); // 47 | |
s0 = mash(' '); // 48 | |
s1 = mash(' '); // 49 | |
s2 = mash(' '); // 50 | |
// | |
for (var i = 0; i < args.length; i++) { // 52 | |
s0 -= mash(args[i]); // 53 | |
if (s0 < 0) { // 54 | |
s0 += 1; // 55 | |
} // | |
s1 -= mash(args[i]); // 57 | |
if (s1 < 0) { // 58 | |
s1 += 1; // 59 | |
} // | |
s2 -= mash(args[i]); // 61 | |
if (s2 < 0) { // 62 | |
s2 += 1; // 63 | |
} // | |
} // | |
mash = null; // 66 | |
// | |
var random = function () { // 68 | |
var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32 // 69 | |
s0 = s1; // 70 | |
s1 = s2; // 71 | |
return s2 = t - (c = t | 0); // 72 | |
}; // | |
random.uint32 = function () { // 74 | |
return random() * 0x100000000; // 2^32 // 75 | |
}; // | |
random.fract53 = function () { // 77 | |
return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53 // 78 | |
}; // | |
random.version = 'Alea 0.9'; // 81 | |
random.args = args; // 82 | |
return random; // 83 | |
})(Array.prototype.slice.call(arguments)); // | |
}; // | |
// | |
var UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz"; // 88 | |
var BASE64_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789-_"; // 89 | |
// | |
// `type` is one of `RandomGenerator.Type` as defined below. // | |
// // | |
// options: // | |
// - seeds: (required, only for RandomGenerator.Type.ALEA) an array // | |
// whose items will be `toString`ed and used as the seed to the Alea // | |
// algorithm // | |
var RandomGenerator = function (type, options) { // 98 | |
var self = this; // 99 | |
self.type = type; // 100 | |
// | |
if (!RandomGenerator.Type[type]) { // 102 | |
throw new Error("Unknown random generator type: " + type); // 103 | |
} // | |
// | |
if (type === RandomGenerator.Type.ALEA) { // 106 | |
if (!options.seeds) { // 107 | |
throw new Error("No seeds were provided for Alea PRNG"); // 108 | |
} // | |
self.alea = Alea.apply(null, options.seeds); // 110 | |
} // | |
}; // | |
// | |
// Types of PRNGs supported by the `RandomGenerator` class // | |
RandomGenerator.Type = { // 115 | |
// Use Node's built-in `crypto.getRandomBytes` (cryptographically // | |
// secure but not seedable, runs only on the server). Reverts to // | |
// `crypto.getPseudoRandomBytes` in the extremely uncommon case that // | |
// there isn't enough entropy yet // | |
NODE_CRYPTO: "NODE_CRYPTO", // 120 | |
// | |
// Use non-IE browser's built-in `window.crypto.getRandomValues` // | |
// (cryptographically secure but not seedable, runs only in the // | |
// browser). // | |
BROWSER_CRYPTO: "BROWSER_CRYPTO", // 125 | |
// | |
// Use the *fast*, seedaable and not cryptographically secure // | |
// Alea algorithm // | |
ALEA: "ALEA" // 129 | |
}; // | |
// | |
RandomGenerator.prototype.fraction = function () { // 132 | |
var self = this; // 133 | |
if (self.type === RandomGenerator.Type.ALEA) { // 134 | |
return self.alea(); // 135 | |
} else if (self.type === RandomGenerator.Type.NODE_CRYPTO) { // | |
var numerator = parseInt(self.hexString(8), 16); // 137 | |
return numerator * 2.3283064365386963e-10; // 2^-32 // 138 | |
} else if (self.type === RandomGenerator.Type.BROWSER_CRYPTO) { // | |
var array = new Uint32Array(1); // 140 | |
window.crypto.getRandomValues(array); // 141 | |
return array[0] * 2.3283064365386963e-10; // 2^-32 // 142 | |
} else { // | |
throw new Error('Unknown random generator type: ' + self.type); // 144 | |
} // | |
}; // | |
// | |
RandomGenerator.prototype.hexString = function (digits) { // 148 | |
var self = this; // 149 | |
if (self.type === RandomGenerator.Type.NODE_CRYPTO) { // 150 | |
var numBytes = Math.ceil(digits / 2); // 151 | |
var bytes; // 152 | |
// Try to get cryptographically strong randomness. Fall back to // | |
// non-cryptographically strong if not available. // | |
try { // 155 | |
bytes = nodeCrypto.randomBytes(numBytes); // 156 | |
} catch (e) { // | |
// XXX should re-throw any error except insufficient entropy // | |
bytes = nodeCrypto.pseudoRandomBytes(numBytes); // 159 | |
} // | |
var result = bytes.toString("hex"); // 161 | |
// If the number of digits is odd, we'll have generated an extra 4 bits // | |
// of randomness, so we need to trim the last digit. // | |
return result.substring(0, digits); // 164 | |
} else { // | |
return this._randomString(digits, "0123456789abcdef"); // 166 | |
} // | |
}; // | |
// | |
RandomGenerator.prototype._randomString = function (charsCount, alphabet) { // 170 | |
var self = this; // 172 | |
var digits = []; // 173 | |
for (var i = 0; i < charsCount; i++) { // 174 | |
digits[i] = self.choice(alphabet); // 175 | |
} // | |
return digits.join(""); // 177 | |
}; // | |
// | |
RandomGenerator.prototype.id = function (charsCount) { // 180 | |
var self = this; // 181 | |
// 17 characters is around 96 bits of entropy, which is the amount of // | |
// state in the Alea PRNG. // | |
if (charsCount === undefined) charsCount = 17; // 184 | |
// | |
return self._randomString(charsCount, UNMISTAKABLE_CHARS); // 187 | |
}; // | |
// | |
RandomGenerator.prototype.secret = function (charsCount) { // 190 | |
var self = this; // 191 | |
// Default to 256 bits of entropy, or 43 characters at 6 bits per // | |
// character. // | |
if (charsCount === undefined) charsCount = 43; // 194 | |
return self._randomString(charsCount, BASE64_CHARS); // 196 | |
}; // | |
// | |
RandomGenerator.prototype.choice = function (arrayOrString) { // 199 | |
var index = Math.floor(this.fraction() * arrayOrString.length); // 200 | |
if (typeof arrayOrString === "string") return arrayOrString.substr(index, 1);else return arrayOrString[index]; // 201 | |
}; // | |
// | |
// instantiate RNG. Heuristically collect entropy from various sources when a // | |
// cryptographic PRNG isn't available. // | |
// | |
// client sources // | |
var height = typeof window !== 'undefined' && window.innerHeight || typeof document !== 'undefined' && document.documentElement && document.documentElement.clientHeight || typeof document !== 'undefined' && document.body && document.body.clientHeight || 1; | |
// | |
var width = typeof window !== 'undefined' && window.innerWidth || typeof document !== 'undefined' && document.documentElement && document.documentElement.clientWidth || typeof document !== 'undefined' && document.body && document.body.clientWidth || 1; | |
// | |
var agent = typeof navigator !== 'undefined' && navigator.userAgent || ""; // 229 | |
// | |
function createAleaGeneratorWithGeneratedSeed() { // 231 | |
return new RandomGenerator(RandomGenerator.Type.ALEA, { seeds: [new Date(), height, width, agent, Math.random()] }); | |
}; // | |
// | |
if (Meteor.isServer) { // 237 | |
Random = new RandomGenerator(RandomGenerator.Type.NODE_CRYPTO); // 238 | |
} else { // | |
if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) { // 240 | |
Random = new RandomGenerator(RandomGenerator.Type.BROWSER_CRYPTO); // 242 | |
} else { // | |
// On IE 10 and below, there's no browser crypto API // | |
// available. Fall back to Alea // | |
// // | |
// XXX looks like at the moment, we use Alea in IE 11 as well, // | |
// which has `window.msCrypto` instead of `window.crypto`. // | |
Random = createAleaGeneratorWithGeneratedSeed(); // 249 | |
} // | |
} // | |
// | |
// Create a non-cryptographically secure PRNG with a given seed (using // | |
// the Alea algorithm) // | |
Random.createWithSeeds = function () { // 255 | |
for (var _len = arguments.length, seeds = Array(_len), _key = 0; _key < _len; _key++) { // | |
seeds[_key] = arguments[_key]; // 255 | |
} // | |
// | |
if (seeds.length === 0) { // 256 | |
throw new Error("No seeds were provided"); // 257 | |
} // | |
return new RandomGenerator(RandomGenerator.Type.ALEA, { seeds: seeds }); // 259 | |
}; // | |
// | |
// Used like `Random`, but much faster and not cryptographically // | |
// secure // | |
Random.insecure = createAleaGeneratorWithGeneratedSeed(); // 264 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
(function(){ | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/random/deprecated.js // | |
// // | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Before this package existed, we used to use this Meteor.uuid() // | |
// implementing the RFC 4122 v4 UUID. It is no longer documented // | |
// and will go away. // | |
// XXX COMPAT WITH 0.5.6 // | |
Meteor.uuid = function () { // 5 | |
var HEX_DIGITS = "0123456789abcdef"; // 6 | |
var s = []; // 7 | |
for (var i = 0; i < 36; i++) { // 8 | |
s[i] = Random.choice(HEX_DIGITS); // 9 | |
} // | |
s[14] = "4"; // 11 | |
s[19] = HEX_DIGITS.substr(parseInt(s[19], 16) & 0x3 | 0x8, 1); // 12 | |
s[8] = s[13] = s[18] = s[23] = "-"; // 13 | |
// | |
var uuid = s.join(""); // 15 | |
return uuid; // 16 | |
}; // | |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package.random = { | |
Random: Random | |
}; | |
/* Package-scope variables */ | |
var MongoID; | |
(function(){ | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/mongo-id/packages/mongo-id.js // | |
// // | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/mongo-id/id.js // // 5 | |
// // // 6 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
MongoID = {}; // 1 // 9 | |
// 2 // 10 | |
MongoID._looksLikeObjectID = function (str) { // 3 // 11 | |
return str.length === 24 && str.match(/^[0-9a-f]*$/); // 4 // 12 | |
}; // 5 // 13 | |
// 6 // 14 | |
MongoID.ObjectID = function (hexString) { // 7 // 15 | |
//random-based impl of Mongo ObjectID // 8 // 16 | |
var self = this; // 9 // 17 | |
if (hexString) { // 10 | |
hexString = hexString.toLowerCase(); // 11 | |
if (!MongoID._looksLikeObjectID(hexString)) { // 12 | |
throw new Error("Invalid hexadecimal string for creating an ObjectID"); // 13 | |
} // 14 | |
// meant to work with _.isEqual(), which relies on structural equality // 15 | |
self._str = hexString; // 16 | |
} else { // 17 | |
self._str = Random.hexString(24); // 18 | |
} // 19 | |
}; // 20 | |
// 21 | |
MongoID.ObjectID.prototype.toString = function () { // 22 | |
var self = this; // 23 | |
return "ObjectID(\"" + self._str + "\")"; // 24 | |
}; // 25 | |
// 26 | |
MongoID.ObjectID.prototype.equals = function (other) { // 27 | |
var self = this; // 28 | |
return other instanceof MongoID.ObjectID && // 29 | |
self.valueOf() === other.valueOf(); // 30 | |
}; // 31 | |
// 32 | |
MongoID.ObjectID.prototype.clone = function () { // 33 | |
var self = this; // 34 | |
return new MongoID.ObjectID(self._str); // 35 | |
}; // 36 | |
// 37 | |
MongoID.ObjectID.prototype.typeName = function() { // 38 | |
return "oid"; // 39 | |
}; // 40 | |
// 41 | |
MongoID.ObjectID.prototype.getTimestamp = function() { // 42 | |
var self = this; // 43 | |
return parseInt(self._str.substr(0, 8), 16); // 44 | |
}; // 45 | |
// 46 | |
MongoID.ObjectID.prototype.valueOf = // 47 | |
MongoID.ObjectID.prototype.toJSONValue = // 48 | |
MongoID.ObjectID.prototype.toHexString = // 49 | |
function () { return this._str; }; // 50 | |
// 51 | |
EJSON.addType("oid", function (str) { // 52 | |
return new MongoID.ObjectID(str); // 53 | |
}); // 54 | |
// 55 | |
MongoID.idStringify = function (id) { // 56 | |
if (id instanceof MongoID.ObjectID) { // 57 | |
return id.valueOf(); // 58 | |
} else if (typeof id === 'string') { // 59 | |
if (id === "") { // 60 | |
return id; // 61 | |
} else if (id.substr(0, 1) === "-" || // escape previously dashed strings // 62 | |
id.substr(0, 1) === "~" || // escape escaped numbers, true, false // 63 | |
MongoID._looksLikeObjectID(id) || // escape object-id-form strings // 64 | |
id.substr(0, 1) === '{') { // escape object-form strings, for maybe implementing later // 73 | |
return "-" + id; // 66 | |
} else { // 67 | |
return id; // other strings go through unchanged. // 68 | |
} // 69 | |
} else if (id === undefined) { // 70 | |
return '-'; // 71 | |
} else if (typeof id === 'object' && id !== null) { // 72 | |
throw new Error("Meteor does not currently support objects other than ObjectID as ids"); // 73 | |
} else { // Numbers, true, false, null // 74 | |
return "~" + JSON.stringify(id); // 75 | |
} // 76 | |
}; // 77 | |
// 78 | |
// 79 | |
MongoID.idParse = function (id) { // 80 | |
if (id === "") { // 81 | |
return id; // 82 | |
} else if (id === '-') { // 83 | |
return undefined; // 84 | |
} else if (id.substr(0, 1) === '-') { // 85 | |
return id.substr(1); // 86 | |
} else if (id.substr(0, 1) === '~') { // 87 | |
return JSON.parse(id.substr(1)); // 88 | |
} else if (MongoID._looksLikeObjectID(id)) { // 89 | |
return new MongoID.ObjectID(id); // 90 | |
} else { // 91 | |
return id; // 92 | |
} // 93 | |
}; // 94 | |
// 95 | |
// 96 | |
//////////////////////////////////////////////////////////////////////////////////////////////////////// // 105 | |
// 106 | |
}).call(this); // 107 | |
// 108 | |
////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['mongo-id'] = { | |
MongoID: MongoID | |
}; | |
/* Package-scope variables */ | |
var DiffSequence; | |
(function(){ | |
//////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/diff-sequence/packages/diff-sequence.js // | |
// // | |
//////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
///////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/diff-sequence/diff.js // // 5 | |
// // // 6 | |
///////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
DiffSequence = {}; // 1 // 9 | |
// 2 // 10 | |
// ordered: bool. // 3 // 11 | |
// old_results and new_results: collections of documents. // 4 // 12 | |
// if ordered, they are arrays. // 5 // 13 | |
// if unordered, they are IdMaps // 6 // 14 | |
DiffSequence.diffQueryChanges = function (ordered, oldResults, newResults, // 7 // 15 | |
observer, options) { // 8 // 16 | |
if (ordered) // 9 // 17 | |
DiffSequence.diffQueryOrderedChanges( // 10 // 18 | |
oldResults, newResults, observer, options); // 11 // 19 | |
else // 12 // 20 | |
DiffSequence.diffQueryUnorderedChanges( // 13 // 21 | |
oldResults, newResults, observer, options); // 14 // 22 | |
}; // 15 // 23 | |
// 16 // 24 | |
DiffSequence.diffQueryUnorderedChanges = function (oldResults, newResults, // 17 // 25 | |
observer, options) { // 18 // 26 | |
options = options || {}; // 19 // 27 | |
var projectionFn = options.projectionFn || EJSON.clone; // 20 // 28 | |
// 21 // 29 | |
if (observer.movedBefore) { // 22 // 30 | |
throw new Error("_diffQueryUnordered called with a movedBefore observer!"); // 23 // 31 | |
} // 24 // 32 | |
// 25 // 33 | |
newResults.forEach(function (newDoc, id) { // 26 // 34 | |
var oldDoc = oldResults.get(id); // 27 // 35 | |
if (oldDoc) { // 28 // 36 | |
if (observer.changed && !EJSON.equals(oldDoc, newDoc)) { // 29 // 37 | |
var projectedNew = projectionFn(newDoc); // 30 // 38 | |
var projectedOld = projectionFn(oldDoc); // 31 // 39 | |
var changedFields = // 32 // 40 | |
DiffSequence.makeChangedFields(projectedNew, projectedOld); // 33 // 41 | |
if (! _.isEmpty(changedFields)) { // 34 // 42 | |
observer.changed(id, changedFields); // 35 // 43 | |
} // 36 // 44 | |
} // 37 // 45 | |
} else if (observer.added) { // 38 // 46 | |
var fields = projectionFn(newDoc); // 39 // 47 | |
delete fields._id; // 40 // 48 | |
observer.added(newDoc._id, fields); // 41 // 49 | |
} // 42 // 50 | |
}); // 43 // 51 | |
// 44 // 52 | |
if (observer.removed) { // 45 // 53 | |
oldResults.forEach(function (oldDoc, id) { // 46 // 54 | |
if (!newResults.has(id)) // 47 // 55 | |
observer.removed(id); // 48 // 56 | |
}); // 49 // 57 | |
} // 50 // 58 | |
}; // 51 // 59 | |
// 52 // 60 | |
// 53 // 61 | |
DiffSequence.diffQueryOrderedChanges = function (old_results, new_results, // 54 // 62 | |
observer, options) { // 55 // 63 | |
options = options || {}; // 56 // 64 | |
var projectionFn = options.projectionFn || EJSON.clone; // 57 // 65 | |
// 58 // 66 | |
var new_presence_of_id = {}; // 59 // 67 | |
_.each(new_results, function (doc) { // 60 // 68 | |
if (new_presence_of_id[doc._id]) // 61 // 69 | |
Meteor._debug("Duplicate _id in new_results"); // 62 // 70 | |
new_presence_of_id[doc._id] = true; // 63 // 71 | |
}); // 64 // 72 | |
// 65 // 73 | |
var old_index_of_id = {}; // 66 // 74 | |
_.each(old_results, function (doc, i) { // 67 // 75 | |
if (doc._id in old_index_of_id) // 68 // 76 | |
Meteor._debug("Duplicate _id in old_results"); // 69 // 77 | |
old_index_of_id[doc._id] = i; // 70 // 78 | |
}); // 71 // 79 | |
// 72 // 80 | |
// ALGORITHM: // 73 // 81 | |
// // 74 // 82 | |
// To determine which docs should be considered "moved" (and which // 75 // 83 | |
// merely change position because of other docs moving) we run // 76 // 84 | |
// a "longest common subsequence" (LCS) algorithm. The LCS of the // 77 // 85 | |
// old doc IDs and the new doc IDs gives the docs that should NOT be // 78 // 86 | |
// considered moved. // 79 // 87 | |
// 80 // 88 | |
// To actually call the appropriate callbacks to get from the old state to the // 81 // 89 | |
// new state: // 82 // 90 | |
// 83 // 91 | |
// First, we call removed() on all the items that only appear in the old // 84 // 92 | |
// state. // 85 // 93 | |
// 86 // 94 | |
// Then, once we have the items that should not move, we walk through the new // 87 // 95 | |
// results array group-by-group, where a "group" is a set of items that have // 88 // 96 | |
// moved, anchored on the end by an item that should not move. One by one, we // 89 // 97 | |
// move each of those elements into place "before" the anchoring end-of-group // 90 // 98 | |
// item, and fire changed events on them if necessary. Then we fire a changed // 91 // 99 | |
// event on the anchor, and move on to the next group. There is always at // 92 // 100 | |
// least one group; the last group is anchored by a virtual "null" id at the // 93 // 101 | |
// end. // 94 // 102 | |
// 95 // 103 | |
// Asymptotically: O(N k) where k is number of ops, or potentially // 96 // 104 | |
// O(N log N) if inner loop of LCS were made to be binary search. // 97 // 105 | |
// 98 // 106 | |
// 99 // 107 | |
//////// LCS (longest common sequence, with respect to _id) // 100 | |
// (see Wikipedia article on Longest Increasing Subsequence, // 101 | |
// where the LIS is taken of the sequence of old indices of the // 102 | |
// docs in new_results) // 103 | |
// // 104 | |
// unmoved: the output of the algorithm; members of the LCS, // 105 | |
// in the form of indices into new_results // 106 | |
var unmoved = []; // 107 | |
// max_seq_len: length of LCS found so far // 108 | |
var max_seq_len = 0; // 109 | |
// seq_ends[i]: the index into new_results of the last doc in a // 110 | |
// common subsequence of length of i+1 <= max_seq_len // 111 | |
var N = new_results.length; // 112 | |
var seq_ends = new Array(N); // 113 | |
// ptrs: the common subsequence ending with new_results[n] extends // 114 | |
// a common subsequence ending with new_results[ptr[n]], unless // 115 | |
// ptr[n] is -1. // 116 | |
var ptrs = new Array(N); // 117 | |
// virtual sequence of old indices of new results // 118 | |
var old_idx_seq = function(i_new) { // 119 | |
return old_index_of_id[new_results[i_new]._id]; // 120 | |
}; // 121 | |
// for each item in new_results, use it to extend a common subsequence // 122 | |
// of length j <= max_seq_len // 123 | |
for(var i=0; i<N; i++) { // 124 | |
if (old_index_of_id[new_results[i]._id] !== undefined) { // 125 | |
var j = max_seq_len; // 126 | |
// this inner loop would traditionally be a binary search, // 127 | |
// but scanning backwards we will likely find a subseq to extend // 128 | |
// pretty soon, bounded for example by the total number of ops. // 129 | |
// If this were to be changed to a binary search, we'd still want // 130 | |
// to scan backwards a bit as an optimization. // 131 | |
while (j > 0) { // 132 | |
if (old_idx_seq(seq_ends[j-1]) < old_idx_seq(i)) // 133 | |
break; // 134 | |
j--; // 135 | |
} // 136 | |
// 137 | |
ptrs[i] = (j === 0 ? -1 : seq_ends[j-1]); // 138 | |
seq_ends[j] = i; // 139 | |
if (j+1 > max_seq_len) // 140 | |
max_seq_len = j+1; // 141 | |
} // 142 | |
} // 143 | |
// 144 | |
// pull out the LCS/LIS into unmoved // 145 | |
var idx = (max_seq_len === 0 ? -1 : seq_ends[max_seq_len-1]); // 146 | |
while (idx >= 0) { // 147 | |
unmoved.push(idx); // 148 | |
idx = ptrs[idx]; // 149 | |
} // 150 | |
// the unmoved item list is built backwards, so fix that // 151 | |
unmoved.reverse(); // 152 | |
// 153 | |
// the last group is always anchored by the end of the result list, which is // 154 | |
// an id of "null" // 155 | |
unmoved.push(new_results.length); // 156 | |
// 157 | |
_.each(old_results, function (doc) { // 158 | |
if (!new_presence_of_id[doc._id]) // 159 | |
observer.removed && observer.removed(doc._id); // 160 | |
}); // 161 | |
// for each group of things in the new_results that is anchored by an unmoved // 162 | |
// element, iterate through the things before it. // 163 | |
var startOfGroup = 0; // 164 | |
_.each(unmoved, function (endOfGroup) { // 165 | |
var groupId = new_results[endOfGroup] ? new_results[endOfGroup]._id : null; // 166 | |
var oldDoc, newDoc, fields, projectedNew, projectedOld; // 167 | |
for (var i = startOfGroup; i < endOfGroup; i++) { // 168 | |
newDoc = new_results[i]; // 169 | |
if (!_.has(old_index_of_id, newDoc._id)) { // 170 | |
fields = projectionFn(newDoc); // 171 | |
delete fields._id; // 172 | |
observer.addedBefore && observer.addedBefore(newDoc._id, fields, groupId); // 181 | |
observer.added && observer.added(newDoc._id, fields); // 174 | |
} else { // 175 | |
// moved // 176 | |
oldDoc = old_results[old_index_of_id[newDoc._id]]; // 177 | |
projectedNew = projectionFn(newDoc); // 178 | |
projectedOld = projectionFn(oldDoc); // 179 | |
fields = DiffSequence.makeChangedFields(projectedNew, projectedOld); // 180 | |
if (!_.isEmpty(fields)) { // 181 | |
observer.changed && observer.changed(newDoc._id, fields); // 182 | |
} // 183 | |
observer.movedBefore && observer.movedBefore(newDoc._id, groupId); // 184 | |
} // 185 | |
} // 186 | |
if (groupId) { // 187 | |
newDoc = new_results[endOfGroup]; // 188 | |
oldDoc = old_results[old_index_of_id[newDoc._id]]; // 189 | |
projectedNew = projectionFn(newDoc); // 190 | |
projectedOld = projectionFn(oldDoc); // 191 | |
fields = DiffSequence.makeChangedFields(projectedNew, projectedOld); // 192 | |
if (!_.isEmpty(fields)) { // 193 | |
observer.changed && observer.changed(newDoc._id, fields); // 194 | |
} // 195 | |
} // 196 | |
startOfGroup = endOfGroup+1; // 197 | |
}); // 198 | |
// 199 | |
// 200 | |
}; // 201 | |
// 202 | |
// 203 | |
// General helper for diff-ing two objects. // 204 | |
// callbacks is an object like so: // 205 | |
// { leftOnly: function (key, leftValue) {...}, // 206 | |
// rightOnly: function (key, rightValue) {...}, // 207 | |
// both: function (key, leftValue, rightValue) {...}, // 208 | |
// } // 209 | |
DiffSequence.diffObjects = function (left, right, callbacks) { // 210 | |
_.each(left, function (leftValue, key) { // 211 | |
if (_.has(right, key)) // 212 | |
callbacks.both && callbacks.both(key, leftValue, right[key]); // 213 | |
else // 214 | |
callbacks.leftOnly && callbacks.leftOnly(key, leftValue); // 215 | |
}); // 216 | |
if (callbacks.rightOnly) { // 217 | |
_.each(right, function(rightValue, key) { // 218 | |
if (!_.has(left, key)) // 219 | |
callbacks.rightOnly(key, rightValue); // 220 | |
}); // 221 | |
} // 222 | |
}; // 223 | |
// 224 | |
// 225 | |
DiffSequence.makeChangedFields = function (newDoc, oldDoc) { // 226 | |
var fields = {}; // 227 | |
DiffSequence.diffObjects(oldDoc, newDoc, { // 228 | |
leftOnly: function (key, value) { // 229 | |
fields[key] = undefined; // 230 | |
}, // 231 | |
rightOnly: function (key, value) { // 232 | |
fields[key] = value; // 233 | |
}, // 234 | |
both: function (key, leftValue, rightValue) { // 235 | |
if (!EJSON.equals(leftValue, rightValue)) // 236 | |
fields[key] = rightValue; // 237 | |
} // 238 | |
}); // 239 | |
return fields; // 240 | |
}; // 241 | |
// 242 | |
DiffSequence.applyChanges = function (doc, changeFields) { // 243 | |
_.each(changeFields, function (value, key) { // 244 | |
if (value === undefined) // 245 | |
delete doc[key]; // 246 | |
else // 247 | |
doc[key] = value; // 248 | |
}); // 249 | |
}; // 250 | |
// 251 | |
// 252 | |
///////////////////////////////////////////////////////////////////////////////////// // 261 | |
// 262 | |
}).call(this); // 263 | |
// 264 | |
//////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['diff-sequence'] = { | |
DiffSequence: DiffSequence | |
}; | |
/* Package-scope variables */ | |
var ObserveSequence, seqChangedToEmpty, seqChangedToArray, seqChangedToCursor; | |
(function(){ | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/observe-sequence/packages/observe-sequence.js // | |
// // | |
////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function(){ // 1 | |
// 2 | |
/////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/observe-sequence/observe_sequence.js // // 5 | |
// // // 6 | |
/////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
var warn = function () { // 1 // 9 | |
if (ObserveSequence._suppressWarnings) { // 2 // 10 | |
ObserveSequence._suppressWarnings--; // 3 // 11 | |
} else { // 4 // 12 | |
if (typeof console !== 'undefined' && console.warn) // 5 // 13 | |
console.warn.apply(console, arguments); // 6 // 14 | |
// 7 // 15 | |
ObserveSequence._loggedWarnings++; // 8 // 16 | |
} // 9 // 17 | |
}; // 10 // 18 | |
// 11 // 19 | |
var idStringify = MongoID.idStringify; // 12 // 20 | |
var idParse = MongoID.idParse; // 13 // 21 | |
// 14 // 22 | |
ObserveSequence = { // 15 // 23 | |
_suppressWarnings: 0, // 16 // 24 | |
_loggedWarnings: 0, // 17 // 25 | |
// 18 // 26 | |
// A mechanism similar to cursor.observe which receives a reactive // 19 // 27 | |
// function returning a sequence type and firing appropriate callbacks // 20 // 28 | |
// when the value changes. // 21 // 29 | |
// // 22 // 30 | |
// @param sequenceFunc {Function} a reactive function returning a // 23 // 31 | |
// sequence type. The currently supported sequence types are: // 24 // 32 | |
// Array, Cursor, and null. // 25 // 33 | |
// // 26 // 34 | |
// @param callbacks {Object} similar to a specific subset of // 27 // 35 | |
// callbacks passed to `cursor.observe` // 28 // 36 | |
// (http://docs.meteor.com/#observe), with minor variations to // 29 // 37 | |
// support the fact that not all sequences contain objects with // 30 // 38 | |
// _id fields. Specifically: // 31 // 39 | |
// // 32 // 40 | |
// * addedAt(id, item, atIndex, beforeId) // 33 // 41 | |
// * changedAt(id, newItem, oldItem, atIndex) // 34 // 42 | |
// * removedAt(id, oldItem, atIndex) // 35 // 43 | |
// * movedTo(id, item, fromIndex, toIndex, beforeId) // 36 // 44 | |
// // 37 // 45 | |
// @returns {Object(stop: Function)} call 'stop' on the return value // 38 // 46 | |
// to stop observing this sequence function. // 39 // 47 | |
// // 40 // 48 | |
// We don't make any assumptions about our ability to compare sequence // 41 // 49 | |
// elements (ie, we don't assume EJSON.equals works; maybe there is extra // 42 // 50 | |
// state/random methods on the objects) so unlike cursor.observe, we may // 43 // 51 | |
// sometimes call changedAt() when nothing actually changed. // 44 // 52 | |
// XXX consider if we *can* make the stronger assumption and avoid // 45 // 53 | |
// no-op changedAt calls (in some cases?) // 46 // 54 | |
// // 47 // 55 | |
// XXX currently only supports the callbacks used by our // 48 // 56 | |
// implementation of {{#each}}, but this can be expanded. // 49 // 57 | |
// // 50 // 58 | |
// XXX #each doesn't use the indices (though we'll eventually need // 51 // 59 | |
// a way to get them when we support `@index`), but calling // 52 // 60 | |
// `cursor.observe` causes the index to be calculated on every // 53 // 61 | |
// callback using a linear scan (unless you turn it off by passing // 54 // 62 | |
// `_no_indices`). Any way to avoid calculating indices on a pure // 55 // 63 | |
// cursor observe like we used to? // 56 // 64 | |
observe: function (sequenceFunc, callbacks) { // 57 // 65 | |
var lastSeq = null; // 58 // 66 | |
var activeObserveHandle = null; // 59 // 67 | |
// 60 // 68 | |
// 'lastSeqArray' contains the previous value of the sequence // 61 // 69 | |
// we're observing. It is an array of objects with '_id' and // 62 // 70 | |
// 'item' fields. 'item' is the element in the array, or the // 63 // 71 | |
// document in the cursor. // 64 // 72 | |
// // 65 // 73 | |
// '_id' is whichever of the following is relevant, unless it has // 66 // 74 | |
// already appeared -- in which case it's randomly generated. // 67 // 75 | |
// // 68 // 76 | |
// * if 'item' is an object: // 69 // 77 | |
// * an '_id' field, if present // 70 // 78 | |
// * otherwise, the index in the array // 71 // 79 | |
// // 72 // 80 | |
// * if 'item' is a number or string, use that value // 73 // 81 | |
// // 74 // 82 | |
// XXX this can be generalized by allowing {{#each}} to accept a // 75 // 83 | |
// general 'key' argument which could be a function, a dotted // 76 // 84 | |
// field name, or the special @index value. // 77 // 85 | |
var lastSeqArray = []; // elements are objects of form {_id, item} // 78 // 86 | |
var computation = Tracker.autorun(function () { // 79 // 87 | |
var seq = sequenceFunc(); // 80 // 88 | |
// 81 // 89 | |
Tracker.nonreactive(function () { // 82 // 90 | |
var seqArray; // same structure as `lastSeqArray` above. // 83 // 91 | |
// 84 // 92 | |
if (activeObserveHandle) { // 85 // 93 | |
// If we were previously observing a cursor, replace lastSeqArray with // 94 | |
// more up-to-date information. Then stop the old observe. // 87 // 95 | |
lastSeqArray = _.map(lastSeq.fetch(), function (doc) { // 88 // 96 | |
return {_id: doc._id, item: doc}; // 89 // 97 | |
}); // 90 // 98 | |
activeObserveHandle.stop(); // 91 // 99 | |
activeObserveHandle = null; // 92 // 100 | |
} // 93 // 101 | |
// 94 // 102 | |
if (!seq) { // 95 // 103 | |
seqArray = seqChangedToEmpty(lastSeqArray, callbacks); // 96 // 104 | |
} else if (seq instanceof Array) { // 97 // 105 | |
seqArray = seqChangedToArray(lastSeqArray, seq, callbacks); // 98 // 106 | |
} else if (isStoreCursor(seq)) { // 99 // 107 | |
var result /* [seqArray, activeObserveHandle] */ = // 100 | |
seqChangedToCursor(lastSeqArray, seq, callbacks); // 101 | |
seqArray = result[0]; // 102 | |
activeObserveHandle = result[1]; // 103 | |
} else { // 104 | |
throw badSequenceError(); // 105 | |
} // 106 | |
// 107 | |
diffArray(lastSeqArray, seqArray, callbacks); // 108 | |
lastSeq = seq; // 109 | |
lastSeqArray = seqArray; // 110 | |
}); // 111 | |
}); // 112 | |
// 113 | |
return { // 114 | |
stop: function () { // 115 | |
computation.stop(); // 116 | |
if (activeObserveHandle) // 117 | |
activeObserveHandle.stop(); // 118 | |
} // 119 | |
}; // 120 | |
}, // 121 | |
// 122 | |
// Fetch the items of `seq` into an array, where `seq` is of one of the // 123 | |
// sequence types accepted by `observe`. If `seq` is a cursor, a // 124 | |
// dependency is established. // 125 | |
fetch: function (seq) { // 126 | |
if (!seq) { // 127 | |
return []; // 128 | |
} else if (seq instanceof Array) { // 129 | |
return seq; // 130 | |
} else if (isStoreCursor(seq)) { // 131 | |
return seq.fetch(); // 132 | |
} else { // 133 | |
throw badSequenceError(); // 134 | |
} // 135 | |
} // 136 | |
}; // 137 | |
// 138 | |
var badSequenceError = function () { // 139 | |
return new Error("{{#each}} currently only accepts " + // 140 | |
"arrays, cursors or falsey values."); // 141 | |
}; // 142 | |
// 143 | |
var isStoreCursor = function (cursor) { // 144 | |
return cursor && _.isObject(cursor) && // 145 | |
_.isFunction(cursor.observe) && _.isFunction(cursor.fetch); // 146 | |
}; // 147 | |
// 148 | |
// Calculates the differences between `lastSeqArray` and // 149 | |
// `seqArray` and calls appropriate functions from `callbacks`. // 150 | |
// Reuses Minimongo's diff algorithm implementation. // 151 | |
var diffArray = function (lastSeqArray, seqArray, callbacks) { // 152 | |
var diffFn = Package['diff-sequence'].DiffSequence.diffQueryOrderedChanges; // 153 | |
var oldIdObjects = []; // 154 | |
var newIdObjects = []; // 155 | |
var posOld = {}; // maps from idStringify'd ids // 156 | |
var posNew = {}; // ditto // 157 | |
var posCur = {}; // 158 | |
var lengthCur = lastSeqArray.length; // 159 | |
// 160 | |
_.each(seqArray, function (doc, i) { // 161 | |
newIdObjects.push({_id: doc._id}); // 162 | |
posNew[idStringify(doc._id)] = i; // 163 | |
}); // 164 | |
_.each(lastSeqArray, function (doc, i) { // 165 | |
oldIdObjects.push({_id: doc._id}); // 166 | |
posOld[idStringify(doc._id)] = i; // 167 | |
posCur[idStringify(doc._id)] = i; // 168 | |
}); // 169 | |
// 170 | |
// Arrays can contain arbitrary objects. We don't diff the // 171 | |
// objects. Instead we always fire 'changedAt' callback on every // 172 | |
// object. The consumer of `observe-sequence` should deal with // 173 | |
// it appropriately. // 174 | |
diffFn(oldIdObjects, newIdObjects, { // 175 | |
addedBefore: function (id, doc, before) { // 176 | |
var position = before ? posCur[idStringify(before)] : lengthCur; // 177 | |
// 178 | |
if (before) { // 179 | |
// If not adding at the end, we need to update indexes. // 180 | |
// XXX this can still be improved greatly! // 181 | |
_.each(posCur, function (pos, id) { // 182 | |
if (pos >= position) // 183 | |
posCur[id]++; // 184 | |
}); // 185 | |
} // 186 | |
// 187 | |
lengthCur++; // 188 | |
posCur[idStringify(id)] = position; // 189 | |
// 190 | |
callbacks.addedAt( // 191 | |
id, // 192 | |
seqArray[posNew[idStringify(id)]].item, // 193 | |
position, // 194 | |
before); // 195 | |
}, // 196 | |
movedBefore: function (id, before) { // 197 | |
if (id === before) // 198 | |
return; // 199 | |
// 200 | |
var oldPosition = posCur[idStringify(id)]; // 201 | |
var newPosition = before ? posCur[idStringify(before)] : lengthCur; // 202 | |
// 203 | |
// Moving the item forward. The new element is losing one position as it // 204 | |
// was removed from the old position before being inserted at the new // 205 | |
// position. // 206 | |
// Ex.: 0 *1* 2 3 4 // 207 | |
// 0 2 3 *1* 4 // 208 | |
// The original issued callback is "1" before "4". // 209 | |
// The position of "1" is 1, the position of "4" is 4. // 210 | |
// The generated move is (1) -> (3) // 211 | |
if (newPosition > oldPosition) { // 212 | |
newPosition--; // 213 | |
} // 214 | |
// 215 | |
// Fix up the positions of elements between the old and the new positions // 216 | |
// of the moved element. // 217 | |
// // 218 | |
// There are two cases: // 219 | |
// 1. The element is moved forward. Then all the positions in between // 220 | |
// are moved back. // 221 | |
// 2. The element is moved back. Then the positions in between *and* the // 230 | |
// element that is currently standing on the moved element's future // 223 | |
// position are moved forward. // 224 | |
_.each(posCur, function (elCurPosition, id) { // 225 | |
if (oldPosition < elCurPosition && elCurPosition < newPosition) // 226 | |
posCur[id]--; // 227 | |
else if (newPosition <= elCurPosition && elCurPosition < oldPosition) // 228 | |
posCur[id]++; // 229 | |
}); // 230 | |
// 231 | |
// Finally, update the position of the moved element. // 232 | |
posCur[idStringify(id)] = newPosition; // 233 | |
// 234 | |
callbacks.movedTo( // 235 | |
id, // 236 | |
seqArray[posNew[idStringify(id)]].item, // 237 | |
oldPosition, // 238 | |
newPosition, // 239 | |
before); // 240 | |
}, // 241 | |
removed: function (id) { // 242 | |
var prevPosition = posCur[idStringify(id)]; // 243 | |
// 244 | |
_.each(posCur, function (pos, id) { // 245 | |
if (pos >= prevPosition) // 246 | |
posCur[id]--; // 247 | |
}); // 248 | |
// 249 | |
delete posCur[idStringify(id)]; // 250 | |
lengthCur--; // 251 | |
// 252 | |
callbacks.removedAt( // 253 | |
id, // 254 | |
lastSeqArray[posOld[idStringify(id)]].item, // 255 | |
prevPosition); // 256 | |
} // 257 | |
}); // 258 | |
// 259 | |
_.each(posNew, function (pos, idString) { // 260 | |
var id = idParse(idString); // 261 | |
if (_.has(posOld, idString)) { // 262 | |
// specifically for primitive types, compare equality before // 263 | |
// firing the 'changedAt' callback. otherwise, always fire it // 264 | |
// because doing a deep EJSON comparison is not guaranteed to // 265 | |
// work (an array can contain arbitrary objects, and 'transform' // 266 | |
// can be used on cursors). also, deep diffing is not // 267 | |
// necessarily the most efficient (if only a specific subfield // 268 | |
// of the object is later accessed). // 269 | |
var newItem = seqArray[pos].item; // 270 | |
var oldItem = lastSeqArray[posOld[idString]].item; // 271 | |
// 272 | |
if (typeof newItem === 'object' || newItem !== oldItem) // 273 | |
callbacks.changedAt(id, newItem, oldItem, pos); // 274 | |
} // 275 | |
}); // 276 | |
}; // 277 | |
// 278 | |
seqChangedToEmpty = function (lastSeqArray, callbacks) { // 279 | |
return []; // 280 | |
}; // 281 | |
// 282 | |
seqChangedToArray = function (lastSeqArray, array, callbacks) { // 283 | |
var idsUsed = {}; // 284 | |
var seqArray = _.map(array, function (item, index) { // 285 | |
var id; // 286 | |
if (typeof item === 'stri |
View raw
(Sorry about that, but we can’t show files that are this big right now.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment