{"hunk": {"id": 0, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-apollo/server/main.js", "type": "replace", "edit_start_line_idx": 24}, "file": "import { Meteor } from 'meteor/meteor';\nimport { LinksCollection } from '/imports/api/links';\n\nasync function insertLink({ title, url }) {\n await LinksCollection.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (LinksCollection.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-typescript/server/main.ts", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.9900028705596924, 0.2479565590620041, 0.0001766245113685727, 0.0008233974222093821, 0.4284208118915558]}
{"hunk": {"id": 0, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-apollo/server/main.js", "type": "replace", "edit_start_line_idx": 24}, "file": "import {LooseParser} from \"./state\"\nimport {isDummy} from \"./parseutil\"\nimport {getLineInfo, tokTypes as tt} from \"../index\"\n\nconst lp = LooseParser.prototype\n\nlp.parseTopLevel = function() {\n let node = this.startNodeAt(this.options.locations ? [0, getLineInfo(this.input, 0)] : 0)\n node.body = []\n while (this.tok.type !== tt.eof) node.body.push(this.parseStatement())\n this.last = this.tok\n if (this.options.ecmaVersion >= 6) {\n node.sourceType = this.options.sourceType\n }\n return this.finishNode(node, \"Program\")\n}\n\nlp.parseStatement = function() {\n let starttype = this.tok.type, node = this.startNode(), kind\n\n if (this.toks.isLet()) {\n starttype = tt._var\n kind = \"let\"\n }\n\n switch (starttype) {\n case tt._break: case tt._continue:\n this.next()\n let isBreak = starttype === tt._break\n if (this.semicolon() || this.canInsertSemicolon()) {\n node.label = null\n } else {\n node.label = this.tok.type === tt.name ? this.parseIdent() : null\n this.semicolon()\n }\n return this.finishNode(node, isBreak ? \"BreakStatement\" : \"ContinueStatement\")\n\n case tt._debugger:\n this.next()\n this.semicolon()\n return this.finishNode(node, \"DebuggerStatement\")\n\n case tt._do:\n this.next()\n node.body = this.parseStatement()\n node.test = this.eat(tt._while) ? this.parseParenExpression() : this.dummyIdent()\n this.semicolon()\n return this.finishNode(node, \"DoWhileStatement\")\n\n case tt._for:\n this.next()\n this.pushCx()\n this.expect(tt.parenL)\n if (this.tok.type === tt.semi) return this.parseFor(node, null)\n let isLet = this.toks.isLet()\n if (isLet || this.tok.type === tt._var || this.tok.type === tt._const) {\n let init = this.parseVar(true, isLet ? \"let\" : this.tok.value)\n if (init.declarations.length === 1 && (this.tok.type === tt._in || this.isContextual(\"of\"))) {\n return this.parseForIn(node, init)\n }\n return this.parseFor(node, init)\n }\n let init = this.parseExpression(true)\n if (this.tok.type === tt._in || this.isContextual(\"of\"))\n return this.parseForIn(node, this.toAssignable(init))\n return this.parseFor(node, init)\n\n case tt._function:\n this.next()\n return this.parseFunction(node, true)\n\n case tt._if:\n this.next()\n node.test = this.parseParenExpression()\n node.consequent = this.parseStatement()\n node.alternate = this.eat(tt._else) ? this.parseStatement() : null\n return this.finishNode(node, \"IfStatement\")\n\n case tt._return:\n this.next()\n if (this.eat(tt.semi) || this.canInsertSemicolon()) node.argument = null\n else { node.argument = this.parseExpression(); this.semicolon() }\n return this.finishNode(node, \"ReturnStatement\")\n\n case tt._switch:\n let blockIndent = this.curIndent, line = this.curLineStart\n this.next()\n node.discriminant = this.parseParenExpression()\n node.cases = []\n this.pushCx()\n this.expect(tt.braceL)\n\n let cur\n while (!this.closes(tt.braceR, blockIndent, line, true)) {\n if (this.tok.type === tt._case || this.tok.type === tt._default) {\n let isCase = this.tok.type === tt._case\n if (cur) this.finishNode(cur, \"SwitchCase\")\n node.cases.push(cur = this.startNode())\n cur.consequent = []\n this.next()\n if (isCase) cur.test = this.parseExpression()\n else cur.test = null\n this.expect(tt.colon)\n } else {\n if (!cur) {\n node.cases.push(cur = this.startNode())\n cur.consequent = []\n cur.test = null\n }\n cur.consequent.push(this.parseStatement())\n }\n }\n if (cur) this.finishNode(cur, \"SwitchCase\")\n this.popCx()\n this.eat(tt.braceR)\n return this.finishNode(node, \"SwitchStatement\")\n\n case tt._throw:\n this.next()\n node.argument = this.parseExpression()\n this.semicolon()\n return this.finishNode(node, \"ThrowStatement\")\n\n case tt._try:\n this.next()\n node.block = this.parseBlock()\n node.handler = null\n if (this.tok.type === tt._catch) {\n let clause = this.startNode()\n this.next()\n this.expect(tt.parenL)\n clause.param = this.toAssignable(this.parseExprAtom(), true)\n this.expect(tt.parenR)\n clause.body = this.parseBlock()\n node.handler = this.finishNode(clause, \"CatchClause\")\n }\n node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null\n if (!node.handler && !node.finalizer) return node.block\n return this.finishNode(node, \"TryStatement\")\n\n case tt._var:\n case tt._const:\n return this.parseVar(false, kind || this.tok.value)\n\n case tt._while:\n this.next()\n node.test = this.parseParenExpression()\n node.body = this.parseStatement()\n return this.finishNode(node, \"WhileStatement\")\n\n case tt._with:\n this.next()\n node.object = this.parseParenExpression()\n node.body = this.parseStatement()\n return this.finishNode(node, \"WithStatement\")\n\n case tt.braceL:\n return this.parseBlock()\n\n case tt.semi:\n this.next()\n return this.finishNode(node, \"EmptyStatement\")\n\n case tt._class:\n return this.parseClass(true)\n\n case tt._import:\n return this.parseImport()\n\n case tt._export:\n return this.parseExport()\n\n default:\n if (this.toks.isAsyncFunction()) {\n this.next()\n this.next()\n return this.parseFunction(node, true, true)\n }\n let expr = this.parseExpression()\n if (isDummy(expr)) {\n this.next()\n if (this.tok.type === tt.eof) return this.finishNode(node, \"EmptyStatement\")\n return this.parseStatement()\n } else if (starttype === tt.name && expr.type === \"Identifier\" && this.eat(tt.colon)) {\n node.body = this.parseStatement()\n node.label = expr\n return this.finishNode(node, \"LabeledStatement\")\n } else {\n node.expression = expr\n this.semicolon()\n return this.finishNode(node, \"ExpressionStatement\")\n }\n }\n}\n\nlp.parseBlock = function() {\n let node = this.startNode()\n this.pushCx()\n this.expect(tt.braceL)\n let blockIndent = this.curIndent, line = this.curLineStart\n node.body = []\n while (!this.closes(tt.braceR, blockIndent, line, true))\n node.body.push(this.parseStatement())\n this.popCx()\n this.eat(tt.braceR)\n return this.finishNode(node, \"BlockStatement\")\n}\n\nlp.parseFor = function(node, init) {\n node.init = init\n node.test = node.update = null\n if (this.eat(tt.semi) && this.tok.type !== tt.semi) node.test = this.parseExpression()\n if (this.eat(tt.semi) && this.tok.type !== tt.parenR) node.update = this.parseExpression()\n this.popCx()\n this.expect(tt.parenR)\n node.body = this.parseStatement()\n return this.finishNode(node, \"ForStatement\")\n}\n\nlp.parseForIn = function(node, init) {\n let type = this.tok.type === tt._in ? \"ForInStatement\" : \"ForOfStatement\"\n this.next()\n node.left = init\n node.right = this.parseExpression()\n this.popCx()\n this.expect(tt.parenR)\n node.body = this.parseStatement()\n return this.finishNode(node, type)\n}\n\nlp.parseVar = function(noIn, kind) {\n let node = this.startNode()\n node.kind = kind\n this.next()\n node.declarations = []\n do {\n let decl = this.startNode()\n decl.id = this.options.ecmaVersion >= 6 ? this.toAssignable(this.parseExprAtom(), true) : this.parseIdent()\n decl.init = this.eat(tt.eq) ? this.parseMaybeAssign(noIn) : null\n node.declarations.push(this.finishNode(decl, \"VariableDeclarator\"))\n } while (this.eat(tt.comma))\n if (!node.declarations.length) {\n let decl = this.startNode()\n decl.id = this.dummyIdent()\n node.declarations.push(this.finishNode(decl, \"VariableDeclarator\"))\n }\n if (!noIn) this.semicolon()\n return this.finishNode(node, \"VariableDeclaration\")\n}\n\nlp.parseClass = function(isStatement) {\n let node = this.startNode()\n this.next()\n if (this.tok.type === tt.name) node.id = this.parseIdent()\n else if (isStatement) node.id = this.dummyIdent()\n else node.id = null\n node.superClass = this.eat(tt._extends) ? this.parseExpression() : null\n node.body = this.startNode()\n node.body.body = []\n this.pushCx()\n let indent = this.curIndent + 1, line = this.curLineStart\n this.eat(tt.braceL)\n if (this.curIndent + 1 < indent) { indent = this.curIndent; line = this.curLineStart }\n while (!this.closes(tt.braceR, indent, line)) {\n if (this.semicolon()) continue\n let method = this.startNode(), isGenerator, isAsync\n if (this.options.ecmaVersion >= 6) {\n method.static = false\n isGenerator = this.eat(tt.star)\n }\n this.parsePropertyName(method)\n if (isDummy(method.key)) { if (isDummy(this.parseMaybeAssign())) this.next(); this.eat(tt.comma); continue }\n if (method.key.type === \"Identifier\" && !method.computed && method.key.name === \"static\" &&\n (this.tok.type != tt.parenL && this.tok.type != tt.braceL)) {\n method.static = true\n isGenerator = this.eat(tt.star)\n this.parsePropertyName(method)\n } else {\n method.static = false\n }\n if (!method.computed &&\n method.key.type === \"Identifier\" && method.key.name === \"async\" && this.tok.type !== tt.parenL &&\n !this.canInsertSemicolon()) {\n this.parsePropertyName(method)\n isAsync = true\n } else {\n isAsync = false\n }\n if (this.options.ecmaVersion >= 5 && method.key.type === \"Identifier\" &&\n !method.computed && (method.key.name === \"get\" || method.key.name === \"set\") &&\n this.tok.type !== tt.parenL && this.tok.type !== tt.braceL) {\n method.kind = method.key.name\n this.parsePropertyName(method)\n method.value = this.parseMethod(false)\n } else {\n if (!method.computed && !method.static && !isGenerator && !isAsync && (\n method.key.type === \"Identifier\" && method.key.name === \"constructor\" ||\n method.key.type === \"Literal\" && method.key.value === \"constructor\")) {\n method.kind = \"constructor\"\n } else {\n method.kind = \"method\"\n }\n method.value = this.parseMethod(isGenerator, isAsync)\n }\n node.body.body.push(this.finishNode(method, \"MethodDefinition\"))\n }\n this.popCx()\n if (!this.eat(tt.braceR)) {\n // If there is no closing brace, make the node span to the start\n // of the next token (this is useful for Tern)\n this.last.end = this.tok.start\n if (this.options.locations) this.last.loc.end = this.tok.loc.start\n }\n this.semicolon()\n this.finishNode(node.body, \"ClassBody\")\n return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\n}\n\nlp.parseFunction = function(node, isStatement, isAsync) {\n let oldInAsync = this.inAsync\n this.initFunction(node)\n if (this.options.ecmaVersion >= 6) {\n node.generator = this.eat(tt.star)\n }\n if (this.options.ecmaVersion >= 8) {\n node.async = !!isAsync\n }\n if (this.tok.type === tt.name) node.id = this.parseIdent()\n else if (isStatement) node.id = this.dummyIdent()\n this.inAsync = node.async\n node.params = this.parseFunctionParams()\n node.body = this.parseBlock()\n this.inAsync = oldInAsync\n return this.finishNode(node, isStatement ? \"FunctionDeclaration\" : \"FunctionExpression\")\n}\n\nlp.parseExport = function() {\n let node = this.startNode()\n this.next()\n if (this.eat(tt.star)) {\n node.source = this.eatContextual(\"from\") ? this.parseExprAtom() : this.dummyString()\n return this.finishNode(node, \"ExportAllDeclaration\")\n }\n if (this.eat(tt._default)) {\n // export default (function foo() {}) // This is FunctionExpression.\n let isParenL = this.tok.type === tt.parenL\n let expr = this.parseMaybeAssign()\n if (!isParenL && expr.id) {\n switch (expr.type) {\n case \"FunctionExpression\": expr.type = \"FunctionDeclaration\"; break\n case \"ClassExpression\": expr.type = \"ClassDeclaration\"; break\n }\n }\n node.declaration = expr\n this.semicolon()\n return this.finishNode(node, \"ExportDefaultDeclaration\")\n }\n if (this.tok.type.keyword || this.toks.isLet() || this.toks.isAsyncFunction()) {\n node.declaration = this.parseStatement()\n node.specifiers = []\n node.source = null\n } else {\n node.declaration = null\n node.specifiers = this.parseExportSpecifierList()\n node.source = this.eatContextual(\"from\") ? this.parseExprAtom() : null\n this.semicolon()\n }\n return this.finishNode(node, \"ExportNamedDeclaration\")\n}\n\nlp.parseImport = function() {\n let node = this.startNode()\n this.next()\n if (this.tok.type === tt.string) {\n node.specifiers = []\n node.source = this.parseExprAtom()\n node.kind = ''\n } else {\n let elt\n if (this.tok.type === tt.name && this.tok.value !== \"from\") {\n elt = this.startNode()\n elt.local = this.parseIdent()\n this.finishNode(elt, \"ImportDefaultSpecifier\")\n this.eat(tt.comma)\n }\n node.specifiers = this.parseImportSpecifierList()\n node.source = this.eatContextual(\"from\") && this.tok.type == tt.string ? this.parseExprAtom() : this.dummyString()\n if (elt) node.specifiers.unshift(elt)\n }\n this.semicolon()\n return this.finishNode(node, \"ImportDeclaration\")\n}\n\nlp.parseImportSpecifierList = function() {\n let elts = []\n if (this.tok.type === tt.star) {\n let elt = this.startNode()\n this.next()\n elt.local = this.eatContextual(\"as\") ? this.parseIdent() : this.dummyIdent()\n elts.push(this.finishNode(elt, \"ImportNamespaceSpecifier\"))\n } else {\n let indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart\n this.pushCx()\n this.eat(tt.braceL)\n if (this.curLineStart > continuedLine) continuedLine = this.curLineStart\n while (!this.closes(tt.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {\n let elt = this.startNode()\n if (this.eat(tt.star)) {\n elt.local = this.eatContextual(\"as\") ? this.parseIdent() : this.dummyIdent()\n this.finishNode(elt, \"ImportNamespaceSpecifier\")\n } else {\n if (this.isContextual(\"from\")) break\n elt.imported = this.parseIdent()\n if (isDummy(elt.imported)) break\n elt.local = this.eatContextual(\"as\") ? this.parseIdent() : elt.imported\n this.finishNode(elt, \"ImportSpecifier\")\n }\n elts.push(elt)\n this.eat(tt.comma)\n }\n this.eat(tt.braceR)\n this.popCx()\n }\n return elts\n}\n\nlp.parseExportSpecifierList = function() {\n let elts = []\n let indent = this.curIndent, line = this.curLineStart, continuedLine = this.nextLineStart\n this.pushCx()\n this.eat(tt.braceL)\n if (this.curLineStart > continuedLine) continuedLine = this.curLineStart\n while (!this.closes(tt.braceR, indent + (this.curLineStart <= continuedLine ? 1 : 0), line)) {\n if (this.isContextual(\"from\")) break\n let elt = this.startNode()\n elt.local = this.parseIdent()\n if (isDummy(elt.local)) break\n elt.exported = this.eatContextual(\"as\") ? this.parseIdent() : elt.local\n this.finishNode(elt, \"ExportSpecifier\")\n elts.push(elt)\n this.eat(tt.comma)\n }\n this.eat(tt.braceR)\n this.popCx()\n return elts\n}\n", "file_path": "tools/tests/apps/modules/packages/modules-test-package/node_modules/acorn/src/loose/statement.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0001788317458704114, 0.0001750691735651344, 0.00016697359387762845, 0.0001752664684318006, 2.49162894760957e-06]}
{"hunk": {"id": 0, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-apollo/server/main.js", "type": "replace", "edit_start_line_idx": 24}, "file": "global.Buffer = global.Buffer || require(\"buffer\").Buffer;\nmodule.exports = require(\"crypto-browserify\");\n", "file_path": "npm-packages/meteor-node-stubs/wrappers/crypto.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0001730589719954878, 0.0001730589719954878, 0.0001730589719954878, 0.0001730589719954878, 0.0]}
{"hunk": {"id": 0, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-apollo/server/main.js", "type": "replace", "edit_start_line_idx": 24}, "file": "console.warn(\n \"The `facebook` package has been deprecated.\\n\" +\n \"\\n\" +\n \"To use the `Facebook` symbol, add the `facebook-oauth` package\\n\" +\n \"and import from it.\\n\" +\n \"\\n\" +\n \"If you need the Blaze OAuth configuration UI, add\\n\" +\n \"`facebook-config-ui` alongside `accounts-ui`.\"\n);\n", "file_path": "packages/deprecated/facebook/deprecation_notice.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00017031581955961883, 0.00017031581955961883, 0.00017031581955961883, 0.00017031581955961883, 0.0]}
{"hunk": {"id": 1, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-full/imports/startup/server/fixtures.js", "type": "replace", "edit_start_line_idx": 19}, "file": "// Fill the DB with example data on startup\n\nimport { Meteor } from 'meteor/meteor';\nimport { Links } from '../../api/links/links.js';\n\nasync function insertLink({ title, url }) {\n await Links.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (Links.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-full/imports/startup/server/fixtures.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.8406789302825928, 0.21966272592544556, 0.00017200529691763222, 0.018899967893958092, 0.3588419556617737]}
{"hunk": {"id": 1, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-full/imports/startup/server/fixtures.js", "type": "replace", "edit_start_line_idx": 19}, "file": "// This exports object was created in pre.js. Now copy the `_` object from it\n// into the package-scope variable `_`, which will get exported.\n_ = exports._;\n", "file_path": "packages/underscore/post.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00017393160669598728, 0.00017393160669598728, 0.00017393160669598728, 0.00017393160669598728, 0.0]}
{"hunk": {"id": 1, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-full/imports/startup/server/fixtures.js", "type": "replace", "edit_start_line_idx": 19}, "file": "import {reservedWords, keywords} from \"./identifier\"\nimport {types as tt} from \"./tokentype\"\nimport {lineBreak} from \"./whitespace\"\nimport {getOptions} from \"./options\"\n\n// Registered plugins\nexport const plugins = {}\n\nfunction keywordRegexp(words) {\n return new RegExp(\"^(\" + words.replace(/ /g, \"|\") + \")$\")\n}\n\nexport class Parser {\n constructor(options, input, startPos) {\n this.options = options = getOptions(options)\n this.sourceFile = options.sourceFile\n this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])\n let reserved = \"\"\n if (!options.allowReserved) {\n for (let v = options.ecmaVersion;; v--)\n if (reserved = reservedWords[v]) break\n if (options.sourceType == \"module\") reserved += \" await\"\n }\n this.reservedWords = keywordRegexp(reserved)\n let reservedStrict = (reserved ? reserved + \" \" : \"\") + reservedWords.strict\n this.reservedWordsStrict = keywordRegexp(reservedStrict)\n this.reservedWordsStrictBind = keywordRegexp(reservedStrict + \" \" + reservedWords.strictBind)\n this.input = String(input)\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n this.containsEsc = false\n\n // Load plugins\n this.loadPlugins(options.plugins)\n\n // Set up token state\n\n // The current position of the tokenizer in the input.\n if (startPos) {\n this.pos = startPos\n this.lineStart = this.input.lastIndexOf(\"\\n\", startPos - 1) + 1\n this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length\n } else {\n this.pos = this.lineStart = 0\n this.curLine = 1\n }\n\n // Properties of the current token:\n // Its type\n this.type = tt.eof\n // For tokens that include more information than their type, the value\n this.value = null\n // Its start and end offset\n this.start = this.end = this.pos\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n this.startLoc = this.endLoc = this.curPosition()\n\n // Position information for the previous token\n this.lastTokEndLoc = this.lastTokStartLoc = null\n this.lastTokStart = this.lastTokEnd = this.pos\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n this.context = this.initialContext()\n this.exprAllowed = true\n\n // Figure out if it's a module code.\n this.strict = this.inModule = options.sourceType === \"module\"\n\n // Used to signify the start of a potential arrow function\n this.potentialArrowAt = -1\n\n // Flags to track whether we are in a function, a generator, an async function.\n this.inFunction = this.inGenerator = this.inAsync = false\n // Positions to delayed-check that yield/await does not exist in default parameters.\n this.yieldPos = this.awaitPos = 0\n // Labels in scope.\n this.labels = []\n\n // If enabled, skip leading hashbang line.\n if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!')\n this.skipLineComment(2)\n }\n\n // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them\n isKeyword(word) { return this.keywords.test(word) }\n isReservedWord(word) { return this.reservedWords.test(word) }\n\n extend(name, f) {\n this[name] = f(this[name])\n }\n\n loadPlugins(pluginConfigs) {\n for (let name in pluginConfigs) {\n let plugin = plugins[name]\n if (!plugin) throw new Error(\"Plugin '\" + name + \"' not found\")\n plugin(this, pluginConfigs[name])\n }\n }\n\n parse() {\n let node = this.options.program || this.startNode()\n this.nextToken()\n return this.parseTopLevel(node)\n }\n}\n", "file_path": "tools/tests/apps/modules/packages/modules-test-package/node_modules/acorn/src/state.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0001744582987157628, 0.00017167018086183816, 0.00016207562293857336, 0.00017266828217543662, 3.2450213893753244e-06]}
{"hunk": {"id": 1, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-full/imports/startup/server/fixtures.js", "type": "replace", "edit_start_line_idx": 19}, "file": "These packages are no longer actively maintained by Meteor Software. Seek\ncommunity alternatives instead.\n\nNote that these packages still exist in atmosphere, and you can still\nbuild a package that depends on one of them by specifying an explicit\npackage version.\n", "file_path": "packages/deprecated/README", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0001652988576097414, 0.0001652988576097414, 0.0001652988576097414, 0.0001652988576097414, 0.0]}
{"hunk": {"id": 2, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-react/server/main.js", "type": "replace", "edit_start_line_idx": 17}, "file": "import { Meteor } from 'meteor/meteor';\nimport { LinksCollection } from '/imports/api/links';\n\nasync function insertLink({ title, url }) {\n await LinksCollection.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (LinksCollection.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-typescript/server/main.ts", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.9742137789726257, 0.24511779844760895, 0.00017881147505249828, 0.0030392948538064957, 0.42094749212265015]}
{"hunk": {"id": 2, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-react/server/main.js", "type": "replace", "edit_start_line_idx": 17}, "file": "{\n \"format\": \"web-program-pre1\",\n \"version\": \"127.0.0.1_root_url\",\n \"cordovaCompatibilityVersions\": {\n \"android\": \"4017747ca6b4f460f33b121e439b7a11a070205a\",\n \"ios\": \"0abe549f2adbcf6cd295428aefea628ebe69666a\"\n },\n \"manifest\": []\n}\n", "file_path": "npm-packages/cordova-plugin-meteor-webapp/tests/fixtures/downloadable_versions/127.0.0.1_root_url/manifest.json", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00016865019279066473, 0.00016865019279066473, 0.00016865019279066473, 0.00016865019279066473, 0.0]}
{"hunk": {"id": 2, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-react/server/main.js", "type": "replace", "edit_start_line_idx": 17}, "file": "---\ntitle: logging\ndescription: Documentation of Meteor's logging utility\n---\n\nThe `logging` package provides a standartised way for you to log and display in console various message from your application.\nThe added benefit is that among other data it will show you the location where the log was fired,\nthis is useful during debugging to quickly locate where the message is coming from.\n\nStart by installing the package:\n```shell\nmeteor add logging\n```\n\nYou can then import the utility anywhere in you code like this:\n```javascript\nimport { Log } from 'meteor/logging'\n```\n\nYou can then call the logging functions in one of the following ways:\n```javascript\nLog('starting up') // or Log.info('starting up')\nLog.error('error message')\nLog.warn('warning')\nLog.debug('this will show only in development')\n```\n\nBesides passing in strings, you can also pass in objects. This has few exceptions and special functions associated.\nFirst in the root of the object the following keys are not allowed: \n```javascript\n'time', 'timeInexact', 'level', 'file', 'line', 'program', 'originApp', 'satellite', 'stderr'\n```\n\nOn the other hand there is `message` and `app`, which are also reserved, but they will display in more prominent manner:\n```javascript\nLog.info({message: 'warning', app: 'DESKTOP', error: { property1: 'foo', property2: 'bar', property3: { foo: 'bar' }} })\n```\nwill turn into:\n```shell\nE20200519-17:57:41.655(9) [DESKTOP] (main.js:36) warning {\"error\":{\"property1\":\"foo\",\"property2\":\"bar\",\"property3\":{\"foo\":\"bar\"}}}\n```\n\nThe display of each log is color coded. Info is `blue`, warn is `magenta`, debug is `green` and error is in `red`.\n\n### Log.debug\nThe `Log.debug()` logging is different from the other calls as these messages will not be displayed in production.\n", "file_path": "docs/source/packages/logging.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00022308471670839936, 0.00017867707356344908, 0.00016242775018326938, 0.0001683567970758304, 2.246811709483154e-05]}
{"hunk": {"id": 2, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-react/server/main.js", "type": "replace", "edit_start_line_idx": 17}, "file": "local\n", "file_path": "tools/tests/old/empty-app/.meteor/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0001783998595783487, 0.0001783998595783487, 0.0001783998595783487, 0.0001783998595783487, 0.0]}
{"hunk": {"id": 3, "code_window": ["\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-typescript/server/main.ts", "type": "replace", "edit_start_line_idx": 17}, "file": "import { Meteor } from 'meteor/meteor';\nimport { LinksCollection } from '/imports/api/links';\n\nasync function insertLink({ title, url }) {\n await LinksCollection.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (LinksCollection.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-typescript/server/main.ts", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.9868729114532471, 0.25498783588409424, 0.0001729601644910872, 0.016452731564641, 0.4227447807788849]}
{"hunk": {"id": 3, "code_window": ["\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-typescript/server/main.ts", "type": "replace", "edit_start_line_idx": 17}, "file": "import { Meteor } from \"meteor/meteor\";\nimport { Tinytest } from \"meteor/tinytest\";\n\nTinytest.add(\"coffeescript - presence\", function(test) {\n test.isTrue(Meteor.__COFFEESCRIPT_PRESENT);\n});\nTinytest.add(\"literate coffeescript - presence\", function(test) {\n test.isTrue(Meteor.__LITCOFFEESCRIPT_PRESENT);\n test.isTrue(Meteor.__COFFEEMDSCRIPT_PRESENT);\n});\n\nTinytest.add(\"coffeescript - exported variable\", function(test) {\n test.equal(COFFEESCRIPT_EXPORTED, 123);\n test.equal(Package['coffeescript-test-helper'].COFFEESCRIPT_EXPORTED, 123);\n test.equal(COFFEESCRIPT_EXPORTED_ONE_MORE, 234);\n test.equal(Package['coffeescript-test-helper'].COFFEESCRIPT_EXPORTED_ONE_MORE, 234);\n test.equal(COFFEESCRIPT_EXPORTED_WITH_BACKTICKS, 345);\n test.equal(Package['coffeescript-test-helper'].COFFEESCRIPT_EXPORTED_WITH_BACKTICKS, 345);\n});\n", "file_path": "packages/non-core/coffeescript/tests/coffeescript_tests.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00016820388555061072, 0.00016669355682097375, 0.00016518321353942156, 0.00016669355682097375, 1.5103360055945814e-06]}
{"hunk": {"id": 3, "code_window": ["\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-typescript/server/main.ts", "type": "replace", "edit_start_line_idx": 17}, "file": "import assert from \"assert\";\nimport {\n checkWhere,\n checkPackageVars,\n} from \"./common\";\n\nexport const where = \"client\";\nexport * from \"./common\";\n\ncheckWhere(where);\n\nvar style = require(\"./css/imported.css\");\nif (! style) {\n require(\"./css/not-imported.css\");\n}\n\nClientPackageVar = \"client\";\ncheckPackageVars();\n", "file_path": "tools/tests/apps/modules/packages/modules-test-package/client.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.000174667700775899, 0.00017421090160496533, 0.00017375408788211644, 0.00017421090160496533, 4.5680644689127803e-07]}
{"hunk": {"id": 3, "code_window": ["\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n", " title: 'Read the Docs',\n", " url: 'https://docs.meteor.com',\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-typescript/server/main.ts", "type": "replace", "edit_start_line_idx": 17}, "file": "---\ntitle: fetch\ndescription: Isomorphic modern/legacy/Node polyfill for WHATWG fetch().\n---\n\nThis package replaces the `http` package for HTTP calls. `fetch` package provides polyfill for the [WHATWG fetch specification](https://fetch.spec.whatwg.org/) for legacy browsers or defaults to the global class which is available in modern browsers and Node. It is recomended that you use this package for compatibility with non-modern browsers.\n\nFor more information we recommend [reading the MDN articles](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) about it as this article covers only basic usage in Meteor.\n\n## Usage\n### Installation\nTo add this package to an existing app, run the following command from\nyour app directory:\n\n```bash\nmeteor add fetch\n```\n\nTo add the `fetch` package to an existing package, include the\nstatement `api.use('fetch');` in the `Package.onUse` callback in your\n`package.js` file:\n\n```js\nPackage.onUse((api) => {\n api.use('fetch');\n});\n```\n\n## API\nYou can import `fetch`, `Headers`, `Request` and `Response` classes from `meteor/fetch`.\n\n```js\nimport { fetch, Headers, Request, Response } from 'meteor/fetch';\n```\n\nFor the most part though, you will only need to import `fetch` and `Headers`.\n\n```js\nimport { Meteor } from 'meteor/meteor';\nimport { fetch, Headers } from 'meteor/fetch';\n\nasync function postData (url, data) {\n try {\n const response = await fetch(url, {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n mode: 'cors', // no-cors, *cors, same-origin\n cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached\n credentials: 'same-origin', // include, *same-origin, omit\n headers: new Headers({\n Authorization: 'Bearer my-secret-key',\n 'Content-Type': 'application/json'\n }),\n redirect: 'follow', // manual, *follow, error\n referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url\n body: JSON.stringify(data) // body data type must match \"Content-Type\" header\n });\n const data = await response.json();\n return response(null, data);\n } catch (err) {\n return response(error, null);\n }\n}\n\nconst postDataCall = Meteor.wrapAsync(postData);\nconst results = postDataCall('https://www.example.org/statsSubmission', { totalUsers: 55 }));\n\n```\n", "file_path": "docs/source/packages/fetch.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00022166944108903408, 0.00018316011119168252, 0.00016358164430130273, 0.00017086707521229982, 2.1016398022766225e-05]}
{"hunk": {"id": 4, "code_window": [" // If the Links collection is empty, add some data.\n", " if (Links.find().count() === 0) {\n", " await insertLink({\n", " title: 'Do the Tutorial',\n", " url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://vue-tutorial.meteor.com/',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 12}, "file": "import { Meteor } from 'meteor/meteor';\nimport Links from './collections/Links.js';\n\nasync function insertLink({ title, url }) {\n await Links.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (Links.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.43007317185401917, 0.17888577282428741, 0.00017486585420556366, 0.14264751970767975, 0.18443873524665833]}
{"hunk": {"id": 4, "code_window": [" // If the Links collection is empty, add some data.\n", " if (Links.find().count() === 0) {\n", " await insertLink({\n", " title: 'Do the Tutorial',\n", " url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://vue-tutorial.meteor.com/',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 12}, "file": "# Meteor packages used by this project, one per line.\n#\n# 'meteor add' and 'meteor remove' will edit this file for you,\n# but you can also edit it by hand.\n\nmeteor-base\nblaze-html-templates\nlocal-plugin\nlocal-plugin-2\n", "file_path": "tools/tests/apps/minifier-plugin-multiple-minifiers-for-js/.meteor/packages", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00029693046235479414, 0.00029693046235479414, 0.00029693046235479414, 0.00029693046235479414, 0.0]}
{"hunk": {"id": 4, "code_window": [" // If the Links collection is empty, add some data.\n", " if (Links.find().count() === 0) {\n", " await insertLink({\n", " title: 'Do the Tutorial',\n", " url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://vue-tutorial.meteor.com/',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 12}, "file": "var system = require('system');\nvar webpage = require('webpage');\n\nif (system.args.length < 2) {\n throw new Error(\"Must pass URL argument to this script.\");\n}\n\nconsole.log(\"opening webpage\", system.args[1]);\n\nwebpage.create().open(system.args[1]);", "file_path": "tools/tool-testing/phantom/open-url.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00017465105338487774, 0.00017302398919127882, 0.00017139691044576466, 0.00017302398919127882, 1.6270714695565403e-06]}
{"hunk": {"id": 4, "code_window": [" // If the Links collection is empty, add some data.\n", " if (Links.find().count() === 0) {\n", " await insertLink({\n", " title: 'Do the Tutorial',\n", " url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://vue-tutorial.meteor.com/',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 12}, "file": "// By default, we use the permessage-deflate extension with default\n// configuration. If $SERVER_WEBSOCKET_COMPRESSION is set, then it must be valid\n// JSON. If it represents a falsey value, then we do not use permessage-deflate\n// at all; otherwise, the JSON value is used as an argument to deflate's\n// configure method; see\n// https://github.com/faye/permessage-deflate-node/blob/master/README.md\n//\n// (We do this in an _.once instead of at startup, because we don't want to\n// crash the tool during isopacket load if your JSON doesn't parse. This is only\n// a problem because the tool has to load the DDP server code just in order to\n// be a DDP client; see https://github.com/meteor/meteor/issues/3452 .)\nvar websocketExtensions = _.once(function () {\n var extensions = [];\n\n var websocketCompressionConfig = process.env.SERVER_WEBSOCKET_COMPRESSION\n ? JSON.parse(process.env.SERVER_WEBSOCKET_COMPRESSION) : {};\n if (websocketCompressionConfig) {\n extensions.push(Npm.require('permessage-deflate').configure(\n websocketCompressionConfig\n ));\n }\n\n return extensions;\n});\n\nvar pathPrefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || \"\";\n\nStreamServer = function () {\n var self = this;\n self.registration_callbacks = [];\n self.open_sockets = [];\n\n // Because we are installing directly onto WebApp.httpServer instead of using\n // WebApp.app, we have to process the path prefix ourselves.\n self.prefix = pathPrefix + '/sockjs';\n RoutePolicy.declare(self.prefix + '/', 'network');\n\n // set up sockjs\n var sockjs = Npm.require('sockjs');\n var serverOptions = {\n prefix: self.prefix,\n log: function() {},\n // this is the default, but we code it explicitly because we depend\n // on it in stream_client:HEARTBEAT_TIMEOUT\n heartbeat_delay: 45000,\n // The default disconnect_delay is 5 seconds, but if the server ends up CPU\n // bound for that much time, SockJS might not notice that the user has\n // reconnected because the timer (of disconnect_delay ms) can fire before\n // SockJS processes the new connection. Eventually we'll fix this by not\n // combining CPU-heavy processing with SockJS termination (eg a proxy which\n // converts to Unix sockets) but for now, raise the delay.\n disconnect_delay: 60 * 1000,\n // Set the USE_JSESSIONID environment variable to enable setting the\n // JSESSIONID cookie. This is useful for setting up proxies with\n // session affinity.\n jsessionid: !!process.env.USE_JSESSIONID\n };\n\n // If you know your server environment (eg, proxies) will prevent websockets\n // from ever working, set $DISABLE_WEBSOCKETS and SockJS clients (ie,\n // browsers) will not waste time attempting to use them.\n // (Your server will still have a /websocket endpoint.)\n if (process.env.DISABLE_WEBSOCKETS) {\n serverOptions.websocket = false;\n } else {\n serverOptions.faye_server_options = {\n extensions: websocketExtensions()\n };\n }\n\n self.server = sockjs.createServer(serverOptions);\n\n // Install the sockjs handlers, but we want to keep around our own particular\n // request handler that adjusts idle timeouts while we have an outstanding\n // request. This compensates for the fact that sockjs removes all listeners\n // for \"request\" to add its own.\n WebApp.httpServer.removeListener(\n 'request', WebApp._timeoutAdjustmentRequestCallback);\n self.server.installHandlers(WebApp.httpServer);\n WebApp.httpServer.addListener(\n 'request', WebApp._timeoutAdjustmentRequestCallback);\n\n // Support the /websocket endpoint\n self._redirectWebsocketEndpoint();\n\n self.server.on('connection', function (socket) {\n // sockjs sometimes passes us null instead of a socket object\n // so we need to guard against that. see:\n // https://github.com/sockjs/sockjs-node/issues/121\n // https://github.com/meteor/meteor/issues/10468\n if (!socket) return;\n\n // We want to make sure that if a client connects to us and does the initial\n // Websocket handshake but never gets to the DDP handshake, that we\n // eventually kill the socket. Once the DDP handshake happens, DDP\n // heartbeating will work. And before the Websocket handshake, the timeouts\n // we set at the server level in webapp_server.js will work. But\n // faye-websocket calls setTimeout(0) on any socket it takes over, so there\n // is an \"in between\" state where this doesn't happen. We work around this\n // by explicitly setting the socket timeout to a relatively large time here,\n // and setting it back to zero when we set up the heartbeat in\n // livedata_server.js.\n socket.setWebsocketTimeout = function (timeout) {\n if ((socket.protocol === 'websocket' ||\n socket.protocol === 'websocket-raw')\n && socket._session.recv) {\n socket._session.recv.connection.setTimeout(timeout);\n }\n };\n socket.setWebsocketTimeout(45 * 1000);\n\n socket.send = function (data) {\n socket.write(data);\n };\n socket.on('close', function () {\n self.open_sockets = _.without(self.open_sockets, socket);\n });\n self.open_sockets.push(socket);\n\n // only to send a message after connection on tests, useful for\n // socket-stream-client/server-tests.js\n if (process.env.TEST_METADATA && process.env.TEST_METADATA !== \"{}\") {\n socket.send(JSON.stringify({ testMessageOnConnect: true }));\n }\n\n // call all our callbacks when we get a new socket. they will do the\n // work of setting up handlers and such for specific messages.\n _.each(self.registration_callbacks, function (callback) {\n callback(socket);\n });\n });\n\n};\n\nObject.assign(StreamServer.prototype, {\n // call my callback when a new socket connects.\n // also call it for all current connections.\n register: function (callback) {\n var self = this;\n self.registration_callbacks.push(callback);\n _.each(self.all_sockets(), function (socket) {\n callback(socket);\n });\n },\n\n // get a list of all sockets\n all_sockets: function () {\n var self = this;\n return _.values(self.open_sockets);\n },\n\n // Redirect /websocket to /sockjs/websocket in order to not expose\n // sockjs to clients that want to use raw websockets\n _redirectWebsocketEndpoint: function() {\n var self = this;\n // Unfortunately we can't use a connect middleware here since\n // sockjs installs itself prior to all existing listeners\n // (meaning prior to any connect middlewares) so we need to take\n // an approach similar to overshadowListeners in\n // https://github.com/sockjs/sockjs-node/blob/cf820c55af6a9953e16558555a31decea554f70e/src/utils.coffee\n ['request', 'upgrade'].forEach((event) => {\n var httpServer = WebApp.httpServer;\n var oldHttpServerListeners = httpServer.listeners(event).slice(0);\n httpServer.removeAllListeners(event);\n\n // request and upgrade have different arguments passed but\n // we only care about the first one which is always request\n var newListener = function(request /*, moreArguments */) {\n // Store arguments for use within the closure below\n var args = arguments;\n\n // TODO replace with url package\n var url = Npm.require('url');\n\n // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while\n // preserving query string.\n var parsedUrl = url.parse(request.url);\n if (parsedUrl.pathname === pathPrefix + '/websocket' ||\n parsedUrl.pathname === pathPrefix + '/websocket/') {\n parsedUrl.pathname = self.prefix + '/websocket';\n request.url = url.format(parsedUrl);\n }\n _.each(oldHttpServerListeners, function(oldListener) {\n oldListener.apply(httpServer, args);\n });\n };\n httpServer.addListener(event, newListener);\n });\n }\n});\n", "file_path": "packages/ddp-server/stream_server.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00030300000798888505, 0.00018338601512368768, 0.0001652815262787044, 0.00017142633441835642, 3.513470073812641e-05]}
{"hunk": {"id": 5, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 17}, "file": "import { Meteor } from 'meteor/meteor';\nimport Links from './collections/Links.js';\n\nasync function insertLink({ title, url }) {\n await Links.insertAsync({ title, url, createdAt: new Date() });\n}\n\nMeteor.startup(async () => {\n // If the Links collection is empty, add some data.\n if (Links.find().count() === 0) {\n await insertLink({\n title: 'Do the Tutorial',\n url: 'https://www.meteor.com/tutorials/react/creating-an-app',\n });\n\n await insertLink({\n title: 'Follow the Guide',\n url: 'http://guide.meteor.com',\n });\n\n await insertLink({\n title: 'Read the Docs',\n url: 'https://docs.meteor.com',\n });\n\n await insertLink({\n title: 'Discussions',\n url: 'https://forums.meteor.com',\n });\n }\n});\n", "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.9900028705596924, 0.2479408085346222, 0.0001766245113685727, 0.0007919011986814439, 0.42842990159988403]}
{"hunk": {"id": 5, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 17}, "file": "process.env.THROW_FROM_PACKAGE && Meteor.startup(function () {\n throw new Error(\"Should be line 2!\");\n});\n", "file_path": "tools/tests/apps/app-throws-error/packages/throwing-package/thrower.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00016534757742192596, 0.00016534757742192596, 0.00016534757742192596, 0.00016534757742192596, 0.0]}
{"hunk": {"id": 5, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 17}, "file": "// This module exists so that it can be accessed directly via\n// require(\"meteor-babel/modern-versions.js\").get() without importing any\n// other modules, which can be expensive (10s of ms). Note that the\n// babel-preset-meteor/modern module has no top-level require calls, so\n// importing it should be very cheap.\nexports.get = function () {\n return require(\"babel-preset-meteor/modern\").minimumVersions;\n};\n", "file_path": "npm-packages/meteor-babel/modern-versions.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.00016405244241468608, 0.00016405244241468608, 0.00016405244241468608, 0.00016405244241468608, 0.0]}
{"hunk": {"id": 5, "code_window": [" });\n", "\n", " await insertLink({\n", " title: 'Follow the Guide',\n", " url: 'http://guide.meteor.com',\n", " });\n", "\n", " await insertLink({\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" url: 'https://guide.meteor.com',\n"], "file_path": "tools/static-assets/skel-vue/imports/api/fixtures.js", "type": "replace", "edit_start_line_idx": 17}, "file": "# Meteor packages used by this project, one per line.\n# Check this file (and the other files in this directory) into your repository.\n#\n# 'meteor add' and 'meteor remove' will edit this file for you,\n# but you can also edit it by hand.\n\nmeteor # Shared foundation for all Meteor packages\nstatic-html # Define static page content in .html files\nstandard-minifier-css # CSS minifier run for production mode\nstandard-minifier-js # JS minifier run for production mode\nes5-shim # ECMAScript 5 compatibility for older browsers\necmascript # Enable ECMAScript2015+ syntax in app code\ntypescript # Enable TypeScript syntax in .ts and .tsx modules\nshell-server # Server-side component of the `meteor shell` command\nwebapp # Serves a Meteor app over HTTP\nserver-render # Support for server-side rendering\ntest-package\nautoupdate\n", "file_path": "tools/tests/apps/client-refresh/.meteor/packages", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/7abe8df1345a0eb93ca37d0c9a75ce484272226f", "dependency_score": [0.0011730347760021687, 0.0007117212517186999, 0.0002504077274352312, 0.0007117212517186999, 0.0004613135242834687]}
{"hunk": {"id": 0, "code_window": ["## v.NEXT\n", "\n", "* Individual Meteor `self-test`'s can now be skipped by adjusting their\n", " `define` call to be prefixed by `skip`. For example,\n", " `selftest.skip.define('some test', ...` will skip running \"some test\".\n", " [PR #9579](https://github.com/meteor/meteor/pull/9579)\n"], "labels": ["keep", "add", "keep", "keep", "keep", "keep"], "after_edit": ["* The `reify` npm package has been updated to version 0.14.1.\n", "\n", "* The `optimism` npm package has been updated to version 0.4.0.\n", "\n"], "file_path": "History.md", "type": "add", "edit_start_line_idx": 2}, "file": "// This file contains a package.json for the dependencies of the command-line\n// tool.\n\n// We put this in a JS file so that it can contain comments. It is processed\n// into a package.json file by generate-dev-bundle.sh.\n\nvar packageJson = {\n name: \"meteor-dev-bundle-tool\",\n private: true,\n dependencies: {\n // Explicit dependency because we are replacing it with a bundled version\n // and we want to make sure there are no dependencies on a higher version\n npm: \"5.6.0\",\n pacote: \"https://github.com/meteor/pacote/tarball/30973f140df79b647dbade03f2d6f19800c2609b\",\n \"node-gyp\": \"3.6.2\",\n \"node-pre-gyp\": \"0.6.36\",\n \"meteor-babel\": \"7.0.0-beta.38-2\",\n \"meteor-promise\": \"0.8.6\",\n promise: \"8.0.1\",\n reify: \"0.13.7\",\n fibers: \"2.0.0\",\n // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n \"@babel/runtime\": \"7.0.0-beta.38\",\n // For backwards compatibility with isopackets that still depend on\n // babel-runtime rather than @babel/runtime.\n \"babel-runtime\": \"7.0.0-beta.3\",\n // Not yet upgrading Underscore from 1.5.2 to 1.7.0 (which should be done\n // in the package too) because we should consider using lodash instead\n // (and there are backwards-incompatible changes either way).\n underscore: \"1.5.2\",\n \"source-map-support\": \"https://github.com/meteor/node-source-map-support/tarball/1912478769d76e5df4c365e147f25896aee6375e\",\n semver: \"5.4.1\",\n request: \"2.83.0\",\n fstream: \"https://github.com/meteor/fstream/tarball/cf4ea6c175355cec7bee38311e170d08c4078a5d\",\n tar: \"2.2.1\",\n kexec: \"3.0.0\",\n \"source-map\": \"0.5.3\",\n chalk: \"0.5.1\",\n sqlite3: \"3.1.8\",\n netroute: \"1.0.2\",\n \"http-proxy\": \"1.16.2\",\n \"wordwrap\": \"0.0.2\",\n \"moment\": \"2.20.1\",\n \"rimraf\": \"2.6.2\",\n \"glob\": \"7.1.2\",\n ignore: \"3.3.7\",\n // XXX: When we update this, see if it fixes this Github issue:\n // https://github.com/jgm/CommonMark/issues/276 . If it does, remove the\n // workaround from the tool.\n \"commonmark\": \"0.15.0\",\n escope: \"3.6.0\",\n split2: \"2.2.0\",\n multipipe: \"2.0.1\",\n pathwatcher: \"7.1.1\",\n optimism: \"0.3.3\",\n 'lru-cache': '4.1.1',\n longjohn: '0.2.12'\n }\n};\n\nif (process.platform === 'win32') {\n // Remove dependencies that do not work on Windows\n delete packageJson.dependencies.netroute;\n delete packageJson.dependencies.kexec;\n}\n\nprocess.stdout.write(JSON.stringify(packageJson, null, 2) + '\\n');\n", "file_path": "scripts/dev-bundle-tool-package.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00018889161583501846, 0.00017113052308559418, 0.00016545293328817934, 0.00016859197057783604, 7.541505510744173e-06]}
{"hunk": {"id": 0, "code_window": ["## v.NEXT\n", "\n", "* Individual Meteor `self-test`'s can now be skipped by adjusting their\n", " `define` call to be prefixed by `skip`. For example,\n", " `selftest.skip.define('some test', ...` will skip running \"some test\".\n", " [PR #9579](https://github.com/meteor/meteor/pull/9579)\n"], "labels": ["keep", "add", "keep", "keep", "keep", "keep"], "after_edit": ["* The `reify` npm package has been updated to version 0.14.1.\n", "\n", "* The `optimism` npm package has been updated to version 0.4.0.\n", "\n"], "file_path": "History.md", "type": "add", "edit_start_line_idx": 2}, "file": "\t/**\n\t * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.\n\t *\n\t * @codingstandard ftlabs-jsv2\n\t * @copyright The Financial Times Limited [All Rights Reserved]\n\t * @license MIT License (see LICENSE.txt)\n\t */\n\n\t/*jslint browser:true, node:true*/\n\t/*global define, Event, Node*/\n\n\n\t/**\n\t * Instantiate fast-clicking listeners on the specified layer.\n\t *\n\t * @constructor\n\t * @param {Element} layer The layer to listen on\n\t * @param {Object} [options={}] The options to override the defaults\n\t */\n\tfunction FastClick(layer, options) {\n 'use strict';\n\t\tvar oldOnClick;\n\n\t\toptions = options || {};\n\n\t\t/**\n\t\t * Whether a click is currently being tracked.\n\t\t *\n\t\t * @type boolean\n\t\t */\n\t\tthis.trackingClick = false;\n\n\n\t\t/**\n\t\t * Timestamp for when click tracking started.\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.trackingClickStart = 0;\n\n\n\t\t/**\n\t\t * The element being tracked for a click.\n\t\t *\n\t\t * @type EventTarget\n\t\t */\n\t\tthis.targetElement = null;\n\n\n\t\t/**\n\t\t * X-coordinate of touch start event.\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.touchStartX = 0;\n\n\n\t\t/**\n\t\t * Y-coordinate of touch start event.\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.touchStartY = 0;\n\n\n\t\t/**\n\t\t * ID of the last touch, retrieved from Touch.identifier.\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.lastTouchIdentifier = 0;\n\n\n\t\t/**\n\t\t * Touchmove boundary, beyond which a click will be cancelled.\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.touchBoundary = options.touchBoundary || 10;\n\n\n\t\t/**\n\t\t * The FastClick layer.\n\t\t *\n\t\t * @type Element\n\t\t */\n\t\tthis.layer = layer;\n\n\t\t/**\n\t\t * The minimum time between tap(touchstart and touchend) events\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.tapDelay = options.tapDelay || 200;\n\n\t\t/**\n\t\t * The maximum time for a tap\n\t\t *\n\t\t * @type number\n\t\t */\n\t\tthis.tapTimeout = options.tapTimeout || 700;\n\n\t\tif (FastClick.notNeeded(layer)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Some old versions of Android don't have Function.prototype.bind\n\t\tfunction bind(method, context) {\n\t\t\treturn function() { return method.apply(context, arguments); };\n\t\t}\n\n\n\t\tvar methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];\n\t\tvar context = this;\n\t\tfor (var i = 0, l = methods.length; i < l; i++) {\n\t\t\tcontext[methods[i]] = bind(context[methods[i]], context);\n\t\t}\n\n\t\t// Set up event handlers as required\n\t\tif (deviceIsAndroid) {\n\t\t\tlayer.addEventListener('mouseover', this.onMouse, true);\n\t\t\tlayer.addEventListener('mousedown', this.onMouse, true);\n\t\t\tlayer.addEventListener('mouseup', this.onMouse, true);\n\t\t}\n\n\t\tlayer.addEventListener('click', this.onClick, true);\n\t\tlayer.addEventListener('touchstart', this.onTouchStart, false);\n\t\tlayer.addEventListener('touchmove', this.onTouchMove, false);\n\t\tlayer.addEventListener('touchend', this.onTouchEnd, false);\n\t\tlayer.addEventListener('touchcancel', this.onTouchCancel, false);\n\n\t\t// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)\n\t\t// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick\n\t\t// layer when they are cancelled.\n\t\tif (!Event.prototype.stopImmediatePropagation) {\n\t\t\tlayer.removeEventListener = function(type, callback, capture) {\n\t\t\t\tvar rmv = Node.prototype.removeEventListener;\n\t\t\t\tif (type === 'click') {\n\t\t\t\t\trmv.call(layer, type, callback.hijacked || callback, capture);\n\t\t\t\t} else {\n\t\t\t\t\trmv.call(layer, type, callback, capture);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tlayer.addEventListener = function(type, callback, capture) {\n\t\t\t\tvar adv = Node.prototype.addEventListener;\n\t\t\t\tif (type === 'click') {\n\t\t\t\t\tadv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {\n\t\t\t\t\t\tif (!event.propagationStopped) {\n\t\t\t\t\t\t\tcallback(event);\n\t\t\t\t\t\t}\n\t\t\t\t\t}), capture);\n\t\t\t\t} else {\n\t\t\t\t\tadv.call(layer, type, callback, capture);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// If a handler is already declared in the element's onclick attribute, it will be fired before\n\t\t// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and\n\t\t// adding it as listener.\n\t\tif (typeof layer.onclick === 'function') {\n\n\t\t\t// Android browser on at least 3.2 requires a new reference to the function in layer.onclick\n\t\t\t// - the old one won't work if passed to addEventListener directly.\n\t\t\toldOnClick = layer.onclick;\n\t\t\tlayer.addEventListener('click', function(event) {\n\t\t\t\toldOnClick(event);\n\t\t\t}, false);\n\t\t\tlayer.onclick = null;\n\t\t}\n\t}\n\n\t/**\n\t* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.\n\t*\n\t* @type boolean\n\t*/\n\tvar deviceIsWindowsPhone = navigator.userAgent.indexOf(\"Windows Phone\") >= 0;\n\n\t/**\n\t * Android requires exceptions.\n\t *\n\t * @type boolean\n\t */\n\tvar deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;\n\n\n\t/**\n\t * iOS requires exceptions.\n\t *\n\t * @type boolean\n\t */\n\tvar deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;\n\n\n\t/**\n\t * iOS 4 requires an exception for select elements.\n\t *\n\t * @type boolean\n\t */\n\tvar deviceIsIOS4 = deviceIsIOS && (/OS 4_\\d(_\\d)?/).test(navigator.userAgent);\n\n\n\t/**\n\t * iOS 6.0-7.* requires the target element to be manually derived\n\t *\n\t * @type boolean\n\t */\n\tvar deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\\d/).test(navigator.userAgent);\n\n\t/**\n\t * BlackBerry requires exceptions.\n\t *\n\t * @type boolean\n\t */\n\tvar deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;\n\n\t/**\n\t * Determine whether a given element requires a native click.\n\t *\n\t * @param {EventTarget|Element} target Target DOM element\n\t * @returns {boolean} Returns true if the element needs a native click\n\t */\n\tFastClick.prototype.needsClick = function(target) {\n\t\tswitch (target.nodeName.toLowerCase()) {\n\n\t\t// Don't send a synthetic click to disabled inputs (issue #62)\n\t\tcase 'button':\n\t\tcase 'select':\n\t\tcase 'textarea':\n\t\t\tif (target.disabled) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase 'input':\n\n\t\t\t// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)\n\t\t\tif ((deviceIsIOS && target.type === 'file') || target.disabled) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase 'label':\n\t\tcase 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames\n\t\tcase 'video':\n\t\t\treturn true;\n\t\t}\n\n\t\treturn (/\\bneedsclick\\b/).test(target.className);\n\t};\n\n\n\t/**\n\t * Determine whether a given element requires a call to focus to simulate click into element.\n\t *\n\t * @param {EventTarget|Element} target Target DOM element\n\t * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.\n\t */\n\tFastClick.prototype.needsFocus = function(target) {\n\t\tswitch (target.nodeName.toLowerCase()) {\n\t\tcase 'textarea':\n\t\t\treturn true;\n\t\tcase 'select':\n\t\t\treturn !deviceIsAndroid;\n\t\tcase 'input':\n\t\t\tswitch (target.type) {\n\t\t\tcase 'button':\n\t\t\tcase 'checkbox':\n\t\t\tcase 'file':\n\t\t\tcase 'image':\n\t\t\tcase 'radio':\n\t\t\tcase 'submit':\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// No point in attempting to focus disabled inputs\n\t\t\treturn !target.disabled && !target.readOnly;\n\t\tdefault:\n\t\t\treturn (/\\bneedsfocus\\b/).test(target.className);\n\t\t}\n\t};\n\n\n\t/**\n\t * Send a click event to the specified element.\n\t *\n\t * @param {EventTarget|Element} targetElement\n\t * @param {Event} event\n\t */\n\tFastClick.prototype.sendClick = function(targetElement, event) {\n\t\tvar clickEvent, touch;\n\n\t\t// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)\n\t\tif (document.activeElement && document.activeElement !== targetElement) {\n\t\t\tdocument.activeElement.blur();\n\t\t}\n\n\t\ttouch = event.changedTouches[0];\n\n\t\t// Synthesise a click event, with an extra attribute so it can be tracked\n\t\tclickEvent = document.createEvent('MouseEvents');\n\t\tclickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);\n\t\tclickEvent.forwardedTouchEvent = true;\n\t\ttargetElement.dispatchEvent(clickEvent);\n\t};\n\n\tFastClick.prototype.determineEventType = function(targetElement) {\n\n\t\t//Issue #159: Android Chrome Select Box does not open with a synthetic click event\n\t\tif (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {\n\t\t\treturn 'mousedown';\n\t\t}\n\n\t\treturn 'click';\n\t};\n\n\n\t/**\n\t * @param {EventTarget|Element} targetElement\n\t */\n\tFastClick.prototype.focus = function(targetElement) {\n\t\tvar length;\n\n\t\t// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.\n\t\tif (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {\n\t\t\tlength = targetElement.value.length;\n\t\t\ttargetElement.setSelectionRange(length, length);\n\t\t} else {\n\t\t\ttargetElement.focus();\n\t\t}\n\t};\n\n\n\t/**\n\t * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.\n\t *\n\t * @param {EventTarget|Element} targetElement\n\t */\n\tFastClick.prototype.updateScrollParent = function(targetElement) {\n\t\tvar scrollParent, parentElement;\n\n\t\tscrollParent = targetElement.fastClickScrollParent;\n\n\t\t// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the\n\t\t// target element was moved to another parent.\n\t\tif (!scrollParent || !scrollParent.contains(targetElement)) {\n\t\t\tparentElement = targetElement;\n\t\t\tdo {\n\t\t\t\tif (parentElement.scrollHeight > parentElement.offsetHeight) {\n\t\t\t\t\tscrollParent = parentElement;\n\t\t\t\t\ttargetElement.fastClickScrollParent = parentElement;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tparentElement = parentElement.parentElement;\n\t\t\t} while (parentElement);\n\t\t}\n\n\t\t// Always update the scroll top tracker if possible.\n\t\tif (scrollParent) {\n\t\t\tscrollParent.fastClickLastScrollTop = scrollParent.scrollTop;\n\t\t}\n\t};\n\n\n\t/**\n\t * @param {EventTarget} targetElement\n\t * @returns {Element|EventTarget}\n\t */\n\tFastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {\n\n\t\t// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.\n\t\tif (eventTarget.nodeType === Node.TEXT_NODE) {\n\t\t\treturn eventTarget.parentNode;\n\t\t}\n\n\t\treturn eventTarget;\n\t};\n\n\n\t/**\n\t * On touch start, record the position and scroll offset.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.onTouchStart = function(event) {\n\t\tvar targetElement, touch, selection;\n\n\t\t// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).\n\t\tif (event.targetTouches.length > 1) {\n\t\t\treturn true;\n\t\t}\n\n\t\ttargetElement = this.getTargetElementFromEventTarget(event.target);\n\t\ttouch = event.targetTouches[0];\n\n\t\tif (deviceIsIOS) {\n\n\t\t\t// Only trusted events will deselect text on iOS (issue #49)\n\t\t\tselection = window.getSelection();\n\t\t\tif (selection.rangeCount && !selection.isCollapsed) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (!deviceIsIOS4) {\n\n\t\t\t\t// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):\n\t\t\t\t// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched\n\t\t\t\t// with the same identifier as the touch event that previously triggered the click that triggered the alert.\n\t\t\t\t// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an\n\t\t\t\t// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.\n\t\t\t\t// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,\n\t\t\t\t// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,\n\t\t\t\t// random integers, it's safe to to continue if the identifier is 0 here.\n\t\t\t\tif (touch.identifier && touch.identifier === this.lastTouchIdentifier) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthis.lastTouchIdentifier = touch.identifier;\n\n\t\t\t\t// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:\n\t\t\t\t// 1) the user does a fling scroll on the scrollable layer\n\t\t\t\t// 2) the user stops the fling scroll with another tap\n\t\t\t\t// then the event.target of the last 'touchend' event will be the element that was under the user's finger\n\t\t\t\t// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check\n\t\t\t\t// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).\n\t\t\t\tthis.updateScrollParent(targetElement);\n\t\t\t}\n\t\t}\n\n\t\tthis.trackingClick = true;\n\t\tthis.trackingClickStart = event.timeStamp;\n\t\tthis.targetElement = targetElement;\n\n\t\tthis.touchStartX = touch.pageX;\n\t\tthis.touchStartY = touch.pageY;\n\n\t\t// Prevent phantom clicks on fast double-tap (issue #36)\n\t\tif ((event.timeStamp - this.lastClickTime) < this.tapDelay) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.touchHasMoved = function(event) {\n\t\tvar touch = event.changedTouches[0], boundary = this.touchBoundary;\n\n\t\tif (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t};\n\n\n\t/**\n\t * Update the last position.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.onTouchMove = function(event) {\n\t\tif (!this.trackingClick) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If the touch has moved, cancel the click tracking\n\t\tif (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {\n\t\t\tthis.trackingClick = false;\n\t\t\tthis.targetElement = null;\n\t\t}\n\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * Attempt to find the labelled control for the given label element.\n\t *\n\t * @param {EventTarget|HTMLLabelElement} labelElement\n\t * @returns {Element|null}\n\t */\n\tFastClick.prototype.findControl = function(labelElement) {\n\n\t\t// Fast path for newer browsers supporting the HTML5 control attribute\n\t\tif (labelElement.control !== undefined) {\n\t\t\treturn labelElement.control;\n\t\t}\n\n\t\t// All browsers under test that support touch events also support the HTML5 htmlFor attribute\n\t\tif (labelElement.htmlFor) {\n\t\t\treturn document.getElementById(labelElement.htmlFor);\n\t\t}\n\n\t\t// If no for attribute exists, attempt to retrieve the first labellable descendant element\n\t\t// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label\n\t\treturn labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');\n\t};\n\n\n\t/**\n\t * On touch end, determine whether to send a click event at once.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.onTouchEnd = function(event) {\n\t\tvar forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;\n\n\t\tif (!this.trackingClick) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Prevent phantom clicks on fast double-tap (issue #36)\n\t\tif ((event.timeStamp - this.lastClickTime) < this.tapDelay) {\n\t\t\tthis.cancelNextClick = true;\n\t\t\treturn true;\n\t\t}\n\n\t\tif ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Reset to prevent wrong click cancel on input (issue #156).\n\t\tthis.cancelNextClick = false;\n\n\t\tthis.lastClickTime = event.timeStamp;\n\n\t\ttrackingClickStart = this.trackingClickStart;\n\t\tthis.trackingClick = false;\n\t\tthis.trackingClickStart = 0;\n\n\t\t// On some iOS devices, the targetElement supplied with the event is invalid if the layer\n\t\t// is performing a transition or scroll, and has to be re-detected manually. Note that\n\t\t// for this to function correctly, it must be called *after* the event target is checked!\n\t\t// See issue #57; also filed as rdar://13048589 .\n\t\tif (deviceIsIOSWithBadTarget) {\n\t\t\ttouch = event.changedTouches[0];\n\n\t\t\t// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null\n\t\t\ttargetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;\n\t\t\ttargetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;\n\t\t}\n\n\t\ttargetTagName = targetElement.tagName.toLowerCase();\n\t\tif (targetTagName === 'label') {\n\t\t\tforElement = this.findControl(targetElement);\n\t\t\tif (forElement) {\n\t\t\t\tthis.focus(targetElement);\n\t\t\t\tif (deviceIsAndroid) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\ttargetElement = forElement;\n\t\t\t}\n\t\t} else if (this.needsFocus(targetElement)) {\n\n\t\t\t// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.\n\t\t\t// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).\n\t\t\tif ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {\n\t\t\t\tthis.targetElement = null;\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.focus(targetElement);\n\t\t\tthis.sendClick(targetElement, event);\n\n\t\t\t// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.\n\t\t\t// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)\n\t\t\tif (!deviceIsIOS || targetTagName !== 'select') {\n\t\t\t\tthis.targetElement = null;\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\n\t\tif (deviceIsIOS && !deviceIsIOS4) {\n\n\t\t\t// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled\n\t\t\t// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).\n\t\t\tscrollParent = targetElement.fastClickScrollParent;\n\t\t\tif (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// Prevent the actual click from going though - unless the target node is marked as requiring\n\t\t// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.\n\t\tif (!this.needsClick(targetElement)) {\n\t\t\tevent.preventDefault();\n\t\t\tthis.sendClick(targetElement, event);\n\t\t}\n\n\t\treturn false;\n\t};\n\n\n\t/**\n\t * On touch cancel, stop tracking the click.\n\t *\n\t * @returns {void}\n\t */\n\tFastClick.prototype.onTouchCancel = function() {\n\t\tthis.trackingClick = false;\n\t\tthis.targetElement = null;\n\t};\n\n\n\t/**\n\t * Determine mouse events which should be permitted.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.onMouse = function(event) {\n\n\t\t// If a target element was never set (because a touch event was never fired) allow the event\n\t\tif (!this.targetElement) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (event.forwardedTouchEvent) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Programmatically generated events targeting a specific element should be permitted\n\t\tif (!event.cancelable) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Derive and check the target element to see whether the mouse event needs to be permitted;\n\t\t// unless explicitly enabled, prevent non-touch click events from triggering actions,\n\t\t// to prevent ghost/doubleclicks.\n\t\tif (!this.needsClick(this.targetElement) || this.cancelNextClick) {\n\n\t\t\t// Prevent any user-added listeners declared on FastClick element from being fired.\n\t\t\tif (event.stopImmediatePropagation) {\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t} else {\n\n\t\t\t\t// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)\n\t\t\t\tevent.propagationStopped = true;\n\t\t\t}\n\n\t\t\t// Cancel the event\n\t\t\tevent.stopPropagation();\n\t\t\tevent.preventDefault();\n\n\t\t\treturn false;\n\t\t}\n\n\t\t// If the mouse event is permitted, return true for the action to go through.\n\t\treturn true;\n\t};\n\n\n\t/**\n\t * On actual clicks, determine whether this is a touch-generated click, a click action occurring\n\t * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or\n\t * an actual click which should be permitted.\n\t *\n\t * @param {Event} event\n\t * @returns {boolean}\n\t */\n\tFastClick.prototype.onClick = function(event) {\n\t\tvar permitted;\n\n\t\t// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.\n\t\tif (this.trackingClick) {\n\t\t\tthis.targetElement = null;\n\t\t\tthis.trackingClick = false;\n\t\t\treturn true;\n\t\t}\n\n\t\t// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.\n\t\tif (event.target.type === 'submit' && event.detail === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tpermitted = this.onMouse(event);\n\n\t\t// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.\n\t\tif (!permitted) {\n\t\t\tthis.targetElement = null;\n\t\t}\n\n\t\t// If clicks are permitted, return true for the action to go through.\n\t\treturn permitted;\n\t};\n\n\n\t/**\n\t * Remove all FastClick's event listeners.\n\t *\n\t * @returns {void}\n\t */\n\tFastClick.prototype.destroy = function() {\n\t\tvar layer = this.layer;\n\n\t\tif (deviceIsAndroid) {\n\t\t\tlayer.removeEventListener('mouseover', this.onMouse, true);\n\t\t\tlayer.removeEventListener('mousedown', this.onMouse, true);\n\t\t\tlayer.removeEventListener('mouseup', this.onMouse, true);\n\t\t}\n\n\t\tlayer.removeEventListener('click', this.onClick, true);\n\t\tlayer.removeEventListener('touchstart', this.onTouchStart, false);\n\t\tlayer.removeEventListener('touchmove', this.onTouchMove, false);\n\t\tlayer.removeEventListener('touchend', this.onTouchEnd, false);\n\t\tlayer.removeEventListener('touchcancel', this.onTouchCancel, false);\n\t};\n\n\n\t/**\n\t * Check whether FastClick is needed.\n\t *\n\t * @param {Element} layer The layer to listen on\n\t */\n\tFastClick.notNeeded = function(layer) {\n\t\tvar metaViewport;\n\t\tvar chromeVersion;\n\t\tvar blackberryVersion;\n\t\tvar firefoxVersion;\n\n\t\t// Devices that don't support touch don't need FastClick\n\t\tif (typeof window.ontouchstart === 'undefined') {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Chrome version - zero for other browsers\n\t\tchromeVersion = +(/Chrome\\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];\n\n\t\tif (chromeVersion) {\n\n\t\t\tif (deviceIsAndroid) {\n\t\t\t\tmetaViewport = document.querySelector('meta[name=viewport]');\n\n\t\t\t\tif (metaViewport) {\n\t\t\t\t\t// Chrome on Android with user-scalable=\"no\" doesn't need FastClick (issue #89)\n\t\t\t\t\tif (metaViewport.content.indexOf('user-scalable=no') !== -1) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\t// Chrome 32 and above with width=device-width or less don't need FastClick\n\t\t\t\t\tif (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t// Chrome desktop doesn't need FastClick (issue #15)\n\t\t\t} else {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (deviceIsBlackBerry10) {\n\t\t\tblackberryVersion = navigator.userAgent.match(/Version\\/([0-9]*)\\.([0-9]*)/);\n\n\t\t\t// BlackBerry 10.3+ does not require Fastclick library.\n\t\t\t// https://github.com/ftlabs/fastclick/issues/251\n\t\t\tif (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {\n\t\t\t\tmetaViewport = document.querySelector('meta[name=viewport]');\n\n\t\t\t\tif (metaViewport) {\n\t\t\t\t\t// user-scalable=no eliminates click delay.\n\t\t\t\t\tif (metaViewport.content.indexOf('user-scalable=no') !== -1) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\t// width=device-width (or less than device-width) eliminates click delay.\n\t\t\t\t\tif (document.documentElement.scrollWidth <= window.outerWidth) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)\n\t\tif (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Firefox version - zero for other browsers\n\t\tfirefoxVersion = +(/Firefox\\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];\n\n\t\tif (firefoxVersion >= 27) {\n\t\t\t// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896\n\n\t\t\tmetaViewport = document.querySelector('meta[name=viewport]');\n\t\t\tif (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version\n\t\t// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx\n\t\tif (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t};\n\n\n\t/**\n\t * Factory method for creating a FastClick object\n\t *\n\t * @param {Element} layer The layer to listen on\n\t * @param {Object} [options={}] The options to override the defaults\n\t */\n\tFastClick.attach = function(layer, options) {\n\t\treturn new FastClick(layer, options);\n\t};\n\n\n\tif (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\n\t\t// AMD. Register as an anonymous module.\n\t\tdefine(function() {\n\t\t\treturn FastClick;\n\t\t});\n\t} else if (typeof module !== 'undefined' && module.exports) {\n\t\tmodule.exports = FastClick.attach;\n\t\tmodule.exports.FastClick = FastClick;\n\t} else {\n\t\twindow.FastClick = FastClick;\n\t}\n", "file_path": "packages/deprecated/fastclick/fastclick.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.0003370115882717073, 0.00016880914336070418, 0.00016365808551199734, 0.0001664314913796261, 1.8631311831995845e-05]}
{"hunk": {"id": 0, "code_window": ["## v.NEXT\n", "\n", "* Individual Meteor `self-test`'s can now be skipped by adjusting their\n", " `define` call to be prefixed by `skip`. For example,\n", " `selftest.skip.define('some test', ...` will skip running \"some test\".\n", " [PR #9579](https://github.com/meteor/meteor/pull/9579)\n"], "labels": ["keep", "add", "keep", "keep", "keep", "keep"], "after_edit": ["* The `reify` npm package has been updated to version 0.14.1.\n", "\n", "* The `optimism` npm package has been updated to version 0.4.0.\n", "\n"], "file_path": "History.md", "type": "add", "edit_start_line_idx": 2}, "file": "Package.describe({\n name: \"~package-name~\", // replaced via `Sandbox.prototype.createPackage`\n summary: \"Test package.\",\n version: \"1.0.0\",\n documentation: null\n});\n", "file_path": "tools/tests/packages/package-of-two-versions/package.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017057699733413756, 0.00017057699733413756, 0.00017057699733413756, 0.00017057699733413756, 0.0]}
{"hunk": {"id": 0, "code_window": ["## v.NEXT\n", "\n", "* Individual Meteor `self-test`'s can now be skipped by adjusting their\n", " `define` call to be prefixed by `skip`. For example,\n", " `selftest.skip.define('some test', ...` will skip running \"some test\".\n", " [PR #9579](https://github.com/meteor/meteor/pull/9579)\n"], "labels": ["keep", "add", "keep", "keep", "keep", "keep"], "after_edit": ["* The `reify` npm package has been updated to version 0.14.1.\n", "\n", "* The `optimism` npm package has been updated to version 0.4.0.\n", "\n"], "file_path": "History.md", "type": "add", "edit_start_line_idx": 2}, "file": "@el2-style: solid;\n@import \"../imports/dotdot.less\";\n", "file_path": "tools/tests/apps/caching-less/subdir/foo.import.less", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00016825216880533844, 0.00016825216880533844, 0.00016825216880533844, 0.00016825216880533844, 0.0]}
{"hunk": {"id": 1, "code_window": ["{\n", " \"lockfileVersion\": 1,\n", " \"dependencies\": {\n", " \"acorn\": {\n", " \"version\": \"5.3.0\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n", " \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n", " },\n", " \"minipass\": {\n", " \"version\": \"2.2.1\",\n", " \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz\",\n", " \"integrity\": \"sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 4}, "file": "{\n \"lockfileVersion\": 1,\n \"dependencies\": {\n \"acorn\": {\n \"version\": \"5.3.0\",\n \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n },\n \"minipass\": {\n \"version\": \"2.2.1\",\n \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n \"integrity\": \"sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==\"\n },\n \"minizlib\": {\n \"version\": \"1.1.0\",\n \"resolved\": \"https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz\",\n \"integrity\": \"sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==\"\n },\n \"reify\": {\n \"version\": \"0.13.7\",\n \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.13.7.tgz\",\n \"integrity\": \"sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==\"\n },\n \"semver\": {\n \"version\": \"5.4.1\",\n \"resolved\": \"https://registry.npmjs.org/semver/-/semver-5.4.1.tgz\",\n \"integrity\": \"sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==\"\n },\n \"yallist\": {\n \"version\": \"3.0.2\",\n \"resolved\": \"https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz\",\n \"integrity\": \"sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=\"\n }\n }\n}\n", "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.9934759736061096, 0.26300403475761414, 0.00019406377396080643, 0.029173070564866066, 0.4222135841846466]}
{"hunk": {"id": 1, "code_window": ["{\n", " \"lockfileVersion\": 1,\n", " \"dependencies\": {\n", " \"acorn\": {\n", " \"version\": \"5.3.0\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n", " \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n", " },\n", " \"minipass\": {\n", " \"version\": \"2.2.1\",\n", " \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz\",\n", " \"integrity\": \"sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 4}, "file": "/*\n * XXX Hack to make bootstrap work when bundled. This needs to be included\n * _after_ the standard bootstrap css files.\n *\n * After being bundled, all CSS is minified and served from the \"/\" dir.\n * Thus, we need to provide absolute paths to the icons here.\n */\n\n[class^=\"icon-\"],\n[class*=\" icon-\"] {\n background-image: url(\"/packages/bootstrap/img/glyphicons-halflings.png\");\n}\n/*\n * Selectors borrowed from bootstrap.css. For all releases of bootstrap, when\n * we upgrade, update this file to borrow the selectors from where bootstrap.css\n * references any .png. When we update to using .less instead, use the less\n * directives in a less file instead.\n */\n.icon-white,\n.nav-pills > .active > a > [class^=\"icon-\"],\n.nav-pills > .active > a > [class*=\" icon-\"],\n.nav-list > .active > a > [class^=\"icon-\"],\n.nav-list > .active > a > [class*=\" icon-\"],\n.navbar-inverse .nav > .active > a > [class^=\"icon-\"],\n.navbar-inverse .nav > .active > a > [class*=\" icon-\"],\n.dropdown-menu > li > a:hover > [class^=\"icon-\"],\n.dropdown-menu > li > a:focus > [class^=\"icon-\"],\n.dropdown-menu > li > a:hover > [class*=\" icon-\"],\n.dropdown-menu > li > a:focus > [class*=\" icon-\"],\n.dropdown-menu > .active > a > [class^=\"icon-\"],\n.dropdown-menu > .active > a > [class*=\" icon-\"],\n.dropdown-submenu:hover > a > [class^=\"icon-\"],\n.dropdown-submenu:focus > a > [class^=\"icon-\"],\n.dropdown-submenu:hover > a > [class*=\" icon-\"],\n.dropdown-submenu:focus > a > [class*=\" icon-\"] {\n background-image: url(\"/packages/bootstrap/img/glyphicons-halflings-white.png\");\n}\n", "file_path": "packages/deprecated/bootstrap/css/bootstrap-override.css", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017662806203588843, 0.00017142159049399197, 0.00016481129569001496, 0.00017212348757311702, 4.251189238857478e-06]}
{"hunk": {"id": 1, "code_window": ["{\n", " \"lockfileVersion\": 1,\n", " \"dependencies\": {\n", " \"acorn\": {\n", " \"version\": \"5.3.0\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n", " \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n", " },\n", " \"minipass\": {\n", " \"version\": \"2.2.1\",\n", " \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz\",\n", " \"integrity\": \"sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 4}, "file": "import {AccountsServer} from \"./accounts_server.js\";\n\n// XXX These should probably not actually be public?\n\nAccountsServer.prototype.urls = {\n resetPassword: function (token) {\n return Meteor.absoluteUrl('#/reset-password/' + token);\n },\n\n verifyEmail: function (token) {\n return Meteor.absoluteUrl('#/verify-email/' + token);\n },\n\n enrollAccount: function (token) {\n return Meteor.absoluteUrl('#/enroll-account/' + token);\n }\n};\n", "file_path": "packages/accounts-base/url_server.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.0001699924614513293, 0.00016747208428569138, 0.00016495169256813824, 0.00016747208428569138, 2.5203844415955245e-06]}
{"hunk": {"id": 1, "code_window": ["{\n", " \"lockfileVersion\": 1,\n", " \"dependencies\": {\n", " \"acorn\": {\n", " \"version\": \"5.3.0\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n", " \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n", " },\n", " \"minipass\": {\n", " \"version\": \"2.2.1\",\n", " \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz\",\n", " \"integrity\": \"sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 4}, "file": "import \"./accounts_tests.js\";\nimport \"./accounts_reconnect_tests.js\";\n", "file_path": "packages/accounts-base/server_tests.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017211982049047947, 0.00017211982049047947, 0.00017211982049047947, 0.00017211982049047947, 0.0]}
{"hunk": {"id": 2, "code_window": [" \"resolved\": \"https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz\",\n", " \"integrity\": \"sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==\"\n", " },\n", " \"reify\": {\n", " \"version\": \"0.13.7\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.13.7.tgz\",\n", " \"integrity\": \"sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==\"\n", " },\n", " \"semver\": {\n", " \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/semver/-/semver-5.4.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"0.14.1\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.14.1.tgz\",\n", " \"integrity\": \"sha512-HAKYzqlCCWsfAcOTm8gsJZ6FE5I06kvjzHRQTCDD6xqUJaY8Mh4ve9oiCDe8yiYXOqZqpt03gn8yS4+bokRmhQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 19}, "file": "{\n \"lockfileVersion\": 1,\n \"dependencies\": {\n \"acorn\": {\n \"version\": \"5.3.0\",\n \"resolved\": \"https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz\",\n \"integrity\": \"sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==\"\n },\n \"minipass\": {\n \"version\": \"2.2.1\",\n \"resolved\": \"https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz\",\n \"integrity\": \"sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==\"\n },\n \"minizlib\": {\n \"version\": \"1.1.0\",\n \"resolved\": \"https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz\",\n \"integrity\": \"sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==\"\n },\n \"reify\": {\n \"version\": \"0.13.7\",\n \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.13.7.tgz\",\n \"integrity\": \"sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==\"\n },\n \"semver\": {\n \"version\": \"5.4.1\",\n \"resolved\": \"https://registry.npmjs.org/semver/-/semver-5.4.1.tgz\",\n \"integrity\": \"sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==\"\n },\n \"yallist\": {\n \"version\": \"3.0.2\",\n \"resolved\": \"https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz\",\n \"integrity\": \"sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=\"\n }\n }\n}\n", "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.9710676670074463, 0.30186647176742554, 0.002027521375566721, 0.11718536168336868, 0.3974625766277313]}
{"hunk": {"id": 2, "code_window": [" \"resolved\": \"https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz\",\n", " \"integrity\": \"sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==\"\n", " },\n", " \"reify\": {\n", " \"version\": \"0.13.7\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.13.7.tgz\",\n", " \"integrity\": \"sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==\"\n", " },\n", " \"semver\": {\n", " \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/semver/-/semver-5.4.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"0.14.1\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.14.1.tgz\",\n", " \"integrity\": \"sha512-HAKYzqlCCWsfAcOTm8gsJZ6FE5I06kvjzHRQTCDD6xqUJaY8Mh4ve9oiCDe8yiYXOqZqpt03gn8yS4+bokRmhQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 19}, "file": "import {isIdentifierStart, isIdentifierChar} from \"./identifier\"\nimport {types as tt, keywords as keywordTypes} from \"./tokentype\"\nimport {Parser} from \"./state\"\nimport {SourceLocation} from \"./locutil\"\nimport {lineBreak, lineBreakG, isNewLine, nonASCIIwhitespace} from \"./whitespace\"\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(p) {\n this.type = p.type\n this.value = p.value\n this.start = p.start\n this.end = p.end\n if (p.options.locations)\n this.loc = new SourceLocation(p, p.startLoc, p.endLoc)\n if (p.options.ranges)\n this.range = [p.start, p.end]\n }\n}\n\n// ## Tokenizer\n\nconst pp = Parser.prototype\n\n// Are we running under Rhino?\nconst isRhino = typeof Packages == \"object\" && Object.prototype.toString.call(Packages) == \"[object JavaPackage]\"\n\n// Move to the next token\n\npp.next = function() {\n if (this.options.onToken)\n this.options.onToken(new Token(this))\n\n this.lastTokEnd = this.end\n this.lastTokStart = this.start\n this.lastTokEndLoc = this.endLoc\n this.lastTokStartLoc = this.startLoc\n this.nextToken()\n}\n\npp.getToken = function() {\n this.next()\n return new Token(this)\n}\n\n// If we're in an ES6 environment, make parsers iterable\nif (typeof Symbol !== \"undefined\")\n pp[Symbol.iterator] = function () {\n let self = this\n return {next: function () {\n let token = self.getToken()\n return {\n done: token.type === tt.eof,\n value: token\n }\n }}\n }\n\n// Toggle strict mode. Re-reads the next number or string to please\n// pedantic tests (`\"use strict\"; 010;` should fail).\n\npp.setStrict = function(strict) {\n this.strict = strict\n if (this.type !== tt.num && this.type !== tt.string) return\n this.pos = this.start\n if (this.options.locations) {\n while (this.pos < this.lineStart) {\n this.lineStart = this.input.lastIndexOf(\"\\n\", this.lineStart - 2) + 1\n --this.curLine\n }\n }\n this.nextToken()\n}\n\npp.curContext = function() {\n return this.context[this.context.length - 1]\n}\n\n// Read a single token, updating the parser object's token-related\n// properties.\n\npp.nextToken = function() {\n let curContext = this.curContext()\n if (!curContext || !curContext.preserveSpace) this.skipSpace()\n\n this.start = this.pos\n if (this.options.locations) this.startLoc = this.curPosition()\n if (this.pos >= this.input.length) return this.finishToken(tt.eof)\n\n if (curContext.override) return curContext.override(this)\n else this.readToken(this.fullCharCodeAtPos())\n}\n\npp.readToken = function(code) {\n // Identifier or keyword. '\\uXXXX' sequences are allowed in\n // identifiers, so '\\' also dispatches to that.\n if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\\' */)\n return this.readWord()\n\n return this.getTokenFromCode(code)\n}\n\npp.fullCharCodeAtPos = function() {\n let code = this.input.charCodeAt(this.pos)\n if (code <= 0xd7ff || code >= 0xe000) return code\n let next = this.input.charCodeAt(this.pos + 1)\n return (code << 10) + next - 0x35fdc00\n}\n\npp.skipBlockComment = function() {\n let startLoc = this.options.onComment && this.curPosition()\n let start = this.pos, end = this.input.indexOf(\"*/\", this.pos += 2)\n if (end === -1) this.raise(this.pos - 2, \"Unterminated comment\")\n this.pos = end + 2\n if (this.options.locations) {\n lineBreakG.lastIndex = start\n let match\n while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {\n ++this.curLine\n this.lineStart = match.index + match[0].length\n }\n }\n if (this.options.onComment)\n this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,\n startLoc, this.curPosition())\n}\n\npp.skipLineComment = function(startSkip) {\n let start = this.pos\n let startLoc = this.options.onComment && this.curPosition()\n let ch = this.input.charCodeAt(this.pos+=startSkip)\n while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {\n ++this.pos\n ch = this.input.charCodeAt(this.pos)\n }\n if (this.options.onComment)\n this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,\n startLoc, this.curPosition())\n}\n\n// Called at the start of the parse and after every token. Skips\n// whitespace and comments, and.\n\npp.skipSpace = function() {\n loop: while (this.pos < this.input.length) {\n let ch = this.input.charCodeAt(this.pos)\n switch (ch) {\n case 32: case 160: // ' '\n ++this.pos\n break\n case 13:\n if (this.input.charCodeAt(this.pos + 1) === 10) {\n ++this.pos\n }\n case 10: case 8232: case 8233:\n ++this.pos\n if (this.options.locations) {\n ++this.curLine\n this.lineStart = this.pos\n }\n break\n case 47: // '/'\n switch (this.input.charCodeAt(this.pos + 1)) {\n case 42: // '*'\n this.skipBlockComment()\n break\n case 47:\n this.skipLineComment(2)\n break\n default:\n break loop\n }\n break\n default:\n if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {\n ++this.pos\n } else {\n break loop\n }\n }\n }\n}\n\n// Called at the end of every token. Sets `end`, `val`, and\n// maintains `context` and `exprAllowed`, and skips the space after\n// the token, so that the next one's `start` will point at the\n// right position.\n\npp.finishToken = function(type, val) {\n this.end = this.pos\n if (this.options.locations) this.endLoc = this.curPosition()\n let prevType = this.type\n this.type = type\n this.value = val\n\n this.updateContext(prevType)\n}\n\n// ### Token reading\n\n// This is the function that is called to fetch the next token. It\n// is somewhat obscure, because it works in character codes rather\n// than characters, and because operator parsing has been inlined\n// into it.\n//\n// All in the name of speed.\n//\npp.readToken_dot = function() {\n let next = this.input.charCodeAt(this.pos + 1)\n if (next >= 48 && next <= 57) return this.readNumber(true)\n let next2 = this.input.charCodeAt(this.pos + 2)\n if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'\n this.pos += 3\n return this.finishToken(tt.ellipsis)\n } else {\n ++this.pos\n return this.finishToken(tt.dot)\n }\n}\n\npp.readToken_slash = function() { // '/'\n let next = this.input.charCodeAt(this.pos + 1)\n if (this.exprAllowed) {++this.pos; return this.readRegexp()}\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.slash, 1)\n}\n\npp.readToken_mult_modulo_exp = function(code) { // '%*'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n let tokentype = code === 42 ? tt.star : tt.modulo\n\n // exponentiation operator ** and **=\n if (this.options.ecmaVersion >= 7 && next === 42) {\n ++size\n tokentype = tt.starstar\n next = this.input.charCodeAt(this.pos + 2)\n }\n\n if (next === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tokentype, size)\n}\n\npp.readToken_pipe_amp = function(code) { // '|&'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)\n}\n\npp.readToken_caret = function() { // '^'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.bitwiseXOR, 1)\n}\n\npp.readToken_plus_min = function(code) { // '+-'\n let next = this.input.charCodeAt(this.pos + 1)\n if (next === code) {\n if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&\n lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {\n // A `-->` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&\n this.input.charCodeAt(this.pos + 3) == 45) {\n if (this.inModule) this.unexpected()\n // `\n", "file_path": ".github/ISSUE_TEMPLATE.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017053242481779307, 0.00016758123820181936, 0.00016318843699991703, 0.0001683020673226565, 2.9734835607087007e-06]}
{"hunk": {"id": 2, "code_window": [" \"resolved\": \"https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz\",\n", " \"integrity\": \"sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==\"\n", " },\n", " \"reify\": {\n", " \"version\": \"0.13.7\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.13.7.tgz\",\n", " \"integrity\": \"sha512-jA6C/TdOf0g1A9WlQL7enh8yfGXgCmU3qbOpgc98vzRNEgu4TrAnSGec+uLxHdci96lftdBow3q0X3pbXnzmGQ==\"\n", " },\n", " \"semver\": {\n", " \"version\": \"5.4.1\",\n", " \"resolved\": \"https://registry.npmjs.org/semver/-/semver-5.4.1.tgz\",\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" \"version\": \"0.14.1\",\n", " \"resolved\": \"https://registry.npmjs.org/reify/-/reify-0.14.1.tgz\",\n", " \"integrity\": \"sha512-HAKYzqlCCWsfAcOTm8gsJZ6FE5I06kvjzHRQTCDD6xqUJaY8Mh4ve9oiCDe8yiYXOqZqpt03gn8yS4+bokRmhQ==\"\n"], "file_path": "packages/modules/.npm/package/npm-shrinkwrap.json", "type": "replace", "edit_start_line_idx": 19}, "file": "# code-prettify\n[Source code of released version](https://github.com/meteor/meteor/tree/master/packages/code-prettify) | [Source code of development version](https://github.com/meteor/meteor/tree/devel/packages/code-prettify)\n***\n\nThis internal Meteor package is now unnecessary and has been deprecated. To\ncontinue to use a working version of this package, please pin your package\nversion to 1.0.11 (e.g. meteor add code-prettify@=1.0.11). For details\nconcerning the deprecation of this package, see\n[issue 4445](https://github.com/meteor/meteor/issues/4445).\n", "file_path": "packages/deprecated/code-prettify/README.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017094594659283757, 0.00017094594659283757, 0.00017094594659283757, 0.00017094594659283757, 0.0]}
{"hunk": {"id": 3, "code_window": ["Package.describe({\n", " name: \"modules\",\n", " version: \"0.11.3\",\n", " summary: \"CommonJS module system\",\n", " documentation: \"README.md\"\n", "});\n"], "labels": ["keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" version: \"0.11.4\",\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 2}, "file": "// This file contains a package.json for the dependencies of the command-line\n// tool.\n\n// We put this in a JS file so that it can contain comments. It is processed\n// into a package.json file by generate-dev-bundle.sh.\n\nvar packageJson = {\n name: \"meteor-dev-bundle-tool\",\n private: true,\n dependencies: {\n // Explicit dependency because we are replacing it with a bundled version\n // and we want to make sure there are no dependencies on a higher version\n npm: \"5.6.0\",\n pacote: \"https://github.com/meteor/pacote/tarball/30973f140df79b647dbade03f2d6f19800c2609b\",\n \"node-gyp\": \"3.6.2\",\n \"node-pre-gyp\": \"0.6.36\",\n \"meteor-babel\": \"7.0.0-beta.38-2\",\n \"meteor-promise\": \"0.8.6\",\n promise: \"8.0.1\",\n reify: \"0.13.7\",\n fibers: \"2.0.0\",\n // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n \"@babel/runtime\": \"7.0.0-beta.38\",\n // For backwards compatibility with isopackets that still depend on\n // babel-runtime rather than @babel/runtime.\n \"babel-runtime\": \"7.0.0-beta.3\",\n // Not yet upgrading Underscore from 1.5.2 to 1.7.0 (which should be done\n // in the package too) because we should consider using lodash instead\n // (and there are backwards-incompatible changes either way).\n underscore: \"1.5.2\",\n \"source-map-support\": \"https://github.com/meteor/node-source-map-support/tarball/1912478769d76e5df4c365e147f25896aee6375e\",\n semver: \"5.4.1\",\n request: \"2.83.0\",\n fstream: \"https://github.com/meteor/fstream/tarball/cf4ea6c175355cec7bee38311e170d08c4078a5d\",\n tar: \"2.2.1\",\n kexec: \"3.0.0\",\n \"source-map\": \"0.5.3\",\n chalk: \"0.5.1\",\n sqlite3: \"3.1.8\",\n netroute: \"1.0.2\",\n \"http-proxy\": \"1.16.2\",\n \"wordwrap\": \"0.0.2\",\n \"moment\": \"2.20.1\",\n \"rimraf\": \"2.6.2\",\n \"glob\": \"7.1.2\",\n ignore: \"3.3.7\",\n // XXX: When we update this, see if it fixes this Github issue:\n // https://github.com/jgm/CommonMark/issues/276 . If it does, remove the\n // workaround from the tool.\n \"commonmark\": \"0.15.0\",\n escope: \"3.6.0\",\n split2: \"2.2.0\",\n multipipe: \"2.0.1\",\n pathwatcher: \"7.1.1\",\n optimism: \"0.3.3\",\n 'lru-cache': '4.1.1',\n longjohn: '0.2.12'\n }\n};\n\nif (process.platform === 'win32') {\n // Remove dependencies that do not work on Windows\n delete packageJson.dependencies.netroute;\n delete packageJson.dependencies.kexec;\n}\n\nprocess.stdout.write(JSON.stringify(packageJson, null, 2) + '\\n');\n", "file_path": "scripts/dev-bundle-tool-package.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00019460129260551184, 0.00017028381989803165, 0.00016544722893740982, 0.0001663930161157623, 9.951976608135737e-06]}
{"hunk": {"id": 3, "code_window": ["Package.describe({\n", " name: \"modules\",\n", " version: \"0.11.3\",\n", " summary: \"CommonJS module system\",\n", " documentation: \"README.md\"\n", "});\n"], "labels": ["keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" version: \"0.11.4\",\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 2}, "file": "console.warn(\n \"The `google` package has been deprecated.\\n\" +\n \"\\n\" +\n \"To use the `Google` symbol, add the `google-oauth` package\\n\" +\n \"and import from it.\\n\" +\n \"\\n\" +\n \"If you need the Blaze OAuth configuration UI, add\\n\" +\n \"`google-config-ui` alongside `accounts-ui`.\"\n);\n", "file_path": "packages/deprecated/google/deprecation_notice.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.0001688503398327157, 0.0001688503398327157, 0.0001688503398327157, 0.0001688503398327157, 0.0]}
{"hunk": {"id": 3, "code_window": ["Package.describe({\n", " name: \"modules\",\n", " version: \"0.11.3\",\n", " summary: \"CommonJS module system\",\n", " documentation: \"README.md\"\n", "});\n"], "labels": ["keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" version: \"0.11.4\",\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 2}, "file": "console.warn(\n \"The `twitter` package has been deprecated.\\n\" +\n \"\\n\" +\n \"To use the `Twitter` symbol, add the `twitter-oauth` package\\n\" +\n \"and import from it.\\n\" +\n \"\\n\" +\n \"If you need the Blaze OAuth configuration UI, add\\n\" +\n \"`twitter-config-ui` alongside `accounts-ui`.\"\n);\n", "file_path": "packages/deprecated/twitter/deprecation_notice.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00016778723511379212, 0.00016778723511379212, 0.00016778723511379212, 0.00016778723511379212, 0.0]}
{"hunk": {"id": 3, "code_window": ["Package.describe({\n", " name: \"modules\",\n", " version: \"0.11.3\",\n", " summary: \"CommonJS module system\",\n", " documentation: \"README.md\"\n", "});\n"], "labels": ["keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" version: \"0.11.4\",\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 2}, "file": "if (Meteor.isServer) {\n var passed = true;\n var expectText = \"Test\\n\";\n\n if (Assets.getText(\"test.txt\") !== expectText)\n throw new Error(\"getText test.txt does not match\");\n if (TestAsset.convert(Assets.getBinary(\"test.txt\"))\n !== expectText)\n throw new Error(\"getBinary test.txt does not match\");\n\n Assets.getText(\"test.txt\", function (err, result) {\n if (err || result !== expectText)\n throw new Error(\"async getText test.txt does not match\");\n Assets.getBinary(\"test.txt\", function (err, result) {\n if (err || TestAsset.convert(result) !== expectText)\n throw new Error(\"async getBinary test.txt does not match\");\n TestAsset.go(true /* exit when done */);\n });\n });\n}\n", "file_path": "tools/tests/old/app-with-private/main.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017816867330111563, 0.00017425553232897073, 0.00017199807916767895, 0.00017259987362194806, 2.7778874027717393e-06]}
{"hunk": {"id": 4, "code_window": [" documentation: \"README.md\"\n", "});\n", "\n", "Npm.depends({\n", " reify: \"0.13.7\"\n", "});\n", "\n", "Package.onUse(function(api) {\n", " api.use(\"modules-runtime\");\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\"\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 8}, "file": "Package.describe({\n name: \"modules\",\n version: \"0.11.3\",\n summary: \"CommonJS module system\",\n documentation: \"README.md\"\n});\n\nNpm.depends({\n reify: \"0.13.7\"\n});\n\nPackage.onUse(function(api) {\n api.use(\"modules-runtime\");\n api.mainModule(\"client.js\", \"client\");\n api.mainModule(\"server.js\", \"server\");\n api.export(\"meteorInstall\");\n});\n", "file_path": "packages/modules/package.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.056004058569669724, 0.02989494800567627, 0.0037858355790376663, 0.02989494800567627, 0.026109110563993454]}
{"hunk": {"id": 4, "code_window": [" documentation: \"README.md\"\n", "});\n", "\n", "Npm.depends({\n", " reify: \"0.13.7\"\n", "});\n", "\n", "Package.onUse(function(api) {\n", " api.use(\"modules-runtime\");\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\"\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 8}, "file": "", "file_path": "tools/tests/apps/build-errors/foo.awesome", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017712288536131382, 0.00017712288536131382, 0.00017712288536131382, 0.00017712288536131382, 0.0]}
{"hunk": {"id": 4, "code_window": [" documentation: \"README.md\"\n", "});\n", "\n", "Npm.depends({\n", " reify: \"0.13.7\"\n", "});\n", "\n", "Package.onUse(function(api) {\n", " api.use(\"modules-runtime\");\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\"\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 8}, "file": "# github-oauth\n\nAn implementation of the GitHub OAuth flow. See the [Meteor Guide](https://guide.meteor.com/accounts.html) for more details.\n", "file_path": "packages/github-oauth/README.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017030721937771887, 0.00017030721937771887, 0.00017030721937771887, 0.00017030721937771887, 0.0]}
{"hunk": {"id": 4, "code_window": [" documentation: \"README.md\"\n", "});\n", "\n", "Npm.depends({\n", " reify: \"0.13.7\"\n", "});\n", "\n", "Package.onUse(function(api) {\n", " api.use(\"modules-runtime\");\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\"\n"], "file_path": "packages/modules/package.js", "type": "replace", "edit_start_line_idx": 8}, "file": "export const packageName = \"bundle-visualizer\";\nexport const classPrefix = \"meteorBundleVisualizer\";\nexport const methodNameStats = `/__meteor__/${packageName}/stats`;\nexport const typeBundle = \"bundle\";\nexport const typePackage = \"package\";\nexport const typeNodeModules = \"node_modules\";\n\nfunction capitalizeFirstLetter(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport function prefixedClass(className) {\n return `${classPrefix}${capitalizeFirstLetter(className)}`;\n}\n", "file_path": "packages/non-core/bundle-visualizer/common.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.0027112362440675497, 0.0014411911834031343, 0.00017114606453105807, 0.0014411911834031343, 0.0012700450606644154]}
{"hunk": {"id": 5, "code_window": [" \"meteor-babel\": \"7.0.0-beta.38-2\",\n", " \"meteor-promise\": \"0.8.6\",\n", " promise: \"8.0.1\",\n", " reify: \"0.13.7\",\n", " fibers: \"2.0.0\",\n", " // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n", " \"@babel/runtime\": \"7.0.0-beta.38\",\n", " // For backwards compatibility with isopackets that still depend on\n", " // babel-runtime rather than @babel/runtime.\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 19}, "file": "// This file contains a package.json for the dependencies of the command-line\n// tool.\n\n// We put this in a JS file so that it can contain comments. It is processed\n// into a package.json file by generate-dev-bundle.sh.\n\nvar packageJson = {\n name: \"meteor-dev-bundle-tool\",\n private: true,\n dependencies: {\n // Explicit dependency because we are replacing it with a bundled version\n // and we want to make sure there are no dependencies on a higher version\n npm: \"5.6.0\",\n pacote: \"https://github.com/meteor/pacote/tarball/30973f140df79b647dbade03f2d6f19800c2609b\",\n \"node-gyp\": \"3.6.2\",\n \"node-pre-gyp\": \"0.6.36\",\n \"meteor-babel\": \"7.0.0-beta.38-2\",\n \"meteor-promise\": \"0.8.6\",\n promise: \"8.0.1\",\n reify: \"0.13.7\",\n fibers: \"2.0.0\",\n // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n \"@babel/runtime\": \"7.0.0-beta.38\",\n // For backwards compatibility with isopackets that still depend on\n // babel-runtime rather than @babel/runtime.\n \"babel-runtime\": \"7.0.0-beta.3\",\n // Not yet upgrading Underscore from 1.5.2 to 1.7.0 (which should be done\n // in the package too) because we should consider using lodash instead\n // (and there are backwards-incompatible changes either way).\n underscore: \"1.5.2\",\n \"source-map-support\": \"https://github.com/meteor/node-source-map-support/tarball/1912478769d76e5df4c365e147f25896aee6375e\",\n semver: \"5.4.1\",\n request: \"2.83.0\",\n fstream: \"https://github.com/meteor/fstream/tarball/cf4ea6c175355cec7bee38311e170d08c4078a5d\",\n tar: \"2.2.1\",\n kexec: \"3.0.0\",\n \"source-map\": \"0.5.3\",\n chalk: \"0.5.1\",\n sqlite3: \"3.1.8\",\n netroute: \"1.0.2\",\n \"http-proxy\": \"1.16.2\",\n \"wordwrap\": \"0.0.2\",\n \"moment\": \"2.20.1\",\n \"rimraf\": \"2.6.2\",\n \"glob\": \"7.1.2\",\n ignore: \"3.3.7\",\n // XXX: When we update this, see if it fixes this Github issue:\n // https://github.com/jgm/CommonMark/issues/276 . If it does, remove the\n // workaround from the tool.\n \"commonmark\": \"0.15.0\",\n escope: \"3.6.0\",\n split2: \"2.2.0\",\n multipipe: \"2.0.1\",\n pathwatcher: \"7.1.1\",\n optimism: \"0.3.3\",\n 'lru-cache': '4.1.1',\n longjohn: '0.2.12'\n }\n};\n\nif (process.platform === 'win32') {\n // Remove dependencies that do not work on Windows\n delete packageJson.dependencies.netroute;\n delete packageJson.dependencies.kexec;\n}\n\nprocess.stdout.write(JSON.stringify(packageJson, null, 2) + '\\n');\n", "file_path": "scripts/dev-bundle-tool-package.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.9388132691383362, 0.14162814617156982, 0.00016561438678763807, 0.00016760862490627915, 0.3259354531764984]}
{"hunk": {"id": 5, "code_window": [" \"meteor-babel\": \"7.0.0-beta.38-2\",\n", " \"meteor-promise\": \"0.8.6\",\n", " promise: \"8.0.1\",\n", " reify: \"0.13.7\",\n", " fibers: \"2.0.0\",\n", " // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n", " \"@babel/runtime\": \"7.0.0-beta.38\",\n", " // For backwards compatibility with isopackets that still depend on\n", " // babel-runtime rather than @babel/runtime.\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 19}, "file": "// These tests were written before rate-limit was factored outside of DDP Rate\n// Limiter and thus are structured with DDP method invocations in mind. These\n// rules still test abstract rate limit package behavior. The tests currently\n// implemented are:\n// * Empty rule set on RateLimiter construction\n// * Multiple inputs, only 1 that matches rule and reaches rate limit\n// * Multiple inputs, 1 hits rate limit, wait for reset, after which inputs\n// allowed\n// * 2 rules, 3 inputs where 2/3 match 1 rule and thus hit rate limit. Second\n// input matches another rule and hits rate limit while 3rd rule not rate\n// limited\n// * One rule affected by two inputs still throws\n// * Global rule triggers on any invocation after reaching limit\n// * Fuzzy rule matching triggers rate limit only when input has more keys than\n// rule\n// * matchRule tests that have various levels of similarity in input and rule\n// * generateKeyString tests for various matches creating appropriate string\n//\n// XXX These tests should be refactored to use Tinytest.add instead of\n// testAsyncMulti as they're all on the server. Any future tests should be\n// written that way.\nTinytest.add('rate limit tests - Check empty constructor creation',\n function (test) {\n r = new RateLimiter();\n test.equal(r.rules, {});\n});\n\nTinytest.add('rate limit tests - Check single rule with multiple ' +\n 'invocations, only 1 that matches',\n function (test) {\n r = new RateLimiter();\n var userIdOne = 1;\n var restrictJustUserIdOneRule = {\n userId: userIdOne,\n IPAddr: null,\n method: null\n };\n\n r.addRule(restrictJustUserIdOneRule, 1, 1000);\n var connectionHandle = createTempConnectionHandle(123, '127.0.0.1');\n var methodInvc1 = createTempMethodInvocation(userIdOne, connectionHandle,\n 'login');\n var methodInvc2 = createTempMethodInvocation(2, connectionHandle,\n 'login');\n for (var i = 0; i < 2; i++) {\n r.increment(methodInvc1);\n r.increment(methodInvc2);\n }\n test.equal(r.check(methodInvc1).allowed, false);\n test.equal(r.check(methodInvc2).allowed, true);\n });\n\ntestAsyncMulti(\"rate limit tests - Run multiple invocations and wait for one\" +\n \" to reset\", [\n function (test, expect) {\n var self = this;\n self.r = new RateLimiter();\n self.userIdOne = 1;\n self.userIdTwo = 2;\n self.restrictJustUserIdOneRule = {\n userId: self.userIdOne,\n IPAddr: null,\n method: null\n };\n self.r.addRule(self.restrictJustUserIdOneRule, 1, 500);\n self.connectionHandle = createTempConnectionHandle(123, '127.0.0.1')\n self.methodInvc1 = createTempMethodInvocation(self.userIdOne,\n self.connectionHandle, 'login');\n self.methodInvc2 = createTempMethodInvocation(self.userIdTwo,\n self.connectionHandle, 'login');\n for (var i = 0; i < 2; i++) {\n self.r.increment(self.methodInvc1);\n self.r.increment(self.methodInvc2);\n }\n test.equal(self.r.check(self.methodInvc1).allowed, false);\n test.equal(self.r.check(self.methodInvc2).allowed, true);\n Meteor.setTimeout(expect(function () {}), 1000);\n },\n function (test, expect) {\n var self = this;\n for (var i = 0; i < 100; i++) {\n self.r.increment(self.methodInvc2);\n }\n\n test.equal(self.r.check(self.methodInvc1).allowed, true);\n test.equal(self.r.check(self.methodInvc2).allowed, true);\n }\n]);\n\nTinytest.add('rate limit tests - Check two rules that affect same methodInvc' +\n ' still throw',\n function (test) {\n r = new RateLimiter();\n var loginMethodRule = {\n userId: null,\n IPAddr: null,\n method: 'login'\n };\n var onlyLimitEvenUserIdRule = {\n userId: function (userId) {\n return userId % 2 === 0\n },\n IPAddr: null,\n method: null\n };\n r.addRule(loginMethodRule, 10, 100);\n r.addRule(onlyLimitEvenUserIdRule, 4, 100);\n\n var connectionHandle = createTempConnectionHandle(1234, '127.0.0.1');\n var methodInvc1 = createTempMethodInvocation(1, connectionHandle,\n 'login');\n var methodInvc2 = createTempMethodInvocation(2, connectionHandle,\n 'login');\n var methodInvc3 = createTempMethodInvocation(3, connectionHandle,\n 'test');\n\n for (var i = 0; i < 5; i++) {\n r.increment(methodInvc1);\n r.increment(methodInvc2);\n r.increment(methodInvc3);\n };\n\n // After for loop runs, we only have 10 runs, so that's under the limit\n test.equal(r.check(methodInvc1).allowed, true);\n // However, this triggers userId rule since this userId is even\n test.equal(r.check(methodInvc2).allowed, false);\n test.equal(r.check(methodInvc2).allowed, false);\n\n // Running one more test causes it to be false, since we're at 11 now.\n r.increment(methodInvc1);\n test.equal(r.check(methodInvc1).allowed, false);\n // 3rd Method Invocation isn't affected by either rules.\n test.equal(r.check(methodInvc3).allowed, true);\n\n });\n\nTinytest.add('rate limit tests - Check one rule affected by two different ' +\n 'invocations',\n function (test) {\n r = new RateLimiter();\n var loginMethodRule = {\n userId: null,\n IPAddr: null,\n method: 'login'\n }\n r.addRule(loginMethodRule, 10, 10000);\n\n var connectionHandle = createTempConnectionHandle(1234, '127.0.0.1');\n var methodInvc1 = createTempMethodInvocation(1, connectionHandle,\n 'login');\n var methodInvc2 = createTempMethodInvocation(2, connectionHandle,\n 'login');\n\n for (var i = 0; i < 5; i++) {\n r.increment(methodInvc1);\n r.increment(methodInvc2);\n }\n // This throws us over the limit since both increment the login rule\n // counter\n r.increment(methodInvc1);\n\n test.equal(r.check(methodInvc1).allowed, false);\n test.equal(r.check(methodInvc2).allowed, false);\n });\n\nTinytest.add(\"rate limit tests - add global rule\", function (test) {\n r = new RateLimiter();\n var globalRule = {\n userId: null,\n IPAddr: null,\n method: null\n }\n r.addRule(globalRule, 1, 10000);\n\n var connectionHandle = createTempConnectionHandle(1234, '127.0.0.1');\n var connectionHandle2 = createTempConnectionHandle(1234, '127.0.0.2');\n\n var methodInvc1 = createTempMethodInvocation(1, connectionHandle,\n 'login');\n var methodInvc2 = createTempMethodInvocation(2, connectionHandle2,\n 'test');\n var methodInvc3 = createTempMethodInvocation(3, connectionHandle,\n 'user-accounts');\n\n // First invocation, all methods would still be allowed.\n r.increment(methodInvc2);\n test.equal(r.check(methodInvc1).allowed, true);\n test.equal(r.check(methodInvc2).allowed, true);\n test.equal(r.check(methodInvc3).allowed, true);\n // Second invocation, everything has reached common rate limit\n r.increment(methodInvc3);\n test.equal(r.check(methodInvc1).allowed, false);\n test.equal(r.check(methodInvc2).allowed, false);\n test.equal(r.check(methodInvc3).allowed, false);\n});\n\nTinytest.add('rate limit tests - Fuzzy rule match does not trigger rate limit',\n function (test) {\n r = new RateLimiter();\n var rule = {\n a: function (inp) {\n return inp % 3 == 0\n },\n b: 5,\n c: \"hi\",\n }\n r.addRule(rule, 1, 10000);\n var input = {\n a: 3,\n b: 5\n }\n for (var i = 0; i < 5; i++) {\n r.increment(input);\n }\n test.equal(r.check(input).allowed, true);\n var matchingInput = {\n a: 3,\n b: 5,\n c: \"hi\",\n d: 1\n }\n r.increment(matchingInput);\n r.increment(matchingInput);\n // Past limit so should be false\n test.equal(r.check(matchingInput).allowed, false);\n\n // Add secondary rule and check that longer time is returned when multiple\n // rules limits are hit\n var newRule = {\n a: function (inp) {\n return inp % 3 == 0\n },\n b: 5,\n c: \"hi\",\n d: 1\n }\n r.addRule(newRule, 1, 10);\n // First rule should still throw while second rule will trigger as well,\n // causing us to return longer time to reset to user\n r.increment(matchingInput);\n r.increment(matchingInput);\n test.equal(r.check(matchingInput).timeToReset > 50, true);\n }\n);\n\n\n/****** Test Our Helper Methods *****/\n\nTinytest.add(\"rate limit tests - test matchRule method\", function (test) {\n r = new RateLimiter();\n var globalRule = {\n userId: null,\n IPAddr: null,\n type: null,\n name: null\n }\n var globalRuleId = r.addRule(globalRule);\n\n var rateLimiterInput = {\n userId: 1023,\n IPAddr: \"127.0.0.1\",\n type: 'sub',\n name: 'getSubLists'\n };\n\n test.equal(r.rules[globalRuleId].match(rateLimiterInput), true);\n\n var oneNotNullRule = {\n userId: 102,\n IPAddr: null,\n type: null,\n name: null\n }\n\n var oneNotNullId = r.addRule(oneNotNullRule);\n test.equal(r.rules[oneNotNullId].match(rateLimiterInput), false);\n\n oneNotNullRule.userId = 1023;\n test.equal(r.rules[oneNotNullId].match(rateLimiterInput), true);\n\n var notCompleteInput = {\n userId: 102,\n IPAddr: '127.0.0.1'\n };\n test.equal(r.rules[globalRuleId].match(notCompleteInput), true);\n test.equal(r.rules[oneNotNullId].match(notCompleteInput), false);\n});\n\nTinytest.add('rate limit tests - test generateMethodKey string',\n function (test) {\n r = new RateLimiter();\n var globalRule = {\n userId: null,\n IPAddr: null,\n type: null,\n name: null\n }\n var globalRuleId = r.addRule(globalRule);\n\n var rateLimiterInput = {\n userId: 1023,\n IPAddr: \"127.0.0.1\",\n type: 'sub',\n name: 'getSubLists'\n };\n\n test.equal(r.rules[globalRuleId]._generateKeyString(rateLimiterInput), \"\");\n globalRule.userId = 1023;\n\n test.equal(r.rules[globalRuleId]._generateKeyString(rateLimiterInput),\n \"userId1023\");\n\n var ruleWithFuncs = {\n userId: function (input) {\n return input % 2 === 0\n },\n IPAddr: null,\n type: null\n };\n var funcRuleId = r.addRule(ruleWithFuncs);\n test.equal(r.rules[funcRuleId]._generateKeyString(rateLimiterInput), \"\");\n rateLimiterInput.userId = 1024;\n test.equal(r.rules[funcRuleId]._generateKeyString(rateLimiterInput),\n \"userId1024\");\n\n var multipleRules = ruleWithFuncs;\n multipleRules.IPAddr = '127.0.0.1';\n var multipleRuleId = r.addRule(multipleRules);\n test.equal(r.rules[multipleRuleId]._generateKeyString(rateLimiterInput),\n \"userId1024IPAddr127.0.0.1\")\n }\n);\n\nfunction createTempConnectionHandle(id, clientIP) {\n return {\n id: id,\n close: function () {\n self.close();\n },\n onClose: function (fn) {\n var cb = Meteor.bindEnvironment(fn, \"connection onClose callback\");\n if (self.inQueue) {\n self._closeCallbacks.push(cb);\n } else {\n // if we're already closed, call the callback.\n Meteor.defer(cb);\n }\n },\n clientAddress: clientIP,\n httpHeaders: null\n };\n}\n\nfunction createTempMethodInvocation(userId, connectionHandle, methodName) {\n var methodInv = new DDPCommon.MethodInvocation({\n isSimulation: false,\n userId: userId,\n setUserId: null,\n unblock: false,\n connection: connectionHandle,\n randomSeed: 1234\n });\n methodInv.method = methodName;\n return methodInv;\n}", "file_path": "packages/rate-limit/rate-limit-tests.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017613611998967826, 0.0001714397076284513, 0.0001637223904253915, 0.00017209633369930089, 2.9860759696020978e-06]}
{"hunk": {"id": 5, "code_window": [" \"meteor-babel\": \"7.0.0-beta.38-2\",\n", " \"meteor-promise\": \"0.8.6\",\n", " promise: \"8.0.1\",\n", " reify: \"0.13.7\",\n", " fibers: \"2.0.0\",\n", " // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n", " \"@babel/runtime\": \"7.0.0-beta.38\",\n", " // For backwards compatibility with isopackets that still depend on\n", " // babel-runtime rather than @babel/runtime.\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 19}, "file": "# ecmascript-runtime-server\n[Source code of released version](https://github.com/meteor/meteor/tree/master/packages/ecmascript-runtime-server) | [Source code of development version](https://github.com/meteor/meteor/tree/devel/packages/ecmascript-runtime-server)\n***\n\n[](https://travis-ci.org/meteor/ecmascript-runtime)\nPolyfills for new ECMAScript 2015 APIs like Map and Set\n", "file_path": "packages/ecmascript-runtime-server/README.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.0002317761245649308, 0.0002317761245649308, 0.0002317761245649308, 0.0002317761245649308, 0.0]}
{"hunk": {"id": 5, "code_window": [" \"meteor-babel\": \"7.0.0-beta.38-2\",\n", " \"meteor-promise\": \"0.8.6\",\n", " promise: \"8.0.1\",\n", " reify: \"0.13.7\",\n", " fibers: \"2.0.0\",\n", " // So that Babel can emit require(\"@babel/runtime/helpers/...\") calls.\n", " \"@babel/runtime\": \"7.0.0-beta.38\",\n", " // For backwards compatibility with isopackets that still depend on\n", " // babel-runtime rather than @babel/runtime.\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": [" reify: \"0.14.1\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 19}, "file": ".build*\n", "file_path": "packages/browser-policy-content/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00016984227113425732, 0.00016984227113425732, 0.00016984227113425732, 0.00016984227113425732, 0.0]}
{"hunk": {"id": 6, "code_window": [" \"commonmark\": \"0.15.0\",\n", " escope: \"3.6.0\",\n", " split2: \"2.2.0\",\n", " multipipe: \"2.0.1\",\n", " pathwatcher: \"7.1.1\",\n", " optimism: \"0.3.3\",\n", " 'lru-cache': '4.1.1',\n", " longjohn: '0.2.12'\n", " }\n"], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" optimism: \"0.4.0\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 54}, "file": "Package.describe({\n name: \"modules\",\n version: \"0.11.3\",\n summary: \"CommonJS module system\",\n documentation: \"README.md\"\n});\n\nNpm.depends({\n reify: \"0.13.7\"\n});\n\nPackage.onUse(function(api) {\n api.use(\"modules-runtime\");\n api.mainModule(\"client.js\", \"client\");\n api.mainModule(\"server.js\", \"server\");\n api.export(\"meteorInstall\");\n});\n", "file_path": "packages/modules/package.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017266703071072698, 0.00017134204972535372, 0.0001700170832918957, 0.00017134204972535372, 1.3249737094156444e-06]}
{"hunk": {"id": 6, "code_window": [" \"commonmark\": \"0.15.0\",\n", " escope: \"3.6.0\",\n", " split2: \"2.2.0\",\n", " multipipe: \"2.0.1\",\n", " pathwatcher: \"7.1.1\",\n", " optimism: \"0.3.3\",\n", " 'lru-cache': '4.1.1',\n", " longjohn: '0.2.12'\n", " }\n"], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" optimism: \"0.4.0\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 54}, "file": "var Future = Npm.require('fibers/future');\n\nvar PHASE = {\n QUERYING: \"QUERYING\",\n FETCHING: \"FETCHING\",\n STEADY: \"STEADY\"\n};\n\n// Exception thrown by _needToPollQuery which unrolls the stack up to the\n// enclosing call to finishIfNeedToPollQuery.\nvar SwitchedToQuery = function () {};\nvar finishIfNeedToPollQuery = function (f) {\n return function () {\n try {\n f.apply(this, arguments);\n } catch (e) {\n if (!(e instanceof SwitchedToQuery))\n throw e;\n }\n };\n};\n\nvar currentId = 0;\n\n// OplogObserveDriver is an alternative to PollingObserveDriver which follows\n// the Mongo operation log instead of just re-polling the query. It obeys the\n// same simple interface: constructing it starts sending observeChanges\n// callbacks (and a ready() invocation) to the ObserveMultiplexer, and you stop\n// it by calling the stop() method.\nOplogObserveDriver = function (options) {\n var self = this;\n self._usesOplog = true; // tests look at this\n\n self._id = currentId;\n currentId++;\n\n self._cursorDescription = options.cursorDescription;\n self._mongoHandle = options.mongoHandle;\n self._multiplexer = options.multiplexer;\n\n if (options.ordered) {\n throw Error(\"OplogObserveDriver only supports unordered observeChanges\");\n }\n\n var sorter = options.sorter;\n // We don't support $near and other geo-queries so it's OK to initialize the\n // comparator only once in the constructor.\n var comparator = sorter && sorter.getComparator();\n\n if (options.cursorDescription.options.limit) {\n // There are several properties ordered driver implements:\n // - _limit is a positive number\n // - _comparator is a function-comparator by which the query is ordered\n // - _unpublishedBuffer is non-null Min/Max Heap,\n // the empty buffer in STEADY phase implies that the\n // everything that matches the queries selector fits\n // into published set.\n // - _published - Min Heap (also implements IdMap methods)\n\n var heapOptions = { IdMap: LocalCollection._IdMap };\n self._limit = self._cursorDescription.options.limit;\n self._comparator = comparator;\n self._sorter = sorter;\n self._unpublishedBuffer = new MinMaxHeap(comparator, heapOptions);\n // We need something that can find Max value in addition to IdMap interface\n self._published = new MaxHeap(comparator, heapOptions);\n } else {\n self._limit = 0;\n self._comparator = null;\n self._sorter = null;\n self._unpublishedBuffer = null;\n self._published = new LocalCollection._IdMap;\n }\n\n // Indicates if it is safe to insert a new document at the end of the buffer\n // for this query. i.e. it is known that there are no documents matching the\n // selector those are not in published or buffer.\n self._safeAppendToBuffer = false;\n\n self._stopped = false;\n self._stopHandles = [];\n\n Package.facts && Package.facts.Facts.incrementServerFact(\n \"mongo-livedata\", \"observe-drivers-oplog\", 1);\n\n self._registerPhaseChange(PHASE.QUERYING);\n\n self._matcher = options.matcher;\n var projection = self._cursorDescription.options.fields || {};\n self._projectionFn = LocalCollection._compileProjection(projection);\n // Projection function, result of combining important fields for selector and\n // existing fields projection\n self._sharedProjection = self._matcher.combineIntoProjection(projection);\n if (sorter)\n self._sharedProjection = sorter.combineIntoProjection(self._sharedProjection);\n self._sharedProjectionFn = LocalCollection._compileProjection(\n self._sharedProjection);\n\n self._needToFetch = new LocalCollection._IdMap;\n self._currentlyFetching = null;\n self._fetchGeneration = 0;\n\n self._requeryWhenDoneThisQuery = false;\n self._writesToCommitWhenWeReachSteady = [];\n\n // If the oplog handle tells us that it skipped some entries (because it got\n // behind, say), re-poll.\n self._stopHandles.push(self._mongoHandle._oplogHandle.onSkippedEntries(\n finishIfNeedToPollQuery(function () {\n self._needToPollQuery();\n })\n ));\n\n forEachTrigger(self._cursorDescription, function (trigger) {\n self._stopHandles.push(self._mongoHandle._oplogHandle.onOplogEntry(\n trigger, function (notification) {\n Meteor._noYieldsAllowed(finishIfNeedToPollQuery(function () {\n var op = notification.op;\n if (notification.dropCollection || notification.dropDatabase) {\n // Note: this call is not allowed to block on anything (especially\n // on waiting for oplog entries to catch up) because that will block\n // onOplogEntry!\n self._needToPollQuery();\n } else {\n // All other operators should be handled depending on phase\n if (self._phase === PHASE.QUERYING) {\n self._handleOplogEntryQuerying(op);\n } else {\n self._handleOplogEntrySteadyOrFetching(op);\n }\n }\n }));\n }\n ));\n });\n\n // XXX ordering w.r.t. everything else?\n self._stopHandles.push(listenAll(\n self._cursorDescription, function (notification) {\n // If we're not in a pre-fire write fence, we don't have to do anything.\n var fence = DDPServer._CurrentWriteFence.get();\n if (!fence || fence.fired)\n return;\n\n if (fence._oplogObserveDrivers) {\n fence._oplogObserveDrivers[self._id] = self;\n return;\n }\n\n fence._oplogObserveDrivers = {};\n fence._oplogObserveDrivers[self._id] = self;\n\n fence.onBeforeFire(function () {\n var drivers = fence._oplogObserveDrivers;\n delete fence._oplogObserveDrivers;\n\n // This fence cannot fire until we've caught up to \"this point\" in the\n // oplog, and all observers made it back to the steady state.\n self._mongoHandle._oplogHandle.waitUntilCaughtUp();\n\n _.each(drivers, function (driver) {\n if (driver._stopped)\n return;\n\n var write = fence.beginWrite();\n if (driver._phase === PHASE.STEADY) {\n // Make sure that all of the callbacks have made it through the\n // multiplexer and been delivered to ObserveHandles before committing\n // writes.\n driver._multiplexer.onFlush(function () {\n write.committed();\n });\n } else {\n driver._writesToCommitWhenWeReachSteady.push(write);\n }\n });\n });\n }\n ));\n\n // When Mongo fails over, we need to repoll the query, in case we processed an\n // oplog entry that got rolled back.\n self._stopHandles.push(self._mongoHandle._onFailover(finishIfNeedToPollQuery(\n function () {\n self._needToPollQuery();\n })));\n\n // Give _observeChanges a chance to add the new ObserveHandle to our\n // multiplexer, so that the added calls get streamed.\n Meteor.defer(finishIfNeedToPollQuery(function () {\n self._runInitialQuery();\n }));\n};\n\n_.extend(OplogObserveDriver.prototype, {\n _addPublished: function (id, doc) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n var fields = _.clone(doc);\n delete fields._id;\n self._published.set(id, self._sharedProjectionFn(doc));\n self._multiplexer.added(id, self._projectionFn(fields));\n\n // After adding this document, the published set might be overflowed\n // (exceeding capacity specified by limit). If so, push the maximum\n // element to the buffer, we might want to save it in memory to reduce the\n // amount of Mongo lookups in the future.\n if (self._limit && self._published.size() > self._limit) {\n // XXX in theory the size of published is no more than limit+1\n if (self._published.size() !== self._limit + 1) {\n throw new Error(\"After adding to published, \" +\n (self._published.size() - self._limit) +\n \" documents are overflowing the set\");\n }\n\n var overflowingDocId = self._published.maxElementId();\n var overflowingDoc = self._published.get(overflowingDocId);\n\n if (EJSON.equals(overflowingDocId, id)) {\n throw new Error(\"The document just added is overflowing the published set\");\n }\n\n self._published.remove(overflowingDocId);\n self._multiplexer.removed(overflowingDocId);\n self._addBuffered(overflowingDocId, overflowingDoc);\n }\n });\n },\n _removePublished: function (id) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._published.remove(id);\n self._multiplexer.removed(id);\n if (! self._limit || self._published.size() === self._limit)\n return;\n\n if (self._published.size() > self._limit)\n throw Error(\"self._published got too big\");\n\n // OK, we are publishing less than the limit. Maybe we should look in the\n // buffer to find the next element past what we were publishing before.\n\n if (!self._unpublishedBuffer.empty()) {\n // There's something in the buffer; move the first thing in it to\n // _published.\n var newDocId = self._unpublishedBuffer.minElementId();\n var newDoc = self._unpublishedBuffer.get(newDocId);\n self._removeBuffered(newDocId);\n self._addPublished(newDocId, newDoc);\n return;\n }\n\n // There's nothing in the buffer. This could mean one of a few things.\n\n // (a) We could be in the middle of re-running the query (specifically, we\n // could be in _publishNewResults). In that case, _unpublishedBuffer is\n // empty because we clear it at the beginning of _publishNewResults. In\n // this case, our caller already knows the entire answer to the query and\n // we don't need to do anything fancy here. Just return.\n if (self._phase === PHASE.QUERYING)\n return;\n\n // (b) We're pretty confident that the union of _published and\n // _unpublishedBuffer contain all documents that match selector. Because\n // _unpublishedBuffer is empty, that means we're confident that _published\n // contains all documents that match selector. So we have nothing to do.\n if (self._safeAppendToBuffer)\n return;\n\n // (c) Maybe there are other documents out there that should be in our\n // buffer. But in that case, when we emptied _unpublishedBuffer in\n // _removeBuffered, we should have called _needToPollQuery, which will\n // either put something in _unpublishedBuffer or set _safeAppendToBuffer\n // (or both), and it will put us in QUERYING for that whole time. So in\n // fact, we shouldn't be able to get here.\n\n throw new Error(\"Buffer inexplicably empty\");\n });\n },\n _changePublished: function (id, oldDoc, newDoc) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._published.set(id, self._sharedProjectionFn(newDoc));\n var projectedNew = self._projectionFn(newDoc);\n var projectedOld = self._projectionFn(oldDoc);\n var changed = DiffSequence.makeChangedFields(\n projectedNew, projectedOld);\n if (!_.isEmpty(changed))\n self._multiplexer.changed(id, changed);\n });\n },\n _addBuffered: function (id, doc) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._unpublishedBuffer.set(id, self._sharedProjectionFn(doc));\n\n // If something is overflowing the buffer, we just remove it from cache\n if (self._unpublishedBuffer.size() > self._limit) {\n var maxBufferedId = self._unpublishedBuffer.maxElementId();\n\n self._unpublishedBuffer.remove(maxBufferedId);\n\n // Since something matching is removed from cache (both published set and\n // buffer), set flag to false\n self._safeAppendToBuffer = false;\n }\n });\n },\n // Is called either to remove the doc completely from matching set or to move\n // it to the published set later.\n _removeBuffered: function (id) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._unpublishedBuffer.remove(id);\n // To keep the contract \"buffer is never empty in STEADY phase unless the\n // everything matching fits into published\" true, we poll everything as\n // soon as we see the buffer becoming empty.\n if (! self._unpublishedBuffer.size() && ! self._safeAppendToBuffer)\n self._needToPollQuery();\n });\n },\n // Called when a document has joined the \"Matching\" results set.\n // Takes responsibility of keeping _unpublishedBuffer in sync with _published\n // and the effect of limit enforced.\n _addMatching: function (doc) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n var id = doc._id;\n if (self._published.has(id))\n throw Error(\"tried to add something already published \" + id);\n if (self._limit && self._unpublishedBuffer.has(id))\n throw Error(\"tried to add something already existed in buffer \" + id);\n\n var limit = self._limit;\n var comparator = self._comparator;\n var maxPublished = (limit && self._published.size() > 0) ?\n self._published.get(self._published.maxElementId()) : null;\n var maxBuffered = (limit && self._unpublishedBuffer.size() > 0)\n ? self._unpublishedBuffer.get(self._unpublishedBuffer.maxElementId())\n : null;\n // The query is unlimited or didn't publish enough documents yet or the\n // new document would fit into published set pushing the maximum element\n // out, then we need to publish the doc.\n var toPublish = ! limit || self._published.size() < limit ||\n comparator(doc, maxPublished) < 0;\n\n // Otherwise we might need to buffer it (only in case of limited query).\n // Buffering is allowed if the buffer is not filled up yet and all\n // matching docs are either in the published set or in the buffer.\n var canAppendToBuffer = !toPublish && self._safeAppendToBuffer &&\n self._unpublishedBuffer.size() < limit;\n\n // Or if it is small enough to be safely inserted to the middle or the\n // beginning of the buffer.\n var canInsertIntoBuffer = !toPublish && maxBuffered &&\n comparator(doc, maxBuffered) <= 0;\n\n var toBuffer = canAppendToBuffer || canInsertIntoBuffer;\n\n if (toPublish) {\n self._addPublished(id, doc);\n } else if (toBuffer) {\n self._addBuffered(id, doc);\n } else {\n // dropping it and not saving to the cache\n self._safeAppendToBuffer = false;\n }\n });\n },\n // Called when a document leaves the \"Matching\" results set.\n // Takes responsibility of keeping _unpublishedBuffer in sync with _published\n // and the effect of limit enforced.\n _removeMatching: function (id) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n if (! self._published.has(id) && ! self._limit)\n throw Error(\"tried to remove something matching but not cached \" + id);\n\n if (self._published.has(id)) {\n self._removePublished(id);\n } else if (self._unpublishedBuffer.has(id)) {\n self._removeBuffered(id);\n }\n });\n },\n _handleDoc: function (id, newDoc) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n var matchesNow = newDoc && self._matcher.documentMatches(newDoc).result;\n\n var publishedBefore = self._published.has(id);\n var bufferedBefore = self._limit && self._unpublishedBuffer.has(id);\n var cachedBefore = publishedBefore || bufferedBefore;\n\n if (matchesNow && !cachedBefore) {\n self._addMatching(newDoc);\n } else if (cachedBefore && !matchesNow) {\n self._removeMatching(id);\n } else if (cachedBefore && matchesNow) {\n var oldDoc = self._published.get(id);\n var comparator = self._comparator;\n var minBuffered = self._limit && self._unpublishedBuffer.size() &&\n self._unpublishedBuffer.get(self._unpublishedBuffer.minElementId());\n var maxBuffered;\n\n if (publishedBefore) {\n // Unlimited case where the document stays in published once it\n // matches or the case when we don't have enough matching docs to\n // publish or the changed but matching doc will stay in published\n // anyways.\n //\n // XXX: We rely on the emptiness of buffer. Be sure to maintain the\n // fact that buffer can't be empty if there are matching documents not\n // published. Notably, we don't want to schedule repoll and continue\n // relying on this property.\n var staysInPublished = ! self._limit ||\n self._unpublishedBuffer.size() === 0 ||\n comparator(newDoc, minBuffered) <= 0;\n\n if (staysInPublished) {\n self._changePublished(id, oldDoc, newDoc);\n } else {\n // after the change doc doesn't stay in the published, remove it\n self._removePublished(id);\n // but it can move into buffered now, check it\n maxBuffered = self._unpublishedBuffer.get(\n self._unpublishedBuffer.maxElementId());\n\n var toBuffer = self._safeAppendToBuffer ||\n (maxBuffered && comparator(newDoc, maxBuffered) <= 0);\n\n if (toBuffer) {\n self._addBuffered(id, newDoc);\n } else {\n // Throw away from both published set and buffer\n self._safeAppendToBuffer = false;\n }\n }\n } else if (bufferedBefore) {\n oldDoc = self._unpublishedBuffer.get(id);\n // remove the old version manually instead of using _removeBuffered so\n // we don't trigger the querying immediately. if we end this block\n // with the buffer empty, we will need to trigger the query poll\n // manually too.\n self._unpublishedBuffer.remove(id);\n\n var maxPublished = self._published.get(\n self._published.maxElementId());\n maxBuffered = self._unpublishedBuffer.size() &&\n self._unpublishedBuffer.get(\n self._unpublishedBuffer.maxElementId());\n\n // the buffered doc was updated, it could move to published\n var toPublish = comparator(newDoc, maxPublished) < 0;\n\n // or stays in buffer even after the change\n var staysInBuffer = (! toPublish && self._safeAppendToBuffer) ||\n (!toPublish && maxBuffered &&\n comparator(newDoc, maxBuffered) <= 0);\n\n if (toPublish) {\n self._addPublished(id, newDoc);\n } else if (staysInBuffer) {\n // stays in buffer but changes\n self._unpublishedBuffer.set(id, newDoc);\n } else {\n // Throw away from both published set and buffer\n self._safeAppendToBuffer = false;\n // Normally this check would have been done in _removeBuffered but\n // we didn't use it, so we need to do it ourself now.\n if (! self._unpublishedBuffer.size()) {\n self._needToPollQuery();\n }\n }\n } else {\n throw new Error(\"cachedBefore implies either of publishedBefore or bufferedBefore is true.\");\n }\n }\n });\n },\n _fetchModifiedDocuments: function () {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._registerPhaseChange(PHASE.FETCHING);\n // Defer, because nothing called from the oplog entry handler may yield,\n // but fetch() yields.\n Meteor.defer(finishIfNeedToPollQuery(function () {\n while (!self._stopped && !self._needToFetch.empty()) {\n if (self._phase === PHASE.QUERYING) {\n // While fetching, we decided to go into QUERYING mode, and then we\n // saw another oplog entry, so _needToFetch is not empty. But we\n // shouldn't fetch these documents until AFTER the query is done.\n break;\n }\n\n // Being in steady phase here would be surprising.\n if (self._phase !== PHASE.FETCHING)\n throw new Error(\"phase in fetchModifiedDocuments: \" + self._phase);\n\n self._currentlyFetching = self._needToFetch;\n var thisGeneration = ++self._fetchGeneration;\n self._needToFetch = new LocalCollection._IdMap;\n var waiting = 0;\n var fut = new Future;\n // This loop is safe, because _currentlyFetching will not be updated\n // during this loop (in fact, it is never mutated).\n self._currentlyFetching.forEach(function (cacheKey, id) {\n waiting++;\n self._mongoHandle._docFetcher.fetch(\n self._cursorDescription.collectionName, id, cacheKey,\n finishIfNeedToPollQuery(function (err, doc) {\n try {\n if (err) {\n Meteor._debug(\"Got exception while fetching documents: \" +\n err);\n // If we get an error from the fetcher (eg, trouble\n // connecting to Mongo), let's just abandon the fetch phase\n // altogether and fall back to polling. It's not like we're\n // getting live updates anyway.\n if (self._phase !== PHASE.QUERYING) {\n self._needToPollQuery();\n }\n } else if (!self._stopped && self._phase === PHASE.FETCHING\n && self._fetchGeneration === thisGeneration) {\n // We re-check the generation in case we've had an explicit\n // _pollQuery call (eg, in another fiber) which should\n // effectively cancel this round of fetches. (_pollQuery\n // increments the generation.)\n self._handleDoc(id, doc);\n }\n } finally {\n waiting--;\n // Because fetch() never calls its callback synchronously,\n // this is safe (ie, we won't call fut.return() before the\n // forEach is done).\n if (waiting === 0)\n fut.return();\n }\n }));\n });\n fut.wait();\n // Exit now if we've had a _pollQuery call (here or in another fiber).\n if (self._phase === PHASE.QUERYING)\n return;\n self._currentlyFetching = null;\n }\n // We're done fetching, so we can be steady, unless we've had a\n // _pollQuery call (here or in another fiber).\n if (self._phase !== PHASE.QUERYING)\n self._beSteady();\n }));\n });\n },\n _beSteady: function () {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._registerPhaseChange(PHASE.STEADY);\n var writes = self._writesToCommitWhenWeReachSteady;\n self._writesToCommitWhenWeReachSteady = [];\n self._multiplexer.onFlush(function () {\n _.each(writes, function (w) {\n w.committed();\n });\n });\n });\n },\n _handleOplogEntryQuerying: function (op) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n self._needToFetch.set(idForOp(op), op.ts.toString());\n });\n },\n _handleOplogEntrySteadyOrFetching: function (op) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n var id = idForOp(op);\n // If we're already fetching this one, or about to, we can't optimize;\n // make sure that we fetch it again if necessary.\n if (self._phase === PHASE.FETCHING &&\n ((self._currentlyFetching && self._currentlyFetching.has(id)) ||\n self._needToFetch.has(id))) {\n self._needToFetch.set(id, op.ts.toString());\n return;\n }\n\n if (op.op === 'd') {\n if (self._published.has(id) ||\n (self._limit && self._unpublishedBuffer.has(id)))\n self._removeMatching(id);\n } else if (op.op === 'i') {\n if (self._published.has(id))\n throw new Error(\"insert found for already-existing ID in published\");\n if (self._unpublishedBuffer && self._unpublishedBuffer.has(id))\n throw new Error(\"insert found for already-existing ID in buffer\");\n\n // XXX what if selector yields? for now it can't but later it could\n // have $where\n if (self._matcher.documentMatches(op.o).result)\n self._addMatching(op.o);\n } else if (op.op === 'u') {\n // Is this a modifier ($set/$unset, which may require us to poll the\n // database to figure out if the whole document matches the selector) or\n // a replacement (in which case we can just directly re-evaluate the\n // selector)?\n var isReplace = !_.has(op.o, '$set') && !_.has(op.o, '$unset');\n // If this modifier modifies something inside an EJSON custom type (ie,\n // anything with EJSON$), then we can't try to use\n // LocalCollection._modify, since that just mutates the EJSON encoding,\n // not the actual object.\n var canDirectlyModifyDoc =\n !isReplace && modifierCanBeDirectlyApplied(op.o);\n\n var publishedBefore = self._published.has(id);\n var bufferedBefore = self._limit && self._unpublishedBuffer.has(id);\n\n if (isReplace) {\n self._handleDoc(id, _.extend({_id: id}, op.o));\n } else if ((publishedBefore || bufferedBefore) &&\n canDirectlyModifyDoc) {\n // Oh great, we actually know what the document is, so we can apply\n // this directly.\n var newDoc = self._published.has(id)\n ? self._published.get(id) : self._unpublishedBuffer.get(id);\n newDoc = EJSON.clone(newDoc);\n\n newDoc._id = id;\n try {\n LocalCollection._modify(newDoc, op.o);\n } catch (e) {\n if (e.name !== \"MinimongoError\")\n throw e;\n // We didn't understand the modifier. Re-fetch.\n self._needToFetch.set(id, op.ts.toString());\n if (self._phase === PHASE.STEADY) {\n self._fetchModifiedDocuments();\n }\n return;\n }\n self._handleDoc(id, self._sharedProjectionFn(newDoc));\n } else if (!canDirectlyModifyDoc ||\n self._matcher.canBecomeTrueByModifier(op.o) ||\n (self._sorter && self._sorter.affectedByModifier(op.o))) {\n self._needToFetch.set(id, op.ts.toString());\n if (self._phase === PHASE.STEADY)\n self._fetchModifiedDocuments();\n }\n } else {\n throw Error(\"XXX SURPRISING OPERATION: \" + op);\n }\n });\n },\n // Yields!\n _runInitialQuery: function () {\n var self = this;\n if (self._stopped)\n throw new Error(\"oplog stopped surprisingly early\");\n\n self._runQuery({initial: true}); // yields\n\n if (self._stopped)\n return; // can happen on queryError\n\n // Allow observeChanges calls to return. (After this, it's possible for\n // stop() to be called.)\n self._multiplexer.ready();\n\n self._doneQuerying(); // yields\n },\n\n // In various circumstances, we may just want to stop processing the oplog and\n // re-run the initial query, just as if we were a PollingObserveDriver.\n //\n // This function may not block, because it is called from an oplog entry\n // handler.\n //\n // XXX We should call this when we detect that we've been in FETCHING for \"too\n // long\".\n //\n // XXX We should call this when we detect Mongo failover (since that might\n // mean that some of the oplog entries we have processed have been rolled\n // back). The Node Mongo driver is in the middle of a bunch of huge\n // refactorings, including the way that it notifies you when primary\n // changes. Will put off implementing this until driver 1.4 is out.\n _pollQuery: function () {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n if (self._stopped)\n return;\n\n // Yay, we get to forget about all the things we thought we had to fetch.\n self._needToFetch = new LocalCollection._IdMap;\n self._currentlyFetching = null;\n ++self._fetchGeneration; // ignore any in-flight fetches\n self._registerPhaseChange(PHASE.QUERYING);\n\n // Defer so that we don't yield. We don't need finishIfNeedToPollQuery\n // here because SwitchedToQuery is not thrown in QUERYING mode.\n Meteor.defer(function () {\n self._runQuery();\n self._doneQuerying();\n });\n });\n },\n\n // Yields!\n _runQuery: function (options) {\n var self = this;\n options = options || {};\n var newResults, newBuffer;\n\n // This while loop is just to retry failures.\n while (true) {\n // If we've been stopped, we don't have to run anything any more.\n if (self._stopped)\n return;\n\n newResults = new LocalCollection._IdMap;\n newBuffer = new LocalCollection._IdMap;\n\n // Query 2x documents as the half excluded from the original query will go\n // into unpublished buffer to reduce additional Mongo lookups in cases\n // when documents are removed from the published set and need a\n // replacement.\n // XXX needs more thought on non-zero skip\n // XXX 2 is a \"magic number\" meaning there is an extra chunk of docs for\n // buffer if such is needed.\n var cursor = self._cursorForQuery({ limit: self._limit * 2 });\n try {\n cursor.forEach(function (doc, i) { // yields\n if (!self._limit || i < self._limit) {\n newResults.set(doc._id, doc);\n } else {\n newBuffer.set(doc._id, doc);\n }\n });\n break;\n } catch (e) {\n if (options.initial && typeof(e.code) === 'number') {\n // This is an error document sent to us by mongod, not a connection\n // error generated by the client. And we've never seen this query work\n // successfully. Probably it's a bad selector or something, so we\n // should NOT retry. Instead, we should halt the observe (which ends\n // up calling `stop` on us).\n self._multiplexer.queryError(e);\n return;\n }\n\n // During failover (eg) if we get an exception we should log and retry\n // instead of crashing.\n Meteor._debug(\"Got exception while polling query: \" + e);\n Meteor._sleepForMs(100);\n }\n }\n\n if (self._stopped)\n return;\n\n self._publishNewResults(newResults, newBuffer);\n },\n\n // Transitions to QUERYING and runs another query, or (if already in QUERYING)\n // ensures that we will query again later.\n //\n // This function may not block, because it is called from an oplog entry\n // handler. However, if we were not already in the QUERYING phase, it throws\n // an exception that is caught by the closest surrounding\n // finishIfNeedToPollQuery call; this ensures that we don't continue running\n // close that was designed for another phase inside PHASE.QUERYING.\n //\n // (It's also necessary whenever logic in this file yields to check that other\n // phases haven't put us into QUERYING mode, though; eg,\n // _fetchModifiedDocuments does this.)\n _needToPollQuery: function () {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n if (self._stopped)\n return;\n\n // If we're not already in the middle of a query, we can query now\n // (possibly pausing FETCHING).\n if (self._phase !== PHASE.QUERYING) {\n self._pollQuery();\n throw new SwitchedToQuery;\n }\n\n // We're currently in QUERYING. Set a flag to ensure that we run another\n // query when we're done.\n self._requeryWhenDoneThisQuery = true;\n });\n },\n\n // Yields!\n _doneQuerying: function () {\n var self = this;\n\n if (self._stopped)\n return;\n self._mongoHandle._oplogHandle.waitUntilCaughtUp(); // yields\n if (self._stopped)\n return;\n if (self._phase !== PHASE.QUERYING)\n throw Error(\"Phase unexpectedly \" + self._phase);\n\n Meteor._noYieldsAllowed(function () {\n if (self._requeryWhenDoneThisQuery) {\n self._requeryWhenDoneThisQuery = false;\n self._pollQuery();\n } else if (self._needToFetch.empty()) {\n self._beSteady();\n } else {\n self._fetchModifiedDocuments();\n }\n });\n },\n\n _cursorForQuery: function (optionsOverwrite) {\n var self = this;\n return Meteor._noYieldsAllowed(function () {\n // The query we run is almost the same as the cursor we are observing,\n // with a few changes. We need to read all the fields that are relevant to\n // the selector, not just the fields we are going to publish (that's the\n // \"shared\" projection). And we don't want to apply any transform in the\n // cursor, because observeChanges shouldn't use the transform.\n var options = _.clone(self._cursorDescription.options);\n\n // Allow the caller to modify the options. Useful to specify different\n // skip and limit values.\n _.extend(options, optionsOverwrite);\n\n options.fields = self._sharedProjection;\n delete options.transform;\n // We are NOT deep cloning fields or selector here, which should be OK.\n var description = new CursorDescription(\n self._cursorDescription.collectionName,\n self._cursorDescription.selector,\n options);\n return new Cursor(self._mongoHandle, description);\n });\n },\n\n\n // Replace self._published with newResults (both are IdMaps), invoking observe\n // callbacks on the multiplexer.\n // Replace self._unpublishedBuffer with newBuffer.\n //\n // XXX This is very similar to LocalCollection._diffQueryUnorderedChanges. We\n // should really: (a) Unify IdMap and OrderedDict into Unordered/OrderedDict\n // (b) Rewrite diff.js to use these classes instead of arrays and objects.\n _publishNewResults: function (newResults, newBuffer) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n\n // If the query is limited and there is a buffer, shut down so it doesn't\n // stay in a way.\n if (self._limit) {\n self._unpublishedBuffer.clear();\n }\n\n // First remove anything that's gone. Be careful not to modify\n // self._published while iterating over it.\n var idsToRemove = [];\n self._published.forEach(function (doc, id) {\n if (!newResults.has(id))\n idsToRemove.push(id);\n });\n _.each(idsToRemove, function (id) {\n self._removePublished(id);\n });\n\n // Now do adds and changes.\n // If self has a buffer and limit, the new fetched result will be\n // limited correctly as the query has sort specifier.\n newResults.forEach(function (doc, id) {\n self._handleDoc(id, doc);\n });\n\n // Sanity-check that everything we tried to put into _published ended up\n // there.\n // XXX if this is slow, remove it later\n if (self._published.size() !== newResults.size()) {\n throw Error(\n \"The Mongo server and the Meteor query disagree on how \" +\n \"many documents match your query. Maybe it is hitting a Mongo \" +\n \"edge case? The query is: \" +\n EJSON.stringify(self._cursorDescription.selector));\n }\n self._published.forEach(function (doc, id) {\n if (!newResults.has(id))\n throw Error(\"_published has a doc that newResults doesn't; \" + id);\n });\n\n // Finally, replace the buffer\n newBuffer.forEach(function (doc, id) {\n self._addBuffered(id, doc);\n });\n\n self._safeAppendToBuffer = newBuffer.size() < self._limit;\n });\n },\n\n // This stop function is invoked from the onStop of the ObserveMultiplexer, so\n // it shouldn't actually be possible to call it until the multiplexer is\n // ready.\n //\n // It's important to check self._stopped after every call in this file that\n // can yield!\n stop: function () {\n var self = this;\n if (self._stopped)\n return;\n self._stopped = true;\n _.each(self._stopHandles, function (handle) {\n handle.stop();\n });\n\n // Note: we *don't* use multiplexer.onFlush here because this stop\n // callback is actually invoked by the multiplexer itself when it has\n // determined that there are no handles left. So nothing is actually going\n // to get flushed (and it's probably not valid to call methods on the\n // dying multiplexer).\n _.each(self._writesToCommitWhenWeReachSteady, function (w) {\n w.committed(); // maybe yields?\n });\n self._writesToCommitWhenWeReachSteady = null;\n\n // Proactively drop references to potentially big things.\n self._published = null;\n self._unpublishedBuffer = null;\n self._needToFetch = null;\n self._currentlyFetching = null;\n self._oplogEntryHandle = null;\n self._listenersHandle = null;\n\n Package.facts && Package.facts.Facts.incrementServerFact(\n \"mongo-livedata\", \"observe-drivers-oplog\", -1);\n },\n\n _registerPhaseChange: function (phase) {\n var self = this;\n Meteor._noYieldsAllowed(function () {\n var now = new Date;\n\n if (self._phase) {\n var timeDiff = now - self._phaseStartTime;\n Package.facts && Package.facts.Facts.incrementServerFact(\n \"mongo-livedata\", \"time-spent-in-\" + self._phase + \"-phase\", timeDiff);\n }\n\n self._phase = phase;\n self._phaseStartTime = now;\n });\n }\n});\n\n// Does our oplog tailing code support this cursor? For now, we are being very\n// conservative and allowing only simple queries with simple options.\n// (This is a \"static method\".)\nOplogObserveDriver.cursorSupported = function (cursorDescription, matcher) {\n // First, check the options.\n var options = cursorDescription.options;\n\n // Did the user say no explicitly?\n // underscored version of the option is COMPAT with 1.2\n if (options.disableOplog || options._disableOplog)\n return false;\n\n // skip is not supported: to support it we would need to keep track of all\n // \"skipped\" documents or at least their ids.\n // limit w/o a sort specifier is not supported: current implementation needs a\n // deterministic way to order documents.\n if (options.skip || (options.limit && !options.sort)) return false;\n\n // If a fields projection option is given check if it is supported by\n // minimongo (some operators are not supported).\n if (options.fields) {\n try {\n LocalCollection._checkSupportedProjection(options.fields);\n } catch (e) {\n if (e.name === \"MinimongoError\") {\n return false;\n } else {\n throw e;\n }\n }\n }\n\n // We don't allow the following selectors:\n // - $where (not confident that we provide the same JS environment\n // as Mongo, and can yield!)\n // - $near (has \"interesting\" properties in MongoDB, like the possibility\n // of returning an ID multiple times, though even polling maybe\n // have a bug there)\n // XXX: once we support it, we would need to think more on how we\n // initialize the comparators when we create the driver.\n return !matcher.hasWhere() && !matcher.hasGeoQuery();\n};\n\nvar modifierCanBeDirectlyApplied = function (modifier) {\n return _.all(modifier, function (fields, operation) {\n return _.all(fields, function (value, field) {\n return !/EJSON\\$/.test(field);\n });\n });\n};\n\nMongoInternals.OplogObserveDriver = OplogObserveDriver;\n", "file_path": "packages/mongo/oplog_observe_driver.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00020418250642251223, 0.00016953090380411595, 0.00016010570107027888, 0.00016896839952096343, 6.1694422583968844e-06]}
{"hunk": {"id": 6, "code_window": [" \"commonmark\": \"0.15.0\",\n", " escope: \"3.6.0\",\n", " split2: \"2.2.0\",\n", " multipipe: \"2.0.1\",\n", " pathwatcher: \"7.1.1\",\n", " optimism: \"0.3.3\",\n", " 'lru-cache': '4.1.1',\n", " longjohn: '0.2.12'\n", " }\n"], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" optimism: \"0.4.0\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 54}, "file": "$el3-style = groove\n", "file_path": "tools/tests/apps/caching-stylus/imports/dotdot.styl", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00016958851483650506, 0.00016958851483650506, 0.00016958851483650506, 0.00016958851483650506, 0.0]}
{"hunk": {"id": 6, "code_window": [" \"commonmark\": \"0.15.0\",\n", " escope: \"3.6.0\",\n", " split2: \"2.2.0\",\n", " multipipe: \"2.0.1\",\n", " pathwatcher: \"7.1.1\",\n", " optimism: \"0.3.3\",\n", " 'lru-cache': '4.1.1',\n", " longjohn: '0.2.12'\n", " }\n"], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep"], "after_edit": [" optimism: \"0.4.0\",\n"], "file_path": "scripts/dev-bundle-tool-package.js", "type": "replace", "edit_start_line_idx": 54}, "file": "{\n \"name\": \"meteor-jsdoc\",\n \"version\": \"0.0.0\",\n \"lockfileVersion\": 1,\n \"requires\": true,\n \"dependencies\": {\n \"babel-eslint\": {\n \"version\": \"4.1.7\",\n \"resolved\": \"https://registry.npmjs.org/babel-eslint/-/babel-eslint-4.1.7.tgz\",\n \"integrity\": \"sha1-eSv6d/JwmvbyCtT3lswtzwtxMWU=\",\n \"requires\": {\n \"acorn-to-esprima\": \"2.0.8\",\n \"babel-traverse\": \"6.10.4\",\n \"babel-types\": \"6.11.1\",\n \"babylon\": \"6.8.4\",\n \"lodash.assign\": \"3.2.0\",\n \"lodash.pick\": \"3.1.0\"\n },\n \"dependencies\": {\n \"acorn-to-esprima\": {\n \"version\": \"2.0.8\",\n \"resolved\": \"https://registry.npmjs.org/acorn-to-esprima/-/acorn-to-esprima-2.0.8.tgz\",\n \"integrity\": \"sha1-AD8MZC65ITL0F9NwjxStqCrfLrE=\"\n },\n \"babel-traverse\": {\n \"version\": \"6.10.4\",\n \"resolved\": \"https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.10.4.tgz\",\n \"integrity\": \"sha1-289B/x8y62FIWc6tSHEWDx8SDXg=\",\n \"requires\": {\n \"babel-code-frame\": \"6.11.0\",\n \"babel-messages\": \"6.8.0\",\n \"babel-runtime\": \"6.9.2\",\n \"babel-types\": \"6.11.1\",\n \"babylon\": \"6.8.4\",\n \"debug\": \"2.2.0\",\n \"globals\": \"8.18.0\",\n \"invariant\": \"2.2.1\",\n \"lodash\": \"4.13.1\"\n },\n \"dependencies\": {\n \"babel-code-frame\": {\n \"version\": \"6.11.0\",\n \"resolved\": \"https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.11.0.tgz\",\n \"integrity\": \"sha1-kHLdI1P7D4W2tX0sl/DRNNGIrtg=\",\n \"requires\": {\n \"babel-runtime\": \"6.9.2\",\n \"chalk\": \"1.1.3\",\n \"esutils\": \"2.0.2\",\n \"js-tokens\": \"2.0.0\"\n },\n \"dependencies\": {\n \"chalk\": {\n \"version\": \"1.1.3\",\n \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz\",\n \"integrity\": \"sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=\",\n \"requires\": {\n \"ansi-styles\": \"2.2.1\",\n \"escape-string-regexp\": \"1.0.5\",\n \"has-ansi\": \"2.0.0\",\n \"strip-ansi\": \"3.0.1\",\n \"supports-color\": \"2.0.0\"\n },\n \"dependencies\": {\n \"ansi-styles\": {\n \"version\": \"2.2.1\",\n \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz\",\n \"integrity\": \"sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=\"\n },\n \"escape-string-regexp\": {\n \"version\": \"1.0.5\",\n \"resolved\": \"https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz\",\n \"integrity\": \"sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=\"\n },\n \"has-ansi\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz\",\n \"integrity\": \"sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=\",\n \"requires\": {\n \"ansi-regex\": \"2.0.0\"\n },\n \"dependencies\": {\n \"ansi-regex\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz\",\n \"integrity\": \"sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=\"\n }\n }\n },\n \"strip-ansi\": {\n \"version\": \"3.0.1\",\n \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz\",\n \"integrity\": \"sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=\",\n \"requires\": {\n \"ansi-regex\": \"2.0.0\"\n },\n \"dependencies\": {\n \"ansi-regex\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz\",\n \"integrity\": \"sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=\"\n }\n }\n },\n \"supports-color\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz\",\n \"integrity\": \"sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=\"\n }\n }\n },\n \"esutils\": {\n \"version\": \"2.0.2\",\n \"resolved\": \"https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz\",\n \"integrity\": \"sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=\"\n },\n \"js-tokens\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-2.0.0.tgz\",\n \"integrity\": \"sha1-eZA/VWPud4zBFi5tzxoAJ8l/nLU=\"\n }\n }\n },\n \"babel-messages\": {\n \"version\": \"6.8.0\",\n \"resolved\": \"https://registry.npmjs.org/babel-messages/-/babel-messages-6.8.0.tgz\",\n \"integrity\": \"sha1-v1BHNsqWfm1l7wrbWipflHyODrk=\",\n \"requires\": {\n \"babel-runtime\": \"6.9.2\"\n }\n },\n \"babel-runtime\": {\n \"version\": \"6.9.2\",\n \"resolved\": \"https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.9.2.tgz\",\n \"integrity\": \"sha1-1/45G8LMKbgIfB2bOYeJEun8/Vk=\",\n \"requires\": {\n \"core-js\": \"2.4.0\",\n \"regenerator-runtime\": \"0.9.5\"\n },\n \"dependencies\": {\n \"core-js\": {\n \"version\": \"2.4.0\",\n \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.0.tgz\",\n \"integrity\": \"sha1-30CKtG0Br/kcAcPnlxk11CLFT4E=\"\n },\n \"regenerator-runtime\": {\n \"version\": \"0.9.5\",\n \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.9.5.tgz\",\n \"integrity\": \"sha1-QD1tQKS9/5wzDdk5Lcuy2ai7ofw=\"\n }\n }\n },\n \"debug\": {\n \"version\": \"2.2.0\",\n \"resolved\": \"https://registry.npmjs.org/debug/-/debug-2.2.0.tgz\",\n \"integrity\": \"sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=\",\n \"requires\": {\n \"ms\": \"0.7.1\"\n },\n \"dependencies\": {\n \"ms\": {\n \"version\": \"0.7.1\",\n \"resolved\": \"https://registry.npmjs.org/ms/-/ms-0.7.1.tgz\",\n \"integrity\": \"sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=\"\n }\n }\n },\n \"globals\": {\n \"version\": \"8.18.0\",\n \"resolved\": \"https://registry.npmjs.org/globals/-/globals-8.18.0.tgz\",\n \"integrity\": \"sha1-k9SmK9ysOM+vr8R9awNHaMsP/LQ=\"\n },\n \"invariant\": {\n \"version\": \"2.2.1\",\n \"resolved\": \"https://registry.npmjs.org/invariant/-/invariant-2.2.1.tgz\",\n \"integrity\": \"sha1-sJcBBUdmjH4zcCjr6Bbr42yKjVQ=\",\n \"requires\": {\n \"loose-envify\": \"1.2.0\"\n },\n \"dependencies\": {\n \"loose-envify\": {\n \"version\": \"1.2.0\",\n \"resolved\": \"https://registry.npmjs.org/loose-envify/-/loose-envify-1.2.0.tgz\",\n \"integrity\": \"sha1-aaZarT3lQs9O4PT+dOjjPHCcyw8=\",\n \"requires\": {\n \"js-tokens\": \"1.0.3\"\n },\n \"dependencies\": {\n \"js-tokens\": {\n \"version\": \"1.0.3\",\n \"resolved\": \"https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.3.tgz\",\n \"integrity\": \"sha1-FOVutoyPGpLEPVn1AU7CncIPKuE=\"\n }\n }\n }\n }\n },\n \"lodash\": {\n \"version\": \"4.13.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz\",\n \"integrity\": \"sha1-g+SxCRP0hJbU0W/sSlYK8u50S2g=\"\n }\n }\n },\n \"babel-types\": {\n \"version\": \"6.11.1\",\n \"resolved\": \"https://registry.npmjs.org/babel-types/-/babel-types-6.11.1.tgz\",\n \"integrity\": \"sha1-o981W6uQ3c9mMYZAcXzywVTmZIo=\",\n \"requires\": {\n \"babel-runtime\": \"6.9.2\",\n \"babel-traverse\": \"6.10.4\",\n \"esutils\": \"2.0.2\",\n \"lodash\": \"4.13.1\",\n \"to-fast-properties\": \"1.0.2\"\n },\n \"dependencies\": {\n \"babel-runtime\": {\n \"version\": \"6.9.2\",\n \"resolved\": \"https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.9.2.tgz\",\n \"integrity\": \"sha1-1/45G8LMKbgIfB2bOYeJEun8/Vk=\",\n \"requires\": {\n \"core-js\": \"2.4.0\",\n \"regenerator-runtime\": \"0.9.5\"\n },\n \"dependencies\": {\n \"core-js\": {\n \"version\": \"2.4.0\",\n \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.0.tgz\",\n \"integrity\": \"sha1-30CKtG0Br/kcAcPnlxk11CLFT4E=\"\n },\n \"regenerator-runtime\": {\n \"version\": \"0.9.5\",\n \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.9.5.tgz\",\n \"integrity\": \"sha1-QD1tQKS9/5wzDdk5Lcuy2ai7ofw=\"\n }\n }\n },\n \"esutils\": {\n \"version\": \"2.0.2\",\n \"resolved\": \"https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz\",\n \"integrity\": \"sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=\"\n },\n \"lodash\": {\n \"version\": \"4.13.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz\",\n \"integrity\": \"sha1-g+SxCRP0hJbU0W/sSlYK8u50S2g=\"\n },\n \"to-fast-properties\": {\n \"version\": \"1.0.2\",\n \"resolved\": \"https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.2.tgz\",\n \"integrity\": \"sha1-8/XAw7pymafvmUJ+RGMyV63kMyA=\"\n }\n }\n },\n \"babylon\": {\n \"version\": \"6.8.4\",\n \"resolved\": \"https://registry.npmjs.org/babylon/-/babylon-6.8.4.tgz\",\n \"integrity\": \"sha1-CXMGuNq66VFZIlzymz6lWRIFMYA=\",\n \"requires\": {\n \"babel-runtime\": \"6.9.2\"\n },\n \"dependencies\": {\n \"babel-runtime\": {\n \"version\": \"6.9.2\",\n \"resolved\": \"https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.9.2.tgz\",\n \"integrity\": \"sha1-1/45G8LMKbgIfB2bOYeJEun8/Vk=\",\n \"requires\": {\n \"core-js\": \"2.4.0\",\n \"regenerator-runtime\": \"0.9.5\"\n },\n \"dependencies\": {\n \"core-js\": {\n \"version\": \"2.4.0\",\n \"resolved\": \"https://registry.npmjs.org/core-js/-/core-js-2.4.0.tgz\",\n \"integrity\": \"sha1-30CKtG0Br/kcAcPnlxk11CLFT4E=\"\n },\n \"regenerator-runtime\": {\n \"version\": \"0.9.5\",\n \"resolved\": \"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.9.5.tgz\",\n \"integrity\": \"sha1-QD1tQKS9/5wzDdk5Lcuy2ai7ofw=\"\n }\n }\n }\n }\n },\n \"lodash.assign\": {\n \"version\": \"3.2.0\",\n \"resolved\": \"https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.2.0.tgz\",\n \"integrity\": \"sha1-POnwI0tLIiPilrj6CsH+6OvKZPo=\",\n \"requires\": {\n \"lodash._baseassign\": \"3.2.0\",\n \"lodash._createassigner\": \"3.1.1\",\n \"lodash.keys\": \"3.1.2\"\n },\n \"dependencies\": {\n \"lodash._baseassign\": {\n \"version\": \"3.2.0\",\n \"resolved\": \"https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz\",\n \"integrity\": \"sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=\",\n \"requires\": {\n \"lodash._basecopy\": \"3.0.1\",\n \"lodash.keys\": \"3.1.2\"\n },\n \"dependencies\": {\n \"lodash._basecopy\": {\n \"version\": \"3.0.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz\",\n \"integrity\": \"sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=\"\n }\n }\n },\n \"lodash._createassigner\": {\n \"version\": \"3.1.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz\",\n \"integrity\": \"sha1-g4pbri/aymOsIt7o4Z+k5taXCxE=\",\n \"requires\": {\n \"lodash._bindcallback\": \"3.0.1\",\n \"lodash._isiterateecall\": \"3.0.9\",\n \"lodash.restparam\": \"3.6.1\"\n },\n \"dependencies\": {\n \"lodash._bindcallback\": {\n \"version\": \"3.0.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz\",\n \"integrity\": \"sha1-5THCdkTPi1epnhftlbNcdIeJOS4=\"\n },\n \"lodash._isiterateecall\": {\n \"version\": \"3.0.9\",\n \"resolved\": \"https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz\",\n \"integrity\": \"sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=\"\n },\n \"lodash.restparam\": {\n \"version\": \"3.6.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz\",\n \"integrity\": \"sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=\"\n }\n }\n },\n \"lodash.keys\": {\n \"version\": \"3.1.2\",\n \"resolved\": \"https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz\",\n \"integrity\": \"sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=\",\n \"requires\": {\n \"lodash._getnative\": \"3.9.1\",\n \"lodash.isarguments\": \"3.0.8\",\n \"lodash.isarray\": \"3.0.4\"\n },\n \"dependencies\": {\n \"lodash._getnative\": {\n \"version\": \"3.9.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz\",\n \"integrity\": \"sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=\"\n },\n \"lodash.isarguments\": {\n \"version\": \"3.0.8\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.0.8.tgz\",\n \"integrity\": \"sha1-W/jaiH8B8qnknAoXXNrrMYoOQ9w=\"\n },\n \"lodash.isarray\": {\n \"version\": \"3.0.4\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz\",\n \"integrity\": \"sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=\"\n }\n }\n }\n }\n },\n \"lodash.pick\": {\n \"version\": \"3.1.0\",\n \"resolved\": \"https://registry.npmjs.org/lodash.pick/-/lodash.pick-3.1.0.tgz\",\n \"integrity\": \"sha1-8lKoVbIEa2G805BLJvdr0u/GVVA=\",\n \"requires\": {\n \"lodash._baseflatten\": \"3.1.4\",\n \"lodash._bindcallback\": \"3.0.1\",\n \"lodash._pickbyarray\": \"3.0.2\",\n \"lodash._pickbycallback\": \"3.0.0\",\n \"lodash.restparam\": \"3.6.1\"\n },\n \"dependencies\": {\n \"lodash._baseflatten\": {\n \"version\": \"3.1.4\",\n \"resolved\": \"https://registry.npmjs.org/lodash._baseflatten/-/lodash._baseflatten-3.1.4.tgz\",\n \"integrity\": \"sha1-B3D/gBMa9uNPO1EXlqe6UhTmX/c=\",\n \"requires\": {\n \"lodash.isarguments\": \"3.0.8\",\n \"lodash.isarray\": \"3.0.4\"\n },\n \"dependencies\": {\n \"lodash.isarguments\": {\n \"version\": \"3.0.8\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.0.8.tgz\",\n \"integrity\": \"sha1-W/jaiH8B8qnknAoXXNrrMYoOQ9w=\"\n },\n \"lodash.isarray\": {\n \"version\": \"3.0.4\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz\",\n \"integrity\": \"sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=\"\n }\n }\n },\n \"lodash._bindcallback\": {\n \"version\": \"3.0.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz\",\n \"integrity\": \"sha1-5THCdkTPi1epnhftlbNcdIeJOS4=\"\n },\n \"lodash._pickbyarray\": {\n \"version\": \"3.0.2\",\n \"resolved\": \"https://registry.npmjs.org/lodash._pickbyarray/-/lodash._pickbyarray-3.0.2.tgz\",\n \"integrity\": \"sha1-H4mNlgfrVgsOFnOEt3x8bRCKpMU=\"\n },\n \"lodash._pickbycallback\": {\n \"version\": \"3.0.0\",\n \"resolved\": \"https://registry.npmjs.org/lodash._pickbycallback/-/lodash._pickbycallback-3.0.0.tgz\",\n \"integrity\": \"sha1-/2G5oBens699MObFPeKK+hm4dQo=\",\n \"requires\": {\n \"lodash._basefor\": \"3.0.3\",\n \"lodash.keysin\": \"3.0.8\"\n },\n \"dependencies\": {\n \"lodash._basefor\": {\n \"version\": \"3.0.3\",\n \"resolved\": \"https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz\",\n \"integrity\": \"sha1-dVC06SGO8J+tJDQ7YSAhx5tMIMI=\"\n },\n \"lodash.keysin\": {\n \"version\": \"3.0.8\",\n \"resolved\": \"https://registry.npmjs.org/lodash.keysin/-/lodash.keysin-3.0.8.tgz\",\n \"integrity\": \"sha1-IsRJPrvtsUJ5YqVLRFssinZ/tH8=\",\n \"requires\": {\n \"lodash.isarguments\": \"3.0.8\",\n \"lodash.isarray\": \"3.0.4\"\n },\n \"dependencies\": {\n \"lodash.isarguments\": {\n \"version\": \"3.0.8\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.0.8.tgz\",\n \"integrity\": \"sha1-W/jaiH8B8qnknAoXXNrrMYoOQ9w=\"\n },\n \"lodash.isarray\": {\n \"version\": \"3.0.4\",\n \"resolved\": \"https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz\",\n \"integrity\": \"sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=\"\n }\n }\n }\n }\n },\n \"lodash.restparam\": {\n \"version\": \"3.6.1\",\n \"resolved\": \"https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz\",\n \"integrity\": \"sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=\"\n }\n }\n }\n }\n },\n \"eslint\": {\n \"version\": \"0.22.1\",\n \"resolved\": \"https://registry.npmjs.org/eslint/-/eslint-0.22.1.tgz\",\n \"integrity\": \"sha1-VbrAiUWwrNoXRWINIKUqK6mH1m4=\",\n \"requires\": {\n \"chalk\": \"1.0.0\",\n \"concat-stream\": \"1.5.0\",\n \"debug\": \"2.2.0\",\n \"doctrine\": \"0.6.4\",\n \"escape-string-regexp\": \"1.0.3\",\n \"escope\": \"3.1.0\",\n \"espree\": \"2.0.3\",\n \"estraverse\": \"2.0.0\",\n \"estraverse-fb\": \"1.3.1\",\n \"globals\": \"6.4.1\",\n \"inquirer\": \"0.8.5\",\n \"is-my-json-valid\": \"2.12.0\",\n \"js-yaml\": \"3.3.1\",\n \"minimatch\": \"2.0.8\",\n \"mkdirp\": \"0.5.1\",\n \"object-assign\": \"2.1.1\",\n \"optionator\": \"0.5.0\",\n \"path-is-absolute\": \"1.0.0\",\n \"strip-json-comments\": \"1.0.2\",\n \"text-table\": \"0.2.0\",\n \"user-home\": \"1.1.1\",\n \"xml-escape\": \"1.0.0\"\n },\n \"dependencies\": {\n \"chalk\": {\n \"version\": \"1.0.0\",\n \"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz\",\n \"integrity\": \"sha1-s89O0P9Tl8mcdbj2edsvUoMfltw=\",\n \"requires\": {\n \"ansi-styles\": \"2.0.1\",\n \"escape-string-regexp\": \"1.0.3\",\n \"has-ansi\": \"1.0.3\",\n \"strip-ansi\": \"2.0.1\",\n \"supports-color\": \"1.3.1\"\n },\n \"dependencies\": {\n \"ansi-styles\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.0.1.tgz\",\n \"integrity\": \"sha1-sDP1f5Pi0oreuLwRE4+hPaD9IKM=\"\n },\n \"has-ansi\": {\n \"version\": \"1.0.3\",\n \"resolved\": \"https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz\",\n \"integrity\": \"sha1-wLWxYV2eOCsP9nFp2We0JeSMpTg=\",\n \"requires\": {\n \"ansi-regex\": \"1.1.1\",\n \"get-stdin\": \"4.0.1\"\n },\n \"dependencies\": {\n \"ansi-regex\": {\n \"version\": \"1.1.1\",\n \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz\",\n \"integrity\": \"sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=\"\n },\n \"get-stdin\": {\n \"version\": \"4.0.1\",\n \"resolved\": \"https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz\",\n \"integrity\": \"sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=\"\n }\n }\n },\n \"strip-ansi\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz\",\n \"integrity\": \"sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=\",\n \"requires\": {\n \"ansi-regex\": \"1.1.1\"\n },\n \"dependencies\": {\n \"ansi-regex\": {\n \"version\": \"1.1.1\",\n \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz\",\n \"integrity\": \"sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=\"\n }\n }\n },\n \"supports-color\": {\n \"version\": \"1.3.1\",\n \"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz\",\n \"integrity\": \"sha1-FXWN8J2P87SswwdTn6vicJXhBC0=\"\n }\n }\n },\n \"concat-stream\": {\n \"version\": \"1.5.0\",\n \"resolved\": \"https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.0.tgz\",\n \"integrity\": \"sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE=\",\n \"requires\": {\n \"inherits\": \"2.0.1\",\n \"readable-stream\": \"2.0.1\",\n \"typedarray\": \"0.0.6\"\n },\n \"dependencies\": {\n \"inherits\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz\",\n \"integrity\": \"sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=\"\n },\n \"readable-stream\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.1.tgz\",\n \"integrity\": \"sha1-YzR5t70vvnoehpgltAoLMzufK/w=\",\n \"requires\": {\n \"core-util-is\": \"1.0.1\",\n \"inherits\": \"2.0.1\",\n \"isarray\": \"0.0.1\",\n \"process-nextick-args\": \"1.0.1\",\n \"string_decoder\": \"0.10.31\",\n \"util-deprecate\": \"1.0.1\"\n },\n \"dependencies\": {\n \"core-util-is\": {\n \"version\": \"1.0.1\",\n \"resolved\": \"https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz\",\n \"integrity\": \"sha1-awcIWu+aPMrG7lO/nT3wwVIaVTg=\"\n },\n \"isarray\": {\n \"version\": \"0.0.1\",\n \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\"\n },\n \"process-nextick-args\": {\n \"version\": \"1.0.1\",\n \"resolved\": \"https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.1.tgz\",\n \"integrity\": \"sha1-kYpatKd0Q0C4P/QWEBulPFxTGHk=\"\n },\n \"string_decoder\": {\n \"version\": \"0.10.31\",\n \"resolved\": \"https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz\",\n \"integrity\": \"sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=\"\n },\n \"util-deprecate\": {\n \"version\": \"1.0.1\",\n \"resolved\": \"https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.1.tgz\",\n \"integrity\": \"sha1-NVaj0TxMaqeYPX4kJUeBlxmbeIE=\"\n }\n }\n },\n \"typedarray\": {\n \"version\": \"0.0.6\",\n \"resolved\": \"https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz\",\n \"integrity\": \"sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=\"\n }\n }\n },\n \"debug\": {\n \"version\": \"2.2.0\",\n \"resolved\": \"https://registry.npmjs.org/debug/-/debug-2.2.0.tgz\",\n \"integrity\": \"sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=\",\n \"requires\": {\n \"ms\": \"0.7.1\"\n },\n \"dependencies\": {\n \"ms\": {\n \"version\": \"0.7.1\",\n \"resolved\": \"https://registry.npmjs.org/ms/-/ms-0.7.1.tgz\",\n \"integrity\": \"sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=\"\n }\n }\n },\n \"doctrine\": {\n \"version\": \"0.6.4\",\n \"resolved\": \"https://registry.npmjs.org/doctrine/-/doctrine-0.6.4.tgz\",\n \"integrity\": \"sha1-gUKEkalC7xiwSSBW7aOADu5X1h0=\",\n \"requires\": {\n \"esutils\": \"1.1.6\",\n \"isarray\": \"0.0.1\"\n },\n \"dependencies\": {\n \"esutils\": {\n \"version\": \"1.1.6\",\n \"resolved\": \"https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz\",\n \"integrity\": \"sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=\"\n },\n \"isarray\": {\n \"version\": \"0.0.1\",\n \"resolved\": \"https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz\",\n \"integrity\": \"sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=\"\n }\n }\n },\n \"escape-string-regexp\": {\n \"version\": \"1.0.3\",\n \"resolved\": \"https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz\",\n \"integrity\": \"sha1-ni2LJbwlVcMzZyN1DgPwmcJzW7U=\"\n },\n \"escope\": {\n \"version\": \"3.1.0\",\n \"resolved\": \"https://registry.npmjs.org/escope/-/escope-3.1.0.tgz\",\n \"integrity\": \"sha1-kspI9ihrOA5DiOCRiKkEsPodm34=\",\n \"requires\": {\n \"es6-map\": \"0.1.1\",\n \"es6-weak-map\": \"0.1.4\",\n \"esrecurse\": \"3.1.1\",\n \"estraverse\": \"3.1.0\"\n },\n \"dependencies\": {\n \"es6-map\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-map/-/es6-map-0.1.1.tgz\",\n \"integrity\": \"sha1-uHkjnteBngsIxAum4Z+gR8p8jR0=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\",\n \"es6-iterator\": \"0.1.3\",\n \"es6-set\": \"0.1.1\",\n \"es6-symbol\": \"0.1.1\",\n \"event-emitter\": \"0.3.3\"\n },\n \"dependencies\": {\n \"d\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/d/-/d-0.1.1.tgz\",\n \"integrity\": \"sha1-2hhMU10Y2O57oqoim5FACfrhEwk=\",\n \"requires\": {\n \"es5-ext\": \"0.10.7\"\n }\n },\n \"es5-ext\": {\n \"version\": \"0.10.7\",\n \"resolved\": \"https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.7.tgz\",\n \"integrity\": \"sha1-366lByEwEELi2JwXGdQ0k/qCFlY=\",\n \"requires\": {\n \"es6-iterator\": \"0.1.3\",\n \"es6-symbol\": \"2.0.1\"\n },\n \"dependencies\": {\n \"es6-symbol\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz\",\n \"integrity\": \"sha1-dhtcZ8/U8dGK+yNPaR1nhoLLO/M=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\"\n }\n }\n }\n },\n \"es6-iterator\": {\n \"version\": \"0.1.3\",\n \"resolved\": \"https://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz\",\n \"integrity\": \"sha1-1vWLjE/EE8JJtLqhl2j45NfIlE4=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\",\n \"es6-symbol\": \"2.0.1\"\n },\n \"dependencies\": {\n \"es6-symbol\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz\",\n \"integrity\": \"sha1-dhtcZ8/U8dGK+yNPaR1nhoLLO/M=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\"\n }\n }\n }\n },\n \"es6-set\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-set/-/es6-set-0.1.1.tgz\",\n \"integrity\": \"sha1-SXzSNcmiaR9Mqg4z3XPvhr3nOKw=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\",\n \"es6-iterator\": \"0.1.3\",\n \"es6-symbol\": \"0.1.1\",\n \"event-emitter\": \"0.3.3\"\n }\n },\n \"es6-symbol\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-symbol/-/es6-symbol-0.1.1.tgz\",\n \"integrity\": \"sha1-nPf6su2v8bHaj+jmi/4/Wspsohg=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\"\n }\n },\n \"event-emitter\": {\n \"version\": \"0.3.3\",\n \"resolved\": \"https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.3.tgz\",\n \"integrity\": \"sha1-346AZUHGirj/IKeaGEG5GrqhvuQ=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\"\n }\n }\n }\n },\n \"es6-weak-map\": {\n \"version\": \"0.1.4\",\n \"resolved\": \"https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-0.1.4.tgz\",\n \"integrity\": \"sha1-cGzvnpmqI2undmwjnIueKG6n0ig=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\",\n \"es6-iterator\": \"0.1.3\",\n \"es6-symbol\": \"2.0.1\"\n },\n \"dependencies\": {\n \"d\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/d/-/d-0.1.1.tgz\",\n \"integrity\": \"sha1-2hhMU10Y2O57oqoim5FACfrhEwk=\",\n \"requires\": {\n \"es5-ext\": \"0.10.7\"\n }\n },\n \"es5-ext\": {\n \"version\": \"0.10.7\",\n \"resolved\": \"https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.7.tgz\",\n \"integrity\": \"sha1-366lByEwEELi2JwXGdQ0k/qCFlY=\",\n \"requires\": {\n \"es6-iterator\": \"0.1.3\",\n \"es6-symbol\": \"2.0.1\"\n }\n },\n \"es6-iterator\": {\n \"version\": \"0.1.3\",\n \"resolved\": \"https://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz\",\n \"integrity\": \"sha1-1vWLjE/EE8JJtLqhl2j45NfIlE4=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\",\n \"es6-symbol\": \"2.0.1\"\n }\n },\n \"es6-symbol\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz\",\n \"integrity\": \"sha1-dhtcZ8/U8dGK+yNPaR1nhoLLO/M=\",\n \"requires\": {\n \"d\": \"0.1.1\",\n \"es5-ext\": \"0.10.7\"\n }\n }\n }\n },\n \"esrecurse\": {\n \"version\": \"3.1.1\",\n \"resolved\": \"https://registry.npmjs.org/esrecurse/-/esrecurse-3.1.1.tgz\",\n \"integrity\": \"sha1-j+uWNpnU0bLWWlds1LEpZnKg8Ok=\",\n \"requires\": {\n \"estraverse\": \"3.1.0\"\n }\n },\n \"estraverse\": {\n \"version\": \"3.1.0\",\n \"resolved\": \"https://registry.npmjs.org/estraverse/-/estraverse-3.1.0.tgz\",\n \"integrity\": \"sha1-FeKKRGuLgrxwDMyLlseK9NoNbLo=\"\n }\n }\n },\n \"espree\": {\n \"version\": \"2.0.3\",\n \"resolved\": \"https://registry.npmjs.org/espree/-/espree-2.0.3.tgz\",\n \"integrity\": \"sha1-H73/YKQQvQ1Baxqz1iMNNLekUOE=\"\n },\n \"estraverse\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/estraverse/-/estraverse-2.0.0.tgz\",\n \"integrity\": \"sha1-WuRpYyQ2ACBmdMyySgnhZnT83KE=\"\n },\n \"estraverse-fb\": {\n \"version\": \"1.3.1\",\n \"resolved\": \"https://registry.npmjs.org/estraverse-fb/-/estraverse-fb-1.3.1.tgz\",\n \"integrity\": \"sha1-Fg51qA5gWwjOiUvM4v4+Qpq/kr8=\"\n },\n \"globals\": {\n \"version\": \"6.4.1\",\n \"resolved\": \"https://registry.npmjs.org/globals/-/globals-6.4.1.tgz\",\n \"integrity\": \"sha1-hJgDKzttHMge68X3lpDY/in6v08=\"\n },\n \"inquirer\": {\n \"version\": \"0.8.5\",\n \"resolved\": \"https://registry.npmjs.org/inquirer/-/inquirer-0.8.5.tgz\",\n \"integrity\": \"sha1-29dAz2yjtzEpamPOb22WGFHzNt8=\",\n \"requires\": {\n \"ansi-regex\": \"1.1.1\",\n \"chalk\": \"1.0.0\",\n \"cli-width\": \"1.0.1\",\n \"figures\": \"1.3.5\",\n \"lodash\": \"3.9.3\",\n \"readline2\": \"0.1.1\",\n \"rx\": \"2.5.3\",\n \"through\": \"2.3.7\"\n },\n \"dependencies\": {\n \"ansi-regex\": {\n \"version\": \"1.1.1\",\n \"resolved\": \"https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz\",\n \"integrity\": \"sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=\"\n },\n \"cli-width\": {\n \"version\": \"1.0.1\",\n \"resolved\": \"https://registry.npmjs.org/cli-width/-/cli-width-1.0.1.tgz\",\n \"integrity\": \"sha1-FNT2hwI02R6X992B52voJxQQoe8=\"\n },\n \"figures\": {\n \"version\": \"1.3.5\",\n \"resolved\": \"https://registry.npmjs.org/figures/-/figures-1.3.5.tgz\",\n \"integrity\": \"sha1-0aMfTh0sKTjs3lwGqhYTTPKfR3E=\"\n },\n \"lodash\": {\n \"version\": \"3.9.3\",\n \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz\",\n \"integrity\": \"sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI=\"\n },\n \"readline2\": {\n \"version\": \"0.1.1\",\n \"resolved\": \"https://registry.npmjs.org/readline2/-/readline2-0.1.1.tgz\",\n \"integrity\": \"sha1-mUQ7pug7gw7zBRv9fcJBqCco1Wg=\",\n \"requires\": {\n \"mute-stream\": \"0.0.4\",\n \"strip-ansi\": \"2.0.1\"\n },\n \"dependencies\": {\n \"mute-stream\": {\n \"version\": \"0.0.4\",\n \"resolved\": \"https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.4.tgz\",\n \"integrity\": \"sha1-qSGZYKbV1dBGWXruUSUsZlX3F34=\"\n },\n \"strip-ansi\": {\n \"version\": \"2.0.1\",\n \"resolved\": \"https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz\",\n \"integrity\": \"sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=\",\n \"requires\": {\n \"ansi-regex\": \"1.1.1\"\n }\n }\n }\n },\n \"rx\": {\n \"version\": \"2.5.3\",\n \"resolved\": \"https://registry.npmjs.org/rx/-/rx-2.5.3.tgz\",\n \"integrity\": \"sha1-Ia3H2A8CACr1Da6X/Z2/JIdV9WY=\"\n },\n \"through\": {\n \"version\": \"2.3.7\",\n \"resolved\": \"https://registry.npmjs.org/through/-/through-2.3.7.tgz\",\n \"integrity\": \"sha1-X8w2kP7S/fmMb8iLTSB6RiSsO4c=\"\n }\n }\n },\n \"is-my-json-valid\": {\n \"version\": \"2.12.0\",\n \"resolved\": \"https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.0.tgz\",\n \"integrity\": \"sha1-j6bECLJr6VtFoj6PjEtGSlOHTSs=\",\n \"requires\": {\n \"generate-function\": \"2.0.0\",\n \"generate-object-property\": \"1.2.0\",\n \"jsonpointer\": \"1.1.0\",\n \"xtend\": \"4.0.0\"\n },\n \"dependencies\": {\n \"generate-function\": {\n \"version\": \"2.0.0\",\n \"resolved\": \"https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz\",\n \"integrity\": \"sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=\"\n },\n \"generate-object-property\": {\n \"version\": \"1.2.0\",\n \"resolved\": \"https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz\",\n \"integrity\": \"sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=\",\n \"requires\": {\n \"is-property\": \"1.0.2\"\n },\n \"dependencies\": {\n \"is-property\": {\n \"version\": \"1.0.2\",\n \"resolved\": \"https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz\",\n \"integrity\": \"sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=\"\n }\n }\n },\n \"jsonpointer\": {\n \"version\": \"1.1.0\",\n \"resolved\": \"https://registry.npmjs.org/jsonpointer/-/jsonpointer-1.1.0.tgz\",\n \"integrity\": \"sha1-w8cu+u07lxVBY9wB3TSeHP4PgPw=\"\n },\n \"xtend\": {\n \"version\": \"4.0.0\",\n \"resolved\": \"https://registry.npmjs.org/xtend/-/xtend-4.0.0.tgz\",\n \"integrity\": \"sha1-i8Nv+Hrtvnzp6vC8o2sjVKdDhA8=\"\n }\n }\n },\n \"js-yaml\": {\n \"version\": \"3.3.1\",\n \"resolved\": \"https://registry.npmjs.org/js-yaml/-/js-yaml-3.3.1.tgz\",\n \"integrity\": \"sha1-yhrNNCPsJ10SFAp7q1HbAVugs8A=\",\n \"requires\": {\n \"argparse\": \"1.0.2\",\n \"esprima\": \"2.2.0\"\n },\n \"dependencies\": {\n \"argparse\": {\n \"version\": \"1.0.2\",\n \"resolved\": \"https://registry.npmjs.org/argparse/-/argparse-1.0.2.tgz\",\n \"integrity\": \"sha1-vPrjkFllbRlz0LnmoadBVLWpoTY=\",\n \"requires\": {\n \"lodash\": \"3.9.3\",\n \"sprintf-js\": \"1.0.2\"\n },\n \"dependencies\": {\n \"lodash\": {\n \"version\": \"3.9.3\",\n \"resolved\": \"https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz\",\n \"integrity\": \"sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI=\"\n },\n \"sprintf-js\": {\n \"version\": \"1.0.2\",\n \"resolved\": \"https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.2.tgz\",\n \"integrity\": \"sha1-EeTYT/MhRONbC/Omb4WH842PmXg=\"\n }\n }\n },\n \"esprima\": {\n \"version\": \"2.2.0\",\n \"resolved\": \"https://registry.npmjs.org/esprima/-/esprima-2.2.0.tgz\",\n \"integrity\": \"sha1-QpLB1o5Bc9gV+iKQ3Hr8ltgfzYM=\"\n }\n }\n },\n \"minimatch\": {\n \"version\": \"2.0.8\",\n \"resolved\": \"https://registry.npmjs.org/minimatch/-/minimatch-2.0.8.tgz\",\n \"integrity\": \"sha1-C8IPa/NXCmmO8N3/kCBjxsq9pr8=\",\n \"requires\": {\n \"brace-expansion\": \"1.1.0\"\n },\n \"dependencies\": {\n \"brace-expansion\": {\n \"version\": \"1.1.0\",\n \"resolved\": \"https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz\",\n \"integrity\": \"sha1-ybfQPAPze8cEvhAOUitA249s/Nk=\",\n \"requires\": {\n \"balanced-match\": \"0.2.0\",\n \"concat-map\": \"0.0.1\"\n },\n \"dependencies\": {\n \"balanced-match\": {\n \"version\": \"0.2.0\",\n \"resolved\": \"https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz\",\n \"integrity\": \"sha1-OPZzDAOqttXtu1K9k0iF51bXFnQ=\"\n },\n \"concat-map\": {\n \"version\": \"0.0.1\",\n \"resolved\": \"https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz\",\n \"integrity\": \"sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=\"\n }\n }\n }\n }\n },\n \"mkdirp\": {\n \"version\": \"0.5.1\",\n \"resolved\": \"https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz\",\n \"integrity\": \"sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=\",\n \"requires\": {\n \"minimist\": \"0.0.8\"\n },\n \"dependencies\": {\n \"minimist\": {\n \"version\": \"0.0.8\",\n \"resolved\": \"https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz\",\n \"integrity\": \"sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=\"\n }\n }\n },\n \"object-assign\": {\n \"version\": \"2.1.1\",\n \"resolved\": \"https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz\",\n \"integrity\": \"sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=\"\n },\n \"optionator\": {\n \"version\": \"0.5.0\",\n \"resolved\": \"https://registry.npmjs.org/optionator/-/optionator-0.5.0.tgz\",\n \"integrity\": \"sha1-t1qJlaLUF98ltuTjhi9QqohlE2g=\",\n \"requires\": {\n \"deep-is\": \"0.1.3\",\n \"fast-levenshtein\": \"1.0.6\",\n \"levn\": \"0.2.5\",\n \"prelude-ls\": \"1.1.2\",\n \"type-check\": \"0.3.1\",\n \"wordwrap\": \"0.0.3\"\n },\n \"dependencies\": {\n \"deep-is\": {\n \"version\": \"0.1.3\",\n \"resolved\": \"https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz\",\n \"integrity\": \"sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=\"\n },\n \"fast-levenshtein\": {\n \"version\": \"1.0.6\",\n \"resolved\": \"https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.0.6.tgz\",\n \"integrity\": \"sha1-O+2xhOOflcsNiJKGiOax7jJzRGo=\"\n },\n \"levn\": {\n \"version\": \"0.2.5\",\n \"resolved\": \"https://registry.npmjs.org/levn/-/levn-0.2.5.tgz\",\n \"integrity\": \"sha1-uo0znQykphDjo/FFucr0iAcVUFQ=\",\n \"requires\": {\n \"prelude-ls\": \"1.1.2\",\n \"type-check\": \"0.3.1\"\n }\n },\n \"prelude-ls\": {\n \"version\": \"1.1.2\",\n \"resolved\": \"https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz\",\n \"integrity\": \"sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=\"\n },\n \"type-check\": {\n \"version\": \"0.3.1\",\n \"resolved\": \"https://registry.npmjs.org/type-check/-/type-check-0.3.1.tgz\",\n \"integrity\": \"sha1-kjOSPE2hdNCsVIDs/W74TDSetY0=\",\n \"requires\": {\n \"prelude-ls\": \"1.1.2\"\n }\n },\n \"wordwrap\": {\n \"version\": \"0.0.3\",\n \"resolved\": \"https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz\",\n \"integrity\": \"sha1-o9XabNXAvAAI03I0u68b7WMFkQc=\"\n }\n }\n },\n \"path-is-absolute\": {\n \"version\": \"1.0.0\",\n \"resolved\": \"https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz\",\n \"integrity\": \"sha1-Jj2tpmqz8vsQv3+dJN2PPlcO+RI=\"\n },\n \"strip-json-comments\": {\n \"version\": \"1.0.2\",\n \"resolved\": \"https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.2.tgz\",\n \"integrity\": \"sha1-WkirlgI9usG3uND/q/b2PxZ3vp8=\"\n },\n \"text-table\": {\n \"version\": \"0.2.0\",\n \"resolved\": \"https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz\",\n \"integrity\": \"sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=\"\n },\n \"user-home\": {\n \"version\": \"1.1.1\",\n \"resolved\": \"https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz\",\n \"integrity\": \"sha1-K1viOjK2Onyd640PKNSFcko98ZA=\"\n },\n \"xml-escape\": {\n \"version\": \"1.0.0\",\n \"resolved\": \"https://registry.npmjs.org/xml-escape/-/xml-escape-1.0.0.tgz\",\n \"integrity\": \"sha1-AJY9aXsq3wwYXE4E5zF0upsojrI=\"\n }\n }\n },\n \"eslint-plugin-react\": {\n \"version\": \"2.5.0\",\n \"resolved\": \"https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-2.5.0.tgz\",\n \"integrity\": \"sha1-b2DLrW/6HcTl2TkZtaHtZ1IubLc=\"\n }\n }\n}\n", "file_path": "scripts/admin/eslint/npm-shrinkwrap.json", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/2cd5b5c6d9793813e35c091e539d18c0233c3bda", "dependency_score": [0.00017382997612003237, 0.0001687839103396982, 0.00016382859030272812, 0.00016860355390235782, 2.1965915948385373e-06]}
{"hunk": {"id": 0, "code_window": ["\n", " // OK, wiped all packages, now let's go and check that everything is removed\n", " // except for the tool we are running right now and the latest tool. i.e. v1\n", " // and v3\n", " _.each(files.readdir(prefix), function (f) {\n", " if (f[0] === '.') return;\n", " if (process.platform === 'win32') {\n", " // this is a dir\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep"], "after_edit": [" var notHidden = function (f) { return f[0] !== '.'; };\n", " var meteorToolDirs = _.filter(files.readdir(prefix), notHidden);\n", " selftest.expectTrue(meteorToolDirs.length === 2);\n", " _.each(meteorToolDirs, function (f) {\n", " var fPath = files.pathJoin(prefix, f);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 114}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.9980150461196899, 0.1674518883228302, 0.00016937182226683944, 0.0008473113994114101, 0.3493664562702179]}
{"hunk": {"id": 0, "code_window": ["\n", " // OK, wiped all packages, now let's go and check that everything is removed\n", " // except for the tool we are running right now and the latest tool. i.e. v1\n", " // and v3\n", " _.each(files.readdir(prefix), function (f) {\n", " if (f[0] === '.') return;\n", " if (process.platform === 'win32') {\n", " // this is a dir\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep"], "after_edit": [" var notHidden = function (f) { return f[0] !== '.'; };\n", " var meteorToolDirs = _.filter(files.readdir(prefix), notHidden);\n", " selftest.expectTrue(meteorToolDirs.length === 2);\n", " _.each(meteorToolDirs, function (f) {\n", " var fPath = files.pathJoin(prefix, f);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 114}, "file": "/**\n * Provide a synchronous Collection API using fibers, backed by\n * MongoDB. This is only for use on the server, and mostly identical\n * to the client API.\n *\n * NOTE: the public API methods must be run within a fiber. If you call\n * these outside of a fiber they will explode!\n */\n\nvar path = Npm.require('path');\nvar MongoDB = Npm.require('mongodb');\nvar Fiber = Npm.require('fibers');\nvar Future = Npm.require(path.join('fibers', 'future'));\n\nMongoInternals = {};\nMongoTest = {};\n\nMongoInternals.NpmModules = {\n mongodb: {\n version: Npm.require('mongodb/package.json').version,\n module: MongoDB\n }\n};\n\n// Older version of what is now available via\n// MongoInternals.NpmModules.mongodb.module. It was never documented, but\n// people do use it.\n// XXX COMPAT WITH 1.0.3.2\nMongoInternals.NpmModule = MongoDB;\n\n// This is used to add or remove EJSON from the beginning of everything nested\n// inside an EJSON custom type. It should only be called on pure JSON!\nvar replaceNames = function (filter, thing) {\n if (typeof thing === \"object\") {\n if (_.isArray(thing)) {\n return _.map(thing, _.bind(replaceNames, null, filter));\n }\n var ret = {};\n _.each(thing, function (value, key) {\n ret[filter(key)] = replaceNames(filter, value);\n });\n return ret;\n }\n return thing;\n};\n\n// Ensure that EJSON.clone keeps a Timestamp as a Timestamp (instead of just\n// doing a structural clone).\n// XXX how ok is this? what if there are multiple copies of MongoDB loaded?\nMongoDB.Timestamp.prototype.clone = function () {\n // Timestamps should be immutable.\n return this;\n};\n\nvar makeMongoLegal = function (name) { return \"EJSON\" + name; };\nvar unmakeMongoLegal = function (name) { return name.substr(5); };\n\nvar replaceMongoAtomWithMeteor = function (document) {\n if (document instanceof MongoDB.Binary) {\n var buffer = document.value(true);\n return new Uint8Array(buffer);\n }\n if (document instanceof MongoDB.ObjectID) {\n return new Mongo.ObjectID(document.toHexString());\n }\n if (document[\"EJSON$type\"] && document[\"EJSON$value\"]\n && _.size(document) === 2) {\n return EJSON.fromJSONValue(replaceNames(unmakeMongoLegal, document));\n }\n if (document instanceof MongoDB.Timestamp) {\n // For now, the Meteor representation of a Mongo timestamp type (not a date!\n // this is a weird internal thing used in the oplog!) is the same as the\n // Mongo representation. We need to do this explicitly or else we would do a\n // structural clone and lose the prototype.\n return document;\n }\n return undefined;\n};\n\nvar replaceMeteorAtomWithMongo = function (document) {\n if (EJSON.isBinary(document)) {\n // This does more copies than we'd like, but is necessary because\n // MongoDB.BSON only looks like it takes a Uint8Array (and doesn't actually\n // serialize it correctly).\n return new MongoDB.Binary(new Buffer(document));\n }\n if (document instanceof Mongo.ObjectID) {\n return new MongoDB.ObjectID(document.toHexString());\n }\n if (document instanceof MongoDB.Timestamp) {\n // For now, the Meteor representation of a Mongo timestamp type (not a date!\n // this is a weird internal thing used in the oplog!) is the same as the\n // Mongo representation. We need to do this explicitly or else we would do a\n // structural clone and lose the prototype.\n return document;\n }\n if (EJSON._isCustomType(document)) {\n return replaceNames(makeMongoLegal, EJSON.toJSONValue(document));\n }\n // It is not ordinarily possible to stick dollar-sign keys into mongo\n // so we don't bother checking for things that need escaping at this time.\n return undefined;\n};\n\nvar replaceTypes = function (document, atomTransformer) {\n if (typeof document !== 'object' || document === null)\n return document;\n\n var replacedTopLevelAtom = atomTransformer(document);\n if (replacedTopLevelAtom !== undefined)\n return replacedTopLevelAtom;\n\n var ret = document;\n _.each(document, function (val, key) {\n var valReplaced = replaceTypes(val, atomTransformer);\n if (val !== valReplaced) {\n // Lazy clone. Shallow copy.\n if (ret === document)\n ret = _.clone(document);\n ret[key] = valReplaced;\n }\n });\n return ret;\n};\n\n\nMongoConnection = function (url, options) {\n var self = this;\n options = options || {};\n self._observeMultiplexers = {};\n self._onFailoverHook = new Hook;\n\n var mongoOptions = {db: {safe: true}, server: {}, replSet: {}};\n\n // Set autoReconnect to true, unless passed on the URL. Why someone\n // would want to set autoReconnect to false, I'm not really sure, but\n // keeping this for backwards compatibility for now.\n if (!(/[\\?&]auto_?[rR]econnect=/.test(url))) {\n mongoOptions.server.auto_reconnect = true;\n }\n\n // Disable the native parser by default, unless specifically enabled\n // in the mongo URL.\n // - The native driver can cause errors which normally would be\n // thrown, caught, and handled into segfaults that take down the\n // whole app.\n // - Binary modules don't yet work when you bundle and move the bundle\n // to a different platform (aka deploy)\n // We should revisit this after binary npm module support lands.\n if (!(/[\\?&]native_?[pP]arser=/.test(url))) {\n mongoOptions.db.native_parser = false;\n }\n\n // XXX maybe we should have a better way of allowing users to configure the\n // underlying Mongo driver\n if (_.has(options, 'poolSize')) {\n // If we just set this for \"server\", replSet will override it. If we just\n // set it for replSet, it will be ignored if we're not using a replSet.\n mongoOptions.server.poolSize = options.poolSize;\n mongoOptions.replSet.poolSize = options.poolSize;\n }\n\n self.db = null;\n // We keep track of the ReplSet's primary, so that we can trigger hooks when\n // it changes. The Node driver's joined callback seems to fire way too\n // often, which is why we need to track it ourselves.\n self._primary = null;\n self._oplogHandle = null;\n self._docFetcher = null;\n\n\n var connectFuture = new Future;\n MongoDB.connect(\n url,\n mongoOptions,\n Meteor.bindEnvironment(\n function (err, db) {\n if (err) {\n throw err;\n }\n\n // First, figure out what the current primary is, if any.\n if (db.serverConfig._state.master)\n self._primary = db.serverConfig._state.master.name;\n db.serverConfig.on(\n 'joined', Meteor.bindEnvironment(function (kind, doc) {\n if (kind === 'primary') {\n if (doc.primary !== self._primary) {\n self._primary = doc.primary;\n self._onFailoverHook.each(function (callback) {\n callback();\n return true;\n });\n }\n } else if (doc.me === self._primary) {\n // The thing we thought was primary is now something other than\n // primary. Forget that we thought it was primary. (This means\n // that if a server stops being primary and then starts being\n // primary again without another server becoming primary in the\n // middle, we'll correctly count it as a failover.)\n self._primary = null;\n }\n }));\n\n // Allow the constructor to return.\n connectFuture['return'](db);\n },\n connectFuture.resolver() // onException\n )\n );\n\n // Wait for the connection to be successful; throws on failure.\n self.db = connectFuture.wait();\n\n if (options.oplogUrl && ! Package['disable-oplog']) {\n self._oplogHandle = new OplogHandle(options.oplogUrl, self.db.databaseName);\n self._docFetcher = new DocFetcher(self);\n }\n};\n\nMongoConnection.prototype.close = function() {\n var self = this;\n\n if (! self.db)\n throw Error(\"close called before Connection created?\");\n\n // XXX probably untested\n var oplogHandle = self._oplogHandle;\n self._oplogHandle = null;\n if (oplogHandle)\n oplogHandle.stop();\n\n // Use Future.wrap so that errors get thrown. This happens to\n // work even outside a fiber since the 'close' method is not\n // actually asynchronous.\n Future.wrap(_.bind(self.db.close, self.db))(true).wait();\n};\n\n// Returns the Mongo Collection object; may yield.\nMongoConnection.prototype.rawCollection = function (collectionName) {\n var self = this;\n\n if (! self.db)\n throw Error(\"rawCollection called before Connection created?\");\n\n var future = new Future;\n self.db.collection(collectionName, future.resolver());\n return future.wait();\n};\n\nMongoConnection.prototype._createCappedCollection = function (\n collectionName, byteSize, maxDocuments) {\n var self = this;\n\n if (! self.db)\n throw Error(\"_createCappedCollection called before Connection created?\");\n\n var future = new Future();\n self.db.createCollection(\n collectionName,\n { capped: true, size: byteSize, max: maxDocuments },\n future.resolver());\n future.wait();\n};\n\n// This should be called synchronously with a write, to create a\n// transaction on the current write fence, if any. After we can read\n// the write, and after observers have been notified (or at least,\n// after the observer notifiers have added themselves to the write\n// fence), you should call 'committed()' on the object returned.\nMongoConnection.prototype._maybeBeginWrite = function () {\n var self = this;\n var fence = DDPServer._CurrentWriteFence.get();\n if (fence)\n return fence.beginWrite();\n else\n return {committed: function () {}};\n};\n\n// Internal interface: adds a callback which is called when the Mongo primary\n// changes. Returns a stop handle.\nMongoConnection.prototype._onFailover = function (callback) {\n return this._onFailoverHook.register(callback);\n};\n\n\n//////////// Public API //////////\n\n// The write methods block until the database has confirmed the write (it may\n// not be replicated or stable on disk, but one server has confirmed it) if no\n// callback is provided. If a callback is provided, then they call the callback\n// when the write is confirmed. They return nothing on success, and raise an\n// exception on failure.\n//\n// After making a write (with insert, update, remove), observers are\n// notified asynchronously. If you want to receive a callback once all\n// of the observer notifications have landed for your write, do the\n// writes inside a write fence (set DDPServer._CurrentWriteFence to a new\n// _WriteFence, and then set a callback on the write fence.)\n//\n// Since our execution environment is single-threaded, this is\n// well-defined -- a write \"has been made\" if it's returned, and an\n// observer \"has been notified\" if its callback has returned.\n\nvar writeCallback = function (write, refresh, callback) {\n return function (err, result) {\n if (! err) {\n // XXX We don't have to run this on error, right?\n refresh();\n }\n write.committed();\n if (callback)\n callback(err, result);\n else if (err)\n throw err;\n };\n};\n\nvar bindEnvironmentForWrite = function (callback) {\n return Meteor.bindEnvironment(callback, \"Mongo write\");\n};\n\nMongoConnection.prototype._insert = function (collection_name, document,\n callback) {\n var self = this;\n\n var sendError = function (e) {\n if (callback)\n return callback(e);\n throw e;\n };\n\n if (collection_name === \"___meteor_failure_test_collection\") {\n var e = new Error(\"Failure test\");\n e.expected = true;\n sendError(e);\n return;\n }\n\n if (!(LocalCollection._isPlainObject(document) &&\n !EJSON._isCustomType(document))) {\n sendError(new Error(\n \"Only plain objects may be inserted into MongoDB\"));\n return;\n }\n\n var write = self._maybeBeginWrite();\n var refresh = function () {\n Meteor.refresh({collection: collection_name, id: document._id });\n };\n callback = bindEnvironmentForWrite(writeCallback(write, refresh, callback));\n try {\n var collection = self.rawCollection(collection_name);\n collection.insert(replaceTypes(document, replaceMeteorAtomWithMongo),\n {safe: true}, callback);\n } catch (e) {\n write.committed();\n throw e;\n }\n};\n\n// Cause queries that may be affected by the selector to poll in this write\n// fence.\nMongoConnection.prototype._refresh = function (collectionName, selector) {\n var self = this;\n var refreshKey = {collection: collectionName};\n // If we know which documents we're removing, don't poll queries that are\n // specific to other documents. (Note that multiple notifications here should\n // not cause multiple polls, since all our listener is doing is enqueueing a\n // poll.)\n var specificIds = LocalCollection._idsMatchedBySelector(selector);\n if (specificIds) {\n _.each(specificIds, function (id) {\n Meteor.refresh(_.extend({id: id}, refreshKey));\n });\n } else {\n Meteor.refresh(refreshKey);\n }\n};\n\nMongoConnection.prototype._remove = function (collection_name, selector,\n callback) {\n var self = this;\n\n if (collection_name === \"___meteor_failure_test_collection\") {\n var e = new Error(\"Failure test\");\n e.expected = true;\n if (callback)\n return callback(e);\n else\n throw e;\n }\n\n var write = self._maybeBeginWrite();\n var refresh = function () {\n self._refresh(collection_name, selector);\n };\n callback = bindEnvironmentForWrite(writeCallback(write, refresh, callback));\n\n try {\n var collection = self.rawCollection(collection_name);\n collection.remove(replaceTypes(selector, replaceMeteorAtomWithMongo),\n {safe: true}, callback);\n } catch (e) {\n write.committed();\n throw e;\n }\n};\n\nMongoConnection.prototype._dropCollection = function (collectionName, cb) {\n var self = this;\n\n var write = self._maybeBeginWrite();\n var refresh = function () {\n Meteor.refresh({collection: collectionName, id: null,\n dropCollection: true});\n };\n cb = bindEnvironmentForWrite(writeCallback(write, refresh, cb));\n\n try {\n var collection = self.rawCollection(collectionName);\n collection.drop(cb);\n } catch (e) {\n write.committed();\n throw e;\n }\n};\n\nMongoConnection.prototype._update = function (collection_name, selector, mod,\n options, callback) {\n var self = this;\n\n if (! callback && options instanceof Function) {\n callback = options;\n options = null;\n }\n\n if (collection_name === \"___meteor_failure_test_collection\") {\n var e = new Error(\"Failure test\");\n e.expected = true;\n if (callback)\n return callback(e);\n else\n throw e;\n }\n\n // explicit safety check. null and undefined can crash the mongo\n // driver. Although the node driver and minimongo do 'support'\n // non-object modifier in that they don't crash, they are not\n // meaningful operations and do not do anything. Defensively throw an\n // error here.\n if (!mod || typeof mod !== 'object')\n throw new Error(\"Invalid modifier. Modifier must be an object.\");\n\n if (!(LocalCollection._isPlainObject(mod) &&\n !EJSON._isCustomType(mod))) {\n throw new Error(\n \"Only plain objects may be used as replacement\" +\n \" documents in MongoDB\");\n return;\n }\n\n if (!options) options = {};\n\n var write = self._maybeBeginWrite();\n var refresh = function () {\n self._refresh(collection_name, selector);\n };\n callback = writeCallback(write, refresh, callback);\n try {\n var collection = self.rawCollection(collection_name);\n var mongoOpts = {safe: true};\n // explictly enumerate options that minimongo supports\n if (options.upsert) mongoOpts.upsert = true;\n if (options.multi) mongoOpts.multi = true;\n // Lets you get a more more full result from MongoDB. Use with caution:\n // might not work with C.upsert (as opposed to C.update({upsert:true}) or\n // with simulated upsert.\n if (options.fullResult) mongoOpts.fullResult = true;\n\n var mongoSelector = replaceTypes(selector, replaceMeteorAtomWithMongo);\n var mongoMod = replaceTypes(mod, replaceMeteorAtomWithMongo);\n\n var isModify = isModificationMod(mongoMod);\n var knownId = selector._id || mod._id;\n\n if (options._forbidReplace && ! isModify) {\n var e = new Error(\"Invalid modifier. Replacements are forbidden.\");\n if (callback) {\n return callback(e);\n } else {\n throw e;\n }\n }\n\n if (options.upsert && (! knownId) && options.insertedId) {\n // XXX If we know we're using Mongo 2.6 (and this isn't a replacement)\n // we should be able to just use $setOnInsert instead of this\n // simulated upsert thing. (We can't use $setOnInsert with\n // replacements because there's nowhere to write it, and $setOnInsert\n // can't set _id on Mongo 2.4.)\n //\n // Also, in the future we could do a real upsert for the mongo id\n // generation case, if the the node mongo driver gives us back the id\n // of the upserted doc (which our current version does not).\n //\n // For more context, see\n // https://github.com/meteor/meteor/issues/2278#issuecomment-64252706\n simulateUpsertWithInsertedId(\n collection, mongoSelector, mongoMod,\n isModify, options,\n // This callback does not need to be bindEnvironment'ed because\n // simulateUpsertWithInsertedId() wraps it and then passes it through\n // bindEnvironmentForWrite.\n function (err, result) {\n // If we got here via a upsert() call, then options._returnObject will\n // be set and we should return the whole object. Otherwise, we should\n // just return the number of affected docs to match the mongo API.\n if (result && ! options._returnObject)\n callback(err, result.numberAffected);\n else\n callback(err, result);\n }\n );\n } else {\n collection.update(\n mongoSelector, mongoMod, mongoOpts,\n bindEnvironmentForWrite(function (err, result, extra) {\n if (! err) {\n if (result && options._returnObject) {\n result = { numberAffected: result };\n // If this was an upsert() call, and we ended up\n // inserting a new doc and we know its id, then\n // return that id as well.\n if (options.upsert && knownId &&\n ! extra.updatedExisting)\n result.insertedId = knownId;\n }\n }\n callback(err, result);\n }));\n }\n } catch (e) {\n write.committed();\n throw e;\n }\n};\n\nvar isModificationMod = function (mod) {\n var isReplace = false;\n var isModify = false;\n for (var k in mod) {\n if (k.substr(0, 1) === '$') {\n isModify = true;\n } else {\n isReplace = true;\n }\n }\n if (isModify && isReplace) {\n throw new Error(\n \"Update parameter cannot have both modifier and non-modifier fields.\");\n }\n return isModify;\n};\n\nvar NUM_OPTIMISTIC_TRIES = 3;\n\n// exposed for testing\nMongoConnection._isCannotChangeIdError = function (err) {\n // First check for what this error looked like in Mongo 2.4. Either of these\n // checks should work, but just to be safe...\n if (err.code === 13596)\n return true;\n if (err.err.indexOf(\"cannot change _id of a document\") === 0)\n return true;\n\n // Now look for what it looks like in Mongo 2.6. We don't use the error code\n // here, because the error code we observed it producing (16837) appears to be\n // a far more generic error code based on examining the source.\n if (err.err.indexOf(\"The _id field cannot be changed\") === 0)\n return true;\n\n return false;\n};\n\nvar simulateUpsertWithInsertedId = function (collection, selector, mod,\n isModify, options, callback) {\n // STRATEGY: First try doing a plain update. If it affected 0 documents,\n // then without affecting the database, we know we should probably do an\n // insert. We then do a *conditional* insert that will fail in the case\n // of a race condition. This conditional insert is actually an\n // upsert-replace with an _id, which will never successfully update an\n // existing document. If this upsert fails with an error saying it\n // couldn't change an existing _id, then we know an intervening write has\n // caused the query to match something. We go back to step one and repeat.\n // Like all \"optimistic write\" schemes, we rely on the fact that it's\n // unlikely our writes will continue to be interfered with under normal\n // circumstances (though sufficiently heavy contention with writers\n // disagreeing on the existence of an object will cause writes to fail\n // in theory).\n\n var newDoc;\n // Run this code up front so that it fails fast if someone uses\n // a Mongo update operator we don't support.\n if (isModify) {\n // We've already run replaceTypes/replaceMeteorAtomWithMongo on\n // selector and mod. We assume it doesn't matter, as far as\n // the behavior of modifiers is concerned, whether `_modify`\n // is run on EJSON or on mongo-converted EJSON.\n var selectorDoc = LocalCollection._removeDollarOperators(selector);\n LocalCollection._modify(selectorDoc, mod, {isInsert: true});\n newDoc = selectorDoc;\n } else {\n newDoc = mod;\n }\n\n var insertedId = options.insertedId; // must exist\n var mongoOptsForUpdate = {\n safe: true,\n multi: options.multi\n };\n var mongoOptsForInsert = {\n safe: true,\n upsert: true\n };\n\n var tries = NUM_OPTIMISTIC_TRIES;\n\n var doUpdate = function () {\n tries--;\n if (! tries) {\n callback(new Error(\"Upsert failed after \" + NUM_OPTIMISTIC_TRIES + \" tries.\"));\n } else {\n collection.update(selector, mod, mongoOptsForUpdate,\n bindEnvironmentForWrite(function (err, result) {\n if (err)\n callback(err);\n else if (result)\n callback(null, {\n numberAffected: result\n });\n else\n doConditionalInsert();\n }));\n }\n };\n\n var doConditionalInsert = function () {\n var replacementWithId = _.extend(\n replaceTypes({_id: insertedId}, replaceMeteorAtomWithMongo),\n newDoc);\n collection.update(selector, replacementWithId, mongoOptsForInsert,\n bindEnvironmentForWrite(function (err, result) {\n if (err) {\n // figure out if this is a\n // \"cannot change _id of document\" error, and\n // if so, try doUpdate() again, up to 3 times.\n if (MongoConnection._isCannotChangeIdError(err)) {\n doUpdate();\n } else {\n callback(err);\n }\n } else {\n callback(null, {\n numberAffected: result,\n insertedId: insertedId\n });\n }\n }));\n };\n\n doUpdate();\n};\n\n_.each([\"insert\", \"update\", \"remove\", \"dropCollection\"], function (method) {\n MongoConnection.prototype[method] = function (/* arguments */) {\n var self = this;\n return Meteor.wrapAsync(self[\"_\" + method]).apply(self, arguments);\n };\n});\n\n// XXX MongoConnection.upsert() does not return the id of the inserted document\n// unless you set it explicitly in the selector or modifier (as a replacement\n// doc).\nMongoConnection.prototype.upsert = function (collectionName, selector, mod,\n options, callback) {\n var self = this;\n if (typeof options === \"function\" && ! callback) {\n callback = options;\n options = {};\n }\n\n return self.update(collectionName, selector, mod,\n _.extend({}, options, {\n upsert: true,\n _returnObject: true\n }), callback);\n};\n\nMongoConnection.prototype.find = function (collectionName, selector, options) {\n var self = this;\n\n if (arguments.length === 1)\n selector = {};\n\n return new Cursor(\n self, new CursorDescription(collectionName, selector, options));\n};\n\nMongoConnection.prototype.findOne = function (collection_name, selector,\n options) {\n var self = this;\n if (arguments.length === 1)\n selector = {};\n\n options = options || {};\n options.limit = 1;\n return self.find(collection_name, selector, options).fetch()[0];\n};\n\n// We'll actually design an index API later. For now, we just pass through to\n// Mongo's, but make it synchronous.\nMongoConnection.prototype._ensureIndex = function (collectionName, index,\n options) {\n var self = this;\n options = _.extend({safe: true}, options);\n\n // We expect this function to be called at startup, not from within a method,\n // so we don't interact with the write fence.\n var collection = self.rawCollection(collectionName);\n var future = new Future;\n var indexName = collection.ensureIndex(index, options, future.resolver());\n future.wait();\n};\nMongoConnection.prototype._dropIndex = function (collectionName, index) {\n var self = this;\n\n // This function is only used by test code, not within a method, so we don't\n // interact with the write fence.\n var collection = self.rawCollection(collectionName);\n var future = new Future;\n var indexName = collection.dropIndex(index, future.resolver());\n future.wait();\n};\n\n// CURSORS\n\n// There are several classes which relate to cursors:\n//\n// CursorDescription represents the arguments used to construct a cursor:\n// collectionName, selector, and (find) options. Because it is used as a key\n// for cursor de-dup, everything in it should either be JSON-stringifiable or\n// not affect observeChanges output (eg, options.transform functions are not\n// stringifiable but do not affect observeChanges).\n//\n// SynchronousCursor is a wrapper around a MongoDB cursor\n// which includes fully-synchronous versions of forEach, etc.\n//\n// Cursor is the cursor object returned from find(), which implements the\n// documented Mongo.Collection cursor API. It wraps a CursorDescription and a\n// SynchronousCursor (lazily: it doesn't contact Mongo until you call a method\n// like fetch or forEach on it).\n//\n// ObserveHandle is the \"observe handle\" returned from observeChanges. It has a\n// reference to an ObserveMultiplexer.\n//\n// ObserveMultiplexer allows multiple identical ObserveHandles to be driven by a\n// single observe driver.\n//\n// There are two \"observe drivers\" which drive ObserveMultiplexers:\n// - PollingObserveDriver caches the results of a query and reruns it when\n// necessary.\n// - OplogObserveDriver follows the Mongo operation log to directly observe\n// database changes.\n// Both implementations follow the same simple interface: when you create them,\n// they start sending observeChanges callbacks (and a ready() invocation) to\n// their ObserveMultiplexer, and you stop them by calling their stop() method.\n\nCursorDescription = function (collectionName, selector, options) {\n var self = this;\n self.collectionName = collectionName;\n self.selector = Mongo.Collection._rewriteSelector(selector);\n self.options = options || {};\n};\n\nCursor = function (mongo, cursorDescription) {\n var self = this;\n\n self._mongo = mongo;\n self._cursorDescription = cursorDescription;\n self._synchronousCursor = null;\n};\n\n_.each(['forEach', 'map', 'fetch', 'count'], function (method) {\n Cursor.prototype[method] = function () {\n var self = this;\n\n // You can only observe a tailable cursor.\n if (self._cursorDescription.options.tailable)\n throw new Error(\"Cannot call \" + method + \" on a tailable cursor\");\n\n if (!self._synchronousCursor) {\n self._synchronousCursor = self._mongo._createSynchronousCursor(\n self._cursorDescription, {\n // Make sure that the \"self\" argument to forEach/map callbacks is the\n // Cursor, not the SynchronousCursor.\n selfForIteration: self,\n useTransform: true\n });\n }\n\n return self._synchronousCursor[method].apply(\n self._synchronousCursor, arguments);\n };\n});\n\n// Since we don't actually have a \"nextObject\" interface, there's really no\n// reason to have a \"rewind\" interface. All it did was make multiple calls\n// to fetch/map/forEach return nothing the second time.\n// XXX COMPAT WITH 0.8.1\nCursor.prototype.rewind = function () {\n};\n\nCursor.prototype.getTransform = function () {\n return this._cursorDescription.options.transform;\n};\n\n// When you call Meteor.publish() with a function that returns a Cursor, we need\n// to transmute it into the equivalent subscription. This is the function that\n// does that.\n\nCursor.prototype._publishCursor = function (sub) {\n var self = this;\n var collection = self._cursorDescription.collectionName;\n return Mongo.Collection._publishCursor(self, sub, collection);\n};\n\n// Used to guarantee that publish functions return at most one cursor per\n// collection. Private, because we might later have cursors that include\n// documents from multiple collections somehow.\nCursor.prototype._getCollectionName = function () {\n var self = this;\n return self._cursorDescription.collectionName;\n}\n\nCursor.prototype.observe = function (callbacks) {\n var self = this;\n return LocalCollection._observeFromObserveChanges(self, callbacks);\n};\n\nCursor.prototype.observeChanges = function (callbacks) {\n var self = this;\n var ordered = LocalCollection._observeChangesCallbacksAreOrdered(callbacks);\n return self._mongo._observeChanges(\n self._cursorDescription, ordered, callbacks);\n};\n\nMongoConnection.prototype._createSynchronousCursor = function(\n cursorDescription, options) {\n var self = this;\n options = _.pick(options || {}, 'selfForIteration', 'useTransform');\n\n var collection = self.rawCollection(cursorDescription.collectionName);\n var cursorOptions = cursorDescription.options;\n var mongoOptions = {\n sort: cursorOptions.sort,\n limit: cursorOptions.limit,\n skip: cursorOptions.skip\n };\n\n // Do we want a tailable cursor (which only works on capped collections)?\n if (cursorOptions.tailable) {\n // We want a tailable cursor...\n mongoOptions.tailable = true;\n // ... and for the server to wait a bit if any getMore has no data (rather\n // than making us put the relevant sleeps in the client)...\n mongoOptions.awaitdata = true;\n // ... and to keep querying the server indefinitely rather than just 5 times\n // if there's no more data.\n mongoOptions.numberOfRetries = -1;\n // And if this is on the oplog collection and the cursor specifies a 'ts',\n // then set the undocumented oplog replay flag, which does a special scan to\n // find the first document (instead of creating an index on ts). This is a\n // very hard-coded Mongo flag which only works on the oplog collection and\n // only works with the ts field.\n if (cursorDescription.collectionName === OPLOG_COLLECTION &&\n cursorDescription.selector.ts) {\n mongoOptions.oplogReplay = true;\n }\n }\n\n var dbCursor = collection.find(\n replaceTypes(cursorDescription.selector, replaceMeteorAtomWithMongo),\n cursorOptions.fields, mongoOptions);\n\n return new SynchronousCursor(dbCursor, cursorDescription, options);\n};\n\nvar SynchronousCursor = function (dbCursor, cursorDescription, options) {\n var self = this;\n options = _.pick(options || {}, 'selfForIteration', 'useTransform');\n\n self._dbCursor = dbCursor;\n self._cursorDescription = cursorDescription;\n // The \"self\" argument passed to forEach/map callbacks. If we're wrapped\n // inside a user-visible Cursor, we want to provide the outer cursor!\n self._selfForIteration = options.selfForIteration || self;\n if (options.useTransform && cursorDescription.options.transform) {\n self._transform = LocalCollection.wrapTransform(\n cursorDescription.options.transform);\n } else {\n self._transform = null;\n }\n\n // Need to specify that the callback is the first argument to nextObject,\n // since otherwise when we try to call it with no args the driver will\n // interpret \"undefined\" first arg as an options hash and crash.\n self._synchronousNextObject = Future.wrap(\n dbCursor.nextObject.bind(dbCursor), 0);\n self._synchronousCount = Future.wrap(dbCursor.count.bind(dbCursor));\n self._visitedIds = new LocalCollection._IdMap;\n};\n\n_.extend(SynchronousCursor.prototype, {\n _nextObject: function () {\n var self = this;\n\n while (true) {\n var doc = self._synchronousNextObject().wait();\n\n if (!doc) return null;\n doc = replaceTypes(doc, replaceMongoAtomWithMeteor);\n\n if (!self._cursorDescription.options.tailable && _.has(doc, '_id')) {\n // Did Mongo give us duplicate documents in the same cursor? If so,\n // ignore this one. (Do this before the transform, since transform might\n // return some unrelated value.) We don't do this for tailable cursors,\n // because we want to maintain O(1) memory usage. And if there isn't _id\n // for some reason (maybe it's the oplog), then we don't do this either.\n // (Be careful to do this for falsey but existing _id, though.)\n if (self._visitedIds.has(doc._id)) continue;\n self._visitedIds.set(doc._id, true);\n }\n\n if (self._transform)\n doc = self._transform(doc);\n\n return doc;\n }\n },\n\n forEach: function (callback, thisArg) {\n var self = this;\n\n // Get back to the beginning.\n self._rewind();\n\n // We implement the loop ourself instead of using self._dbCursor.each,\n // because \"each\" will call its callback outside of a fiber which makes it\n // much more complex to make this function synchronous.\n var index = 0;\n while (true) {\n var doc = self._nextObject();\n if (!doc) return;\n callback.call(thisArg, doc, index++, self._selfForIteration);\n }\n },\n\n // XXX Allow overlapping callback executions if callback yields.\n map: function (callback, thisArg) {\n var self = this;\n var res = [];\n self.forEach(function (doc, index) {\n res.push(callback.call(thisArg, doc, index, self._selfForIteration));\n });\n return res;\n },\n\n _rewind: function () {\n var self = this;\n\n // known to be synchronous\n self._dbCursor.rewind();\n\n self._visitedIds = new LocalCollection._IdMap;\n },\n\n // Mostly usable for tailable cursors.\n close: function () {\n var self = this;\n\n self._dbCursor.close();\n },\n\n fetch: function () {\n var self = this;\n return self.map(_.identity);\n },\n\n count: function () {\n var self = this;\n return self._synchronousCount().wait();\n },\n\n // This method is NOT wrapped in Cursor.\n getRawObjects: function (ordered) {\n var self = this;\n if (ordered) {\n return self.fetch();\n } else {\n var results = new LocalCollection._IdMap;\n self.forEach(function (doc) {\n results.set(doc._id, doc);\n });\n return results;\n }\n }\n});\n\nMongoConnection.prototype.tail = function (cursorDescription, docCallback) {\n var self = this;\n if (!cursorDescription.options.tailable)\n throw new Error(\"Can only tail a tailable cursor\");\n\n var cursor = self._createSynchronousCursor(cursorDescription);\n\n var stopped = false;\n var lastTS = undefined;\n var loop = function () {\n while (true) {\n if (stopped)\n return;\n try {\n var doc = cursor._nextObject();\n } catch (err) {\n // There's no good way to figure out if this was actually an error\n // from Mongo. Ah well. But either way, we need to retry the cursor\n // (unless the failure was because the observe got stopped).\n doc = null;\n }\n // Since cursor._nextObject can yield, we need to check again to see if\n // we've been stopped before calling the callback.\n if (stopped)\n return;\n if (doc) {\n // If a tailable cursor contains a \"ts\" field, use it to recreate the\n // cursor on error. (\"ts\" is a standard that Mongo uses internally for\n // the oplog, and there's a special flag that lets you do binary search\n // on it instead of needing to use an index.)\n lastTS = doc.ts;\n docCallback(doc);\n } else {\n var newSelector = _.clone(cursorDescription.selector);\n if (lastTS) {\n newSelector.ts = {$gt: lastTS};\n }\n cursor = self._createSynchronousCursor(new CursorDescription(\n cursorDescription.collectionName,\n newSelector,\n cursorDescription.options));\n // Mongo failover takes many seconds. Retry in a bit. (Without this\n // setTimeout, we peg the CPU at 100% and never notice the actual\n // failover.\n Meteor.setTimeout(loop, 100);\n break;\n }\n }\n };\n\n Meteor.defer(loop);\n\n return {\n stop: function () {\n stopped = true;\n cursor.close();\n }\n };\n};\n\nMongoConnection.prototype._observeChanges = function (\n cursorDescription, ordered, callbacks) {\n var self = this;\n\n if (cursorDescription.options.tailable) {\n return self._observeChangesTailable(cursorDescription, ordered, callbacks);\n }\n\n // You may not filter out _id when observing changes, because the id is a core\n // part of the observeChanges API.\n if (cursorDescription.options.fields &&\n (cursorDescription.options.fields._id === 0 ||\n cursorDescription.options.fields._id === false)) {\n throw Error(\"You may not observe a cursor with {fields: {_id: 0}}\");\n }\n\n var observeKey = JSON.stringify(\n _.extend({ordered: ordered}, cursorDescription));\n\n var multiplexer, observeDriver;\n var firstHandle = false;\n\n // Find a matching ObserveMultiplexer, or create a new one. This next block is\n // guaranteed to not yield (and it doesn't call anything that can observe a\n // new query), so no other calls to this function can interleave with it.\n Meteor._noYieldsAllowed(function () {\n if (_.has(self._observeMultiplexers, observeKey)) {\n multiplexer = self._observeMultiplexers[observeKey];\n } else {\n firstHandle = true;\n // Create a new ObserveMultiplexer.\n multiplexer = new ObserveMultiplexer({\n ordered: ordered,\n onStop: function () {\n delete self._observeMultiplexers[observeKey];\n observeDriver.stop();\n }\n });\n self._observeMultiplexers[observeKey] = multiplexer;\n }\n });\n\n var observeHandle = new ObserveHandle(multiplexer, callbacks);\n\n if (firstHandle) {\n var matcher, sorter;\n var canUseOplog = _.all([\n function () {\n // At a bare minimum, using the oplog requires us to have an oplog, to\n // want unordered callbacks, and to not want a callback on the polls\n // that won't happen.\n return self._oplogHandle && !ordered &&\n !callbacks._testOnlyPollCallback;\n }, function () {\n // We need to be able to compile the selector. Fall back to polling for\n // some newfangled $selector that minimongo doesn't support yet.\n try {\n matcher = new Minimongo.Matcher(cursorDescription.selector);\n return true;\n } catch (e) {\n // XXX make all compilation errors MinimongoError or something\n // so that this doesn't ignore unrelated exceptions\n return false;\n }\n }, function () {\n // ... and the selector itself needs to support oplog.\n return OplogObserveDriver.cursorSupported(cursorDescription, matcher);\n }, function () {\n // And we need to be able to compile the sort, if any. eg, can't be\n // {$natural: 1}.\n if (!cursorDescription.options.sort)\n return true;\n try {\n sorter = new Minimongo.Sorter(cursorDescription.options.sort,\n { matcher: matcher });\n return true;\n } catch (e) {\n // XXX make all compilation errors MinimongoError or something\n // so that this doesn't ignore unrelated exceptions\n return false;\n }\n }], function (f) { return f(); }); // invoke each function\n\n var driverClass = canUseOplog ? OplogObserveDriver : PollingObserveDriver;\n observeDriver = new driverClass({\n cursorDescription: cursorDescription,\n mongoHandle: self,\n multiplexer: multiplexer,\n ordered: ordered,\n matcher: matcher, // ignored by polling\n sorter: sorter, // ignored by polling\n _testOnlyPollCallback: callbacks._testOnlyPollCallback\n });\n\n // This field is only set for use in tests.\n multiplexer._observeDriver = observeDriver;\n }\n\n // Blocks until the initial adds have been sent.\n multiplexer.addHandleAndSendInitialAdds(observeHandle);\n\n return observeHandle;\n};\n\n// Listen for the invalidation messages that will trigger us to poll the\n// database for changes. If this selector specifies specific IDs, specify them\n// here, so that updates to different specific IDs don't cause us to poll.\n// listenCallback is the same kind of (notification, complete) callback passed\n// to InvalidationCrossbar.listen.\n\nlistenAll = function (cursorDescription, listenCallback) {\n var listeners = [];\n forEachTrigger(cursorDescription, function (trigger) {\n listeners.push(DDPServer._InvalidationCrossbar.listen(\n trigger, listenCallback));\n });\n\n return {\n stop: function () {\n _.each(listeners, function (listener) {\n listener.stop();\n });\n }\n };\n};\n\nforEachTrigger = function (cursorDescription, triggerCallback) {\n var key = {collection: cursorDescription.collectionName};\n var specificIds = LocalCollection._idsMatchedBySelector(\n cursorDescription.selector);\n if (specificIds) {\n _.each(specificIds, function (id) {\n triggerCallback(_.extend({id: id}, key));\n });\n triggerCallback(_.extend({dropCollection: true, id: null}, key));\n } else {\n triggerCallback(key);\n }\n};\n\n// observeChanges for tailable cursors on capped collections.\n//\n// Some differences from normal cursors:\n// - Will never produce anything other than 'added' or 'addedBefore'. If you\n// do update a document that has already been produced, this will not notice\n// it.\n// - If you disconnect and reconnect from Mongo, it will essentially restart\n// the query, which will lead to duplicate results. This is pretty bad,\n// but if you include a field called 'ts' which is inserted as\n// new MongoInternals.MongoTimestamp(0, 0) (which is initialized to the\n// current Mongo-style timestamp), we'll be able to find the place to\n// restart properly. (This field is specifically understood by Mongo with an\n// optimization which allows it to find the right place to start without\n// an index on ts. It's how the oplog works.)\n// - No callbacks are triggered synchronously with the call (there's no\n// differentiation between \"initial data\" and \"later changes\"; everything\n// that matches the query gets sent asynchronously).\n// - De-duplication is not implemented.\n// - Does not yet interact with the write fence. Probably, this should work by\n// ignoring removes (which don't work on capped collections) and updates\n// (which don't affect tailable cursors), and just keeping track of the ID\n// of the inserted object, and closing the write fence once you get to that\n// ID (or timestamp?). This doesn't work well if the document doesn't match\n// the query, though. On the other hand, the write fence can close\n// immediately if it does not match the query. So if we trust minimongo\n// enough to accurately evaluate the query against the write fence, we\n// should be able to do this... Of course, minimongo doesn't even support\n// Mongo Timestamps yet.\nMongoConnection.prototype._observeChangesTailable = function (\n cursorDescription, ordered, callbacks) {\n var self = this;\n\n // Tailable cursors only ever call added/addedBefore callbacks, so it's an\n // error if you didn't provide them.\n if ((ordered && !callbacks.addedBefore) ||\n (!ordered && !callbacks.added)) {\n throw new Error(\"Can't observe an \" + (ordered ? \"ordered\" : \"unordered\")\n + \" tailable cursor without a \"\n + (ordered ? \"addedBefore\" : \"added\") + \" callback\");\n }\n\n return self.tail(cursorDescription, function (doc) {\n var id = doc._id;\n delete doc._id;\n // The ts is an implementation detail. Hide it.\n delete doc.ts;\n if (ordered) {\n callbacks.addedBefore(id, doc, null);\n } else {\n callbacks.added(id, doc);\n }\n });\n};\n\n// XXX We probably need to find a better way to expose this. Right now\n// it's only used by tests, but in fact you need it in normal\n// operation to interact with capped collections.\nMongoInternals.MongoTimestamp = MongoDB.Timestamp;\n\nMongoInternals.Connection = MongoConnection;\n", "file_path": "packages/mongo/mongo_driver.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00043854338582605124, 0.00017219330766238272, 0.00015823783178348094, 0.00016967541887424886, 2.432183282508049e-05]}
{"hunk": {"id": 0, "code_window": ["\n", " // OK, wiped all packages, now let's go and check that everything is removed\n", " // except for the tool we are running right now and the latest tool. i.e. v1\n", " // and v3\n", " _.each(files.readdir(prefix), function (f) {\n", " if (f[0] === '.') return;\n", " if (process.platform === 'win32') {\n", " // this is a dir\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep"], "after_edit": [" var notHidden = function (f) { return f[0] !== '.'; };\n", " var meteorToolDirs = _.filter(files.readdir(prefix), notHidden);\n", " selftest.expectTrue(meteorToolDirs.length === 2);\n", " _.each(meteorToolDirs, function (f) {\n", " var fPath = files.pathJoin(prefix, f);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 114}, "file": "// Use path instead of files.js here because we are explicitly trying to\n// track requires, and files.js is often a culprit of slow requires.\nvar path = require('path');\n\n// seconds since epoch\nvar now = function () {\n return (+ new Date)/1000;\n};\n\nvar currentInvocation;\nvar RequireInvocation = function (name, filename) {\n var self = this;\n self.name = name; // module required\n self.filename = filename; // file doing the requiring, if known\n self.timeStarted = now();\n self.timeFinished = null;\n self.parent = currentInvocation;\n self.children = []; // array of RequireInvocation\n\n self.selfTime = null;\n self.totalTime = null;\n};\n\nRequireInvocation.prototype.isOurCode = function () {\n var self = this;\n\n if (! self.filename)\n return self.name === 'TOP';\n\n if (! self.name.match(/\\//))\n return false; // we always require our stuff via a path\n\n var ourSource = path.resolve(__dirname);\n var required = path.resolve(path.dirname(self.filename), self.name);\n if (ourSource.length > required.length)\n return false;\n return required.substr(0, ourSource.length) === ourSource;\n};\n\nRequireInvocation.prototype.why = function () {\n var self = this;\n var walk = self;\n var last = null;\n\n while (walk && ! walk.isOurCode()) {\n last = walk;\n walk = walk.parent;\n }\n\n if (! walk)\n return \"???\";\n if (last)\n return path.basename(walk.name) + \":\" + path.basename(last.name);\n return path.basename(walk.name);\n};\n\nexports.start = function () {\n var moduleModule = require('module');\n currentInvocation = new RequireInvocation('TOP');\n\n var realLoader = moduleModule._load;\n moduleModule._load = function (/* arguments */) {\n var inv = new RequireInvocation(arguments[0], arguments[1].filename);\n var parent = currentInvocation;\n currentInvocation.children.push(inv);\n currentInvocation = inv;\n\n try {\n return realLoader.apply(this, arguments);\n } finally {\n inv.timeFinished = now();\n currentInvocation = parent;\n }\n };\n};\n\nexports.printReport = function () {\n currentInvocation.timeFinished = now();\n var _ = require('underscore');\n\n var computeTimes = function (inv) {\n inv.totalTime = inv.timeFinished - inv.timeStarted;\n\n var childTime = 0;\n _.each(inv.children, function (child) {\n computeTimes(child);\n childTime += child.totalTime;\n });\n\n if (inv.totalTime !== null)\n inv.selfTime = inv.totalTime - childTime;\n };\n computeTimes(currentInvocation);\n\n var summary = {};\n var summarize = function (inv, depth) {\n var padding = (new Array(depth*2 + 1)).join(' ');\n // console.log(padding + inv.name + \" [\" + inv.selfTime + \"]\");\n if (! (inv.name in summary))\n summary[inv.name] = { name: inv.name, time: 0, ours: inv.isOurCode(),\n via: {} };\n summary[inv.name].time += inv.selfTime;\n if (! inv.isOurCode()) {\n summary[inv.name].via[inv.why()] = true;\n }\n\n _.each(inv.children, function (inv) {\n summarize(inv, depth + 1);\n });\n };\n summarize(currentInvocation, 0);\n\n var times = _.sortBy(_.values(summary), 'time').reverse();\n var ourTotal = 0, otherTotal = 0;\n _.each(times, function (item) {\n var line = (item.time * 1000).toFixed(2) + \" \" + item.name;\n if (! item.ours)\n line += \" [via \" + _.keys(item.via).join(\", \") + \"]\";\n console.log(line);\n if (item.ours)\n ourTotal += item.time;\n else\n otherTotal += item.time;\n });\n\n\n var grandTotal = currentInvocation.totalTime;\n if (grandTotal - ourTotal - otherTotal > 1/1000)\n throw new Error(\"Times don't add up\");\n console.log(\"TOTAL: ours \" + (ourTotal * 1000).toFixed(2) +\n \", other \" + (otherTotal * 1000).toFixed(2) +\n \", grand total \" + (grandTotal * 1000).toFixed(2));\n};\n", "file_path": "tools/profile-require.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.003543520113453269, 0.0004491960571613163, 0.00016626311116851866, 0.00017027606372721493, 0.0008689412497915328]}
{"hunk": {"id": 0, "code_window": ["\n", " // OK, wiped all packages, now let's go and check that everything is removed\n", " // except for the tool we are running right now and the latest tool. i.e. v1\n", " // and v3\n", " _.each(files.readdir(prefix), function (f) {\n", " if (f[0] === '.') return;\n", " if (process.platform === 'win32') {\n", " // this is a dir\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep"], "after_edit": [" var notHidden = function (f) { return f[0] !== '.'; };\n", " var meteorToolDirs = _.filter(files.readdir(prefix), notHidden);\n", " selftest.expectTrue(meteorToolDirs.length === 2);\n", " _.each(meteorToolDirs, function (f) {\n", " var fPath = files.pathJoin(prefix, f);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 114}, "file": "var _ = require('underscore');\n\n// schema - Object, representing paths to correct. Ex.:\n// {\n// format: false,\n// arch: false,\n// load: [\n// {\n// node_modulus: true,\n// sourceMap: true,\n// sourceMapRoot: true,\n// path: true\n// }\n// ]\n// }\nvar convertBySchema = function (val, schema) {\n if (schema === true)\n return convert(val);\n else if (schema === false)\n return val;\n\n if (_.isArray(schema)) {\n if (schema.length !== 1) {\n throw new Error(\"Expected an array with one element in schema\");\n }\n\n if (! _.isArray(val)) {\n throw new Error(\"Expected an array in value, got \" + typeof val);\n }\n\n return _.map(val, function (subval) {\n return convertBySchema(subval, schema[0]);\n });\n }\n\n if (! _.isObject(schema))\n throw new Error(\"Unexpected type of schema: \" + typeof(schema));\n\n var ret = _.clone(val);\n _.each(schema, function (subschema, key) {\n if (_.has(ret, key))\n ret[key] = convertBySchema(val[key], subschema);\n });\n\n return ret;\n};\n\nvar convert = function (path) {\n return path.replace(/:/g, '_');\n};\n\nvar ISOPACK_SCHEME = {\n builds: [{\n path: true\n }],\n plugins: [{\n path: true\n }]\n};\n\nvar UNIBUILD_SCHEME = {\n node_modules: true,\n resources: [{\n file: true,\n sourceMap: true,\n servePath: true\n }]\n};\n\nvar JAVASCRIPT_IMAGE_SCHEME = {\n load: [{\n sourceMap: true,\n sourceMapRoot: true,\n path: true,\n node_modules: true\n }]\n};\n\nexports.convertIsopack = function (data) {\n return convertBySchema(data, ISOPACK_SCHEME);\n};\n\nexports.convertUnibuild = function (data) {\n return convertBySchema(data, UNIBUILD_SCHEME);\n};\n\nexports.convertJSImage = function (data) {\n return convertBySchema(data, JAVASCRIPT_IMAGE_SCHEME);\n};\n\nexports.convert = convert;\n\n", "file_path": "tools/colon-converter.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.005752760451287031, 0.0009051371598616242, 0.0001666602329351008, 0.00017122802091762424, 0.0016973038436844945]}
{"hunk": {"id": 1, "code_window": [" if (process.platform === 'win32') {\n", " // this is a dir\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n", " } else {\n", " // this is a symlink to a dir and this dir exists\n"], "labels": ["keep", "keep", "replace", "keep", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isDirectory());\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 118}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.9939395189285278, 0.07426263391971588, 0.0001675943931331858, 0.0006991945556364954, 0.25518348813056946]}
{"hunk": {"id": 1, "code_window": [" if (process.platform === 'win32') {\n", " // this is a dir\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n", " } else {\n", " // this is a symlink to a dir and this dir exists\n"], "labels": ["keep", "keep", "replace", "keep", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isDirectory());\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 118}, "file": "@menu-width: 270px;\n@column: 5.55555%;\n\nbody {\n .position(absolute, 0, 0, 0, 0);\n background-color: #315481;\n .background-image( linear-gradient(top, #315481, #918e82 100%) );\n background-repeat: no-repeat;\n background-attachment: fixed;\n}\n\n#container {\n .position(absolute, 0, 0, 0, 0);\n\n @media screen and (min-width: 60em) {\n left: @column;\n right: @column;\n }\n\n @media screen and (min-width: 80em) {\n left: 2*@column;\n right: 2*@column;\n }\n\n // Hide anything offscreen\n overflow: hidden;\n}\n\n#menu {\n .position(absolute, 0, 0, 0, 0, @menu-width);\n}\n\n#content-container {\n .position(absolute, 0, 0, 0, 0);\n .transition(all 200ms ease-out);\n .transform(translate3d(0, 0, 0));\n background: @color-tertiary;\n opacity: 1;\n\n @media screen and (min-width: 40em) {\n left: @menu-width;\n }\n\n .content-scrollable {\n .position(absolute, 0, 0, 0, 0);\n .transform(translate3d(0, 0, 0));\n overflow-y: auto;\n -webkit-overflow-scrolling: touch;\n }\n\n // Toggle menu on mobile\n .menu-open & {\n .transform(translate3d(@menu-width, 0, 0));\n opacity: .85;\n left: 0;\n\n @media screen and (min-width: 40em) {\n // Show menu on desktop, negate .menu-open\n .transform(translate3d(0, 0, 0)); //reset transform and use position properties instead\n opacity: 1;\n left: @menu-width;\n }\n }\n}\n\n// Transparent screen to prevent interactions on content when menu is open\n.content-overlay {\n .position(absolute, 0, 0, 0, 0);\n cursor: pointer;\n\n .menu-open & {\n .transform(translate3d(@menu-width, 0, 0));\n z-index: 1;\n }\n\n // Hide overlay on desktop\n @media screen and (min-width: 40em) { display: none; }\n}", "file_path": "examples/todos/client/stylesheets/globals/layout.import.less", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017695136193651706, 0.00017469871090725064, 0.00017178876441903412, 0.0001747365458868444, 1.6827224271764862e-06]}
{"hunk": {"id": 1, "code_window": [" if (process.platform === 'win32') {\n", " // this is a dir\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n", " } else {\n", " // this is a symlink to a dir and this dir exists\n"], "labels": ["keep", "keep", "replace", "keep", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isDirectory());\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 118}, "file": "// This implementation of Min/Max-Heap is just a subclass of Max-Heap\n// with a Min-Heap as an encapsulated property.\n//\n// Most of the operations are just proxy methods to call the same method on both\n// heaps.\n//\n// This implementation takes 2*N memory but is fairly simple to write and\n// understand. And the constant factor of a simple Heap is usually smaller\n// compared to other two-way priority queues like Min/Max Heaps\n// (http://www.cs.otago.ac.nz/staffpriv/mike/Papers/MinMaxHeaps/MinMaxHeaps.pdf)\n// and Interval Heaps\n// (http://www.cise.ufl.edu/~sahni/dsaac/enrich/c13/double.htm)\nMinMaxHeap = function (comparator, options) {\n var self = this;\n\n MaxHeap.call(self, comparator, options);\n self._minHeap = new MinHeap(comparator, options);\n};\n\nMeteor._inherits(MinMaxHeap, MaxHeap);\n\n_.extend(MinMaxHeap.prototype, {\n set: function (id, value) {\n var self = this;\n MaxHeap.prototype.set.apply(self, arguments);\n self._minHeap.set(id, value);\n },\n remove: function (id) {\n var self = this;\n MaxHeap.prototype.remove.apply(self, arguments);\n self._minHeap.remove(id);\n },\n clear: function () {\n var self = this;\n MaxHeap.prototype.clear.apply(self, arguments);\n self._minHeap.clear();\n },\n setDefault: function (id, def) {\n var self = this;\n MaxHeap.prototype.setDefault.apply(self, arguments);\n return self._minHeap.setDefault(id, def);\n },\n clone: function () {\n var self = this;\n var clone = new MinMaxHeap(self._comparator, self._heap);\n return clone;\n },\n minElementId: function () {\n var self = this;\n return self._minHeap.minElementId();\n }\n});\n\n", "file_path": "packages/binary-heap/min-max-heap.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017705971549730748, 0.00017441390082240105, 0.00016774548566900194, 0.0001755667180987075, 3.0886178592481883e-06]}
{"hunk": {"id": 1, "code_window": [" if (process.platform === 'win32') {\n", " // this is a dir\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n", " } else {\n", " // this is a symlink to a dir and this dir exists\n"], "labels": ["keep", "keep", "replace", "keep", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isDirectory());\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 118}, "file": ".build*\n", "file_path": "packages/preserve-inputs/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017769854457583278, 0.00017769854457583278, 0.00017769854457583278, 0.00017769854457583278, 0.0]}
{"hunk": {"id": 2, "code_window": [" } else {\n", " // this is a symlink to a dir and this dir exists\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n", " }\n"], "labels": ["keep", "keep", "replace", "replace", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(fPath))));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 121}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.3262854218482971, 0.026332179084420204, 0.0001663590664975345, 0.0012636248720809817, 0.08333621919155121]}
{"hunk": {"id": 2, "code_window": [" } else {\n", " // this is a symlink to a dir and this dir exists\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n", " }\n"], "labels": ["keep", "keep", "replace", "replace", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(fPath))));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 121}, "file": "# This file contains information which helps Meteor properly upgrade your\n# app when you run 'meteor update'. You should check it into version control\n# with your project.\n\nnotices-for-0.9.0\nnotices-for-0.9.1\n0.9.4-platform-file\nnotices-for-facebook-graph-api-2\n", "file_path": "examples/clock/.meteor/.finished-upgraders", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.0001656428212299943, 0.0001656428212299943, 0.0001656428212299943, 0.0001656428212299943, 0.0]}
{"hunk": {"id": 2, "code_window": [" } else {\n", " // this is a symlink to a dir and this dir exists\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n", " }\n"], "labels": ["keep", "keep", "replace", "replace", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(fPath))));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 121}, "file": "# accounts-weibo\n\nA login service for Weibo. See the [project page](https://www.meteor.com/accounts) on Meteor Accounts for more details.", "file_path": "packages/accounts-weibo/README.md", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.0001660283305682242, 0.0001660283305682242, 0.0001660283305682242, 0.0001660283305682242, 0.0]}
{"hunk": {"id": 2, "code_window": [" } else {\n", " // this is a symlink to a dir and this dir exists\n", " selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n", " }\n"], "labels": ["keep", "keep", "replace", "replace", "keep"], "after_edit": [" selftest.expectTrue(files.lstat(fPath).isSymbolicLink());\n", " selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(fPath))));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 121}, "file": "#pragma once\n//-------------------------------------------------------------------------------------------------\n// \n// Copyright (c) 2004, Outercurve Foundation.\n// This software is released under Microsoft Reciprocal License (MS-RL).\n// The license and further copyright text can be found in the file\n// LICENSE.TXT at the root directory of the distribution.\n// \n// \n// \n// Header for string dict helper functions.\n// \n//-------------------------------------------------------------------------------------------------\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ReleaseDict(sdh) if (sdh) { DictDestroy(sdh); }\n#define ReleaseNullDict(sdh) if (sdh) { DictDestroy(sdh); sdh = NULL; }\n\ntypedef void* STRINGDICT_HANDLE;\ntypedef const void* C_STRINGDICT_HANDLE;\n\nextern const int STRINGDICT_HANDLE_BYTES;\n\nenum DICT_FLAG\n{\n DICT_FLAG_NONE = 0,\n DICT_FLAG_CASEINSENSITIVE = 1\n};\n\nHRESULT DAPI DictCreateWithEmbeddedKey(\n __out_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE* psdHandle,\n __in DWORD dwNumExpectedItems,\n __in_opt void **ppvArray,\n __in size_t cByteOffset,\n __in DICT_FLAG dfFlags\n );\nHRESULT DAPI DictCreateStringList(\n __out_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE* psdHandle,\n __in DWORD dwNumExpectedItems,\n __in DICT_FLAG dfFlags\n );\nHRESULT DAPI DictCreateStringListFromArray(\n __out_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE* psdHandle,\n __in_ecount(cStringArray) const LPCWSTR* rgwzStringArray,\n __in const DWORD cStringArray,\n __in DICT_FLAG dfFlags\n );\nHRESULT DAPI DictCompareStringListToArray(\n __in_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE sdStringList,\n __in_ecount(cStringArray) const LPCWSTR* rgwzStringArray,\n __in const DWORD cStringArray\n );\nHRESULT DAPI DictAddKey(\n __in_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE sdHandle,\n __in_z LPCWSTR szString\n );\nHRESULT DAPI DictAddValue(\n __in_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE sdHandle,\n __in void *pvValue\n );\nHRESULT DAPI DictKeyExists(\n __in_bcount(STRINGDICT_HANDLE_BYTES) C_STRINGDICT_HANDLE sdHandle,\n __in_z LPCWSTR szString\n );\nHRESULT DAPI DictGetValue(\n __in_bcount(STRINGDICT_HANDLE_BYTES) C_STRINGDICT_HANDLE sdHandle,\n __in_z LPCWSTR szString,\n __out void **ppvValue\n );\nvoid DAPI DictDestroy(\n __in_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE sdHandle\n );\n\n#ifdef __cplusplus\n}\n#endif\n", "file_path": "scripts/windows/installer/WiXSDK/inc/dictutil.h", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017773665604181588, 0.00017268958617933095, 0.00016566365957260132, 0.00017313091666437685, 4.139316388318548e-06]}
{"hunk": {"id": 3, "code_window": [" }\n", " });\n", "\n", " // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["\n", " // check that the version is either the running one, or the latest one\n", " selftest.expectTrue(_.contains(['33.0.1', '33.0.3'], f));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "add", "edit_start_line_idx": 124}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.9928211569786072, 0.1451805830001831, 0.0001677058171480894, 0.0011345215607434511, 0.3444081246852875]}
{"hunk": {"id": 3, "code_window": [" }\n", " });\n", "\n", " // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["\n", " // check that the version is either the running one, or the latest one\n", " selftest.expectTrue(_.contains(['33.0.1', '33.0.3'], f));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "add", "edit_start_line_idx": 124}, "file": "// quick jquery extension to bind text inputs to blur and RET.\n$.fn.onBlurOrEnter = function (callback) {\n this.bind('blur', callback);\n this.bind('keypress', function (evt) {\n if (evt.keyCode === 13 && $(this).val())\n callback.call(this, evt);\n });\n};\n\n// everything else happens after DOM is ready\n$(function () {\n $('body').layout({north__minSize: 50,\n spacing_open: 10,\n north__fxSettings: { direction: \"vertical\" }});\n\n // cache the template function for a single item.\n var item_template = _.template($('#item-template').html());\n\n // this render function could be replaced with a handlebars\n // template. underscore template isn't safe for user-entered data\n // like the item text (XSS).\n function renderItem (obj) {\n // generate template for todo\n var elt = $(item_template(obj));\n\n // set text through jquery for XSS protection\n elt.find('.todo-text').text(obj.text);\n\n // clicking the checkbox toggles done state\n elt.find('.check').click(function () {\n Todos.update(obj._id, {$set: {done: !obj.done}});\n });\n\n // clicking destroy button removes the item\n elt.find('.destroy').click(function () {\n Todos.remove(obj._id);\n });\n\n // wire up tag destruction links\n elt.find('.tag .remove').click(function () {\n var tag = $(this).attr('name');\n $(this).parent().fadeOut(500, function () {\n Todos.update(obj._id, {$pull: {tags: tag}});\n });\n });\n\n // wire up add tag\n elt.find('.addtag').click(function () {\n $(this).hide();\n elt.find('.edittag').show();\n elt.find('.edittag input').focus();\n });\n\n // wire up edit tag\n elt.find('.edittag input').onBlurOrEnter(function () {\n elt.find('.edittag').hide();\n elt.find('.addtag').show();\n if ($(this).val() !== '')\n Todos.update(obj._id, {$addToSet: {tags: $(this).val()}});\n });\n\n // doubleclick on todo text brings up the editor\n elt.find('.todo-text').dblclick(function () {\n elt.addClass('editing');\n\n var input = elt.find('.todo-input');\n input.val(obj.text);\n input.focus();\n input.select();\n\n input.onBlurOrEnter(function () {\n elt.removeClass('editing');\n if ($(this).val() !== '')\n Todos.update(obj._id, {$set: {text: elt.find('.todo-input').val()}});\n });\n });\n\n return elt[0];\n };\n\n // construct new todo from text box\n $('#new-todo').bind('keypress', function (evt) {\n var list_id = Session.get('list_id');\n var tag = Session.get('tag_filter');\n\n // prevent creation of a new todo if nothing is selected\n if (!list_id) return;\n\n var text = $('#new-todo').val();\n\n if (evt.keyCode === 13 && text) {\n var obj = {text: text,\n list_id: list_id,\n done: false,\n timestamp: (new Date()).getTime()};\n if (tag) obj.tags = [tag];\n\n Todos.insert(obj);\n $('#new-todo').val('');\n }\n });\n\n var current_list_stop;\n function setCurrentList (list_id) {\n Session.set('list_id', list_id);\n\n $('#items-view').show();\n\n // kill current findLive render\n if (current_list_stop)\n current_list_stop.stop();\n\n var query = {list_id: list_id};\n if (Session.get('tag_filter'))\n query.tags = Session.get('tag_filter')\n\n // render individual todo list, stash kill function\n current_list_stop =\n Meteor.ui.renderList(Todos, $('#item-list'), {\n selector: query,\n sort: {timestamp: 1},\n render: renderItem,\n events: {}\n });\n };\n\n // render list of lists in the left sidebar.\n Meteor.ui.renderList(Lists, $('#lists'), {\n sort: {name: 1},\n template: $('#list-template'),\n events: {\n 'click': function (evt) {\n window.History.pushState({list_id: this._id},\n \"Todos: \" + this.name,\n \"/\" + this._id);\n },\n 'dblclick': function (evt) {\n var list_elt = $(evt.currentTarget);\n var input = list_elt.find('.list-name-input');\n\n list_elt.addClass('editing');\n\n input.val(this.name);\n input.focus();\n input.select();\n\n var _id = this._id;\n input.onBlurOrEnter(function () {\n list_elt.removeClass('editing');\n if (input.val() !== '')\n Lists.update(_id, {$set: {name: input.val()}});\n });\n }\n }\n });\n\n // construct new todo list from text box\n $('#new-list').bind('keypress', function (evt) {\n var text = $('#new-list').val();\n\n if (evt.keyCode === 13 && text) {\n var list = Lists.insert({name: text});\n $('#new-list').val('');\n window.History.pushState({list_id: list._id},\n \"Todos: \" + list.name,\n \"/\" + list._id);\n }\n });\n\n // tags and filters\n\n // the tag filter bar is easy to generate using a simple\n // renderList() against a minimongo query. since minimongo doesn't\n // support aggregate queries, construct a local collection to serve\n // the same purpose, and drive the renderList() off of it.\n\n var LocalTags = new Mongo.Collection;\n (function () {\n function updateLocalTags() {\n var real = _(Todos.find()).chain().pluck('tags').compact().flatten().uniq().value();\n real.unshift(null); // XXX fake tag\n\n var computed = _(LocalTags.find()).pluck('tag');\n\n _.each(_.difference(real, computed), function (new_tag) {\n LocalTags.insert({tag: new_tag});\n });\n\n _.each(_.difference(computed, real), function (dead_tag) {\n LocalTags.remove({tag: dead_tag});\n });\n };\n\n Todos.findLive({}, {\n added: function (obj, before_idx) { _.defer(updateLocalTags); },\n removed: function (id, at_idx) { _.defer(updateLocalTags); },\n changed: function (obj, at_idx) { _.defer(updateLocalTags); },\n });\n })();\n\n // findLive() against the computed tag table. since we also want a\n // show-all button, arrange for the computed table to always include\n // a null placeholder tag, and for the template to render that as\n // \"Show all\". always begin the user session with a null filter.\n\n Session.set('tag_filter', null);\n\n Meteor.ui.renderList(LocalTags, $('#tag-filter'), {\n sort: {tag: 1},\n template: $('#tag-filter-template'),\n events: {\n 'click': function (evt) {\n if (Session.equals('tag_filter', this.tag))\n Session.set('tag_filter', null);\n else\n Session.set('tag_filter', this.tag);\n\n setCurrentList(Session.get('list_id'));\n }\n }\n });\n\n // load list on statechange (which we drive from several places).\n window.History.Adapter.bind(window, 'statechange', function () {\n var state = window.History.getState();\n var list = Lists.find(state.data.list_id);\n setCurrentList(list._id);\n });\n\n // subscribe to all available todo lists. once the inital load\n // completes, navigate to the list specified by URL, if any.\n Meteor.subscribe('lists', function () {\n var initial_list_id = window.location.pathname.split('/')[1];\n var list;\n\n if (initial_list_id) {\n list = Lists.find(initial_list_id);\n } else {\n var lists = Lists.find({}, {sort: {name: 1}, limit: 1});\n list = lists[0];\n }\n\n if (list) {\n window.History.replaceState({list_id: list._id},\n \"Todos: \" + list.name,\n \"/\" + list._id);\n // replaceState doesn't always trigger statechange on reload. if\n // you last reloaded the same page and the state is the same, it\n // won't fire. so call this here. double calling is not great, but\n // OK.\n setCurrentList(list._id);\n }\n });\n\n // subscribe to all the items in each list. no need for a callback\n // here: todo items are never queried using collection.find().\n Meteor.subscribe('todos');\n});\n", "file_path": "examples/unfinished/todos-underscore/client/client.js", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017446062702219933, 0.0001701934525044635, 0.0001642957067815587, 0.00017030283925123513, 2.700097411434399e-06]}
{"hunk": {"id": 3, "code_window": [" }\n", " });\n", "\n", " // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["\n", " // check that the version is either the running one, or the latest one\n", " selftest.expectTrue(_.contains(['33.0.1', '33.0.3'], f));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "add", "edit_start_line_idx": 124}, "file": "\n{{#markdown}}\n## `webapp`\n\nThe `webapp` package is what lets your Meteor app serve content to a web\nbrowser. It is included in the `meteor-platform` set of packages that is\nautomatically added when you run `meteor create`. You can easily build a\nMeteor app without it - for example if you wanted to make a command-line\ntool that still used the Meteor package system and DDP.\n\nThis package also allows you to add handlers for HTTP requests.\nThis lets other services access your app's data through an HTTP API, allowing\nit to easily interoperate with tools and frameworks that don't yet support DDP.\n\n`webapp` exposes the [connect](https://github.com/senchalabs/connect) API for\nhandling requests through `WebApp.connectHandlers`.\nHere's an example that will let you handle a specific URL:\n\n```js\n// Listen to incoming HTTP requests, can only be used on the server\nWebApp.connectHandlers.use(\"/hello\", function(req, res, next) {\n res.writeHead(200);\n res.end(\"Hello world from: \" + Meteor.release);\n});\n```\n\n`WebApp.connectHandlers.use([path], handler)` has two arguments:\n\n**path** - an optional path field.\nThis handler will only be called on paths that match\nthis string. The match has to border on a `/` or a `.`. For example, `/hello`\nwill match `/hello/world` and `/hello.world`, but not `/hello_world`.\n\n**handler** - this is a function that takes three arguments:\n\n- **req** - a Node.js\n[IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage)\nobject with some extra properties. This argument can be used to get information\nabout the incoming request.\n- **res** - a Node.js\n[ServerResponse](http://nodejs.org/api/http.html#http_class_http_serverresponse)\nobject. Use this to write data that should be sent in response to the\nrequest, and call `res.end()` when you are done.\n- **next** - a function. Calling this function will pass on the handling of\nthis request to the next relevant handler.\n{{/markdown}}\n", "file_path": "docs/client/full-api/packages/webapp.html", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00016960629727691412, 0.0001653441577218473, 0.0001615835353732109, 0.00016423821216449142, 3.275692279203213e-06]}
{"hunk": {"id": 3, "code_window": [" }\n", " });\n", "\n", " // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["\n", " // check that the version is either the running one, or the latest one\n", " selftest.expectTrue(_.contains(['33.0.1', '33.0.3'], f));\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "add", "edit_start_line_idx": 124}, "file": "\n
\n", "file_path": "examples/localmarket/client/templates/overlay.html", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00017411580483894795, 0.00017411580483894795, 0.00017411580483894795, 0.00017411580483894795, 0.0]}
{"hunk": {"id": 4, "code_window": [" // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n", " if (p[0] === '.') return;\n", " if (p === 'meteor-tool') return;\n", " var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n", " contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n", " selftest.expectTrue(contents.length === 0);\n", " });\n", "});\n", ""], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" contents = _.filter(contents, notHidden);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 131}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.9983273148536682, 0.14442963898181915, 0.00016679504187777638, 0.0010921244975179434, 0.348265141248703]}
{"hunk": {"id": 4, "code_window": [" // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n", " if (p[0] === '.') return;\n", " if (p === 'meteor-tool') return;\n", " var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n", " contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n", " selftest.expectTrue(contents.length === 0);\n", " });\n", "});\n", ""], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" contents = _.filter(contents, notHidden);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 131}, "file": "local\n", "file_path": "tools/tests/old/app-with-private/.meteor/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00016961651272140443, 0.00016961651272140443, 0.00016961651272140443, 0.00016961651272140443, 0.0]}
{"hunk": {"id": 4, "code_window": [" // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n", " if (p[0] === '.') return;\n", " if (p === 'meteor-tool') return;\n", " var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n", " contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n", " selftest.expectTrue(contents.length === 0);\n", " });\n", "});\n", ""], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" contents = _.filter(contents, notHidden);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 131}, "file": "# Meteor packages used by this project, one per line.\n#\n# 'meteor add' and 'meteor remove' will edit this file for you,\n# but you can also edit it by hand.\n\nstandard-app-packages\njquery\nunderscore\nshowdown\nspiderable\nappcache\nreload-safetybelt\nsimple:markdown-templating\nsimple:highlight.js\nless\n", "file_path": "docs/.meteor/packages", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00024026025494094938, 0.00020350213162600994, 0.0001667440083110705, 0.00020350213162600994, 3.675812331493944e-05]}
{"hunk": {"id": 4, "code_window": [" // Check that all other packages are wiped\n", " _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n", " if (p[0] === '.') return;\n", " if (p === 'meteor-tool') return;\n", " var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n", " contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n", " selftest.expectTrue(contents.length === 0);\n", " });\n", "});\n", ""], "labels": ["keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [" contents = _.filter(contents, notHidden);\n"], "file_path": "tools/tests/wipe-all-packages.js", "type": "replace", "edit_start_line_idx": 131}, "file": "local\n", "file_path": "tools/tests/apps/standard-app/.meteor/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00016961651272140443, 0.00016961651272140443, 0.00016961651272140443, 0.00016961651272140443, 0.0]}
{"hunk": {"id": 5, "code_window": [" var self = this;\n", "\n", " if (self.platform === \"win32\") {\n", " // XXX wipeAllPackages won't work on Windows until we fix that function\n", " isopack.saveToPath(self.packagePath(packageName, isopack.version));\n", " } else {\n", " // Note: wipeAllPackages depends on this filename structure\n", " // On Mac and Linux, we used to use a filename structure that used the\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [], "file_path": "tools/tropohouse.js", "type": "replace", "edit_start_line_idx": 327}, "file": "var selftest = require('../selftest.js');\nvar Sandbox = selftest.Sandbox;\nvar files = require(\"../files.js\");\nvar utils = require(\"../utils.js\");\nvar archinfo = require(\"../archinfo.js\");\nvar _ = require('underscore');\n\nselftest.define(\"wipe all packages\", function () {\n var s = new Sandbox({\n warehouse: {\n v1: { tool: \"meteor-tool@33.0.1\" },\n v2: { tool: \"meteor-tool@33.0.2\" },\n v3: { tool: \"meteor-tool@33.0.3\" }\n }\n });\n var meteorToolVersion = function (v) {\n return {\n _id: 'VID' + v.replace(/\\./g, ''),\n packageName: 'meteor-tool',\n testName: null,\n version: v,\n publishedBy: null,\n description: 'The Meteor command-line tool',\n git: undefined,\n dependencies: { meteor: { constraint: null, references: [{ arch: 'os' }, { arch: 'web.browser' }, { arch: 'web.cordova' }] } },\n source: null,\n lastUpdated: null,\n published: null,\n isTest: false,\n debugOnly: false,\n containsPlugins: false\n };\n };\n\n // insert the new tool versions into the catalog\n s.warehouseOfficialCatalog.insertData({\n syncToken: {},\n formatVersion: \"1.0\",\n collections: {\n packages: [],\n versions: [meteorToolVersion('33.0.1'), meteorToolVersion('33.0.2'), meteorToolVersion('33.0.3')],\n builds: [],\n releaseTracks: [],\n releaseVersions: []\n }\n });\n\n // help warehouse faking by copying the meteor-tool 3 times and introducing 3\n // fake versions (identical in code to the one we are running)\n var latestMeteorToolVersion =\n files.readLinkToMeteorScript(files.pathJoin(s.warehouse, 'meteor')).split('/');\n latestMeteorToolVersion = latestMeteorToolVersion[latestMeteorToolVersion.length - 3];\n\n var prefix = files.pathJoin(s.warehouse, 'packages', 'meteor-tool');\n var copyTool = function (srcVersion, dstVersion) {\n if (process.platform === 'win32') {\n // just copy the files\n files.cp_r(\n files.pathJoin(prefix, srcVersion),\n files.pathJoin(prefix, dstVersion), {\n preserveSymlinks: true\n });\n } else {\n // figure out what the symlink links to and copy the folder *and* the\n // symlink\n var srcFullVersion = files.readlink(files.pathJoin(prefix, srcVersion));\n var dstFullVersion = srcFullVersion.replace(srcVersion, dstVersion);\n\n // copy the hidden folder\n files.cp_r(\n files.pathJoin(prefix, srcFullVersion),\n files.pathJoin(prefix, dstFullVersion), {\n preserveSymlinks: true\n });\n\n // link to it\n files.symlink(\n dstFullVersion,\n files.pathJoin(prefix, dstVersion));\n }\n\n var replaceVersionInFile = function (filename) {\n var filePath = files.pathJoin(prefix, dstVersion, filename);\n files.writeFile(\n filePath,\n files.readFile(filePath, 'utf8')\n .replace(new RegExp(srcVersion, 'g'), dstVersion));\n };\n\n // \"fix\" the isopack.json and unibuild.json files (they contain the versions)\n replaceVersionInFile('isopack.json');\n replaceVersionInFile('unipackage.json');\n };\n\n copyTool(latestMeteorToolVersion, '33.0.3');\n copyTool(latestMeteorToolVersion, '33.0.2');\n copyTool(latestMeteorToolVersion, '33.0.1');\n\n // since the warehouse faking system is weak and under-developed, add more\n // faking, such as making the v3 the latest version\n files.linkToMeteorScript(\n files.pathJoin(s.warehouse, 'packages', 'meteor-tool', '33.0.3', 'mt-' + archinfo.host(), 'meteor'),\n files.pathJoin(s.warehouse, 'meteor'));\n\n\n var run;\n\n run = s.run('--release', 'v1', 'admin', 'wipe-all-packages');\n run.waitSecs(15);\n run.expectExit(0);\n\n // OK, wiped all packages, now let's go and check that everything is removed\n // except for the tool we are running right now and the latest tool. i.e. v1\n // and v3\n _.each(files.readdir(prefix), function (f) {\n if (f[0] === '.') return;\n if (process.platform === 'win32') {\n // this is a dir\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isDirectory());\n } else {\n // this is a symlink to a dir and this dir exists\n selftest.expectTrue(files.lstat(files.pathJoin(prefix, f)).isSymbolicLink());\n selftest.expectTrue(files.exists(files.pathJoin(prefix, files.readlink(files.pathJoin(prefix, f)))));\n }\n });\n\n // Check that all other packages are wiped\n _.each(files.readdir(files.pathJoin(s.warehouse, 'packages')), function (p) {\n if (p[0] === '.') return;\n if (p === 'meteor-tool') return;\n var contents = files.readdir(files.pathJoin(s.warehouse, 'packages', p));\n contents = _.filter(contents, function (f) { return f[0] !== '.'; });\n selftest.expectTrue(contents.length === 0);\n });\n});\n\n", "file_path": "tools/tests/wipe-all-packages.js", "label": 1, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.0004402086779009551, 0.00020332720305304974, 0.00016621364920865744, 0.00017021014355123043, 8.212235843529925e-05]}
{"hunk": {"id": 5, "code_window": [" var self = this;\n", "\n", " if (self.platform === \"win32\") {\n", " // XXX wipeAllPackages won't work on Windows until we fix that function\n", " isopack.saveToPath(self.packagePath(packageName, isopack.version));\n", " } else {\n", " // Note: wipeAllPackages depends on this filename structure\n", " // On Mac and Linux, we used to use a filename structure that used the\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [], "file_path": "tools/tropohouse.js", "type": "replace", "edit_start_line_idx": 327}, "file": "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Consolas;}{\\f1\\fnil Consolas;}{\\f2\\fnil\\fcharset0 Calibri;}}\n{\\*\\generator Msftedit 5.41.21.2509;}\\viewkind4\\uc1\\pard\\sa200\\sl276\\slmult1\\b\\f0\\fs40 [Put Your License Agreement Here]\\lang9\\b0\\f1\\fs19\\par\n\\lang1033\\f0 L\\lang9\\f1 orem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies ultricies arcu id commodo. Ut dignissim ante nec urna elementum imperdiet. Praesent pretium condimentum orci sit amet laoreet. Fusce condimentum tempor leo, vitae tempor quam interdum et. Nulla ante dui, tincidunt sed porta nec, pulvinar in felis. Pellentesque pellentesque ornare nibh id accumsan. In eu arcu nibh. Aenean ut vulputate nisl. Proin at nibh lacinia urna elementum commodo. Donec semper lorem quis neque fringilla quis facilisis dolor dignissim. Suspendisse a massa in odio viverra vehicula. Curabitur id lectus purus, non bibendum arcu. Cras dictum, turpis eget gravida condimentum, turpis ante varius leo, molestie pulvinar mauris libero ut leo. Morbi libero diam, sollicitudin id interdum sit amet, rhoncus eget turpis.\\par\nVestibulum arcu dui, suscipit vitae suscipit laoreet, posuere eget risus. Sed vitae massa in justo vehicula elementum sed at arcu. Pellentesque arcu ante, accumsan sed lacinia sed, lacinia vel urna. Vivamus at ligula nulla, lobortis ultricies tortor. Vivamus suscipit dolor non velit adipiscing venenatis. Nullam adipiscing accumsan condimentum. Nullam ut lorem neque, et iaculis felis. Donec sed massa diam, et feugiat velit. Pellentesque facilisis mi a odio ultrices facilisis. Nam porta, lorem feugiat aliquet placerat, ipsum risus accumsan sem, euismod bibendum velit dolor sed turpis. Suspendisse tincidunt, lectus congue rhoncus sollicitudin, magna erat porttitor ante, eget sodales ante sem eu augue. Aenean risus risus, mattis vitae pretium at, venenatis dictum est. Vestibulum consectetur euismod magna vel sodales.\\par\nQuisque eu urna lacus. Nunc eget dictum odio. Pellentesque vel dolor leo. Praesent aliquet, erat vel fringilla lobortis, ante nibh dapibus augue, sed semper ligula odio vitae nulla. Nullam dictum gravida lectus nec lacinia. Vivamus fermentum ultricies lobortis. In quis magna massa, ut commodo lectus. Donec nunc velit, gravida id euismod luctus, luctus sed ante. Nunc elementum mollis sapien, ac interdum quam fringilla eu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam dui enim, tempus vel aliquam sed, pretium sed nisi. Fusce vitae magna nec nibh aliquam suscipit vel a felis. Etiam gravida, lorem id laoreet gravida, nisl leo hendrerit dolor, quis porta mauris enim vitae justo. Maecenas congue, felis at rhoncus vestibulum, nisl urna pellentesque urna, id iaculis augue metus eget neque. Curabitur pretium risus nec tortor vulputate et rhoncus ipsum gravida.\\par\nMaecenas elementum volutpat arcu, nec ultricies velit faucibus facilisis. Etiam sem lacus, mattis eget gravida ut, rhoncus porta lorem. Vivamus volutpat dui sit amet risus mollis venenatis. Quisque velit velit, condimentum id pharetra sed, varius vitae lectus. Praesent nisi turpis, porttitor nec accumsan a, aliquam sit amet augue. Quisque facilisis enim sed enim pretium tristique. Aliquam commodo varius mi, ut iaculis nunc tempus non. Vivamus velit nunc, dictum a dignissim vitae, commodo id metus. Integer volutpat, neque at ultrices dignissim, felis nulla commodo orci, at auctor nisl quam nec sem. Pellentesque interdum pellentesque nulla, ac fermentum tortor porttitor a. Etiam condimentum aliquet sapien vel adipiscing. Quisque est velit, vulputate a iaculis ut, tempus in nibh. Cras consectetur quam nibh, vel lobortis justo. Aenean a elit leo. Aenean mollis dolor a odio accumsan mollis. Proin blandit neque erat. Integer lectus urna, volutpat quis vulputate et, fermentum et ante. Maecenas vitae ultricies dui.\\par\nMauris accumsan varius luctus. In hac habitasse platea dictumst. Mauris malesuada tempus nibh, porta accumsan tortor tincidunt eu. Proin orci mauris, commodo id malesuada nec, adipiscing ut sapien. Phasellus at dui vel nisi adipiscing auctor quis vel sem. Phasellus fermentum, enim id sodales ullamcorper, magna sapien facilisis urna, ac lobortis nunc augue ut ligula. Quisque vulputate nibh sed velit pharetra dictum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque mi metus, vestibulum vitae dapibus vel, ultrices at tellus. Vivamus iaculis dui a nisl faucibus eget congue velit gravida. Donec vel quam ligula. Nam magna ante, vulputate id pharetra ac, dapibus commodo velit. Cras nisl nulla, congue sit amet laoreet eget, cursus et lorem. Mauris diam tortor, porttitor vitae fringilla id, iaculis sit amet eros. Donec sed enim eget felis fermentum posuere. Pellentesque sodales feugiat dolor, vel molestie est adipiscing non. Morbi tincidunt viverra felis ut hendrerit.\\f2\\fs22\\par\n}\n\u0000", "file_path": "scripts/windows/installer/WiXInstaller/Resources/License.rtf", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.0001654944207984954, 0.0001654944207984954, 0.0001654944207984954, 0.0001654944207984954, 0.0]}
{"hunk": {"id": 5, "code_window": [" var self = this;\n", "\n", " if (self.platform === \"win32\") {\n", " // XXX wipeAllPackages won't work on Windows until we fix that function\n", " isopack.saveToPath(self.packagePath(packageName, isopack.version));\n", " } else {\n", " // Note: wipeAllPackages depends on this filename structure\n", " // On Mac and Linux, we used to use a filename structure that used the\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [], "file_path": "tools/tropohouse.js", "type": "replace", "edit_start_line_idx": 327}, "file": ".build*\n", "file_path": "packages/html-tools/.gitignore", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.0001732491800794378, 0.0001732491800794378, 0.0001732491800794378, 0.0001732491800794378, 0.0]}
{"hunk": {"id": 5, "code_window": [" var self = this;\n", "\n", " if (self.platform === \"win32\") {\n", " // XXX wipeAllPackages won't work on Windows until we fix that function\n", " isopack.saveToPath(self.packagePath(packageName, isopack.version));\n", " } else {\n", " // Note: wipeAllPackages depends on this filename structure\n", " // On Mac and Linux, we used to use a filename structure that used the\n"], "labels": ["keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep"], "after_edit": [], "file_path": "tools/tropohouse.js", "type": "replace", "edit_start_line_idx": 327}, "file": "32t5gt1m39x2tmc1zkd", "file_path": "tools/tests/apps/package-tests/.meteor/identifier", "label": 0, "commit_url": "https://github.com/meteor/meteor/commit/d9cc95531ba9495cb9b18f53569a5175d64523e4", "dependency_score": [0.00016583262186031789, 0.00016583262186031789, 0.00016583262186031789, 0.00016583262186031789, 0.0]}
{"hunk": {"id": 0, "code_window": ["// Display no toolbar\n", "const char kNoToolbar[] = \"no-toolbar\";\n", "\n", "// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n"], "labels": ["keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n"], "file_path": "src/common/shell_switches.cc", "type": "add", "edit_start_line_idx": 45}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/shell_content_browser_client.h\"\n\n#include \"base/command_line.h\"\n#include \"base/file_path.h\"\n#include \"content/public/common/content_switches.h\"\n#include \"content/public/browser/browser_url_handler.h\"\n#include \"content/public/browser/resource_dispatcher_host.h\"\n#include \"content/nw/src/browser/shell_devtools_delegate.h\"\n#include \"content/nw/src/browser/shell_resource_dispatcher_host_delegate.h\"\n#include \"content/nw/src/common/shell_switches.h\"\n#include \"content/nw/src/media/media_internals.h\"\n#include \"content/nw/src/shell.h\"\n#include \"content/nw/src/shell_browser_context.h\"\n#include \"content/nw/src/shell_browser_main_parts.h\"\n#include \"content/nw/src/nw_package.h\"\n#include \"geolocation/shell_access_token_store.h\"\n#include \"googleurl/src/gurl.h\"\n#include \"ui/base/l10n/l10n_util.h\"\n\n#if defined(OS_ANDROID)\n#include \"base/android/path_utils.h\"\n#include \"base/path_service.h\"\n#include \"base/platform_file.h\"\n#include \"content/shell/android/shell_descriptors.h\"\n#endif\n\nnamespace content {\n\nShellContentBrowserClient::ShellContentBrowserClient()\n : shell_browser_main_parts_(NULL) {\n}\n\nShellContentBrowserClient::~ShellContentBrowserClient() {\n}\n\nBrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(\n const MainFunctionParams& parameters) {\n shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);\n return shell_browser_main_parts_;\n}\n\nvoid ShellContentBrowserClient::RenderViewHostCreated(\n RenderViewHost* render_view_host) {\n}\n\nvoid ShellContentBrowserClient::AppendExtraCommandLineSwitches(\n CommandLine* command_line, int child_process_id) {\n // Disable web security\n command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);\n command_line->AppendSwitch(switches::kDisableWebSecurity);\n\n if (nw::GetManifest() && nw::GetUseNode())\n command_line->AppendSwitch(switches::kmNodejs);\n}\n\nstd::string ShellContentBrowserClient::GetApplicationLocale() {\n return l10n_util::GetApplicationLocale(\"en-US\");\n}\n\nvoid ShellContentBrowserClient::ResourceDispatcherHostCreated() {\n resource_dispatcher_host_delegate_.reset(\n new ShellResourceDispatcherHostDelegate());\n ResourceDispatcherHost::Get()->SetDelegate(\n resource_dispatcher_host_delegate_.get());\n}\n\nstd::string ShellContentBrowserClient::GetDefaultDownloadName() {\n return \"download\";\n}\n\nMediaObserver* ShellContentBrowserClient::GetMediaObserver() {\n return MediaInternals::GetInstance();\n}\n\nvoid ShellContentBrowserClient::BrowserURLHandlerCreated(\n BrowserURLHandler* handler) {\n}\n\n#if defined(OS_ANDROID)\nvoid ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(\n const CommandLine& command_line,\n base::GlobalDescriptors::Mapping* mappings) {\n int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;\n FilePath pak_file;\n DCHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file));\n pak_file = pak_file.Append(FILE_PATH_LITERAL(\"paks\"));\n pak_file = pak_file.Append(FILE_PATH_LITERAL(\"nw.pak\"));\n\n base::PlatformFile f =\n base::CreatePlatformFile(pak_file, flags, NULL, NULL);\n if (f == base::kInvalidPlatformFileValue) {\n NOTREACHED() << \"Failed to open file when creating renderer process: \"\n << \"nw.pak\";\n }\n mappings->push_back(std::pair(\n kShellPakDescriptor, f));\n}\n#endif\n\nShellBrowserContext* ShellContentBrowserClient::browser_context() {\n return shell_browser_main_parts_->browser_context();\n}\n\nShellBrowserContext*\n ShellContentBrowserClient::off_the_record_browser_context() {\n return shell_browser_main_parts_->off_the_record_browser_context();\n}\n\nAccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() {\n return new ShellAccessTokenStore(browser_context()->GetRequestContext());\n}\n\n} // namespace content\n", "file_path": "src/shell_content_browser_client.cc", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017610924260225147, 0.00017017223581206053, 0.00016562749806325883, 0.00016891604172997177, 3.3102553516073385e-06]}
{"hunk": {"id": 0, "code_window": ["// Display no toolbar\n", "const char kNoToolbar[] = \"no-toolbar\";\n", "\n", "// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n"], "labels": ["keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n"], "file_path": "src/common/shell_switches.cc", "type": "add", "edit_start_line_idx": 45}, "file": "// Copyright (c) 2012 Roger Wang \n// Zhao Cheng \n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#ifndef NW_VERSION_H\n#define NW_VERSION_H\n\n#define NW_MAJOR_VERSION 0\n#define NW_MINOR_VERSION 2\n#define NW_PATCH_VERSION 6\n#define NW_VERSION_IS_RELEASE 0\n\n#ifndef NW_STRINGIFY\n#define NW_STRINGIFY(n) NW_STRINGIFY_HELPER(n)\n#define NW_STRINGIFY_HELPER(n) #n\n#endif\n\n#if NW_VERSION_IS_RELEASE\n# define NW_VERSION_STRING NW_STRINGIFY(NW_MAJOR_VERSION) \".\" \\\n NW_STRINGIFY(NW_MINOR_VERSION) \".\" \\\n NW_STRINGIFY(NW_PATCH_VERSION)\n#else\n# define NW_VERSION_STRING NW_STRINGIFY(NW_MAJOR_VERSION) \".\" \\\n NW_STRINGIFY(NW_MINOR_VERSION) \".\" \\\n NW_STRINGIFY(NW_PATCH_VERSION) \"-pre\"\n#endif\n\n#define NW_VERSION \"v\" NW_VERSION_STRING\n\n\n#define NW_VERSION_AT_LEAST(major, minor, patch) \\\n (( (major) < NW_MAJOR_VERSION) \\\n || ((major) == NW_MAJOR_VERSION && (minor) < NW_MINOR_VERSION) \\\n || ((major) == NW_MAJOR_VERSION && (minor) == NW_MINOR_VERSION && (patch) <= NW_PATCH_VERSION))\n\n#endif /* NW_VERSION_H */\n", "file_path": "src/nw_version.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0003685752453748137, 0.00020323546777945012, 0.00016340547881554812, 0.0001732881646603346, 7.40614632377401e-05]}
{"hunk": {"id": 0, "code_window": ["// Display no toolbar\n", "const char kNoToolbar[] = \"no-toolbar\";\n", "\n", "// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n"], "labels": ["keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n"], "file_path": "src/common/shell_switches.cc", "type": "add", "edit_start_line_idx": 45}, "file": "// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#ifndef CHROME_COMMON_ZIP_INTERNAL_H_\n#define CHROME_COMMON_ZIP_INTERNAL_H_\n\n#include \n\n#include \"third_party/zlib/contrib/minizip/unzip.h\"\n#include \"third_party/zlib/contrib/minizip/zip.h\"\n\n// Utility functions and constants used internally for the zip file\n// library in the directory. Don't use them outside of the library.\nnamespace zip {\nnamespace internal {\n\n// Opens the given file name in UTF-8 for unzipping, with some setup for\n// Windows.\nunzFile OpenForUnzipping(const std::string& file_name_utf8);\n\n#if defined(OS_POSIX)\n// Opens the file referred to by |zip_fd| for unzipping.\nunzFile OpenFdForUnzipping(int zip_fd);\n#endif\n\n// Opens the given file name in UTF-8 for zipping, with some setup for\n// Windows. |append_flag| will be passed to zipOpen2().\nzipFile OpenForZipping(const std::string& file_name_utf8, int append_flag);\n\nconst int kZipMaxPath = 256;\nconst int kZipBufSize = 8192;\n\n} // namespace internal\n} // namespace zip\n\n#endif // CHROME_COMMON_ZIP_INTERNAL_H_\n", "file_path": "src/common/zip_internal.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0002442144032102078, 0.0001887475955300033, 0.0001654311636229977, 0.00017267241491936147, 3.223183375666849e-05]}
{"hunk": {"id": 0, "code_window": ["// Display no toolbar\n", "const char kNoToolbar[] = \"no-toolbar\";\n", "\n", "// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n"], "labels": ["keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n"], "file_path": "src/common/shell_switches.cc", "type": "add", "edit_start_line_idx": 45}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/api/menu/menu.h\"\n\n#import \n#include \"content/nw/src/api/menuitem/menuitem.h\"\n\nnamespace api {\n\nusing namespace v8;\n\nMenu::Menu(CreationOption option) {\n menu_ = [[NSMenu alloc]\n initWithTitle:[NSString stringWithUTF8String:option.title.c_str()]];\n [menu_ setAutoenablesItems:NO];\n}\n\nMenu::~Menu() {\n [menu_ release];\n}\n\nvoid Menu::SetTitle(const std::string& title) {\n [menu_ setTitle:[NSString stringWithUTF8String:title.c_str()]];\n}\n\nstd::string Menu::GetTitle() {\n return [[menu_ title] UTF8String];\n}\n\nvoid Menu::Append(MenuItem* menu_item) {\n [menu_ addItem:menu_item->menu_item_];\n}\n\nvoid Menu::Insert(MenuItem* menu_item, int pos) {\n [menu_ insertItem:menu_item->menu_item_ atIndex:pos];\n}\n\nvoid Menu::Remove(MenuItem* menu_item) {\n [menu_ removeItem:menu_item->menu_item_];\n}\n\nvoid Menu::Remove(int pos) {\n [menu_ removeItemAtIndex:pos];\n}\n\n} // namespace api\n", "file_path": "src/api/menu/menu_mac.mm", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017610924260225147, 0.00017172984371427447, 0.00016770567162893713, 0.00017239080625586212, 3.3991746022365987e-06]}
{"hunk": {"id": 1, "code_window": ["// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n", "// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n", "const char kmMain[] = \"main\";\n", "const char kmName[] = \"name\";\n", "const char kmWebkit[] = \"webkit\";\n", "const char kmNodejs[] = \"nodejs\";\n"], "labels": ["keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": ["// Set current working directory\n", "const char kWorkingDirectory[] = \"working-directory\";\n"], "file_path": "src/common/shell_switches.cc", "type": "replace", "edit_start_line_idx": 48}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/common/shell_switches.h\"\n\nnamespace switches {\n\n// Check whether all system dependencies for running layout tests are met.\nconst char kCheckLayoutTestSysDeps[] = \"check-layout-test-sys-deps\";\n\n// Tells Content Shell that it's running as a content_browsertest.\nconst char kContentBrowserTest[] = \"browser-test\";\n\n// Makes Content Shell use the given path for its data directory.\nconst char kContentShellDataPath[] = \"data-path\";\n\n// Enable developer tools\nconst char kDeveloper[] = \"developer\";\n\n// Request pages to be dumped as text once they finished loading.\nconst char kDumpRenderTree[] = \"dump-render-tree\";\n\n// Disables the timeout for layout tests.\nconst char kNoTimeout[] = \"no-timeout\";\n\n// Display no toolbar\nconst char kNoToolbar[] = \"no-toolbar\";\n\n// Show version and quit\nconst char kVersion[] = \"version\";\n\n// Open specified url\nconst char kUrl[] = \"url\";\n\nconst char kmMain[] = \"main\";\nconst char kmName[] = \"name\";\nconst char kmWebkit[] = \"webkit\";\nconst char kmNodejs[] = \"nodejs\";\nconst char kmRoot[] = \"root\";\nconst char kmWindow[] = \"window\";\nconst char kmTitle[] = \"title\";\nconst char kmToolbar[] = \"toolbar\";\nconst char kmIcon[] = \"icon\";\nconst char kmWidth[] = \"width\";\nconst char kmHeight[] = \"height\";\nconst char kmX[] = \"x\";\nconst char kmY[] = \"y\";\nconst char kmResizable[] = \"resizable\";\nconst char kmPosition[] = \"position\";\nconst char kmMinWidth[] = \"min_width\";\nconst char kmMinHeight[] = \"min_height\";\nconst char kmMaxWidth[] = \"max_width\";\nconst char kmMaxHeight[] = \"max_height\";\nconst char kmAsDesktop[] = \"as_desktop\";\n\n} // namespace switches\n", "file_path": "src/common/shell_switches.cc", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.9981426000595093, 0.2515798807144165, 0.00017437830683775246, 0.0033469132613390684, 0.43087849020957947]}
{"hunk": {"id": 1, "code_window": ["// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n", "// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n", "const char kmMain[] = \"main\";\n", "const char kmName[] = \"name\";\n", "const char kmWebkit[] = \"webkit\";\n", "const char kmNodejs[] = \"nodejs\";\n"], "labels": ["keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": ["// Set current working directory\n", "const char kWorkingDirectory[] = \"working-directory\";\n"], "file_path": "src/common/shell_switches.cc", "type": "replace", "edit_start_line_idx": 48}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/shell_browser_main_parts.h\"\n\n#include \"base/bind.h\"\n#include \"base/command_line.h\"\n#include \"base/message_loop.h\"\n#include \"base/string_number_conversions.h\"\n#include \"base/threading/thread.h\"\n#include \"base/threading/thread_restrictions.h\"\n#include \"content/nw/src/browser/shell_devtools_delegate.h\"\n#include \"content/nw/src/common/shell_switches.h\"\n#include \"content/nw/src/nw_package.h\"\n#include \"content/nw/src/shell.h\"\n#include \"content/nw/src/shell_browser_context.h\"\n#include \"content/public/common/content_switches.h\"\n#include \"content/public/common/main_function_params.h\"\n#include \"content/public/common/url_constants.h\"\n#include \"googleurl/src/gurl.h\"\n#include \"grit/net_resources.h\"\n#include \"net/base/net_module.h\"\n#include \"ui/base/resource/resource_bundle.h\"\n\n#if defined(OS_ANDROID)\n#include \"net/base/network_change_notifier.h\"\n#include \"net/android/network_change_notifier_factory.h\"\n#endif\n\nnamespace content {\n\nnamespace {\n\nbase::StringPiece PlatformResourceProvider(int key) {\n if (key == IDR_DIR_HEADER_HTML) {\n base::StringPiece html_data =\n ui::ResourceBundle::GetSharedInstance().GetRawDataResource(\n IDR_DIR_HEADER_HTML, ui::SCALE_FACTOR_NONE);\n return html_data;\n }\n return base::StringPiece();\n}\n\n} // namespace\n\nShellBrowserMainParts::ShellBrowserMainParts(\n const MainFunctionParams& parameters)\n : BrowserMainParts(),\n parameters_(parameters),\n run_message_loop_(true),\n devtools_delegate_(NULL) {\n}\n\nShellBrowserMainParts::~ShellBrowserMainParts() {\n}\n\n#if !defined(OS_MACOSX)\nvoid ShellBrowserMainParts::PreMainMessageLoopStart() {\n}\n#endif\n\nvoid ShellBrowserMainParts::PostMainMessageLoopStart() {\n#if defined(OS_ANDROID)\n MessageLoopForUI::current()->Start();\n#endif\n}\n\nvoid ShellBrowserMainParts::PreEarlyInitialization() {\n#if defined(OS_ANDROID)\n net::NetworkChangeNotifier::SetFactory(\n new net::android::NetworkChangeNotifierFactory());\n#endif\n}\n\nvoid ShellBrowserMainParts::PreMainMessageLoopRun() {\n#if !defined(OS_MACOSX)\n Init();\n#endif\n\n if (parameters_.ui_task) {\n parameters_.ui_task->Run();\n delete parameters_.ui_task;\n run_message_loop_ = false;\n }\n}\n\nbool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {\n return !run_message_loop_;\n}\n\nvoid ShellBrowserMainParts::PostMainMessageLoopRun() {\n#if defined(USE_AURA)\n Shell::PlatformExit();\n#endif\n if (devtools_delegate_)\n devtools_delegate_->Stop();\n browser_context_.reset();\n off_the_record_browser_context_.reset();\n}\n\nvoid ShellBrowserMainParts::Init() {\n nw::InitPackageForceNoEmpty();\n\n browser_context_.reset(new ShellBrowserContext(false));\n off_the_record_browser_context_.reset(new ShellBrowserContext(true));\n\n Shell::PlatformInitialize();\n net::NetModule::SetResourceProvider(PlatformResourceProvider);\n\n int port = 0;\n// On android the port number isn't used.\n#if !defined(OS_ANDROID)\n // See if the user specified a port on the command line (useful for\n // automation). If not, use an ephemeral port by specifying 0.\n const CommandLine& command_line = *CommandLine::ForCurrentProcess();\n if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {\n int temp_port;\n std::string port_str =\n command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);\n if (base::StringToInt(port_str, &temp_port) &&\n temp_port > 0 && temp_port < 65535) {\n port = temp_port;\n } else {\n DLOG(WARNING) << \"Invalid http debugger port number \" << temp_port;\n }\n }\n#endif\n devtools_delegate_ = new ShellDevToolsDelegate(\n port, browser_context_->GetRequestContext());\n\n Shell::CreateNewWindow(browser_context_.get(),\n nw::GetStartupURL(),\n NULL,\n MSG_ROUTING_NONE,\n NULL);\n}\n\n} // namespace\n", "file_path": "src/shell_browser_main_parts.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0002706618106458336, 0.00018350158643443137, 0.0001660943526076153, 0.00017232162645086646, 3.0919723940314725e-05]}
{"hunk": {"id": 1, "code_window": ["// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n", "// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n", "const char kmMain[] = \"main\";\n", "const char kmName[] = \"name\";\n", "const char kmWebkit[] = \"webkit\";\n", "const char kmNodejs[] = \"nodejs\";\n"], "labels": ["keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": ["// Set current working directory\n", "const char kWorkingDirectory[] = \"working-directory\";\n"], "file_path": "src/common/shell_switches.cc", "type": "replace", "edit_start_line_idx": 48}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/shell.h\"\n\n#include \"base/auto_reset.h\"\n#include \"base/command_line.h\"\n#include \"base/message_loop.h\"\n#include \"base/path_service.h\"\n#include \"base/string_number_conversions.h\"\n#include \"base/string_util.h\"\n#include \"base/utf_string_conversions.h\"\n#include \"base/values.h\"\n#include \"content/public/browser/devtools_http_handler.h\"\n#include \"content/public/browser/navigation_entry.h\"\n#include \"content/public/browser/navigation_controller.h\"\n#include \"content/public/browser/notification_details.h\"\n#include \"content/public/browser/notification_source.h\"\n#include \"content/public/browser/notification_types.h\"\n#include \"content/public/browser/render_view_host.h\"\n#include \"content/public/browser/web_contents.h\"\n#include \"content/nw/src/browser/file_select_helper.h\"\n#include \"content/nw/src/browser/shell_devtools_delegate.h\"\n#include \"content/nw/src/browser/shell_javascript_dialog_creator.h\"\n#include \"content/nw/src/common/shell_switches.h\"\n#include \"content/nw/src/media/media_stream_devices_controller.h\"\n#include \"content/nw/src/nw_package.h\"\n#include \"content/nw/src/shell_browser_main_parts.h\"\n#include \"content/nw/src/shell_content_browser_client.h\"\n#include \"ui/gfx/size.h\"\n\nnamespace content {\n\nstd::vector Shell::windows_;\nbase::Callback Shell::shell_created_callback_;\n\nbool Shell::quit_message_loop_ = true;\n\nShell::Shell(WebContents* web_contents, base::DictionaryValue* manifest)\n : window_(NULL),\n url_edit_view_(NULL),\n window_manifest_(manifest),\n is_show_devtools_(false),\n is_toolbar_open_(true),\n max_height_(-1),\n max_width_(-1),\n min_height_(-1),\n min_width_(-1)\n#if defined(OS_WIN) && !defined(USE_AURA)\n , default_edit_wnd_proc_(0)\n#endif\n {\n if (window_manifest_) {\n window_manifest_->GetBoolean(switches::kmToolbar, &is_toolbar_open_);\n window_manifest_->GetBoolean(switches::kDeveloper, &is_show_devtools_);\n window_manifest_->GetInteger(switches::kmMaxHeight, &max_height_);\n window_manifest_->GetInteger(switches::kmMaxWidth, &max_width_);\n window_manifest_->GetInteger(switches::kmMinHeight, &min_height_);\n window_manifest_->GetInteger(switches::kmMinWidth, &min_width_);\n }\n\n registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,\n Source(web_contents));\n windows_.push_back(this);\n\n if (!shell_created_callback_.is_null()) {\n shell_created_callback_.Run(this);\n shell_created_callback_.Reset();\n }\n}\n\nShell::~Shell() {\n PlatformCleanUp();\n\n for (size_t i = 0; i < windows_.size(); ++i) {\n if (windows_[i] == this) {\n windows_.erase(windows_.begin() + i);\n break;\n }\n }\n\n if (windows_.empty() && quit_message_loop_)\n MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());\n}\n\nShell* Shell::CreateShell(WebContents* web_contents,\n base::DictionaryValue* manifest) {\n int width = 700;\n int height = 450;\n manifest->GetInteger(switches::kmWidth, &width);\n manifest->GetInteger(switches::kmHeight, &height);\n\n Shell* shell = new Shell(web_contents, manifest);\n shell->PlatformCreateWindow(width, height);\n\n shell->web_contents_.reset(web_contents);\n web_contents->SetDelegate(shell);\n\n shell->PlatformSetContents();\n\n shell->PlatformResizeSubViews();\n return shell;\n}\n\nvoid Shell::CloseAllWindows() {\n AutoReset auto_reset(&quit_message_loop_, false);\n std::vector open_windows(windows_);\n for (size_t i = 0; i < open_windows.size(); ++i)\n open_windows[i]->Close();\n MessageLoop::current()->RunAllPending();\n}\n\nvoid Shell::SetShellCreatedCallback(\n base::Callback shell_created_callback) {\n DCHECK(shell_created_callback_.is_null());\n shell_created_callback_ = shell_created_callback;\n}\n\nShell* Shell::FromRenderViewHost(RenderViewHost* rvh) {\n for (size_t i = 0; i < windows_.size(); ++i) {\n if (windows_[i]->web_contents() &&\n windows_[i]->web_contents()->GetRenderViewHost() == rvh) {\n return windows_[i];\n }\n }\n return NULL;\n}\n\nShell* Shell::CreateNewWindow(BrowserContext* browser_context,\n const GURL& url,\n SiteInstance* site_instance,\n int routing_id,\n WebContents* base_web_contents) {\n WebContents* web_contents = WebContents::Create(\n browser_context,\n site_instance,\n routing_id,\n base_web_contents);\n\n // Create with package's manifest\n base::DictionaryValue *manifest = NULL;\n nw::GetManifest()->GetDictionary(switches::kmWindow, &manifest);\n manifest->SetBoolean(switches::kDeveloper,\n CommandLine::ForCurrentProcess()->HasSwitch(switches::kDeveloper));\n\n // Center window by default\n if (!manifest->HasKey(switches::kmPosition))\n manifest->SetString(switches::kmPosition, \"center\");\n\n Shell* shell = CreateShell(web_contents, manifest);\n if (!url.is_empty())\n shell->LoadURL(url);\n return shell;\n}\n\nvoid Shell::LoadURL(const GURL& url) {\n web_contents_->GetController().LoadURL(\n url,\n Referrer(),\n PAGE_TRANSITION_TYPED,\n std::string());\n web_contents_->Focus();\n}\n\nvoid Shell::GoBackOrForward(int offset) {\n web_contents_->GetController().GoToOffset(offset);\n web_contents_->Focus();\n}\n\nvoid Shell::Reload() {\n web_contents_->GetController().Reload(false);\n web_contents_->Focus();\n}\n\nvoid Shell::Stop() {\n web_contents_->Stop();\n web_contents_->Focus();\n}\n\nvoid Shell::UpdateNavigationControls() {\n int current_index = web_contents_->GetController().GetCurrentEntryIndex();\n int max_index = web_contents_->GetController().GetEntryCount() - 1;\n\n PlatformEnableUIControl(BACK_BUTTON, current_index > 0);\n PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);\n PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading());\n}\n\nvoid Shell::ShowDevTools() {\n ShellContentBrowserClient* browser_client =\n static_cast(\n GetContentClient()->browser());\n ShellDevToolsDelegate* delegate =\n browser_client->shell_browser_main_parts()->devtools_delegate();\n GURL url = delegate->devtools_http_handler()->GetFrontendURL(\n web_contents()->GetRenderViewHost());\n\n // Use our minimum set manifest\n base::DictionaryValue manifest;\n manifest.SetBoolean(switches::kmToolbar, false);\n manifest.SetBoolean(switches::kDeveloper, true);\n manifest.SetInteger(switches::kmWidth, 600);\n manifest.SetInteger(switches::kmHeight, 500);\n\n Shell* shell = CreateShell(\n WebContents::Create(web_contents()->GetBrowserContext(),\n NULL, MSG_ROUTING_NONE, NULL),\n &manifest);\n shell->LoadURL(url);\n}\n\ngfx::NativeView Shell::GetContentView() {\n if (!web_contents_.get())\n return NULL;\n return web_contents_->GetNativeView();\n}\n\nWebContents* Shell::OpenURLFromTab(WebContents* source,\n const OpenURLParams& params) {\n // The only one we implement for now.\n DCHECK(params.disposition == CURRENT_TAB);\n source->GetController().LoadURL(\n params.url, params.referrer, params.transition, std::string());\n return source;\n}\n\nvoid Shell::LoadingStateChanged(WebContents* source) {\n UpdateNavigationControls();\n PlatformSetIsLoading(source->IsLoading());\n}\n\nvoid Shell::ActivateContents(content::WebContents* contents) {\n LOG(ERROR) << \"activate\";\n}\n\nvoid Shell::DeactivateContents(content::WebContents* contents) {\n LOG(ERROR) << \"deactivate\";\n}\n\nvoid Shell::CloseContents(WebContents* source) {\n Close();\n}\n\nvoid Shell::MoveContents(WebContents* source, const gfx::Rect& pos) {\n Move(pos);\n}\n\nbool Shell::IsPopupOrPanel(const WebContents* source) const {\n // Treat very window as popup so we can use window operations\n return true;\n}\n\nbool Shell::TakeFocus(WebContents* soruce,\n bool reverse) {\n return true;\n}\n\nvoid Shell::LostCapture() {\n}\n\nvoid Shell::WebContentsFocused(WebContents* contents) {\n}\n\nvoid Shell::WebContentsCreated(WebContents* source_contents,\n int64 source_frame_id,\n const GURL& target_url,\n WebContents* new_contents) {\n // Create with package's manifest\n base::DictionaryValue *manifest = NULL;\n nw::GetManifest()->GetDictionary(switches::kmWindow, &manifest);\n manifest->SetBoolean(switches::kDeveloper,\n CommandLine::ForCurrentProcess()->HasSwitch(switches::kDeveloper));\n\n // Get window features\n WebKit::WebWindowFeatures features = new_contents->GetWindowFeatures();\n if (features.widthSet)\n manifest->SetInteger(switches::kmWidth, features.width);\n if (features.heightSet)\n manifest->SetInteger(switches::kmHeight, features.height);\n if (features.xSet)\n manifest->SetInteger(switches::kmX, features.x);\n if (features.ySet)\n manifest->SetInteger(switches::kmY, features.y);\n\n CreateShell(new_contents, manifest);\n}\n\nvoid Shell::RunFileChooser(WebContents* web_contents,\n const content::FileChooserParams& params) {\n FileSelectHelper::RunFileChooser(web_contents, params);\n}\n\nvoid Shell::EnumerateDirectory(WebContents* web_contents,\n int request_id,\n const FilePath& path) {\n FileSelectHelper::EnumerateDirectory(web_contents, request_id, path);\n}\n\nvoid Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) {\n PlatformSetAddressBarURL(web_contents->GetURL());\n}\n\nJavaScriptDialogCreator* Shell::GetJavaScriptDialogCreator() {\n if (!dialog_creator_.get())\n dialog_creator_.reset(new ShellJavaScriptDialogCreator());\n return dialog_creator_.get();\n}\n\nbool Shell::AddMessageToConsole(WebContents* source,\n int32 level,\n const string16& message,\n int32 line_no,\n const string16& source_id) {\n return false;\n}\n\n\nvoid Shell::RequestMediaAccessPermission(\n content::WebContents* web_contents,\n const content::MediaStreamRequest* request,\n const content::MediaResponseCallback& callback) {\n scoped_ptr\n controller(new MediaStreamDevicesController(request,\n callback));\n controller->DismissInfoBarAndTakeActionOnSettings();\n}\n\nvoid Shell::Observe(int type,\n const NotificationSource& source,\n const NotificationDetails& details) {\n if (type == NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {\n std::pair* title =\n Details >(details).ptr();\n\n if (title->first) {\n string16 text = title->first->GetTitle();\n PlatformSetTitle(text);\n }\n }\n}\n\n} // namespace content\n", "file_path": "src/shell.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.7123246192932129, 0.020841671153903008, 0.0001647369790589437, 0.00017289405514020473, 0.11692409217357635]}
{"hunk": {"id": 1, "code_window": ["// Show version and quit\n", "const char kVersion[] = \"version\";\n", "\n", "// Open specified url\n", "const char kUrl[] = \"url\";\n", "\n", "const char kmMain[] = \"main\";\n", "const char kmName[] = \"name\";\n", "const char kmWebkit[] = \"webkit\";\n", "const char kmNodejs[] = \"nodejs\";\n"], "labels": ["keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep"], "after_edit": ["// Set current working directory\n", "const char kWorkingDirectory[] = \"working-directory\";\n"], "file_path": "src/common/shell_switches.cc", "type": "replace", "edit_start_line_idx": 48}, "file": "\n
\n \n node-webkit versions\n
\n\n node-webkit v \n node.js v \n
\n\n", "file_path": "src/resources/nw_version.html", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017337048484478146, 0.00016978391795419157, 0.00016619733651168644, 0.00016978391795419157, 3.586574166547507e-06]}
{"hunk": {"id": 2, "code_window": ["extern const char kDeveloper[];\n", "extern const char kDumpRenderTree[];\n", "extern const char kNoTimeout[];\n", "extern const char kNoToolbar[];\n", "extern const char kVersion[];\n", "extern const char kUrl[];\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep"], "after_edit": [], "file_path": "src/common/shell_switches.h", "type": "replace", "edit_start_line_idx": 18}, "file": "// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n// Defines all the \"content_shell\" command-line switches.\n\n#ifndef CONTENT_NW_SRC_SHELL_SWITCHES_H_\n#define CONTENT_NW_SRC_SHELL_SWITCHES_H_\n\nnamespace switches {\n\nextern const char kCheckLayoutTestSysDeps[];\nextern const char kContentBrowserTest[];\nextern const char kContentShellDataPath[];\nextern const char kDeveloper[];\nextern const char kDumpRenderTree[];\nextern const char kNoTimeout[];\nextern const char kNoToolbar[];\nextern const char kVersion[];\nextern const char kUrl[];\n\n// Manifest settings\nextern const char kmMain[];\nextern const char kmName[];\nextern const char kmWebkit[];\nextern const char kmNodejs[];\nextern const char kmRoot[];\nextern const char kmWindow[];\nextern const char kmTitle[];\nextern const char kmToolbar[];\nextern const char kmIcon[];\nextern const char kmWidth[];\nextern const char kmHeight[];\nextern const char kmX[];\nextern const char kmY[];\nextern const char kmResizable[];\nextern const char kmPosition[];\nextern const char kmMinWidth[];\nextern const char kmMinHeight[];\nextern const char kmMaxWidth[];\nextern const char kmMaxHeight[];\nextern const char kmAsDesktop[];\n\n} // namespace switches\n\n#endif // CONTENT_NW_SRC_SHELL_SWITCHES_H_\n", "file_path": "src/common/shell_switches.h", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.9980276226997375, 0.19996467232704163, 0.00016918990877456963, 0.00024237397883553058, 0.3990316689014435]}
{"hunk": {"id": 2, "code_window": ["extern const char kDeveloper[];\n", "extern const char kDumpRenderTree[];\n", "extern const char kNoTimeout[];\n", "extern const char kNoToolbar[];\n", "extern const char kVersion[];\n", "extern const char kUrl[];\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep"], "after_edit": [], "file_path": "src/common/shell_switches.h", "type": "replace", "edit_start_line_idx": 18}, "file": "// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#ifndef CONTENT_SHELL_SHELL_BROWSER_MAIN_H_\n#define CONTENT_SHELL_SHELL_BROWSER_MAIN_H_\n\nnamespace content {\nstruct MainFunctionParams;\n}\n\nint ShellBrowserMain(const content::MainFunctionParams& parameters);\n\n#endif // CONTENT_SHELL_SHELL_BROWSER_MAIN_H_\n", "file_path": "src/shell_browser_main.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00016890476399566978, 0.00016845838399603963, 0.00016801200399640948, 0.00016845838399603963, 4.463799996301532e-07]}
{"hunk": {"id": 2, "code_window": ["extern const char kDeveloper[];\n", "extern const char kDumpRenderTree[];\n", "extern const char kNoTimeout[];\n", "extern const char kNoToolbar[];\n", "extern const char kVersion[];\n", "extern const char kUrl[];\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep"], "after_edit": [], "file_path": "src/common/shell_switches.h", "type": "replace", "edit_start_line_idx": 18}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/browser/shell_login_dialog.h\"\n\n#include \n\n#include \"base/logging.h\"\n#include \"base/string16.h\"\n#include \"base/utf_string_conversions.h\"\n#include \"content/public/browser/browser_thread.h\"\n#include \"content/public/browser/render_view_host.h\"\n#include \"content/public/browser/resource_dispatcher_host.h\"\n#include \"content/public/browser/resource_request_info.h\"\n#include \"content/public/browser/web_contents.h\"\n#include \"content/public/browser/web_contents_view.h\"\n#include \"ui/base/gtk/gtk_hig_constants.h\"\n\nnamespace content {\n\nvoid ShellLoginDialog::PlatformCreateDialog(const string16& message) {\n DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n\n int render_process_id;\n int render_view_id;\n if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderView(\n &render_process_id, &render_view_id)) {\n NOTREACHED();\n }\n\n WebContents* web_contents = NULL;\n RenderViewHost* render_view_host =\n RenderViewHost::FromID(render_process_id, render_view_id);\n if (render_view_host)\n web_contents = WebContents::FromRenderViewHost(render_view_host);\n DCHECK(web_contents);\n\n gfx::NativeWindow parent_window =\n web_contents->GetView()->GetTopLevelNativeWindow();\n\n root_ = gtk_message_dialog_new(parent_window,\n GTK_DIALOG_MODAL,\n GTK_MESSAGE_INFO,\n GTK_BUTTONS_OK_CANCEL,\n \"Please log in.\");\n\n GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(root_));\n GtkWidget* label = gtk_label_new(UTF16ToUTF8(message).c_str());\n gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);\n gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);\n\n username_entry_ = gtk_entry_new();\n gtk_entry_set_activates_default(GTK_ENTRY(username_entry_), TRUE);\n\n password_entry_ = gtk_entry_new();\n gtk_entry_set_activates_default(GTK_ENTRY(password_entry_), TRUE);\n gtk_entry_set_visibility(GTK_ENTRY(password_entry_), FALSE);\n\n GtkWidget* table = gtk_table_new(2, 2, FALSE);\n gtk_table_set_col_spacing(GTK_TABLE(table), 0, ui::kLabelSpacing);\n gtk_table_set_row_spacings(GTK_TABLE(table), ui::kControlSpacing);\n\n GtkWidget* username_label = gtk_label_new(\"Username:\");\n gtk_misc_set_alignment(GTK_MISC(username_label), 0, 0.5);\n\n gtk_table_attach(GTK_TABLE(table), username_label, 0, 1, 0, 1, GTK_FILL,\n GTK_FILL, 0, 0);\n gtk_table_attach_defaults(GTK_TABLE(table), username_entry_, 1, 2, 0, 1);\n\n GtkWidget* password_label = gtk_label_new(\"Password:\");\n gtk_misc_set_alignment(GTK_MISC(password_label), 0, 0.5);\n\n gtk_table_attach(GTK_TABLE(table), password_label, 0, 1, 1, 2, GTK_FILL,\n GTK_FILL, 0, 0);\n gtk_table_attach_defaults(GTK_TABLE(table), password_entry_, 1, 2, 1, 2);\n\n gtk_box_pack_start(GTK_BOX(content_area), table, FALSE, FALSE, 0);\n\n g_signal_connect(root_, \"response\", G_CALLBACK(OnResponseThunk), this);\n gtk_widget_grab_focus(username_entry_);\n gtk_widget_show_all(GTK_WIDGET(root_));\n}\n\nvoid ShellLoginDialog::PlatformCleanUp() {\n DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n}\n\nvoid ShellLoginDialog::PlatformRequestCancelled() {\n DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));\n}\n\nvoid ShellLoginDialog::OnResponse(GtkWidget* sender, int response_id) {\n switch (response_id) {\n case GTK_RESPONSE_OK:\n UserAcceptedAuth(\n UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(username_entry_))),\n UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(password_entry_))));\n break;\n case GTK_RESPONSE_CANCEL:\n case GTK_RESPONSE_DELETE_EVENT:\n UserCancelledAuth();\n break;\n default:\n NOTREACHED();\n }\n\n gtk_widget_destroy(root_);\n}\n\n} // namespace content\n", "file_path": "src/browser/shell_login_dialog_gtk.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017752325220499188, 0.00017306781955994666, 0.00016686982417013496, 0.0001727834460325539, 3.053085947612999e-06]}
{"hunk": {"id": 2, "code_window": ["extern const char kDeveloper[];\n", "extern const char kDumpRenderTree[];\n", "extern const char kNoTimeout[];\n", "extern const char kNoToolbar[];\n", "extern const char kVersion[];\n", "extern const char kUrl[];\n"], "labels": ["keep", "keep", "keep", "keep", "replace", "keep"], "after_edit": [], "file_path": "src/common/shell_switches.h", "type": "replace", "edit_start_line_idx": 18}, "file": "\n\n\n\n\tCFBundleDevelopmentRegion\n\ten\n\tCFBundleDisplayName\n\t${EXECUTABLE_NAME}\n\tCFBundleExecutable\n\t${EXECUTABLE_NAME}\n\tCFBundleIdentifier\n\tcom.intel.nw.helper\n\tCFBundleInfoDictionaryVersion\n\t6.0\n\tCFBundleName\n\t${PRODUCT_NAME}\n\tCFBundlePackageType\n\tAPPL\n\tCFBundleSignature\n\t????\n\tLSFileQuarantineEnabled\n\t\n\tLSMinimumSystemVersion\n\t${MACOSX_DEPLOYMENT_TARGET}.0\n\tLSUIElement\n\t1\n\tNSSupportsAutomaticGraphicsSwitching\n\t\n\n\n", "file_path": "src/mac/helper-Info.plist", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0001759649021551013, 0.00017109177133534104, 0.00016822264296934009, 0.00017008975555654615, 2.9945961159683065e-06]}
{"hunk": {"id": 3, "code_window": ["extern const char kUrl[];\n", "\n", "// Manifest settings\n", "extern const char kmMain[];\n", "extern const char kmName[];\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["extern const char kVersion[];\n", "extern const char kWorkingDirectory[];\n"], "file_path": "src/common/shell_switches.h", "type": "add", "edit_start_line_idx": 20}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/common/shell_switches.h\"\n\nnamespace switches {\n\n// Check whether all system dependencies for running layout tests are met.\nconst char kCheckLayoutTestSysDeps[] = \"check-layout-test-sys-deps\";\n\n// Tells Content Shell that it's running as a content_browsertest.\nconst char kContentBrowserTest[] = \"browser-test\";\n\n// Makes Content Shell use the given path for its data directory.\nconst char kContentShellDataPath[] = \"data-path\";\n\n// Enable developer tools\nconst char kDeveloper[] = \"developer\";\n\n// Request pages to be dumped as text once they finished loading.\nconst char kDumpRenderTree[] = \"dump-render-tree\";\n\n// Disables the timeout for layout tests.\nconst char kNoTimeout[] = \"no-timeout\";\n\n// Display no toolbar\nconst char kNoToolbar[] = \"no-toolbar\";\n\n// Show version and quit\nconst char kVersion[] = \"version\";\n\n// Open specified url\nconst char kUrl[] = \"url\";\n\nconst char kmMain[] = \"main\";\nconst char kmName[] = \"name\";\nconst char kmWebkit[] = \"webkit\";\nconst char kmNodejs[] = \"nodejs\";\nconst char kmRoot[] = \"root\";\nconst char kmWindow[] = \"window\";\nconst char kmTitle[] = \"title\";\nconst char kmToolbar[] = \"toolbar\";\nconst char kmIcon[] = \"icon\";\nconst char kmWidth[] = \"width\";\nconst char kmHeight[] = \"height\";\nconst char kmX[] = \"x\";\nconst char kmY[] = \"y\";\nconst char kmResizable[] = \"resizable\";\nconst char kmPosition[] = \"position\";\nconst char kmMinWidth[] = \"min_width\";\nconst char kmMinHeight[] = \"min_height\";\nconst char kmMaxWidth[] = \"max_width\";\nconst char kmMaxHeight[] = \"max_height\";\nconst char kmAsDesktop[] = \"as_desktop\";\n\n} // namespace switches\n", "file_path": "src/common/shell_switches.cc", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.988832950592041, 0.12549971044063568, 0.00017520446272101253, 0.0003631538129411638, 0.3263355493545532]}
{"hunk": {"id": 3, "code_window": ["extern const char kUrl[];\n", "\n", "// Manifest settings\n", "extern const char kmMain[];\n", "extern const char kmName[];\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["extern const char kVersion[];\n", "extern const char kWorkingDirectory[];\n"], "file_path": "src/common/shell_switches.h", "type": "add", "edit_start_line_idx": 20}, "file": "// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#ifndef CONTENT_SHELL_PATHS_MAC_H_\n#define CONTENT_SHELL_PATHS_MAC_H_\n\n#include \"base/file_path.h\"\n\n// Sets up base::mac::FrameworkBundle.\nvoid OverrideFrameworkBundlePath();\n\n// Sets up the CHILD_PROCESS_EXE path to properly point to the helper app.\nvoid OverrideChildProcessPath();\n\n// Gets the path to the content shell's pak file.\nFilePath GetResourcesPakFilePath();\n\n#endif // CONTENT_SHELL_PATHS_MAC_H_\n", "file_path": "src/paths_mac.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017555698286741972, 0.00017105865117628127, 0.00016656031948514283, 0.00017105865117628127, 4.498331691138446e-06]}
{"hunk": {"id": 3, "code_window": ["extern const char kUrl[];\n", "\n", "// Manifest settings\n", "extern const char kmMain[];\n", "extern const char kmName[];\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["extern const char kVersion[];\n", "extern const char kWorkingDirectory[];\n"], "file_path": "src/common/shell_switches.h", "type": "add", "edit_start_line_idx": 20}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/api/tray/tray.h\"\n\n#include \"content/nw/src/api/menu/menu.h\"\n\n#import \n\nnamespace api {\n\nTray::Tray(CreationOption option) {\n NSStatusBar *status_bar = [NSStatusBar systemStatusBar];\n status_item_ = [status_bar statusItemWithLength:NSVariableStatusItemLength];\n [status_item_ retain];\n [status_item_ setHighlightMode:YES];\n\n if (!option.icon.empty())\n SetIcon(option.icon);\n if (!option.title.empty())\n SetTitle(option.title);\n if (!option.tooltip.empty())\n SetTooltip(option.tooltip);\n}\n\nTray::~Tray() {\n [status_item_ release];\n}\n\nvoid Tray::SetTitle(const std::string& title) {\n [status_item_ setTitle:\n [NSString stringWithUTF8String:title.c_str()]];\n}\n\nstd::string Tray::GetTitle() {\n return [[status_item_ title] UTF8String];\n}\n\nvoid Tray::SetIcon(const std::string& path) {\n NSString* icon_path = [NSString stringWithUTF8String:path.c_str()];\n NSImage* icon = [[NSImage alloc] initWithContentsOfFile:icon_path];\n [status_item_ setImage:icon];\n}\n\nvoid Tray::SetTooltip(const std::string& tooltip) {\n [status_item_ setToolTip:\n [NSString stringWithUTF8String:tooltip.c_str()]];\n}\n\nstd::string Tray::GetTooltip() {\n NSString* tooltip = [status_item_ toolTip];\n return tooltip == nil ? \"\" : [tooltip UTF8String];\n}\n\nvoid Tray::SetMenu(Menu* menu) {\n [status_item_ setMenu:menu->menu_];\n}\n\nvoid Tray::Remove() {\n [[NSStatusBar systemStatusBar] removeStatusItem:status_item_];\n}\n\n} // namespace api\n\n", "file_path": "src/api/tray/tray_mac.mm", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0001790143141988665, 0.0001745812623994425, 0.00016954680904746056, 0.00017520446272101253, 2.836315388776711e-06]}
{"hunk": {"id": 3, "code_window": ["extern const char kUrl[];\n", "\n", "// Manifest settings\n", "extern const char kmMain[];\n", "extern const char kmName[];\n"], "labels": ["add", "keep", "keep", "keep", "keep"], "after_edit": ["extern const char kVersion[];\n", "extern const char kWorkingDirectory[];\n"], "file_path": "src/common/shell_switches.h", "type": "add", "edit_start_line_idx": 20}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/shell_browser_main.h\"\n\n#include \"base/command_line.h\"\n#include \"base/compiler_specific.h\"\n#include \"base/logging.h\"\n#include \"base/memory/scoped_ptr.h\"\n#include \"base/threading/thread_restrictions.h\"\n#include \"content/nw/src/common/shell_switches.h\"\n#include \"content/nw/src/nw_package.h\"\n#include \"content/nw/src/shell.h\"\n#include \"content/nw/src/shell_browser_context.h\"\n#include \"content/nw/src/shell_content_browser_client.h\"\n#include \"content/public/browser/browser_main_runner.h\"\n\n// Main routine for running as the Browser process.\nint ShellBrowserMain(const content::MainFunctionParams& parameters) {\n scoped_ptr main_runner_(\n content::BrowserMainRunner::Create());\n\n int exit_code = main_runner_->Initialize(parameters);\n\n if (exit_code >= 0)\n return exit_code;\n\n exit_code = main_runner_->Run();\n\n main_runner_->Shutdown();\n\n return exit_code;\n}\n", "file_path": "src/shell_browser_main.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0002523738658055663, 0.00018725272093433887, 0.00016488564142491668, 0.0001760190207278356, 2.9460044970619492e-05]}
{"hunk": {"id": 4, "code_window": ["// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "\n", "#include \"content/nw/src/renderer/shell_content_renderer_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/logging.h\"\n", "#include \"base/utf_string_conversions.h\"\n", "#include \"content/nw/src/api/dispatcher.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_path.h\"\n", "#include \"base/file_util.h\"\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 23}, "file": "// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n// Defines all the \"content_shell\" command-line switches.\n\n#ifndef CONTENT_NW_SRC_SHELL_SWITCHES_H_\n#define CONTENT_NW_SRC_SHELL_SWITCHES_H_\n\nnamespace switches {\n\nextern const char kCheckLayoutTestSysDeps[];\nextern const char kContentBrowserTest[];\nextern const char kContentShellDataPath[];\nextern const char kDeveloper[];\nextern const char kDumpRenderTree[];\nextern const char kNoTimeout[];\nextern const char kNoToolbar[];\nextern const char kVersion[];\nextern const char kUrl[];\n\n// Manifest settings\nextern const char kmMain[];\nextern const char kmName[];\nextern const char kmWebkit[];\nextern const char kmNodejs[];\nextern const char kmRoot[];\nextern const char kmWindow[];\nextern const char kmTitle[];\nextern const char kmToolbar[];\nextern const char kmIcon[];\nextern const char kmWidth[];\nextern const char kmHeight[];\nextern const char kmX[];\nextern const char kmY[];\nextern const char kmResizable[];\nextern const char kmPosition[];\nextern const char kmMinWidth[];\nextern const char kmMinHeight[];\nextern const char kmMaxWidth[];\nextern const char kmMaxHeight[];\nextern const char kmAsDesktop[];\n\n} // namespace switches\n\n#endif // CONTENT_NW_SRC_SHELL_SWITCHES_H_\n", "file_path": "src/common/shell_switches.h", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0005452478071674705, 0.0002650842652656138, 0.00017095115617848933, 0.0001782050239853561, 0.0001437245518900454]}
{"hunk": {"id": 4, "code_window": ["// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "\n", "#include \"content/nw/src/renderer/shell_content_renderer_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/logging.h\"\n", "#include \"base/utf_string_conversions.h\"\n", "#include \"content/nw/src/api/dispatcher.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_path.h\"\n", "#include \"base/file_util.h\"\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 23}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#ifndef CONTENT_NW_SRC_RENDERER_PRERENDERER_PRERENDERER_CLIENT_H_\n#define CONTENT_NW_SRC_RENDERER_PRERENDERER_PRERENDERER_CLIENT_H_\n\n#include \"base/compiler_specific.h\"\n#include \"content/public/renderer/render_view_observer.h\"\n#include \"third_party/WebKit/Source/WebKit/chromium/public/WebPrerendererClient.h\"\n\nnamespace prerender {\n\nclass PrerendererClient : public content::RenderViewObserver,\n public WebKit::WebPrerendererClient {\n public:\n explicit PrerendererClient(content::RenderView* render_view);\n\n private:\n virtual ~PrerendererClient();\n\n // Implements WebKit::WebPrerendererClient\n virtual void willAddPrerender(WebKit::WebPrerender* prerender) OVERRIDE;\n};\n\n} // namespace prerender\n\n#endif // CONTENT_NW_SRC_RENDERER_PRERENDERER_PRERENDERER_CLIENT_H_\n\n", "file_path": "src/renderer/prerenderer/prerenderer_client.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0303734689950943, 0.008091849274933338, 0.00016125969705171883, 0.00017297366866841912, 0.011722820810973644]}
{"hunk": {"id": 4, "code_window": ["// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "\n", "#include \"content/nw/src/renderer/shell_content_renderer_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/logging.h\"\n", "#include \"base/utf_string_conversions.h\"\n", "#include \"content/nw/src/api/dispatcher.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_path.h\"\n", "#include \"base/file_util.h\"\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 23}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/browser/shell_javascript_dialog_creator.h\"\n\n#include \"base/command_line.h\"\n#include \"base/logging.h\"\n#include \"base/utf_string_conversions.h\"\n#include \"content/public/browser/web_contents.h\"\n#include \"content/public/browser/web_contents_view.h\"\n#include \"content/nw/src/browser/shell_javascript_dialog.h\"\n#include \"content/nw/src/common/shell_switches.h\"\n#include \"net/base/net_util.h\"\n\nnamespace content {\n\nShellJavaScriptDialogCreator::ShellJavaScriptDialogCreator() {\n}\n\nShellJavaScriptDialogCreator::~ShellJavaScriptDialogCreator() {\n}\n\nvoid ShellJavaScriptDialogCreator::RunJavaScriptDialog(\n WebContents* web_contents,\n const GURL& origin_url,\n const std::string& accept_lang,\n JavaScriptMessageType javascript_message_type,\n const string16& message_text,\n const string16& default_prompt_text,\n const DialogClosedCallback& callback,\n bool* did_suppress_message) {\n if (!dialog_request_callback_.is_null()) {\n dialog_request_callback_.Run();\n callback.Run(true, string16());\n dialog_request_callback_.Reset();\n return;\n }\n\n#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)\n *did_suppress_message = false;\n\n if (dialog_.get()) {\n // One dialog at a time, please.\n *did_suppress_message = true;\n return;\n }\n\n string16 new_message_text = net::FormatUrl(origin_url, accept_lang) +\n ASCIIToUTF16(\"\\n\\n\") +\n message_text;\n gfx::NativeWindow parent_window =\n web_contents->GetView()->GetTopLevelNativeWindow();\n\n dialog_.reset(new ShellJavaScriptDialog(this,\n parent_window,\n javascript_message_type,\n new_message_text,\n default_prompt_text,\n callback));\n#else\n // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if\n *did_suppress_message = true;\n return;\n#endif\n}\n\nvoid ShellJavaScriptDialogCreator::RunBeforeUnloadDialog(\n WebContents* web_contents,\n const string16& message_text,\n bool is_reload,\n const DialogClosedCallback& callback) {\n if (!dialog_request_callback_.is_null()) {\n dialog_request_callback_.Run();\n callback.Run(true, string16());\n dialog_request_callback_.Reset();\n return;\n }\n\n#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)\n if (dialog_.get()) {\n // Seriously!?\n callback.Run(true, string16());\n return;\n }\n\n string16 new_message_text =\n message_text +\n ASCIIToUTF16(\"\\n\\nIs it OK to leave/reload this page?\");\n\n gfx::NativeWindow parent_window =\n web_contents->GetView()->GetTopLevelNativeWindow();\n\n dialog_.reset(new ShellJavaScriptDialog(this,\n parent_window,\n JAVASCRIPT_MESSAGE_TYPE_CONFIRM,\n new_message_text,\n string16(), // default_prompt_text\n callback));\n#else\n // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if\n callback.Run(true, string16());\n return;\n#endif\n}\n\nvoid ShellJavaScriptDialogCreator::ResetJavaScriptState(\n WebContents* web_contents) {\n#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)\n if (dialog_.get()) {\n dialog_->Cancel();\n dialog_.reset();\n }\n#else\n // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if\n#endif\n}\n\nvoid ShellJavaScriptDialogCreator::DialogClosed(ShellJavaScriptDialog* dialog) {\n#if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)\n DCHECK_EQ(dialog, dialog_.get());\n dialog_.reset();\n#else\n // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if\n#endif\n}\n\n} // namespace content\n", "file_path": "src/browser/shell_javascript_dialog_creator.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0011683071497827768, 0.0003211634757462889, 0.00016125969705171883, 0.00017297366866841912, 0.0002822621609084308]}
{"hunk": {"id": 4, "code_window": ["// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "\n", "#include \"content/nw/src/renderer/shell_content_renderer_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/logging.h\"\n", "#include \"base/utf_string_conversions.h\"\n", "#include \"content/nw/src/api/dispatcher.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_path.h\"\n", "#include \"base/file_util.h\"\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 23}, "file": "\n\n \n\n\n\n\n\n", "file_path": "tests/menu/index.html", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0001785201602615416, 0.0001757772552082315, 0.00016552470333408564, 0.00017764449876267463, 3.5556811326387106e-06]}
{"hunk": {"id": 5, "code_window": ["\n", "ShellContentRendererClient::~ShellContentRendererClient() {\n", "}\n", "\n", "void ShellContentRendererClient::RenderThreadStarted() {\n", " // Initialize node after render thread is started\n", " v8::V8::Initialize();\n", " v8::HandleScope scope;\n", "\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep"], "after_edit": [" // Change working directory\n", " CommandLine* command_line = CommandLine::ForCurrentProcess();\n", " if (command_line->HasSwitch(switches::kWorkingDirectory)) {\n", " file_util::SetCurrentDirectory(\n", " command_line->GetSwitchValuePath(switches::kWorkingDirectory));\n", " }\n", "\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 47}, "file": "// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n// Defines all the \"content_shell\" command-line switches.\n\n#ifndef CONTENT_NW_SRC_SHELL_SWITCHES_H_\n#define CONTENT_NW_SRC_SHELL_SWITCHES_H_\n\nnamespace switches {\n\nextern const char kCheckLayoutTestSysDeps[];\nextern const char kContentBrowserTest[];\nextern const char kContentShellDataPath[];\nextern const char kDeveloper[];\nextern const char kDumpRenderTree[];\nextern const char kNoTimeout[];\nextern const char kNoToolbar[];\nextern const char kVersion[];\nextern const char kUrl[];\n\n// Manifest settings\nextern const char kmMain[];\nextern const char kmName[];\nextern const char kmWebkit[];\nextern const char kmNodejs[];\nextern const char kmRoot[];\nextern const char kmWindow[];\nextern const char kmTitle[];\nextern const char kmToolbar[];\nextern const char kmIcon[];\nextern const char kmWidth[];\nextern const char kmHeight[];\nextern const char kmX[];\nextern const char kmY[];\nextern const char kmResizable[];\nextern const char kmPosition[];\nextern const char kmMinWidth[];\nextern const char kmMinHeight[];\nextern const char kmMaxWidth[];\nextern const char kmMaxHeight[];\nextern const char kmAsDesktop[];\n\n} // namespace switches\n\n#endif // CONTENT_NW_SRC_SHELL_SWITCHES_H_\n", "file_path": "src/common/shell_switches.h", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00019938396872021258, 0.00017682972247712314, 0.00016843900084495544, 0.00017267558723688126, 1.144593352364609e-05]}
{"hunk": {"id": 5, "code_window": ["\n", "ShellContentRendererClient::~ShellContentRendererClient() {\n", "}\n", "\n", "void ShellContentRendererClient::RenderThreadStarted() {\n", " // Initialize node after render thread is started\n", " v8::V8::Initialize();\n", " v8::HandleScope scope;\n", "\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep"], "after_edit": [" // Change working directory\n", " CommandLine* command_line = CommandLine::ForCurrentProcess();\n", " if (command_line->HasSwitch(switches::kWorkingDirectory)) {\n", " file_util::SetCurrentDirectory(\n", " command_line->GetSwitchValuePath(switches::kWorkingDirectory));\n", " }\n", "\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 47}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/api/menu/menu.h\"\n\nnamespace api {\n\nusing namespace v8;\n\nMenu::Menu(CreationOptions options) {\n}\n\nMenu::~Menu() {\n}\n\n} // namespace api\n", "file_path": "src/api/menu/menu_win.cc", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.0017202908638864756, 0.0005612641689367592, 0.0001738336286507547, 0.00017546610615681857, 0.0006691653397865593]}
{"hunk": {"id": 5, "code_window": ["\n", "ShellContentRendererClient::~ShellContentRendererClient() {\n", "}\n", "\n", "void ShellContentRendererClient::RenderThreadStarted() {\n", " // Initialize node after render thread is started\n", " v8::V8::Initialize();\n", " v8::HandleScope scope;\n", "\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep"], "after_edit": [" // Change working directory\n", " CommandLine* command_line = CommandLine::ForCurrentProcess();\n", " if (command_line->HasSwitch(switches::kWorkingDirectory)) {\n", " file_util::SetCurrentDirectory(\n", " command_line->GetSwitchValuePath(switches::kWorkingDirectory));\n", " }\n", "\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 47}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/browser/shell_javascript_dialog.h\"\n\n#import \n\n#import \"base/memory/scoped_nsobject.h\"\n#include \"base/sys_string_conversions.h\"\n#include \"content/nw/src/browser/shell_javascript_dialog_creator.h\"\n\n// Helper object that receives the notification that the dialog/sheet is\n// going away. Is responsible for cleaning itself up.\n@interface ShellJavaScriptDialogHelper : NSObject {\n @private\n scoped_nsobject alert_;\n NSTextField* textField_; // WEAK; owned by alert_\n\n // Copies of the fields in ShellJavaScriptDialog because they're private.\n content::ShellJavaScriptDialogCreator* creator_;\n content::JavaScriptDialogCreator::DialogClosedCallback callback_;\n}\n\n- (id)initHelperWithCreator:(content::ShellJavaScriptDialogCreator*)creator\n andCallback:(content::JavaScriptDialogCreator::DialogClosedCallback)callback;\n- (NSAlert*)alert;\n- (NSTextField*)textField;\n- (void)alertDidEnd:(NSAlert*)alert\n returnCode:(int)returnCode\n contextInfo:(void*)contextInfo;\n- (void)cancel;\n\n@end\n\n@implementation ShellJavaScriptDialogHelper\n\n- (id)initHelperWithCreator:(content::ShellJavaScriptDialogCreator*)creator\n andCallback:(content::JavaScriptDialogCreator::DialogClosedCallback)callback {\n if (self = [super init]) {\n creator_ = creator;\n callback_ = callback;\n }\n\n return self;\n}\n\n- (NSAlert*)alert {\n alert_.reset([[NSAlert alloc] init]);\n return alert_;\n}\n\n- (NSTextField*)textField {\n textField_ = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 22)];\n [[textField_ cell] setLineBreakMode:NSLineBreakByTruncatingTail];\n [alert_ setAccessoryView:textField_];\n [textField_ release];\n\n return textField_;\n}\n\n- (void)alertDidEnd:(NSAlert*)alert\n returnCode:(int)returnCode\n contextInfo:(void*)contextInfo {\n if (returnCode == NSRunStoppedResponse)\n return;\n\n bool success = returnCode == NSAlertFirstButtonReturn;\n string16 input;\n if (textField_)\n input = base::SysNSStringToUTF16([textField_ stringValue]);\n\n content::ShellJavaScriptDialog* native_dialog =\n reinterpret_cast(contextInfo);\n callback_.Run(success, input);\n creator_->DialogClosed(native_dialog);\n}\n\n- (void)cancel {\n [NSApp endSheet:[alert_ window]];\n alert_.reset();\n}\n\n@end\n\nnamespace content {\n\nShellJavaScriptDialog::ShellJavaScriptDialog(\n ShellJavaScriptDialogCreator* creator,\n gfx::NativeWindow parent_window,\n JavaScriptMessageType message_type,\n const string16& message_text,\n const string16& default_prompt_text,\n const JavaScriptDialogCreator::DialogClosedCallback& callback)\n : creator_(creator),\n callback_(callback) {\n bool text_field = message_type == JAVASCRIPT_MESSAGE_TYPE_PROMPT;\n bool one_button = message_type == JAVASCRIPT_MESSAGE_TYPE_ALERT;\n\n helper_ =\n [[ShellJavaScriptDialogHelper alloc] initHelperWithCreator:creator\n andCallback:callback];\n\n // Show the modal dialog.\n NSAlert* alert = [helper_ alert];\n NSTextField* field = nil;\n if (text_field) {\n field = [helper_ textField];\n [field setStringValue:base::SysUTF16ToNSString(default_prompt_text)];\n }\n [alert setDelegate:helper_];\n [alert setInformativeText:base::SysUTF16ToNSString(message_text)];\n [alert setMessageText:@\"Javascript alert\"];\n [alert addButtonWithTitle:@\"OK\"];\n if (!one_button) {\n NSButton* other = [alert addButtonWithTitle:@\"Cancel\"];\n [other setKeyEquivalent:@\"\\e\"];\n }\n\n [alert\n beginSheetModalForWindow:nil // nil here makes it app-modal\n modalDelegate:helper_\n didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)\n contextInfo:this];\n\n if ([alert accessoryView])\n [[alert window] makeFirstResponder:[alert accessoryView]];\n}\n\nShellJavaScriptDialog::~ShellJavaScriptDialog() {\n [helper_ release];\n}\n\nvoid ShellJavaScriptDialog::Cancel() {\n [helper_ cancel];\n}\n\n} // namespace content\n", "file_path": "src/browser/shell_javascript_dialog_mac.mm", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.002417774172499776, 0.0003803152940236032, 0.00016748496273066849, 0.00017440569354221225, 0.0005471268086694181]}
{"hunk": {"id": 5, "code_window": ["\n", "ShellContentRendererClient::~ShellContentRendererClient() {\n", "}\n", "\n", "void ShellContentRendererClient::RenderThreadStarted() {\n", " // Initialize node after render thread is started\n", " v8::V8::Initialize();\n", " v8::HandleScope scope;\n", "\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep"], "after_edit": [" // Change working directory\n", " CommandLine* command_line = CommandLine::ForCurrentProcess();\n", " if (command_line->HasSwitch(switches::kWorkingDirectory)) {\n", " file_util::SetCurrentDirectory(\n", " command_line->GetSwitchValuePath(switches::kWorkingDirectory));\n", " }\n", "\n"], "file_path": "src/renderer/shell_content_renderer_client.cc", "type": "add", "edit_start_line_idx": 47}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#ifndef CONTENT_NW_SRC_MEDIA_MEDIA_INTERNALS_H_\n#define CONTENT_NW_SRC_MEDIA_MEDIA_INTERNALS_H_\n\n#include \"base/memory/ref_counted.h\"\n#include \"base/memory/singleton.h\"\n#include \"base/observer_list.h\"\n#include \"base/values.h\"\n#include \"content/public/browser/media_observer.h\"\n\n// This class stores information about currently active media.\n// It's constructed on the UI thread but all of its methods are called on the IO\n// thread.\nclass MediaInternals : public content::MediaObserver {\n public:\n virtual ~MediaInternals();\n\n static MediaInternals* GetInstance();\n\n // Overridden from content::MediaObserver:\n virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE;\n virtual void OnSetAudioStreamPlaying(void* host,\n int stream_id,\n bool playing) OVERRIDE;\n virtual void OnSetAudioStreamStatus(void* host,\n int stream_id,\n const std::string& status) OVERRIDE;\n virtual void OnSetAudioStreamVolume(void* host,\n int stream_id,\n double volume) OVERRIDE;\n virtual void OnMediaEvent(int render_process_id,\n const media::MediaLogEvent& event) OVERRIDE;\n virtual void OnCaptureDevicesOpened(\n int render_process_id,\n int render_view_id,\n const content::MediaStreamDevices& devices) OVERRIDE;\n virtual void OnCaptureDevicesClosed(\n int render_process_id,\n int render_view_id,\n const content::MediaStreamDevices& devices) OVERRIDE;\n\n private:\n friend struct DefaultSingletonTraits;\n\n MediaInternals();\n\n DISALLOW_COPY_AND_ASSIGN(MediaInternals);\n};\n\n#endif // CONTENT_NW_SRC_MEDIA_MEDIA_INTERNALS_H_\n", "file_path": "src/media/media_internals.h", "label": 0, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00017674698028713465, 0.00017107951862271875, 0.00016736700490582734, 0.0001701285073067993, 3.105803898506565e-06]}
{"hunk": {"id": 6, "code_window": ["\n", "#include \"content/nw/src/shell_content_browser_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/file_path.h\"\n", "#include \"content/public/common/content_switches.h\"\n", "#include \"content/public/browser/browser_url_handler.h\"\n", "#include \"content/public/browser/resource_dispatcher_host.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_util.h\"\n"], "file_path": "src/shell_content_browser_client.cc", "type": "add", "edit_start_line_idx": 24}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/common/shell_switches.h\"\n\nnamespace switches {\n\n// Check whether all system dependencies for running layout tests are met.\nconst char kCheckLayoutTestSysDeps[] = \"check-layout-test-sys-deps\";\n\n// Tells Content Shell that it's running as a content_browsertest.\nconst char kContentBrowserTest[] = \"browser-test\";\n\n// Makes Content Shell use the given path for its data directory.\nconst char kContentShellDataPath[] = \"data-path\";\n\n// Enable developer tools\nconst char kDeveloper[] = \"developer\";\n\n// Request pages to be dumped as text once they finished loading.\nconst char kDumpRenderTree[] = \"dump-render-tree\";\n\n// Disables the timeout for layout tests.\nconst char kNoTimeout[] = \"no-timeout\";\n\n// Display no toolbar\nconst char kNoToolbar[] = \"no-toolbar\";\n\n// Show version and quit\nconst char kVersion[] = \"version\";\n\n// Open specified url\nconst char kUrl[] = \"url\";\n\nconst char kmMain[] = \"main\";\nconst char kmName[] = \"name\";\nconst char kmWebkit[] = \"webkit\";\nconst char kmNodejs[] = \"nodejs\";\nconst char kmRoot[] = \"root\";\nconst char kmWindow[] = \"window\";\nconst char kmTitle[] = \"title\";\nconst char kmToolbar[] = \"toolbar\";\nconst char kmIcon[] = \"icon\";\nconst char kmWidth[] = \"width\";\nconst char kmHeight[] = \"height\";\nconst char kmX[] = \"x\";\nconst char kmY[] = \"y\";\nconst char kmResizable[] = \"resizable\";\nconst char kmPosition[] = \"position\";\nconst char kmMinWidth[] = \"min_width\";\nconst char kmMinHeight[] = \"min_height\";\nconst char kmMaxWidth[] = \"max_width\";\nconst char kmMaxHeight[] = \"max_height\";\nconst char kmAsDesktop[] = \"as_desktop\";\n\n} // namespace switches\n", "file_path": "src/common/shell_switches.cc", "label": 1, "commit_url": "https://github.com/nwjs/nw.js/commit/74e4029e44d11d60e1d6a0ce285ae5ee401ebf51", "dependency_score": [0.00801808200776577, 0.0012251005973666906, 0.00016594049520790577, 0.00017415874754078686, 0.0025708952452987432]}
{"hunk": {"id": 6, "code_window": ["\n", "#include \"content/nw/src/shell_content_browser_client.h\"\n", "\n", "#include \"base/command_line.h\"\n", "#include \"base/file_path.h\"\n", "#include \"content/public/common/content_switches.h\"\n", "#include \"content/public/browser/browser_url_handler.h\"\n", "#include \"content/public/browser/resource_dispatcher_host.h\"\n"], "labels": ["keep", "keep", "keep", "keep", "add", "keep", "keep", "keep"], "after_edit": ["#include \"base/file_util.h\"\n"], "file_path": "src/shell_content_browser_client.cc", "type": "add", "edit_start_line_idx": 24}, "file": "// Copyright (c) 2012 Intel Corp\n// Copyright (c) 2012 The Chromium Authors\n// \n// Permission is hereby granted, free of charge, to any person obtaining a copy \n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n// to do so, subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n// \n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n// OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#include \"content/nw/src/api/v8_utils.h\"\n\nusing namespace v8;\n\nnamespace api {\n\nHandle CallMethod(Handle recv,\n const char* method,\n int argc,\n Handle argv[]) {\n Handle