@graphiql/plugin-doc-explorer 0.1.0-canary-65327511.0 → 0.1.0

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 (42) hide show
  1. package/dist/components/argument.d.ts +2 -1
  2. package/dist/components/argument.js +3 -3
  3. package/dist/components/argument.js.map +1 -1
  4. package/dist/components/default-value.d.ts +4 -3
  5. package/dist/components/default-value.js +2 -2
  6. package/dist/components/default-value.js.map +1 -1
  7. package/dist/components/deprecation-reason.d.ts +3 -2
  8. package/dist/components/deprecation-reason.js +2 -2
  9. package/dist/components/deprecation-reason.js.map +1 -1
  10. package/dist/components/directive.d.ts +2 -1
  11. package/dist/components/directive.js +2 -2
  12. package/dist/components/directive.js.map +1 -1
  13. package/dist/components/doc-explorer.d.ts +2 -1
  14. package/dist/components/doc-explorer.js +116 -126
  15. package/dist/components/doc-explorer.js.map +1 -1
  16. package/dist/components/field-documentation.d.ts +4 -3
  17. package/dist/components/field-documentation.js +66 -71
  18. package/dist/components/field-documentation.js.map +1 -1
  19. package/dist/components/field-link.d.ts +4 -3
  20. package/dist/components/field-link.js +21 -27
  21. package/dist/components/field-link.js.map +1 -1
  22. package/dist/components/schema-documentation.d.ts +2 -1
  23. package/dist/components/schema-documentation.js +98 -95
  24. package/dist/components/schema-documentation.js.map +1 -1
  25. package/dist/components/search.js +130 -151
  26. package/dist/components/search.js.map +1 -1
  27. package/dist/components/section.d.ts +2 -2
  28. package/dist/components/section.js +37 -33
  29. package/dist/components/section.js.map +1 -1
  30. package/dist/components/type-documentation.d.ts +2 -1
  31. package/dist/components/type-documentation.js +47 -44
  32. package/dist/components/type-documentation.js.map +1 -1
  33. package/dist/components/type-link.d.ts +2 -1
  34. package/dist/components/type-link.js +19 -26
  35. package/dist/components/type-link.js.map +1 -1
  36. package/dist/context.d.ts +47 -28
  37. package/dist/context.js +214 -142
  38. package/dist/context.js.map +1 -1
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.js +5 -4
  41. package/dist/index.js.map +1 -1
  42. package/package.json +4 -3
