@docusaurus/types 0.0.0-5858 → 0.0.0-5861

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/plugin.d.ts +19 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "0.0.0-5858",
3
+ "version": "0.0.0-5861",
4
4
  "description": "Common types for Docusaurus packages.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -27,5 +27,5 @@
27
27
  "react": "^18.0.0",
28
28
  "react-dom": "^18.0.0"
29
29
  },
30
- "gitHead": "03c831aae7cfffd88cb38425971139a865a79a40"
30
+ "gitHead": "f6dfa0af9be06d1e24f30243244145fdc03fb25c"
31
31
  }
package/src/plugin.d.ts CHANGED
@@ -18,11 +18,11 @@ import type {RouteConfig} from './routing';
18
18
 
19
19
  export type PluginOptions = {id?: string} & {[key: string]: unknown};
20
20
 
21
- export type PluginConfig =
21
+ export type PluginConfig<Content = unknown> =
22
22
  | string
23
23
  | [string, PluginOptions]
24
- | [PluginModule, PluginOptions]
25
- | PluginModule
24
+ | [PluginModule<Content>, PluginOptions]
25
+ | PluginModule<Content>
26
26
  | false
27
27
  | null;
28
28
 
@@ -110,7 +110,9 @@ export type Plugin<Content = unknown> = {
110
110
  contentLoaded?: (args: {
111
111
  /** The content loaded by this plugin instance */
112
112
  content: Content; //
113
- /** Content loaded by ALL the plugins */
113
+ actions: PluginContentLoadedActions;
114
+ }) => Promise<void> | void;
115
+ allContentLoaded?: (args: {
114
116
  allContent: AllContent;
115
117
  actions: PluginContentLoadedActions;
116
118
  }) => Promise<void> | void;
@@ -163,6 +165,15 @@ export type Plugin<Content = unknown> = {
163
165
  }) => ThemeConfig;
164
166
  };
165
167
 
168
+ /**
169
+ * Data required to uniquely identify a plugin
170
+ * The name or instance id alone is not enough
171
+ */
172
+ export type PluginIdentifier = {
173
+ readonly name: string;
174
+ readonly id: string;
175
+ };
176
+
166
177
  export type InitializedPlugin = Plugin & {
167
178
  readonly options: Required<PluginOptions>;
168
179
  readonly version: PluginVersionInformation;
@@ -174,8 +185,10 @@ export type LoadedPlugin = InitializedPlugin & {
174
185
  readonly content: unknown;
175
186
  };
176
187
 
177
- export type PluginModule = {
178
- (context: LoadContext, options: unknown): Plugin | Promise<Plugin>;
188
+ export type PluginModule<Content = unknown> = {
189
+ (context: LoadContext, options: unknown):
190
+ | Plugin<Content>
191
+ | Promise<Plugin<Content>>;
179
192
  validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
180
193
  validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
181
194