@astralweb/nova-recently-viewed 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +311 -0
- package/dist/api/extendMiddleware.d.ts +16 -0
- package/dist/api/extendMiddleware.d.ts.map +1 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/queryFields.d.ts +3 -0
- package/dist/api/queryFields.d.ts.map +1 -0
- package/dist/api/web.d.ts +27 -0
- package/dist/api/web.d.ts.map +1 -0
- package/dist/api.cjs +46 -0
- package/dist/api.js +2201 -0
- package/dist/chunks/useRecentlyViewed-BMqCM4G9.js +1 -0
- package/dist/chunks/useRecentlyViewed-DmIwibiG.js +96 -0
- package/dist/chunks/web-DMlcd6E0.js +1 -0
- package/dist/chunks/web-WoqqfD6L.js +26 -0
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.d.ts.map +1 -0
- package/dist/composables/useRecentlyViewed.d.ts +7 -0
- package/dist/composables/useRecentlyViewed.d.ts.map +1 -0
- package/dist/composables.cjs +1 -0
- package/dist/composables.js +4 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/types/api.d.ts +9 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/composables.d.ts +19 -0
- package/dist/types/composables.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types.cjs +1 -0
- package/dist/types.js +1 -0
- package/package.json +95 -0
package/dist/api.js
ADDED
|
@@ -0,0 +1,2201 @@
|
|
|
1
|
+
import { a as Qe, f as ze, g as We, s as He } from "./chunks/web-WoqqfD6L.js";
|
|
2
|
+
const $e = `
|
|
3
|
+
recently_viewed_products {
|
|
4
|
+
product_sku
|
|
5
|
+
viewed_at
|
|
6
|
+
}
|
|
7
|
+
`, Ge = `
|
|
8
|
+
add_recently_viewed_products(input: $input) {
|
|
9
|
+
success
|
|
10
|
+
message
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
var k = function() {
|
|
14
|
+
return k = Object.assign || function(t) {
|
|
15
|
+
for (var n, s = 1, i = arguments.length; s < i; s++) {
|
|
16
|
+
n = arguments[s];
|
|
17
|
+
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
}, k.apply(this, arguments);
|
|
21
|
+
};
|
|
22
|
+
function R(e, t) {
|
|
23
|
+
if (!!!e)
|
|
24
|
+
throw new Error(t);
|
|
25
|
+
}
|
|
26
|
+
function te(e) {
|
|
27
|
+
return typeof e == "object" && e !== null;
|
|
28
|
+
}
|
|
29
|
+
function ne(e, t) {
|
|
30
|
+
if (!!!e)
|
|
31
|
+
throw new Error(
|
|
32
|
+
"Unexpected invariant triggered."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const ie = /\r\n|[\n\r]/g;
|
|
36
|
+
function w(e, t) {
|
|
37
|
+
let n = 0, s = 1;
|
|
38
|
+
for (const i of e.body.matchAll(ie)) {
|
|
39
|
+
if (typeof i.index == "number" || ne(!1), i.index >= t)
|
|
40
|
+
break;
|
|
41
|
+
n = i.index + i[0].length, s += 1;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
line: s,
|
|
45
|
+
column: t + 1 - n
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function se(e) {
|
|
49
|
+
return $(
|
|
50
|
+
e.source,
|
|
51
|
+
w(e.source, e.start)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function $(e, t) {
|
|
55
|
+
const n = e.locationOffset.column - 1, s = "".padStart(n) + e.body, i = t.line - 1, r = e.locationOffset.line - 1, a = t.line + r, u = t.line === 1 ? n : 0, l = t.column + u, E = `${e.name}:${a}:${l}
|
|
56
|
+
`, h = s.split(/\r\n|[\n\r]/g), N = h[i];
|
|
57
|
+
if (N.length > 120) {
|
|
58
|
+
const m = Math.floor(l / 80), L = l % 80, f = [];
|
|
59
|
+
for (let x = 0; x < N.length; x += 80)
|
|
60
|
+
f.push(N.slice(x, x + 80));
|
|
61
|
+
return E + U([
|
|
62
|
+
[`${a} |`, f[0]],
|
|
63
|
+
...f.slice(1, m + 1).map((x) => ["|", x]),
|
|
64
|
+
["|", "^".padStart(L)],
|
|
65
|
+
["|", f[m + 1]]
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
return E + U([
|
|
69
|
+
// Lines specified like this: ["prefix", "string"],
|
|
70
|
+
[`${a - 1} |`, h[i - 1]],
|
|
71
|
+
[`${a} |`, N],
|
|
72
|
+
["|", "^".padStart(l)],
|
|
73
|
+
[`${a + 1} |`, h[i + 1]]
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
function U(e) {
|
|
77
|
+
const t = e.filter(([s, i]) => i !== void 0), n = Math.max(...t.map(([s]) => s.length));
|
|
78
|
+
return t.map(([s, i]) => s.padStart(n) + (i ? " " + i : "")).join(`
|
|
79
|
+
`);
|
|
80
|
+
}
|
|
81
|
+
function re(e) {
|
|
82
|
+
const t = e[0];
|
|
83
|
+
return t == null || "kind" in t || "length" in t ? {
|
|
84
|
+
nodes: t,
|
|
85
|
+
source: e[1],
|
|
86
|
+
positions: e[2],
|
|
87
|
+
path: e[3],
|
|
88
|
+
originalError: e[4],
|
|
89
|
+
extensions: e[5]
|
|
90
|
+
} : t;
|
|
91
|
+
}
|
|
92
|
+
class M extends Error {
|
|
93
|
+
/**
|
|
94
|
+
* An array of `{ line, column }` locations within the source GraphQL document
|
|
95
|
+
* which correspond to this error.
|
|
96
|
+
*
|
|
97
|
+
* Errors during validation often contain multiple locations, for example to
|
|
98
|
+
* point out two things with the same name. Errors during execution include a
|
|
99
|
+
* single location, the field which produced the error.
|
|
100
|
+
*
|
|
101
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
102
|
+
*/
|
|
103
|
+
/**
|
|
104
|
+
* An array describing the JSON-path into the execution response which
|
|
105
|
+
* corresponds to this error. Only included for errors during execution.
|
|
106
|
+
*
|
|
107
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* An array of GraphQL AST Nodes corresponding to this error.
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* The source GraphQL document for the first location of this error.
|
|
114
|
+
*
|
|
115
|
+
* Note that if this Error represents more than one node, the source may not
|
|
116
|
+
* represent nodes after the first node.
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* An array of character offsets within the source GraphQL document
|
|
120
|
+
* which correspond to this error.
|
|
121
|
+
*/
|
|
122
|
+
/**
|
|
123
|
+
* The original error thrown from a field resolver during execution.
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Extension fields to add to the formatted error.
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
130
|
+
*/
|
|
131
|
+
constructor(t, ...n) {
|
|
132
|
+
var s, i, r;
|
|
133
|
+
const { nodes: a, source: u, positions: l, path: E, originalError: h, extensions: N } = re(n);
|
|
134
|
+
super(t), this.name = "GraphQLError", this.path = E ?? void 0, this.originalError = h ?? void 0, this.nodes = B(
|
|
135
|
+
Array.isArray(a) ? a : a ? [a] : void 0
|
|
136
|
+
);
|
|
137
|
+
const m = B(
|
|
138
|
+
(s = this.nodes) === null || s === void 0 ? void 0 : s.map((f) => f.loc).filter((f) => f != null)
|
|
139
|
+
);
|
|
140
|
+
this.source = u ?? (m == null || (i = m[0]) === null || i === void 0 ? void 0 : i.source), this.positions = l ?? m?.map((f) => f.start), this.locations = l && u ? l.map((f) => w(u, f)) : m?.map((f) => w(f.source, f.start));
|
|
141
|
+
const L = te(
|
|
142
|
+
h?.extensions
|
|
143
|
+
) ? h?.extensions : void 0;
|
|
144
|
+
this.extensions = (r = N ?? L) !== null && r !== void 0 ? r : /* @__PURE__ */ Object.create(null), Object.defineProperties(this, {
|
|
145
|
+
message: {
|
|
146
|
+
writable: !0,
|
|
147
|
+
enumerable: !0
|
|
148
|
+
},
|
|
149
|
+
name: {
|
|
150
|
+
enumerable: !1
|
|
151
|
+
},
|
|
152
|
+
nodes: {
|
|
153
|
+
enumerable: !1
|
|
154
|
+
},
|
|
155
|
+
source: {
|
|
156
|
+
enumerable: !1
|
|
157
|
+
},
|
|
158
|
+
positions: {
|
|
159
|
+
enumerable: !1
|
|
160
|
+
},
|
|
161
|
+
originalError: {
|
|
162
|
+
enumerable: !1
|
|
163
|
+
}
|
|
164
|
+
}), h != null && h.stack ? Object.defineProperty(this, "stack", {
|
|
165
|
+
value: h.stack,
|
|
166
|
+
writable: !0,
|
|
167
|
+
configurable: !0
|
|
168
|
+
}) : Error.captureStackTrace ? Error.captureStackTrace(this, M) : Object.defineProperty(this, "stack", {
|
|
169
|
+
value: Error().stack,
|
|
170
|
+
writable: !0,
|
|
171
|
+
configurable: !0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
get [Symbol.toStringTag]() {
|
|
175
|
+
return "GraphQLError";
|
|
176
|
+
}
|
|
177
|
+
toString() {
|
|
178
|
+
let t = this.message;
|
|
179
|
+
if (this.nodes)
|
|
180
|
+
for (const n of this.nodes)
|
|
181
|
+
n.loc && (t += `
|
|
182
|
+
|
|
183
|
+
` + se(n.loc));
|
|
184
|
+
else if (this.source && this.locations)
|
|
185
|
+
for (const n of this.locations)
|
|
186
|
+
t += `
|
|
187
|
+
|
|
188
|
+
` + $(this.source, n);
|
|
189
|
+
return t;
|
|
190
|
+
}
|
|
191
|
+
toJSON() {
|
|
192
|
+
const t = {
|
|
193
|
+
message: this.message
|
|
194
|
+
};
|
|
195
|
+
return this.locations != null && (t.locations = this.locations), this.path != null && (t.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (t.extensions = this.extensions), t;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function B(e) {
|
|
199
|
+
return e === void 0 || e.length === 0 ? void 0 : e;
|
|
200
|
+
}
|
|
201
|
+
function d(e, t, n) {
|
|
202
|
+
return new M(`Syntax Error: ${n}`, {
|
|
203
|
+
source: e,
|
|
204
|
+
positions: [t]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
class oe {
|
|
208
|
+
/**
|
|
209
|
+
* The character offset at which this Node begins.
|
|
210
|
+
*/
|
|
211
|
+
/**
|
|
212
|
+
* The character offset at which this Node ends.
|
|
213
|
+
*/
|
|
214
|
+
/**
|
|
215
|
+
* The Token at which this Node begins.
|
|
216
|
+
*/
|
|
217
|
+
/**
|
|
218
|
+
* The Token at which this Node ends.
|
|
219
|
+
*/
|
|
220
|
+
/**
|
|
221
|
+
* The Source document the AST represents.
|
|
222
|
+
*/
|
|
223
|
+
constructor(t, n, s) {
|
|
224
|
+
this.start = t.start, this.end = n.end, this.startToken = t, this.endToken = n, this.source = s;
|
|
225
|
+
}
|
|
226
|
+
get [Symbol.toStringTag]() {
|
|
227
|
+
return "Location";
|
|
228
|
+
}
|
|
229
|
+
toJSON() {
|
|
230
|
+
return {
|
|
231
|
+
start: this.start,
|
|
232
|
+
end: this.end
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
class G {
|
|
237
|
+
/**
|
|
238
|
+
* The kind of Token.
|
|
239
|
+
*/
|
|
240
|
+
/**
|
|
241
|
+
* The character offset at which this Node begins.
|
|
242
|
+
*/
|
|
243
|
+
/**
|
|
244
|
+
* The character offset at which this Node ends.
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* The 1-indexed line number on which this Token appears.
|
|
248
|
+
*/
|
|
249
|
+
/**
|
|
250
|
+
* The 1-indexed column number at which this Token begins.
|
|
251
|
+
*/
|
|
252
|
+
/**
|
|
253
|
+
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
254
|
+
*
|
|
255
|
+
* Note: is undefined for punctuation tokens, but typed as string for
|
|
256
|
+
* convenience in the parser.
|
|
257
|
+
*/
|
|
258
|
+
/**
|
|
259
|
+
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
260
|
+
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
261
|
+
* the last.
|
|
262
|
+
*/
|
|
263
|
+
constructor(t, n, s, i, r, a) {
|
|
264
|
+
this.kind = t, this.start = n, this.end = s, this.line = i, this.column = r, this.value = a, this.prev = null, this.next = null;
|
|
265
|
+
}
|
|
266
|
+
get [Symbol.toStringTag]() {
|
|
267
|
+
return "Token";
|
|
268
|
+
}
|
|
269
|
+
toJSON() {
|
|
270
|
+
return {
|
|
271
|
+
kind: this.kind,
|
|
272
|
+
value: this.value,
|
|
273
|
+
line: this.line,
|
|
274
|
+
column: this.column
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const ae = {
|
|
279
|
+
Name: [],
|
|
280
|
+
Document: ["definitions"],
|
|
281
|
+
OperationDefinition: [
|
|
282
|
+
"name",
|
|
283
|
+
"variableDefinitions",
|
|
284
|
+
"directives",
|
|
285
|
+
"selectionSet"
|
|
286
|
+
],
|
|
287
|
+
VariableDefinition: ["variable", "type", "defaultValue", "directives"],
|
|
288
|
+
Variable: ["name"],
|
|
289
|
+
SelectionSet: ["selections"],
|
|
290
|
+
Field: ["alias", "name", "arguments", "directives", "selectionSet"],
|
|
291
|
+
Argument: ["name", "value"],
|
|
292
|
+
FragmentSpread: ["name", "directives"],
|
|
293
|
+
InlineFragment: ["typeCondition", "directives", "selectionSet"],
|
|
294
|
+
FragmentDefinition: [
|
|
295
|
+
"name",
|
|
296
|
+
// Note: fragment variable definitions are deprecated and will removed in v17.0.0
|
|
297
|
+
"variableDefinitions",
|
|
298
|
+
"typeCondition",
|
|
299
|
+
"directives",
|
|
300
|
+
"selectionSet"
|
|
301
|
+
],
|
|
302
|
+
IntValue: [],
|
|
303
|
+
FloatValue: [],
|
|
304
|
+
StringValue: [],
|
|
305
|
+
BooleanValue: [],
|
|
306
|
+
NullValue: [],
|
|
307
|
+
EnumValue: [],
|
|
308
|
+
ListValue: ["values"],
|
|
309
|
+
ObjectValue: ["fields"],
|
|
310
|
+
ObjectField: ["name", "value"],
|
|
311
|
+
Directive: ["name", "arguments"],
|
|
312
|
+
NamedType: ["name"],
|
|
313
|
+
ListType: ["type"],
|
|
314
|
+
NonNullType: ["type"],
|
|
315
|
+
SchemaDefinition: ["description", "directives", "operationTypes"],
|
|
316
|
+
OperationTypeDefinition: ["type"],
|
|
317
|
+
ScalarTypeDefinition: ["description", "name", "directives"],
|
|
318
|
+
ObjectTypeDefinition: [
|
|
319
|
+
"description",
|
|
320
|
+
"name",
|
|
321
|
+
"interfaces",
|
|
322
|
+
"directives",
|
|
323
|
+
"fields"
|
|
324
|
+
],
|
|
325
|
+
FieldDefinition: ["description", "name", "arguments", "type", "directives"],
|
|
326
|
+
InputValueDefinition: [
|
|
327
|
+
"description",
|
|
328
|
+
"name",
|
|
329
|
+
"type",
|
|
330
|
+
"defaultValue",
|
|
331
|
+
"directives"
|
|
332
|
+
],
|
|
333
|
+
InterfaceTypeDefinition: [
|
|
334
|
+
"description",
|
|
335
|
+
"name",
|
|
336
|
+
"interfaces",
|
|
337
|
+
"directives",
|
|
338
|
+
"fields"
|
|
339
|
+
],
|
|
340
|
+
UnionTypeDefinition: ["description", "name", "directives", "types"],
|
|
341
|
+
EnumTypeDefinition: ["description", "name", "directives", "values"],
|
|
342
|
+
EnumValueDefinition: ["description", "name", "directives"],
|
|
343
|
+
InputObjectTypeDefinition: ["description", "name", "directives", "fields"],
|
|
344
|
+
DirectiveDefinition: ["description", "name", "arguments", "locations"],
|
|
345
|
+
SchemaExtension: ["directives", "operationTypes"],
|
|
346
|
+
ScalarTypeExtension: ["name", "directives"],
|
|
347
|
+
ObjectTypeExtension: ["name", "interfaces", "directives", "fields"],
|
|
348
|
+
InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"],
|
|
349
|
+
UnionTypeExtension: ["name", "directives", "types"],
|
|
350
|
+
EnumTypeExtension: ["name", "directives", "values"],
|
|
351
|
+
InputObjectTypeExtension: ["name", "directives", "fields"]
|
|
352
|
+
};
|
|
353
|
+
new Set(Object.keys(ae));
|
|
354
|
+
var y;
|
|
355
|
+
(function(e) {
|
|
356
|
+
e.QUERY = "query", e.MUTATION = "mutation", e.SUBSCRIPTION = "subscription";
|
|
357
|
+
})(y || (y = {}));
|
|
358
|
+
var P;
|
|
359
|
+
(function(e) {
|
|
360
|
+
e.QUERY = "QUERY", e.MUTATION = "MUTATION", e.SUBSCRIPTION = "SUBSCRIPTION", e.FIELD = "FIELD", e.FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION", e.FRAGMENT_SPREAD = "FRAGMENT_SPREAD", e.INLINE_FRAGMENT = "INLINE_FRAGMENT", e.VARIABLE_DEFINITION = "VARIABLE_DEFINITION", e.SCHEMA = "SCHEMA", e.SCALAR = "SCALAR", e.OBJECT = "OBJECT", e.FIELD_DEFINITION = "FIELD_DEFINITION", e.ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION", e.INTERFACE = "INTERFACE", e.UNION = "UNION", e.ENUM = "ENUM", e.ENUM_VALUE = "ENUM_VALUE", e.INPUT_OBJECT = "INPUT_OBJECT", e.INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
|
|
361
|
+
})(P || (P = {}));
|
|
362
|
+
var c;
|
|
363
|
+
(function(e) {
|
|
364
|
+
e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
|
|
365
|
+
})(c || (c = {}));
|
|
366
|
+
function ce(e) {
|
|
367
|
+
return e === 9 || e === 32;
|
|
368
|
+
}
|
|
369
|
+
function g(e) {
|
|
370
|
+
return e >= 48 && e <= 57;
|
|
371
|
+
}
|
|
372
|
+
function Y(e) {
|
|
373
|
+
return e >= 97 && e <= 122 || // A-Z
|
|
374
|
+
e >= 65 && e <= 90;
|
|
375
|
+
}
|
|
376
|
+
function J(e) {
|
|
377
|
+
return Y(e) || e === 95;
|
|
378
|
+
}
|
|
379
|
+
function ue(e) {
|
|
380
|
+
return Y(e) || g(e) || e === 95;
|
|
381
|
+
}
|
|
382
|
+
function le(e) {
|
|
383
|
+
var t;
|
|
384
|
+
let n = Number.MAX_SAFE_INTEGER, s = null, i = -1;
|
|
385
|
+
for (let a = 0; a < e.length; ++a) {
|
|
386
|
+
var r;
|
|
387
|
+
const u = e[a], l = pe(u);
|
|
388
|
+
l !== u.length && (s = (r = s) !== null && r !== void 0 ? r : a, i = a, a !== 0 && l < n && (n = l));
|
|
389
|
+
}
|
|
390
|
+
return e.map((a, u) => u === 0 ? a : a.slice(n)).slice(
|
|
391
|
+
(t = s) !== null && t !== void 0 ? t : 0,
|
|
392
|
+
i + 1
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
function pe(e) {
|
|
396
|
+
let t = 0;
|
|
397
|
+
for (; t < e.length && ce(e.charCodeAt(t)); )
|
|
398
|
+
++t;
|
|
399
|
+
return t;
|
|
400
|
+
}
|
|
401
|
+
var o;
|
|
402
|
+
(function(e) {
|
|
403
|
+
e.SOF = "<SOF>", e.EOF = "<EOF>", e.BANG = "!", e.DOLLAR = "$", e.AMP = "&", e.PAREN_L = "(", e.PAREN_R = ")", e.SPREAD = "...", e.COLON = ":", e.EQUALS = "=", e.AT = "@", e.BRACKET_L = "[", e.BRACKET_R = "]", e.BRACE_L = "{", e.PIPE = "|", e.BRACE_R = "}", e.NAME = "Name", e.INT = "Int", e.FLOAT = "Float", e.STRING = "String", e.BLOCK_STRING = "BlockString", e.COMMENT = "Comment";
|
|
404
|
+
})(o || (o = {}));
|
|
405
|
+
class he {
|
|
406
|
+
/**
|
|
407
|
+
* The previously focused non-ignored token.
|
|
408
|
+
*/
|
|
409
|
+
/**
|
|
410
|
+
* The currently focused non-ignored token.
|
|
411
|
+
*/
|
|
412
|
+
/**
|
|
413
|
+
* The (1-indexed) line containing the current token.
|
|
414
|
+
*/
|
|
415
|
+
/**
|
|
416
|
+
* The character offset at which the current line begins.
|
|
417
|
+
*/
|
|
418
|
+
constructor(t) {
|
|
419
|
+
const n = new G(o.SOF, 0, 0, 0, 0);
|
|
420
|
+
this.source = t, this.lastToken = n, this.token = n, this.line = 1, this.lineStart = 0;
|
|
421
|
+
}
|
|
422
|
+
get [Symbol.toStringTag]() {
|
|
423
|
+
return "Lexer";
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Advances the token stream to the next non-ignored token.
|
|
427
|
+
*/
|
|
428
|
+
advance() {
|
|
429
|
+
return this.lastToken = this.token, this.token = this.lookahead();
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Looks ahead and returns the next non-ignored token, but does not change
|
|
433
|
+
* the state of Lexer.
|
|
434
|
+
*/
|
|
435
|
+
lookahead() {
|
|
436
|
+
let t = this.token;
|
|
437
|
+
if (t.kind !== o.EOF)
|
|
438
|
+
do
|
|
439
|
+
if (t.next)
|
|
440
|
+
t = t.next;
|
|
441
|
+
else {
|
|
442
|
+
const n = fe(this, t.end);
|
|
443
|
+
t.next = n, n.prev = t, t = n;
|
|
444
|
+
}
|
|
445
|
+
while (t.kind === o.COMMENT);
|
|
446
|
+
return t;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function de(e) {
|
|
450
|
+
return e === o.BANG || e === o.DOLLAR || e === o.AMP || e === o.PAREN_L || e === o.PAREN_R || e === o.SPREAD || e === o.COLON || e === o.EQUALS || e === o.AT || e === o.BRACKET_L || e === o.BRACKET_R || e === o.BRACE_L || e === o.PIPE || e === o.BRACE_R;
|
|
451
|
+
}
|
|
452
|
+
function O(e) {
|
|
453
|
+
return e >= 0 && e <= 55295 || e >= 57344 && e <= 1114111;
|
|
454
|
+
}
|
|
455
|
+
function S(e, t) {
|
|
456
|
+
return q(e.charCodeAt(t)) && X(e.charCodeAt(t + 1));
|
|
457
|
+
}
|
|
458
|
+
function q(e) {
|
|
459
|
+
return e >= 55296 && e <= 56319;
|
|
460
|
+
}
|
|
461
|
+
function X(e) {
|
|
462
|
+
return e >= 56320 && e <= 57343;
|
|
463
|
+
}
|
|
464
|
+
function T(e, t) {
|
|
465
|
+
const n = e.source.body.codePointAt(t);
|
|
466
|
+
if (n === void 0)
|
|
467
|
+
return o.EOF;
|
|
468
|
+
if (n >= 32 && n <= 126) {
|
|
469
|
+
const s = String.fromCodePoint(n);
|
|
470
|
+
return s === '"' ? `'"'` : `"${s}"`;
|
|
471
|
+
}
|
|
472
|
+
return "U+" + n.toString(16).toUpperCase().padStart(4, "0");
|
|
473
|
+
}
|
|
474
|
+
function p(e, t, n, s, i) {
|
|
475
|
+
const r = e.line, a = 1 + n - e.lineStart;
|
|
476
|
+
return new G(t, n, s, r, a, i);
|
|
477
|
+
}
|
|
478
|
+
function fe(e, t) {
|
|
479
|
+
const n = e.source.body, s = n.length;
|
|
480
|
+
let i = t;
|
|
481
|
+
for (; i < s; ) {
|
|
482
|
+
const r = n.charCodeAt(i);
|
|
483
|
+
switch (r) {
|
|
484
|
+
// Ignored ::
|
|
485
|
+
// - UnicodeBOM
|
|
486
|
+
// - WhiteSpace
|
|
487
|
+
// - LineTerminator
|
|
488
|
+
// - Comment
|
|
489
|
+
// - Comma
|
|
490
|
+
//
|
|
491
|
+
// UnicodeBOM :: "Byte Order Mark (U+FEFF)"
|
|
492
|
+
//
|
|
493
|
+
// WhiteSpace ::
|
|
494
|
+
// - "Horizontal Tab (U+0009)"
|
|
495
|
+
// - "Space (U+0020)"
|
|
496
|
+
//
|
|
497
|
+
// Comma :: ,
|
|
498
|
+
case 65279:
|
|
499
|
+
// <BOM>
|
|
500
|
+
case 9:
|
|
501
|
+
// \t
|
|
502
|
+
case 32:
|
|
503
|
+
// <space>
|
|
504
|
+
case 44:
|
|
505
|
+
++i;
|
|
506
|
+
continue;
|
|
507
|
+
// LineTerminator ::
|
|
508
|
+
// - "New Line (U+000A)"
|
|
509
|
+
// - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"]
|
|
510
|
+
// - "Carriage Return (U+000D)" "New Line (U+000A)"
|
|
511
|
+
case 10:
|
|
512
|
+
++i, ++e.line, e.lineStart = i;
|
|
513
|
+
continue;
|
|
514
|
+
case 13:
|
|
515
|
+
n.charCodeAt(i + 1) === 10 ? i += 2 : ++i, ++e.line, e.lineStart = i;
|
|
516
|
+
continue;
|
|
517
|
+
// Comment
|
|
518
|
+
case 35:
|
|
519
|
+
return Ee(e, i);
|
|
520
|
+
// Token ::
|
|
521
|
+
// - Punctuator
|
|
522
|
+
// - Name
|
|
523
|
+
// - IntValue
|
|
524
|
+
// - FloatValue
|
|
525
|
+
// - StringValue
|
|
526
|
+
//
|
|
527
|
+
// Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | }
|
|
528
|
+
case 33:
|
|
529
|
+
return p(e, o.BANG, i, i + 1);
|
|
530
|
+
case 36:
|
|
531
|
+
return p(e, o.DOLLAR, i, i + 1);
|
|
532
|
+
case 38:
|
|
533
|
+
return p(e, o.AMP, i, i + 1);
|
|
534
|
+
case 40:
|
|
535
|
+
return p(e, o.PAREN_L, i, i + 1);
|
|
536
|
+
case 41:
|
|
537
|
+
return p(e, o.PAREN_R, i, i + 1);
|
|
538
|
+
case 46:
|
|
539
|
+
if (n.charCodeAt(i + 1) === 46 && n.charCodeAt(i + 2) === 46)
|
|
540
|
+
return p(e, o.SPREAD, i, i + 3);
|
|
541
|
+
break;
|
|
542
|
+
case 58:
|
|
543
|
+
return p(e, o.COLON, i, i + 1);
|
|
544
|
+
case 61:
|
|
545
|
+
return p(e, o.EQUALS, i, i + 1);
|
|
546
|
+
case 64:
|
|
547
|
+
return p(e, o.AT, i, i + 1);
|
|
548
|
+
case 91:
|
|
549
|
+
return p(e, o.BRACKET_L, i, i + 1);
|
|
550
|
+
case 93:
|
|
551
|
+
return p(e, o.BRACKET_R, i, i + 1);
|
|
552
|
+
case 123:
|
|
553
|
+
return p(e, o.BRACE_L, i, i + 1);
|
|
554
|
+
case 124:
|
|
555
|
+
return p(e, o.PIPE, i, i + 1);
|
|
556
|
+
case 125:
|
|
557
|
+
return p(e, o.BRACE_R, i, i + 1);
|
|
558
|
+
// StringValue
|
|
559
|
+
case 34:
|
|
560
|
+
return n.charCodeAt(i + 1) === 34 && n.charCodeAt(i + 2) === 34 ? ye(e, i) : Ne(e, i);
|
|
561
|
+
}
|
|
562
|
+
if (g(r) || r === 45)
|
|
563
|
+
return me(e, i, r);
|
|
564
|
+
if (J(r))
|
|
565
|
+
return Oe(e, i);
|
|
566
|
+
throw d(
|
|
567
|
+
e.source,
|
|
568
|
+
i,
|
|
569
|
+
r === 39 ? `Unexpected single quote character ('), did you mean to use a double quote (")?` : O(r) || S(n, i) ? `Unexpected character: ${T(e, i)}.` : `Invalid character: ${T(e, i)}.`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
return p(e, o.EOF, s, s);
|
|
573
|
+
}
|
|
574
|
+
function Ee(e, t) {
|
|
575
|
+
const n = e.source.body, s = n.length;
|
|
576
|
+
let i = t + 1;
|
|
577
|
+
for (; i < s; ) {
|
|
578
|
+
const r = n.charCodeAt(i);
|
|
579
|
+
if (r === 10 || r === 13)
|
|
580
|
+
break;
|
|
581
|
+
if (O(r))
|
|
582
|
+
++i;
|
|
583
|
+
else if (S(n, i))
|
|
584
|
+
i += 2;
|
|
585
|
+
else
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
return p(
|
|
589
|
+
e,
|
|
590
|
+
o.COMMENT,
|
|
591
|
+
t,
|
|
592
|
+
i,
|
|
593
|
+
n.slice(t + 1, i)
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
function me(e, t, n) {
|
|
597
|
+
const s = e.source.body;
|
|
598
|
+
let i = t, r = n, a = !1;
|
|
599
|
+
if (r === 45 && (r = s.charCodeAt(++i)), r === 48) {
|
|
600
|
+
if (r = s.charCodeAt(++i), g(r))
|
|
601
|
+
throw d(
|
|
602
|
+
e.source,
|
|
603
|
+
i,
|
|
604
|
+
`Invalid number, unexpected digit after 0: ${T(
|
|
605
|
+
e,
|
|
606
|
+
i
|
|
607
|
+
)}.`
|
|
608
|
+
);
|
|
609
|
+
} else
|
|
610
|
+
i = F(e, i, r), r = s.charCodeAt(i);
|
|
611
|
+
if (r === 46 && (a = !0, r = s.charCodeAt(++i), i = F(e, i, r), r = s.charCodeAt(i)), (r === 69 || r === 101) && (a = !0, r = s.charCodeAt(++i), (r === 43 || r === 45) && (r = s.charCodeAt(++i)), i = F(e, i, r), r = s.charCodeAt(i)), r === 46 || J(r))
|
|
612
|
+
throw d(
|
|
613
|
+
e.source,
|
|
614
|
+
i,
|
|
615
|
+
`Invalid number, expected digit but got: ${T(
|
|
616
|
+
e,
|
|
617
|
+
i
|
|
618
|
+
)}.`
|
|
619
|
+
);
|
|
620
|
+
return p(
|
|
621
|
+
e,
|
|
622
|
+
a ? o.FLOAT : o.INT,
|
|
623
|
+
t,
|
|
624
|
+
i,
|
|
625
|
+
s.slice(t, i)
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function F(e, t, n) {
|
|
629
|
+
if (!g(n))
|
|
630
|
+
throw d(
|
|
631
|
+
e.source,
|
|
632
|
+
t,
|
|
633
|
+
`Invalid number, expected digit but got: ${T(
|
|
634
|
+
e,
|
|
635
|
+
t
|
|
636
|
+
)}.`
|
|
637
|
+
);
|
|
638
|
+
const s = e.source.body;
|
|
639
|
+
let i = t + 1;
|
|
640
|
+
for (; g(s.charCodeAt(i)); )
|
|
641
|
+
++i;
|
|
642
|
+
return i;
|
|
643
|
+
}
|
|
644
|
+
function Ne(e, t) {
|
|
645
|
+
const n = e.source.body, s = n.length;
|
|
646
|
+
let i = t + 1, r = i, a = "";
|
|
647
|
+
for (; i < s; ) {
|
|
648
|
+
const u = n.charCodeAt(i);
|
|
649
|
+
if (u === 34)
|
|
650
|
+
return a += n.slice(r, i), p(e, o.STRING, t, i + 1, a);
|
|
651
|
+
if (u === 92) {
|
|
652
|
+
a += n.slice(r, i);
|
|
653
|
+
const l = n.charCodeAt(i + 1) === 117 ? n.charCodeAt(i + 2) === 123 ? Te(e, i) : Ie(e, i) : xe(e, i);
|
|
654
|
+
a += l.value, i += l.size, r = i;
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
if (u === 10 || u === 13)
|
|
658
|
+
break;
|
|
659
|
+
if (O(u))
|
|
660
|
+
++i;
|
|
661
|
+
else if (S(n, i))
|
|
662
|
+
i += 2;
|
|
663
|
+
else
|
|
664
|
+
throw d(
|
|
665
|
+
e.source,
|
|
666
|
+
i,
|
|
667
|
+
`Invalid character within String: ${T(
|
|
668
|
+
e,
|
|
669
|
+
i
|
|
670
|
+
)}.`
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
throw d(e.source, i, "Unterminated string.");
|
|
674
|
+
}
|
|
675
|
+
function Te(e, t) {
|
|
676
|
+
const n = e.source.body;
|
|
677
|
+
let s = 0, i = 3;
|
|
678
|
+
for (; i < 12; ) {
|
|
679
|
+
const r = n.charCodeAt(t + i++);
|
|
680
|
+
if (r === 125) {
|
|
681
|
+
if (i < 5 || !O(s))
|
|
682
|
+
break;
|
|
683
|
+
return {
|
|
684
|
+
value: String.fromCodePoint(s),
|
|
685
|
+
size: i
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
if (s = s << 4 | A(r), s < 0)
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
throw d(
|
|
692
|
+
e.source,
|
|
693
|
+
t,
|
|
694
|
+
`Invalid Unicode escape sequence: "${n.slice(
|
|
695
|
+
t,
|
|
696
|
+
t + i
|
|
697
|
+
)}".`
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
function Ie(e, t) {
|
|
701
|
+
const n = e.source.body, s = j(n, t + 2);
|
|
702
|
+
if (O(s))
|
|
703
|
+
return {
|
|
704
|
+
value: String.fromCodePoint(s),
|
|
705
|
+
size: 6
|
|
706
|
+
};
|
|
707
|
+
if (q(s) && n.charCodeAt(t + 6) === 92 && n.charCodeAt(t + 7) === 117) {
|
|
708
|
+
const i = j(n, t + 8);
|
|
709
|
+
if (X(i))
|
|
710
|
+
return {
|
|
711
|
+
value: String.fromCodePoint(s, i),
|
|
712
|
+
size: 12
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
throw d(
|
|
716
|
+
e.source,
|
|
717
|
+
t,
|
|
718
|
+
`Invalid Unicode escape sequence: "${n.slice(t, t + 6)}".`
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
function j(e, t) {
|
|
722
|
+
return A(e.charCodeAt(t)) << 12 | A(e.charCodeAt(t + 1)) << 8 | A(e.charCodeAt(t + 2)) << 4 | A(e.charCodeAt(t + 3));
|
|
723
|
+
}
|
|
724
|
+
function A(e) {
|
|
725
|
+
return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : -1;
|
|
726
|
+
}
|
|
727
|
+
function xe(e, t) {
|
|
728
|
+
const n = e.source.body;
|
|
729
|
+
switch (n.charCodeAt(t + 1)) {
|
|
730
|
+
case 34:
|
|
731
|
+
return {
|
|
732
|
+
value: '"',
|
|
733
|
+
size: 2
|
|
734
|
+
};
|
|
735
|
+
case 92:
|
|
736
|
+
return {
|
|
737
|
+
value: "\\",
|
|
738
|
+
size: 2
|
|
739
|
+
};
|
|
740
|
+
case 47:
|
|
741
|
+
return {
|
|
742
|
+
value: "/",
|
|
743
|
+
size: 2
|
|
744
|
+
};
|
|
745
|
+
case 98:
|
|
746
|
+
return {
|
|
747
|
+
value: "\b",
|
|
748
|
+
size: 2
|
|
749
|
+
};
|
|
750
|
+
case 102:
|
|
751
|
+
return {
|
|
752
|
+
value: "\f",
|
|
753
|
+
size: 2
|
|
754
|
+
};
|
|
755
|
+
case 110:
|
|
756
|
+
return {
|
|
757
|
+
value: `
|
|
758
|
+
`,
|
|
759
|
+
size: 2
|
|
760
|
+
};
|
|
761
|
+
case 114:
|
|
762
|
+
return {
|
|
763
|
+
value: "\r",
|
|
764
|
+
size: 2
|
|
765
|
+
};
|
|
766
|
+
case 116:
|
|
767
|
+
return {
|
|
768
|
+
value: " ",
|
|
769
|
+
size: 2
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
throw d(
|
|
773
|
+
e.source,
|
|
774
|
+
t,
|
|
775
|
+
`Invalid character escape sequence: "${n.slice(
|
|
776
|
+
t,
|
|
777
|
+
t + 2
|
|
778
|
+
)}".`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
function ye(e, t) {
|
|
782
|
+
const n = e.source.body, s = n.length;
|
|
783
|
+
let i = e.lineStart, r = t + 3, a = r, u = "";
|
|
784
|
+
const l = [];
|
|
785
|
+
for (; r < s; ) {
|
|
786
|
+
const E = n.charCodeAt(r);
|
|
787
|
+
if (E === 34 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34) {
|
|
788
|
+
u += n.slice(a, r), l.push(u);
|
|
789
|
+
const h = p(
|
|
790
|
+
e,
|
|
791
|
+
o.BLOCK_STRING,
|
|
792
|
+
t,
|
|
793
|
+
r + 3,
|
|
794
|
+
// Return a string of the lines joined with U+000A.
|
|
795
|
+
le(l).join(`
|
|
796
|
+
`)
|
|
797
|
+
);
|
|
798
|
+
return e.line += l.length - 1, e.lineStart = i, h;
|
|
799
|
+
}
|
|
800
|
+
if (E === 92 && n.charCodeAt(r + 1) === 34 && n.charCodeAt(r + 2) === 34 && n.charCodeAt(r + 3) === 34) {
|
|
801
|
+
u += n.slice(a, r), a = r + 1, r += 4;
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (E === 10 || E === 13) {
|
|
805
|
+
u += n.slice(a, r), l.push(u), E === 13 && n.charCodeAt(r + 1) === 10 ? r += 2 : ++r, u = "", a = r, i = r;
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if (O(E))
|
|
809
|
+
++r;
|
|
810
|
+
else if (S(n, r))
|
|
811
|
+
r += 2;
|
|
812
|
+
else
|
|
813
|
+
throw d(
|
|
814
|
+
e.source,
|
|
815
|
+
r,
|
|
816
|
+
`Invalid character within String: ${T(
|
|
817
|
+
e,
|
|
818
|
+
r
|
|
819
|
+
)}.`
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
throw d(e.source, r, "Unterminated string.");
|
|
823
|
+
}
|
|
824
|
+
function Oe(e, t) {
|
|
825
|
+
const n = e.source.body, s = n.length;
|
|
826
|
+
let i = t + 1;
|
|
827
|
+
for (; i < s; ) {
|
|
828
|
+
const r = n.charCodeAt(i);
|
|
829
|
+
if (ue(r))
|
|
830
|
+
++i;
|
|
831
|
+
else
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
return p(
|
|
835
|
+
e,
|
|
836
|
+
o.NAME,
|
|
837
|
+
t,
|
|
838
|
+
i,
|
|
839
|
+
n.slice(t, i)
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
const _e = 10, Q = 2;
|
|
843
|
+
function z(e) {
|
|
844
|
+
return b(e, []);
|
|
845
|
+
}
|
|
846
|
+
function b(e, t) {
|
|
847
|
+
switch (typeof e) {
|
|
848
|
+
case "string":
|
|
849
|
+
return JSON.stringify(e);
|
|
850
|
+
case "function":
|
|
851
|
+
return e.name ? `[function ${e.name}]` : "[function]";
|
|
852
|
+
case "object":
|
|
853
|
+
return Ae(e, t);
|
|
854
|
+
default:
|
|
855
|
+
return String(e);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function Ae(e, t) {
|
|
859
|
+
if (e === null)
|
|
860
|
+
return "null";
|
|
861
|
+
if (t.includes(e))
|
|
862
|
+
return "[Circular]";
|
|
863
|
+
const n = [...t, e];
|
|
864
|
+
if (ge(e)) {
|
|
865
|
+
const s = e.toJSON();
|
|
866
|
+
if (s !== e)
|
|
867
|
+
return typeof s == "string" ? s : b(s, n);
|
|
868
|
+
} else if (Array.isArray(e))
|
|
869
|
+
return De(e, n);
|
|
870
|
+
return ve(e, n);
|
|
871
|
+
}
|
|
872
|
+
function ge(e) {
|
|
873
|
+
return typeof e.toJSON == "function";
|
|
874
|
+
}
|
|
875
|
+
function ve(e, t) {
|
|
876
|
+
const n = Object.entries(e);
|
|
877
|
+
return n.length === 0 ? "{}" : t.length > Q ? "[" + ke(e) + "]" : "{ " + n.map(
|
|
878
|
+
([i, r]) => i + ": " + b(r, t)
|
|
879
|
+
).join(", ") + " }";
|
|
880
|
+
}
|
|
881
|
+
function De(e, t) {
|
|
882
|
+
if (e.length === 0)
|
|
883
|
+
return "[]";
|
|
884
|
+
if (t.length > Q)
|
|
885
|
+
return "[Array]";
|
|
886
|
+
const n = Math.min(_e, e.length), s = e.length - n, i = [];
|
|
887
|
+
for (let r = 0; r < n; ++r)
|
|
888
|
+
i.push(b(e[r], t));
|
|
889
|
+
return s === 1 ? i.push("... 1 more item") : s > 1 && i.push(`... ${s} more items`), "[" + i.join(", ") + "]";
|
|
890
|
+
}
|
|
891
|
+
function ke(e) {
|
|
892
|
+
const t = Object.prototype.toString.call(e).replace(/^\[object /, "").replace(/]$/, "");
|
|
893
|
+
if (t === "Object" && typeof e.constructor == "function") {
|
|
894
|
+
const n = e.constructor.name;
|
|
895
|
+
if (typeof n == "string" && n !== "")
|
|
896
|
+
return n;
|
|
897
|
+
}
|
|
898
|
+
return t;
|
|
899
|
+
}
|
|
900
|
+
const Ce = globalThis.process && // eslint-disable-next-line no-undef
|
|
901
|
+
process.env.NODE_ENV === "production", Se = (
|
|
902
|
+
/* c8 ignore next 6 */
|
|
903
|
+
// FIXME: https://github.com/graphql/graphql-js/issues/2317
|
|
904
|
+
Ce ? function(t, n) {
|
|
905
|
+
return t instanceof n;
|
|
906
|
+
} : function(t, n) {
|
|
907
|
+
if (t instanceof n)
|
|
908
|
+
return !0;
|
|
909
|
+
if (typeof t == "object" && t !== null) {
|
|
910
|
+
var s;
|
|
911
|
+
const i = n.prototype[Symbol.toStringTag], r = (
|
|
912
|
+
// We still need to support constructor's name to detect conflicts with older versions of this library.
|
|
913
|
+
Symbol.toStringTag in t ? t[Symbol.toStringTag] : (s = t.constructor) === null || s === void 0 ? void 0 : s.name
|
|
914
|
+
);
|
|
915
|
+
if (i === r) {
|
|
916
|
+
const a = z(t);
|
|
917
|
+
throw new Error(`Cannot use ${i} "${a}" from another module or realm.
|
|
918
|
+
|
|
919
|
+
Ensure that there is only one instance of "graphql" in the node_modules
|
|
920
|
+
directory. If different versions of "graphql" are the dependencies of other
|
|
921
|
+
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
922
|
+
|
|
923
|
+
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
924
|
+
|
|
925
|
+
Duplicate "graphql" modules cannot be used at the same time since different
|
|
926
|
+
versions may have different capabilities and behavior. The data from one
|
|
927
|
+
version used in the function from another could produce confusing and
|
|
928
|
+
spurious results.`);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return !1;
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
class W {
|
|
935
|
+
constructor(t, n = "GraphQL request", s = {
|
|
936
|
+
line: 1,
|
|
937
|
+
column: 1
|
|
938
|
+
}) {
|
|
939
|
+
typeof t == "string" || R(!1, `Body must be a string. Received: ${z(t)}.`), this.body = t, this.name = n, this.locationOffset = s, this.locationOffset.line > 0 || R(
|
|
940
|
+
!1,
|
|
941
|
+
"line in locationOffset is 1-indexed and must be positive."
|
|
942
|
+
), this.locationOffset.column > 0 || R(
|
|
943
|
+
!1,
|
|
944
|
+
"column in locationOffset is 1-indexed and must be positive."
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
get [Symbol.toStringTag]() {
|
|
948
|
+
return "Source";
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
function be(e) {
|
|
952
|
+
return Se(e, W);
|
|
953
|
+
}
|
|
954
|
+
function Le(e, t) {
|
|
955
|
+
const n = new Re(e, t), s = n.parseDocument();
|
|
956
|
+
return Object.defineProperty(s, "tokenCount", {
|
|
957
|
+
enumerable: !1,
|
|
958
|
+
value: n.tokenCount
|
|
959
|
+
}), s;
|
|
960
|
+
}
|
|
961
|
+
class Re {
|
|
962
|
+
constructor(t, n = {}) {
|
|
963
|
+
const s = be(t) ? t : new W(t);
|
|
964
|
+
this._lexer = new he(s), this._options = n, this._tokenCounter = 0;
|
|
965
|
+
}
|
|
966
|
+
get tokenCount() {
|
|
967
|
+
return this._tokenCounter;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Converts a name lex token into a name parse node.
|
|
971
|
+
*/
|
|
972
|
+
parseName() {
|
|
973
|
+
const t = this.expectToken(o.NAME);
|
|
974
|
+
return this.node(t, {
|
|
975
|
+
kind: c.NAME,
|
|
976
|
+
value: t.value
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
// Implements the parsing rules in the Document section.
|
|
980
|
+
/**
|
|
981
|
+
* Document : Definition+
|
|
982
|
+
*/
|
|
983
|
+
parseDocument() {
|
|
984
|
+
return this.node(this._lexer.token, {
|
|
985
|
+
kind: c.DOCUMENT,
|
|
986
|
+
definitions: this.many(
|
|
987
|
+
o.SOF,
|
|
988
|
+
this.parseDefinition,
|
|
989
|
+
o.EOF
|
|
990
|
+
)
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Definition :
|
|
995
|
+
* - ExecutableDefinition
|
|
996
|
+
* - TypeSystemDefinition
|
|
997
|
+
* - TypeSystemExtension
|
|
998
|
+
*
|
|
999
|
+
* ExecutableDefinition :
|
|
1000
|
+
* - OperationDefinition
|
|
1001
|
+
* - FragmentDefinition
|
|
1002
|
+
*
|
|
1003
|
+
* TypeSystemDefinition :
|
|
1004
|
+
* - SchemaDefinition
|
|
1005
|
+
* - TypeDefinition
|
|
1006
|
+
* - DirectiveDefinition
|
|
1007
|
+
*
|
|
1008
|
+
* TypeDefinition :
|
|
1009
|
+
* - ScalarTypeDefinition
|
|
1010
|
+
* - ObjectTypeDefinition
|
|
1011
|
+
* - InterfaceTypeDefinition
|
|
1012
|
+
* - UnionTypeDefinition
|
|
1013
|
+
* - EnumTypeDefinition
|
|
1014
|
+
* - InputObjectTypeDefinition
|
|
1015
|
+
*/
|
|
1016
|
+
parseDefinition() {
|
|
1017
|
+
if (this.peek(o.BRACE_L))
|
|
1018
|
+
return this.parseOperationDefinition();
|
|
1019
|
+
const t = this.peekDescription(), n = t ? this._lexer.lookahead() : this._lexer.token;
|
|
1020
|
+
if (n.kind === o.NAME) {
|
|
1021
|
+
switch (n.value) {
|
|
1022
|
+
case "schema":
|
|
1023
|
+
return this.parseSchemaDefinition();
|
|
1024
|
+
case "scalar":
|
|
1025
|
+
return this.parseScalarTypeDefinition();
|
|
1026
|
+
case "type":
|
|
1027
|
+
return this.parseObjectTypeDefinition();
|
|
1028
|
+
case "interface":
|
|
1029
|
+
return this.parseInterfaceTypeDefinition();
|
|
1030
|
+
case "union":
|
|
1031
|
+
return this.parseUnionTypeDefinition();
|
|
1032
|
+
case "enum":
|
|
1033
|
+
return this.parseEnumTypeDefinition();
|
|
1034
|
+
case "input":
|
|
1035
|
+
return this.parseInputObjectTypeDefinition();
|
|
1036
|
+
case "directive":
|
|
1037
|
+
return this.parseDirectiveDefinition();
|
|
1038
|
+
}
|
|
1039
|
+
if (t)
|
|
1040
|
+
throw d(
|
|
1041
|
+
this._lexer.source,
|
|
1042
|
+
this._lexer.token.start,
|
|
1043
|
+
"Unexpected description, descriptions are supported only on type definitions."
|
|
1044
|
+
);
|
|
1045
|
+
switch (n.value) {
|
|
1046
|
+
case "query":
|
|
1047
|
+
case "mutation":
|
|
1048
|
+
case "subscription":
|
|
1049
|
+
return this.parseOperationDefinition();
|
|
1050
|
+
case "fragment":
|
|
1051
|
+
return this.parseFragmentDefinition();
|
|
1052
|
+
case "extend":
|
|
1053
|
+
return this.parseTypeSystemExtension();
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
throw this.unexpected(n);
|
|
1057
|
+
}
|
|
1058
|
+
// Implements the parsing rules in the Operations section.
|
|
1059
|
+
/**
|
|
1060
|
+
* OperationDefinition :
|
|
1061
|
+
* - SelectionSet
|
|
1062
|
+
* - OperationType Name? VariableDefinitions? Directives? SelectionSet
|
|
1063
|
+
*/
|
|
1064
|
+
parseOperationDefinition() {
|
|
1065
|
+
const t = this._lexer.token;
|
|
1066
|
+
if (this.peek(o.BRACE_L))
|
|
1067
|
+
return this.node(t, {
|
|
1068
|
+
kind: c.OPERATION_DEFINITION,
|
|
1069
|
+
operation: y.QUERY,
|
|
1070
|
+
name: void 0,
|
|
1071
|
+
variableDefinitions: [],
|
|
1072
|
+
directives: [],
|
|
1073
|
+
selectionSet: this.parseSelectionSet()
|
|
1074
|
+
});
|
|
1075
|
+
const n = this.parseOperationType();
|
|
1076
|
+
let s;
|
|
1077
|
+
return this.peek(o.NAME) && (s = this.parseName()), this.node(t, {
|
|
1078
|
+
kind: c.OPERATION_DEFINITION,
|
|
1079
|
+
operation: n,
|
|
1080
|
+
name: s,
|
|
1081
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
1082
|
+
directives: this.parseDirectives(!1),
|
|
1083
|
+
selectionSet: this.parseSelectionSet()
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* OperationType : one of query mutation subscription
|
|
1088
|
+
*/
|
|
1089
|
+
parseOperationType() {
|
|
1090
|
+
const t = this.expectToken(o.NAME);
|
|
1091
|
+
switch (t.value) {
|
|
1092
|
+
case "query":
|
|
1093
|
+
return y.QUERY;
|
|
1094
|
+
case "mutation":
|
|
1095
|
+
return y.MUTATION;
|
|
1096
|
+
case "subscription":
|
|
1097
|
+
return y.SUBSCRIPTION;
|
|
1098
|
+
}
|
|
1099
|
+
throw this.unexpected(t);
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* VariableDefinitions : ( VariableDefinition+ )
|
|
1103
|
+
*/
|
|
1104
|
+
parseVariableDefinitions() {
|
|
1105
|
+
return this.optionalMany(
|
|
1106
|
+
o.PAREN_L,
|
|
1107
|
+
this.parseVariableDefinition,
|
|
1108
|
+
o.PAREN_R
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* VariableDefinition : Variable : Type DefaultValue? Directives[Const]?
|
|
1113
|
+
*/
|
|
1114
|
+
parseVariableDefinition() {
|
|
1115
|
+
return this.node(this._lexer.token, {
|
|
1116
|
+
kind: c.VARIABLE_DEFINITION,
|
|
1117
|
+
variable: this.parseVariable(),
|
|
1118
|
+
type: (this.expectToken(o.COLON), this.parseTypeReference()),
|
|
1119
|
+
defaultValue: this.expectOptionalToken(o.EQUALS) ? this.parseConstValueLiteral() : void 0,
|
|
1120
|
+
directives: this.parseConstDirectives()
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Variable : $ Name
|
|
1125
|
+
*/
|
|
1126
|
+
parseVariable() {
|
|
1127
|
+
const t = this._lexer.token;
|
|
1128
|
+
return this.expectToken(o.DOLLAR), this.node(t, {
|
|
1129
|
+
kind: c.VARIABLE,
|
|
1130
|
+
name: this.parseName()
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* ```
|
|
1135
|
+
* SelectionSet : { Selection+ }
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
parseSelectionSet() {
|
|
1139
|
+
return this.node(this._lexer.token, {
|
|
1140
|
+
kind: c.SELECTION_SET,
|
|
1141
|
+
selections: this.many(
|
|
1142
|
+
o.BRACE_L,
|
|
1143
|
+
this.parseSelection,
|
|
1144
|
+
o.BRACE_R
|
|
1145
|
+
)
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Selection :
|
|
1150
|
+
* - Field
|
|
1151
|
+
* - FragmentSpread
|
|
1152
|
+
* - InlineFragment
|
|
1153
|
+
*/
|
|
1154
|
+
parseSelection() {
|
|
1155
|
+
return this.peek(o.SPREAD) ? this.parseFragment() : this.parseField();
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Field : Alias? Name Arguments? Directives? SelectionSet?
|
|
1159
|
+
*
|
|
1160
|
+
* Alias : Name :
|
|
1161
|
+
*/
|
|
1162
|
+
parseField() {
|
|
1163
|
+
const t = this._lexer.token, n = this.parseName();
|
|
1164
|
+
let s, i;
|
|
1165
|
+
return this.expectOptionalToken(o.COLON) ? (s = n, i = this.parseName()) : i = n, this.node(t, {
|
|
1166
|
+
kind: c.FIELD,
|
|
1167
|
+
alias: s,
|
|
1168
|
+
name: i,
|
|
1169
|
+
arguments: this.parseArguments(!1),
|
|
1170
|
+
directives: this.parseDirectives(!1),
|
|
1171
|
+
selectionSet: this.peek(o.BRACE_L) ? this.parseSelectionSet() : void 0
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Arguments[Const] : ( Argument[?Const]+ )
|
|
1176
|
+
*/
|
|
1177
|
+
parseArguments(t) {
|
|
1178
|
+
const n = t ? this.parseConstArgument : this.parseArgument;
|
|
1179
|
+
return this.optionalMany(o.PAREN_L, n, o.PAREN_R);
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Argument[Const] : Name : Value[?Const]
|
|
1183
|
+
*/
|
|
1184
|
+
parseArgument(t = !1) {
|
|
1185
|
+
const n = this._lexer.token, s = this.parseName();
|
|
1186
|
+
return this.expectToken(o.COLON), this.node(n, {
|
|
1187
|
+
kind: c.ARGUMENT,
|
|
1188
|
+
name: s,
|
|
1189
|
+
value: this.parseValueLiteral(t)
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
parseConstArgument() {
|
|
1193
|
+
return this.parseArgument(!0);
|
|
1194
|
+
}
|
|
1195
|
+
// Implements the parsing rules in the Fragments section.
|
|
1196
|
+
/**
|
|
1197
|
+
* Corresponds to both FragmentSpread and InlineFragment in the spec.
|
|
1198
|
+
*
|
|
1199
|
+
* FragmentSpread : ... FragmentName Directives?
|
|
1200
|
+
*
|
|
1201
|
+
* InlineFragment : ... TypeCondition? Directives? SelectionSet
|
|
1202
|
+
*/
|
|
1203
|
+
parseFragment() {
|
|
1204
|
+
const t = this._lexer.token;
|
|
1205
|
+
this.expectToken(o.SPREAD);
|
|
1206
|
+
const n = this.expectOptionalKeyword("on");
|
|
1207
|
+
return !n && this.peek(o.NAME) ? this.node(t, {
|
|
1208
|
+
kind: c.FRAGMENT_SPREAD,
|
|
1209
|
+
name: this.parseFragmentName(),
|
|
1210
|
+
directives: this.parseDirectives(!1)
|
|
1211
|
+
}) : this.node(t, {
|
|
1212
|
+
kind: c.INLINE_FRAGMENT,
|
|
1213
|
+
typeCondition: n ? this.parseNamedType() : void 0,
|
|
1214
|
+
directives: this.parseDirectives(!1),
|
|
1215
|
+
selectionSet: this.parseSelectionSet()
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* FragmentDefinition :
|
|
1220
|
+
* - fragment FragmentName on TypeCondition Directives? SelectionSet
|
|
1221
|
+
*
|
|
1222
|
+
* TypeCondition : NamedType
|
|
1223
|
+
*/
|
|
1224
|
+
parseFragmentDefinition() {
|
|
1225
|
+
const t = this._lexer.token;
|
|
1226
|
+
return this.expectKeyword("fragment"), this._options.allowLegacyFragmentVariables === !0 ? this.node(t, {
|
|
1227
|
+
kind: c.FRAGMENT_DEFINITION,
|
|
1228
|
+
name: this.parseFragmentName(),
|
|
1229
|
+
variableDefinitions: this.parseVariableDefinitions(),
|
|
1230
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
1231
|
+
directives: this.parseDirectives(!1),
|
|
1232
|
+
selectionSet: this.parseSelectionSet()
|
|
1233
|
+
}) : this.node(t, {
|
|
1234
|
+
kind: c.FRAGMENT_DEFINITION,
|
|
1235
|
+
name: this.parseFragmentName(),
|
|
1236
|
+
typeCondition: (this.expectKeyword("on"), this.parseNamedType()),
|
|
1237
|
+
directives: this.parseDirectives(!1),
|
|
1238
|
+
selectionSet: this.parseSelectionSet()
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* FragmentName : Name but not `on`
|
|
1243
|
+
*/
|
|
1244
|
+
parseFragmentName() {
|
|
1245
|
+
if (this._lexer.token.value === "on")
|
|
1246
|
+
throw this.unexpected();
|
|
1247
|
+
return this.parseName();
|
|
1248
|
+
}
|
|
1249
|
+
// Implements the parsing rules in the Values section.
|
|
1250
|
+
/**
|
|
1251
|
+
* Value[Const] :
|
|
1252
|
+
* - [~Const] Variable
|
|
1253
|
+
* - IntValue
|
|
1254
|
+
* - FloatValue
|
|
1255
|
+
* - StringValue
|
|
1256
|
+
* - BooleanValue
|
|
1257
|
+
* - NullValue
|
|
1258
|
+
* - EnumValue
|
|
1259
|
+
* - ListValue[?Const]
|
|
1260
|
+
* - ObjectValue[?Const]
|
|
1261
|
+
*
|
|
1262
|
+
* BooleanValue : one of `true` `false`
|
|
1263
|
+
*
|
|
1264
|
+
* NullValue : `null`
|
|
1265
|
+
*
|
|
1266
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
1267
|
+
*/
|
|
1268
|
+
parseValueLiteral(t) {
|
|
1269
|
+
const n = this._lexer.token;
|
|
1270
|
+
switch (n.kind) {
|
|
1271
|
+
case o.BRACKET_L:
|
|
1272
|
+
return this.parseList(t);
|
|
1273
|
+
case o.BRACE_L:
|
|
1274
|
+
return this.parseObject(t);
|
|
1275
|
+
case o.INT:
|
|
1276
|
+
return this.advanceLexer(), this.node(n, {
|
|
1277
|
+
kind: c.INT,
|
|
1278
|
+
value: n.value
|
|
1279
|
+
});
|
|
1280
|
+
case o.FLOAT:
|
|
1281
|
+
return this.advanceLexer(), this.node(n, {
|
|
1282
|
+
kind: c.FLOAT,
|
|
1283
|
+
value: n.value
|
|
1284
|
+
});
|
|
1285
|
+
case o.STRING:
|
|
1286
|
+
case o.BLOCK_STRING:
|
|
1287
|
+
return this.parseStringLiteral();
|
|
1288
|
+
case o.NAME:
|
|
1289
|
+
switch (this.advanceLexer(), n.value) {
|
|
1290
|
+
case "true":
|
|
1291
|
+
return this.node(n, {
|
|
1292
|
+
kind: c.BOOLEAN,
|
|
1293
|
+
value: !0
|
|
1294
|
+
});
|
|
1295
|
+
case "false":
|
|
1296
|
+
return this.node(n, {
|
|
1297
|
+
kind: c.BOOLEAN,
|
|
1298
|
+
value: !1
|
|
1299
|
+
});
|
|
1300
|
+
case "null":
|
|
1301
|
+
return this.node(n, {
|
|
1302
|
+
kind: c.NULL
|
|
1303
|
+
});
|
|
1304
|
+
default:
|
|
1305
|
+
return this.node(n, {
|
|
1306
|
+
kind: c.ENUM,
|
|
1307
|
+
value: n.value
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
case o.DOLLAR:
|
|
1311
|
+
if (t)
|
|
1312
|
+
if (this.expectToken(o.DOLLAR), this._lexer.token.kind === o.NAME) {
|
|
1313
|
+
const s = this._lexer.token.value;
|
|
1314
|
+
throw d(
|
|
1315
|
+
this._lexer.source,
|
|
1316
|
+
n.start,
|
|
1317
|
+
`Unexpected variable "$${s}" in constant value.`
|
|
1318
|
+
);
|
|
1319
|
+
} else
|
|
1320
|
+
throw this.unexpected(n);
|
|
1321
|
+
return this.parseVariable();
|
|
1322
|
+
default:
|
|
1323
|
+
throw this.unexpected();
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
parseConstValueLiteral() {
|
|
1327
|
+
return this.parseValueLiteral(!0);
|
|
1328
|
+
}
|
|
1329
|
+
parseStringLiteral() {
|
|
1330
|
+
const t = this._lexer.token;
|
|
1331
|
+
return this.advanceLexer(), this.node(t, {
|
|
1332
|
+
kind: c.STRING,
|
|
1333
|
+
value: t.value,
|
|
1334
|
+
block: t.kind === o.BLOCK_STRING
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* ListValue[Const] :
|
|
1339
|
+
* - [ ]
|
|
1340
|
+
* - [ Value[?Const]+ ]
|
|
1341
|
+
*/
|
|
1342
|
+
parseList(t) {
|
|
1343
|
+
const n = () => this.parseValueLiteral(t);
|
|
1344
|
+
return this.node(this._lexer.token, {
|
|
1345
|
+
kind: c.LIST,
|
|
1346
|
+
values: this.any(o.BRACKET_L, n, o.BRACKET_R)
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* ```
|
|
1351
|
+
* ObjectValue[Const] :
|
|
1352
|
+
* - { }
|
|
1353
|
+
* - { ObjectField[?Const]+ }
|
|
1354
|
+
* ```
|
|
1355
|
+
*/
|
|
1356
|
+
parseObject(t) {
|
|
1357
|
+
const n = () => this.parseObjectField(t);
|
|
1358
|
+
return this.node(this._lexer.token, {
|
|
1359
|
+
kind: c.OBJECT,
|
|
1360
|
+
fields: this.any(o.BRACE_L, n, o.BRACE_R)
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* ObjectField[Const] : Name : Value[?Const]
|
|
1365
|
+
*/
|
|
1366
|
+
parseObjectField(t) {
|
|
1367
|
+
const n = this._lexer.token, s = this.parseName();
|
|
1368
|
+
return this.expectToken(o.COLON), this.node(n, {
|
|
1369
|
+
kind: c.OBJECT_FIELD,
|
|
1370
|
+
name: s,
|
|
1371
|
+
value: this.parseValueLiteral(t)
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
// Implements the parsing rules in the Directives section.
|
|
1375
|
+
/**
|
|
1376
|
+
* Directives[Const] : Directive[?Const]+
|
|
1377
|
+
*/
|
|
1378
|
+
parseDirectives(t) {
|
|
1379
|
+
const n = [];
|
|
1380
|
+
for (; this.peek(o.AT); )
|
|
1381
|
+
n.push(this.parseDirective(t));
|
|
1382
|
+
return n;
|
|
1383
|
+
}
|
|
1384
|
+
parseConstDirectives() {
|
|
1385
|
+
return this.parseDirectives(!0);
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* ```
|
|
1389
|
+
* Directive[Const] : @ Name Arguments[?Const]?
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
parseDirective(t) {
|
|
1393
|
+
const n = this._lexer.token;
|
|
1394
|
+
return this.expectToken(o.AT), this.node(n, {
|
|
1395
|
+
kind: c.DIRECTIVE,
|
|
1396
|
+
name: this.parseName(),
|
|
1397
|
+
arguments: this.parseArguments(t)
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
// Implements the parsing rules in the Types section.
|
|
1401
|
+
/**
|
|
1402
|
+
* Type :
|
|
1403
|
+
* - NamedType
|
|
1404
|
+
* - ListType
|
|
1405
|
+
* - NonNullType
|
|
1406
|
+
*/
|
|
1407
|
+
parseTypeReference() {
|
|
1408
|
+
const t = this._lexer.token;
|
|
1409
|
+
let n;
|
|
1410
|
+
if (this.expectOptionalToken(o.BRACKET_L)) {
|
|
1411
|
+
const s = this.parseTypeReference();
|
|
1412
|
+
this.expectToken(o.BRACKET_R), n = this.node(t, {
|
|
1413
|
+
kind: c.LIST_TYPE,
|
|
1414
|
+
type: s
|
|
1415
|
+
});
|
|
1416
|
+
} else
|
|
1417
|
+
n = this.parseNamedType();
|
|
1418
|
+
return this.expectOptionalToken(o.BANG) ? this.node(t, {
|
|
1419
|
+
kind: c.NON_NULL_TYPE,
|
|
1420
|
+
type: n
|
|
1421
|
+
}) : n;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* NamedType : Name
|
|
1425
|
+
*/
|
|
1426
|
+
parseNamedType() {
|
|
1427
|
+
return this.node(this._lexer.token, {
|
|
1428
|
+
kind: c.NAMED_TYPE,
|
|
1429
|
+
name: this.parseName()
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
// Implements the parsing rules in the Type Definition section.
|
|
1433
|
+
peekDescription() {
|
|
1434
|
+
return this.peek(o.STRING) || this.peek(o.BLOCK_STRING);
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Description : StringValue
|
|
1438
|
+
*/
|
|
1439
|
+
parseDescription() {
|
|
1440
|
+
if (this.peekDescription())
|
|
1441
|
+
return this.parseStringLiteral();
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* ```
|
|
1445
|
+
* SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ }
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
parseSchemaDefinition() {
|
|
1449
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1450
|
+
this.expectKeyword("schema");
|
|
1451
|
+
const s = this.parseConstDirectives(), i = this.many(
|
|
1452
|
+
o.BRACE_L,
|
|
1453
|
+
this.parseOperationTypeDefinition,
|
|
1454
|
+
o.BRACE_R
|
|
1455
|
+
);
|
|
1456
|
+
return this.node(t, {
|
|
1457
|
+
kind: c.SCHEMA_DEFINITION,
|
|
1458
|
+
description: n,
|
|
1459
|
+
directives: s,
|
|
1460
|
+
operationTypes: i
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* OperationTypeDefinition : OperationType : NamedType
|
|
1465
|
+
*/
|
|
1466
|
+
parseOperationTypeDefinition() {
|
|
1467
|
+
const t = this._lexer.token, n = this.parseOperationType();
|
|
1468
|
+
this.expectToken(o.COLON);
|
|
1469
|
+
const s = this.parseNamedType();
|
|
1470
|
+
return this.node(t, {
|
|
1471
|
+
kind: c.OPERATION_TYPE_DEFINITION,
|
|
1472
|
+
operation: n,
|
|
1473
|
+
type: s
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* ScalarTypeDefinition : Description? scalar Name Directives[Const]?
|
|
1478
|
+
*/
|
|
1479
|
+
parseScalarTypeDefinition() {
|
|
1480
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1481
|
+
this.expectKeyword("scalar");
|
|
1482
|
+
const s = this.parseName(), i = this.parseConstDirectives();
|
|
1483
|
+
return this.node(t, {
|
|
1484
|
+
kind: c.SCALAR_TYPE_DEFINITION,
|
|
1485
|
+
description: n,
|
|
1486
|
+
name: s,
|
|
1487
|
+
directives: i
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* ObjectTypeDefinition :
|
|
1492
|
+
* Description?
|
|
1493
|
+
* type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
|
|
1494
|
+
*/
|
|
1495
|
+
parseObjectTypeDefinition() {
|
|
1496
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1497
|
+
this.expectKeyword("type");
|
|
1498
|
+
const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
|
|
1499
|
+
return this.node(t, {
|
|
1500
|
+
kind: c.OBJECT_TYPE_DEFINITION,
|
|
1501
|
+
description: n,
|
|
1502
|
+
name: s,
|
|
1503
|
+
interfaces: i,
|
|
1504
|
+
directives: r,
|
|
1505
|
+
fields: a
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* ImplementsInterfaces :
|
|
1510
|
+
* - implements `&`? NamedType
|
|
1511
|
+
* - ImplementsInterfaces & NamedType
|
|
1512
|
+
*/
|
|
1513
|
+
parseImplementsInterfaces() {
|
|
1514
|
+
return this.expectOptionalKeyword("implements") ? this.delimitedMany(o.AMP, this.parseNamedType) : [];
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* ```
|
|
1518
|
+
* FieldsDefinition : { FieldDefinition+ }
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
parseFieldsDefinition() {
|
|
1522
|
+
return this.optionalMany(
|
|
1523
|
+
o.BRACE_L,
|
|
1524
|
+
this.parseFieldDefinition,
|
|
1525
|
+
o.BRACE_R
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* FieldDefinition :
|
|
1530
|
+
* - Description? Name ArgumentsDefinition? : Type Directives[Const]?
|
|
1531
|
+
*/
|
|
1532
|
+
parseFieldDefinition() {
|
|
1533
|
+
const t = this._lexer.token, n = this.parseDescription(), s = this.parseName(), i = this.parseArgumentDefs();
|
|
1534
|
+
this.expectToken(o.COLON);
|
|
1535
|
+
const r = this.parseTypeReference(), a = this.parseConstDirectives();
|
|
1536
|
+
return this.node(t, {
|
|
1537
|
+
kind: c.FIELD_DEFINITION,
|
|
1538
|
+
description: n,
|
|
1539
|
+
name: s,
|
|
1540
|
+
arguments: i,
|
|
1541
|
+
type: r,
|
|
1542
|
+
directives: a
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* ArgumentsDefinition : ( InputValueDefinition+ )
|
|
1547
|
+
*/
|
|
1548
|
+
parseArgumentDefs() {
|
|
1549
|
+
return this.optionalMany(
|
|
1550
|
+
o.PAREN_L,
|
|
1551
|
+
this.parseInputValueDef,
|
|
1552
|
+
o.PAREN_R
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* InputValueDefinition :
|
|
1557
|
+
* - Description? Name : Type DefaultValue? Directives[Const]?
|
|
1558
|
+
*/
|
|
1559
|
+
parseInputValueDef() {
|
|
1560
|
+
const t = this._lexer.token, n = this.parseDescription(), s = this.parseName();
|
|
1561
|
+
this.expectToken(o.COLON);
|
|
1562
|
+
const i = this.parseTypeReference();
|
|
1563
|
+
let r;
|
|
1564
|
+
this.expectOptionalToken(o.EQUALS) && (r = this.parseConstValueLiteral());
|
|
1565
|
+
const a = this.parseConstDirectives();
|
|
1566
|
+
return this.node(t, {
|
|
1567
|
+
kind: c.INPUT_VALUE_DEFINITION,
|
|
1568
|
+
description: n,
|
|
1569
|
+
name: s,
|
|
1570
|
+
type: i,
|
|
1571
|
+
defaultValue: r,
|
|
1572
|
+
directives: a
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* InterfaceTypeDefinition :
|
|
1577
|
+
* - Description? interface Name Directives[Const]? FieldsDefinition?
|
|
1578
|
+
*/
|
|
1579
|
+
parseInterfaceTypeDefinition() {
|
|
1580
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1581
|
+
this.expectKeyword("interface");
|
|
1582
|
+
const s = this.parseName(), i = this.parseImplementsInterfaces(), r = this.parseConstDirectives(), a = this.parseFieldsDefinition();
|
|
1583
|
+
return this.node(t, {
|
|
1584
|
+
kind: c.INTERFACE_TYPE_DEFINITION,
|
|
1585
|
+
description: n,
|
|
1586
|
+
name: s,
|
|
1587
|
+
interfaces: i,
|
|
1588
|
+
directives: r,
|
|
1589
|
+
fields: a
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* UnionTypeDefinition :
|
|
1594
|
+
* - Description? union Name Directives[Const]? UnionMemberTypes?
|
|
1595
|
+
*/
|
|
1596
|
+
parseUnionTypeDefinition() {
|
|
1597
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1598
|
+
this.expectKeyword("union");
|
|
1599
|
+
const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseUnionMemberTypes();
|
|
1600
|
+
return this.node(t, {
|
|
1601
|
+
kind: c.UNION_TYPE_DEFINITION,
|
|
1602
|
+
description: n,
|
|
1603
|
+
name: s,
|
|
1604
|
+
directives: i,
|
|
1605
|
+
types: r
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* UnionMemberTypes :
|
|
1610
|
+
* - = `|`? NamedType
|
|
1611
|
+
* - UnionMemberTypes | NamedType
|
|
1612
|
+
*/
|
|
1613
|
+
parseUnionMemberTypes() {
|
|
1614
|
+
return this.expectOptionalToken(o.EQUALS) ? this.delimitedMany(o.PIPE, this.parseNamedType) : [];
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* EnumTypeDefinition :
|
|
1618
|
+
* - Description? enum Name Directives[Const]? EnumValuesDefinition?
|
|
1619
|
+
*/
|
|
1620
|
+
parseEnumTypeDefinition() {
|
|
1621
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1622
|
+
this.expectKeyword("enum");
|
|
1623
|
+
const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseEnumValuesDefinition();
|
|
1624
|
+
return this.node(t, {
|
|
1625
|
+
kind: c.ENUM_TYPE_DEFINITION,
|
|
1626
|
+
description: n,
|
|
1627
|
+
name: s,
|
|
1628
|
+
directives: i,
|
|
1629
|
+
values: r
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* ```
|
|
1634
|
+
* EnumValuesDefinition : { EnumValueDefinition+ }
|
|
1635
|
+
* ```
|
|
1636
|
+
*/
|
|
1637
|
+
parseEnumValuesDefinition() {
|
|
1638
|
+
return this.optionalMany(
|
|
1639
|
+
o.BRACE_L,
|
|
1640
|
+
this.parseEnumValueDefinition,
|
|
1641
|
+
o.BRACE_R
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* EnumValueDefinition : Description? EnumValue Directives[Const]?
|
|
1646
|
+
*/
|
|
1647
|
+
parseEnumValueDefinition() {
|
|
1648
|
+
const t = this._lexer.token, n = this.parseDescription(), s = this.parseEnumValueName(), i = this.parseConstDirectives();
|
|
1649
|
+
return this.node(t, {
|
|
1650
|
+
kind: c.ENUM_VALUE_DEFINITION,
|
|
1651
|
+
description: n,
|
|
1652
|
+
name: s,
|
|
1653
|
+
directives: i
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* EnumValue : Name but not `true`, `false` or `null`
|
|
1658
|
+
*/
|
|
1659
|
+
parseEnumValueName() {
|
|
1660
|
+
if (this._lexer.token.value === "true" || this._lexer.token.value === "false" || this._lexer.token.value === "null")
|
|
1661
|
+
throw d(
|
|
1662
|
+
this._lexer.source,
|
|
1663
|
+
this._lexer.token.start,
|
|
1664
|
+
`${v(
|
|
1665
|
+
this._lexer.token
|
|
1666
|
+
)} is reserved and cannot be used for an enum value.`
|
|
1667
|
+
);
|
|
1668
|
+
return this.parseName();
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* InputObjectTypeDefinition :
|
|
1672
|
+
* - Description? input Name Directives[Const]? InputFieldsDefinition?
|
|
1673
|
+
*/
|
|
1674
|
+
parseInputObjectTypeDefinition() {
|
|
1675
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1676
|
+
this.expectKeyword("input");
|
|
1677
|
+
const s = this.parseName(), i = this.parseConstDirectives(), r = this.parseInputFieldsDefinition();
|
|
1678
|
+
return this.node(t, {
|
|
1679
|
+
kind: c.INPUT_OBJECT_TYPE_DEFINITION,
|
|
1680
|
+
description: n,
|
|
1681
|
+
name: s,
|
|
1682
|
+
directives: i,
|
|
1683
|
+
fields: r
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* ```
|
|
1688
|
+
* InputFieldsDefinition : { InputValueDefinition+ }
|
|
1689
|
+
* ```
|
|
1690
|
+
*/
|
|
1691
|
+
parseInputFieldsDefinition() {
|
|
1692
|
+
return this.optionalMany(
|
|
1693
|
+
o.BRACE_L,
|
|
1694
|
+
this.parseInputValueDef,
|
|
1695
|
+
o.BRACE_R
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1699
|
+
* TypeSystemExtension :
|
|
1700
|
+
* - SchemaExtension
|
|
1701
|
+
* - TypeExtension
|
|
1702
|
+
*
|
|
1703
|
+
* TypeExtension :
|
|
1704
|
+
* - ScalarTypeExtension
|
|
1705
|
+
* - ObjectTypeExtension
|
|
1706
|
+
* - InterfaceTypeExtension
|
|
1707
|
+
* - UnionTypeExtension
|
|
1708
|
+
* - EnumTypeExtension
|
|
1709
|
+
* - InputObjectTypeDefinition
|
|
1710
|
+
*/
|
|
1711
|
+
parseTypeSystemExtension() {
|
|
1712
|
+
const t = this._lexer.lookahead();
|
|
1713
|
+
if (t.kind === o.NAME)
|
|
1714
|
+
switch (t.value) {
|
|
1715
|
+
case "schema":
|
|
1716
|
+
return this.parseSchemaExtension();
|
|
1717
|
+
case "scalar":
|
|
1718
|
+
return this.parseScalarTypeExtension();
|
|
1719
|
+
case "type":
|
|
1720
|
+
return this.parseObjectTypeExtension();
|
|
1721
|
+
case "interface":
|
|
1722
|
+
return this.parseInterfaceTypeExtension();
|
|
1723
|
+
case "union":
|
|
1724
|
+
return this.parseUnionTypeExtension();
|
|
1725
|
+
case "enum":
|
|
1726
|
+
return this.parseEnumTypeExtension();
|
|
1727
|
+
case "input":
|
|
1728
|
+
return this.parseInputObjectTypeExtension();
|
|
1729
|
+
}
|
|
1730
|
+
throw this.unexpected(t);
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* ```
|
|
1734
|
+
* SchemaExtension :
|
|
1735
|
+
* - extend schema Directives[Const]? { OperationTypeDefinition+ }
|
|
1736
|
+
* - extend schema Directives[Const]
|
|
1737
|
+
* ```
|
|
1738
|
+
*/
|
|
1739
|
+
parseSchemaExtension() {
|
|
1740
|
+
const t = this._lexer.token;
|
|
1741
|
+
this.expectKeyword("extend"), this.expectKeyword("schema");
|
|
1742
|
+
const n = this.parseConstDirectives(), s = this.optionalMany(
|
|
1743
|
+
o.BRACE_L,
|
|
1744
|
+
this.parseOperationTypeDefinition,
|
|
1745
|
+
o.BRACE_R
|
|
1746
|
+
);
|
|
1747
|
+
if (n.length === 0 && s.length === 0)
|
|
1748
|
+
throw this.unexpected();
|
|
1749
|
+
return this.node(t, {
|
|
1750
|
+
kind: c.SCHEMA_EXTENSION,
|
|
1751
|
+
directives: n,
|
|
1752
|
+
operationTypes: s
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* ScalarTypeExtension :
|
|
1757
|
+
* - extend scalar Name Directives[Const]
|
|
1758
|
+
*/
|
|
1759
|
+
parseScalarTypeExtension() {
|
|
1760
|
+
const t = this._lexer.token;
|
|
1761
|
+
this.expectKeyword("extend"), this.expectKeyword("scalar");
|
|
1762
|
+
const n = this.parseName(), s = this.parseConstDirectives();
|
|
1763
|
+
if (s.length === 0)
|
|
1764
|
+
throw this.unexpected();
|
|
1765
|
+
return this.node(t, {
|
|
1766
|
+
kind: c.SCALAR_TYPE_EXTENSION,
|
|
1767
|
+
name: n,
|
|
1768
|
+
directives: s
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* ObjectTypeExtension :
|
|
1773
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1774
|
+
* - extend type Name ImplementsInterfaces? Directives[Const]
|
|
1775
|
+
* - extend type Name ImplementsInterfaces
|
|
1776
|
+
*/
|
|
1777
|
+
parseObjectTypeExtension() {
|
|
1778
|
+
const t = this._lexer.token;
|
|
1779
|
+
this.expectKeyword("extend"), this.expectKeyword("type");
|
|
1780
|
+
const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
|
|
1781
|
+
if (s.length === 0 && i.length === 0 && r.length === 0)
|
|
1782
|
+
throw this.unexpected();
|
|
1783
|
+
return this.node(t, {
|
|
1784
|
+
kind: c.OBJECT_TYPE_EXTENSION,
|
|
1785
|
+
name: n,
|
|
1786
|
+
interfaces: s,
|
|
1787
|
+
directives: i,
|
|
1788
|
+
fields: r
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* InterfaceTypeExtension :
|
|
1793
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
|
|
1794
|
+
* - extend interface Name ImplementsInterfaces? Directives[Const]
|
|
1795
|
+
* - extend interface Name ImplementsInterfaces
|
|
1796
|
+
*/
|
|
1797
|
+
parseInterfaceTypeExtension() {
|
|
1798
|
+
const t = this._lexer.token;
|
|
1799
|
+
this.expectKeyword("extend"), this.expectKeyword("interface");
|
|
1800
|
+
const n = this.parseName(), s = this.parseImplementsInterfaces(), i = this.parseConstDirectives(), r = this.parseFieldsDefinition();
|
|
1801
|
+
if (s.length === 0 && i.length === 0 && r.length === 0)
|
|
1802
|
+
throw this.unexpected();
|
|
1803
|
+
return this.node(t, {
|
|
1804
|
+
kind: c.INTERFACE_TYPE_EXTENSION,
|
|
1805
|
+
name: n,
|
|
1806
|
+
interfaces: s,
|
|
1807
|
+
directives: i,
|
|
1808
|
+
fields: r
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* UnionTypeExtension :
|
|
1813
|
+
* - extend union Name Directives[Const]? UnionMemberTypes
|
|
1814
|
+
* - extend union Name Directives[Const]
|
|
1815
|
+
*/
|
|
1816
|
+
parseUnionTypeExtension() {
|
|
1817
|
+
const t = this._lexer.token;
|
|
1818
|
+
this.expectKeyword("extend"), this.expectKeyword("union");
|
|
1819
|
+
const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseUnionMemberTypes();
|
|
1820
|
+
if (s.length === 0 && i.length === 0)
|
|
1821
|
+
throw this.unexpected();
|
|
1822
|
+
return this.node(t, {
|
|
1823
|
+
kind: c.UNION_TYPE_EXTENSION,
|
|
1824
|
+
name: n,
|
|
1825
|
+
directives: s,
|
|
1826
|
+
types: i
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* EnumTypeExtension :
|
|
1831
|
+
* - extend enum Name Directives[Const]? EnumValuesDefinition
|
|
1832
|
+
* - extend enum Name Directives[Const]
|
|
1833
|
+
*/
|
|
1834
|
+
parseEnumTypeExtension() {
|
|
1835
|
+
const t = this._lexer.token;
|
|
1836
|
+
this.expectKeyword("extend"), this.expectKeyword("enum");
|
|
1837
|
+
const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseEnumValuesDefinition();
|
|
1838
|
+
if (s.length === 0 && i.length === 0)
|
|
1839
|
+
throw this.unexpected();
|
|
1840
|
+
return this.node(t, {
|
|
1841
|
+
kind: c.ENUM_TYPE_EXTENSION,
|
|
1842
|
+
name: n,
|
|
1843
|
+
directives: s,
|
|
1844
|
+
values: i
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* InputObjectTypeExtension :
|
|
1849
|
+
* - extend input Name Directives[Const]? InputFieldsDefinition
|
|
1850
|
+
* - extend input Name Directives[Const]
|
|
1851
|
+
*/
|
|
1852
|
+
parseInputObjectTypeExtension() {
|
|
1853
|
+
const t = this._lexer.token;
|
|
1854
|
+
this.expectKeyword("extend"), this.expectKeyword("input");
|
|
1855
|
+
const n = this.parseName(), s = this.parseConstDirectives(), i = this.parseInputFieldsDefinition();
|
|
1856
|
+
if (s.length === 0 && i.length === 0)
|
|
1857
|
+
throw this.unexpected();
|
|
1858
|
+
return this.node(t, {
|
|
1859
|
+
kind: c.INPUT_OBJECT_TYPE_EXTENSION,
|
|
1860
|
+
name: n,
|
|
1861
|
+
directives: s,
|
|
1862
|
+
fields: i
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* ```
|
|
1867
|
+
* DirectiveDefinition :
|
|
1868
|
+
* - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
|
|
1869
|
+
* ```
|
|
1870
|
+
*/
|
|
1871
|
+
parseDirectiveDefinition() {
|
|
1872
|
+
const t = this._lexer.token, n = this.parseDescription();
|
|
1873
|
+
this.expectKeyword("directive"), this.expectToken(o.AT);
|
|
1874
|
+
const s = this.parseName(), i = this.parseArgumentDefs(), r = this.expectOptionalKeyword("repeatable");
|
|
1875
|
+
this.expectKeyword("on");
|
|
1876
|
+
const a = this.parseDirectiveLocations();
|
|
1877
|
+
return this.node(t, {
|
|
1878
|
+
kind: c.DIRECTIVE_DEFINITION,
|
|
1879
|
+
description: n,
|
|
1880
|
+
name: s,
|
|
1881
|
+
arguments: i,
|
|
1882
|
+
repeatable: r,
|
|
1883
|
+
locations: a
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* DirectiveLocations :
|
|
1888
|
+
* - `|`? DirectiveLocation
|
|
1889
|
+
* - DirectiveLocations | DirectiveLocation
|
|
1890
|
+
*/
|
|
1891
|
+
parseDirectiveLocations() {
|
|
1892
|
+
return this.delimitedMany(o.PIPE, this.parseDirectiveLocation);
|
|
1893
|
+
}
|
|
1894
|
+
/*
|
|
1895
|
+
* DirectiveLocation :
|
|
1896
|
+
* - ExecutableDirectiveLocation
|
|
1897
|
+
* - TypeSystemDirectiveLocation
|
|
1898
|
+
*
|
|
1899
|
+
* ExecutableDirectiveLocation : one of
|
|
1900
|
+
* `QUERY`
|
|
1901
|
+
* `MUTATION`
|
|
1902
|
+
* `SUBSCRIPTION`
|
|
1903
|
+
* `FIELD`
|
|
1904
|
+
* `FRAGMENT_DEFINITION`
|
|
1905
|
+
* `FRAGMENT_SPREAD`
|
|
1906
|
+
* `INLINE_FRAGMENT`
|
|
1907
|
+
*
|
|
1908
|
+
* TypeSystemDirectiveLocation : one of
|
|
1909
|
+
* `SCHEMA`
|
|
1910
|
+
* `SCALAR`
|
|
1911
|
+
* `OBJECT`
|
|
1912
|
+
* `FIELD_DEFINITION`
|
|
1913
|
+
* `ARGUMENT_DEFINITION`
|
|
1914
|
+
* `INTERFACE`
|
|
1915
|
+
* `UNION`
|
|
1916
|
+
* `ENUM`
|
|
1917
|
+
* `ENUM_VALUE`
|
|
1918
|
+
* `INPUT_OBJECT`
|
|
1919
|
+
* `INPUT_FIELD_DEFINITION`
|
|
1920
|
+
*/
|
|
1921
|
+
parseDirectiveLocation() {
|
|
1922
|
+
const t = this._lexer.token, n = this.parseName();
|
|
1923
|
+
if (Object.prototype.hasOwnProperty.call(P, n.value))
|
|
1924
|
+
return n;
|
|
1925
|
+
throw this.unexpected(t);
|
|
1926
|
+
}
|
|
1927
|
+
// Core parsing utility functions
|
|
1928
|
+
/**
|
|
1929
|
+
* Returns a node that, if configured to do so, sets a "loc" field as a
|
|
1930
|
+
* location object, used to identify the place in the source that created a
|
|
1931
|
+
* given parsed object.
|
|
1932
|
+
*/
|
|
1933
|
+
node(t, n) {
|
|
1934
|
+
return this._options.noLocation !== !0 && (n.loc = new oe(
|
|
1935
|
+
t,
|
|
1936
|
+
this._lexer.lastToken,
|
|
1937
|
+
this._lexer.source
|
|
1938
|
+
)), n;
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Determines if the next token is of a given kind
|
|
1942
|
+
*/
|
|
1943
|
+
peek(t) {
|
|
1944
|
+
return this._lexer.token.kind === t;
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* If the next token is of the given kind, return that token after advancing the lexer.
|
|
1948
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
1949
|
+
*/
|
|
1950
|
+
expectToken(t) {
|
|
1951
|
+
const n = this._lexer.token;
|
|
1952
|
+
if (n.kind === t)
|
|
1953
|
+
return this.advanceLexer(), n;
|
|
1954
|
+
throw d(
|
|
1955
|
+
this._lexer.source,
|
|
1956
|
+
n.start,
|
|
1957
|
+
`Expected ${H(t)}, found ${v(n)}.`
|
|
1958
|
+
);
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* If the next token is of the given kind, return "true" after advancing the lexer.
|
|
1962
|
+
* Otherwise, do not change the parser state and return "false".
|
|
1963
|
+
*/
|
|
1964
|
+
expectOptionalToken(t) {
|
|
1965
|
+
return this._lexer.token.kind === t ? (this.advanceLexer(), !0) : !1;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* If the next token is a given keyword, advance the lexer.
|
|
1969
|
+
* Otherwise, do not change the parser state and throw an error.
|
|
1970
|
+
*/
|
|
1971
|
+
expectKeyword(t) {
|
|
1972
|
+
const n = this._lexer.token;
|
|
1973
|
+
if (n.kind === o.NAME && n.value === t)
|
|
1974
|
+
this.advanceLexer();
|
|
1975
|
+
else
|
|
1976
|
+
throw d(
|
|
1977
|
+
this._lexer.source,
|
|
1978
|
+
n.start,
|
|
1979
|
+
`Expected "${t}", found ${v(n)}.`
|
|
1980
|
+
);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* If the next token is a given keyword, return "true" after advancing the lexer.
|
|
1984
|
+
* Otherwise, do not change the parser state and return "false".
|
|
1985
|
+
*/
|
|
1986
|
+
expectOptionalKeyword(t) {
|
|
1987
|
+
const n = this._lexer.token;
|
|
1988
|
+
return n.kind === o.NAME && n.value === t ? (this.advanceLexer(), !0) : !1;
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Helper function for creating an error when an unexpected lexed token is encountered.
|
|
1992
|
+
*/
|
|
1993
|
+
unexpected(t) {
|
|
1994
|
+
const n = t ?? this._lexer.token;
|
|
1995
|
+
return d(
|
|
1996
|
+
this._lexer.source,
|
|
1997
|
+
n.start,
|
|
1998
|
+
`Unexpected ${v(n)}.`
|
|
1999
|
+
);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Returns a possibly empty list of parse nodes, determined by the parseFn.
|
|
2003
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2004
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2005
|
+
*/
|
|
2006
|
+
any(t, n, s) {
|
|
2007
|
+
this.expectToken(t);
|
|
2008
|
+
const i = [];
|
|
2009
|
+
for (; !this.expectOptionalToken(s); )
|
|
2010
|
+
i.push(n.call(this));
|
|
2011
|
+
return i;
|
|
2012
|
+
}
|
|
2013
|
+
/**
|
|
2014
|
+
* Returns a list of parse nodes, determined by the parseFn.
|
|
2015
|
+
* It can be empty only if open token is missing otherwise it will always return non-empty list
|
|
2016
|
+
* that begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2017
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2018
|
+
*/
|
|
2019
|
+
optionalMany(t, n, s) {
|
|
2020
|
+
if (this.expectOptionalToken(t)) {
|
|
2021
|
+
const i = [];
|
|
2022
|
+
do
|
|
2023
|
+
i.push(n.call(this));
|
|
2024
|
+
while (!this.expectOptionalToken(s));
|
|
2025
|
+
return i;
|
|
2026
|
+
}
|
|
2027
|
+
return [];
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
2031
|
+
* This list begins with a lex token of openKind and ends with a lex token of closeKind.
|
|
2032
|
+
* Advances the parser to the next lex token after the closing token.
|
|
2033
|
+
*/
|
|
2034
|
+
many(t, n, s) {
|
|
2035
|
+
this.expectToken(t);
|
|
2036
|
+
const i = [];
|
|
2037
|
+
do
|
|
2038
|
+
i.push(n.call(this));
|
|
2039
|
+
while (!this.expectOptionalToken(s));
|
|
2040
|
+
return i;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Returns a non-empty list of parse nodes, determined by the parseFn.
|
|
2044
|
+
* This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
|
|
2045
|
+
* Advances the parser to the next lex token after last item in the list.
|
|
2046
|
+
*/
|
|
2047
|
+
delimitedMany(t, n) {
|
|
2048
|
+
this.expectOptionalToken(t);
|
|
2049
|
+
const s = [];
|
|
2050
|
+
do
|
|
2051
|
+
s.push(n.call(this));
|
|
2052
|
+
while (this.expectOptionalToken(t));
|
|
2053
|
+
return s;
|
|
2054
|
+
}
|
|
2055
|
+
advanceLexer() {
|
|
2056
|
+
const { maxTokens: t } = this._options, n = this._lexer.advance();
|
|
2057
|
+
if (n.kind !== o.EOF && (++this._tokenCounter, t !== void 0 && this._tokenCounter > t))
|
|
2058
|
+
throw d(
|
|
2059
|
+
this._lexer.source,
|
|
2060
|
+
n.start,
|
|
2061
|
+
`Document contains more that ${t} tokens. Parsing aborted.`
|
|
2062
|
+
);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
function v(e) {
|
|
2066
|
+
const t = e.value;
|
|
2067
|
+
return H(e.kind) + (t != null ? ` "${t}"` : "");
|
|
2068
|
+
}
|
|
2069
|
+
function H(e) {
|
|
2070
|
+
return de(e) ? `"${e}"` : e;
|
|
2071
|
+
}
|
|
2072
|
+
var D = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map(), Z = !0, C = !1;
|
|
2073
|
+
function K(e) {
|
|
2074
|
+
return e.replace(/[\s,]+/g, " ").trim();
|
|
2075
|
+
}
|
|
2076
|
+
function Fe(e) {
|
|
2077
|
+
return K(e.source.body.substring(e.start, e.end));
|
|
2078
|
+
}
|
|
2079
|
+
function we(e) {
|
|
2080
|
+
var t = /* @__PURE__ */ new Set(), n = [];
|
|
2081
|
+
return e.definitions.forEach(function(s) {
|
|
2082
|
+
if (s.kind === "FragmentDefinition") {
|
|
2083
|
+
var i = s.name.value, r = Fe(s.loc), a = V.get(i);
|
|
2084
|
+
a && !a.has(r) ? Z && console.warn("Warning: fragment with name " + i + ` already exists.
|
|
2085
|
+
graphql-tag enforces all fragment names across your application to be unique; read more about
|
|
2086
|
+
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : a || V.set(i, a = /* @__PURE__ */ new Set()), a.add(r), t.has(r) || (t.add(r), n.push(s));
|
|
2087
|
+
} else
|
|
2088
|
+
n.push(s);
|
|
2089
|
+
}), k(k({}, e), { definitions: n });
|
|
2090
|
+
}
|
|
2091
|
+
function Pe(e) {
|
|
2092
|
+
var t = new Set(e.definitions);
|
|
2093
|
+
t.forEach(function(s) {
|
|
2094
|
+
s.loc && delete s.loc, Object.keys(s).forEach(function(i) {
|
|
2095
|
+
var r = s[i];
|
|
2096
|
+
r && typeof r == "object" && t.add(r);
|
|
2097
|
+
});
|
|
2098
|
+
});
|
|
2099
|
+
var n = e.loc;
|
|
2100
|
+
return n && (delete n.startToken, delete n.endToken), e;
|
|
2101
|
+
}
|
|
2102
|
+
function Ve(e) {
|
|
2103
|
+
var t = K(e);
|
|
2104
|
+
if (!D.has(t)) {
|
|
2105
|
+
var n = Le(e, {
|
|
2106
|
+
experimentalFragmentVariables: C,
|
|
2107
|
+
allowLegacyFragmentVariables: C
|
|
2108
|
+
});
|
|
2109
|
+
if (!n || n.kind !== "Document")
|
|
2110
|
+
throw new Error("Not a valid GraphQL document.");
|
|
2111
|
+
D.set(t, Pe(we(n)));
|
|
2112
|
+
}
|
|
2113
|
+
return D.get(t);
|
|
2114
|
+
}
|
|
2115
|
+
function I(e) {
|
|
2116
|
+
for (var t = [], n = 1; n < arguments.length; n++)
|
|
2117
|
+
t[n - 1] = arguments[n];
|
|
2118
|
+
typeof e == "string" && (e = [e]);
|
|
2119
|
+
var s = e[0];
|
|
2120
|
+
return t.forEach(function(i, r) {
|
|
2121
|
+
i && i.kind === "Document" ? s += i.loc.source.body : s += i, s += e[r + 1];
|
|
2122
|
+
}), Ve(s);
|
|
2123
|
+
}
|
|
2124
|
+
function Me() {
|
|
2125
|
+
D.clear(), V.clear();
|
|
2126
|
+
}
|
|
2127
|
+
function Ue() {
|
|
2128
|
+
Z = !1;
|
|
2129
|
+
}
|
|
2130
|
+
function Be() {
|
|
2131
|
+
C = !0;
|
|
2132
|
+
}
|
|
2133
|
+
function je() {
|
|
2134
|
+
C = !1;
|
|
2135
|
+
}
|
|
2136
|
+
var _ = {
|
|
2137
|
+
gql: I,
|
|
2138
|
+
resetCaches: Me,
|
|
2139
|
+
disableFragmentWarnings: Ue,
|
|
2140
|
+
enableExperimentalFragmentVariables: Be,
|
|
2141
|
+
disableExperimentalFragmentVariables: je
|
|
2142
|
+
};
|
|
2143
|
+
(function(e) {
|
|
2144
|
+
e.gql = _.gql, e.resetCaches = _.resetCaches, e.disableFragmentWarnings = _.disableFragmentWarnings, e.enableExperimentalFragmentVariables = _.enableExperimentalFragmentVariables, e.disableExperimentalFragmentVariables = _.disableExperimentalFragmentVariables;
|
|
2145
|
+
})(I || (I = {}));
|
|
2146
|
+
I.default = I;
|
|
2147
|
+
const ee = (e, t = {}) => {
|
|
2148
|
+
const { getCustomerToken: n, getStore: s, getCurrency: i } = e.config.state;
|
|
2149
|
+
return {
|
|
2150
|
+
...n() && { Authorization: `Bearer ${n()}` },
|
|
2151
|
+
...s() && { store: s() },
|
|
2152
|
+
...i() && { "Content-Currency": i() },
|
|
2153
|
+
...t
|
|
2154
|
+
};
|
|
2155
|
+
}, Ye = async (e, t) => {
|
|
2156
|
+
const { client: n } = e;
|
|
2157
|
+
try {
|
|
2158
|
+
return await n.query({
|
|
2159
|
+
query: I`
|
|
2160
|
+
query recentlyViewedProducts {
|
|
2161
|
+
recentlyViewedProducts {
|
|
2162
|
+
product_sku
|
|
2163
|
+
viewed_at
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
`,
|
|
2167
|
+
variables: t,
|
|
2168
|
+
context: { headers: ee(e) }
|
|
2169
|
+
});
|
|
2170
|
+
} catch (s) {
|
|
2171
|
+
throw s;
|
|
2172
|
+
}
|
|
2173
|
+
}, Je = async (e, t) => {
|
|
2174
|
+
const { client: n } = e;
|
|
2175
|
+
try {
|
|
2176
|
+
return await n.mutate({
|
|
2177
|
+
mutation: I`
|
|
2178
|
+
mutation addRecentlyViewedProducts($input: [RecentlyViewedProductInput!]!) {
|
|
2179
|
+
addRecentlyViewedProducts(input: $input) {
|
|
2180
|
+
success
|
|
2181
|
+
message
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
`,
|
|
2185
|
+
variables: t,
|
|
2186
|
+
context: { headers: ee(e) }
|
|
2187
|
+
});
|
|
2188
|
+
} catch (s) {
|
|
2189
|
+
throw s;
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
export {
|
|
2193
|
+
Je as addRecentlyViewedProducts,
|
|
2194
|
+
Ge as addRecentlyViewedProductsFields,
|
|
2195
|
+
Qe as addRecentlyViewedWeb,
|
|
2196
|
+
ze as fetchRecentlyViewedWeb,
|
|
2197
|
+
We as getSdk,
|
|
2198
|
+
Ye as recentlyViewedProducts,
|
|
2199
|
+
$e as recentlyViewedProductsFields,
|
|
2200
|
+
He as setSdk
|
|
2201
|
+
};
|