package/dist/context.js CHANGED
@@ -1,19 +1,158 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
4
- import { useState, useEffect } from "react";
5
- import { createNullableContext, createContextHook, useSchemaContext } from "@graphiql/react";
6
- const initialNavStackItem = {
4
+ import { createContext, useRef, useEffect, useContext } from "react";
5
+ import { useSchemaContext } from "@graphiql/react";
6
+ import { createStore, useStore } from "zustand";
7
+ function createDocExplorerStore(initialNavStackItem = {
7
8
  name: "Docs"
8
- };
9
- const ExplorerContext = createNullableContext("ExplorerContext");
10
- function ExplorerContextProvider(props) {
11
- const $ = c(14);
9
+ }) {
10
+ return createStore((set, get) => ({
11
+ explorerNavStack: [initialNavStackItem],
12
+ actions: {
13
+ push(item) {
14
+ set((state) => {
15
+ const curr = state.explorerNavStack;
16
+ const lastItem = curr.at(-1);
17
+ const explorerNavStack = (
18
+ // Avoid pushing duplicate items
19
+ lastItem.def === item.def ? curr : [...curr, item]
20
+ );
21
+ return {
22
+ explorerNavStack
23
+ };
24
+ });
25
+ },
26
+ pop() {
27
+ set((state) => {
28
+ const curr = state.explorerNavStack;
29
+ const explorerNavStack = curr.length > 1 ? curr.slice(0, -1) : curr;
30
+ return {
31
+ explorerNavStack
32
+ };
33
+ });
34
+ },
35
+ reset() {
36
+ set((state) => {
37
+ const curr = state.explorerNavStack;
38
+ const explorerNavStack = curr.length === 1 ? curr : [initialNavStackItem];
39
+ return {
40
+ explorerNavStack
41
+ };
42
+ });
43
+ },
44
+ resolveSchemaReferenceToNavItem(schemaReference) {
45
+ if (!schemaReference) {
46
+ return;
47
+ }
48
+ const {
49
+ push
50
+ } = get().actions;
51
+ switch (schemaReference.kind) {
52
+ case "Type": {
53
+ push({
54
+ name: schemaReference.type.name,
55
+ def: schemaReference.type
56
+ });
57
+ break;
58
+ }
59
+ case "Field": {
60
+ push({
61
+ name: schemaReference.field.name,
62
+ def: schemaReference.field
63
+ });
64
+ break;
65
+ }
66
+ case "Argument": {
67
+ if (schemaReference.field) {
68
+ push({
69
+ name: schemaReference.field.name,
70
+ def: schemaReference.field
71
+ });
72
+ }
73
+ break;
74
+ }
75
+ case "EnumValue": {
76
+ if (schemaReference.type) {
77
+ push({
78
+ name: schemaReference.type.name,
79
+ def: schemaReference.type
80
+ });
81
+ }
82
+ break;
83
+ }
84
+ }
85
+ },
86
+ rebuildNavStackWithSchema(schema) {
87
+ set((state) => {
88
+ const oldNavStack = state.explorerNavStack;
89
+ if (oldNavStack.length === 1) {
90
+ return oldNavStack;
91
+ }
92
+ const newNavStack = [initialNavStackItem];
93
+ let lastEntity = null;
94
+ for (const item of oldNavStack) {
95
+ if (item === initialNavStackItem) {
96
+ continue;
97
+ }
98
+ if (item.def) {
99
+ if (isNamedType(item.def)) {
100
+ const newType = schema.getType(item.def.name);
101
+ if (newType) {
102
+ newNavStack.push({
103
+ name: item.name,
104
+ def: newType
105
+ });
106
+ lastEntity = newType;
107
+ } else {
108
+ break;
109
+ }
110
+ } else if (lastEntity === null) {
111
+ break;
112
+ } else if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
113
+ const field = lastEntity.getFields()[item.name];
114
+ if (field) {
115
+ newNavStack.push({
116
+ name: item.name,
117
+ def: field
118
+ });
119
+ } else {
120
+ break;
121
+ }
122
+ } else if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
123
+ break;
124
+ } else {
125
+ const field = lastEntity;
126
+ if (field.args.some((a) => a.name === item.name)) {
127
+ newNavStack.push({
128
+ name: item.name,
129
+ def: field
130
+ });
131
+ } else {
132
+ break;
133
+ }
134
+ }
135
+ } else {
136
+ lastEntity = null;
137
+ newNavStack.push(item);
138
+ }
139
+ }
140
+ return {
141
+ explorerNavStack: newNavStack
142
+ };
143
+ });
144
+ }
145
+ }
146
+ }));
147
+ }
148
+ const DocExplorerContext = createContext(null);
149
+ const DocExplorerContextProvider = (props) => {
150
+ const $ = c(11);
12
151
  let t0;
13
152
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
14
153
  t0 = {
15
154
  nonNull: true,
16
- caller: ExplorerContextProvider
155
+ caller: DocExplorerContextProvider
17
156
  };
18
157
  $[0] = t0;
19
158
  } else {
@@ -21,163 +160,96 @@ function ExplorerContextProvider(props) {
21
160
  }
22
161
  const {
23
162
  schema,
24
- validationErrors
163
+ validationErrors,
164
+ schemaReference
25
165
  } = useSchemaContext(t0);
26
- let t1;
27
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
28
- t1 = [initialNavStackItem];
29
- $[1] = t1;
30
- } else {
31
- t1 = $[1];
166
+ const storeRef = useRef(null);
167
+ if (storeRef.current === null) {
168
+ let t12;
169
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
170
+ t12 = createDocExplorerStore();
171
+ $[1] = t12;
172
+ } else {
173
+ t12 = $[1];
174
+ }
175
+ storeRef.current = t12;
32
176
  }
