polen 0.10.0-next.21 → 0.10.0-next.23
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/builder/builder.d.ts +4 -11
- package/build/api/builder/builder.d.ts.map +1 -1
- package/build/api/builder/builder.js +4 -3
- package/build/api/builder/builder.js.map +1 -1
- 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/config/merge.d.ts.map +1 -1
- package/build/api/config/merge.js +8 -0
- package/build/api/config/merge.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/cli/commands/build.js +11 -7
- package/build/cli/commands/build.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/builder/builder.ts +8 -13
- package/src/api/config/configurator.ts +72 -11
- package/src/api/config/merge.ts +13 -0
- package/src/api/vite/plugins/core.ts +1 -0
- package/src/cli/commands/build.ts +11 -7
- 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,71 @@
|
|
1
|
+
/**
|
2
|
+
* Tree-sitter GraphQL parsing with semantic analysis
|
3
|
+
*
|
4
|
+
* This module combines tree-sitter syntax parsing with GraphQL semantic
|
5
|
+
* analysis to create unified tokens for interactive code blocks.
|
6
|
+
*/
|
7
|
+
import type { CodeAnnotation } from 'codehike/code';
|
8
|
+
import { type GraphQLSchema } from 'graphql';
|
9
|
+
import * as WebTreeSitter from 'web-tree-sitter';
|
10
|
+
import type { SemanticNode } from './semantic-nodes.js';
|
11
|
+
/**
|
12
|
+
* Unified token structure that combines tree-sitter and GraphQL semantics
|
13
|
+
*
|
14
|
+
* This interface represents a single parsed token from a GraphQL document,
|
15
|
+
* enriched with semantic information from the GraphQL schema when available.
|
16
|
+
* It provides a consistent API for accessing syntax highlighting, interactivity,
|
17
|
+
* and CodeHike annotation data.
|
18
|
+
*
|
19
|
+
* @example
|
20
|
+
* ```typescript
|
21
|
+
* const tokens = await parseGraphQLWithTreeSitter(code, [], schema)
|
22
|
+
* const fieldToken = tokens.find(t => t.text === 'name')
|
23
|
+
*
|
24
|
+
* if (fieldToken?.polen.isInteractive()) {
|
25
|
+
* const url = fieldToken.polen.getReferenceUrl()
|
26
|
+
* console.log(`Navigate to: ${url}`)
|
27
|
+
* }
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
export interface GraphQLToken {
|
31
|
+
/** Reference to the tree-sitter node that this token represents */
|
32
|
+
treeSitterNode: WebTreeSitter.Node;
|
33
|
+
/**
|
34
|
+
* Optional semantic information from GraphQL schema analysis
|
35
|
+
* This includes type information, field definitions, and validation results
|
36
|
+
*/
|
37
|
+
semantic?: SemanticNode;
|
38
|
+
/** Text content of the token (computed from tree-sitter node) */
|
39
|
+
get text(): string;
|
40
|
+
/** Start character position in the source code (computed from tree-sitter node) */
|
41
|
+
get start(): number;
|
42
|
+
/** End character position in the source code (computed from tree-sitter node) */
|
43
|
+
get end(): number;
|
44
|
+
/** Polen specific functionality for interactive GraphQL documentation */
|
45
|
+
polen: {
|
46
|
+
/** Check if this token should be interactive (clickable/hoverable) */
|
47
|
+
isInteractive: () => boolean;
|
48
|
+
/** Get the reference URL for navigation, or null if not applicable */
|
49
|
+
getReferenceUrl: () => string | null;
|
50
|
+
};
|
51
|
+
/** Syntax highlighting functionality */
|
52
|
+
highlighter: {
|
53
|
+
/** Get the CSS class name for styling this token */
|
54
|
+
getCssClass: () => string;
|
55
|
+
};
|
56
|
+
/** CodeHike integration for enhanced code block features */
|
57
|
+
codeHike: {
|
58
|
+
/** Array of CodeHike annotations that apply to this token */
|
59
|
+
annotations: CodeAnnotation[];
|
60
|
+
};
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Parse GraphQL code into interactive tokens with semantic information
|
64
|
+
*
|
65
|
+
* @param code - The raw GraphQL code to parse
|
66
|
+
* @param annotations - CodeHike annotations that might affect rendering
|
67
|
+
* @param schema - Optional GraphQL schema for semantic analysis
|
68
|
+
* @returns Array of tokens representing the parsed code
|
69
|
+
*/
|
70
|
+
export declare function parseGraphQLWithTreeSitter(code: string, annotations?: CodeAnnotation[], schema?: GraphQLSchema): Promise<GraphQLToken[]>;
|
71
|
+
//# sourceMappingURL=parser.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../../src/template/components/GraphQLInteractive/lib/parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAUL,KAAK,aAAa,EAInB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAA;AAQhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAWvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,cAAc,EAAE,aAAa,CAAC,IAAI,CAAA;IAElC;;;OAGG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IAEvB,iEAAiE;IACjE,IAAI,IAAI,IAAI,MAAM,CAAA;IAElB,mFAAmF;IACnF,IAAI,KAAK,IAAI,MAAM,CAAA;IAEnB,iFAAiF;IACjF,IAAI,GAAG,IAAI,MAAM,CAAA;IAEjB,yEAAyE;IACzE,KAAK,EAAE;QACL,sEAAsE;QACtE,aAAa,EAAE,MAAM,OAAO,CAAA;QAC5B,sEAAsE;QACtE,eAAe,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;KACrC,CAAA;IAED,wCAAwC;IACxC,WAAW,EAAE;QACX,oDAAoD;QACpD,WAAW,EAAE,MAAM,MAAM,CAAA;KAC1B,CAAA;IAED,4DAA4D;IAC5D,QAAQ,EAAE;QACR,6DAA6D;QAC7D,WAAW,EAAE,cAAc,EAAE,CAAA;KAC9B,CAAA;CACF;AAqYD;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,cAAc,EAAO,EAClC,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,YAAY,EAAE,CAAC,CAiDzB"}
|