@xyd-js/uniform 0.0.0-build

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.
@@ -0,0 +1,264 @@
1
+ // src/markdown/index.ts
2
+ import { remark } from "remark";
3
+ import remarkStringify from "remark-stringify";
4
+
5
+ // src/markdown/utils.ts
6
+ import { fromMarkdown } from "mdast-util-from-markdown";
7
+ import { u } from "unist-builder";
8
+ var START_DEPTH_LEVEL = 2;
9
+ function root(ast) {
10
+ return u("root", ast);
11
+ }
12
+ function heading(title, canonical, description, refCategory, refType, refContext) {
13
+ const uTitle = u(
14
+ "heading",
15
+ { depth: START_DEPTH_LEVEL },
16
+ [u("text", `!!references ${title}`)]
17
+ );
18
+ const uCanonical = u(
19
+ "heading",
20
+ { depth: uTitle.depth + 1 },
21
+ [u("text", `!canonical ${canonical}`)]
22
+ );
23
+ let uDesc = [
24
+ u(
25
+ "heading",
26
+ { depth: uTitle.depth + 1 },
27
+ [u("text", `!description`)]
28
+ ),
29
+ u("paragraph", [u("text", description)])
30
+ ];
31
+ let uRefCategory;
32
+ if (refCategory) {
33
+ uRefCategory = u(
34
+ "heading",
35
+ { depth: uTitle.depth + 1 },
36
+ [u("text", `!category ${refCategory}`)]
37
+ );
38
+ }
39
+ let uRefType;
40
+ if (refType) {
41
+ uRefType = u(
42
+ "heading",
43
+ { depth: uTitle.depth + 1 },
44
+ [u("text", `!type ${refType}`)]
45
+ );
46
+ }
47
+ let uContext = [];
48
+ if (refContext && Object.keys(refContext)) {
49
+ uContext.push(u(
50
+ "heading",
51
+ { depth: uTitle.depth + 1 },
52
+ [
53
+ u("text", `!context`)
54
+ ]
55
+ ));
56
+ for (const [key, value] of Object.entries(refContext)) {
57
+ if (typeof value === "object") {
58
+ if (value.code) {
59
+ uContext.push(
60
+ u("heading", { depth: uContext[0].depth + 1 }, [u("text", `!${key}`)])
61
+ );
62
+ uContext.push(
63
+ u("code", { lang: value.lang }, value.code)
64
+ );
65
+ continue;
66
+ }
67
+ }
68
+ uContext.push(
69
+ u("heading", { depth: uContext[0].depth + 1 }, [u("text", `!${key} ${value.toString()}`)])
70
+ );
71
+ }
72
+ }
73
+ return {
74
+ title: uTitle,
75
+ canonical: uCanonical,
76
+ description: uDesc,
77
+ category: uRefCategory || null,
78
+ type: uRefType || null,
79
+ context: uContext || null
80
+ };
81
+ }
82
+ function examples(examples2) {
83
+ const md = [];
84
+ const uExampleRoot = u(
85
+ "heading",
86
+ { depth: START_DEPTH_LEVEL + 1 },
87
+ [u("text", `!examples`)]
88
+ );
89
+ md.push(uExampleRoot);
90
+ examples2.groups.forEach((group) => {
91
+ const uExampleGroups = u(
92
+ "heading",
93
+ { depth: uExampleRoot.depth + 1 },
94
+ [u("text", `!!groups`)]
95
+ );
96
+ md.push(uExampleGroups);
97
+ const uGroupDescription = u(
98
+ "heading",
99
+ { depth: uExampleGroups.depth + 1 },
100
+ [u("text", `!description ${group.description}`)]
101
+ );
102
+ md.push(uGroupDescription);
103
+ group.examples.forEach((example) => {
104
+ const uExamples = u(
105
+ "heading",
106
+ { depth: uExampleGroups.depth + 1 },
107
+ [u("text", `!!examples`)]
108
+ );
109
+ md.push(uExamples);
110
+ const codeBlock = u(
111
+ "heading",
112
+ { depth: uExamples.depth + 1 },
113
+ [u("text", `!codeblock`)]
114
+ );
115
+ md.push(codeBlock);
116
+ const codeBlockTitle = u(
117
+ "heading",
118
+ { depth: codeBlock.depth + 1 },
119
+ [u("text", `!title ${example.codeblock.title}`)]
120
+ );
121
+ md.push(codeBlockTitle);
122
+ const tabs = u(
123
+ "heading",
124
+ { depth: codeBlock.depth + 1 },
125
+ [u("text", `!!tabs`)]
126
+ );
127
+ md.push(tabs);
128
+ example.codeblock.tabs.forEach((tab) => {
129
+ const code = u("code", {
130
+ lang: tab.language,
131
+ meta: `!code ${tab.title}`
132
+ }, tab.code);
133
+ md.push(code);
134
+ });
135
+ });
136
+ });
137
+ return md;
138
+ }
139
+ function definitions(definitions2) {
140
+ const md = [];
141
+ definitions2.forEach((definition) => {
142
+ const uDefinition = u(
143
+ "heading",
144
+ { depth: START_DEPTH_LEVEL + 1 },
145
+ [u("text", `!!definitions`)]
146
+ );
147
+ md.push(uDefinition);
148
+ md.push(u(
149
+ "heading",
150
+ { depth: uDefinition.depth + 1 },
151
+ [u("text", `!title ${definition.title}`)]
152
+ ));
153
+ definition.properties.forEach((prop) => {
154
+ properties(
155
+ uDefinition.depth + 1,
156
+ {
157
+ name: prop.name,
158
+ type: prop.type,
159
+ description: prop.description,
160
+ context: prop.context,
161
+ properties: prop.properties
162
+ // TODO: fix ts
163
+ },
164
+ md
165
+ );
166
+ });
167
+ });
168
+ return md;
169
+ }
170
+ function properties(depth, props, output = []) {
171
+ const paramName = props.name;
172
+ const propTitle = `!!properties ${paramName}`;
173
+ const uPropTitle = u("heading", { depth }, [u("text", propTitle)]);
174
+ const uPropName = u("paragraph", { depth }, [u("text", `!name ${paramName}`)]);
175
+ const uPropType = u("paragraph", { depth }, [u("text", `!type ${props.type}`)]);
176
+ const markdownAst = fromMarkdown(props.description || "");
177
+ const uPropDesc = u("paragraph", { depth }, markdownAst.children);
178
+ const uContext = [];
179
+ if (props.context && Object.keys(props.context)) {
180
+ uContext.push(u(
181
+ "heading",
182
+ { depth: depth + 1 },
183
+ [
184
+ u("text", `!context`)
185
+ ]
186
+ ));
187
+ for (const [key, value] of Object.entries(props.context)) {
188
+ uContext.push(
189
+ u(
190
+ "heading",
191
+ { depth: uContext[0].depth + 1 },
192
+ [u("text", `!${key} ${value}`)]
193
+ )
194
+ );
195
+ }
196
+ }
197
+ output.push(
198
+ uPropTitle,
199
+ uPropName,
200
+ uPropType,
201
+ uPropDesc,
202
+ ...uContext
203
+ );
204
+ if (props.properties) {
205
+ const deepDepth = depth + 1;
206
+ for (const prop of props.properties) {
207
+ properties(deepDepth, prop, output);
208
+ }
209
+ }
210
+ }
211
+
212
+ // src/markdown/index.ts
213
+ function compile(ast) {
214
+ return remark().use(remarkStringify, {
215
+ bullet: "-",
216
+ fences: true,
217
+ listItemIndent: "one",
218
+ incrementListMarker: false,
219
+ handlers: {
220
+ heading(node) {
221
+ return `${"#".repeat(node.depth)} ${node.children[0].value}`;
222
+ }
223
+ }
224
+ }).stringify(root(ast));
225
+ }
226
+ function referenceAST(ref) {
227
+ var _a, _b;
228
+ const md = [];
229
+ const mdHeading = heading(
230
+ ref.title,
231
+ ref.canonical,
232
+ typeof ref.description === "string" ? ref.description : "",
233
+ ref.category,
234
+ ref.type,
235
+ ref.context
236
+ );
237
+ md.push(
238
+ mdHeading.title
239
+ );
240
+ if ((_a = mdHeading == null ? void 0 : mdHeading.description) == null ? void 0 : _a.length) {
241
+ md.push(...mdHeading.description);
242
+ }
243
+ md.push(
244
+ mdHeading.canonical
245
+ );
246
+ if (mdHeading.category) {
247
+ md.push(mdHeading.category);
248
+ }
249
+ if (mdHeading.type) {
250
+ md.push(mdHeading.type);
251
+ }
252
+ if ((_b = mdHeading == null ? void 0 : mdHeading.context) == null ? void 0 : _b.length) {
253
+ md.push(...mdHeading.context);
254
+ }
255
+ const mdExamples = examples(ref.examples);
256
+ const mdDefinitions = definitions(ref.definitions);
257
+ md.push(...mdExamples, ...mdDefinitions);
258
+ return md;
259
+ }
260
+ export {
261
+ compile,
262
+ referenceAST
263
+ };
264
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/markdown/index.ts","../src/markdown/utils.ts"],"sourcesContent":["import {remark} from \"remark\";\nimport remarkStringify from \"remark-stringify\";\n\nimport {Reference} from \"../types\";\n\nimport {definitions, examples, heading, root} from \"./utils\";\n\n// TODO: any\nexport function compile(ast: any) {\n return remark()\n // .use(unlimitedHeadings)\n .use(remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n incrementListMarker: false,\n handlers: {\n heading(node) {\n return `${\"#\".repeat(node.depth)} ${node.children[0].value}`;\n },\n },\n })\n .stringify(root(ast));\n}\n\nexport function referenceAST(ref: Reference) {\n const md = []\n\n const mdHeading = heading(\n ref.title,\n ref.canonical,\n typeof ref.description === \"string\" ? ref.description : \"\",\n ref.category,\n ref.type,\n ref.context\n )\n\n md.push(\n mdHeading.title,\n )\n\n if (mdHeading?.description?.length) {\n md.push(...mdHeading.description)\n }\n\n md.push(\n mdHeading.canonical,\n )\n\n if (mdHeading.category) {\n md.push(mdHeading.category)\n }\n\n if (mdHeading.type) {\n md.push(mdHeading.type)\n }\n\n if (mdHeading?.context?.length) {\n md.push(...mdHeading.context)\n }\n\n const mdExamples = examples(ref.examples)\n const mdDefinitions = definitions(ref.definitions)\n md.push(...mdExamples, ...mdDefinitions)\n\n return md;\n}\n","import { fromMarkdown } from \"mdast-util-from-markdown\";\nimport {u} from \"unist-builder\";\n\nimport {\n ExampleRoot,\n Definition,\n ReferenceCategory,\n ReferenceContext,\n ReferenceType,\n DefinitionProperty\n} from \"../types\";\n\n// START_DEPTH_LEVEL is the start depth level for the markdown AST\n// starts from 2 because 1 is reserved for the title\nconst START_DEPTH_LEVEL = 2\n\n// TODO: fix any\nexport function root(ast: any) {\n return u('root', ast);\n}\n\nexport function heading(\n title: string,\n canonical: string,\n description: string,\n refCategory?: ReferenceCategory,\n refType?: ReferenceType,\n refContext?: ReferenceContext\n) {\n const uTitle = u(\n 'heading',\n {depth: START_DEPTH_LEVEL},\n [u('text', `!!references ${title}`)]\n )\n\n const uCanonical = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!canonical ${canonical}`)]\n )\n\n let uDesc = [\n u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!description`),]\n ),\n u('paragraph', [u('text', description)])\n ]\n\n let uRefCategory\n if (refCategory) {\n uRefCategory = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!category ${refCategory}`)]\n )\n }\n\n let uRefType\n if (refType) {\n uRefType = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!type ${refType}`)]\n )\n }\n\n let uContext = []\n\n if (refContext && Object.keys(refContext)) {\n uContext.push(u(\n 'heading',\n {depth: uTitle.depth + 1},\n [\n u('text', `!context`),\n ]\n ))\n\n\n for (const [key, value] of Object.entries(refContext)) {\n if (typeof value === \"object\") {\n // TODO: support ```<lang> ??\n if (value.code) {\n uContext.push(\n u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key}`)])\n );\n\n uContext.push(\n u('code', {lang: value.lang}, value.code)\n );\n\n continue;\n }\n }\n\n uContext.push(\n u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key} ${value.toString()}`)])\n );\n }\n }\n\n return {\n title: uTitle,\n canonical: uCanonical,\n description: uDesc,\n category: uRefCategory || null,\n type: uRefType || null,\n context: uContext || null\n }\n}\n\nexport function examples(examples: ExampleRoot) {\n const md = []\n\n const uExampleRoot = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!examples`)]\n )\n md.push(uExampleRoot)\n\n examples.groups.forEach(group => {\n const uExampleGroups = u(\n 'heading',\n {depth: uExampleRoot.depth + 1},\n [u('text', `!!groups`)]\n )\n md.push(uExampleGroups)\n\n const uGroupDescription = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!description ${group.description}`)]\n )\n md.push(uGroupDescription)\n\n group.examples.forEach(example => {\n const uExamples = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!!examples`)]\n )\n md.push(uExamples)\n\n const codeBlock = u(\n 'heading',\n {depth: uExamples.depth + 1},\n [u('text', `!codeblock`)]\n )\n md.push(codeBlock)\n\n const codeBlockTitle = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!title ${example.codeblock.title}`)]\n )\n md.push(codeBlockTitle)\n\n const tabs = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!!tabs`)]\n )\n md.push(tabs)\n\n example.codeblock.tabs.forEach(tab => {\n const code = u('code', {\n lang: tab.language,\n meta: `!code ${tab.title}`\n }, tab.code);\n\n md.push(code)\n })\n\n })\n })\n\n return md\n}\n\nexport function definitions(definitions: Definition[]) {\n const md: any[] = []\n\n definitions.forEach(definition => {\n const uDefinition = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!!definitions`)]\n )\n md.push(uDefinition)\n\n md.push(u(\n 'heading',\n {depth: uDefinition.depth + 1},\n [u('text', `!title ${definition.title}`)]\n ))\n\n definition.properties.forEach(prop => {\n properties(\n uDefinition.depth + 1,\n {\n name: prop.name,\n type: prop.type,\n description: prop.description,\n context: prop.context,\n properties: prop.properties // TODO: fix ts\n },\n md,\n )\n })\n })\n\n return md\n}\n\n// TODO: any[]\nexport function properties(\n depth: number,\n props: DefinitionProperty,\n output: any[] = []\n) {\n const paramName = props.name;\n\n const propTitle = `!!properties ${paramName}`; // TODO: check if `!!properties is enough`\n const uPropTitle = u('heading', {depth}, [u('text', propTitle)]);\n const uPropName = u('paragraph', {depth}, [u('text', `!name ${paramName}`)]);\n const uPropType = u('paragraph', {depth}, [u('text', `!type ${props.type}`)]);\n const markdownAst = fromMarkdown(props.description || '');\n const uPropDesc = u(\"paragraph\", { depth }, markdownAst.children);\n const uContext = []\n\n if (props.context && Object.keys(props.context)) {\n uContext.push(u(\n 'heading',\n {depth: depth + 1},\n [\n u('text', `!context`),\n ]\n ))\n\n for (const [key, value] of Object.entries(props.context)) {\n uContext.push(u(\n 'heading',\n {depth: uContext[0].depth + 1},\n [u('text', `!${key} ${value}`)]\n )\n )\n }\n }\n\n output.push(\n uPropTitle,\n uPropName,\n uPropType,\n uPropDesc,\n ...uContext\n );\n\n if (props.properties) {\n const deepDepth = depth + 1\n\n for (const prop of props.properties) {\n properties(deepDepth, prop, output)\n }\n }\n}\n\n\n\n"],"mappings":";AAAA,SAAQ,cAAa;AACrB,OAAO,qBAAqB;;;ACD5B,SAAS,oBAAoB;AAC7B,SAAQ,SAAQ;AAahB,IAAM,oBAAoB;AAGnB,SAAS,KAAK,KAAU;AAC3B,SAAO,EAAE,QAAQ,GAAG;AACxB;AAE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AAA,EAChC;AAEA,QAAM,aAAa,SAAS,IAAI,QAAQ;AACxC,QAAM,gBAAgB,YAAY,IAAI,WAAW;AACjD,KAAG,KAAK,GAAG,YAAY,GAAG,aAAa;AAEvC,SAAO;AACX;","names":["examples","definitions"]}
@@ -0,0 +1,180 @@
1
+ import React from 'react';
2
+ import { HighlightedCode } from 'codehike/code';
3
+
4
+ interface Reference<C = ReferenceContext, M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
5
+ title: string;
6
+ description: string | React.ReactNode;
7
+ canonical: string;
8
+ definitions: Definition<M, VM>[];
9
+ examples: ExampleRoot;
10
+ category?: ReferenceCategory;
11
+ type?: ReferenceType;
12
+ context?: C;
13
+ /**
14
+ * TODO: !!!! BETTER !!!!
15
+ * @internal
16
+ */
17
+ __UNSAFE_selector?: (selector: string) => any;
18
+ }
19
+ type DefinitionOpenAPIMeta = Meta<"contentType" | "required" | "definitionDescription">;
20
+ type DefinitionTypeDocMeta = Meta<"type">;
21
+ type DefinitionGraphqlMeta = Meta<"type" | "graphqlName">;
22
+ type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta;
23
+ type SymbolDef = {
24
+ id?: string | string[];
25
+ canonical?: string | string[];
26
+ };
27
+ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
28
+ title: string;
29
+ properties: DefinitionProperty[];
30
+ rootProperty?: DefinitionProperty;
31
+ variants?: DefinitionVariant<VM>[];
32
+ description?: string | React.ReactNode;
33
+ meta?: M[];
34
+ /**
35
+ * @internal
36
+ */
37
+ symbolDef?: SymbolDef;
38
+ /**
39
+ * @internal
40
+ */
41
+ id?: string;
42
+ /**
43
+ * @internal
44
+ */
45
+ type?: string;
46
+ }
47
+ type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
48
+ type CommonDefinitionVariantMeta = Meta<"symbolName">;
49
+ type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta;
50
+ interface DefinitionVariant<M extends DefinitionVariantMeta = DefinitionVariantMeta> {
51
+ title: string;
52
+ properties: DefinitionProperty[];
53
+ rootProperty?: DefinitionProperty;
54
+ description?: string | React.ReactNode;
55
+ symbolDef?: SymbolDef;
56
+ meta?: M[];
57
+ }
58
+ interface Meta<T = string> {
59
+ name: T;
60
+ value?: unknown;
61
+ }
62
+ type DefinitionPropertyMeta = Meta<"required" | "deprecated" | "internal" | "defaults" | "nullable" | "example" | "examples" | "minimum" | "maximum" | "enum-type">;
63
+ declare enum DEFINED_DEFINITION_PROPERTY_TYPE {
64
+ UNION = "$$union",
65
+ XOR = "$$xor",
66
+ ARRAY = "$$array",
67
+ ENUM = "$$enum"
68
+ }
69
+ interface DefinitionProperty {
70
+ name: string;
71
+ type: string | DEFINED_DEFINITION_PROPERTY_TYPE;
72
+ description: string | React.ReactNode;
73
+ examples?: string | string[];
74
+ symbolDef?: SymbolDef;
75
+ meta?: DefinitionPropertyMeta[];
76
+ context?: any;
77
+ properties?: DefinitionProperty[];
78
+ ofProperty?: DefinitionProperty;
79
+ }
80
+ interface ExampleRoot {
81
+ groups: ExampleGroup[];
82
+ }
83
+ interface ExampleGroup {
84
+ description?: string;
85
+ examples: Example[];
86
+ }
87
+ interface Example {
88
+ description?: string;
89
+ codeblock: CodeBlock;
90
+ }
91
+ interface CodeBlock {
92
+ title?: string;
93
+ tabs: CodeBlockTab[];
94
+ }
95
+ interface CodeBlockTab {
96
+ title: string;
97
+ code: string;
98
+ language: string;
99
+ context?: ExampleContext;
100
+ highlighted?: HighlightedCode;
101
+ }
102
+ type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;
103
+ declare enum ReferenceCategory {
104
+ COMPONENTS = "components",
105
+ HOOKS = "hooks",
106
+ REST = "rest",
107
+ GRAPHQL = "graphql",
108
+ FUNCTIONS = "functions"
109
+ }
110
+ declare enum ReferenceType {
111
+ COMPONENT = "component",
112
+ HOOK = "hook",
113
+ REST_HTTP_GET = "rest_get",
114
+ REST_HTTP_POST = "rest_post",
115
+ REST_HTTP_PUT = "rest_put",
116
+ REST_HTTP_PATCH = "rest_patch",
117
+ REST_HTTP_DELETE = "rest_delete",
118
+ REST_HTTP_OPTIONS = "rest_options",
119
+ REST_HTTP_HEAD = "rest_head",
120
+ REST_HTTP_TRACE = "rest_trace",
121
+ REST_COMPONENT_SCHEMA = "rest_component_schema",
122
+ GRAPHQL_QUERY = "graphql_query",
123
+ GRAPHQL_MUTATION = "graphql_mutation",
124
+ GRAPHQL_SUBSCRIPTION = "graphql_subscription",
125
+ GRAPHQL_SCALAR = "graphql_scalar",
126
+ GRAPHQL_OBJECT = "graphql_object",
127
+ GRAPHQL_INTERFACE = "graphql_interface",
128
+ GRAPHQL_UNION = "graphql_union",
129
+ GRAPHQL_ENUM = "graphql_enum",
130
+ GRAPHQL_INPUT = "graphql_input",
131
+ FUNCTION_JS = "function_js"
132
+ }
133
+ interface BaseReferenceContext {
134
+ group?: string[];
135
+ scopes?: string[];
136
+ }
137
+ interface GraphQLReferenceContext extends BaseReferenceContext {
138
+ /**
139
+ * @internal
140
+ */
141
+ graphqlTypeShort: string;
142
+ graphqlName: string;
143
+ }
144
+ interface OpenAPIReferenceContext extends BaseReferenceContext {
145
+ method?: string;
146
+ path?: string;
147
+ fullPath?: string;
148
+ componentSchema?: string;
149
+ }
150
+ type TypeDocReferenceContextMeta = Meta<"internal">;
151
+ interface TypeDocReferenceContext extends BaseReferenceContext {
152
+ symbolId: string;
153
+ symbolName: string;
154
+ symbolKind: number;
155
+ packageName: string;
156
+ fileName: string;
157
+ fileFullPath: string;
158
+ line: number;
159
+ col: number;
160
+ signatureText: {
161
+ code: string;
162
+ lang: string;
163
+ };
164
+ sourcecode: {
165
+ code: string;
166
+ lang: string;
167
+ };
168
+ category?: string;
169
+ meta?: TypeDocReferenceContextMeta[];
170
+ }
171
+ type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext;
172
+ interface GraphQLExampleContext {
173
+ schema?: any;
174
+ }
175
+ interface OpenAPIExampleContext {
176
+ status?: number;
177
+ content?: string;
178
+ }
179
+
180
+ export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type Definition as d, type DefinitionVariantOpenAPIMeta as e, type DefinitionVariantMeta as f, type DefinitionVariant as g, type DefinitionPropertyMeta as h, DEFINED_DEFINITION_PROPERTY_TYPE as i, type DefinitionProperty as j, type ExampleGroup as k, type Example as l, type CodeBlock as m, type CodeBlockTab as n, type ExampleContext as o, ReferenceCategory as p, ReferenceType as q, type TypeDocReferenceContext as r, type ReferenceContext as s, type GraphQLExampleContext as t, type OpenAPIExampleContext as u };
@@ -0,0 +1,180 @@
1
+ import React from 'react';
2
+ import { HighlightedCode } from 'codehike/code';
3
+
4
+ interface Reference<C = ReferenceContext, M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
5
+ title: string;
6
+ description: string | React.ReactNode;
7
+ canonical: string;
8
+ definitions: Definition<M, VM>[];
9
+ examples: ExampleRoot;
10
+ category?: ReferenceCategory;
11
+ type?: ReferenceType;
12
+ context?: C;
13
+ /**
14
+ * TODO: !!!! BETTER !!!!
15
+ * @internal
16
+ */
17
+ __UNSAFE_selector?: (selector: string) => any;
18
+ }
19
+ type DefinitionOpenAPIMeta = Meta<"contentType" | "required" | "definitionDescription">;
20
+ type DefinitionTypeDocMeta = Meta<"type">;
21
+ type DefinitionGraphqlMeta = Meta<"type" | "graphqlName">;
22
+ type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta;
23
+ type SymbolDef = {
24
+ id?: string | string[];
25
+ canonical?: string | string[];
26
+ };
27
+ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
28
+ title: string;
29
+ properties: DefinitionProperty[];
30
+ rootProperty?: DefinitionProperty;
31
+ variants?: DefinitionVariant<VM>[];
32
+ description?: string | React.ReactNode;
33
+ meta?: M[];
34
+ /**
35
+ * @internal
36
+ */
37
+ symbolDef?: SymbolDef;
38
+ /**
39
+ * @internal
40
+ */
41
+ id?: string;
42
+ /**
43
+ * @internal
44
+ */
45
+ type?: string;
46
+ }
47
+ type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
48
+ type CommonDefinitionVariantMeta = Meta<"symbolName">;
49
+ type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta;
50
+ interface DefinitionVariant<M extends DefinitionVariantMeta = DefinitionVariantMeta> {
51
+ title: string;
52
+ properties: DefinitionProperty[];
53
+ rootProperty?: DefinitionProperty;
54
+ description?: string | React.ReactNode;
55
+ symbolDef?: SymbolDef;
56
+ meta?: M[];
57
+ }
58
+ interface Meta<T = string> {
59
+ name: T;
60
+ value?: unknown;
61
+ }
62
+ type DefinitionPropertyMeta = Meta<"required" | "deprecated" | "internal" | "defaults" | "nullable" | "example" | "examples" | "minimum" | "maximum" | "enum-type">;
63
+ declare enum DEFINED_DEFINITION_PROPERTY_TYPE {
64
+ UNION = "$$union",
65
+ XOR = "$$xor",
66
+ ARRAY = "$$array",
67
+ ENUM = "$$enum"
68
+ }
69
+ interface DefinitionProperty {
70
+ name: string;
71
+ type: string | DEFINED_DEFINITION_PROPERTY_TYPE;
72
+ description: string | React.ReactNode;
73
+ examples?: string | string[];
74
+ symbolDef?: SymbolDef;
75
+ meta?: DefinitionPropertyMeta[];
76
+ context?: any;
77
+ properties?: DefinitionProperty[];
78
+ ofProperty?: DefinitionProperty;
79
+ }
80
+ interface ExampleRoot {
81
+ groups: ExampleGroup[];
82
+ }
83
+ interface ExampleGroup {
84
+ description?: string;
85
+ examples: Example[];
86
+ }
87
+ interface Example {
88
+ description?: string;
89
+ codeblock: CodeBlock;
90
+ }
91
+ interface CodeBlock {
92
+ title?: string;
93
+ tabs: CodeBlockTab[];
94
+ }
95
+ interface CodeBlockTab {
96
+ title: string;
97
+ code: string;
98
+ language: string;
99
+ context?: ExampleContext;
100
+ highlighted?: HighlightedCode;
101
+ }
102
+ type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;
103
+ declare enum ReferenceCategory {
104
+ COMPONENTS = "components",
105
+ HOOKS = "hooks",
106
+ REST = "rest",
107
+ GRAPHQL = "graphql",
108
+ FUNCTIONS = "functions"
109
+ }
110
+ declare enum ReferenceType {
111
+ COMPONENT = "component",
112
+ HOOK = "hook",
113
+ REST_HTTP_GET = "rest_get",
114
+ REST_HTTP_POST = "rest_post",
115
+ REST_HTTP_PUT = "rest_put",
116
+ REST_HTTP_PATCH = "rest_patch",
117
+ REST_HTTP_DELETE = "rest_delete",
118
+ REST_HTTP_OPTIONS = "rest_options",
119
+ REST_HTTP_HEAD = "rest_head",
120
+ REST_HTTP_TRACE = "rest_trace",
121
+ REST_COMPONENT_SCHEMA = "rest_component_schema",
122
+ GRAPHQL_QUERY = "graphql_query",
123
+ GRAPHQL_MUTATION = "graphql_mutation",
124
+ GRAPHQL_SUBSCRIPTION = "graphql_subscription",
125
+ GRAPHQL_SCALAR = "graphql_scalar",
126
+ GRAPHQL_OBJECT = "graphql_object",
127
+ GRAPHQL_INTERFACE = "graphql_interface",
128
+ GRAPHQL_UNION = "graphql_union",
129
+ GRAPHQL_ENUM = "graphql_enum",
130
+ GRAPHQL_INPUT = "graphql_input",
131
+ FUNCTION_JS = "function_js"
132
+ }
133
+ interface BaseReferenceContext {
134
+ group?: string[];
135
+ scopes?: string[];
136
+ }
137
+ interface GraphQLReferenceContext extends BaseReferenceContext {
138
+ /**
139
+ * @internal
140
+ */
141
+ graphqlTypeShort: string;
142
+ graphqlName: string;
143
+ }
144
+ interface OpenAPIReferenceContext extends BaseReferenceContext {
145
+ method?: string;
146
+ path?: string;
147
+ fullPath?: string;
148
+ componentSchema?: string;
149
+ }
150
+ type TypeDocReferenceContextMeta = Meta<"internal">;
151
+ interface TypeDocReferenceContext extends BaseReferenceContext {
152
+ symbolId: string;
153
+ symbolName: string;
154
+ symbolKind: number;
155
+ packageName: string;
156
+ fileName: string;
157
+ fileFullPath: string;
158
+ line: number;
159
+ col: number;
160
+ signatureText: {
161
+ code: string;
162
+ lang: string;
163
+ };
164
+ sourcecode: {
165
+ code: string;
166
+ lang: string;
167
+ };
168
+ category?: string;
169
+ meta?: TypeDocReferenceContextMeta[];
170
+ }
171
+ type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext;
172
+ interface GraphQLExampleContext {
173
+ schema?: any;
174
+ }
175
+ interface OpenAPIExampleContext {
176
+ status?: number;
177
+ content?: string;
178
+ }
179
+
180
+ export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type Definition as d, type DefinitionVariantOpenAPIMeta as e, type DefinitionVariantMeta as f, type DefinitionVariant as g, type DefinitionPropertyMeta as h, DEFINED_DEFINITION_PROPERTY_TYPE as i, type DefinitionProperty as j, type ExampleGroup as k, type Example as l, type CodeBlock as m, type CodeBlockTab as n, type ExampleContext as o, ReferenceCategory as p, ReferenceType as q, type TypeDocReferenceContext as r, type ReferenceContext as s, type GraphQLExampleContext as t, type OpenAPIExampleContext as u };
package/index.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./src/types"
2
+ export type {
3
+ UniformPlugin,
4
+ UniformPluginArgs
5
+ } from "./src/index"
6
+
7
+ export { default } from "./src/index"
8
+
9
+ export {
10
+ pluginJsonView,
11
+ pluginNavigation,
12
+ } from "./src/plugins"
13
+
14
+
package/markdown.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/markdown/index";