@graphiql/plugin-query-builder 1.0.0 → 1.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.
Files changed (43) hide show
  1. package/dist/components/arg-input/arg-input-by-type.js +1 -2
  2. package/dist/components/arg-input/arg-input-by-type.js.map +1 -1
  3. package/dist/components/arg-input/enum-arg-control.js +1 -2
  4. package/dist/components/arg-input/enum-arg-control.js.map +1 -1
  5. package/dist/components/arg-input/index.js +1 -2
  6. package/dist/components/arg-input/index.js.map +1 -1
  7. package/dist/components/arg-input/scalar-arg-control.js +1 -2
  8. package/dist/components/arg-input/scalar-arg-control.js.map +1 -1
  9. package/dist/components/field-row.js +1 -2
  10. package/dist/components/field-row.js.map +1 -1
  11. package/dist/components/field-tree-context.d.ts +1 -1
  12. package/dist/components/field-tree-context.js +1 -2
  13. package/dist/components/field-tree-context.js.map +1 -1
  14. package/dist/components/field-tree-node.js +228 -92
  15. package/dist/components/field-tree-node.js.map +1 -1
  16. package/dist/components/field-tree.js +2 -3
  17. package/dist/components/field-tree.js.map +1 -1
  18. package/dist/components/fragment-editor.js +1 -2
  19. package/dist/components/fragment-editor.js.map +1 -1
  20. package/dist/components/fragment-section.js +1 -2
  21. package/dist/components/fragment-section.js.map +1 -1
  22. package/dist/components/query-builder.js +81 -91
  23. package/dist/components/query-builder.js.map +1 -1
  24. package/dist/components/type-condition-selector.js +193 -203
  25. package/dist/components/type-condition-selector.js.map +1 -1
  26. package/dist/components/use-cursor-path.js +1 -2
  27. package/dist/components/use-cursor-path.js.map +1 -1
  28. package/dist/components/use-cursor-reveal.d.ts +3 -1
  29. package/dist/components/use-cursor-reveal.js +49 -46
  30. package/dist/components/use-cursor-reveal.js.map +1 -1
  31. package/dist/components/use-working-document.js +295 -281
  32. package/dist/components/use-working-document.js.map +1 -1
  33. package/dist/index.js +2 -3
  34. package/dist/lib/arg-value.js +1 -2
  35. package/dist/lib/arguments.js +1 -2
  36. package/dist/lib/ast-path.js +1 -2
  37. package/dist/lib/field-list-view.js +1 -2
  38. package/dist/lib/field-selection.js +1 -2
  39. package/dist/lib/fragments.js +1 -2
  40. package/dist/lib/inline-fragments.js +1 -2
  41. package/dist/lib/schema-walk.js +1 -2
  42. package/dist/lib/variables.js +1 -2
  43. package/package.json +10 -8
@@ -1,17 +1,17 @@
1
- import { definitionSelectionOffset, findDefinition, findOperation } from "../lib/ast-path.js";
2
- import { extractRawArgValue, readVariables, resolveSchemaArg, resolveSchemaArgFromRoot } from "../lib/schema-walk.js";
1
+ import { addInlineFragment, removeInlineFragment } from "../lib/inline-fragments.js";
3
2
  import { argValueToValueNode } from "../lib/arg-value.js";
4
- import { toggleFieldSelection } from "../lib/field-selection.js";
5
- import { setFieldArgument } from "../lib/arguments.js";
6
- import { demoteVariable, promoteArgToVariable, suggestVarName } from "../lib/variables.js";
7
3
  import { createFragmentFromSelection, inlineFragment, listFragments, removeFragmentSpread, renameFragment } from "../lib/fragments.js";
8
- import { addInlineFragment, removeInlineFragment } from "../lib/inline-fragments.js";
4
+ import { demoteVariable, promoteArgToVariable, suggestVarName } from "../lib/variables.js";
5
+ import { definitionSelectionOffset, findDefinition, findOperation } from "../lib/ast-path.js";
6
+ import { setFieldArgument } from "../lib/arguments.js";
7
+ import { toggleFieldSelection } from "../lib/field-selection.js";
8
+ import { extractRawArgValue, readVariables, resolveSchemaArg, resolveSchemaArgFromRoot } from "../lib/schema-walk.js";
9
9
  import { useCursorContext } from "./use-cursor-path.js";
10
10
  import { useGraphiQL, useGraphiQLActions } from "@graphiql/react";
11
11
  import { c } from "react-compiler-runtime";
12
12
  import { Kind, getNamedType, parse, parseValue, print, valueFromASTUntyped } from "graphql";
13
- import { useEffect, useRef, useState } from "react";
14
- //#region src/components/use-working-document.ts
13
+ import { useEffect, useState } from "react";
14
+ // src/components/use-working-document.ts
15
15
  /**
16
16
  * Parse query text into a DocumentNode, or null when it's empty or unparseable
17
17
  * (callers keep the last valid document instead).
@@ -34,7 +34,7 @@ function emptyDoc() {
34
34
  * external-edit sync, and all document-mutation handlers.
35
35
  */
