@xyd-js/plugins 0.1.0-xyd.2
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 +19 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +616 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
- package/src/index.ts +52 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +33 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @xyd-js/plugins
|
|
2
|
+
|
|
3
|
+
## 0.1.0-xyd.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- test
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @xyd-js/framework@0.1.0-xyd.34
|
|
10
|
+
- @xyd-js/uniform@0.1.0-xyd.17
|
|
11
|
+
|
|
12
|
+
## 0.1.0-xyd.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- update packages
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @xyd-js/framework@0.1.0-xyd.33
|
|
19
|
+
- @xyd-js/uniform@0.1.0-xyd.16
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 xyd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import { Plugin as Plugin$1 } from 'vite';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { UniformPlugin } from '@xyd-js/uniform';
|
|
5
|
+
import { SurfaceTarget } from '@xyd-js/framework/react';
|
|
6
|
+
|
|
7
|
+
type RawTheme = {
|
|
8
|
+
name?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
tokenColors?: ThemeSetting[];
|
|
11
|
+
colors?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
type ThemeSetting = {
|
|
17
|
+
name?: string;
|
|
18
|
+
scope?: string | string[];
|
|
19
|
+
settings: {
|
|
20
|
+
fontStyle?: string;
|
|
21
|
+
foreground?: string;
|
|
22
|
+
background?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const THEME_NAMES: readonly ["dark-plus", "dracula-soft", "dracula", "github-dark", "github-dark-dimmed", "github-from-css", "github-light", "light-plus", "material-darker", "material-default", "material-from-css", "material-lighter", "material-ocean", "material-palenight", "min-dark", "min-light", "monokai", "nord", "one-dark-pro", "poimandres", "slack-dark", "slack-ochin", "solarized-dark", "solarized-light"];
|
|
26
|
+
type NamesTuple$1 = typeof THEME_NAMES;
|
|
27
|
+
type StringTheme = NamesTuple$1[number];
|
|
28
|
+
type Theme$1 = StringTheme | RawTheme;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Main settings interface for the application
|
|
32
|
+
*/
|
|
33
|
+
interface Settings {
|
|
34
|
+
/** Theme configuration for the application */
|
|
35
|
+
theme?: Theme;
|
|
36
|
+
/** Navigation configuration */
|
|
37
|
+
navigation?: Navigation;
|
|
38
|
+
/** API configuration */
|
|
39
|
+
api?: API;
|
|
40
|
+
/** Integrations configuration */
|
|
41
|
+
integrations?: Integrations;
|
|
42
|
+
/** Plugins configuration */
|
|
43
|
+
plugins?: Plugins;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
* @unsafe
|
|
47
|
+
*
|
|
48
|
+
* Redirects configuration
|
|
49
|
+
*/
|
|
50
|
+
redirects?: Redirects[];
|
|
51
|
+
/**
|
|
52
|
+
* @unsafe
|
|
53
|
+
* SEO configuration
|
|
54
|
+
*/
|
|
55
|
+
seo?: SEO;
|
|
56
|
+
/** Engine configuration */
|
|
57
|
+
engine?: Engine;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Theme configuration that changes the look and feel of the project
|
|
61
|
+
*/
|
|
62
|
+
interface Theme {
|
|
63
|
+
/**
|
|
64
|
+
* A preset theme configuration that changes the look and feel of the project.
|
|
65
|
+
* A theme is a set of default styling configurations.
|
|
66
|
+
*
|
|
67
|
+
* Example built-in themes: `cosmo`, `gusto`, `poetry`, `picasso`
|
|
68
|
+
*/
|
|
69
|
+
readonly name: ThemePresetName | (string & {});
|
|
70
|
+
/**
|
|
71
|
+
* The default color scheme to use.
|
|
72
|
+
*/
|
|
73
|
+
defaultColorScheme?: "light" | "dark" | "os";
|
|
74
|
+
/**
|
|
75
|
+
* Path to logo image or object with path to "light" and "dark" mode logo images, and where the logo links to.
|
|
76
|
+
* SVG format is recommended as it does not pixelate and the file size is generally smaller.
|
|
77
|
+
*/
|
|
78
|
+
logo?: string | Logo | React.JSX.Element;
|
|
79
|
+
/**
|
|
80
|
+
* Coder configuration for the theme, including options like syntax highlighting.
|
|
81
|
+
*/
|
|
82
|
+
coder?: Coder;
|
|
83
|
+
/**
|
|
84
|
+
* Banner configuration for the theme.
|
|
85
|
+
*/
|
|
86
|
+
banner?: Banner;
|
|
87
|
+
/** Path to the favicon image. For example: /path/to/favicon.svg */
|
|
88
|
+
favicon?: string;
|
|
89
|
+
/** The defult level of the table of contents. */
|
|
90
|
+
maxTocDepth?: number;
|
|
91
|
+
/** Head configuration */
|
|
92
|
+
head?: HeadConfig[];
|
|
93
|
+
/** The iconify library */
|
|
94
|
+
icons?: Icons;
|
|
95
|
+
/**
|
|
96
|
+
* Custom scripts to be added to the head of the every page.
|
|
97
|
+
* Paths are relative to the root of the project or absolute.
|
|
98
|
+
*/
|
|
99
|
+
scripts?: Script[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Coder configuration for the theme, including options like syntax highlighting.
|
|
103
|
+
*/
|
|
104
|
+
interface Coder {
|
|
105
|
+
/**
|
|
106
|
+
* If `true` then code blocks will have line numbers.
|
|
107
|
+
*/
|
|
108
|
+
lines?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* If `true` then code blocks will have a scrollbar.
|
|
111
|
+
*/
|
|
112
|
+
scroll?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Syntax highlighting configuration.
|
|
115
|
+
*/
|
|
116
|
+
syntaxHighlight?: Theme$1;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Configuration type for head elements that can be added to the HTML head.
|
|
120
|
+
* Format: [tagName, attributes]
|
|
121
|
+
*
|
|
122
|
+
* @example: ['script', { src: 'https://example.com/script.js', defer: true }]
|
|
123
|
+
*/
|
|
124
|
+
type HeadConfig = [string, Record<string, string | boolean>];
|
|
125
|
+
type Script = string;
|
|
126
|
+
/**
|
|
127
|
+
* Logo configuration interface
|
|
128
|
+
*/
|
|
129
|
+
interface Logo {
|
|
130
|
+
/** Path to the logo in light mode. For example: `/path/to/logo.svg` */
|
|
131
|
+
light?: string;
|
|
132
|
+
/** Path to the logo in dark mode. For example: `/path/to/logo.svg` */
|
|
133
|
+
dark?: string;
|
|
134
|
+
/** Where clicking on the logo links you to */
|
|
135
|
+
href?: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Banner configuration interface
|
|
139
|
+
*/
|
|
140
|
+
interface Banner {
|
|
141
|
+
/**
|
|
142
|
+
* Banner content.
|
|
143
|
+
*/
|
|
144
|
+
content: string | React.JSX.Element;
|
|
145
|
+
/**
|
|
146
|
+
* Banner label.
|
|
147
|
+
*/
|
|
148
|
+
label?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Banner kind.
|
|
151
|
+
*/
|
|
152
|
+
kind?: "secondary";
|
|
153
|
+
/**
|
|
154
|
+
* Banner icon.
|
|
155
|
+
*/
|
|
156
|
+
icon?: string;
|
|
157
|
+
}
|
|
158
|
+
interface IconLibrary {
|
|
159
|
+
/** The iconify library name */
|
|
160
|
+
name: string;
|
|
161
|
+
/** The iconify library version */
|
|
162
|
+
version?: string;
|
|
163
|
+
/** The default iconify icon name */
|
|
164
|
+
default?: boolean;
|
|
165
|
+
/** Merge icons from the library into the default iconify library */
|
|
166
|
+
noprefix?: boolean;
|
|
167
|
+
}
|
|
168
|
+
interface Icons {
|
|
169
|
+
/** The iconify library */
|
|
170
|
+
library?: string | string[] | IconLibrary | IconLibrary[];
|
|
171
|
+
}
|
|
172
|
+
/** Available theme preset names */
|
|
173
|
+
type ThemePresetName = "poetry" | "cosmo" | "opener" | "picasso";
|
|
174
|
+
/**
|
|
175
|
+
* Navigation configuration interface
|
|
176
|
+
*/
|
|
177
|
+
interface Navigation {
|
|
178
|
+
/** Definition of sidebar - an array of groups with all the pages within that group */
|
|
179
|
+
sidebar: (SidebarRoute | Sidebar | string)[];
|
|
180
|
+
/** Array of headers */
|
|
181
|
+
header?: Header[];
|
|
182
|
+
/** Array of segments */
|
|
183
|
+
segments?: Segment[];
|
|
184
|
+
/**
|
|
185
|
+
* Array of version names. Only use this if you want to show different versions of docs
|
|
186
|
+
* with a dropdown in the navigation bar.
|
|
187
|
+
*/
|
|
188
|
+
/** Anchors, includes the icon, name, and url */
|
|
189
|
+
anchors?: AnchorRoot;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Sidebar multi-group configuration
|
|
193
|
+
*/
|
|
194
|
+
interface SidebarRoute {
|
|
195
|
+
/** Route for this sidebar group */
|
|
196
|
+
route: string;
|
|
197
|
+
/** Sidebar pages within this group */
|
|
198
|
+
pages: Sidebar[];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Sidebar configuration
|
|
202
|
+
*/
|
|
203
|
+
interface Sidebar {
|
|
204
|
+
/** The name of the group */
|
|
205
|
+
group?: string;
|
|
206
|
+
/**
|
|
207
|
+
* The relative paths to the markdown files that will serve as pages.
|
|
208
|
+
* Note: groups are recursive, so to add a sub-folder add another group object in the page array.
|
|
209
|
+
*/
|
|
210
|
+
pages?: PageURL[];
|
|
211
|
+
/**
|
|
212
|
+
* The icon of the group.
|
|
213
|
+
*/
|
|
214
|
+
icon?: string;
|
|
215
|
+
/**
|
|
216
|
+
* The sort order of the group.
|
|
217
|
+
*/
|
|
218
|
+
sort?: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Page URL type
|
|
222
|
+
*/
|
|
223
|
+
type PageURL = string | VirtualPage | Sidebar;
|
|
224
|
+
/**
|
|
225
|
+
* @internal
|
|
226
|
+
*
|
|
227
|
+
* Virtual page type
|
|
228
|
+
*
|
|
229
|
+
* Virtual pages are composition of pages, needed for templating e.g in uniform
|
|
230
|
+
*
|
|
231
|
+
* Example:
|
|
232
|
+
*
|
|
233
|
+
* {
|
|
234
|
+
* pages: [0
|
|
235
|
+
* ".xyd/.cache/.content/docs/rest/todo:docs/rest/todo",
|
|
236
|
+
* ]
|
|
237
|
+
* }
|
|
238
|
+
*
|
|
239
|
+
* above will be rendered as docs/rest/todo.md using composition from xyd's `.content`
|
|
240
|
+
*/
|
|
241
|
+
type VirtualPage = string | {
|
|
242
|
+
/** The virtual page to use for the page */
|
|
243
|
+
virtual: string;
|
|
244
|
+
/** The page to use for the page */
|
|
245
|
+
page: string;
|
|
246
|
+
/** The template to use for the page */
|
|
247
|
+
templates?: string | string[];
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Segment configuration
|
|
251
|
+
*/
|
|
252
|
+
interface Segment {
|
|
253
|
+
/** Route for this segment */
|
|
254
|
+
route: string;
|
|
255
|
+
/** Title of this segment */
|
|
256
|
+
title: string;
|
|
257
|
+
/** Items within this segment */
|
|
258
|
+
pages: SegmentPage[];
|
|
259
|
+
}
|
|
260
|
+
interface SegmentPage {
|
|
261
|
+
page: string;
|
|
262
|
+
title: string;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Header configuration
|
|
266
|
+
*/
|
|
267
|
+
type Header = {
|
|
268
|
+
/** The name of the button */
|
|
269
|
+
title?: string;
|
|
270
|
+
/** The url once you click on the button */
|
|
271
|
+
page?: string;
|
|
272
|
+
/** Float the header to the right */
|
|
273
|
+
float?: "right";
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Anchor configuration
|
|
277
|
+
*/
|
|
278
|
+
interface Anchor {
|
|
279
|
+
/** The iconify icon name */
|
|
280
|
+
icon?: string;
|
|
281
|
+
/** The name of the anchor label */
|
|
282
|
+
name?: string;
|
|
283
|
+
/**
|
|
284
|
+
* The start of the URL that marks what pages go in the anchor.
|
|
285
|
+
* Generally, this is the name of the folder you put your pages in.
|
|
286
|
+
*/
|
|
287
|
+
url?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Anchor root configuration
|
|
291
|
+
*/
|
|
292
|
+
interface AnchorRoot {
|
|
293
|
+
/** Bottom anchors */
|
|
294
|
+
bottom?: Anchor[];
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* API configuration interface
|
|
298
|
+
*/
|
|
299
|
+
interface API {
|
|
300
|
+
/**
|
|
301
|
+
* OpenAPI configuration
|
|
302
|
+
*/
|
|
303
|
+
openapi?: APIFile;
|
|
304
|
+
/**
|
|
305
|
+
* GraphQL configuration
|
|
306
|
+
*/
|
|
307
|
+
graphql?: APIFile;
|
|
308
|
+
/**
|
|
309
|
+
* Sources configuration
|
|
310
|
+
*/
|
|
311
|
+
sources?: APIFile;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* API file configuration. Can be a path, an array of paths, a map of paths, or an advanced configuration
|
|
315
|
+
*/
|
|
316
|
+
type APIFile = string | string[] | APIFileMap | APIFileAdvanced;
|
|
317
|
+
/**
|
|
318
|
+
* API file map type
|
|
319
|
+
*/
|
|
320
|
+
type APIFileMap = {
|
|
321
|
+
[name: string]: string | APIFileAdvanced;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* API file advanced type
|
|
325
|
+
*/
|
|
326
|
+
type APIFileAdvanced = {
|
|
327
|
+
/** API information configuration */
|
|
328
|
+
info?: APIInfo;
|
|
329
|
+
/** Route configuration */
|
|
330
|
+
route: string;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* API file type - can be a string, array of strings, or a map of strings
|
|
334
|
+
*/
|
|
335
|
+
/**
|
|
336
|
+
* API information configuration
|
|
337
|
+
*/
|
|
338
|
+
interface APIInfo {
|
|
339
|
+
/**
|
|
340
|
+
* The base url for all API endpoints. If baseUrl is an array, it will enable
|
|
341
|
+
* for multiple base url options that the user can toggle.
|
|
342
|
+
*/
|
|
343
|
+
baseUrl?: string;
|
|
344
|
+
/** Authentication information */
|
|
345
|
+
auth?: APIAuth;
|
|
346
|
+
/**
|
|
347
|
+
* The name of the authentication parameter used in the API playground.
|
|
348
|
+
* If method is basic, the format should be [usernameName]:[passwordName]
|
|
349
|
+
*/
|
|
350
|
+
name?: string;
|
|
351
|
+
/**
|
|
352
|
+
* The default value that's designed to be a prefisx for the authentication input field.
|
|
353
|
+
* E.g. If an inputPrefix of AuthKey would inherit the default input result of the authentication field as AuthKey.
|
|
354
|
+
*/
|
|
355
|
+
inputPrefix?: string;
|
|
356
|
+
/** Configurations for the API playground */
|
|
357
|
+
playground?: APIPlayground;
|
|
358
|
+
/** Request configuration */
|
|
359
|
+
request?: APIInfoRequest;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* API authentication configuration
|
|
363
|
+
*/
|
|
364
|
+
interface APIAuth {
|
|
365
|
+
/** The authentication strategy used for all API endpoints */
|
|
366
|
+
method: "bearer" | "basic" | "key";
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* API playground configuration
|
|
370
|
+
*/
|
|
371
|
+
interface APIPlayground {
|
|
372
|
+
/** Playground display mode */
|
|
373
|
+
mode?: "show" | "simple" | "hide";
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* API request configuration
|
|
377
|
+
*/
|
|
378
|
+
interface APIInfoRequest {
|
|
379
|
+
/** Configurations for the auto-generated API request examples */
|
|
380
|
+
example?: {
|
|
381
|
+
/**
|
|
382
|
+
* An array of strings that determine the order of the languages of the auto-generated request examples.
|
|
383
|
+
* You can either define custom languages utilizing x-codeSamples or use our default languages which include
|
|
384
|
+
* bash, python, javascript, php, go, java
|
|
385
|
+
*/
|
|
386
|
+
languages?: string[];
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Integrations configuration
|
|
391
|
+
*/
|
|
392
|
+
interface Integrations {
|
|
393
|
+
/**
|
|
394
|
+
* Configurations to add third-party analytics integrations.
|
|
395
|
+
* See full list of supported analytics here.
|
|
396
|
+
*/
|
|
397
|
+
analytics?: IntegrationAnalytics;
|
|
398
|
+
/**
|
|
399
|
+
* Configurations to add third-party search integrations.
|
|
400
|
+
* See full list of supported search here.
|
|
401
|
+
*/
|
|
402
|
+
search?: IntegrationSearch;
|
|
403
|
+
apps?: IntegrationApps;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Analytics configuration
|
|
407
|
+
*/
|
|
408
|
+
interface IntegrationAnalytics {
|
|
409
|
+
/** Livesession analytics configuration */
|
|
410
|
+
livesession?: {
|
|
411
|
+
/** Livesession's TrackID */
|
|
412
|
+
trackId: string;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Search configuration
|
|
417
|
+
*/
|
|
418
|
+
interface IntegrationSearch {
|
|
419
|
+
/** Algolia search configuration */
|
|
420
|
+
algolia?: {
|
|
421
|
+
/** Algolia application ID */
|
|
422
|
+
appId: string;
|
|
423
|
+
/** Algolia API key */
|
|
424
|
+
apiKey: string;
|
|
425
|
+
};
|
|
426
|
+
orama?: {
|
|
427
|
+
/** Orama endpoint */
|
|
428
|
+
endpoint: string;
|
|
429
|
+
/** Orama API key */
|
|
430
|
+
apiKey: string;
|
|
431
|
+
/** Orama suggestions */
|
|
432
|
+
suggestions?: string[];
|
|
433
|
+
} | boolean;
|
|
434
|
+
}
|
|
435
|
+
interface IntegrationApps {
|
|
436
|
+
/**
|
|
437
|
+
* Github star app configuration.
|
|
438
|
+
* List of all [options](https://github.com/buttons/react-github-btn).
|
|
439
|
+
*/
|
|
440
|
+
githubStar?: IntegrationAppGithubStar;
|
|
441
|
+
}
|
|
442
|
+
interface IntegrationAppGithubStar {
|
|
443
|
+
/**
|
|
444
|
+
* The title of the Github button
|
|
445
|
+
*/
|
|
446
|
+
title: string;
|
|
447
|
+
/**
|
|
448
|
+
* The label of the Github Button
|
|
449
|
+
*/
|
|
450
|
+
label?: string;
|
|
451
|
+
/**
|
|
452
|
+
* The href of the Github project
|
|
453
|
+
*/
|
|
454
|
+
href: string;
|
|
455
|
+
/**
|
|
456
|
+
* The data-show-count of the Github project
|
|
457
|
+
*/
|
|
458
|
+
dataShowCount?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* The data-icon of the Github button
|
|
461
|
+
*/
|
|
462
|
+
dataIcon?: string;
|
|
463
|
+
/**
|
|
464
|
+
* The data-size of the Github button
|
|
465
|
+
*/
|
|
466
|
+
dataSize?: string;
|
|
467
|
+
/**
|
|
468
|
+
* The aria-label of the Github button
|
|
469
|
+
*/
|
|
470
|
+
ariaLabel?: string;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Plugin configuration
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* 1)
|
|
477
|
+
* {
|
|
478
|
+
* plugins: [
|
|
479
|
+
* "livesession",
|
|
480
|
+
* ]
|
|
481
|
+
* }
|
|
482
|
+
*
|
|
483
|
+
* or 2)
|
|
484
|
+
* {
|
|
485
|
+
* plugins: [
|
|
486
|
+
* [
|
|
487
|
+
* "livesession",
|
|
488
|
+
* "accountID.websiteID",
|
|
489
|
+
* {
|
|
490
|
+
* keystrokes: true
|
|
491
|
+
* }
|
|
492
|
+
* ]
|
|
493
|
+
* ]
|
|
494
|
+
* }
|
|
495
|
+
*
|
|
496
|
+
* @example [audience:dev]
|
|
497
|
+
* You can also use the type to define the plugin config in your code:
|
|
498
|
+
*
|
|
499
|
+
* const livesessionPlugin: PluginConfig<"livesession", [string, { keystrokes: boolean }]> = [
|
|
500
|
+
* "livesession",
|
|
501
|
+
* "accountID.websiteID",
|
|
502
|
+
* {
|
|
503
|
+
* keystrokes: true
|
|
504
|
+
* }
|
|
505
|
+
* ]
|
|
506
|
+
*/
|
|
507
|
+
type Plugins = (string | PluginConfig$1)[];
|
|
508
|
+
type PluginConfig$1<PluginName extends string = string, PluginArgs extends unknown[] = unknown[]> = [PluginName, ...PluginArgs];
|
|
509
|
+
/**
|
|
510
|
+
* Redirects configuration
|
|
511
|
+
*/
|
|
512
|
+
interface Redirects {
|
|
513
|
+
/** Source path to redirect from */
|
|
514
|
+
source: string;
|
|
515
|
+
/** Destination path to redirect to */
|
|
516
|
+
destination: string;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* SEO configuration
|
|
520
|
+
*/
|
|
521
|
+
interface SEO {
|
|
522
|
+
/**
|
|
523
|
+
* Domain name
|
|
524
|
+
*/
|
|
525
|
+
domain?: string;
|
|
526
|
+
/**
|
|
527
|
+
* Meta tags
|
|
528
|
+
*/
|
|
529
|
+
metatags?: {
|
|
530
|
+
[tag: string]: string;
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Config configuration
|
|
535
|
+
*/
|
|
536
|
+
interface Engine {
|
|
537
|
+
/**
|
|
538
|
+
* Path aliases for imports. Avoid long relative paths by creating shortcuts.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```json
|
|
542
|
+
* {
|
|
543
|
+
* "paths": {
|
|
544
|
+
* "@my-package/*": ["../my-package/src/*"],
|
|
545
|
+
* "@livesession-go/*": ["https://github.com/livesession/livesession-go/*"]
|
|
546
|
+
* }
|
|
547
|
+
* }
|
|
548
|
+
* ```
|
|
549
|
+
*
|
|
550
|
+
* Usage:
|
|
551
|
+
* ```typescript
|
|
552
|
+
* // Instead of
|
|
553
|
+
* @importCode("../../../my-package/src/components/Badge.tsx")
|
|
554
|
+
*
|
|
555
|
+
* // Use
|
|
556
|
+
* @importCode("@my-package/src/components/Badge.tsx")
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
paths?: EnginePaths;
|
|
560
|
+
/**
|
|
561
|
+
* @unsafe
|
|
562
|
+
*
|
|
563
|
+
* Uniform configuration
|
|
564
|
+
*
|
|
565
|
+
*/
|
|
566
|
+
uniform?: EngineUniform;
|
|
567
|
+
}
|
|
568
|
+
type EnginePaths = {
|
|
569
|
+
[key: string]: string[];
|
|
570
|
+
};
|
|
571
|
+
type EngineUniform = {
|
|
572
|
+
/**
|
|
573
|
+
* If `true` then virtual pages will not created and generated content will be stored on disk
|
|
574
|
+
*/
|
|
575
|
+
store?: boolean;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
interface PluginCustomComponents {
|
|
579
|
+
component: React__default.ComponentType<any>;
|
|
580
|
+
surface: SurfaceTarget;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Plugin interface
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* function myPlugin(): Plugin {
|
|
588
|
+
* return {
|
|
589
|
+
* name: "my-plugin",
|
|
590
|
+
* vite: [
|
|
591
|
+
* {
|
|
592
|
+
* name: "my-vite-plugin",
|
|
593
|
+
* }
|
|
594
|
+
* ],
|
|
595
|
+
* uniform: [
|
|
596
|
+
* pluginOpenAIMeta,
|
|
597
|
+
* ],
|
|
598
|
+
* atlas: {
|
|
599
|
+
* components: {
|
|
600
|
+
* }
|
|
601
|
+
* }
|
|
602
|
+
* }
|
|
603
|
+
* }
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
interface PluginConfig {
|
|
607
|
+
name: string;
|
|
608
|
+
vite?: Plugin$1[];
|
|
609
|
+
uniform?: UniformPlugin<any>[];
|
|
610
|
+
customComponents?: {
|
|
611
|
+
[name: string]: PluginCustomComponents;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
type Plugin = (settings: Settings) => PluginConfig;
|
|
615
|
+
|
|
616
|
+
export type { Plugin, PluginConfig, PluginCustomComponents };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyd-js/plugins",
|
|
3
|
+
"version": "0.1.0-xyd.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./package.json": "./package.json",
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@xyd-js/uniform": "0.1.0-xyd.17"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@xyd-js/framework": "0.1.0-xyd.34"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
21
|
+
"vite": "^6.1.0",
|
|
22
|
+
"vitest": "^1.3.1",
|
|
23
|
+
"rimraf": "^3.0.2",
|
|
24
|
+
"tsup": "^8.3.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rimraf build",
|
|
28
|
+
"prebuild": "pnpm clean",
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"test": "vitest",
|
|
31
|
+
"test:coverage": "vitest run --coverage"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Plugin as Vite } from "vite"
|
|
2
|
+
import React from "react"
|
|
3
|
+
|
|
4
|
+
import { type UniformPlugin as Uniform } from "@xyd-js/uniform"
|
|
5
|
+
import { Settings } from "@xyd-js/core"
|
|
6
|
+
import type { SurfaceTarget } from "@xyd-js/framework/react"
|
|
7
|
+
|
|
8
|
+
// TODO: share with theme-api ?
|
|
9
|
+
export interface PluginCustomComponents {
|
|
10
|
+
component: React.ComponentType<any>
|
|
11
|
+
surface: SurfaceTarget
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Plugin interface
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* function myPlugin(): Plugin {
|
|
20
|
+
* return {
|
|
21
|
+
* name: "my-plugin",
|
|
22
|
+
* vite: [
|
|
23
|
+
* {
|
|
24
|
+
* name: "my-vite-plugin",
|
|
25
|
+
* }
|
|
26
|
+
* ],
|
|
27
|
+
* uniform: [
|
|
28
|
+
* pluginOpenAIMeta,
|
|
29
|
+
* ],
|
|
30
|
+
* atlas: {
|
|
31
|
+
* components: {
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export interface PluginConfig {
|
|
39
|
+
name: string
|
|
40
|
+
vite?: Vite[]
|
|
41
|
+
|
|
42
|
+
uniform?: Uniform<any>[] // TODO: fix any
|
|
43
|
+
|
|
44
|
+
// atlas?: { // TODO: in the future
|
|
45
|
+
// components?: any
|
|
46
|
+
// }
|
|
47
|
+
customComponents?: {
|
|
48
|
+
[name: string]: PluginCustomComponents
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type Plugin = (settings: Settings) => PluginConfig
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"target": "esnext",
|
|
7
|
+
"baseUrl": ".",
|
|
8
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": false,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"incremental": false,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"jsx": "preserve",
|
|
17
|
+
"plugins": [],
|
|
18
|
+
"strictNullChecks": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
21
|
+
"exclude": ["node_modules"]
|
|
22
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {copyFile} from 'node:fs/promises';
|
|
2
|
+
import {join} from 'node:path';
|
|
3
|
+
|
|
4
|
+
import {defineConfig, Options} from 'tsup';
|
|
5
|
+
|
|
6
|
+
import pkg from './package.json';
|
|
7
|
+
|
|
8
|
+
const deps = [
|
|
9
|
+
// ...Object.keys(pkg.dependencies || {}),
|
|
10
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
11
|
+
]
|
|
12
|
+
const config: Options = {
|
|
13
|
+
entry: {
|
|
14
|
+
index: 'src/index.ts',
|
|
15
|
+
},
|
|
16
|
+
dts: {
|
|
17
|
+
entry: {
|
|
18
|
+
index: 'src/index.ts',
|
|
19
|
+
},
|
|
20
|
+
resolve: true, // Resolve external types
|
|
21
|
+
},
|
|
22
|
+
format: ['esm'],
|
|
23
|
+
platform: 'node',
|
|
24
|
+
shims: false,
|
|
25
|
+
splitting: false,
|
|
26
|
+
sourcemap: true,
|
|
27
|
+
clean: true,
|
|
28
|
+
external: [
|
|
29
|
+
...deps,
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default defineConfig(config);
|