33
- const [navStack, setNavStack] = useState(t1);
177
+ let t1;
34
178
  let t2;
35
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
36
- t2 = (item) => {
37
- setNavStack((currentState) => {
38
- const lastItem = currentState.at(-1);
39
- return lastItem.def === item.def ? currentState : [...currentState, item];
40
- });
179
+ if ($[2] !== schemaReference) {
180
+ t1 = () => {
181
+ const {
182
+ resolveSchemaReferenceToNavItem
183
+ } = storeRef.current.getState().actions;
184
+ resolveSchemaReferenceToNavItem(schemaReference);
41
185
  };
42
- $[2] = t2;
186
+ t2 = [schemaReference];
187
+ $[2] = schemaReference;
188
+ $[3] = t1;
189
+ $[4] = t2;
43
190
  } else {
44
- t2 = $[2];
191
+ t1 = $[3];
192
+ t2 = $[4];
45
193
  }
46
- const push = t2;
194
+ useEffect(t1, t2);
47
195
  let t3;
48
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
49
- t3 = () => {
50
- setNavStack(_temp);
51
- };
52
- $[3] = t3;
53
- } else {
54
- t3 = $[3];
55
- }
56
- const pop = t3;
57
196
  let t4;
58
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
59
- t4 = () => {
60
- setNavStack(_temp2);
61
- };
62
- $[4] = t4;
63
- } else {
64
- t4 = $[4];
65
- }
66
- const reset = t4;
67
- let t5;
68
- let t6;
69
197
  if ($[5] !== schema || $[6] !== validationErrors) {
70
- t5 = () => {
198
+ t3 = () => {
199
+ const {
200
+ reset,
201
+ rebuildNavStackWithSchema
202
+ } = storeRef.current.getState().actions;
71
203
  if (schema == null || validationErrors.length > 0) {
72
204
  reset();
73
- return;
205
+ } else {
206
+ rebuildNavStackWithSchema(schema);
74
207
  }
75
- setNavStack((oldNavStack) => {
76
- if (oldNavStack.length === 1) {
77
- return oldNavStack;
78
- }
79
- const newNavStack = [initialNavStackItem];
80
- let lastEntity = null;
81
- for (const item_0 of oldNavStack) {
82
- if (item_0 === initialNavStackItem) {
83
- continue;
84
- }
85
- if (item_0.def) {
86
- if (isNamedType(item_0.def)) {
87
- const newType = schema.getType(item_0.def.name);
88
- if (newType) {
89
- newNavStack.push({
90
- name: item_0.name,
91
- def: newType
92
- });
93
- lastEntity = newType;
94
- } else {
95
- break;
96
- }
97
- } else {
98
- if (lastEntity === null) {
99
- break;
100
- } else {
101
- if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
102
- const field = lastEntity.getFields()[item_0.name];
103
- if (field) {
104
- newNavStack.push({
105
- name: item_0.name,
106
- def: field
107
- });
108
- } else {
109
- break;
110
- }
111
- } else {
112
- if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
113
- break;
114
- } else {
115
- const field_0 = lastEntity;
116
- if (field_0.args.some((a) => a.name === item_0.name)) {
117
- newNavStack.push({
118
- name: item_0.name,
119
- def: field_0
120
- });
121
- } else {
122
- break;
123
- }
124
- }
125
- }
126
- }
127
- }
128
- } else {
129
- lastEntity = null;
130
- newNavStack.push(item_0);
131
- }
132
- }
133
- return newNavStack;
134
- });
135
208
  };
136
- t6 = [schema, validationErrors];
209
+ t4 = [schema, validationErrors];
137
210
  $[5] = schema;
138
211
  $[6] = validationErrors;
