polen 0.10.0-next.21 → 0.10.0-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/config/configurator.d.ts +62 -11
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +9 -0
- package/build/api/config/configurator.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +1 -0
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/project-data.d.ts +1 -0
- package/build/project-data.d.ts.map +1 -1
- package/build/sandbox.js +40 -17
- package/build/sandbox.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +3 -5
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/Field.js +1 -1
- package/build/template/components/Field.js.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts +31 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js +275 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js.map +1 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.d.ts +39 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.js +51 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.js.map +1 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.d.ts +33 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.js +242 -0
- package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.js.map +1 -0
- package/build/template/components/GraphQLInteractive/hooks/use-popover-state.d.ts +45 -0
- package/build/template/components/GraphQLInteractive/hooks/use-popover-state.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/hooks/use-popover-state.js +176 -0
- package/build/template/components/GraphQLInteractive/hooks/use-popover-state.js.map +1 -0
- package/build/template/components/GraphQLInteractive/index.d.ts +2 -0
- package/build/template/components/GraphQLInteractive/index.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/index.js +2 -0
- package/build/template/components/GraphQLInteractive/index.js.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/graphql-node-types.d.ts +52 -0
- package/build/template/components/GraphQLInteractive/lib/graphql-node-types.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/graphql-node-types.js +34 -0
- package/build/template/components/GraphQLInteractive/lib/graphql-node-types.js.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts +71 -0
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/parser.js +836 -0
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/semantic-nodes.d.ts +98 -0
- package/build/template/components/GraphQLInteractive/lib/semantic-nodes.d.ts.map +1 -0
- package/build/template/components/GraphQLInteractive/lib/semantic-nodes.js +31 -0
- package/build/template/components/GraphQLInteractive/lib/semantic-nodes.js.map +1 -0
- package/build/template/components/content/$$.d.ts +0 -1
- package/build/template/components/content/$$.d.ts.map +1 -1
- package/build/template/components/content/$$.js +0 -1
- package/build/template/components/content/$$.js.map +1 -1
- package/package.json +5 -21
- package/src/api/config/configurator.ts +72 -11
- package/src/api/vite/plugins/core.ts +1 -0
- package/src/lib/kit-temp.test.ts +9 -9
- package/src/project-data.ts +1 -0
- package/src/sandbox.ts +40 -17
- package/src/template/components/CodeBlock.tsx +6 -9
- package/src/template/components/Field.tsx +1 -1
- package/src/template/components/GraphQLInteractive/GraphQLInteractive.tsx +464 -0
- package/src/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.tsx +96 -0
- package/src/template/components/GraphQLInteractive/components/GraphQLTokenPopover.tsx +492 -0
- package/src/template/components/GraphQLInteractive/hooks/use-popover-state.ts +244 -0
- package/src/template/components/GraphQLInteractive/index.ts +1 -0
- package/src/template/components/GraphQLInteractive/lib/graphql-node-types.ts +217 -0
- package/src/template/components/GraphQLInteractive/lib/parser.ts +1075 -0
- package/src/template/components/GraphQLInteractive/lib/semantic-nodes.ts +154 -0
- package/src/template/components/GraphQLInteractive/tests/parser-comment.test.ts +33 -0
- package/src/template/components/GraphQLInteractive/tests/parser-error-hint.test.ts +102 -0
- package/src/template/components/GraphQLInteractive/tests/parser.test.ts +131 -0
- package/src/template/components/content/$$.ts +0 -1
- package/build/template/components/content/GraphQLDocumentWithSchema.d.ts +0 -8
- package/build/template/components/content/GraphQLDocumentWithSchema.d.ts.map +0 -1
- package/build/template/components/content/GraphQLDocumentWithSchema.js +0 -13
- package/build/template/components/content/GraphQLDocumentWithSchema.js.map +0 -1
- package/build/template/components/content/GraphQLDocumentWrapper.d.ts +0 -7
- package/build/template/components/content/GraphQLDocumentWrapper.d.ts.map +0 -1
- package/build/template/components/content/GraphQLDocumentWrapper.js +0 -48
- package/build/template/components/content/GraphQLDocumentWrapper.js.map +0 -1
- package/src/template/components/content/GraphQLDocumentWithSchema.tsx +0 -13
- package/src/template/components/content/GraphQLDocumentWrapper.tsx +0 -72
@@ -0,0 +1,275 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { React as ReactHooks } from '#dep/react/index';
|
3
|
+
import { Box } from '@radix-ui/themes';
|
4
|
+
import { GraphQLErrorBoundary } from './components/GraphQLErrorBoundary.js';
|
5
|
+
import { GraphQLTokenPopover } from './components/GraphQLTokenPopover.js';
|
6
|
+
import { usePopoverState } from './hooks/use-popover-state.js';
|
7
|
+
import { parseGraphQLWithTreeSitter } from './lib/parser.js';
|
8
|
+
/**
|
9
|
+
* Main component that renders an interactive GraphQL code block
|
10
|
+
*
|
11
|
+
* This component:
|
12
|
+
* 1. Parses the GraphQL code into tokens using tree-sitter
|
13
|
+
* 2. Renders each token with appropriate styling
|
14
|
+
* 3. Adds interactivity to certain token types (types and fields)
|
15
|
+
* 4. Shows loading/error states during parsing
|
16
|
+
*/
|
17
|
+
/**
|
18
|
+
* Internal GraphQL Interactive implementation
|
19
|
+
* Wrapped by error boundary in the main export
|
20
|
+
*/
|
21
|
+
const GraphQLInteractiveImpl = ({ codeblock, schema, showWarningIfNoSchema = true, }) => {
|
22
|
+
// State to hold the parsed tokens
|
23
|
+
const [tokens, setTokens] = ReactHooks.useState(null);
|
24
|
+
// Loading state while parser initializes and processes the code
|
25
|
+
const [isLoading, setIsLoading] = ReactHooks.useState(true);
|
26
|
+
// Error state if parsing fails
|
27
|
+
const [error, setError] = ReactHooks.useState(null);
|
28
|
+
// Retry attempt counter
|
29
|
+
const [retryCount, setRetryCount] = ReactHooks.useState(0);
|
30
|
+
// Popover state management - must be called at top level for hooks rules
|
31
|
+
const popoverState = usePopoverState({
|
32
|
+
showDelay: 300,
|
33
|
+
hideDelay: 100,
|
34
|
+
allowMultiplePins: true,
|
35
|
+
});
|
36
|
+
// Memoize token parsing to avoid re-computation on unrelated renders
|
37
|
+
const parseTokens = ReactHooks.useCallback(async () => {
|
38
|
+
try {
|
39
|
+
setIsLoading(true);
|
40
|
+
setError(null);
|
41
|
+
// Parse the code into tokens with semantic analysis
|
42
|
+
const parsedTokens = await parseGraphQLWithTreeSitter(codeblock.code, codeblock.annotations, schema);
|
43
|
+
setTokens(parsedTokens);
|
44
|
+
setRetryCount(0); // Reset retry count on success
|
45
|
+
}
|
46
|
+
catch (err) {
|
47
|
+
// Provide detailed error information to users
|
48
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown parsing error';
|
49
|
+
setError(errorMessage);
|
50
|
+
setTokens([]); // Set empty tokens on error for fallback rendering
|
51
|
+
}
|
52
|
+
finally {
|
53
|
+
setIsLoading(false);
|
54
|
+
}
|
55
|
+
}, [codeblock.code, codeblock.annotations, schema]);
|
56
|
+
// Retry function for users
|
57
|
+
const handleRetry = ReactHooks.useCallback(() => {
|
58
|
+
setRetryCount(prev => prev + 1);
|
59
|
+
parseTokens();
|
60
|
+
}, [parseTokens]);
|
61
|
+
// Parse the GraphQL code whenever dependencies change
|
62
|
+
ReactHooks.useEffect(() => {
|
63
|
+
parseTokens();
|
64
|
+
}, [parseTokens]);
|
65
|
+
// Render loading state
|
66
|
+
// Shows the code with reduced opacity and a loading indicator
|
67
|
+
if (isLoading) {
|
68
|
+
return (_jsxs("div", { className: 'graphql-loading', children: [_jsx("pre", { style: { opacity: 0.5 }, children: _jsx("code", { children: codeblock.code }) }), _jsx("div", { style: {
|
69
|
+
position: 'absolute',
|
70
|
+
top: '8px',
|
71
|
+
right: '8px',
|
72
|
+
fontSize: '12px',
|
73
|
+
color: '#666',
|
74
|
+
backgroundColor: '#f0f0f0',
|
75
|
+
padding: '2px 6px',
|
76
|
+
borderRadius: '3px',
|
77
|
+
}, children: "Loading tree-sitter..." })] }));
|
78
|
+
}
|
79
|
+
// Render error state with retry option
|
80
|
+
if (error) {
|
81
|
+
return (_jsxs(Box, { className: 'graphql-error', p: '4', style: {
|
82
|
+
borderRadius: 'var(--radius-2)',
|
83
|
+
backgroundColor: 'var(--gray-2)',
|
84
|
+
position: 'relative',
|
85
|
+
borderLeft: '3px solid var(--red-9)',
|
86
|
+
}, children: [_jsx("pre", { style: { margin: 0, whiteSpace: 'pre' }, children: _jsx("code", { children: codeblock.code }) }), _jsxs("div", { style: {
|
87
|
+
color: 'var(--red-11)',
|
88
|
+
fontSize: '12px',
|
89
|
+
marginTop: '8px',
|
90
|
+
padding: '8px',
|
91
|
+
backgroundColor: 'var(--red-a3)',
|
92
|
+
borderRadius: '3px',
|
93
|
+
display: 'flex',
|
94
|
+
justifyContent: 'space-between',
|
95
|
+
alignItems: 'center',
|
96
|
+
}, children: [_jsxs("span", { children: ["Interactive parsing failed: ", error] }), retryCount < 3 && (_jsxs("button", { onClick: handleRetry, style: {
|
97
|
+
backgroundColor: 'var(--red-9)',
|
98
|
+
color: 'white',
|
99
|
+
border: 'none',
|
100
|
+
padding: '4px 8px',
|
101
|
+
borderRadius: '3px',
|
102
|
+
fontSize: '11px',
|
103
|
+
cursor: 'pointer',
|
104
|
+
}, children: ["Retry (", retryCount + 1, "/3)"] }))] })] }));
|
105
|
+
}
|
106
|
+
// Fallback if no tokens were parsed or parsing failed
|
107
|
+
if (!tokens || tokens.length === 0) {
|
108
|
+
return (_jsxs(Box, { className: 'graphql-fallback', p: '4', style: {
|
109
|
+
borderRadius: 'var(--radius-2)',
|
110
|
+
backgroundColor: 'var(--gray-2)',
|
111
|
+
position: 'relative',
|
112
|
+
}, children: [_jsx("pre", { style: { margin: 0, whiteSpace: 'pre' }, children: _jsx("code", { children: codeblock.code }) }), error && (_jsx("div", { style: {
|
113
|
+
position: 'absolute',
|
114
|
+
top: '8px',
|
115
|
+
right: '8px',
|
116
|
+
fontSize: '12px',
|
117
|
+
color: 'var(--red-11)',
|
118
|
+
backgroundColor: 'var(--red-a3)',
|
119
|
+
padding: '2px 6px',
|
120
|
+
borderRadius: '3px',
|
121
|
+
maxWidth: '200px',
|
122
|
+
}, title: error, children: "Interactive features unavailable" }))] }));
|
123
|
+
}
|
124
|
+
// Main render: Show the parsed and interactive code
|
125
|
+
return (_jsxs(Box, { className: 'graphql-interactive', p: '4', position: 'relative', style: {
|
126
|
+
borderRadius: 'var(--radius-2)',
|
127
|
+
backgroundColor: 'var(--gray-2)',
|
128
|
+
overflowX: 'auto',
|
129
|
+
maxWidth: '100%',
|
130
|
+
}, children: [_jsx("pre", { style: { margin: 0, whiteSpace: 'pre' }, children: _jsx("code", { children: tokens.map((token, index) => {
|
131
|
+
const tokenId = `${token.start}-${token.end}-${index}`;
|
132
|
+
return (_jsx(TokenComponent, { token: token, tokenId: tokenId, popoverState: popoverState, schema: schema }, tokenId));
|
133
|
+
}) }) }), !schema && showWarningIfNoSchema && (_jsxs("div", { style: {
|
134
|
+
position: 'absolute',
|
135
|
+
top: '8px',
|
136
|
+
right: '8px',
|
137
|
+
fontSize: '12px',
|
138
|
+
color: 'var(--amber-11)',
|
139
|
+
backgroundColor: 'var(--amber-a3)',
|
140
|
+
padding: '2px 6px',
|
141
|
+
borderRadius: '3px',
|
142
|
+
display: 'flex',
|
143
|
+
alignItems: 'center',
|
144
|
+
gap: '4px',
|
145
|
+
}, title: 'Interactive features are not available because no GraphQL schema is configured', children: [_jsxs("svg", { width: '12', height: '12', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', children: [_jsx("path", { d: 'M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z' }), _jsx("line", { x1: '12', y1: '9', x2: '12', y2: '13' }), _jsx("line", { x1: '12', y1: '17', x2: '12.01', y2: '17' })] }), "No schema configured"] }))] }));
|
146
|
+
};
|
147
|
+
/**
|
148
|
+
* Component that renders a single token with interactive features
|
149
|
+
*
|
150
|
+
* This component handles:
|
151
|
+
* - Applying syntax highlighting based on token type
|
152
|
+
* - Hover effects for interactive tokens
|
153
|
+
* - Click handlers for navigation
|
154
|
+
* - Visual feedback for CodeHike annotations
|
155
|
+
*/
|
156
|
+
const TokenComponent = ({ token, tokenId, popoverState, schema }) => {
|
157
|
+
// Track hover state for interactive tokens
|
158
|
+
const [isHovered, setIsHovered] = ReactHooks.useState(false);
|
159
|
+
// Handle clicks on interactive tokens - memoized to prevent unnecessary re-renders
|
160
|
+
const handleClick = ReactHooks.useCallback((e) => {
|
161
|
+
if (token.polen.isInteractive()) {
|
162
|
+
e.preventDefault();
|
163
|
+
e.stopPropagation();
|
164
|
+
// Don't allow pinning for invalid fields
|
165
|
+
if (token.semantic && 'kind' in token.semantic && token.semantic.kind === 'InvalidField') {
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
// Toggle popover pin state only - no navigation
|
169
|
+
popoverState.onTogglePin(tokenId);
|
170
|
+
}
|
171
|
+
}, [token, tokenId, popoverState]);
|
172
|
+
// Show hover effects when mouse enters an interactive token - memoized
|
173
|
+
const handleMouseEnter = ReactHooks.useCallback(() => {
|
174
|
+
if (token.polen.isInteractive()) {
|
175
|
+
setIsHovered(true);
|
176
|
+
popoverState.onHoverStart(tokenId);
|
177
|
+
}
|
178
|
+
}, [token, tokenId, popoverState]);
|
179
|
+
// Hide hover effects when mouse leaves - memoized
|
180
|
+
const handleMouseLeave = ReactHooks.useCallback(() => {
|
181
|
+
setIsHovered(false);
|
182
|
+
popoverState.onHoverEnd(tokenId);
|
183
|
+
}, [tokenId, popoverState]);
|
184
|
+
// Get the appropriate CSS class from the token
|
185
|
+
const baseClass = token.highlighter.getCssClass();
|
186
|
+
// Map class names to inline styles
|
187
|
+
const getBaseStyle = () => {
|
188
|
+
switch (baseClass) {
|
189
|
+
case 'graphql-keyword':
|
190
|
+
return { color: 'var(--red-11)', fontWeight: 'bold' };
|
191
|
+
case 'graphql-type-interactive':
|
192
|
+
return { color: 'var(--blue-11)', fontWeight: 500 };
|
193
|
+
case 'graphql-field-interactive':
|
194
|
+
return { color: 'var(--violet-11)' };
|
195
|
+
case 'graphql-field-error':
|
196
|
+
return {
|
197
|
+
color: 'var(--red-11)',
|
198
|
+
};
|
199
|
+
case 'graphql-error-hint':
|
200
|
+
return {
|
201
|
+
color: 'var(--red-11)',
|
202
|
+
fontSize: '0.9em',
|
203
|
+
fontStyle: 'italic',
|
204
|
+
opacity: 0.5,
|
205
|
+
};
|
206
|
+
case 'graphql-comment':
|
207
|
+
return {
|
208
|
+
color: 'var(--gray-11)',
|
209
|
+
fontStyle: 'italic',
|
210
|
+
opacity: 0.6,
|
211
|
+
};
|
212
|
+
case 'graphql-operation':
|
213
|
+
return { color: 'var(--violet-11)', fontStyle: 'italic' };
|
214
|
+
case 'graphql-fragment':
|
215
|
+
return { color: 'var(--violet-11)', fontStyle: 'italic' };
|
216
|
+
case 'graphql-variable':
|
217
|
+
return { color: 'var(--orange-11)' };
|
218
|
+
case 'graphql-argument':
|
219
|
+
return { color: 'var(--gray-12)' };
|
220
|
+
case 'graphql-string':
|
221
|
+
return { color: 'var(--blue-11)' };
|
222
|
+
case 'graphql-number':
|
223
|
+
return { color: 'var(--blue-11)' };
|
224
|
+
case 'graphql-punctuation':
|
225
|
+
return { color: 'var(--gray-11)', opacity: 0.5 };
|
226
|
+
default:
|
227
|
+
return { color: 'var(--gray-12)' };
|
228
|
+
}
|
229
|
+
};
|
230
|
+
// Check if this is an invalid field
|
231
|
+
const isInvalidField = token.semantic && 'kind' in token.semantic && token.semantic.kind === 'InvalidField';
|
232
|
+
// Build the style object for this token
|
233
|
+
const style = {
|
234
|
+
...getBaseStyle(),
|
235
|
+
// Interactive tokens get special styling (except invalid fields)
|
236
|
+
...(token.polen.isInteractive() && !isInvalidField && {
|
237
|
+
cursor: 'pointer',
|
238
|
+
textDecoration: isHovered ? 'underline' : 'none',
|
239
|
+
backgroundColor: isHovered ? 'var(--accent-a3)' : 'transparent',
|
240
|
+
}),
|
241
|
+
// Invalid fields get different hover styling - no cursor change, no underline
|
242
|
+
...(isInvalidField && {
|
243
|
+
cursor: 'default',
|
244
|
+
textDecoration: 'underline wavy var(--red-a5)',
|
245
|
+
textUnderlineOffset: '2px',
|
246
|
+
// Subtle background change on hover to show it's interactive for popover
|
247
|
+
backgroundColor: isHovered ? 'var(--red-a2)' : 'transparent',
|
248
|
+
}),
|
249
|
+
// Tokens with CodeHike annotations get highlighted
|
250
|
+
...(token.codeHike.annotations.length > 0 && {
|
251
|
+
position: 'relative',
|
252
|
+
backgroundColor: 'var(--yellow-a3)',
|
253
|
+
}),
|
254
|
+
};
|
255
|
+
// Build the span element
|
256
|
+
const tokenSpan = (_jsx("span", { className: baseClass, style: style, "data-token-class": baseClass, "data-interactive": token.polen.isInteractive(), children: token.text }));
|
257
|
+
// Wrap in popover if token has semantic information
|
258
|
+
return (_jsx(GraphQLTokenPopover, { token: token, open: popoverState.isOpen(tokenId), pinned: popoverState.isPinned(tokenId), onTriggerHover: handleMouseEnter, onTriggerLeave: handleMouseLeave, onTriggerClick: handleClick, onContentHover: () => popoverState.onPopoverHover(tokenId), onContentLeave: () => popoverState.onPopoverLeave(tokenId), onClose: () => popoverState.unpin(tokenId), children: tokenSpan }));
|
259
|
+
};
|
260
|
+
/**
|
261
|
+
* Main GraphQL Interactive component with error boundary protection
|
262
|
+
*
|
263
|
+
* This is the component that should be used in user code. It wraps the
|
264
|
+
* internal implementation with an error boundary that provides graceful
|
265
|
+
* fallback to static code rendering if interactive features fail.
|
266
|
+
*/
|
267
|
+
export const GraphQLInteractive = (props) => {
|
268
|
+
return (_jsx(GraphQLErrorBoundary, { fallbackCode: props.codeblock.code, onError: (error, errorInfo) => {
|
269
|
+
// Log error for debugging (only in development)
|
270
|
+
if (process.env['NODE_ENV'] === 'development') {
|
271
|
+
console.error('GraphQL Interactive Error Boundary:', error, errorInfo);
|
272
|
+
}
|
273
|
+
}, children: _jsx(GraphQLInteractiveImpl, { ...props }) }));
|
274
|
+
};
|
275
|
+
//# sourceMappingURL=GraphQLInteractive.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"GraphQLInteractive.js","sourceRoot":"","sources":["../../../../src/template/components/GraphQLInteractive/GraphQLInteractive.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAqB,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAa/E;;;;;;;;GAQG;AACH;;;GAGG;AACH,MAAM,sBAAsB,GAAsC,CAAC,EACjE,SAAS,EACT,MAAM,EACN,qBAAq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L,KAAC,oBAAoB,IACnB,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,EAClC,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC5B,gDAAgD;YAChD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,aAAa,EAAE,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;YACxE,CAAC;QACH,CAAC,YAED,KAAC,sBAAsB,OAAK,KAAK,GAAI,GAChB,CACxB,CAAA;AACH,CAAC,CAAA"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* Error boundary for GraphQL Interactive components
|
3
|
+
*
|
4
|
+
* Provides graceful fallback rendering when the interactive GraphQL parser
|
5
|
+
* encounters errors. Falls back to static syntax highlighting.
|
6
|
+
*/
|
7
|
+
import type { React } from '#dep/react/index';
|
8
|
+
import { React as ReactHooks } from '#dep/react/index';
|
9
|
+
interface GraphQLErrorBoundaryProps {
|
10
|
+
/** Child components to protect */
|
11
|
+
children: React.ReactNode;
|
12
|
+
/** Fallback code to display if interactive parsing fails */
|
13
|
+
fallbackCode: string;
|
14
|
+
/** Optional callback when errors occur */
|
15
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
16
|
+
}
|
17
|
+
interface GraphQLErrorBoundaryState {
|
18
|
+
hasError: boolean;
|
19
|
+
error?: Error;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Error boundary that catches React errors in GraphQL Interactive components
|
23
|
+
* and provides a fallback static code display.
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* ```tsx
|
27
|
+
* <GraphQLErrorBoundary fallbackCode={codeblock.code}>
|
28
|
+
* <GraphQLInteractive codeblock={codeblock} schema={schema} />
|
29
|
+
* </GraphQLErrorBoundary>
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
export declare class GraphQLErrorBoundary extends ReactHooks.Component<GraphQLErrorBoundaryProps, GraphQLErrorBoundaryState> {
|
33
|
+
constructor(props: GraphQLErrorBoundaryProps);
|
34
|
+
static getDerivedStateFromError(error: Error): GraphQLErrorBoundaryState;
|
35
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
36
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
37
|
+
}
|
38
|
+
export {};
|
39
|
+
//# sourceMappingURL=GraphQLErrorBoundary.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"GraphQLErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../../src/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGtD,UAAU,yBAAyB;IACjC,kCAAkC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAA;IACpB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,KAAK,IAAI,CAAA;CAC7D;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,SAAQ,UAAU,CAAC,SAAS,CAC5D,yBAAyB,EACzB,yBAAyB,CAC1B;gBACa,KAAK,EAAE,yBAAyB;IAK5C,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,yBAAyB;IAK/D,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAQ1D,MAAM;CAqChB"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { React as ReactHooks } from '#dep/react/index';
|
3
|
+
import { Box } from '@radix-ui/themes';
|
4
|
+
/**
|
5
|
+
* Error boundary that catches React errors in GraphQL Interactive components
|
6
|
+
* and provides a fallback static code display.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```tsx
|
10
|
+
* <GraphQLErrorBoundary fallbackCode={codeblock.code}>
|
11
|
+
* <GraphQLInteractive codeblock={codeblock} schema={schema} />
|
12
|
+
* </GraphQLErrorBoundary>
|
13
|
+
* ```
|
14
|
+
*/
|
15
|
+
export class GraphQLErrorBoundary extends ReactHooks.Component {
|
16
|
+
constructor(props) {
|
17
|
+
super(props);
|
18
|
+
this.state = { hasError: false };
|
19
|
+
}
|
20
|
+
static getDerivedStateFromError(error) {
|
21
|
+
// Update state so the next render will show the fallback UI
|
22
|
+
return { hasError: true, error };
|
23
|
+
}
|
24
|
+
componentDidCatch(error, errorInfo) {
|
25
|
+
// Log the error or send to error reporting service
|
26
|
+
console.error('GraphQL Interactive Error:', error, errorInfo);
|
27
|
+
// Call optional error handler
|
28
|
+
this.props.onError?.(error, errorInfo);
|
29
|
+
}
|
30
|
+
render() {
|
31
|
+
if (this.state.hasError) {
|
32
|
+
return (_jsxs(Box, { className: 'graphql-error-fallback', p: '4', style: {
|
33
|
+
borderRadius: 'var(--radius-2)',
|
34
|
+
backgroundColor: 'var(--gray-2)',
|
35
|
+
position: 'relative',
|
36
|
+
borderLeft: '3px solid var(--red-9)',
|
37
|
+
}, children: [_jsx("pre", { style: { margin: 0, whiteSpace: 'pre' }, children: _jsx("code", { children: this.props.fallbackCode }) }), _jsx("div", { style: {
|
38
|
+
position: 'absolute',
|
39
|
+
top: '8px',
|
40
|
+
right: '8px',
|
41
|
+
fontSize: '12px',
|
42
|
+
color: 'var(--red-11)',
|
43
|
+
backgroundColor: 'var(--red-a3)',
|
44
|
+
padding: '2px 6px',
|
45
|
+
borderRadius: '3px',
|
46
|
+
}, title: this.state.error?.message || 'Interactive features failed to load', children: "Interactive mode unavailable" })] }));
|
47
|
+
}
|
48
|
+
return this.props.children;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
//# sourceMappingURL=GraphQLErrorBoundary.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"GraphQLErrorBoundary.js","sourceRoot":"","sources":["../../../../../src/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAgBtC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAAqB,SAAQ,UAAU,CAAC,SAGpD;IACC,YAAY,KAAgC;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IAClC,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAY;QAC1C,4DAA4D;QAC5D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IAClC,CAAC;IAEQ,iBAAiB,CAAC,KAAY,EAAE,SAA0B;QACjE,mDAAmD;QACnD,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QAE7D,8BAA8B;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACxC,CAAC;IAEQ,MAAM;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,CACL,MAAC,GAAG,IACF,SAAS,EAAC,wBAAwB,EAClC,CAAC,EAAE,GAAG,EACN,KAAK,EAAE;oBACL,YAAY,EAAE,iBAAiB;oBAC/B,eAAe,EAAE,eAAe;oBAChC,QAAQ,EAAE,UAAU;oBACpB,UAAU,EAAE,wBAAwB;iBACrC,aAED,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAC1C,yBAAO,IAAI,CAAC,KAAK,CAAC,YAAY,GAAQ,GAClC,EACN,cACE,KAAK,EAAE;4BACL,QAAQ,EAAE,UAAU;4BACpB,GAAG,EAAE,KAAK;4BACV,KAAK,EAAE,KAAK;4BACZ,QAAQ,EAAE,MAAM;4BAChB,KAAK,EAAE,eAAe;4BACtB,eAAe,EAAE,eAAe;4BAChC,OAAO,EAAE,SAAS;4BAClB,YAAY,EAAE,KAAK;yBACpB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,IAAI,qCAAqC,6CAGrE,IACF,CACP,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IAC5B,CAAC;CACF"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* Popover component for GraphQL tokens
|
3
|
+
*
|
4
|
+
* Provides rich overlays with type information that can be triggered by hover
|
5
|
+
* and pinned by clicking. Supports multiple simultaneous popovers.
|
6
|
+
*/
|
7
|
+
import type { React } from '#dep/react/index';
|
8
|
+
import type { GraphQLToken } from '../lib/parser.js';
|
9
|
+
interface GraphQLTokenPopoverProps {
|
10
|
+
/** The token to create a popover for */
|
11
|
+
token: GraphQLToken;
|
12
|
+
/** Child element that triggers the popover */
|
13
|
+
children: React.ReactNode;
|
14
|
+
/** Whether the popover is open */
|
15
|
+
open: boolean;
|
16
|
+
/** Whether the popover is pinned */
|
17
|
+
pinned: boolean;
|
18
|
+
/** Called when mouse enters the trigger */
|
19
|
+
onTriggerHover: () => void;
|
20
|
+
/** Called when mouse leaves the trigger */
|
21
|
+
onTriggerLeave: () => void;
|
22
|
+
/** Called when trigger is clicked */
|
23
|
+
onTriggerClick: (e: React.MouseEvent) => void;
|
24
|
+
/** Called when popover content is hovered */
|
25
|
+
onContentHover: () => void;
|
26
|
+
/** Called when mouse leaves popover content */
|
27
|
+
onContentLeave: () => void;
|
28
|
+
/** Called when close button is clicked */
|
29
|
+
onClose: () => void;
|
30
|
+
}
|
31
|
+
export declare const GraphQLTokenPopover: React.FC<GraphQLTokenPopoverProps>;
|
32
|
+
export {};
|
33
|
+
//# sourceMappingURL=GraphQLTokenPopover.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"GraphQLTokenPopover.d.ts","sourceRoot":"","sources":["../../../../../src/template/components/GraphQLInteractive/components/GraphQLTokenPopover.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAG7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAUpD,UAAU,wBAAwB;IAChC,wCAAwC;IACxC,KAAK,EAAE,YAAY,CAAA;IAEnB,8CAA8C;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAEzB,kCAAkC;IAClC,IAAI,EAAE,OAAO,CAAA;IAEb,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAA;IAEf,2CAA2C;IAC3C,cAAc,EAAE,MAAM,IAAI,CAAA;IAE1B,2CAA2C;IAC3C,cAAc,EAAE,MAAM,IAAI,CAAA;IAE1B,qCAAqC;IACrC,cAAc,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IAE7C,6CAA6C;IAC7C,cAAc,EAAE,MAAM,IAAI,CAAA;IAE1B,+CAA+C;IAC/C,cAAc,EAAE,MAAM,IAAI,CAAA;IAE1B,0CAA0C;IAC1C,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AA2HD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA8TlE,CAAA"}
|