@xyd-js/uniform 0.1.0-xyd.5 → 0.1.0-xyd.56
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/CHANGELOG.md +418 -0
- package/LICENSE +21 -0
- package/dist/index.cjs +141 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +138 -78
- package/dist/index.js.map +1 -1
- package/dist/markdown.cjs +16 -7
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.d.cts +3 -1
- package/dist/markdown.d.ts +3 -1
- package/dist/markdown.js +16 -7
- package/dist/markdown.js.map +1 -1
- package/dist/types-BiglsETJ.d.cts +180 -0
- package/dist/types-BiglsETJ.d.ts +180 -0
- package/index.ts +10 -4
- package/package.json +9 -5
- package/src/index.ts +35 -17
- package/src/markdown/index.ts +1 -1
- package/src/markdown/utils.ts +21 -7
- package/src/plugins/__tests__/pluginJsonView.test.ts +132 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/pluginJsonView.ts +54 -0
- package/src/plugins/pluginNavigation.ts +135 -0
- package/src/types.ts +230 -73
- package/tsconfig.json +4 -1
- package/vitest.config.ts +15 -0
- package/dist/types-CbDJSEtC.d.cts +0 -81
- package/dist/types-CbDJSEtC.d.ts +0 -81
- package/src/utils.ts +0 -123
|
@@ -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
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./src/types"
|
|
2
|
+
export type {
|
|
3
|
+
UniformPlugin,
|
|
4
|
+
UniformPluginArgs
|
|
5
|
+
} from "./src/index"
|
|
6
|
+
|
|
7
|
+
export { default } from "./src/index"
|
|
2
8
|
|
|
3
9
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
pluginJsonView,
|
|
11
|
+
pluginNavigation,
|
|
12
|
+
} from "./src/plugins"
|
|
6
13
|
|
|
7
|
-
export * from "./src/types"
|
|
8
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/uniform",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.56",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,25 +12,29 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"codehike": "^1.0.3",
|
|
15
|
-
"
|
|
15
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
16
16
|
"remark": "^15.0.1",
|
|
17
17
|
"remark-stringify": "^11.0.0",
|
|
18
18
|
"unist-builder": "^4.0.0",
|
|
19
19
|
"unist-util-visit": "^5.0.0",
|
|
20
|
-
"@xyd-js/core": "0.1.0-xyd.
|
|
20
|
+
"@xyd-js/core": "0.1.0-xyd.54"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@mdx-js/mdx": "^3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
26
27
|
"@types/node": "^22.10.5",
|
|
27
28
|
"rimraf": "^3.0.2",
|
|
28
29
|
"tsup": "^8.3.0",
|
|
29
|
-
"typescript": "^4.5.5"
|
|
30
|
+
"typescript": "^4.5.5",
|
|
31
|
+
"vitest": "^1.3.1"
|
|
30
32
|
},
|
|
31
33
|
"scripts": {
|
|
32
34
|
"clean": "rimraf build",
|
|
33
35
|
"prebuild": "pnpm clean",
|
|
34
|
-
"build": "tsup"
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"test": "vitest",
|
|
38
|
+
"test:coverage": "vitest run --coverage"
|
|
35
39
|
}
|
|
36
40
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
// Define the new PluginV type with a callback function that returns another function
|
|
2
2
|
import {Reference} from "./types";
|
|
3
3
|
|
|
4
|
+
export * from "./types";
|
|
5
|
+
|
|
4
6
|
// Define the new PluginV type with a callback function that returns another function
|
|
5
|
-
export type
|
|
7
|
+
export type UniformPluginArgs = {
|
|
8
|
+
references: Reference[] | Reference,
|
|
9
|
+
defer: (defer: () => any) => void;
|
|
10
|
+
|
|
11
|
+
// TODO: maybe in the future
|
|
12
|
+
// visit: (selector: string | "[method] [path]", callback: (...args: any[]) => void) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type UniformPluginRestArgs = {
|
|
17
|
+
index: number;
|
|
18
|
+
}
|
|
19
|
+
export type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;
|
|
6
20
|
|
|
7
21
|
// Utility type to infer if a type is an array and avoid wrapping it into an array twice
|
|
8
22
|
type NormalizeArray<T> = T extends Array<infer U> ? U[] : T;
|
|
@@ -35,22 +49,28 @@ export default function uniform<T extends UniformPlugin<any>[]>(
|
|
|
35
49
|
out: {} as { [K in keyof ResultType]: ResultType[K] }
|
|
36
50
|
};
|
|
37
51
|
|
|
38
|
-
|
|
39
|
-
const finishCallbacks = new Set();
|
|
40
|
-
|
|
41
52
|
config.plugins.forEach((plugin) => {
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
let defer: any = undefined; // fix any
|
|
54
|
+
|
|
55
|
+
const call = plugin({
|
|
56
|
+
references: references,
|
|
57
|
+
defer: (cb) => {
|
|
58
|
+
if (typeof cb === "function") {
|
|
59
|
+
defer = cb
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
// visit: (pattern, callback) => {
|
|
63
|
+
// }
|
|
44
64
|
})
|
|
45
65
|
|
|
46
|
-
references.
|
|
47
|
-
call(ref
|
|
66
|
+
references.map((ref, i) => {
|
|
67
|
+
call(ref, {
|
|
68
|
+
index: i,
|
|
69
|
+
})
|
|
48
70
|
});
|
|
49
|
-
})
|
|
50
71
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const resp = cb()
|
|
72
|
+
if (typeof defer === "function") {
|
|
73
|
+
const resp = defer()
|
|
54
74
|
if (typeof resp !== "object") {
|
|
55
75
|
throw new Error(`Invalid callback return type: ${typeof resp}`)
|
|
56
76
|
}
|
|
@@ -59,10 +79,8 @@ export default function uniform<T extends UniformPlugin<any>[]>(
|
|
|
59
79
|
...response.out,
|
|
60
80
|
...resp
|
|
61
81
|
}
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error(`Invalid callback type: ${typeof cb}`)
|
|
64
82
|
}
|
|
65
|
-
})
|
|
83
|
+
})
|
|
66
84
|
|
|
67
85
|
return response;
|
|
68
86
|
}
|
|
@@ -72,8 +90,8 @@ export default function uniform<T extends UniformPlugin<any>[]>(
|
|
|
72
90
|
// return (ref: Reference) => {
|
|
73
91
|
// };
|
|
74
92
|
// };
|
|
75
|
-
// function examplePlugin(
|
|
76
|
-
//
|
|
93
|
+
// function examplePlugin(defer: (defer: () => { value: boolean }) => void) {
|
|
94
|
+
// defer(() => ({
|
|
77
95
|
// value: true,
|
|
78
96
|
// }));
|
|
79
97
|
//
|
package/src/markdown/index.ts
CHANGED
package/src/markdown/utils.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
1
2
|
import {u} from "unist-builder";
|
|
2
3
|
|
|
3
4
|
import {
|
|
@@ -78,12 +79,24 @@ export function heading(
|
|
|
78
79
|
|
|
79
80
|
|
|
80
81
|
for (const [key, value] of Object.entries(refContext)) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
if (typeof value === "object") {
|
|
83
|
+
// TODO: support ```<lang> ??
|
|
84
|
+
if (value.code) {
|
|
85
|
+
uContext.push(
|
|
86
|
+
u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key}`)])
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
uContext.push(
|
|
90
|
+
u('code', {lang: value.lang}, value.code)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
uContext.push(
|
|
98
|
+
u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key} ${value.toString()}`)])
|
|
99
|
+
);
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
102
|
|
|
@@ -213,7 +226,8 @@ export function properties(
|
|
|
213
226
|
const uPropTitle = u('heading', {depth}, [u('text', propTitle)]);
|
|
214
227
|
const uPropName = u('paragraph', {depth}, [u('text', `!name ${paramName}`)]);
|
|
215
228
|
const uPropType = u('paragraph', {depth}, [u('text', `!type ${props.type}`)]);
|
|
216
|
-
const
|
|
229
|
+
const markdownAst = fromMarkdown(props.description || '');
|
|
230
|
+
const uPropDesc = u("paragraph", { depth }, markdownAst.children);
|
|
217
231
|
const uContext = []
|
|
218
232
|
|
|
219
233
|
if (props.context && Object.keys(props.context)) {
|