139
- $[7] = t5;
140
- $[8] = t6;
212
+ $[7] = t3;
213
+ $[8] = t4;
141
214
  } else {
142
- t5 = $[7];
143
- t6 = $[8];
215
+ t3 = $[7];
216
+ t4 = $[8];
144
217
  }
145
- useEffect(t5, t6);
146
- let t7;
147
- if ($[9] !== navStack) {
148
- t7 = {
149
- explorerNavStack: navStack,
150
- push,
151
- pop,
152
- reset
153
- };
154
- $[9] = navStack;
155
- $[10] = t7;
218
+ useEffect(t3, t4);
219
+ let t5;
220
+ if ($[9] !== props.children) {
221
+ t5 = /* @__PURE__ */ jsx(DocExplorerContext.Provider, { value: storeRef, children: props.children });
222
+ $[9] = props.children;
223
+ $[10] = t5;
156
224
  } else {
157
- t7 = $[10];
225
+ t5 = $[10];
158
226
  }
159
- const value = t7;
160
- let t8;
161
- if ($[11] !== props.children || $[12] !== value) {
162
- t8 = /* @__PURE__ */ jsx(ExplorerContext.Provider, { value, children: props.children });
163
- $[11] = props.children;
164
- $[12] = value;
165
- $[13] = t8;
166
- } else {
167
- t8 = $[13];
227
+ return t5;
228
+ };
229
+ function useDocExplorerStore(selector) {
230
+ const store = useContext(DocExplorerContext);
231
+ if (!store) {
232
+ throw new Error("Missing `DocExplorerContextProvider` in the tree");
168
233
  }
169
- return t8;
234
+ return useStore(store.current, selector);
170
235
  }
171
- function _temp2(currentState_1) {
172
- return currentState_1.length === 1 ? currentState_1 : [initialNavStackItem];
236
+ const useDocExplorer = () => {
237
+ return useDocExplorerStore(_temp);
238
+ };
239
+ const useDocExplorerActions = () => {
240
+ return useDocExplorerStore(_temp2);
241
+ };
242
+ function _temp(state) {
243
+ return state.explorerNavStack;
173
244
  }
174
- function _temp(currentState_0) {
175
- return currentState_0.length > 1 ? currentState_0.slice(0, -1) : currentState_0;
245
+ function _temp2(state) {
246
+ return state.actions;
176
247
  }
177
- const useExplorerContext = createContextHook(ExplorerContext);
178
248
  export {
179
- ExplorerContext,
180
- ExplorerContextProvider,
181
- useExplorerContext
249
+ DocExplorerContext,
250
+ DocExplorerContextProvider,
251
+ createDocExplorerStore,
252
+ useDocExplorer,
253
+ useDocExplorerActions
182
254
  };
183
255
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { ReactNode, useEffect, useState } from 'react';\nimport {\n useSchemaContext,\n createContextHook,\n createNullableContext,\n} from '@graphiql/react';\n\nexport type ExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type ExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | ExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type ExplorerNavStack = [\n ExplorerNavStackItem,\n ...ExplorerNavStackItem[],\n];\n\nconst initialNavStackItem: ExplorerNavStackItem = { name: 'Docs' };\n\nexport type ExplorerContextType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: ExplorerNavStack;\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: ExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n};\n\nexport const ExplorerContext =\n createNullableContext<ExplorerContextType>('ExplorerContext');\n\ntype ExplorerContextProviderProps = {\n children: ReactNode;\n};\n\nexport function ExplorerContextProvider(props: ExplorerContextProviderProps) {\n const { schema, validationErrors } = useSchemaContext({\n nonNull: true,\n caller: ExplorerContextProvider,\n });\n\n const [navStack, setNavStack] = useState<ExplorerNavStack>([\n initialNavStackItem,\n ]);\n\n const push = (item: ExplorerNavStackItem) => {\n setNavStack(currentState => {\n const lastItem = currentState.at(-1)!;\n return lastItem.def === item.def\n ? // Avoid pushing duplicate items\n currentState\n : [...currentState, item];\n });\n };\n\n const pop = () => {\n setNavStack(currentState =>\n currentState.length > 1\n ? (currentState.slice(0, -1) as ExplorerNavStack)\n : currentState,\n );\n };\n\n const reset = () => {\n setNavStack(currentState =>\n currentState.length === 1 ? currentState : [initialNavStackItem],\n );\n };\n\n useEffect(() => {\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n return;\n }\n // Replace the nav stack with an updated version using the new schema\n setNavStack(oldNavStack => {\n if (oldNavStack.length === 1) {\n return oldNavStack;\n }\n const newNavStack: ExplorerNavStack = [initialNavStackItem];\n let lastEntity: GraphQLNamedType | GraphQLField<unknown, unknown> | null =\n null;\n for (const item of oldNavStack) {\n if (item === initialNavStackItem) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return newNavStack;\n });\n }, [schema, validationErrors]);\n\n const value: ExplorerContextType = {\n explorerNavStack: navStack,\n push,\n pop,\n reset,\n };\n\n return (\n <ExplorerContext.Provider value={value}>\n {props.children}\n </ExplorerContext.Provider>\n );\n}\n\nexport const useExplorerContext = createContextHook(ExplorerContext);\n"],"names":["initialNavStackItem","name","ExplorerContext","createNullableContext","ExplorerContextProvider","props","$","_c","t0","Symbol","for","nonNull","caller","schema","validationErrors","useSchemaContext","t1","navStack","setNavStack","useState","t2","item","currentState","lastItem","at","def","push","t3","_temp","pop","t4","_temp2","reset","t5","t6","length","oldNavStack","newNavStack","lastEntity","item_0","isNamedType","newType","getType","isObjectType","isInputObjectType","field","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","field_0","args","some","a","useEffect","t7","explorerNavStack","value","t8","children","currentState_1","currentState_0","slice","useExplorerContext","createContextHook"],"mappings":";;;;;AA6CA,MAAMA,sBAA4C;AAAA,EAAEC,MAAM;AAAO;AAwBpDC,MAAAA,kBACXC,sBAA2C,iBAAiB;AAMvD,SAAAC,wBAAAC,OAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AACiD,SAAA;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gBb,iBAAY,CAAAtB,mBAAA;AAAwB;AA9B/D,SAAA4B,MAAAkC,gBAAA;AAAA,SAsBDxC,eAAYa,SAAA,IACPb,eAAYyC,MAAY,GAAA,EAAA,IACzBzC;AAAY;AA4GT0C,MAAAA,qBAAqBC,kBAAkB/D,eAAe;"}
1
+ {"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport {\n createContext,\n FC,\n ReactNode,\n RefObject,\n useContext,\n useEffect,\n useRef,\n} from 'react';\nimport { SchemaContextType, useSchemaContext } from '@graphiql/react';\nimport { createStore, StoreApi, useStore } from 'zustand';\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerContextType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: DocExplorerNavStack;\n actions: {\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: DocExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n resolveSchemaReferenceToNavItem(\n schemaReference: SchemaContextType['schemaReference'],\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nexport function createDocExplorerStore(\n initialNavStackItem: DocExplorerNavStackItem = { name: 'Docs' },\n) {\n return createStore<DocExplorerContextType>((set, get) => ({\n explorerNavStack: [initialNavStackItem],\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack: DocExplorerNavStack =\n curr.length === 1 ? curr : [initialNavStackItem];\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { push } = get().actions;\n switch (schemaReference.kind) {\n case 'Type': {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n break;\n }\n case 'Field': {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n break;\n }\n case 'Argument': {\n if (schemaReference.field) {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (schemaReference.type) {\n push({\n name: schemaReference.type.name,\n def: schemaReference.type,\n });\n }\n break;\n }\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return oldNavStack;\n }\n const newNavStack: DocExplorerNavStack = [initialNavStackItem];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === initialNavStackItem) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return { explorerNavStack: newNavStack };\n });\n },\n },\n }));\n}\n\nexport const DocExplorerContext = createContext<RefObject<\n StoreApi<DocExplorerContextType>\n> | null>(null);\n\nexport const DocExplorerContextProvider: FC<{\n children: ReactNode;\n}> = props => {\n const { schema, validationErrors, schemaReference } = useSchemaContext({\n nonNull: true,\n caller: DocExplorerContextProvider,\n });\n\n const storeRef = useRef<StoreApi<DocExplorerContextType>>(null!);\n\n if (storeRef.current === null) {\n storeRef.current = createDocExplorerStore();\n }\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n storeRef.current.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n storeRef.current.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n return (\n <DocExplorerContext.Provider value={storeRef}>\n {props.children}\n </DocExplorerContext.Provider>\n );\n};\n\nfunction useDocExplorerStore<T>(\n selector: (state: DocExplorerContextType) => T,\n): T {\n const store = useContext(DocExplorerContext);\n if (!store) {\n throw new Error('Missing `DocExplorerContextProvider` in the tree');\n }\n return useStore(store.current, selector);\n}\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"names":["createDocExplorerStore","initialNavStackItem","name","createStore","set","get","explorerNavStack","actions","push","item","state","curr","lastItem","at","def","pop","length","slice","reset","resolveSchemaReferenceToNavItem","schemaReference","kind","type","field","rebuildNavStackWithSchema","schema","oldNavStack","newNavStack","lastEntity","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","args","some","a","DocExplorerContext","createContext","DocExplorerContextProvider","props","$","_c","t0","Symbol","for","nonNull","caller","validationErrors","useSchemaContext","storeRef","useRef","current","t1","t2","getState","useEffect","t3","t4","t5","children","useDocExplorerStore","selector","store","useContext","Error","useStore","useDocExplorer","_temp","useDocExplorerActions","_temp2"],"mappings":";;;;;;AAkFO,SAASA,uBACdC,sBAA+C;AAAA,EAAEC,MAAM;AAAO,GAC9D;AACOC,SAAAA,YAAoC,CAACC,KAAKC,SAAS;AAAA,IACxDC,kBAAkB,CAACL,mBAAmB;AAAA,IACtCM,SAAS;AAAA,MACPC,KAAKC,MAAM;AACTL,YAAIM,CAAS,UAAA;AACX,gBAAMC,OAAOD,MAAMJ;AACbM,gBAAAA,WAAWD,KAAKE,GAAG,EAAE;AACrBP,gBAAAA;AAAAA;AAAAA,YAEJM,SAASE,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,EAAA;AAE7DC,SAAAA,SAASH,MAAKX,SAAUU,QAAQ;AAAC;AAGnC,MAAMK,iBAAiBA,MAAA;AAAA,SAC5BN,oBAAAO,KAAmD;AAAC;AAC/C,MAAMC,wBAAwBA,MAAA;AAAA,SACnCR,oBAAAS,MAA0C;AAAC;AAHf,SAAAF,MAAA/D,OAAA;AAAA,SACCA,MAAKJ;AAAA;AACC,SAAAqE,OAAAjE,OAAA;AAAA,SACNA,MAAKH;AAAA;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { GraphiQLPlugin } from '@graphiql/react';
2
2
  export * from './components';
3
- export { ExplorerContext, ExplorerContextProvider, useExplorerContext, } from './context';
4
- export type { ExplorerContextType, ExplorerFieldDef, ExplorerNavStack, ExplorerNavStackItem, } from './context';
3
+ export { DocExplorerContext, DocExplorerContextProvider, useDocExplorer, useDocExplorerActions, } from './context';
4
+ export type { DocExplorerContextType, DocExplorerFieldDef, DocExplorerNavStack, DocExplorerNavStackItem, } from './context';
5
5
  export declare const DOC_EXPLORER_PLUGIN: GraphiQLPlugin;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { usePluginContext, DocsFilledIcon, DocsIcon } from "@graphiql/react";
3
- import { ExplorerContext, ExplorerContextProvider, useExplorerContext } from "./context.js";
3
+ import { DocExplorerContext, DocExplorerContextProvider, useDocExplorer, useDocExplorerActions } from "./context.js";
4
4
  import { DocExplorer } from "./components/doc-explorer.js";
5
5
  import { Argument } from "./components/argument.js";
6
6
  import { DefaultValue } from "./components/default-value.js";
@@ -28,8 +28,8 @@ export {
28
28
  DeprecationReason,
29
29
  Directive,
30
30
  DocExplorer,
31
- ExplorerContext,
32
- ExplorerContextProvider,
31
+ DocExplorerContext,
32
+ DocExplorerContextProvider,
33
33
  ExplorerSection,
34
34
  FieldDocumentation,
35
35
  FieldLink,
@@ -37,6 +37,7 @@ export {
37
37
  Search,
38
38
  TypeDocumentation,
39
39
  TypeLink,
40
- useExplorerContext
40
+ useDocExplorer,
41
+ useDocExplorerActions
41
42
  };
42
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n DocsFilledIcon,\n DocsIcon,\n GraphiQLPlugin,\n usePluginContext,\n} from '@graphiql/react';\nimport { DocExplorer } from './components';\n\nexport * from './components';\n\nexport {\n ExplorerContext,\n ExplorerContextProvider,\n useExplorerContext,\n} from './context';\n\nexport type {\n ExplorerContextType,\n ExplorerFieldDef,\n ExplorerNavStack,\n ExplorerNavStackItem,\n} from './context';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const pluginContext = usePluginContext();\n return pluginContext?.visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n"],"names":["DOC_EXPLORER_PLUGIN","title","icon","Icon","pluginContext","usePluginContext","visiblePlugin","content","DocExplorer"],"mappings":";;;;;;;;;;;;;;;AAuBO,MAAMA,sBAAsC;AAAA,EACjDC,OAAO;AAAA,EACPC,MAAM,SAASC,OAAO;AACpB,UAAMC,gBAAgBC,iBAAiB;AACvC,YAAOD,+CAAeE,mBAAkBN,0CACrC,gBAAiB,CAAA,CAAA,wBAEjB,UACF,EAAA;AAAA,EACH;AAAA,EACAO,SAASC;AACX;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n DocsFilledIcon,\n DocsIcon,\n GraphiQLPlugin,\n usePluginContext,\n} from '@graphiql/react';\nimport { DocExplorer } from './components';\n\nexport * from './components';\n\nexport {\n DocExplorerContext,\n DocExplorerContextProvider,\n useDocExplorer,\n useDocExplorerActions,\n} from './context';\n\nexport type {\n DocExplorerContextType,\n DocExplorerFieldDef,\n DocExplorerNavStack,\n DocExplorerNavStackItem,\n} from './context';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const pluginContext = usePluginContext();\n return pluginContext?.visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n"],"names":["DOC_EXPLORER_PLUGIN","title","icon","Icon","pluginContext","usePluginContext","visiblePlugin","content","DocExplorer"],"mappings":";;;;;;;;;;;;;;;AAwBO,MAAMA,sBAAsC;AAAA,EACjDC,OAAO;AAAA,EACPC,MAAM,SAASC,OAAO;AACpB,UAAMC,gBAAgBC,iBAAiB;AACvC,YAAOD,+CAAeE,mBAAkBN,0CACrC,gBAAiB,CAAA,CAAA,wBAEjB,UACF,EAAA;AAAA,EACH;AAAA,EACAO,SAASC;AACX;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphiql/plugin-doc-explorer",
3
- "version": "0.1.0-canary-65327511.0",
3
+ "version": "0.1.0",
4
4
  "sideEffects": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,8 +42,9 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "react-compiler-runtime": "19.1.0-rc.1",
45
- "@graphiql/react": "^0.32.0-canary-65327511.0",
46
- "@headlessui/react": "^2.2"
45
+ "@graphiql/react": "^0.32.2",
46
+ "@headlessui/react": "^2.2",
47
+ "zustand": "^5"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@vitejs/plugin-react": "^4.4.1",