@docusaurus/types 0.0.0-4684 → 0.0.0-4688

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.d.ts +22 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "0.0.0-4684",
3
+ "version": "0.0.0-4688",
4
4
  "description": "Common types for Docusaurus packages.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -23,5 +23,5 @@
23
23
  "webpack": "^5.69.1",
24
24
  "webpack-merge": "^5.8.0"
25
25
  },
26
- "gitHead": "9230ee0c61b8d04d2fcf195e72e1f992d7b39a86"
26
+ "gitHead": "1b4b624e2d929f444465aec5a01ccb8518c60df6"
27
27
  }
package/src/index.d.ts CHANGED
@@ -40,24 +40,24 @@ export interface DocusaurusConfig {
40
40
  deploymentBranch?: string;
41
41
  githubHost?: string;
42
42
  githubPort?: string;
43
- plugins?: PluginConfig[];
44
- themes?: PluginConfig[];
45
- presets?: PresetConfig[];
43
+ plugins: PluginConfig[];
44
+ themes: PluginConfig[];
45
+ presets: PresetConfig[];
46
46
  themeConfig: ThemeConfig;
47
47
  customFields?: {
48
48
  [key: string]: unknown;
49
49
  };
50
- scripts?: (
50
+ scripts: (
51
51
  | string
52
52
  | {
53
53
  src: string;
54
54
  [key: string]: unknown;
55
55
  }
56
56
  )[];
57
- clientModules?: string[];
57
+ clientModules: string[];
58
58
  ssrTemplate?: string;
59
59
  staticDirectories: string[];
60
- stylesheets?: (
60
+ stylesheets: (
61
61
  | string
62
62
  | {
63
63
  href: string;
@@ -226,18 +226,15 @@ export interface Props extends LoadContext, InjectedHtmlTags {
226
226
 
227
227
  export interface PluginContentLoadedActions {
228
228
  addRoute: (config: RouteConfig) => void;
229
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
- createData: (name: string, data: any) => Promise<string>;
229
+ createData: (name: string, data: string) => Promise<string>;
231
230
  setGlobalData: <T = unknown>(data: T) => void;
232
231
  }
233
232
 
234
- export type AllContent = Record<
235
- string, // plugin name
236
- Record<
237
- string, // plugin id
238
- unknown // plugin data
239
- >
240
- >;
233
+ export type AllContent = {
234
+ [pluginName: string]: {
235
+ [pluginID: string]: unknown;
236
+ };
237
+ };
241
238
 
242
239
  // TODO improve type (not exposed by postcss-loader)
243
240
  export type PostCssOptions = Record<string, unknown> & {plugins: unknown[]};
@@ -245,12 +242,11 @@ export type PostCssOptions = Record<string, unknown> & {plugins: unknown[]};
245
242
  export interface Plugin<Content = unknown> {
246
243
  name: string;
247
244
  loadContent?: () => Promise<Content>;
248
- contentLoaded?: ({
249
- content,
250
- actions,
251
- }: {
252
- content: Content; // the content loaded by this plugin instance
253
- allContent: AllContent; // content loaded by ALL the plugins
245
+ contentLoaded?: (args: {
246
+ /** the content loaded by this plugin instance */
247
+ content: Content; //
248
+ /** content loaded by ALL the plugins */
249
+ allContent: AllContent;
254
250
  actions: PluginContentLoadedActions;
255
251
  }) => Promise<void>;
256
252
  routesLoaded?: (routes: RouteConfig[]) => void; // TODO remove soon, deprecated (alpha-60)
@@ -269,7 +265,7 @@ export interface Plugin<Content = unknown> {
269
265
  getPathsToWatch?: () => string[];
270
266
  getClientModules?: () => string[];
271
267
  extendCli?: (cli: CommanderStatic) => void;
272
- injectHtmlTags?: ({content}: {content: Content}) => {
268
+ injectHtmlTags?: (args: {content: Content}) => {
273
269
  headTags?: HtmlTags;
274
270
  preBodyTags?: HtmlTags;
275
271
  postBodyTags?: HtmlTags;
@@ -277,28 +273,13 @@ export interface Plugin<Content = unknown> {
277
273
  // TODO before/afterDevServer implementation
278
274
 
279
275
  // translations
280
- getTranslationFiles?: ({
281
- content,
282
- }: {
283
- content: Content;
284
- }) => Promise<TranslationFiles>;
285
- getDefaultCodeTranslationMessages?: () => Promise<
286
- Record<
287
- string, // id
288
- string // message
289
- >
290
- >;
291
- translateContent?: ({
292
- content,
293
- translationFiles,
294
- }: {
276
+ getTranslationFiles?: (args: {content: Content}) => Promise<TranslationFiles>;
277
+ getDefaultCodeTranslationMessages?: () => Promise<{[id: string]: string}>;
278
+ translateContent?: (args: {
295
279
  content: Content; // the content loaded by this plugin instance
296
280
  translationFiles: TranslationFiles;
297
281
  }) => Content;
298
- translateThemeConfig?: ({
299
- themeConfig,
300
- translationFiles,
301
- }: {
282
+ translateThemeConfig?: (args: {
302
283
  themeConfig: ThemeConfig;
303
284
  translationFiles: TranslationFiles;
304
285
  }) => ThemeConfig;