@graphiql/plugin-doc-explorer 0.0.2 → 0.0.3-canary-5d447953.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.
@@ -1,53 +1,43 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { useExplorerContext } from "../context.js";
3
+ import { useDocExplorerActions } from "../context.js";
4
4
  import { renderType } from "./utils.js";
5
5
  /* empty css */
6
6
  const TypeLink = (t0) => {
7
- const $ = c(6);
7
+ const $ = c(5);
8
8
  const {
9
9
  type
10
10
  } = t0;
11
- let t1;
12
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
13
- t1 = {
14
- nonNull: true,
15
- caller: TypeLink
16
- };
17
- $[0] = t1;
18
- } else {
19
- t1 = $[0];
20
- }
21
11
  const {
22
12
  push
23
- } = useExplorerContext(t1);
13
+ } = useDocExplorerActions();
24
14
  if (!type) {
25
15
  return null;
26
16
  }
27
- let t2;
28
- if ($[1] !== push) {
29
- t2 = (namedType) => /* @__PURE__ */ jsx("a", { className: "graphiql-doc-explorer-type-name", onClick: (event) => {
17
+ let t1;
18
+ if ($[0] !== push) {
19
+ t1 = (namedType) => /* @__PURE__ */ jsx("a", { className: "graphiql-doc-explorer-type-name", onClick: (event) => {
30
20
  event.preventDefault();
31
21
  push({
32
22
  name: namedType.name,
33
23
  def: namedType
34
24
  });
35
25
  }, href: "#", children: namedType.name });
36
- $[1] = push;
37
- $[2] = t2;
26
+ $[0] = push;
27
+ $[1] = t1;
38
28
  } else {
39
- t2 = $[2];
29
+ t1 = $[1];
40
30
  }
41
- let t3;
42
- if ($[3] !== t2 || $[4] !== type) {
43
- t3 = renderType(type, t2);
44
- $[3] = t2;
45
- $[4] = type;
46
- $[5] = t3;
31
+ let t2;
32
+ if ($[2] !== t1 || $[3] !== type) {
33
+ t2 = renderType(type, t1);
34
+ $[2] = t1;
35
+ $[3] = type;
36
+ $[4] = t2;
47
37
  } else {
48
- t3 = $[5];
38
+ t2 = $[4];
49
39
  }
50
- return t3;
40
+ return t2;
51
41
  };
52
42
  export {
53
43
  TypeLink
@@ -1 +1 @@
1
- {"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport { useExplorerContext } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useExplorerContext({ nonNull: true, caller: TypeLink });\n\n if (!type) {\n return null;\n }\n\n return renderType(type, namedType => (\n <a\n className=\"graphiql-doc-explorer-type-name\"\n onClick={event => {\n event.preventDefault();\n push({ name: namedType.name, def: namedType });\n }}\n href=\"#\"\n >\n {namedType.name}\n </a>\n ));\n};\n"],"names":["TypeLink","t0","$","_c","type","t1","Symbol","for","nonNull","caller","push","useExplorerContext","t2","namedType","event","preventDefault","name","def","t3","renderType"],"mappings":";;;;;AAaO,MAAMA,WAA8BC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAAQI,MAAAA;AAAA,MAAAH,EAAA,CAAA,MAAAI,OAAAC,IAAA,2BAAA,GAAA;AACd,SAAA;AAAA,MAAAC,SAAA;AAAA,MAAAC,QAAAT;AAAAA,IAAA;AAAmCE,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAAvE,QAAA;AAAA,IAAAQ;AAAAA,EAAAA,IAAiBC,mBAAmBN,EAAmC;AAAE,MAAA,CAEpED,MAAI;AAAA,WAAA;AAAA,EAAA;AAAAQ,MAAAA;AAAAV,MAAAA,SAAAQ,MAAA;AAIeE,SAAAC,eACtB,oBAAA,KAAA,EACY,WAAA,mCACD,SAAAC,CAAA,UAAA;AACPA,YAAKC,eAAgB;AACjB,WAAA;AAAA,QAAAC,MAASH,UAASG;AAAAA,QAAAC,KAAYJ;AAAAA,MAAAA,CAAW;AAAA,IAE1C,GAAA,MAAA,KAEJA,UAAAA,UAASG,KACZ,CAAA;AACDd,WAAAQ;AAAAR,WAAAU;AAAAA,EAAAA,OAAA;AAAAA,SAAAV,EAAA,CAAA;AAAA,EAAA;AAAAgB,MAAAA;AAAA,MAAAhB,EAAAU,CAAAA,MAAAA,MAAAV,SAAAE,MAAA;AAXMe,SAAAA,WAAWf,MAAMQ,EAWvB;AAACV,WAAAU;AAAAV,WAAAE;AAAAF,WAAAgB;AAAAA,EAAAA,OAAA;AAAAA,SAAAhB,EAAA,CAAA;AAAA,EAAA;AAXKgB,SAAAA;AAWL;"}
1
+ {"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport { useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n\n if (!type) {\n return null;\n }\n\n return renderType(type, namedType => (\n <a\n className=\"graphiql-doc-explorer-type-name\"\n onClick={event => {\n event.preventDefault();\n push({ name: namedType.name, def: namedType });\n }}\n href=\"#\"\n >\n {namedType.name}\n </a>\n ));\n};\n"],"names":["TypeLink","t0","$","_c","type","push","useDocExplorerActions","t1","namedType","event","preventDefault","name","def","t2","renderType"],"mappings":";;;;;AAaO,MAAMA,WAA8BC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAC1C,QAAA;AAAA,IAAAI;AAAAA,MAAiBC,sBAAsB;AAAE,MAAA,CAEpCF,MAAI;AAAA,WAAA;AAAA,EAAA;AAAAG,MAAAA;AAAAL,MAAAA,SAAAG,MAAA;AAIeE,SAAAC,eACtB,oBAAA,KAAA,EACY,WAAA,mCACD,SAAAC,CAAA,UAAA;AACPA,YAAKC,eAAgB;AACjB,WAAA;AAAA,QAAAC,MAASH,UAASG;AAAAA,QAAAC,KAAYJ;AAAAA,MAAAA,CAAW;AAAA,IAE1C,GAAA,MAAA,KAEJA,UAAAA,UAASG,KACZ,CAAA;AACDT,WAAAG;AAAAH,WAAAK;AAAAA,EAAAA,OAAA;AAAAA,SAAAL,EAAA,CAAA;AAAA,EAAA;AAAAW,MAAAA;AAAA,MAAAX,EAAAK,CAAAA,MAAAA,MAAAL,SAAAE,MAAA;AAXMU,SAAAA,WAAWV,MAAMG,EAWvB;AAACL,WAAAK;AAAAL,WAAAE;AAAAF,WAAAW;AAAAA,EAAAA,OAAA;AAAAA,SAAAX,EAAA,CAAA;AAAA,EAAA;AAXKW,SAAAA;AAWL;"}
package/dist/context.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType } from 'graphql';
2
- import { FC, ReactNode } from 'react';
3
- export declare type ExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
4
- export declare type ExplorerNavStackItem = {
1
+ import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType, GraphQLSchema } from 'graphql';
2
+ import { FC, ReactNode, RefObject } from 'react';
3
+ import { SchemaContextType } from '@graphiql/react';
4
+ import { StoreApi } from 'zustand';
5
+ export declare type DocExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
6
+ export declare type DocExplorerNavStackItem = {
5
7
  /**
6
8
  * The name of the item.
7
9
  */
@@ -10,23 +12,52 @@ export declare type ExplorerNavStackItem = {
10
12
  * The definition object of the item, this can be a named type, a field, an
11
13
  * input field or an argument.
12
14
  */
13
- def?: GraphQLNamedType | ExplorerFieldDef;
15
+ def?: GraphQLNamedType | DocExplorerFieldDef;
14
16
  };
15
- export declare type ExplorerNavStack = [
16
- ExplorerNavStackItem,
17
- ...ExplorerNavStackItem[]
17
+ export declare type DocExplorerNavStack = [
18
+ DocExplorerNavStackItem,
19
+ ...DocExplorerNavStackItem[]
18
20
  ];
19
- export declare type ExplorerContextType = {
21
+ export declare type DocExplorerContextType = {
20
22
  /**
21
23
  * A stack of navigation items. The last item in the list is the current one.
22
24
  * This list always contains at least one item.
23
25
  */
24
- explorerNavStack: ExplorerNavStack;
26
+ explorerNavStack: DocExplorerNavStack;
27
+ actions: {
28
+ /**
29
+ * Push an item to the navigation stack.
30
+ * @param item The item that should be pushed to the stack.
31
+ */
32
+ push(item: DocExplorerNavStackItem): void;
33
+ /**
34
+ * Pop the last item from the navigation stack.
35
+ */
36
+ pop(): void;
37
+ /**
38
+ * Reset the navigation stack to its initial state, this will remove all but
39
+ * the initial stack item.
40
+ */
41
+ reset(): void;
42
+ resolveSchemaReferenceToNavItem(schemaReference: SchemaContextType['schemaReference']): void;
43
+ /**
44
+ * Replace the nav stack with an updated version using the new schema.
45
+ */
46
+ rebuildNavStackWithSchema(schema: GraphQLSchema): void;
47
+ };
48
+ };
49
+ export declare function createDocExplorerStore(initialNavStackItem?: DocExplorerNavStackItem): StoreApi<DocExplorerContextType>;
50
+ export declare const DocExplorerContext: import('react').Context<RefObject<StoreApi<DocExplorerContextType>> | null>;
51
+ export declare const DocExplorerContextProvider: FC<{
52
+ children: ReactNode;
53
+ }>;
54
+ export declare const useDocExplorer: () => DocExplorerNavStack;
55
+ export declare const useDocExplorerActions: () => {
25
56
  /**
26
57
  * Push an item to the navigation stack.
27
58
  * @param item The item that should be pushed to the stack.
28
59
  */
29
- push(item: ExplorerNavStackItem): void;
60
+ push(item: DocExplorerNavStackItem): void;
30
61
  /**
31
62
  * Pop the last item from the navigation stack.
32
63
  */
@@ -36,19 +67,9 @@ export declare type ExplorerContextType = {
36
67
  * the initial stack item.
37
68
  */
38
69
  reset(): void;
39
- };
40
- export declare const ExplorerContext: import('react').Context<ExplorerContextType | null>;
41
- export declare const ExplorerContextProvider: FC<{
42
- children: ReactNode;
43
- }>;
44
- export declare const useExplorerContext: {
45
- (options: {
46
- nonNull: true;
47
- caller?: Function | undefined;
48
- }): ExplorerContextType;
49
- (options: {
50
- nonNull?: boolean | undefined;
51
- caller?: Function | undefined;
52
- }): ExplorerContextType | null;
53
- (): ExplorerContextType | null;
70
+ resolveSchemaReferenceToNavItem(schemaReference: SchemaContextType['schemaReference']): void;
71
+ /**
72
+ * Replace the nav stack with an updated version using the new schema.
73
+ */
74
+ rebuildNavStackWithSchema(schema: GraphQLSchema): void;
54
75
  };
package/dist/context.js CHANGED
@@ -1,234 +1,245 @@
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 { useSchemaStore } from "@graphiql/react";
6
+ import { createStore, useStore } from "zustand";
7
+ function createDocExplorerStore(initialNavStackItem = {
7
8
  name: "Docs"
8
- };
9
- const ExplorerContext = createNullableContext("ExplorerContext");
10
- const ExplorerContextProvider = (props) => {
11
- const $ = c(17);
12
- let t0;
13
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
14
- t0 = {
15
- nonNull: true,
16
- caller: ExplorerContextProvider
17
- };
18
- $[0] = t0;
19
- } else {
20
- t0 = $[0];
21
- }
22
- const {
23
- schema,
24
- validationErrors,
25
- schemaReference
26
- } = useSchemaContext(t0);
27
- let t1;
28
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
29
- t1 = [initialNavStackItem];
30
- $[1] = t1;
31
- } else {
32
- t1 = $[1];
33
- }
34
- const [navStack, setNavStack] = useState(t1);
35
- let t2;
36
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
- t2 = (item) => {
38
- setNavStack((currentState) => {
39
- const lastItem = currentState.at(-1);
40
- return lastItem.def === item.def ? currentState : [...currentState, item];
41
- });
42
- };
43
- $[2] = t2;
44
- } else {
45
- t2 = $[2];
46
- }
47
- const push = t2;
48
- let t3;
49
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
50
- t3 = () => {
51
- setNavStack(_temp);
52
- };
53
- $[3] = t3;
54
- } else {
55
- t3 = $[3];
56
- }
57
- const pop = t3;
58
- let t4;
59
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
60
- t4 = () => {
61
- setNavStack(_temp2);
62
- };
63
- $[4] = t4;
64
- } else {
65
- t4 = $[4];
66
- }
67
- const reset = t4;
68
- let t5;
69
- let t6;
70
- if ($[5] !== schemaReference) {
71
- t5 = () => {
72
- if (!schemaReference) {
73
- return;
74
- }
75
- bb26: switch (schemaReference.kind) {
76
- case "Type": {
77
- push({
78
- name: schemaReference.type.name,
79
- def: schemaReference.type
80
- });
81
- break bb26;
82
- }
83
- case "Field": {
84
- push({
85
- name: schemaReference.field.name,
86
- def: schemaReference.field
87
- });
88
- break bb26;
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;
89
47
  }
90
- case "Argument": {
91
- if (schemaReference.field) {
48
+ const {
49
+ push
50
+ } = get().actions;
51
+ switch (schemaReference.kind) {
52
+ case "Type": {
92
53
  push({
93
- name: schemaReference.field.name,
94
- def: schemaReference.field
54
+ name: schemaReference.type.name,
55
+ def: schemaReference.type
95
56
  });
57
+ break;
96
58
  }
97
- break bb26;
98
- }
99
- case "EnumValue": {
100
- if (schemaReference.type) {
59
+ case "Field": {
101
60
  push({
102
- name: schemaReference.type.name,
103
- def: schemaReference.type
61
+ name: schemaReference.field.name,
62
+ def: schemaReference.field
104
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;
105
83
  }
106
84
  }
107
- }
108
- };
109
- t6 = [schemaReference, push];
110
- $[5] = schemaReference;
111
- $[6] = t5;
112
- $[7] = t6;
113
- } else {
114
- t5 = $[6];
115
- t6 = $[7];
116
- }
117
- useEffect(t5, t6);
118
- let t7;
119
- let t8;
120
- if ($[8] !== schema || $[9] !== validationErrors) {
121
- t7 = () => {
122
- if (schema == null || validationErrors.length > 0) {
123
- reset();
124
- } else {
125
- setNavStack((oldNavStack) => {
85
+ },
86
+ rebuildNavStackWithSchema(schema) {
87
+ set((state) => {
88
+ const oldNavStack = state.explorerNavStack;
126
89
  if (oldNavStack.length === 1) {
127
90
  return oldNavStack;
128
91
  }
129
92
  const newNavStack = [initialNavStackItem];
130
93
  let lastEntity = null;
131
- for (const item_0 of oldNavStack) {
132
- if (item_0 === initialNavStackItem) {
94
+ for (const item of oldNavStack) {
95
+ if (item === initialNavStackItem) {
133
96
  continue;
134
97
  }
135
- if (item_0.def) {
136
- if (isNamedType(item_0.def)) {
137
- const newType = schema.getType(item_0.def.name);
98
+ if (item.def) {
99
+ if (isNamedType(item.def)) {
100
+ const newType = schema.getType(item.def.name);
138
101
  if (newType) {
139
102
  newNavStack.push({
140
- name: item_0.name,
103
+ name: item.name,
141
104
  def: newType
142
105
  });
143
106
  lastEntity = newType;
144
107
  } else {
145
108
  break;
146
109
  }
147
- } else {
148
- if (lastEntity === null) {
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 {
149
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
+ });
150
131
  } else {
151
- if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
152
- const field = lastEntity.getFields()[item_0.name];
153
- if (field) {
154
- newNavStack.push({
155
- name: item_0.name,
156
- def: field
157
- });
158
- } else {
159
- break;
160
- }
161
- } else {
162
- if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
163
- break;
164
- } else {
165
- const field_0 = lastEntity;
166
- if (field_0.args.some((a) => a.name === item_0.name)) {
167
- newNavStack.push({
168
- name: item_0.name,
169
- def: field_0
170
- });
171
- } else {
172
- break;
173
- }
174
- }
175
- }
132
+ break;
176
133
  }
177
134
  }
178
135
  } else {
179
136
  lastEntity = null;
180
- newNavStack.push(item_0);
137
+ newNavStack.push(item);
181
138
  }
182
139
  }
183
- return newNavStack;
140
+ return {
141
+ explorerNavStack: newNavStack
142
+ };
184
143
  });
185
144
  }
145
+ }
146
+ }));
147
+ }
148
+ const DocExplorerContext = createContext(null);
149
+ const DocExplorerContextProvider = (props) => {
150
+ const $ = c(10);
151
+ const {
152
+ schema,
153
+ validationErrors,
154
+ schemaReference
155
+ } = useSchemaStore();
156
+ const storeRef = useRef(null);
157
+ if (storeRef.current === null) {
158
+ let t02;
159
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
160
+ t02 = createDocExplorerStore();
161
+ $[0] = t02;
162
+ } else {
163
+ t02 = $[0];
164
+ }
165
+ storeRef.current = t02;
166
+ }
167
+ let t0;
168
+ let t1;
169
+ if ($[1] !== schemaReference) {
170
+ t0 = () => {
171
+ const {
172
+ resolveSchemaReferenceToNavItem
173
+ } = storeRef.current.getState().actions;
174
+ resolveSchemaReferenceToNavItem(schemaReference);
186
175
  };
187
- t8 = [schema, validationErrors];
188
- $[8] = schema;
189
- $[9] = validationErrors;
190
- $[10] = t7;
191
- $[11] = t8;
176
+ t1 = [schemaReference];
177
+ $[1] = schemaReference;
178
+ $[2] = t0;
179
+ $[3] = t1;
192
180
  } else {
193
- t7 = $[10];
194
- t8 = $[11];
181
+ t0 = $[2];
182
+ t1 = $[3];
195
183
  }
196
- useEffect(t7, t8);
197
- let t9;
198
- if ($[12] !== navStack) {
199
- t9 = {
200
- explorerNavStack: navStack,
201
- push,
202
- pop,
203
- reset
184
+ useEffect(t0, t1);
185
+ let t2;
186
+ let t3;
187
+ if ($[4] !== schema || $[5] !== validationErrors) {
188
+ t2 = () => {
189
+ const {
190
+ reset,
191
+ rebuildNavStackWithSchema
192
+ } = storeRef.current.getState().actions;
193
+ if (schema == null || validationErrors.length > 0) {
194
+ reset();
195
+ } else {
196
+ rebuildNavStackWithSchema(schema);
197
+ }
204
198
  };
205
- $[12] = navStack;
206
- $[13] = t9;
199
+ t3 = [schema, validationErrors];
200
+ $[4] = schema;
201
+ $[5] = validationErrors;
202
+ $[6] = t2;
203
+ $[7] = t3;
207
204
  } else {
208
- t9 = $[13];
205
+ t2 = $[6];
206
+ t3 = $[7];
209
207
  }
210
- const value = t9;
211
- let t10;
212
- if ($[14] !== props.children || $[15] !== value) {
213
- t10 = /* @__PURE__ */ jsx(ExplorerContext.Provider, { value, children: props.children });
214
- $[14] = props.children;
215
- $[15] = value;
216
- $[16] = t10;
208
+ useEffect(t2, t3);
209
+ let t4;
210
+ if ($[8] !== props.children) {
211
+ t4 = /* @__PURE__ */ jsx(DocExplorerContext.Provider, { value: storeRef, children: props.children });
212
+ $[8] = props.children;
213
+ $[9] = t4;
217
214
  } else {
218
- t10 = $[16];
215
+ t4 = $[9];
219
216
  }
220
- return t10;
217
+ return t4;
218
+ };
219
+ function useDocExplorerStore(selector) {
220
+ const store = useContext(DocExplorerContext);
221
+ if (!store) {
222
+ throw new Error("Missing `DocExplorerContextProvider` in the tree");
223
+ }
224
+ return useStore(store.current, selector);
225
+ }
226
+ const useDocExplorer = () => {
227
+ return useDocExplorerStore(_temp);
228
+ };
229
+ const useDocExplorerActions = () => {
230
+ return useDocExplorerStore(_temp2);
221
231
  };
222
- const useExplorerContext = createContextHook(ExplorerContext);
223
- function _temp(currentState_0) {
224
- return currentState_0.length > 1 ? currentState_0.slice(0, -1) : currentState_0;
232
+ function _temp(state) {
233
+ return state.explorerNavStack;
225
234
  }
226
- function _temp2(currentState_1) {
227
- return currentState_1.length === 1 ? currentState_1 : [initialNavStackItem];
235
+ function _temp2(state) {
236
+ return state.actions;
228
237
  }
229
238
  export {
230
- ExplorerContext,
231
- ExplorerContextProvider,
232
- useExplorerContext
239
+ DocExplorerContext,
240
+ DocExplorerContextProvider,
241
+ createDocExplorerStore,
242
+ useDocExplorer,
243
+ useDocExplorerActions
233
244
  };
234
245
  //# sourceMappingURL=context.js.map