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.
Files changed (94) hide show
  1. package/build/api/builder/builder.d.ts +4 -11
  2. package/build/api/builder/builder.d.ts.map +1 -1
  3. package/build/api/builder/builder.js +4 -3
  4. package/build/api/builder/builder.js.map +1 -1
  5. package/build/api/config/configurator.d.ts +62 -11
  6. package/build/api/config/configurator.d.ts.map +1 -1
  7. package/build/api/config/configurator.js +9 -0
  8. package/build/api/config/configurator.js.map +1 -1
  9. package/build/api/config/merge.d.ts.map +1 -1
  10. package/build/api/config/merge.js +8 -0
  11. package/build/api/config/merge.js.map +1 -1
  12. package/build/api/vite/plugins/core.d.ts.map +1 -1
  13. package/build/api/vite/plugins/core.js +1 -0
  14. package/build/api/vite/plugins/core.js.map +1 -1
  15. package/build/cli/commands/build.js +11 -7
  16. package/build/cli/commands/build.js.map +1 -1
  17. package/build/project-data.d.ts +1 -0
  18. package/build/project-data.d.ts.map +1 -1
  19. package/build/sandbox.js +40 -17
  20. package/build/sandbox.js.map +1 -1
  21. package/build/template/components/CodeBlock.d.ts.map +1 -1
  22. package/build/template/components/CodeBlock.js +3 -5
  23. package/build/template/components/CodeBlock.js.map +1 -1
  24. package/build/template/components/Field.js +1 -1
  25. package/build/template/components/Field.js.map +1 -1
  26. package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts +31 -0
  27. package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts.map +1 -0
  28. package/build/template/components/GraphQLInteractive/GraphQLInteractive.js +275 -0
  29. package/build/template/components/GraphQLInteractive/GraphQLInteractive.js.map +1 -0
  30. package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.d.ts +39 -0
  31. package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.d.ts.map +1 -0
  32. package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.js +51 -0
  33. package/build/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.js.map +1 -0
  34. package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.d.ts +33 -0
  35. package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.d.ts.map +1 -0
  36. package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.js +242 -0
  37. package/build/template/components/GraphQLInteractive/components/GraphQLTokenPopover.js.map +1 -0
  38. package/build/template/components/GraphQLInteractive/hooks/use-popover-state.d.ts +45 -0
  39. package/build/template/components/GraphQLInteractive/hooks/use-popover-state.d.ts.map +1 -0
  40. package/build/template/components/GraphQLInteractive/hooks/use-popover-state.js +176 -0
  41. package/build/template/components/GraphQLInteractive/hooks/use-popover-state.js.map +1 -0
  42. package/build/template/components/GraphQLInteractive/index.d.ts +2 -0
  43. package/build/template/components/GraphQLInteractive/index.d.ts.map +1 -0
  44. package/build/template/components/GraphQLInteractive/index.js +2 -0
  45. package/build/template/components/GraphQLInteractive/index.js.map +1 -0
  46. package/build/template/components/GraphQLInteractive/lib/graphql-node-types.d.ts +52 -0
  47. package/build/template/components/GraphQLInteractive/lib/graphql-node-types.d.ts.map +1 -0
  48. package/build/template/components/GraphQLInteractive/lib/graphql-node-types.js +34 -0
  49. package/build/template/components/GraphQLInteractive/lib/graphql-node-types.js.map +1 -0
  50. package/build/template/components/GraphQLInteractive/lib/parser.d.ts +71 -0
  51. package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -0
  52. package/build/template/components/GraphQLInteractive/lib/parser.js +836 -0
  53. package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -0
  54. package/build/template/components/GraphQLInteractive/lib/semantic-nodes.d.ts +98 -0
  55. package/build/template/components/GraphQLInteractive/lib/semantic-nodes.d.ts.map +1 -0
  56. package/build/template/components/GraphQLInteractive/lib/semantic-nodes.js +31 -0
  57. package/build/template/components/GraphQLInteractive/lib/semantic-nodes.js.map +1 -0
  58. package/build/template/components/content/$$.d.ts +0 -1
  59. package/build/template/components/content/$$.d.ts.map +1 -1
  60. package/build/template/components/content/$$.js +0 -1
  61. package/build/template/components/content/$$.js.map +1 -1
  62. package/package.json +5 -21
  63. package/src/api/builder/builder.ts +8 -13
  64. package/src/api/config/configurator.ts +72 -11
  65. package/src/api/config/merge.ts +13 -0
  66. package/src/api/vite/plugins/core.ts +1 -0
  67. package/src/cli/commands/build.ts +11 -7
  68. package/src/lib/kit-temp.test.ts +9 -9
  69. package/src/project-data.ts +1 -0
  70. package/src/sandbox.ts +40 -17
  71. package/src/template/components/CodeBlock.tsx +6 -9
  72. package/src/template/components/Field.tsx +1 -1
  73. package/src/template/components/GraphQLInteractive/GraphQLInteractive.tsx +464 -0
  74. package/src/template/components/GraphQLInteractive/components/GraphQLErrorBoundary.tsx +96 -0
  75. package/src/template/components/GraphQLInteractive/components/GraphQLTokenPopover.tsx +492 -0
  76. package/src/template/components/GraphQLInteractive/hooks/use-popover-state.ts +244 -0
  77. package/src/template/components/GraphQLInteractive/index.ts +1 -0
  78. package/src/template/components/GraphQLInteractive/lib/graphql-node-types.ts +217 -0
  79. package/src/template/components/GraphQLInteractive/lib/parser.ts +1075 -0
  80. package/src/template/components/GraphQLInteractive/lib/semantic-nodes.ts +154 -0
  81. package/src/template/components/GraphQLInteractive/tests/parser-comment.test.ts +33 -0
  82. package/src/template/components/GraphQLInteractive/tests/parser-error-hint.test.ts +102 -0
  83. package/src/template/components/GraphQLInteractive/tests/parser.test.ts +131 -0
  84. package/src/template/components/content/$$.ts +0 -1
  85. package/build/template/components/content/GraphQLDocumentWithSchema.d.ts +0 -8
  86. package/build/template/components/content/GraphQLDocumentWithSchema.d.ts.map +0 -1
  87. package/build/template/components/content/GraphQLDocumentWithSchema.js +0 -13
  88. package/build/template/components/content/GraphQLDocumentWithSchema.js.map +0 -1
  89. package/build/template/components/content/GraphQLDocumentWrapper.d.ts +0 -7
  90. package/build/template/components/content/GraphQLDocumentWrapper.d.ts.map +0 -1
  91. package/build/template/components/content/GraphQLDocumentWrapper.js +0 -48
  92. package/build/template/components/content/GraphQLDocumentWrapper.js.map +0 -1
  93. package/src/template/components/content/GraphQLDocumentWithSchema.tsx +0 -13
  94. 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"}