@graphiql/plugin-doc-explorer 0.1.0-canary-24ce3ea2.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.
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { useState } from "react";
4
4
  import { isNamedType, isObjectType, isInterfaceType, isInputObjectType, isEnumType, isAbstractType } from "graphql";
5
- import { MarkdownContent, Button, useSchemaStore } from "@graphiql/react";
5
+ import { MarkdownContent, Button, useSchemaContext } from "@graphiql/react";
6
6
  import { Argument } from "./argument.js";
7
7
  import { DefaultValue } from "./default-value.js";
8
8
  import { DeprecationReason } from "./deprecation-reason.js";
@@ -299,7 +299,7 @@ const EnumValue = (t0) => {
299
299
  }
300
300
  let t2;
301
301
  if ($[2] !== value.description) {
302
- t2 = value.description && /* @__PURE__ */ jsx(MarkdownContent, { type: "description", children: value.description });
302
+ t2 = value.description ? /* @__PURE__ */ jsx(MarkdownContent, { type: "description", children: value.description }) : null;
303
303
  $[2] = value.description;
304
304
  $[3] = t2;
305
305
  } else {
@@ -307,7 +307,7 @@ const EnumValue = (t0) => {
307
307
  }
308
308
  let t3;
309
309
  if ($[4] !== value.deprecationReason) {
310
- t3 = value.deprecationReason && /* @__PURE__ */ jsx(MarkdownContent, { type: "deprecation", children: value.deprecationReason });
310
+ t3 = value.deprecationReason ? /* @__PURE__ */ jsx(MarkdownContent, { type: "deprecation", children: value.deprecationReason }) : null;
311
311
  $[4] = value.deprecationReason;
312
312
  $[5] = t3;
313
313
  } else {
@@ -330,36 +330,45 @@ const EnumValue = (t0) => {
330
330
  return t4;
331
331
  };
332
332
  const PossibleTypes = (t0) => {
333
- const $ = c(6);
333
+ const $ = c(7);
334
334
  const {
335
335
  type
336
336
  } = t0;
337
+ let t1;
338
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
339
+ t1 = {
340
+ nonNull: true
341
+ };
342
+ $[0] = t1;
343
+ } else {
344
+ t1 = $[0];
345
+ }
337
346
  const {
338
347
  schema
339
- } = useSchemaStore();
348
+ } = useSchemaContext(t1);
340
349
  if (!schema || !isAbstractType(type)) {
341
350
  return null;
342
351
  }
343
- const t1 = isInterfaceType(type) ? "Implementations" : "Possible Types";
344
- let t2;
345
- if ($[0] !== schema || $[1] !== type) {
346
- t2 = schema.getPossibleTypes(type).map(_temp7);
347
- $[0] = schema;
348
- $[1] = type;
349
- $[2] = t2;
352
+ const t2 = isInterfaceType(type) ? "Implementations" : "Possible Types";
353
+ let t3;
354
+ if ($[1] !== schema || $[2] !== type) {
355
+ t3 = schema.getPossibleTypes(type).map(_temp7);
356
+ $[1] = schema;
357
+ $[2] = type;
358
+ $[3] = t3;
350
359
  } else {
351
- t2 = $[2];
360
+ t3 = $[3];
352
361
  }
353
- let t3;
354
- if ($[3] !== t1 || $[4] !== t2) {
355
- t3 = /* @__PURE__ */ jsx(ExplorerSection, { title: t1, children: t2 });
356
- $[3] = t1;
362
+ let t4;
363
+ if ($[4] !== t2 || $[5] !== t3) {
364
+ t4 = /* @__PURE__ */ jsx(ExplorerSection, { title: t2, children: t3 });
357
365
  $[4] = t2;
358
366
  $[5] = t3;
367
+ $[6] = t4;
359
368
  } else {
360
- t3 = $[5];
369
+ t4 = $[6];
361
370
  }
362
- return t3;
371
+ return t4;
363
372
  };
364
373
  function _temp(implementedInterface) {
365
374
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TypeLink, { type: implementedInterface }) }, implementedInterface.name);
@@ -1 +1 @@
1
- {"version":3,"file":"type-documentation.js","sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useSchemaStore, Button, MarkdownContent } from '@graphiql/react';\nimport { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({ type }) => {\n return isNamedType(type) ? (\n <>\n {type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n <ImplementsInterfaces type={type} />\n <Fields type={type} />\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name])) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 ? (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedValues.length > 0 ? (\n showDeprecated || values.length === 0 ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description && (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n )}\n {value.deprecationReason && (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n )}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const { schema } = useSchemaStore();\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"names":["TypeDocumentation","t0","$","_c","type","t1","isNamedType","description","ImplementsInterfaces","isObjectType","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","useState","Symbol","for","handleShowDeprecated","isInterfaceType","isInputObjectType","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","isEnumType","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","schema","useSchemaStore","isAbstractType","getPossibleTypes","_temp7","implementedInterface","field_0","field_1","value_0","value_1","possibleType"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,oBAAgDC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAAQI,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAC7DE,SAAAA,YAAYF,IAAI,IAElBA,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAA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tC,oBAAA,WAAA,EAAkCd,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AAzBL,SAAAyB,OAAAY,SAAA;AAAA,SAiCpC,oBAAA,WAAA,EAAkCf,OAAAA,QAAAA,GAAnBA,QAAKtB,IAAuB;AAAA;AA+BJ,SAAAgC,OAAAM,cAAA;AAU9C,SAAA,6BACE,UAAC,oBAAA,UAAA,EAAeA,mBAAY,CAAA,KADpBA,aAAYtC,IAEtB;AAAM;"}
1
+ {"version":3,"file":"type-documentation.js","sources":["../../src/components/type-documentation.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport {\n GraphQLEnumValue,\n GraphQLNamedType,\n isAbstractType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { useSchemaContext, Button, MarkdownContent } from '@graphiql/react';\nimport { DocExplorerFieldDef } from '../context';\nimport { Argument } from './argument';\nimport { DefaultValue } from './default-value';\nimport { DeprecationReason } from './deprecation-reason';\nimport { FieldLink } from './field-link';\nimport { ExplorerSection } from './section';\nimport { TypeLink } from './type-link';\nimport './type-documentation.css';\n\ntype TypeDocumentationProps = {\n /**\n * The type that should be rendered.\n */\n type: GraphQLNamedType;\n};\n\nexport const TypeDocumentation: FC<TypeDocumentationProps> = ({ type }) => {\n return isNamedType(type) ? (\n <>\n {type.description ? (\n <MarkdownContent type=\"description\">{type.description}</MarkdownContent>\n ) : null}\n <ImplementsInterfaces type={type} />\n <Fields type={type} />\n <EnumValues type={type} />\n <PossibleTypes type={type} />\n </>\n ) : null;\n};\n\nconst ImplementsInterfaces: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n if (!isObjectType(type)) {\n return null;\n }\n const interfaces = type.getInterfaces();\n return interfaces.length > 0 ? (\n <ExplorerSection title=\"Implements\">\n {type.getInterfaces().map(implementedInterface => (\n <div key={implementedInterface.name}>\n <TypeLink type={implementedInterface} />\n </div>\n ))}\n </ExplorerSection>\n ) : null;\n};\n\nconst Fields: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return null;\n }\n\n const fieldMap = type.getFields();\n\n const fields: DocExplorerFieldDef[] = [];\n const deprecatedFields: DocExplorerFieldDef[] = [];\n\n for (const field of Object.keys(fieldMap).map(name => fieldMap[name])) {\n if (field.deprecationReason) {\n deprecatedFields.push(field);\n } else {\n fields.push(field);\n }\n }\n\n return (\n <>\n {fields.length > 0 ? (\n <ExplorerSection title=\"Fields\">\n {fields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedFields.length > 0 ? (\n showDeprecated || fields.length === 0 ? (\n <ExplorerSection title=\"Deprecated Fields\">\n {deprecatedFields.map(field => (\n <Field key={field.name} field={field} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Fields\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst Field: FC<{ field: DocExplorerFieldDef }> = ({ field }) => {\n const args =\n 'args' in field ? field.args.filter(arg => !arg.deprecationReason) : [];\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div>\n <FieldLink field={field} />\n {args.length > 0 ? (\n <>\n (\n <span>\n {args.map(arg =>\n args.length === 1 ? (\n <Argument key={arg.name} arg={arg} inline />\n ) : (\n <div\n key={arg.name}\n className=\"graphiql-doc-explorer-argument-multiple\"\n >\n <Argument arg={arg} inline />\n </div>\n ),\n )}\n </span>\n )\n </>\n ) : null}\n {': '}\n <TypeLink type={field.type} />\n <DefaultValue field={field} />\n </div>\n {field.description ? (\n <MarkdownContent type=\"description\" onlyShowFirstChild>\n {field.description}\n </MarkdownContent>\n ) : null}\n <DeprecationReason>{field.deprecationReason}</DeprecationReason>\n </div>\n );\n};\n\nconst EnumValues: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const [showDeprecated, setShowDeprecated] = useState(false);\n const handleShowDeprecated = () => {\n setShowDeprecated(true);\n };\n\n if (!isEnumType(type)) {\n return null;\n }\n\n const values: GraphQLEnumValue[] = [];\n const deprecatedValues: GraphQLEnumValue[] = [];\n for (const value of type.getValues()) {\n if (value.deprecationReason) {\n deprecatedValues.push(value);\n } else {\n values.push(value);\n }\n }\n\n return (\n <>\n {values.length > 0 ? (\n <ExplorerSection title=\"Enum Values\">\n {values.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : null}\n {deprecatedValues.length > 0 ? (\n showDeprecated || values.length === 0 ? (\n <ExplorerSection title=\"Deprecated Enum Values\">\n {deprecatedValues.map(value => (\n <EnumValue key={value.name} value={value} />\n ))}\n </ExplorerSection>\n ) : (\n <Button type=\"button\" onClick={handleShowDeprecated}>\n Show Deprecated Values\n </Button>\n )\n ) : null}\n </>\n );\n};\n\nconst EnumValue: FC<{ value: GraphQLEnumValue }> = ({ value }) => {\n return (\n <div className=\"graphiql-doc-explorer-item\">\n <div className=\"graphiql-doc-explorer-enum-value\">{value.name}</div>\n {value.description ? (\n <MarkdownContent type=\"description\">\n {value.description}\n </MarkdownContent>\n ) : null}\n {value.deprecationReason ? (\n <MarkdownContent type=\"deprecation\">\n {value.deprecationReason}\n </MarkdownContent>\n ) : null}\n </div>\n );\n};\n\nconst PossibleTypes: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const { schema } = useSchemaContext({ nonNull: true });\n if (!schema || !isAbstractType(type)) {\n return null;\n }\n return (\n <ExplorerSection\n title={isInterfaceType(type) ? 'Implementations' : 'Possible Types'}\n >\n {schema.getPossibleTypes(type).map(possibleType => (\n <div key={possibleType.name}>\n <TypeLink type={possibleType} />\n </div>\n ))}\n </ExplorerSection>\n );\n};\n"],"names":["TypeDocumentation","t0","$","_c","type","t1","isNamedType","description","ImplementsInterfaces","isObjectType","getInterfaces","interfaces","t2","length","map","_temp","Fields","showDeprecated","setShowDeprecated","useState","Symbol","for","handleShowDeprecated","isInterfaceType","isInputObjectType","deprecatedFields","fields","fieldMap","getFields","field","Object","keys","name","deprecationReason","push","_temp2","t3","_temp3","t4","Field","args","filter","_temp4","arg_0","arg","t5","t6","t7","t8","t9","EnumValues","isEnumType","deprecatedValues","values","value","getValues","_temp5","_temp6","EnumValue","PossibleTypes","nonNull","schema","useSchemaContext","isAbstractType","getPossibleTypes","_temp7","implementedInterface","field_0","field_1","value_0","value_1","possibleType"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,oBAAgDC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAAQI,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAC7DE,SAAAA,YAAYF,IAAI,IAElBA,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA,KAAIG,cACF,oBAAA,iBAAA,EAAqB,MAAA,eAAeH,UAAAA,KAAIG,aAAa,IACjD;AAAA,MACP,oBAAC,wBAA2BH,MAAI;AAAA,MAChC,oBAAC,UAAaA,MAAI;AAAA,MAClB,oBAAC,cAAiBA,MAAI;AAAA,MACtB,oBAAC,iBAAoBA,KAAI,CAAA;AAAA,IAAA,EAAA,CAAI,IAEzB;AAAAF,WAAAE;AAAAF,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAVDG,SAAAA;AAUC;AAGV,MAAMG,uBAAuDP,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AACvDQ,MAAAA,CAAAA,aAAaL,IAAI,GAAC;AAAA,WAAA;AAAA,EAAA;AAAAC,MAAAA;AAAAH,MAAAA,SAAAE,MAAA;AAGJC,SAAAD,KAAIM,cAAe;AAACR,WAAAE;AAAAF,WAAAG;AAAAA,EAAAA,OAAA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2
- import { FC, ReactNode } from 'react';
2
+ import { FC, ReactNode, RefObject } from 'react';
3
3
  import { SchemaContextType } from '@graphiql/react';
4
+ import { StoreApi } from 'zustand';
4
5
  export declare type DocExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
5
6
  export declare type DocExplorerNavStackItem = {
6
7
  /**
@@ -45,7 +46,8 @@ export declare type DocExplorerContextType = {
45
46
  rebuildNavStackWithSchema(schema: GraphQLSchema): void;
46
47
  };
47
48
  };
48
- export declare const docExplorerStore: import('zustand').StoreApi<DocExplorerContextType>;
49
+ export declare function createDocExplorerStore(initialNavStackItem?: DocExplorerNavStackItem): StoreApi<DocExplorerContextType>;
50
+ export declare const DocExplorerContext: import('react').Context<RefObject<StoreApi<DocExplorerContextType>> | null>;
49
51
  export declare const DocExplorerContextProvider: FC<{
50
52
  children: ReactNode;
51
53
  }>;
package/dist/context.js CHANGED
@@ -1,184 +1,205 @@
1
+ import { jsx } from "react/jsx-runtime";
1
2
  import { c } from "react-compiler-runtime";
2
3
  import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
3
- import { useEffect } from "react";
4
- import { useSchemaStore } from "@graphiql/react";
5
- import { useStore, createStore } from "zustand";
6
- const INITIAL_NAV_STACK = [{
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 docExplorerStore = createStore((set, get) => ({
10
- explorerNavStack: INITIAL_NAV_STACK,
11
- actions: {
12
- push(item) {
13
- set((state) => {
14
- const curr = state.explorerNavStack;
15
- const lastItem = curr.at(-1);
16
- const explorerNavStack = (
17
- // Avoid pushing duplicate items
18
- lastItem.def === item.def ? curr : [...curr, item]
19
- );
20
- return {
21
- explorerNavStack
22
- };
23
- });
24
- },
25
- pop() {
26
- set((state) => {
27
- const curr = state.explorerNavStack;
28
- const explorerNavStack = curr.length > 1 ? curr.slice(0, -1) : curr;
29
- return {
30
- explorerNavStack
31
- };
32
- });
33
- },
34
- reset() {
35
- set((state) => {
36
- const curr = state.explorerNavStack;
37
- const explorerNavStack = curr.length === 1 ? curr : INITIAL_NAV_STACK;
38
- return {
39
- explorerNavStack
40
- };
41
- });
42
- },
43
- resolveSchemaReferenceToNavItem(schemaReference) {
44
- if (!schemaReference) {
45
- return;
46
- }
47
- const {
48
- push
49
- } = get().actions;
50
- switch (schemaReference.kind) {
51
- case "Type": {
52
- push({
53
- name: schemaReference.type.name,
54
- def: schemaReference.type
55
- });
56
- break;
57
- }
58
- case "Field": {
59
- push({
60
- name: schemaReference.field.name,
61
- def: schemaReference.field
62
- });
63
- break;
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;
64
47
  }
65
- case "Argument": {
66
- if (schemaReference.field) {
48
+ const {
49
+ push
50
+ } = get().actions;
51
+ switch (schemaReference.kind) {
52
+ case "Type": {
67
53
  push({
68
- name: schemaReference.field.name,
69
- def: schemaReference.field
54
+ name: schemaReference.type.name,
55
+ def: schemaReference.type
70
56
  });
57
+ break;
71
58
  }
72
- break;
73
- }
74
- case "EnumValue": {
75
- if (schemaReference.type) {
59
+ case "Field": {
76
60
  push({
77
- name: schemaReference.type.name,
78
- def: schemaReference.type
61
+ name: schemaReference.field.name,
62
+ def: schemaReference.field
79
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;
80
83
  }
81
- break;
82
- }
83
- }
84
- },
85
- rebuildNavStackWithSchema(schema) {
86
- set((state) => {
87
- const oldNavStack = state.explorerNavStack;
88
- if (oldNavStack.length === 1) {
89
- return oldNavStack;
90
84
  }
91
- const newNavStack = [...INITIAL_NAV_STACK];
92
- let lastEntity = null;
93
- for (const item of oldNavStack) {
94
- if (item === INITIAL_NAV_STACK[0]) {
95
- continue;
85
+ },
86
+ rebuildNavStackWithSchema(schema) {
87
+ set((state) => {
88
+ const oldNavStack = state.explorerNavStack;
89
+ if (oldNavStack.length === 1) {
90
+ return oldNavStack;
96
91
  }
97
- if (item.def) {
98
- if (isNamedType(item.def)) {
99
- const newType = schema.getType(item.def.name);
100
- if (newType) {
101
- newNavStack.push({
102
- name: item.name,
103
- def: newType
104
- });
105
- lastEntity = newType;
106
- } else {
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) {
107
111
  break;
108
- }
109
- } else if (lastEntity === null) {
110
- break;
111
- } else if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
112
- const field = lastEntity.getFields()[item.name];
113
- if (field) {
114
- newNavStack.push({
115
- name: item.name,
116
- def: field
117
- });
118
- } else {
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)) {
119
123
  break;
120
- }
121
- } else if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
122
- break;
123
- } else {
124
- const field = lastEntity;
125
- if (field.args.some((a) => a.name === item.name)) {
126
- newNavStack.push({
127
- name: item.name,
128
- def: field
129
- });
130
124
  } else {
131
- break;
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
+ }
132
134
  }
135
+ } else {
136
+ lastEntity = null;
137
+ newNavStack.push(item);
133
138
  }
134
- } else {
135
- lastEntity = null;
136
- newNavStack.push(item);
137
139
  }
138
- }
139
- return {
140
- explorerNavStack: newNavStack
141
- };
142
- });
140
+ return {
141
+ explorerNavStack: newNavStack
142
+ };
143
+ });
144
+ }
143
145
  }
146
+ }));
147
+ }
148
+ const DocExplorerContext = createContext(null);
149
+ const DocExplorerContextProvider = (props) => {
150
+ const $ = c(11);
151
+ let t0;
152
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
153
+ t0 = {
154
+ nonNull: true,
155
+ caller: DocExplorerContextProvider
156
+ };
157
+ $[0] = t0;
158
+ } else {
159
+ t0 = $[0];
144
160
  }
145
- }));
146
- const DocExplorerContextProvider = (t0) => {
147
- const $ = c(7);
148
- const {
149
- children
150
- } = t0;
151
161
  const {
152
162
  schema,
153
163
  validationErrors,
154
164
  schemaReference
155
- } = useSchemaStore();
165
+ } = useSchemaContext(t0);
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;
176
+ }
156
177
  let t1;
157
178
  let t2;
158
- if ($[0] !== schemaReference) {
179
+ if ($[2] !== schemaReference) {
159
180
  t1 = () => {
160
181
  const {
161
182
  resolveSchemaReferenceToNavItem
162
- } = docExplorerStore.getState().actions;
183
+ } = storeRef.current.getState().actions;
163
184
  resolveSchemaReferenceToNavItem(schemaReference);
164
185
  };
165
186
  t2 = [schemaReference];
166
- $[0] = schemaReference;
167
- $[1] = t1;
168
- $[2] = t2;
187
+ $[2] = schemaReference;
188
+ $[3] = t1;
189
+ $[4] = t2;
169
190
  } else {
170
- t1 = $[1];
171
- t2 = $[2];
191
+ t1 = $[3];
192
+ t2 = $[4];
172
193
  }
173
194
  useEffect(t1, t2);
174
195
  let t3;
175
196
  let t4;
176
- if ($[3] !== schema || $[4] !== validationErrors) {
197
+ if ($[5] !== schema || $[6] !== validationErrors) {
177
198
  t3 = () => {
178
199
  const {
179
200
  reset,
180
201
  rebuildNavStackWithSchema
181
- } = docExplorerStore.getState().actions;
202
+ } = storeRef.current.getState().actions;
182
203
  if (schema == null || validationErrors.length > 0) {
183
204
  reset();
184
205
  } else {
@@ -186,19 +207,31 @@ const DocExplorerContextProvider = (t0) => {
186
207
  }
187
208
  };
188
209
  t4 = [schema, validationErrors];
189
- $[3] = schema;
190
- $[4] = validationErrors;
191
- $[5] = t3;
192
- $[6] = t4;
210
+ $[5] = schema;
211
+ $[6] = validationErrors;
212
+ $[7] = t3;
213
+ $[8] = t4;
193
214
  } else {
194
- t3 = $[5];
195
- t4 = $[6];
215
+ t3 = $[7];
216
+ t4 = $[8];
196
217
  }
197
218
  useEffect(t3, t4);
198
- return children;
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;
224
+ } else {
225
+ t5 = $[10];
226
+ }
227
+ return t5;
199
228
  };
200
229
  function useDocExplorerStore(selector) {
201
- return useStore(docExplorerStore, selector);
230
+ const store = useContext(DocExplorerContext);
231
+ if (!store) {
232
+ throw new Error("Missing `DocExplorerContextProvider` in the tree");
233
+ }
234
+ return useStore(store.current, selector);
202
235
  }
203
236
  const useDocExplorer = () => {
204
237
  return useDocExplorerStore(_temp);
@@ -213,8 +246,9 @@ function _temp2(state) {
213
246
  return state.actions;
214
247
  }
215
248
  export {
249
+ DocExplorerContext,
216
250
  DocExplorerContextProvider,
217
- docExplorerStore,
251
+ createDocExplorerStore,
218
252
  useDocExplorer,
219
253
  useDocExplorerActions
220
254
  };