@0no-co/graphql.web
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -25,9 +25,10 @@ Object.defineProperty(exports, "__esModule", { | ||
} | ||
if (!o && a) { | ||
var l = a.extensions; | ||
if (l && "object" == typeof l) { | ||
l; | ||
var l = o; | ||
if (!l && a) { | ||
var u = a.extensions; | ||
if (u && "object" == typeof u) { | ||
l = u; | ||
} | ||
} | ||
this.extensions = o || {}; | ||
this.extensions = l || {}; | ||
} | ||
@@ -65,39 +66,40 @@ toJSON() { | ||
function blockString(e) { | ||
var r = ""; | ||
var n = 0; | ||
var r = e.split("\n"); | ||
var n = ""; | ||
var t = 0; | ||
var a = -1; | ||
var o = e.split("\n"); | ||
for (var l = 0; l < o.length; l++) { | ||
var a = 0; | ||
var o = r.length - 1; | ||
for (var l = 0; l < r.length; l++) { | ||
i.lastIndex = 0; | ||
if (i.test(o[l])) { | ||
if (l && (!n || i.lastIndex < n)) { | ||
n = i.lastIndex; | ||
if (i.test(r[l])) { | ||
if (l && (!t || i.lastIndex < t)) { | ||
t = i.lastIndex; | ||
} | ||
t = t || l; | ||
a = l; | ||
a = a || l; | ||
o = l; | ||
} | ||
} | ||
for (var u = t; u <= a; u++) { | ||
if (u !== t) { | ||
r += "\n"; | ||
for (var u = a; u <= o; u++) { | ||
if (u !== a) { | ||
n += "\n"; | ||
} | ||
r += o[u].slice(n).replace(/\\"""/g, '"""'); | ||
n += r[u].slice(t).replace(/\\"""/g, '"""'); | ||
} | ||
return r; | ||
return n; | ||
} | ||
var n = /(?:[\s,]*|#[^\n\r]*)*/y; | ||
function ignored() { | ||
n.lastIndex = r; | ||
n.test(e); | ||
r = n.lastIndex; | ||
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) {} | ||
} | ||
} | ||
r--; | ||
} | ||
var t = /[_\w][_\d\w]*/y; | ||
var n = /[_\w][_\d\w]*/y; | ||
function name() { | ||
var e; | ||
if (e = advance(t)) { | ||
if (e = advance(n)) { | ||
return { | ||
@@ -110,11 +112,11 @@ kind: "Name", | ||
var a = /null|true|false/y; | ||
var t = /null|true|false/y; | ||
var o = /\$[_\w][_\d\w]*/y; | ||
var a = /\$[_\w][_\d\w]*/y; | ||
var l = /[-]?\d+/y; | ||
var o = /[-]?\d+/y; | ||
var u = /(?:[-]?\d+)?(?:\.\d+)(?:[eE][+-]?\d+)?/y; | ||
var l = /(?:[-]?\d+)?(?:\.\d+)(?:[eE][+-]?\d+)?/y; | ||
var s = /\\/g; | ||
var u = /\\/g; | ||
@@ -126,6 +128,6 @@ var d = /"""(?:[\s\S]+(?="""))?"""/y; | ||
function value(i) { | ||
var n; | ||
var s; | ||
var c; | ||
if (c = advance(a)) { | ||
n = "null" === c ? { | ||
if (c = advance(t)) { | ||
s = "null" === c ? { | ||
kind: "NullValue" | ||
@@ -136,4 +138,4 @@ } : { | ||
}; | ||
} else if (!i && (c = advance(o))) { | ||
n = { | ||
} else if (!i && (c = advance(a))) { | ||
s = { | ||
kind: "Variable", | ||
@@ -145,14 +147,14 @@ name: { | ||
}; | ||
} else if (c = advance(u)) { | ||
n = { | ||
} else if (c = advance(l)) { | ||
s = { | ||
kind: "FloatValue", | ||
value: c | ||
}; | ||
} else if (c = advance(l)) { | ||
n = { | ||
} else if (c = advance(o)) { | ||
s = { | ||
kind: "IntValue", | ||
value: c | ||
}; | ||
} else if (c = advance(t)) { | ||
n = { | ||
} else if (c = advance(n)) { | ||
s = { | ||
kind: "EnumValue", | ||
@@ -162,3 +164,3 @@ value: c | ||
} else if (c = advance(d)) { | ||
n = { | ||
s = { | ||
kind: "StringValue", | ||
@@ -169,8 +171,8 @@ value: blockString(c.slice(3, -3)), | ||
} else if (c = advance(v)) { | ||
n = { | ||
s = { | ||
kind: "StringValue", | ||
value: s.test(c) ? JSON.parse(c) : c.slice(1, -1), | ||
value: u.test(c) ? JSON.parse(c) : c.slice(1, -1), | ||
block: !1 | ||
}; | ||
} else if (n = function list(i) { | ||
} else if (s = function list(i) { | ||
var n; | ||
@@ -225,6 +227,6 @@ if (91 === e.charCodeAt(r)) { | ||
}(i)) { | ||
return n; | ||
return s; | ||
} | ||
ignored(); | ||
return n; | ||
return s; | ||
} | ||
@@ -283,3 +285,2 @@ | ||
function field() { | ||
ignored(); | ||
var i = name(); | ||
@@ -344,6 +345,6 @@ if (i) { | ||
var c = /on/y; | ||
var s = /on/y; | ||
function typeCondition() { | ||
if (advance(c)) { | ||
if (advance(s)) { | ||
ignored(); | ||
@@ -362,7 +363,6 @@ var e = name(); | ||
var f = /\.\.\./y; | ||
var c = /\.\.\./y; | ||
function fragmentSpread() { | ||
ignored(); | ||
if (advance(f)) { | ||
if (advance(c)) { | ||
ignored(); | ||
@@ -416,6 +416,6 @@ var e = r; | ||
var p = /fragment/y; | ||
var f = /fragment/y; | ||
function fragmentDefinition() { | ||
if (advance(p)) { | ||
if (advance(f)) { | ||
ignored(); | ||
@@ -446,3 +446,3 @@ var e = name(); | ||
var m = /query|mutation|subscription/y; | ||
var p = /query|mutation|subscription/y; | ||
@@ -453,4 +453,4 @@ function operationDefinition() { | ||
var t = []; | ||
var a = []; | ||
if (i = advance(m)) { | ||
var o = []; | ||
if (i = advance(p)) { | ||
ignored(); | ||
@@ -465,3 +465,3 @@ n = name(); | ||
ignored(); | ||
while (i = advance(o)) { | ||
while (i = advance(a)) { | ||
ignored(); | ||
@@ -475,7 +475,7 @@ if (58 !== e.charCodeAt(r++)) { | ||
} | ||
var a = void 0; | ||
var o = void 0; | ||
if (61 === e.charCodeAt(r)) { | ||
r++; | ||
ignored(); | ||
if (!(a = value(!0))) { | ||
if (!(o = value(!0))) { | ||
throw error("VariableDefinition"); | ||
@@ -495,3 +495,3 @@ } | ||
type: t, | ||
defaultValue: a, | ||
defaultValue: o, | ||
directives: directives(!0) | ||
@@ -507,3 +507,3 @@ }); | ||
}(); | ||
a = directives(!1); | ||
o = directives(!1); | ||
} | ||
@@ -517,3 +517,3 @@ var l = selectionSet(); | ||
variableDefinitions: t, | ||
directives: a, | ||
directives: o, | ||
selectionSet: l | ||
@@ -524,3 +524,3 @@ }; | ||
var g = {}; | ||
var m = {}; | ||
@@ -537,4 +537,99 @@ function printString(e) { | ||
var h = 80; | ||
var g = { | ||
OperationDefinition(e) { | ||
if ("query" === e.operation && !e.name && !hasItems(e.variableDefinitions) && !hasItems(e.directives)) { | ||
return g.SelectionSet(e.selectionSet); | ||
} | ||
var r = e.operation; | ||
if (e.name) { | ||
r += " " + e.name.value; | ||
} | ||
if (hasItems(e.variableDefinitions)) { | ||
if (!e.name) { | ||
r += " "; | ||
} | ||
r += "(" + e.variableDefinitions.map(g.VariableDefinition).join(", ") + ")"; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return r + " " + g.SelectionSet(e.selectionSet); | ||
}, | ||
VariableDefinition(e) { | ||
var r = g.Variable(e.variable) + ": " + print(e.type); | ||
if (e.defaultValue) { | ||
r += " = " + print(e.defaultValue); | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return r; | ||
}, | ||
Field(e) { | ||
var r = (e.alias ? e.alias.value + ": " : "") + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
var i = e.arguments.map(g.Argument); | ||
var n = r + "(" + i.join(", ") + ")"; | ||
r = n.length > 80 ? r + "(\n " + i.join("\n").replace(/\n/g, "\n ") + "\n)" : n; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return e.selectionSet ? r + " " + g.SelectionSet(e.selectionSet) : r; | ||
}, | ||
StringValue: e => e.block ? printBlockString(e.value) : printString(e.value), | ||
BooleanValue: e => "" + e.value, | ||
NullValue: e => "null", | ||
IntValue: e => e.value, | ||
FloatValue: e => e.value, | ||
EnumValue: e => e.value, | ||
Name: e => e.value, | ||
Variable: e => "$" + e.name.value, | ||
ListValue: e => "[" + e.values.map(print).join(", ") + "]", | ||
ObjectValue: e => "{" + e.fields.map(g.ObjectField).join(", ") + "}", | ||
ObjectField: e => e.name.value + ": " + print(e.value), | ||
Document: e => hasItems(e.definitions) ? e.definitions.map(print).join("\n\n") : "", | ||
SelectionSet: e => "{\n " + e.selections.map(print).join("\n").replace(/\n/g, "\n ") + "\n}", | ||
Argument: e => e.name.value + ": " + print(e.value), | ||
FragmentSpread(e) { | ||
var r = "..." + e.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return r; | ||
}, | ||
InlineFragment(e) { | ||
var r = "..."; | ||
if (e.typeCondition) { | ||
r += " on " + e.typeCondition.name.value; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
}, | ||
FragmentDefinition(e) { | ||
var r = "fragment " + e.name.value; | ||
r += " on " + e.typeCondition.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(g.Directive).join(" "); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
}, | ||
Directive(e) { | ||
var r = "@" + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
r += "(" + e.arguments.map(g.Argument).join(", ") + ")"; | ||
} | ||
return r; | ||
}, | ||
NamedType: e => e.name.value, | ||
ListType: e => "[" + print(e.type) + "]", | ||
NonNullType: e => print(e.type) + "!" | ||
}; | ||
function print(e) { | ||
return g[e.kind] ? g[e.kind](e) : ""; | ||
} | ||
function valueFromASTUntyped(e, r) { | ||
@@ -576,3 +671,3 @@ switch (e.kind) { | ||
exports.BREAK = g; | ||
exports.BREAK = m; | ||
@@ -593,2 +688,9 @@ exports.GraphQLError = GraphQLError; | ||
VARIABLE: "Variable", | ||
INT: "IntValue", | ||
FLOAT: "FloatValue", | ||
STRING: "StringValue", | ||
BOOLEAN: "BooleanValue", | ||
NULL: "NullValue", | ||
ENUM: "EnumValue", | ||
LIST: "ListValue", | ||
OBJECT: "ObjectValue", | ||
@@ -651,126 +753,4 @@ OBJECT_FIELD: "ObjectField", | ||
exports.print = function print(e) { | ||
var r; | ||
switch (e.kind) { | ||
case "OperationDefinition": | ||
if ("query" === e.operation && !e.name && !hasItems(e.variableDefinitions) && !hasItems(e.directives)) { | ||
return print(e.selectionSet); | ||
} | ||
r = e.operation; | ||
if (e.name) { | ||
r += " " + e.name.value; | ||
} | ||
if (hasItems(e.variableDefinitions)) { | ||
if (!e.name) { | ||
r += " "; | ||
} | ||
r += "(" + e.variableDefinitions.map(print).join(", ") + ")"; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
exports.print = print; | ||
case "VariableDefinition": | ||
r = print(e.variable) + ": " + print(e.type); | ||
if (e.defaultValue) { | ||
r += " = " + print(e.defaultValue); | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return r; | ||
case "Field": | ||
r = (e.alias ? print(e.alias) + ": " : "") + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
var i = e.arguments.map(print); | ||
var n = r + "(" + i.join(", ") + ")"; | ||
r = n.length > h ? r + "(\n " + i.join("\n").replace(/\n/g, "\n ") + "\n)" : n; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return e.selectionSet ? r + " " + print(e.selectionSet) : r; | ||
case "StringValue": | ||
return e.block ? printBlockString(e.value) : printString(e.value); | ||
case "BooleanValue": | ||
return "" + e.value; | ||
case "NullValue": | ||
return "null"; | ||
case "IntValue": | ||
case "FloatValue": | ||
case "EnumValue": | ||
case "Name": | ||
return e.value; | ||
case "ListValue": | ||
return "[" + e.values.map(print).join(", ") + "]"; | ||
case "ObjectValue": | ||
return "{" + e.fields.map(print).join(", ") + "}"; | ||
case "ObjectField": | ||
case "Argument": | ||
return e.name.value + ": " + print(e.value); | ||
case "Variable": | ||
return "$" + e.name.value; | ||
case "Document": | ||
return hasItems(e.definitions) ? e.definitions.map(print).join("\n\n") : ""; | ||
case "SelectionSet": | ||
return "{\n " + e.selections.map(print).join("\n").replace(/\n/g, "\n ") + "\n}"; | ||
case "FragmentSpread": | ||
r = "..." + e.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return r; | ||
case "InlineFragment": | ||
r = "..."; | ||
if (e.typeCondition) { | ||
r += " on " + e.typeCondition.name.value; | ||
} | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
case "FragmentDefinition": | ||
r = "fragment " + e.name.value; | ||
r += " on " + e.typeCondition.name.value; | ||
if (hasItems(e.directives)) { | ||
r += " " + e.directives.map(print).join(" "); | ||
} | ||
return r + " " + print(e.selectionSet); | ||
case "Directive": | ||
r = "@" + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
r += "(" + e.arguments.map(print).join(", ") + ")"; | ||
} | ||
return r; | ||
case "NamedType": | ||
return e.name.value; | ||
case "ListType": | ||
return "[" + print(e.type) + "]"; | ||
case "NonNullType": | ||
return print(e.type) + "!"; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
exports.printBlockString = printBlockString; | ||
@@ -822,3 +802,3 @@ | ||
var o = !1; | ||
var l = r[e.kind] && r[e.kind].enter || r[e.kind]; | ||
var l = r[e.kind] && r[e.kind].enter || r[e.kind] || r.enter; | ||
var u = l && l.call(r, e, t, a, n, i); | ||
@@ -829,4 +809,4 @@ if (!1 === u) { | ||
return null; | ||
} else if (u === g) { | ||
throw g; | ||
} else if (u === m) { | ||
throw m; | ||
} else if (u && "string" == typeof u.kind) { | ||
@@ -839,9 +819,9 @@ o = u !== e; | ||
} | ||
var s; | ||
var d = { | ||
var d; | ||
var v = { | ||
...e | ||
}; | ||
for (var v in e) { | ||
n.push(v); | ||
var c = e[v]; | ||
for (var s in e) { | ||
n.push(s); | ||
var c = e[s]; | ||
if (Array.isArray(c)) { | ||
@@ -853,12 +833,12 @@ var f = []; | ||
n.push(p); | ||
s = traverse(c[p], p, c); | ||
d = traverse(c[p], p, c); | ||
n.pop(); | ||
i.pop(); | ||
if (void 0 === s) { | ||
if (void 0 === d) { | ||
f.push(c[p]); | ||
} else if (null === s) { | ||
} else if (null === d) { | ||
o = !0; | ||
} else { | ||
o = o || s !== c[p]; | ||
f.push(s); | ||
o = o || d !== c[p]; | ||
f.push(d); | ||
} | ||
@@ -869,5 +849,5 @@ } | ||
} else if (null != c && "string" == typeof c.kind) { | ||
if (void 0 !== (s = traverse(c, v, e))) { | ||
o = o || c !== s; | ||
c = s; | ||
if (void 0 !== (d = traverse(c, s, e))) { | ||
o = o || c !== d; | ||
c = d; | ||
} | ||
@@ -877,3 +857,3 @@ } | ||
if (o) { | ||
d[v] = c; | ||
v[s] = c; | ||
} | ||
@@ -884,12 +864,12 @@ } | ||
} | ||
var m = r[e.kind] && r[e.kind].leave; | ||
var h = m && m.call(r, e, t, a, n, i); | ||
if (h === g) { | ||
throw g; | ||
var g = r[e.kind] && r[e.kind].leave || r.leave; | ||
var h = g && g.call(r, e, t, a, n, i); | ||
if (h === m) { | ||
throw m; | ||
} else if (void 0 !== h) { | ||
return h; | ||
} else if (void 0 !== u) { | ||
return o ? d : u; | ||
return o ? v : u; | ||
} else { | ||
return o ? d : e; | ||
return o ? v : e; | ||
} | ||
@@ -899,3 +879,3 @@ }(e); | ||
} catch (r) { | ||
if (r !== g) { | ||
if (r !== m) { | ||
throw r; | ||
@@ -902,0 +882,0 @@ } |
{ | ||
"name": "@0no-co/graphql.web", | ||
"description": "A spec-compliant client-side GraphQL implementation", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150574
2042