@0no-co/graphql.web
Advanced tools
Comparing version 1.0.9 to 1.0.10-canary-8825d164745bdd99db348a65cfd8d329cdddb6d9
@@ -684,3 +684,3 @@ /*@ts-ignore*/ | ||
}; | ||
declare function parse(string: string | Source, _options?: ParseOptions | undefined): DocumentNode; | ||
declare function parse(string: string | Source, options?: ParseOptions | undefined): DocumentNode; | ||
declare function parseValue( | ||
@@ -745,2 +745,4 @@ string: string | Source, | ||
declare function isSelectionNode(node: ASTNode): node is SelectionNode; | ||
export { | ||
@@ -815,2 +817,3 @@ type ASTNode, | ||
type VariableNode, | ||
isSelectionNode, | ||
parse, | ||
@@ -817,0 +820,0 @@ parseType, |
@@ -6,3 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
class GraphQLError extends Error { | ||
constructor(e, r, i, n, t, a, l) { | ||
constructor(e, r, n, i, t, a, o) { | ||
super(e); | ||
@@ -17,19 +17,19 @@ this.name = "GraphQLError"; | ||
} | ||
if (n) { | ||
this.source = n; | ||
} | ||
if (i) { | ||
this.source = i; | ||
this.positions = i; | ||
} | ||
if (n) { | ||
this.positions = n; | ||
} | ||
if (a) { | ||
this.originalError = a; | ||
} | ||
var o = l; | ||
if (!o && a) { | ||
var l = o; | ||
if (!l && a) { | ||
var u = a.extensions; | ||
if (u && "object" == typeof u) { | ||
o = u; | ||
l = u; | ||
} | ||
} | ||
this.extensions = o || {}; | ||
this.extensions = l || {}; | ||
} | ||
@@ -58,40 +58,40 @@ toJSON() { | ||
function advance(i) { | ||
i.lastIndex = r; | ||
if (i.test(e)) { | ||
return e.slice(r, r = i.lastIndex); | ||
function advance(n) { | ||
n.lastIndex = r; | ||
if (n.test(e)) { | ||
return e.slice(r, r = n.lastIndex); | ||
} | ||
} | ||
var i = / +(?=[^\s])/y; | ||
var n = / +(?=[^\s])/y; | ||
function blockString(e) { | ||
var r = e.split("\n"); | ||
var n = ""; | ||
var i = ""; | ||
var t = 0; | ||
var a = 0; | ||
var l = r.length - 1; | ||
for (var o = 0; o < r.length; o++) { | ||
i.lastIndex = 0; | ||
if (i.test(r[o])) { | ||
if (o && (!t || i.lastIndex < t)) { | ||
t = i.lastIndex; | ||
var o = r.length - 1; | ||
for (var l = 0; l < r.length; l++) { | ||
n.lastIndex = 0; | ||
if (n.test(r[l])) { | ||
if (l && (!t || n.lastIndex < t)) { | ||
t = n.lastIndex; | ||
} | ||
a = a || o; | ||
l = o; | ||
a = a || l; | ||
o = l; | ||
} | ||
} | ||
for (var u = a; u <= l; u++) { | ||
for (var u = a; u <= o; u++) { | ||
if (u !== a) { | ||
n += "\n"; | ||
i += "\n"; | ||
} | ||
n += r[u].slice(t).replace(/\\"""/g, '"""'); | ||
i += r[u].slice(t).replace(/\\"""/g, '"""'); | ||
} | ||
return n; | ||
return i; | ||
} | ||
function ignored() { | ||
for (var i = 0 | e.charCodeAt(r++); 9 === i || 10 === i || 13 === i || 32 === i || 35 === i || 44 === i || 65279 === i; i = 0 | e.charCodeAt(r++)) { | ||
if (35 === i) { | ||
while (10 !== (i = e.charCodeAt(r++)) && 13 !== i) {} | ||
for (var n = 0 | e.charCodeAt(r++); 9 === n || 10 === n || 13 === n || 32 === n || 35 === n || 44 === n || 65279 === n; n = 0 | e.charCodeAt(r++)) { | ||
if (35 === n) { | ||
while (10 !== (n = e.charCodeAt(r++)) && 13 !== n) {} | ||
} | ||
@@ -102,5 +102,5 @@ } | ||
var n = /[_A-Za-z]\w*/y; | ||
var i = /[_A-Za-z]\w*/y; | ||
var t = new RegExp("(?:(null|true|false)|\\$(" + n.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + n.source + "))", "y"); | ||
var t = new RegExp("(?:(null|true|false)|\\$(" + i.source + ')|(-?\\d+)((?:\\.\\d+)?[eE][+-]?\\d+|\\.\\d+)?|("""(?:"""|(?:[\\s\\S]*?[^\\\\])"""))|("(?:"|[^\\r\\n]*?[^\\\\]"))|(' + i.source + "))", "y"); | ||
@@ -118,6 +118,6 @@ var a = function(e) { | ||
var l = /\\/; | ||
var o = /\\/; | ||
function value(i) { | ||
var o; | ||
function value(n) { | ||
var l; | ||
var u; | ||
@@ -130,3 +130,3 @@ t.lastIndex = r; | ||
while (93 !== e.charCodeAt(r)) { | ||
d.push(value(i)); | ||
d.push(value(n)); | ||
} | ||
@@ -144,3 +144,3 @@ r++; | ||
while (125 !== e.charCodeAt(r)) { | ||
if (null == (o = advance(n))) { | ||
if (null == (l = advance(i))) { | ||
throw error("ObjectField"); | ||
@@ -157,5 +157,5 @@ } | ||
kind: "Name", | ||
value: o | ||
value: l | ||
}, | ||
value: value(i) | ||
value: value(n) | ||
}); | ||
@@ -172,11 +172,11 @@ } | ||
ignored(); | ||
if (null != (o = u[a.Const])) { | ||
return "null" === o ? { | ||
if (null != (l = u[a.Const])) { | ||
return "null" === l ? { | ||
kind: "NullValue" | ||
} : { | ||
kind: "BooleanValue", | ||
value: "true" === o | ||
value: "true" === l | ||
}; | ||
} else if (null != (o = u[a.Var])) { | ||
if (i) { | ||
} else if (null != (l = u[a.Var])) { | ||
if (n) { | ||
throw error("Variable"); | ||
@@ -188,7 +188,7 @@ } else { | ||
kind: "Name", | ||
value: o | ||
value: l | ||
} | ||
}; | ||
} | ||
} else if (null != (o = u[a.Int])) { | ||
} else if (null != (l = u[a.Int])) { | ||
var v; | ||
@@ -198,3 +198,3 @@ if (null != (v = u[a.Float])) { | ||
kind: "FloatValue", | ||
value: o + v | ||
value: l + v | ||
}; | ||
@@ -204,21 +204,21 @@ } else { | ||
kind: "IntValue", | ||
value: o | ||
value: l | ||
}; | ||
} | ||
} else if (null != (o = u[a.BlockString])) { | ||
} else if (null != (l = u[a.BlockString])) { | ||
return { | ||
kind: "StringValue", | ||
value: blockString(o.slice(3, -3)), | ||
value: blockString(l.slice(3, -3)), | ||
block: !0 | ||
}; | ||
} else if (null != (o = u[a.String])) { | ||
} else if (null != (l = u[a.String])) { | ||
return { | ||
kind: "StringValue", | ||
value: l.test(o) ? JSON.parse(o) : o.slice(1, -1), | ||
value: o.test(l) ? JSON.parse(l) : l.slice(1, -1), | ||
block: !1 | ||
}; | ||
} else if (null != (o = u[a.Enum])) { | ||
} else if (null != (l = u[a.Enum])) { | ||
return { | ||
kind: "EnumValue", | ||
value: o | ||
value: l | ||
}; | ||
@@ -230,3 +230,3 @@ } | ||
function arguments_(i) { | ||
function arguments_(n) { | ||
if (40 === e.charCodeAt(r)) { | ||
@@ -238,3 +238,3 @@ var t = []; | ||
do { | ||
if (null == (a = advance(n))) { | ||
if (null == (a = advance(i))) { | ||
throw error("Argument"); | ||
@@ -253,3 +253,3 @@ } | ||
}, | ||
value: value(i) | ||
value: value(n) | ||
}); | ||
@@ -263,3 +263,3 @@ } while (41 !== e.charCodeAt(r)); | ||
function directives(i) { | ||
function directives(n) { | ||
if (64 === e.charCodeAt(r)) { | ||
@@ -270,3 +270,3 @@ var t = []; | ||
r++; | ||
if (null == (a = advance(n))) { | ||
if (null == (a = advance(i))) { | ||
throw error("Directive"); | ||
@@ -281,3 +281,3 @@ } | ||
}, | ||
arguments: arguments_(i) | ||
arguments: arguments_(n) | ||
}); | ||
@@ -290,3 +290,3 @@ } while (64 === e.charCodeAt(r)); | ||
function type() { | ||
var i; | ||
var n; | ||
var t = 0; | ||
@@ -298,3 +298,3 @@ while (91 === e.charCodeAt(r)) { | ||
} | ||
if (null == (i = advance(n))) { | ||
if (null == (n = advance(i))) { | ||
throw error("NamedType"); | ||
@@ -307,3 +307,3 @@ } | ||
kind: "Name", | ||
value: i | ||
value: n | ||
} | ||
@@ -334,3 +334,3 @@ }; | ||
var o = new RegExp("(?:(\\.{3})|(" + n.source + "))", "y"); | ||
var l = new RegExp("(?:(\\.{3})|(" + i.source + "))", "y"); | ||
@@ -344,19 +344,19 @@ var u = function(e) { | ||
function selectionSet() { | ||
var i = []; | ||
var n = []; | ||
var t; | ||
var a; | ||
do { | ||
o.lastIndex = r; | ||
if (null != (a = o.exec(e))) { | ||
r = o.lastIndex; | ||
l.lastIndex = r; | ||
if (null != (a = l.exec(e))) { | ||
r = l.lastIndex; | ||
if (null != a[u.Spread]) { | ||
ignored(); | ||
var l = advance(n); | ||
if (null != l && "on" !== l) { | ||
var o = advance(i); | ||
if (null != o && "on" !== o) { | ||
ignored(); | ||
i.push({ | ||
n.push({ | ||
kind: "FragmentSpread", | ||
name: { | ||
kind: "Name", | ||
value: l | ||
value: o | ||
}, | ||
@@ -367,4 +367,4 @@ directives: directives(!1) | ||
ignored(); | ||
if ("on" === l) { | ||
if (null == (l = advance(n))) { | ||
if ("on" === o) { | ||
if (null == (o = advance(i))) { | ||
throw error("NamedType"); | ||
@@ -379,9 +379,9 @@ } | ||
ignored(); | ||
i.push({ | ||
n.push({ | ||
kind: "InlineFragment", | ||
typeCondition: l ? { | ||
typeCondition: o ? { | ||
kind: "NamedType", | ||
name: { | ||
kind: "Name", | ||
value: l | ||
value: o | ||
} | ||
@@ -400,3 +400,3 @@ } : void 0, | ||
s = t; | ||
if (null == (t = advance(n))) { | ||
if (null == (t = advance(i))) { | ||
throw error("Field"); | ||
@@ -415,3 +415,3 @@ } | ||
} | ||
i.push({ | ||
n.push({ | ||
kind: "Field", | ||
@@ -439,3 +439,3 @@ alias: s ? { | ||
kind: "SelectionSet", | ||
selections: i | ||
selections: n | ||
}; | ||
@@ -445,13 +445,13 @@ } | ||
function fragmentDefinition() { | ||
var i; | ||
var n; | ||
var t; | ||
if (null == (i = advance(n))) { | ||
if (null == (n = advance(i))) { | ||
throw error("FragmentDefinition"); | ||
} | ||
ignored(); | ||
if ("on" !== advance(n)) { | ||
if ("on" !== advance(i)) { | ||
throw error("FragmentDefinition"); | ||
} | ||
ignored(); | ||
if (null == (t = advance(n))) { | ||
if (null == (t = advance(i))) { | ||
throw error("FragmentDefinition"); | ||
@@ -469,3 +469,3 @@ } | ||
kind: "Name", | ||
value: i | ||
value: n | ||
}, | ||
@@ -486,13 +486,13 @@ typeCondition: { | ||
function operationDefinition(i) { | ||
function operationDefinition(n) { | ||
var t; | ||
var a; | ||
var l; | ||
if (i) { | ||
var o; | ||
if (n) { | ||
ignored(); | ||
t = advance(n); | ||
t = advance(i); | ||
a = function variableDefinitions() { | ||
ignored(); | ||
if (40 === e.charCodeAt(r)) { | ||
var i = []; | ||
var n = []; | ||
r++; | ||
@@ -505,3 +505,3 @@ ignored(); | ||
} | ||
if (null == (t = advance(n))) { | ||
if (null == (t = advance(i))) { | ||
throw error("Variable"); | ||
@@ -515,10 +515,10 @@ } | ||
var a = type(); | ||
var l = void 0; | ||
var o = void 0; | ||
if (61 === e.charCodeAt(r)) { | ||
r++; | ||
ignored(); | ||
l = value(!0); | ||
o = value(!0); | ||
} | ||
ignored(); | ||
i.push({ | ||
n.push({ | ||
kind: "VariableDefinition", | ||
@@ -533,3 +533,3 @@ variable: { | ||
type: a, | ||
defaultValue: l, | ||
defaultValue: o, | ||
directives: directives(!0) | ||
@@ -540,6 +540,6 @@ }); | ||
ignored(); | ||
return i; | ||
return n; | ||
} | ||
}(); | ||
l = directives(!1); | ||
o = directives(!1); | ||
} | ||
@@ -551,3 +551,3 @@ if (123 === e.charCodeAt(r)) { | ||
kind: "OperationDefinition", | ||
operation: i || "query", | ||
operation: n || "query", | ||
name: t ? { | ||
@@ -558,3 +558,3 @@ kind: "Name", | ||
variableDefinitions: a, | ||
directives: l, | ||
directives: o, | ||
selectionSet: selectionSet() | ||
@@ -567,11 +567,11 @@ }; | ||
function mapJoin(e, r, i) { | ||
var n = ""; | ||
function mapJoin(e, r, n) { | ||
var i = ""; | ||
for (var t = 0; t < e.length; t++) { | ||
if (t) { | ||
n += r; | ||
i += r; | ||
} | ||
n += i(e[t]); | ||
i += n(e[t]); | ||
} | ||
return n; | ||
return i; | ||
} | ||
@@ -619,7 +619,7 @@ | ||
if (e.arguments && e.arguments.length) { | ||
var i = mapJoin(e.arguments, ", ", c.Argument); | ||
if (r.length + i.length + 2 > 80) { | ||
var n = mapJoin(e.arguments, ", ", c.Argument); | ||
if (r.length + n.length + 2 > 80) { | ||
r += "(" + (v += " ") + mapJoin(e.arguments, v, c.Argument) + (v = v.slice(0, -2)) + ")"; | ||
} else { | ||
r += "(" + i + ")"; | ||
r += "(" + n + ")"; | ||
} | ||
@@ -716,12 +716,12 @@ } | ||
case "ListValue": | ||
var i = []; | ||
for (var n = 0, t = e.values.length; n < t; n++) { | ||
i.push(valueFromASTUntyped(e.values[n], r)); | ||
var n = []; | ||
for (var i = 0, t = e.values.length; i < t; i++) { | ||
n.push(valueFromASTUntyped(e.values[i], r)); | ||
} | ||
return i; | ||
return n; | ||
case "ObjectValue": | ||
var a = Object.create(null); | ||
for (var l = 0, o = e.fields.length; l < o; l++) { | ||
var u = e.fields[l]; | ||
for (var o = 0, l = e.fields.length; o < l; o++) { | ||
var u = e.fields[o]; | ||
a[u.name.value] = valueFromASTUntyped(u.value, r); | ||
@@ -773,16 +773,30 @@ } | ||
exports.parse = function parse(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
exports.Source = function Source(e, r, n) { | ||
return { | ||
body: e, | ||
name: r, | ||
locationOffset: n || { | ||
line: 1, | ||
column: 1 | ||
} | ||
}; | ||
}; | ||
exports.isSelectionNode = function isSelectionNode(e) { | ||
return "Field" === e.kind || "FragmentSpread" === e.kind || "InlineFragment" === e.kind; | ||
}; | ||
exports.parse = function parse(n, i) { | ||
r = 0; | ||
return function document() { | ||
return function document(e, n) { | ||
var i; | ||
var n; | ||
var t; | ||
ignored(); | ||
var t = []; | ||
var a = []; | ||
do { | ||
if ("fragment" === (i = advance(d))) { | ||
ignored(); | ||
t.push(fragmentDefinition()); | ||
} else if (null != (n = operationDefinition(i))) { | ||
t.push(n); | ||
a.push(fragmentDefinition()); | ||
} else if (null != (t = operationDefinition(i))) { | ||
a.push(t); | ||
} else { | ||
@@ -792,11 +806,40 @@ throw error("Document"); | ||
} while (r < e.length); | ||
if (!n) { | ||
var o; | ||
return { | ||
kind: "Document", | ||
definitions: a, | ||
set loc(e) { | ||
o = e; | ||
}, | ||
get loc() { | ||
if (!o) { | ||
o = { | ||
start: 0, | ||
end: e.length, | ||
startToken: void 0, | ||
endToken: void 0, | ||
source: { | ||
body: e, | ||
name: "graphql.web", | ||
locationOffset: { | ||
line: 1, | ||
column: 1 | ||
} | ||
} | ||
}; | ||
} | ||
return o; | ||
} | ||
}; | ||
} | ||
return { | ||
kind: "Document", | ||
definitions: t | ||
definitions: a | ||
}; | ||
}(); | ||
}(e = "string" == typeof n.body ? n.body : n, i && i.noLocation); | ||
}; | ||
exports.parseType = function parseType(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
exports.parseType = function parseType(n, i) { | ||
e = "string" == typeof n.body ? n.body : n; | ||
r = 0; | ||
@@ -806,4 +849,4 @@ return type(); | ||
exports.parseValue = function parseValue(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
exports.parseValue = function parseValue(n, i) { | ||
e = "string" == typeof n.body ? n.body : n; | ||
r = 0; | ||
@@ -825,7 +868,7 @@ ignored(); | ||
exports.valueFromTypeNode = function valueFromTypeNode(e, r, i) { | ||
exports.valueFromTypeNode = function valueFromTypeNode(e, r, n) { | ||
if ("Variable" === e.kind) { | ||
return i ? valueFromTypeNode(i[e.name.value], r, i) : void 0; | ||
return n ? valueFromTypeNode(n[e.name.value], r, n) : void 0; | ||
} else if ("NonNullType" === r.kind) { | ||
return "NullValue" !== e.kind ? valueFromTypeNode(e, r, i) : void 0; | ||
return "NullValue" !== e.kind ? valueFromTypeNode(e, r, n) : void 0; | ||
} else if ("NullValue" === e.kind) { | ||
@@ -835,12 +878,12 @@ return null; | ||
if ("ListValue" === e.kind) { | ||
var n = []; | ||
var i = []; | ||
for (var t = 0, a = e.values.length; t < a; t++) { | ||
var l = valueFromTypeNode(e.values[t], r.type, i); | ||
if (void 0 === l) { | ||
var o = valueFromTypeNode(e.values[t], r.type, n); | ||
if (void 0 === o) { | ||
return; | ||
} else { | ||
n.push(l); | ||
i.push(o); | ||
} | ||
} | ||
return n; | ||
return i; | ||
} | ||
@@ -853,6 +896,6 @@ } else if ("NamedType" === r.kind) { | ||
case "Bool": | ||
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, i) : void 0; | ||
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, n) : void 0; | ||
default: | ||
return valueFromASTUntyped(e, i); | ||
return valueFromASTUntyped(e, n); | ||
} | ||
@@ -863,9 +906,9 @@ } | ||
exports.visit = function visit(e, r) { | ||
var n = []; | ||
var i = []; | ||
var n = []; | ||
try { | ||
var t = function traverse(e, t, a) { | ||
var l = !1; | ||
var o = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter; | ||
var u = o && o.call(r, e, t, a, n, i); | ||
var o = !1; | ||
var l = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter; | ||
var u = l && l.call(r, e, t, a, i, n); | ||
if (!1 === u) { | ||
@@ -878,7 +921,7 @@ return e; | ||
} else if (u && "string" == typeof u.kind) { | ||
l = u !== e; | ||
o = u !== e; | ||
e = u; | ||
} | ||
if (a) { | ||
i.push(a); | ||
n.push(a); | ||
} | ||
@@ -890,3 +933,3 @@ var d; | ||
for (var c in e) { | ||
n.push(c); | ||
i.push(c); | ||
var f = e[c]; | ||
@@ -897,11 +940,11 @@ if (Array.isArray(f)) { | ||
if (null != f[g] && "string" == typeof f[g].kind) { | ||
i.push(e); | ||
n.push(g); | ||
n.push(e); | ||
i.push(g); | ||
d = traverse(f[g], g, f); | ||
i.pop(); | ||
n.pop(); | ||
i.pop(); | ||
if (null == d) { | ||
l = !0; | ||
o = !0; | ||
} else { | ||
l = l || d !== f[g]; | ||
o = o || d !== f[g]; | ||
p.push(d); | ||
@@ -914,8 +957,8 @@ } | ||
if (void 0 !== (d = traverse(f, c, e))) { | ||
l = l || f !== d; | ||
o = o || f !== d; | ||
f = d; | ||
} | ||
} | ||
n.pop(); | ||
if (l) { | ||
i.pop(); | ||
if (o) { | ||
v[c] = f; | ||
@@ -925,6 +968,6 @@ } | ||
if (a) { | ||
i.pop(); | ||
n.pop(); | ||
} | ||
var m = r[e.kind] && r[e.kind].leave || r.leave; | ||
var h = m && m.call(r, e, t, a, n, i); | ||
var h = m && m.call(r, e, t, a, i, n); | ||
if (h === s) { | ||
@@ -935,5 +978,5 @@ throw s; | ||
} else if (void 0 !== u) { | ||
return l ? v : u; | ||
return o ? v : u; | ||
} else { | ||
return l ? v : e; | ||
return o ? v : e; | ||
} | ||
@@ -940,0 +983,0 @@ }(e); |
{ | ||
"name": "@0no-co/graphql.web", | ||
"description": "A spec-compliant client-side GraphQL implementation", | ||
"version": "1.0.9", | ||
"version": "1.0.10-canary-8825d164745bdd99db348a65cfd8d329cdddb6d9", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -6,0 +6,0 @@ "source": "./src/index.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
177263
2580
2