36
36
  function useWorkingDocument() {
37
- const $ = c(114);
37
+ const $ = c(112);
38
38
  const schema = useGraphiQL(_temp);
39
39
  const queryEditor = useGraphiQL(_temp2);
40
40
  const variableEditor = useGraphiQL(_temp3);
@@ -46,12 +46,21 @@ function useWorkingDocument() {
46
46
  const variablesText = tabs[activeTabIndex]?.variables;
47
47
  let t0;
48
48
  if ($[0] !== queryText) {
49
- t0 = () => tryParse(queryText) ?? emptyDoc();
49
+ t0 = () => ({
50
+ doc: tryParse(queryText) ?? emptyDoc(),
51
+ observedText: queryText,
52
+ syncedText: queryText ?? null
53
+ });
50
54
  $[0] = queryText;
51
55
  $[1] = t0;
52
56
  } else t0 = $[1];
53
- const [workingDoc, setWorkingDoc] = useState(t0);
54
- const lastSyncedRef = useRef(queryText ?? null);
57
+ const [documentState, setDocumentState] = useState(t0);
58
+ const workingDoc = documentState.doc;
59
+ if (queryText !== documentState.observedText) setDocumentState({
60
+ doc: queryText === documentState.syncedText ? workingDoc : tryParse(queryText) ?? (queryText?.trim() ? workingDoc : emptyDoc()),
61
+ observedText: queryText,
62
+ syncedText: queryText ?? null
63
+ });
55
64
  let t1;
56
65
  if ($[2] !== queryEditor || $[3] !== updateActiveTabValues) {
57
66
  t1 = (printed) => {
@@ -59,11 +68,10 @@ function useWorkingDocument() {
59
68
  const position = queryEditor.getPosition();
60
69
  queryEditor.setValue(printed);
61
70
  if (position) queryEditor.setPosition(position);
62
- lastSyncedRef.current = queryEditor.getValue();
63
- return;
71
+ return queryEditor.getValue();
64
72
  }
65
- lastSyncedRef.current = printed;
66
73
  updateActiveTabValues({ query: printed });
74
+ return printed;
67
75
  };
68
76
  $[2] = queryEditor;
69
77
  $[3] = updateActiveTabValues;
@@ -71,80 +79,65 @@ function useWorkingDocument() {
71
79
  } else t1 = $[4];
72
80
  const writeToEditor = t1;
73
81
  let t2;
74
- let t3;
75
- if ($[5] !== queryText) {
76
- t2 = () => {
77
- if (queryText === lastSyncedRef.current) return;
78
- lastSyncedRef.current = queryText ?? null;
79
- const parsed = tryParse(queryText);
80
- if (parsed) setWorkingDoc(parsed);
81
- else if (!queryText?.trim()) setWorkingDoc(emptyDoc());
82
- };
83
- t3 = [queryText];
84
- $[5] = queryText;
85
- $[6] = t2;
86
- $[7] = t3;
87
- } else {
88
- t2 = $[6];
89
- t3 = $[7];
90
- }
91
- useEffect(t2, t3);
82
+ if ($[5] !== operationName || $[6] !== workingDoc) {
83
+ t2 = findOperation(workingDoc, operationName)?.operation;
84
+ $[5] = operationName;
85
+ $[6] = workingDoc;
86
+ $[7] = t2;
87
+ } else t2 = $[7];
88
+ const activeOpKind = t2;
89
+ const cursor = useCursorContext();
90
+ const cursorFragment = cursor.target?.kind === "fragment" ? cursor.target.name : cursor.target?.kind === "operation" ? null : void 0;
91
+ const t3 = cursorFragment ?? null;
92
92
  let t4;
93
- if ($[8] !== operationName || $[9] !== workingDoc) {
94
- t4 = findOperation(workingDoc, operationName)?.operation;
95
- $[8] = operationName;
96
- $[9] = workingDoc;
93
+ if ($[8] !== cursorFragment || $[9] !== t3) {
94
+ t4 = {
95
+ name: t3,
96
+ cursorFragment
97
+ };
98
+ $[8] = cursorFragment;
99
+ $[9] = t3;
97
100
  $[10] = t4;
98
101
  } else t4 = $[10];
99
- const activeOpKind = t4;
100
- const cursor = useCursorContext();
101
- const [activeFragment, setActiveFragment] = useState(null);
102
- const cursorFragment = cursor.target?.kind === "fragment" ? cursor.target.name : cursor.target?.kind === "operation" ? null : void 0;
102
+ const [fragmentState, setFragmentState] = useState(t4);
103
+ const activeFragment = cursorFragment !== fragmentState.cursorFragment && cursorFragment !== void 0 ? cursorFragment : fragmentState.name;
103
104
  let t5;
104
- let t6;
105
- if ($[11] !== cursorFragment) {
106
- t5 = () => {
107
- if (cursorFragment !== void 0) setActiveFragment(cursorFragment);
108
- };
109
- t6 = [cursorFragment];
110
- $[11] = cursorFragment;
111
- $[12] = t5;
112
- $[13] = t6;
113
- } else {
114
- t5 = $[12];
115
- t6 = $[13];
116
- }
117
- useEffect(t5, t6);
118
- let t7;
119
- if ($[14] !== activeFragment || $[15] !== workingDoc) {
120
- t7 = activeFragment != null && findDefinition(workingDoc, {
105
+ if ($[11] !== activeFragment || $[12] !== workingDoc) {
106
+ t5 = activeFragment != null && findDefinition(workingDoc, {
121
107
  kind: "fragment",
122
108
  name: activeFragment
123
109
  }) ? activeFragment : null;
124
- $[14] = activeFragment;
125
- $[15] = workingDoc;
126
- $[16] = t7;
127
- } else t7 = $[16];
128
- const visibleFragment = t7;
129
- let t8;
130
- if ($[17] !== operationName || $[18] !== visibleFragment) {
131
- t8 = visibleFragment != null ? {
110
+ $[11] = activeFragment;
111
+ $[12] = workingDoc;
112
+ $[13] = t5;
113
+ } else t5 = $[13];
114
+ const visibleFragment = t5;
115
+ if (fragmentState.cursorFragment !== cursorFragment || fragmentState.name !== visibleFragment || fragmentState.resetCursor && fragmentState.resetCursor.editor !== queryEditor) setFragmentState({
116
+ name: visibleFragment,
117
+ cursorFragment,
118
+ resetCursor: activeFragment != null && visibleFragment == null ? {
119
+ operationName,
120
+ editor: queryEditor
121
+ } : void 0
122
+ });
123
+ let t6;
124
+ if ($[14] !== operationName || $[15] !== visibleFragment) {
125
+ t6 = visibleFragment != null ? {
132
126
  kind: "fragment",
133
127
  name: visibleFragment
134
128
  } : {
135
129
  kind: "operation",
136
130
  name: operationName
137
131
  };
138
- $[17] = operationName;
139
- $[18] = visibleFragment;
140
- $[19] = t8;
141
- } else t8 = $[19];
142
- const target = t8;
132
+ $[14] = operationName;
133
+ $[15] = visibleFragment;
134
+ $[16] = t6;
135
+ } else t6 = $[16];
136
+ const target = t6;
143
137
  const cursorPath = cursor.target != null && (visibleFragment != null ? cursor.target.kind === "fragment" && cursor.target.name === visibleFragment : cursor.target.kind === "operation") ? cursor.path : void 0;
144
- let t9;
145
- if ($[20] !== queryEditor) {
146
- t9 = (next) => {
147
- setActiveFragment(next.kind === "fragment" ? next.name : null);
138
+ let t7;
139
+ if ($[17] !== queryEditor) {
140
+ t7 = (next) => {
148
141
  if (!queryEditor) return;
149
142
  const model = queryEditor.getModel();
150
143
  if (!model) return;
@@ -156,88 +149,110 @@ function useWorkingDocument() {
156
149
  }
157
150
  if (offset != null) queryEditor.setPosition(model.getPositionAt(offset));
158
151
  };
159
- $[20] = queryEditor;
160
- $[21] = t9;
161
- } else t9 = $[21];
162
- const moveCursorToTarget = t9;
163
- let t10;
164
- let t11;
165
- if ($[22] !== activeFragment || $[23] !== moveCursorToTarget || $[24] !== operationName || $[25] !== visibleFragment) {
166
- t10 = () => {
167
- if (activeFragment != null && visibleFragment == null) moveCursorToTarget({
152
+ $[17] = queryEditor;
153
+ $[18] = t7;
154
+ } else t7 = $[18];
155
+ const moveEditorCursorToTarget = t7;
156
+ const resetCursor = fragmentState.resetCursor;
157
+ let t8;
158
+ let t9;
159
+ if ($[19] !== moveEditorCursorToTarget || $[20] !== queryEditor || $[21] !== resetCursor) {
160
+ t8 = () => {
161
+ if (resetCursor && resetCursor.editor === queryEditor) moveEditorCursorToTarget({
168
162
  kind: "operation",
169
- name: operationName
163
+ name: resetCursor.operationName
170
164
  });
171
165
  };
172
- t11 = [
173
- activeFragment,
174
- visibleFragment,
175
- operationName,
176
- moveCursorToTarget
166
+ t9 = [
167
+ resetCursor,
168
+ queryEditor,
169
+ moveEditorCursorToTarget
177
170
  ];
178
- $[22] = activeFragment;
179
- $[23] = moveCursorToTarget;
180
- $[24] = operationName;
181
- $[25] = visibleFragment;
182
- $[26] = t10;
183
- $[27] = t11;
171
+ $[19] = moveEditorCursorToTarget;
172
+ $[20] = queryEditor;
173
+ $[21] = resetCursor;
174
+ $[22] = t8;
175
+ $[23] = t9;
184
176
  } else {
185
- t10 = $[26];
186
- t11 = $[27];
177
+ t8 = $[22];
178
+ t9 = $[23];
187
179
  }
188
- useEffect(t10, t11);
189
- let t12;
190
- if ($[28] !== moveCursorToTarget) {
191
- t12 = function handleFocusFragment(fragmentName) {
180
+ useEffect(t8, t9);
181
+ let t10;
182
+ if ($[24] !== moveEditorCursorToTarget) {
183
+ t10 = function moveCursorToTarget(next_0) {
184
+ setFragmentState((state_5) => ({
185
+ ...state_5,
186
+ name: next_0.kind === "fragment" ? next_0.name : null,
187
+ resetCursor: void 0
188
+ }));
189
+ moveEditorCursorToTarget(next_0);
190
+ };
191
+ $[24] = moveEditorCursorToTarget;
192
+ $[25] = t10;
193
+ } else t10 = $[25];
194
+ const moveCursorToTarget = t10;
195
+ let t11;
196
+ if ($[26] !== moveCursorToTarget) {
197
+ t11 = function handleFocusFragment(fragmentName) {
192
198
  moveCursorToTarget({
193
199
  kind: "fragment",
194
200
  name: fragmentName
195
201
  });
196
202
  };
197
- $[28] = moveCursorToTarget;
198
- $[29] = t12;
199
- } else t12 = $[29];
200
- const handleFocusFragment = t12;
201
- let t13;
202
- if ($[30] !== moveCursorToTarget || $[31] !== operationName) {
203
- t13 = function handleBackToQuery() {
203
+ $[26] = moveCursorToTarget;
204
+ $[27] = t11;
205
+ } else t11 = $[27];
206
+ const handleFocusFragment = t11;
207
+ let t12;
208
+ if ($[28] !== moveCursorToTarget || $[29] !== operationName) {
209
+ t12 = function handleBackToQuery() {
204
210
  moveCursorToTarget({
205
211
  kind: "operation",
206
212
  name: operationName
207
213
  });
208
214
  };
209
- $[30] = moveCursorToTarget;
210
- $[31] = operationName;
215
+ $[28] = moveCursorToTarget;
216
+ $[29] = operationName;
217
+ $[30] = t12;
218
+ } else t12 = $[30];
219
+ const handleBackToQuery = t12;
220
+ let t13;
221
+ if ($[31] !== writeToEditor) {
222
+ t13 = function applyDoc(next_1) {
223
+ const printed_0 = print(next_1);
224
+ setDocumentState((state_6) => ({
225
+ ...state_6,
226
+ doc: next_1,
227
+ syncedText: printed_0
228
+ }));
229
+ const syncedText = writeToEditor(printed_0);
230
+ if (syncedText !== printed_0) setDocumentState((state_7) => ({
231
+ ...state_7,
232
+ syncedText
233
+ }));
234
+ };
235
+ $[31] = writeToEditor;
211
236
  $[32] = t13;
212
237
  } else t13 = $[32];
213
- const handleBackToQuery = t13;
238
+ const applyDoc = t13;
214
239
  let t14;
215
- if ($[33] !== writeToEditor) {
216
- t14 = function applyDoc(next_0) {
217
- setWorkingDoc(next_0);
218
- writeToEditor(print(next_0));
219
- };
220
- $[33] = writeToEditor;
221
- $[34] = t14;
222
- } else t14 = $[34];
223
- const applyDoc = t14;
224
- let t15;
225
- if ($[35] !== updateActiveTabValues || $[36] !== variableEditor) {
226
- t15 = function applyVariables(next_1) {
227
- const serialized = Object.keys(next_1).length ? JSON.stringify(next_1, null, 2) : "";
240
+ if ($[33] !== updateActiveTabValues || $[34] !== variableEditor) {
241
+ t14 = function applyVariables(next_2) {
242
+ const serialized = Object.keys(next_2).length ? JSON.stringify(next_2, null, 2) : "";
228
243
  if (variableEditor) variableEditor.setValue(serialized);
229
244
  else updateActiveTabValues({ variables: serialized });
230
245
  };
231
- $[35] = updateActiveTabValues;
232
- $[36] = variableEditor;
233
- $[37] = t15;
234
- } else t15 = $[37];
235
- const applyVariables = t15;
236
- let t16;
237
- if ($[38] !== applyVariables || $[39] !== variablesText) {
238
- t16 = function reconcileVariablesJson(next_2) {
246
+ $[33] = updateActiveTabValues;
247
+ $[34] = variableEditor;
248
+ $[35] = t14;
249
+ } else t14 = $[35];
250
+ const applyVariables = t14;
251
+ let t15;
252
+ if ($[36] !== applyVariables || $[37] !== variablesText) {
253
+ t15 = function reconcileVariablesJson(next_3) {
239
254
  const definedVars = /* @__PURE__ */ new Set();
240
- for (const def of next_2.definitions) if (def.kind === Kind.OPERATION_DEFINITION) for (const vd of def.variableDefinitions ?? []) definedVars.add(vd.variable.name.value);
255
+ for (const def of next_3.definitions) if (def.kind === Kind.OPERATION_DEFINITION) for (const vd of def.variableDefinitions ?? []) definedVars.add(vd.variable.name.value);
241
256
  const vars = readVariables(variablesText);
242
257
  if (Object.keys(vars).some((name_0) => !definedVars.has(name_0))) {
243
258
  const reconciled = {};
@@ -245,28 +260,28 @@ function useWorkingDocument() {
245
260
  applyVariables(reconciled);
246
261
  }
247
262
  };
248
- $[38] = applyVariables;
249
- $[39] = variablesText;
250
- $[40] = t16;
251
- } else t16 = $[40];
252
- const reconcileVariablesJson = t16;
253
- let t17;
254
- if ($[41] !== applyDoc || $[42] !== reconcileVariablesJson || $[43] !== target || $[44] !== workingDoc) {
255
- t17 = function handleToggle(path) {
256
- const next_3 = toggleFieldSelection(workingDoc, path, target);
257
- applyDoc(next_3);
258
- reconcileVariablesJson(next_3);
263
+ $[36] = applyVariables;
264
+ $[37] = variablesText;
265
+ $[38] = t15;
266
+ } else t15 = $[38];
267
+ const reconcileVariablesJson = t15;
268
+ let t16;
269
+ if ($[39] !== applyDoc || $[40] !== reconcileVariablesJson || $[41] !== target || $[42] !== workingDoc) {
270
+ t16 = function handleToggle(path) {
271
+ const next_4 = toggleFieldSelection(workingDoc, path, target);
272
+ applyDoc(next_4);
273
+ reconcileVariablesJson(next_4);
259
274
  };
260
- $[41] = applyDoc;
261
- $[42] = reconcileVariablesJson;
262
- $[43] = target;
263
- $[44] = workingDoc;
264
- $[45] = t17;
265
- } else t17 = $[45];
266
- const handleToggle = t17;
267
- let t18;
268
- if ($[46] !== activeOpKind || $[47] !== schema || $[48] !== target || $[49] !== workingDoc) {
269
- t18 = function schemaArgFor(path_0, argName) {
275
+ $[39] = applyDoc;
276
+ $[40] = reconcileVariablesJson;
277
+ $[41] = target;
278
+ $[42] = workingDoc;
279
+ $[43] = t16;
280
+ } else t16 = $[43];
281
+ const handleToggle = t16;
282
+ let t17;
283
+ if ($[44] !== activeOpKind || $[45] !== schema || $[46] !== target || $[47] !== workingDoc) {
284
+ t17 = function schemaArgFor(path_0, argName) {
270
285
  if (!schema) return;
271
286
  if (target.kind === "operation") return resolveSchemaArg(schema, activeOpKind, path_0, argName);
272
287
  const def_0 = findDefinition(workingDoc, target);
@@ -274,31 +289,31 @@ function useWorkingDocument() {
274
289
  const rootType = rootTypeName ? schema.getType(rootTypeName) ?? void 0 : void 0;
275
290
  return resolveSchemaArgFromRoot(schema, rootType, path_0, argName);
276
291
  };
277
- $[46] = activeOpKind;
278
- $[47] = schema;
279
- $[48] = target;
280
- $[49] = workingDoc;
281
- $[50] = t18;
282
- } else t18 = $[50];
283
- const schemaArgFor = t18;
284
- let t19;
285
- if ($[51] !== applyDoc || $[52] !== schemaArgFor || $[53] !== target || $[54] !== workingDoc) {
286
- t19 = function handleSetArg(path_1, argName_0, value_0) {
292
+ $[44] = activeOpKind;
293
+ $[45] = schema;
294
+ $[46] = target;
295
+ $[47] = workingDoc;
296
+ $[48] = t17;
297
+ } else t17 = $[48];
298
+ const schemaArgFor = t17;
299
+ let t18;
300
+ if ($[49] !== applyDoc || $[50] !== schemaArgFor || $[51] !== target || $[52] !== workingDoc) {
301
+ t18 = function handleSetArg(path_1, argName_0, value_0) {
287
302
  const schemaArg = schemaArgFor(path_1, argName_0);
288
303
  if (!schemaArg) return;
289
304
  const valueNode = argValueToValueNode(schemaArg.type, value_0);
290
305
  applyDoc(setFieldArgument(workingDoc, path_1, argName_0, valueNode, target));
291
306
  };
292
- $[51] = applyDoc;
293
- $[52] = schemaArgFor;
294
- $[53] = target;
295
- $[54] = workingDoc;
296
- $[55] = t19;
297
- } else t19 = $[55];
298
- const handleSetArg = t19;
299
- let t20;
300
- if ($[56] !== applyDoc || $[57] !== applyVariables || $[58] !== operationName || $[59] !== schemaArgFor || $[60] !== variablesText || $[61] !== workingDoc) {
301
- t20 = function handlePromoteArg(path_2, argName_1, suggestedName) {
307
+ $[49] = applyDoc;
308
+ $[50] = schemaArgFor;
309
+ $[51] = target;
310
+ $[52] = workingDoc;
311
+ $[53] = t18;
312
+ } else t18 = $[53];
313
+ const handleSetArg = t18;
314
+ let t19;
315
+ if ($[54] !== applyDoc || $[55] !== applyVariables || $[56] !== operationName || $[57] !== schemaArgFor || $[58] !== variablesText || $[59] !== workingDoc) {
316
+ t19 = function handlePromoteArg(path_2, argName_1, suggestedName) {
302
317
  const schemaArg_0 = schemaArgFor(path_2, argName_1);
303
318
  if (!schemaArg_0) return;
304
319
  const namedType = getNamedType(schemaArg_0.type);
@@ -314,18 +329,18 @@ function useWorkingDocument() {
314
329
  });
315
330
  } catch {}
316
331
  };
317
- $[56] = applyDoc;
318
- $[57] = applyVariables;
319
- $[58] = operationName;
320
- $[59] = schemaArgFor;
321
- $[60] = variablesText;
322
- $[61] = workingDoc;
323
- $[62] = t20;
324
- } else t20 = $[62];
325
- const handlePromoteArg = t20;
326
- let t21;
327
- if ($[63] !== applyDoc || $[64] !== applyVariables || $[65] !== operationName || $[66] !== schemaArgFor || $[67] !== variablesText || $[68] !== workingDoc) {
328
- t21 = function handleDemoteArg(path_3, argName_2, varName_0) {
332
+ $[54] = applyDoc;
333
+ $[55] = applyVariables;
334
+ $[56] = operationName;
335
+ $[57] = schemaArgFor;
336
+ $[58] = variablesText;
337
+ $[59] = workingDoc;
338
+ $[60] = t19;
339
+ } else t19 = $[60];
340
+ const handlePromoteArg = t19;
341
+ let t20;
342
+ if ($[61] !== applyDoc || $[62] !== applyVariables || $[63] !== operationName || $[64] !== schemaArgFor || $[65] !== variablesText || $[66] !== workingDoc) {
343
+ t20 = function handleDemoteArg(path_3, argName_2, varName_0) {
329
344
  const vars_0 = readVariables(variablesText);
330
345
  const jsValue_0 = vars_0[varName_0];
331
346
  const schemaArg_1 = schemaArgFor(path_3, argName_2);
@@ -336,99 +351,99 @@ function useWorkingDocument() {
336
351
  delete rest[varName_0];
337
352
  applyVariables(rest);
338
353
  };
339
- $[63] = applyDoc;
340
- $[64] = applyVariables;
341
- $[65] = operationName;
342
- $[66] = schemaArgFor;
343
- $[67] = variablesText;
344
- $[68] = workingDoc;
345
- $[69] = t21;
346
- } else t21 = $[69];
347
- const handleDemoteArg = t21;
348
- let t22;
349
- if ($[70] !== applyDoc || $[71] !== target || $[72] !== workingDoc) {
350
- t22 = function handleAddInlineFragment(path_4, typeName) {
354
+ $[61] = applyDoc;
355
+ $[62] = applyVariables;
356
+ $[63] = operationName;
357
+ $[64] = schemaArgFor;
358
+ $[65] = variablesText;
359
+ $[66] = workingDoc;
360
+ $[67] = t20;
361
+ } else t20 = $[67];
362
+ const handleDemoteArg = t20;
363
+ let t21;
364
+ if ($[68] !== applyDoc || $[69] !== target || $[70] !== workingDoc) {
365
+ t21 = function handleAddInlineFragment(path_4, typeName) {
351
366
  applyDoc(addInlineFragment(workingDoc, path_4, typeName, target));
352
367
  };
353
- $[70] = applyDoc;
354
- $[71] = target;
355
- $[72] = workingDoc;
356
- $[73] = t22;
357
- } else t22 = $[73];
358
- const handleAddInlineFragment = t22;
359
- let t23;
360
- if ($[74] !== applyDoc || $[75] !== reconcileVariablesJson || $[76] !== target || $[77] !== workingDoc) {
361
- t23 = function handleRemoveInlineFragment(path_5, typeName_0) {
362
- const next_4 = removeInlineFragment(workingDoc, path_5, typeName_0, target);
363
- applyDoc(next_4);
364
- reconcileVariablesJson(next_4);
365
- };
366
- $[74] = applyDoc;
367
- $[75] = reconcileVariablesJson;
368
- $[76] = target;
369
- $[77] = workingDoc;
370
- $[78] = t23;
371
- } else t23 = $[78];
372
- const handleRemoveInlineFragment = t23;
373
- let t24;
374
- if ($[79] !== applyDoc || $[80] !== reconcileVariablesJson || $[81] !== target || $[82] !== workingDoc) {
375
- t24 = function handleRemoveFragmentSpread(path_6, fragmentName_0) {
376
- const next_5 = removeFragmentSpread(workingDoc, path_6, fragmentName_0, target);
368
+ $[68] = applyDoc;
369
+ $[69] = target;
370
+ $[70] = workingDoc;
371
+ $[71] = t21;
372
+ } else t21 = $[71];
373
+ const handleAddInlineFragment = t21;
374
+ let t22;
375
+ if ($[72] !== applyDoc || $[73] !== reconcileVariablesJson || $[74] !== target || $[75] !== workingDoc) {
376
+ t22 = function handleRemoveInlineFragment(path_5, typeName_0) {
377
+ const next_5 = removeInlineFragment(workingDoc, path_5, typeName_0, target);
377
378
  applyDoc(next_5);
378
379
  reconcileVariablesJson(next_5);
379
380
  };
380
- $[79] = applyDoc;
381
- $[80] = reconcileVariablesJson;
382
- $[81] = target;
383
- $[82] = workingDoc;
384
- $[83] = t24;
385
- } else t24 = $[83];
386
- const handleRemoveFragmentSpread = t24;
387
- let t25;
388
- if ($[84] !== applyDoc || $[85] !== target || $[86] !== workingDoc) {
389
- t25 = function handleExtractFragment(path_7, typeName_1) {
381
+ $[72] = applyDoc;
382
+ $[73] = reconcileVariablesJson;
383
+ $[74] = target;
384
+ $[75] = workingDoc;
385
+ $[76] = t22;
386
+ } else t22 = $[76];
387
+ const handleRemoveInlineFragment = t22;
388
+ let t23;
389
+ if ($[77] !== applyDoc || $[78] !== reconcileVariablesJson || $[79] !== target || $[80] !== workingDoc) {
390
+ t23 = function handleRemoveFragmentSpread(path_6, fragmentName_0) {
391
+ const next_6 = removeFragmentSpread(workingDoc, path_6, fragmentName_0, target);
392
+ applyDoc(next_6);
393
+ reconcileVariablesJson(next_6);
394
+ };
395
+ $[77] = applyDoc;
396
+ $[78] = reconcileVariablesJson;
397
+ $[79] = target;
398
+ $[80] = workingDoc;
399
+ $[81] = t23;
400
+ } else t23 = $[81];
401
+ const handleRemoveFragmentSpread = t23;
402
+ let t24;
403
+ if ($[82] !== applyDoc || $[83] !== target || $[84] !== workingDoc) {
404
+ t24 = function handleExtractFragment(path_7, typeName_1) {
390
405
  const base = `${typeName_1}Fields`;
391
406
  const existing = new Set(listFragments(workingDoc));
392
407
  let name_1 = base;
393
408
  for (let n = 2; existing.has(name_1); n++) name_1 = `${base}_${n}`;
394
409
  applyDoc(createFragmentFromSelection(workingDoc, path_7, name_1, typeName_1, target));
395
410
  };
396
- $[84] = applyDoc;
397
- $[85] = target;
398
- $[86] = workingDoc;
399
- $[87] = t25;
400
- } else t25 = $[87];
401
- const handleExtractFragment = t25;
402
- let t26;
403
- if ($[88] !== applyDoc || $[89] !== workingDoc) {
404
- t26 = function handleRenameFragment(oldName, newName) {
411
+ $[82] = applyDoc;
412
+ $[83] = target;
413
+ $[84] = workingDoc;
414
+ $[85] = t24;
415
+ } else t24 = $[85];
416
+ const handleExtractFragment = t24;
417
+ let t25;
418
+ if ($[86] !== applyDoc || $[87] !== workingDoc) {
419
+ t25 = function handleRenameFragment(oldName, newName) {
405
420
  applyDoc(renameFragment(workingDoc, oldName, newName));
406
421
  };
407
- $[88] = applyDoc;
408
- $[89] = workingDoc;
409
- $[90] = t26;
410
- } else t26 = $[90];
411
- const handleRenameFragment = t26;
412
- let t27;
413
- if ($[91] !== activeFragment || $[92] !== applyDoc || $[93] !== moveCursorToTarget || $[94] !== operationName || $[95] !== workingDoc) {
414
- t27 = function handleDeleteFragment(fragmentName_1) {
422
+ $[86] = applyDoc;
423
+ $[87] = workingDoc;
424
+ $[88] = t25;
425
+ } else t25 = $[88];
426
+ const handleRenameFragment = t25;
427
+ let t26;
428
+ if ($[89] !== activeFragment || $[90] !== applyDoc || $[91] !== moveCursorToTarget || $[92] !== operationName || $[93] !== workingDoc) {
429
+ t26 = function handleDeleteFragment(fragmentName_1) {
415
430
  applyDoc(inlineFragment(workingDoc, fragmentName_1));
416
431
  if (activeFragment === fragmentName_1) moveCursorToTarget({
417
432
  kind: "operation",
418
433
  name: operationName
419
434
  });
420
435
  };
421
- $[91] = activeFragment;
422
- $[92] = applyDoc;
423
- $[93] = moveCursorToTarget;
424
- $[94] = operationName;
425
- $[95] = workingDoc;
426
- $[96] = t27;
427
- } else t27 = $[96];
428
- const handleDeleteFragment = t27;
429
- let t28;
430
- if ($[97] !== activeOpKind || $[98] !== cursorPath || $[99] !== handleAddInlineFragment || $[100] !== handleBackToQuery || $[101] !== handleDeleteFragment || $[102] !== handleDemoteArg || $[103] !== handleExtractFragment || $[104] !== handleFocusFragment || $[105] !== handlePromoteArg || $[106] !== handleRemoveFragmentSpread || $[107] !== handleRemoveInlineFragment || $[108] !== handleRenameFragment || $[109] !== handleSetArg || $[110] !== handleToggle || $[111] !== target || $[112] !== workingDoc) {
431
- t28 = {
436
+ $[89] = activeFragment;
437
+ $[90] = applyDoc;
438
+ $[91] = moveCursorToTarget;
439
+ $[92] = operationName;
440
+ $[93] = workingDoc;
441
+ $[94] = t26;
442
+ } else t26 = $[94];
443
+ const handleDeleteFragment = t26;
444
+ let t27;
445
+ if ($[95] !== activeOpKind || $[96] !== cursorPath || $[97] !== handleAddInlineFragment || $[98] !== handleBackToQuery || $[99] !== handleDeleteFragment || $[100] !== handleDemoteArg || $[101] !== handleExtractFragment || $[102] !== handleFocusFragment || $[103] !== handlePromoteArg || $[104] !== handleRemoveFragmentSpread || $[105] !== handleRemoveInlineFragment || $[106] !== handleRenameFragment || $[107] !== handleSetArg || $[108] !== handleToggle || $[109] !== target || $[110] !== workingDoc) {
446
+ t27 = {
432
447
  workingDoc,
433
448
  activeOpKind,
434
449
  target,
@@ -446,25 +461,25 @@ function useWorkingDocument() {
446
461
  handleRenameFragment,
447
462
  handleDeleteFragment
448
463
  };
449
- $[97] = activeOpKind;
450
- $[98] = cursorPath;
451
- $[99] = handleAddInlineFragment;
452
- $[100] = handleBackToQuery;
453
- $[101] = handleDeleteFragment;
454
- $[102] = handleDemoteArg;
455
- $[103] = handleExtractFragment;
456
- $[104] = handleFocusFragment;
457
- $[105] = handlePromoteArg;
458
- $[106] = handleRemoveFragmentSpread;
459
- $[107] = handleRemoveInlineFragment;
460
- $[108] = handleRenameFragment;
461
- $[109] = handleSetArg;
462
- $[110] = handleToggle;
463
- $[111] = target;
464
- $[112] = workingDoc;
465
- $[113] = t28;
466
- } else t28 = $[113];
467
- return t28;
464
+ $[95] = activeOpKind;
465
+ $[96] = cursorPath;
466
+ $[97] = handleAddInlineFragment;
467
+ $[98] = handleBackToQuery;
468
+ $[99] = handleDeleteFragment;
469
+ $[100] = handleDemoteArg;
470
+ $[101] = handleExtractFragment;
471
+ $[102] = handleFocusFragment;
472
+ $[103] = handlePromoteArg;
473
+ $[104] = handleRemoveFragmentSpread;
474
+ $[105] = handleRemoveInlineFragment;
475
+ $[106] = handleRenameFragment;
476
+ $[107] = handleSetArg;
477
+ $[108] = handleToggle;
478
+ $[109] = target;
479
+ $[110] = workingDoc;
480
+ $[111] = t27;
481
+ } else t27 = $[111];
482
+ return t27;
468
483
  }
469
484
  function _temp6(state_4) {
470
485
  return state_4.tabs;
@@ -484,7 +499,6 @@ function _temp2(state_0) {
484
499
  function _temp(state) {
485
500
  return state.schema;
486
501
  }
487
- //#endregion
488
502
  export { useWorkingDocument };
489
503
 
490
504
  //# sourceMappingURL=use-working-document.js.map